akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
  #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
   double a,b;
   cin>>a>>b;
   cout<<fixed;
   cout<<setprecision(10)<<(double)a/b<<endl;	
}
int32_t main(){
   IOS;
   solve();
   //debug();
  #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif	
}


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

string divide[4]={"dream","dreamer","erase","eraser"};

int main(){
    string S;
    cin>>S;
    reverse(S.begin(),S.end());
    for(int i=0;i<4;i++) reverse(divide[i].begin(),divide[i].end());

    bool can=1;

    for(int i=0;i<S.size();){
        bool can2=0;
        for(int j=0;j<4;j++){
            string d = divide[j];
            if(S.substr(i,d.size())==d){
                can2=true;
                i+=d.size();
            }
        }
        if(!can2){
            can=0;
            break;
        }
    }
    if(can)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using LL = long long;
int H, W;
LL ans = 1 << 50;
LL INF = 1 << 50;

void solve(LL a,LL b) {
	for (int i = 1; i < a; i++) {
		LL tmp1, tmp2, tmp3;
		tmp1 = i*b;
		tmp2 = (a - i)*(b / 2);
		tmp3 = (a - i)*b - tmp2;
		LL minx, maxx;
		minx = std::min({ tmp1,tmp2,tmp3 });
		maxx = std::max({ tmp1,tmp2,tmp3 });
		LL tmpex = maxx - minx;
		ans = std::min(ans, tmpex);	
	}
}

int main() {
	std::cin >> H >> W;
	if (H % 3 == 0 || W % 3 == 0) {
		std::cout << 0 << std::endl;
		return 0;
	}
	else {
		ans = std::min(H, W);
	}
	solve(H, W);
	solve(W, H);
	std::cout << ans << std::endl;
	return 0;
}

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

int main(){
    long long N;
    cin>>N;
    int digit=0;
    long long new_N=N;
    while(new_N!=0){
        new_N/=10;
        digit++;
    }
    //cout<<digit<<endl;
    long long ans=9,basic=1;
    for(int i=1;i<digit;++i){
        basic*=10;
        ans*=10;
        ans+=9;
    }
    while(ans>N){
        ans-=basic;
    }
    int digit_sum=0;
    while(ans!=0){
        digit_sum+=ans-(ans/10)*10;
        ans/=10;
    }
    cout<<digit_sum<<"\n";
}

Measured memory_bytes: 256
N, K = map(int,input().split())
A = list(map(int,input().split()))
A.insert(0,0)
list = []
replist = []
judge = [True] * (2 * 10 ** 5 + 1)
pos = 1
owari = True
while owari:
    judge[pos] = False
    list.append(pos)
    pos = A[pos]
    if not judge[pos]:
        while True:
            replist.append(pos)
            judge[pos] = True
            pos = A[pos]
            if judge[pos]:
                owari = False
                break
if K <= len(list)-1:
    print(list[K])
else:
    K = K - len(list) + 1
    print(replist[( K % len(replist) ) -1])



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

int main()
{
	
	int n, q;
	vector<int> S, T;
	
	cin >> n;

	while (n--)
	{
		int a;
		cin >> a;
		S.push_back(a);
	}

	cin >> q;

	while (q--)
	{
		int a;
		cin >> a;
		T.push_back(a);
	}

	sort(S.begin(), S.end());

	int c = 0;

	for (int i = 0; i < T.size(); i++) {

		int left, middle, right;
		left = 0;
		right = S.size() - 1;

		while (left <= right)
		{
			middle = (left + right) / 2;

			if (T[i] == S[middle]) {
				c++;
				break;
			}
			else if (T[i] > S[middle]) {
				left = middle + 1;
			}
			else if (T[i] < S[middle]) {
				right = middle - 1;
			}
		}
	}

	cout << c << endl;

	return 0;
}


Measured memory_bytes: 3240
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define inf 1000000007;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, m, x[100000], mu;

signed main() {
	cin >> n >> m;
	rep(i, m) cin >> x[i];
	if (n >= m) {
		cout << 0 << endl;
		return 0;
	}
	sort(x, x + m);
	if (n == 1) {
		cout << x[m - 1] - x[0] << endl;
		return 0;
	}
	vector<int> ta;
	for (int i = 1; i < m; i++) {
		ta.push_back(x[i] - x[i - 1]);
	}
	sort(ta.begin(), ta.end());
	reverse(ta.begin(), ta.end());
	for (int i = 0; i < n - 1; i++) {
		mu += ta[i];
	}
	cout << x[m - 1] - x[0] - mu << endl;
	getchar(); getchar();
	return 0;
}

Measured memory_bytes: 2168
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>
#include <set>
#include <numeric>

using namespace std;

template <typename T>
using TABLE = vector<vector<T>>;

long long PRIME = 1e9 + 7;
long long PRIME2 = 998244353;


int main(){
    long long N;
    string S;

    cin >> S;

    if(S == "ABC"){
        cout << "ARC";
    }
    else{
        cout << "ABC";
    }
}


Measured memory_bytes: 3592
from heapq import heappop, heappush


def solve(field, s, t, k):
    INF = 10 ** 18
    ans = [[INF, INF] for _ in field]
    ans[s][0] = ans[s][1] = 0
    MOVE = [(-w2, 0), (-1, 1), (1, 1), (w2, 0)]

    q = [(0, s, 0)]
    while q:
        cost, v, direction = heappop(q)
        if v == t:
            return (cost - 1) // k + 1

        ceiling = -1
        for di, ax in MOVE:
            u = v + di
            if field[u] == '@':
                continue
            nc = cost + 1 if di == direction else ceiling
            if nc == -1:
                nc = ceiling = ((cost - 1) // k + 1) * k + 1
            if ans[u][ax] <= nc:
                continue
            ans[u][ax] = nc
            heappush(q, (nc, u, di))

    return -1


h, w, k = map(int, input().split())
x1, y1, x2, y2 = map(int, input().split())
h2 = h + 2
w2 = w + 2

field_tmp = [input() for _ in range(h)]
field = ['@' * w2]
for row in field_tmp:
    field.append('@')
    field.append(row)
    field.append('@')
field.append('@' * w2)
field = ''.join(field)
s = x1 * w2 + y1
t = x2 * w2 + y2
print(solve(field, s, t, k))


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

int main() {
    string s;
    cin >> s;

    if (s == "ABC")
        cout << "ARC" << endl;
    else
        cout << "ABC" << endl;
    return 0;
}


Measured memory_bytes: 3628
from collections import deque

H, W, N = map(int, input().split())
field = [list(input()) for i in range(H)]
node_posi = [0 for i in range(N+1)]

nodes = 'S123456789'
for i in range(H):
	for j in range(W):
		if field[i][j] in nodes:
			node_posi[nodes.index(field[i][j])] = [j, i]

cost = 0
for i in range(len(node_posi)-1):
	searched = [[-1]*W for i in range(H)]
	start, goal = node_posi[i], node_posi[i+1]
	Q = deque([start])
	searched[start[1]][start[0]] = 0
	goal_flag = False
	
	while Q and not goal_flag:
		x, y = Q.popleft()
		goal_flag = False

		for q in range(4):
			nx = x + [1,0,-1,0][q]
			ny = y + [0,1,0,-1][q]
			
			if nx >= 0 and nx < W and ny >= 0 and ny < H:
				if searched[ny][nx] == -1 and field[ny][nx] != 'X':
					Q.append([nx, ny])
					searched[ny][nx] = searched[y][x] + 1
					if ([nx, ny] == goal):
						cost += searched[ny][nx]
						goal_flag = True
						break

print(cost)


Measured memory_bytes: 42352
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#include <climits>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  char c;
  cin >> c;
  c++;
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for(auto v:(V))cout<<v<<" "<<endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;

ll mp(const vll& bb, ll g)
{
    ll sum = accumulate(ALL(bb), 0LL);
    return abs(sum - g) + (bb.size()-1)*10;
}

ll solve(const vll& bb, ll a, ll b, ll c)
{
    ll ans = 1LL << 60;
    rep(i, pow(4, bb.size()))
    {
        vvll reg(4);
        rep(j, bb.size())
        {
            reg.at((i/int(pow(4, j))) % 4).emplace_back(bb.at(j));
        }
        if (reg.at(0).size() > 0 && reg.at(1).size() > 0 && reg.at(2).size() > 0)
        {
            ll need = mp(reg.at(0), a) + mp(reg.at(1), b) + mp(reg.at(2), c);
            ans = min(ans, need);
        }
    }
    return ans;
}

int main()
{
    ll N, A, B, C;
    cin >> N >> A >> B >> C;
    vll l(N);
    rep(i, N)
    {
        cin >> l[i];
    }
    cout << solve(l, A, B, C) << endl;
}

Measured memory_bytes: 256
import  java.util.*;

public class Main{
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int sec = sc.nextInt();
    int per_num = sc.nextInt();
    double max_sec = (double)sc.nextInt() + 0.5;

    int ans_num = 0;

    for (int i = sec; i < max_sec; i += sec) {
      ans_num += per_num;
    }

    System.out.println(ans_num);
  }
}


Measured memory_bytes: 22868
MOD = 10 ** 9 + 7
N = gets.to_i
A = gets.split.map(&:to_i)

counter = Array.new(3, 0)
patterns = []

A.each do |a|
  patterns << counter.count { |c| c == a }

  3.times do |i|
    if counter[i] == a
      counter[i] += 1
      break
    end
  end
end

puts patterns.inject(:*) % MOD


Measured memory_bytes: 84028
object Main {
  def main(args: Array[String]) {
    val input = io.Source.stdin.getLines().mkString("\n");
    println(solve(input))

    def solve(input: String): String = {
      val a :: s :: _ = input.split("\n").toList
      if (a.toInt >= 3200) {
        s
      } else {
        "red"
      }
    }
  }
}

Measured memory_bytes: 25544
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
typedef vector<int> Node;
typedef vector<Node> Graph;
int V1, V2;
Graph G;
int dist[1002];
int match[1002];
const int NIL = 1001;
bool BFS(){
  queue<int> que;
  REP(v, V1){
    if(match[v] == NIL){
      dist[v] = 0;
      que.push(v);
    }else{
      dist[v] = INF;
    }
  }
  dist[NIL] = INF;
  while(!que.empty()){
    int v = que.front(); que.pop();
    if(dist[v] < dist[NIL]){
      for(int i = 0; i < G[v].size(); i++){
        int u = G[v][i];
        if(dist[match[u]] == INF){
          dist[match[u]] = dist[v] + 1;
          que.push(match[u]);
        }
      }
    }
  }
  return dist[NIL] != INF;
}

bool DFS(int v){
  if(v != NIL){
    for(int i = 0; i < G[v].size(); i++){
      int u = G[v][i];
      if(dist[match[u]] == dist[v] + 1 && DFS(match[u])){
        match[u] = v;
        match[v] = u;
        return true;
      }
    }
    dist[v] = INF;
    return false;
  }
  return true;
}

int Hopcroft_Karp(){
  REP(v, G.size()) match[v] = NIL;
  int matching = 0;
  while(BFS()){
    REP(v, V1){
      if(match[v] == NIL && DFS(v)){
        matching ++;
      }
    }
  }
  return matching;
}
int main(){
  while(scanf("%d %d", &V1, &V2) && (V1 != 0 || V2 != 0)){
    G = Graph(V1 + V2);
    static int blue[500];
    static int red[500];
    if(V1 < V2){
      REP(i, V1) scanf("%d", blue + i);
      REP(i, V2) scanf("%d", red + i);
      REP(u, V1) REP(v, V2){
        if(__gcd(blue[u], red[v]) != 1) {
          G[u].push_back(V1 + v);
          //G[V1 + v].push_back(u);
        }
      }
    }else{
      swap(V1, V2);
      REP(i, V2) scanf("%d", blue + i);
      REP(i, V1) scanf("%d", red + i);
      REP(v, V2) REP(u, V1){
        if(__gcd(blue[v], red[u]) != 1) {
          G[u].push_back(V1 + v);
          //G[V1 + v].push_back(u);
        }
      }
    }
    printf("%d\n", Hopcroft_Karp());
  }
  return 0;
}

Measured memory_bytes: 2192
#def area###############################
def pr(s,a,b):
	print s[int(a):int(b)+1]

def rv(s,a,b):
#	a="abcdefghijklmn"len=14
#	ra="nmlkjihgfedcba"
#		edc=9,10,11
#	ans="abedcfghijklmn"
#	reverse 2 4
#	14-b-1,14-a-1
#	"
	tmp=s[::-1]
	news=s[:int(a)]+tmp[len(tmp)-int(b)-1:len(tmp)-int(a)]+s[int(b)+1:]
	return news
def rp(s,a,b,p):
	news=s[:int(a)]+p+s[int(b)+1:]
	return news
########################################


I=raw_input()
n=int(input())
for i in range(n):
	k=raw_input().split(" ")
	if k[0]=="replace":
		I=rp(I,k[1],k[2],k[3])
	elif k[0]=="reverse":
		I=rv(I,k[1],k[2])
	elif k[0]=="print":
		pr(I,k[1],k[2])

Measured memory_bytes: 6472
#include<stdio.h>
#include<stdlib.h>

struct node{
	int key;
	struct node *next;
	struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

void init()
{
	nil = NULL;
}

void insert(int key)
{
	struct node *newcell;

	newcell = (struct node*)malloc(sizeof(struct node));
	if (newcell == NULL) {
		puts( "malloc failed." );
		return;
	}

	if (nil == NULL) {
		nil = newcell;
		nil->next = nil;
		nil->prev = nil;
		nil->key = key;
		return;
	} else if (nil->next == nil) {
		nil->prev = newcell;
	} else if (nil->next->next == nil) {
		nil->prev->prev = newcell;
	}
	newcell->key = nil->key; 
	newcell->prev = nil;
	newcell->next = nil->next;
	nil->next->prev = newcell;
	nil->next = newcell;
	nil->key = key;
	return;
}

void deleteLast()
{
	struct node *last;
	if (nil->next == nil) {
		free(nil);
		nil = NULL;
		return;
	} else {
		last = nil->prev;
		nil->prev->prev->next = nil;
		nil->prev = last->prev;
		free(last);
	}
}

void deleteFirst()
{
	struct node *first;
	if (nil->prev == nil) {
		free(nil);
		nil = NULL;
		return;
	} else {
		first = nil;
		nil = nil->next;
		nil->prev = first->prev;
		first->prev->next = nil;
		free(first);
	}
}

void delete(int key)
{
	struct node *p;
	if (nil->key == key) {
		deleteFirst();
		return;
	}
	for (p = nil->next; p != nil; p = p->next) {
		if (p->key == key) {
			p->prev->next = p->next;
			p->next->prev = p->prev;
			free(p);
			return;
		}
	}
}

void printList()
{
	struct node *p;
	printf("%d", nil->key);
	for (p = nil->next; p != nil; p = p->next) {
		printf(" %d", p->key);
	}
	printf("\n");
	return;
}

int main(){
	int i, n, key;
	char com[12];
	struct node *p;

	scanf("%d", &n);
	init();

	for ( i = 0; i < n; i++ ){
		scanf("%s", com);

		if ( com[0] == 'i' ) {
			scanf("%d", &key);
			insert(key);
		} else if ( com[0] == 'd' ) {
			if (strlen(com) > 6){
				if ( com[6] == 'F' ) {
					deleteFirst();
				} else if ( com[6] == 'L' ) {
					deleteLast();
				}
			} else {
				scanf("%d", &key);
				delete(key);
			}
		}
	}
	printList();
	return 0;
}

Measured memory_bytes: 32948
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18

#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

struct edge{ int cost, from, to; };

bool cmp(const edge& lhs, const edge& rhs){
	return lhs.cost < rhs.cost;
}

bool cmp2(const edge& lhs, const edge& rhs){
	int l = lhs.from+lhs.to, r = rhs.from+rhs.to;
	return l < r;
}

int N, M, K;
int c[114514];

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

	cin >> N >> M >> K;
	REP(i, N)
		cin >> c[i];
	vector<edge> e;
	Union_find uf(K+N+1);
	int cnt = 0;
	REP(i, M){
		int u, v, w;
		cin >> u >> v >> w;
		if(c[u-1] > c[v-1]) swap(u, v);
		e.push_back({w, u-1, v-1});
	}
	sort(all(e), cmp);
	uf.unite(0, 1);
	ll res = 0;
	REP(i, e.size()){
		if(c[e[i].from] != 0 && c[e[i].to] != 0 && uf.same(c[e[i].from], c[e[i].to])) continue;
		if(c[e[i].from] == 0 && c[e[i].to] != 0 && uf.same(e[i].from+K+1, c[e[i].to])) continue;
		if(c[e[i].from] == 0 && c[e[i].to] == 0 && uf.same(e[i].from+K+1, e[i].to+K+1)) continue;
		cnt++;
		if(c[e[i].from] != 0)
			uf.unite(c[e[i].from], c[e[i].to]);
		else if(c[e[i].from] == 0 && c[e[i].to] != 0)
			uf.unite(e[i].from+K+1, c[e[i].to]);
		else
			uf.unite(e[i].from+K+1, e[i].to+K+1);
		res += e[i].cost;
		if(cnt >= K-1)
			break;
	}
	if(cnt < K-1){
		cout << -1 << endl;
	}else{
		cout << res << endl;
	}
}


Measured memory_bytes: 4588
import java.io.*;

import java.math.BigInteger;
import java.util.*;

import java.util.ArrayList;

import java.util.Scanner;


public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

    static final int mod = 1000000007;

    public static int gcd(int a, int b)
    {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }


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

       int a[]=new int[n];
       for(int j=0;j<n;j++)
           a[j]=sc.nextInt();

       HashMap<Integer,Integer>hm=new HashMap<>();
        HashMap<Integer,Integer>hm1=new HashMap<>();
        int b[]=new int[n];
        int c[]=new int[n];
        for(int j=0;j<n;j++)
        {
            b[j]=(j+1)+a[j];
            c[j]=(j+1)-a[j];
        }
        for(int j=0;j<n;j++)
        {
            hm.put(b[j],hm.getOrDefault(b[j],0)+1);
        }
        long res=0;

        for(int j=0;j<n;j++)
        {
            if(hm.get(c[j])!=null)
                res+=hm.get(c[j]);
        }

        System.out.println(res);


    }
}









