akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> bool chmax(T &a, U b) { if (a < b) a = b; return true; }
template<class T, class U> bool chmin(T &a, U b) { if (a > b) a = b; return true; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  ll n, m, k; cin >> n >> m >> k;
  vll a(n), b(m);

  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];

  vll sum_a(n+1, 0), sum_b(m+1, 0);
  rep(i, n) sum_a[i+1] += sum_a[i] + a[i];
  rep(i, m) sum_b[i+1] += sum_b[i] + b[i];

  ll ans = 0;
  int idx = m;

  rep(i, n+1) {
    ll tmp = k - sum_a[i];

    if (tmp < 0) continue;

    while (sum_b[idx] > tmp) --idx;
    chmax(ans, i+idx);
  }

  cout << ans << endl;

  return (0);
}


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

int main() {
  std::int_fast64_t n, m;
  std::cin >> n >> m;

  std::vector<std::vector<std::int_fast64_t>> outbounds = std::vector<std::vector<std::int_fast64_t>>(n, std::vector<std::int_fast64_t>());
  std::vector<std::pair<std::int_fast64_t, std::int_fast64_t>> edges;
  edges.reserve(m);
  for (std::int_fast64_t i = 0; i < m; ++i) {
    std::int_fast64_t a_i, b_i;
    std::cin >> a_i >> b_i;
    --a_i;
    --b_i;
    outbounds[a_i].push_back(b_i);
    outbounds[b_i].push_back(a_i);
    edges.push_back(std::make_pair(a_i, b_i));
  }

  std::int_fast64_t answer = 0;
  for (const std::pair<std::int_fast64_t, std::int_fast64_t>& edge : edges) {
    std::unordered_set<std::int_fast64_t> visitable_set({edge.first});
    std::vector<std::int_fast64_t> visitable_vector({edge.first});
    for (std::int_fast64_t i = 0; i < static_cast<std::int_fast64_t>(visitable_vector.size()); ++i) {
      const std::int_fast64_t from = visitable_vector[i];
      for (const std::int_fast64_t& to : outbounds[from]) {
        if ((from == edge.first && to == edge.second) || (from == edge.second && to == edge.first)) continue;
        if (visitable_set.find(to) != visitable_set.end()) continue;
        if (to == edge.second) goto FOUND_ANOTHER_PATH;
        visitable_set.insert(to);
        visitable_vector.push_back(to);
      }
    }
    ++answer;
  FOUND_ANOTHER_PATH:
    ;
  }

  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
const double EPS = 1e-9;
#define INF (1LL<<60)
#define fs first
#define sc second
#define D double
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int n;
void solve(){
  int ans = 0, bot = 0;
  FOR(i,1,n+1){
    int tmp = n - i*(i-1)/2;
    if(tmp <= 0) break;
    if(tmp % i == 0) ans = i, bot = tmp/i;
  }
  cout << bot SP ans << endl;
}

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

  while(cin >> n,n) solve();

  return 0;
}


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

int main(void){
    int x,y,z;
        cin >> x;
        cin >> y;
        cin >> z;
        if (x <= y && y <= z) {
            cout << x << " " << y << " " << z << endl;
        }
            else if (x <= z && z <= y) {
            cout << x << " " << z << " " << y << endl;
        }
        else if (y <= x && x <= z) {
        cout << y << " " << x << " " << z << endl;
        }
        else if (y <= z && z <= x) {
            cout << y << " " << z << " " << x << endl;
        }
        else if (z <= y && y <= x) {
            cout << z << " " << y << " " << x << endl;
        }
        else{
            cout << z << " " << x << " " << y << endl;
        }
}


Measured memory_bytes: 3080
A, B, K = map(int, input().split())
mitasu_seisu = []
for i in range(A, min(A + K, B)):
    mitasu_seisu.append(i)
for j in range(max(A, B - K + 1), B + 1):
    mitasu_seisu.append(j)
for k in sorted(set(mitasu_seisu)):
    print(k)

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    public static void Main()
    {


        var n = long.Parse(Console.ReadLine());
        var d = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

        List<long> list = new List<long>(d);

        long ans = 0;

        if (n % 2 == 1)
        {
            ans = 0;
        }
        else
        {
            list.Sort();

            if(list.ElementAt((int)((n / 2) - 1)) == list.ElementAt((int)(n / 2)))
            {
                ans = 0;
            }
            else
            {
                ans = list.ElementAt((int)(n / 2)) - list.ElementAt((int)((n / 2) - 1));
            }
        }



        Console.WriteLine(ans);

    }
}

