akhauriyash/Code-Regression huggingface dataset:
n=int(input())
d_list = list(map(int,input().split()))
sum_all = 0
for i in range(n):
    for j in range(n):
        sum_all += d_list[i] * d_list[j]
sum_diff = 0
for k in range(n):
    sum_diff += d_list[k] * d_list[k]
print((sum_all - sum_diff) // 2)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int  main(){
    long long int  n,w;
    cin>>n>>w;
    vector<int>c(n),v(n);
    for(long long int  i=0;i<n;i++)
    {
        cin>>c[i]>>v[i];
    }
    vector<vector<long long int>>dp(n+1,vector<long long int>(w+1));
    for(long long int   i=0;i<=w;i++){
        dp[0][i]=0;
    }
    for(long long int  i=1;i<=n;i++)
    {
        long long int  weight=c[i-1];
        long long int  value=v[i-1];
        for(long long int  j=0;j<w+1;j++)
        {
            if(j>=weight){
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-weight]+value);
            }
            else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[n][w];
}

Measured memory_bytes: 83120
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define mp make_pair
#define pb push_back
#define mod 1000000007

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int k,x;
	cin>>k>>x;
	for(int i=x-k+1;i<x+k;i++)
	{
		cout<<i<<" ";
	}
return 0;
}



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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int h, w;
  cin >> h >> w;
  
  vector<vector<char>> a(h, vector<char>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a.at(i).at(j);
    }
  }
  
  vector<vector<char>> x(h, vector<char>(w, '.')), y(h, vector<char>(w, '.'));
  for (int j = 0; j < w; j++) {
    x.at(0).at(j) = '#';
    y.at(h - 1).at(j) = '#';
  }
  for (int i = 1; i < h - 1; i++) {
    for (int j = 0; j < w; j++) {
      if (j % 2 == 0) x.at(i).at(j) = '#';
      else y.at(i).at(j) = '#';
    }
  }
  
  for (int i = 1; i < h - 1; i++) {
    for (int j = 1; j < w - 1; j++) {
      if (a.at(i).at(j) == '#') {
        x.at(i).at(j) = '#';
        y.at(i).at(j) = '#';
      }
    }
  }
  
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << x.at(i).at(j);
    }
    cout << '\n';
  }
  cout << '\n';
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << y.at(i).at(j);
    }
    cout << '\n';
  }
}

Measured memory_bytes: 1536
#include <stdio.h>

enum ACGT {
	A, C, G, T
};

#define LEN 100

int NG(int x, int y, int z) {
	return (x == A && y == G && z == C);
}

int FLAT(int x, int y, int z) {
	return (x * 4 + y) * 4 + z;
}

#define MOD 1000000007

int X[LEN+1][64];
int main() {
	int N;
	scanf("%d\n", &N);

	for (int i1 = 0; i1 < 4; i1++)
	for (int i2 = 0; i2 < 4; i2++)
	for (int i3 = 0; i3 < 4; i3++) {
		if (NG(i1, i2, i3)) continue;
		if (NG(i2, i1, i3)) continue;
		if (NG(i1, i3, i2)) continue;

		X[3][FLAT(i1, i2, i3)] = 1;
	}

	for (int i = 4; i <= N; i++) {
		for (int i1 = 0; i1 < 4; i1++)
		for (int i2 = 0; i2 < 4; i2++)
		for (int i3 = 0; i3 < 4; i3++)
		for (int i4 = 0; i4 < 4; i4++) {
			if (NG(i2, i3, i4)) continue;
			if (NG(i3, i2, i4)) continue;
			if (NG(i2, i4, i3)) continue;

			if (NG(i1, i3, i4)) continue;
			if (NG(i1, i2, i4)) continue;

			X[i][FLAT(i2, i3, i4)] += X[i - 1][FLAT(i1, i2, i3)];
			X[i][FLAT(i2, i3, i4)] %= MOD;
		}
	}
	int sum = 0;
	for (int i1 = 0; i1 < 4; i1++)
	for (int i2 = 0; i2 < 4; i2++)
	for (int i3 = 0; i3 < 4; i3++) {
		sum += X[N][FLAT(i1, i2, i3)];
		sum %= MOD;
	}
	printf("%d\n", sum);
}


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

using vi = vector<int>;
using vvi = vector<vi>;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i=0; i<(int)n; i++)
using vb = vector<bool>;

int main(){
  int N,M;
  cin>>N>>M;
  vvi G(N);
  int x,y,z;
  rep(i,M){
    cin>>x>>y>>z;
    x--;y--;
    G[x].pb(y);
    G[y].pb(x);
  }

  int renketu = 0;
  vb checked(N, false);
  for(int i=0; i<N; i++){
    if(checked[i])continue;
    queue<int> que;
    que.push(i);

    while(!que.empty()){
      int now = que.front();
      que.pop();

      if(!checked[now]){
        checked[now] = true;
        for(int next: G[now]){
          que.push(next);
        }
      }
    }
    renketu++;
  }

  cout<<renketu<<endl;
}

Measured memory_bytes: 6520
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

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

	int a, b;
	scanf("%d%d", &a, &b);
	if (a <= 5)
		b = 0;
	else if (a <= 12)
		b /= 2;
	printf("%d\n", b);
}


Measured memory_bytes: 256
// 2019/03/22 Tazoe

#include <iostream>
#include <string>
using namespace std;

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

	string s;
	cin >> s;

	string t;
	cin >> t;

	int DP[26] = {0};
	DP[(int)(s[0]-'a')] = 1;

	for(int i=1; i<N-1; i++){
		DP[(int)(s[i]-'a')] += DP[(int)(t[i]-'a')];
		DP[(int)(s[i]-'a')] %= 1000000007;
	}

	cout << DP[(int)(t[N-1]-'a')] << endl;

	return 0;
}



