akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  int N,A,B; cin>>N>>A>>B;

  if (A+B <= N) cout << min(A,B) << " " << 0 << endl;
  else cout << min(A,B) << " " << A+B-N << endl;
  
  
  return 0;
}

Measured memory_bytes: 256
program main
  implicit none
  
  integer(8) :: n, f, b, fb
  
  read *, n
  
  f = n/3_8
  b = n/5_8
  fb = n/15_8
  
  print *, n*(n+1_8)/2_8 - 3_8*(f*(f+1_8)/2_8) - 5_8*(b*(b+1_8)/2_8) + 15_8*(fb*(fb+1_8)/2_8)
  
  stop
end program main

Measured memory_bytes: 2872
/*

*/
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((ll)(x).size())
#define cin1(x) cin >> x
#define cin2(x, y) cin >> x >> y
#define cin3(x, y, z) cin >> x >> y >> z
#define cin4(x, y, z, _) cin >> x >> y >> z >> _
#define cin5(x, y, z, p, q) cin >> x >> y >> z >> p >> q
#define cou(x) cout << x
#define cous(x) cout << x << " "
#define coul(x) cout << x << "\n"
#define ret(x) return x
#define MAX 5000001
#define start int main() {   fastio
#define finish ret(0); }
#define Test ll _t cin1(_t); rep(i, 0, _t)

struct point{    int x, y, ind;   char ch;  };
typedef long long ll;
typedef vector<ll> VI;
typedef pair<ll,ll> PII;
typedef double db;
//mt19937 mrand(random_device{}());
const ll mod=1000000007;
//ll rnd(ll x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}ret(res);}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll fact[13];
void factorial() {   fact[0]=1;  rep(i, 1, 12) fact[i]=(fact[i-1]*i);  }
vector <ll> sie; //for sieve function
ll spf[MAX+7];  //for sieve function
void sieve() {    rep(i, 2, MAX)  {  if (spf[i] == 0) {  spf[i] = i;   sie.pb(i);  }    for (ll j=0; j<SZ(sie) && i*sie[j] <= MAX && sie[j] <= spf[i]; j++)   spf[i * sie[j]] = sie[j]; }   }
bool cmp(point A, point B){   if(A.x != B.x) ret(A.x < B.x);  ret(A.y < B.y);   }
// head collected

ll q, _, __, re;
string str, s1, s2, s;
char ara_a[55][55];
char ara_b[55][55];

start;

    cin2(str, q);

    while(q--){
        cin1(_);
        if( _ == 1 ){
            re++;
        }
        else{
            cin1(__);
            cin1( s);
            if( re % 2 == 1){
                if( __ == 1)
                    __ = 2;
                else
                     __ = 1;
            }
            if( __ == 1)
                s1 += s;
            else
                s2 += s;
        }
    }

    if( re % 2 == 1) {
        reverse(all(s2));
        reverse(all(str));
        cou(s2);cou(str);
        coul(s1);
    }
    else {
        reverse(all(s1));
        cou(s1);cou(str);
        coul(s2);
    }


finish


/*
rtry
14
1
2 2 s
2 1 d
1
2 1 h
2 2 j
2 2 u
1
2 1 n
1
2 2 b
2 1 b
2 2 n
2 1 n

*/









Measured memory_bytes: 1104
a, b = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# k = int(input())
#p = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# py = [list(map(int, input().split())) for i in range(m)]
# b = list(map(int, input().split()))
print(a*b)


Measured memory_bytes: 9148
//Author:  Pranta
//Date:    2020-Sep-11
//Problem: B_Substring
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
void solve()
{
    string s,t;
    cin>>s>>t;
    int c=0,ans=0;
    for(int i=0;i<=s.size()-t.size();++i){
        c=0;
        for(int j=0;j<t.size();++j){
        if(s[j+i]==t[j]){
            c++;
        }
        }
    ans=max(c,ans); 

    }
    cout<<t.size()-ans;
}
int main()
{
    fast;
    int t;
    //cin>>t;
    //while(t--)
    solve();
}

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