Measured memory_bytes: 22240
#include<stdio.h>
int main()
{
    long long int a,b,c,d,m1,m2,t,d1,d2;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    d1=a*c;d2=a*d;
    if(d1>d2)m1=d1;
    else m1=d2;
    d1=b*c;d2=b*d;
    if(d1>d2)m2=d1;
    else m2=d2;
    if(m1>m2)printf("%lld",m1);
    else printf("%lld",m2);
}


Measured memory_bytes: 1736
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
ll MOD = 1000000007;

int main() {
	ll N, M; cin >> N;
	map<string, int> b;
	map<string, int> r;
	string B[100];

	rep(i, 0, N) {
		string z;
		cin >> z;
		b[z]++;
		B[i] = z;
	}
	cin >> M;
	rep(i, 0, M) {
		string z;
		cin >> z;
		r[z]++;
	}
	ll maxV = 0;
	rep(i, 0, N) {
		ll t = b[B[i]] - r[B[i]];
		if (maxV < t) {
			maxV = t;
		}
	}
	if (maxV < 0) {
		maxV = 0;
	}
	cout << maxV << endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <set>
#include <iostream>

struct segment_tree {
    void build(std::string const &a) {
        t.resize(4 * a.size());
        build(0, 0, a.size(), a);
    }

    void update(size_t pos, char new_value) {
        update(0, 0, t.size() / 4, pos, new_value);
    }

    int32_t get(size_t l, size_t r) {
        return get(0, 0, t.size() / 4, l, r + 1).size();
    }

private:
    std::vector<std::set<char>> t;
    void build(size_t v, size_t l, size_t r, std::string const &a) {
        if (l + 1 == r) {
            std::set<char> m;
            m.insert(a[l]);
            t[v] = m;
        } else {
            size_t mid = (l + r) / 2;
            build(2 * v + 1, l, mid, a);
            build(2 * v + 2, mid, r, a);
            for (auto elem : t[2 * v + 1]) {
                t[v].insert(elem);
            }
            for (auto elem : t[2 * v + 2]) {
                t[v].insert(elem);
            }
        }
    }

    void update(size_t v, size_t l, size_t r, size_t pos, char new_value) {
        if (l + 1 == r) {
            std::set<char> m;
            m.insert(new_value);
            t[v] = m;
        } else {
            size_t mid = (l + r) / 2;
            if (pos < mid) {
                update(2 * v + 1, l, mid, pos, new_value);
            } else {
                update(2 * v + 2, mid, r, pos, new_value);
            }
            t[v].clear();
            for (auto elem : t[2 * v + 1]) {
                t[v].insert(elem);
            }
            for (auto elem : t[2 * v + 2]) {
                t[v].insert(elem);
            }
        }
    }

    std::set<char> get(size_t v, size_t l, size_t r, size_t req_l, size_t req_r) {
        if (req_l >= req_r) {
            return std::set<char> ();
        } else if (l == req_l && r == req_r) {
            return t[v];
        } else {
            size_t mid = (l + r) / 2;
            std::set<char> cur = get(2 * v + 1, l, mid, req_l, std::min(mid, req_r));
            for (auto elem : get(2 * v + 2, mid, r, std::max(mid, req_l), req_r)) {
                cur.insert(elem);
            }
            return cur;
        }
    }
};

int main() {
    std::ios_base::sync_with_stdio(false);
    segment_tree chr;
    size_t n;
    std::cin >> n;
    std::string a;
    std::cin >> a;
    chr.build(a);
    size_t k;
    std::cin >> k;
    while (k-- > 0) {
        size_t type;
        std::cin >> type;
        if (type == 1) {
            size_t pos;
            char ch;
            std::cin >> pos >> ch;
            chr.update(pos - 1, ch);
        } else {
            size_t l, r;
            std::cin >> l >> r;
            std::cout << chr.get(l - 1, r - 1) << '\n';
        }
    }

    return 0;
}


Measured memory_bytes: 233756
import java.util.*

fun main(args: Array<String>) {
    Scanner(System.`in`).use { sc ->
        val a = sc.nextInt()
        val b = sc.nextInt()
        val c = sc.nextInt()
        val d = sc.nextInt()

        println(Math.max(Math.min(b, d) - Math.max(a, c), 0))
    }
}


Measured memory_bytes: 31144
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

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

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n,k;
  cin>>n>>k;
  vector<bool> have(n+1,false);
  for(int i=0;i<k;i++){
    int d;
    cin>>d;
    for(int j=0;j<d;j++){
      int a;
      cin>>a;
      have[a]=true;
    }
  }

  int result=0;
  for(int i=1;i<=n;i++){
    if(!have[i]){
      result++;
    }
  }
  cout<<result<<endl;

  return 0;
}




Measured memory_bytes: 3656
#110_B
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
flg=True
if max(x)>=min(y) or X>=Y:
    flg=False
elif min(y)<=X or Y<=max(x):
    flg=False
