akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using namespace std::chrono; 
#define ll long long
#define fo(i,v,e) for(v=i;v<e;v++)
#define rfo(i,v,e) for(v=i;v>e;v--)
#define pb(x) push_back(x)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fi first 
#define se second
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vl vector<ll>
#define sz(x) (int)x.size()
#define ull unsigned long long
#define vvi vector<vi>
#define vvl vector<vl>
#define vpi vector<pii>
#define vpl vector<pll>
ll mod = 1000000007;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x);
#else
#define deb(x...)
#endif
#define PI 3.14159265358979323846
void init()
{
}

void solve()
{
    long double a,b,h,m,i,j,ans,temp,th;
    cin>>a>>b>>h>>m;
    ans = a*a+b*b;
    temp = 2.0*a*b;
    th = abs(6*m-(0.5*(h*60+m)));
    th = min(th,360-th);
    th = (th*PI)/180.0;
    temp = temp*cos(th);
    cout<<setprecision(20)<<sqrt(ans-temp)<<endl;
}
int main()
{
    init();
    #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    #endif
    auto start = high_resolution_clock::now(); 
    int T = 1;
    // cin>>T;
    while(T--)
    {
        solve();
    }
    auto stop = high_resolution_clock::now(); 
    auto duration = duration_cast<milliseconds>(stop - start); 
    #ifndef ONLINE_JUDGE
    // cout << "time taken : "<<duration.count()<<" ms" << endl;
     #endif
}


Measured memory_bytes: 4140
a,b = [int(i) for i in input().split()]
if a > 0:
  a=a-1
  if a%4==0:
    pass
  elif a%4==1:
    a=1
  elif a%4==2:
    a=a+1
  else:
    a=0
    
  if b%4==0:
    pass
  elif b%4==1:
    b=1
  elif b%4==2:
    b=b+1
  else:
    b=0

  print(a^b)

else:
  print(a^b)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn (1<<19)
//#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

typedef complex<double> cp;
const db pi=acos(-1.0);
int r[maxn*2+5],n2;

int BASE=2,P=200003;
int lg[maxn+5];
int cnt[maxn];
ll a[maxn+5];

cp W[maxn];

void FFT(cp a[],int opt)
{
    rep(i,1,n2-1) if(r[i]>i) swap(a[i],a[r[i]]);
    for(int step=1;step<n2;step<<=1)
    {
        rep(i,0,step-1)
        {
            W[i].real(cos(pi*i/step*opt));
            W[i].imag(sin(pi*i/step*opt));
        }
        //w.real(cos(sita)); w.imag(sin(sita));
        for(int step2=step<<1,i=0;i<n2;i+=step2)
        {
            //cp wj=1;
            rep(j,0,step-1)
            {
                cp even=a[i+j];
                cp odd=a[i+j+step];
                cp tmp=W[j]*odd;
                a[i+j]=even+tmp;
                a[i+j+step]=even-tmp;
            }
        }
    }
}

cp x[maxn];

int main()
{
    int t=1;
    ll ans=0;
    rep(i,1,P-1)
    {
        t=1ll*t*BASE%P;
        lg[t]=i;
    }

    int n; scanf("%d",&n);
    rep(i,1,n)
    {
        int x; scanf("%d",&x);
        cnt[lg[x]]++;
        //printf("?? %d\n",lg[x]);
        ans-=1ll*x*x%P;
    }
    int l=0;
    for(n2=1;n2<P*2;n2<<=1) l++;
    rep(i,1,n2-1) r[i]=(r[i>>1]>>1)|((i&1)<<l-1);
    rep(i,1,P-1) x[i]=cnt[i];
    FFT(x,1);
    rep(i,0,n2-1) x[i]=x[i]*x[i];
    FFT(x,-1);
    rep(i,0,n2-1) a[i]=x[i].real()/n2+0.5;
    rep(i,1,P-1) ans+=1ll*i*(a[lg[i]]+a[lg[i]+P-1]);
    assert(ans%2==0);
    printf("%lld\n",ans/2);
    return 0;
}

Measured memory_bytes: 24128
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<string> S(N);
    vector<ll> t(N);
    rep(i,N){
        cin>>S[i]>>t[i];
    }
    string X; cin>>X;
    ll ans=0;
    bool ok=false;
    rep(i,N){
        if(ok) ans+=t[i];
        if(S[i]==X) ok=true;
    }
    cout<< ans <<"\n";

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

int main(){
	ll N, Z, W; cin >> N >> Z >> W;
	vector<ll> A(N);
	for (int i = 0;i < N;i++) {
		cin >> A[i];
	}
	if (N != 1)
		cout << max(abs(W - A[N - 1]), abs(A[N - 2] - A[N - 1]));
	else
		cout << abs(W - A[N - 1]);
}

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

