akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	int n,m;
	cin >> n >> m;

	ll sum = n * (n-1) / 2 + (m *(m-1)/2);
	cout << sum;
    return 0;
}

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

typedef long long ll;

/*
  let's try computer shogi!!!
 */

struct area{
  ll l;
  ll r;
  ll id;
};

bool compleft(area &a, area &b){
  return a.l > b.l;
}

bool compright(area &a, area &b){
  return a.r < b.r;
}

void move(ll &cx, area &a, ll &score){
  if(cx < a.l){
    score += a.l - cx;
    cx = a.l;
    return;
  }
  if(cx > a.r){
    score += cx - a.r;
    cx = a.r;
    return;
  }
  return;
}

int main(){
  vector<area> a;
  vector<area> lvec;
  vector<area> rvec;
  ll n;
  cin >> n;
  bool used[n];
  a.resize(n);
  for(ll i=0;i<n;++i){
    cin >> a[i].l >> a[i].r;
    a[i].id = i;
    used[i] = false;
  }
  cerr<<"---"<<endl;
  sort(a.begin(),a.end(),compleft);
  lvec = a;
  for(ll i=0;i<n;++i){
    cerr<<a[i].l <<"," <<a[i].r<<","<<a[i].id<<endl;
  }
  cerr<<"---"<<endl;
  sort(a.begin(),a.end(),compright);
  rvec = a;
  for(ll i=0;i<n;++i){
    cerr<<a[i].l <<"," <<a[i].r<<","<<a[i].id<<endl;
  }
  cerr<<"---"<<endl;
  ll maxsc = 0;
  
  for(int loop=0;loop<2;++loop){
    for(ll i=0;i<n;++i){
      used[i]=false;
    }
    ll ir = 0;
    ll il = 0;
    ll cx = 0;
    ll score = 0;
    ll cnt = 0;
    
    for(ll i=0; i<n; ++i){
      
      for(ll j=il;j<n;++j){
	if(loop == 1 && i == 0){
	  continue;
	}

	if(!used[lvec[j].id]){
	  move(cx, lvec[j], score);
	  cerr<<cnt<<":"<<lvec[j].id<<"(id),"<<cx<<","<<score<<endl;
	  used[lvec[j].id]=true;
	  cnt++;
	  il = j+1;
	  break;
	}
      }
      if(cnt == n){break;}
      for(ll j=ir;j<n;++j){
	if(!used[rvec[j].id]){
	  move(cx, rvec[j], score);
	  cerr<<cnt<<":"<<rvec[j].id<<"(id),"<<cx<<","<<score<<endl;
	  used[rvec[j].id]=true;
	  cnt++;
	  ir = j+1;
	  break;
	}
      }
      if(cnt == n){break;}
    }
    score += abs(cx);
    cerr<<"final"<<score<<endl;
    if(maxsc < score){
      maxsc = score;
    }
  }

  cout<<maxsc<<endl;
  return 0;
  
}

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

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

  c = n * a;
  
  if (c >= b) {
    cout << b << endl;
  }
  else if (c <= b){
    cout << c << endl;
  }
}

Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;

	vector<int> v(n);

	for(int i = 0; i < n; i++) cin >> v[i];

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

	long long ans = v[n - 1];

	int get = n - 2;

	for(int i = n - 2; i >= 0; i--) {
		if(get) {
			get--;
			ans += v[i];
		}
		if(get) {
			get--;
			ans += v[i];
		}
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 3988
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		long N = long.Parse(Console.ReadLine());
		long[]A = new long[N];
		for(var i=0;i<N;i++){
			A[i] = long.Parse(Console.ReadLine());
		}
		long[]B = new long[200001];
		long[]D = new long[200001];
		long[]C = new long[200001];
		C[0] = 1;
		long mod = 1000000007;
		for(var i=1;i<=N;i++){
			if(i==1 || A[i-1]!=A[i-2]){
				D[i] = B[A[i-1]];
				C[i] = (C[i-1] + D[i]) % mod;
				B[A[i-1]] = C[i];
			} else {
				C[i] = C[i-1];
			}
		}
		long ans = 1;
		for(var i=1;i<=N;i++){
			ans = (ans + D[i]) % mod;
		}
		//for(var i=0;i<=N;i++){
		//	Console.WriteLine(D[i]+" "+C[i]);
		//}
		Console.WriteLine(ans);
	}
}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int n = in(), a = in();
  cout << n * n - a << endl;
}


Measured memory_bytes: 256
import sys
import collections
import itertools
import numpy as np

n,m = map(int, input().split())
al = np.ones(n,dtype="int8")
H = list(map(int, input().split()))
AB=[]

for i in range(m):
    AB.append(tuple(map(int, input().split())))

