akhauriyash/Code-Regression huggingface dataset:
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    V< P<ll, ll> > xl;
    REP(i, n) {
        ll x, l; cin >> x >> l;
        xl.emplace_back(x, l);
    }

    sort(ALL(xl), [&](P<ll, ll> i, P<ll, ll> j) {
        if (i.first + i.second == j.first + j.second) return i.first < j.first;
        else return i.first + i.second < j.first + j.second;
    });

    ll prer = -HIGHINF;
    int ans = 0;
    for (P<ll, ll> xxl: xl) {
        if (prer <= xxl.first - xxl.second) {
            ans++;
            prer = xxl.first + xxl.second;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n;
  cin >> n;
  vector<pair<int,int>> p(n);
  for(int i=0;i<n;i++){
    int a,b;
    cin >> a >> b;
    p.at(i) = make_pair(b,a);
  }
  
  sort(p.begin(),p.end());
  
  int total=0;
  for(int i=0;i<n;i++){
    int a,b;
    tie(b,a) = p.at(i);
    total += a;
    if(total > b){
      cout << "No" << endl;
      return(0);
    }
  }
  
  cout << "Yes" << endl;
  
  return(0);
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define first fi
#define second se
#define sz(x) (int)x.size()
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;

const int N = 5005;
bitset<5005> pr[N], sf[N];

int n, k, a[N];

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    pr[0][0] = 1;
    for (int i = 1; i <= n; i++)
        pr[i] = pr[i - 1]|(pr[i - 1]<<a[i]);
    sf[n + 1][0] = 1;
    for (int i = n; i >= 1; i--)
        sf[i] = sf[i + 1]|(sf[i + 1]<<a[i]);
    int ans = n;
    for (int i = 1; i <= n; i++) {
        if (a[i] >= k) {
            ans--;
            continue;
        }
        int l = k - a[i], r = k - 1;
        int cnt = 0;
        for (int j = l; j <= r; j++) cnt += pr[i - 1][j];
        for (int j = 0; j < k; j++) {
   //         printf("%d %d %d %d %d\n", i, j, l, r, cnt);
            if (sf[i + 1][j] && cnt) {
                ans--;
                break;
            }
            if (r >= 0) cnt -= pr[i - 1][r];
            l--; r--;
            if (l >= 0) cnt += pr[i - 1][l];
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 6400
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String args[]){

		
		Scanner sc = new Scanner(System.in);
		int intX = -1;
		int intY = -1;

		for(int i = 0; i < 3000; i++){


			intX = sc.nextInt();
			intY = sc.nextInt();

			if((intX == 0) && (intY == 0)){
				break;
			}

			int[] arr = new int[]{intX,intY};
			Arrays.sort(arr);

			System.out.println(arr[0] + " " + arr[1]);

		}
	}
}

Measured memory_bytes: 36684
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)

//変数
int D, G;
vector<ll> p, c;

//解法
void solve() {

	int ans = INT_MAX;

	rep(i, 1<<D) {

		ll score = 0;
		int num = 0;
		int maxi = -1;
		rep(j, D) {
			if ((1 & i >> j) == 1) {
				score += (j+1) * p[j] * 100 + c[j];
				num+=p[j];
			}
			else {
				maxi = max(maxi, j);
			}
		}

		if (score >= G) {
			ans = min(ans, num);
			continue;
		}
		else if (maxi!=-1){
			rep(i, p[maxi]) {
				score += (maxi + 1) * 100;
				num++;
				if (score >= G) {
					ans = min(ans, num);
					break;
				}
			}
		}

	}

	cout << ans;

	return;
}

int main() {
	//入力
	cin >> D >> G;
	p.resize(D);
	c.resize(D);
	rep(i, D) cin >> p[i] >> c[i];
	solve();
	cout << endl;
	return 0;
}


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

int main(){
  int a, b;
  cin >> a >> b;
  int count = 0;
  for (int i = a;i <= b;i++){
    if( (i / 10000) == (i % 10) ){
      int tmp = i;
      tmp %= 10000;
      if(tmp < 10){
        count++;
        continue;
      }
      if(tmp < 100){
        continue;
      }
      tmp /= 10;
      //cout << tmp << endl;
      if( (tmp / 100) == (tmp % 10) ){
        count++;
      }
    }
  }
  cout << count << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef vector<pll> vll;
typedef vector<vl> vvl;

#define fori(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i >= 0; i--)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define trav(x, a) for (auto &x : a)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define sz(a) (int)(a).size()
#define fi first
#define se second

clock_t time_p = clock();
void time_taken()
{
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}

const ll mod = 1e9 + 7;
const ll INF = 1e18;

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

    int n;
    cin >> n;
    vi a((1 << n));
    fori(i, (1 << n)) cin >> a[i];
    vector<pii> ans((1 << n), {0, 0});
    fori(i, (1 << n))
    {
        ans[i] = {a[i], 0};
    }
    auto merge = [&](pii a, pii b) {
        vi foo{a.fi, a.se, b.fi, b.se};
        sort(all(foo));
        return make_pair(foo[sz(foo) - 1], foo[sz(foo) - 2]);
    };
    fori(j, n)
    {
        fori(k, (1 << n))
        {
            if ((k & (1 << j)) != 0)
            {
                ans[k] = merge(ans[k], ans[(k ^ (1 << j))]);
            }
        }
    }
    int res = 0;
    rep(i,1,(1 << n)-1)
    {
        int foo = ans[i].fi + ans[i].se;
        res = max(res, foo);
        cout << res << endl;
    }

    time_taken();
    return 0;
}

Measured memory_bytes: 6456
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define VLL vector<long long>
#define SORT(x) sort(x.begin(),x.end())
#define REVE(x) reverse(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define COUT(x) cout<<x<<endl
double pai = 3.1415926535;
string atc = "atcoder";
typedef pair<long long, long long> data_t;
string strnum = "0123456789";
string alpS = "abcdefghijklmnopqrstuvwxyz";
string alpL = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int sizealp = (int)(alpS.size());
int mod = 1e9 + 7;
bool test = false;

void Test(char a) {
	if (test) {
		printf("%c", a);
	}
}

int main() {
	int N;
	cin >> N;
	vector<int> h(N);
	rep(i, N)cin >> h[i];
	vector<int> HighLow;
	int ans = 0;
	do
	{
		for (int i = 1; i < h.size(); ) { //remove flat
			if (h[i - 1] == h[i]) 
				h.erase(h.begin() + i);
			else 
				i++;
			//cout << 'a';
		}
		if (h.size() < 3)break;
		for (int i = 0; i < h.size()&&h.size()>2; i++) { //make HighLow
			if (i == 0) {
				if (h[i] > h[i + 1]) {
					HighLow.push_back(h[i]);
				}
			}
			else if (i == h.size() - 1) {
				if (h[i] > h[i - 1])
					HighLow.push_back(h[i]);
			}
			else {
				if ((h[i - 1]<h[i] && h[i]>h[i + 1]) || (h[i - 1] > h[i] && h[i] < h[i + 1]))
					HighLow.push_back(h[i]);
			}
          
			//cout << 'b';
		}
      //rep(i,HighLow.size())cout<<HighLow[i]<<' ';
          //cout<<endl;
		for (int i = 0; i < HighLow.size()&&HighLow.size()>2; i++) { //change convex into flat
			if (i % 2 == 0) {
				if (i == 0) {
					ans += HighLow[i] - HighLow[i + 1];
					HighLow[i] = HighLow[i + 1];
				}
				else if (i == HighLow.size() - 1) {
					ans += HighLow[i] - HighLow[i - 1];
					HighLow[i] = HighLow[i - 1];
				}
				else {
					ans += HighLow[i] - max(HighLow[i - 1], HighLow[i + 1]);
					HighLow[i] = max(HighLow[i - 1], HighLow[i + 1]);
				}
			}
			//cout << 'c';
		}
		h = HighLow;
		HighLow = vector<int>(0);
	} while (h.size()>=3);
	if (h.size() == 2)ans += max(h[0], h[1]);
	else ans += h[0];
	COUT(ans);

}

Measured memory_bytes: 256
card = [list(map(int, input().split())) for _ in range(3)]

N = int(input())
b = [int(input()) for _ in range(N)]

candidates = []

for i in range(len(card)):
    candidates.append(card[i])

for i in range(len(card[0])):
    candidates.append([card[j][i] for j in range(len(card))])

candidates.append([card[0][0], card[1][1], card[2][2]])
candidates.append([card[0][2], card[1][1], card[2][0]])

if any([all([num in b for num in c]) for c in candidates]):
    print("Yes")
else:
    print("No")

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

int main() {
    string n;
    std::cin >> n;
    if (n[0] == n[1] && n[1] == n[2]){
        std::cout << "Yes" << std::endl;
    }
    else if (n[1] == n[2] && n[2] == n[3]){
        std::cout << "Yes" << std::endl;
    }
    else{
        std::cout << "No" << std::endl;
    }
}

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

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

  int L = M / N;
  int flag = 0;
  while (flag == 0) {
    if ((M-L*(N-1))%L==0){
      flag = 1;
      cout << L;
    }
  else{
    L -= 1;
  }
  }
}