Measured memory_bytes: 69540
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
#define N 123456

int n, m, x, to[66][N];
ll k;
ll a[N], d[N], dans[N], ans[N];
int main() {
    scanf("%d", &n);
    fo(i,0,n) scanf("%lld", a+i);
    fo(i,0,n-1) d[i] = a[i+1] - a[i];
    scanf("%d %lld", &m, &k);
    fo(i,0,n-1) to[0][i] = i;
    fo(i,0,m) {
        scanf("%d", &x);
        x -= 2;
        swap(to[0][x], to[0][x+1]);
    }
    fo(i,1,66) fo(j,0,n-1) to[i][j] = to[i-1][to[i-1][j]];
    ans[0] = a[0];
    fo(i,0,n-1) {
        int pt = i;
        for (ll j = 62; j >= 0; j--) if (k & (1ll<<j)) pt = to[j][pt];
        dans[i] = d[pt];
    }
    fo(i,0,n-1) ans[i+1] = ans[i] + dans[i];
    fo(i,0,n) printf("%lld\n", ans[i]);

        return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);

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

  bool f = false;
  int ans = 0;
  int x = 1;

  for (int i = 0; i < n; i++) {
    if (a[i] == x) {
      x++;
      f = true;
    } else {
      ans++;
    }
  }
  cout << (f ? ans : -1 ) << endl;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;
