akhauriyash/Code-Regression huggingface dataset:
//                                                   ¯\_(ツ)_/¯
  #pragma GCC optimize("Ofast")
 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
#define pi pair<int,int>
const int N=1e5,MOD=998244353;

using namespace std;

string a,b;
int dp[3005][3005];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);


	cin>>a>>b;

	for(int i=0;i<sz(a);i++){

		for(int j=0;j<sz(b);j++){

			if(a[i]==b[j])dp[i+1][j+1]=1+dp[i][j];
			else dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
		}
	}

	string ans ;

	pair<int,int>curr = {sz(a),sz(b)};

	while(curr.first != 0 && curr.second != 0){

		int i = curr.first , j =curr.second;

		if(a[i-1]==b[j-1])ans.pb(a[i-1]),curr={i-1,j-1};
		else{
			if(dp[i-1][j]>dp[i][j-1])curr={i-1,j};
			else curr={i,j-1};
		}
	}

	reverse(all(ans));

	cout<<ans<<'\n';
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  long long cnt=0,sum=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='B')cnt++;
    else sum+=cnt;
  }
  cout<<sum<<endl;
  return(0);
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.util.OptionalInt;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(n);

            int max = Arrays.stream(a).max().getAsInt();

            int cntMax = 0;
            int cntMaxMinus1 = 0;
            for (int i = 0; i < n; i++) {
                if (a[i] == max) {
                    cntMax++;
                } else if (a[i] == max - 1) {
                    cntMaxMinus1++;
                } else {
                    out.println("No");
                    return;
                }
            }

            if (cntMaxMinus1 == 0) {
                if (max == n - 1 || 2 * max <= n) {
                    out.println("Yes");
                    return;
                }
            } else {
                if (cntMaxMinus1 < max && 2 * (max - cntMaxMinus1) <= cntMax) {
                    out.println("Yes");
                    return;
                }
            }

            out.println("No");
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 36836
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
 
int main(){
  int N, C, K;
  cin >> N >> C >> K;
  int T[N];
  for (int i=0;i<N;i++) cin >> T[i];
  sort(T, T+N);
  
  int bus = 1, start=0;
  for (int i=0;i<N;i++){
    if (T[i]-T[start]>K || i-start>=C) {
      bus++;
      start = i;
    }
    
  }

  cout << bus << endl;
}
 

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> state;
long double pi = acos(-1);
const int INF = 1001001001;
const int N_MAX = 100001;

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }
int ceil(int a,int b){
  // a/bの切り上げを考える
  return (a+b-1)/b;
}

int main(){
  int n;
  cin >> n;
  int h[n], dp[n];

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

  rep(i,n)dp[i] = INF;
  dp[0] = 0;

  for (int i = 0;i < n-1;i++) {
    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]));
    if(i != n-2)
      dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]));
  }
  cout << dp[n-1] << endl;
  
}

Measured memory_bytes: 4396
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define mk  make_pair
#define pb  push_back
#define pi 3.141592653589793238

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    double n;
    cin>>n;
    double ans=2.0*pi*n;
    cout<<fixed<<setprecision(20)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3796
#include <stdio.h>

int main (){
    int a[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            scanf("%d", &a[i][j]);
        }
    }
    int ce[3][3] = {};
    int n;
    scanf("%d", &n);
    int x;
    for(int i = 0; i < n; i++){
        scanf("%d", &x);
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(x == a[j][k]){
                    ce[j][k]++;
                    if((ce[0][0] > 0 && ce[0][1] > 0 && ce[0][2] > 0) || (ce[1][0] > 0 && ce[1][1] > 0 && ce[1][2] > 0) || (ce[2][0] > 0 && ce[2][1] > 0 && ce[2][2] > 0) || (ce[0][0] > 0 && ce[1][0] > 0 && ce[2][0] > 0) || (ce[0][1] > 0 && ce[1][1] > 0 && ce[2][1] > 0) || (ce[0][2] > 0 && ce[1][2] > 0 && ce[2][2] > 0) || (ce[0][2] > 0 && ce[1][1] > 0 && ce[2][0] > 0) || (ce[0][0] > 0 && ce[1][1] > 0 && ce[2][2] > 0)){
                        puts("Yes");
                        return 0;
                    } 
                }
            }
        }
    }
    puts("No");    


    return 0;
}

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