for t in range(m):
    A = AB[t][0]
    B = AB[t][1]
	
    bou1 = H[A-1]
    bou2 = H[B-1]
    if bou1<bou2:
        al[A-1] = al[A-1]-1
    elif bou2<bou1:
        al[B-1] = al[B-1]-1
    else:
        al[A-1] = al[A-1]-1
        al[B-1] = al[B-1]-1
print(np.count_nonzero(al==1))

Measured memory_bytes: 45124
N=int(input())
A=[0]*N
B=[0]*N
for i in range(N):
    A[i], B[i]=map(int, input().split())
    
A.sort()
B.sort()

if N%2==1:
    print(B[N//2]-A[N//2]+1)
else:
    print(B[N//2]+B[N//2-1]-A[N//2]-A[N//2-1]+1)

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

using namespace std;

int main()
{
  int r, c, sum;
  sum = 0;
  cin >> r >> c;

  int list[r][c], sum_r[r], sum_c[c];

  for (int i = 0; i < r; i++)
  {
    sum_r[i] = 0;
  }

  for (int i = 0; i < c; i++)
  {
    sum_c[i] = 0;
  }

  for (int i = 0; i < r; i++)
  {
    for (int j = 0; j < c; j++)
    {
      cin >> list[i][j];
    }
  }

  for (int i = 0; i < r; i++)
  {
    for (int j = 0; j < c; j++)
    {
      sum_r[i] += list[i][j];
    }
  }

  for (int i = 0; i < c; i++)
  {
    for (int j = 0; j < r; j++)
    {
      // cout << list[j][i] << endl;
      sum_c[i] += list[j][i];
    }
  }

  for (int i = 0; i < r; i++)
  {
    for (int j = 0; j < c; j++)
    {
      sum += list[i][j];
    }
  }

  for (int i = 0; i <= r; i++)
  {
    for (int j = 0; j <= c; j++)
    {
      if (i == r)
      {
        if (j == c)
        {
          cout << sum << endl;
          ;
          break;
        }
        else
        {
          cout << sum_c[j] << " ";
          continue;
        }
      }

      if (j == c)
      {
        cout << sum_r[i] << endl;
      }
      else
      {
        cout << list[i][j] << " ";
      }
    }
  }
}


Measured memory_bytes: 3136
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
int main(void){
    int i,n,x[100],y[100];
    double p_1=0,p_2=0,p_3=0,p_0=0;
 
    scanf("%d",&n);
     
    for(i=0;i<n;i++)
        scanf("%d",&x[i]);
    for(i=0;i<n;i++)
        scanf("%d",&y[i]);
     
    for(i=0;i<n;i++){
         
    //p=1
        p_1 += abs(x[i]-y[i]);
     
    //p=2
        p_2 += pow(fabs((double)x[i]-y[i]),2.0);
     
    //p=3
        p_3 += pow(fabs((double)x[i]-y[i]),3.0);
     
    //p=endless
        if(p_0 < abs(x[i]-y[i])) p_0 = abs(x[i]-y[i]);
         
    }
     
    printf("%lf\n%lf\n%lf\n%lf\n", p_1, pow(p_2,1.0/2), pow(p_3,1.0/3), p_0);
     
     
    return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
string s;
int a[15], len;
int main(){
    ios::sync_with_stdio(false);
    cin >> s;
    for(int i = 0; i < (int)s.size(); ++i){
        if(s[i] == 66){
            if(len) len--;
        }
        else a[++len] = (s[i] ^ 48);
    }
    for(int i = 1; i <= len; ++i){
        cout << a[i];
    }
    cout << (char)10;
    return 0;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var wh=arr.shift().split(" ").map(Number);
   var w=wh[0];
   var h=wh[1];
   if(w==0 && h==0)break;
   var yx=[];
   for(var i=0;i<h;i++)yx.push(arr.shift().split(" ").map(Number));
   var dp=[];
   for(var i=0;i<h;i++){
      dp[i]=[];
      for(var j=0;j<w;j++){
         dp[i][j]=0;
      }
   }
   for(var i=0;i<h;i++){
      for(var j=0;j<w;j++){
         if(i==0 && yx[i][j]==0)dp[i][j]=1;
         else if(i>=1){
            var a=(j==0 || yx[i-1][j-1]==2)?0:dp[i-1][j-1];
            var b=(yx[i-1][j]==2)?0:dp[i-1][j];
            var c=(j==w-1 ||  yx[i-1][j+1]==2)?0:dp[i-1][j+1];
            var d=(i>=2 && yx[i-2][j]==2)?dp[i-2][j]:0;
            if(yx[i][j]==0)dp[i][j]+=a+b+c+d;
            else if(yx[i][j]==1)dp[i][j]=0;
            else if(yx[i][j]==2)dp[i][j]+=b+d;
         }
      }
   }
   var sum=0;
   for(var i=h-2;i<h;i++){
      for(var j=0;j<w;j++){
         if(h>=2 && i==h-2 && yx[i][j]==2)sum+=dp[i][j];
         if(h>=1 && i==h-1 && (yx[i][j]==0 || yx[i][j]==2))sum+=dp[i][j];
      }
   }
   console.log(sum);
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n,x;cin >>n>>x;
    ll ans=0;
    vector<ll>a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    for (int i = 0; i < n-1; ++i) {
        ll sum=a[i]+a[i+1];
        if(sum<=x)continue;
        if(a[i+1]<sum-x){
            ans+=a[i+1];
            ll c=sum-x;
            c-=a[i+1];
            a[i+1]=0;
            a[i]-=c;
            ans+=c;
        }
        else {
            a[i+1]-=sum-x;
            ans+=sum-x;
        }
    }
    cout <<ans <<endl;
    return 0;
}


Measured memory_bytes: 4052
A, B, C, D = map(int, input().split())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)


CD = lcm(C, D)

#print(CD)

C_count = B//C - (A-1)//C 
D_count = B//D - (A-1)//D
CD_count = B//CD - (A-1)//CD 



#print(C_count, D_count, CD_count)

print(B - A + 1 - C_count - D_count + CD_count)


Measured memory_bytes: 38728
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())

N = II()
A_li = LI()

import fractions
from functools import reduce
from functools import lru_cache

@lru_cache(maxsize=None)
def calc_gcd(a, b):
    return fractions.gcd(a, b)

def gcd_list(numbers):
    if len(numbers) == 0: return None
    elif len(numbers) == 1: return numbers[0]
    else: return reduce(calc_gcd, numbers)

left_gcd = [None,A_li[0]]
prev_gcd = A_li[0]
for i in range(1,N-1):
    prev_gcd = calc_gcd(prev_gcd, A_li[i])
    left_gcd.append(prev_gcd)

right_gcd = [None, A_li[N-1]]
prev_gcd = A_li[N-1]
for i in range(1,N-1):
    prev_gcd = calc_gcd(prev_gcd, A_li[N-1-i])
    right_gcd.append(prev_gcd)
right_gcd.reverse()

print(max([right_gcd[0]]+[calc_gcd(left_gcd[i], right_gcd[i]) for i in range(1,len(A_li)-1)]+[left_gcd[N-1]]))


Measured memory_bytes: 14076
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
class TOPO{//out is tsort's return.
	public:
	vvi G;
	vi out;
	vector<bool>V;
	vi indeg;
	int n;
	TOPO(int size){
		n=size;
		G=vvi(n);
		out=vi(0);
		V=vector<bool>(n);
		indeg=vi(n);
	}
	void add_edge(int s,int t){
		G[s].pb(t);
	}
	void bfs(int s){
		queue<int>q;
		q.push(s);
		V[s]=true;
		while(!q.empty()){
			int u=q.front();q.pop();
			out.pb(u);
			rep(i,G[u].size()){
				int v=G[u][i];
				indeg[v]--;
				if(indeg[v]==0&&!V[v]){
					V[v]=true;
					q.push(v);
				}
			}
		}
	}
	void tsort(){
		rep(i,n)indeg[i]=0;
		rep(i,n)rep(j,G[i].size()){
			int v=G[i][j];
			indeg[v]++;
		}
		rep(i,n)if(indeg[i]==0&&!V[i])bfs(i);
//		rep(i,n)cout<<out[i]<<endl;
	}
};
int main(){
	int n,m;
	cin>>n>>m;
	TOPO topo(n);
	while(m--){
		int a,b;
		cin>>a>>b;
		topo.add_edge(a,b);
	}
	topo.tsort();
	rep(i,n)cout<<topo.out[i]<<endl;
}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

string s;
ll cnt = 0;
bool cch = false;
int ch() {
  if(s[0] != 'A') return false;
  if(s[1] >= 'A' && s[1] <= 'Z') return false;
  FOR(i, 2, s.size() - 1) {
    if(s[i] == 'C') {
      cnt++;
      cch = true;
    } else if(s[s.size() - 1] >= 'A' && s[s.size() - 1] <= 'Z') return false;
  }
  if(s[s.size() - 1] >= 'A' && s[s.size() - 1] <= 'Z') return false;
  if(cnt == 1 && cch == true) return true;
  else return false;
}

signed main() {
  cin >> s;
  if(ch()) cout << "AC" << endl;
  else cout << "WA" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<cmath>
#include<algorithm>
using namespace std;
int n;
long long int k;
long long a[200005],f[200005];
bool cmp(int a,int b)
{
	return a>b;
}
int check(long long mid)
{
	long long cnt=0;
	int i;
	for(i=1;i<=n;i++)
	{
		if(a[i]*f[i]>mid)
		{
			if((a[i]*f[i]-mid)%f[i]==0)cnt+=(a[i]*f[i]-mid)/f[i];
			else cnt+=(a[i]*f[i]-mid)/f[i]+1;
		}
	}
	return cnt<=k?1:0;
}
int main()
{
	cin>>n>>k;
	int i;
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&f[i]);
	}
	sort(a+1,a+n+1);
	sort(f+1,f+n+1,cmp);
	long long l=0,r=1e12,mid;
	while(l<r)
	{
		mid=(l+r)/2;
		if(check(mid))
		{
			r=mid;
		}
		else
		{
			l=mid+1;
		}
	}
	cout<<l;
	return 0; 
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
//↓✟MLE魔、TLE魔✟
#define int long long
//↑✟MLE魔、TLE魔✟
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
signed main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(b/a,c)<<endl;
    return 0;
}

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

int main() {
  int n, m, e, j;
  while(cin >> n, n) {
    for(int i = 0; i < n; i++) {
      cin >> m >> e >> j;
      if(m == 100 || e == 100 || j == 100)
	cout <<	"A" << endl;
      else if(m+e >= 180)
	cout << "A" << endl;
      else if(m+e+j >= 240)
	cout << "A" << endl;
      else if(m+e+j >= 210)
	cout << "B" << endl;
      else if(m+e+j >= 150 && (e >= 80 || m >= 80))
	cout << "B" << endl;
      else
	cout << "C" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3068
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        int sum = Integer.parseInt(buffer.readLine());
        long [] dp = new long[sum+1];
        dp[0] = 1;
        int MOD = (int)1e9 + 7;
        for (int currSum = 1; currSum <= sum; currSum++) {
            for (int firstNum = 3; firstNum <= sum; firstNum++) {
                if (currSum >= firstNum)
                    dp[currSum] = (dp[currSum]%MOD+dp[currSum-firstNum]%MOD)%MOD;
            }
        }
        System.out.println(dp[sum]);
    }
}


Measured memory_bytes: 32652
#include<iostream>
#include<cstdint>
#include<algorithm>
using namespace std; // 575

const int MAX = 100000;
int main() {
	int N;
	static pair<int, pair<int, int> > p[MAX];
	cin >> N;
	for (int i = 0;i < N;++ i) {
		cin >> p[i].second.first >> p[i].second.second;
		p[i].first = -p[i].second.first - p[i].second.second;
	}
	sort(p, p+N);
	int64_t get = 0;
	for (int i = 0;i < N;++ i) {
		if (i & 1) get -= p[i].second.second;
		else get += p[i].second.first;
	}
	cout << get;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

*/

Measured memory_bytes: 1408
#include <stdio.h>
int main ()
{
	int A,B,c;
	scanf("%d %d",&A,&B);
	
	if(A>9||B>9)
	{
		printf("-1\n");
	}
	else
	{
		c=A*B;
		printf("%d\n",c);
	}
	return 0;
}

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

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n,-1) {}
    int findRoot(int x) {
        if (d[x] < 0) return x;
        return d[x] = findRoot(d[x]);
    }
    bool unite(int x, int y) {
        x = findRoot(x); y = findRoot(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x,y); //-d[x] < -d[y]
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return findRoot(x) == findRoot(y);}
    int size(int x) { return -d[findRoot(x)];}
};

int deg[100005];
vector<int> to[100005];

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a,b);
    }
    int ans = 0;
    for(int i = 0;i < n;i++) {
        ans = max(ans, uf.size(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6336
#include <bits/stdc++.h>
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using namespace std;
using pii = pair<int,int>;
using lli = long long;
using pli = pair<lli,int>;
using pll = pair<lli,lli>;
using pdd = pair<double,double>;

int n;
int main() {
    scanf("%d",&n);
    int ans=0;
    for(int i=0;i<n;i++) {
        int v;
        scanf("%d",&v);
        ans ^= v;
    }
    puts(ans ? "No" : "Yes");
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))


#define MOD 1000000007

typedef pair<int,int>P;
#define INF (1<<29)
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

int p[100005];
int n;
int main(){
	scanf("%d ", &n);
	FOR(i,1,n){
		scanf("%d ", &p[i]);
	}
	int ans = 0;
	FOR(i,1,n){
		if (p[i] == i) {///
			swap(p[i], p[i + 1]);
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


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


int main(){
    string str;
    cin >> str;

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

    }

    cout << max << endl;
    
    return 0;
}

Measured memory_bytes: 256
def main():
    N, Y = map(int, input().split())
    if Y == 10000 * N:
        print(N, 0, 0)
        return

    for i in range(N+1):
        tmp = 0
        tmp += 10000 * i
        for j in range(N-i+1):
            _tmp = tmp
            _tmp += 5000 * j
            if (Y - _tmp > 0 and (Y-_tmp) == 1000 * (N-i-j)) or (Y == _tmp and i + j == N):
                print(i, j, N-i-j)
                return

    print(-1, -1, -1)

if __name__ == "__main__":
    main()


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

using namespace std;

using Weight=int;
using DArray=vector<Weight>;
using DMatrix=vector<DArray>;

static const Weight INF=1<<29;

struct Edge {
    size_t src, dst;
    Weight weight;
    Edge() {}
    Edge(size_t src, size_t dst, Weight weight=1):
        src(src), dst(dst), weight(weight)
    {}
};


bool operator<(const Edge &e, const Edge &f) {
    if (e.weight != f.weight) {
        return e.weight > f.weight;
    } else {
        return e.src!=f.src? e.src<f.src : e.dst<f.dst;
    }
}

using Edges=vector<Edge>;
using Vertex=vector<Edge>;
using Graph=vector<Vertex>;

void join(Graph &g, size_t s, size_t d, Weight w=1) {
    // non-directed
    g[s].push_back(Edge(s, d, w));
    g[d].push_back(Edge(d, s, w));
}

void connect(Graph &g, size_t s, size_t d, Weight w=1) {
    // directed
    g[s].push_back(Edge(s, d, w));
}

int main() {
    size_t n;
    scanf("%zu", &n);

    Graph g(n);
    vector<size_t> parent(n, -1);
    for (size_t i=0; i<n; ++i) {
        size_t p, m;
        scanf("%zu %zu", &p, &m);
        for (size_t j=0; j<m; ++j) {
            size_t c;
            scanf("%zu", &c);
            connect(g, p, c);
            parent[c] = p;
        }
    }

    for (size_t i=0; i<n; ++i) {
        printf("node %zu: ", i);
        if (~parent[i]) {
            printf("parent = %zu, ", parent[i]);
        } else {
            printf("parent = -1, ");
        }

        size_t d=0;
        for (size_t j=i; ~parent[j]; j=parent[j])
            ++d;

        printf("depth = %zu, ", d);
        if (!d) {
            printf("root, ");
        } else if (g[i].empty()) {
            printf("leaf, []\n");
            continue;
        } else {
            printf("internal node, ");
        }

        printf("[");
        if (g[i].empty())
            return !printf("]\n");

        for (size_t j=0; j<g[i].size(); ++j)
            printf("%zu%s", g[i][j].dst, j<g[i].size()-1? ", ":"]\n");
    }

    return 0;
}

Measured memory_bytes: 9584
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
using namespace std;
int main() {
	string s;
	cin >> s;
	char f;
	f = s[0];
	int ans = 0;
	for (int i = 1; i < s.size(); i++) {
		if (s[i] != f) {
			ans++;
		}
		f = s[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
import heapq

N,K = (int(x) for x in input().split())
H = list((-1)*(int(x)) for x in input().split())
heapq.heapify(H)
count = 0

for _ in range(K):
    if len(H) == 1:
        print(0)
        break

    heapq.heappop(H)
    count += 1

if len(H) != 1:
    sum = 0
    for _ in range(len(H)):
        sum -= heapq.heappop(H)

    print(sum)

elif len(H) == 1 and K == count:
    print(-heapq.heappop(H))

    

    


Measured memory_bytes: 25768
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
template<typename T, int FAC_MAX> struct Comb { vector<T> fac, ifac;
    Comb(){fac.resize(FAC_MAX,1);ifac.resize(FAC_MAX,1);rep(i,1,FAC_MAX)fac[i]=fac[i-1]*i;
        ifac[FAC_MAX-1]=T(1)/fac[FAC_MAX-1];rrep(i,FAC_MAX-2,1)ifac[i]=ifac[i+1]*T(i+1);}
    T aPb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b]; }
    T aCb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b] * ifac[b]; }
    T nHk(int n, int k) { if (n == 0 && k == 0) return T(1); if (n <= 0 || k < 0) return 0;
        return aCb(n + k - 1, k); }}; // nHk = (n+k-1)Ck : n is separator
typedef ModInt<1000000007> mint;
//------------------------------------------------------------------------------
void _main()
{
    int A, B;
    cin >> A >> B;
    cout << max({A + B, A - B, A * B}) << endl;
}


Measured memory_bytes: 892
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;

int main() {
	int N, M, C;
	cin >> N >> M >> C;

	//長さMの配列を作る。要素を0で初期化する
	vector<int> B(M, 0);
	for (int i = 0; i < M; i++)
	{
		cin >> B[i];
	}


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

		int sum = 0;
		for (int j = 0; j < M; j++)
		{
			int Aij;
			cin >> Aij;
			sum += Aij * B[j];
		}
		sum += C;
		if (sum > 0) ans++;
	}

	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N;
  cin >> N;
  vector <int> A(N);
  rep(i,N) cin >> A[i];
  vector <int> s = A;
  sort(all(s));
  int mx = s[N - 1];
  int second = s[N - 2];
  rep(i,N){
    if (A[i] != mx) cout << mx << endl;
    else cout << second << endl;
  }
  return 0;
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ll A, B; cin >> A >> B;
    ll g = __gcd(A, B);
    ll ans = (A/g) * (B/g) * g;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n ,x) for (int i = x; i < (int)(n); ++i)
#define repB(i, n) for (int i = n; i >= 0; --i)
#define repBX(i, n) for (int i = n; i >= 0; --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    bool flag = false;
    rep(i,N){
        cin >> A[i];
        if(A[i]==1)flag = true;
    }
    if(!flag){
        cout << -1 << endl;
        return 0;
    }
    int last = 0;
    int ans = 0;
    rep(i,N){
        if(last+1!=A[i])ans ++;
        else{
            last = A[i];
        }
    }
    cout << ans << endl;
    
    return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)

static const ll INF = 1e18;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

const ll mod = 1000000007;

ll mpow(ll x, ll n) {
	ll ans = 1; x %= mod;
	while (n != 0) {
		if (n & 1) ans = ans * x % mod;
		x = x * x % mod;
		n = n >> 1;
	}
	return ans;
}

ll inv_mod(ll a) { return mpow(a, mod - 2); }

class Factorial {
private:
	vector<ll> fac;
	vector<ll> ifac;
public:

	Factorial(ll N) {
		fac.push_back(1);
		for (int i = 0; i < N; i++) fac.push_back(fac[i] * (i + 1) % mod);
		ifac.resize(N + 1);
		ifac[N] = inv_mod(fac[N]);
		for (int i = 0; i < N; i++) ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod;
	}

	ll fact(ll a) { return fac[a]; }
	ll ifact(ll a) { return ifac[a]; }

	ll cmb(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		ll tmp = ifact(a - b) * ifact(b) % mod;
		return tmp * fac[a] % mod;
	}
	ll per(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		return fac[a] * ifac[a - b] % mod;
	}
};


int main() {
	ll n;
	cin >> n;
	vector<ll> as(n);
	rep(i, n) cin >> as[i];
	ll minus = 0;
	vector<ll> ab(n);
	rep(i, n) {
		ab[i] = abs(as[i]);
		if (as[i] < 0) {
			minus++;
		}
	}
	sort(ab.begin(), ab.end());
	ll s = ab[0];
	if (minus % 2 == 1) {
		s = -ab[0];
	}
	for (int i = 1; i < n; i++) {
		s += ab[i];
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 4792
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;

  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    int d1, d2;
    cin >> d1 >> d2;
    if (d1 == d2) cnt++;
    else cnt = 0;
    if (cnt == 3) {
      puts("Yes");
      return 0;
    }
  }
  
  puts("No");
  return 0;
}


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

int main(){
	string s, strCopy;
	while ( getline(cin, s) ) {
		for(int j=0 ; j<26 ; j++){
			for(int i=0 ; i<s.size() ; i++){
				if( s[i] >= 'a' && s[i] <= 'z' ){
					s[i] = ( s[i] == 'z' )? 'a' : s[i] + 1;
				}
			}
			if( s.find( "the" ) != string::npos || s.find( "this" ) != string::npos || s.find( "that" ) != string::npos ){
				cout << s << endl;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<iostream>

int main() {
	int x, X, y, Y, z, Z;
	std::cin >> x >> y >> z;
	X = x;
	Y = y;
	Z = z;

	x = Y;
	y = X;

	X = x;

	x = Z;
	z = X;
	std::cout << x << " "<< y << " " << z << " " << std::endl;
}

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

ll dp[100005];

ll ab(ll x,ll y){
	if(x>y)return x - y;
	else return y - x;
}

int main(){
	ll n; cin >> n;
	vl h(n); rep(i,n)cin >> h[i];
	dp[0] = 0;
	dp[1] = ab(h[0],h[1]);
	for(ll i = 2;i<n;i++){
		dp[i] = min(dp[i-2] + ab(h[i],h[i-2]),dp[i-1] + ab(h[i],h[i-1]));

	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
#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-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


int main(){
	while(1){
		int n,k,m;
		cin>>n>>m>>k;
		if(n==0) break;
		vi a(n);
		for(int i=0;i<n;i++) a[i]=i;
		k--;
		a.erase(a.begin()+k);
		for(int i=0;i<n-2;i++){
			int s=a.size();
			k=(k+m-1)%s;
			a.erase(a.begin()+k);
		}
		cout<<a[0]+1<<endl;
	}
}


Measured memory_bytes: 3116
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b) cout<<c;
	if(a==c) cout<<b;
	if(b==c) cout<<a;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        var nab = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nab[0];
        long a = nab[1] - nab[2];
        long b = nab[2];
        var h = Enumerable.Repeat(0, n).Select(_ => long.Parse(Console.ReadLine())).ToArray();
        int valid = int.MaxValue / 2;
        int invalid = 0;
        while (valid - invalid > 1)
        {
            var mid = (valid + invalid) / 2;
            if (h.Sum(x => (Max(0, x - b * mid) + a - 1) / a) <= mid) valid = mid;
            else invalid = mid;
        }
        Console.WriteLine(valid);
    }
}


Measured memory_bytes: 17884
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 max = a + b;
		max = Math.max(max, a-b);
		max = Math.max(max, a*b);
		System.out.println(max);

	}
}


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

int main(){
    int n;
    cin >> n;
    int answer = 0;
    vector<int> a(n);
    for(int &x : a) cin >> x;
    map<int,int> cnt;
    for(int i = 0;i<n;++i) ++cnt[a[i]];
    sort(a.begin(),a.end());
    a.resize(unique(a.begin(),a.end())-a.begin());
    n = a.size();
    for(int i = 0 ;i<n;++i){
       	long long int sum = a[i];
        for(int j = i+1;j<n;++j){
          for(int k = j+1;k<n;++k){
              if(sum + a[j] > a[k]){
                answer += cnt[a[i]]*cnt[a[j]]*cnt[a[k]];
              }
          }
        }
    }
   cout << answer <<"\n";
	return 0;
}

Measured memory_bytes: 3568
#include<cstdio>
int n,k;
double ans;
int s[21];
int main() {
	scanf("%d %d",&n,&k);
	s[0]=1;
	for(int i=1;i<20;i++) s[i]=s[i-1]*2;
	for(int i=1;i<=n;i++) {
		for(int j=19;j>=0;j--) {
			if(1LL*i*s[j]<1LL*k) {
				double l=1.0/s[j+1];
				ans+=1.0/s[j+1];
				break;
			}
		}
	}
	if(n>=k) ans+=(double)(n-k+1);
	printf("%.12lf",ans/n-1e-10);
	return 0;
}

Measured memory_bytes: 1748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll n,m;
    cin>>n>>m;
    priority_queue<ll>q;
    rep(0,i,n){
        ll a;
        cin>>a;
        q.push(a);
    }
    rep(0,i,m){
        ll q0=q.top();q.pop();
        q.push(q0/2);
    }
    ll ans=0;
    rep(0,i,n){
        ans+=q.top();q.pop();
    }
    cout<<ans;
}


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

using namespace std;

const int N = 1e3 + 2;
string a[N];

int main() {
	int h, w; cin >> h >> w;
	int sh, sw, eh, ew; 
	cin >> sh >> sw >> eh >> ew;
	--sh; --sw; --eh; --ew;
	for (int i = 0; i < h; ++i) cin >> a[i];
	
	deque<pair<int, int> > q;
	q.push_front({sh, sw});
	vector<vector<int> > dist(h, vector<int> (w, 1e7));
	dist[sh][sw] = 0;
	while (!q.empty()) {
		auto top = q.front(); q.pop_front();
		int x = top.second, y = top.first;
		for (int i = y - 2; i <= y + 2; ++i) {
			for (int j = x - 2; j <= x + 2; ++j) {
				if (i < 0 || i >= h || j < 0 || j >= w) continue;
				if (i == y && j == x) continue;
				if (a[i][j] == '#') continue;
				int w = 1;
				if ((abs(y - i) == 1 && !(x - j))|| abs(x - j) == 1 && !(y - i)) w = 0;
				if (dist[i][j] > dist[y][x] + w) {
					dist[i][j] = w + dist[y][x];
					if (w) q.push_back({i, j});
					else q.push_front({i, j});
				}
			}
		}
	}
	if (dist[eh][ew] == (int)1e7) cout << -1;
	else cout << dist[eh][ew];
}

Measured memory_bytes: 9436
n = int(input())
x = list(map(int,input().split()))
xs = sorted(x)
mid = xs[n//2]
tmp = n//2
for i, xx in enumerate(x):
    if xx < mid:
        print(mid)
    elif xx > mid:
        if xx == xs[tmp-1]:
            print(xs[tmp-2])
        else:
            print(xs[tmp-1])
    else:

        print(xs[tmp-1])


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

int main() {
   int n;
   cin >> n;
   if (n < 105) cout << 0 << endl;
   else if (n < 135) cout << 1 << endl;
   else if (n < 165) cout << 2 << endl;
   else if (n < 189) cout << 3 << endl;
   else if (n < 195) cout << 4 << endl;
   else cout << 5 << endl;
   
   return 0;
}


Measured memory_bytes: 256
// AOJ ITP 1_5_C
#include<cstdio>
#define rep(i,a) for( int i = 0; i != (a); ++i )

int main()
{
	int H, W;
	while( scanf( "%d%d", &H, &W ), H|W )
	{
		rep( i, H )
		{
			rep( j, W )
				putchar( i&1 ? (j&1 ? '#' : '.') : (j&1 ? '.' : '#') );
			puts("");
		}
		puts("");
	}

	return 0;
}

Measured memory_bytes: 1020
// The moment you think of giving up you have already lost the battle
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
#define Mod 1000000007
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }

    }
}
int main()
{
   ll X;
   cin>>X;
   if(X>=30)
    cout<<"Yes";
   else
    cout<<"No";
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
char a[1002][1002];
int f[1002][1002];
queue<pair<int,int> >q;
int d[5]={-1,1,0,0};
int c[5]={0,0,1,-1};
int n,m;
void BFS(){
    while(!q.empty()){
        int x=q.front().first;
        int y=q.front().second;
        q.pop();
        for(int i=0;i<=3;i++){
            int u=x+d[i];
            int v=y+c[i];
            if((u>=1)&&(u<=n)&&(v>=1)&&(v<=m)&&(a[u][v]=='.')){
                a[u][v]='#';
                f[u][v]=f[x][y]+1;
                q.push(make_pair(u,v));
            }
        }
    }
}
int main(){

    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>a[i][j];
            if(a[i][j]=='#'){
                q.push(make_pair(i,j));
            }
        }
    }
    BFS();
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            ans=max(ans,f[i][j]);
        }
    }
    cout<<ans;
}


