akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int a, b, c;
    cin >> a >> b >> c;

    int sum = a+b+c;
    int maxabc = 0;
    maxabc = max(a, b);
    maxabc = max(maxabc, c);

    if(sum%2 == maxabc%2){
        cout << (maxabc*3 - sum) / 2 << endl;
    }else{
        cout << ((maxabc+1)*3 - sum) / 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
ans=[]
for i in range(n):
    t1,t2=map(int,input().split())
    a.append(t1)
    b.append(t2)
for i in range(m):
    t1,t2=map(int,input().split())
    c.append(t1)
    d.append(t2)

for i in range(n):
    mi=1000000000
    for j in range(m):
        if abs(c[j]-a[i])+abs(d[j]-b[i])<mi:
            mi=abs(c[j]-a[i])+abs(d[j]-b[i])
            an=j+1
    ans.append(an)
for i in range(n):
    print(ans[i])






Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A[3],K;
    rep(i,3)cin >> A[i];
    cin >> K;
    sort(A,A+3);
    rep(i,K){
        A[2]*=2;
    }
    cout << A[0]+A[1]+A[2] << endl;




}


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

int main(){
  
  string input;
  cin>>input;
  int len= input.length();
  string a(input.begin(), input.begin()+ (len-1)/2);
   string b(input.begin()+ (len+3)/2-1,input.end());
  if(input== string(input.rbegin(), input.rend())
    && a== string(a.rbegin(), a.rend())
    && b== string(b.rbegin(), b.rend())){
  		
        cout<<"Yes";
  }else
    cout<<"No";
  
  
}

Measured memory_bytes: 256
url = "https://atcoder.jp/contests/abc087/tasks/abc087_b"

def main():
    coins = [int(input()) for v in range(3)]
    che = int(input())
    count = 0
    for i in range(0, coins[0] + 1):
        for j in range(0, coins[1] + 1):
            for k in range(0, coins[2] + 1):
                if che == (500 * i) + (100 * j) + (50 * k):
                    count += 1
    print(count)


if __name__ == '__main__':
    main()




Measured memory_bytes: 3060
import sys

m = int(input())

l, r = {}, {}

def insert(num):
    y = None
    x = root
    while True:
        y = x
        if num < x:
            try:
                x = l[x]
            except KeyError:
                break
        else:
            try:
                x = r[x]
            except KeyError:
                break
    if num < y:
        l[y] = num
    else:
        r[y] = num

def find(num):
    x = root
    while True:
        if num == x:
            print('yes')
            return
        elif num < x:
            try:
                x = l[x]
            except KeyError:
                print('no')
                return
        else:
            try:
                x = r[x]
            except KeyError:
                print('no')
                return

def inorder(num):
    try:
        inorder(l[num])
    except KeyError:
        pass
    print(' ' + str(num), end='')
    try:
        inorder(r[num])
    except KeyError:
        pass

def preorder(num):
    print(' ' + str(num), end='')
    try:
        preorder(l[num])
    except KeyError:
        pass
    try:
        preorder(r[num])
    except KeyError:
        pass

for i in range(m):
    order = sys.stdin.readline()
    if i == 0:
        global root
        root = int(order[7:])
        continue
    if order[0] == 'i':
        insert(int(order[7:]))
    elif order[0] == 'p':
        inorder(root)
        print()
        preorder(root)
        print()
    else:
        find(int(order[5:]))


Measured memory_bytes: 42312
#include <stdio.h>
int main()
{
  int a,x,y,z,min;
  while(1){
    scanf("%d",&a);
    x=0;
    y=0;
    z=0;
    min=1000000;
    if(a==0)break;
    for(z=0;z*z*z<=a;z++){
      for(y=0;a-z*z*z>=y*y;y++){
      }
      y--;
      x=a-(z*z*z)-(y*y);
      //printf("%d %d %d\n",x,y,z);/// 
      if(min>x+y+z)min=x+y+z;
    }
    printf("%d\n",min);
  }
  return 0;
}

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

using namespace std;