print('No War' if flg else 'War')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=2e5+10;
int a[maxn],f[maxn];
int n,k;
int check(int x){
    int ans=0;
    for(int i=1;i<=n;++i){
        int tmp=a[i]*f[n-i+1]-x;
        if(tmp>0){
            ans+=(tmp-1)/f[n-i+1]+1;
        }
    }
    return ans;
}
main(){
    scanf("%lld%lld",&n,&k);
    for(int i=1;i<=n;++i){
        scanf("%lld",&a[i]);
    }
    for(int i=1;i<=n;++i){
        scanf("%lld",&f[i]);
    }
    sort(a+1,a+n+1);
    sort(f+1,f+n+1);
    int l=0,r=f[n]*a[n];
    while(l<=r){
        int mid=(l+r)>>1;
        if(check(mid)<=k)r=mid-1;
        else l=mid+1;
    }
    cout<<l<<endl;
}


Measured memory_bytes: 3328
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//スペルミスに注意
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n%M) * (f(n - 1) % M);
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

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

	ll ans = 0;
	for (ll n = K; n <= N+1; n++) {
		ll l = (n - 1)*n / 2;
		ll g = n * (2 * N + (n - 1) * (-1)) / 2;
		ans += (g - l + 1);
	}

	cout << ans %M<< endl;
}

Measured memory_bytes: 11024
import sys
inputs = sys.stdin.readlines()

from collections import Counter

N = int(inputs[0])
a_list = list(map(int, inputs[1].split()))

def check(N, a_list):
    mc = Counter(a_list).most_common()
    n = len(mc)
    if n == 1:
        if mc[0][0] == 0:
            print('Yes')
            return
    elif n == 2:
        if mc[0][1] == 2*N // 3 and mc[1][0] == 0:
            print('Yes')
            return
    elif n == 3:
        if mc[0][1] == mc[1][1] == mc[2][1] and mc[0][0] ^ mc[1][0] ^ mc[2][0] == 0:
            print('Yes')
            return
    print('No')

check(N, a_list)

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

int main(){
    int N,M;
    cin >> N >> M;
    int S[N]; for (int i = 0; i < N; i++) S[i] = -1;
    for (int i = 0; i < M; i++) {
        int s,c; cin >> s >> c;
        if (N != 1 && s == 1 && c == 0) {
            cout << -1;
            return 0;
        }
        if (S[s-1] == -1) {
            S[s-1] = c;
        } else if (S[s-1] != c) {
            cout << -1;
            return 0;
        }
    }
    if (N == 1) {
        cout << ((S[0] == -1) ? 0 : S[0]);
    } else {
        cout << ((S[0] == -1) ? 1 : S[0]);
        for (int i = 1; i < N; i++) {
            cout << ((S[i] == -1) ? 0 : S[i]);
        }
        return 0;
    }
}

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

using namespace std;