int main(){
    int n; cin >> n;
    for (int i = 1; i <= n; i++){
        if (i % 3 == 0){
            cout << " " << i;
            continue;
        }
        string s = to_string(i);
        int l = s.size();
        for (int j = 0; j < l; j++){
            if (s[j] == '3'){
                cout << " " << i;
                break;
            }
        }
        
    }
    cout << endl;
    return 0;

}



Measured memory_bytes: 3224
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val k = readLine()!!.toInt()
    val x = readLine()!!.toInt()
    val y = readLine()!!.toInt()
    var ans = Math.min(k, n) * x
    if (k < n) ans += (n-k)*y
    println(ans)
}



Measured memory_bytes: 34536
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

long long N;
vector<vector<long long>> G;
vector<pair<long long, long long>> edges;

int main(){
    cin >> N;
    G.resize(N);
    REP(i, N-1){
        long long u, v;
        cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        if(u > v) swap(u, v);
        edges.emplace_back(u, v);
    }
    long long ans = 0;
    for(long long i=1; i<=N; i++) ans += i*(N-i+1);
    for(auto edge : edges){
        long long u, v;
        u = edge.first;
        v = edge.second;
        ans -= (u+1)*(N-v);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15560
import java.util.*;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();

        int[] dist = new int[n];
        int a0 = sc.nextInt();
        int prev = a0;

        for (int i = 0; i < n - 1; i++) {
            int now = sc.nextInt();
            dist[i] = now - prev;
            prev = now;
        }
        dist[n - 1] = k + a0 - prev;

        System.out.println(k - IntStream.of(dist).max().orElse(0));
    }
}


Measured memory_bytes: 85676
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Sun Jan  6 15:04:41 2019
//
package main

import (
	"container/heap"
	"fmt"
)

type route struct {
	to, weight int
}

type node struct {
	routes []route
	index  int
	weight int
}

type priQ []*node

func (pq priQ) Len() int {
	return len(pq)
}

func (pq priQ) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq priQ) Less(i, j int) bool {
	return pq[i].weight < pq[j].weight
}

func (pq *priQ) Push(x interface{}) {
	n := len(*pq)
	r := x.(*node)
	r.index = n
	*pq = append(*pq, r)
}

func (pq *priQ) Pop() interface{} {
	old := *pq
	n := len(*pq)
	r := old[n-1]
	*pq = old[:n-1]
	return r
}

func (pq *priQ) update(n *node) {
	heap.Fix(pq, n.index)
}

func dikstra(start int, end int, graph []node) int {
	graph[start].weight = 0

	pq := priQ{}
	heap.Init(&pq)
	heap.Push(&pq, &graph[start])
	pq.update(&graph[start])

	for pq.Len() > 0 {
		n := heap.Pop(&pq).(*node)
		for _, r := range n.routes {
			w := n.weight + r.weight
			if w < graph[r.to].weight {
				graph[r.to].weight = w

				heap.Push(&pq, &graph[r.to])
			}
		}
	}

	return graph[end].weight
}

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

	graph := make([]node, K)
	for i := range graph {
		if i+1 < len(graph) {
			graph[i].routes = append(graph[i].routes, route{to: i + 1, weight: 1})
		} else {
			graph[i].routes = append(graph[i].routes, route{to: 0, weight: 1})
		}
		graph[i].routes = append(graph[i].routes, route{to: (i * 10) % K, weight: 0})
		graph[i].index = i
		graph[i].weight = 1 << 60
	}

	fmt.Println(dikstra(1, 0, graph) + 1)
}


Measured memory_bytes: 10240
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int di[] = {0, -1, 0, 1};
int dj[] = {-1, 0, 1, 0};

int main() {
	for (;;) {
		int N; cin >> N;
		if (N == 0) break;
		vector< pair<double, string> > v(N);
		for (int i = 0; i < N; i++) {
			string l; int p, a, b, c, d, e, f, s, m;
			cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
			int t = (a + b + c) + m * (d + e);
			int z = m * f * s - p;
			v[i] = make_pair(-(double)z / t, l);
		}
		sort(v.begin(), v.end());
		for (int i = 0; i < N; i++)
			cout << v[i].second << endl;
		cout << '#' << endl;
	}
}

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

int main(){
    int n,m;cin>>n>>m;
    vector<vector<int>> a(m);
    int count=0;
    for(int i=0;i<n;i++){
        int c,d;cin>>c>>d;
        if(c>m)continue;
        a[m-c].push_back(d);
        count++;
        //m-c日以前にやるしかない仕事
    }
    priority_queue<int> money;
    int sum=0;


    for(int i=m-1;i>=0;i--){
        for(int j:a[i]){
            money.push(j);
        }
        if(!money.empty()){
            sum+=money.top();
            money.pop();
        }
    }
    
    cout <<sum;
    
}