Measured memory_bytes: 3328
n=int(input())
li=[]
ans=0
flug=0

for i in range(n):
    li.append(input().split())

x=input()

for j in range(n):
    if flug==0:
        if li[j][0]==x:
            flug=1
    else:
        ans+=int(li[j][1])

print(ans)

Measured memory_bytes: 3064
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"

using namespace std;

const long long int MOD = 1000000007;

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


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

	string s;
	cin >> s;
	cin >> N;
	M = s.size();
	K = 0;
	while (N) {
		if (s[K] == 'a') {
			K++;
			if (K == M)break;
			continue;
		}
		if (N < 26 - (s[K] - 'a')) {
			K++;
			if (K == M)break;
			continue;
		}
		else {
			N -= 26 - (s[K] - 'a');
			s[K] = 'a';
		}
		K++;
		if (K == M)break;
	}
	N %= 26;
	s[M - 1] += N;
	if (s[M - 1] > 'z')s[M - 1] -= 26;
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=5*1e5+5;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int k;
	cin>>k;
	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cout<<a[k-1];	
}
// Don't be afraid to fail. Be afraid not to try.
// "Become grindian instead of greendian" - aryanc403
// When you want to succeed as bad as you want to breathe, only then you’ll Be Successful!
// No Matter,How Fast You Are Driving If You Are Driving in a Wrong Direction You Will Never Reach Your Destination
// When failures hit you, you hit the failures back with Bounce Back!
// When you face failures, Don’t change your goal, Change your strategy!

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
   int n,a,v,ma=999,mv=-1;
   cin >> n;
   for (n;n>0;n--) {
   cin >> a >> v;
   if (mv<=v) { if (mv==v) ma=min(ma,a); else ma=a; mv=v; }
   }
   cout << ma << ' ' << mv << endl;
   return 0;
}

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

using namespace std;

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    vector < ll > pos(n);
    for( int i = 0; i < n; i++)
    {
        cin >> pos[i];
    }
    ll ans = 100000000;
    for( int i = 1; i <= 100; i++)
    {
        ll sum = 0;
        for( int j = 0; j < n; j++)
        {
            sum+=(abs(i-pos[j])*abs(i-pos[j]));
        }
        ans = min(ans,sum);
    }
    cout << ans;
}


Measured memory_bytes: 256
import qualified Data.Vector as V (Vector, fromList, (!))
import Control.Applicative


binarySearch :: (V.Vector Int, Int, Int) -> Int -> Bool
binarySearch (vec, s, e) a
  | v == a = True
  | s >= e = False
  | v >  a = binarySearch (vec, s, n - 1) a
  | v <  a = binarySearch (vec, n + 1, e) a
  where
    n = div (s + e) 2
    v = vec V.! n

main :: IO ()
main = do
  _ <- getLine
  s <- map read . words <$> getLine
  _ <- getLine
  t <- map read . words <$> getLine
  let vec = V.fromList s
  let ans = length $ filter (binarySearch (vec, 0, length s - 1)) t
  print ans



Measured memory_bytes: 110112
N,L=map(int,input().split())
A=[]
for i in range(N):
    A.append(L+i)
total=sum(A) #予定のアップルパイ 例1なら20

#絶対値の低いやつPU
b=10000
j=0 #絶対値の小さいリンゴの番号
for i in range(N):
    if abs(A[i]) < b:
        j=i
        b =abs(A[i])
print(total-A[j])

Measured memory_bytes: 3064
/**     Md. Mujahedul Azad (Turin)
        Hajee Mohammad Danesh Science & Technology University **/

#include <map>
#include <math.h>
#include <cstdio>
#include <vector>
#include <climits>
#include <cstring>
#include <algorithm>
using namespace std;

template<class T> T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template<class T> T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template<typename T> T power(T val, T p, T mod){val%=mod; T result=1; while(p>0){if(p&0x1)result=(result*val)%mod;val=(val*val)%mod;p>>=1;}return result;}
template<typename T> inline void read(T &res){int sign=1; res=0;char ch = getchar();while(true){if(ch == '-') break;if(ch >= '0' && ch <='9') break;ch = getchar();}if(ch == '-') sign = -1;else res = ch-'0';while(true){ch = getchar();if(ch < '0' || ch > '9') break;res = (res * 10 + (ch - '0'));}res *= sign;}

#define ff                  first
#define se                  second
#define sfr(a)              read(a)
#define G()                 getchar()
#define pb                  push_back
#define pi                  acos(-1.0)
#define sq(x)               ((x) * (x))
#define sfi(x)              scanf("%d", &x)
#define sfrr(a,b)           read(a), read(b)
#define inOut               {input; output;}
#define SZ(x)               ((int) (x).size())
#define all(x)              (x).begin(), (x).end()
#define mem(a,b)            memset((a),(b),sizeof(a))
#define Case                printf("Case %d: ", cases)
#define input               freopen("input.txt","r",stdin)
#define output              freopen("output.txt","w",stdout)

#define PF                  printf
#define CASE                printf("Case %d: ", cs);
#define CASEN               printf("Case %d:\n", cs);

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

const double eps=3e-8;
const int mx = 1e5+5;



int main(){
    int n; sfr(n);
    if(n>81) puts("No");
    else{
        for(int i=1; i<10; i++)
            if(n%i == 0 && n/i<10)
                {puts("Yes"); return 0;}
        puts("No"); return 0;
    }
    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

// A/B problem

int main(){
	int a, b;
	cin >> a >> b;
	cout << a / b << ' ' << a % b << ' ';
	cout << fixed << setprecision(5) << (double)a / (double)b << endl;

	return 0;
}


Measured memory_bytes: 3300
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)