Measured memory_bytes: 11280
N = int(input())
a = list(map(int, input().split()))

count = 0 
for i in range(N):
  like = a[i]-1
  if a[i] == -1:
    pass
  elif a[i] != i+1 and a[like] == i+1:
    a[like] = -1
    count += 1

print(count)


  



Measured memory_bytes: 13880
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
// #define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int N = 2e6 + 6;
int A[N];
int B[N];
int n;

#define pi 3.1415926535897932

void solve()
{
	int n;
	cin >> n;

	loop(i,0,n-1)
	{
		cin >> A[i];
		B[A[i]]++;
	}

	loop(i,1,n+1)cout << B[i] << endl;
}
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);

ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	

 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

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

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define forv(i,v) for (auto i = v.begin(); i != v.end(); ++i)
#define forr(i,v) for (auto i = v.end(); i != v.begin() && (--i, 1); )
#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T> inline T abs (T x) {return x > T() ? x : -x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 210;
string c[N];
int n;

const int inf = 1 << 30;

int bfs(int start) {
	queue<int> q;
	q.push(start);
	vi d(n, inf);
	d[start] = 0;
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		forn(i, n) {
			if (c[v][i] == '0') {
				continue;
			}
			if (d[i] == d[v]) {
				return -1;
			}
			if (d[i] == inf) {
				d[i] = d[v] + 1;
				q.push(i);
			}
		}
	}
	return *max_element(all(d));
}

