akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define SIZE 100000
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
class unionfind
{
public:
	int par[SIZE];
	int ran[SIZE];
	int ren[SIZE];
	void init()
	{
		for (int i = 0; i<SIZE; i++)
		{
			par[i] = i;
			ran[i] = 0;
			ren[i] = 1;
		}
	}
	int find(int a)
	{
		if (a == par[a])return a;
		else return par[a] = find(par[a]);
	}
	void unite(int a, int b)
	{
		a = find(a);
		b = find(b);
		if (a == b)return;
		if (ran[a]>ran[b])
		{
			par[b] = a;
			ren[a] += ren[b];
		}
		else
		{
			par[a] = b;
			ren[b] += ren[a];
		}
		if (ran[a] == ran[b])ran[b]++;
	}
};
unionfind uf;
int d[101010];
ll dp[5555][5555];
bool f[101010];
int main()
{
	invinit();
	uf.init();
	int num;
	scanf("%d", &num);
	int c = 0;
	for (int i = 0; i < num; i++)
	{
		scanf("%d", &d[i]);
		if (d[i] != -1)d[i]--, uf.unite(i, d[i]);
		else c++;
	}
	for (int i = 0; i < num; i++)if (d[i] == -1)f[uf.find(i)] = true;
	dp[0][0] = 1;
	for (int i = 0; i < num; i++)
	{
		for (int j = 0; j <= num; j++)dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % mod;
		if (uf.find(i) != i)continue;
		if (!f[i])continue;
		ll x = uf.ren[i] * inv[num - 1] % mod;
		for (int j = 0; j <= num; j++)dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j] * x) % mod;
	}
	ll r = 0;
	for (int i = 2; i <= num; i++)r = (r + dp[num][i] * kai[i - 1]) % mod;
	for (int i = 0; i < num; i++)if (uf.find(i) == i&&f[i])r = (r + (uf.ren[i] - 1)*inv[num - 1]) % mod;
	for (int i = 0; i < num; i++)if (uf.find(i) == i && (!f[i]))r++;
	ll ans = (num + mod - r) % mod;
	for (int i = 0; i < c; i++)ans = ans*(num - 1) % mod;
	printf("%lld\n", ans);
}

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

int toint(string s) {
    int ans = 0;
    for(char x: s) ans = ans * 10 + (x - '0');
    return ans;
}

int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    string s;
    cin>>s;
    int s1 = toint(s.substr(0,2));
    int s2 = toint(s.substr(2));
    // cout<<s1<<" "<<s2<<endl;
    // mmyy
    if(s1 >= 1 && s1 <= 12 && (s2 > 12 || s2 == 0)) cout<<"MMYY\n";
    else if(s2 >= 1 && s2 <= 12 && (s1 > 12 || s1 == 0)) cout<<"YYMM\n";
    else if(s2 >= 1 && s2 <= 12 && s1 >= 1 && s1 <= 12) cout<<"AMBIGUOUS\n";
    else cout<<"NA\n";
}

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

