akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        boolean f = true;
        char temp;
        temp = s.charAt(0);

        for(int i=1;i<s.length();i++){
            if(temp == s.charAt(i)){
                continue;
            }else{
                System.out.println("Yes");
                System.exit(0);
            }
        }
        System.out.println("No");
    }

}


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

using namespace std;

int solve(vector<set<int> > info,vector<int> seq){
	int c=0;
	int ans=0;
	for(int i=0;i<info.size();i++){
		bool b=true;
		for(int k=0;k<seq.size();k++){
			if(info[i].find(seq[k])==info[i].end()){
				b=false;
				break;
			}
		}
		if(b){c++;
			ans = i;
			if(c>1)return -1;
		}
	}
	if(c>1)return -1;
	if(c==0)return -1;
	return ans+1;
}

int main(){
	while(true){
		int n;
		cin >> n;
		if(n==0)return 0;
		vector<set<int> > info(n);

		for(int i=0;i<n;i++){
			int m;
			cin >> m;
			for(int k=0;k<m;k++){
				int t;
				cin >> t;
				info[i].insert(t);
			}
			//info[i].insert(i);
		}
		vector<int> seq;
		int m;
		cin>>m;
		for(int i=0;i<m;i++){
			int t;
			cin >> t;
			seq.push_back(t);
		}
		cout << solve(info,seq) << endl;
	}
}

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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

int N;
int x[110000], y[110000];
char d[110000];
double rmax = -1e9, rmin = 1e9, lmax = -1e9, lmin = 1e9, vmax = -1e9, vmin = 1e9;
double umax = -1e9, umin = 1e9, dmax = -1e9, dmin = 1e9, hmax = -1e9, hmin = 1e9;
signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> d[i];
        if (d[i] == 'R') {
            chmax(rmax, x[i]), chmin(rmin, x[i]), chmax(hmax, y[i]), chmin(hmin, y[i]);
        } else if (d[i] == 'L') {
            chmax(lmax, x[i]), chmin(lmin, x[i]), chmax(hmax, y[i]), chmin(hmin, y[i]);
        } else if (d[i] == 'U') {
            chmax(umax, y[i]), chmin(umin, y[i]), chmax(vmax, x[i]), chmin(vmin, x[i]);
        } else if (d[i] == 'D') {
            chmax(dmax, y[i]), chmin(dmin, y[i]), chmax(vmax, x[i]), chmin(vmin, x[i]);
        }
    }
    double ans = 1e20;
    for (int i = 0; i < 5e8; i++) {
        double w = max({rmax, lmax, vmax}) - min({rmin, lmin, vmin});
        double h = max({umax, dmax, hmax}) - min({umin, dmin, hmin});
        chmin(ans, w * h);
        rmax += 0.5, rmin += 0.5, lmax -= 0.5, lmin -= 0.5;
        umax += 0.5, umin += 0.5, dmax -= 0.5, dmin -= 0.5;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1920
import math



n = int(input())

x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

p1 = 0
p2 = 0
p3 = 0
p4 = []
for i in range(n):
    p1 += math.pow(abs(x[i]-y[i]),1)

for i in range(n):
    p2 += math.pow(abs(x[i]-y[i]),2)

for i in range(n):
    p3 += math.pow(abs(x[i]-y[i]),3)
for i in range(n):
    p4.append(abs(x[i]-y[i]))

print(p1)
print(math.sqrt(p2))
print(math.pow((p3),1/3))
print(max(p4))



Measured memory_bytes: 5720
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int N;
	while(cin >> N){
		vector<int> A(N);
		for(int i=0;i<N;i++) cin >> A[i];
		sort(A.begin(), A.end());
		bool ok = true;
		for(int i=0;i<N;i++){
			if(A[i] != (i+N%2)/2*2+(1-N%2)) ok = false;
		}
		if(!ok) cout << 0 << endl;
		else {
			int res = 1;
			for(int i=0;i<N/2;i++) res = (2*res)%1000000007;
			cout << res << endl;
		}
	}
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))

x = 0
for i in range(N): # x_0の値を得る
    if i % 2 == 0:
        x += A[i]
    else:
        x -= A[i]

for i in range(N):
    print(x, end=' ') # x_iをprint
    x = 2 * A[i] - x # x_(i+1)を得る

Measured memory_bytes: 14028
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define p_b push_back
#define pll pair < ll , ll >

using namespace std;

const ll M = 1000000007;

ll mult( ll a, ll b)
{
    return (a*b)%M;
}

ll bin_pow( ll a, ll n)
{
    ll ans = 1;
    while(n>0)
    {
        if(n&1) ans = mult(ans,a);
        a = mult(a,a);
        n/=2;
    }
    return ans%M;
}