int main(){
	int N;
	cin>>N;
	
	vector<pair<long long,long long>> task(N);
	
	for(int i=0;i<N;i++){
		int a,b;
		cin>>a>>b;
		task[i] = make_pair(b,a);
	}
	
	sort(task.begin(),task.end());
	
	long long now = 0;
	
	for(int i=0;i<N;i++){
		now += task[i].second;
		if(now > task[i].first){
			cout<<"No"<<endl;
			return 0;
		}
	}
	
	cout<<"Yes"<<endl;
	
	return 0;
}


Measured memory_bytes: 3328
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();//トッピングの個数
		int A = s.nextInt();//生地の値段
		int B = s.nextInt();//トッピングの値段
		int C = s.nextInt();//生地のカロリー
		int[] result = new int[n];//合計カロリー
		int[] onedoller = new int[n+1];//1ドルあたりのカロリー
		int[] tcal = new int[n];//トッピングカロリー配列
		onedoller[0] = C/A;//トッピング何もなし
		
		for(int i=0; i<n; i++){//配列初期化
			result[i] = 0;
		}
		for(int i=0; i<n; i++){//カロリーの入力
			tcal[i] = s.nextInt();
		}
		for(int i=0; i<tcal.length-1; i++){//大きい順に並べ替え
			for(int j=i+1; j<tcal.length; j++){
				if(tcal[j]>tcal[i]){
					int temp = tcal[i];
					tcal[i] = tcal[j];
					tcal[j] = temp;
				}
			}
		}
		int sum = C;
		int c = 1;//トッピング数カウンター
		for(int i=0; i<tcal.length; i++){
			result[i] = tcal[i]+sum;
			sum = result[i];
			onedoller[i+1] = result[i]/(A+B*c);
			c++;
		}

		for(int i=0; i<onedoller.length-1; i++){//大きい順に並べ替え
			for(int j=i+1; j<onedoller.length; j++){
				if(onedoller[j]>onedoller[i]){
					int temp = onedoller[i];
					onedoller[i] = onedoller[j];
					onedoller[j] = temp;
				}
			}
		}
		System.out.println(onedoller[0]);
	}
}

