akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static void tp_swap(_T& right, _T& left) {
	//	usage:  tp_swap<type name>(a, b);
	_T tmp = right;
	right = left;
	left = tmp;
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static void ABC089C_March();

#if 1
int main()
{
	ABC089C_March();
	
	fflush(stdout);
	return 0;
}
#endif


static void ABC089C_March()
{
	int N;
	get1int(N);

	std::map<char, LLONG> nList;
	for (int i = 0; i < N; i++) {
		char names[11] = { 0 };
		getstring(names);

		nList[names[0]]++;
	}
	
	int iniKind = 0;
	LLONG iniCount[5] = { 0 };
	const char* initial = "MARCH";
	for (int i = 0; i < 5; i++) {
		if (nList.find(initial[i]) != nList.end()) {
			iniCount[iniKind] = nList[initial[i]];
			iniKind++;
		}
	}
	if (iniKind < 3) {
		printf("0\n");
		return;
	}

	LLONG pattern = 0;
	for (int i = 0; i < iniKind - 2; i++) {
		for (int j = i + 1; j < iniKind - 1; j++) {
			for (int k = j + 1; k < iniKind; k++) {
				pattern += iniCount[i] * iniCount[j] * iniCount[k];
			}
		}
	}
	printf("%lld\n", pattern);
}


Measured memory_bytes: 384
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N,M = MI()
X = LI()

if N >= M:
    print(0)
    exit()

X.sort()
Y = [X[i+1]-X[i] for i in range(M-1)]
Y.sort()
print(sum(Y[:M-N]))


Measured memory_bytes: 83300
import copy

n,m=map(int,input().split())
h=list(map(int,input().split()))
l=[]
for i in range(m):
    a,b=map(int,input().split())
    l.append([a,b])
    
ll=[0]*n

for j in l:
    if h[j[0]-1]>h[j[1]-1]:
        ll[j[1]-1]+=1
    elif h[j[0]-1]==h[j[1]-1]:
        ll[j[1]-1]+=1
        ll[j[0]-1]+=1
    else:
        ll[j[0]-1]+=1

ans=0

for k in ll:
    if k==0:
        ans+=1
print(ans)

Measured memory_bytes: 29232
#include <stdio.h>
int main(void)
{
   int a, b, c;
   
   scanf("%d %d %d", &a, &b, &c);
   
   if (a < b && b < c){
      printf("Yes\n");
   }
   else{
      printf("No\n");
   }
   return (0);
}

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

using namespace std;
using ll=long long;

void solve() {
    ll a,b,c;
    cin >> a >> b >> c;
    if (c <= a+b) {
        cout << "No";
    } else {
        bool r = (4*a*b < (c-a-b)*(c-a-b));
        cout << (r?"Yes":"No");
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int x,a; cin >> x >> a;
    if(a > x) cout << "0" << endl;
    else cout << "10" << endl;

    return 0;
}

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

int main() {
 int a,b,c,d;
 cin>>a>>b>>c>>d;
  if(min(b,d)-max(a,c)<0){
	  cout<<0<<endl;
  }else{
	  cout<<min(b,d)-max(a,c)<<endl;
  }
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;

int main() {
	int n,m; 
	cin >> n>>m;
	int ans=0;
	rep(i, m - n) {
		ans += i;
	}
	ans = ans - n;
	cout << ans << endl;
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>

using namespace std;

void solve(long long N, long long C, vector<vector<long long>> D, vector<vector<long long>> c){
    vector< vector<long long> > l(3, vector<long long>(C, 0));
    for (int i = 0; i < C; i++) {
        for (int x = 0; x < N; x++) {
            for (int y = 0; y < N; y++) {
                l[(x+y) % 3][i] += D[c[x][y]-1][i];
            }
        }
    }
    long long ret = 10000000000000000;
    for (int i = 0; i < C; i++) {
        for (int j = 0; j < C; j++) {
            for (int k = 0; k < C; k++) {
                if (i == j || j == k || i == k) {
                    continue;
                }
                ret = min(ret, l[0][i] + l[1][j] + l[2][k]);
            }
        }
    }
    std::cout << ret << std::endl;
}

int main(){	
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    long long C;
    long long N;
    scanf("%lld",&N);
    vector<vector<long long>> c(N-1+1,vector<long long>(N-1+1));
    scanf("%lld",&C);
    vector<vector<long long>> D(C-1+1,vector<long long>(C-1+1));
    for(int i = 0 ; i <= C-1 ; i++){
    	for(int j = 0 ; j <= C-1 ; j++){
    		scanf("%lld",&D[i][j]);
    	}
    }
    for(int i = 0 ; i <= N-1 ; i++){
    	for(int j = 0 ; j <= N-1 ; j++){
    		scanf("%lld",&c[i][j]);
    	}
    }
    solve(N, C, D, c);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
//S.size()
//配列名.Length()
using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;


int main(void){
	string S; cin>>S;
	cout<<S[0];
	int cnt = 0;
	for(int i = 1; i < S.size() - 1; i++)cnt++;
	cout<<cnt;
	cout<<S[S.size() - 1];
}


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

using int64 = long long;

int main() {
    int64 N, K;
    cin >> N >> K;

    if (K == 0) {
        cout << N * N << endl;
        return 0;
    }

    int64 ans = 0;
    for (int64 b = K + 1; b <= N; b++) {
        int64 cycle = N / b;  // cycle回[K, b-1]が登場する
        int64 rem = N % b;

        ans += cycle * (b - K);
        ans += max(0LL, rem - K + 1);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int a[3];
    rep(i, 3)cin >> a[i];
    qsort(a, sizeof(a)/sizeof(int), sizeof(int), desc);
    cout << a[0] * 10 + a[1] + a[2] << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io;
use std::cmp;


fn main() {
    let s = read_one::<String>()
        .chars()
        .collect::<Vec<char>>();

    let mut cnt = 0;
    let mut len = 0;
    for i in 0..s.len() {
        if ['A', 'C', 'G', 'T'].contains(&s[i]) {
            len += 1;
            cnt = cmp::max(cnt, len);
        } else { len = 0; }
    }

    println!("{}", cnt);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int main() {
    int n;
    cin>>n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin>>v[i];
    }
    map<int,int> a;
    map<int,int> b;
    for (int i = 0; i < n-1; i+=2) {
        a[v[i]]+=1;
    }
    for (int i = 1; i < n; i+=2) {
        b[v[i]]+=1;
    }
    priority_queue<pair<int,int>> aq,bq;
    for(auto i:a){
        aq.emplace(i.second,i.first);
    }
    for(auto i:b){
        bq.emplace(i.second,i.first);
    }
    int ans=0;
    if(aq.top().second!=bq.top().second){
        ans+=n/2-aq.top().first;
        ans+=n/2-bq.top().first;
        cout<<ans<<endl;
        return 0;
    }
    else {
        if(aq.top().first>bq.top().first){
            bq.pop();
            ans+=n/2-aq.top().first;
            if(bq.empty())ans+=n/2;
            else ans+=n/2-bq.top().first;
            cout<<ans<<endl;
            return 0;
        }
        else if(aq.top().first<bq.top().first){
            aq.pop();
            if(aq.empty())ans+=n/2;
            else ans+=n/2-aq.top().first;
            ans+=n/2-bq.top().first;
            cout<<ans<<endl;
            return 0;
        }
        else {
            int m=min(aq.top().first,bq.top().first);
            aq.pop();
            bq.pop();
            if(aq.empty()){
                if(bq.empty()){
                    ans=n/2-m;
                    ans+=n/2;
                }
                else {
                    ans+=n/2-m;
                    ans+=n/2-bq.top().first;
                }
            }
            else if(bq.empty()){
                ans+=n/2-m;
                ans+=n/2-aq.top().first;
            }
            else {
                ans+=n/2-m;
                ans+=min(n/2-aq.top().first,n/2-bq.top().first);
            }
            cout<<ans<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 6520
#include<iostream>
#include<algorithm>
#include <math.h>
#include <cmath>
using namespace std;
#define ll long long

ll a[100050] = {};

int main()
{
	ll n, k;
	ll min;
	ll s = 0; 
	ll ans = 0;

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

	sort(a, a + n);
	min = a[0];

	for (int i = 0; i < n; i++)
	{
		if (min != a[i]) {
			s++;
		}
	}

	if (s % (k - 1) == 0) {
		ans = s / (k - 1);
	}
	else {
		ans = s / (k - 1) + 1;
	}

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


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,i,j,dp[100005];
string st;
int main()
{
	cin>>st;
	dp[0]=1;
	for (i=0;i<st.length();i++)
	{
		if (!dp[i]) continue;
		if (i+5<=st.length())
		{
			if (st.substr(i,5)=="dream"||st.substr(i,5)=="erase") dp[i+5]=1;
		}
		if (i+6<=st.length())
		{
			if (st.substr(i,6)=="eraser") dp[i+6]=1;
		}
		if (i+7<=st.length())
		{
			if (st.substr(i,7)=="dreamer") dp[i+7]=1;
		}
	}
	if (dp[st.length()]) cout<<"YES";
		else cout<<"NO";
	return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;
public class Main {
	public static void ans(int bord[][]){
		int i,j;
		for(j=0;j<8;j++){
			for(i=0;i<8;i++){
				if(bord[i][j]==1){
					if(i+1<8 && j+1<8 && bord[i+1][j]==1 && bord[i][j+1]==1 && bord[i+1][j+1]==1){
						System.out.println("A");return;
					}
					if(j+3<8 && bord[i][j+1]==1 && bord[i][j+2]==1 && bord[i][j+3]==1){
						System.out.println("B");return;
					}
					if(i+3<8 && bord[i+1][j]==1 && bord[i+2][j]==1 && bord[i+3][j]==1){
						System.out.println("C");return;
					}
					if(i-1>=0 && j+2<8 && bord[i][j+1]==1 && bord[i-1][j+1]==1 && bord[i-1][j+2]==1){
						System.out.println("D");return;
					}
					if(i+2<8 && j+1<8 && bord[i+1][j]==1 && bord[i+1][j+1]==1 && bord[i+2][j+1]==1){
						System.out.println("E");return;
					}
					if(i+1<8 && j+2<8 && bord[i][j+1]==1 && bord[i+1][j+1]==1 && bord[i+1][j+2]==1){
						System.out.println("F");return;
					}
					if(i-1>=0 && i+1<8 && j+1<8 && bord[i+1][j]==1 && bord[i][j+1]==1 && bord[i-1][j+1]==1){
						System.out.println("G");return;
					}
				}//if
			}//for
		}//for
	}
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int bord[][]=new int[8][8],i,j;
		char ch[]=new char[8];
		String str;
		while(sc.hasNext()){
			for(j=0;j<8;j++){
				str=sc.next();
				ch=str.toCharArray();
				for(i=0;i<8;i++)
					bord[i][j]=ch[i]-'0';
			}
			ans(bord);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#include <ratio>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
using namespace std;
vector<ll> v;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
vector<tuple<ll, ll, ll>> vt;
set<ll> st;
map<ll, ll> mp;

int main()
{
	ll n;
	cin >> n;
	cout << (n >= 1200 ? "ARC" : "ABC") << endl;
}

Measured memory_bytes: 764
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int n, x;
  readf("%s %s\n", &n, &x);
  auto m = new int[](n);
  foreach (i; 0..n) {
    m[i] = readln.chomp.to!int;
  }
  x -= m.sum;
  m.sort();
  auto num = n;
  num += x / m[0];
  num.writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

class Graph{
	private:
	int n;
	vvp g;
	public:
	int DIJ(int s,int t){
		priority_queue<P> q;
		vi d(n,inf);
		d[s]=0;
		q.push({0,s});
		while(!q.empty()){
			P p=q.top();
			q.pop();
			int v=p.second;
			if(d[v]<-p.first) continue;
			for(auto i:g[v]){
				int u=i.first,D=d[v]+i.second;
				if(d[u]>D){
					d[u]=D;
					q.push({-D,u});
				}
			}
		}
		return d[t];
	}
	Graph(int v){
		n=v;
		g=vvp(v);
	}
	void add_edge(int s,int t,int c){
		g[s].push_back({t,c});
		g[t].push_back({s,c});
	}
};

bool isPrime(ll n){
	if(n<=1) return 0;
	for(ll k=2;k*k<=n;k++) if(n%k==0) return 0;
	return 1;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m,s,t;
	cin>>n>>m>>s>>t;
	Graph g(2*n);
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g.add_edge(u,v+n,1);
		g.add_edge(u+n,v,1);
	}
	s--;t--;
	int x=g.DIJ(s,t);
	if(x==2) cout<<2<<endl;
	else{
		int y=g.DIJ(s,t+n);
		if(y==inf) cout<<-1<<endl;
		else{
			while(!isPrime(y)) y+=2;
			cout<<y<<endl;
		}
	}
}


Measured memory_bytes: 15368
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

vector<P> pt;

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

    int K, N;
    cin >> N >> K;
    REP(i, N){
        int x, y;
        cin >> x >> y;
        pt.pb(mp(x,y));
    }
    llint ans = -1;
    REP(a, N)REP(b, N)REP(c,N)REP(d, N){
        if(a==b || b==c || c==d || d==a) continue;
        int x1 = min(pt[a].first, pt[b].first);
        int x2 = max(pt[a].first, pt[b].first);
        int y1 = min(pt[c].second, pt[d].second);
        int y2 = max(pt[c].second, pt[d].second);
        int x, y;
        int ct = 0;

        REP(e, N){
            x = pt[e].first;
            y = pt[e].second;
            if(x1 <= x && x <= x2 && y1 <= y && y <= y2) ct++;
        }
        if(ct >= K){
            if(ans == -1) ans = (llint)(x2-x1)*(y2-y1);
            else ans = min(ans, (llint)(x2-x1)*(y2-y1));
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
long double EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////////////////


int main(){fastio;
    ll x;cin>>x;
    ll k;cin>>k;
    ll t[k+1];
    t[0]=0;rep(i,1,k)cin>>t[i];
    ll l[k+1],r[k+1];
    ll s[k+1];
    s[0]=0;
    rep(i,1,k){
        if(i%2==1){
            s[i]=s[i-1]-(t[i]-t[i-1]);
        }else{
            s[i]=s[i-1]+(t[i]-t[i-1]);
        }
    }
    ll brpos=k+2;
    l[0]=0;r[0]=x;
    rep(i,1,k){
        l[i]=l[i-1];r[i]=r[i-1];
        if(i%2==1){
            if(r[i-1]+s[i]<0){
                brpos=i;break;
            }else if(l[i-1]+s[i]<0){
                l[i]=l[i-1]+(-(l[i-1]+s[i]));
            }
        }else{
            if(l[i-1]+s[i]>x){
                brpos=i;break;
            }else if(r[i-1]+s[i]>x){
                r[i]=r[i-1]-(r[i-1]+s[i]-x);
            }
        }
    }
    ll con[k+1];
    //cout<<brpos<<endl;
    if(brpos!=k+2){
        if(brpos%2==1)con[brpos]=0;
        else con[brpos]=x;
        rep(i,brpos+1,k){
            if(i%2==1){
                con[i]=con[i-1]-(t[i]-t[i-1]);
                if(con[i]<0)con[i]=0;
            }else{
                con[i]=con[i-1]+(t[i]-t[i-1]);
                if(con[i]>x)con[i]=x;
            }
        }
    }
    /*rep(i,0,k){
        cout<<i<<" "<<con[i]<<endl;
    }*/
    /*rep(i,0,k){
        cout<<i<<" "<<s[i]<<" "<<l[i]<<" "<<r[i]<<endl;
    }cout<<endl;*/
    ll q;cin>>q;
    while(q--){
        ll c,a;cin>>c>>a;
        ll pos=upper_bound(t,t+k+1,c)-t-1;
        ll res;
        if(pos>=brpos){
            res=con[pos];
            if(pos%2==0){
                res-=c-t[pos];
            }else{
                res+=(c-t[pos]);
            }
        }else if(l[pos]<=a&&a<=r[pos]){
            res=a+s[pos];
            if(pos%2==0){
                res-=c-t[pos];
            }else{
                res+=c-t[pos];
            }
        }else if(a<l[pos]){
            res=s[pos]+l[pos];
            if(pos%2==0){
                res-=c-t[pos];
            }else{
                res+=c-t[pos];
            }
        }else{
            res=s[pos]+r[pos];
            if(pos%2==0){
                res-=c-t[pos];
            }else{
                res+=c-t[pos];
            }
        }
        if(res<0)res=0;
        if(res>x)res=x;
        cout<<res<<endl;
    }

    
    return 0;
}


Measured memory_bytes: 4480
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        System.out.println(C<=(A+B) ? (C+B) : (A+B+B+1));
        sc.close();
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;

#define pb push_back
#define mp make_pair

int n, k;
int a[100000];
map<int, int> t;

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> a[i];
    bool ok = false;
    for(int i = 0; i < n; i++){
        if(a[i] == k){
            cout << "POSSIBLE" << endl;
            exit(0);
        }
        if(a[i] > k) ok = true;
        t[a[i]] = true;
    }
    for(int i = 0; i < n; i++){
        if(t[k - a[i]] && ok){
            cout << "POSSIBLE" << endl;
            exit(0);
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  
  for (int i=0; i<K; i++) {
    if (B <= A) {
      B *= 2;
    }
    else {
      C *= 2;
    }
  }
  
  if (C > B && B > A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main()
{
	string s;
	cin >> s;
	int nums[4];
	for (int i = 0; i < 4; i++)
		nums[i] = s[i] - '0';
	int sum;
	string ans;
	for (int i = 0; i < (1 << 3); i++)
	{
		sum = nums[0];
		ans = '0' + nums[0];
		for (int j = 0; j < 3; j++)
		{
			if (i&(1 << j))
			{
				sum -= nums[j + 1];
				ans += '-';
				ans += '0' + nums[j + 1];
			}
			else
			{
				sum += nums[j + 1];
				ans += '+';
				ans += '0' + nums[j + 1];
			}
		}
		if (sum == 7)
		{
			cout << ans << "=7" << endl;
			return 0;
		}
	}

    return 0;
}


Measured memory_bytes: 256
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}




signed main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for(auto& x : s)
        cin >> x;

    vector<vector<int>> dist(h, vector<int>(w, MOD));
    int ma = 0;
    vector<int> dx{1, 0, -1, 0};
    vector<int> dy{0, 1, 0, -1};
    function<void(int, int)> f = [&](int i, int j){
        dist.assign(h, vector<int>(w, MOD));
        dist[i][j] = 0;
        queue<pair<int,int>> que;
        que.emplace(i, j);
        while(!que.empty()){
            int x, y;
            tie(x, y) = que.front();
            que.pop();
            for(int d = 0; d < 4; ++d){
                int nx = x + dx[d];
                int ny = y + dy[d];
                if(!(nx < 0 || ny < 0 || nx >= h || ny >= w) && s[nx][ny] == '.' && chmin(dist[nx][ny], dist[x][y] + 1))
                    que.emplace(nx, ny);
            }
        }
        for(int i = 0; i < h; ++i)
            for(int j = 0; j < w; ++j)
                if(s[i][j] != '#')
                    chmax(ma, dist[i][j]);
    };

    for(int i = 0; i < h; ++i)
        for(int j = 0; j < w; ++j){
            if(s[i][j] != '#')
                f(i, j);
        }
    cout << ma << endl;
    return 0;
}


Measured memory_bytes: 256
r=j=x=1
M=10**9+7
`sed 1d`.split.map{x=$*[k=_1.to_i]||x+1
$*[k]=$.+=1}.map{|i|p (-j+r=r*($.+1-i)%M*s=i.pow(M-2,M))%M
j=j*s%M*x-=1}

Measured memory_bytes: 26740
#include <bits/stdc++.h>
using namespace std;
char value(long k){
    if(k>0)return 'a'+(k-1);
    else return'z';
}
int main(){
    long n;cin>>n;
    long digitc=0;
    long digit=0;
    while(n>digitc){
        digit++;
        digitc+=powl(26,digit);
    }
    n-=powl(26,digit-1);
    string s="";
    long check=1;
    while(s.size()!=digit){
        long j=n%long(powl(26,check));
        long check2=0;
        while(j>powl(26,check-1)*check2){
            check2++;
        }
        if(j==0&&s.size()!=(digit-1)){
          s='z'+s;
          n-=long(powl(26,check));
          check++;
          continue;
        }
        if(s.size()==(digit-1)){
          s=value(check2+1)+s;
        }else s=value(check2)+s;
        n-=(j);
        check++;
    }
    cout<<s<<endl;
}


Measured memory_bytes: 3744
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    k = i_input()
    print("ACL"*k)


    

 

if __name__=="__main__":
    main()

    


Measured memory_bytes: 65676
N, M = map(int, input().split())

k=[]
for i in range(M):
  temp = list(map(int, input().split()))
  k.append(temp[1:])

p = list(map(int, input().split()))

result = 0
for i in range(2 ** N):
  for j, v in enumerate(k):
    s = [1 for temp in v if 2 ** (temp-1) & i]
    if sum(s) % 2 != p[j]:
      break
  else :
    result += 1
  

print(result)

Measured memory_bytes: 3064
object Main extends App {
  
  var count : Array[Int] = new Array(5)
  count(0) = readInt
  count(1) = readInt
  count(2) = readInt
  count(3) = readInt
  count(4) = readInt
  var k = readInt
  var flag = 0
  for(i <- 0 to count.size - 1) {
    for(j <- 1 to count.size - 1) {
      if(count(j) - count(i) > k)
      flag=1
    }
  }
  println(if(flag!=1){"Yay!"}else{":("})
}

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

int main(){
    long long x,y,z,k;
    cin>>x>>y>>z>>k;
    long long a[x],b[y],c[z];
    for(int i=0;i<x;i++){
        cin>>a[i];
    }
    for(int i=0;i<y;i++){
        cin>>b[i];
    }
    for(int i=0;i<z;i++){
        cin>>c[i];
    }

   

    sort(a,a+x);
    sort(b,b+y);
    sort(c,c+z);
    reverse(a,a+x);
    reverse(b,b+y);
    reverse(c,c+z);

    long long s[x*y];
    int cn=0;
    for(int i=0;i<x;i++)for(int j=0;j<y;j++){
        s[cn]=a[i]+b[j];
        cn++;
    }

    sort(s,s+x*y);
    reverse(s,s+x*y);
    vector<long long> ans;

    for(int i=0;i<min(k,x*y);i++)for(int j=0;j<z;j++){
        ans.push_back(s[i]+c[j]);
    }
    sort(ans.begin(),ans.end());
    reverse(ans.begin(),ans.end());

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


    
}

Measured memory_bytes: 42980
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
#define MAXN 40000
 
int dp[2][2*MAXN];
 
int main() {
	string s; cin >> s;
	int x, y; cin >> x >> y;
	vector<int> val[2];
	int cur = 0, len = s.size();
	for (int i = 0; i < len; ) {
		int j = i;
		while (j < len && s[j] != 'T') j ++;
		val[cur].push_back(j - i);
		cur = 1 - cur; 
		i = j + 1;
	}
	
	memset(dp, 0, sizeof(dp));
	dp[0][20000] = 1;
	cur = 1;
	for (int i = 0; i < val[0].size(); i ++) { 
		for (int j = MAXN; j >= 0; j --) {
			if (i == 0) { 
				if (j >= val[0][i]) dp[cur][j] = dp[1-cur][j-val[0][i]];
			} else { 
				if (j >= val[0][i]) 
					dp[cur][j] = dp[1-cur][j-val[0][i]] || dp[1-cur][j+val[0][i]];
				else 
					dp[cur][j] = dp[1-cur][j+val[0][i]];
			} 
		}
		memcpy(dp[1-cur], dp[cur], sizeof(dp[cur]));
		cur = 1-cur;
	} 
	int flag1 = dp[1-cur][x+20000];
	memset(dp, 0, sizeof(dp));
	dp[0][20000] = 1;
	cur = 1;
	for (int i = 0; i < val[1].size(); i ++) {
		for (int j = MAXN; j >= 0; j --) {
			if (j >= val[1][i]) 
					dp[cur][j] = dp[1-cur][j-val[1][i]] || dp[1-cur][j+val[1][i]];
				else 
					dp[cur][j] = dp[1-cur][j+val[1][i]];
		}
		memcpy(dp[1-cur], dp[cur], sizeof(dp[cur]));
		cur = 1-cur;
	} 
	int flag2 = dp[1-cur][y+20000];
	if (flag1 && flag2) cout << "Yes\n";
	else cout << "No\n";
	
	return 0;
} 

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  while(1){
  int dx[5]={1,-1,0,0},dy[5]={0,0,1,-1};
  int i,j,n,m,a[110][110],b[110][110];
  char s;
  int INF=(1<<29);
  scanf("%d %d\n",&m,&n);
  if(m==0 && n==0){
    return 0;
  }
  for(i=0;i<=n+1;i++){
    for(j=0;j<=m+1;j++){
      a[i][j]=2;
      b[i][j]=INF;
    }
  }
  queue<P> que;
  for(i=1;i<=n;i++){
   for(j=1;j<=m;j++){
     scanf("%c",&s);
     if(s=='.'){
       a[i][j]=0;
     }
     else if(s=='&'){
       a[i][j]=0,b[i][j]=0;
       que.push(P(i,j));
     }
     else{
       a[i][j]=1;
     }
   }
    scanf("\n");
  }
  while(!que.empty()){
    P p=que.front();
    que.pop();
    for(i=0;i<4;i++){
      if(a[p.first][p.second]==1 && a[p.first+dx[i]][p.second+dy[i]]==0){
        if(b[p.first+dx[i]][p.second+dy[i]]>b[p.first][p.second]+1){
          que.push(P(p.first+dx[i],p.second+dy[i]));
          b[p.first+dx[i]][p.second+dy[i]]=b[p.first][p.second]+1;
        }
      }
      else if(a[p.first][p.second]==1 && a[p.first+dx[i]][p.second+dy[i]]==2){
        if(b[p.first+dx[i]][p.second+dy[i]]>b[p.first][p.second]+1){
          b[p.first+dx[i]][p.second+dy[i]]=b[p.first][p.second]+1;
        }
      }
      else if(a[p.first+dx[i]][p.second+dy[i]]==2){
        if(b[p.first+dx[i]][p.second+dy[i]]>b[p.first][p.second]){
          b[p.first+dx[i]][p.second+dy[i]]=b[p.first][p.second];
        }
      }
      else{
        if(b[p.first+dx[i]][p.second+dy[i]]>b[p.first][p.second]){
          que.push(P(p.first+dx[i],p.second+dy[i]));
          b[p.first+dx[i]][p.second+dy[i]]=b[p.first][p.second];
        }
      }
    }
  }
  int ans=INF;
  for(i=0;i<=n+1;i++){
    for(j=0;j<=m+1;j++){
      if(a[i][j]==2 && ans>b[i][j]){
        ans=b[i][j];
      }
    }
  }
  cout << ans << endl;
  }
}


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

namespace MyProgram{
    class AtCoder{
        static void Main(){
            int N = int.Parse(Console.ReadLine());
            long[] a = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
            long sum = 0;
            var sum_a = new List<long>();
            for(var i=0;i<N;i++){
                sum += a[i];
                sum_a.Add(sum);
            }
            long x_min_y = 100000000000000000;
            for(var i=0;i<N-1;i++){
                long min = sum - 2*sum_a[i];
                x_min_y = Math.Min(x_min_y,Math.Abs(min));
            }
            Console.WriteLine(x_min_y);
        }
    } 
}

Measured memory_bytes: 33244
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>


#define ll long long
//#define int ll
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 600 + 1;

int n ;
int d[N];
ll ans = 0;
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> n;
	stack<char>st;
	st.push('*');
	while(n--){
		char ch;
		cin >> ch;
		if(st.top() != ch)
			st.push(ch);
	}
	cout << sz(st) - 1;

}

Measured memory_bytes: 384
n,m = map(int,input().split())
xy = [list(map(int,input().split())) for _ in range(m)]
red = [0] *(n)
red[0] = 1
ball = [1]*(n)
for i in range(m):
    if red[xy[i][0]-1] == 1:
        red[xy[i][1]-1] = 1
        if ball[xy[i][0]-1] == 1:
            red[xy[i][0]-1] = 0
    ball[xy[i][0]-1] -=1
    ball[xy[i][1]-1] += 1
print(sum(red))

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

void main_()
{
    ll N;
    vector<ll> as;
    cin >> N;
    copy_n(istream_iterator<ll>(cin), N, back_inserter(as));

    auto ans
        = count_if(
              begin(as), end(as),
              [i = 0, &as](int a) mutable {
                  return as[a - 1] - 1 == i++;
              })
        / 2;

    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include<limits.h>
using namespace std;
using T = tuple<int,int,int>;

#define gc getchar_unlocked
#define sdi(a, b)   si(a);si(b)
#define FOR(i, n)  for(int i = 0;i < n; i++) 
#define eb emplace_back
#define pb push_back
#define MP make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,j,n) for (int i = j; i < n; ++i)
#define repn(i,j,n) for (int i = j; i <= n; ++i)
#define revn(i,j,n) for (int i = j; i >= n; --i)
#define sz(i) i.size()
#define mem(i,v) memset(i,v,sizeof(i))
#define all(v) v.begin(), v.end()
#define endl '\n'
#define int long long
#define INF 1e9
#define ss second
#define ff first
#define vi vector<int>
#define pri(arr,a,b) repn(i,1,a){repn(j,i+1,b){cout<<arr[i][j]<<" ";}cout<<endl;}
 
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair<int,pair<int,int>> piii;
 
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
 
const int mod=1e9+7;
//const int mod=998244353;
const int up=1e5+10;
const int MAXN=1e6+10;



void solve()
{
    int n,sum=0,b,c,f,a;
    cin>>n;
    map<int,int>mp;
    rep(i,0,n){
        cin>>a;
        sum+=a;
        mp[a]++;
    }
    int q;
    cin>>q;
    while(q--){
        cin>>b>>c;
        f=mp[b];
        mp[b]=0;
        mp[c]+=f;
        sum+=(c-b)*f;
        cout<<sum<<endl;
    }
}

int32_t main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("inputf.in", "r", stdin);
    //     freopen("outputf.in", "w", stdout);
    // #endif
    fast_cin();
    int T;
    //sieve();
    //cin>>T;
    T=1;
    int t1=1;
    while(true)
    {  
        
        solve(); 
        t1++;
        if(t1>T)
            break;
    }
}

Measured memory_bytes: 9584
private fun readInts() = readLine()!!.split(" ").map { it.toInt() }

fun main(args: Array<String>) {
    val (a, b, c) = readInts()
    val (N) = readInts()
    
    listOf(a, b, c).max()!!.let { max -> println((a + b + c + max * Math.pow(2.0, N.toDouble()) - max).toInt()) }
}

Measured memory_bytes: 37748
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<typename T> T minimum(T head, T tail) { return std::min(head, tail); }
template<typename Head, typename... Tail> Head minimum(Head head, Tail... tail) {
  return std::min(head, minimum(tail...));
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v){os << " [" << i++ << "]" << x; if (i % 5 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 5 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  //std::ostringstream oss;
  //oss << "ABC" << N;
  //std::string ans = oss.str();

  ll X, A, B;
  std::cin >> X >> A >> B;

  if (A - B >= 0) print("delicious");
  else if (B - A > X) print("dangerous");
  else print("safe");

  return 0;
}


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

int main() {
	int N,K;
	cin>>N>>K;
	int j;
	std::vector<int> v(N);
	for(int i=0;i<N;i++){
		cin>>v[i];
		if(v[i]==1)j=i;
	}
	int a=1000000;
	int b=1000000;
	int ans=0;
	ans+=j/(K-1);
	if(j%(K-1)){
		ans++;
		a=j%(K-1);
	}
	j=N-j-1;
	ans+=j/(K-1);
	if(j%(K-1)){
		ans++;
		b=j%(K-1);
	}
	if(K-1>=a+b)ans--;
	cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define BUFSIZE 1000000
long long A,B,N;
char hoge[BUFSIZE]={0};






int main(void){

    scanf("%s",hoge);

    if(hoge[1]=='B') printf("ARC");
    else printf("ABC");
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dy[8] = {-1,-1, 0, 1, 1, 1, 0,-1}; 
const int dx[8] = { 0, 1, 1, 1, 0,-1,-1,-1};

char s[105][105];

int main()
{
	memset(s, 0, sizeof(s));
	rep (i, 105) rep (j, 105) s[i][j] = '-';
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int M, N; cin >> M >> N;
	rep (i, M) rep (j, N) cin >> s[i+1][j+1];

	int res = 0;
	for (int i = 2; i <= M; ++i){
		for (int j = 1; j <= N; ++j){
			bool ng = false;
			if (s[i][j] != '-') ng |= true;
			if (s[i][j-1] != '-' || s[i][j+1] != '-') ng |= true;
			rep (k, 8)
				if (s[i+dy[k]][j+dx[k]] == 'x') ng |= true;
			if (!ng) ++res;
		} // end for
	} // end for
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  cout<<(n-2)*180<<endl;
  return 0;
}


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

int main()
{
  int64_t N, A, B;
  cin >> N >> A >> B;
  if (abs(A - B) % 2 == 0)
  {
    cout << abs(A - B) / 2 << endl;
  }
  else
  {
    int64_t a = ((N - A) + (N - B) + 1) / 2;
    int64_t b = (A - 1 + B - 1 + 1) / 2;
    cout << min(a, b) << endl;
  }
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define forx(i, n) for(int i = 1 ; (i) <= (n) ; ++i)
#define ll long long
#define all(x) (x).begin(),(x).end()
#define sqr(x) (x) * (x)
#define debug(x) cout << #x <<" = " << x << endl
#define printvpair(v) for(auto x : v) cout << x.first  <<" " << x.second << endl;
#define printv(v) for(auto x : v) cout << x << " "; cout << endl;
#define MINUS(a) memset(a,0xff,sizeof(a))

const int N = 1e5 + 7;
int a[N],b[N];
int n,m,x,y;
int main() {
    cin >> n >> m >> x >> y;
    forn(i,n) cin >> a[i];
    forn(i,m) cin >> b[i];

    sort(a,a + n);
    sort(b,b + m);

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

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


Measured memory_bytes: 256
#include <bits//stdc++.h>
using namespace std;
#define rep(i,n,k) for(int i=n;i<k;i++)
#define int unsigned long long
#define F first 
#define S second
#define P make_pair 

signed main(void){
 
    
    int n,m,q,p,ans;
    string s;
    ans=0;
    vector<int> v;
    cin>>n;
    cout<<(n/500)*1000+((n%500)/5)*5<<endl;
}


Measured memory_bytes: 256
#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 <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

char s[510000];
int a[1000000];
char ans[510000];

int main()
{
  vector<int> a;
  int i,j,n,k,f,jian,h,t,need;
  scanf("%d%d",&n,&k);
  scanf("%s",s);
  if (n==1)
  {
    if (k%2==1) s[0]='A'+'B'-s[0];
    printf("%s\n",s);
    return 0;
  }
  s[n]='B';
  for (i=1;i<n;i++)
    s[n+i]='A'+'B'-s[n+i-1];
  ans[n]='\0';
  for (i=0;i<n;i++)
  {
    if (i==0)
    {
      if (s[0]=='A') need=2;
      else need=1;
    }
    else
    {
      if (s[i]==s[i+n-1])
      {
        need=2;
      }
      else need=1;
    }
    if (k>=need) k-=need;
    else
    {
      for (j=0;j<n;j++)
        if ((i==0)||(s[i+n-1]=='A'))
          ans[j]=s[i+j];
        else ans[j]='A'+'B'-s[i+j];
      if (k==1) ans[0]='A'+'B'-ans[0];
      printf("%s\n",ans);
      return 0;
    }
  }
  if ((s[n]==s[n+n-1])&&(k%2!=0))
  {
    for (j=0;j<n;j++)
      if (s[n+n-1]=='A')
        ans[j]=s[n+j];
      else ans[j]='A'+'B'-s[n+j];
    ans[0]='B';
    printf("%s\n",ans);
  }
  else
  {
    for (j=0;j<n;j++)
      if (s[n+n-1]=='A')
        ans[j]=s[n+j];
      else ans[j]='A'+'B'-s[n+j];
    printf("%s\n",ans);
  }
  /*
  for (i=0;i<k;i++)
  {
    j=0;f=1;
    while ((j>=0)&&(j<n))
    {
      if (s[j]=='A')
      {
        s[j]='B';f=-f;
        j+=f;
      }
      else
      {
        s[j]='A';
        j+=f;
      }
    }
    printf("%s\n",s);
  }
  */
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <string.h>

int main (){


  int n,ans = 0,count = 0,temp;
  int cc[5],ku;
  cc[0] = 5;
  cc[1] = 7;
  cc[2] = 5;
  cc[3] = 7;
  cc[4] = 7;

  char moji[40][10];
  while(1){
    scanf("%d",&n);
    if(n == 0) break;
    for(int i = 0;i < n;i++){
      scanf("%s",&moji[i]);
      //printf("%s ",moji[i]);fflush(0);
    }
	ans = 0;
	count = 0;
	temp = 0;
	ku = 0;
	while(1){
		temp += strlen(moji[ans+count]);
		//printf("%d",temp);
		if(cc[ku] == temp){
			if(ku == 4){
				break;
			}
			temp = 0;
			ku++;
		}
		else if(cc[ku] < temp){
			ku = 0;
			temp = 0;
			ans++;
			count = 0;
			continue;
		}
		count++;
	}
    printf("%d\n",ans+1);
  }
  return 0;
}

Measured memory_bytes: 2668
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define full(x) (bin((x)+1)-1)
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) printf("")
#endif
#define deb debug("line %d\n",__LINE__)
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("-1");exit(0);}

	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int MM=3e6+10;
	ll fac[MM],facinv[MM],Inv[MM];ll Comb(int n,int m){return n<0 or m<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,MM-1) fac[i]=fac[i-1]*i%MOD;
		facinv[MM-1]=invm(fac[MM-1]);fd(i,MM-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,MM-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}
	
	const int N=1e5+10;
	//------------------FIXED------------------
	ll a[N];
	void main()
	{
		ll S=1;
		int n=qread();int cnt=0;
		fo(i,1,n) a[i]=qread(),cnt+=(a[i]==0);
		if(cnt){write(0);return;}
		fo(i,1,n){ ll now=a[i];if(now>(ll)1e18/S) GG();S*=now; } write(S);
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::main();
	debug("\n------------------------------------------\nTime: %.2lf s\n",1.0*clock()/CLOCKS_PER_SEC);
}

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef map<int, int> mpii;
typedef set<int> seti;

const int mxN = 2e5, iinf = 1e9 + 10, inf = 1e18 + iinf + 10, mod = 1000000007;
const ld pi = 4.0 * atanl(1.0), prec = .000001;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

ll n, m, t, a[mxN];

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

int main() {
  fast();
  for (int i = 0; i < 4; ++i) {
    cin >> a[i];
  }
  ll mx = -1e18;
  for (int i = 0; i < 2; ++i) {
    for (int j = 2; j < 4; ++j) {
      ll v = a[i] * a[j];
      mx = max(mx, v);
    }
  }
  cout << mx;
  return 0;
}


Measured memory_bytes: 3664