int main() {
  int N, D; cin >> N >> D;
  vector<vector<int>> X(N, vector<int>(D));
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < D; j++) {
      cin >> X[i][j];
    }
  }

  int cnt = 0;
  for(int i = 0; i < N; i++) {
    for(int j = i+1; j < N; j++) {
      long long distance = 0;
      for(int k = 0; k < D; k++) {
        distance += pow(X[i][k] - X[j][k], 2);
      }
      long long sqrt_dist = sqrt(distance);
      if(distance == sqrt_dist * sqrt_dist) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,m;cin>>n>>m;
    map<int,vector<int > > mp;
    for(int i=0;i<m;i++)
    {
        int k,h; scanf("%d %d",&k,&h);
        mp[k].push_back(h);
        mp[h].push_back(k);
        
    }
    for(int i=1;i<=n;i++)
    {
        sort(mp[i].begin(),mp[i].end());
        unique(mp[i].begin(),mp[i].end());
        cout<<mp[i].size()<<"\n";
    }
    
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int i = sc.nextInt();
		
		if(i < 1200)
			System.out.println("ABC");
		else if(i < 2800)
			System.out.println("ARC");
		else
			System.out.println("AGC");
	}
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

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

  string s;
  cin >> s;
  if(s[0]=='7' || s[1] =='7'||s[2]=='7'){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3652
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first.first
#define yy first.second
#define __V vector
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace __gnu_pbds;
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifdef LOCALc
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
template<typename T, typename l>
void getv(T& a, int n, l f) {
	a.resize(n);
	for (auto& i : a)
		cin >> i, f(i);
}
template<typename T>
void getv(T& a, int n) {
	a.resize(n);
	for (auto& i : a)
		cin >> i;
}
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int dp[3100][3100], p[3100][3100];
string S, T;

int f(int i, int j) {
	if (dp[i][j] != -1)
		return dp[i][j];
	if (i == S.size() || j == T.size())
		return 0;
	int& ans = dp[i][j];
	int t;
	ans = INT_MIN;
	if (S[i] == T[j]) {
		t = 1 + f(i + 1, j + 1);
		if (t > ans) {
			ans = t;
			p[i][j] = 3;
		}
	}
	t = f(i + 1, j);
	if (t > ans) {
		ans = t;
		p[i][j] = 1;
	}
	t = f(i, j + 1);
	if (t > ans) {
		ans = t;
		p[i][j] = 2;
	}
	return ans;
}

void bt(int i, int j) {
	if(i == S.size() || j == T.size())
		return;
	if(p[i][j] == 1)
	{
		bt(i+1, j);
	} else if(p[i][j] == 2) {
		bt(i, j+1);
	} else {
		cout << T[j];
		bt(i+1, j+1);
	}
}

int main() {
	doin();
	for (int i = 0; i < 3100; i++)
		for (int j = 0; j < 3100; j++)
			dp[i][j] = -1;
	cin >> S >> T;
	f(0, 0);
	bt(0, 0);
}


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

using namespace std;

typedef long long int ll;

void solve()
{
	ll a, b;
	cin >> a >> b;
	for(int i = 0; i <= 100; i++)
	{
		for(int j = 0; j <= 100; j++)
		{
			if(2 * i + 4 * j == b && i + j == a)
			{
				cout << "Yes\n";
				return;
			}
		}
	}
	cout << "No\n";	
}

int main()
{
	int t = 1;
//	cin >> t;
	while(t--)
	{
		solve();
	}
	return 0;
}



Measured memory_bytes: 3632
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int
#define pii pair<int,int>
#define ti3 tuple<int,int,int>

struct BIT
{
    std::vector<int> bit;
    
    BIT(int size) : bit(size, 0){ }
    
    void add(int k, int x) {
        while (k < bit.size()) {
            bit[k] += x;
            k += k &-k;
        }
    }
    int sum(int k) {
        int res = 0;
        while (k > 0) {
            res += bit[k];
            k -= k&-k;
        }
        return res;
    }
};

struct UnionFind {
    vector<int> data;
    
    UnionFind(int size) : data(size, -1) { }
    
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y)
        {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

int v[100];

int main(void)
{
    int n,m;
    cin >> n >> m;
    for(int i = 0;i < m;i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        v[a]++;
        v[b]++;
    }
    for(int i = 0;i < n;i++)
    {
        cout << v[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	N := nextInt()

	ds := 0
	for num := N; num > 0; num /= 10 {
		ds += num % 10
	}

	if N % ds == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
k=int(input())
n=50

a=[k//n+49 for i in range(n)]

for i in range(n):
    if i<k%n:
        a[i]+=n-k%n+1
    else:
        a[i]-=k%n

print(n)
for i in range(n):
    if i<n-1:
        print(a[i],end=" ")
    else:
        print(a[i])
    






Measured memory_bytes: 3060
N, M = map(int, input().split())
G = [[] for _ in range(N+1)]
for _ in range(M):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)
print("POSSIBLE" if any(N in G[u] for u in G[1]) else "IMPOSSIBLE")

Measured memory_bytes: 38296
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
const double PI = acos(-1);

typedef complex<double> Point;
typedef vector<Point> VP;

int main(void){
    int n;
    cin >> n;
    VP ps(n);
    rep(i,n){
        double x,y;
        cin >> x >> y;
        ps[i] = Point(x,y);
    }
    double M = 100000;
    double res = 0;
    rep(i,M){
        Point inf = polar(1e9, 2.0*PI*(i/M));
        VP used;
        Point p(0,0);
        rep(j,n){
            if (abs(ps[j]-inf) < 1e9) {
                p += ps[j];
            }
        }
        res = max(res, abs(p));
    }
    printf("%.20f\n", res);
    return 0;
}


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

using namespace std;

int main() {
    int n;
    double s[1001], m, std;
    cin >> n;
    while (n != 0) {
        m = 0.;
        std = 0.;
        for (int i = 0; i < n; ++i) {
            cin >> s[i];
            m += s[i];
        }
        m /= (double) n;
        for (int i = 0; i < n; ++i) {
            std += pow(s[i] - m, 2);
        }
        std /= (double) n;
        std = sqrt(std);
        printf("%f\n", std);
        cin >> n;
    }
    return 0;
}


Measured memory_bytes: 3296
from itertools import accumulate
import math
from collections import deque
from collections import defaultdict
from itertools import permutations
import heapq
import bisect
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**10
from functools import reduce

s = input()
c = Counter(s)
if ((c["S"] == c["N"] == 0) or (c["S"]*c["N"] > 0)) and ((c["E"] == c["W"] == 0) or (c["E"]*c["W"] > 0)):
    print("Yes")
else:
    print("No")

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

int main(){
	int n;
	cin >> n;
	int c = 0;
	for(int i = 1; i <= n; i++){
		int x;
		cin >> x;
		if(x % 2 == 1 && i % 2 == 1) c++;
	}
	cout << c << "\n";
}


Measured memory_bytes: 3616
n=gets.to_i
s=gets.chomp.split("")
maxCount = []
(1..(n-1)).each do |index|
  xString = s[0,index]
  yString = s[index..-1]
  #配列の＆は積集合
  maxCount << (xString & yString).size
end
puts maxCount.max

Measured memory_bytes: 3836
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {
    /**
     * Iterate through each line of input.
     */

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run(){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] array = new int[N];

        for(int i=0; i<N; i++){
            array[i] = sc.nextInt();
        }

        int count = 1;
        int next = 0;
if(array[0] == 2) System.out.println(1);
else{
        while(true){
            count++;
            next = array[next]-1;
            if(array[next] == 2){
                System.out.println(count);
                break;
            }

            if(count >= N){
                System.out.println(-1);
                break;
            }
        }
    }
}

}


Measured memory_bytes: 51372
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;

int main(void){
    int n,m,x,y;
scanf("%d %d %d %d",&n,&m,&x,&y);
    int X[n],Y[m];
    int max,min;
for (int i = 0; i < n; i++) {
	cin >> X[i];
}
for (int i = 0; i < m; i++) {
	cin >> Y[i];
}
if(y<=x){printf("War");}
else{

max = x;
for(int i =0; i<n;i++){

  if( max < X[i] ) {
    max = X[i];
  }
}

min = y;
for(int i =0; i<m;i++){

  if( min > Y[i] ) {
    min = Y[i];
  }
}

if(max<min){printf("No War");}
else{printf("War");}





}
}

Measured memory_bytes: 256
N,M = gets.chomp.split(" ").map(&:to_i)
list = Array.new(N+1){Array.new}
ans = Array.new(M)
p = Array.new(M)
y = Array.new(M)
M.times do |i|
  p[i],y[i] = gets.chomp.split(" ").map(&:to_i)
  list[p[i]] << [y[i], i]
end
(N+1).times do |i|
  list[i] = list[i].sort_by{|x| x[0]}
  x = 1
  list[i].each do |v|
    str_p = i.to_s
    j = 6-str_p.length
    j.times do
      str_p = "0" + str_p
    end
    str_x = x.to_s
    j = 6-str_x.length
    j.times do
      str_x = "0" + str_x
    end
    ans[v[1]] = str_p + str_x
    x += 1
  end
end
ans.each do |x|
  puts x
end

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

using namespace std;
typedef pair<int, int> P;

int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
   string s;
    cin >> s;
    string w = "YAKI";
    for(int i = 0; i < 4; i++){
        if(s[i] != w[i]){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";

    

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll mypow(ll a, ll b) {
    ll ret = 1;
    while (b--) {
        ret *= a;
    }
    return ret;
}

int main() {
    ll k, a, b;
    cin >> k >> a >> b;
    ll ans;

    if (k >= a && b - 1 > a) {
        k -= (a - 1);
        ans = a + k / 2 * (b - a) + (k % 2);
        cout << ans << "\n";
    } else {
        cout << k + 1 << "\n";
    }

    return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define INF 100000000000
#define MAX 200001
#define MOD 1000000007
ll fac[MAX], finv[MAX], inv[MAX];
const int MX = 1000005;
const double PI = acos(-1);

int main(){
    char a; 
    cin >> a;
    int flag = 0;
    for(char c = 'a'; c <= 'z'; c++){
        if(a == c) flag=1;
    }
    if(flag) cout << 'a' << endl;
    else cout << 'A' << endl;
}

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

#define ll long long int
#define mod 1000000007

ll power(ll base,ll exp)
{
    ll res=1;
    base=base%mod;

    while(exp>0)
    {
        if(exp & 1)
            res=(res*base)%mod;
        exp= exp >> 1;
        base= (base*base)%mod;
    }
    return res;


}

ll solve(ll n,ll r)
{
    ll fact[n+1];
    fact[0]=1;
    for(ll i=1;i<=n;i++)
    {
        fact[i]= fact[i-1]*i%mod;

    }

    ll ans= ((fact[n]%mod)*(power(fact[r],mod-2)%mod)*(power(fact[n-r],mod-2)%mod))%mod;
    return ans;


}
#define MAXN 2001
ll c[MAXN][MAXN];

void pascal()
{

    c[0][0]=1;
    for(ll n=1;n<MAXN;n++)
    {

        c[n][0]=c[n][n]=1;
        for(ll k=1;k<n;k++){
            c[n][k]= (c[n-1][k-1]%mod+ c[n-1][k]%mod)%mod;


        }
    }

}


int main()
{
    pascal();
    	ll n,k;
	 cin>>n>>k;

	 for(int i=1;i<=k;i++)
     {
         ll ans= c[n-k+1][i]*c[k-1][i-1]%mod;
         cout<<ans<<" ";
     }


	return 0;
}













Measured memory_bytes: 30080
var P = 2

fun mod(x: Int) = if (x >= 0) x % P else (P - ((-x) % P)) % P
fun modPlus(x1: Int, x2: Int) = (x1 + x2) % P
fun modMinus(x1: Int, x2: Int) = (x1 + P - x2) % P
fun modTimes(x1: Int, x2: Int): Int = ((x1.toLong() * x2.toLong()) % P).toInt()

class IntArray2D(val size1: Int, val size2: Int) {
  private val innerArray = IntArray(size1 * size2)

  operator fun get(i1: Int, i2: Int): Int = innerArray[i2 + size2 * i1]

  operator fun set(i1: Int, i2: Int, v: Int) {
    innerArray[i2 + size2 * i1] = v
  }
}

fun main(args: Array<String>) {
  val (n, p) = readLine()!!.split(" ").map { it.toInt() }
  P = p

  val pTable = IntArray(n + 1, { 0 })
  pTable[0] = 2
  for (i in 1..n) {
    pTable[i] = modTimes(pTable[i - 1], pTable[i - 1])
  }

  val cTable = IntArray2D(n + 1, n + 1)
  cTable[0, 0] = 1
  for (i in 1..n) {
    for (j in 0..i) {
      cTable[i, j] = if (j == 0) 1 else modPlus(cTable[i - 1, j - 1], cTable[i - 1, j])
    }
  }

  val gTable = IntArray2D(n + 1, n + 1)
  gTable[0, 0] = 1
  for (i in 1..n) {
    for (j in 0..i) {
      gTable[i, j] =
          if (j == 0 || j == i) 1
          else modPlus(gTable[i - 1, j - 1], modTimes(gTable[i - 1, j], j + 1))
    }
  }

  val hTable = IntArray2D(n + 1, n + 1)
  for (i in 0..n) {
    for (j in 0..n) {
      hTable[i, j] =
          if (i == 0 || j == 0) 1
          else if (i == 1) modTimes(hTable[1, j - 1], 2)
          else modTimes(hTable[i - 1, j], hTable[1, j])
    }
  }


  val fTable = IntArray(n + 1, { 0 })
  for (i in 1..n) {
    var acc = 0
    for (x in 0..i) {
      acc = modPlus(acc, modTimes(gTable[i, x], hTable[x, n - i]))
    }
    fTable[i] = modTimes(pTable[n - i], acc)
  }

  var ans = pTable[n]
  for (k in 1..n) {
    val sign = if (k % 2 == 0) 1 else mod(-1)
    ans = modPlus(ans, modTimes(modTimes(sign, cTable[n, k]), fTable[k]))
  }

  println(ans)
}

Measured memory_bytes: 143672
#include <stdio.h>
int n,m,l,i,j,k;
int A[100][100],B[100][100];
long C[100][100]={0};
int main(){
  scanf("%d %d %d",&n,&m,&l);
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&A[i][j]);
    }
  }
  for(i=0;i<m;i++){
    for(j=0;j<l;j++){
      scanf("%d",&B[i][j]);
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<l;j++){
      for(k=0;k<m;k++){
        C[i][j]+=A[i][k]*B[k][j];
      }
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<l-1;j++){
      printf("%ld ",C[i][j]);
    }
    printf("%ld\n",C[i][l-1]);
  }
  return 0;
}

Measured memory_bytes: 2816
import sys
def input():
    return sys.stdin.readline()[:-1]
N,C,K=map(int,input().split())
T=[int(input()) for i in range(N)]
T.sort()
t=T[0]+K
a=1
h=1
for i in T[1:]:
    if t>=i and h<C:
        h+=1
    else:
        t=i+K
        h=1
        a+=1
print(a)

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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)
#define forall(it, c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); ++ it)

template <typename T> inline void read(T &x) {
	x = 0; bool f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	for (;  isdigit(c); c = getchar()) x = x * 10 + (c & 15);
	if (!f) x = -x;
}

const int maxn = 1e5 + 5;
int n, m;
vector <int> g[maxn];
int que[maxn], ql, qr;
int dis[maxn], pre[maxn];

void bfs(int S) {
	memset(dis, -1, sizeof(dis));
	dis[S] = 0;
	ql = qr = 0;
	que[qr ++] = S;
	while (ql < qr) {
		int u = que[ql ++];
		rep(i, g[u].size()) {
			int v = g[u][i];
			if (!~dis[v]) {
				dis[v] = dis[u] + 1;
				pre[v] = u;
				que[qr ++] = v;
			}
		}
	}
}

int main() {
	read(n); read(m);
	rep(i, m) {
		int u, v; read(u); read(v);
		-- u; -- v;
		g[u].pb(v); g[v].pb(u);
	}
	bfs(0);
	puts("Yes");
	rep(i, n) if (i) printf("%d\n", pre[i] + 1);
	return 0;
}


Measured memory_bytes: 11192
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static char S[200001], T[200001];

int main(void) {
    size_t H, W, N, sr, sc;

    scanf("%zu %zu %zu\n%zu %zu\n%s\n%s", &H, &W, &N, &sr, &sc, S, T);

    sr--;
    sc--;

    int32_t leftBoundary = 0;
    int32_t rightBoundary = W - 1;
    int32_t upperBoundary = 0;
    int32_t bottomBoundary = H - 1;

    bool kickOutable = false;

    for (size_t cnt = 0; cnt < N; cnt++) {
        {
            if (T[N - cnt - 1] == 'L' && rightBoundary < (int32_t)(W - 1)) {
                rightBoundary++;
            }

            if (S[N - cnt - 1] == 'R') {
                rightBoundary--;
            }
        }
        {
            if (T[N - cnt - 1] == 'R' && 0 < leftBoundary) {
                leftBoundary--;
            }

            if (S[N - cnt - 1] == 'L') {
                leftBoundary++;
            }
        }

        if (rightBoundary < leftBoundary) {
            break;
        }

        {
            if (T[N - cnt - 1] == 'D' && 0 < upperBoundary) {
                upperBoundary--;
            }

            if (S[N - cnt - 1] == 'U') {
                upperBoundary++;
            }
        }
        {
            if (T[N - cnt - 1] == 'U' && bottomBoundary < (int32_t)(H - 1)) {
                bottomBoundary++;
            }

            if (S[N - cnt - 1] == 'D') {
                bottomBoundary--;
            }
        }

        if (bottomBoundary < upperBoundary) {
            break;
        }
    }

    if (leftBoundary <= (int32_t)sc && (int32_t)sc <= rightBoundary && upperBoundary <= (int32_t)sr && (int32_t)sr <= bottomBoundary) {
        puts("YES");
    }
    else {
        puts("NO");
    }

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
  char s[14][14]={0};
  int i,j,k,c,t,r,x[150],y[150],ny,nx;
  int Y[]={1,0,-1,0};
  int X[]={0,-1,0,1};
  while(scanf("%s",s[1]+1)!=EOF){
    c=0;
    for(i=2;i<13;i++)scanf("%s",s[i]+1);
    for(i=1;i<13;i++){
      for(j=1;j<13;j++){
	if(s[i][j]-'1')continue;
	c++;
	s[y[0]=i][x[0]=j]=t=0;
	for(r=1;r-t;t++){
	  for(k=0;k<4;k++){
	    ny=y[t]+Y[k];
	    nx=x[t]+X[k];
	    if(s[ny][nx]-'1')continue;
	    s[y[r]=ny][x[r]=nx]=0;
	    r++;
	  }
	}
      }
    }
    printf("%d\n",c);
  }
  return 0;
}
  

Measured memory_bytes: 540
H,W=map(int,input().split())
MAP=[list(input()) for i in range(H)]

BLIST=[]

for i in range(H):
    for j in range(W):
        if MAP[i][j]=="B":
            BLIST.append([i,j])

BLIST.sort(key=lambda x:x[0]+x[1])
ANS=abs(BLIST[0][0]-BLIST[-1][0])+abs(BLIST[0][1]-BLIST[-1][1])

BLIST.sort(key=lambda x:x[0]-x[1])
ANS=max(ANS,abs(BLIST[0][0]-BLIST[-1][0])+abs(BLIST[0][1]-BLIST[-1][1]))

print(ANS)



Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int 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) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    int ans = 1;
    int m = h[0];
    for (int i = 1; i < n; i++){
		ans += (h[i] >= m);
		m = max(m, h[i]);
	}
	cout << ans << '\n';
}

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

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


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
int n ;
int counter = 1;
cin>>n;
bool b = 0;
if (n>=100 && n <= 999){
int m = n;
while(true){
    if (n < 10)
        break;
    n /= 10;
    counter += 1;
}
int x[counter];
for(int i = counter -1 ; i >= 0 ; i -- ){
    x[i] = m % 10;
    m /= 10;
}
for(int i =0 ; i< counter ; i++){
    if (x[i]==7)
        {b = 1;break;}
}if (b==1)cout<<"Yes";
else
    cout<<"No";
}

return 0;}


Measured memory_bytes: 3624
import os

import itertools
import sys
import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
A, B = list(zip(*[map(int, sys.stdin.buffer.readline().split()) for _ in range(N)]))
A = list(A)
B = list(B)
AB = list(zip(A, B))


def test():
    ranges = (range(a, b + 1) for a, b in AB)
    s = set()
    for X in itertools.product(*ranges):
        s.add(np.median(np.array(X, dtype=float)))
    print(len(s))
    print(list(sorted(s)))


A.sort()
B.sort()


def solve_odd():
    mid = N // 2
    l, r = A[mid], B[mid]
    return r - l + 1


def solve_even():
    mid = N // 2 - 1
    l1, l2 = A[mid:mid + 2]
    r1, r2 = B[mid:mid + 2]
    return r1 + r2 - l1 - l2 + 1
    # print(l1 + l2)
    # print(r1 + r2)
    # print(l1, l2, (l1 + l2) / 2, r1, r2, (r1 + r2) / 2)
    # print(A)
    # print(B)
    # return r - l + 1


if N % 2 == 1:
    ans = solve_odd()
else:
    ans = solve_even()
print(ans)

# test()


Measured memory_bytes: 124920
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;
import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int h = parseInt(sc.next());
		int w = parseInt(sc.next());
		char[][] a = new char[h][w];
		for (i = 0; i < h; i++) {
			a[i] = sc.next().toCharArray();
		}
		sc.close();
		ArrayList<Integer> hh = new ArrayList<>();
		ArrayList<Integer> ww = new ArrayList<>();
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				if(a[i][j] != '.') {
					hh.add(i);
					break;
				}
			}
		}
		for (i = 0; i < w; i++) {
			for (j = 0; j < h; j++) {
				if(a[j][i] != '.') {
					ww.add(i);
					break;
				}
			}
		}
