akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, B, M; cin >> A >> B >> M;
  vector<int> a(A, 0);
  vector<int> b(B, 0);
  vector<int> x(M, 0);
  vector<int> y(M, 0);
  vector<int> c(M, 0);
  int minA = 1e6, minB = 1e6;
  REP(i, A){
    cin >> a[i];
    minA = min(minA, a[i]);
  }
  REP(i, B){
    cin >> b[i];
    minB = min(minB, b[i]);
  }
  int ans = minA + minB;
  REP(i, M){
    cin >> x[i] >> y[i] >> c[i]; x[i]--; y[i]--;
    ans = min(ans, a[x[i]]+b[y[i]]-c[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2176
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<numeric>
#include<cmath>
using namespace std;

int main(void)
{
	int N;
	cin >> N;

	unsigned long long cnt[2];
	cin >> cnt[0] >> cnt[1];

	for(int i=1; i<N; i++)
	{
		int T, A;
		cin >> T >> A;

		unsigned long long n = max((cnt[0]+T-1)/T, (cnt[1]+A-1)/A);
		cnt[0] = T * n;
		cnt[1] = A * n;
	}

	cout << cnt[0] + cnt[1] << endl;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long 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;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	string s;
	cin >> s;
	string sreverse(s.rbegin(),s.rend());
	if (s != sreverse) {
		cout << "No";
		return 0;
	}
	int n = s.size();
	sreverse = s.substr(0, (n - 1) / 2);
	reverse(sreverse.begin(), sreverse.end());

	if (s.substr(0, (n - 1) / 2) != sreverse) {
		cout << "No";
		return 0;
	}
	sreverse = s.substr((n + 1) / 2);
	reverse(sreverse.begin(), sreverse.end());
	if (s.substr((n + 1) / 2) != sreverse) {
		cout << "No";
		return 0;
	}
	cout << "Yes";
 }

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <stdio.h>
#include <string>

int main()
{
	char ch;
	std::string str;
	while (1)
	{
		scanf("%c", &ch);
		if (ch == '\n')
		{
			break;
		}
		if (islower(ch))
		{
			str += (char)toupper(ch);
		}
		else if (isupper(ch))
		{
			str += (char)tolower(ch);
		}
		else
		{
			str += ch;
		}
	}
	printf("%s\n", str.c_str());
	return 0;
}

Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        if (Math.abs(a - c) <= d || (Math.abs(a - b) <= d && Math.abs(b - c) <= d)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 35692
#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 FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

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

ll n, s[100001];

int binarySearch(int t) {
  ll left = 0, right = n, mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (t == s[mid]) return 1;
    if (t > s[mid]) left = mid + 1;
    else if (t < s[mid]) right = mid;
  }
  return 0;
}

signed main() {
	ll result = 0, t, q;
  cin >> n;
  rep(i, n) cin >> s[i];
  cin >> q;
  rep(i, q) {
    cin >> t;
    if (binarySearch(t)) result++;
  }
  cout << result << endl;
}


Measured memory_bytes: 3920
s = input()
t = ""
Q = int(input())

flag = 0
for _ in range(Q):
  A = list(map(str, input().split()))
  if A[0] == "1":
    flag += 1
  else:
    if (int(A[1]) + flag) %2:
      t += A[2]
    else:
      s += A[2]
ans = t[::-1]+s

if flag%2:
  print(ans[::-1])
else:
  print(ans)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for ( int i = 0; i < N; i++ ) {
    cin >> a[i];
  }
  
  int ans = 0;
  long long min = 10000000;
  for ( int i = -100; i <= 100; i++ ) {
    int ANS = 0;
    for ( int j = 0; j < N; j++ ) {
      ANS += ( a[j] - i ) * ( a[j] - i );
    }
    if ( ANS < min ) {
      ans = ANS;
      min = ANS;
    }
  }
  
  cout << ans << endl;
    
  return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(void){
    int N, a[4], i;
    scanf("%d", &N);
    for(i = 0; i < 4; i++){
        a[i] = N % 10;
        N = N /10;
    }
    if((a[0] == a[1] && a[1] == a[2]) || (a[1] == a[2] && a[2] == a[3])) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <algorithm> 
#include <set>
#include <sstream>
#include <bit>
#include <bitset>
#include <iomanip>
#include <queue>
typedef long long int ll;
using namespace std;
int main() {
	string S, T, U; cin >> S >> T;
	int A, B; cin >> A >> B;
	cin >> U;
	if (S == U) {
		cout <<A-1<<" " << B << endl;
	}
	else {
		cout << A << " "<<B-1<<endl;
	}
}

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

int main()
{
    string S,T;
    cin >> S >> T;
    size_t size1 = S.length();
    size_t size2 = T.length();
    T.pop_back();
    if((T == S)&&( size1 + 1 == size2 ))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    
    return 0;
}


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

int main()
{
  int n[3];
  cin >> n[0] >> n[1] >> n[2];

  sort( n, n + 3 );

  cout << n[ 0 ] << " " << n[ 1 ] << " " << n[ 2 ] << endl;

  return 0;
}

Measured memory_bytes: 3136
H, W = [int(x) for x in input().split()]
cell = [['.' for x in range(W + 2)] for y in range(H + 2)]
for y in range(H):
    cell[y + 1][1:-1] = [c for c in input()]

def calc(row, col):
    bomb = 0
    for dx in [0, -1, 1]:
        for dy in [0, -1, 1]:
            if cell[row + dy][col + dx] == '#':
                bomb += 1
    return bomb

for row in range(H):
    for col in range(W):
        if cell[row + 1][col + 1] == '.':
            print(calc(row + 1, col + 1), end='')
        else:
            print('#', end='')
    print()

Measured memory_bytes: 3444
fun main() {
    val input = rsplong()
    val x = input[0]
    val k = input[1]
    val min = when {
        x <= k / 2 -> x
        x < k -> k - x
        x % k > k / 2 -> k - x % k
        else -> x % k
    }
    println(min)
}

fun rl() = readLine()!!
fun rsp() = readLine()!!.split(" ")
fun rint() = readLine()!!.toInt()
fun rspint() = readLine()!!.split(" ").map(String::toInt)
fun rsplong() = readLine()!!.split(" ").map(String::toLong)

fun main(args: Array<String>) = main()

Measured memory_bytes: 37792
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>

int main(void){

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

    // Get input
    std::string s, t; std::cin >> s >> t;

    // Store locations by character
    std::vector<int> locations[26];
    for(int i=0; i<s.length(); i++) locations[s[i] - 'a'].push_back(i);

    // Edge case
    bool t_occurred[26] = {0,};
    for(char ch: t) t_occurred[ch - 'a'] = true;
    for(char c = 'a'; c <= 'z'; c++){
        if(locations[c-'a'].empty() && t_occurred[c-'a']){ // alphabet in s will not appear in t
            //printf("Char %c is invalid\n", c);
            printf("-1\n");
            return 0;
        }
    }

    long long int answer = 0;
    for(int i=0; i<t.length();){
        char ch = t[i];
        int index = std::lower_bound(locations[ch-'a'].begin(), locations[ch-'a'].end(), (int)(answer % s.length())) - locations[ch-'a'].begin();
        if(index == locations[ch-'a'].size()){ // Not found: Return to zero
            answer += s.length() - answer % s.length();
        }
        else{
            answer += locations[ch - 'a'][index] - answer % s.length();
            answer++;
            i++;
            //printf("t[%d] = %c / answer changed to %d(%d), (index = %d)\n", i, ch, answer, answer % s.length(), locations[ch - 'a'][index]);
        }
    }
    std::cout << answer;
    return 0;
}

Measured memory_bytes: 1216
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,b,a) for(i=b-1;i>=(ll)a;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  if(n<r)return 0;
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // int codeforces;cin>>codeforces;while(codeforces--){
  ll N,l,r;
  string s;
  cin>>s;
  N=s.size();
  l=r=N>>1;
  --l;
  if(N&1){
    ++r;
  }else if(s[l]!=s[r]){
    print(r);
    return 0;
  }
  while(~l&&s[l]==s[l+1])--l;
  while(r<N&&s[r]==s[r-1])++r;
  print(min(r,N-l-1));
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    string S,T;cin>>S>>T;
    map<string,int>memo;
    int N=S.size();
    if(N<T.size())cout<<"UNRESTORABLE"<<endl;
    else{
        for(int i=0;i+T.size()<=N;i++){
            bool ok=true;
            for(int j=0;j<T.size();j++){
                if((S[i+j]!=T[j])&&(S[i+j]!='?')){
                    ok=false;
                    break;
                }
            }
            if(ok){
                string ans="";
                REP(j,N){
                    if(S[j]=='?')ans+='a';
                    else ans+=S[j];
                }
                REP(j,T.size())ans[i+j]=T[j];
            	memo[ans]++;
            }
        }  
        if(memo.empty())cout<<"UNRESTORABLE"<<endl;
        else{
            auto it=memo.begin();
            cout<<it->first<<endl;
        }
    }
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n,d;
  cin >> n >> d;
  ll ans = 0;
  vector<vl> x(n,vl(d));
  REP(i,n){
    REP(j,d){
      cin >> x[i][j];
    }
  }
  REP(i,n){
    FOR(j,i+1,n){
      ll dist = 0;
      REP(k,d){
        dist += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
      }
      ll sq = sqrt(dist);
      if(sq*sq==dist) ans++;
    }
  }
  cout << ans<< endl;
  return 0;
}


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

bool d[300000];
int n;

int solve(int i){

  if(i > 2 * n) return 0;  
  if(d[i]) return solve(i+1) + 1;
  else return solve(i+1);

}

int main(){

  memset(d,true,sizeof(d));
  d[0] = d[1] = false;
  for(int i=2;i*i<300000;i++){
    if(d[i]){
      for(int j=i+i;j<300000;j+=i) d[j] = false;
    }
  }

  while(cin >> n, n){
    cout << solve(n+1) << endl;
  }

}

Measured memory_bytes: 1460
input()
d = dict()
while True:
    try:
        s = input()
    except EOFError:
        break
    try:
        d[s] = d[s] + 1
    except KeyError:
        d[s] = 1
m = max(d.values())
d = sorted(d.items(), key=lambda x: x[1], reverse=True)
for i, item in enumerate(d):
    if item[1] < m:
        d = d[:i]
        break
d = sorted(d, key=lambda x: x[0])
for item in d:
    print(item[0])


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

int memo[1111][11][1111];

int solve(int bit, int n, int s){
  
  if(!n && !s) return memo[bit][n][s] = 1;
  if(!n || s < 0) return memo[bit][n][s] = 0;
  if(~memo[bit][n][s]) return memo[bit][n][s];

  int ans = 0;
  for(int i=0;i<10;i++){
    if(!(bit&(1<<i))) ans += solve(bit|(1<<i), n-1, s-i*n);
  }

  return memo[bit][n][s] = ans;
}

int main(){

  int n, s;
  while(cin >> n >> s){
    memset(memo, -1, sizeof(memo));
    cout << solve(0, n, s) << endl;
  }
  
}

Measured memory_bytes: 54204
i = int(input())

taro = 0
hanako = 0
for i in range(i):
    a, b = input().split()

    if a > b:
        taro += 3
    elif a < b:
        hanako += 3
    else:
        taro += 1
        hanako += 1

print(taro, hanako)

Measured memory_bytes: 7532
#include <bits/stdc++.h>
#include <stdio.h>
# define M_PI  3.14159265358979323846
using namespace std;

typedef long long ll;
const int N = 2e5 + 9, M = 9e2 + 9, OO = 0x3f3f3f3f;
const double EPS = 0.00000000001;
const int mod = 1000000000+7;


ll a, b, c, d;

ll gcd(ll a, ll b){
  if (a == 0) return b;
  return gcd(b % a, a);
 }

 ll LCM(ll a, ll b)
 {
    return (a*b)/gcd(a, b);
 }


int main(){

  scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
  ll divisibleC = (b/c) - ((a-1)/c);
  ll divisibleD = (b/d) - ((a-1)/d);
  ll lcm = LCM(c, d);
  ll divisibleLCM = (b/lcm) - ((a-1)/lcm);
  ll total = divisibleC+divisibleD-divisibleLCM;
  printf("%lld\n", (b-a+1)-total);



  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
static_assert(sizeof(long) >= 8, "long too short");

vector<int> adj[100000];
vector<int> data1[100000];

int solvea(int n) {
    int ans = 0;
    for (int i = 0; i < n; i++)
        ans += adj[i].size() % 2;
    return ans / 2;
}

int dfs(int u, int p, int b) {
    auto &v = data1[u];
    v.clear();
    v.reserve(adj[u].size() + 1);

    for (int c : adj[u]) {
        if (c != p) {
            v.push_back(dfs(c, u, b));
        }
    }
    if (adj[u].size() % 2)
        v.push_back(0);
    sort(v.begin(), v.end());

    if (p < 0) {
        int ans = 0;
        for (int i = 0, j = v.size() - 1; i < j; i++, j--)
            ans = max(ans, v[i] + v[j]);
        return ans;
    } else {
        int l = 0, r = v.size();
        while (l < r) {
            int k = (l + r) / 2;
            bool ok = true;
            for (int i = 0, j = v.size() - 1; i < j; i++, j--) {
                if (i == k)
                    i++;
                if (j == k)
                    j--;
                if (i >= j)
                    break;
                if (v[i] + v[j] > b) {
                    ok = false;
                    break;
                }
            }
            if (ok)
                r = k;
            else
                l = k + 1;
        }
        if (r < (int) v.size())
            return v[r] + 1;
        return b + 1;
    }
}

bool checkb(int b) {
    return dfs(0, -1, b) <= b;
}

int solveb(int n) {
    int l = 1, r = n - 1;
    while (l < r) {
        int m = (l + r) / 2;
        if (checkb(m))
            r = m;
        else
            l = m + 1;
    }
    return r;
}

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--, b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    int a = solvea(n);
    int b = solveb(n);
    printf("%d %d\n", a, b);
}


Measured memory_bytes: 20480
n = int(input())
ab = [0] * n
for i in range(n):
    a, b = map(int, input().split())
    ab[i] = (a, b)
ab.sort()

ans = ab[n-1][0] - ab[0][0] + 1
ans += ab[0][0]-1
ans += ab[n-1][1]
print(ans)

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

int main() {
    int N;
    cin >> N;
    int x = N;
    if (N % 2 == 1) x--;
    vector<int> a, b;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            if (j <= i || j == x) continue;
            a.push_back(i);
            b.push_back(j);
        }
        x--;
    }
    cout << a.size() << endl;
    for (int i = 0; i < a.size(); i++) {
        cout << a[i] << " " << b[i] << endl;
    }
}

Measured memory_bytes: 384
h,w=map(int,input().split())
l=[]
l.append(['#' for i in range(w+2)])
for i in range(h):
  l.append(list('#'+input()+'#'))
l.append(['#' for i in range(w+2)])
ctw=0
for i in range(1,h+1):
  for j in range(1,w+1):
    if l[i][j]=='.':ctw+=1
L=[[1,1]]
ct=0
x=0
for i in range(h*w):
  L2=[]
  for j in range(len(L)):
    L3=[[L[j][0]-1,L[j][1]],[L[j][0]+1,L[j][1]],[L[j][0],L[j][1]-1],[L[j][0],L[j][1]+1]]
    for k in range(4):
      if l[L3[k][0]][L3[k][1]]=='.':
        L2.append(L3[k])
        l[L3[k][0]][L3[k][1]]='#'
  ct+=1
  L=L2
  if [h,w] in L:
    x=ct
    break
if x==0:print(-1)
else:print(ctw-ct-1)

Measured memory_bytes: 3064
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,ii,jj;
ll n,m,sum,num=INF;
ll ans;
ll a,b,c,d,e;
ll x[100005],y[100005],z[100005];
ll xa[100005],ya[100005],za[100005];
ll dp[100005];
char s[100005];

int main(){
    cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>a;
		if(a<num){
			num=a;
		}
		m-=a;
	}
	p(n+m/num);
	return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define maxn 5010
#define ull unsigned long long
char str[maxn],ans[maxn];
int n,m,i,j,k,t=0,len;
ull a[10],s,s1;
bool check(int x,int y)
{
	int i;
	for (i=1;i<=t;i++)
		if (a[i]==s) return false;
	if (!len) return true;
	for (i=x;i<=y;i++)
		if (i-x+1>len) return false;
			else if (str[i]<ans[i-x+1]) return true;
				else if (str[i]>ans[i-x+1]) return false;
	return true;
}
void copy(int x,int y)
{
	int i;
	for (i=x;i<=y;i++)
		ans[i-x+1]=str[i];
	ans[i-x+1]=0;
}
int main()
{
	scanf("%s",str+1);
	m=strlen(str+1);
	for (scanf("%d",&n);n;n--)
	{
		len=0;
		for (i=1;i<=m;i++)
		{
			s=0;
			for (j=i;j<=m;j++)
			{
				s=s*10ull+str[j];
				if (check(i,j))
				{
					copy(i,j);
					len=j-i+1;
					s1=s;
				}
			}
		}
		a[++t]=s1;
	}
	printf("%s",ans+1);
	return 0;
}

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

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var p = Input();
		var n = p[0].ToInt();
		double wa = 0;
		for(int i = 0; i < n; i++)
		{
			p = Input();
			if(p[1]=="BTC")
			{
				wa += double.Parse(p[0])*380000;
			}
			else
			{
				wa += p[0].ToLong();
			}
		}
		Console.WriteLine(wa);
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
ll eulerPhi(ll n) {
  if (n == 0) return 0;
  ll ans = n;
  for (ll x = 2; x*x <= n; ++x) {
    if (n % x == 0) {
      ans -= ans / x;
      while (n % x == 0) n /= x;
    }
  }
  if (n > 1) ans -= ans / n;
  return ans;
}
int main(){
    ll n;cin>>n;
    cout<<eulerPhi(n)<<endl;
    return 0;
}


Measured memory_bytes: 3116
n, m, x = map(int, input().split())

books = [list(map(int, input().split())) for _ in range(n)]

ans = 10**10
for j in range(1 << n):
    flg = True
    for i in range(1, m+1):
        x1 = 0
        for k in range(n):
            a = books[k][i]
            if j & (1 << k):
                x1 += a

        if x1 < x:
            flg = False
            break
    if not flg:
        continue

    ans1 = 0
    for k in range(n):
        c = books[k][0]
        if j & (1 << k):
            ans1 += c

    ans = min(ans, ans1)

if ans == 10**10:
    print(-1)
else:
    print(ans)





Measured memory_bytes: 9228
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();
		if ((a * b) % 2 == 0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
	}
}

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

