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

//def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

    char c;
    cin >> c;
    c = char(int(c) + 1);
    out(c);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long x[1000010],y[1000010];
#define int long long
signed main(){
  
  cin.tie(0);
  ios::sync_with_stdio(false);

  int a,b,c,d;
  cin>>a>>b>>c>>d;
  
  cout<<max((a*b),(c*d))<<'\n';
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

		static void solve() {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int sum = 0;
			int[] dishes = new int[n];
			int[] bpoints = new int[n];
			int[] cpoints = new int [n-1];
			for(int i = 0;i<n;i++) {
				dishes[i] = sc.nextInt();
			}
			for(int i = 0;i<n;i++) {
				bpoints[i] = sc.nextInt();
			}
			for(int i = 0;i<n-1;i++) {
				cpoints[i] = sc.nextInt();
			}
			for(int i = 0;i<n;i++) {
				sum+=bpoints[dishes[i]-1];

			}
			for(int i = 1;i<n;i++) {
				if(dishes[i]-dishes[i-1]==1) {
					sum+=cpoints[dishes[i-1]-1];
				}
			}
			System.out.println(sum);
			sc.close();
		}
	public static void main(String[] args) {
		solve();

	}

}

Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int a,b,c,k,m,ans=0;
	cin>>a>>b>>c>>k;
	m=max(a,b);
	m=max(m,c);
	ans+=(a+b+c-m);
	m*=pow(2,k);
	ans+=m;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>

using namespace std;

int main(){
    long long X;
    cin >> X;

    long long ans = 0;;
    long long p = 0;
    for(long long i = 1; ; i++){
        p += i;
        ans++;
        if(p >= X){
            break;
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n, q, k; cin >> n;
	vector<vector<pair<int, ll>>> e(n, vector<pair<int, ll>>());
	rep(i, 1, n - 1)
	{
		int a, b; ll c;
		cin >> a >> b >> c;
		--a, --b;
		e[a].push_back({ b,c });
		e[b].push_back({ a,c });
	}
	cin >> q >> k;
	--k;
	vector<ll> d(n, 1LL<<60);
	d[k] = 0;
	queue<int> que;
	que.push(k);
	while (!que.empty())
	{
		int now = que.front();
		que.pop();
		for (auto p : e[now])
		{
			int next = p.first;
			int cost = p.second;
			if (d[next] > d[now] + cost)
			{
				d[next] = d[now] + cost;
				que.push(next);
			}
		}
	}
	rep(i, 1, q)
	{
		int x, y; cin >> x >> y;
		--x, --y;
		cout << d[x] + d[y] << endl;
	}
}


Measured memory_bytes: 11264
import numpy as np


x1, y1, x2, y2 = map(int, input().split())
a = np.array([x1, y1])
b = np.array([x2, y2])
R = np.array([[0, -1], [1, 0]])
ab = b - a
ad = np.dot(R, ab)
d = ad + a
dc = np.dot(R, a - d)
c = dc + d

print('{} {} {} {}'.format(c[0], c[1], d[0], d[1]))


Measured memory_bytes: 21904
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
#define pb  push_back
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}
int main()
{FAST

string s;
cin>>s;
if(s[0]==s[1]&&s[1]==s[2])
{
	cout<<"No"<<endl;
}
else
cout<<"Yes"<<endl;

return  0;
}




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

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

    if(n%1000 == 0){
        n = 0;
    }else{
        n=(n/1000+1)*1000-n;
    }
  
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3592
//
// Created by kuribohkute on 29/12/2018.
//

#include <vector>
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

typedef long long cc;

bool was[10];

int main() {

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    was[a] = was[b] = was[c] = was[d] = true;
    if (was[1] && was[9] && was[7] && was[4]) {
        cout << "YES";
    } else {
        cout << "NO";
    }

    return 0;
}

Measured memory_bytes: 256
import copy
N = int(input())
A = [int(input()) for i in range(N)]
tmp = copy.copy(A)
tmp.sort()
MAX = tmp[-1]
MAXsub = tmp[-2]
place = A.index(MAX)
for i in range(N):
    if i != place:
        print(MAX)
    else:
        print(MAXsub)


Measured memory_bytes: 14560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        int H,W;
        String work[] = new String[2];
 
        while(true){
 
            try {
                work = br.readLine().split("[\\s]+");
 
                if(work[0].equals("0") && work[1].equals("0"))break;
 
                H = Integer.parseInt(work[0]);
                W = Integer.parseInt(work[1]);
 
                for(int col = 0; col < W; col++){
                    System.out.printf("#");
                }
                System.out.printf("\n");
 
                for(int row = 1; row <= H-2; row++){
                    System.out.printf("#");
                    for(int col = 1; col <= W-2; col++){
                        System.out.printf(".");
                    }
                    System.out.printf("#\n");
                }
 
                for(int col = 0; col < W; col++){
                    System.out.printf("#");
                }
                System.out.printf("\n\n");
 
 
            } catch (IOException e) {
 
                e.printStackTrace();
            }
        }
    }
}


