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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		if(!check(s,t)) {
			System.out.println("UNRESTORABLE");
			return;
		}
		int N = s.length;
		for(int i = 0 ; i < N ; i++) {
			if(s[i] == '?') {
				for(char c = 'a' ; ; c++) {
					s[i] = c;
					if(check(s, t)) break;
				}
			}
		}
		System.out.println(String.valueOf(s));
	}

	public static boolean check(char[] s, char[] t) {
		int N = s.length;
		int M = t.length;
		for(int i = 0 ; i + M <= N ; i++) {
			boolean ok = true;
			for(int j = 0 ; j < M ; j++) {
				if(s[i + j] == '?' || s[i + j] ==t[j]);
				else ok = false;
			}
			if(ok) return true;
		}
		return false;
	}
}

Measured memory_bytes: 22996
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a.sort()
dp = [0] * a[-1]
c = Counter(a)
for i in a:
    for j in range(i, a[-1]+1, i):
        dp[j-1] += 1
ans = 0
for i in a:
    if dp[i-1] == 1 and c[i]:
        ans += 1
print(ans)

Measured memory_bytes: 135036
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

string a, b;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b;
	reverse(b.begin(), b.end());
	cout << ((a == b) ? "YES\n" : "NO\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
    #include <math.h>
    #include <vector>
    #include <string>
    #include <cstdlib>
    #include <cmath>
    #include <algorithm>
    using namespace std;

int main() {

    int N,i;cin>>N>>i;
    cout<<N-i+1<<endl;
    return 0;   

}

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

public class Main{
	public static void main(String[] args) throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] tok = in.readLine().split(" ");
		int h = Integer.parseInt(tok[0]);
		int w = Integer.parseInt(tok[1]);
		String[] lines = new String[h];
		for(int i = 0; i < h; ++i){
			lines[i] = in.readLine();
		}

		int m = 610;
		boolean[][] exist = new boolean[m][m];
		for(int i = 0; i < h; ++i)
		for(int j = 0; j < w; ++j)
		if(lines[i].charAt(j) == '#'){
			exist[i + j + 2][i - j + 302] = true;
		}
		int[][] sumh = new int[m][m], sumv = new int[m][m];
		for(int i = 1; i < m; ++i)
		for(int j = 1; j < m; ++j){
			int t = exist[i][j] ? 1 : 0;
			sumh[i][j] = sumh[i][j - 1] + t;
			sumv[i][j] = sumv[i - 1][j] + t;
		}
		
		long res1 = 0, res2 = 0;
		for(int y1 = 0; y1 < m; ++y1)
		for(int x1 = y1 & 1; x1 < m; x1 += 2)
		if(exist[y1][x1]){
			for(int x2 = x1 + 2; x2 < m; x2 += 2)
			if(exist[y1][x2]){
				int d = x2 - x1;
				for(int s = -1; s <= 1; s += 2){
					int y2 = y1 + d * s;
					if(y2 < 0 || y2 >= m){ continue; }
					res1 += exist[y2][x1] ? 1 : 0;
					res1 += exist[y2][x2] ? 1 : 0;
					res2 += sumh[y2][x2 - 1] - sumh[y2][x1];
				}
			}
			for(int y2 = y1 + 2; y2 < m; y2 += 2)
			if(exist[y2][x1]){
				int d = y2 - y1;
				for(int s = -1; s <= 1; s += 2){
					int x2 = x1 + d * s;
					if(x2 < 0 || x2 >= m){ continue; }
					res1 += exist[y1][x2] ? 1 : 0;
					res1 += exist[y2][x2] ? 1 : 0;
					res2 += sumv[y2 - 1][x2] - sumv[y1][x2];
				}
			}
		}
		
		System.out.println(res1 / 2 + res2);
	}
}


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