Measured memory_bytes: 888
import qualified Data.Set as S

solve :: [Int] -> [Int] -> Int
solve ss ts = S.size $ S.intersection ss' ts' 
  where
    ss' = S.fromList ss
    ts' = S.fromList ts

  
readInt :: String -> Int
readInt = read

main = do
  n <- getLine 
  s <- fmap (map readInt . words) getLine 

  q <- getLine 
  t <- fmap (map readInt . words) getLine 

  let ans = solve s t 
  print ans



Measured memory_bytes: 88828
from collections import deque
q = deque([0])

def dfs():
    while q:
        v = q.popleft()
        for nv in g[v]:
            if p[nv] < 1:
                p[nv] = v + 1
                q.append(nv)
n,m = map(int,input().split())
g = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(lambda x:int(x) - 1,input().split())
    g[a].append(b)
    g[b].append(a)
    # ループ？お互いに辺がある場合やねこれ
p = [0] * n
dfs()
if 0 in p:
    print('No')
else:
    print('Yes',*p[1:],sep='\n')


Measured memory_bytes: 38924
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	p := make([]int, n)
	for i := range p {
		fmt.Scan(&p[i])
	}

	cnt := 0
	for i := range p {
		v := p[i]
		if v == i+1 {
			continue
		}
		cnt++
	}
	if cnt == 0 || cnt == 2 {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}


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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		long[] t = new long[n];
		for (int i = 0; i < n; i++) {
			t[i] = sc.nextLong();
		}

		long ans = 1;
		for (int i = 0; i < n; i++) {
			long gcd = gcd(ans, t[i]);

			ans *= t[i] / gcd;
		}

		pr.println(ans);
	}

	private static long gcd(long n, long m) {
		if (m == 0) {
			return n;
		} else {
			return gcd(m, n % m);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


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

using namespace std;

typedef long long lint;

const double EPS = 1e-8;

class Point{
public:
    double x, y;
    Point(double x = 0, double y = 0): x(x), y(y){}
    Point operator + (Point p){return Point(x + p.x, y + p.y);}
    Point operator - (Point p){return Point(x - p.x, y - p.y);}
    Point operator * (double a){return Point(x * a, y * a);}
    Point operator / (double a){return Point(x / a, y / a);}
    Point operator * (const Point &a){
        return Point(x * a.x - y * a.y, x * a.y + y * a.x);
    }
    bool operator < (const Point &p) const {
        return (x != p.x ? x < p.x : y < p.y);
    }
    bool operator == (const Point &p) const {
        return (fabs(x - p.x) < EPS && fabs(y - p.y) < EPS);
    }
};

typedef Point Vector;

double norm(Vector a){return (a.x * a.x + a.y * a.y);}
double abs(Vector a){return (sqrt(norm(a)));}
double dot(Vector a, Vector b){return (a.x * b.x + a.y * b.y);}
double cross(Vector a, Vector b){return (a.x * b.y - a.y * b.x);}

int ccw(Point p0, Point p1, Point p2)
{
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if (cross(a, b) > EPS) return (+1);
    if (cross(a, b) < -EPS) return (-1);
    if (dot(a, b) < -EPS) return (+2);
    if (norm(a) < norm(b)) return (-2);
    return (0);
}

bool isIntersectSP(Point p1, Point p2, Point p)
{
    return (ccw(p1, p2, p) == 0);
}

bool isIntersectSS(Point p1, Point p2, Point p3, Point p4)
{
    return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
             ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}

Point projection(Point p1, Point p2, Point p3)
{
    double t = dot(p3 - p1, p2 - p1) / norm(p2 - p1);
    return (p1 + (p2 - p1) * t);
}

double distanceSP(Point s1, Point s2, Point p)
{
    Point r = projection(s1, s2, p);
    if (isIntersectSP(s1, s2, r)) return (abs(r - p));
    return (min(abs(s1 - p), abs(s2 - p)));
}

double distanceSS(Point s1, Point s2, Point t1, Point t2){
    if (isIntersectSS(s1, s2, t1, t2)) return (0);
    return (min(min(distanceSP(s1, s2, t1), distanceSP(s1, s2, t2)),
            min(distanceSP(t1, t2, s1), distanceSP(t1, t2, s2))));
}

int main()
{
    int n;
    while (scanf("%d", &n) && n){
        Point s, e;
        scanf("%lf %lf %lf %lf", &s.x, &s.y, &e.x, &e.y);

        double ans = 1001001001ll;
        for (int i = 0; i < n; i++){
            double minx, miny, maxx, maxy, h;
            scanf("%lf %lf %lf %lf %lf", &minx, &miny, &maxx, &maxy, &h);
            Point p1 = Point(minx, miny), p2 = Point(minx, maxy),
                  p3 = Point(maxx, miny), p4 = Point(maxx, maxy);
            double dist = min(min(distanceSS(p1, p2, s, e), distanceSS(p3, p4, s, e)),
                              min(distanceSS(p1, p3, s, e), distanceSS(p2, p4, s, e)));

            if ((minx <= min(s.x, e.x) && max(s.x, e.x) <= maxx &&
                 miny <= min(s.y, e.y) && max(s.y, e.y) <= maxy)) ans = 0;
            if (dist <= h) ans = min(ans, dist);
            else {
                ans = min(ans, 0.5 * (h + dist * dist / h));
            }
        }
        printf("%.10lf\n", ans);
    }

    return (0);
}

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

int main() {
    int sum = 0;
    for (int i = 0; i < 3; i++) {
        int a;
        cin >> a;
        sum += a;
    }
    if (sum >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, X, Y;
    cin >> n >> m >> X >> Y;
    vector<int> x(n), y(m);
    rep(i, 0, n) cin >> x[i];
    rep(i, 0, m) cin >> y[i];
    int MAXX = *max_element(x.begin(), x.end());
    int MINY = *min_element(y.begin(), y.end());
    int Z = max(X, MAXX) + 1;
    int ZZ = min(Y, MINY);
    if(Z <= ZZ) cout << "No War" << endl;
    else cout << "War" << endl;
}

Measured memory_bytes: 256
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    n,m,r = map(int,ipt().split())
    tgt = [int(i)-1 for i in ipt().split()]
    dt = [[10**18]*n for i in range(n)]
    for i in range(n):
        dt[i][i] = 0
    for i in range(m):
        a,b,c = map(int,ipt().split())
        a -= 1
        b -= 1
        dt[a][b] = c
        dt[b][a] = c

    for i in range(n):
        for j in range(n):
            for k in range(n):
                if dt[j][k] > dt[j][i]+dt[i][k]:
                    dt[j][k] = dt[j][i]+dt[i][k]

    mi = 10**18
    for i in itertools.permutations(range(r)):
        nm = 0
        for j in range(r-1):
            nm += dt[tgt[i[j]]][tgt[i[j+1]]]
        if mi > nm:
            mi = nm

    print(mi)

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 76564
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <bitset>
#include <unordered_map>

using ll = long long;

using namespace std;

using bs = bitset<26>;
#define INF 200010

int main() {
    string s;
    cin >> s;
    int len = s.size();
    bs rui[len+1];
    for (int i=0; i<len; i++) {
        rui[i+1] = rui[i];
        rui[i+1].flip(s[i] - 'a');
    }
    unordered_map<bs, int> dp;
    dp[0] = 0;
    for (int i=0; i<=len; i++) {
        for (bs dif('1' + string(25, '0')); ; dif >>= 1) {
            bs from = rui[i] ^ dif;
            if (!dp.count(rui[i])) dp[rui[i]] = INF;
            if (!dp.count(from)) dp[from] = INF;
            dp[rui[i]] = min(dp[rui[i]], dp[from] + 1);
            if (dif.to_ullong() == 0) break;
        }
    }
    cout << max(dp[rui[len]], 1) << '\n';
    return 0;
}

Measured memory_bytes: 171868
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "queue"

using namespace std;
typedef long long ll;

int main()
{
  int n;
  cin >> n;
  string a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  for (int i = 0; i < n; i++)
  {
    char x = a.at(i);
    char y = b.at(i);
    char z = c.at(i);
    if (x != y && y != z && z != x)
    {
      ans += 2;
    }
    else
    if ((x == y && x != z) || (y == z && y != x) || (z == x && z != y))
    {
      ans++;
    }
  }
  cout << ans << "\n";
}

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

typedef long long ll;

int main()
{
    int h,w;
    cin >> h >> w;
    int i,j;
    vector<string> s(h);
    int temp_w = 0;
    for(i = 0;i < h;++i){
        cin >> s.at(i);
        for(j = 0;j < w;++j){
            if(s.at(i).at(j) == '.'){
                ++temp_w;
            }
        }
    }
    vector<vector<int>> d(h,vector<int>(w,-1));
    queue<pair<int,int>> que;
    que.emplace(0,0);
    d.at(0).at(0) = 0;
    int x,y;
    int dx[4] = {1,0,-1,0};
    int dy[4] = {0,1,0,-1};
    int nx,ny;
    while(!que.empty()){
        x = que.front().first;
        y = que.front().second;
        if(x == h-1 && y == w-1){
            break;
        }
        que.pop();
        for(i = 0;i < 4;++i){
            nx = x + dx[i];
            ny = y + dy[i];
            if(nx < 0 || nx >= h || ny < 0 || ny >= w){
                continue;
            }else{
                if(s.at(nx).at(ny) == '#'){
                    continue;
                }
                if(d.at(nx).at(ny) == -1){
                    d.at(nx).at(ny) = d.at(x).at(y) + 1;
                    que.emplace(nx,ny);
                }
            }
        }
    }
    if(d.at(h-1).at(w-1) == -1){
        cout << -1 << endl;
    }else{
        cout << temp_w-d.at(h-1).at(w-1)-1 << endl;
    }
    return 0;
}

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

// O(\sqrt{n})
bool is_prime(int n){
    for(int i=2; i*i <= n; i++){
        if(n%i == 0) return false;
    }
    return n != 1; // n == 1 のときは例外
}

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

    map<int, int> pr;
    for(int i = 1; i <= n; i++){
        for(int j = 2; j <= i; j++){
            int cur = i;
            if(is_prime(j)){
                while(cur % j == 0){
                    pr[j]++;
                    cur /= j;
                }
            }
        }
    }

    vector<int> a = {2, 4, 14, 24, 74};
    map<int, int> num;
    for(int i = 2; i <= n; i++){
        for(int k = 0; k < 5; k++){
            if(pr[i] >= a[k]) num[a[k]]++;
        }
    }

    // cout << num[2] << " " << num[4] << " " << num[14] << " " << num[24] << " " << num[74] << endl;
    int ans = ((num[2] - 2) * (num[4] - 1) * num[4]) / 2 + ((num[4] - 1) * num[14]) + ((num[2] - 1) * num[24]) + (num[74]);
    cout << ans << endl;
    return 0;
}

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 200007;

int n, m;
int qx, qy;
int a[MAXN];
int _cc[MAXN*2], *cc = _cc + MAXN;
int rc[MAXN];

void init ();
void input ();
void inputq ();
void work ();



int main()
{
	init();
	input();
	work();
}



void init ()
{
	// Init Everything Here
	
	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method
	
	scanf ( "%d%d", &n, &m );
	lpi ( i, 1, n ) scanf ( "%d", &a[i] );
}

void inputq ()
{
	// input query
	
	scanf ( "%d%d", &qx, &qy );
}

void work ()
{
	// main work
	
	lpi ( i, 1, n ) cc[i] = -1;
	lpi ( i, 1, n ) ++rc[a[i]], ++cc[a[i]-rc[a[i]]+1];
	
	int ans = 0;
	lpi ( i, -n, n ) if ( cc[i] > 0 ) ans += cc[i];
	
	lp ( _q, 0, m ){
		inputq ();
		
		if ( cc[a[qx]-rc[a[qx]]+1] > 0 ) --ans;
		--cc[a[qx]-rc[a[qx]]+1];
		--rc[a[qx]];
		
		a[qx] = qy;
		
		++rc[qy];
		++cc[qy-rc[qy]+1];
		if ( cc[qy-rc[qy]+1] > 0 ) ++ans;
		
		printf ( "%d\n", ans );
	}
}

Measured memory_bytes: 3968
using System;

namespace atcoder_bc173
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = Convert.ToInt32(Console.ReadLine());
            int K = 1000;
            while(K<N)
            {
                K += 1000;
            }
            Console.WriteLine(K-N);
        }
    }
}


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

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout.precision(10);
	int x;
	cin >> x;
	cout << ((x) ? '0' : '1') << endl;
	return 0;
}