Measured memory_bytes: 8484
A=[0 for  d in range(26)]
while True:
	try:
		s=list(input())
		for n in range(len(s)):
			c=ord(s[n])
			if 97 <= c and c <= 122:
				A[c-97]+=1
			elif 65 <= c and c <= 90:
				A[c-65]+=1
	except EOFError:
		break
for n in range(26):
	print(f"{chr(97+n)} : {A[n]}")



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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

int sx,sy,tx,ty;
int main() {
    cin >> sx >> sy >> tx >> ty;
    int w,h;
    w = tx - sx;
    h = ty - sy;

    string ans;

    cout << string(h,'U') << string(w,'R');
    cout << string(h,'D') << string(w,'L');
    cout << 'L' << string(h+1,'U') << string(w+1,'R') << 'D';
    cout << 'R' << string(h+1,'D') << string(w+1,'L') << 'U' << endl;   
    return 0;
}

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

int main(){
    int a,b,ans;
    cin>>a>>b;
    ans=a/(2*b+1);
    if(a%(2*b+1)!=0){
    	ans++;
    }
    cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1000000000000000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    string S;
    cin >> S;
    ll N= S.size();
    ll cnt = 0;
    rep(i,26){
        ll n = count(ALL(S),'a'+i);
        cnt += n * (n-1) / 2;
    }
    cout << N * (N-1) / 2 - cnt + 1 << endl;
}




Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("win");}else{puts("bust");}
#define MAX_N 200005

int main() {
    int a,b,c;
    cin >> a >> b >> c;

    int ans = a + b + c;

    if(ans <= 21)yn;

    return 0;
}



Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	h,w,n = readline() |> split |> parseMap
	sr,sc = readline() |> split |> parseMap
	s = readline() |> chomp
	t = readline() |> chomp
	r = sc
	l = sc
	u = sr
	d = sr
	f = 0
	for i in 1:n
		if s[i]=='R'
			r+=1
		elseif s[i]=='L'
			l-=1
		elseif s[i]=='D'
			u+=1
		else
			d-=1
		end
		if r>w||l<1||u>h||d<1
			f = 1
			break
		end
		if t[i]=='R'
			l=min(w,l+1)
		elseif t[i]=='L'
			r=max(1,r-1)
		elseif t[i]=='D'
			d=min(h,d+1)
		else
			u=max(1,u-1)
		end
	end
	println(f==0?"YES":"NO")
end

main()

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

struct edge{int to; ll a_cost, b_cost;};

int main()
{
  int n; cin >> n;
  vector<ll> t(n);
  rep(i, n) cin >> t[i];
  ll ans = 1;
  rep(i, n) ans *= (t[i] / __gcd(ans, t[i]));
  cout << ans << endl;
}


Measured memory_bytes: 3616
import itertools
n,m=map(int,input().split())
tbl=[[0]*n for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    tbl[a-1][b-1]=1
    tbl[b-1][a-1]=1
ans=0
l=[i+1 for i in range(n-1)]
for p in itertools.permutations(l,n-1):
    flag=True
    p=[0]+list(p)
    for i in range(n-1):
        if tbl[p[i]][p[i+1]]==0:
            flag=False
            break
    if flag:
      ans+=1
print(ans)

Measured memory_bytes: 9228
def make_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)
    return divisors

def l_b(x):
  ok = 0
  ng = 40
  while ng - ok > 1:
    mid = (ok+ng) // 2
    if n % (k ** mid) == 0:
      ok = mid
    else:
      ng = mid
  return x ** ok
n = int(input())
L = make_divisors(n)
ans = 0
for k in L:
  if k == 1:
    continue
  k_m = l_b(k)
  if (n // k_m) % k == 1:
    ans += 1
ans += len(make_divisors(n-1))
ans -= 1
print(ans)

Measured memory_bytes: 3188
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  ll n,m,q;
  cin>>n>>m>>q;
  
  ll A[n+1][n+1];
  rep(i,n+1){
    rep(j,n+1) A[i][j]=0;
  }
  
  ll l,r;
  rep(i,m){
    cin>>l>>r;
    A[l][r]++;
  }
  
  ll s[n+2][n+2];
  rep(i,n+2){
    rep(j,n+2) s[i][j]=0;
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      s[i+1][j+1]=s[i+1][j]+s[i][j+1]-s[i][j]+A[i][j];
    }
  }
  
  ll a,b;
  rep(i,q){
    cin>>a>>b;
    cout<<s[b+1][b+1]-s[a][b+1]-s[b+1][a]+s[a][a]<<endl;
  }

  return 0;
}