int N;
int A[110];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];

    bool f = true;
    for (int i = 0; i < N; i++) {
        if (A[i] % 2 == 0) {
            if (A[i] % 3 != 0 && A[i] % 5 != 0) {
                f = false;
            }
        }
    }

    cout << (f ? "APPROVED" : "DENIED") << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  for(int i=0;i<N;i++){
    cin >> V.at(i);
  }
  
  sort(V.begin(), V.end());
    reverse(V.begin(), V.end());
  
  int count=1;
  
    for (int i = 1; i < N; i++) {
       if(V.at(i)==V.at(i-1)){
         continue;
       }else{
         count ++;
       }
    }
  cout << count << endl;
}


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

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

    int N;
    cin >> N;
    vector<int> T(N);
    int sum = 0;
    for (auto &x : T) {
        cin >> x;
        sum += x;
    }
    int M;
    cin >> M;
    for (int i = 0; i < M; ++i) {
        int P, X;
        cin >> P >> X;
        cout << sum - T.at(P - 1) + X << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mod 1000000007
#define ar array
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

void init() {
  int n, m;
  cin >> n >> m;
  vi a(m);
  if (n >= m) {
    cout << 0 << endl;
    return;
  }
  for (int &i : a)
    cin >> i;
  sort(all(a));
  vi diff(m - 1);
  for (int i = 1; i < m; i++)
    diff[i - 1] = a[i] - a[i - 1];
  sort(all(diff));
  int ans = 0;
  for (int i = 0; i < m - n; i++)
    ans += diff[i];
  cout << ans << endl;
}
int32_t main() {
  IOS;
  init();
  return 0;
}


Measured memory_bytes: 4728
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
using namespace std;
int main(){
	int H,W;
	cin >> H >> W;
	char a[H][W];
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin >> a[i][j];
		}
	}
	for(int h=0;h<H;h++){
		for(int k=0;k<W;k++){
			cout << a[h][k];
		}
		cout << endl;
		for(int s=0;s<W;s++){
			cout << a[h][s];
		}
		cout << endl;
	}

	

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);++(i))

int main(){
    int N,M,Q,L,R;
    cin>>N>>M>>Q;
    vector<vector<int>> sum(N+1,vector<int>(N+1,0));
    FOR(i,0,M){
        cin>>L>>R;
        ++sum[L][R];
    }

    FOR(i,1,N+1){
        FOR(j,1,N+1){
            sum[i][j] += sum[i-1][j];
            sum[i][j] += sum[i][j-1];
            sum[i][j] -= sum[i-1][j-1];
        }
    }

    FOR(i,0,Q){
        cin>>L>>R;
        cout<<sum[R][R] - sum[R][L-1] - sum[L-1][R] + sum[L-1][L-1]<<endl;
    }
}

Measured memory_bytes: 1920
#include <stdio.h>
int main(void)
{
int H, W, i, j,k;

while(1){
scanf("%d %d",&H, &W);
if(H == 0 && W == 0)break;

	for(i = 0;i < H;i ++){
  		for(j = 0;j < W;j ++){
			k = i + j;
   			if(k % 2 == 0)
				printf("#");
			
			else 
 	   		printf(".");
  }
	
printf("\n");
}

printf("\n");
}
return 0;
}


Measured memory_bytes: 2032
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
#define Maxn 110

int ax[Maxn],ay[Maxn],ah[Maxn];

int mymax(int x,int y) {return x>y?x:y;}

int main()
{
	int n,id;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d%d",&ax[i],&ay[i],&ah[i]);
	for(int i=0;i<=100;i++) if(ah[i]!=0) {id=i;break;}
	for(int i=0;i<=100;i++)
	{
		for(int j=0;j<=100;j++)
		{
			int H=ah[id]+abs(ax[id]-i)+abs(ay[id]-j);
			bool p=1;
			for(int k=1;k<=n;k++)
			{
				if(mymax(H-abs(ax[k]-i)-abs(ay[k]-j),0)!=ah[k])
				{
					p=0;
					break;
				}
			}
			if(p) printf("%d %d %d\n",i,j,H);
		}
	}
	return 0;
}

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

int arr[55];

