akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int A = 0;
	int B = 0;
	int AW = 0;
	int BW = 0;
	int W = 0;
	int distance1 = 0;
	int distance2 = 0;
	cin>>W>>A>>B;
	AW = A + W;
	BW = B + W;
	if((A>=B)&&(A<=BW))
	{
		cout<<0;
		return 0;
	}
	if((B>=A)&&(B<=AW))
	{
		cout<<0;
		return 0;
	}
	
	distance1 = abs(AW-B);
	distance2 = abs(BW-A);
	if(distance1<=distance2)
	{
		cout<<distance1;
	}
	else
	{
		cout<<distance2;
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/

int main(){
    int n; cin >> n;
    int a, b; cin >> a >> b;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    int a_count = 0;
    int b_count = 0;
    int c_count = 0;

    rep(i, n){
        if(p[i] <= a)a_count++;
        else if(a < p[i] && p[i] <= b)b_count++;
        else c_count++;
    }
    cout << min({a_count, b_count, c_count}) << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>

typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 3e5;
const ll bits = 20;
const ld pi = 3.14159265358979323846;
const ll mod = 1e9+7;
const ll p = 29;


int main(){

    FASTIO;
    PRECISION; 

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int cnt = 1;

    while(1){
        if(cnt){
            c-=b;
            if(c<=0){
                cout<<"Yes\n";
                return 0;
            }
        }else{
            a-=d;
            if(a<=0){
                cout<<"No\n";
                return 0;
            }
        }
        // cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
        cnt=!cnt;
    }


    


}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> xs(1 << n);
    for (int& x : xs) {
        cin >> x;
    }
    sort(xs.begin(), xs.end(), [](int a, int b) { return a > b; });
    vector<int> chosen(1 << n, -1);
    chosen[0] = 0;
    for (int t = 1; t <= n; ++t) {
        int i = 0, j = 0;
        for (int k = 0; k < (1 << (t-1)); ++k) {
            while (j < (1 << n) && (chosen[j] != -1 || xs[j] == xs[i])) ++j;
            if (j == (1 << n)) {
                cout << "No" << endl;
                return 0;
            }
            chosen[j] = t;
            ++i;
            while (i < (1 << n) && (chosen[i] == -1 || chosen[i] == t)) ++i;
            j = max(i, j);
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 2304
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let s: Vec<char> = iterator.next().unwrap().chars().collect();

    let mut count = 0;
    for i in 0..1000 {
        let t: Vec<char> = format!("{:>03}", i).chars().collect();
        let mut j = 0;
        for k in 0..n {
            if j >= 3 {
                break;
            }
            if t[j] == s[k] {
                j += 1;
            }
        }
        if j == 3 {
            count += 1;
        }
    }
    return count.to_string();
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}

void deb_p(pii p) { printf("pair = %d %d\n", p.fi, p.se); }
void deb_i(int i) { printf("i = %d\n", i); }
void deb_v(vector<int> v) {
  printf("v = ");
  for (auto i : v) printf("%d ", i);
  printf("\n");
}
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  string s;
  cin >> s;
  rep(i, size(s)) if (s[i] == ',') s[i] = ' ';
  out(s);
}
int main(void) { solve(); }

Measured memory_bytes: 3608
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A.append(0)
B.append(0)
count =0
nokori = 0

for x in range(len(A)-1):
    count += min(A[x], B[x])
    nokori = B[x] - min(A[x], B[x])
    if nokori >= 0:
        count += min(A[x+1], nokori)
        A[x+1] -= min(A[x+1], nokori)
print(count)

Measured memory_bytes: 18624
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int q = sc.nextInt();
		int h = sc.nextInt();
		int s = sc.nextInt();
		int d = sc.nextInt();
		
		long n = sc.nextInt();
		
		h=Math.min(q*2,h);
		s=Math.min(h*2,s);
		d=Math.min(s*2,d);
		
		long ans = (n/2)*d+(n%2)*s;
		System.out.println(ans);
	}

}


Measured memory_bytes: 21844
# -*- coding: utf-8 -*-
from sys import stdin

a = [[int(x) for x in stdin.readline().rstrip().split()] for l in range(3)]

for i in range(3):
    to101 = 101 - a[i][0]
    for j in range(3):
        a[i][j] += to101

for i in range(3):
    if a[0][i] != a[1][i] or a[0][i] != a[2][i]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3064
N = int(input())
D,X = list(map(int,input().split()))
A = [int(input()) for i in range(N)]

count = 0


for i in range(N):
    for j in range(1,100):
        if j * A[i] + 1 <= D:
            count += 1
        else:
            break

print(count + N + X)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k; cin>>k;
    ll ans=0;
    FOR(a,1,k)FOR(b,1,k)FOR(c,1,k){
        ans += __gcd(a, __gcd(b,c));
    }
    cout<<ans<<"\n";
    return 0;
}


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

using namespace std;

typedef vector<int> vi;
typedef set<int> si;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define onesNumber(x) builtin_popcount(x) //builtin_popcount(ll)
const double PI = acos(-1.0);
const int N = 1e6 + 6;
const int MD = 1e9 + 7;