using namespace std;

void rwFile() {
    freopen("INP.inp", "r", stdin);
    freopen("OUT.out", "w", stdout);
}

const int MAXN = 1e5 + 5;
int ans = 0;

vector<int> adj[MAXN];
int trace[MAXN];
int res[MAXN];

void BFS(int s) {
    queue<int> Q;
    res[s] = 0;
    Q.push(s);
    while (!Q.empty()) {
        int u = Q.front();
        Q.pop();
        for (int i : adj[u]) {
            Q.push(i);
            res[i] = max(res[i], res[u] + 1);
            ans = max(ans, res[i]);
        }
    }
}

void Res(int n) {
    for (int i = 1; i <= n; i++) {
        if (trace[i] == 0) {
            BFS(i);
        }
    }
}

vector<int> Topo;
int check[MAXN];

void DFSVisit(int s) {
    check[s] = 1;
    for (int i : adj[s]) {
        if (check[i] == 0) DFSVisit(i);
    }
    Topo.push_back(s);
}

void DFS(int n) {
    for (int i = 1; i <= n; i++) {
        if (check[i] == 0) DFSVisit(i);
    }
    //reverse(Topo.begin(), Topo.end());
}

void solve() {
    int n, m; cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int u, v; cin >> u >> v;
        adj[u].push_back(v);
        trace[v] = 1;
    }
    DFS(n);
    for (int i : Topo) {
        for (int j : adj[i]) {
            res[i] = max(res[i], res[j]);
        }
        res[i]++;
    }
    int RES = 0;
    for (int i = 1; i <= n; i++) RES = max(RES, res[i]);
    cout << RES - 1;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    //rwFile();
    solve();
}