int main()
{
    int n, mxi=1;
    scanf("%d",&n);
    for(int i=1; i<=n; i++) {
        scanf("%d",&arr[i]);
        if(max(arr[mxi], -arr[mxi]) < max(arr[i], -arr[i])) mxi = i;
    }
    printf("%d\n",2*n);
    if(arr[mxi] < 0) {
        printf("%d %d\n",mxi,n);
        printf("%d %d\n",mxi,n);
        for(int i=n-1; i>=1; i--) {
            printf("%d %d\n",i+1,i);
            printf("%d %d\n",i+1,i);
        }
    }
    else {
        printf("%d %d\n",mxi,1);
        printf("%d %d\n",mxi,1);
        for(int i=2; i<=n; i++) {
            printf("%d %d\n",i-1,i);
            printf("%d %d\n",i-1,i);
        }
    }
    return 0;
}

Measured memory_bytes: 256
import math
X = []
Y = []
N,D = (int(x) for x in input().split())

count = 0
for i in range(N):
  X,Y = (int(x) for x in input().split())
  distance = math.sqrt((X*X + Y*Y))
  if distance <= D:
    count += 1

print(count)

Measured memory_bytes: 9140
//In The Name Of GOD

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;
typedef long double ld ;

const ll mod = 998244353;
const ll inf = 2000000000;
const ll infll = (ll)2*1000*1000*1000*1000*1000*1000;
const ll maxn = 2*1001+1;

#define pb push_back
#define pp pop_back
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);

int main(){
	int n,mx=0,my=-1,ans;
	cin >> n;
	const int m = n;
	int A[m];
	for(int i=0;i<n;i++){
		cin >> A[i];
		mx = max(mx, A[i]);
	}
	for(int i=0;i<n;i++){
		if(A[i]==mx)continue;
		if(my < min(A[i],mx-A[i])){
			my = min(A[i],mx-A[i]);
			ans = A[i];
		}
	}
	cout<<mx<<' '<<ans;
}

Measured memory_bytes: 640
ARGF.each_line do |line|
  h, w = line.split.map(&:to_i)
  break if h == 0 && w == 0
  h.times do |i|
    case i
      when 0, (h - 1)
        puts "#{'#' * w}"
      else
        puts "#" + "." * (w - 2) + "#"
     end
  end
  puts
end

Measured memory_bytes: 6120
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace AGC024B
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(int.Parse);
            var P = ss.Next(int.Parse, N);
            var dp = new int[N + 1];

            foreach (var p in P) dp[p] = dp[p - 1] + 1;
            sw.WriteLine(N - dp.Max());
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 17548
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
 
 
public class Main {
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
		
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		
		List<int[]> lines = new ArrayList<>();
		
		for(int i=0;i<M;i++){
			int k = Integer.parseInt(sc.next());
			int[] line = new int[k];
			for(int j=0;j<k;j++){
				line[j] = Integer.parseInt(sc.next())-1;
			}
			lines.add(line);
		}
		
		int[] P = new int[M];
		for(int i=0;i<M;i++){
			P[i] = Integer.parseInt(sc.next());
		}
		
		int ans = 0;
		for(int i=0; i<(1<<N);i++){
			boolean flag = true;
			for(int j=0;j<M;j++){
				int on = 0;
				for(int k:lines.get(j)){
					if((1&i>>k)==1)on++;
				}
				if(on%2 != P[j]){
					flag = false;
					break;
				}
			}
			if(flag)ans++;
		}
	
		System.out.println(ans);
		
		
		
	}
	
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <list>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <vector>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
// const ll MOD = 1000000009;

#define M 1000000007

#define INF (LLONG_MAX/2)

int main() {
    ll N, MaxW;
    cin >> N >> MaxW;
    vector<ll> W(N), V(N);
    ll sumV = 0;
    ll sumW = 0;
    for (ll i = 0; i < N; ++i) {
        cin >> W[i] >> V[i];
        sumV += V[i];
        sumW += W[i];
    }
    sumW++;

    vector<vector<ll>> dp(N+1, vector<ll>(sumV+1, sumW));
    for (ll i = 0; i < N; ++i) {
        dp[i][0] = 0;
    }
    
    ll res = 0;
    for (ll i = 0; i < N; ++i) {
        for (ll j = 0; j <= sumV; ++j) {
            if (j >= V[i]) {
                dp[i+1][j] = min(dp[i][j], W[i] + dp[i][j-V[i]]);
            }
            dp[i+1][j] = min(dp[i][j], dp[i+1][j]);
        }
    }

    //for (ll i = 0; i <= N; ++i) {
    //    for (ll j = 0; j <= sumV; ++j) {
    //        if (dp[i][j] == sumW) {
    //            cerr <<  "INF, ";
    //        } else {
    //            cerr << dp[i][j] << ", ";
    //        }
    //    }
    //    cerr << endl;
    //}

    for (ll j = 0; j <= sumV; ++j) {
        if (dp[N][j] <= MaxW) res = j;
    }

    cout << res << endl;
}