using ll=long long;

ll a[110];
inline ll norm(ll n){return n*n;}

int main(void){
	int n;
	cin >> n;
	rep(i,n) cin >> a[i];

	ll ans=0LL;
	rep(i,n) ans+=norm(a[i]-a[0]);
	rep(i,-100,101){
		ll cur=0LL;
		rep(j,n) cur+=norm(a[j]-i);
		chmin(ans,cur);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
        ios::sync_with_stdio(0);
        cin.tie(0);
        int n{0};
        double X{0},Y{0};
        cin>>n;
        vector<double> x(n),y(n);
        for(int i =0;i<n;i++)
        {
                cin>>x[i]>>y[i];
                X += x[i];
                Y += y[i];
        }
        X = X/n;
        Y /= n;
        double p = 0.1;
        double d{0};
        for(int i =0;i<30000;i++)
        {
                int f{0};
                d =(X - x[0])*(X - x[0]) + (Y - y[0])*(Y-y[0]); 
                for(int j = 1;j<n;j++)
                {
                        double e = (X - x[j])*(X - x[j]) + (Y - y[j])*(Y-y[j]);
                        if( e > d)
                        {
                                d=e;
                                f = j;
                        }
                }
                X += (x[f] - X)*p;
                Y += (y[f] - Y)*p;
                p *= .999;
        }
        cout<<fixed<<setprecision(20)<<sqrt(d);



        return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
struct Point{
    double x;
    double y;
};
void solve(int n, Point begin, Point end)
{
    if(n == 0)
        return;
    else{
        Point a,b,c;

        a.x = begin.x +(end.x - begin.x)/3.0;
        a.y = begin.y +(end.y - begin.y)/3.0;

        c.x = begin.x +(end.x - begin.x)/3.0*2.0;
        c.y = begin.y +(end.y - begin.y)/3.0*2.0;

        b.x = (c.x - a.x) * cos(M_PI / 3.0) + (c.y - a.y) * sin(-M_PI / 3.0) + a.x;
        b.y = (c.x - a.x) * sin(M_PI / 3.0) + (c.y - a.y) * cos(M_PI / 3.0) + a.y;


        solve(n-1,begin,a);
        printf("%.7lf %.7lf\n",a.x,a.y);
        solve(n-1,a,b);
        printf("%.7lf %.7lf\n",b.x,b.y);
        solve(n-1,b,c);
        printf("%.7lf %.7lf\n",c.x,c.y);
        solve(n-1,c,end);

    }
}

int main()
{
    Point begin,end;
    begin.x = 0.0;
    begin.y = 0.0;

    end.x = 100.0;
    end.y = 0.0;

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

    //printf("%lf %lf\n",begin.x,begin.y);
    //printf("%l %ld",end.x,end.y);
    printf("%.7lf %.7lf\n",begin.x,begin.y);
    solve(n,begin,end);
    printf("%.7lf %.7lf\n",end.x,end.y);

    return 0;

}



Measured memory_bytes: 2648
/*
ID: computerbox --> Huseyn Hajiyev
LANG: C++
TASK: target_mode_on
*/
#include <bits/stdc++.h>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define _CRT_SECURE_NO_WARNINGS
//#include <boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
#define FAST_READ ios_base::sync_with_stdio(0);
#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define COUT(n, a) cout<< fixed << setprecision(a) << n<<endl
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
#define DTIME(ccc) __begin = clock(); ccc; cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<endl;
#define MAXN 100010
//cin.ignore (7777, '\n');

using namespace std;

#define debug(args...)(Debugger()) , args
class Debugger
{
  public:
  Debugger(const std::string& _separator=", ") :
  first(true),separator(_separator){}
  template<typename ObjectType>
  Debugger& operator,(const ObjectType& v)
  {
        if(!first)cerr<<separator;
        cerr<<v;
        first=false;
        return *this;
  }
  ~Debugger() {cerr<<endl;}      
  private:
    bool first;
    string separator;
};
 
template <typename T1, typename T2>
inline ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
   return os<<"("<<p.first<<", "<<p.second<<")";
}
template<typename T>
inline ostream &operator<<(ostream & os,const vector<T>& v)
{
    bool first=true;
    os<<"[";
    for(unsigned ll i=0;i<v.size();i++)
    {
        if(!first)os<<", ";
        os<<v[i];
        first=false;
    }
        return os<<"]";
}
template<typename T>
inline ostream &operator<<(ostream & os,const set<T>&v)
{
    bool first=true;
    os<<"[";
    for(typename set<T>::const_iterator ii=v.begin();ii!=v.end();++ii)
    {
        if(!first)os<<", ";
        os<<*ii;
        first=false;
    }
    return os<<"]";
}
template<typename T1, typename T2>
inline ostream &operator<<(ostream & os,const map<T1, T2>&v)
{
        bool first=true;
        os<<"[";
        for(typename map<T1,T2>::const_iterator ii=v.begin(); ii!=v.end();++ii)
        {
            if(!first)os<<", ";
            os<<*ii;
            first=false;
        }
        return os<<"]";
}

ll dp[MAXN];
ll n;
ll massiv[MAXN];

int main(){
FAST_READ;
cin>>n;
for(ll i=1;i<=n;i++)
{
  cin>>massiv[i];
  dp[i]=LLONG_MAX;
}
dp[0]=0;
dp[1]=0;
dp[2]=abs(massiv[2]-massiv[1]);
for(ll i=3;i<=n;i++)
{
  dp[i]=min(dp[i-1]+abs(massiv[i]-massiv[i-1]),dp[i-2]+abs(massiv[i]-massiv[i-2]));
}
cout<<dp[n]<<endl;



return 0;
} 


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public class Node
	{
		public int Index {get;set;}
		public Dictionary<int, long> Connections{get;set;}
		public bool Visited {get;set;}
		public int Color {get;set;}
		
	}
	
	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var nodes = new Node[n];
		for(int i = 0; i < n; i++)
		{
			nodes[i] =new Node(){ Index = i, Color = -1, Connections = new Dictionary<int, long>() };
		}
		for(int i = 0; i < n-1; i++)
		{
			var p = Input();
			int i1 = p[0].ToInt() - 1;
			int i2 = p[1].ToInt() - 1;
			long d = p[2].ToLong();
			nodes[i1].Connections.Add(i2, d);
			nodes[i2].Connections.Add(i1, d);
		}
		
		Fill(nodes, 0, 0);
		for(int i = 0; i < n; i++)
		{
			Console.WriteLine(nodes[i].Color);
		}
	}
	
	public static void Fill(Node[] nodes, int index, long distance)
	{
		if(nodes[index].Visited)
			return;
		nodes[index].Visited = true;
		foreach(var c in nodes[index].Connections)
		{
			Fill(nodes, c.Key, distance+c.Value);
		}
		
		nodes[index].Color = (int)(distance % 2);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}