int main(){
  int H, W; cin >> H >> W;
  vector<vector<char>> pic(H, vector<char>(W));
  rep(i, W+2) {
    cout << "#";
    if(i == W+1) cout << endl;
  }
  rep(i, H){
    rep(j, W){
      cin >> pic.at(i).at(j);
      if(j == 0) cout << "#";
      cout << pic.at(i).at(j);
      if(j == W-1) cout << "#" << endl;
    }
  }
  rep(i, W+2) {
    cout << "#";
    if(i == W+1) cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
r,c=gets.split.map &:to_i
map=Array.new(r){Array.new}
dis=Array.new(r){Array.new(c,Float::INFINITY)} 
r.times do |i|
    map[i]=gets.chomp.split(//)
end
cnt=0
r.times do |i|
    c.times do |j|
        if map[i][j]=="#"
            cnt += 1
        end
    end
end
gy=r-1
gx=c-1
que=[]
que << [0,0]
searchy=[1,-1,0,0]
searchx=[0,0,1,-1]
dis[0][0]=0
chk="yet"
until que.empty?
    y,x=que.shift
    if chk=="yet"
        0.upto(3) do |j|
            ny=y+searchy[j]
            nx=x+searchx[j]
            if ny==gy && nx==gx
                dis[ny][nx]=[dis[ny][nx],dis[y][x]+1].min
                chk="finish"
                break
            elsif ny>=0 && nx>= 0 && ny<r && nx<c && map[ny][nx]=="." 
                que << [ny,nx]
                dis[ny][nx]=[dis[ny][nx],dis[y][x]+1].min
                map[ny][nx]="#"
            end
        end
    end
end

if chk=="yet"
    puts -1
else
    puts r*c-(cnt+dis[gy][gx]+1)
end


Measured memory_bytes: 2172
from heapq import heappush, heappop
import math
N, M = map(int, input().split())
As = list(map(int, input().split()))
q = []
for a in As:
  heappush(q, -a)
for _ in range(M):
  a = heappop(q)
  heappush(q, math.ceil(a / 2))
print(-sum(q))

Measured memory_bytes: 14536
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
#define rep(i, n) for (int i = 1; i <= (n); i++)

int gcd(int a, int b)
{
    if (a < b)
    {
        a, b = b, a;
    }
    int mod = a % b;
    if (mod == 0)
    {
        return b;
    }
    else
    {
        return gcd(b, mod);
    }
}

int main()
{
    int k;
    // scanf("%d", &x);
    cin >> k;
    // printf("%d\n", x * x * x);
    long s = 0;
    rep(i, k) rep(j, k) rep(n, k)
    {
        s += gcd(gcd(i, j), n);
    }
    cout << s << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <cmath>
#include <string>
#include <algorithm>
#include <queue>
#include <vector>
#include <functional>
#include <stack>
#include <map>
#include <utility>
#define REP(i,n) for(int i=0;i<n;++i)
using namespace std;

int main() {
  int n, x, y, c = 0;
  double d;
  cin >> n >> d;
  REP(i, n){
    cin >> x >> y;
    if (d >= sqrt(pow(x, 2) + pow(y, 2))) ++c;
  }
  cout << c << endl;
}


Measured memory_bytes: 3744
class Locate
   def initialize()
      @x=0
      @y=0
      @m=0
   end
   def go(r,s)
      @x+=r*Math.sin(Math::PI/180*@m)
      @y+=r*Math.cos(Math::PI/180*@m)
      @m+=s
   end
   def show
      return {"x"=>@x.floor,"y"=>@y.ceil}
   end
end
obj=Locate.new
loop{
   buf=gets.chop
   buf=(buf.split(",")).map{|e| e.to_i}
   if buf[0] == 0 and buf[1] == 0 then 
      break
   end
   obj.go(buf[0],buf[1])
}
   buf=obj.show
   puts(buf["x"])
   puts(buf["y"])

Measured memory_bytes: 6168
#include<stdio.h>
        int main()
        {
            double a,b;
            scanf("%lf",&a);
            scanf("%lf",&b);
     
            if(a > b){
                printf("GREATER\n");
            }else if(a == b){ 
                printf("EQUAL\n");
            }else if(a < b){
                printf("LESS\n");
            }
            return 0;
        }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define per(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#ifdef LOCAL
#define debug(x) cerr << '[' << #x << " = " << (x) << "]\n"
#else
#define debug(x)
#endif
const int maxn=1001,mod=1e9+7;
int dp[maxn][maxn];
string grid[maxn];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int h,w;cin>>h>>w;
	rep(i,0,h)cin>>grid[i];
	dp[0][0]=1;
	rep(i,0,h){
		rep(j,0,w){
			if(grid[i][j]=='#')continue;
			if(j)dp[i][j]+=dp[i][j-1];
			if(i)dp[i][j]+=dp[i-1][j];
			dp[i][j]%=mod;
		}
	}
	cout<<dp[h-1][w-1]<<'\n';
}

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

int main(){
  int x,y;
  cin>>x>>y;
  int s = 0;
  int curr;
  int result = 1;
  for(int i=0;i<x;++i){
    cin>>curr;
    s+=curr;
    if(s<=y){
      result ++;
    }
  }
  cout<<result<<endl;
  return 0;
}

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

using namespace std;

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int n,a[100],b[100],f[100];
long long Ans;
inline bool check(long long X)
{
	for(int i=1;i<=n;i++) 
	{
		memset(f,0,sizeof f);
		f[a[i]]=1;
		for(int j=49;j>=0;j--) if(X&(1ll<<j))
		{
			for(int k=0;k<=50;k++)
				f[k%(j+1)]|=f[k];
		}
		if(!f[b[i]]) return 0;
	}
	return 1;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++) b[i]=read();
	Ans=(1ll<<50)-1;
	if(!check(Ans)){puts("-1"); return 0;}
	for(int i=49;i>=0;i--)
	{
		Ans^=(1ll<<i);
		if(!check(Ans)) Ans^=(1ll<<i);
	}
	check(Ans);
	cout << (Ans<<1) << endl; return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  vector <ll> sum(n+1, 0);
  rep(i, n) sum.at(i+1) += sum.at(i)+v.at(i);
  ll ans = 0, tmp = 1;
  sort(sum.begin(), sum.end());
  rep(i, n) {
    if (i == n-1) {
      if (sum.at(i) == sum.at(i+1)) {
        tmp++;
        ans += (tmp*(tmp-1))/2;
      } else {
        if (tmp != 1) {
          ans += (tmp*(tmp-1))/2;
        }
      }
    } else {
      if (sum.at(i) == sum.at(i+1)) {
        tmp++;
      } else {
        if (tmp != 1) {
          ans += (tmp*(tmp-1))/2;
          tmp = 1;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3328
import java.io.*;
import java.util.*;
 
public class Main {
	private static InputStreamReader isr;
	private static BufferedReader br;
	public static void main(String args[]) throws IOException{
	    isr = new InputStreamReader(System.in);
		br = new BufferedReader(isr);
		int c;
		while ((c = getint() ) > 0){
		    int[] arr = getData(c);
            Arrays.sort(arr);
            System.out.println( averageP(arr) );
        }
	}
	private static int getint(){
	    try{
	        int n = 0;
			String buf = br.readLine();
			n = Integer.parseInt(buf);
			return n;
		}catch(Exception e){
		    return -1;
		}
	}
	private static int[] getData(int n){
	    try{
    	    int[] r = new int[n];
    	    for(int i=0; i<n; i++){
    	        r[i] = Integer.parseInt(br.readLine());
    	    }
    	    return r;
	    }catch(Exception e){
	        System.err.println("List Length Error");
	        return new int[]{};
	    }
	}
	private static int averageP(int[] r){
	    if(r.length > 2){
	        int sum = 0;
	        for(int i=1; i<(r.length-1); i++){
	            sum += r[i];
	        }
	        sum = sum / (r.length - 2);
	        return sum;
	    }else{
	        return 0;
	    }
	}
}

Measured memory_bytes: 24288
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a =sc.nextInt();
		int b =sc.nextInt();
		if(a%2 == 1 && b%2==1){
			System.out.println("Odd");
		}else{
			System.out.println("Even");
		}
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
// increment
#define rep_n(_1, _2, _3, NAME,...) NAME
#define rep_2(i, n) for(int i = 0; i < (int)(n); ++i)
#define rep_3(i, initial, n) for(int i = (int)(initial); i < (int)(n); ++i)
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME,...) NAME
#define rep_r_2(i, n) for(int i = (int)(n); i > 0; i--) 
#define rep_r_3(i, initial, n) for(int i = (int)(initial); i > (int)(n); i--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

	ll sum = 0;
	vector<int> A(N, 0);

	int b = 0;
	repeat(i, N) {
		int a = 0;
		cin >> a;

		sum += abs(a - b);
		b = a;
		A[i] = a;
	}

	sum += abs(b - 0);


	ll result = 0;
	int prev = 0;
	int next = 0;
	repeat(i, N) {
		prev = (i == 0) ? 0 : A[i-1];
		next = ((i+1) == N) ? 0 : A[i+1]; 

		ll a = abs(prev - A[i]);
		ll b = abs(A[i] - next);
		ll c = abs(next - prev);
		result = sum - (a + b) + c;

		cout << result << endl;
	}
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
using namespace std;
int main() {
	int N;
	double X = 0;
	cin >> N;
	vector<double> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v.at(i);
		X += 1/v.at(i);
	}
	cout << 1 / X << endl;
	return 0;
}

Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n, m; cin >> n >> m;
  vector<vector<int>> G(n);
  for(int i = 0; i < m; i++){
    int a, b; cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  if(m % 2 == 1){
    cout << -1 << endl;
    return 0;
  }

  vector<pair<int, int>> ans;
  vector<int> depth(n, -1), deg(n, 0);
  function< void(int,int) > dfs =
  [&](int u, int pre){
    for(int v : G[u]){
      if(depth[v] == -1){
        depth[v] = depth[u] + 1;
        dfs(v, u);
      }else{
        if(depth[v] > depth[u]){
          ans.emplace_back(u, v);
          deg[u]++;
        }
      }
    }
    if(pre == -1) return;
    if(deg[u] % 2 == 1){
      ans.emplace_back(u, pre);
      deg[u]++;
    }else{
      ans.emplace_back(pre, u);
      deg[pre]++;
    }
  };
  depth[0] = 0;
  dfs(0, -1);
  for(auto p : ans){
    cout << p.first+1 << " " << p.second+1 << endl;
  }

  return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    int N; cin>>N;
    vector<ll> A(N); rep(i,N)cin>>A.at(i);
    vector<ll> B(N-1); rep(i,N-1)B.at(i) = A.at(i)^A.at(i+1);//a[i] xor a[i+1];
    ll X = 0;
    for(int i = 2; i < N-1; i += 2) X ^= B.at(i);
    N /= 2;
    rep(i,N){
        cout<<(A.at(2*i+1)^X)<<" ";
        cout<<(A.at(2*i)^X);
        if(i!=N-1)cout<<" ";
        else cout<<endl;
        if(i!=N-1)X ^= B.at(2*i)^B.at(2*i+2);
    }
}


Measured memory_bytes: 6236
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
using namespace std;
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (; isdigit(c); c = getchar())
		x = x * 10 + c - 48;
	return x * f;
}
string s, ss;
int k;
int main() {
	cin >> k;
	cin >> s;
	if (k >= s.size()) {
		cout << s << endl;
		return 0;
	}
	ss.assign(s, 0, k);
	s = "...";
	ss += s;
	cout << ss << endl;
	return 0;
}

Measured memory_bytes: 3640
n, *b = $stdin.readline.chomp.split.map(&:to_i)
b.unshift(0)
l = Array.new(n) { $stdin.readline.to_i }

res = 10 ** 4
(1 << (2 * n)).times do |bit|
  d = Array.new(4, 0)
  cnt = Array.new(4, 0)
  n.times do |i|
    d[(bit >> (2 * i)) & 3] += l[i]
    cnt[(bit >> (2 * i)) & 3] += 1
  end
  
  next if cnt[1..3].any? {|x| x == 0 }
  mp = (1..3).to_a.inject(0) {|acc, j| acc + 10 * (cnt[j] - 1) + (b[j] - d[j]).abs }
  res = [res, mp].min
end
puts res

Measured memory_bytes: 14380
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
	string s;
	cin>>s;
	int count=0,ans=0;
	char s1=s[0];
	char s2=s[1];
	char s3=s[2];
	if(s1=='R' && s2=='R' && s3=='R')
	{
		ans=3;
	}
	else if((s1=='R' && s2=='R') ||(s2=='R' && s3=='R'))
	{
		ans=2;
	}
	else if(s1=='R' || s2=='R' || s3=='R')
	{
		ans=1;
	}
	else
	{
		ans=0;
	}
/*	for(int i=0;i<3;i++)
	{
		if(s[i]=='R')
		{
			count++;
		}
		else
		{
			ans=max(count,ans);
			count=0;
		}
	}*/
	cout<<ans;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
//unionfind
int main()
{
    int M, K;
    cin >> M >> K;
    if (M == 0)
    {
        if (K == 0)
        {
            cout << "0 0" << endl;
            return 0;
        }
        else
        {
            cout << -1 << endl;
            return 0;
        }
    }
    if (M == 1)
    {
        if (K == 0)
        {
            cout << "0 0 1 1" << endl;
            return 0;
        }
        else
        {
            cout << -1 << endl;
            return 0;
        }
    }
    int N = 1 << M;
    if (N <= K)
    {
        cout << -1 << endl;
        return 0;
    }

    for (int i = N - 1; i >= 0; i--)
    {
        if (i != K)
            cout << i << " ";
    }
    cout << K << " ";
    for (int i = 0; i < N; i++)
    {
        if (i != K)
            cout << i << " ";
    }
    cout << K << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;

string r="qwertasdfgzxcvb";
string l="yuiophjklnm";

bool serch(string str,char ch){
	rep(i,str.size()){
		if(str[i]==ch) return true;
	}
	return false;
}

int main(){
	while(1){
		string str;
		cin >>str;
		if(str=="#")break;
		int flag=-1;//1??????,0??????
		int ans=0;
		if(serch(r,str[0])) flag=1;
		else flag=0;

		for(int i=1;i<str.size();i++){
			if(serch(r,str[i])&&flag==0){
				ans++;
				flag=1;
			}else if(serch(l,str[i])&&flag==1){
				ans++;
				flag=0;
			}	
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1196
N, D = map(int, input().split())
D = D*D
c = 0
answer = [input().split() for i in range(N)]
for i in range(N):
    a = int(answer[i][0])
    b = int(answer[i][1])
    if ((a*a+b*b) <= D):
        c += 1
print(c)

Measured memory_bytes: 67640
// #define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto&& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto&& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template <size_t N>
class sieve_of_eratosthenes {
    std::bitset<N> is_prime_;

  public:
    constexpr sieve_of_eratosthenes(){
      is_prime_ = ~is_prime_;
      is_prime_.reset(0), is_prime_.reset(1);
      for (size_t p = 2; p < N; p++) {
        if (!is_prime_.test(p)) continue;
        for (size_t j = 2; j * p < N; j++) {
          is_prime_.reset(p * j);
        }
      }
    }

    // Return the bitset testing if a number is prime.
    constexpr const auto& is_prime() const {return is_prime_;}

    // Returns the vector of prime numbers.
    template <typename T>
    auto primes() const {
      std::vector<T> primes{}; 
      for (size_t i = 0; i < N; i++) {
        if (is_prime_.test(i)) primes.push_back(i);
      }
      return primes;
    }
};

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  sieve_of_eratosthenes<1'000'000> soe;
  auto isp = soe.is_prime();

  int n; std::cin >> n;
  while (true) {
    if (isp.test(n)) break;
    n++;
  }
  std::cout << n << std::endl;
  return 0;
}

Measured memory_bytes: 768
# coding: utf-8
# Your code here!
H,W = [int(i) for i in input().split()]
c=[[int(i) for i in input().split()] for _ in range(10)] 
A=[[int(i) for i in input().split()] for _ in range(H)]


dist = c
n=10
#n: 頂点数
for k,dk in enumerate(dist):
    for di in dist:
        for j in range(n):
            if di[j] > di[k]+ dk[j]:
                di[j] = di[k]+ dk[j]


ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] != -1:
            ans += dist[A[i][j]][1]
print(ans)     



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

int main(void)
{
    int i, N, T, A;
    scanf("%d", &N);
    int x, count;
    double temp;
    scanf("%d %d", &T, &A);
    for(i=1;i<N+1;i++){
        scanf("%d", &x);
        if(i==1){
            temp = T-x*0.006;
            count = i;
        }
        if(abs((T-x*0.006)-A) < abs(temp-A)){
            temp = T-x*0.006;
            count = i;
        }
    }
    printf("%d\n", count);
}

Measured memory_bytes: 256
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = 3005;

int n;
long double res, p[N], dp[N][N];

int main() {
  init_ios();
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i];
    if (i == 1) {
      dp[i][0] = 1-p[i];
      dp[i][1] = p[i];
      continue;
    }
    dp[i][0] = dp[i-1][0]*(1-p[i]);
    for (int j = 1; j <= i; ++j)
      dp[i][j] = dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
  }
  for (int i = (n+1)/2; i <= n; ++i)
    res += dp[n][i];
  cout<<fixed<<setprecision(13)<<res<<"\n";
}

Measured memory_bytes: 139392
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	long h, w, n;
	Set<P> set;
	int[][] dx, dy;

	class P implements Comparable<P> {
		int x, y;

		P(int x, int y) {
			this.x = x;
			this.y = y;
		}

		@Override
		public int compareTo(P o) {
			if (this.x != o.x) {
				return this.x - o.x;
			}
			return this.y - o.y;
		}

		@Override
		public String toString() {
			return "(" + x + "," + y + ")";
		}
	}

	void dxy() {
		dx = new int[][] {
			{ -2, -1, 0, -2, -1, 0, -2, -1 },
			{ -1, 0, 1, -1, 0, 1, -1, 1 },
			{ 0, 1, 2, 0, 1, 2, 1, 2 },
			{ -2, -1, 0, -2, -1, -2, -1, 0 },
			{ -1, 0, 1, -1, 1, -1, 0, 1 },
			{ 0, 1, 2, 1, 2, 0, 1, 2 },
			{ -2, -1, -2, -1, 0, -2, -1, 0 },
			{ -1, 1, -1, 0, 1, -1, 0, 1 },
			{ 1, 2, 0, 1, 2, 0, 1, 2 },
		};
		dy = new int[][] {
			{ -2, -2, -2, -1, -1, -1, 0, 0 },
			{ -2, -2, -2, -1, -1, -1, 0, 0 },
			{ -2, -2, -2, -1, -1, -1, 0, 0 },
			{ -1, -1, -1, 0, 0, 1, 1, 1 },
			{ -1, -1, -1, 0, 0, 1, 1, 1 },
			{ -1, -1, -1, 0, 0, 1, 1, 1 },
			{ 0, 0, 1, 1, 1, 2, 2, 2 },
			{ 0, 0, 1, 1, 1, 2, 2, 2 },
			{ 0, 0, 1, 1, 1, 2, 2, 2 },
		};
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		h = sc.nextInt();
		w = sc.nextInt();
		n = sc.nextInt();
		set = new TreeSet<P>();
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			set.add(new P(b, a));
		}

		dxy();

		long[] ans = new long[10];
		for (P p : set) {
			L: for (int i = 0; i < 9; i++) {
				List<P> list = new LinkedList<P>();
				for (int j = 0; j < 8; j++) {
					int nx = p.x + dx[i][j];
					int ny = p.y + dy[i][j];
					P np = new P(nx, ny);
					if (nx < 0 || w <= nx || ny < 0 || h <= ny) {
						continue L;
					}
					if (!set.contains(np)) {
						continue;
					}
					if (np.compareTo(p) < 0) {
						continue L;
					}
					//					System.out.println(p + ": " + np);
					list.add(np);
				}
				//				System.out.println();
				ans[list.size() + 1]++;
			}
		}
		ans[0] = (h - 2) * (w - 2);
		for (int i = 1; i < 10; i++) {
			ans[0] -= ans[i];
		}

		for (int i = 0; i < 10; i++) {
			System.out.println(ans[i]);
		}
	}

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


Measured memory_bytes: 28212
let x, y, d, z = Scanf.scanf " %d %d" @@ fun a b -> a, b, abs b - abs a, ref a
let c = if d < 0 then (z := -(abs x + d); if x < 0 then -d else -d + 1) else if d > 0 then (z := abs x + d; if x < 0 then d + 1 else d) else 0
let _ = Printf.printf "%d\n" @@ if !z = y then c else c + 1

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

int main(int argc, char const *argv[])
{
    int n;cin>>n;
    vector<int> w(n);
    for (int i=0;i<n;i++){
        cin>>w[i];
    }
    int s1,s2;
    int ret=10000;
    vector<int> p_sum(n,0);
    p_sum[0]=w[0];
    for(int i=1;i<n;i++){
        p_sum[i]=w[i]+p_sum[i-1];
    }
    for(int i=0;i<n;i++){
        ret = min(ret, abs(p_sum[n-1] - p_sum[i]*2));
    }
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
import bisect
import math
n =  int(input().strip())
nums  = list(map(int, input().strip().split(' ')))
sortedNums = sorted(nums)
x = sortedNums[-1]
insert_index  = bisect.bisect_left(sortedNums,int(x/2))
if insert_index == 0: y = sortedNums[0]
else:
    if x/2 - sortedNums[insert_index-1] > sortedNums[insert_index]-x/2: y = sortedNums[insert_index]
    else: y = sortedNums[insert_index - 1]
if n==2: y=sortedNums[0]
print(x,y)


Measured memory_bytes: 14184
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> X;
    for(int i =0; i <= 9; i++) X.push_back(i) ;
    for(int i = 0; i <= 9; i++){
        for(int j = 0; j < 10; j++){
            if(X[i] * X[j] == N){
                cout << "Yes" << endl;
                goto label;
            }
        }
    }
    cout << "No" << endl;
    label:
     return 0;
}

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

using namespace std;

int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  if (a <= 0 && b >= 0) {
    puts("Zero");
  } else if (b < 0) {
    puts(((b - a + 1) & 1) ? "Negative" : "Positive");
  } else {
    puts("Positive");
  }
  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
g = Array.new(n){ [] }
(n-1).times do
  a,b = gets.split.map(&:to_i)
  a -= 1; b -= 1
  g[a] << b
  g[b] << a
end

c = gets.split.map(&:to_i).sort.reverse.each
seen = Array.new(n, -1)
ans = 0

_, sv = g.each_with_index.max_by{|v,i|v.size}
que = [[sv,0]]
while que.size > 0
  v, pre = que.pop
  next if seen[v] != -1
  now = c.next
  seen[v] = now
  ans += pre < now ? pre : now
  g[v].each do |nv|
    que << [nv, now]
  end
end

puts ans
puts seen.join(" ")


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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);
  vector<int> count(n);
  for(int i=0; i<m; i++){
    cin >> a[i] >> b[i];
    for(int j=0; j<n; j++){
      if(a[i]==j+1 || b[i]==j+1)
        count[j]++;
    }
  }
  for(int j=0; j<n; j++){
    cout << count[j] << endl;
  }
  
}

Measured memory_bytes: 256
//#pragma GCC optimize(2)
//ÄÏ¾©ÊÐµÚÈýÇøOIÎ¯ÌáÐÑÄú£º
//´úÂëÇ§ÍòÌõ£¬-O2µÚÒ»Ìõ¡£
//-O2²»¹æ·¶£¬³¬Ê±Á½ÐÐÀá¡£
// Happy TLE and WA every day!
// by: zxb
#include<bits/stdc++.h>
#define mp              make_pair
#define rep(i,n)        for(int i = 0; i < n; i++)
#define foreach(i,c)    for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define BINF            0x7fffffff
#define INF             0x3f3f3f3f
#define LINF            4557430888798830399
#define pb              push_back
#define F               first
#define S               second
#define Time            clock()/CLOCKS_PER_SEC
#define read            ZXBs_fast_input
#define write           ZXBs_fast_output
//#define usingFiles
using namespace std;

typedef unsigned int ui;
typedef pair<int, int> pii;
typedef long long ll;

inline bool read(int& x){
	x = 0;
	int c;
	int sign = 1;
	while( (c = getchar()) < '0' || c > '9' ) if(c == '-') sign = -1;
	x = c ^ '0';
	while( (c = getchar()) >= '0' && c <= '9' ) x = (x<<3) + (x<<1) + (c ^ '0');
	x *= sign;
	return 1;
}

inline bool write(int x){
	if(x >= 10) write(x / 10);
	putchar(x % 10 + '0');
	return 1;
}

const int rp = 666666;
const bool debug = 1;
const bool I_good_vegetable_a = 1;

// 8/15

int k;
string s;
int num = 0;

signed main(){
	ios::sync_with_stdio(false);
	#ifdef usingFiles
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	cin >> s;
	rep(i, s.size()){
		num += (s[i] == 'x');
	}
	if(num < 8) cout << "YES\n";
	else cout << "NO\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
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; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

// 二項係数計算
long long com(ll n){
    ll k = 2;
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return n*(n-1)/2;
}

int main()
{

    ll N;
    cin >> N;
    vector<ll> A;
    ll same[200005] = {};
    int done[200005] = {};

    for(ll i=0; i<N; ++i)
    {
        ll tmp;
        cin >> tmp;
        A.push_back(tmp);
        ++same[tmp];
    }

    ll all = 0;
    for(ll i=0; i<N; ++i)
    {
        if(done[A[i]]==1) continue;
        else
        {
            done[A[i]] = 1;
            all += com(same[A[i]]);
        }
    }

    for(ll i=0; i<N; ++i)
    {
        cout << all - com(same[A[i]]) + com(same[A[i]]-1) << endl;
    }

    return 0;
}


Measured memory_bytes: 6640
#include <iostream>
#include <limits>

using namespace std;


int main() {
    
    int h, w;
    
    while (cin >> h >> w)
    {
        if (h == 0 && w == 0)
            break;

        for (int y = 0; y < h; ++y)
        {
            for (int x = 0; x < w; ++x)
            {
                cout << '#';
            }
            cout << endl;
        }

        cout << endl;
    }

    return 0;
} 

Measured memory_bytes: 3100
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 105;
char in[maxn];
int main() {
    long long k;
    scanf("%s%lld", in, &k);
    int len = strlen(in);
    int f = 1, m = 0, b = 0;
    for (int i = 1; i < len; i++)
        if (in[i] == in[i - 1]) f++;
        else break;
    for (int i = len - 1; i > f; i--)
        if (in[i] == in[0]) b++;
        else break;
    for (int i = f + 1; i < len - b; i++)
        if (in[i] == in[i - 1])
            m++, in[i] = '#';
    // printf("%d %d %d\n", f, m, b);
    if (f == len) printf("%lld", (f * k) >> 1);
    else printf("%lld", k * m + (k - 1) * ((f + b) >> 1) + (f >> 1) + (b >> 1));
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(){
	int N, D;
	while(cin >> N >> D){
		vector<long long> d(N);
		for(int i=0;i<N;i++) cin >> d[i];
		vector<long long> A(N+1);
		vector<long long> B(N+1);
		A[0] = D;
		for(int i=0;i<N;i++){
			A[i+1] = min(A[i], (long long)abs(A[i] - d[i]));
		}
		B[N] = 1;
		for(int i=N-1;i>=0;i--){
			B[i] = B[i+1] + (d[i] < 2*B[i+1] ? d[i] : 0);
		}
		int Q; cin >> Q;
		for(int i=0;i<Q;i++){
			int q; cin >> q;
			cout << (A[q-1] >= B[q] ? "YES" : "NO") << endl;
		}
	}
}



Measured memory_bytes: 13696
#include<bits/stdc++.h>
using namespace std;
int go(vector<vector<int> >a,int n){
	vector<vector<int> >dp(n+1,vector<int>(3,0));
	dp[1][0]=a[1][0];
	dp[1][1]=a[1][1];
	dp[1][2]=a[1][2];
	for(int i=2;i<=n;i++){
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+a[i][2];
	}
	return max(dp[n][0],max(dp[n][1],dp[n][2]));
}
int main(){
	int n;
	cin>>n;
	vector<vector<int> >a(n+1,vector<int>(3,0));
	for(int i=1;i<=n;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	cout<<go(a,n);
}

Measured memory_bytes: 19608
//Schedule
#include <iostream>

using namespace std;
static const int MOD = 10007;

enum MEMBER {
    J = 0,
    O = 1,
    I = 2
};

int main() {
    int N;
    cin >> N;
    int S[N][8];
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < 8; j++) {
            S[i][j] = 0;
        }
    }

    char c;
    for(int i = 0; i < N; i++) {
        cin >> c;
        if(i == 0) {
            if(c == 'J') {
                S[i][1] = 1;
                S[i][3] = 1;
                S[i][5] = 1;
                S[i][7] = 1;
            } else if(c == 'O') {
                S[i][3] = 1;
                S[i][7] = 1;
            } else if(c == 'I') {
                S[i][5] = 1;
                S[i][7] = 1;
            }
        } else {
            if(c == 'J') {
                S[i][1] = (S[i - 1][1] + S[i - 1][3] + S[i - 1][5] + S[i - 1][7]) % MOD;
                S[i][3] = (S[i - 1][1] + S[i - 1][2] + S[i - 1][3] + S[i - 1][5] + S[i - 1][6] + S[i - 1][7]) % MOD;
                S[i][5] = (S[i - 1][1] + S[i - 1][3] + S[i - 1][4] + S[i - 1][5] + S[i - 1][6] + S[i - 1][7]) % MOD;
                S[i][7] = (S[i - 1][1] + S[i - 1][2] + S[i - 1][3] + S[i - 1][4] + S[i - 1][5] + S[i - 1][6] + S[i - 1][7]) % MOD;
            } else if(c == 'O') {
                S[i][2] = (S[i - 1][2] + S[i - 1][3] + S[i - 1][6] + S[i - 1][7]) % MOD;
                S[i][3] = (S[i - 1][1] + S[i - 1][2] + S[i - 1][3] + S[i - 1][5] + S[i - 1][6] + S[i - 1][7]) % MOD;
                S[i][6] = (S[i - 1][2] + S[i - 1][3] + S[i - 1][4] + S[i - 1][5] + S[i - 1][6] + S[i - 1][7]) % MOD;
                S[i][7] = (S[i - 1][1] + S[i - 1][2] + S[i - 1][3] + S[i - 1][4] + S[i - 1][5] + S[i - 1][6] + S[i - 1][7]) % MOD;
            } else if(c == 'I') {
                S[i][4] = (S[i - 1][4] + S[i - 1][5] + S[i - 1][6] + S[i - 1][7]) % MOD;
                S[i][5] = (S[i - 1][1] + S[i - 1][3] + S[i - 1][4] + S[i - 1][5] + S[i - 1][6] + S[i - 1][7]) % MOD;
                S[i][6] = (S[i - 1][2] + S[i - 1][3] + S[i - 1][4] + S[i - 1][5] + S[i - 1][6] + S[i - 1][7]) % MOD;
                S[i][7] = (S[i - 1][1] + S[i - 1][2] + S[i - 1][3] + S[i - 1][4] + S[i - 1][5] + S[i - 1][6] + S[i - 1][7]) % MOD;
            }
        }
    }

    int combination = 0;
    for(int j = 1; j < 8; j++) {
        combination += S[N - 1][j];
    }

    cout << (combination % MOD) << endl;
}


Measured memory_bytes: 3112
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
   input!{x:i64, a:i64, b:i64};
   println!("{}", if (x-a).abs() < (x-b).abs() {"A"} else {"B"});
}


Measured memory_bytes: 4352
#include <iostream>
#include <math.h>
using namespace std;

int main() {
//    freopen("in.txt", "r", stdin);

    double x1,x2,y1,y2;
    double result;
    cin >> x1 >> y1 >> x2 >> y2;
    result = sqrt(pow(x1-x2, 2)+pow(y1-y2, 2));
    printf("%.4lf", result);
}

Measured memory_bytes: 3284
object Main extends App {
  val Array(n, k) = scala.io.StdIn.readLine.split(" ").map{_.toLong}
  def cube(l: Long) = l * l * l
  println(cube(n / k) + (if ((k & 1) == 1) 0 else cube((n + k / 2) / k)))
}

Measured memory_bytes: 27168
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
//long long mo = 1e9 + 7;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll K;
    string S;
    cin >> K;
    ll sum = 0;
    for(ll a=1; a<=K; a++)for(ll b=1; b<=K; b++)for(ll c=1; c<=K; c++){
       sum += __gcd(ll(__gcd(a,b)),c);
    }
    cout << sum <<endl;
}

Measured memory_bytes: 3628
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	Scanner sc=new Scanner (System.in);
	int a=sc.nextInt();
	int b=sc.nextInt();
	int c=sc.nextInt();
	System.out.println(c+" "+a+" "+b);
		
	}

}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
vector <P> ans;
string str;
 