int main()
{
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> vb(m);
    vector<vector<int>> v(n, vector<int>(m));
    int count = 0;
    rep(i, m)
    {
        cin >> vb[i];
    }
    rep(i, n)
    {
        REP(j, m)
        {
            cin >> v[i][j];
        }
    }
    rep(i, n)
    {
        int sum = 0;
        REP(j, m)
        {
            sum += vb[j] * v[i][j];
        }
        sum += c;
        if (sum > 0)
        {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
from itertools import combinations
N, D = map(int, input().split())
X = [tuple(map(int, input().split())) for _ in range(N)]
res = 0
for i, j in combinations(list(range(N)), 2):
    tmp = sum((y - z) ** 2 for y, z in zip(X[i], X[j]))
    tmp **= 0.5
    if tmp == int(tmp):
        res += 1
print(res)

Measured memory_bytes: 9384
#include <bits/stdc++.h>
#include <time.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD=1000000007;
const long double PI=3.14159265358979;
const ll MAX=0;

int main() {
  ll D,ans=0;
  cin>>D;
  ll c[26];
  ll s[D][26];
  rep(i,26){
    cin>>c[i];
  }
  rep(i,D){
    rep(j,26){
      cin>>s[i][j];
    }
  }
  ll t[D];
  rep(i,D){
    t[i]=rand()%26;
  }
  
  
  ll satis=0;
  rep(i,D){
    ll last[26];
    rep(j,26){
      last[j]=-1;
    }
    satis=0;
    satis+=s[i][t[i]];
    last[t[i]]=i;
    rep(j,26){
      satis-=c[j]*(i-last[j]);
    }
  }
  ll b_satis=satis;
  ans=satis;
  while(clock()<1900000){
    ll w=rand()%365,u=rand()%26;
    satis=0;
    ll last[26];
    rep(i,26){
      last[i]=-1;
    }
    ll g=t[w];
    t[w]=u;
    rep(i,D){
      satis+=s[i][t[i]];
      last[t[i]]=i;
      rep(j,26){
        satis-=c[j]*(i-last[j]);
      }
      
    }
    if(ans>satis){
      t[w]=g;
    }
    ans=max(ans,satis);
  }
  rep(i,D){
    cout<<t[i]+1<<endl;
  }
}


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

void f(int n, string s, vector<map<string, int>>& r, string a, string b) {
  int i = a.size() + b.size();
  if (i == n) {
    reverse(begin(b), end(b));
    string c = a + b;
    r[a.size()][c]++;
    return;
  }
  a.push_back(s[i]);
  f(n, s, r, a, b);
  a.pop_back();
  b.push_back(s[i]);
  f(n, s, r, a, b);
}

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<map<string, int>> u(n + 1), v(n + 1);
  f(n, s, u, "", "");
  reverse(begin(s), end(s));
  f(n, s, v, "", "");
  ll m = 0;
  for (int i = 0; i < n + 1; i++) {
    for (auto e : u[i]) {
      m += (ll)e.second * v[i][e.first];
    }
  }
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 82688
import math
k = int(input())
total = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        g1 = math.gcd(a, b)
        for c in range(1, k+1):
            g2 = math.gcd(g1, c)
            total += g2
print(total)



Measured memory_bytes: 9156
#include<stdio.h>
int table[100002];
int main()
{
	int n,i,j;
	scanf("%d",&n);
	for(i=0;i<n;++i)
	{
		scanf("%d",&j);
		table[j+1]++;
	}
	j=1;
	for(i=2;i<100002;++i)
		if(table[j-1]+table[j]+table[j+1]<table[i-1]+table[i]+table[i+1])
			j=i;
	printf("%d",table[j-1]+table[j]+table[j+1]);
	return 0;
 } 

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

public class Main {

	class DSU {
		int[] p;

		public DSU(int n) {
			p = new int[n];
			for (int i = 0; i < n; i++) {
				p[i] = i;
			}
		}

		int get(int i) {
			if (p[i] == i) {
				return i;
			}
			return p[i] = get(p[i]);
		}

		void union(int a, int b) {
			p[get(b)] = get(a);
		}
	}

	void solve() {
		int n = in.nextInt(), m = in.nextInt();
		int[] cost = new int[n];
		for (int i = 0; i < n; i++) {
			cost[i] = in.nextInt();
		}
		DSU dsu = new DSU(n);
		for (int i = 0; i < m; i++) {
			dsu.union(in.nextInt(), in.nextInt());
		}
		int edges = n - m - 1;
		int needTake = 2 * edges;
		int[] count = new int[n];

		Integer[] a = new Integer[n];
		for (int i = 0; i < n; i++) {
			a[i] = i;
		}
		Arrays.sort(a, (i, j) -> Integer.compare(cost[i], cost[j]));
		long ans = 0;
		if (needTake == 0){ 
			out.println(0);
			return;
		}
		boolean[] used = new boolean[n];
		for (int i : a) {
			if (count[dsu.get(i)] == 0) {
				ans += cost[i];
				needTake--;
				count[dsu.get(i)]++;
				used[i] = true;
			}
		}
		for (int i : a) {
			if (used[i]) {
				continue;
			}
			if (count[dsu.get(i)] < edges && needTake > 0) {
				ans += cost[i];
				needTake--;
				count[dsu.get(i)]++;
				used[i] = true;
			}
		}
		out.println(needTake == 0 ? ans : "Impossible");
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

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

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

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

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

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

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 47228
#include <stdio.h>
#include <stdlib.h>
#include <vector>

#define MAX_N (100)
#define INF (1000000000)

using namespace std;

typedef struct {
  int to;
  int cap;
  int rev;
} edge;

int find_path(vector<vector<edge>> &adj_lists, int cur, int min_to_cur, int dst,
              vector<int> &useds) {
  if (cur == dst) {
    return min_to_cur;
  }
  useds[cur] = 1;
  int ret = 0;
  for (edge &e : adj_lists[cur]) {
    if (!useds[e.to] && e.cap > 0) {
      int cap_path =
          find_path(adj_lists, e.to, min(min_to_cur, e.cap), dst, useds);
      if (cap_path > 0) {
        ret = cap_path;
        edge &r = adj_lists[e.to][e.rev];
        e.cap -= cap_path;
        r.cap += cap_path;
        break;
      }
    }
  }
  return ret;
}

int maximum_flow(vector<vector<edge>> &adj_lists, int src, int dst) {
  int ret = 0, cap_path;
  vector<int> useds(adj_lists.size());
  while (1) {
    for (int &used : useds) {
      used = 0;
    }
    cap_path = find_path(adj_lists, src, INF, dst, useds);
    if (cap_path > 0) {
      ret += cap_path;
    } else {
      break;
    }
  }
  return ret;
}

void add_edge(vector<vector<edge>> &adj_lists, int u, int v, int cap) {
  const edge e = {v, cap, (int)adj_lists[v].size()};
  const edge r = {u, 0, (int)adj_lists[u].size()};
  adj_lists[u].push_back(e);
  adj_lists[v].push_back(r);
}

int main() {
  // read inputs
  int N, as[MAX_N], bs[MAX_N], cs[MAX_N], ds[MAX_N];
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d %d", &as[i], &bs[i]);
  }
  for (int i = 0; i < N; i++) {
    scanf("%d %d", &cs[i], &ds[i]);
  }

  // create graph
  // nodes:
  //   0     ~ N - 1     : red points
  //   N - 1 ~ 2 * N - 1 : blue points
  //   2 * N             : start
  //   2 * N + 1         : end
  vector<vector<edge>> adj_lists(2 * N + 2, vector<edge>());
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (as[i] < cs[j] && bs[i] < ds[j]) {
        add_edge(adj_lists, i, j + N, 1);
      }
    }
  }
  for (int i = 0; i < N; i++) {
    add_edge(adj_lists, 2 * N, i, 1);
  }
  for (int i = 0; i < N; i++) {
    add_edge(adj_lists, i + N, 2 * N + 1, 1);
  }

  // calculate maximum flow
  printf("%d\n", maximum_flow(adj_lists, 2 * N, 2 * N + 1));
}

Measured memory_bytes: 384
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

long long int N, M, K, L, R, H, W;
//int N, M, K, L, R, H, W;



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

	cin >> H >> W;
	vector<string>v(H);
	for (auto &i : v)cin >> i;
	vector<vector<int>>dis(H, vector<int>(W, MOD));
	dis[0][0] = 0;
	deque<pair<int, int>>Q;
	Q.push_back({ 0,0 });
	int dir[] = { 1,0,1 };
	while (!Q.empty()) {
		int cy = Q.front().first;
		int cx = Q.front().second;
		Q.pop_front();
		for (int i = 0; i < 2; i++) {
			int ny = cy + dir[i];
			int nx = cx + dir[i + 1];
			if (ny < 0 || nx < 0 || ny >= H || nx >= W)continue;
			if (v[ny][nx] == v[cy][cx]) {
				if (dis[ny][nx] > dis[cy][cx]) {
					dis[ny][nx] = dis[cy][cx];
					Q.push_front({ ny,nx });
				}
			}
			else {
				if (dis[ny][nx] > dis[cy][cx]+1) {
					dis[ny][nx] = dis[cy][cx]+1;
					Q.push_back({ ny,nx });
				}
			}
		}
	}
	int ans = (dis.back().back()) / 2;
	if (v[0][0] == '#'||v.back().back()=='#')ans++;
	cout << ans << endl;
}


Measured memory_bytes: 384
n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

mod = 10 ** 9 + 7

sx = 0
sy = 0
for i in range(n):
    sx = (sx + x[i] * i - x[i] * (n - 1 - i)) % mod
for i in range(m):
    sy = (sy + y[i] * i - y[i] * (m - 1 - i)) % mod
print(sx * sy % mod)


Measured memory_bytes: 24456
#include <stdio.h>
int main(){

  int x,y,r,temp;

  scanf("%d%d",&x, &y);
  
  if(x<y){
    temp=x;
    x=y;
    y=temp;
  }
  
  while (y>0){
    r = x % y;
    x = y;
    y = r;
	  }
  printf("%d\n",x);
  return 0;
}

//AOJ answer

/*#include <stdio.h>
int main(){
 
  int x,y,r,temp;
 
  scanf("%d%d",&x, &y);
   
  if(x<y){
    temp=x;
    x=y;
    y=temp;
  }
   
  while (y>0){
    r = x % y;
    x = y;
    y = r;
      }
  printf("%d\n",x);
  return 0;
}
*/



Measured memory_bytes: 2120
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,l[100000],r[100000],ans=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>l[i]>>r[i];
		ans+=r[i]-l[i]+1;
	}
	cout<<ans<<endl;
	return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