Measured memory_bytes: 80256
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}

int32_t main()
{
	int t;
	t=1;
	while(t--)
	{
		int n,x,t;
		cin >> n >> x >> t;
		int raj=0,ans=0;
		while(raj<n)
		{
			raj+=x;
			ans+=t;
		}
		cout << ans;
	}
}




Measured memory_bytes: 3628
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int gcd(int x, int y);

const int INF = 1001001001;

//mint�p�̕ϐ� (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }
int n, m, q;
vector<int> a(0);
vector<int> b(0);
vector<int> c(0);
vector<int> d(0);
int ans = -1;

void dfs(vector<int> a_array) {
    if (a_array.size() == n) {
        int num = 0;
        rep(i, q) {
            if (a_array[b[i] - 1] - a_array[a[i] - 1] == c[i])
                num += d[i];
        }
        ans = max(ans, num);
    }
    else {
        int num = 1;
        if (a_array.size() != 0) {
            num = a_array[a_array.size() - 1];
        }
        for (int i = num; i <= m; i++) {
            a_array.emplace_back(i);
            dfs(a_array);
            a_array.erase(a_array.begin() + a_array.size() - 1);
        }
    }
}

int main() {
    cin >> n >> m >> q;
    rep(i, q) {
        int ai, bi, ci, di;
        cin >> ai >> bi >> ci >> di;
        a.emplace_back(ai);
        b.emplace_back(bi);
        c.emplace_back(ci);
        d.emplace_back(di);
    }

    vector<int> a_array(0, 0);
    dfs(a_array);
    cout << ans << endl;
    return 0;
}
/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
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; }
const long long INF = 1LL << 60;

int count(int bit, int n){
    int cnt=0;
    REP(i, n){
        if(bit&1<<i) cnt++;
    }
    return cnt;
}

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

    vector<int> a(N); 
    vector<int> b(N); 
    vector<int> c(N); 

    REP(i,N) cin>>a[i];
    REP(i,N) cin>>b[i];
    REP(i,N) cin>>c[i];

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    
    ll ans = 0;
    REP(idx2, N){
        ll idx1 = lower_bound(a.begin(), a.end(), b[idx2]) - a.begin();
        ll idx3 = c.end()-upper_bound(c.begin(), c.end(), b[idx2]);
        ans += idx1*idx3;
        }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}


 main()

{
    fast
    int n,m;
    cin>>n>>m;
    int ses=(n*(n-1))/2;
    ses+=((m*(m-1))/2);
    cout<<ses<<endl;


















    return 0;

}













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



int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N){
      cin >> A[i];
  }
  bool flag = true;
  rep(i,N){
      if(A[i]%2 == 0){
          if(A[i]%3 != 0 && A[i]%5 != 0){
              flag = false;
              break;
          }
      }
  }
  if(flag) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
L, R = map(int, input().split())
ans = 3000
for i in range(L, R):
  for j in range(i+1, R+1):
    if (i*j)%2019 == 0:
      ans = 0
      break
    else:
      if ans > (i*j)%2019:
        ans = (i*j)%2019
  if ans == 0:
    break
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<math.h>

int main()
{
	long long a,b,c,k;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
	long long sum=0;
	while(k--)
	{
		if(a>0)
		{
			sum++;
		a--;
		}
		else if(b>0)
		{
			b--;
		}
		else
		{
			sum--;
		}
	}
	printf("%lld\n",sum);
	
	
	return 0;
}

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