int main() {
  string S = "";
  cin >> S;
  string ans = "";
  if(S[0] == S[1] && S[1] == S[2]) {
    ans = "No";
  }
  else {
    ans = "Yes";
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>

using namespace std;

#define sz(a) static_cast<int>((a).size())
#define f first
#define s second
#define els(v) for (auto &el : (v))


#ifdef KIRYA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h << "\n";
}

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

void solve() {
    char c;
    cin >> c;
    cout << char(c + 1) << '\n';
}

int main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    
    int q = 1;

    for (int i = 0; i < q; ++i) {
        solve();
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

void trace(int A[],int N){
  REP(i,N){
    if(i>0){
      cout<<" ";
    }
    cout<<A[i];
  }
  cout<<endl;
}
void insertionSort(int A[],int N){
  int j,v;
  FOR(i,1,N){
    v=A[i];
    j=i-1;
    while (j>=0&&A[j]>v) {
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    trace(A,N);
  }
}

int main(void){
    int N;
    int A[100];
    cin>>N;
    REP(i,N){
      cin>>A[i];
    }
    trace(A,N);
    insertionSort(A,N);


    return 0;
}



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

int main(){
    int N, Cl;
    std::cin >> N >> Cl;
    std::vector< int > S(N);
    std::vector< int > T(N);
    std::vector< int > C(N);
    std::vector< std::pair< int, int > > SC(N);
    std::vector< std::pair< int, int > > TC(N);
    for(int i=0; i<N; i++){
        std::cin >> S[i] >> T[i] >> C[i];
        SC[i].first = S[i];
        SC[i].second = C[i];
        TC[i].first = T[i];
        TC[i].second = C[i];
    }
    
    std::sort(SC.begin(), SC.end());
    std::sort(TC.begin(), TC.end());
    
    int max = 0;
    std::map< int, int > mp;
    int s_index = 0;
    int t_index = 0;
    
    for(int i=1; i<=1e5; i++){
        int s_index_tmp = s_index;
        while(s_index_tmp != N && SC[s_index_tmp].first == i){
            mp[SC[s_index_tmp].second] = 1;;
            s_index_tmp++;
        }
        if(max < mp.size()){
            max = mp.size();
        }
        while(t_index != N && TC[t_index].first == i){
            auto itr = mp.find(TC[t_index].second);
            mp.erase(itr);
            t_index++;
        }
        
        while(s_index != N && SC[s_index].first == i){
            mp[SC[s_index].second] = 1;;
            s_index++;
        }
    }
    
    std::cout << max << std::endl;
    
    
    return 0;
    
}


Measured memory_bytes: 5908
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
using namespace std;

int main(void)
{
    int r;
    cin >> r;
    if(r < 1200){
        cout << "ABC" ;
        return 0;
    }else if(1200 <=r && r <2800){
        cout << "ARC";
        return 0;
    }
    else
    {
        cout << "AGC";
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
		int X = sc.nextInt(); //動物の数
		int Y = sc.nextInt(); //足の総数
		int num = 0;
		//鶴の数をiとすれば、亀の数はx-iだけ存在する
		
		for ( int i = 0; i <= X; i++) {
			if (Y == i*2 + (X - i)*4) {
			//	System.out.println("鶴:"+i + " ,亀:"+ (X-i));
				break;
			}
			else
				num++;
		}
		
		if ( num == (X+1))
			System.out.println("No");
		else
			System.out.println("Yes");
  }
}

Measured memory_bytes: 35916
using System;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            long X = cin.NextLong();
            long N = 100;
            int K = 0;
            while(N < X)
            {
                N += N /100;
                K++;
            }
            Console.WriteLine(K);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public string[] ArrayNext(int N)
        {
            string[] Array = new string[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Next();
            }
            return Array;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 17880
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    int ans = 0;
    while(1){
        bool pro = true;
        for(int i = 0; i < N; i++){
            if(A.at(i) % 2 == 0){
                A.at(i) /= 2;
            }
            else{
                pro = false;
            }
        }
        if(!pro){
            break;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(void) {
    int K, X;
    
    cin >> K >> X;
    
    if (500 * K >= X) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << 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++)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1LL<<30;

int main() {
    int x;
    cin >> x;
    x = (x+5)%7;

    if (x == 0) cout << "sat" << endl;
    if (x == 1) cout << "sun" << endl;
    if (x == 2) cout << "mon" << endl;
    if (x == 3) cout << "tue" << endl;
    if (x == 4) cout << "wed" << endl;
    if (x == 5) cout << "thu" << endl;
    if (x == 6) cout << "fri" << endl;

    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() { 
    string s;
    cin >> s;
    int n = s.size();
    
    int res = n;
    for (int i = 1; i < n; i++) {
        if (s[i] != s[i - 1]) {
            // i -> n - i 
            res = min(res, max(i, n - i));
        }
    }
    cout << res << endl;
}




Measured memory_bytes: 3760
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int i, j, tempL, tempR;
        int L = Integer.MIN_VALUE;
        int R = Integer.MAX_VALUE;
        for (i = 0; i < m; i++) {
            tempL = sc.nextInt();
            tempR = sc.nextInt();
            L = Math.max(L, tempL);
            R = Math.min(R, tempR);
        }

        if (L > R) {
            System.out.println(0);
            return;
        } else {
            System.out.println(R - L + 1);
        }

        sc.close();

    }
}


Measured memory_bytes: 61480
<?php
  list($n, $k) = explode(" ", trim(fgets(STDIN)));

  $l = array_map('intval', explode(" ", trim(fgets(STDIN))));

  rsort($l);

  $ans=0;
  for($i=0;$i<$k;$i++){
    $ans+=$l[$i];
  }
  echo $ans;

Measured memory_bytes: 16232
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N; cin >> N;
  string S; cin >> S;
  vecll Ws(N+1);
  Ws[0] = 0;
  REP(i, N) {
    Ws[i+1] = Ws[i] + (S[i] == 'W');
  }
  ll res = 10000000;
  REP(i, N) {
    ll es = (N-1-i) - (Ws[N]-Ws[i+1]);
    ll ws = Ws[i];
    res = min(es+ws, res);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3076
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef long long ll;

int main()
{
	int x;
	scanf("%d", &x);
	int n = (x / 100) * 105;
	if (x > n)
		printf ("0\n");
	else
		printf("1\n");
	return (0);
}


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

int main() {
  
  int N;
  cin >> N;
  if(N>=100){
    N=N%100;
  }
  if(N>=10){
    N=N%10;
  }
  if(N==3){
    cout << "bon" << endl;
  }
  else if(N==0 || N==1 || N==6 || N==8){
    cout << "pon" << endl;
  }
  else {
    cout << "hon" << endl;
  }
}


Measured memory_bytes: 3632
#include <stdio.h>

int main()
{
    int N,M,C,sum = 0,cont = 0;
    int A[20][20],B[20];
    scanf("%d %d %d",&N,&M,&C);
    for (int i = 0; i < M; i++)
    {
        scanf("%d",&B[i]);
    }
    for(int j = 0;j < N;j++)
    {
        for(int k = 0;k < M;k++)
        {
            scanf("%d",&A[j][k]);
        }
    }
    for(int l = 0;l < N;l++)
    {
        for(int n = 0;n < M;n++)
        {
            sum += (B[n] * A[l][n]);
        }
        sum += C;
        if(sum > 0)cont++;
        sum = 0;
    }
    printf("%d",cont);
    return 0;
}

Measured memory_bytes: 128
/*
 * FileName:     complete_binary_tree
 * CreatedDate:  2020-04-30 12:30:33 +0900
 * LastModified: 2020-04-30 20:42:27 +0900
 */

#include <stdio.h>
#include <stdlib.h>
typedef struct node_str{
    long long int key;
    int index;
    struct node_str *parent;
    struct node_str *left;
    struct node_str *right;
}str;
str *create_node(long long int key,int index){
    str *node = (str*) calloc(1,sizeof(str));
    node->key = key;
    node->index = index;
    node->left = NULL;
    node->right = NULL;
    node->parent = NULL;
    return node;
}
str *search_pare(str *tree, int index){
    if(tree==NULL){
        return NULL;
    }
    str *left = search_pare(tree->left,index);
    str *right = search_pare(tree->right,index);
    if(left!=NULL&&left->index==index/2){
        return left;
    }
    else if(right!=NULL&&right->index==index/2){
        return right;
    }
    else if(tree->index==index/2){
        return tree;
    }
    else{
        return NULL;
    } 
}
str *search_node(str *tree,int index){
    if(tree==NULL){
        return NULL;
    }
    str *left = search_node(tree->left,index);
    str *right = search_node(tree->right,index);
    if(left!=NULL&&left->index==index){
        return left;
    }
    else if(right!=NULL&&right->index==index){
        return right;
    }
    else if(tree!=NULL&&tree->index==index){
        return tree;
    }
    else{
        return NULL;
    }
}
void insert(str *tree,str *node,int index){
    str *pare = search_pare(tree,index);
    if(index%2==0){
        pare->left = node;
        node->parent = pare;
    }
    else{
        pare->right = node;
        node->parent = pare;
    }
}

int main(void){
    int h;
    str *root;
    scanf("%d",&h);
    for(int i=1;i<h+1;i++){
        long long int key;
        scanf("%lld",&key);
        str *node = create_node(key,i);
        if(i==1){
            root = node;
            continue;
        }
        insert(root,node,i);
    }
    for(int i=1;i<h+1;i++){
        printf("node %d: ",i);
        str *tmp = search_node(root,i);
        printf("key = %lld, ",tmp->key);
        if(tmp->parent!=NULL){
            printf("parent key = %lld, ",tmp->parent->key);
        }
        if(tmp->left!=NULL){
            printf("left key = %lld, ",tmp->left->key);
        }
        if(tmp->right!=NULL){
            printf("right key = %lld, ",tmp->right->key);
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

int main() {
  ll H, W, D;
  cin >> H >> W >> D;
  // vector<ll> map(H*W);
  map<ll, ll> map;
  for (ll i = 0; i < H; i++) {
    for (ll j = 0; j < W; j++) {
      ll a;
      cin >> a;
      map[a-1] = i*W + j;
    }
  }

  vector<ll> sum(H*W);
  for (ll i = H*W-1; i >= 0; i--) {
    if (i + D >= H*W) {
      sum[i] = 0;
    } else {
      // cout << "i: " << i << " index:" << map[i] << endl;
      // cout << "i+D: " << i+D << " index:" << map[i+D] << endl;
      ll index = map[i];
      ll h = index/W;
      ll w = index%W;

      ll nindex = map[i+D];
      ll nh = nindex/W;
      ll nw = nindex%W;

      sum[i] = abs(h-nh) + abs(w-nw) + sum[i+D];
    }
  }
  // for (ll i = 0; i < H*W; i++) {
  //   cout << sum[i] << endl;
  // }
  // cout << endl;

  ll Q;
  cin >> Q;
  for (ll i = 0; i < Q; i++) {
    ll l, r;
    cin >> l >> r;
    cout << sum[l-1] - sum[r-1] << endl;
  }
  return 0;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

const ll mod = 1e9 + 7;

map<ll,ll> mp;
ll f(ll n) {
  if (n==0) return 0;
  if (n==1) return 1;
  if (mp.count(n)) return mp[n];
  if (n%2) {
    return mp[n] = (2LL*f(n/2)%mod + f(n/2+1)%mod);
  } else {
    return mp[n] = (2LL*f(n/2)%mod + f(n/2-1)%mod);
  }
}

ll n;
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cin>>n;
  ll res = f(n+1);
  res %= mod;
  res += mod;
  res %= mod;
  cout<<res<<endl;
  

  return 0;
}
// don't forget to read in the input :^)


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

int main() {
    int16_t n, c;
    cin >> n >> c;
    int16_t d[c][c];
    int16_t k[n][n];

    for (int16_t i = 0; i < c; i++) {
        for (int16_t j = 0; j < c; j++) {
            cin >> d[i][j];
        }
    }
    for (int16_t i = 0; i < n; i++) {
        for (int16_t j = 0; j < n; j++) {
            cin >> k[i][j];
        }
    }

    int32_t s[3][c];
    for (int16_t i = 0; i < c; i++) {
        s[0][i] = s[1][i] = s[2][i] = 0;
        for (int16_t j_h = 0; j_h < n; j_h++) {
            for (int16_t j_w = 0; j_w < n; j_w++) {
                s[(j_h + j_w) % 3][i] += d[k[j_h][j_w] - 1][i];
            }
        }
    }

    int32_t answer = 2147483647;
    for (int16_t i0 = 0; i0 < c; i0++) {
        for (int16_t i1 = 0; i1 < c; i1++) {
            for (int16_t i2 = 0; i2 < c; i2++) {
                if (i0 != i1 && i1 != i2 && i2 != i0) {
                    if (s[0][i0] + s[1][i1] + s[2][i2] < answer) {
                        answer = s[0][i0] + s[1][i1] + s[2][i2];
                    }
                }
            }
        }
    }

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int digit_sum(int n) {
  int sum=n%10;
  while(n!=0) {
    n/=10;
    sum+=n%10;
  }
  return sum;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}




int main() {
  int w,a,b;
  cin >> w >> a >> b;
  if(a>b) {
    int t=a;
    a=b;
    b=t;
  }
  int ans=b-w-a;
  if(ans<0) ans=0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

int div2(int n) {
  int ans = 0;
  while (n % 2 == 0) {
    n /= 2;
    ans++;
  }
  return ans;
}

void Main() {
  Cin(int, n);
  Cins(int, n, a);
  int ans = 0;
  for (auto e : a) ans += div2(e);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
 
using namespace std;
typedef long long ll;
 
// ll naive(ll N, ll K) {
//   int cnt = 0;
//   for (int a = 1; a <= N; a++) {
//     for (int b = 1; b <= N; b++) {
//       for (int c = 1; c <= N; c++) {
//         if ((a + b) % K == 0 && (b + c) % K == 0 && (a + c) % K == 0) {
//           cnt++;
//         }
//       }
//     }
//   }
//   return cnt;
// }

ll solve(ll N, ll K) {
  ll ans = 0;
  vector<ll> cnt(200001);
  for(ll i = 1; i <= N; i++) {
    cnt[i % K]++;
  }
  for(ll b = 1; b <= N; b++) {
    ll m = (K - b) % K;
    if (m < 0) {
      m += K * (-m / K) + K;
      m %= K;
    }
    if ((2 * m) % K == 0) {
      ans += cnt[m] * cnt[m];
    }
  }
  return ans;
}

int main() {
  ll N, K;
  cin >> N >> K;
  cout << solve(N, K) << endl;
  return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();

		int p = 0;
		int count = 1;
		for(int i = 0 ; i < N ; i++){
			int q = sc.nextInt();
			p+=q;

			if(p<=X){
				count++;
			}
			else{
				System.out.println(count);
				break;
			}
		}

		if(count == N+1){
			System.out.println(count);
		}


			sc.close();
	}
}


Measured memory_bytes: 21844
#include<stdio.h>

int main()
{
    char s[3];
    scanf("%s",s);
    for(int i = 0; i <= 2; i++)
    {
        if(s[i] == '9')
            s[i] = '1';
        else if(s[i] == '1')
            s[i] = '9';
    }
    printf("%s\n",s);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll, ll> pll;


ll n, m;
vector< ll > b[1000005];
int main()
{
        cin >> n >> m;
        for(ll i=1;i<=n;i++) {
                ll a, x;
                cin >> a >> x;
                b[a].pb(x);
        }
        for(ll i=1;i<=100000;i++){
                if(b[i].size() == 0) continue;
                sort(b[i].rbegin(), b[i].rend());
        }
        priority_queue<ll> pq;
        ll ans = 0;
        ll tk=0;
        for(ll i=1;i<=m;i++) {
                if(b[i].size() > 0)
                for(auto &j : b[i]) pq.push(j);
                if(pq.size() != 0) {
                        ans += pq.top();
                        pq.pop();
                }
        }
        cout << ans << endl;
        return 0;
}


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

int main(void) {
  int YYMM = 0, MMYY = 0;
  string S; cin >> S;
  if (S[0] == '0' && S[1] != '0') MMYY = 1;
  else if (S[0] == '1' && (S[1] == '0' || S[1] == '1' || S[1] == '2')) MMYY = 1;
  if (S[2] == '0' && S[3] != '0') YYMM = 1;
  else if (S[2] == '1' && (S[3] == '0' || S[3] == '1' || S[3] == '2')) YYMM = 1;

  if (YYMM && MMYY) cout << "AMBIGUOUS" << endl;
  else if (YYMM && !MMYY) cout << "YYMM" << endl;
  else if (!YYMM && MMYY) cout << "MMYY" << endl;
  else cout << "NA" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define REP(i, n) for (int i=0; i<n; ++i)
#define print(x) cout << x << endl;

using namespace std;

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

    vector<int> A(N), dist(N+1);
    REP(i, N) cin >> A[i];
    int total = 0;
    int prev = 0;
    
    REP(i, N) {
        total += abs(A[i] - prev);
        dist[i] = abs(A[i] - prev);
        prev = A[i];
    }
    total += abs(0 - A[N-1]);
    dist[N] = abs(0 - A[N-1]);

    REP(i, N) {
        int ans = total - dist[i] - dist[i+1];
        if (i == 0) {
            ans += abs(0 - A[i+1]);
        } else if(i == N-1) {
            ans += abs(A[i-1] - 0);
        } else {
            ans += abs(A[i-1] - A[i+1]);
        }
        print(ans);
    }


}

int main() {

    solve();
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

int main(void){
	int N, K;
	cin >> N >> K;
	int M = N / 2;
	N - M >= K ? cout << "YES" << endl : cout << "NO" << endl;
    return 0;
}


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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;


int main(){
  int N;
  string s;
  cin>>N>>s;
  vector<int>r,g,b;
  for(int i(0);i<N;i++){
    if(s[i] == 'R') r.push_back(i);
    if(s[i] == 'G') g.push_back(i);
    if(s[i] == 'B') b.push_back(i); 
  }
  ll ans(0);
  for(int i(0);i<N;i++){
    for(int j(i+1);j<N;j++){
      if(s[i] != s[j]){
        int sa = j - i;
        char iro;
        if((s[i] == 'R' && s[j] == 'G') ||( s[i] == 'G' && s[j] == 'R')) iro = 'B';
        else if((s[i] == 'R' && s[j] == 'B') ||( s[i] == 'B' && s[j] == 'R')) iro = 'G';
        else if((s[i] == 'B' && s[j] == 'G') ||( s[i] == 'G' && s[j] == 'B')) iro = 'R';
        int cnt(0);
        if(iro == 'B'){
          cnt = b.end() - upper_bound(b.begin(),b.end(),j);
        }else if(iro == 'G'){
          cnt = g.end() - upper_bound(g.begin(),g.end(),j);
        }else if(iro == 'R'){
          cnt = r.end() - upper_bound(r.begin(),r.end(),j);
        }
        ans += cnt;
        if(j+sa < N && s[j+sa] == iro){
          ans--;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}



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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#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 SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

#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;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


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

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

  int N; cin >> N;
  // num => (idx, num_m)
  map<LL,PLL> xs;
  REP(i,N){
	LL x;
	cin >> x;
	if(xs.count(x))
	  xs[x].SS++;
	else
	  xs[x] = MP(i,1);
  }

  VL ans(N);
  while(!xs.empty()){
	auto it = end(xs);
	--it;
	if(it != begin(xs)){
	  auto pit = it;
	  --pit;
	  LL diff = it->FF - pit->FF;
	  ans[it->SS.FF] += it->SS.SS * diff;
	  mini(pit->SS.FF, it->SS.FF);
	  pit->SS.SS += it->SS.SS;
	  xs.erase(it);
	}
	else{
	  ans[0] += it->SS.SS * it->FF;
	  break;
	}
  }

  REP(i,N) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 9976
o=lambda:map(int,raw_input().split());s=9999
n,k=o();r=range(n)
e=[[]for _ in [0]*n]
for _ in [0]*(n-1):a,b=o();e[a-1]+=[b-1];e[b-1]+=[a-1]
def U(x,f):
 if f<n:l[f]=0
 q=[(x,0)]
 while len(q):
  v,c=q.pop(0)
  if c>k/2:break
  l[v]=0
  for w in e[v]:
   if l[w]:q+=[(w,c+1)]
 return n-l.count(0)
if k%2:
 for i in r:
  for j in e[i]:
   if i<j:l=[1]*n;U(i,j);s=min(s,U(j,i))
else:
 for i in r:l=[1]*n;s=min(s,U(i,n))
print s


Measured memory_bytes: 26908
#include <bits/stdc++.h>
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#include <boost/iostreams/device/file_descriptor.hpp>

using namespace std;
typedef long long int lli;
typedef vector<int> iv;
typedef vector<bool> bv;
typedef vector<string> sv;
typedef vector<long long int> llv;
typedef vector<double> dv;

#define sor_(vec) sort(vec.begin(),vec.end())
#define rev_(vec) reverse(vec.begin(),vec.end())
#define rep(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define reps(i,n,s) for(int i=static_cast<int>(s);i<static_cast<int>(n);i++)
#define isposi(num) if(num>0)
const long long mod = 1000000007;

template<typename TypeInt>
std::string Itoa(const TypeInt v, int base)
{
    static const char table[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    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 += '-';
    }
    std::reverse(ret.begin(), ret.end());

    return ret;
}

int upf(double num){
    if(num-(int)num>0)return (int)num+1;
    else return num;
}

void printm(char const *format,...){
    va_list arguments;
    va_start(arguments,format);
    unsigned index=0;
    while (format[index]!='\0') {
        if(format[index]=='%'){
            index++;
            if(format[index]=='d')printf("%d",va_arg(arguments, int));
            else if(format[index]=='c')printf("%c",va_arg(arguments, int));
            else if(format[index]=='x')printf("%x",va_arg(arguments,int));
            else if(format[index]=='o')printf("%o",va_arg(arguments,int));
            else if(format[index]=='f')printf("%f",va_arg(arguments, double));
            else if(format[index]=='s')printf("%s",va_arg(arguments, char const *));
            else if(format[index]=='p')printf("%p",va_arg(arguments,void*));
            else if(format[index]=='y')printf("Yes");
            else if(format[index]=='n')printf("No");
            else if(format[index]=='%')printf("%%");
            else assert(!"Unknown format with %.");
        }
        else printf("%c",format[index]);
        index++;
    }
    va_end(arguments);
    return;
}

struct Chara{
    int hp;
    int sp;
};

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    for(size_t i=0;i<s.length();i++){
        if(s[i]=='?'){
            if(i==0)s[i]='D';
            else if(s[i-1]=='P')s[i]='D';
            else if(s[i+1]=='D')s[i]='P';
            else if(s[i+1]=='?')s[i]='P';
            else s[i]='D';
        }
    }
    cout<<s;
    return 0;
}


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

using namespace std;

int main()
{
	int a, b, c;
	while(~scanf("%d%d%d", &a, &b, &c))
	{
		if(a%2!=0||b%2!=0||c%2!=0)
		{
			printf("0\n");
			continue;
		}
		
		bool flag = 0;
		int res = 0;
		for(int i=1;i<=1000;i++)
		{
			int x=a, y=b, z=c; 
			a = (y+z)/2;
			b = (x+z)/2;
			c = (x+y)/2;
			res++;
			if(a%2!=0||b%2!=0||c%2!=0)
			{
				flag = 1;
				break;
			}
		}
		if(flag)
		printf("%d\n", res);
		else 
		printf("-1\n");
	}
	return 0;
}

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

int main(){
    using namespace std;
    unsigned long N, Q;
    cin >> N >> Q;
    vector<unsigned long> q(Q);
    for(auto& i : q)cin >> i;
    reverse(q.begin(), q.end());
    q.push_back(N);
    map<unsigned long, unsigned long, greater<>> mp;
    mp.emplace(q.front(), 1);
    for(const auto& i : q)while(mp.begin() -> first > i){
        auto t = *mp.begin();
        mp.erase(mp.begin());
        mp[i] += t.first / i * t.second;
        if(t.first % i)mp[t.first % i] += t.second;
    }
    vector<unsigned long> ans(N);
    for(const auto& i : mp)ans[i.first - 1] += i.second;
    partial_sum(ans.rbegin(), ans.rend(), ans.rbegin());
    copy(ans.begin(), ans.end(), ostream_iterator<unsigned long>(cout, "\n"));
    return 0;
}

Measured memory_bytes: 9072
k,n=map(int,input().split())
a=list(map(int,input().split()))
p=[]
for i in range(n-1):
    p.append(a[i+1]-a[i])
if a[0]==0:p.append(k-a[n-1])
else:p.append(k-a[n-1]+a[0])
#print(p)
print(k-max(p))


Measured memory_bytes: 86140
#include <stdio.h>

int binarysearch(int a[] , int n , int key);

int main(void)
{
	int i;
	int n;
	scanf("%d",&n);
	int s[n];
	int j=0;
	for( i = 0; i < n; i++)
	{
		scanf("%d",&s[i]);
	}
	int q;
	scanf("%d",&q);
	int t[q];
	for( i = 0; i < q; i++)
	{
		scanf("%d",&t[i]);
	}
	for( i = 0; i < q; i++)
	{
		j += binarysearch(s,n,t[i]);
	}
	printf("%d\n",j);
	return 0;
}

int binarysearch(int a[] , int n , int key)
{
	int left = 0;
	int right = n;
	int mid;
	while(left < right)
	{
		mid = (left+right)/2;
		if(a[mid] == key)
		{
			return 1;
		}
		else if(key < a[mid])
		{
			right = mid;
		}
		else{
			left = mid + 1;
		}
	}
	return 0;
}


Measured memory_bytes: 2252
#!/usr/bin/env python3


def main():
    N = int(input())
    A = list(map(int, input().split()))
    p = 10**9 + 7

    digit_0 = [0] * 60
    digit_1 = [0] * 60

    for i in range(N):
        for j in range(60):
            if (A[i] >> j) & 1:
                digit_1[j] += 1
            else:
                digit_0[j] += 1
    
    ans = 0
    for j in range(60):
        ans += ((digit_0[j] * digit_1[j] % p) * pow(2,j,p) % p)
        ans %= p
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 125624
s = input()
a, b, c, d = map(int, s)
A, B, C, D = map(str, s)
x = "=7"
if a + b + c + d == 7:
    print(A + "+" + B + "+" + C + "+"+D + x)
elif a - b + c + d == 7:
    print(A + "-" + B + "+" + C + "+"+D + x)
elif a + b - c + d == 7:
    print(A + "+" + B + "-" + C + "+"+D + x)
elif a + b + c - d == 7:
    print(A + "+" + B + "+" + C + "-" + D + x)
elif a - b - c + d == 7:
    print(A + "-" + B + "-" + C + "+" + D + x)
elif a - b + c - d == 7:
    print(A + "-" + B + "+" + C + "-" + D + x)
elif a + b - c - d == 7:
    print(A + "+" + B + "-" + C + "-" + D + x)
elif a - b - c - d == 7:
    print(A + "-" + B + "-" + C + "-" + D + x)


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;


int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2 - x1;
    int dy = y2 - y1;
    int x3 = x2 - dy;
    int y3 = y2 + dx;
    int x4 = x1 - dy;
    int y4 = y1 + dx;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin>>N;
	int A[N];
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	bool flag=true;
	for(int i=0;i<N-1;i++){
		if(A[i+1]-A[i]>1){
			flag=false;
			break;
		}
	}
	if(A[0]!=0){
		flag=false;
	}
	if(!flag){
		cout<<-1<<endl;
	}else{
		long long sum=0;
		for(int i=0;i<N-1;i++){
			if(A[i]<A[i+1]){
				sum++;
			}else if(A[i]==A[i+1]){
				sum+=A[i+1];
			}else if(A[i]>A[i+1]&&A[i+1]!=0){
				sum+=A[i+1];

			}
		}
		cout<<sum<<endl;

	}

}

	

Measured memory_bytes: 1152
#include <stdio.h>
int main(){
  int W,H,x,y,r;
  scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
  if(x+r <= W && y+r <= H && x-r >= 0 && y-r >= 0){ printf("Yes\n");}
  
else{
printf("No\n");}
 return 0;
}

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

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);  
  //問題文を読む時間をケチらない！！
  //未定義動作に気を付ける！！
  //DPや二分探索の範囲に気をつける！！

  int a,b,c;
  cin >> a >> b >> c;

  int cnt = 0;
  RFOR(i,1,101){
    if(a%i == 0 && b%i == 0) cnt++;
    if(cnt == c){
      cout << i << endl;
      return 0;
    }
   }

  return 0;
}

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

typedef long long ll;
ll N,K;

ll merge_count(vector<ll> &a){
	int n = a.size();
	if(n<=1) return 0;
	ll cnt = 0;
	vector<ll> b(a.begin(),a.begin() + n/2);
	vector<ll> c(a.begin() + n/2, a.end());
	cnt += merge_count(b);
	cnt += merge_count(c);
	int ai = 0,bi = 0,ci = 0;
	while(ai<n){
		if(bi<b.size() && (ci == c.size() || b[bi] <= c[ci])){
			a[ai++] = b[bi++];
		}else{
			cnt += n/2 - bi;
			a[ai++] = c[ci++];
		}
	}
	return cnt;
}

int main(){
	cin >> N >> K;
	vector<ll> A(N+1);
	A[0] = 0;
	for(int i=1;i<=N;i++){
		cin >> A[i];
		A[i] -= K;
		A[i] += A[i-1];
	}
	cout << N*(N+1)/2 - merge_count(A) << endl;
}

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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A.at(i);
    map<int,int> res;
    rep(i,N) {
        if(1 <= A.at(i) && A.at(i) < 400) {
            if(res.count(0))
                res[0]++;
            else 
                res[0] = 1;
            continue;
        }
        for(int j = 1; j <= 7; j++) {
            if(400*j <= A.at(i) && A.at(i) < 400*(j+1)) {
                if(res.count(j))
                    res[j]++;
                else
                    res[j] = 1;
                break;
            }
        }
        if(A.at(i) >= 3200) {
            if(res.count(8))
                res[8]++;
            else
                res[8] = 1;
        }
    }

    int kind = 0;
    for(auto x:res) {
        if(x.first != 8)
            kind++;
    }
    if(kind == 0) cout << 1 << " ";
    else cout << kind << " ";

    kind += res[8];
    cout << kind << endl;
}


Measured memory_bytes: 256