Measured memory_bytes: 9464
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n"
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
    int t;
    string s;
    cin >> t;
    int ac = 0, wa = 0, tle = 0, re = 0;
    while(t--) {
        cin >> s;
        if(s == "AC") {
            ac++;
        } else if(s == "WA") {
            wa++;
        } else if(s == "TLE") {
            tle++;
        } else {
            re++;
        }
    }
    cout << "AC x " << ac << "\n";
    cout << "WA x " << wa << "\n";
    cout << "TLE x " << tle << "\n";
    cout << "RE x " << re << "\n";
}

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


Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

vector<L> tangentLines(C x, C y) {
    P a = x.first, b = y.first;
    double ar = x.second, br = y.second;
    vector<L> ls;
    double d = abs(b-a);

    rep(i,0,2) {
        double sin = (ar - (1-i*2)*br) / d;
        if(!LE(sin*sin, 1)) break;

        double cos = sqrt(max(1 - sin*sin, 0.0));
        rep(j,0,2) {
            P n = (b-a) * P(sin, (1-j*2)*cos) / d;
            ls.push_back(L(a + ar*n, b + (1-i+2)*br*n));
            if(cos < EPS) break; // ??????????????\???????????? (??????????????????????????????????????????)
        }
    }
    return ls;
}

int main() {
    C a, b;
    cin >> a.fr.X >> a.fr.Y >> a.sc >> b.fr.X >> b.fr.Y >> b.sc;
    vector<L> ans = tangentLines(a, b);
    sort(ans.begin(), ans.end());
    rep(i,0,ans.size()) {
        if(abs(ans[i].fr.X) < EPS) ans[i].fr.X = 0.0;
        if(abs(ans[i].fr.Y) < EPS) ans[i].fr.Y = 0.0;
        printf("%.10f %.10f\n", ans[i].fr.X, ans[i].fr.Y);
    }
    return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
typedef pair<int,int> pii;
const int mod = (int) 1000000007;
const int inf = (int) 2e18;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
  cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
  	string n;
  	cin >> n;
  	int num = 0;
  	for(int i=0; i<n.size(); i++){
  	    string s(1, n[i]);
  	    num += stoi(s);
  	}
  	if(num % 9 == 0) cout << "Yes" << "\n";
  	else cout << "No" << "\n";
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_str = vector<string>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


int main()
{
    ll N;
    cin >> N;
    
    mat c(10, vec(10, 0));
    vec d(6, 0);
    ll k;
    REP(i,0,N) {
        ++d[0];
        REP(j,0,6) {
            if(d[j] == 10) {
                d[j] = 0;
                ++d[j+1];
            }
        }
        REP(j,0,6) {
            if(d[5-j] != 0) {
                k = 5 - j;
                break;
            }            
        }
        ++c[d[k]][d[0]];
    }

    ll ans = 0;
    REP(i,1,10) REP(j,1,10) ans += c[i][j] * c[j][i];
    _PR(ans);

    return 0;
}

/*

    A = i####j
    B = j####i

*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mxn 200005
#define mod 1000000007
#define ld long double
#define pb push_back
#define inf 1e18
#define fi first
#define se second
typedef long long int ll;
int bit[130][8];
using  namespace std;
int main(void){
	#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	fast;
	ll n,d,ans=0,x,y,i;
	cin>>n>>d;
	for(i=0;i<n;i++){
		cin>>x>>y;
		ll p=1LL*x*x+1LL*y*y;
		if(p<=d*d)
		ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 3664
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	char a[100];
	char b[100];
	scanf("%s",a);
	scanf("%s",b);
	int lena=0;
	while(a[lena]!=0)lena++;
	int result;
	result=strncmp(a,b,lena);
	if(result!=0)printf("No");
	else printf("Yes");
	return 0;
}

Measured memory_bytes: 3848
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
int n, x; vector<int> G[100009];
int solve(int pos, int pre) {
	vector<int> res;
	for (int i : G[pos]) {
		if (pre == i) continue;
		res.push_back(solve(i, pos));
	}
	sort(res.begin(), res.end(), greater<int>());
	int ret = 0;
	for (int i = 0; i < res.size(); i++) ret = max(ret, res[i] + i + 1);
	return ret;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		scanf("%d", &x); x--;
		G[x].push_back(i);
	}
	int ret = solve(0, -1);
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 15104
H, W, K = map(int,input().split())
C = []
for h in range(H):
    C.append(list(input()))

ans = 0

for h in range(2**H-1):
    for w in range(2**W-1):
        black = 0
        for i in range(H):
            for j in range(W):
                if ((h>>i) & 1) == 0 and ((w>>j) & 1) == 0 and C[i][j] == '#':
                    black += 1
        if black == K:
            ans += 1

print(ans)

Measured memory_bytes: 9116
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;


int main()
{
	int N;
	cin >> N;
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			if (i * j == N) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
using namespace std;
int x, y;
int a, b;
/*
2a + 2b = 2x;
2a + 4b = y;

b = (y - 2x) / 2;
*/
int main() {
	cin >> x >> y;
	if (y < 2 * x) {
		puts("No");
	} else {
		if ((y - 2 * x) % 2) {
			puts("No");
		} else {
			b = (y - 2 * x) / 2;
			a = x - b;
			if (a < 0) puts("No");
			else puts("Yes");
		} 
	}
	
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#define all(x) (x).begin(),(x).end()
typedef long long ll;

using namespace std;

int main(){
    int N, K, j;    cin >> N >> K;
    ll ans = 10000000000000000;
    ll ans1;
    vector<ll> v(N);
    j = 0;
    for(int i=0; i<N; i++){
        cin >> v[i];
    }
    for(int i=0; i<=N-K; i++){
        if(v[i] * v[i+K-1] < 0){
            ans1 = abs(v[i]) + v[i+K-1] + min(abs(v[i]),v[i+K-1]);
        }else if(v[i] * v[i+K-1] == 0){
            ans1 = max(abs(v[i]), v[i+K-1]);
        }else{
            ans1 = max(abs(v[i]), abs(v[i+K-1]));
        }
        ans = min(ans,ans1);
    }
    cout << ans;
}

Measured memory_bytes: 4044
(s=[]
$_.to_i.times{d,p,q=gets.split.map &:to_i
w=d<2?p:1
y=s.rindex{|l|l[q-1,w].any?}||-1
(y+1..(d<2?y+1:y+p)).map{|i|(s[i]||=[$,]*5)[q-1,w]=[1]*w}
s-=[[1]*5]}
p s.flatten.count 1)while gets[0]>?0

Measured memory_bytes: 10020
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
//#define scanf scanf_s
#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple
#define pub push_back
using namespace std;
typedef long long int llint;
const llint one = 1;
const llint big = (one<<30);
const llint mod=1000000007;

/*printf("? %c %c\n",x,y);
		fflush(stdout);
		char ret;scanf(" %c", &ret);
		*/
int main(void){
	int i,j,k,N=200,chousei=7,a,b;
	vector<pair<int,int>> kotae;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		for(j=i+1;j<N;j+=chousei){
			printf("? ");
			for(k=0;k<N;k++){
				if(k==i||(j<=k&&k<j+chousei)){a=1;} else{a=0;}
				printf("%d",a);
			}
			printf("\n");
			fflush(stdout);
			scanf("%d",&a);
			if(a!=0){
				printf("? ");
					for(k=0;k<N;k++){
						if(j<=k&&k<j+chousei){b=1;} else{b=0;}
						printf("%d",b);
					}
				printf("\n");
				fflush(stdout);
				scanf("%d",&b);
				if(a==b){continue;}

				for(k=j;k<min(j+chousei,N);k++){
					printf("? ");
					for(int l=0;l<N;l++){
						if(l==i||k==l){b=1;} else{b=0;}
						printf("%d",b);
					}
				printf("\n");
				fflush(stdout);
				scanf("%d",&b);
				if(b!=0){kotae.pub(mp(i,k));}
				}
			}
		}
	}
	printf("!");
	for(i=0;i<kotae.size();i++){
		printf(" (%d,%d)",kotae[i].first,kotae[i].second);
		
	}
	printf("\n");
	fflush(stdout);
	return 0;
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	string s; cin>>s;
	string ans;
	rep(i,0,s.size()){
		if(s[i]=='0')ans.push_back('0');
		else if(s[i]=='1')ans.push_back('1');
		else if(!ans.empty())ans.pop_back();
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
char s[200005],s1[200005];
int len;
map<char,char>mp,mp1;
int main()
{
	scanf("%s%s",s,s1);
	len=strlen(s);
	for(int i=0;i<len;i++)
	{
		if(mp[s[i]]==0&&mp1[s1[i]]==0)
			mp[s[i]]=s1[i],mp1[s1[i]]=s[i];
		if(mp[s[i]]!=s1[i]||mp1[s1[i]]!=s[i])
		{
			//printf("%d\n",i);
			printf("No");
			return 0;
		}
	}
	printf("Yes");
}

Measured memory_bytes: 640
from collections import deque

def make_wall(maze,h,w):
    maze=deque(maze)
    for i in range(h):
        maze[i]="##"+maze[i]+"##"
    maze.appendleft("#"*(w+4))
    maze.appendleft("#"*(w+4))
    maze.append("#"*(w+4))
    maze.append("#"*(w+4))
    return list(maze)

def bfs(maze, visited, sy, sx, gy, gx):
    queue = deque([[sy, sx]])
    cost[sy][sx]=0
    walk = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    warp = [(i,j) for i in range(-2,3) for j in range(-2,3) if (i,j) not in [(0,0)]+walk]
    
    while queue:
        y, x = queue.popleft()
        if [y, x] == [gy, gx]:
            return cost[y][x]
        
        # 移動A
        for i,j in walk:
            ny, nx = y+i, x+j
            if maze[ny][nx] == "." and cost[ny][nx]>cost[y][x]:
                cost[ny][nx]=cost[y][x]
                queue.appendleft([ny,nx])
            
        # 移動B
        for i, j in warp:
            ny, nx = y+i, x+j
            if cost[ny][nx] > cost[y][x]+1 and maze[ny][nx]==".":
                cost[ny][nx]=cost[y][x]+1
                queue.append([ny,nx])
            
    return -1 #ゴールできない

h,w=map(int,input().split())
sy,sx=map(int,input().split())
gy,gx=map(int,input().split())

maze=[input() for _ in range(h)]

maze=make_wall(maze,h,w)
h+=4
w+=4
sy+=2
sx+=2
gy+=2
gx+=2

INF = 10**12
cost = [[INF]*w for _ in range(h)]

ans=bfs(maze, cost, sy-1, sx-1, gy-1, gx-1)
if ans==INF:
    ans=-1
print(ans)


Measured memory_bytes: 96316
#include <bits/stdc++.h>//復習必須
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
int main (){ 
    ll a , b ;
    cin >> a >> b ;
    cout << a * b << endl;
    return 0 ;
}

 


Measured memory_bytes: 3636
#include <bits/stdc++.h> 
#include <unistd.h>
using namespace std; 
using namespace std::chrono; 
#define ll long long int 

int main() 
{ 
    //freopen("input.txt","r",stdin);
    //freopen("output1.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	string s;
	cin>>s;
	if(s.size()==1){
			cout<<"No"<<endl;
			return 0;
	}
	ll flag=0;
	for(ll i=0;i<s.size();i++){
		if(s[i]=='h'){
			if(s[i+1]=='i'){
					i++;
			}
			else{
				flag=1;
				break;
			}
		}
		else{
			flag=1;
			break;
		}
	}
	if(flag==1)
		cout<<"No"<<endl;
		else
			cout<<"Yes"<<endl;
	return 0;
}


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

using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;
using str = string;
using bl = bool;
using ch = char;

template<class T> using v = vector<T>;
template<class T> using uset = unordered_set<T>;
template<class T1, class T2> using umap = unordered_map<T1, T2>;

template<class T> void pd(T x)
{
    cout << x << " ";
}
template<class T> void pl(T x)
{
    cout << x << endl;
}

#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define sz(x) ((int)(x).size())
#define ph push_back
#define pp pop_back
#define mp make_pair
#define rep(i, a) for(int i = 0; i < (int)a; ++i)
#define repd(i, a) for(int i = (int)a; i >= 0; --i)
#define REP(i, a, b) for(int i = a; i < (int)b; ++i)
#define REPD(i, a, b) for(int i = (int)a; i >= b; --i)
#define fore(i, a) for(auto& i : a)
#define FORE(i, a) for(auto i : a)
#define PI 3.14159265358979323846264338327950L

// -----



int main()
{
    string s;
    int n=0, a=0;
    cin >> s;
    rep(i, 3)
    {
        if(s[i] == 'R') ++a;
        else a=0;
        n=max(a, n);
    }
    pl(n);
}

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

int main() {
    char c;
    cin >> c;

    if(c == 'a' | c == 'i' | c == 'u' | c == 'e' | c == 'o') {
        cout << "vowel" << endl;
    } 
    else 
        cout << "consonant" << endl;
}

Measured memory_bytes: 256
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
#define SZ 10000005
int len[SZ],fail[SZ];
bool can[SZ];
string s,t;
int ans[SZ];
void build(string &p){
	int len=p.size(),j=fail[0]=-1;
	for(int i=1;i<=len;i++){
		while(j>=0&&p[j]!=p[i-1])j=fail[j];
		fail[i]=++j;//if(p[fail[i]-1]==p[i-1])fail[i]=fail[fail[i]];
	}
}
bool kmp(string &_t,string &_s){
	int n=_t.size(),m=_s.size();
	for(int i=0,k=0;i<n;i++){
		while(k>=0&&_s[k]!=_t[i])k=fail[k];
		len[i]=++k;
		if(len[i]==m)can[i]=1;
		else can[i]=0;
	}
	return (*max_element(len,len+n))==m;
}
int main(){
	cin>>s>>t;
	const int size=2*((int)s.size()+t.size());
	while(s.size()<size){
		s=s+s;
	}
	s=s+s;
	build(t);
	kmp(s,t);
//	cerr<<s<<" "<<t<<endl;
//	for(int i=0;i<=s.size();i++){
//		cerr<<i<<" "<<fail[i]<<endl;
//	}
	for(int i=(int)s.size()-1;i>=0;i--){
		if(can[i]){
			ans[i-(int)t.size()+1]=max(ans[i-(int)t.size()+1],ans[i+1]+1);
		}
	}
	int final_ans=*max_element(ans,ans+(int)s.size()+1);
	if(final_ans>=(int)s.size()/t.size()-2){
		puts("-1");
		return 0;
	}
	cout<<final_ans<<endl;
	return 0;
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int p = 0;
    while (p * (p+1) / 2 < n) p++;
    for (int i = 1; i <= p; i++) {
        if (p * (p+1) / 2 == n + i) continue;
        cout << i << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
input =raw_input

N = int(input())

counts = [0] * (N+1)

# x< y < z
x = 1
while True:
    tmp1 = x ** 2
    y = x + 1

    ycount = 0
    while True:
        tmp2 = y ** 2 + x * y
        z = y + 1

        zcount = 0
        while True:
            tmp3 = z ** 2 + x * z + y * z
            n = tmp1 + tmp2 + tmp3
            if n > N:
                break
            else:
                counts[n] += 6
            z += 1
            zcount += 1
        if zcount == 0:
            break
        ycount += 1
        y += 1

    if ycount == 0:
        break
    x += 1

# x < y = z
x = 1
while True:
    tmp1 = x ** 2
    y = x+1
    ycount = 0
    while True:
        z = y
        tmp2 = y ** 2 + z ** 2 + x*y + y*z + z * x
        n = tmp1 + tmp2
        if n > N:
            break
        else:
            counts[n] += 3
        y += 1
        ycount += 1
    if ycount == 0:
        break
    else:
        x += 1
        
# x = y < z
if True:
    x = 1
    while True:
        y = x
        tmp1 = x ** 2 + y ** 2 + x*y

        zcount = 0
        z = y + 1
        while True:
            tmp2 = z ** 2 + y*z + z * x
            n = tmp1 + tmp2
            if n > N:
                break
            else:
                counts[n] += 3
            z += 1
            zcount += 1
        if zcount == 0:
            break
        else:
            x += 1
 
# x = y = z
if True:
    x = 1
    while True:
        n = 6 * (x ** 2)
        if n > N:
            break
        else:
            counts[n] += 1
        x += 1

for c in counts[1:]:
    print(c)


Measured memory_bytes: 94108