void solve(){
    int a[6];
    for(int i = 1; i < 6; i++)
        cin >> a[i];
    for(int i = 1; i < 6; i++){
        if(a[i] == 0){
            cout << i;
            break;
        }
    }

}
int main()
{
    //ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
    //freopen("descartes.in", "r", stdin);
    //freopen("output.txt", "w", stdout);

        solve();

    return 0;
}


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

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

	int A[n+1],B[n+1],C[n+1];

	for(int i=1;i<=n;i++)
		cin>>A[i];

	for(int i=1;i<=n;i++)
		cin>>B[i];

	for(int i=1;i<n;i++)
		cin>>C[i];


	int sat = 0;
	for(int i=1;i<=n;i++)	
	{
		int d = A[i];

		sat = sat + B[d];

		if(A[i] - 1 == A[i-1])
			sat  = sat + C[d-1];
	}

	cout<<sat<<endl;

	return 0;
}


Measured memory_bytes: 256
use std::io;

fn main(){
    let mut line = String::new();
    let _ = io::stdin().read_line(&mut line);
    let words: Vec<&str> = line.split_whitespace().collect();
    let num : i64 = words.join("").parse().unwrap();
    println!("{}", if num % 4 == 0 {"YES"} else {"NO"} );
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define int long long
#define dl long double
#define ff first
#define ss second
#define pb push_back
#define inf 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef pair<int,int> pii;


int32_t main(){
	int w,h,x,y;
	cin>>w>>h>>x>>y;
	int ways=0;
	//ways==1 if x,y is in the diagonal
	
	if(w%2==0 && h%2==0 && x==w/2 && y==h/2)ways=1;
	
	double area = 1.0*w*h/2.0;
	
	cout<<setprecision(9)<<fixed<<area<<" ";
	cout<<ways<<endl;

}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int n;
    cin >> n;
    int min1 = -INF;
    int count = 0;
    REP(i,n){
        int a,b;
        cin >> a >> b;
        if(min1<a){
            min1 = a;
            count = b;
        }
    }
    cout << min1+count << endl;
    return 0;
}

Measured memory_bytes: 256
N,A,B,C,D = map(int,input().split())

if N % A == 0:
    x_1 = N // A
else:
    x_1 = N // A + 1
x_2 = x_1 * B

if N % C == 0:
    y_1 = N // C
else:
    y_1 = N // C + 1
y_2 = y_1 * D

if x_2 > y_2:
    print(y_2)
else:
    print(x_2)


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

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i].first >> a[i].second;

    ll mint = 1, mina = 1;
    for (int i = 0; i < n; i++)
    {
        ll t = max(mint / a[i].first + (mint % a[i].first != 0),
                   mina / a[i].second + (mina % a[i].second != 0));
        mint = a[i].first * t;
        mina = a[i].second * t;
    }
    cout << mint + mina << endl;
}


Measured memory_bytes: 3604
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main()
{
	unsigned long long int N,A,B,C,D,E;
	cin>>N>>A>>B>>C>>D>>E;
	unsigned long long int x = min(A,min(B,min(C,min(D,E))));
	if( N % x == 0){
		cout<<(N/x)+4<<endl;
	}else{
		cout<<(N/x) + 5<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<char>>();
    println!(
        "{}",
        if s[0] == *s.last().unwrap() {
            "Yes"
        } else {
            "No"
        }
    );
}


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


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

    int X;
    cin >> X;

    int x=X/100;
    int y=X%100;
    int ans=1;
    if(x*5<y) ans=0;
    cout << ans << endl;
}

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

int main(){
  ll n,k,r,s,p,ans=0;
  string t;cin>>n>>k>>r>>s>>p>>t;
  vector<string> tt(k);
  
  REP(i,n){
    tt.at(i%k)+=t.at(i);
  }

  /*REP(i,k){
    cout<<tt.at(i)<<endl;
  }*/

  REP(i,k){
    char f;
    ll count=1;
    
    REP(j,tt.at(i).size()){
      if(!j){
        f=tt.at(i).at(j);
        if(tt.at(i).size()!=1) continue;
        else{
          ll scr;
          if(f=='r') scr=p;
          else if(f=='s') scr=r;
          else scr=s;
          ans+=scr;
          break;
        }
      }
      
      if(tt.at(i).at(j)==f){
        count++;
      }
      
      if(tt.at(i).at(j)!=f){
        count=(count+1)/2;
        ll scr;
        if(f=='r') scr=p;
        else if(f=='s') scr=r;
        else scr=s;
        ans+=scr*count;
        f=tt.at(i).at(j);
        count=1;
      }
      
      if(j==tt.at(i).size()-1){
        count=(count+1)/2;
        ll scr;
        if(f=='r') scr=p;
        else if(f=='s') scr=r;
        else scr=s;
        ans+=scr*count;
      }
      
    }
  }
   
  cout<<ans;
}

Measured memory_bytes: 5120
//const int N=1e5;
#define INF 1e9
#include <bits/stdc++.h>
using namespace std;
const int M = 100;