int main(){
  ll anssum=0,anssize=0;
  ll maxH,nowH,cnt,maxW;
  cin>>str;
  maxH=nowH=20000LL;
  cnt=0;
 
  for(int i=0;i<(int)str.size();i++){
 
    if(str[i]=='/'){
      nowH++;
      if(maxH==nowH){
    cnt++;
    ans.push_back(P(i,cnt/2));
    cnt=0;
      }else if(maxH<nowH){
    maxH=nowH;
      }else{
    cnt+=(maxH-nowH)*2+1;
      }
       
    }else if(str[i]=='_'){
 
      if(maxH>nowH){
    cnt+=(maxH-nowH)*2;
 
      }
    }else{
 
      nowH--;
      if(maxH>nowH){
    cnt+=(maxH-nowH)*2-1;
      }
 
    }
  }
   
  maxH=nowH=20000LL;
  maxW=(int)str.size()-1;
 
  cnt=0;
 
  for(int i=(int)str.size()-1;i>=0;i--){
    if(str[i]=='\\'){
      nowH++;
      if(maxH==nowH){
    cnt++;
    ans.push_back(P(maxW,cnt/2));
    cnt=0;
      }else if(maxH<nowH){
    maxH=nowH;
    maxW=i;
      }else{
    cnt+=(maxH-nowH)*2+1;
      }
    }else if(str[i]=='_'){
      if(maxH>nowH){
    cnt+=(maxH-nowH)*2;
     
      }else if(maxH==nowH){
    maxW=i;
      }
    }else{
      if(nowH==maxH)maxW=i;
      nowH--;
      if(maxH>nowH){
    cnt+=(maxH-nowH)*2-1;
      }
    }
  }
 
  sort(ans.begin(),ans.end());
  anssum=anssize=0;
  for(int i=0;i<(int)ans.size();i++){
    if(i>0&&ans[i-1]==ans[i])continue;
    anssum+=ans[i].second;
    anssize++;
  }
   
  cout<<anssum<<endl;
  cout<<anssize;
  for(int i=0;i<(int)ans.size();i++){
    if(i>0&&ans[i-1]==ans[i])continue;
    cout<<' '<<ans[i].second;
  }
  cout<<endl;
}


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