#define ll     long long
#define fr     first
#define sec    second
#define rep(i,n)  for(i=0;i<n;i++)
#define vi     vector <int>
#define vc     vector <char>
#define vl     vector <ll>
#define vb     vector <bool>
#define pb     push_back
#define M      1000000007
#define ios    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define open   freopen("input.txt","r",stdin);
#define close  freopen("output.txt","w",stdout);
#define M_PI   3.14159265358979323846
#define pp     pair<int,int>
#define nn 100003

int main()
{
    ios;
    ll x,y;
    cin>>x>>y;
    ll m=4*x-y;
    ll n=y-2*x;
    if(m>=0 && n>=0 && m%2==0 && n%2==0)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

int main() {
  int N, K; cin >> N >> K;
  vi h(N); rep(i,N) cin >> h.at(i);
  
  SORT(h);
  
  int ans = 1000000000;
  rep(i,N-K+1) {
    ans = min(ans, h.at(i+K-1)-h.at(i));
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
using static ConsoleApplication.Utils;

namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var line = ReadStrings().ToArray();
            var res = $"A{line[1].First()}C";
            WriteLine(res);
        }
    }

    public static class Utils
    {
        #region Extensions for IO

        public static long ReadLong()
            => ReadLine().ToLong();
        public static int ReadInt()
            => ReadLine().ToInt();

        public static IEnumerable<int> ReadInts()
            => ReadStrings().Select(int.Parse);

        public static IEnumerable<string> ReadStrings()
            => ReadLine().Split(' ');

        public static IEnumerable<string> ReadLines(int n)
        {
            foreach (var i in Enumerable.Range(0, n))
            {
                yield return ReadLine();
            }
        }

        #endregion

        #region Extensions of int

        public static bool IsOdd(this int n)
            => !n.IsEven();

        public static bool IsEven(this int n)
            => n % 2 == 0;

        public static bool CanDivideWith(this int n, int divisor)
            => n % divisor == 0;

        #endregion

        #region Extensions of string

        public static int ToInt(this string str)
            => int.Parse(str);

        public static long ToLong(this string str)
            => long.Parse(str);

        public static double ToDouble(this string str)
            => double.Parse(str);

        public static bool IsNullOrEmpty(this string str)
            => string.IsNullOrEmpty(str);

        #endregion

        public static TSource Min<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
            where TKey : IComparable
            => source.OrderBy(keySelector).First();

        public static TSource Max<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
            where TKey : IComparable
            => source.OrderByDescending(keySelector).First();

        public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
        {
            foreach (var item in source)
            {
                action(item);
            }
        }

        public static IEnumerable<T> Peek<T>(this IEnumerable<T> source, Action<T> action)
        {
            foreach (var item in source)
            {
                action(item);
            }
            return source;
        }
    }
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N, M; cin >> N >> M;
        vector<int> A(M), B(M);
        vector<int> sum(N + 1);
        rep(i, M) {
            cin >> A[i] >> B [i];
            A[i]--; B[i]--;
            if(A[i] > B[i]) swap(A[i], B[i]);
            sum[A[i]]++;
            sum[B[i]]--;
        }
        // debug(sum);
        rep(i, N) sum[i + 1] += sum[i];
        bool ok = true;
        rep(i, N) ok &= sum[i] % 2 == 0;
        // debug(sum);
        cout << (ok ? "YES" : "NO") << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 1408
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;


struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main(){
int N;
cin>>N;
ld p[N+1];
rep3(i,N)cin>>p[i];
ld dp[N+1][N+1];
rep(i,N+1)rep(j,N+1)dp[i][j]=0;
dp[0][0]=1;
rep(i,N+1)rep3(j,N){
    if(i>0){
        dp[i][j]+=p[j]*dp[i-1][j-1];
    }
    dp[i][j]+=(1-p[j])*dp[i][j-1];
}
ld ans=0;
rep4(i,N/2+1,N)ans+=dp[i][N];
cout(12)<<ans<<endl;
}

Measured memory_bytes: 144404
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b)
{
    if (a % b == 0)
    {
        return b;
    }
    else
    {
        return (gcd(b, a % b));
    }
}
long long lcm(long long a, long long b)
{
  return a / gcd(a, b) * b;
}