Measured memory_bytes: 7548
//😄😄😄😄😄😄😄😄😄😄😄😄😄
//Apno Swagat che//
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define For(i,a,b) for(ll i=a;i<b;i++)
#define endl "\n"
#define debug(x) cout<<"AA Baju Smit------> "<<#x<<" -> "<<x<<endl
#define all(x) x.begin(),x.end()
#define mint map<int,int>
#define mod 10000007
#define ciN cin
#define XX INT_MAX
#define NN INT_MIN
////////////////////////////////////////////////////////////////
//Ha Moj Ha///
////////////////////////////////////////////////////////////////
////TEST CASES ATTACHED CHE BHULTO NAI......///////////////////


void jabru() {
	int n, k; ciN >> n >> k;
	vi h(n + 1, 0);
	vi dp(n + 1, XX);
	dp[0] = dp[1] = 0;
	For(i, 1, n + 1)cin >> h[i];
	For(i, 2, n + 1) {
		for (int j = 1; j <= k; j++) {
			if (i - j > 0) {
				dp[i] = min(dp[i], abs(h[i] - h[i - j]) + dp[i - j]);
			}
			else
				break;
		}
	}
	cout << dp[n] << endl;
}




////////////////////////////////////////////////////////////////
//Bas aabaju nai javanu///
////////////////////////////////////////////////////////////////

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

//	int t; cin >> t;
	//while (t--)
	jabru();

	return 0;
}





///////////////////////////////////////////////////////////////////////////////////////////
//Kai baju bhai???


Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define PI 3.1415926535897932384626433
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }
 
int main(){
    ll n;
    cin >> n;
    ll a[n];
    for (ll i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<ll> ans(n+1, 0);
    ll cnt = 0;

    for (ll i = n; i > 0; i--){
        int sum = 0;
        for (ll j = i; j <= n; j += i){
            sum += ans[j];
        }
        if (a[i - 1] == 1 && sum % 2 == 0){
            ans[i]++;
            cnt++;
        }else if(a[i-1] == 0 && sum % 2 == 1){
            ans[i]++;
            cnt++;
        }
    }
    
    if(cnt == 0){
        cout << 0 << endl;
        return 0;
    }
    cout << cnt << endl;
    for (ll i = 1; i <= n; i++){
        if(ans[i] != 0){
            cout << i;
            if(i != n){
                cout << " ";
            }
        }
    }
    cout << endl;
    return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

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

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;




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

	string s;
	cin>>s;
	for(char i='a';i<='z';i++) {
		bool ok = false;
		for(auto j: s)
			if(i==j)
			{ok=true;break;}
		if(!ok) {cout<<i;return 0;}
	}
	cout<<"None";

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const ll inf = 1e18;

template <class T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus; 
    exp >>= 1;
  }
  return result % modulus;
}

//mod(1e9+7)
const ll mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x = 0) : x(x % mod){}
    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
};

int main() {
    ll n, k;
    cin >> n >> k;
    mint sum = 0;
    vector<mint> x(k+1);
    for (int i = k; i >= 1; i--) {
        mint tmp = modpow(k/i,n,mod);
        for (int l = 2; i*l <= k; l++) tmp -= x[i*l];
        x[i] = tmp.x;
        sum += x[i] * i;
    }
    cout << sum.x << endl;
}

Measured memory_bytes: 4008
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

ll N,X;
ll nums[200009];

ll calc(int k){
    ll res=0;
    int r=N,l=r-k;
    for(int i=1;r>0;i++){
        ll x=nums[r]-nums[l];
        if(i==1) res+=5*x;
        else res+=(2*i+1)*x;
        if(res<0) break;
        r-=k;
        l=max(0,l-k);
    }
    if(res<0) res=LLINF*5;
    else res+=(N+k)*X;
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>X;
    rep1(i,N) cin>>nums[i];
    rep1(i,N-1) nums[i+1]+=nums[i];
    
    ll mn=LLINF*5;
    rep1(i,N) chmin(mn,calc(i));
    cout1(mn)
}

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

int main() {
	int n;	cin >> n;
	int ans = 0;
	while(n >= 500) {
		n -= 500;
		ans += 1000;
	}
	while(n >= 5) {
		n -= 5;
		ans += 5;
	}
	cout << ans;
}


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

using namespace std;

#define watch(x) cout << (#x) << " is " << (x) << endl
#define watchArray(v) for(auto i : v) cout << i << " "; cout << endl;
#define all(v) (v).begin(), (v).end()