#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;

int main(int argc, char *argv[]) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    Yn((abs(a-b) <= d && abs(b-c) <= d) || abs(a-c) <= d)

    return 0;
}


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

static ArrayList<Integer[]> list=new ArrayList<>();
static ArrayList<Integer[]> set=new ArrayList<>();


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

//   String nyuA=sc.nextLine();
 //  String nyuB=sc.nextLine();
 
    String[] s=sc.nextLine().split(" ");
//     String[] e=sc.nextLine().split(" ");

//int N=Integer.parseInt(nyuA);

int H=Integer.parseInt(s[0]);
int W=Integer.parseInt(s[1]);


String[][] num=new String[H][W];
int[][] min=new int[H][W];

for(int i=0;i<H;i++){
num[i]=sc.nextLine().split("");
}

for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
if(num[i][j].equals("#"))min[i][j]=24;
else{
int count=0;
for(int k=-1;k<=1;k++){
for(int l=-1;l<=1;l++){
try{
if(num[i+k][j+l].equals("#") && !(k==0 && l==0)){
count++;
}

}catch(Exception e){}

}
}
min[i][j]=count;

}//else

}}


for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
if(min[i][j]==24)
System.out.print("#");
else
System.out.print(min[i][j]);

//if(j!=W-1)System.out.print(" ");
}
System.out.println();
}


	}

}