int main(void)
{
    int N;
    cin >> N;
    long long ans = 1;
    for (int i = 0; i < N; i++)
    {
        long long t;
        cin >> t;
        ans = lcm(ans, t);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lowbit(x) (x&-x)
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int INF=0x3f3f3f3f;
const int MOD=20010905;
const int maxn=1e6+10;
int n,m,b[maxn];
struct segment
{
    int l,r;
}a[maxn];
bool cmp(const segment &x,const segment &y)
{
    return x.r<y.r;
}
void preprocess()
{
    sort(b+1,b+2*n+1);
    m=unique(b+1,b+2*n+1)-(b+1);
    for(int i=1;i<=n;i++)
    {
        a[i].l=lower_bound(b+1,b+m+1,a[i].l)-b;
        a[i].r=lower_bound(b+1,b+m+1,a[i].r)-b;
    }
}
int c[maxn],dp[maxn];
void updata(int x,int v)
{
    for(;x<=m;x+=lowbit(x))
        c[x]=max(c[x],v);
}
int query(int x)
{
    int res=0;
    for(;x;x-=lowbit(x))
        res=max(res,c[x]);
    return res;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int X,L;
        scanf("%d %d",&X,&L);
        b[2*i-1]=a[i].l=X-L;
        b[2*i]=a[i].r=X+L;
    }
    preprocess();
    sort(a+1,a+n+1,cmp);
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        dp[i]=query(a[i].l)+1;
        updata(a[i].r,dp[i]);
        ans=max(ans,dp[i]);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 12928
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int K; cin >> K;
  int even = K / 2;
  int odd = (K + 1) / 2;
  cout << even * odd << endl;
}


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

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  char S1, S2, S3;
  S1 = s1.at(0) + 'A' - 'a';
  S2 = s2.at(0) + 'A' - 'a';
  S3 = s3.at(0) + 'A' - 'a';
  cout << (char)S1 << (char)S2 << (char)S3 << endl;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<random>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#define endl "\n"
#define fi first
#define se second
#define db double
#define gcd __gcd
#define pb push_back
#define mp make_pair
#define lowbit(x) (x & (-x))
#define PII  pair<int, int> 
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << endl
#define rep(i, a, b) for(__typeof(b) i = a; i <= (b); i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i >= (b); i--)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template<class T> inline T qmin(T a, T b) { return a < b ? a : b; }
template<class T> inline T qmax(T a, T b) { return a > b ? a : b; }
typedef long long ll;
typedef unsigned long long ull;
const db eps = 1e-9;
const db PI = acos(-1);
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e5 + 5;//remember to modify it, No RE or MLE
const ll INF = 0x3f3f3f3f3f3f3f3f;
using namespace std;

int n;
vector<int> G[maxn];
ll dp[maxn][2];

void mul(ll &a, ll b){
	a = (a * b) % mod;
}

void dfs(int u, int fa){
	int len = G[u].size();
	rep(i, 0, len - 1){
		int v = G[u][i];
		if(v == fa) continue;
		dfs(v, u);
		mul(dp[u][0], dp[v][1]);
		mul(dp[u][1], dp[v][1] + dp[v][0]);
	}
}

int main()
{
	scanf("%d", &n);
	rep(i, 1, n - 1){
		int u, v; scanf("%d %d", &u, &v);
		G[u].pb(v);
		G[v].pb(u);
	}
	rep(i, 1, n) dp[i][0] = dp[i][1] = 1;
	dfs(1, 0);
	printf("%d\n", (dp[1][0] + dp[1][1]) % mod);
	return 0;
}

Measured memory_bytes: 14208
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= (ll) b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const int MAX= 1e6+100;


ll re[MAX];
map<ll,ll> m;
int main(){
	fastio;
	ll tc,n,dig=1;
	string s;
	cin>>s;
	s+="0";
	reverse(all(s));
	f(i,1,s.size()){
		re[i] = (re[i-1] + (s[i]-'0')*dig)%2019;
		dig = (dig*10)%2019;
	}
	ll ans=0;
	af(i,s.size()-1,0){
		ans+= m[re[i]];
		m[re[i]]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5308
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 1e9+7;

ll add(ll a,ll b)
{
	a%=MOD; b%=MOD;
	a+=b;a%=MOD;
	if(a<0) a+=MOD;
	return a;
}
ll mult(ll a, ll b)
{
	a%=MOD; b%=MOD;
	ll ans=(a*b)%MOD;
	if(ans<0) ans+=MOD;
	return ans;
}

ll eval(ll l, ll r){
	return (r+l)*(r-l+1)/2;
}

const int MAXN = 200005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	ll n,K; cin>>n>>K;
	ll ans=0;
	for(int i=K;i<=n;i++){
		ans=add(ans, eval(n-i+1,n)-eval(0,i-1)+1);
	}
	cout<<(ans+1)%MOD<<'\n';
	
	return 0;
}


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


signed main(){

    std::vector<int> v(2);
    int i=0;

    std::cin >> v[0] >> v[1];

    int area, perimeter;

    area = v[0] * v[1];
    perimeter = 2 * v[0] + 2 * v[1];

    std::cout << area << " " << perimeter << std::endl;

    return 0;

}


Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadString()
	sum := 0
	for i := 0; i < len(N); i++ {
		sum += int(N[i] - '0')
	}
	if sum%9 == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

int main() {
  int n,sum=0,M=0;
  int l[15];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> l[i];
    sum += l[i];
    M = max(M, l[i]);
  }
  if(M < sum-M) cout << "Yes";
  else cout << "No";
  return 0;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7
INF = 10 ** 12
import sys
sys.setrecursionlimit(1000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))

    subarray = []
    for i in range(n):
        subarray.append(a[i])
        sub = a[i]
        for j in range(i - 1,-1,-1):
            sub += a[j]
            subarray.append(sub)
    
    for bit in range(50,-1,-1):
        next = []
        for sub in subarray:
            if (sub>>bit)&1:
                next.append(sub)
        if len(next) >= k:
            subarray = next
    
    ans = subarray[0]
    for i in range(1,len(subarray)):
        ans &= subarray[i]
    print(ans)   
if __name__ =='__main__':
    main()  

Measured memory_bytes: 27696
n = int(input())
a = list(map(int, input().split()))
b = 0
c = True
cnt = 1
for i in range(len(a)):
    if b == 0:
        b += 1
    else:
        if b == 1:
            if a[i] > a[i-1]:
                c = True
                b += 1
            elif a[i] < a[i-1]:
                c = False
                b += 1
        else:
            if c:
                if a[i] < a[i-1]:
                    cnt += 1
                    b = 1
            else:
                if a[i] > a[i-1]:
                    cnt += 1
                    b = 1
print(cnt)


Measured memory_bytes: 14252
#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>;

char s[1009][1009];

int dist[1009][1009];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main() {
  int h, w;
  cin >> h >> w;
  int ch, cw, dh, dw;
  cin >> ch >> cw >> dh >> dw;
  --ch; --cw; --dh; --dw;
  rep(i, h) rep(j, w) cin >> s[i][j];

  rep(i, h) rep(j, w) dist[i][j] = -1;

  queue<P> Q, R;
  dist[ch][cw] = 0;
  Q.push(make_pair(ch, cw));

  while (Q.size()) {
    while (Q.size()) {
      P p = Q.front(); Q.pop();
      int x = p.first, y = p.second;
      R.push(make_pair(x, y));
      rep(i, 4) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
        if (s[nx][ny] == '#' || dist[nx][ny] != -1) continue;
        dist[nx][ny] = dist[x][y];
        Q.push(make_pair(nx, ny));
        R.push(make_pair(nx, ny));
      }
    }

    while (R.size()) {
      P p = R.front(); R.pop();
      int x = p.first, y = p.second;
      for (int dx = -2; dx <= 2; ++dx) {
        for (int dy = -2; dy <= 2; ++dy) {
          int nx = x + dx;
          int ny = y + dy;
          if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
          if (s[nx][ny] == '#' || dist[nx][ny] != -1) continue;
          dist[nx][ny] = dist[x][y] + 1;
          Q.push(make_pair(nx, ny)); 
        }
      }
    }

    // rep(i, 50) printf("-");
    // printf("\n");
    // rep(i, h) {
    //   rep(j, w) printf("%2d", dist[i][j]);
    //   printf("\n");
    // }
  }
  // rep(i, h) {
  //   rep(j, w) cout << dist[i][j];
  //   cout << endl;
  // }
  cout << dist[dh][dw] << endl;
  return 0;
}