#define endl '\n'
#define MAX 100000
#define MOD 100000007
#define INF numeric_limits<int>::max()
#define INFLL numeric_limits<long long int>::max()

typedef long long int lli;
typedef long double ld;

int n, c;
vector<pair<lli, lli>> v;
vector<vector<lli>> memo;

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

  cin >> n >> c;
  v.resize(n+1);
  memo.assign(n + 1, vector<lli>(c+1, 0));

  for(int i = 1; i < v.size(); i++) cin >> v[i].first >> v[i].second;

  for(int i = 1; i < v.size(); i++) {
    for(int j = 0; j <= c; j++) {
      int peso = v[i].first, valor = v[i].second;
      if(peso > j) memo[i][j] = memo[i-1][j];
      else memo[i][j] = max(memo[i-1][j], memo[i-1][j-peso] + valor);
    }
  }

  cout << memo[n][c] << endl;

  return 0;
}


Measured memory_bytes: 80256
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();

        if (N == M){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 22740
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	public static class Hoge{
		public int a =  0;
		public int b = 0;
		Hoge(int a, int b){
			this.a = a;
			this.b = b;
		}
	}

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int N = Integer.parseInt(sc.next());
			int M = Integer.parseInt(sc.next());
			List<Hoge> AB = new ArrayList<Hoge>();
			for(int i = 0; i < N; i++) {
				AB.add(new Hoge(Integer.parseInt(sc.next()), Integer.parseInt(sc.next())));
			}
			
			Collections.sort(AB, new Comparator<Hoge>() {
				public int compare(Hoge a1, Hoge a2) {
					return a1.a - a2.a;
				}
			});
			
			long ret = 0L;
			int count = 0;
			for(int i = 0; i < N; i++) {
				if(count >= M) {
					break;
				}
				for(int j = 0; j < AB.get(i).b; j++) {
					if(count >= M) {
						break;
					}
					ret += AB.get(i).a;
					count++;
				}
			}
			System.out.println(ret);
		} // Scanner Close
	}
}

Measured memory_bytes: 64220
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    int[] a=new int[s.length()];
    for(int i=0;i<s.length();i++){
      if(s.charAt(i)=='R'){
        a[i]=i+1;
      }else{
        a[i]=i-1;
      }
    }
    int[] aa=new int[a.length];
    
    for(int i=0;i<17;i++){
      for(int j=0;j<a.length;j++){
        aa[j]=a[a[j]];
      }
      a=aa;
    }
    
    int[] b=new int[a.length];
    for(int i=0;i<a.length;i++){
      b[a[i]]++;
    }
    for(int i=0;i<a.length;i++){
      System.out.print(b[i]+" ");
    }
  }
}

Measured memory_bytes: 47304
import java.util.Scanner;

public class Main {

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

		int[] S = new int[N + 1];  // 番兵入れるために要素数+1
		for(int i = 0; i < N; i++) {
			S[i] = sc.nextInt();
		}

		int Q = sc.nextInt();
		for(int i = 0; i < Q; i++) {
			S[N] = sc.nextInt();  // 探す値をそのまま番兵に設定
			ans += linear_search(S, S[N]);
		}

		System.out.println(ans);
		sc.close();
	}

	// 見つかれば1、見つからなければ0(番兵の存在が前提)
	public static int linear_search(int[] a, int x) {
		int i = 0;
		while(a[i] != x) {
			i++;  // 番兵を用いることでメインループ内の比較演算の回数を減らすことができる
		}
		if(i == a.length - 1) {
			return 0;
		}
		return 1;
	}
}


Measured memory_bytes: 40148
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール
// Union-Find モジュール
struct union_find {
    vector<ull> par;
    vector<ull> num;
    union_find(ull n) : par(n, 0), num(n, 1) { iota(ALL_OF(par), 0); }
    ull root(ull i) { return par[i] == i ? i : (par[i] = root(par[i])); }
    bool same(ull i, ull j) { return root(i) == root(j); }
    void unite(ull i, ull j) {
        ull ri = root(i);
        ull rj = root(j);
        if (ri != rj) {
            if (num[ri] > num[rj]) swap(ri, rj);
            par[ri] = rj;
            num[rj] += num[ri];
        }
    }
};