ll solve( ll a, ll n)
{
    ll p = 1, q = 1;
    for( int i = 1; i <= a; i++)
    {
        p = mult(p,i);
    }
    for( int i = 0; i < a; i++)
    {
        q = mult(q,n-i);
    }
    return mult(q,bin_pow(p,M-2));
}


int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,a,b;
    cin >> n >> a >> b;
    ll ans = bin_pow(2,n)-1;
    ans = ans - solve(a,n)-solve(b,n);
    ans%=M;
    if(ans<0)
    {
        ans+=M;
    }
    cout << ans;
}



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

int main(){

    int A[3];
    for(int i=0;i<3;++i)cin>>A[i];

    sort(A,A+3);
    int X=A[2];

    if((3*X)%2==(A[0]+A[1]+A[2])%2){
        cout<<(2*X-A[1]-A[0])/2;

    }else{
        cout<<(3*(X+1)-A[1]-A[2]-A[0])/2;
    }

}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, a) for (int i = 0; i < (int)(a); i++)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
typedef long long ll;
template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.first>>v.second;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.first<<","<<v.second;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const vector<T>&a){ll res(0);for(auto&&x:a)res+=x;return res;}

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template <typename Head> void dump(Head &&head) {
  cerr << head;
  dump();
}
template <typename Head, typename... Tail>
void dump(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  dump(forward<Tail>(tail)...);
}
#define debug(...)                                                               \
  do {                                                                         \
    cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = ";                        \
    dump(__VA_ARGS__);                                                         \
  } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template <typename T> struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;

const ll LINF = 1LL << 60;
const int INF = 1001001001;

/////////////////////////////////////////////////////////////////////


int main()
{
  int t; scanf("%d", &t);

  while (t--) {
    ll n,m,a,b; scanf("%lld %lld %lld %lld", &n, &m, &a, &b);
    printf("%lld\n", floor_sum(n, m, a, b));
  }

  return 0;
}


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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    ll n, t;
    cin >> n >> t;

    vector<ll> nums(n);
    rep(i, n) cin >> nums[i];

    ll sum = 0;
    for(int idx = 0; idx < n - 1; ++ idx){
        sum += min(t, nums[idx+1] - nums[idx]);
    }
    sum += t;

    cout << sum << endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;

int cnt[100010];
void solve() {
	int N, X, Y; cin >> N >> X >> Y;
	X--, Y--;
	REP(i, N - 1) {
		FOR(j, i + 1, N) {
			int d = abs(j - i);
			chmin(d, abs(X - i) + 1 + abs(Y - j));
			chmin(d, abs(Y - i) + 1 + abs(X - j));
			cnt[d]++;
		}
	}
	FOR(j, 1, N) {
		print(cnt[j]);
	}
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 256
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
using namespace std;
typedef long long  ll;

/** Problem0206 : Next Trip **/
int main()
{
	int L, a, b, sum, ans;
	while (cin>>L, L!=0) {
		ans=0; sum=0;
		rep(i, 12) {
			cin >> a >> b;
			sum+=a-b;
			
			if (ans>0) continue;
			
			if (sum>=L) {
				ans = i+1;
			}
		}
		if (ans>0)
			cout << ans << endl;
		else
			cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int N;
    int L[100];
    cin >> N;
    for(int i =0; i < N; i++){
        cin >> L[i];
    }

    int count = 0;
    int tmp [100];
    int cnt = 10;

    for(int j = 0; j < N-1; j++){
        if(L[j] > L[ j + 1]){
            if(count == 0){
              
                tmp[0] = L[j];

                cnt = j;
                count  = 1;
            }else if(count == 1){

                tmp[1] = L[j+1]; 
                L[j+1] = tmp[0];
                L[cnt] = tmp[1];
                count ++;
            }
        }
    }

    bool flag = true;

    if(count != 0){
        for(int k = 0; k < N-1; k++){
             if(L[k] > L[ k + 1]){
                flag = false;
             }
        }
    }


    if(flag == 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

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

int main() {
  int q; cin >> q;
  map<string, int> mp;
  for (int i = 0; i < q; i++) {
    int cmd; cin >> cmd;
    if (cmd == 0) {
      string key; int x; cin >> key >> x;
      mp[key] = x;
    }
    if (cmd == 1) {
      string key; cin >> key;
      cout << mp[key] << endl;
    }
  }
}



Measured memory_bytes: 27864
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**6)
# ----------------------------------------------------------- #

a, v = (int(x) for x in input().split())
b, w = (int(x) for x in input().split())
t = int(input())

if a == b:
    print("YES")
elif a < b:
    if a + t*v >= b + t*w:
        print("YES")
    else:
        print("NO")
else:
    if a - t*v <= b - t*w:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 72396
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b<c+d){
        cout<<"Right"<<endl;
    }
    else if(a+b==c+d){
        cout<<"Balanced"<<endl;
    }
    else{
        cout<<"Left"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 1234567890123456
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int maxn =1e5 + 10;

//initialization here
//
int ko[maxn];
int memo[maxn];
//
//initialization finish


// your function is here
//

//
// your function finished



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here
	//
	int n, m; cin >> n >> m;
	memset(memo, 0, sizeof memo);
	memo[0]++;
	rep(i, n) ko[i] = 1;
	rep(i, m)
	{
		int x, y; cin >> x >> y;
		x--, y--;
		ko[x]--, ko[y]++;
		if (memo[x])memo[y]++;
		if (ko[x] == 0)
		{
			if (memo[x]) memo[x] = 0;
		}
	}

	int cnt = 0;
	rep(i, n)if (memo[i])cnt++;
	
	Print(cnt);



	//
	// your code finished


	return 0;
}

Measured memory_bytes: 1024
#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 a, b, c, k;
    cin >> a >> b >> c >> k;
    // a < b < c
    while (k > 0 && a >= b) b *= 2, --k;
    while (k > 0 && b >= c) c *= 2, --k;
    if (a < b && b < c)
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 3632
N, S = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353
dp = [[0 for _ in range(S+1)] for _ in range(N)]

for j in range(0, S+1):
    if j == A[0]:
        dp[0][j] = 1
        break

for i in range(1, N):
    for j in range(0, S+1):
        if j > A[i]:
            dp[i][j] = (dp[i-1][j]+dp[i-1][j-A[i]])%mod
        elif j == A[i]:
            dp[i][j] = (dp[i-1][j]+(i+1))%mod
        else:
            dp[i][j] = dp[i-1][j]
            
ans = 0
for i in range(0, N):
    ans = (ans+dp[i][S])%mod
    
print (ans)

Measured memory_bytes: 120028
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();
        for(int i = 0; i < 10; i++){
            int tmp = r * x - d;
            System.out.println(tmp);
            x = tmp;
        }
    }
}


Measured memory_bytes: 21844
#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(){
	ll n,k;
	cin >> n >> k;
	ll m = n%k;
	ll ans = min(m, abs(k-m));
	cout << ans << endl;  
}