Measured memory_bytes: 57544
import sys
from operator import itemgetter
N = int(input())
S = sys.stdin.read().split()
HT_high = []
HT_low = []
for s in S:
    t = 0
    h = 0
    for c in s:
        if c == "(":
            h += 1
        else:
            h -= 1
            if h < t:
                t = h
    if h >= 0:
        HT_high.append((h, t))
    else:
        HT_low.append((h, t))
HT_high.sort(key=itemgetter(1), reverse=True)
HT_low.sort(key=lambda x: x[0]-x[1], reverse=True)
h0 = 0
for h, t in HT_high + HT_low:
    if h0 + t < 0:
        print("No")
        exit()
    h0 += h
if h0 != 0:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 101952
N, W = map(int, input().split())
WV = [list(map(int, input().split())) for _ in range(N)]
WV = [[0, 0]] + WV

# dp[m][w] mまで使ってwを超えない価値の最大値
dp = [[0] * (W + 1) for _ in range(N + 1)]


for i in range(N + 1):
    w, v = WV[i]
    for j in range(W + 1):
        if 0 <= j - w:
            dp[i][j] = max(dp[i - 1][j - w] + v, dp[i - 1][j])
        else:
            dp[i][j] = dp[i - 1][j]

print(max(dp[-1]))


Measured memory_bytes: 120300
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cmath>

using namespace std;
const long long INF = (long long) (1e18)+1;