void sol() {
	int n; cin >> n;
	cout << (n + (n * n) + (n * n * n));
}

int main() {
	// std::ios::sync_with_stdio(false);
	// cin.tie(nullptr);
	// cout.tie(nullptr);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	//cin >> t;
	while (t--) {
		sol();
	}

	return 0;
}

Measured memory_bytes: 3596
xxx = Rational(4, gets.to_i)



(1..3500).each{|h|
  yyy = xxx - Rational(1, h)
  next if yyy.numerator<0
  (h..3500).each{|n|
    zzz = yyy - Rational(1, n)
    if zzz.numerator == 1 
      puts "#{h} #{n} #{zzz.denominator}"
      exit
    end
  }
}

Measured memory_bytes: 3836
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    string s;
    cin>>s;
    for(int i=1;i<s.length();i++){
        if(s[i-1]==s[i])
        {
            cout<<"Bad"<<'\n';
            return 0;
        }
    }
    cout<<"Good"<<'\n';
    return 0;
}


Measured memory_bytes: 256
"use strict";

const Main = (input) => {
  let xs = input.trim().split(' ');
  let A = parseInt(xs[0],10) + parseInt(xs[1],10);
  let B = parseInt(xs[0],10) + parseInt(xs[2],10);
  let C = parseInt(xs[1],10) + parseInt(xs[2],10);
  
  const compare = (a, b) => {
  return a - b;
  }
 
  let ans = [A,B,C];
  ans.sort(compare);
  console.log(ans[0]);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
import math,sys,bisect,heapq
from collections import defaultdict,Counter,deque
from itertools import groupby,accumulate
#sys.setrecursionlimit(200000000)
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: map(int,input().split())
alele = lambda: list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
#def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
MOD = 1000000000 + 7
def Y(c):  print(["NO","YES"][c])
def y(c):  print(["no","yes"][c])
def Yy(c):  print(["No","Yes"][c])
    
def fun(A,P,W,N):
    if N == 0 or W == 0:
        return 0
    dp = list2d(N+1,W+1,0)
    for i in range(1,N+1):
        for j in range(1,W+1):
            if A[i-1] <= j:
                dp[i][j] = max(dp[i-1][j] , P[i-1] + dp[i-1][j - A[i-1]])
            else:
                dp[i][j] = dp[i-1][j]
    return dp[N][W]
N,W = ilele()
P = []
A = []
for i in range(N):
    a,b =ilele()
    A.append(a)
    P.append(b)
print(fun(A,P,W,N))
    

Measured memory_bytes: 147356
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, M, D = map(int, input().split())

    if D == 0:
        ans = 1 / N
        # 一つの数列中の間隔の数をかける
        ans *= M - 1
    else:
        # 絶対値の差がDになる二つの文字列の並びの数
        cnt = 2 * (N - D)

        # N**2通りの文字の美しさの平均
        ans = cnt / (N ** 2)

        # 一つの数列中の間隔の数をかける
        ans *= M - 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define cin(a) scanf("%d",&a)
#define pii pair<int,int>
#define ll long long
#define gcd __gcd
const int inf = 0x3f3f3f3f;
const int maxn = 201110;
const int M = 1e9+7;

ll a[maxn];

int main()
{
	ll n,k;
	cin>>n>>k;
	ll ans = 0;
	for(int i = 0; i < n; i++) 
	{
		cin>>a[i];
	}
	sort(a,a+n);
	n = n-k;
	for(int i = 0; i < n; i++) 
	{
		ans += a[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    i64 sum = 0;
    int v, e;
    cin >> v >> e;
    vvi adj(v, vi(v, 1e9));
    vi deg(v);
    for (int i = 0; i < v; i++) {
        adj[i][i] = 0;
    }
    for (int i = 0; i < e; i++) {
        i64 s, t, d;
        cin >> s >> t >> d;
        deg[s]++;
        deg[t]++;
        adj[s][t] = min(adj[s][t], d);
        adj[t][s] = min(adj[t][s], d);
        sum += d;
    }

    vi odd;
    for (int i = 0; i < v; i++) {
        if (deg[i] % 2) {
            odd.push_back(i);
        }
    }

    int n = odd.size();
    if (n == 0) {
        cout << sum << endl;
        return 0;
    }

    assert(n % 2 == 0);

    vvi adj2(n, vi(n, 1e9));

    for (int k = 0; k < v; k++) {
        for (int i = 0; i < v; i++) {
            for (int j = 0; j < v; j++) {
                adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j]);
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            adj2[i][j] = adj[odd[i]][odd[j]];
            adj2[j][i] = adj[odd[j]][odd[i]];
        }
    }

    vi match(1 << n, 1e18);
    match[0] = 0;
    for (int i = 0; i < 1 << n; i++) {
        for (int j = 0; j < n; j++) {
            if ((i >> j) & 1) continue;
            for (int k = 0; k < n; k++) {
                if (j == k) continue;
                if ((i >> k) & 1) continue;
                match[i | (1 << j) | (1 << k)] = min(match[i | (1 << j) | (1 << k)], match[i] + adj2[j][k]);
            }
        }
    }

    cout << sum + match.back() << endl;
}


Measured memory_bytes: 3200
def gcd(a, b)
  if a % b == 0
    return b
  else
    return gcd(b, a % b)
  end
end
while (str = gets)
  a, b = str.split(" ").map(&:to_i)
  puts [gcd(a, b), (a * b) / gcd(a, b)].join(" ")
end

Measured memory_bytes: 6096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define F first
#define S second
#define pb push_back
mt19937 rnd;


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n, d;
    cin >> n >> d;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int x, y;
        cin >> x >> y;
        if (1ll * x * x + 1ll * y * y <= 1ll * d * d) {
            ans++;
        }
    }
    cout << ans << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int INF=1<<29;

int main(){
	int N,M,Ans=0;
	cin>>N>>M;
	int table[N+1][N+1];
	int copy[N+1][N+1];
	for(int i=0;i<N+1;i++){
		for(int j=0;j<N+1;j++){
			if(i==j) table[i][j]=0;
			else table[i][j]=INF;
			copy[i][j]=0;
		}
	}
	for(int i=0;i<M;i++){
		int a,b,c;
		cin>>a>>b>>c;
		table[a][b]=c;
		table[b][a]=c;
		copy[a][b]=c;
		copy[b][a]=c;
	}
	for(int k=1;k<N+1;k++){
		for(int i=1;i<N+1;i++){
			for(int j=1;j<N+1;j++){
				table[i][j]=min(table[i][k]+table[k][j],table[i][j]);
			}
		}
	}
	for(int i=1;i<N+1;i++){
		for(int j=1;j<N+1;j++){
			if(copy[i][j]==0) continue;
			if(copy[i][j]>table[i][j]) Ans++;
		}
	}
	cout<<Ans/2<<endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i, n) cin >> x[i];
  
  int sum=0;
  int min=0;
  
  for(int i=1; i<101; i++){
    sum = 0;
    for(int j=0; j<n; j++){
      sum+=(x[j]-i)*(x[j]-i);
    }
    if(i==1) min = sum;
    else if(sum < min) min = sum;
  }
  
  cout << min << endl;
  
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - ROT N
            int N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            var chars = GetChars();
            var ans = "";

            foreach(var c in S)
            {
                int index = (chars[c] + N) % 26;
                var query = chars.First(x => x.Value == index);
                ans += query.Key.ToString();
            }

            Console.WriteLine(ans);
        }

        static Dictionary<char, int> GetChars()
        {
            var chars = new Dictionary<char, int>();
            int i = 0;

            for (char c = 'A'; c <= 'Z'; c++)
            {
                chars.Add(c, i);
                i++;
            }

            return chars;
        }
    }
}