// 処理内容
int main() {
    
    ll n, m; cin >> n >> m;
    vector<ll> p(n);
    REP(i, n) {
        cin >> p[i];
        p[i]--;
    }

    union_find uf(n);

    REP(i, m) {
        ll x, y; cin >> x >> y;
        x--; y--;
        uf.unite(x, y);
    }

    ll ans = 0;
    REP(i, n) {
        ans += uf.same(i, p[i]);
    }
    cout << ans << endl;

    
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 998244353LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

ll _pow(ll a, ll n) {
	if(n==0) return 1;
	else {
		ll res = 1;
		ll buf = a;
		while(n>0) {
			if(n%2==1) {
				res *= buf;
				res %= MOD;
			}
			buf *= buf;
			buf %= MOD;
			n/=2;
		}
		return res;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	map<pll, ll> ma;
	REP(i, m) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		ma[pll(a, b)] = c;
	}
	ll ans = 1;
	ll rem = n * n - n - (2 * (n - 1)) - (2 * (n - 2));
	if(n == 2) rem = 0;
	for(auto x: ma) {
		pll pos = x.first;
		ll num = x.second;
		if(abs(x.first.first - x.first.second) <= 2) continue;
		if(ma.count(pll(x.first.second, x.first.first))) {
			rem--;
			if(ma[pll(x.first.second, x.first.first)] != num) {
				cout << 0 << endl;
				return 0;
			}
		} else {
			rem -= 2;
		}
	}
	ans *= _pow(2, rem / 2);
	vector<vector<ll>> dp(n, vector<ll>(2, 0));
	dp[0][0] = 1; if(ma.count(pll(0, 0)) && ma[pll(0, 0)] != 0) dp[0][0] = 0;
	dp[0][1] = 1; if(ma.count(pll(0, 0)) && ma[pll(0, 0)] != 1) dp[0][1] = 0;
	FOR(i, 1, n) {
		if(ma.count(pll(i - 1, i)) && ma.count(pll(i, i - 1))) {
			if((ma[pll(i - 1, i)] + ma[pll(i, i - 1)]) % 2 == 1) {
				dp[i][0] = dp[i - 1][1];
				dp[i][1] = dp[i - 1][0];
			} else {
				dp[i][0] = dp[i - 1][0];
				dp[i][1] = dp[i - 1][1];
			}
		} else if(ma.count(pll(i, i - 1)) || ma.count(pll(i - 1, i))) {
			dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
			dp[i][1] = dp[i - 1][0] + dp[i - 1][1];
		} else {
			dp[i][0] = 2 * dp[i - 1][0] + 2 * dp[i - 1][1];
			dp[i][1] = 2 * dp[i - 1][0] + 2 * dp[i - 1][1];
		}
		if(ma.count(pll(i, i)) && ma[pll(i, i)] != 0) dp[i][0] = 0;
		if(ma.count(pll(i, i)) && ma[pll(i, i)] != 1) dp[i][1] = 0;
		dp[i][0] %= MOD; dp[i][1] %= MOD;
		if(i == n - 1) continue;
		if(ma.count(pll(i - 1, i + 1)) && ma.count(pll(i + 1, i - 1))) {
			if((ma[pll(i - 1, i + 1)] + ma[pll(i + 1, i - 1)]) % 2 == 1) {
				dp[i][0] = 0;
			} else {
				dp[i][1] = 0;
			}
		} else if(ma.count(pll(i - 1, i + 1)) || ma.count(pll(i + 1, i - 1))) {
			// 何もしない
		} else {
			dp[i][0] *= 2; dp[i][1] *= 2;
		}
		dp[i][0] %= MOD; dp[i][1] %= MOD;
	}
	ans *= (dp[n - 1][0] + dp[n - 1][1]);
	ans %= MOD;
	cout << ans << endl;
  	return 0;
}
/* --------------------------------------- */


Measured memory_bytes: 8832
#include<iostream>
#include<vector>

using namespace std;

int main()
{
	int n, a, d2, d4;
	d2 = d4 = 0;

	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a;
		if (a % 2 != 0)
			d2++;
		if (a % 4 == 0)
			d4++;
	}
	if (d2 + d4 == n)
	{
		if (d2 - d4 <= 1)
			cout << "Yes";
		else
			cout << "No";
	}
	else
	{
		if (d4 >= d2)
			cout << "Yes";
		else
			cout << "No";
	}
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm;

void main(){
  long a, b;
  readf("%d %d", &a, &b);

  long[] xs = [a, b, a-1, b-1];
  xs = sort(xs).array;

  writeln(xs[$-1] + xs[$-2]);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <forward_list>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <set>

using namespace std;

#define MAX 100000

int cnt;
int pre[MAX];
int low[MAX];
set<int> ans;

class EDGE{
public:
    int v;
    int w;
    EDGE(int vin,int win):v(vin),w(win){;}
};

class Graph{
public:
    int V;
    int E;
    vector<forward_list<int>> adj_list;
    void addedge(int v,int w);
    void Arculation(EDGE e);
    Graph(int v,int e):V(v),E(e){adj_list.resize(v);}
};

void Graph::addedge(int v,int w){
    adj_list[v].push_front(w);
    adj_list[w].push_front(v);
}

void Graph::Arculation(EDGE e){
    pre[e.w] = cnt++;
    low[e.w] = pre[e.w];
    int t;
    int counts = 0;
    for(auto n = adj_list[e.w].cbegin();n != adj_list[e.w].cend();++n){
        t = *n;
        if(pre[t] == -1){
            counts++;
            Arculation(EDGE(e.w,t));
            if(low[t] < low[e.w]) low[e.w] = low[t];
            if(low[t] >= pre[e.w] && e.w != e.v) ans.insert(e.w);
            if(e.w == e.v && counts >= 2) ans.insert(e.w);
        }
        else if(t != e.v){
            if(low[e.w] > pre[t]) low[e.w] = pre[t];
        }

    }
}

void solution(Graph &G){
    cnt = 0;
    for(int i = 0; i < G.V;i++){
        if(pre[i] == -1){
            G.Arculation(EDGE(i,i));
        }
    }
}

int main(){
    int V,E,s,t;
    scanf("%d %d",&V,&E);
    Graph G(V,E);
    for(int i = 0; i < E;i++){
        scanf("%d %d",&s,&t);
        G.addedge(s,t);
    }

    for(int i = 0;i < V;i++){
        pre[i] = -1;
        low[i] = -1;
    }

    solution(G);
    for(auto &a:ans){
        printf("%d\n",a);
    }
}


Measured memory_bytes: 6888
use List::Util qw/min/;

$input = <>;chomp $input;
($a, $b, $c) = split / /, $input;

@array = ($a, $b, $c);

@array = sort { int $b <=> int $a} @array;
($d, $e) = (pop @array, pop @array);
print $d + $e;


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
#define vv(a,b) vector< vector<int> > v(a,vector<int>(b,0));
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end(),greater<int>());
    int alice=0,bob=0;
    rep(i,n)
    {
        if(i%2==0)
        {
            alice+=a[i];
        }
        else
        {
            bob+=a[i];
        }
        
    }
    cout<<alice-bob;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

c = [0] * m
d = [0] * m
for i in range(m):
    c[i], d[i] = map(int, input().split())

import numpy as np
for i in range(n):
    min_distance = np.inf
    checkpoint = 0
    for j in range(m):
        distance = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if distance == min_distance:
            checkpoint = min(checkpoint, j)
        elif distance < min_distance:
            checkpoint = j
            min_distance = distance
    print(checkpoint + 1)


Measured memory_bytes: 14484
#include <bits/stdc++.h>
#define D(x) cout << #x << "=" << x <<endl; 
#define De(...)
using namespace std; 

int _; 

int k;

int main()
{
	scanf("%d",&k);
	int ans=k*360/__gcd(k,360);
	printf("%d\n",ans/k);
	return 0;
}


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>m;

	f(i,0,n-1) cin>>ara[i],mini=min(mini,ara[i]);

	int sum=0;
	f(i,0,n-1){
	    sum+=ara[i];
	}

    m-=sum;

    cout<<n+(m/mini)<<endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			double d = sc.nextInt();

			int count = 0;

			for (int i = 0; i < n; i++) {
				double x = sc.nextDouble();
				double y = sc.nextDouble();

				if (d >= calDist(x, y)) {
					count++;
				}
			}

			System.out.println(count);


		} catch (Exception e) {
			// TODO: handle exception
		}
	}

	public static double calDist (double  x, double y) {
		double ans = 0;

		ans = Math.pow(x, 2) + Math.pow(y, 2);
		ans = Math.sqrt(ans);

		return ans;
	}
}


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