//		out.println(hh.toString());
//		out.println(ww.toString());
		PrintWriter pw = new PrintWriter(out);
		for (Integer ii:hh) {
			for (Integer jj:ww) {
				pw.print(a[ii][jj]);
			}
			pw.println();
		}
		pw.flush();
	}
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define EPS 0.000000001 //1e-9
using ll = long long;
using pii = pair<int, int>;
const long long INF = 2e18;

template <class A, class B> ostream& operator<<(ostream &os, const pair<A, B> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;} 
template <class A> ostream& operator<<(ostream &os, const vector<A> &v) {os << "{"; for(int i = 0; i < (int)v.size(); i++) if(i == 0) os << v[i]; else os << ", " << v[i]; os << "}"; return os;}

void dprint(string s) {cout << endl;}
template <class T, class... U> void dprint(string s, T t, U... u) 
{int w = s.find(','); cout << "[" << s.substr(0, w) << ": " << t << "] "; dprint(s.substr(w+2, (int)s.size()-w-1), u...);} 

#define DEBUG 
#ifdef DEBUG
#define dbg(X...) dprint(#X, X)
#else
#define dbg(X...) "KEEP CALM" 
#endif

const int N=3e5+5; // CHANGE this value ACC. TO Q.

int row[N], col[N];
int n, m; 