Measured memory_bytes: 18344
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let hw: Vec<usize> = read_vec();
    let h = hw[0];
    let w = hw[1];
    let c: Vec<Vec<i32>> = read_vec2(10);
    let a: Vec<Vec<i32>> = read_vec2(h);

    let mut tmp: Vec<i32> = vec![];
    for i in 0..10 {
        tmp.push(c[i][1]);
    }

    let mut cost: Vec<i32> = vec![0; 10];
    for _ in 0..10 {
        let mut cst = 100000;
        let mut idx = 0;
        for i in 0..10 {
            if tmp[i] >= 0 && tmp[i] < cst {
                cst = tmp[i];
                idx = i;
            }
        }
        cost[idx] = cst;
        for i in 0..10 {
            if cost[idx] + c[i][idx] < tmp[i] {
                tmp[i] = cost[idx] + c[i][idx];
            }
        }
        tmp[idx] = -1;
    }

    let mut ans: i32 = 0;
    for i in 0..h {
        for j in 0..w {
            if a[i][j] >= 0 {
                ans += cost[a[i][j] as usize];
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>

#define INF 1 << 30
#define MOD 1000000007
#define PI 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }

static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

int main() { 
        string x;
        cin >> x;
        int delcnt = 0;
        int ans = 0;
        rep(i, x.size()) {
                if (x[i] == 'S') {
                        delcnt ++;
                } else {
                        if (delcnt > 0) {
                                delcnt --;
                                ans += 2;
                        }
                }
        }
        D(x.size() - ans);
        return 0;
}



Measured memory_bytes: 640
module DoublyLinkedList = struct
  type t = {
    mutable data : int;
    mutable next : t;
    mutable prev : t;
  }

  let make () =
    let rec head = { data = 0; next = head; prev = head } in
    head

  let insert data head =
    let x = { data = data; next = head.next; prev = head } in
    head.next.prev <- x;
    head.next <- x

  let delete x =
    x.next.prev <- x.prev;
    x.prev.next <- x.next

  let delete_first head = delete head.next

  let delete_last head = delete head.prev

  let delete_node data head =
    let rec doit ite =
      if ite == head then None
      else if ite.data = data then Some ite
      else doit ite.next
    in
    match doit head.next with
    | None -> ()
    | Some ite -> delete ite

  let iteri head ~f =
    let rec doit i ite =
      if ite != head then (f i ite.data; doit (i + 1) ite.next)
    in
    doit 0 head.next
end

module L = DoublyLinkedList

let split str delim =
  let rec doit s acc =
    match
      try Some (String.rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s1 (s2 :: acc)
  in
  doit str []

let () =
  let n = read_int () in
  let head = L.make () in
  let rec read i =
    if i < n then begin
      match split (read_line ()) ' ' with
      | ["insert"; n] -> (L.insert (int_of_string n) head; read (i + 1))
      | ["delete"; n] -> (L.delete_node (int_of_string n) head; read (i + 1))
      | ["deleteFirst"] -> (L.delete_first head; read (i + 1))
      | ["deleteLast"] -> (L.delete_last head; read (i + 1))
      | _ -> exit 1
    end
  in
  read 0;
  L.iteri head ~f:(fun i n -> Printf.printf (if i = 0 then "%d" else " %d") n);
  print_newline ()

Measured memory_bytes: 39160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int s;
    cin >> s;
    set<int> used;
    int a = s;
    while(used.count(a) == 0) {
        used.insert(a);
        if (a % 2 == 0) a /= 2;
        else a = a * 3 + 1;
    }
    cout << used.size() + 1 << endl;
    return 0;
}


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

int c[105][105];

pair<int, int> next_square(int x, int y) // 1 <= x <= H, 1 <= y <= W
{
    pair<int, int> p;
    if (c[x - 1][y] != 0)
    {
        if (c[x][y - 1] != 0)
        {
            if (c[x + 1][y] != 0)
            {
                if (c[x][y + 1] != 0) p = make_pair(-1, -1);
                else p = make_pair(x, y + 1);
            }
            else p = make_pair(x + 1, y);
        }
        else p = make_pair(x, y - 1);
    }
    else
    {
        if (c[x][y + 1] != 0) p = make_pair(x - 1, y);
        else p = make_pair(x, y + 1);
    }

    return p;
}

int main()
{
    int H, W, N;
    cin >> H >> W >> N;
    int a[10005];
    for (int i = 1; i <= N; i++)
    {
        cin >> a[i];
    }

    for (int p = 0; p <= H + 1; p++)
    {
        if (p == 0 || p == H + 1)
        {
            for (int q = 0; q <= W + 1; q++)
            {
                c[p][q] = -1;
            }
        }
        else
        {
            c[p][0] = -1;
            c[p][W + 1] = -1;
        }
    }

    pair<int, int> xy = make_pair(1, 1);
    for (int i = 1; i <= N; i++)
    {
        int ai = a[i];
        while (ai > 0)
        {
            int x = xy.first, y = xy.second;
            if (c[x][y] == 0)
            {
                c[x][y] = i;
                ai--;
            }
            xy = next_square(x, y);
        }
    }

    for (int h = 1; h <= H; h++)
    {
        for (int w = 1; w <= W; w++)
        {
            cout << c[h][w] << " ";
        }
        cout << endl;
    }
    cout << endl;
    return 0;
}

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

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

  int ans = 0;
  for (int i = 0; i < n; i ++) {
    for (int j = i + 1; j < n; j ++) {
      int t = 0;
      for (int k = 0; k < d; k ++) {
        t += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
      }
      for (int k = 1; k * k <= t; k ++) {
        if (k * k == t) ans ++;
      }
    }
  }

  cout << ans << endl;
}

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


int main()
{
    int a,b,c;
    cin >> a >> b >> c;

    if(b+c <= a){
        cout << 0 << endl;
    }
    else cout << b+c-a << endl;
    return 0;
}

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

static const int MAX = 200000;

int main() {
    int R[MAX], n;

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

    int maxv = -2000000000;
    int minv = R[0];

    for(int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;
}



Measured memory_bytes: 3864
#include"bits/stdc++.h"
using namespace std;
#define int long long
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
typedef pair<int, P>PP;
constexpr long long inf = 1e17;
constexpr int mod = 1000000007;
string s[105];

struct node {
	int i, j, k;

	bool operator ==(const node& A) const {
		return i == A.i&&j == A.j&&k == A.k;
	}
};
struct edge {
	node to;
	int cap, rev;
};
vector<edge>G[102][102][2];
int level[102][102][2], iter[102][102][2];

void add_edge(node from, node to, int cap) {
	G[from.i][from.j][from.k].push_back({to,cap,G[to.i][to.j][to.k].size() });
	G[to.i][to.j][to.k].push_back({ from,0,G[from.i][from.j][from.k].size() - 1 });
}

void bfs(node s) {
	rep(i, 102)rep(j, 102)rep(k,2)level[i][j][k] = -1;
	queue<node>Q;
	level[s.i][s.j][s.k] = 0;
	Q.push(s);
	while (Q.size()) {
		node v = Q.front(); Q.pop();
		rep(i, G[v.i][v.j][v.k].size()) {
			edge e = G[v.i][v.j][v.k][i];
			if (e.cap > 0 && level[e.to.i][e.to.j][e.to.k] < 0) {
				level[e.to.i][e.to.j][e.to.k] = level[v.i][v.j][v.k] + 1;
				Q.push(e.to);
			}
		}
	}
}

int dfs(node v, node t, int f) {
	if (v==t)return f;
	for (int &i = iter[v.i][v.j][v.k]; i < G[v.i][v.j][v.k].size(); i++) {
		edge &e = G[v.i][v.j][v.k][i];
		if (e.cap > 0 && level[v.i][v.j][v.k] < level[e.to.i][e.to.j][e.to.k]) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to.i][e.to.j][e.to.k][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int maxflow(node s, node t) {
	int flow = 0;
	while (1) {
		bfs(s);
		if (level[t.i][t.j][t.k] < 0)return flow;
		rep(i, 102)rep(j, 102)rep(k,2)iter[i][j][k] = 0;
		int f;
		while ((f = dfs(s, t, inf)) > 0)flow += f;
	}
}

signed main() {
	int h, w; cin >> h >> w;
	rep(i, h)cin >> s[i];

	rep(i, h) {
		rep(j, w) {
			if(s[i][j]=='.'||s[i][j]=='o')add_edge({ i,j,0 }, { i,j,1 }, 1);
			else add_edge({ i,j,0 }, { i,j,1 }, inf);
		}
	}

	rep(i, h) {
		vector<int>v;
		rep(j, w) {
			if (s[i][j] != '.')v.push_back(j);
		}
		rep(j, v.size()) {
			for (int k = j + 1; k < v.size(); k++) {
				node e = { i,v[j],1 }, f = { i,v[k],0 };
				add_edge( e,f,inf);
				e.k = 0, f.k = 1;
				add_edge(f, e, inf);
			}
		}
	}

	rep(j, w) {
		vector<int>v;
		rep(i, h) {
			if (s[i][j] != '.')v.push_back(i);
		}
		rep(i, v.size()) {
			for (int k = i + 1; k < v.size(); k++) {
				node e = { v[i],j,1 }, f = { v[k],j,0 };
				add_edge(e, f, inf);
				e.k = 0, f.k = 1;
				add_edge(f, e, inf);
			}
		}
	}
	node S, G;
	rep(i, h) {
		rep(j, w) {
			if (s[i][j] == 'S') {
				S.i = i, S.j = j, S.k = 0;
			}
			if (s[i][j] == 'T') {
				G.i = i, G.j = j, G.k = 1;
			}
		}
	}
	int ans = maxflow(S, G);
	if (ans > 1e16)ans = -1;
	cout << ans << endl;
}


Measured memory_bytes: 205944
import java.util.*;
 
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();
    String ans = "";
    if(A+B == C || B+C == A || C+A == B){
      ans = "Yes";
    }else{
      ans = "No";
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main(){
    int count[4][3][10] = {};
    int n,b,f,r,v;//building,floor,room,v
    int i,j,k,l;    
    cin>>n;
    for(i=0;i<n;i++){
        cin>>b>>f>>r>>v;
        count[b-1][f-1][r-1] += v;
        if(count[b-1][f-1][r-1] < 0){
            count[b-1][f-1][r-1] = 0;
        }
        if(count[b-1][f-1][r-1] > 9){
            count[b-1][f-1][r-1] = 9;
        }
    }
    for(k=0;k<4;k++){
        for(i=0;i<3;i++){
            for(j=0;j<10;j++){
                cout<<" "<<count[k][i][j];
            }
            cout<<endl;
        }        
        for(l=0;l<20;l++){
            if(k==3)break;
            cout<<"#";
        }
        if(k<4-1)cout<<endl;
    }
    return 0;
}


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

int main(){

    int a,b;
    string s;
    cin >> a >> s >> b;

    if(s=="+"){
        cout << a + b << endl;
    }else{
        cout << a-b << endl;
    }

    return 0;
}

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

int main(){
  int n, m; cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  vector<pair<int, int>> cb(m);
  for (int i = 0; i < m; i++){
    int b, c; cin >> b >> c;
    cb.at(i) = make_pair(c, b);
  }
  sort(cb.rbegin(), cb.rend());
  vector<int> bound(m);
  for (int i = 0; i < m; i++){
    bound.at(i) = lower_bound(a.begin(), a.end(), cb.at(i).first) - a.begin();
  }
  int s = 0;
  for (int i = 0; i < m; i++){
    for (int j = s; j < min(s+cb.at(i).second, bound.at(i)); j++){
      a.at(j) = cb.at(i).first;
    }
    s = min(s+cb.at(i).second, bound.at(i));
  }
  int64_t ans = 0;
  for (int i = 0; i < n; i++){
    ans += a.at(i);
  }
  cout << ans << endl;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,d,m,t;
	map<int,int> a,b;
	cin>>n;
	while(n-->0)
		cin>>d, a[d]++;
	cin>>m;
	while(m-->0)
		cin>>t, b[t]++;
	for (const auto &it : b)
		if(a[it.first]<it.second) {
			cout<<"NO\n";
			return 0;
		}
	cout<<"YES\n";
	return 0;
}

Measured memory_bytes: 19072
A,B,K=input().split()
A=int(A)
B=int(B)

if int(K)%2==1:
    isOdd=True
else:
    isOdd=False
K=int(int(K)/2)

for i in range(K):
    if A%2==1:
        A=A-1
    B=int(B+A/2)
    if B%2==1:
        B=B-1
    A=int(A/2+B/2)
    B=int(B/2)

if isOdd:
    if A%2==1:
        A=A-1
    B=int(B+A/2)
    A=int(A/2)

print(A,B)


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

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a < 9 && b < 9) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int64_t> l(n + 1);
    l.at(0) = 2;
    l.at(1) = 1;
    for (int i = 2; i <= n; i++) {
        l.at(i) = l.at(i - 1) + l.at(i - 2);
    }
    cout << l.at(n) << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define f first
#define se second
#define pb push_back
#define ld long double
 
using namespace std;
 
 
const int N = 2e5 + 123;
const int MAXN = 1e5 + 12;
const int inf = 1e9 + 7;
const ll mod = 1e9 + 7;


int n, k, a[N], t[4 * N][2], R[N];


void build(int v, int tl, int tr) {
    if (tl == tr) {
        t[v][0] = t[v][1] = a[tl];
        return;
    }
    int tm = (tl + tr) / 2;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    t[v][0] = min(t[v * 2][0], t[v * 2 + 1][0]);
    t[v][1] = max(t[v * 2][1], t[v * 2 + 1][1]);
}


int getm(int v, int tl, int tr, int l, int r) {
    if (r < tl || tr < l)
        return inf;
    int tm = (tl + tr) / 2;
    if (l <= tl && tr <= r)
        return t[v][0];
    return min(getm(v * 2, tl, tm, l, r), getm(v * 2 + 1,tm + 1, tr, l, r));
}


int getmx(int v, int tl, int tr, int l, int r) {
    if (r < tl || tr < l)
        return -1;
    int tm = (tl + tr) / 2;
    if (l <= tl && tr <= r)
        return t[v][1];
    return max(getmx(v * 2, tl, tm, l, r), getmx(v * 2 + 1,tm + 1, tr, l, r));
}

 
int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    build(1, 1, n);
    a[n + 1] = -1;
    for (int i = n; i >= 1; i--) {
        if (a[i] < a[i + 1])
            R[i] = R[i + 1];
        else
            R[i] = i;
    }
    int t1, t2, cl, cr, ans = 0, i = 1, x;
    int srt = 0;
    while (true) {
        if (i > n - k + 1)
            break;
        if (R[i] - i + 1 >= k)
            srt++;
        if (i == n - k + 1) {
            ans++;
            break;
        }
        t1 = getmx(1, 1, n, i + 1, i + k - 1);
        t2 = getm(1, 1, n, i + 1, i + k - 1);
        if (t1 > a[i + k] || t2 < a[i]) {
            ans++;
            i++;
            continue;
        }
        cl = R[i];
        cr = R[i + k];
        if (cl >= i + k - 1) {
            ans++;
            i = i + min(cl - i + 2, cr - (i + k) + 2);
            continue;
        }
        x = getm(1, 1, n, cl + 1, i + k - 1);
        int L, R, M, opt = i;
        L = i; R = cl;
        while (L <= R) {
            M = (L + R) / 2;
            if (a[M] < x) {
                opt = max(opt, M);
                L = M + 1;
            } else {
                R = M - 1;
            }
        }
        ans++;
        i = min(i + cr - (i + k) + 2, i + opt - i + 2);
    }
    if (srt == 0)
        cout << ans;
    else
        cout << ans - srt + 1;
    return 0;
}

Measured memory_bytes: 7168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SoundHound1
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var values = Console.ReadLine().Split(' ');
            var n1 = int.Parse(values[0]);
            var n2 = int.Parse(values[1]);
            if (n1 + n2 == 15)
            {
                Console.WriteLine('+');
            }
            else if (n1 * n2 == 15)
            {
                Console.WriteLine('*');
            }
            else
            {
                Console.WriteLine('x');
            }
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
    
int main(){
    
 int i=0,a[3]={0},k;
    
for(;;){
  
 scanf("%d",&k);

   
if(a[0]<=k){
   
a[2]=a[1];
a[1]=a[0];
a[0]=k;
   
 
}


if(a[0]>k&&a[1]<=k){
	a[2]=a[1];
a[1]=k;
   
 
}
if(a[1]>k&&a[2]<=k){
a[2]=k;
   
 
}

   i++;
if(i==10)break;
   
}
    
   
printf("%d\n%d\n%d\n",a[0],a[1],a[2]);
    
    return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <cstdio>
using namespace std;
const int maxn=1e5+5;
pair<int,int> a[maxn];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i].first);
        a[i].second=i;
    }
        
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)
    {
        printf("%d ",a[i].second);
    }




    return 0;
}


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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int ans;
  if (k <= a) {
    ans = k;
  }
  else if (k <= a + b) {
    ans = a;
  }
  else {
    ans = a - (k - a - b);
  }
  cout << ans << endl;
}

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