Measured memory_bytes: 35152
#include <bits/stdc++.h>
using namespace std;
# define M_PI 3.14159265358979323846
using ll = long long int;
const int MOD = 1e9 + 7;
int main()
{
    string s;
    cin>>s;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='7')
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
}

Measured memory_bytes: 3592
/*
 * a.c
 *
 *  Created on: 2017/06/13
 *      Author: AWV060608
 */

#include	<stdio.h>

#define		MXCLEN		1200

int		main(void)
{
	int		i;
	//int		str[MXCLEN];
	char	str[MXCLEN]={0};

	fgets( str, MXCLEN, stdin);

	for( i=0; i<MXCLEN; i++ )
	{
		if(str[i] == '\0')
			break;

		if( 65<=str[i] && str[i]<=90 )
		{
			str[i] = str[i] + 32;
		}
		else if( 97<=str[i] && str[i]<=122 )
		{
			str[i] = str[i] - 32;
		}
		printf("%c",str[i] );
	}

	return 0;
}

Measured memory_bytes: 524
#include <cstdio>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int n, q, tmp;
  set<int> s;

  scanf("%d", &n);
  for (int i = 0; i < n; i++)
  {
    scanf("%d", &tmp);
    s.insert(tmp);
  }

  scanf("%d", &q);
  vector<int> t(q);
  for (int i = 0; i < q; i++)
    scanf("%d", &t[i]);

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

  int count = 0;
  for (set<int>::iterator itr = s.begin(); itr != s.end(); itr++)
    if (binary_search(t.begin(), t.end(), *itr))
      count++;

  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 7520
/********** Raaghav Raaj (cf: raaghavraaj, cc: mothercoder27) *************/
#include<bits/stdc++.h>
using namespace std;
#define fast cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false);
#pragma optimize("-O3")

// #ifndef LOCAL
// #include "trace.h"
// #else
// #define trace(args...)
// #endif

#define int long long
#define vi vector<int>
#define vc vector<char>
#define pi pair<int, int>
#define pii pair<pi,int>
#define rep(i,a,b) for(int i=a; i<b; i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define sp " "
#define endl '\n'
#define all(v) v.begin(), v.end()
#define debug(data) for(auto it: data) cout<<it<<sp;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

const int sz = 1e9 + 7;
int gcd(int n, int m) {
	while (n) swap(n, m), n %= m;
	return m;
}