ll H, W;
ll ans = 1e15;

ll solve() {
   ll ret = 1e15;
   repp (i, 1, W) {
      ll a = (H/2)*i, b = ((H+1)/2)*i, c = H*(W-i);
      ll t = abs(max({a, b, c}) - min({a, b, c}));
      ret = min(ret, t);
   }
   repp (i, 1, H) {
      ll a = W/2*i, b = (W+1)/2*i, c = (H-i)*W;
      ll t = abs(max({a, b, c}) - min({a, b, c}));
      ret = min(ret, t);
   }
   return ret;
}

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

   ll a, b, c;
   a = b = c = H/3;
   ll amari = H - ((H/3)*3);
   if (amari == 1) { a++; } 
   if (amari == 2) { a++, b++; } 
   ans = min(ans, a*W - c*W);

   a = b = c = W/3;
   amari = W - ((W/3)*3);
   if (amari == 1) { a++; } 
   if (amari == 2) { a++, b++; } 
   ans = min(ans, a*H - c*H);

   cout << min(ans, solve()) << endl;

   return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    vl a(n);
    vl cnt(n);
    cin >> a;

    ll ans = 1;
    rep(i, n) {
        if (a[i] == 0) ans *= (3 - cnt[a[i]]);
        else ans *= (cnt[a[i] - 1] - cnt[a[i]]);
        ans %= mod;
        cnt[a[i]]++;
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 4836
#include <algorithm>
#include <cstdio>
#include <queue>

using namespace std;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

struct Data
{
	int y, x, c;
	Data(int y, int x, int c) : y(y), x(x), c(c) {}
};

int main()
{
	int h, w, n;
	scanf("%d%d%d", &h, &w, &n);
	
	char field[1024][1024];
	int sy, sx;
	rep(i, h){
		scanf("%s", field[i]);
		rep(j, w){
			if(field[i][j] == 'S'){
				sy = i;
				sx = j;
				break;
			}
		}
	}
	int ans = 0;
	rep(i, n){
		bool visited[1000][1000] = {{false}};
		
		queue<Data> Q;
		Q.push(Data(sy, sx, 0));
		while(!Q.empty()){
			Data d = Q.front();
			Q.pop();
			if(field[d.y][d.x] == i+1+'0'){
				ans += d.c;
				sy = d.y;
				sx = d.x;
				break;
			}
			if(visited[d.y][d.x])
				continue;
			visited[d.y][d.x] = true;
			
			const int dy[] = {-1, 0, 0, 1};
			const int dx[] = {0, 1, -1, 0};
			rep(j, 4){
				int py = d.y + dy[j];
				int px = d.x + dx[j];
				if(py<0 || h<=py || px<0 || w<=px || field[py][px]=='X')
					continue;
				Q.push(Data(py, px, d.c+1));
			}
		}
	}
	printf("%d\n", ans);
	
	return 0;
}

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

using namespace std;

int main(){
  int N; cin >> N;
  vector<double> A(N);
  for(int  i= 0; i < N; i++){ cin >> A[i];}
  sort(A.begin(),A.end());
  
  double v = A[0];
  
  for(int i = 1; i < N; i++){
    v = (v + A[i]) / 2;}
  
  cout << fixed << setprecision(10) << v << endl; return 0;}
  
  


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

using namespace std;

int main(){
	int N, M; cin >> N >> M;
	vector< pair<int, int> > student(N);
	vector< pair<int, int> > checkpoint(M);
	for(int i = 0; i < N; ++i){
		cin >> student[i].first >> student[i].second;
	}
	for(int i = 0; i < M; ++i){
		cin >> checkpoint[i].first >> checkpoint[i].second;
	}
	for(int i = 0; i < N; ++i){
		vector< pair<int, int> > distance(M);
		for(int j = 0; j < M; ++j){
			distance[j].first = abs(student[i].first - checkpoint[j].first) + abs(student[i].second - checkpoint[j].second);
			distance[j].second = j+1;
		}
		sort(distance.begin(), distance.end());
		cout << distance[0].second << endl;
		distance.clear();
	}
}

Measured memory_bytes: 256
import math,collections
n=int(input())
a=sorted(map(int,input().split()))[::-1]
s=collections.Counter(a)
r=0
f=0
for i,v in enumerate(a):
	if f:f=0;continue
	if s[v]==0:continue
	p=2**math.ceil(math.log2(v))-v
	if p in s.keys() and s[p]>0:s[v]-=1;s[p]-=1;r+=1;continue
	if i<n-1 and p==0 and a[i+1]==v and s[v]>=2:s[v]-=2;r+=1;f=1
print(r)

Measured memory_bytes: 33416
#include<bits/stdc++.h>
using namespace std;
int cost(int h[],int src,int n,int dp[])
{
	if(src==n)
	 return 0;
	 
	 if(dp[src]!=-1)
	  return dp[src];
	  
	  int op1,op2;
	if(src+1>n)
	  op1=INT_MAX;
	else
	  op1=abs(h[src+1]-h[src])+cost(h,src+1,n,dp);
	
	if(src+2>n)
	   op2=INT_MAX;
	else
	 op2=abs(h[src+2]-h[src])+cost(h,src+2,n,dp);
//	int op1= if(src+1>n)?INT_MAX:abs(h[src+1]-h[src])+cost(h,src+1,n,dp);
//	int op2=if(src+2>n)?INT_MAX:abs(h[src+2]-h[src])+cost(h,src+2,n,dp);
	return dp[src]=min(op1,op2);
}
int main()
{
    int n;
    cin>>n;
    int h[n+1];
    for(int i=1;i<=n;i++)
    {
    	cin>>h[i];
	}
	int dp[n+1];
	for(int i=1;i<=n;i++)
	  dp[i]=-1;
	int ans=cost(h,1,n,dp);
	cout<<ans<<endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int x, y, tx, ty;

int main() {
    cin >> x >> y >> tx >> ty;
    int dx = tx - x;
    int dy = ty - y;
    string ans = "";
    auto add = [&](int n, char c){
        while (n) {
            ans += c;
            --n;
        }
    };
    // +dx +dy +1x -dy -1y -dx -1x +1y
    add(dx, 'R');
    add(dy, 'U');
    add(1, 'R');
    add(dy + 1, 'D');
    add(dx + 1, 'L');
    add(1, 'U');
    // +dy +dx +1y -dx -1x -dy -1y +1x
    add(dy, 'U');
    add(dx, 'R');
    add(1, 'U');
    add(dx + 1, 'L');
    add(dy + 1, 'D');
    add(1, 'R');
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000

int main(void){
  int dp[1111][1111];
  for(int i = 0; i < 1111; i++) for(int j = 0; j < 1111; j++) dp[i][j] = INF;

  int N, M;
  int C[1111], D[1111];
  cin >> N >> M;
  for(int i = 0; i < N; i++) cin >> D[i];
  for(int i = 0; i < M; i++) cin >> C[i];
  for(int i = 0; i < M; i++){
    dp[i][0] = 0;
  }
  for(int i = 1; i <= M; i++){
    for(int j = 0; j <= N; j++){
      if(j != 0){
        dp[i][j] = min(dp[i-1][j], dp[i-1][j-1] + D[j-1] * C[i-1]);
      }
    }
  }
  cout << dp[M][N] << endl;
}

Measured memory_bytes: 7932
#include <iostream>
#include <string>

using namespace std;

int main()
{
    while(1 == 1){
        int a,b;
    string op;
    int result;
        cin >> a >> op >> b;
    if(op == "?") break;
    if(op == "+"){
        result = a + b;
        cout << result << endl;
    }
    if(op == "-"){
        result = a - b;
        cout << result << endl;
    }
    if(op == "*"){
        result = a * b;
        cout << result << endl;
    }
    if(op == "/"){
        result = a / b;
        cout << result << endl;
    }
    }
        
}

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

x=1
while K:
    if K&1: x=A[x-1]
    K>>=1

    A2 = [None]*N
    for i,a in enumerate(A):
        A2[i]=A[A[i]-1]
    A=A2

print(x)

Measured memory_bytes: 170996
N = int(input())
P = []

for i in range(N):
    x, y = map(int, input().split())
    P.append((x, y))
d = 0
k = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        k += 1
        d += ((P[i][0] - P[j][0]) ** 2 + (P[i][1] - P[j][1]) ** 2) ** 0.5

print(d / k * (N - 1))



Measured memory_bytes: 3064
N,K = map(int,input().split())
l = [list(map(int,input().split())) for i in range(N)]
l.sort()
ans = []
for i in range(N):
    for j in range(i+1,N+1):
        nl = l[i:j]
        h = nl[-1][0]-nl[0][0]
        if len(nl)< K: continue
        nl.sort(key = lambda x:x[1])
        v = len(nl)
        for m in range(v-K+1):
            ans.append(h*(nl[m+K-1][1]-nl[m][1]))
print(min(ans))

Measured memory_bytes: 74288
#include<stdio.h>

int main(){
    long long int l, r;
    scanf("%lld%lld", &l, &r);
    long long int min = 2018;
    for(long long int i=l; i<r; i++){
        for(long long int j=i+1; j<=r; j++){
            if((i*j)%2019 < min){
                min = (i*j)%2019;
            }
            if(min == 0){
                break;
            }
        }
        if(min == 0){
            break;
        }
    }
    printf("%lld", min);

    return 0;
}

Measured memory_bytes: 128
function main(input){
  input = input.split("\n");
  l = input[1].split(" ");
  input = input[0].split(" ");
  var n = parseInt(input[0], 10);
  var x = parseInt(input[1], 10);
  var bound_position = 0;
  var bound_count = 1;
  for(var i = 0; i < n; i++){
    bound_position += parseInt(l[i], 10);
    if(bound_position > x){
      break;
    }else{
      bound_count++;
    }
  }
  console.log(bound_count);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

void seven_check(vector<int> &a, vector<char> &ans, int depth, int sum, bool &flag) {
  depth++;
  if(depth == 3) {
    if(sum + a.at(depth) == 7) {
      ans.at(depth-1) = '+';
      flag = true;
    }
    else if(sum - a.at(depth) == 7) {
      ans.at(depth-1) = '-';
      flag = true;
    }
    return;
  }
  if(!flag) {
    sum += a.at(depth);
    ans.at(depth-1) = '+';
    seven_check(a, ans, depth, sum, flag);
    sum -= a.at(depth);
  }
  else return;
  if(!flag) {
    sum -= a.at(depth);
    ans.at(depth-1) = '-';
    seven_check(a, ans, depth, sum, flag);
    sum += a.at(depth);
  }
  else return;
}

int main(){
  int x;
  cin >> x;
  vector<int> a(4);
  a.at(0) = x/1000;
  a.at(1) = (x/100)%10;
  a.at(2) = (x/10)%10;
  a.at(3) = x%10;
  vector<char> ans(3);
  int depth = 0, sum = a.at(0);
  bool flag = false;
  seven_check(a, ans, depth, sum, flag);
  cout << a.at(0);
  for (int i=0; i<3; i++) {
    cout << ans.at(i) << a.at(i+1);
  }
  cout << "=7" << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    sort(a.begin(),a.end());
    if(debug){
        rep(i,n) cout << a.at(i) << " ";
        cout << endl;
    }
    ll cnt = 0;
    rep(i,n-2){
        for(int j=i+1;j<n-1;j++){
            int minc = abs(a.at(i)-a.at(j))+1;
            int maxc = a.at(i) + a.at(j)-1;

            // max
            int l = j;
            int r = n;
            while(l+1<r){
                int mid = (l+r)/2;
                if(a.at(mid) <= maxc) l = mid;
                else r = mid;
            }
            int maxidx = l;
            if(a.at(maxidx) > maxc) continue;

            l=j;
            r=maxidx+1;
            while(l+1<r){
                int mid = (l+r)/2;
                if(a.at(mid) >= minc) r = mid;
                else l = mid;
            }
            int minidx = r;
            cnt += max(maxidx-minidx+1,0);
            if(debug){
                cout << "(" << a.at(i) << "," << a.at(j) << ") " << minc << "-" << maxc << " " << a.at(minidx) << "-" << a.at(maxidx) << " " << cnt << endl;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <map>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int N, M;
    map<string, int> blue, red;  // <key, value> mp["key"] = 1;
    
    cin >> N;
    vector<string> b(N);
    REP(i, N) {
        cin >> b[i];
        blue[b[i]] = 0;
    }
    cin >> M;
    vector<string> r(M);
    REP(i, M) {
        cin >> r[i];
        red[r[i]] = 0;
    }
    
    // calculation
    REP(i, N) {
        blue[b[i]]++;
    }
    REP(i, M) {
        red[r[i]]++;
    }
    
    int res = 0;
    auto begin = blue.begin(), end = blue.end();
    for (auto itr = begin; itr != end; itr++) {
        // first: key, second: value
        string key = itr->first;
        res = max(res, blue[key] - red[key]);
    }
    cout << res << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<int> g[100010];
int ind[100010];
int a,b,c;
int dp[100010];
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		g[a].push_back(b);
		ind[b]++;
	}
	stack<int> s;
	for(int i=1;i<=n;i++)
	   if(ind[i]==0)
	      s.push(i);
	while(s.size()){
		int p=s.top();
		s.pop();
		for(int i=0;i<g[p].size();i++){
			int to=g[p][i];
			if(dp[p]+1>dp[to]){
				dp[to]=dp[p]+1;
			}
			ind[to]--;
			if(!ind[to]) s.push(to);
		}
	}
	cout<<*(max_element(dp+1,dp+n+1));
	return 0;
}


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

double sqr(double x)
{
  return(x * x);
}
double abs2(double ax, double ay, double az, int x, int y, int z)
{
  return(sqr(ax - x) + sqr(ay - y) + sqr(az - z));
}

int main()
{
  int64 N, Q, x[50], y[50], z[50], r[50], l[50];
  cin >> N >> Q;
  for(int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> z[i] >> r[i] >> l[i];
  }
  while(Q--) {
    int sx, sy, sz, dx, dy, dz;
    cin >> sx >> sy >> sz >> dx >> dy >> dz;
    int64 ret = 0;
    for(int k = 0; k < N; k++) {
      double low = 0, high = 1.0;
      for(int i = 0; i < 50; i++) {
        double left = (low * 2 + high) / 3;
        double right = (low + high * 2) / 3;
        double ll = abs2(sx + (dx - sx) * left, sy + (dy - sy) * left, sz + (dz - sz) * left, x[k], y[k], z[k]);
        double rr = abs2(sx + (dx - sx) * right, sy + (dy - sy) * right, sz + (dz - sz) * right, x[k], y[k], z[k]);
        if(ll < rr) high = right;
        else low = left;
      }
      double mm = abs2(sx + (dx - sx) * (low + high) / 2, sy + (dy - sy) * (low + high) / 2, sz + (dz - sz) * (low + high) / 2, x[k], y[k], z[k]);
      if(mm < r[k] * r[k] + 1e-9) ret += l[k]; 
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 1168
def check(find):
    for i in range(3):
        ok = True
        for j in range(3):
            ok &= find[i][j]
        if ok:
            return True
    for j in range(3):
        ok = True
        for i in range(3):
            ok &= find[i][j]
        if ok:
            return True
    return find[0][0] and find[1][1] and find[2][2] or \
        find[0][2] and find[1][1] and find[2][0]


def main():
    A = [list(map(int, input().split())) for _ in range(3)]
    N = int(input())
    B = [int(input()) for _ in range(N)]
    find = [[False] * 3 for _ in range(3)]
    for b in B:
        for i in range(3):
            for j in range(3):
                if A[i][j] == b:
                    find[i][j] = True
    if check(find):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
n = int(input())
A = tuple(map(int, input().split()))

# 最左をプラスとする場合
sa = A[0]
pc = 0
if sa <= 0:
    pc = 1 - sa
    sa = 1
plus = -1
for a in A[1:]:
    sa += a
    if plus > 0 and sa <= 0:
        pc += 1 - sa
        sa = 1
    elif plus < 0 and sa >= 0:
        pc += 1 + sa
        sa = -1
    plus *= -1

# 最左がマイナスの場合
sa = A[0]
mc = 0
if sa >= 0:
    mc = 1 + sa
    sa = -1
plus = 1
for a in A[1:]:
    sa += a
    if plus > 0 and sa <= 0:
        mc += 1 - sa
        sa = 1
    elif plus < 0 and sa >= 0:
        mc += 1 + sa
        sa = -1
    plus *= -1

print(min(pc, mc))


Measured memory_bytes: 84648
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.close();
        long power = 1;
        long c = (long) (Math.pow(10, 9) + 7);

        for (int i = 1; i <= N; i++) {
            power *= i;
            power %= c;
        }
        System.out.println(power);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;

int main()
{
	int n;
	ll ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(i<10)
			ans++;
		else if(i>=100 && i<1000)
			ans++;
		else if(i>=10000 && i<100000)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int INF=0x3f3f3f3f;


int main(){
	ios_base::sync_with_stdio(false);
	int n,tmp;
	cin>>n;
	set <int> s;
	set <int> ::iterator x;
	for(int i=1;i<=n;i++){
		cin>>tmp;
		x=s.lower_bound(tmp);
		if(*x==tmp) s.erase(tmp);
		else s.insert(tmp);	
	}
	cout<<s.size()<<endl;
	return 0;
}

Measured memory_bytes: 4992
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n, x = LI()

    b, a = sorted([x, n - x])
    ans = a + b
    while b:
        q, mod = divmod(a, b)
        ans += (2 * q - (not mod)) * b
        a, b = b, mod

    return ans


print(main())


Measured memory_bytes: 3188
N = int(input())
ab = sorted([ tuple(map(int, input().split())) for x in range(N)], key=lambda x:x[1],reverse=True)
cd = sorted([ tuple(map(int, input().split())) for x in range(N)])
resultx = []
resulty = []
for xb, yb in list(cd):
    for xr, yr in list(ab):
        if (xr, yr) in resultx:
            continue
        if xr < xb and yr < yb:
            resultx.append((xr,yr))
            resulty.append((xb,yb))
            break

print(len(resultx))

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys
import collections


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    cur = 1
    c = {}
    route = []
    second_f = None
    while (True):
        if cur in c:
            second_f = cur
            break
        route.append(cur)
        c[cur] = 1
        cur = A[cur - 1]
    idx = route.index(second_f)
    if K <= idx:
        print(route[K])
        return
    roop = route[idx:]
    print(roop[(K - idx) % len(roop)])
    return


if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;

vector<ll> a(51), p(51);

ll baga(ll N, ll X) {
    if (N == 0) return X <= 0 ? 0 : 1;
    else if (X <= (1 + a[N-1])) return baga(N-1, X-1);
    else return p[N-1] + 1 + baga(N-1, X - 2 - a[N-1]);
}

int main() {
    ll N, X;
    cin >> N >> X;


    a[0] = 1; p[0] = 1;
    for (int i = 1; i < N; i++) {
        a[i] = a[i-1]*2 + 3;
        p[i] = p[i-1]*2 + 1;
    }


    ll res = baga(N, X);

    cout << res << endl;

}


Measured memory_bytes: 256
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	int[] aa, pq, ip; int cnt;
	boolean lt(int i, int j) {
		return aa[i] < aa[j];
	}
	int p2(int p) {
		return (p *= 2) > cnt ? 0 : p < cnt && lt(ip[p + 1], ip[p]) ? p + 1 : p;
	}
	void pq_dn(int i) {
		int j, p, q;
		for (p = pq[i]; (q = p2(p)) > 0 && lt(j = ip[q], i); p = q)
			ip[pq[j] = p] = j;
		ip[pq[i] = p] = i;
	}
	void pq_add_last(int i) {
		ip[pq[i] = ++cnt] = i;
	}
	void solve(long[] pp, int n) {
		cnt = 0;
		long sum = 0;
		for (int i = 0; i < n; i++) {
			pq_add_last(i);
			sum += aa[i];
		}
		for (int p = cnt / 2; p > 0; p--)
			pq_dn(ip[p]);
		for (int i = n; i < n * 2; i++) {
			pp[i - n] = sum;
			int d = aa[i] - aa[ip[1]];
			if (d > 0) {
				sum += d;
				pq[i] = 1; pq_dn(i);
			}
		}
		pp[n] = sum;
	}
	void main() {
		int n = sc.nextInt(), n2 = n * 2, n3 = n * 3;
		aa = new int[n3];
		for (int i = 0; i < n3; i++)
			aa[i] = sc.nextInt();
		pq = new int[n2]; ip = new int[n + 1];
		long[] pp = new long[n + 1];
		long[] qq = new long[n + 1];
		solve(pp, n);
		for (int i = 0; i < n3; i++)
			aa[i] = -aa[i];
		for (int i = 0, j = n3 - 1; i < j; i++, j--) {
			int tmp = aa[i]; aa[i] = aa[j]; aa[j] = tmp;
		}
		solve(qq, n);
		long ans = -0x3f3f3f3f3f3f3f3fL;
		for (int i = 0; i <= n; i++)
			ans = Math.max(ans, pp[i] + qq[n - i]);
		println(ans);
	}
}


Measured memory_bytes: 62060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define gg(x) getInt(&x)
using namespace std;
typedef long long ll;
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
ll n;
ll dp[maxn];
ll a[maxn];
ll k;
int main()
{
    gbtb;
    cin>>n>>k;
    repd(i,1,n)
    {
        cin>>a[i];
    }
    dp[1]=0;
    dp[0]=0;
    repd(i,2,n)
    {
        dp[i]=inf;
    }
    repd(i,2,n)
    {
        for(int j=i-1;j>=max(1ll,i-k);j--)
        {
            dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
        }
    }
    cout<<dp[n];
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}

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

int main () {
  string a, b;
  cin >> a >> b;
  int ab = stoi(a + b);
  
  double d = sqrt(ab);
  if (ceil(d) == floor(d)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int cnt = 0;
    for(int i=0;i<s.size()/2;i++){
        if(s[i] != s[s.size()-(i+1)])
            cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>

using namespace std;

template <typename Tlist, typename Tfunc>
void __combination(
    Tlist const& list, typename Tlist::size_type const n, Tfunc const& func,
    Tlist& tmp, typename Tlist::size_type const i, typename Tlist::size_type const j)
{
    if (i == n)
    {
        func(tmp);
        return;
    }

    for (typename Tlist::size_type k = j; k != list.size() + (1 + i- n); ++k)
    {
        tmp[i] = list[k];
        __combination(list, n, func, tmp, i + 1, k + 1);
    }
}

template <typename Tlist, typename Tfunc>
void combination(
    Tlist const& list, typename Tlist::size_type const n, Tfunc const& func)
{
    Tlist tmp(n);
    __combination(list, n, func, tmp, 0, 0);
}

/*
  uint64_t sum = 0;
  combination(inis, 3, [&sum](auto& v) {
  sum += std::accumulate(std::begin(v), std::end(v), 1ULL, [](auto acc, auto nn) {
  return acc*nn;
  });
  });
*/


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

    struct P {
        int64_t x;
        int64_t y;
    };

    std::vector<P> points;
    std::vector<int64_t> xaxis;
    std::vector<int64_t> yaxis;
    for (size_t i = 0; i < N; ++i) {
        int64_t x, y;
        std::cin >> x >> y;
        points.push_back({x, y});
        xaxis.push_back(x);
        yaxis.push_back(y);
    }

    // 重複点捨てておく
    xaxis.erase(std::unique(std::begin(xaxis), std::end(xaxis)), std::end(xaxis));
    yaxis.erase(std::unique(std::begin(yaxis), std::end(yaxis)), std::end(yaxis));

    int64_t m = INT64_MAX;
    combination(xaxis, 2, [&m, K, &points, &yaxis](auto& xx) {
            combination(yaxis, 2, [&m, K, &xx, &points](auto& yy) {
                    int inCount = 0;
                    const auto xmin = std::min(xx[0], xx[1]);
                    const auto ymin = std::min(yy[0], yy[1]);
                    const auto xmax = std::max(xx[0], xx[1]);
                    const auto ymax = std::max(yy[0], yy[1]);
                    for (auto&& p : points) {
                        if (xmin <= p.x && p.x <= xmax &&
                            ymin <= p.y && p.y <= ymax)
                        {
                            inCount++;
                        }
                    }
                    if (inCount >= K) {
                        m = std::min(m, (xmax - xmin)*(ymax - ymin));
                    }
                });
        });

    std::cout << m << std::endl;

    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<queue<int>> Q(n);
	int q;
	cin >> q;
	for (int i = 0; i < q; ++i) {
		int query;
		cin >> query;
		if (query == 0) {
			int t, x;
			cin >> t >> x;
			Q[t].push(x);
		}
		else if (query == 1) {
			int t;
			cin >> t;
			if (!Q[t].empty()) cout << Q[t].front() << endl;
		}
		else {
			int t;
			cin >> t;
			if (!Q[t].empty()) Q[t].pop();
		}
	}
}


Measured memory_bytes: 4300
#include <stdio.h>
 
int main(int argc, char *argv[]) {
  char first, second;
  scanf("%c %c", &first, &second);
  if (first < second){
    printf("<");
  }
  else if(first == second){
    printf("=");
  }
  else{
  printf(">");
  }
  return 0;
}

Measured memory_bytes: 128
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n+1);
	REP1(i, n) cin >> a[i];
	ll rw[n+1] ={};
	REP1(i, n) rw[i] = a[i] + rw[i-1];
	vector<ll> pa;
	REP1(i, n) REP(j, i) pa.push_back(rw[i]-rw[j]);
	sort(pa.begin(), pa.end());
	ll co;
	//REP(i, pa.size()) cout << pa[i] << endl;
	for(int i = 62; i >= 0; i--){
		co = 0;
		REP(j, pa.size()){
			if(((ans & pa[j]) == ans) && ((ll)1<<i & pa[j])){
				co++;
			}
		}
		if(co >= k) ans |= (ll)1 << i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 7416
import java.util.*;
import java.math.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int humans = sc.nextInt();
    
    int[] lives = new int[humans];
    
    for(int i=0;i<humans;i++){
      lives[i] = sc.nextInt();
    }
    
    int minPowerPoint = -1;
    int minPower = -1;
    
    for(int p = 1; p <= 100 ; p++){
      int power = 0;
      for(int live:lives){
        power += Math.pow(live-p,2);
      }
      
      if(minPowerPoint == -1 || power < minPower){
        minPowerPoint = p;
        minPower = power;
      }
    }
    System.out.println(minPower);
    
    
  }
}

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

int triple_max(int x, int y, int z);

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    cout << (abs(x - a) < abs(x - b) ? "A" : "B") << endl;

    return 0;
}

int triple_max(int x, int y, int z){
    int ans = x;
    if (y > x && y > z) ans = y;
    else if (z > x && z > y) ans = z;

    return ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
//#define NDEBUG
int main(void){
	using namespace std;
	static const int INPUT_N_MIN = 0;
	static const int INPUT_N_MAX = 10000;
	static const int INPUT_A_MIN = -1000000;
	static const int INPUT_A_MAX =  1000000;
	int ans_min = INPUT_A_MAX;			/* 最小値 */
	int ans_max = INPUT_A_MIN;			/* 最大値 */
	long long ans_sum = 0;					/* 合計値 100000*10000まで対応のためlong */
	int input_n = 0;
	/* 整数の個数nを入力 */
	cin >> input_n;
	
	/* 入力値の前提条件 最大・最小の制限*/
	assert (INPUT_N_MIN < input_n && input_n <= INPUT_N_MAX);
	
	int input_a;
	
	/* 計算する整数a群を入力 */
	for (int i = 0; i < input_n; i++){
		
		/* 入力値の前提条件 最大・最小の制限*/
		cin >> input_a;
		assert (INPUT_A_MIN <= input_a && input_a <= INPUT_A_MAX);
		
		/* 最大・最小値の更新判定 */
		if(input_a < ans_min){
			ans_min = input_a;		/* 最小値更新 */
		}
		if(input_a > ans_max){
			ans_max = input_a;		/* 最大値更新 */
		}
		
		/* 合計値に加算 */
		ans_sum = ans_sum + static_cast<long long>(input_a);
	}
	
	/* 出力 */
	cout << ans_min << " " << ans_max << " " << ans_sum << endl;
	
	return 0;
}


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

int main()
{
  ll x;
  cin >> x;
  
  if(x == 2){
    cout << 2 << endl;
    return 0;
  }else if(x % 2 == 0){
    x++;
  }
  
  bool flag = true;
  int ans = 0;
  for(int i = x; ;i += 2){
    for(int j = 2; j <= i/2; j++){
      if(i % j == 0){
        flag = false;
        break;
      }
    }//for
    if(flag == true){ 
      ans = i;
      break;
    }
    flag = true;
  }//for
  
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;++j){
            if(i*j==n){
                std::cout << "Yes" << std::endl;
                return 0;
            }
        }
    }
    std::cout << "No" << std::endl;
    
}


Measured memory_bytes: 3628