const int maxn=3010;
char a[maxn],b[maxn];
int dp[maxn][maxn];
int l1,l2;

void rek(int i, int j)
{
	if(i==0 || j==0)
		return;
	if(dp[i-1][j-1]+1==dp[i][j] && a[i]==b[j])
		{ rek(i-1,j-1); printf("%c",a[i]); }
	else
		{ (dp[i-1][j]>dp[i][j-1]) ? rek(i-1,j) : rek(i,j-1);  }
}

int main()
{
	scanf("%s",a+1);
	scanf("%s",b+1);
	l1=strlen(a+1); l2=strlen(b+1);
	for(int i=1;i<=l1;i++)
	{
		for(int j=1;j<=l2;j++)
		{
			dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
			if(a[i]==b[j])
				dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
		}
	}
	rek(l1,l2);
}

Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <cmath>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <iomanip>

#define MOD (1000000007)
using namespace std;

typedef long long ll;

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

    map<ll, vector<ll>> m;
    vector<ll> A(M), B(M);
    for(ll i = 0; i < M; i++) {
        ll A, B;
        cin >> A >> B;
        //cin >> A[i] >> B[i];
        m[A-1].push_back(B-1);
        m[B-1].push_back(A-1);
    }

    queue<pair<ll, ll>> q;

    vector<ll> ans(N, -2);

    q.push(make_pair(0, -1));
    while(q.size() >= 1) {
        pair<ll, ll> p = q.front(); q.pop();
        ll now = p.first;
        ll parent = p.second;
        // cout << now << ":" <<  parent << endl;
        if(ans[now] == -2) ans[now] = parent;
        else continue;

        // cout << m[now].size() << endl;
        for(ll i = 0 ; i < m[now].size(); i++) {
            q.push(make_pair(m[now][i], now));
        }
    }

    cout << "Yes" << endl;
    for(ll i = 1; i < N; i++) {
        cout << ans[i] + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 25564
/// https://github.com/hatoo/competitive-rust-snippets
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules !get {([$t:ty]) => {{let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); line.split_whitespace().map(|t| t.parse::<$t>() .unwrap () ) .collect ::<Vec <_ >>() } } ;([$t :ty ] ;$n :expr ) =>{(0 ..$n ) .map (|_ |get !([$t ] ) ) .collect ::<Vec <_ >>() } ;($t :ty ) =>{{let mut line :String =String ::new () ;stdin () .read_line (&mut line ) .unwrap () ;line .trim () .parse ::<$t >() .unwrap () } } ;($($t :ty ) ,*) =>{{let mut line :String =String ::new () ;stdin () .read_line (&mut line ) .unwrap () ;let mut iter =line .split_whitespace () ;($(iter .next () .unwrap () .parse ::<$t >() .unwrap () ,) *) } } ;($t :ty ;$n :expr ) =>{(0 ..$n ) .map (|_ |get !($t ) ) .collect ::<Vec <_ >>() } ;($($t :ty ) ,*;$n :expr ) =>{(0 ..$n ) .map (|_ |get !($($t ) ,*) ) .collect ::<Vec <_ >>() } ;}
#[allow(unused_macros)]
macro_rules !debug {($($a :expr ) ,*) =>{eprintln !(concat !($(stringify !($a ) ," = {:?}, " ) ,*) ,$($a ) ,*) ;} }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let mut input: Vec<u8> = get!([u8]);
    input.sort();
    if input == [5, 5, 7] {
        println!("YES");
    }else{
        println!("NO");
    }
}

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