int main () {
	//std::ios::sync_with_stdio(false);
    //std::cin.tie(nullptr);
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
	cin >> n;
	forn(i, n) {
		cin >> c[i];
	}
	int ans = 0;
	forn(i, n) {
		int k = bfs(i);
		if (k < 0) {
			cout << -1 << endl;
			return 0;
		}
		umx(ans, k + 1);
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main() {

    int N, M;
    cin >> N >> M;
    vector<vector<int>> nodes(N);
    for (int i = 0; i < M; ++i) {
        int u, v;
        cin >> u >> v;
        nodes[u - 1].push_back(v - 1);
    }

    vector<array<int, 3>> memo(N, { -1,-1,-1 });

    int S, T;
    cin >> S >> T;

    queue<pair<int, int>> q;
    q.push(make_pair(S - 1, 0));
    memo[S - 1][0] = 0;
    while (!q.empty()) {
        pair<int, int> now = q.front();
        q.pop();
        for (auto& next : nodes[now.first]) {
            int tmp = (now.second + 1) % 3;
            if (memo[next][tmp] != -1)continue;
            memo[next][tmp] = memo[now.first][now.second] + 1;
            q.push(make_pair(next, tmp));
        }
    }
    int ans = memo[T - 1][0];
    if (ans != -1)ans /= 3;
    cout << ans << endl;
}

Measured memory_bytes: 6912
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {

		String s = reader.readLine();
		char[] c = s.toCharArray();
		boolean oddNumber = true;
		boolean evenNumber = true;

		for(int i = 0; i < c.length; i++) {
			//奇数の場合
			if(i%2 == 0){
				if(c[i] == 'L')
					oddNumber = false;
			}
			//偶数の場合
			else{
				if(c[i] == 'R')
					evenNumber = false;
			}
		}

		if(oddNumber && evenNumber){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

		} catch(IOException e) {
			System.out.println(e);
		} 
	}
}

Measured memory_bytes: 23124
#include <iostream>

using namespace std;

int main() {
    string str;
    cin >> str;
    int a = stoi(str.substr(0, 2));
    int b = stoi(str.substr(2, 2));

    if (1 <= b and b <= 12) {
        if (1 <= a and a <= 12) {
            cout << "AMBIGUOUS";
            return 0;
        } else {
            cout<<"YYMM";
            return 0;
        }

    } else{
        if(1<=a and a<=12){
            cout<<"MMYY";
            return 0;
        }
        else
        {
            cout<<"NA";
        }
    }
    return 0;
}

Measured memory_bytes: 256