public class Main {
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
	int n=sc.nextInt();
	int p[]=new int[n];
	for(int i=0;i<n;i++) {
		p[i]=sc.nextInt();
	}
	Arrays.sort(p);
	int ans=0;
	for(int j=0;j<n-1;j++) {
		ans+=p[j];
	}
	ans+=p[n-1]/2;
	System.out.println(ans);
	}
		
	//-----------http://codeforces.com/blog/entry/7018---------------------------------
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	//--------------------------------------------------------

}





Measured memory_bytes: 20948
var cnt:Int = 0

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val arr: Array<Int> = Array(n) {
        readLine()!!.toInt()
    }
    shellSort(arr,n)
    //val list: List<Int> = readLine()!!.split(" ").map { it.toInt() }
    //insertionSort(list.toIntArray(),n,2)
}
fun shellSort(A:Array<Int>, n:Int)
{
    var G =  gaps(n)
    var m = G.count()
    var R:Array<Int> = A
    println(m)
    println(G.joinToString(" "))

    for (i in (0..(m-1)))
    {
        R=insertionSort(A, n, G[i])
    }
    println(cnt)
    for (i in (0..(R.count() - 1)))
    {
        println(R[i])
    }
}
private fun gaps(n: Int): List<Int> {
    return generateSequence(1, { it * 3 + 1 })
            .takeWhile { it <= n }
            .toList()
            .reversed()
}
fun  insertionSort(A:Array<Int>, n:Int, g:Int):Array<Int>
{
    var v:Int
    var j:Int
    for (i in (g .. (n-1)))
    {
        v = A[i]
        j = i - g
        while (j >= 0 && A[j] > v)
        {
            A[j+g] = A[j]
            j = j - g
            cnt++
            A[j+g] = v
        }
    }
    return A
}




