akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    int a;
    long long ans = 0,b[100010];
    cin >> a;
   
    for (int i = 0; i < a; i++) {
        cin >> b[i];
        ans ^= b[i];
    }

    if (ans == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
	auto N = readln.split[0].to!int;
	foreach (n; 1 .. 10) {
		if (N <= n*111) { writeln(n*111); return; }
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>
#include <fstream>
#include <ctime>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};

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

    int N, K, Q;
    cin >> N >> K >> Q;

    map<int, int> A;
    REP(i, Q) {
        int a;
        cin >> a;
        a--;
        A[a]++;
    }

    REP(i, N) {
        if (A[i] > Q - K) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5632
import java.util.Scanner;
import java.util.Arrays; 
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    char[] letters = sc.next().toCharArray();
    Arrays.sort(letters);
    if(letters[0] == letters[1] && letters[2] == letters[3] && letters[2] != letters[1]){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21972
#include <iostream>

using namespace std;

int main(void){
    long long N, A[100004], B[100004], count = 0;
    cin >> N;
    for(long long i = 0; i < (N+1); i++){
        cin >> A[i];
    }
    for(int i = 0; i < N; i++){
        cin >> B[i];
        if(B[i] <= A[i]) count += B[i];
        else if((B[i]-A[i]) <= A[i+1]){
            //cout << "@" << endl;
            count += B[i];
            A[i+1] -= (B[i] - A[i]);
        } else{
            //cout << "#" << endl;
            count += (A[i] + A[i+1]);
            A[i+1] = 0;
        }
        //cout << count << endl;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
string sa,sb;
int f[3030][3030],p[3030][3030][2],t[3030][3030],ans[3030],cnt;
void print(int i,int j)
{
	if(i==-1 || j==-1)
		return ;
	print(p[i][j][0],p[i][j][1]);
//	cout<<1<<endl;
//	cout<<i<<' '<<j<<' '<<t[i][j]<<endl;
	if(sa[i]==sb[j] && i<sa.size() && j<sb.size())
	{
		
		ans[cnt++]=i;
	}
}
int main()
{
	cin>>sa>>sb;
	for(int i=0;i<sa.size();i++)
	{
		for(int j=0;j<sb.size();j++)
		{
			if(sa[i]==sb[j])
			{
				f[i][j]=f[i-1][j-1]+1;
				p[i][j][0]=i-1,p[i][j][1]=j-1;
				t[i][j]=1;
			}
			else
			{
				if(f[i-1][j]>=f[i][j-1])
				{
					f[i][j]=f[i-1][j];
					p[i][j][0]=i-1,p[i][j][1]=j;
				}
				else
				{
					f[i][j]=f[i][j-1];
					p[i][j][0]=i,p[i][j][1]=j-1;
				}
			}
		}
	}
	print(sa.size()-1,sb.size()-1);
	for(int i=0;i<cnt;i++)
		cout<<sa[ans[i]];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 143872
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;
typedef pair<int, char> ICpair;

LL a[5000];
vector<LL> vals;

int N, K, Q;

int main() {
	ios_base::sync_with_stdio(false);
	vals.clear();
	cin >> N >> K >> Q;
	FOR (i, N) {
		cin >> a[i];
		vals.pb(a[i]);
	}
	sort(all(vals));
	LL ret = -1LL;
	FOR (curr, N) {
		LL v = vals[curr];
		vector<LL> toUse;
		toUse.clear();
		vector<LL> current;
		int i = 0, j;
		while (i < N) {
			while (i < N && a[i] < v)
				i++;
			if (i == N)
				break;
			j = i + 1;
			while (j < N && a[j] >= v)
				j++;
			current.clear();
			ffor (k, i, j)
				current.pb(a[k]);
			sort(all(current));
			FOR (k, current.sz - K + 1)
				toUse.pb(current[k]);
			i = j;
		}
		sort(all(toUse));
		if (toUse.sz < Q)
			continue;
		LL tmp = toUse[Q - 1] - toUse[0];
		if (ret == -1 || tmp < ret)
			ret = tmp;
	}
	
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
using namespace std;
int w[110], n, D[110], Mod = 1000000007;
int Pow(int a, long long b) {
	int r = 1;
	while (b) {
		if (b & 1)r = 1ll * r*a%Mod;
		a = 1ll * a*a%Mod; b >>= 1;
	}
	return r;
}
int main() {
	int i, j, k;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d", &w[i]);
	}
	D[0] = 1;
	w[n + 1] = 1;
	for (i = 1; i <= n + 1; i++) {
		D[i] = D[i - 1] * 2 % Mod;
		for (j = 1; j < i; j++) {
			int b = max(w[i], w[j - 1]), e = w[j] - 1;
			long long s = 0;
			for (k = j; k < i; k++) {
				e = min(e, w[k] - 1);
				s += max(w[k + 1] - w[k], 0);
			}
			if (b <= e) {
				int t1 = Pow(2, w[j] - 1 - e);
				int t2 = Pow(2, e - b + 1) - 1;
				int t3 = Pow(2, s);
				D[i] = (D[i] + 4ll * D[j - 1] * t1 % Mod* t2%Mod * t3)%Mod;
			}
		}
	}
	printf("%lld\n", 1ll*D[n + 1]*((Mod+1)/2)%Mod);
}

Measured memory_bytes: 128
K = int(input())

lunlun = set()

def dfs(A):
    # 終端条件 --- 10 重ループまで回したら処理して打ち切り
    if len(A) == 10:
        return
    for v in range(0, 10):
        if len(A) != 0:
            if abs(A[-1] - v) > 1:
                continue
        A.append(v)
        lunlun.add(int(''.join(list(map(str, A)))))
        dfs(A)
        A.pop() # これが結構ポイント

dfs([])

print(sorted(list(lunlun))[K])

Measured memory_bytes: 21500
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll n,p,ans=1;
    cin>>n>>p;
    for (int i=2;((ll)i*i)<=p;i++) {
        ll ct=0;
        while (p%i==0) {
            p /= i;
            ct++;
        }
        ct /= n;
        while (ct--) {
            ans *= (ll)i;
        }
    }
    if (p>1 && n==1) ans *= p;
    cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n,cnt=0;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<n-2;i++)
    {
		if(s[i]=='A' and s[i+1]=='B' and s[i+2]=='C')
		{
			cnt++;
		}
	}
	cout<<cnt;
	
	
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<stdio.h>
int main(void)
{
    long ans = 0;
    char c=getchar_unlocked();
    while(c<='9'&&c>='0') {ans=(ans<<1)+(ans<<3)+c-'0'; c=getchar_unlocked();}
    long n = ans + 1;
    int u, v, i = 1;
    while(++i < n)
    {
        u = v = 0;
        c=getchar_unlocked();
        while(c<='9'&&c>='0') {u=(u<<1)+(u<<3)+c-'0'; c=getchar_unlocked();}
        c=getchar_unlocked();
        while(c<='9'&&c>='0') {v=(v<<1)+(v<<3)+c-'0'; c=getchar_unlocked();}
        switch(u > v)
        {
            case 1: ans += i * (n - i) - v * (n - u); break;
            default: ans += i * (n - i) - u * (n - v);
        }
    }
    printf("%ld", ans);
    return 0;
}


Measured memory_bytes: 1604
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
leeway = sum(A) - sum(B)
if leeway < 0:
	print(-1)
else:
	cnt = N
	for i in sorted(range(N), key = lambda x: A[x] - B[x]):
		diff = A[i] - B[i]
		if diff >= 0:
			if diff <= leeway:
				leeway -= diff
				cnt -= 1
			else:
				break
	print(cnt)

Measured memory_bytes: 85680
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();
        int M = sc.nextInt();
        City[] all = new City[M];
        ArrayList<ArrayList<City>> cities = new ArrayList<>();
        for (int i = 0; i <= N; i++) {
            cities.add(new ArrayList<>());
        }
        for (int i = 0; i < M; i++) {
            int P = Integer.parseInt(sc.next());
            int Y = Integer.parseInt(sc.next());
            all[i] = new City(Y, P);
            cities.get(P).add(all[i]);
        }
        for (int i = 0; i <= N; i++) {
            if (cities.isEmpty()) continue;
            Collections.sort(cities.get(i));
            for (int j = 0; j < cities.get(i).size(); j++) {
                cities.get(i).get(j).order = j + 1;
            }
        }
        for (City c : all) {
            System.out.printf("%06d%06d\n", c.pref, c.order);
        }
    }

    static class City implements Comparable<City> {
        int year;
        int pref;
        int order;

        public City(int year, int pref) {
            this.year = year;
            this.pref = pref;
        }

        @Override
        public int compareTo(City o) {
            return Integer.compare(this.year, o.year);
        }
    }
}


Measured memory_bytes: 114800
x,y = map(int, input().split())
ans = 0
d = [300000,200000,100000]
if 1<=x and x<=3:
    ans += d[x-1]

if 1<=y and y<=3:
    ans += d[y-1]

if x==y and x==1:
    ans += 400000

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
map<ll,ll>mp;
map<ll,ll>mpp;
int main()
{
    ll n,k=0,i,j;

   cin>>n;

   for(i=1;i<=n;i++){
       if(i%3!=0 && i%5!=0){
        k+=i;
       }
   }

   cout<<k<<endl;



}


Measured memory_bytes: 3640
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	LL n,a=1,b=1;
	cin>>n;
	FOR(i,0,n){
		LL p,q;
		cin>>p>>q;
		LL mx=(a+p-1)/p;
		LL mx2=(b+q-1)/q;
		a=max(mx,mx2)*p;
		b=max(mx,mx2)*q;
	}
	cout<<a+b;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
const ll INF=1e15;
#define int long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
const double pi = acos(-1.0);
int gcd (int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
int lcm (int a, int b) {
    return a / gcd(a, b) * b;
}
 
long long binpows(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)  //impar
            res = res * a;
        a = a * a;
        b >>= 1;  // /2
    }
    return res;
}
const int mod=1e9+7;
int binpow(int a, int b, int m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
//CHECAR SE PRECISA DE LONG LONG
vector<int> adj[1234567];
int dp[1234567][2];
int n;
int resolve(int pos,bool b,int pai){
    if(adj[pos].size()==1 and pai!=-1){
        return 1+!b;
    }
    int &x=dp[pos][b];
    if(x!=-1)
        return x;
    x=1;
    int aux1=1;
    int aux2=1;
    for(auto it: adj[pos]){
        if(it!=pai){
            if(!b){
                aux1*=resolve(it,1,pos);
                aux1%=mod;
            }
            aux2*=resolve(it,0,pos);
            aux2%=mod;
        }
    }
    x=aux2+(b==0?aux1:0);
    return x%=mod;
}
void solve(){
    memset(dp,-1,sizeof(dp));
	cin>>n;
    for(int i=0; i<n-1; i++){
        int a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    cout<<resolve(1,0,-1)<<endl;
}
//revise as variaveis e a ordem nas funções
signed main(){fastio;
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 63272
#include <bits/stdc++.h>
#define MAX 0

using namespace std;

#define fst first
#define snd second

#define mp make_pair
#define pb push_back

typedef pair<int,int> ii;
typedef long long ll;

int main() {
  int x, a, b;
  scanf("%d %d %d", &x, &a, &b);
  printf("%d\n", (x - a) % b);

  return 0;
}

Measured memory_bytes: 256
n, k = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]
total = sum(a)

def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

divs = divisors(total)
# print(divs)
for div in divs[::-1]:
    mod_div = [0] * n
    mod_sum = 0
    opr_cnt = 0
    for i, item in enumerate(a):
        mod_div[i] = item % div
    mod_sum = opr_cnt = sum(mod_div)
    mod_div.sort()
    for i, item in enumerate(mod_div[::-1]):
        if mod_sum == 0:
            break
        # print(item, opr_cnt)
        mod_sum -= div
        opr_cnt += div - 2 * item
    if opr_cnt <= k * 2:
        print(div)
        exit()
    # print(div, opr_cnt)

Measured memory_bytes: 42732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    ll N, K; cin >> N >> K;
    vector<pair<int, int>> a(N);
    for(int i=0; i<N; i++) cin >> a[i].first >> a[i].second;

    sort(a.begin(), a.end());
    ll cnt = 0;
    for(int i=0; i<N; i++){
        cnt += (ll)a[i].second;
        if(cnt >= K){
            cout << a[i].first << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+1;
const int mod = 1e9+7;
int main() {
	int n;
	sd(n);
	ll ans=0;
	for(int i = 1; i <= n; i++) if((i%3)&&(i%5)) ans+=i;
	plld(ans);
	return 0;
}

Measured memory_bytes: 3760
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

// -----------------------------------------------------------------------------------------------------

// -----------------------------------------------------------------------------------------------------

let main() =
    let N = read int
    let A = Array.zeroCreate (N + 1)
    for i in 0 .. N - 1 do
        let a = read int64
        A.[i] <- a

    let mutable ans = 0L
    for i in 0 .. N - 1 do
        let a = A.[i] / 2L
        ans <- ans + a
        A.[i] <- A.[i] % 2L
        if A.[i] > 0L && A.[i + 1] > 0L then
            ans <- ans + 1L
            A.[i] <- A.[i] - 1L
            A.[i + 1] <- A.[i + 1] - 1L

    puts ans
    ()

// -----------------------------------------------------------------------------------------------------
main()
writer.Dispose()


Measured memory_bytes: 17464
#include "bits/stdc++.h"
#define REP(i, m, n) for(long long i = m; i < n; ++i)
#define CO(n) cout << n << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

ll H;
ll ans = 0;
ll cnt = 0;

int main()
{
    ios::sync_with_stdio(false);
    cin >> H;
    while (H) {
        H /= 2;
        ans += pow(2,cnt);
        cnt += 1;
    }
    CO(ans);
    return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int ar[n];
    for(int i=0;i<n;i++){
        cin >> ar[i];
    }

    sort(ar,ar+n);

    double sum=(double)(ar[0]+ar[1])/2;
    for(int i=2;i<n;i++){
        sum=(double)(sum+ar[i])/2;
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
// clang-format off
	#include <bits/stdc++.h>
	using namespace std; using ll = long long; using uint = unsigned int;
	#define SFINAE(x, ...)	template <class, class = void> struct x : false_type {}; template <class T> struct x<T, void_t<__VA_ARGS__>> : true_type {};
	SFINAE(DefaultIO, decltype(cout << declval<T &>()))
	SFINAE(IsTuple, typename tuple_size<T>::type)
	SFINAE(Iterable, decltype(begin(declval<T>())))
	template <class T> constexpr char Space(const T &) { return (Iterable<T>::value or IsTuple<T>::value) ? '\n' : ' '; }
	template <auto &os> struct Writer {
		template <class T> void Impl(T const &t) const {
			if constexpr (DefaultIO<T>::value) os << t;
			else if constexpr (Iterable<T>::value) { int i = 0; for (auto &&x : t) ((i++) ? (os << Space(x), Impl(x)) : Impl(x)); }
			else if constexpr (IsTuple<T>::value) apply([this](auto const &... args) { int i = 0; (((i++) ? (os << ' ', Impl(args)) : Impl(args)), ...);}, t);
			else static_assert(IsTuple<T>::value, "No matching type for print");
		}
		template <class F, class... Ts> auto &operator()(F const &f, Ts const &... ts) const { return Impl(f), ((os << ' ', Impl(ts)), ...), os << '\n', *this; }
	};
	template <auto &is> struct Reader {
		template <class T> auto& operator()(T &t) const {
			if constexpr (DefaultIO<T>::value) is >> t;
			else if constexpr (Iterable<T>::value) for (auto &x : t) (*this)(x);
			else if constexpr (IsTuple<T>::value) apply([this](auto &... args) { ((*this)(args), ...); }, t);
			else static_assert(IsTuple<T>::value, "No matching type for read");
			return *this;
		}
	};
	#ifdef NARUT_LOCAL
	#define Debug(...) cerr << "\033[0;31m", Writer<cerr>{}(__VA_ARGS__), cerr << "\033[0m\n"
	#else
	#define Debug(...) 0
	#endif
	[[maybe_unused]] constexpr Reader<cin> Cin; [[maybe_unused]] constexpr Writer<cout> Cout;
	#define FOR(i, j, n) for (int i = int(j); i < int(n); ++i)
	#define ROF(i, j, n) for (int i = int(n) - 1; i >= int(j); --i)
// clang-format on


auto Main() {
	uint h,w,k;
	cin>>h>>w>>k;
	array<uint,2> src, dst;
	Cin(src)(dst);

	vector<string> G(h);
	Cin(G);

	vector<vector<uint>> dist(h, vector<uint>(w, -1));
	src[0]--, src[1]--, dst[0]--, dst[1]--;
	dist[src[0]][src[1]]=0;

	queue<array<uint,2>> q({{src[0], src[1]}});
	constexpr array deltas = {pair{-1, 0}, pair{0, -1}, pair{1, 0}, pair{0, 1}};
	while (q.size()) {
		auto [u,v]= q.front();
		q.pop();

		uint d = dist[u][v]+1;
		for(auto [dx, dy] : deltas) {
			FOR(p,1,k+1) {
				uint i = u+p*dx, j = v+p*dy;
				// if (d==5 and dx==1 and dy==0) {
				// 	Debug("in", i,j, p);
				// }
				if (i >= h or j >= w) break;
				if (G[i][j]=='@') break;
				if (d > dist[i][j]) break;
				if (d==dist[i][j]) continue;
				// if (d==5 and dx==1 and dy==0) {
				// 	Debug("out",i,j, p);
				// }
				dist[i][j]=d;
				q.push({i,j});
			}
		}
	}
	Debug(dist);
	cout << int(dist[dst[0]][dst[1]]);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
#ifdef NARUT_LOCAL
	assert(freopen("io/test.in", "r", stdin));
	cin.exceptions(cin.badbit | cin.failbit);
	cerr << fixed << setprecision(10);
#endif

	Main();
}


Measured memory_bytes: 12184
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    tmp0 = input[0].split(" ");
    N = Number(tmp0[0]);
    M = Number(tmp0[1]);
    A = input[1].split(" ").map(str => parseInt(str,10));
    // console.log(A)
    A = A.sort((a, b) => a-b)
    // console.log(A)

    BCdict=[]
    for(var i=1; i<=M;i++){
        tmp = input[i+1].split(" ")
        // tmp[0] // Bi
        // tmp[1] // Ci
        obj = {"value": Number(tmp[1]), "count": Number(tmp[0])}
        BCdict.push(obj)
    }
    // console.log(BCdict)
    BCdict = BCdict.sort((a,b) => b.value - a.value)
    // console.log(BCdict)

    // BCarray = []
    // for(var i=0; i < BCdict.length; i++)
    // {
    //     BCarray = BCarray.concat(Array.apply(null, Array(BCdict[i].count)).map(function(){return BCdict[i].value}))
    // }
    // // console.log(BCarray)

    // for(var i=0; i < BCarray.length; i++)
    // {
    //     if(BCarray[i] > A[i]){
    //         A[i] = BCarray[i]
    //     }else{
    //         break
    //     }
    // }

    dictIndex = 0
    dictCount = 0    
    for(var i=0; i < A.length; i++)
    {
        var value = BCdict[dictIndex].value
        if(value > A[i])
        {
            A[i] = value
            dictCount++
            if(dictCount == BCdict[dictIndex].count){
                dictIndex++
                dictCount=0
                if(dictIndex == BCdict.length){
                    break
                }
            }
        }else{
            break
        }
    }

    
    var ans=0
    for(var i=0; i < A.length; i++)
    {
        ans += A[i]
    }
    console.log(ans)
  }
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//   Main("3 2\n5 1 4\n2 3\n1 5\n");

Measured memory_bytes: 54084
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(i) i.begin(),i.end()
template<typename T=ll>
using v =vector<T>;
template<typename T=ll>
using vv = vector<v<T>>;
//using p = pair<ll,ll>;
const ll INF = (ll)1e9;
template<typename T> T chmin(T &a,T b){a=min(a,b);}
template<typename T> T chmax(T &a,T b){a=max(a,b);}
ll n,k;
ll r,s,p;//r:g,s:c,p:p
string t;
int main(){
    cin >> n >> k;
    cin >> r >> s >> p;
    cin >> t;
	t = '#'+t;
  	ll ans =0;
 	for(ll i=1;i<=n;i++){
    	if(t[max(0LL,i-k)]==t[i]) t[i]=-1;
      	if(t[i]=='r') ans+=p;
    	else if(t[i] == 's') ans+=r;
      	else if(t[i] == 'p') ans +=s;
    }
  	cout << ans << endl;
  	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector <long> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    long ans = 0;
    for(int i = 0; i < n; i++){
        if(a[i]%2==1){
            break;
        }else{
            a[i]/=2;
        }
        if(i==n-1){
            ans++;
            i=0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
long long g[87]={2,1};
int main()
{
	int n;
	cin>>n;
	for(int i=2;i<=n;i++)
	{
		g[i]=g[i-1]+g[i-2];
	}
	cout<<g[n];
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int ans[3]={0};
    for(int i=0;i<3;i++)
    {
        int j=i;
        while(s[j]=='R'&&j<3) ans[i]++,j++;
    }
    int res=0;
    for(int i=0;i<3;i++)
        res=max(res,ans[i]);
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

void AllSum(vector<vector<int>> & d) {
	int i, j;
	rep(i, d.size()) {
		rep(j, d[i].size() - 1)
			d[i][j + 1] += d[i][j];
	}
	rep(j, d[0].size()) {
		rep(i, d.size() - 1)
			d[i + 1][j] += d[i][j];
	}
	return;
}

int main(void) {
	int num, i, j, k, kk, a, b, ans = 0, sum;
	char c;
	cin >> num >> k;
	kk = k << 1;
	vector<vector<int>> d(k, vector<int>(kk, 0));
	rep(i, num) {
		cin >> a >> b >> c;
		if (c == 'W')
			a += k;
		a %= kk;
		b %= kk;
		if (a >= k) {
			a -= k;
			b += k;
			b %= kk;
		}
		d[a][b]++;
	}
	AllSum(d);
	rep(i, k) {
		rep(j, k) {
			sum = (d[i][j] << 1) + d[k - 1][j + k] - d[i][j + k] - d[k - 1][j];
			if (j < k - 1)
				sum += d[i][kk - 1] - d[i][j + k];
			chmax(ans, sum);
			chmax(ans, num - sum);
		}
	}
	cout << ans << "\n";
	return 0;
}

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

typedef long long ll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

const char nl = '\n';

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    int a, b, c; cin >> a >> b >> c;
    int x[3] = {a, b, c};
    sort(x, x + 3);
    int d1 = x[2] - x[1];
    int d2 = x[2] - x[0];
    int ans;
    if ((d1 & 1) != (d2 & 1)) {
        d2++;
        ans = 1;
        if (d2 & 1) ans += 1 + d2 / 2 + d1 / 2;
        else ans += d2 / 2 + d1 / 2;
    } else {
        if (d1 & 1) ans = 1 + d1 / 2 + d2 / 2;
        else ans = d1 / 2 + d2 / 2;
    }
    cout << ans << nl;
}

Measured memory_bytes: 3556
/*
AizuOnline A0527
Title
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int N;
char ban[100001];
//
void show()
{
  int i;
  char c;
  for(i=1;i<=N;i++)
    {
      if(ban[i]==1)
	c='o';
      else if(ban[i]==0)
	c='*';
      else
	c='.';
      printf("%c",c);
    }
  printf("\n");
}
main()
{
  int i,j,cnt,isi;

  while(EOF!=scanf("%d ",&N) && N)
    {
      memset(ban,-1,sizeof(ban));
      for(i=1;i<=N;i++)
	{
	  scanf("%d",&isi);
	  ban[i]=isi;
	  
	  if((i&1)==0)
	    {  j=i-1;
	      while(j>0 && ban[j]+isi==1)
		{
		  ban[j]=isi;
		  j--;
		}
	    }
	  //show();
	}
      cnt=0;
      for(i=1;i<=N;i++)
	cnt += (ban[i]==0);
      
      printf("%d\n",cnt);
    }
return(0);
}

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

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  int m = 0;

  if (A + B > 2 * C) {
    m = min(X, Y);
    X -= m;
    Y -= m;
    m *= 2;
  }
  if (X > 0 && A > 2 * C) {
    m += 2 * X;
    X = 0;
    Y = 0;
  }
  if (Y > 0 && B > 2 * C) {
    m += 2 * Y;
    X = 0;
    Y = 0;
  }

  cout << A * X + B * Y + C * m << endl;
  return 0;
}


Measured memory_bytes: 256
s = input()

n = len(s)
ans = "Yes"

if s != s[::-1]:
    ans = "No"
elif s[:(n-1)//2] != s[:(n-1)//2][::-1]:
    ans = "No"
elif s[(n+2)//2:] != s[(n+2)//2:][::-1]:
    ans = "No"
    
print(ans)

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

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

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; }

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

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

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

int main() {
    int n, w;
    cin >> n >> w;
    vector<P> wv(n);
    rep(i, n) cin >> wv[i].first >> wv[i].second;

    vector<vector<int> > dp(n + 1, vector<int> (100100, INF));

    dp[0][0] = 0;
    rep(i, n) {
        rep(j, 100100) {
            if (j >= wv[i].second) chmin(dp[i + 1][j], dp[i][j - wv[i].second] + wv[i].first);
            chmin(dp[i + 1][j], dp[i][j]);
        }
    }
    int ans = 0;

    rep(i, 100100) {
        if (dp[n][i] <= w)
            ans = max(ans, i);
    }
    cout << ans << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

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

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 43380
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using vvii = vector<vector<int> >;
using vvll =  vector<vector<ll> >;

const ll inf = 1LL << 60;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    string S,T; 
    cin >> S;
    cin >> T;
    int ans = 0;
    REP(i,S.length()){
        if(S[i] != T[i]){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3796
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int n, ans_a, ans_b, ans_c, min_cost;
vi l(8);
void DFS(int i, int a, int b, int c, int cost){
	if(i==n&&a>0&&b>0&&c>0){
		int ans=cost+abs(ans_a-a)+abs(ans_b-b)+abs(ans_c-c)-30;
		min_cost=min(min_cost, ans);
		return;
	} else if(i==n){
		return;
	}

	DFS(i+1, a+l[i], b, c, cost+10);

	DFS(i+1, a, b+l[i], c, cost+10);

	DFS(i+1, a, b, c+l[i], cost+10);

	DFS(i+1, a, b, c, cost);
}
int main(void)
{
	cin>>n>>ans_a>>ans_b>>ans_c;

	rep(i, n) cin>>l[i];

	min_cost=1e9;

	DFS(0, 0, 0, 0, 0);

	cout<<min_cost<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
template<typename T, int FAC_MAX> struct Comb { vector<T> fac, ifac;
    Comb() {fac.resize(FAC_MAX, 1); ifac.resize(FAC_MAX, 1);rep(i, 1, FAC_MAX) fac[i] = fac[i - 1] * i;
        rep(i, 1, FAC_MAX) ifac[i] = T(1) / fac[i];}
    T aPb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b]; }
    T aCb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b] * ifac[b]; }
    T nHk(int n, int k) { if (n == 0 && k == 0) return T(1); if (n <= 0 || k < 0) return 0;
        return aCb(n + k - 1, k); }
};
typedef ModInt<1000000007> mint;
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
 
 
Comb<mint, 201010> com;
int N, M;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M;
 
    mint ans = 0;
    
    if (M == N) ans = com.aPb(N, N) * com.aPb(M, M) * 2;
    else if (abs(N - M) == 1) ans = com.aPb(N, N) * com.aPb(M, M);
    else ans = 0;
 
    cout << ans.get() << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if((a==b && a!=c) || (b==c && b!=a) || (c==a && c!=b)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
  lint N,M;
  cin>>N>>M;
  lint a[100],b[100],c[100],d[100],ans[100];
  for(int t=0;t<N;t++)cin>>a[t]>>b[t];
  for(int t=0;t<M;t++)cin>>c[t]>>d[t];

  for(int t=0;t<N;t++){
    lint min=abs(a[t]-c[0])+abs(b[t]-d[0])+1;
    ans[t]=0;
    for(int i=0;i<M;i++){
      lint temp=abs(a[t]-c[i])+abs(b[t]-d[i]);
      if(temp<min){
        min=temp;
        ans[t]=i+1;
      }
    }
  }

  for(int t=0;t<N;t++){
    cout<<ans[t]<<"\n";
  }
  return 0;
}


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

int main(){
  int N,M;
  cin >> N >> M;
  int lmax,rmin;
  lmax=0,rmin=N;
  for(int i=0;i<M;i++){
    int l,r;
    cin >> l >> r;
    if(l>lmax){
      lmax=l;
    }
    if(r<rmin){
      rmin=r;
    }
  }
  int ans;
  if(rmin-lmax+1>0){
    ans=rmin-lmax+1;
  }
  else{
    ans=0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll          long long int
#define pii         pair<int,int>
#define uu          first
#define vv          second
#define fastIO      ios::sync_with_stdio(0);cin.tie(0);
using namespace std;

const int MAX = 2e5 + 5;
const int MOD = 1e9 + 7;
int main()
{
    fastIO;
    int n;
    cin>>n;
    vector<double>vec(n+1);
    vector< vector<double> > dp(n+1, vector<double>(n+1));
    for(int i =1; i <=n ; i++ ) cin>>vec[i];
    dp[0][0] = 1;
    
    for(int i =1 ; i <=n ; i++) {
        for(int j = 0 ; j <=i ; j++ ) {
            dp[i][j] = dp[i-1][j]*(1.0-vec[i]);
            if(j) dp[i][j] += dp[i-1][j-1]*vec[i] ;
        }
    }
    
    double ans = 0;
    for(int i= n/2 + 1; i <=n ; i++ ) ans += dp[n][i];
    cout<<setprecision(12)<<fixed<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 73672
#include<bits/stdc++.h>
using namespace std;
long long ret5(long long num){
  return num*num*num*num*num;
}
int main()
{
  int X;
  cin>>X;
  for(long long i=-200;i<200;i++){
    for(long long j=-200;j<200;j++){
      if(ret5(i)==X+ret5(j)){
        cout<<i<<" "<<j;
        return 0;
      }
    }
  }
  cout<<0;
  return 0;
}


Measured memory_bytes: 3592
table = %w(black blue lime aqua red fuchsia yellow white)

until (rgb = $<.gets.chomp) == "0"
  color = rgb[1..-1].chars.each_slice(2).map {|a| a.join.to_i(16)}
  idx = [0, 0xff].repeated_permutation(3).map.with_index do |tc, i|
    [3.times.map {|i| (tc[i] - color[i]) ** 2}.sum, i]
  end.sort.first.last
  puts table[idx]
end


Measured memory_bytes: 7068
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
//V,P(大文字)使用不可
//乗算の際にオーバーフローに注意せよ！！（適切にmodをとれ）
//制約をよく読め！

const ll INF=1e18;

signed main(){
    int n,k;
    cin>>n>>k;
    if(k>(n-1)*(n-2)/2) cout<<-1<<endl;
    else{
        vector<pair<int,int>> p;
        for(int i=2;i<=n;i++) p.push_back(make_pair(1,i));
        int m=(n-1)*(n-2)/2-k;
        int u=2,v=3;
        while(m--){
            p.push_back(make_pair(u,v));
            if(v==n){
                u++;
                v=u+1;
            }else v++;
        }
        cout<<p.size()<<endl;
        for(auto pp:p) cout<<pp.ft<<' '<<pp.sc<<endl;
    }
}

Measured memory_bytes: 384
import sys
from collections import deque
from collections import  Counter
import statistics
import math
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

d, n = na()
if n != 100:
    print(100 ** d * n)
else:
    print(101 * (100 ** d))


Measured memory_bytes: 5132
#include<stdio.h>

int main(){
  int x, y, x_group, y_group;
  
  scanf("%d %d", &x, &y);
  
  if(x == 2){
    x_group = 3;
  } else if(x == 4 || x == 6 || x == 9 || x == 11){
    x_group = 2;
  } else {
    x_group = 1;
  }
  if(y == 2){
    y_group = 3;
  } else if(y == 4 || y == 6 || y == 9 || y == 11){
    y_group = 2;
  } else {
    y_group = 1;
  }
  
  if(x_group == y_group){
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
n, m, c = map(int,input().split())
b = list(map(int,input().split()))
ans = 0

for i in range(n):
  a = list(map(int,input().split()))
  count = 0
  for j in range(m):
    count += b[j]*a[j]
  if count+c > 0:
      ans += 1
print(ans)

Measured memory_bytes: 9072
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
using namespace std;
int a[2][105];
int sum1[105],sum2[105];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<2;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>a[i][j];
		}
	}
	sum1[0]=a[0][0];
	sum2[0]=a[1][0];
	for(int i=1;i<n;i++)
	{
		sum1[i]+=sum1[i-1]+a[0][i];
		sum2[i]+=sum2[i-1]+a[1][i];
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		ans=max(ans,sum1[i]+sum2[n-1]-sum2[i-1]);
	}
	cout<<ans;
	return 0;
}

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

int num[6];
int table[1000000];

void numset(int n,int l){
  for(int i=l-1;i>=0;i--){
    if(n!=0){
      num[i]=n%10;
      n=n*0.1;
    }else{
      num[i]=0;
    }
  }
}

int max_f(int l){
  int n=0;
  for(int i=l-1;i>=0;i--){
    n+=num[i];
    n*=10;
  }
  return n/10;
}

int min_f(int l){
  int n=0;
  for(int i=0;i<l;i++){
    n+=num[i];
    n*=10;
  }
  return n/10;
}

int main(){
  int a,L;
  while(cin>>a>>L,L){
    memset(table,0,sizeof(table));
    table[a]=1;
    int i;
    for(i=2;i<=25;i++){
      numset(a,L);
      sort(num,num+L);
      int min = min_f(L);
      int max = max_f(L);
      a=max-min;
      if(table[a]!=0){
	break;
      }else{
	table[a]=i;
      }
    }
    cout<<table[a]-1<<" "<<a<<" "<<i-table[a]<<endl;
  }
  return 0;
}

Measured memory_bytes: 5088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18
#define MAX_V 100005

struct edge{int to, cost;};
vector <edge> G[MAX_V];

int d[MAX_V], dt[MAX_V], da[MAX_V];
int V, E;

void dijkstra2(int s){
    // queの中身は頂点．P<最短距離, 頂点番号>で格納されている．
    // greater<P> を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0,s));

    while(!que.empty()){
        P p=que.top(); que.pop();
        int v=p.second;
        if(d[v] < p.first) continue; // これはなんのために
        for(int i=0; i<G[v].size(); ++i){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}


int main(){
    cin >> V;
    int u, v;
    cin >> u >> v;
    u--;
    v--;

    rep(i, V-1){
        int from_, to_;
        cin >> from_ >> to_;
        --from_;
        --to_;
        edge e;
        e.to = to_; e.cost = 1;
        G[from_].emplace_back(e);
        e.to = from_;
        G[to_].emplace_back(e); // 戻る方向のも追加が必要！！
    }

    dijkstra2(u);
    rep(i, V){
        dt[i] = d[i];
    }

    dijkstra2(v);
    rep(i, V){
        da[i] = d[i];
    } 

    int ans = 0;
    rep(i, V){
        if(dt[i]<da[i]){
            int t=dt[i];
            int a = da[i];
            ans = max(ans, a-1);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7948