Measured memory_bytes: 51004
#include<iostream>
#include<vector>
#include<map>
#include<stack>
using namespace std;

int main(){
	int N,M;
	cin>>N>>M;
	int a[M],b[M];
	for(int i=0;i<M;++i){
		cin>>a[i]>>b[i];
		a[i]--;
		b[i]--;
	}
	stack<int>S;
	stack<int>num;
	S.push(0);
	num.push(0);
	map<int,vector<int> >bridge;
	for(int i=0;i<M;++i){
		bridge[a[i]].push_back(b[i]);
	}
	int state,numstate;
	int ans=0;
	while(!S.empty()){
		state=S.top();
		numstate=num.top();
		S.pop();
		num.pop();
		if(numstate>2)continue;
		if(state==N-1){
			ans=1;
			break;
		}
		for(int i=0;i<bridge[state].size();++i){
			S.push(bridge[state][i]);
			num.push(numstate+1);
		}
	}
	if(ans==1)cout<<"POSSIBLE"<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
}


Measured memory_bytes: 20984
#include<stdio.h>
#include<stdlib.h>
#define N 10000
int n;
void CountingSort(int *,int *);
int main(){
  int A[2000000],i,B[2000000];
  scanf("%d",&n);
  for(i=1;i<n+1;i++){
    scanf("%d",&A[i]);
  }
  CountingSort(A,B);
  for(i=1;i<=n-1;i++){
    printf("%d ",B[i]);
  }
  printf("%d",B[n]);
  printf("\n");
  return 0;
}