Measured memory_bytes: 3652
(defun f(line)
  (let* ((line0 (subseq line 0 (truncate (/ (length line) 2))))
         (line1 (nreverse (subseq line (if (oddp (length line)) (1+ (truncate (/ (length line) 2))) (truncate (/ (length line) 2)))))))
    (labels ((rec (line0 line1 i acc)
                  (if (= i (length line0))
                    acc
                    (if (char= (char line0 i) (char line1 i))
                      (rec line0 line1 (1+ i) acc)
                      (rec line0 line1 (1+ i) (1+ acc))))))
      (rec line0 line1 0 0))))
(let ((line (read-line nil nil)))
  (format t "~A~%" (f line)))


Measured memory_bytes: 14048
import sys

N, K = (int(x) for x in input().split())
H = list(map(int, input().split()))
ans=0

if K>=N:
  print(0)
  sys.exit(0)
  
H.sort(reverse=True)
del H[0:K]
for i in range(len(H)):
  ans+=H[i]
print(ans)

Measured memory_bytes: 31636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int w;
	cin >> w;
	vector<int> bb;
	while (w > 0) {
		bb.push_back(w % 3);
		w /= 3;
	}
	int c = 0;
	string s = "";
	for (int i = 0; i < bb.size(); i++) {
		if (bb[i] + c == 3) {
			s += '0';
			c = 1;
		}
		else if (bb[i] + c == 2) {
			s += '-';
			c = 1;
		}
		else if (bb[i] + c == 1) {
			s += '+';
			c = 0;
		}
		else {
			s += '0';
			c = 0;
		}
	}
	if (c == 1) {
		s += '+';
	}
	reverse(s.begin(), s.end());
	cout << s << endl;
	return 0;
}

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

