akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
	int n, m;
	int a[1000];
	int i,j,tmp;
	float o;

	cin >> n >> m;

	o = 0;
	for (auto i = 0; i < n; i++) {
		cin >> a[i];
		o = o + (float)a[i];
	}
	/* 数値を降順にソート */
	for (i = 0; i < n; ++i) {
		for (j = i + 1; j < n; ++j) {
			if (a[i] < a[j]) {
				tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
	o = o / (4 * (float)m);
	for (i = 0; i < m; i++) {
		if ((float)a[i] < o) {
			cout << "No";
			return 0;
		}
		
	}
	cout << "Yes";

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main(){
    fastio;
    int n,k;
    cin >> n >> k;
    long long h[n],dp[(int)1e5];
    for(int i=0; i<n; i++){cin >> h[i];}
    dp[0]=0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        long long an=INT_MAX;
        for(int j=1;j<=k;j++){
            if(i>=j){
                an = min(an,abs(h[i]-h[i-j])+dp[i-j]);
            }
        }
        dp[i] = an;
    }
    cout << dp[n-1] <<"\n";
    return 0;
}


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

int main() {
  string s; cin >> s; int ans = 0, now = 0;
  for (auto e : s) {
    if (e == 'A' or e == 'T' or e == 'G' or e == 'C') ans = max(ans, ++now);
    else now = 0;
  }
  cout << ans << endl;
}

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
	cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	cout << head;
	if (sizeof...(tail) != 0) cout << " ";
	print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
	for (auto& a : vec) {
		cout << a;
		if (&a != &vec.back()) cout << " ";
	}
	cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
	for (auto& vec : df) {
		print(vec);
	}
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int x, a, b;
	cin >> x >> a >> b;
	x -= a;
	int cnt = x / b;
	print(x - b * cnt);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int a, b, c; cin >> a >> b >> c;
  vi v = {a, b, c};
  sort(v.begin(), v.end());
  cout << v[0] + v[1] << endl;
  
}


Measured memory_bytes: 256
const M: usize = 1000000007;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
    }
    let mut result = 1;
    for i in 2..n + 1 {
        result = (result * i) % M
    }
    println!("{}", result);
}


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

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

long long N;
int ans = 0;

void func(long long n, int num3, int num5, int num7) {
    if (n > N){
        return;
    }
    
    if (num3 > 0 && num5 > 0 && num7 > 0) ans++;
 
    func(n * 10 + 3, num3 + 1, num5, num7);
    func(n * 10 + 5, num3, num5 + 1, num7);
    func(n * 10 + 7, num3, num5, num7 + 1);
 
}