Measured memory_bytes: 8516
odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']
S = list(input())
for i in range(len(S)):
  if i % 2 == 0 and S[i] not in odd:
    print('No')
    exit()
  elif i % 2 == 1 and S[i] not in even:
    print('No')
    exit()

print('Yes')

Measured memory_bytes: 3060
"""
中途半端にとく問題は一種類のみで良い。
全探索で全ての点数帯について、ボーナスをとるか・一問もとかないかで全探索
もし点がGに満たない場合は一番点が高いものを解く。
"""
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

ans = float("inf")

for bit in range(1 << d):  #2^d通り試す
    count = 0
    sum = 0
    rest = list(range(1, d + 1))  #一問も解いていない点数帯の集合

    for i in range(d):
        if bit & (1 << i):
            sum += pc[i][0] * (i + 1) * 100 + pc[i][1]
            count += pc[i][0]
            rest.remove(i + 1)

    # G 点に満たなければ nokori のうち一番大きいものを解く
    if sum < g:
        use = max(rest)
        n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))  ##全部解いても足りないかもしれない。-(-a//b))で切り上げをしている。
        count += n
        sum += n * use * 100

    if sum >= g:
        ans = min(ans, count)

print(ans)

Measured memory_bytes: 9012
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int main(){
  int N;  cin >> N;
  int H[100000];
  REP(i, N) cin >> H[i];
  PERS(i, N-1){
    int diff = H[i]-H[i-1];
    if(diff >= 0) continue;
    if(diff == -1){
      H[i-1]--;
      continue;
    }
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 640
#include <cstdio>

int main()
{
  int n, x;
  scanf("%d %d", &n, &x);
  int ans = 1;
  int sum = 0;
  for (int i = 0; i < n; ++i)
  {
    int l;
    scanf("%d", &l);
    sum += l;
    if (sum <= x) ++ans;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
let s = stdin.ReadLine()
let n = s |> Seq.length
let rec f i p =
    if i<=0 then p+i+2
    elif s.[i]=s.[i-1] then f (i-3) (p+2)
    else f (i-1) (p+1)
f (n-1) -1 |> stdout.WriteLine

Measured memory_bytes: 14036
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		final String CASE = "Case ";
		int count = 0;
		while (true) {
			count++;
			int i = scanner.nextInt();
			if (i == 0)
				break;
			System.out.println(CASE+count+": "+i);
		}
		scanner.close();
	}
}

Measured memory_bytes: 31360
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

int n, K;
LL MOD = 1000000007;
LL dp[55][55][5200];

void solve() {
  cin >> n >> K;
  dp[1][0][0] = 1;
  dp[1][1][2] = 1;
  FOR(i, 1, n) REP(j, i+1) REP(k, K+10) {
    LL now = dp[i][j][k];
    dp[i+1][j+1][k+j*2+2] = (dp[i+1][j+1][k+j*2+2] + now) % MOD;
    dp[i+1][j][k+j*2] = (dp[i+1][j][k+j*2] + (now*(j*2+1))%MOD) % MOD;
    if(j > 0) {
      dp[i+1][j-1][k+(j-1)*2] = (dp[i+1][j-1][k+(j-1)*2] + (now*j*j)%MOD) % MOD;
    }
  }
  // FOR(i, 1, n+1) REP(j, n+1) REP(k, K+10) {
  //   if(dp[i][j][k] > 0) {
  //     cout << i << " " <<  j << " " << k << endl;
  //     OUT(dp[i][j][k]);
  //   }
  // }
  cout << dp[n][0][K] << endl;
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 112896
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

int main() {
  double n, l;
  cin >> n >> l;
  //  vector<int> val(n);
  // rep(i, n) << val.push_back(l + i);
  double sum = (2 * l + n - 1) * n / 2;  // 1~n
  if (l >= 0) {                          // all +
    cout << sum - l;
  } else if (l < 0 && l + n - 1 > 0) {
    cout << sum;
  } else {
    cout << sum - (l + n - 1);
  }

  return 0;
}


Measured memory_bytes: 256