Measured memory_bytes: 397708
def gcd(a, b):
  while b:
    a, b = b, a % b
  return a
for _ in range(int(input())):
  a,b,c,d=map(int,input().split())
  if a<b or b>d:print("No");continue
  if c>=b:print("Yes");continue
  g=gcd(b,d)
  if (a%g+b-g)%b>c:print("No")
  else:print("Yes")

Measured memory_bytes: 9124
#include <string>
#include <vector>
#include <cstring>
#include <algorithm>
#include <iostream> 
#include <cmath>
 
using namespace std;
typedef long long ll;
typedef long double ld;

const ll MOD=ll(1e9+7);

//repetition
#define REP(i,n)  for(ll i=0;i<n;i++)

ll P_POW(ll i, ll n) {
  if(n==0) return 1;

  n--;
  ll rep = i;

  while(n) {
    rep = rep * i;
    n--;
  }
  return rep;
} 

unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
 
unsigned binarySearch(ll target, ll max, ll min) {
  while((max - min) > 1) {
      if((max + min)/2 > target) {
        max = (max + min)/2;
        min = min;
      } else {
        max = max;
        min = (max + min)/2;
      }
    }
}

ll n;


long long solve2(long long N) {
    if (N % 2 == 1) return 0;

    long long res = 0;
    N /= 2;
    while (N) {
        res += N / 5;
        cout << "N/5: " << N/5 <<  endl;
        cout << "res1: " << res <<  endl;
        N /= 5;
    }
    return res;
}


ll solve(ll n) {
    if (n % 2 == 1) return 0;

    ll res = 0;
    n /= 2;
    int c = 1;

    while ((ll) n/((ll)pow(5,c))) {
      res += n/P_POW(5,c);
      c++;
    }
    return res;
}

void f(int rest, string s) {
  char abc[] = "abc";
  if(rest == 0) {
    cout << s << endl;
  } else {
    for(int i=0; i < 3; i++) {
      f(rest - 1, s+abc[i]);
    }
  }
}

int main() {
  ll n;
  cin >> n;
  // 2次元vector
  //vector<vector<ll>> a(n ,vector<ll>{2,0});
  vector<ll> sw(n,0);
  vector<ll> se(n,0);

  REP(i, n) {
    char c;
    cin >> c;
    if(c == 'W') {
      if (i==0) {
        sw[i] = 1;
        se[i] = 0;
      } else {
        sw[i] = sw[i-1] + 1;
        se[i] = se[i-1];
      }
    } else {
      if (i==0) {
        sw[i] = 0;
        se[i] = 1;
      } else {
        sw[i] = sw[i-1];
        se[i] = se[i-1] + 1;
      }
    }
  }

  ll c = 0;
  REP(i, n) {
    /*
    cout << "i: " << i << endl;
    cout << "sw[i-1] : " << sw[i-1] << endl;
    cout << "se[n-1]: " << se[n-1] << endl;
    cout << "se[n-1]-se[i]: " << se[n-1] - se[i] << endl;
    cout << "sw[i-1] + se[n-1] - se[i]:  " << sw[i-1] + se[n-1] - se[i] << endl;
    */
    if(i==0) {
      c = se[n-1] - se[i];
    } else {
      c = min(c, sw[i-1] + se[n-1] - se[i]);
    }
  }

  cout << c << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
	
	int ret = 101;
	for (int i = 0 ; i < 26 ; i ++){
		char c = 'a' + i;
		int pre = -1;
		int cnt = 0;
		for (int j = 0 ; j < s.size() ; ++j){
			if(s[j] == c){
				cnt = max(cnt, j - pre);
				pre = j;
			}
		}
		cnt = max(cnt, (int)s.size() - pre);
		ret = min(ret, cnt - 1);
	}

	cout << ret << endl;
}

Measured memory_bytes: 256