void CountingSort(int A[],int B[]){
  int i,j;
  int C[N];
  for(i=0;i<=N;i++){
    C[i] = 0;
  }
  for(j=1;j<n+1;j++){
    C[A[j]]++;
  }
  for(i=1;i<=N;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=n;0<j;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}



Measured memory_bytes: 17428
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  int x[n];
  double sum = 0;
  rep(i,n){
    cin >> x[i];
    sum += x[i];
  }
  sum /= n;
  int p;
  if(sum-(int)(sum) > 0.5) p = (int)(sum)+1;
  else p = (int)(sum);
  int ans = 0;
  rep(i,n){
    ans += (x[i]-p)*(x[i]-p);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main(){
ll n,k;
cin>>n>>k;
vcl a(n);
rep(i,n){
    cin>>a[i];
}
sort(a.begin(), a.end());
ll ans=0;
rep(i,k){
ans+=a[i];
}
cout<<ans<<endl;
}


Measured memory_bytes: 3624
#include<stdio.h>

int main(void){
        int x;
        scanf("%d", &x);
        int flag = 0;
        for(int i=0; i<=1000; i++){
                if(100*i<=x && x<=105*i) flag = 1;
        }
        printf("%d\n", flag);
        return 0;
}


Measured memory_bytes: 128
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class E { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int N, X, Y, Z;
	void Solve()
	{
		var I = G();
		N = I[0];
		X = I[1];
		Y = I[2];
		Z = I[3];
		var M = 1 << (X + Y + Z);
		var m = M - 1;
		var ng = (1 << (Z - 1)) | (1 << (Y + Z - 1)) | (1 << (X + Y + Z - 1));
		var dp = new long[N + 1, M];
		dp[0, 0] = 1;
		for (var i = 0; i < N; i++) for (var s = 0; s < M; s++) if (dp[i, s] != 0) for (var a = 1; a <= 10; a++)
					{
						var t = ((s << a) | (1 << (a - 1))) & m;
						if ((t & ng) != ng) dp[i + 1, t] = (dp[i + 1, t] + dp[i, s]) % MOD;
					}
		var ans = 1L;
		for (var i = 0; i < N; i++) ans = ans * 10 % MOD;
		for (var s = 0; s < M; s++) ans -= dp[N, s];
		if ((ans %= MOD) < 0) ans += MOD;
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 54112
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ_console
{
    class _1_7_A
    {
        static void Main()
        {
            List<List<int>> datas = new List<List<int>>();
            while (true)
            {
                var data = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
                if (data[0] == -1 && data[1] == -1 && data[2] == -1)
                    break;
                datas.Add(data);
            }
            datas.Select(x => x[0] == -1 || x[1] == -1 ? "F" : (x[0] + x[1] >= 80 ? "A" : (x[0] + x[1] >= 65 ? "B" : (x[0] + x[1] >= 50 ? "C" : (x[2] >= 50 ? "C" : (x[0] + x[1] >= 30 ? "D" : "F")))))).ToList().ForEach(x => Console.WriteLine(x));
        }
    }
}

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

const ll mod = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    ll ans = 1;
    rep(i, n){
        ans *= (i + 1);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
txy = [[0,0,0]]+ [list(map(int, input().split())) for i in range(N)]

# その場に留まることは出来ないが、往復は出来る
# 

def move(xy1, xy2):
    return abs(xy1[0]-xy2[0]) + abs(xy1[1]-xy2[1])

for i in range(N):
    move_distance = move(txy[i+1][1:], txy[i][1:])
    tmp = txy[i+1][0]-txy[i][0]
    if tmp < move_distance:
        print("No")
        exit()
    if move_distance%2==0: # 移動距離が偶数なら
        if tmp%2==1:
            print("No")
            exit()
    else: # 移動距離が奇数なら
        if tmp%2==0:
            print("No")
            exit()

    
print("Yes")

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

int main() {
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  A--, B--, C--, D--;
  char S[200010];
  cin >> S;

  bool flag = true;
  for (int i = A; i < C; i++) {
    if (S[i] == '#' && S[i + 1] == '#') {
      flag = false;
    }
  }

  for (int i = B; i < D; i++) {
    if (S[i] == '#' && S[i + 1] == '#') {
      flag = false;
    }
  }

  if (C > D) {
    flag = false;
    for (int i = B; i < D + 1; i++) {
      if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') flag = true;
    }
  }

  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 384
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M = map(int,input().split())
edge = [list(map(int,input().split())) for _ in range(M)]
ans = 0
for i in range(M):
    tmp = edge.pop(i)
    uf = UnionFind(N)
    for j in range(M-1):
        u,t = edge[j][0]-1,edge[j][1]-1
        uf.union(u,t)
        uf.union(t,u)
    if uf.group_count() != 1:
        ans += 1
    edge.insert(i,tmp)
print(ans)

Measured memory_bytes: 3188
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//省略
using vi  = vector<int>;
using vii = vector<vector<int>>;
using vl  = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
    ll H,W,M;
    cin>>H>>W>>M;
    vl h(M),w(M);
    REP(i,M) cin>>h[i]>>w[i];

    map<ll,ll> x,y;
    map<pair<ll,ll>,ll> mp;
    map<ll,vector<ll>> mpx,mpy;
    REP(i,M){
        x[h[i]]++;
        y[w[i]]++;
        mp[make_pair(h[i],w[i])]++;
        mpx[h[i]].push_back(w[i]);
        mpy[w[i]].push_back(h[i]);

    }

    

    vector<ll> xlist;
    set<ll> yset;
    ll xmax=0;
    ll ymax=0;
    for(auto itr=x.begin();itr!=x.end();itr++){
        xmax=max(xmax,itr->second);
    }

    for(auto itr=y.begin();itr!=y.end();itr++){
        ymax=max(ymax,itr->second);
    }

    for(auto itr=y.begin();itr!=y.end();itr++){
        if(itr->second==ymax) yset.insert(itr->first);
    }


    ll ans=xmax+ymax-1;

    for(auto itr=mpx.begin();itr!=mpx.end();itr++){
        vl vec=itr->second;
        ll cnt=0;
        if(vec.size()!=xmax) continue;
        REP(i,vec.size()){
            ll ykouho=vec[i];
            if(yset.count(ykouho)) cnt++;
        }
        if(cnt==yset.size()) continue;
        else{
            ans=xmax+ymax;
        }
        
    }

    
    cout<<ans<<endl;



}

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

// 長方形の中心を通るか通らないか

int main()
{
    int a, b, x, y;
    cin >> a >> b >> x >> y;
    cout << fixed << setprecision(10) << double(a) * double(b) / 2.0 << " " << (x + x == a && y + y == b ? 1 : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int N, tmp, past;
  int cnt = 0;
  int cnt_max = 0;

  scanf("%d", &N);
  scanf("%d", &past);
  cnt = 0;
  for (int i = 0; i < N - 1; i++)
  {
    scanf("%d", &tmp);
    if (past >= tmp)
    {
      cnt++;
    }
    else
    {
      if (cnt > cnt_max)
      {
        cnt_max = cnt;
      }
      cnt = 0;
    }
    past = tmp;
  }

  if (cnt > cnt_max)
  {
    cnt_max = cnt;
  }

  printf("%d", cnt_max);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {

  i64 N, i;
  cin >> N;
  vi C(N);
  REP(0, N, i)
    cin >> C[i];

  sort(all(C), greater<i64>());

  i64 NUM = 1000000007;
  vi pow2(N + 1);
  pow2[0] = 1;
  REP(1, N + 1, i) {
    pow2[i] = pow2[i-1] * 2;
    pow2[i] %= NUM;
  }

  i64 ans = 0;
  REP(0, N, i) {
    i64 da = 1;
    if(i != 0) {
      da *= i; da %= NUM;
      da *= pow2[i-1]; da %= NUM;
      da += pow2[i]; da %= NUM;
    }

    da *= pow2[N-i-1];
    da %= NUM;

    da *= C[i];
    da %= NUM;

    ans += da;
    ans %= NUM;
  }

  ans *= pow2[N];
  ans %= NUM;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;
int main(void){
    // Your code here!
    int N,M;
    cin >> N >> M;
    Graph G(N);
    for(int i=0;i<M;i++){
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    
    vector<int> dist(N, -1);
    vector<int> near(N, -1);
    queue<int> que;
    dist[0] = 0;
    que.push(0);
    
    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (int nv : G[v]) {
            if (dist[nv] != -1) continue;

            dist[nv] = dist[v] + 1;
            near[nv] = v+1;
            que.push(nv);
        }
    }
    cout << "Yes" << endl;
    for (int v = 1; v < N; ++v) cout << near[v] << endl;
    //cout << res << endl;
}


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

int main() {
  long S;
  cin >> S;
  
  int gap;
  
  for (int i =0; (long)pow(10,i-2) <=S; i++) {
    if (abs(753-S/(long)pow(10, i) % 1000) < gap) {
      gap = abs(753-S/(long)pow(10, i) %1000);
    }
  }
  cout << gap << endl;
}

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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int ans = 0;
        HashMap<String, Integer> map = new HashMap<String, Integer>();
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            if(!map.containsKey(s)){
                ans++;
                map.put(s, 1);
            }
        }

        System.out.println(ans);
    }




    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}


Measured memory_bytes: 61028
#include<stdio.h>
int min(int a,int b){return a<b?a:b;}
int main(){
  int d[100][100];
  int e[1000][3];
  int i,j,k,l,m,n;
  scanf("%d%d",&n,&m);
  for(i=0;i<n;i++)for(j=0;j<n;j++)d[i][j]=1e9*(i!=j);
  for(i=0;i<m;i++){scanf("%d%d%d",&j,&k,&l);e[i][0]=j-1;e[i][1]=k-1;d[k-1][j-1]=d[j-1][k-1]=e[i][2]=l;}
  for(i=0;i<n;i++)for(j=0;j<n;j++)for(k=0;k<n;k++)d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
  k=0;for(i=0;i<m;i++)if(d[e[i][0]][e[i][1]]-e[i][2])k++;
  printf("%d",k);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
using ll = long long;

int main()
{

    string T;
    cin >> T;

    bool pre_p_f = false;
    rep(i,T.size()){
        if(T[i] == '?'){
            T[i] = 'D';                            
        }
    }
    // 出力
    cout << T << endl;
    return 0;
}


Measured memory_bytes: 3748