int power(int a, int b) {
	a %= sz;
	int res = 1;
	while (b) {
		if (b & 1) res = (res * a) % sz;
		a = (a * a) % sz;
		b >>= 1;
	}
	return res;
}

int modInverse(int a) { //sz must be prime
	return power(a, sz - 2);
}

void solve() {
	int A, B, M; cin >> A >> B >> M;
	if (A % M == 0)
	{cout << (B / M) - (A / M) + 1 << endl; return;}

	// A is not divisible by M
	cout << (B / M) - (A / M) << endl;
}

int32_t main() {

	fast;
	int T = 1;
	// cin >> T;
	rep(i, 1, T + 1) {
		// cout << "Case #" << i << ": ";
		solve();
	}
}

Measured memory_bytes: 3652
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const MAX = 101

var f [MAX]int
var d [MAX]int
var list [][]int
var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func dfs(u, cnt int) int {
	if d[u] != 0 {
		return cnt
	}

	cnt++
	d[u] = cnt
	for _, next := range list[u] {
		cnt = dfs(next, cnt)
	}
	cnt++
	f[u] = cnt
	return cnt
}

func main() {
	n := scanInt()
	list = make([][]int, n+1)
	for i := 1; i <= n; i++ {
		u := scanInt()
		k := scanInt()
		for j := 0; j < k; j++ {
			n := scanInt()
			list[u] = append(list[u], n)
		}
	}

	cnt := 0
	for i := 1; i <= n; i++ {
		cnt = dfs(i, cnt)
	}

	w := bufio.NewWriter(os.Stdout)
	for i := 1; i <= n; i++ {
		fmt.Fprint(w, i)
		fmt.Fprint(w, " ")
		fmt.Fprint(w, d[i])
		fmt.Fprint(w, " ")
		fmt.Fprint(w, f[i])
		fmt.Fprintln(w)
	}
	w.Flush()
}



Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define ll long long
#define M 100000007
#define fr first
#define sc second
#define endl "\n"
#define vc vector
#define pb push_back
#define pii pair<ll,ll>
#define psi pair<string,ll>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265
#define r0 return 0

/* typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
*/
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
using namespace std;
int factorial(int n) 
{ 
    return (n==1 || n==0) ? 1: n * factorial(n - 1);  
} 
int main()
{
	fast
    int n;
    cin>>n;
    string s;
    map<string,int>m;
    rep(i,0,n) {
        cin>>s;
        sort(all(s));
        m[s]++;
    }
    ll cnt=0;
    tr(m,i) cnt+=(ll)(i->second)*(i->second-1) / 2;
    cout<<cnt<<endl;



    // int n;
    // cin>>n;
    // vector<string> s(n);
    // rep(i,0,n) cin>>s[i];
    // rep(i,0,n) sort(all(s[i]));
    // map<string,int>m;
    // rep(i,0,n){
    //     if(m.find(s[i])==m.end()) m[s[i]]=1;
    //     else m[s[i]]++;
    // }
    // ll count=0;
    // // tr(m,i) cout<<i->first<<" "<<i->second<<endl;
    // tr(m,i) count+=(ll)((i->second)*(i->second-1))/2;
    // cout<<count;


}


Measured memory_bytes: 11264
#include<iostream>
using namespace std;
int main() {


	//C
	int a[100];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int sum;
	int min = 100000000;
	for (int i = -100; i <= 100; i++) {
		sum = 0;
		for (int j = 0; j < n; j++) {
			sum = sum + (i - a[j]) * (i - a[j]);
		}
		if (sum < min)min = sum;
	}
	cout << min << endl;
	return 0;


	//D
	/*
	string s;
	cin >> s;
	int i, j, k;
	int ab[26];
	for (i = 0; i < 26; i++) {
		ab[i] = 0;
	}
	for (j = 0; j < s.length() - 1; j++) {
		if (s[j] == s[j + 1]) {
			cout << j + 1 << ' ' << j + 2 << endl;
			return 0;
		}
		else if (j < s.length() - 2) {
			if (s[j] == s[j + 2]) {
				cout << j + 1 << ' ' << j + 3 << endl;
				return 0;
			}
		}
	}
	cout << -1 << ' ' << -1 << endl;
	return 0;*/
}

Measured memory_bytes: 3632
#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 V (500)
#define LLM (1000000000000000)
//n<=50000
struct edge{
	int to;
	long long cap;
	int rev;
};
vector<edge> g[V];
bool used[V];

//辺追加(1回)
void add_edge(void){
	int x, y;
	long long z;
	scanf("%d %d %lld", &x, &y, &z);
	x--;
	y--;
	g[x].push_back({ y, z, g[y].size() });
	g[y].push_back({ x, 0, g[x].size() - 1 });
}