int main(){
  int n,d;
  cin>>n>>d;
  int x[n][d];
  int cnt=0;
  rep(i,n)rep(j,d)cin>>x[i][j];
  
  int ians=0;
  double fans=0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      for(int k=0;k<d;k++){
        ians+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        fans+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      }
      ians=sqrt(ians);
      fans=sqrt(fans);
      if(ians==fans)cnt++;
      ians=0;
      fans=0;
    }
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pll = pair<ll, ll>;

int main() {
	int N, K;
	cin >> N >> K;
	if (K > (N - 1) * (N - 2) / 2)
		cout << -1 << endl;
	else {
		const int M = N * (N - 1) / 2 - K;
		cout << M << endl;
		for (int j = 2; j <= N; j++)
			cout << 1 << " " << j << endl;
		int n = K;
		for (int i = 2; i <= N; i++)
			for (int j = i + 1; j <= N; j++) {
				if (n > 0) {
					n--;
					continue;
				}
				cout << i << " " << j << endl;
			}
	}
	return 0;
}


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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;

using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;


int main() {

    int n; cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    int s = 0;
    REP(i, n) s ^= a[i];

    REP(i, n) {
        if (i) cout << ' ';
        cout << (a[i] ^ s);
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 3956
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author emli
 */


#include <bits/stdc++.h>
using namespace std;

class AWeLoveGolf {
public:
    void solve(std::istream& cin, std::ostream& cout) {
		ios::sync_with_stdio(false);
        cin.tie(nullptr);

        int k,a,b;

        cin >> k >> a >> b;

        for (int i = a; i <= b; ++i) {
            if (i % k == 0){
                cout << "OK" << endl;
                return;
            }
        }
        cout << "NG" << endl;
	}
};


int main() {
	AWeLoveGolf solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int N;
int R[4010][4010];
LL dp[4010][4010];
LL sum[4010];
LL xs[4010];

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

  cin >> N;
  REP(i,N){
	cin >> xs[i];
	sum[i+1] = sum[i] + xs[i];
  }
  fill((LL*)dp, (LL*)dp+4010*4010, 1e15);
  REP(i,N){
	dp[i][i] = 0;
	R[i][i] = i;
  }
  
  for(int l=2;l<=N;++l){
	for(int i=0,r=i+l-1;r<N;++i,++r){
	  LL w = sum[r+1] - sum[i];
	  for(int c=R[i][r-1];c<=R[i+1][r];++c){
		LL t = dp[i][c] + dp[c+1][r] + w;
		if(dp[i][r] > t){
		  dp[i][r] = t;
		  R[i][r] = c;
		}
	  }
	}
  }

  cout << dp[0][N-1] << endl;

  return 0;
}

Measured memory_bytes: 174112
// checklist
// ll, int overflow, array bounds
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

ll const mxn=2e5+5;

ll fact[mxn],ifact[mxn];

ll modpow(ll a, ll b) // put b = mod-2, calc for (x!)^(mod-2) % mod only
{
	ll r=1;
	while(b)
	{
		if(b&1)r=(r*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return r;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	ll n,a,b;
	cin >> n >> a >> b;
	ll ans = modpow(2,n)-1;
	ll ctot=1;
	for(int i=1; i<=a; i++){
		ctot=(ctot*(n-i+1))%MOD;
		ctot=(ctot*(modpow(i,MOD-2)))%MOD;
	}
	ans -= ctot; ans %= MOD;
	if(ans<0)ans+=MOD;
	ctot=1;
	for(int i=1; i<=b; i++){
		ctot=(ctot*(n-i+1))%MOD;
		ctot=(ctot*(modpow(i,MOD-2)))%MOD;
	}
	ans -= ctot; ans %= MOD;
	if(ans<0)ans+=MOD;
	cout << ans%MOD << endl;
}	


Measured memory_bytes: 384
n = int(input())
ans = 0
yaku = 0
for i in range(1,n+1,2):
  yaku = 0
  for j in range(1,i+1,2):
#    print(i,j)
    if i % j == 0:
      yaku += 1
#  print(yaku)
  if yaku == 8:
    ans += 1
print(ans)

Measured memory_bytes: 3060
#include <cstdio>

int main() {
  int ans = 0, bal = 0;
  char c = getchar();
  while(c != 'S' && c != 'T') {
    c = getchar();
  }
  while(c == 'S' || c == 'T') {
    if(c == 'T') {
      if(bal) {
        --ans;
        --bal;
      }
      else {
        ++ans;
      }
    }
    else {
      ++ans;
      ++bal;
    }
    c = getchar();
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
#define LL long long
#define N 100
int a[N],b[N];
int main()
{
    string s;
    LL k;
    cin>>s>>k;
    int cnt=0;
    int p=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='1')
        {
            cnt++;
            p=i;
        }
        else break;
    }
    if(cnt==0)
    {
        cout<<s[0]-'0'<<endl;
    }
    else if(k<=cnt)
    {
        cout<<1<<endl;
    }
    else
    {
        cout<<s[p+1]-'0'<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
	std::string s;
	std::cin >> s;
	
	int alph[26] {};
	for (char c : s) alph[c - 'a']++;
	
	std::cout << (std::find_if(alph, alph + 26,
		[](int x) { return x > 1; }) == alph + 26 ?
		"yes" : "no") << std::endl;
	
	return 0;
}


Measured memory_bytes: 3164
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	string t(s,n/2);
	t += t;
	cout << (t == s ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
int a,b;
cin >> a >> b;
for(int i=1;i<=b*100;i++){
    double che = i*0.08,chee = i*0.1;
    ll aa = che,bb=chee;
    if(aa==a&&bb==b){cout<<i<<endl; return 0;}
}
cout << -1<<endl;
}




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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
  ll l, r;
  cin >> l >> r;

  int ans = 2018;
  r = min(r, l+4038);
  for (ll i = l; i <= r; i++) {
    for (ll j = i+1; j <= r; j++) {
      int x = i * j % 2019;
      ans = min(ans, x);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
#define MOD 1'000'000'007
using namespace std;
typedef long long ll;
typedef long double ld;

int L,R,d;

int main(){
    cin>>L>>R>>d;

    int ans=0;
    rep(i,R-L+1){
        if((i+L)%d==0) ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int  long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
using namespace std;
/// khodaya komak kon
const int N=2e5;
ll mod=1e9+7;

ll fac[N];
ll power(ll n, ll k){
    if (k==0){
        return 1;
    }
    else{
        if (k%2==0){
            ll x=power(n,k/2);
            return x*x%mod;
        }
        else{
            ll x=power(n,k/2);
            x=x*x%mod;
            return x*n%mod;
        }
    }
}
ll fm[N];
ll ent(ll k, ll n){
	if (k==0 || k==n){
        return 1;
	}

	return (((fac[n]*fm[k])%mod)*fm[n-k])%mod;
}

int32_t main(){
    fac[0] = 1;

	for(int i=1;i<N;i++) {
        fac[i]=(fac[i-1]*i)%mod;
	}
	for(int i=0;i<N;i++) {
        fm[i]=power(fac[i],mod-2);
	}
	ll n,m;
	cin >> n >> m;
	ll a,b;
	cin >> a >> b;
	ll ans=0;
	for (int i=1;i<=n-a;i++){
        ans+=ent(b-1,i-1+b-1)*ent(m-b-1,n-i+m-b-1)%mod;
        ans%=mod;
	}
	cout << ans << endl;

}










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

int main(void){
	int x, y;
	
	while (true){
		cin >> x >> y;
		
		if (x == 0 && y == 0) break;

		if (x > y) cout << y << " " << x << "\n";
		else cout << x << " " << y << "\n";
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    double  a,b;
    long long c=0;
    for(int i=k-1; i<n; i++)
    {
        a=((double)i/2)*(i+1);
        b=((double)(n+n-i)/2)*(n-n+i+1);
        c+=b-a+1;
        c%=1000*1000*1000+7;
    }
   
    cout<<c+1;
}

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

using namespace std;

typedef long long ll;

bool G[10][10]; //隣接行列

int main(){
  ll N,M,i,a,b;
  ll res = 0;
  cin >> N >> M;
  for(i=0;i<=M-1;i++){
    cin >> a >> b;
    a--;
    b--;
    G[a][b] = true;
    G[b][a] = true;
  }
  ll ord[N];
  
  for(i=0;i<=N-1;i++)
    ord[i] = i;
    
  do{
    if(ord[0] != 0) break;
    bool x = true;
    for(i=0;i<=N-2;i++){
      ll from = ord[i];
      ll to = ord[i+1];
      if(!G[from][to]) x = false;
    }
    if(x) res++;
    next_permutation(ord,ord+N);
  }while(true);

  cout << res << endl;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        var nm = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var stuX = new int[nm[0]];
        var stuY = new int[nm[0]];
        var cpX = new int[nm[1]];
        var cpY = new int[nm[1]];
        for (int i = 0; i < nm[0]; i++)
        {
            var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            stuX[i] = inp[0];
            stuY[i] = inp[1];
        }
        for (int i = 0; i < nm[1]; i++)
        {
            var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            cpX[i] = inp[0];
            cpY[i] = inp[1];
        }
        for (int i = 0; i < nm[0]; i++)
        {
            int target = -1;
            int dist = int.MaxValue;
            for (int j = 0; j < nm[1]; j++)
            {
                int nextDist = Math.Abs(cpX[j] - stuX[i]) + Math.Abs(cpY[j] - stuY[i]);
                if (nextDist < dist)
                {
                    dist = nextDist;
                    target = j;
                }
            }
            Console.WriteLine(target + 1);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    string ss;
    cin >> ss;
    vector<int> s(4);
    for(int i=0; i<4; i++){
        s[i]=ss[i];
    }
    sort(s.begin(), s.end());
    if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[2]) cout << "Yes";
    else cout << "No";



    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;
//const int mod = 998244353;


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

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
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= 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
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  rep(i, h) cin >> a[i];

  vector<vector<int>> dist(h, vector<int>(w, INF));
  queue<P> q;
  auto update = [&](P x) {
    int i = x.first, j = x.second;
    rep(k, 4) {
      int ni = i+di[k], nj = j+dj[k];
      if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
      if(dist[ni][nj] == INF) {
        q.push(P(ni, nj));
        dist[ni][nj] = dist[i][j]+1;
      }
    }
  };
  rep(i, h) rep(j, w) {
    if(a[i][j] == '#') {
      dist[i][j] = 0;
      q.push(P(i, j));
    }
  }

  while(!q.empty()) {
    P now = q.front(); q.pop();
    update(now);
  }
  int ans = 0;
  rep(i, h) rep(j, w) chmax(ans, dist[i][j]);
  cout << ans << endl;
}


Measured memory_bytes: 13456
#include <stdio.h>

#define LIMIT 1000000007
typedef long long LL;

LL summin(LL k){
    //0~k-1の和
    LL ans = ((k-1)*k);
    ans /= 2;
    return ans;
}

LL summax(LL k, LL max){
    //~max,k項の和
    LL ans = 2*max;
    ans = (ans-k+1);
    ans = ans*k;
    ans /= 2;
    return ans;
}

int main(){
    LL N, K, k;
    scanf("%lld%lld", &N, &K);
    LL ans = 0, buf;
    for(k=K; k<=N+1; k++){
        buf = summax(k, N) - summin(k) + 1;
        ans += buf;
        ans %= LIMIT;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1732
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        for(int i = a; i <= b; i++){
            if(a <= i && i < a+k){
                System.out.println(i);
            } else if((b-k+1) <= i && i <= b){
                System.out.println(i);
            }
        }
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include <queue>

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;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef pair<int, int> P;

int h, w;
char s[30][30];
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int INF = 1000000000+7;


int bfs(){
    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '#') continue;
            vector<vector<int>> dist(h, vector<int>(w, INF));
            queue<P> q;
            q.push(P(i,j));
            dist[i][j] = 0; //s(i,j)がスタート
            while(!q.empty()){
                int vy = q.front().first;
                int vx = q.front().second;
                q.pop();
                for(int d = 0; d < 4; d++){
                    int nx = vx + dx[d], ny = vy + dy[d]; //次のマスの座標
                    if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
                    if(s[ny][nx] == '#') continue;

                    if(dist[ny][nx] == INF){
                        dist[ny][nx] = dist[vy][vx] + 1;
                        q.push(P(ny, nx));
                    }
                }
            }

            for(int n = 0; n < h; n++){
                for(int m = 0; m < w; m++){
                    if(dist[n][m] == INF) continue;
                    ans = max(ans, dist[n][m]);
                }
            }
        }   
    }
    return ans;
}

int main(){
    cin >> h >> w;
    int M;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> s[i][j];
        }
    }
    M = bfs();
    cout << M << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
from scipy.sparse.csgraph import shortest_path

N,M = map(int,input().split())

edge = [[int(x) for x in input().split()] for _ in range(M)]

graph = np.zeros((N,N)) # 0-indexed
for a,b,c in edge:
  graph[a-1,b-1] = c

dist = shortest_path(graph,directed=False).astype(int)

answer = 0
for a,b,c in edge:
  if c != dist[a-1,b-1]:
    answer += 1
print(answer)

Measured memory_bytes: 14072
#include<cstdio>
#include<cstring>

using namespace std;
typedef long long ll;

int a[100];
ll dp[100][2];
int main()
{
	int n, p;
	scanf("%d%d", &n, &p);
	for(int i=1;i<=n;i++)
	scanf("%d", &a[i]);
	
	ll ans;
	if(p == 0)
	ans = 1ll;
	else 
	ans = 0ll;
	
	memset(dp, 0, sizeof dp);
	for(int i=1;i<=n;i++)
	{
		if(a[i] % 2 == 0)
		{
			dp[i][0] += dp[i-1][0]*2ll + 1;
			dp[i][1] += dp[i-1][1]*2ll;
		}
		else 
		{
			dp[i][1] += dp[i-1][0]+dp[i-1][1] + 1;
			dp[i][0] += dp[i-1][1] + dp[i-1][0];
		}
	}
	if(p == 0)
	dp[n][0] += 1ll;
	
	if(p == 0)
	printf("%lld\n", dp[n][0]);
	else 
	printf("%lld\n", dp[n][1]);
	return 0;
}

Measured memory_bytes: 128
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a > b) swap(a, b);
  if (a < c && c < b) cout << "Yes" << '\n';
  else cout << "No" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3588