int32_t main()
{
    IOS;
    cin>>n>>m;
    int ntar; cin>>ntar;
    
    set<pii> s;
    int mxr=0, mxc=0;
    for(int i=0;i<ntar;i++)
    {
        int x, y; cin>>x>>y;
        s.insert({x, y});
        row[x]++, col[y]++;
        mxr=max(mxr, row[x]), mxc=max(mxc, col[y]);
    }
    vector<int> mrow, mcol;
    for(int i=0;i<N;i++)
    {
        if(row[i]==mxr)
            mrow.pb(i);
    }
    for(int i=0;i<N;i++)
    {
        if(col[i]==mxc)
            mcol.pb(i);
    }
    for(int i: mrow)
    {
        for(int j: mcol)
        {
            if(s.count({i, j}))
                ;
            else
            {
                cout<<mxr+mxc;
                return 0;
            }
        }
    }
    cout<<mxr+mxc-1;
    return 0;
}

Measured memory_bytes: 34996
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>
const long long INF=1e18;

using namespace std;

int main(void) {
    int L,R,d;
    cin>>L>>R>>d;
    int ans=0;

    for(int i=L;i<=R;i++){
        if(i%d==0){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    ll a,b,c; cin >> a >> b >> c;
    if(a%2 == 0 || b%2 == 0 || c%2 == 0) {
        cout << 0 << endl;
    } else {
        cout << min(a*b,min(b*c,a*c)) << endl;
    }
}

Measured memory_bytes: 256