//増加路探索
long long dfs(int vec, int ep, long long val){
	if (vec == ep)return val;
	used[vec] = true;
	f(i, g[vec].size()){
		edge &e = g[vec][i];
		if (!used[e.to] && e.cap > 0){
			long long d = dfs((e.to), ep, min(val, e.cap));
			if (d > 0){
				e.cap -= d;
				g[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

//最大流探索
long long max_flow(int s, int t){
	long long ret = 0;
	long long res;
	bool z = true;
	while (z){
		memset(used, 0, sizeof(used));
		res = dfs(s, t, LLM);
		if (res == 0)z = false;
		else ret += res;
	}
	return ret;
}


int main(void){
	int n, m, s, t;
	int x, y;
	long long z, ans;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++){
		scanf("%d %d %lld", &x, &y, &z);
		g[x].push_back({ y, z, g[y].size() });
		g[y].push_back({ x, 0, g[x].size() - 1 });
	}
	ans = max_flow(0, n-1);
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 2888
X = int(input())

while True:
    pf={}
    m=X
    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:pf[m]=1
    #print(i,pf)
    #print(len(list(pf)))

    if len(list(pf))==1 and list(pf.values())[0]==1:
        break
    else:
        X+=1

print(m)


Measured memory_bytes: 63712
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

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

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

int gcd(int a, int b) {
    if (a < b) swap(a,b);
    while (b) {
        a %= b;
        swap(a,b);
    }
    return a;
}

void solve() {
    int a,b,k;
    cin >> a >> b >> k;
    int c = gcd(a,b);
    VI s;
    RREP(i,1,c+1) if (c % i == 0) s.push_back(i);
    cout << s[k-1] << endl;
}

int main() {
    solve();
    
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

ll gcd(ll a, ll b){
    if (b)
        return gcd(b, a%b);
    return a;
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    ll A, B;
    cin >> A >> B;

    ll d = gcd(A, B);
    ll d0 = d;
    int cnt = 1;
    for(ll p=2; p*p<=d; p++){
        if (d%p==0){
            cnt++;
            while(d%p==0)
                d/=p;
        }
    }
    cnt += d>1;
    cout << cnt << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 256
fun main(){
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val h = readLine()!!.split(" ").map { it.toInt() }
    val e = Array(n){mutableListOf<Int>()}
    for(i in 0 until m){
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        e[a - 1].add(b - 1)
        e[b - 1].add(a - 1)
    }

    var count = 0
    for(i in 0 until n){
        var f = true
        e[i].forEach {
            if(h[i] <= h[it]) f = false
        }
        if(f) count++
    }
    println(count)
}


Measured memory_bytes: 73692
H,W = map(int,input().split())

while H != 0 or W != 0:
    for i in range(H):
        if i % 2 == 0:
            flg = 0
        else:
            flg = 1    
        for j in range(W):
            if j % 2 == flg:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()
    H,W = map(int,input().split())



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

long long T[1010],A[1010];
int main(){
	int N;
	cin>>N;
	for(int i=1;i<=N;i++){
		cin>>T[i]>>A[i];
	}
	long long tn=1,an=1,hog=0;
	for(int i=1;i<=N;i++){
		hog=max(((tn-1)/T[i]+1),((an-1)/A[i]+1));
		tn=hog*T[i];
		an=hog*A[i];
	}
	cout<<tn+an<<endl;
	return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
H = [int(h) for h in input().split()]

d = {}

for i in range(N):
    d[i+1] = H[i]

for _ in range(M):
    A,B = map(int,input().split())

    if H[B-1] >= H[A-1]:
        d[A] = 0

    if H[B-1] <= H[A-1]:
        d[B] = 0

print(N - list(d.values()).count(0))

Measured memory_bytes: 24492
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define mset(a,x) memset(a,x,sizeof(a))
#define FASTIO cin.tie(0),ios::sync_with_stdio(0)




int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) scanf("%d", &a[i]);

    map<int, int> mp;
    for (auto&& i : a) {
        mp[i]++;
        mp[i - 1]++;
        mp[i + 1]++;
    }

    int ma = 0, ans = 0;
    for (auto&& i : mp) {
        if (ma < i.second) {
            ma = i.second;
        }
    }

    cout << ma << endl;

    return 0;
}

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

#define endl '\n'
#define int long long

const int N = 110, V = 1e5+9;
int cache[N][V], items[N][2], n, w;
bool vis[N][V];

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> n >> w;
	for(int i = 1; i <= n; i ++) {
		for(int j = 0; j < 2; j ++) {
			cin >> items[i][j];
		}
	}
	cache[0][0] = w;
	vis[0][0] = 1;
	for(int i = 1; i <= n; i ++) {
		for(int j = 0; j < V; j ++) {
			cache[i][j] = cache[i-1][j];
			vis[i][j] = vis[i-1][j];
		}
		for(int j = V-1; j >= 0; j --) {
			if(vis[i][j]) {
				if(cache[i][j] - items[i][0] >= 0) {
					cache[i][j + items[i][1]] = max(cache[i][j + items[i][1]], cache[i][j] - items[i][0]);
					vis[i][j + items[i][1]] = 1;
				}
			}
		}
	}
	int ans = 0;
	for(int i = 0; i < V; i ++) {
		if(vis[n][i]) {
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 91544
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
//#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
int find(int i,int a[]){
	if(a[i]==i)return i;
	return a[i]=find(a[i],a);
}
void uni(int i,int j,int a[],int sz[]){
	int x=find(i,a);
	int y=find(j,a);
	if(sz[x]>sz[y])a[y]=x;
	else a[x]=y;
	sz[x]+=sz[y];
	sz[y]=sz[x];
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    if(s=="RRR")cout<<3;
    else if(s=="RRS"||s=="SRR")cout<<2;
    else if(s=="SSS")cout<<0;
    else cout<<1;
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<set>
#include<cmath>
#include<vector>
#include<algorithm>
#define inf 0x3f3f3f3f
#define ll long long
using namespace std;
const int maxn = 1e3+5;

int main(){
	int n, m; cin >> n >> m;
	cout << n * (n-1) / 2 + m * (m - 1) / 2 << endl;
}

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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        System.out.println((char)(s.charAt(0)) + Integer.toString(s.length() - 2) + (char)s.charAt(s.length()-1));
        System.out.println();
        sc.close();
    }
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (int)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

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

    vll h(n),dp(n,0);
    rep(i,n)cin >> h[i];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);

    REP(i,2,n){
        ll tmp1 = abs(h[i] - h[i-2]) + dp[i-2];
        ll tmp2 = abs(h[i] - h[i-1]) + dp[i-1];

        dp[i] = min(tmp1,tmp2);
    }

    cout << dp[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef unsigned long long int ull;
ull min(ull x, ull y) {
    if (x <= y) return x;
    else return y;
    return 0;
}
int main() {
    ull N; cin >> N;
    ull ans = 18446744073709551615;
    for (ull i = 1; i <= 1000000; ++i) {
        if (N % i == 0) {
            ull tmp = 0;
            tmp = N / i;
            ans = min(ans, tmp + i);
        }
        if (i > N) break;
    }
    cout << ans - 2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

template<typename Monoid,typename F>
class SegmentTree{
private:
    int sz;
    vector<Monoid> seg;
    const F op;
    const Monoid e;
public:
    SegmentTree(int n,const F op,const Monoid &e):op(op),e(e){
        sz = 1;
        while(sz<=n) sz <<= 1;
        seg.assign(2*sz,e);
    }
    void set(int k, const Monoid &x){
        seg[k+sz] = x;
    }
    void build(){
        for(int i=sz-1;i>0;i--){
            seg[i] = op(seg[2*i],seg[2*i+1]);
        }
    }
    void update(int k,const Monoid &x){
        k += sz;
        seg[k] += x;
        while(k>>=1){
            seg[k] = op(seg[2*k],seg[2*k+1]);
        }
    }
    Monoid query(int l,int r){
        Monoid L = e,R = e;
        for(l+=sz,r+=sz;l<r;l>>=1,r>>=1){
            if(l&1) L = op(L,seg[l++]);
            if(r&1) R = op(seg[--r],R);
        }
        return op(L,R);
    }
    Monoid operator[](const int &k)const{
        return seg[k+sz];
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W,M;
    cin >> H >> W >> M;
    vec<int> cntH(H),cntW(W);
    vvec<int> g(H);
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        cntH[a]++; cntW[b]++;
    }
    SegmentTree seg(W,[](int a,int b){return max(a,b);},0);
    for(int i=0;i<W;i++) seg.set(i,cntW[i]);
    seg.build();
    int ans = 0;
    for(int i=0;i<H;i++){
        int now = cntH[i];
        for(auto& to:g[i]) seg.update(to,-1);
        ans = max(ans,now+seg.query(0,W));
        for(auto& to:g[i]) seg.update(to,1);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 26160
#include<iostream>
#include<string>
#include<algorithm>

using namespace std ;
int main () {
  int N;
  int a[100];
  int sumA=0,sumB=0;
  cin >> N;
  for(int i=0;i<N;i++) {
    cin >> a[i];
  }
  sort(a,a+N,greater<int>());
  for(int i=0;i<N;i=i+2) {
    sumA = sumA+a[i];
  }
  for(int i=1;i<N;i=i+2) {
    sumB = sumB+a[i];
  }
  cout << sumA-sumB << endl;
  return(0);
}

Measured memory_bytes: 256
h,w = map(int, input().split())
#get hight and weidth 
glid = [0] * ( h+ 2)

h_index = [-1, -1, -1, 0, 0, 1, 1, 1]
w_index = [-1, 0, 1, -1, 1, -1, 0, 1]

glid[0]=[0] * ( w + 2 )
glid[h + 1 ] = [0] * ( w + 2 )

for i in range(h):
	temp1 = [0]
	temp2 = list(input())
	temp1.extend(temp2)
	temp1.append(0)
	glid[ i + 1 ] = temp1

# get glids 

for j in range(h):
	for k in range(w):
		if glid[ j + 1 ][ k + 1 ] == "#":
			continue
		else:
			cnt = 0
			for n in range(8):
				if glid[ j  + 1 + h_index[ n ] ][ k + 1 + w_index[ n ]] == "#" :
					cnt += 1
			glid[ j + 1 ][ k +1 ] = str(cnt)

for h_print in range ( h ):
	for w_print in range ( w ):
		print(glid[h_print + 1][w_print + 1], end="")
	print()

Measured memory_bytes: 3572
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef long int li;

int main(){
    ll ans=0;
    ll ksk;
    char s[100001];
    for(ll i=0;i<100001;i++){
        cin >> s[i];
    }
    ll a=0;
    ll b=0;
    for(ll i=0;i<100001;i++){
      if(s[i]!='0'&&s[i]!='1')break;
        if(s[i]=='0')a++;
        if(s[i]=='1')b++;
    }
    ans=min(a,b)*2;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 384
def f(a, b):
    return max(len(str(a)), len(str(b)))

import math
def main():
    N = int(input())

    ans = 10**10
    for i in range(1, int(math.sqrt(N)) + 1):
        j = N // i

        if i * j == N:
            ans = min(ans, f(i, j))

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9124
import math

n = int(input())
num = 2 * n
tmp = int(math.sqrt(num))
if tmp * (tmp + 1) != num:
    print("No")
    exit()
print("Yes")
print(tmp + 1)
lst = [[] for _ in range(tmp + 1)]
last = 1
for i in range(tmp + 1):
    print(tmp, end = " ")
    cnt = 0
    for j in range(i):
        x = lst[j].pop()
        print(x, end = " ")
        cnt += 1
    for k in range(cnt, tmp):
        print(last, end = " ")
        lst[i].append(last)
        last += 1
        
    print()

Measured memory_bytes: 6732
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <stack>
#include <queue>

using namespace std;
#define Fill(a, b) memset(a, b, sizeof(a))
#define Debug(x) cout << #x << "=" << (x) << endl;
typedef long long LL;
const LL inf = 1LL << 61;
const LL mod = 1000000007;
#define DEBUG
#ifdef DEBUG
#endif
const int maxn = 510;

char mat1[maxn][maxn];
char mat2[2*maxn][2*maxn];
int main()
{
    std::ios::sync_with_stdio(false);
    int h, w, d;
    scanf("%d%d%d", &h, &w, &d);
    for(int i = 1, f1 = 0; i < 2*maxn; i+=d, f1++)
    {
    	for(int j = 1, f2 = 0; j < 2*maxn; j+=d, f2++)
    	{
    		char ch;
    		if(f1%2)
    		{
    			if(f2%2)
    			{
    				ch = 'B';
    			}
    			else
    			{
    				ch = 'Y';
    			}
    		}
    		else
    		{
    			if(f2%2)
    			{
    				ch = 'R';
    			}
    			else
    			{
    				ch = 'G';
    			}
    		}
    		for(int r = i; r < min(i+d,2*maxn); r++)
    		{
    			for(int c = j; c < min(j+d,2*maxn); c++)
    			{
    				mat2[r][c] = ch;
    			}
    		}
    	}
    }
    /*
    cout << "mat2\n";
    for(int i = 1; i < h+w; i++)
    {
    	for(int j = 1; j < h+w; j++)cout << mat2[i][j];cout << endl;
    }
    */
	for(int i = 1; i <= h; i++)
	{
		for(int j = 1; j <= w; j++)
		{
			int x = w+i-j, y = i+j-1;
			mat1[i][j] = mat2[x][y];
		}
	}
	//cout << "mat1\n";
    for(int i = 1; i <= h; i++)
    {
    	for(int j = 1; j <= w; j++)
    	{
    		printf("%c", mat1[i][j]);
    	}
    	puts("");
    }
	






















    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) ((a).begin(), (a).end())
typedef long long ll;
// const long long INF = 1LL << 60;
const int INF = 1010101010;
// using Graph = vector<vector<int>>;
const int MOD = 1000000007;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  /* 左から選ぶA個と右から選ぶB個を決めてK個から引いた数をCとする。
  C個分捨てることができる。
  */

  ll res = 0;
  for (int p = 0; p <= min(k, n); p++) {
    for (int q = 0; p + q <= min(k, n); q++) {
      vector<ll> V;
      ll cur = 0;
      rep(i, p) V.push_back(v[i]), cur += v[i];
      rep(i, q) V.push_back(v[n - 1 - i]), cur += v[n - 1 - i];

      SORT(V);
      for (int i = 0; i < min(k - p - q, (int)V.size()); i++) {
        if (V[i] < 0) cur -= V[i];
      }
      res = max(res, cur);
    }
  }
  cout << res << endl;
}


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

using namespace std;

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

int main(){
    ll a, b, x;
    cin >> a >> b >> x;

    ll nb = b/x;
    ll na = (a-1)/x;
    na = max((ll)0, na);

    ll ans = nb -na;
    if(a == 0) ans++;

    cout << ans << endl;

    return 0;
}


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

int main()
{
  int a,b,c,d,e,f;
  cin >> a;
  cin >> b;
  c=(a+b);
  d=((c+1)/2);
  e=(c%2);
  f=(c/2);
  if (e==0)
  {
    cout << f<< endl;
  }
  else 
  {
    cout << d<< endl;
  }
  return 0;
 }

Measured memory_bytes: 3596