void erup( vector<string> &t, int i, int j )
{
	t[i][j] = ' ';
	for( int k = i; k - 1 >= 0; k-- ) {
		if( t[k - 1][j] == ' ' ) break;
		t[k][j] = t[k - 1][j];
		t[k - 1][j] = ' ';
	}
}

void chk( vector<string> &t, int i, int j, int W, int K, vector<pair<int, int>> &er )
{
	for( int k = i; k >= 0; k-- ) {
		for( int l = 0; l < W - 1; l++ ) {
			if( t[k][l] != ' ' && t[k][l] == t[k][l + 1] ) {
				vector<pair<int, int>> tv;
				char nc = t[k][l];
				while( l < W && t[k][l] == nc ) {
					tv.push_back( make_pair( k, l ) );
					l++;
				}
				l--;
				if( tv.size() >= K ) er.insert( er.end(), tv.begin(), tv.end() );
			}
		}
	}
}

int main()
{
	int H, W, K;
	cin >> H >> W >> K;
	vector<string> c( H );
	for( int i = 0; i < H; i++ ) {
		cin >> c[i];
	}

	long long ans = 0;
	for( int i = 0; i < H; i++ ) {
		for( int j = 0; j < W; j++ ) {
			vector<string> t = c;
			long long sc = 0;
			erup( t, i, j );
			int idx = 0;
			while( 1 ) {
				vector<pair<int, int>> er;
				chk( t, i, j, W, K, er );
				if( er.size() == 0 ) break;
				int sum = 0;
				for( int k = 0; k < er.size(); k++ ) sum += t[er[k].first][er[k].second] - '0';
				sc += (1LL << idx) * sum;
				idx++;
				while( er.size() ) {
					int ii, jj;
					tie( ii, jj ) = er.back();
					er.pop_back();
					erup( t, ii, jj );
				}
				ans = max( ans, sc );
			}
		}
	}
	cout << ans << endl;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    ll res1 = A*X+B*Y;
    ll res2 = C*max(X, Y)*2;
    bool flg = false;
    if (X > Y) flg = true;
    ll res3 = C*min(X, Y)*2 + abs(X-Y) * (flg ? A : B);
    cout << min(min(res1, res2), res3) << endl;
    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
void alert(vector<int> vec){
  int64_t N = vec.size();
  for(int64_t i=0; i<N-1; i++){
    cout << vec.at(i) << " ";
  }
  cout << vec.at(N-1) << endl;
}

int main(){
  double R; cin >> R;
  cout << fixed << setprecision(7);
  cout << 3.1415926535798932384626 * 2 * R << endl;
}

Measured memory_bytes: 3792
N = gets.to_i
A = gets.split.map(&:to_i)

hash = {}
A.each do |a|
  hash[a] ||= 0
  hash[a]+= 1
end

all = 0
hash.values.each do |v|
  if v >= 2
    all += v * (v - 1) / 2
  end
end
# puts all
# require 'pp'
# pp hash
# puts "--"
A.each do |a|
  ac = hash[a]
  if ac < 2
    puts all
    next
  end
  puts all - ac + 1
end

Measured memory_bytes: 29700
#include <stdio.h>
#include <math.h>
double dis(double x1, double y1, double x2, double y2)
{
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

int main()
{
    double x1, y1, x2, y2, d;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    d = dis(x1, y1, x2, y2);

    printf("%.6lf\n", d);

    return 0;
}


Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define SORT(i) sort((i).begin(),(i).end())
#define INF 2000000000
constexpr ll mod = 1000000007;

ll gcd(ll x, ll y) {
	return y != 0 ? gcd(y, x % y) : x;
}

int main() {
	int N;
	cin >> N;
	vector<ll>A(N);
	for (int i = 0;i < N;++i) {
		cin >> A[i];
	}
	ll ans = INF;
	for (int i = 0;i < N - 1;++i) {
		A[i + 1] = gcd(A[i], A[i + 1]);
		ans = min(ans, A[i + 1]);
	}
	cout << ans << "\n";


	return 0;
}

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

int main() {
    string s; //string型で受け取って後で数字に変換する
    cin >> s; //入力(sの長さは1~10)
    int l = s.size() - 1; //sの数字の間に入れられる+の個数の限界値
    long long ans = 0; //本当の答え。最後に出力する
    if (l == 0) {
        ans = s[0] - '0';
        cout << ans << endl;
        return 0;
    }
    
    for (int bit = 0; bit < (1<<l); bit++) { //フラグが立っている場所に+を配置すると考える
        long long tempAns = s[0] - '0';
        for (int i = 0; i<l; i++) { //i番目のフラグが立っているか確かめるためのループ
            if (!(bit & (1<<i))) { //i番目のフラグが立っていない場合
                tempAns = tempAns * 10 + s[i+1] - '0'; //10倍してi+1番目の数を足す
            }
            else { //i番目のフラグが立っている場合
                ans += tempAns;
                tempAns = s[i+1] - '0';
            }
            if (i == l-1) ans += tempAns;
        }
    }
    cout << ans << endl; //合計を出力
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

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

Measured memory_bytes: 256
/* C++14(GCC5.4.1) */
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

int main(void){
    string s;
    cin >> s;
    int n=s.length();

    bool flag_l = false; // trueならLR収束範囲を決めにかかってる
    int tmp_l, tmp_r, tmp_next_r=0;
    int conv_lr=0; // lかrどちらかに収束する人数
    // tmp_rが偶数で収束ならそこにはconv_lr人がはいる

    // 結果を格納する配列
    int answer[n] = {0};

    for(int i=0; i<n; i++){

        if(i%2==0) conv_lr += 1;

        if(s[i]=='L' && flag_l==false){
            tmp_r = i-1;
            tmp_l = i;
            flag_l = true;
        }

        if(s[i]=='R' && flag_l==true){
            if(i%2 == 0) conv_lr -= 1;
            
            flag_l = false;
            if(tmp_r%2 == 0){
                answer[tmp_r] = conv_lr;
                answer[tmp_l] = i - tmp_next_r - conv_lr;
            }
            else{
                answer[tmp_r] = i - tmp_next_r - conv_lr;
                answer[tmp_l] = conv_lr;
            }

            if(i%2==0) conv_lr = 1;
            else conv_lr = 0;

            tmp_next_r = i;
        }

        if(i==n-1){
            if(tmp_r%2 == 0){
                answer[tmp_r] = conv_lr;
                answer[tmp_l] = i - (tmp_next_r-1) - conv_lr;
            }
            else{
                answer[tmp_r] = i - (tmp_next_r-1) - conv_lr;
                answer[tmp_l] = conv_lr;
            }
        }
    }

    for(int i=0; i<n; i++){
        cout << answer[i] << " ";
    }

    return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N, D, X;
    cin >> N >> D >> X;
    int A[110];
    REP(i,N) cin >> A[i];
    int count = 0;
    REP(i,N){
        int day = 1;
        while(day <= D){
            day += A[i];
            count++;
        }
    }
    cout << X + count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>

using namespace std;

using vi = vector<int>;
using tii = tuple<int, int, int>;

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl

int main() {
  IN(N);

  vector<tii> info;
  REP(i, N) {
    IN(x); IN(y); IN(h);
    info.push_back(make_tuple(h, x, y));
  }
  sort(ALL(info));
  reverse(ALL(info));
  REP(cx, 101) REP(cy, 101) {
    int H = get<0>(info[0]) + abs(get<1>(info[0]) - cx) + abs(get<2>(info[0]) - cy);
    bool contra = false;
    REP(i, N) {
      int h = get<0>(info[i]),
          x = get<1>(info[i]),
          y = get<2>(info[i]);
      int _H = max(H - abs(x-cx) - abs(y-cy), 0);
      if (_H != h) {
        contra = true;
        break;
      }
    }
    if (!contra) {
      OUT(cx << " " << cy << " " << H);
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;

  if(s[k-1]=='A') s[k-1]='a';
  else if(s[k-1]=='B') s[k-1]='b';
  else s[k-1]='c';

  cout<<s<<endl;

  return 0;
}


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

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

    final int INF = 1_000_000;
    int N = scanner.nextInt();
    int[][] g = new int[N][N];
    for (int i = 0; i < N; i++) {
      char[] l = scanner.next().toCharArray();
      for (int j = 0; j < N; j++) {
        if (l[j] == '1') g[i][j] = 1;
        else g[i][j] = INF;
      }
    }
    int[] ids = new int[N];
    Arrays.fill(ids, -1);
    if (!dfs(N, 0, 0, ids, g)) {
      System.out.println(-1);
      return;
    }

    for (int k = 0; k < N; k++) {
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
          if (g[i][k] + g[k][j] < g[i][j]) g[i][j] = g[i][k] + g[k][j];
        }
      }
    }

    int max = 0;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (i != j) max = Math.max(max, g[i][j]);
      }
    }
    System.out.println(max + 1);
  }

  private static boolean dfs(int N, int node, int id, int[] ids, int[][] g) {
    ids[node] = id;
    boolean result = true;
    for (int i = 0; i < N; i++) {
      if (g[node][i] == 1) {
        if (ids[i] < 0) result &= dfs(N, i, 1 - id, ids, g);
        else if (ids[i] != 1 - id) return false;
      }
    }
    return result;
  }
}


Measured memory_bytes: 26568
#include <stdio.h>

int H,W;
int i,j;

main(){
	while(1){
	scanf("%d%d",&H,&W);
	if(H != 0 && W != 0){
		for(i=0 ;i<H; i++){
			for(j=0 ;j<W; j++){
				printf("#");
			}
			printf("\n");
		}
	}else{
		break;
	}
	printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	vector<int>a;
	int n, k;
	int x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d %d", &n,&k);
	y = 0;
	a.push_back(y);
	f(i, n){
		scanf("%d", &x);
		x = x%k;
		y += x;
		y = y%k;
		a.push_back(y);
	}
	sort(a.begin(), a.end());
	s = 1;
	f(i, n){
		if (a[i] == a[i + 1]){
			ans += s;
			s++;
		}
		else s = 1;
	}

	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 892
#8:47
MOD=10**9+7
INT_MAX=10**20+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
#################################################################################
x,y=INPUT()
if y>=2*x and y<=4*x and y%2==0:
    print("Yes")
else:
    print("No")
    


Measured memory_bytes: 61744