int main() {
  int n;
  cin >> n;
  long long ans = 0;
  for (int i=1; i<=n; ++i) {
    if (i % 3 == 0 || i % 5 == 0) {
      continue;
    } else {
      ans += i;
    }
  }
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define INF 1 << 30 - 1

int main() {
  int n, m, r; cin >> n >> m >> r;
  vvi g(n, vi(n, INF));
  rep(i, n) g[i][i] = 0;
  vi rs(r);
  rep(i, r) cin >> rs[i];
  rep(i, m) {
    int a, b, c; cin >> a >> b >> c;
    --a; --b;
    g[a][b] = g[b][a] = c;
  }
  rep(i, n) rep(j, n) rep(k, n) g[j][k] = min(g[j][k], g[j][i] + g[i][k]);
  sort(rs.begin(), rs.end());
  int ans = INF;
  do {
    int d = 0;
    for (int i = 0; i < r - 1; ++i) {
      d += g[rs[i] - 1][rs[i + 1] - 1];
    }
    ans = min(ans, d);
  } while (next_permutation(rs.begin(), rs.end()));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<set>
#include<string>
int main() {
	int i, j, k;
	std::string s;
	std::set<std::string> subs;
	std::cin >> s >> k;
	for (i = 0; i < s.length(); i++) {
		for (j = 1; j<=5 ; j++) {
			subs.insert(s.substr(i, j));
		}
	}
	for (i = 1; i < k; i++)subs.erase(*subs.begin());
	std::cout << *subs.begin();
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<deque>
using namespace std;
typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;


const int BIG_INT = 1000000000;
const ll BIG_NUM = 1000000000000000000;



int main() {
	int n;
	cin >> n;
	vector<set<string>> strSet(n, set<string>());
	strSet[0].insert("a");
	for (int i = 1; i < n; i++) {
		for (auto it = strSet[i - 1].begin(); it != strSet[i - 1].end(); it++) {
			string s = *it;
			char maxC = 'a';
			for (int j = 0; j < i; j++) {
				maxC = max(maxC, s[j]);
			}

			for (char c = 'a'; c <= maxC + 1; c++) {
				strSet[i].insert(s + c);
			}

		}
	}

	for (auto it = strSet[n - 1].begin(); it != strSet[n - 1].end(); it++) {
		cout << *it << endl;

	}


}




Measured memory_bytes: 17024
#include <bits/stdc++.h>
using namespace std;
  typedef vector<vector<char>> field_t;

typedef pair<int, int> point_t;

point_t operator+(const point_t &lhs, const point_t &rhs)
{
    point_t p = { lhs.first + rhs.first, lhs.second + rhs.second };
    return p;
}

bool operator==(const point_t &lhs, const point_t &rhs)
{
    return (lhs.first == rhs.first) && (lhs.second == rhs.second);
}

bool is_in_field(int col, int row, const point_t &point)
{
    const int c = point.second;
    const int r = point.first;
    return (0 <= c && c < col) && (0 <= r && r < row); 
}

int solve(int col, int row, field_t &field, const point_t &start, const point_t &goal)
{
    // 2. 各マスの訪問履歴(memo)を作成する
    //    memoにはスタートからそのマスまでの歩数を格納する(初期値は0)
    vector<vector<int>> memo;
    for(int i = 0; i < row; ++i) {
        vector<int> v(col, 0); 
        memo.push_back(v);
    }   

    // 移動方向(上下左右)
    const point_t points[] = { 
        { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 },
    };  

    // 3. スタートのマスをキューに格納する
    queue<point_t> q;
    q.push(start);

    // 11. 4から10をキューが空になるまで繰り返す
    while( !q.empty() ) {
        // 4. キューの先頭から一マス取得する
        point_t cur = q.front(); q.pop();

        // 5. 取り出したマスがゴールなら終了
        if(cur == goal) {
            return memo[cur.first][cur.second];
        }

        for(const auto &point : points) {
            // 6. 手順4で取り出したマス(cur)から上下左右の何れかに移動する
            point_t next = cur + point;
            // 7. 移動先のマス(next)が迷路外でないことを確認する(迷路外の場合は手順6に戻る)
            if( is_in_field(col, row, next) ) {
                const char s = field[next.first][next.second];
                // 8. 移動先のマス(next)が道またはゴールであることを確認する(道でもゴールでもない場合は手順6に戻る)
                if(s == '0' || s == 'g') {
                    // 9. 移動先のマス(next)が未訪問であることを確認する(訪問済みの場合は手順6に戻る)
                    if(memo[next.first][next.second] == 0) {
                        // 10. 移動先のマス(next)をキューに格納し、訪問履歴を更新する
                        q.push(next);
                        memo[next.first][next.second] = memo[cur.first][cur.second] + 1;
                    }
                }
            }
        }
    }
    return -1;
}

int main()
{
    int H, W;
    cin >> H >> W;

    point_t start, goal;
    field_t field;

    // 1. 迷路(field)を作成する
    for(int i = 0; i < H; ++i) {
        vector<char> v;
        for(int j = 0; j < W; ++j) {
            char c;
            cin >> c;
            if(c == '.')v.push_back('0');
            else v.push_back('1');
            // スタート地点とゴール地点は別途覚えておく
        }
        field.push_back(v);
    }
    // 最短歩数はsolveで計算する
    int ans = -1000000000;
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        if(field[i][j] == '1')continue;
        for(int k = 0; k < H; k++) {
          for(int l = 0; l < W; l++){
            if(field[k][l] == '1')continue;
            start.first = i;
            start.second = j;
            goal.first = k;
            goal.second = l;
            ans = max(ans, solve(W, H, field, start, goal));
          }
        }
      }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) {
    cin >> a[i];
    a[i]--;
  }

  int ans = 0;
  int temp = 9999;
  rep(i, N - 1) {
    if (a[i] == a[i + 1]) {
      ans++;
      a[i + 1] = temp--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
a = list()
for i in range(3):
    a.append(list(map(int, input().split())))
n = int(input())
b = list()
for i in range(n):
    b.append(int(input()))
check = False

for i in range(3):
    count = 0
    for j in range(3):
        if a[i][j] in b:
            count += 1
    if count == 3:
        check = True
        break
for i in range(3):
    count = 0
    for j in range(3):
        if a[j][i] in b:
            count += 1
    if count == 3:
        check = True
        break
if (a[0][0] in b) and (a[1][1] in b) and (a[2][2] in b):
    check = True
if (a[2][0] in b) and (a[1][1] in b) and (a[0][2] in b):
    check = True
if check == False:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

int main(){
    int N, K;
    cin >> N >> K;

    long ans = 0;
    for(int i=K; i<=N+1; i++){
        ans = ans + (ll)(N+1+N-i)*i/2 - (ll)(i-1)*i/2 + 1;
        ans = ans % MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc = new Scanner(System.in);
	public void run(){
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			calc(n);
		}
	}
	public void calc(int n){
		String before = sc.next();
		int min = -1000010000;
		int max = 1000010000;
		int breakflug = 0;

		for(int i = 1; i < n; i++){
			String s = sc.next();
			if(breakflug == 0){
				if(s.equals("x")){
					if(before.equals("x")){//x???2??£?¶?????????????????????§?????????
						min = 0;
						max = 0;
						breakflug = 1;
					}
					else if(i%2 == 0){//?\???°??????
						int b = Integer.parseInt(before);
						if (b < max){
							max = b;
						}
					}
					else{//??¶??°??????
						int b = Integer.parseInt(before);
						if(b > min){
							min = b;
						}
					}
				}
				else{//??°????????´???
					int a = Integer.parseInt(s);
					if(before.equals("x")){//???????£???????????????¨???
						if(i%2 == 0){//x?????¶??°??????
							if(a > min){
								min = a;
							}	
						}
						else{//x????\???°??????
							if(a < max){
								max = a;
							}
						}
					}
					else{//????????°????????¨???
						int b = Integer.parseInt(before);
						if(i%2 == 0){//???????\???°??????
							if(b <= a){
								min = 0;
								max = 0;
								breakflug = 1;
							}
						}
						else{//????????¶??°??????
							if(b >= a){
								min = 0; 
								max = 0;
								breakflug = 1;
							}
						}
					}
				}
			}
			before = s;
		}
		
		if(max-min < 2){
			System.out.println("none");
		}
		else if(max-min == 2){
			System.out.println(max-1);
		}
		else{
			System.out.println("ambiguous");
		}
	}
	
	public static void main(String[] args){
		new Main().run();
	}
	
}

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

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

    long long tmp = N;
    long long sum = 0;

    while(tmp > 0)
    {
        sum += (tmp % 10);
        tmp /= 10;
    }

    if(N % sum == 0)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan =new Scanner(System.in);
		String s = scan.next();
		int ans = Integer.parseInt(String.valueOf(s.charAt(0)));
		for (int i = 0; i <8; ++i){
			ans=Integer.parseInt(String.valueOf(s.charAt(0)));
			for (int j =0;j < 3; ++j){//ビット全探索
				if ((1&i>>j)==1){
					ans+=Integer.parseInt(String.valueOf(s.charAt(j+1)));
				}else{
					ans-=Integer.parseInt(String.valueOf(s.charAt(j+1)));
				}
			}
			if (ans==7){
				System.out.print(s.charAt(0));
				for (int j =0;j < 3; ++j){
					if ((1&i>>j)==1){
						System.out.print("+"+String.valueOf(s.charAt(j+1)));
					}else{
						System.out.print("-"+String.valueOf(s.charAt(j+1)));
					}
				}
				System.out.print("=7");
				break;
			}
		}


	}
}
//end


Measured memory_bytes: 22996
#include <stdio.h>
int main(void){
  int n,m;  
  scanf("%d %d",&n,&m);
  
  int a[n];
  int wa = 0;
  
  for(int i = 0;i < n;i++){
    scanf("%d",&a[i]);
    wa += a[i];
  }
  
  for(int i = 1;i < n;i++){
    for(int j = n-1;j >= i;j--){
      if(a[j] >a[j-1]){
        int temp = a[j];
        a[j] = a[j-1];
        a[j-1] = temp;
      }
    }
  }
  
  if(a[m-1] >= wa/4.0/m)
    printf("Yes");
  else
    printf("No");
  
  return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n ;
    cin >> n ;
    stack<long long>s;
    long long maxi = 0 , ans = 0;
    for(int i = 0 ; i < n ; i++){
        long long x ;
        cin >> x ;
        if(s.empty()){
            s.push(x);
            maxi = x ;
        }
        else if(x<maxi){
            ans+=(maxi-x);
        }
        else{
            maxi = x ;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define INF ((int64_t)2e18)
#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define Matrix vector<vector<int>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'
const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 3;

signed main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;

  cin >> n;

  vector<int> arr(n);

  map<int, int> m;
  for (int &x : arr) {
    cin >> x;
    m[x]++;
  }

  int ans = 0;
  for (const ii x : m) {
    ans += (x.ss * (x.ss - 1)) / 2;
  }

  for (int x : arr) {
    int cur = ans;
    cur -= m[x] * (m[x] - 1) / 2;
    cur += max(0ll, (m[x] - 1) * (m[x] - 2) / 2);
    cout << cur << endl;
  }
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[])
{
    int row, column;
    cin >> row >> column;
    vector<vector<int>> mat;
    vector<int> input;
    for (int i = 0; i < row; i++)
    {
        vector<int> col;
        for (int j = 0; j < column; j++)
        {
            int tmpint;
            cin >> tmpint;
            col.push_back(tmpint);
        }
        mat.push_back(col);
    }
    for (int i = 0; i < column; i++)
    {
        int tmpint;
        cin >> tmpint;
        input.push_back(tmpint);
    }
    for (int i = 0; i < row; i++)
    {
        int tmptotal = 0;
        for (int j = 0; j < column ; j++)
        {
            tmptotal += mat[i][j]*input[j];
        }
        cout << tmptotal << endl;
    }
    return 0;
}


Measured memory_bytes: 3208
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int a,b,h;

int main(){
	cin>>a>>b>>h;
	cout<<(a+b)*h/2<<endl;
}

Measured memory_bytes: 256
#
answer = Array.new

while linebuf = $stdin.gets
		line = linebuf.split( /\s/ )
		line.map!{ |n| n.to_f }
		a = line[ 0 ]; b = line[ 1 ]; c = line[ 2 ] 
		d = line[ 3 ]; e = line[ 4 ]; f = line[ 5 ] 

		di = a * e - b * d
		x1 = e * c - b * f 
		x2 = f * a - c * d
		u1 = x1 / di
		u2 = x2 / di
		answer << [u1,u2]
		
end
answer.each{ |n|
	s1 = sprintf( "%.03f", n[0] )
	s1 = "0.000" if s1 == "-0.000"
	s2 = sprintf( "%.03f", n[1] )
	s2 = "0.000" if s1 == "-0.000"
	printf( "%s %s\n", s1, s2 )
}


Measured memory_bytes: 6140
#include "bits/stdc++.h"

using namespace std;

int main(){
  long long int n,k;
  cin>>n>>k;
  long long int ans=0;
  for(long long int i=k+1;i<=n;++i){
    ans+=((n-k)/i+1)*(i-k);
    if(n%i>=k)ans-=i-(n%i)-1;
  }
  if(k==0)ans=n*n;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int K;
int A[100000];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> K;
  rep(i, K) cin >> A[i];
  reverse(A, A+K);
  long long lo = 2, hi = 2;
  rep(i, K) {
    //cout<<"["<<lo<<","<<hi<<"]\n";
    long long a = A[i];
    hi -= hi % a;
    if (lo % a) lo += a - (lo%a);
    assert(lo%a == 0 && hi%a == 0);
    if (lo > hi) {
      cout << -1 << "\n";
      return 0;
    }
    hi += a-1;
  }
  cout << lo << " " << hi << "\n";
  return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll calc(ll R, ll C, ll a, ll b) {
    if (a == 0)
        return b;
    if (a == R)
        return R + C + (C - b);
    if (b == C)
        return C + a;
    return 2 * C + R + (R - a);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll R, C, N;
    cin >> R >> C >> N;
    vector<pll> E;
    REP(i, N) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        if (a != 0 && a != R && b != 0 && b != C)
            continue;
        if (c != 0 && c != R && d != 0 && d != C)
            continue;
        ll x = calc(R, C, a, b);
        ll y = calc(R, C, c, d);
        E.push_back(pll(min(x, y), max(x, y)));
    }
    N = E.size();
    sort(E.begin(), E.end(), [](pll a, pll b) { return a.second < b.second; });
#if false
    REP(i, N) {
        pll a = E[i];
        cout << a.first << "," << a.second << endl;
    }
#endif

    std::set<pll> s;
    REP(i, N) {
        auto t = s.lower_bound(E[i]);
        if (t != s.begin()) {
            t--;
            if (t->first < E[i].first && E[i].first < t->second) {
                cout << "NO" << endl;
                return 0;
            }
            t++;
        }
        while (t != s.end()) {
            if (t->first > E[i].first && t->second < E[i].second) {
                t = s.erase(t);
                continue;
            }
            break;
        }
        s.insert(E[i]);
#if false
        auto it = s.begin();
        while (it != s.end()) {
            pll p = (*it);
            cout << "(" << p.first << "," << p.second << ") ";
            it++;
        }
        cout << endl;
#endif
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 5484
#include <bits/stdc++.h>
using namespace std;
int main () {
	int n,d;
	set <int> S;
	cin >> n;
	for(int i=1 ; i<=n ; i++){
		cin >> d;
		if (S.count(d) == 0) S.insert(d);
	}
	cout << S.size() << endl;
}

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

int main(int argc, const char * argv[]) {
    int N, K;
    cin >> N;
    cin >> K;
    
    vector<int> p;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
    }
    
    sort(p.begin(), p.end());
    
    int ans = 0;
    for (int i = 0; i < K; i++) {
        ans += p[i];
    }

    std::cout << ans;

    return 0;
}


Measured memory_bytes: 3172
sx,sy,tx,ty = list(map(int, input().split()))
dx = tx - sx
dy = ty - sy
res = []


for _ in range(dx):
	res.append("R")
for _ in range(dy):
	res.append("U")
for _ in range(dx):
	res.append("L")
for _ in range(dy):
	res.append("D")

res.append("L")
for _ in range(dy+1):
	res.append("U")
for _ in range(dx+1):
	res.append("R")
res.append("D")

res.append("R")
for _ in range(dy+1):
	res.append("D")
for _ in range(dx+1):
	res.append("L")
res.append("U")
print("".join(res))

Measured memory_bytes: 3188
S = input()
N = len(S)
left_R = [0] * N
right_L = [N-1] * N

for i,s in enumerate(S[1:],1):
    left_R[i] = i if s == 'R' else left_R[i-1]
    
for i,s in enumerate(S[N-2::-1],1):
    i = N - 1 - i
    right_L[i] = i if s == 'L' else right_L[i+1]
    
answer = [0] * N
for i,(s,R,L) in enumerate(zip(S,left_R, right_L)):
    if s == 'L':
        # R に流れ着いて、RとR+1で往復
        j = left_R[i]
        if (i+j) & 1:
            j += 1
    else:
        j = right_L[i]
        if (i+j) & 1:
            j -= 1
    answer[j] += 1
print(' '.join(map(str,answer)))

Measured memory_bytes: 15396
import numpy as np
w = input()

alp_list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

w_list = []
for s in w:
    w_list.append(s)

count_list = []
for i in alp_list:
    count = w_list.count(i)
    count_list.append(count)

div_array = np.array(count_list) % 2
div_list = div_array.tolist()

if div_list.count(0) == 26:
    print('Yes')
else:
    print('No')


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

typedef long long ll;

static const ll MOD = 1000000007LL;

int main(void){
    string S;
    cin >> S;
    ll dp[S.size()+10][13];
    for(int i=0; i<S.size()+10; i++){
        for(int j=0;j<13;j++){
            dp[i][j] = 0;
        }
    }
    dp[0][0]=1;
    for(int i=0;i<S.size();i++){
        /*ll buffdp[13];
        for(int k=0; k<13;k++){
            buffdp[k] = dp[i][k];
        }*/
        if('0'<=S[i]&&S[i]<='9'){
            int d = S[i]-'0';
            for(int j=0; j<13; j++){
                dp[i+1][(j*10+d)%13] += dp[i][j]/*+1*/;
//=buffdp[j] % mod;
            }
            //dp[i+1][d%13]++;
        }else if(S[i] == '?'){
            for(int d=0; d<10; d++){
                /*for(int k=0; k<13; k++){
                    buffdp[k] = dp[i][k];
                }*/
                for(int j=0; j<13; j++){
                    dp[i+1][(j*10+d)%13] += dp[i][j]/*+1*/;
                      //buffdp[j] % mod;
                }
                //dp[i+1][d%13]++;
            }
        }
        for(int m=0;m<13;m++){
            dp[i+1][m]=dp[i+1][m]%MOD;
        }
        //dbg
        //cout << dp[i+1][0] <<endl;
    }
    cout << dp[S.size()][5] << endl;
    return 0;
}


Measured memory_bytes: 10624
import sys
import numpy as np
# from decimal import Decimal
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# ----------------------------------------
n = int(readline())
#s = readline()
# print(s)
s = input()

ans = 0
x = 0
for i in range(n):
    tar = s[i]
    if (tar == 'I'):
        x += 1
    else:
        x -= 1

    ans = max(x, ans)
    # print(ans)


print(ans)


Measured memory_bytes: 26992
#include<stdio.h>
 
int main(void){
  char s[5];
  scanf("%s",s);
  for(int i=0;i<3;i++){
    if(s[i]==s[i+1]){
      printf("Bad\n");
      return 0;
    }
  }
  printf("Good\n");
  return 0;
}

Measured memory_bytes: 1596
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int m, n;
    cin >> m >> n;
    vector<int> v(n);
    for (auto &&j : v) scanf("%d", &j);
    if(m == 2){
        int ans1 = 0, ans2 = 0;
        for (int i = 0; i < n; ++i) {
            if(i&1) {
                if(v[i] == 1) ans1++;
                else ans2++;
            } else {
                if(v[i] == 1) ans2++;
                else ans1++;
            }
        }
        cout << min(ans1, ans2) << "\n";
        return 0;
    }
    vector<pair<int, int>> u;
    u.emplace_back(v[0], 1);
    for (int i = 1; i < n; ++i) {
        if(u.back().first == v[i]) u.back().second++;
        else u.emplace_back(v[i], 1);
    }
    int ans = 0;
    for (int i = 0; i < u.size(); ++i) {
        ans += u[i].second/2;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4340
module S = Set.Make (struct type t = int let compare = compare end)

let () =
    let find_root ver =
        let rec loop prev cur =
            let rec loop_2 = function
                | [] -> cur
                | (hd, _) :: tl -> if hd = prev then loop_2 tl else loop cur hd
            in
            loop_2 ver.(cur)
        in
        loop 1 (fst (List.hd ver.(1)))
    in
    let main () =
        let n = int_of_string (read_line ()) in
        let ab = Array.init (n - 1) (fun i -> Scanf.sscanf (read_line ()) "%d %d" (fun a b -> a, b, i)) in
        let ver = Array.make (n + 1) [] in
        let used = Array.make (n + 1) S.empty in
        let col = Array.make (n + 1) 0 in
        Array.iter (fun (a, b, i) ->
            ver.(a) <- (b, i) :: ver.(a);
            ver.(b) <- (a, i) :: ver.(b)) ab;
        let k = Array.fold_left (fun acc l -> max acc (List.length l)) 0 ver in
        let find_color prevc set =
            let rec loop i set = if S.mem i set then loop (i + 1) set else i in
            loop prevc set
        in
        let rec loop cur =
            let rec loop2 prevc = function
                | [] -> ()
                | (hd, edge) :: tl -> (
                    let c = if col.(edge) = 0 then (
                        let c = find_color prevc used.(cur) in
                        col.(edge) <- c;
                        used.(cur) <- S.add c used.(cur);
                        used.(hd) <- S.add c used.(hd);
                        loop hd;
                        c + 1
                    ) else prevc in
                    loop2 c tl
                )
            in
            loop2 1 ver.(cur)
        in
        let root = find_root ver in
        loop root;
        Printf.printf "%d\n" k;
        for i = 0 to n - 2 do
            Printf.printf "%d\n" col.(i)
        done
    in
    main ()

Measured memory_bytes: 27136
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int mod=1e9+7;
int dp[1000006][2][2];
signed main()
{
	int n;
	cin>>n;
	dp[0][0][0]=1;
	for (int i=0;i<n;i++)
		for (int j=0;j<2;j++)
			for (int k=0;k<2;k++)
				if (dp[i][j][k]){
					int aa=dp[i][j][k];
					if (j+k==0)
						dp[i+1][0][1]+=aa,dp[i+1][1][0]+=aa,dp[i+1][0][0]+=aa*8%mod;
					if (j+k==1)
						dp[i+1][1][1]+=aa,dp[i+1][j][k]+=aa*9%mod;
					if (j&&k)
						dp[i+1][1][1]+=aa*10%mod;
				}
	cout<<dp[n][1][1]%mod;
	re 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;

#define FOR(i, b, e) for(int i=b; i<=e; i++)
#define FORD(i, b, e) for(int i=b; i>=e; i--)
#define SIZE(x) ((int)x.size())
#define pb push_back
#define st first
#define nd second
#define sp ' '
#define ent '\n'
//END OF TEMPLATE

int a, b, both, ans;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	string s;
	cin>>n;
	FOR(j, 1, n){
		cin>>s;
		if(s[0]=='B' && s[SIZE(s)-1]=='A') both++;
		else if(s[0]=='B') b++;
		else if(s[SIZE(s)-1]=='A') a++;
		FOR(i, 0, SIZE(s)-2){
			if(s[i]=='A'&&s[i+1]=='B') ans++;
		}
	}
	if(a==0 && b==0) ans+=max(both-1, 0);
	else ans+=both+min(a, b);
	cout<<ans<<ent;
	return 0;
}


Measured memory_bytes: 256
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string s,t;
    cin>>s>>t;
    ll ans=t.length();
    for (int i = 0; i < s.length()-t.length()+1; ++i)
    {
        ll co=0;
        for(int j=0;j<t.length();j++)
        {
            if(s[i+j]!=t[j])
            {
                co++;
            }
        }
        ans=min(ans,co);
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 3660
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <utility>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iterator>
#include <sstream>

using namespace std;

bool t[101][101];
int n,k;
 
int solve()
{
    for (int i = 0; i < n; i++){
        int m; cin>>m;
        //t[i][i] = true;
        for (int j = 0; j < m; j++){
            int x; cin>>x;
            t[i][x-1] = true;
        }
    }
 
    cin>>k;
    vector<int> l(k);
    for (int i = 0; i < k; i++){
        cin>>l[i];  l[i]--;
    }
 
    int ans = -1;
 
    for (int i = 0; i < n; i++){
        int j = 0;
        for (; j < k; j++){
            if(!t[i][l[j]]) break;
        }
        if(j == k){
            if(ans == -1) {
                ans = i + 1;
            } else {return -1;}
        }
    }
 
    return ans;
}
 
int main(){
    while(cin >> n,n){
        memset(t,0,sizeof(t));
        int ans = solve();
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 916
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG abc/abc067/d.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

vector<vector<int>> g;
vector<int> depth_f;
vector<int> depth_s;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    int n;
    cin >> n;
    g.resize(n);
    depth_f.resize(n);
    depth_s.resize(n);
    rep(i, n){
        depth_f[i] = -1;
        depth_s[i] = -1;
    }
    rep(i, n - 1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    depth_f[0] = 0;
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int nd = q.front();
        q.pop();
        rep(i, g[nd].size()){
            if(depth_f[g[nd][i]] < 0){
                depth_f[g[nd][i]] = depth_f[nd] + 1;
                q.push(g[nd][i]);
            }
        }
    }

    depth_s[n - 1] = 0;
    q.push(n - 1);
    while(!q.empty()){
        int nd = q.front();
        q.pop();
        rep(i, g[nd].size()){
            if(depth_s[g[nd][i]] < 0){
                depth_s[g[nd][i]] = depth_s[nd] + 1;
                q.push(g[nd][i]);
            }
        }
    }

    int f = 0;
    int s = 0;
    rep(i, n){
        if(depth_f[i] <= depth_s[i]) f++;
        else s++;
    }
    if(f > s) cout << "Fennec" << "\n";
    else cout << "Snuke" << "\n";
    return 0;
}

Measured memory_bytes: 6528
using System;

class Hello{
static void Main(){
string [] str=Console.ReadLine().Split(' ');

int a=int.Parse(str[0]);
int b=int.Parse(str[1]);

if(a>b)Console.WriteLine("a > b");
else if(a<b)Console.WriteLine("a < b");
else Console.WriteLine("a == b");
}
}


Measured memory_bytes: 15968
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iostream>

class Point{
public:
	Point(int n = -1, int m = 0, int l = 0):id(n), x(m), y(l){};
	int get_x() const {return x;}
	int get_y() const {return y;}
	int get(bool flag) const {if (flag){return get_x();}else{return get_y();};}
	int get_id() const {return id;}
private:
	int id;
	int x, y;
};
void sort(std::vector<Point> &array, bool flag, int left, int right){
	if (right > left){
		int mid = left + (right - left) / 2;
		int pivot = array.at(mid).get(flag);
		int l = left; int r = right;
		while (r >= l){
			while (array.at(l).get(flag) < pivot)++l;
			while (array.at(r).get(flag) > pivot)--r;
			if (r >= l){
				Point temp = array.at(l);
				array.at(l) = array.at(r);
				array.at(r) = temp;
				++l; --r;
			}
		}
		sort(array, flag, left, r); sort(array, flag, l, right);
	}
}
void sort(std::vector<int> &array, int left, int right){
	if (right > left){
		int mid = left + (right - left) / 2;
		int pivot = array.at(mid);
		int l = left; int r = right;
		while (r >= l){
			while (array.at(l) < pivot)++l;
			while (array.at(r) > pivot)--r;
			if (r >= l){
				int temp = array.at(l);
				array.at(l) = array.at(r);
				array.at(r) = temp;
				++l; --r;
			}
		}
		sort(array, left, r); sort(array, l, right);
	}
}
template <class T>
void make_kDtree(std::vector<T> &array, bool flag, int left, int right){
	if (right > left){
		sort(array, flag, left, right);
		int mid = left + (right - left) / 2;
		make_kDtree(array, !flag, left, mid - 1);make_kDtree(array, !flag, mid + 1, right);
	}
}
void search_point(std::vector<Point> &array, bool flag, int left, int right, const Point &max, const Point &min, std::vector<int> &result){
	if (right >= left){
		int mid = left + (right - left) / 2;
		if (max.get(flag) >= array.at(mid).get(flag) and array.at(mid).get(flag) >= min.get(flag)){
			if (max.get(!flag) >= array.at(mid).get(!flag) and array.at(mid).get(!flag) >= min.get(!flag)){
				result.push_back(array.at(mid).get_id());
			}
			search_point(array, !flag, left, mid - 1, max, min, result); search_point(array, !flag, mid + 1, right, max, min, result);
		}else if (array.at(mid).get(flag) > max.get(flag)){
			search_point(array, !flag, left, mid - 1, max, min, result);
		}else{
			search_point(array, !flag, mid + 1, right, max, min, result);
		}
	}
}
int main(){
	std::vector<Point> array;
	int n;
	std::scanf("%d", &n);
	for (auto i = 0; i < n; ++i){
		int x, y;
		std::scanf("%d %d", &x, &y);
		array.push_back(Point(i, x, y));
	}
	make_kDtree(array, true, 0, array.size() - 1);
	int q;
	std::scanf("%d", &q);
	for (auto i = 0; i < q; ++i){
		int xmin, xmax, ymin, ymax;
		std::scanf("%d %d %d %d", &xmin, &xmax, &ymin, &ymax);
		std::vector<int> result;
		Point max(-1, xmax, ymax);
		Point min(-1, xmin, ymin);
		search_point(array, true, 0, array.size() - 1, max, min, result);
		sort(result, 0, result.size() - 1);
		for (auto j : result){
			std::printf("%d\n", j);
		}
		std::printf("\n");
	}
}

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int main()
{
    Hello
    string s, start = "", en = "";
    bool rev = false, st = true;
    int q;
    cin >> s >> q;
    while(q--)
    {
        int test;
        cin >> test;
        if(test == 1)
        {
            rev = !rev;
            st = !st;
        }
        else if(test == 2)
        {
            int casee;
            string ch;
            cin >> casee >> ch;
            if(casee == 1)
            {
                if(st)
                {
                    start = ch + start;
                }
                else
                {
                    en += ch;
                }
            }
            else if(casee == 2)
            {
                if(st)
                {
                    en += ch;
                }
                else
                {
                    start = ch + start;
                }
            }
        }
    }
    if(rev)
    {
        for(int i = en.size() - 1; i >= 0; i--)
            cout << en[i];
        for(int i = s.size() - 1; i >= 0; i--)
            cout << s[i];
        for(int i = start.size() - 1; i >= 0; i--)
            cout << start[i];
    }
    else
        cout << start << s << en;
    return 0;
}


Measured memory_bytes: 1104
#include <iostream>

using namespace std;

struct node
{
    int key;
    int index;
};

int main()
{
    int n;
    cin>>n;
    int a[n],b[n];
    int i;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
        b[a[i]-1]=i;
    }
    for(i=0;i<n;i++)
    {
        cout<<b[i]+1<<" ";
    }
    return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <math.h>
int main(){
	int x,y,i,d;
	scanf("%d %d",&x,&y);
	d=y;
	while(d%x!=0){
		y = d;
		d = x;
		x = y%x;
	}
	printf("%d\n",x);
	return 0;
}

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

int main()
{
	int N, K;
	string S;
	cin >> N >> S >> K; --K;
	for (int i = 0; i < N; i++) {
		cout << (S[i] == S[K] ? S[i] : '*');
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int n,a[maxn],b[maxn];

int main()
{
	n=read(); rep(i,1,n) a[i]=read(),b[i]=read(); int F=0;
	rep(i,3,n)
	{
		if(a[i]==b[i]&&b[i-1]==a[i-1]&&a[i-2]==b[i-2])
		{
			F=1;
			break;
		}
	}
	if(F) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3640
R, G, B, N = map(int, input().split())
ans = 0
rest_gb = N
for r in range(N // R + 1):
    rest_gb = N - R * r
    for g in range(rest_gb // G + 1):
        rest_b = rest_gb - G * g
        if rest_b % B == 0:
            # print(r, g, rest_b // B)
            ans += 1
print(ans)

Measured memory_bytes: 40556
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int m = in.nextInt();
			int[][] sp = new int[n][2];
			int[][] cp = new int[m][2];

			for (int i = 0; i < n; i++) {
				sp[i] = in.nextIntArray(2);
			}
			for (int i = 0; i < m; i++) {
				cp[i] = in.nextIntArray(2);
			}

			int[] ans = new int[n];
			for (int i = 0; i < n; i++) {
				int min = Integer.MAX_VALUE;
				for (int j = 0; j < m; j++) {
					int dis = MathUtils.calcDistance(sp[i][0], sp[i][1], cp[j][0], cp[j][1]);
					if (min > dis) {
						min = dis;
						ans[i] = j;
					}

				}
			}

			for (int i : ans) {
				out.println(i+1);
			}

		}

	}

	static class MathUtils {
		public static int calcDistance(int x1, int y1, int x2, int y2) {
			return Math.abs(x1-x2) + Math.abs(y1-y2);
		}
	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}

	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

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

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

		public long nextLong() {
			return Long.parseLong(nextString());
		}

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

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

	}

}


Measured memory_bytes: 21332