Measured memory_bytes: 23380
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #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 rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define bit(n) (1LL<<(n))
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main(){
    int n,z,w; cin >> n >> z >> w;
    vi a(n); rep(i,n) cin >> a[i];
    if(n==1){
        cout << abs(a[0]-w) << '\n';
    } else {
        cout << max(abs(a[n-1]-w),abs(a[n-1]-a[n-2])) << '\n';
    }
    

    

}

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

using namespace std;

int main(void){
    int a=0;
    int b=0;
    string op;

    cin >> a >> op >> b;

    if(op=="+")cout << a+b << endl;
    else if(op=="-")cout << a-b << endl;

    return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  int ans = 0;
  for (int i = 0; i < k; i++) {
    ans += p[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned ui;
typedef unsigned long long ul;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef pair<bool, bool> pbb;
typedef vector<int> vi;
#define pb push_back
#define fi first
#define se second
#define mid ((l + r) >> 1)
#define ls (i << 1)
#define rs (i << 1 | 1)
#define enum(i, j, k) for(int i = j; i <= k; i ++)
#define open(i, j, k)  for(int i = j; i <  k; i ++)
#define dec(i, j, k)  for(int i = j; i >= k; i --)
#define ae(x) for(node *p = h[x]; p; p = p->nxt)
template <class T> bool chkmin(T &x, T y)
{ return y < x ? x = y , true : false; }
template <class T> bool chkmax(T &x, T y)
{ return y > x ? x = y , true : false; }
void __init()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(16);
    srand(time(0) ^ ui(ul(new char)));
}
/* default code ends here */
#define mod 1000000007
int n;
string s;
int tot[26];
int main()
{
    __init();
    cin >> n >> s;
    for(char c : s)
        tot[c - 'a'] ++;
    ll ans = 1;
    open(i, 0, 26)
        ans = ans * (tot[i] + 1) % mod;
    cout << ans - 1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> flag(H);
    REP(y, H) cin >> flag[y];
    string mark[2];
    REP(i, 2) cin >> mark[i];

    int base = 0;
    REP(y, H - 1) REP(x, W - 1){
        int cnt = 0;
        REP(dy, 2) REP(dx, 2) cnt += flag[y + dy][x + dx] == mark[dy][dx];
        if(cnt == 4) base++;
    }

    string JOI = "JOI";
    int max_diff = 0;
    REP(y, H) REP(x, W) for(char c : JOI) {
        int diff = 0;
        REP(sdy, 2) REP(sdx, 2) {
            int sy = y - sdy;
            int sx = x - sdx;
            if(sx >= 0 && sx + 1 < W && sy >= 0 && sy + 1 < H) {
                int cnt = 0;
                REP(dy, 2) REP(dx, 2) cnt += flag[sy + dy][sx + dx] == mark[dy][dx];
                if(cnt == 4) diff--;
            }
        }
        char tmp = flag[y][x];
        flag[y][x] = c;
        REP(sdy, 2) REP(sdx, 2) {
            int sy = y - sdy;
            int sx = x - sdx;
            if(sx >= 0 && sx + 1 < W && sy >= 0 && sy + 1 < H) {
                int cnt = 0;
                REP(dy, 2) REP(dx, 2) cnt += flag[sy + dy][sx + dx] == mark[dy][dx];
                if(cnt == 4) diff++;
            }
        }
        flag[y][x] = tmp;
        max_diff = max(max_diff, diff);
    }
    cout << base + max_diff << endl;

    return 0;
}

Measured memory_bytes: 2052
n=int(input())
s=input()
leng=len(s)
slist=[]
#print(slist)
alphabet=["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
#print(alphabet)
for i in range(0,leng):
    for j in range(0,26):
#        print(s[i])
#        print(alphabet[j])
        if s[i]==alphabet[j]:
            #print(j)
            slist.append(alphabet[j+n])
            #print(alphabet[j+n])
            #print(slist[i])

print(''.join(slist))


Measured memory_bytes: 3188