int main() {
    cin >> N;
    func(0,0,0,0);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	string n;
	int sum = 0;
	cin >> n;
	for (int i = 0; i < n.length(); i++) {
		sum += stoi(n.substr(i, 1));
	}

	if (stoi(n)%sum == 0)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 764
/*@author hussein zayed ;
    ___  ___
   |\  \|\  \
   \ \  \_\  \
    \ \   ___ \USSEIN
     \ \  \\ \ \
      \ \__\\ \_\
       \|__| \|__|
****************************************
*/

#include <bits/stdc++.h>
using namespace std;
#define fr for(int i=0;i<n;++i)
#define fr1 for(int i=1;i<=n;++i)
#define cinA for(int i=0;i<n;++i){cin>>arr[i];}
#define cinA1 for(int i=1;i<=n;++i){cin>>arr[i];}
#define coutA for(int i=0;i<n;++i){cout<<arr[i]<<" ";}
#define ll long long
#define lnarray sizeof(arr)/sizeof(*arr)
#define vi vector<int>
#define vs vector<string>
void Fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int RD()
{
    int i ;
    cin>>i;
    return i;
}

inline float RF()
{
    float i ;
    cin>>i;
    return i;
}

inline double RDO()
{
    double i ;
    cin>>i;
    return i;
}

inline string RS()
{
    string i ;
    cin>>i;
    return i;
}

inline ll RLL()
{
    ll i ;
    cin>>i;
    return i;
}

ll sumSet(ll n)
{
    return (1ll*n*(n+1))/2;
}
string s;


bool isPrime(int n)
{
    if(n==1)
        return false;
    for(int i=2; i*i<=n; ++i)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int sumDigit(int n){
int sum =0;
  while (n != 0)
    {
        sum+= + n % 10;
        n = n / 10;
    }
    return sum;
}

ll power2(int n){
  ll ans=(1<<n);
  return ans;
}

ll sumpow2(ll n){
 ll sum=(n*(n+1)*(2*n-1))/6;
 return sum;
}


int main(){
    Fast();
//freopen("output.txt" , "w" , stdout);
//freopen("wall.in" , "r" , stdin);
   string a=RS() , b=RS() ,s=a+b ;
   stringstream v( s );
   int n=0;
   v >> n ;
   int y=sqrt(n) ;
   if(y*y == n)
    cout << "Yes";
   else
    cout << "No";

}


Measured memory_bytes: 256
#include<iostream>
    #include<algorithm>
    #include<functional>
    #include<cmath>
    #include<string>
    #include<vector>
    #include<stack>
    #include<queue>
    #include<map>
    #include<set>
    #include<deque>
    using namespace std;
    #define ll long long
    const int mod = 1000000007;
    const ll INF = 1000000000000000000;
     
    struct UnionFind {
    	vector<int> par;
    	UnionFind(int x) : par(x, -1) {}
    	void init(int x) { par.assign(x, -1); }
    	int root(int x) {
    		if (par[x] <= -1) return x;
    		else return root(par[x]);
    	}
    	bool issame(int x, int y) {
    		return root(x) == root(y);
    	}
    	bool merge(int x, int y) {
    		x = root(x); y = root(y);
    		if (x == y) return false;
    		if (par[x] > par[y]) swap(x, y);
    		par[x] += par[y];
    		par[y] = x;
    		return true;
    	}
    	int size(int x) {
    		return -par[root(x)];
    	}
    };
     
    int p[100010];
    int main()
    {
    	int N, M;
    	cin >> N >> M;
    	for (int i = 0; i < N; i++) {
    		cin >> p[i];
    		p[i]--;
    	}
    	UnionFind uf(N);
    	for (int i = 0; i < M; i++) {
    		int a, b;
    		cin >> a >> b;
    		a--; b--;
    		uf.merge(a, b);
    	}
    	int ans = 0;
    	for (int i = 0; i < N; i++) {
    		if (uf.issame(i, p[i])) ans++;
    	}
    	cout << ans << endl;
    }


Measured memory_bytes: 4020
W, H, x, y = map(int, input().split())
max_s = W*H/2
cnt = 0
if x*H == max_s:
    cnt += 1
if y*W == max_s:
    cnt += 1
if x*y/2 == max_s:
    cnt += 1

if cnt > 1:
    print(max_s, 1)
else:
    print(max_s, 0)


Measured memory_bytes: 2940
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  (n, m) = InputLine.to_ia

  flag = true
  v = [-1] * n

  m.times do |i|
    (s, c) = InputLine.to_ia

    if v[s - 1] < 0 then
      v[s - 1] = c
    else
      if v[s - 1] != c then
        flag = false
        break
      end
    end
  end

  unless flag then
    puts (-1).to_s
    return
  end

  if ((n > 1) and (v[0] == 0)) then
    flag = false
  end
  
  unless flag then
    puts (-1).to_s
    return
  end
  
  v[0] = 1 if ((n > 1) and (v[0] < 0))
  n.times{|i| v[i] = 0 if v[i] < 0}
  puts v.map(&:to_s).join('')
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int a[51],b[51],c[51],d[51];
int main(){
    int n,m;
    cin>>n>>m;
    rep(i,n) cin>>a[i]>>b[i];
    rep(i,m) cin>>c[i]>>d[i];
    int cur;
    rep(i,n){
        int ds=1000100010;
        rep(j,m){
            if(abs(a[i]-c[j])+abs(b[i]-d[j])<ds){
                cur=j+1;ds=abs(a[i]-c[j])+abs(b[i]-d[j]);
            }
        }
        cout<<cur<<endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
    int N, A, B;
    cin >> N >> A >> B;

    // 答え
    int ret = 0;

    for (int i = 1; i <= N; ++i)
    {
        int a = i;

        // 各桁の和を求める
        int sum = 0;
        while (a > 0)
        {
            sum += a % 10;
            a /= 10;
        }

        if (A <= sum && sum <= B)
        {
            ret += i;
        }
    }

    cout << ret << endl;

    return 0;
}


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

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

    rep(i, n)
    {
        if (a[i] % 2 == 0)
        {
            if (a[i] % 6 != 0 && a[i] % 10 != 0)
            {
                puts("DENIED");
                return 0;
            }
        }
    }
    puts("APPROVED");
}

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

using namespace std;

int main() {
   int n,i;
   cin >>  n >> i;
   cout << n-i+1 << endl;
}

Measured memory_bytes: 256
from math import gcd


G = [[gcd(l, r) for l in range(201)] for r in range(201)]
            
K = int(input())

S = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            S += G[G[a][b]][c]

print(S)


Measured memory_bytes: 9520
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

class Main {
	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			String[] list = br.readLine().split(" ");
			List<Integer> ret = new ArrayList<Integer>();
			int i;
			for (i = 0; i < list.length; i++) {
				ret.add(Integer.parseInt(list[i]));
			}
			Collections.sort(ret);
			String output = "";
			for (int num : ret) {
				output = output + num + " ";
			}
			System.out.println(output.substring(0, output.length() - 1));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

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

int main(){
    int n; cin >> n;
    vector<int> h(n);
    for(auto& v:h){
        cin >> v;
    }
    vector<int> dp(n, 0);
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=2; i<n; i++){
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n-1] << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
 

int main(){
  ll N,K,an=0;
  
  cin>>N>>K;
  vector<ll> vec(N);
	for (int i = 0; i < N; i++) {
  		cin >> vec.at(i);
	}
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  rep(i,K){
  an+=vec.at(i);
  }

  cout<<an<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<sstream>
#include<map>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
typedef long long ll;
typedef long double ld;
const ll MOD =  1000000007;
using pll= pair<int, int>;
struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    int size(int x) {
        return -par[root(x)];
    }
};
int main() {
    int k, l, n,a,b; cin >> n >> k >> l;
    UnionFind tree1(n), tree2(n);
    rep(i, k) {
        cin >> a >> b; a--; b--;
        tree1.merge(a, b);
    }rep(i, l) {
        cin >> a >> b; a--; b--;
        tree2.merge(a, b);
    }
    map<pll, int> mp;
    rep(i, n) {
        pll v(tree1.root(i), tree2.root(i));
        mp[v]++;
    }rep(i, n) {
        pll p(tree1.root(i), tree2.root(i));
        cout << mp[p] << " ";
    }
}

Measured memory_bytes: 13568
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

vector<double> X,Y;
double MEMO[100][100][100];

double kakudo(int a,int b,int c){
	if(MEMO[a][b][c] != -100){
		return MEMO[a][b][c];
	}
	double retval = acos(((X[b]-X[a])*(X[c]-X[a]) + (Y[b]-Y[a])*(Y[c]-Y[a]))
		/ pow(pow(X[b]-X[a],2) + pow(Y[b]-Y[a],2),0.5) / pow(pow(X[c]-X[a],2) + pow(Y[c]-Y[a],2), 0.5));
	//cout<<((X[b]-X[a])*(X[c]-X[a]) + (Y[b]-Y[a])*(Y[c]-Y[a]))
	//	/ pow(pow(X[b]-X[a],2) + pow(Y[b]-Y[a],2),0.5) / pow(pow(X[c]-X[a],2) + pow(Y[c]-Y[a],2), 0.5)<<" aaa"<<endl;
	MEMO[a][b][c] = retval;
	return retval;
}


bool kakomare(int a,int b,int c,int d){
	double wa = kakudo(a,b,c) + kakudo(a,c,d) + kakudo(a,d,b);
	if(wa >= 0.99999 * 2 * M_PI && wa <= 1.00001 * 2 * M_PI){
		return true;
	}
	return false;
}


int main(void){
	ll n,m;
	double x,y;
	cin>>n;
	rep(i,n){
		rep(j,n){
			rep(k,n){
				MEMO[i][j][k] = -100;
			}
		}
	}
	vector<double> ans;
	rep(i,n){
		cin>>x>>y;
		X.push_back(x);
		Y.push_back(y);
	}
	if(n==2){
		cout<<0.5<<endl;
		cout<<0.5<<endl;
		return 0;
	}
	rep(i,n){
		bool isZero = false;
		rep(j,n){
			if(isZero || j==i) continue;
			rep(k,n){
				if(isZero || k==i || k==j) continue;
				rep(l,n){
					if(isZero || l==i || l==j || l==k) continue;
					if(kakomare(i,j,k,l)){
						isZero = true;
						break;
					}
				}
				if(isZero) break;
			}
			if(isZero) break;
		}
		if(isZero){
			ans.push_back(0);
			continue;
		}
		double memo = 1000;
		rep(j,n-1){
			if(j==i) continue;
			for(int k=j+1; k<n;k++){
				if(k==j || k==i) continue;
				//cout<<kakudo(i,j,k)<<endl;
				memo = min(memo, M_PI - kakudo(i,j,k));
			}
		}
		ans.push_back(memo/2/M_PI);
	}
	rep(i,n){
		cout<<ans[i]<<endl;
	}
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    int a[n];

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

    sort(a, a+n);

    int ans = n;
    for (int i = 1; i < n; i++) {
        if (a[i] == a[i-1]) {
            a[i] = 0;
            ans -= 2;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld =long double;
const ld eps = 1e-9;

enum R_Way {
	R_Left,
	R_Front,
	R_Right,
	R_Back,

	R_Dummy,
};

struct Dice {
	int tp;
	int bo;
	int no;
	int so;
	int ea;
	int we;
	Dice(int tp_, int bo_, int no_, int so_, int ea_, int we_) :
		tp(tp_), bo(bo_), no(no_), so(so_), ea(ea_), we(we_) {

	}
	Dice(vector<int>pips_) {

	}

	Dice() {
		tp = 1;
		/*bo = 6;
		no = 2;
		so = 5;
		ea = 3;
		we = 4;*/
	}

	int rotate(const R_Way way) {
		switch (way) {
		case R_Right: {
			int c = tp;
			tp = we;
			we = bo;
			bo = ea;
			ea = c;
		}
					  break;
		case R_Back: {
			int c = tp;
			tp = so;
			so = bo;
			bo = no;
			no = c;
		}
					 break;
		case R_Left: {
			int c = tp;
			tp = ea;
			ea = bo;
			bo = we;
			we = c;
		}
					 break;
		case R_Front: {
			int c = tp;
			tp = no;
			no = bo;
			bo = so;
			so = c;
		}
					  break;
		default:
			assert(false);
		}
		return tp;
	}
	int rotate(const int way) {
		return rotate(static_cast<R_Way>(way));
	}
	void spin(const int  clockwise) {
		if (!clockwise) {

			rotate(R_Way::R_Left);
			rotate(R_Way::R_Back);
			rotate(R_Way::R_Right);
		}
		else {

			rotate(R_Way::R_Left);
			rotate(R_Way::R_Front);
			rotate(R_Way::R_Right);
		}
	}
	int hash()const {
		return tp + we * 6 + no * 36;
	}
};
int geteast(int top, int south) {
	map<pair<int, int>, int>mp;
	mp[make_pair(1, 2)] = 3;
	mp[make_pair(1, 3)] = 5;
	mp[make_pair(2, 3)] = 1;
	mp[make_pair(2, 4)] = 6;
	bool rev = false;
	if (top >= 4) {
		rev = !rev; top = 7 - top;
	}
	if (south >= 4) {
		rev = !rev; south = 7 - south;
	}
	if (top > south) {
		rev = !rev; swap(top, south);
	}
	return mp[make_pair(top, south)];
}

bool connect(char a, char b) {
	return abs(a-b)==abs('A'-'a');
}

bool solve(bitset<8>&used, const int now, vector<Dice>&dices) {
	if(now==8)return true;
	else {
		for (int i = 0; i < 8; ++i) {
			if(used[i])continue;
			else {
				for (int tp = 1; tp <= 6; ++tp) {
					for (int so = 1; so <= 6; ++so) {
						if(tp==so||tp+so==7)continue;
						int le=geteast(tp,so);

						vector<int>perms(6);
						perms[0]=tp-1;
						//perms[1]=
					}
				}
			}
		}
	}
}

int main()
{
	int N;cin>>N;
	for (int i = 0; i < N; ++i) {
		vector<ld>v(8);
		for(int j=0;j<8;++j)cin>>v[j];

		ld ax=v[2]-v[0];
		ld ay=v[3]-v[1];

		ld bx=v[6]-v[4];
		ld by=v[7]-v[5];

		bool ok=abs(ax*by-bx*ay)<eps/1000;

		if(ok)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3080
// 2020-08-17 21:25:24
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

const int MX = 310;
const ll inf = 1e18;
ll dp[MX][MX];
void answer() {
  int n, k;
  cin >> n >> k;
  if(n == k) {
    cout << 0 << '\n';
    return;
  }
  vector<ll> h(n+1);
  rep(i, n) cin >> h[i+1];
  repc(i, n) repc(j, n) dp[i][j] = inf;
  dp[0][0] = 0;
  REPC(i, 1, n) rep(j, i) REPC(ki, 1, min(i, n-k)) {
    chmin(dp[i][ki], dp[j][ki-1] + max(0ll, h[i] - h[j]));
  }
  ll ans = inf;
  repc(i, n) chmin(ans, dp[i][n-k]);
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 4392
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
  int N,M;
  cin >> N >> M;
  vector<vector<long long int> >S(N, vector<long long int>(2));
  vector<vector<long long int> >P(M, vector<long long int>(2));
  for(int i=0; i < N; i++){
    cin >> S[i][0];
    cin >> S[i][1];
  }
  for(int i=0; i < M; i++){
    cin >> P[i][0];
    cin >> P[i][1];
  }
  for(int i=0; i < N; i++){
    long long int min=1000000000;
    int minp;
    for(int j=0; j < M; j++){
      long long int man = abs(S[i][0] - P[j][0]) + abs(S[i][1] - P[j][1]);
      if(man < min){
	minp = j + 1;
	min = man;
      }
    }
    cout << minp << endl;
  }
  return 0;
}


Measured memory_bytes: 256
class Cheese

  def initialize(f)
    @u,@v,@w = f.sort
    @x = Math.sqrt(@u**2+@v**2)
  end

  def thru(r)
    return (2*r > @x) ? "OK" : "NA"
  end

end

def main
  if true then
    fh=STDIN
  else
    fh=open("in1_0107.txt")
  end

  while fh.gets do
    u,v,w = $_.chomp.split.map{|x| x.to_i}
    break if u==0 and v==0 and w==0
    n = fh.gets.chomp.to_i
    rad = []
    0.upto(n-1){|i|
      rad[i] = fh.gets.chomp.to_i
    }

    ch = Cheese.new([u,v,w])

    0.upto(n-1){|i|
      puts ch.thru(rad[i])
    }
  end
end

main
if $0 == __FILE__ then
end

Measured memory_bytes: 8684
/*
	0104:Magical Tiles
*/
#include	<iostream>

using namespace std;

//GV
char map[101][101];

//FN
void refmaps(void);
void start(void);

int main(void) {
	while(1) {
		int W, H;
		
		refmaps();
		
		cin >> H >> W;
		if(H == 0 && W == 0) { break; }
		
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				char c;
				cin >> c;
				map[i][j] = c;
			}
		}
		
		start();
	}
	return 0;
}

void refmaps(void) {
	for(int i = 0; i < 101; i++) {
		for(int j = 0; j < 101; j++) {
			map[i][j] = '.';
		}
	}
}

void start(void) {
	int h = 0, w = 0;
	const int vx[4] = {1, 0, -1, 0}, vy[4] = {0, 1, 0, -1};
	const char vc[4] = {'>', 'v', '<', '^'};
	
	while(1) {
		if(map[h][w] == '.') { cout << w << ' ' << h << endl; return; }
		else if(map[h][w] == 'L') { cout << "LOOP" << endl; return; }
		else {
			for(int i = 0; i < 4; i++) {
				if(map[h][w] == vc[i]) {
					map[h][w] = 'L';
					h += vy[i];		w += vx[i];
				}
			}
		}
	}
}

Measured memory_bytes: 1168
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,n) for(int i=1;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define Rrep(i,n) for(int i=n-1;i>0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
#define P pair<int,int>
#define Pll pair<ll,ll>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main(){
    int n,x; cin >> n >> x;
    int res=0;
    int ans=0;
    if(res<=x) ans++;
    rep(i,n){
        int q; cin >> q;
        res+=q;
        if(res<=x) ans++;
    }
    cout << ans << endl;
}


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

int main() {
    int cnt[4]{};
    REP(i,3){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        cnt[a]++;
        cnt[b]++;
    }
    bool ok = true;
    REP(i,4) if(cnt[i]>2) ok = false;
    cout << (ok?"YES":"NO") << endl;
    return 0;
}


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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int N;
int main() {
    std::cin >> N;
    int rn = std::sqrt(N);
    std::cout << rn * rn << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n, k;
	cin >> n >> k;
	if (k > (n - 1) * (n - 2) / 2) {
		cout << -1 << endl;
		return 0;
	}

	vector<vector<ll>> ans(0);
	for (ll i = 1; i < n; i++) {
		ans.push_back({1, i + 1});
	}

	ll cnt = (n - 1) * (n - 2) / 2;
	for (ll i = 1; i < n - 1; i++) {
		for (ll j = i + 1; j < n; j++) {
			if (cnt == k) {
				i = n;
				break;
			}
			ans.push_back({i + 1, j + 1});
			cnt--;
		}
	}
	cout << ans.size() << endl;
	for (ll i = 0; i < ans.size(); i++) {
		cout << ans[i][0] << " " << ans[i][1] << endl;
	}
}


Measured memory_bytes: 640
import math
n = int(input())
p = list(map(int, input().split()))

# 連続する部分列を数える
cnt=0
ary=[]
for i in range(n):
    if p[i]==i+1:
        cnt+=1
    else:
        ary.append(cnt)
        cnt=0
ary.append(cnt)
print(sum([math.ceil(i/2) for i in ary if i > 0]))

Measured memory_bytes: 13812
#include <stdio.h>
#include <math.h>

a, b, x;
double s, t, ans1, ans2;

main () {
	scanf("%d %d %d", &a, &b, &x);
	s = ((double)x) / a;
	
	// shita sankaku
	t = s * 2 / b;
	if(t<=a){
	  printf("%lf\n", 90-atan2(t, b)*360/2/M_PI);
	  return 0;
	}
	
	// ue sankaku
	t = (a*b - s) * 2 / a;
	printf("%.7lf\n",atan2(t, a)*360/2/M_PI);
}


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

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

	string ans = "NG";
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			ans = "OK";
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
const zeroPadding = (num, length) => {
  return ('0000000000' + num).slice(-length);
};

const Main = (input) => {
  // 入力値の整形
  /*
  753数を出力する。
  */
  const numberArray = [7, 5, 3];
  const genaratedArray = Array(Math.pow(3, input.length))
    .fill(0)
    .map((a, b) => {
      return b.toString(3);
    })
    .reduce((accurator, value) => {
      // inputが3桁の場合は
      // 000~222?
      for (var index = value.length; index <= input.length; index++) {
        accurator.push(zeroPadding(value, index));
      }
      return accurator;
    }, [])
    .filter((value) => {
      return (
        value.split('').filter((x, i, self) => {
          return self.indexOf(x) === i;
        }).length === 3
      );
    })
    .map((value, index, romArray) => {
      return value.split('').reduce((accurator, value) => {
        return accurator + String(numberArray[value]);
      }, '');
    })
    .filter((value) => {
      return Number(value) <= Number(input);
    });

  console.log(genaratedArray.length);
};

//* この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 51608
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;

const string src = "Hoshino";
bool check(string str,int n,int m){
    if(str[n]==src[m]){
        if(m==6) return true;
        return check(str,n+1,m+1);
    }
        return false;
}
int main(){
    int n;
    cin >> n;
    cin.ignore();
    string *str=new string[n];
    for(int i=0;i<n;i++){
        getline(cin,str[i]);
        for(int j=0;j<str[i].size();j++){
            if(check(str[i],j,0)){
                str[i][j+6]='a';
                j+=5;
            }
        }
    }
    for(int i=0;i<n;i++){
        cout << str[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1224
#include<cstdio>
int n,f[200005];
long long ans=0;
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&f[i]);
    int l=1,r=0,x=0,y=0;
    for (;l<=n;x=x^f[l],y=y-f[l],l++)
    {
        while ((x^f[r+1])==(y+f[r+1])&&r<n) ++r,x=x^f[r],y=y+f[r];
        ans=ans+(r-l+1);
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 896
import java.util.Scanner;

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

        sc.nextInt();
        String s = sc.next();

        System.out.println(solve(s));

        sc.close();
    }

    static String solve(String s) {
        for (String prefix : new String[] { "SS", "SW", "WS", "WW" }) {
            String assignment = buildAssignment(s, prefix);
            if (assignment != null) {
                return assignment;
            }
        }

        return "-1";
    }

    static String buildAssignment(String s, String prefix) {
        StringBuilder result = new StringBuilder(prefix);
        for (int i = 1; i < s.length() - 1; ++i) {
            result.append(another(s, result, i, result.charAt(i - 1)));
        }

        return (another(s, result, result.length() - 1, result.charAt(result.length() - 2)) == result.charAt(0)
                && another(s, result, 0, result.charAt(1)) == result.charAt(result.length() - 1)) ? result.toString()
                        : null;
    }

    static char another(String s, StringBuilder assignment, int index, char neighbor) {
        if (assignment.charAt(index) == 'S') {
            if (s.charAt(index) == 'o') {
                return neighbor;
            } else {
                return invert(neighbor);
            }
        } else {
            if (s.charAt(index) == 'o') {
                return invert(neighbor);
            } else {
                return neighbor;
            }
        }
    }

    static char invert(char neighbor) {
        return (neighbor == 'S') ? 'W' : 'S';
    }
}

Measured memory_bytes: 26852
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i >= 0; i--)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int R;
    cin >> R;
    printf("%.20f",R*2*acos(-1));

    return 0;
}

Measured memory_bytes: 3756
#include<iostream>
#include<string>
using namespace std;
int main() {
	//<<<ここにプログラムを書く>>>
	int x, y, z;
	cin >> x >> y >> z;
	if (x <= y)
	{
		if (x >= z)
		{
			cout << z << " " << x << " " << y << endl;
		}
		else if (y <= z)
		{
			cout << x << " " << y << " " << z << endl;
		}
		else
		{
			cout << x << " " << z << " " << y << endl;
		}
	}
	if (x >= y)
	{
		if (x <= z)
		{
			cout << y << " " << x << " " << z << endl;
		}
		else if (y >= z)
		{
			cout << z << " " << y << " " << x << endl;
		}
		else
		{
			cout << y << " " << z << " " << x << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3076
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

n, m = map(int, input().split())
s = input()
t = input()
gcd_nm = gcd(n, m)
for i in range(gcd_nm):
    if s[i * n // gcd_nm] != t[i * m // gcd_nm]:
        print(-1)
        break
else:
    print(n*m//gcd_nm)

Measured memory_bytes: 9292
#!/usr/bin/env python3

def main():
    N = int(input())
    *H, = map(int, input().split())

    h_min = H[0]
    flag = True
    for i in range(0, N):
        if H[i] - 1 >= h_min:
            H[i] = H[i] - 1
        elif H[i] < h_min:
            flag = False
            break
        h_min = H[i]
    
    if flag:
        print('Yes')
    else:
        print('No')


main()

Measured memory_bytes: 15020
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: i64 = input();
    let b: i64 = input();
    println!(
        "{}",
        if a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 {
            "Possible"
        } else {
            "Impossible"
        }
    );
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
    int n;
    long long sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(i%3 == 0) continue;
        if(i%5 == 0) continue;
        sum+=i;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3628
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,W,w[110],v[110],dp[110][100010],ans=0;

int main()
{
  cin>>n>>W;
  rep(i,n) cin>>w[i]>>v[i];
  rep(i,105) rep(j,100005) dp[i][j]=2e9;
  dp[0][0]=0;
  rep(i,n)
  {
  	rep(j,100005)
  	{
  		if(dp[i][j]==2e9) continue;
  		dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
  		if(dp[i][j]+w[i]<=W) dp[i+1][j+v[i]]=min(dp[i+1][j+v[i]],dp[i][j]+w[i]);
		}
	}
	rep(i,100005) if(dp[n][i]<=W) ans=i;
	cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 41216
import sys
sys.setrecursionlimit(100000)

N, M = map(int, input().split())
childs = [[] for _ in range(N)]
for i in range(M):
    p, c = map(int, input().split())
    childs[p-1].append(c-1)

depth = [-1] * N
def dfs(n):
    if depth[n] != -1:
        return depth[n]
    if childs[n]:
        depth[n] = max((dfs(nc) for nc in childs[n])) + 1
    else:
        depth[n] = 0
    return depth[n]

print(max((dfs(n) for n in range(N))))


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

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    while(true) {
        if(a+1 != b) {
            ++a;
        } else {
            if(a == 1) {
                cout << "Borys";
                return 0;
            }
            --a;
        }
        if(b-1 != a) {
            --b;
        } else {
            if(b == n) {
                cout << "Alice";
                return 0;
            }
            ++b;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  int a,b,c,d =0;
  cin>>a;
  a = a%10;
  if(a==2||a==4||a==5||a==7||a==9){
    cout<<"hon";
  }else if(a==3){
    cout<<"bon";
  }else{
    cout<<"pon";
  }
}

Measured memory_bytes: 3056
#include <stdio.h>
#include <iostream>
#include <vector>

//https://atcoder.jp/contests/abc074/tasks/abc074_b

int main()
{
    std::ios::sync_with_stdio(false); // toggler av synkronisjon mellom c og c++ data streams. kan ikke blade de etter skrudd av
    std::cin.tie(NULL);               //gj;r at man ikke venter på cout og de can printe samtidig tror jeg

    //linjen er opp til 100. det er en linje p[ lengde hundre med hus p[ bare de nevte stedene]]

    int numberOfLines, lineLength;
    std::cin >> numberOfLines >> lineLength;

    int total = 0;
    for (int i = 0; i < numberOfLines; i++)
    {
        int location;
        std::cin >> location;
        total = total + 2 * std::min(location, lineLength - location);
    }

    std::cout << total << "\n";
}


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

int N, A[3][3], b[10];
bool appear[3][3];

int main()
{

    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < 3; j++)
            cin >> A[i][j];
    }
    cin >> N;
    for(int i = 0; i < N; i++)
        cin >> b[i];
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N; j++)
        {
            appear[i][j] = false;
            for(int k = 0; k < N; k++)
            {
                if(A[i][j] == b[k])
                    appear[i][j] = true;
            }
        }
    }
    string ANS = "No";
    for(int i = 0; i < 3; i++)
    {
        if(appear[i][0] and appear[i][1] and appear[i][2])
            ANS = "Yes";
    }
    for(int i = 0; i < 3; i++)
    {
        if(appear[0][i] and appear[1][i] and appear[2][i])
            ANS = "Yes";
    }
    if(appear[0][0] and appear[1][1] and appear[2][2])
        ANS = "Yes";
    if(appear[0][2] and appear[1][1] and appear[2][0])
        ANS = "Yes";
    cout << ANS << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define deb(x) cout << #x << "=" << x << endl

int main() {
	// your code goes here
	ll t;
	t=1;
	while(t--)
	{
	    ll n,k;
	    cin>>n>>k;
	    ll A[n];
	    for(ll i=0;i<n;i++)
	    {
	        cin>>A[i];
	    }
	    ll dp[n+1];
	    dp[0]=0;
	    for(ll i=1;i<n;i++)
	    {
	        ll ans=INT_MAX;
	        for(ll j=1;j<=k;j++)
	        {
	           if(i-j>=0)
	           {
	               ans=min(ans,abs(A[i]-A[i-j])+dp[i-j]);
	           }
	        }
	        dp[i]=ans;
	    }
	    cout<<dp[n-1];
	}
	return 0;
}


Measured memory_bytes: 5144
#include <bits/stdc++.h>
#define PI 2*asin(1)
#define int long long
#define mod 1000000007
#define all(a) begin(a),end(a)
#define fore(i, j, n) for(long long i = j; i < n;i++)
using namespace std;

int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    double a,b,x; cin>>a>>b>>x;
    if(x/a>= a*b/2)cout << setprecision(20)<< atan(2*(a*b-x/a)/a/a)*90.0/asin(1);
else 
cout << setprecision(20)<< 90- atan((2*x/a/b/b))*90.0/asin(1);
}


Measured memory_bytes: 512
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#else
#define debug(fmt, ...)
#endif

int main(void) {
    int num, tickets;
    cin >> num >> tickets;
    priority_queue<int> queue;
    for(int i = 0; i < num; i++) {
        int val;
        cin >> val;
        queue.push(val);
    }

    for(int i = 0; i < tickets; i++) {
        int val = queue.top(); queue.pop();
        val >>= 1;
        queue.push(val);
    }

    int64_t sum = 0;
    while(!queue.empty()) {
        sum += queue.top();
        queue.pop();
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3868
#include<stdio.h>
int main(){
    int a,b,c,d,e;
    scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
    int x=c*60+d;
    int y=a*60+b;
    int z=x-y-e;
    printf("%d\n",z);
}

Measured memory_bytes: 1720
//
// Created by yamunaku on 2019/11/26.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(n % 2 == 0 && s.substr(0, n / 2) == s.substr(n / 2, n / 2)) CYES;
    else CNO;
    return 0;
}

Measured memory_bytes: 256
s = input()
t = input()

p = 0
roop = 0
dic = [['' for i in range(len(s))] for j in range(26)]

for i in range(len(t)):
    dis = 0
    if dic[ord(t[i])-97][p] == '':
        for j in range(p,len(s)):
            if t[i] == s[j]:
                for k in range(p,j+1):
                    dic[ord(t[i])-97][k] = j
                dis = 1
                break
        if dis == 0:
            for j in range(0,p):
                if t[i] == s[j]:
                    for k in range(p,len(s)):
                        dic[ord(t[i])-97][k] = j
                    for k in range(0,j+1):
                        dic[ord(t[i])-97][k] = j
                    dis = 1
                    break
        if dis == 0:
            dis = 2
            break
    if p > dic[ord(t[i])-97][p]:
        roop += 1
    if dic[ord(t[i])-97][p] == len(s)-1:
        roop += 1        
        p = 0
    else:
        p = dic[ord(t[i])-97][p] + 1

if dis == 2:
    print(-1)
else:
    print(roop*len(s)+p)

Measured memory_bytes: 140148
#include <stdio.h>

int main(void) {

    int a, b, c;
    int tmp;

    scanf("%d %d %d", &a, &b, &c);

    tmp = b;
    b = a;
    a = c;
    c = tmp;

    printf("%d %d %d", a, b, c);


    return 0;
}

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

class Main {
	final static BufferedReader br = new BufferedReader(new InputStreamReader(
			System.in));
	final static StringBuilder out = new StringBuilder();
	public static void main(String[] Args) throws IOException {
		Queue<Process> p = new ArrayDeque<Process>();
		Process work;
		int elapse = 0;
		String[] in = br.readLine().split("\\s+");
		int n = Integer.parseInt(in[0]);
		int q = Integer.parseInt(in[1]);
		for (int i = 0; i < n; i++) {
			work = new Process(br.readLine());
			p.add(work);
		}
		while ((work = p.poll()) != null) {
			if (work.time <= q) {
				elapse += work.time;
				out.append(work.name).append(' ').append(elapse).append('\n');
			} else {
				work.time -= q;
				elapse += q;
				p.add(work);
			}
		}
		System.out.print(out);
	}
}

class Process {
	String name;
	int time;
	public Process(String str) {
		String[] in = str.split("\\s+");
		name = in[0];
		time = Integer.parseInt(in[1]);
	}
	public Process(String name, int time) {
		this.name = name;
		this.time = time;
	}
}

Measured memory_bytes: 60092
#include<stdio.h>

int solve(int i,int m);
int n,A[50];

int main(){
    int q,M,i;

    scanf("%d",&n);
    for(i = 0; i < n; i++) scanf("%d",&A[i]);

    scanf("%d",&q);
    for(i = 0; i < q; i++){
    scanf("%d",&M);
    if(solve(0,M)) printf("yes\n");
    else printf("no\n");
    }
return 0;
}
int solve(int i,int m){
    if(m == 0) return 1;
    if(i >= n) return 0;
    int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}


Measured memory_bytes: 2104