int main() {
    int N, H, W;
    cin >> N >> H >> W;

    int c = 0;
    for (int i = 0; i < N; i++) {
        int A, B;
        cin >> A >> B;
        c += A >= H && B >= W;
    }

    cout << c << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (233)
#define M ()
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c) {
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
int n,K,P;
int solve(int n,int K){
	int f[N][N],ans=0; memset(f,0,sizeof(f)); f[0][0]=1;
	for(int i=0;i<n;i++)
	for(int j=0;j<=K;j++)
	(f[i+1][0]+=f[i][j])%=P,(f[i+1][j+1]+=f[i][j])%=P;
	for(int i=0;i<=K;i++)(ans+=f[n][i])%=P; return ans;
}
int main(){
	read(n),read(K),read(P);
	if(K&1){
		int f[N][N][N]; memset(f,0,sizeof(f));
		f[0][0][0]=1;
		for(int i=1;i<=n+1;i++)
		for(int j=0;j<=n;j++)
		for(int k=0,tmp;k<=K+1;k++)
		if(f[i-1][j][k]){
			(f[i][0][0]+=f[i-1][j][k])%=P;
			if(i*2<=n)(f[i][j+1][0]+=f[i-1][j][k])%=P;
			if(i*2-K>0&&i*2-K<=n&&k+1<K+2)(f[i][0][k?k+1:0]+=f[i-1][j][k])%=P;
            if(i*2-K>0&&i*2<=n&&(tmp=max(j+2,k+1))<K+2)(f[i][j+1][tmp]+=f[i-1][j][k])%=P;
		}
		printf("%d\n",f[n+1][0][0]);
	}
	else printf("%lld\n",1ll*solve(n/2,K/2)*solve((n+1)/2,K/2)%P);
}

Measured memory_bytes: 51712
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL V<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM emptm()
#define V vector
#define Q queue
#define DQ deque
#define PQ prioritm_queue
#define ST stack
#define FI first
#define MAn 1e18
#define MIN -1e18
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
map<LL,LL>u;
void Y()
{
    cout<<"YES"<<endl;
}
void N()
{
    cout<<"NO"<<endl;
}
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z=0,r;
    string a,b,c;
    cin>>n;
    k=0;
    for(i=1; i<=n; i++)
    {
        cin>>o;
        if(o!=i)
        {
            k++;
        }
    }
    if(k<=2)
    {
        Y();
    }
    else
    {
        N();
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#include <complex>

#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 complex<double> P;

typedef pair<double,double> DD;
typedef pair<double, DD> TD;

// 点 p1, p2  の通る直線の方程式
TD calc_line (P p1, P p2 )
{
	double a = p1.imag() - p2.imag();
	double b = p2.real() - p1.real();
	double c = p1.real()*p2.imag() - p2.real()*p1.imag();

	return TD (a, DD (b, c ) );
}

// 直線 ax+by+c = 0 に対して点 p の対称点を求める
P symmetric_pos (double a, double b, double c, P p )
{
	double C = 2.*(a*p.real() + b*p.imag() + c )/(a*a + b*b );

	return (p - C*P(a, b ) );
}

// 点 p から直線l:ax+by+c = 0　へ垂線と直線lとの交点の座標
P perp_foot (double a, double b, double c, P p )
{
	double C = (a*p.real() + b*p.imag() + c )/(a*a + b*b );

	return (p - C*P(a, b ) );

}

int main()
{
//	cut here before submit 
//	freopen ("testcase.a_symmetric_point", "r", stdin );
	double x1, y1, x2, y2, xq, yq;
	while (scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq) != EOF ) {
		P p1 = P (x1, y1 );
		P p2 = P (x2, y2 );
		P q  = P (xq, yq );
		TD l = calc_line (p1, p2 );
		P res  = symmetric_pos (l.first, l.second.first, l.second.second, q ); 
		printf ("%lf %lf\n", res.real(), res.imag() );
	} // end loop
		
	return 0;
}

Measured memory_bytes: 1236
import sys
N = int(input())
btn = [int(input()) for _ in range(N)]
ans = []
x = 0

for i in range(N):
  ans.append(btn[x])
  if ans[i] == 2:
    print(len(ans))
    sys.exit()
  else:
    x = ans[i] - 1
print(-1)

Measured memory_bytes: 7852
//Utkarsh.25dec
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
ll power(ll a,ll b) {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;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n;
    cin>>n;
    ll a,b;
    cin>>a>>b;
    if((b-a)%2==0)
    {
        cout<<(b-a)/2;
    }
    else
    {
        ll temp1=a;
        ll tb=b-a;
        temp1+=((tb-1)/2);
        ll temp2=n-b+1;
        ll ta=a+temp2;
        temp2+=((n-ta)/2);
        cout<<min(temp1,temp2);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
static const double EPS = 1e-10;
static const double PI  = acos(-1.0);
static const ll MOD = 1000000007;
// static const ll MOD = 998244353;
static const int INF = 1 << 30;
// static const ll INF = 1LL << 62;
// --------------------------------------------------------


struct P {
    ll x, y;
    P() {};
    P(ll x, ll y) : x(x), y(y) {
    }
    P operator + (P p) {
        return P(x + p.x, y + p.y);
    }
    P operator - (P p) {
        return P(x - p.x, y - p.y);
    }
    P operator * (ll d) {
        return P(x * d, y * d);
    }
    ll dot(P p) {
        return (x * p.x) + (y * p.y);
    }
    ll det(P p) {
        return (x * p.y) + (-y * p.x);
    }
};


ll dist(P p, P q) {
    return llabs(p.x - q.x) + llabs(p.y - q.y);
}


bool cmp_x(const P& p, const P& q) {
    if (p.x != q.x) return p.x < q.x;
    return p.y < q.y;
}


vector<P> convex_hull(P* ps, int n) {
    sort(ps, ps + n, cmp_x);
    int k = 0;
    vector<P> qs(n * 2);

    for (int i = 0; i < n; i++) {
        while (k > 1 && (qs[k - 1] - qs[k - 2]).det(ps[i] - qs[k - 1]) <= 0) k--;
        qs[k++] = ps[i];
    }
    for (int i = n - 2, t = k; i >= 0; i--) {
        while (k > t && (qs[k - 1] - qs[k - 2]).det(ps[i] - qs[k - 1]) <= 0) k--;
        qs[k++] = ps[i];
    }
    qs.resize(k - 1);
    return qs;
}


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

    int N; cin >> N;
    P ps[N];
    REP(i, N) {
        ll x, y; cin >> x >> y;
        ps[i] = P(x, y);
    }

    vector<P> qs = convex_hull(ps, N);
    ll ans = 0;
    for (int i = 0; i < SZ(qs); i++) {
        for (int j = 0; j < i; j++) {
            ans = max(ans, dist(qs[i], qs[j]));
        }
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 6764
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int p[10000];
int main(){
  int N;
  cin >> N;

  int ans = 0;
  rep(i, N){
    cin >> p[i];
    ans += p[i];
  }
  sort(p, p + N);
  ans -= p[N - 1] / 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
#include <chrono>
#include <thread>

using namespace std;

const bool debug = true;

#ifndef M_PI
    const double M_PI = acos(-1.0);
#endif // M_PI

#define y1 roman_kaban
#define rank oryshych_konb
#define ull unsigned long long
//#define ll long long
//const int mod = int(1e9) + 7;
//const int inf = 1e9;
//const long long infLL = 1e16;
//const int MX2 = 10100500; //  e7
//const long long INF = 1e18 + 0.5;
const int MX = 300500; //       e5
//const int SZ = 2100;
//const int delta = 1 << 19;

pair<int,int> a[MX];
int main()
{
    ios_base::sync_with_stdio(false);
    //if(debug)
//freopen("/Users/ozzy/Documents/in.txt","r", stdin);
    int n;
    cin >> n;
    long long k;
    cin >> k;
    for(int i =0 ; i < n; i++){
        cin >> a[i].first >> a[i].second;
    }
    sort(a, a + n);
    for(int i =0 ; i < n; i++){
        k -= a[i].second;
        if(k <= 0) {cout << a[i].first << endl; break;}
    }
    return 0;
}


Measured memory_bytes: 1024
#a.append(list(map(int, input().split())))
#b.append(list(map(int, input().split())))
#c.append(list(map(int, input().split())))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))


count = int(input())

for num in range(count):
    x = int(input())
    for y in range(3):
        if a[y] == x:
            a[y] = 0
    for y in range(3):
        if b[y] == x:
            b[y] = 0
    for y in range(3):
        if c[y] == x:
            c[y] = 0

#ans = 0
#ans = a[0] * a[1] * a[2]
#ans += b[0] * b[1] * b[2]
#ans += c[0] * c[1] * c[2]
#ans += a[0] * b[0] * c[0]
#ans += a[1] * b[1] * c[1]
#ans += a[2] * b[2] * c[2]

#if ans == 0:
#    print("Yes")
if a[0]+a[1]+a[2] == 0:
    print("Yes")
elif b[0]+b[1]+b[2] == 0:
    print("Yes")
elif c[0]+c[1]+c[2] == 0:
    print("Yes")
elif a[0] + b[0] + c[0] ==0:
    print("Yes")
elif a[1] + b[1] + c[1] ==0:
    print("Yes")
elif a[2] + b[2] + c[2] ==0:
    print("Yes")
elif a[0] + b[1] + c[2] == 0:
    print("Yes")
elif a[2] + b[1] + c[0] ==0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
use std::collections::BTreeSet;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let w:usize = read();
    let h:usize = read();
    let n:usize = read();
    let mut xs = BTreeSet::new();
    let mut ys = BTreeSet::new();
    for _ in 0..n {
        let x:usize = read();
        let y:usize = read();
        let a:usize = read();
        match a {
            1 => {
                for i in 1..=x {
                    xs.insert(i);
                }
            },
            2 => {
                for i in x+1..=w {
                    xs.insert(i);
                }
            },
            3 => {
                for i in 1..=y {
                    ys.insert(i);
                }
            },
            _ => {
                for i in y+1..=h {
                    ys.insert(i);
                }
            }
        }
    }
    let mut leng = 0;
    for i in 1..=w {
        if !xs.contains(&i) {
            leng += 1;
        }
    }
    let mut height = 0;
    for i in 1..=h {
        if !ys.contains(&i) {
            height += 1;
        }
    }
    println!("{}", leng * height);
}


Measured memory_bytes: 2136
#include <iostream>
#include <algorithm>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long
struct rb
{
	int l,r;
}R[100005];
bool operator <(const struct rb &a,const struct rb &b)
{
	
	return a.r<b.r;
}
int main(int argc, char** argv) {
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		R[i].l=x-y;
		R[i].r=x+y;
	}
	sort(R+1,R+n+1);
	int r=-1e9,ans=0;
	for(int i=1;i<=n;i++)
	{
		if(R[i].l>=r)
		{
			ans++;
			r=R[i].r;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
N, M, X, Y = map(int, input().split())
XX = list(map(int, input().split()))
YY = list(map(int, input().split()))

rightX = max(XX)
leftY = min(YY)
print('No War' if max(rightX, X) < min(leftY, Y) and X < Y else 'War')


Measured memory_bytes: 2940
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    p.back() /= 2;
    cout << accumulate(p.begin(), p.end(), 0) << endl;
    return 0;
}

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/f.in", "r", stdin);
//  freopen("../IO/f.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

struct point_t {
  int x, y;
  point_t() = default;
  point_t(int x, int y) : x(x), y(y) {}
  int quad() const {
    return y > 0 || (y >= 0 && x >= 0);
  }
  int64_t abs2() const {
    return (int64_t) x * x + (int64_t) y * y;
  }
  int64_t dot(point_t rhs) const {
    return (int64_t) x * rhs.x + (int64_t) y * rhs.y;
  }
  int64_t det(point_t rhs) const {
    return (int64_t) x * rhs.y - (int64_t) y * rhs.x;
  }
};

struct PolarAngleComparator {
  bool operator()(point_t a, point_t b) const {
    int c1 = a.quad(), c2 = b.quad();
    if (c1 != c2) {
      return c1 > c2;
    }
    auto orientation = a.det(b);
    if (orientation == 0) {
      return a.abs2() < b.abs2();
    } else {
      return orientation > 0;
    }
  }
};
void solve(std::istream &in, std::ostream &out) {
  int n;
  in >> n;
  vector<point_t> points(n);
  for (point_t &point : points) {
    in >> point.x >> point.y;
  }
  sort(points.begin(), points.end(), PolarAngleComparator());
  int64_t result = 0;
  int64_t sx = 0, sy = 0;
  for (int r = 0, l = 0; l < n; ++l) {
    if (points[l].x == 0 && points[l].y == 0) continue;
    while (r - l < n &&  (points[l].det(points[r % n]) > 0 ||
                          (points[l].det(points[r % n]) == 0 && points[l].dot(points[r % n]) >= 0))) {
      sx += points[r%n].x;
      sy += points[r%n].y;
      ++r;
      result = max(result, sx * sx + sy * sy);
    }
    sx -= points[l%n].x;
    sy -= points[l%n].y;
    result = max(result, sx * sx + sy * sy);
  }
  out << fixed << setprecision(12) << sqrt(result) << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(void){
	int a, b; cin >> a >> b;
	printf("%.9f\n", double(a * b) / (a + b));
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
# coding: utf-8
import sys
sys.setrecursionlimit(10000000)

#const
dxdy=((1,0),(0,1))
# my functions here!
def pin(type=int):
    return map(type,input().rstrip().split())
    

#絶対TLEする！A問題のpython回答はこちら！！！！

def sx(h,w,ans=0):#depth-first? search functionを障害物を消しながら行う
    from collections import deque as DQ
    q=DQ()
    q.append((h,w,ans,0))
    
    flag=0
    while (len(q) >0):
        temp=q.pop()
        s,t,z,flag=temp
        
        if s>=H or t>=W:continue
        #print(maze[s][t])
        if maze[s][t]=="#":
            z+=1-flag
            flag=1
        elif maze[s][t]==".":
            flag=0
        #print((s,t,z))            
        if z<dp[s][t]:
            dp[s][t]=z
            for d in dxdy:
                q.append((s+d[0],t+d[1],z,flag))

def resolve():
    
    global anss ,dp,H,W,maze
    global res
    res=0
    H,W=pin()
    dp=[[(H+W)]*W for _ in range(H)]
    
    maze=tuple(tuple(input())for i in range(H))
    sx(0,0)
    #print(min(anss),len(anss),res)
    print(dp[H-1][W-1])
    

"""         
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 3
.##
.#.
##."""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2 2
#.
.#"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """4 4
..##
#...
###.
###."""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """5 5
.#.#.
#.#.#
.#.#.
#.#.#
.#.#."""
        output = """4"""
        self.assertIO(input, output)


if __name__=="__main__":resolve()


Measured memory_bytes: 56296
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <algorithm>

using namespace std;
const int NMAX = 10000;

void print(int* A, int N)
{
   cout << A[0]; 
   for (int k = 1; k < N;k++) {
     cout << " " << A[k] ; 
   }
   cout << endl;
}

int GCD(int x, int y)
{
  if (y == 0) {
    return x;
  } else {
    return GCD(y, x%y);
  }
}


int main()
{
  int n;
  cin >> n;
  
  int x;
  int minv;
  cin >> x;
  int maxv;  
  minv = x; 
  for (int i = 1; i < n; i++) {
    cin >> x;
    if (i == 1) {
      maxv = x - minv;
    }
    maxv = max(maxv, x - minv); 
    minv = min(minv, x); 
   }
  cout << maxv << endl; 
  return 0;
}

Measured memory_bytes: 1160
from math import sqrt, floor
from functools import reduce


def divide(p):
    global n, a, limit
    while not (n % p):
        a.add(p)
        n = n // p
        limit = floor(sqrt(n))


n, p = int(input()), 3
n0 = n
limit = floor(sqrt(n))
a, i = set(), 3

divide(2)

while p <= limit:
    divide(p)
    p += 2

if n > 1:
    a.add(n)

print(reduce(lambda prev, now: prev * (now - 1) // now, a, n0))

Measured memory_bytes: 8392
# https://atcoder.jp/contests/abc047/tasks/arc063_a
# 連長圧縮すれば簡単
# 圧縮後の文字列長-1となる


def run_length_encoding(s):
    '''連長圧縮を行う
    s ... iterable object e.g. list, str 
    return
    ----------
    s_composed,s_num,s_idx
    それぞれ、圧縮後の文字列、その文字数、その文字が始まるidx'''
    s_composed, s_sum = [], []
    s_idx = [0]
    pre = s[0]
    cnt = 1
    for i, ss in enumerate(s[1:], start=1):
        if pre == ss:
            cnt += 1
        else:
            s_sum.append(cnt)
            s_composed.append(pre)
            s_idx.append(i)
            cnt = 1
            pre = ss
    s_sum.append(cnt)
    s_composed.append(pre)
    # assert len(s_sum) == len(s_composed)
    return s_composed, s_sum, s_idx


S_composed, _, _ = run_length_encoding(input())
print(len(S_composed) - 1)


Measured memory_bytes: 86364
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), r = sc.nextInt();
		int ans = (n >= 10 ? r : r + (100 * (10 - n)));
		sc.close();
		System.out.println(ans);
	}
}


Measured memory_bytes: 22996
#include<stdio.h>
int main()
{
  	int c = 0;
 	char s[3];
  	scanf("%s", s);
  	if (s[0] == '1') c++;
  	if (s[1] == '1') c++;
  	if (s[2] == '1') c++;
  	printf("%d\n", c);
}

Measured memory_bytes: 128
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e6 + 6;

int n, p;
ll cnt[2];

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

	cin >> n >> p;
	forn(i, 1, n) {
        int x;
        cin >> x;
        cnt[x & 1]++;
	}

	if (p) cout << (1ll << cnt[0]) * (cnt[1] ? (1ll << cnt[1]) : 0) / 2ll << "\n";
    else cout << (1ll << cnt[0]) * (cnt[1] ? (1ll << cnt[1]) / 2ll : 1ll) << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    string S;
    cin >> N >> K >> S;
    vector<int> T;
    if (S[0] == '0')
        T.push_back(0);
    char st = S[0];
    int num = 0;
    REP(i, N)
    {
        if (S[i] != st)
        {
            T.push_back(i - num);
            num = i;
            st = S[i];
        }
    }
    T.push_back(N - num);
    if (S[N - 1] == '0')
        T.push_back(0);
    if (K >= (int)T.size() / 2)
    {
        cout << N << "\n";
    }
    else
    {
        int maxVal = 0;
        vector<int> Tsum;
        Tsum.push_back(0);
        Tsum.push_back(T[0]); //1
        REPS(i, (int)T.size() - 1)
        {
            Tsum.push_back(Tsum[i] + T[i]);
        }
        REP(i, (int)Tsum.size())
        {
            //   cout << "i" << i << " " << Tsum[i] << "\n";
        }
        //i番目の和 Tsum[i+1]
        //[p,p+2*K] p=0,p+2*K<=
        //Tsum[p+2*K+1]-Tsum[p]
        for (int p = 0; p + 2 * K <= (int)T.size() - 1; p += 2)
        {
            if (Tsum[p + 2 * K + 1] - Tsum[p] > maxVal)
            {
                maxVal = Tsum[p + 2 * K + 1] - Tsum[p];
            }
        }
        cout << maxVal << "\n";
    }
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
long long N, M, K; 
long long fac[200010], inv[200010], finv[200010];  
long long MOD = 998244353; 
long long power(long long a, long long n){
	long long ans = 1; long long mul = a; 
	while(n){
		if(n & 1){
			ans *= mul; ans %= MOD; 
		}
		n >>= 1; 
		mul = mul * mul % MOD; 
	}
	return ans; 
}
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < 200005; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0); 
	cin >> N >> M >> K; 
	long long ans = 0; COMinit(); 
	for(int i = 0; i <= K; i++){
		long long tmp = M; 
		tmp *= power(M-1, N-1-i); 
		tmp %= MOD; 
		tmp *= COM(N-1, i); 
		tmp %= MOD; 
		ans += tmp; 
		ans %= MOD; 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 8256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, i;
  int flag=0;
  cin >> N ;
  for(i=1;i<=N;i++){
    string op;
    cin >> op;
		if (op == "Y") {
          flag = 1;
		}
		else {
		}  
  }  
    	if(flag == 1){
        cout <<"Four"<<endl;
        }
    	else{
        cout <<"Three"<<endl;
        }

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll d[300][300];
ll V;
vector<int> v;

void warshall_floyd(){
  rep(k,V){
    rep(i,V){
      rep(j,V)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    }
  }
}

int main(){
  rep(i,300){
    rep(j,300){
      if(i!=j)d[i][j]=inf;
    }
  }
  ll m,R;
  cin >> V >> m >> R;
  ll r[R];
  rep(i,R){
    cin >> r[i];
    r[i]--;
  }
  ll a[m],b[m],c[m];
  rep(i,m){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]]=min(d[a[i]][b[i]],c[i]);
    d[b[i]][a[i]]=min(d[b[i]][a[i]],c[i]);
  }
  warshall_floyd();
  ll ans=inf;
  rep(i,R){
    v.push_back(i);
  }
  while(next_permutation(v.begin(),v.end())){
        ll temp=0;
    rep(i,R-1)temp+=d[r[v[i]]][r[v[i+1]]];
    ans=min(ans,temp);
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int n, ct;
pair<int, int> ab[202000];

bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second == b.second) {
        return (a.first < b.first);
    }
    
    return (a.second < b.second);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n;
    rep(i, n) cin >> ab[i].first >> ab[i].second;
    
    sort(ab, ab + n, cmp);
    ct = 0;
    
    rep(i, n) {
        ct += ab[i].first;
        
        if (ct > ab[i].second) {
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1792
($N,$A)=glob<>;@y=map$_-$A,@x=(0,glob<>);$_>$X&&($X=$_)for@x,$A;
for$j(0..$N){for$t(0..2*$N*$X){
	$dp[$j][$t]=
	(
		  $j==0 &&  $t==$N*$X                            ? 1
		: $j>=1 && ($t-$y[$j]< 0 || $t-$y[$j]> 2*$N*$X ) ? $dp[$j-1][$t]
		: $j>=1 &&  0<=$t-$y[$j] && $t-$y[$j]<=2*$N*$X   ? $dp[$j-1][$t] + $dp[$j-1][$t-$y[$j]]
		:                                                  0
	)
}}
print$dp[$N][$N*$X]-1,$/

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

int main ()
{
	int n, k;
  	cin >> n >> k;
  	vector<double> e(n);
  	double sum = 0.0;
  	double ans = 0.0;
  	for (int i = 0; i < n; i++)
    {
    	cin >> e.at(i);
      	e.at(i) = (e.at(i) + 1) / 2;
    }
  	vector<double> tasu(n + 1, 0.0);
  	for (int i = 0; i < n; i++)
    {
    	tasu.at(i + 1)  = tasu.at(i) + e.at(i);
    }
  	for (int i = 0; i <= n - k; i++)
    {
    	sum = tasu.at(i + k) - tasu.at(i);
      	ans = max(ans, sum);
    }
  	cout << setprecision(9) << ans << endl;
  	return 0;
}


Measured memory_bytes: 3328
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1

n=int(input())
ab=[list(map(int,input().split())) for i in range(n)]
cd=[list(map(int,input().split())) for i in range(n)]
usedab=[0]*n
usedcd=[0]*n
cd.sort();ab.sort(key=lambda tup:-tup[1])
for i,(c,d) in enumerate(cd):
    for j,(a,b) in enumerate(ab):
        if a<c and b<d and (not usedab[j]) and (not usedcd[i]):
            usedab[j]=1
            usedcd[i]=1
            count+=1
            # print(a,b,c,d)
print(count)
# print(usedab)
# print(usedcd)


        

        

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;

const int mod = 1e9 + 7;

long long x, y;

int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> x >> y;
    if(x % y == 0)
        cout << "-1\n";
    else
        cout << x << "\n";
}


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

namespace ConsoleApplication49
{
    class Program
    {
        static void Main()
        {
            int s = 0;
            while (true)
            { int m = 0;
                string a = Console.ReadLine();
                if (a == null) break;
                for(int b = 0; b < a.Length; b++)
                {
                    if (char.IsDigit(a[b]))
                    {
                        m = 10 * m + (int)char.GetNumericValue(a[b]);
                        if (a.Length - 1 == b) s += m;
                    }
                    else  { s += m; m = 0; }
                }
            }
            Console.WriteLine(s);
        }
    }
}

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


char s[1000];

int main() {
    int n;
    double res = 0;
    scanf("%d", &n);
    while (n--) {
        double t;
        scanf("%lf %s", &t, s + 1);
        if (s[1] == 'J') res += t;
        else res += 380000.0 * t;
    }
    printf("%.6lf\n", res);
    return 0;
}


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

ll Min(ll x,ll y){
	if (x > y){
		return y;
	}else{
		return x;
	}
}
ll Max(ll x,ll y){
	if(x > y){
		return x;
	}else{
		return y;
	}
}

int main(){
	int N,_;
	ll Array[100010];
	ll input;
	ll mins[100010];
	ll min = 10000000000,max = 0;
	
	cin >> N >> _;
	for(int i=0;i<N;i++){
		cin >> Array[i];
		min = Min(min,Array[i]);
		mins[i] = min;
	}
	
	
	ll maxrieki = 0;
	for(int i=0;i<N;i++){
		maxrieki = Max(maxrieki,Array[i] - mins[i]);
	}
	
	int answer = 0;
	for(int i=0;i<N;i++){
		if (maxrieki == Array[i] - mins[i]){
			answer ++;
		}
	}
	
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

char map[16][16] = {0};

void delete_island(int x, int y)
{
	if (map[x][y] == 0) return;
	map[x][y] = 0;
	delete_island(x - 1, y);
	delete_island(x + 1, y);
	delete_island(x, y - 1);
	delete_island(x, y + 1);
}

int main(void)
{
	while (scanf("%s", &map[0][1]) != EOF){
		int i, j;
		int count = 0;
		
		for (i = 1; i < 12; i++) scanf("%s", &map[i][1]);
		for (i = 0; i < 12; i++){
			for (j = 0; j < 12; j++) map[i][j + 1] -= '0';
		}
		
		for (i = 0; i < 12; i++){
			for (j = 0; j < 12; j++){
				if (map[i][j + 1] == 1){
					count++;
					delete_island(i, j + 1);
				}
			}
		}
		printf("%d\n", count);
		scanf("%*c");
	}
	
	return 0;
}

Measured memory_bytes: 544
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long A = sc.nextLong();
        long B = sc.nextLong();
        int C = sc.nextInt();
        int D = sc.nextInt();

        System.out.println(solve(A, B, C, D));

        sc.close();
    }

    static long solve(long A, long B, int C, int D) {
        return B - A + 1 - computeMultipleNum(A, B, C) - computeMultipleNum(A, B, D)
                + computeMultipleNum(A, B, lcm(C, D));
    }

    static long lcm(int x, int y) {
        return (long) x * y / gcd(x, y);
    }

    static int gcd(int x, int y) {
        return (y == 0) ? x : gcd(y, x % y);
    }

    static long computeMultipleNum(long A, long B, long factor) {
        long min = (A + factor - 1) / factor;
        long max = B / factor;

        return max - min + 1;
    }
}

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

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
#define DRT() int t; si(t); while(t--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//# define M_PI           3.14159265358979323846264338327950288
// DSU
void IO(){
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
}

int main(){
	IO();
	LL n;
	cin>>n;
	if(n >= 30)
		dout("Yes");
	else
		dout("No");
	return 0;
}

Measured memory_bytes: 3632
// *** creator : cfmasterr *** //
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
	string s;
	cin >> n >> s;
	int ans = 1;
	for (int i = 1; i < (int) s.size(); i++) {
		ans += (s[i] != s[i - 1]);
	}
	cout << ans << '\n';
  return 0;
}



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

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
    ifstream t("/proc/self/status");
    cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum = 0, fg = 1;
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) - '0' + ch;
	return sum * fg;
}

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

int L;

inline void input()
{
	L = read<int>();
}

struct edge
{
	int u, v, w;

	edge() { }
	edge(int _u, int _v, int _w): u(_u), v(_v), w(_w) { }
};

inline void solve()
{
	const int MAXN = 20;

	int N = 0;
	static vector<edge> E;
	static int prefix[MAXN + 5];
	E.clear(), prefix[1] = 0;

	for(N = 2; N <= 20 && prefix[N - 1] + (1 << (N - 2)) < L; ++N)
	{
		prefix[N] = prefix[N - 1] + (1 << (N - 2));
		E.emplace_back(N - 1, N, 1 << (N - 2));
		E.emplace_back(N - 1, N, 0);
	}
	--N;

	int cnt = L - (1 << (N - 1)), cur = prefix[N];
	for(int i = N; i; --i)
		while(cnt >= (1 << (i - 1)) && cur + prefix[i] < L)
		{
			cnt -= 1 << (i - 1);
			E.emplace_back(i, N, cur + 1), cur += 1 << (i - 1);
		}

	printf("%d %d\n", N, SZ(E));
	for(auto it : E) printf("%d %d %d\n", it.u, it.v, it.w);
}

int main()
{

	input();
	solve();

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;
const int MAX = 100005;

vector<int> G[MAX];
int dt[MAX], da[MAX];

void dfs(int u) {
  for (int v: G[u]) {
    if (dt[v] != -1) continue;
    dt[v] = dt[u] + 1;
    dfs(v);
  }
}

void dfs2(int u) {
  for (int v: G[u]) {
    if (da[v] != -1) continue;
    da[v] = da[u] + 1;
    dfs2(v);
  }
}

bool check(int u) {
  for (int v: G[u]) {
    if (da[v] > da[u]) return false;
  }
  return true;
}



int main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--, v--;
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  memset(dt, -1, sizeof(dt));
  memset(da, -1, sizeof(da));
  dt[u] = 0, da[v] = 0;
  dfs(u), dfs2(v);

  int res = -1, idx = -1;
  rep(i, n) {
    if (!check(i)) continue;
    if (dt[i] < da[i] && da[i] > res) {
      res = da[i];
      idx = i;
    }
  }
  
  cout << max(0, da[idx] - 1) << endl;

  







  


  
  return 0;
}

Measured memory_bytes: 9088
#include <stdio.h>
#define NMAX 100005
#define QMAX 200005

int main(void)
{
    int n;
    int QueryNum;
    int QueryValue[QMAX];
    int i, j;
    int LowerBound;
    int UpperBound;
    int Num[NMAX] = {};
    
    
    scanf("%d",&n);
    
    for(i = 0; i < n; i++){
        scanf("%d ", &Num[i]);
    }
    
    scanf("%d",&QueryNum);
    
    for(i = 0; i < QueryNum; i++){
        scanf("%d", &QueryValue[i]);
        while((QueryValue[i] > Num[j]) && (LowerBound != n)){
            j++;
            if(j == n){
                break;
            }
        }
        LowerBound = j;
        while(Num[j] == QueryValue[i]){
            j++;
            if(j == n){
                break;
            }
        }
        UpperBound = j;
        printf("%d %d\n", LowerBound, UpperBound);
        j = LowerBound;
    }
    
    return 0;
}



Measured memory_bytes: 2948
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
ll dp[1002][1002];
ll func(string mat[],ll i, ll j,ll ans , ll n , ll m){
	
	if (dp[i][j]!=-1) return dp[i][j];
	if(i==n-1 && j==m-1)
		return 1;
	
	if(i>=n ||j>=m ||mat[i][j]=='#')
		return dp[i][j] = 0;

	return dp[i][j]= (func(mat , i, j+1 , ans,n,m) + func(mat ,i+1  ,j , ans,n,m) )%mod;
	
}
int main()
{
  	ll n , m ,i;
  	scanf("%lld %lld",&n, &m);
	memset(dp, -1, sizeof(dp));
  	string mat[n];
  	for(i=0;i<n;i++)
  		cin>>mat[i];
  	printf("%d",func(mat , 0 , 0 , 0 , n, m));
  	return 0;
  	
}

Measured memory_bytes: 13708
n=int(input())
a=list(map(int,input().split()))
q=int(input())
l=[0]*q
ans=sum(a)
for i in range(q):
    b,c=map(int,input().split())
    l[i]=(b,c)
book={}
for i in a:
    if i in book:
        book[i]+=1
    else:
        book[i]=1

for i in range(q):
    if l[i][0] in book:
        if l[i][1] in book:
            ans+=(l[i][1]-l[i][0])*book[l[i][0]]
            book[l[i][1]]+=book[l[i][0]]
            book[l[i][0]]=0
        else:
            ans+=(l[i][1]-l[i][0])*book[l[i][0]]
            book[l[i][1]]=book[l[i][0]]
            book[l[i][0]]=0
    print(ans)

Measured memory_bytes: 89392
import statistics
n=int(input())
A=list(map(int,input().split()))
B=[0]*n
for i in range(n):
    B[i]=A[i]-(i+1)
b=statistics.median(B)
C=[0]*n
for i in range(n):
    C[i]=abs(B[i]-b)
print(int(sum(C)))

Measured memory_bytes: 28072
# frozen_string_literal: true

n = gets.to_i
a = gets.split.map(&:to_i)
sum = 0
0.upto(n - 1) do |i|
  sum += i.even? ? a[i] : -a[i]
end
x = []
x.push sum
prev = sum
1.upto(n - 1) do |i|
  xx = 2 * a[i - 1] - prev
  x.push xx
  prev = xx
end
puts x.join(' ')


Measured memory_bytes: 14084