Measured memory_bytes: 3628
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(" ");
            int X = int.Parse(input[0]);
            int Y = int.Parse(input[1]);
            string ans = "No";
            for (int k = 0; k <= 100; k++)
            {
                for (int t = 0; t <= 100; t++)
                    if (k + t == X && 2 * k + 4 * t == Y)
                    {
                        ans = "Yes";
                        break;
                    }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 17852
N = int(input())
a = list(map(int, input().split()))

A =[] 

for i in range(N):
  A.append([i+1,a[i]])


A.sort(key=lambda x: x[1], reverse=True)


dp = [[0] * (N+1) for i in [1] * (N+1)]


for i in range(N+1):
  for x in range(i+1):
    y = i - x
    if x == 0 and y == 0:
      dp[x][y] = 0
    
    elif x == 0:
      dp[x][y] = dp[x][y-1] + A[y-1][1]*((N-y+1) - (A[y-1][0]))


    elif y == 0:
      dp[x][y] = dp[x-1][y] + A[x-1][1]*((A[x-1][0]) - x )


    else:
      dp[x][y] = max(dp[x][y-1] + A[x+y-1][1]*((N-y+1) - (A[x+y-1][0])) , dp[x-1][y] + A[x+y-1][1]*((A[x+y-1][0]) - x ))

ans = 0
for x in range(N+1):
  y = N - x
  ans = max(ans,dp[x][y])
  
print(ans)

Measured memory_bytes: 105884
//
//  main.cpp
//  ervb
//
//  Created by Kanak Gautam on 21/04/20.
//  Copyright © 2020 Kanak Gautam. All rights reserved.
//
 
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#define pb push_back
#define mk make_pair
#define endl "\n"
#define mod 1000000007
using namespace std;
typedef long long int lli;
typedef long double ld;
priority_queue <lli, vector<lli>, greater<lli> > ti;
vector <lli> p[500005],g[500005],f(500005,0),b(500005,0),a(500005,0),ans(500005,0);
map <pair<lli,lli>,lli> mp;
set<pair<lli, lli> > s;
set<lli> st;
map<lli,lli> np,v;
queue<lli> qy;
lli n,q;
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
lli bpow(lli a, lli b) {
    lli res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res%mod;
}
lli fact(lli i)
{
    f[0]=1;
    for(lli k=1;k<=i;k++)
    {
        (f[k]=f[k-1]*k)%=mod;
    }
    return f[i];
}
lli isprime(lli n)
{
    if(n==1)
        return 0;
    for(lli i=2;i<=sqrt(n);i++)
        if(n%i==0)
            return 0;
    return 1;
}
bool cmp(lli i,lli j)
{
    return p[i].size()<p[j].size();
}
 void add(lli i,lli x)
{
    for(;i<=n;i+=i&(-i))
    {
        f[i]+=x;
    }
}
lli sum(lli i)
{
    lli c=0;
    for(;i>0;i-=i&(-i))
    {
        c+=f[i];
    }
    return c;
}
/*void sieve()
{
    for(lli i=2;i<=5000000;i++)
    {
        if(b[i]==0)
        {
        for(lli j=2;i*j<=5000000;j++)
        {
            b[i*j]=1;
        }
        }
    }
}*/
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cin>>n>>q;
    for(lli i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    lli l,r;
    for(lli i=1;i<=q;i++)
    {
        cin>>l>>r;
        p[r].pb(l);
        g[r].pb(i);
    }
    for(lli i=1;i<=n;i++)
    {
        if(b[a[i]]>0)
        {
            add(b[a[i]],-1);
        }
        add(i,1);
        b[a[i]]=i;
        for(lli j=0;j<p[i].size();j++)
        {
            ans[g[i][j]]=sum(i)-sum(p[i][j]-1);
        }
    }
    for(lli i=1;i<=q;i++)
    {
        cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 62688
n = int(input())

score = {}
for i in range(1, n+1):
    c = 0
    i_ = i
    while(1):
        if i_ % 2 == 0:
            i_ /= 2
            c += 1
        else:
            break
    score[i] = c 

ans = max(score.items(), key=lambda x:x[1])[0]    
        
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
	char name[100];
	int t;
}p;

p Q[LEN];

int head,tail;

void enqueue(p x)
{
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

p dequeue(){
	p x = Q[head];
	head = (head+1) % LEN;
	return x;
}

int min(int a,int b){
	return a<b?a:b;
}

int main()
{
	int n,q,c;
	int sum = 0;
	p u;
	scanf("%d %d",&n,&q);
	
	for(int i=1; i<=n; i++)
	{
		scanf("%s",Q[i].name);
		scanf("%d",&Q[i].t);
	}
	
	head = 1, tail = n+1;
	while(head != tail)
	{
		u = dequeue();
		c = min(q,u.t);
		u.t -= c;
		sum += c;
		
		if(u.t>0)
		{
			enqueue(u);
		}
		else 
		{
			printf("%s %d\n",u.name,sum);
		}
			
	}
}


Measured memory_bytes: 11872
#include <cstdio>
#include <stack>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#define MAXN 100005
using namespace std;
int maxC = 0x7fffffff;
int h[MAXN];
int dp[MAXN];

int main(void)
{
    int n;
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> h[i];
    }

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

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

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

    for(int i=1;i<3;i++){
        int d=c[0][i]-c[0][0];
        for(int j=1;j<3;j++){
            if(c[j][i]!=c[j][0]+d){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
bool check(int x)
{
	if(x<10)return true;
	else return false;
}
void mprint(int a,int b,int c)
{
	if(check(a))
	{
		cout << 0 << a;
	}
	else
	{
		cout << a;
	}
	cout << ':';
	if(check(b))
	{
		cout << 0 << b;
	}
	else
	{
		cout << b;
	}
	cout << ':';
	if(check(c))
	{
		cout << 0 << c;
	}
	else
	{
		cout << c;
	}
	cout << endl;
	return ;
}
int main()
{
	int const v=120*60;
	int a,b,c;
	while(1)
	{
		cin >> a >> b >> c;
		if(a==-1&&b==-1&&c==-1)break;
		int x=0,t=v;
		x+=3600*a;
		x+=60*b;
		x+=c;
		x=t-x;
		int y=3*x;
		a=x/3600;
		x-=a*3600;
		b=x/60;
		x-=b*60;
		c=x;
		mprint(a,b,c);
		a=y/3600;
		y-=a*3600;
		b=y/60;
		y-=b*60;
		c=y;
		mprint(a,b,c);
	}
	return 0;
}

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

using namespace std;

//typedef pair<int,int> P;
typedef long long ll; 

#define int ll

struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;
  vector<ll> next;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
	next.resize(V);
    for(int i=0;i<V;i++){
      d[i] = 1000000;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    for(int i=0;i<V;i++){
      d[i] = 1000000;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
		  next[e.to]=v;
        }
      }
    }
  }
};


main(){
	int n,m;
	cin >> n >> m;
	graph g(n);
	
	for(int i=0;i<m;i++){
		int a,b;
		cin >> a >> b;
		g.add_edge(a-1,b-1,1);
		g.add_edge(b-1,a-1,1);
	}

	g.dijkstra(0);
	for(int i=1;i<n;i++){
		if(g.d[i]==1000000){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	for(int i=1;i<n;i++){
		cout << g.next[i]+1 << endl;
	}

	
	return 0;
}


Measured memory_bytes: 19320
#include<bits/stdc++.h>
using namespace std;
char a[1005];int l,i;bool b[4];
int main(){
	scanf("%s",a);
	l=strlen(a);
	for(i=0;i<l;i++){
		if(a[i]=='N') b[0]=1;
		if(a[i]=='W') b[1]=1;
		if(a[i]=='S') b[2]=1;
		if(a[i]=='E') b[3]=1;
		if(b[0]==1&&b[1]==1&&b[2]==1&&b[3]==1) break;
	}
	b[0]==b[2]&&b[1]==b[3]?printf("Yes\n"):printf("No\n");
	return 0;
}

Measured memory_bytes: 256
s = input()
ans = 0
con = 0

for i in range(len(s)):
  
  if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T':
    con += 1
    ans = max(ans, con)
  else:
    con = 0

print(ans)

Measured memory_bytes: 3064
# https://atcoder.jp/contests/abc044/tasks/arc060_a
# ソートしてからごちゃごちゃやればどうにかなりそう(無理でした)

'''
解説満点解法1
もしもk枚選んだとき、合計がsになる通りの数がわかったら？→s=k*Aとなる場合の数の合計をすれば良い

k枚選んだとき、合計がsになる通りの数は典型的なDP！
dp(j,k,s)... X[0:j]からk枚選んで、その合計をsにするような選び方の総数
と定義すると、
dp(j+1,k,s) = X[j]を選んだ結果sになったときの通りの数 + X[j]を選ばずにsになっている通りの数 なので
dp(j+1,k,s) = dp(j,k-1,s-X[j]) + dp(j,k,s)

あとは初期条件と境界条件と伝播条件を付け加える。
境界条件 dp(j,k,0)=0 (数枚選んで合計が0になるのはありえない)
初期条件 dp(j,0,0)=1 (ただし、0枚選んだときは1通りとなる)(s-X[j]=0のときに1通りとなってほしいという気持ちもある)

伝播条件 s-X[j]<0に関しては dp(j-1,k-1,s-X[j])が必ず0通りとなる(ありえないので)
'''

import sys
read = sys.stdin.readline
from itertools import product


def read_ints():
    return list(map(int, read().split()))


N, A = read_ints()
X = read_ints()
S = sum(X)

# 満点解法1
dp = [[[0] * (S + 1) for _ in range(N + 1)] for _ in range(N + 1)]
for j in range(N + 1):  # 初期条件
    dp[j][0][0] = 1  # 1枚も選ばずに0になるのは1通り


for j, k, s in product(range(N), range(1, N + 1), range(S + 1)):
    dp[j + 1][k][s] = dp[j][k][s] + \
        (0 if s - X[j] < 0 else dp[j][k - 1][s - X[j]])

# s=k*Aとなるような通りの数の総数
ans = 0
for k in range(1, N + 1):  # 0個はとる通りの数はいらない
    s = k * A
    if s <= S:
        ans += dp[N][k][s]

# print(dp)
print(ans)


'''
満点解法2


'''


Measured memory_bytes: 92124
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include "iomanip"

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * b, c * d);
    return 0;
}



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

int arr[3];
int main(){

for(int i=0;i<3;i++){cin>>arr[i];}
sort(arr,arr+3);
if(arr[0]!=arr[1]) cout<<arr[0];
else cout<<arr[2];


return 0;

}








Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))


struct unifo{
	int n;
	int uni[100005];
	void init(int in){
		n=in;
		rep(i,n)uni[i]=i;
	}
	int find(int p){
		if(uni[p]==p)return p;
		else return (uni[p]=find(uni[p]));
	}
	void mer(int p,int q){
		if(!same(p,q))uni[find(p)]=find(q);
	}
	bool same(int p,int q){
		return find(p)==find(q);
	}
	void out(){
		vector<mp> ps;
		//printf("%d %d\n",i,find(i));
		rep(i,n)ps.push_back(mp(find(i),i));
		sort(ps.begin(),ps.end());
		printf("uni .. %d elem\n{ ",n);
		rep(i,n){
			if(i!=0 && ps[i-1].fir!=ps[i].fir)printf("}\n{ ");
			printf("%d ",ps[i].sec);
		}
		printf("}\n\n");
	}
} uni;

vector<int> dat[100005];

int n,m;
int main(void){
	scanf("%d%d",&n,&m);
	uni.init(n+3);
	rep(i,n){
		int k;
		scanf("%d",&k);
		rep(j,k){
			int a;
			scanf("%d",&a); a--;
			dat[a].push_back(i);
		}
	}
	
	rep(i,m){
		int ls=dat[i].size();
		rep(j,ls-1){
			int a=dat[i][j],b=dat[i][j+1];
			//printf("%d %d\n",a,b);
			uni.mer(a,b);
		}
	}
	
	bool ok=true;
	reg(i,1,n-1){
		if(!uni.same(0,i))ok=false;
	}
	printf("%s\n",ok?"YES":"NO");
	return 0;
}






Measured memory_bytes: 4988
x,n = map(int, input().split())
if n == 0:
  print(x)
else:
  line = list(map(int, input().split()))
  sign = [0 for i in range(100)] #x以上ならば0，小さければ1
  abs_list = [0 for i in range(100)] #差の絶対値のリスト

  for i in range(n):
    y = x - line[i]
    if y < 0:
      sign[abs(y)] += 1
    abs_list[abs(y)] += 1
  for mini in range(100):
    if mini == 0:
      if abs_list[mini] == 0:
        print(x)
        break
    else:
      if abs_list[mini] == 0:
        print(x - mini)
        break
      if abs_list[mini] == 1:
        if sign[mini] == 0:
          print(x + mini)
          break
        else:
          print(x - mini)
          break

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, x, diff = INF, a, ans;
  cin >> x >> n;
  set<ll> p;
  vector<ll> q;
  rep(i, n) cin >> a, p.insert(a);
  for (int i = 0; i <= 101; ++i)
    if (p.count(i) == 0) q.push_back(i);

  for (int i = q.size() - 1; i >= 0; --i)
    if (abs(x - q[i]) <= diff) ans = q[i], diff = abs(x - q[i]);

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3564
a=int(input())
b=int(input())
c=int(input())
x=int(input())
count=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k == x:
                count+=1
print(count)


Measured memory_bytes: 67388
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
 
int main(){
  int A , B ;
  cin >> A >> B ;
  if( A >= 0  && A <= 5 ) cout << 0 << endl;
  else if( A >= 6  && A <= 12 ) cout << B/2 << endl;
  else if( A >= 13 ) cout << B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9+3;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
int main(){
    char c[6*int(1e5)];
    int left = int((2*1e5)+5);
    string s;
    cin >> s;
    int right = int((2*1e5)+5)+s.size()+1;
    rep(i,s.size()) c[int(2*(1e5)+5)+1+i]=s[i];
    bool reverse = false;
    int q;
    cin >> q;
    int k,f;
    char cc;
    rep(i,q){
        cin >> k;
        if(k==1) reverse = !reverse;
        else{
            cin >> f >> cc;
            if((f==1&&!reverse) || (f==2 && reverse)) c[left]=cc,left--;
            else c[right]=cc,right++;
        }
        //cout << reverse << endl;
    }
    if(reverse) for(int i = right-1;i>left;i--) cout << c[i];
    else for(int i = left+1;i<right;i++) cout << c[i];
    cout << endl;
}

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

void calcSum(string str1, string str2){
    int c = 0;
    string str = "";
    if (str1.size() > str2.size()){
        swap(str1, str2);
    }
    for (int i=0;i<(int)str1.size();i++){
        int sum = (str1[i] - '0') + (str2[i] - '0') + c;
        if (sum >= 10){
            str += (sum % 10) + '0';
            c = 1;
        }else{
            str += sum + '0';
            c = 0;
        }
    }
    for (int i=(int)str1.size();i<(int)str2.size();i++){
        int sum = (str2[i] - '0') + c;
        if (sum >= 10){
            str += (sum % 10) + '0';
            c = 1;
        }else{
            str += sum + '0';
            c = 0;
        }
    }
    if (c == 1)
        str += '1';
    reverse(str.begin(), str.end());
    if (str.size() > 80){
        cout << "overflow" << endl;
    }else{
        cout << str << endl;
    }
}

int main()
{
    int n;
    string str1, str2;
    
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> str1;
        cin >> str2;
        reverse(str1.begin(), str1.end());
        reverse(str2.begin(), str2.end());
        calcSum(str1, str2);
    }

    return 0;
}

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

// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

typedef vector<ll> vl;
typedef pair<ll, ll> pll;

#define St first
#define Nd second
#define Pb push_back
#define Mp make_pair
#define print_pair(p) cout<<p.St<<" "<<p.Nd
#define endl "\n"

#define REP(i,a,b) for(int i = a; i <= b; i++)
#define REV(i,a,b) for(int i = a; i >= b; i--)

#define AritSum(a,d,n) ((n)*(2*(a)+((n)-1)*(d)))/2
#define Log(base, num) log2(num)/log2(base)

#define MOD 17
ll binpow(ll x, ll y) {
	ll z = 1;
	while(y > 0) {
		if(y % 2 == 1)
			z = (z*x)%MOD;
		x = (x*x)%MOD;
		y /= 2;
	}
	return z;
}
// a^-1 (mod m) = a^(m-2) (mod m) - m is prime
ll inv(ll x) {return binpow(x, MOD - 2);}
ll divide(ll x, ll y) {return x* inv(y);}

// ************* MAIN *******************

ll N; 
int A[200005], B[200005];

void solve() {
    cin>>N;
    REP(i,0,N-1) cin >> A[i] >> B[i];
    sort(A,A+N);
    sort(B,B+N);
    if (N&1) {
        cout << B[N/2] - A[N/2] + 1 << endl;
    }else {
        cout << B[N/2] + B[N/2-1] - A[N/2] - A[N/2-1] + 1 << endl;
    }
}

/*
g++ -std=c++14 -Wall -Wextra -O2 Test.cpp -o Test

./Test < in
*/
int main() {
    int _=1;
    // cin>>_;
    REP(t,1,_) {
        // cout << "Case #" << t << ": ";
        solve();
        // cout << solve() << endl;
    }
    return 0;
}


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

#define For(i, j, k) for (int i = j; i <= k; i++)

using namespace std;

const int N = 2e5 + 10;

int n;
int pa[N], fa[N], w[N];
int c0[N], c1[N];

int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }

struct Node {
	int o, x, y;

	bool operator < (const Node B) const {
		return 1ll * y * B.x > 1ll * x * B.y;
	}
};

priority_queue<Node> q;

int main() {

	scanf("%d", &n);
	For(i, 2, n) scanf("%d", &pa[i]);
	For(i, 1, n) {
		scanf("%d", &w[i]), fa[i] = i;
		c0[i] = !w[i], c1[i] = w[i];
		if (i > 1) q.push((Node){i, c0[i], c1[i]});
	}

	long long ans = 0;
	while (!q.empty()) {
		Node s = q.top(); q.pop();
		int o = find(s.o);
		if (c0[o] != s.x || c1[o] != s.y) continue;
		int f = find(pa[o]);
		ans += 1ll * c1[f] * c0[o];
		fa[o] = f, c0[f] += c0[o], c1[f] += c1[o];
		if (f != 1) q.push((Node){f, c0[f], c1[f]});
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 8176
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int M = sc.nextInt();
		
		long[] xs = new long[N];
		long[] ys = new long[N];
		for(int i = 0; i < N; i++){
			xs[i] = sc.nextLong();
			ys[i] = sc.nextLong();
		}
		
		long[] cs = new long[M];
		long[] ds = new long[M];
		for(int i = 0; i < M; i++){
			cs[i] = sc.nextLong();
			ds[i] = sc.nextLong();
		}
		
		for(int i = 0; i < N; i++){
			long dist = Long.MAX_VALUE;
			int min_j = -1;
			
			for(int j = 0; j < M; j++){
				final long d = Math.abs(xs[i] - cs[j]) + Math.abs(ys[i] - ds[j]);
				
				if(d < dist){
					dist = d;
					min_j = j;
				}
			}
			
			System.out.println(min_j + 1);
		}
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
		
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 23252
#include<stdio.h>
#include<string.h>

int main(void)
{
     char a[10];
     char b[100];
     char c[10];
     scanf("%s",a);
     scanf("%s",b);
     scanf("%s",c);
     printf("%c%c%c\n",a[0],b[0],c[0]);
     return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define _ << " " <<

typedef long long llint;
typedef long long ll;
typedef pair<int, int> P;
#define X first
#define Y second

const int MOD = 1e9 + 7;

int add(int a, int b)
{
  a += b;
  if (a >= MOD)
    a -= MOD;
  return a;
}

int sub(int a, int b)
{
  a -= b;
  if (a < 0)
    a += MOD;
  return a;
}

int mul(int a, int b)
{
  return (int) (((ll) a * b) % MOD);
}

int pot(int x, int e)
{
  int r = 1;
  for (; e; x = mul(x, x), e /= 2)
    if (e & 1)
      r = mul(r, x);
  return r;
}

int inv(int x)
{
  return pot(x, MOD - 2);
}

int divv(int a, int b)
{
  return mul(a, inv(b));
}

const int mod = int(1e9) + 7;
const int DIM = 4;

struct Matrix {
  int a[DIM][DIM];
  int *operator [] (int r) { return a[r]; };

  Matrix(int x = 0) {
    memset(a, 0, sizeof a);
    if (x) REP(i, DIM) a[i][i] = x;
  }
} const I(1);

Matrix operator * (Matrix A, Matrix B) {
  const llint mod2 = llint(mod) * mod;
  Matrix C;
  REP(i, DIM) REP(j, DIM) {
    llint w = 0;
    REP(k, DIM) {
      w += llint(A[i][k]) * B[k][j];
      if (w >= mod2) w -= mod2;
    }
    C[i][j] = (int) (w % mod);
  }
  return C;
}

Matrix operator ^ (Matrix A, llint b) {
  Matrix R = I;
  for (; b > 0; b /= 2) {
    if (b % 2) R = R*A;
    A = A*A;
  }
  return R;
}

Matrix ob, pos;

int main()
{
  REP(i, 4) {
    REP(j, 4) { //iz i u j
      if (!j) ob[j][i] = 1; 
      else {
	if (j>=i) ob[j][i]++;
	if (j == 2 && i <= 1) ob[j][i]++;
	pos[j][i] = ob[j][i];
      }
    }
  }   

  int n, m;
  scanf("%d%d", &n, &m);

  Matrix tmp = I;

  int zad = 0;
  REP(i, m) {
    int x;
    scanf("%d", &x);
    
    tmp = (ob ^ (x - zad - 1)) * tmp;
    tmp = pos * tmp;
    zad = x;
  }

  tmp = (ob ^ (n - zad)) * tmp;

  printf("%d\n", tmp[0][0]);
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>                                                             
#include <cmath>
using namespace std;
 
#define PI atan(1)*4
int main()
{
    double s, c, r;
    cin >> r;
    s = PI*r*r;
    c = 2*PI*r;
    cout << fixed << s << " " << c << endl;
    return 0;
}


Measured memory_bytes: 3284
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
#import numpy as np
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
S = str(input())

if S[0] == S[1] and S[1] == S[2] :
  print ("No")
else :
  print ("Yes")



Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
int main() {
  ll n = 0;
  ll sum = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      sum += i;
    }
  }
  cout << sum << endl;
}

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

typedef struct {
  int value;
  char mark;
}card;

int isstable(card *ori, card *srt,int N){
  int i=0,flg;
  while (i<N){
    flg=0;
    for (int j=0;j<N;j++){
      if (srt[i].value==ori[j].value && srt[i].mark==ori[j].mark){
	if (i+1<N && srt[i].value==srt[i+1].value)i++;
	else{
	  flg=1;
	  i++;
	  break;
	}
      }
    }
    if (flg) continue;
    else return 0;
  }
  return 1;
}

int partition(card *A,int p,int r){
  int x,i;
  card t;
  x=A[r].value;
  i=p-1;
  
  for (int j=p;j<r;j++){
    if (A[j].value<=x){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }

  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;

  return i+1;
}

void quicksort(card *A,int p,int r){
  int q;
  if (p<r){
    q = partition(A,p,r);
    quicksort(A,p,q-1);
    quicksort(A,q+1,r);
  }
}

int main(){
  int i,n;
  card A[100005];
  card B[100005];
  
  cin >> n;
  for(i=0;i<n;i++){
    cin >> A[i].mark >> A[i].value;
    B[i]=A[i];
  }
  quicksort(B,0,n-1);

  if (isstable(A,B,n))cout << "Stable" << endl;
  else cout << "Not stable"<<endl;

  for (i=0;i<n;i++)
    cout << B[i].mark << " " << B[i].value << endl;
  
  
  return 0;
}

Measured memory_bytes: 4596
#include <stdio.h>

int main(){

    double a,b,c,d,e,f,y,x;
    double tmpb,tmpc,tmpe,tmpf;

    while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF){
        tmpb = b;
        tmpc = c;
        tmpe = e;
        tmpf = f;

        tmpb = b * d;
        tmpc = c * d;
        tmpe = e * a;
        tmpf = f * a;

        y = (tmpc - tmpf)/(tmpb - tmpe);
        x = (c - b*y) / a;

        printf("%.3lf %.3lf\n", x,y);

    }

}




Measured memory_bytes: 1972
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(s) scanf("%s",s)
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define ps(s) printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define FIO ios_base::sync_with_stdio(NULL);  cin.tie(0);   cout.tie(0);
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
void myInit();
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//============TQR=============//
vi g[N];
int a[N];

int minCost(int a[], int n) {
	int dp[n], i;
	dp[n - 1] = 0;
	dp[n - 2] = abs(a[n - 2] - a[n - 1]);
	// deb2(dp[n - 1], dp[n - 2]);
	for (i = n - 3; i >= 0; i--) {
		dp[i] = min(abs(a[i] - a[i + 1]) + dp[i + 1], abs(a[i] - a[i + 2]) + dp[i + 2]);
		// deb2(i, dp[i]);
	}
	return dp[0];
}

int main() {
	//myInit();
	FIO;
	int n, i = 0;
	cin >> n;
	int h[n];
	fo(i, n) {
		cin >> h[i];
	}
	cout << minCost(h, n) << endl;

	return 0;
}

//============TQR=============//
void myInit() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = ((ll)result * base) % mod;
		base = ((ll)base * base) % mod;
		exp >>= 1;
	}
	return result;
}

void ipgraph(int n, int m) {
	int i, u, v;
	while (m--) {
		cin >> u >> v;
		g[u - 1].pb(v - 1);
		g[v - 1].pb(u - 1);
	}
}

void dfs(int u, int par) {
	for (int v : g[u]) {
		if (v == par) continue;
		dfs(v, u);
	}
}


Measured memory_bytes: 8064