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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n + 2];
		a[0] = 0;
		int ans = 0, total = 0;
		for (int i = 1; i <= n; ++i) {
			a[i] = sc.nextInt();
			total += Math.abs(a[i] - a[i - 1]);
		}
		a[n + 1] = 0;
		total += Math.abs(a[n + 1] - a[n]);
		sc.close();
		int tmp = 0;
		for (int i = 1; i <= n; ++i) {
			tmp = Math.abs(a[i] - a[i - 1]) + Math.abs(a[i + 1] - a[i]);
			ans = total - tmp;
			tmp = Math.abs(a[i + 1] - a[i - 1]);
			ans += tmp;
			System.out.println(ans);
		}
	}

}


Measured memory_bytes: 55424
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::prelude::BufRead;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufReader, BufWriter, Write};
#[allow(unused_imports)]
use std::mem::swap;
#[allow(unused_imports)]
use std::str::FromStr;

fn main() {
	let arr = read_chars();
	let mut ans = std::usize::MAX;
	for ch in [('0', '1'), ('1', '0')].iter() {
		let mut count = 0;
		for i in 0..arr.len() {
			if i % 2 == 0 {
				if arr[i] != ch.0 {
					count += 1;
				}
			} else {
				if arr[i] != ch.1 {
					count += 1;
				}
			}
		}
		if count < ans {
			ans = count;
		}
	}
	println!("{}", ans);
}
#[allow(dead_code)]
fn read<T>() -> T
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf.trim().parse().unwrap();
}

#[allow(dead_code)]
fn read_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::with_capacity(100);
    stdin().read_line(&mut buf).unwrap();
    return buf.split_whitespace().map(|s| s.parse().unwrap()).collect();
}

#[allow(dead_code)]
fn read_matrix<T>() -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    use std::io::prelude::*;
    let stdin = stdin();
    let mut reader = BufReader::with_capacity(100 * 1024, stdin);
    let mut line = String::with_capacity(100);
    let mut matrix: Vec<Vec<T>> = Vec::new();

    while reader.read_line(&mut line).unwrap() > 0 {
        matrix.push(
            line.trim()
                .split_whitespace()
                .map(|s| s.parse().unwrap())
                .collect(),
        );
        line.clear();
    }

    return matrix;
}

#[allow(dead_code)]
fn read_chars() -> Vec<char> {
    let stdin = stdin();
    let mut buf = String::new();
    let _bytes = stdin.read_line(&mut buf).unwrap();
    return buf.trim().chars().collect();
}


Measured memory_bytes: 4352
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
// #define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 2e5+5, LG = 17, MOD = 1e9+7;
const int SQ = 450;
const long double EPS = 1e-7;
int n, k;
int C[2005][2005];
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  f(i,0,2005)
    f(j,0,i+1)
      if(i==j)C[i][j]=1;
      else  C[i][j] = (C[i-1][j]+C[i-1][j-1])%MOD;

  cin >> n >> k;

  f(i,1,k+1){
    cout << C[n-k+1][i] * 1ll * C[k-1][i-1] % MOD << "\n";
  }

  return 0;
}


Measured memory_bytes: 15104
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;

int main(){
    int N;
    int A[100000];
    cin >> N;
    vector<pair<int, int>> pairs(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        pairs[i] = make_pair(A[i], i);
    }

    sort(pairs.begin(), pairs.end());
    for (int i = 0; i < N;i++){
        cout << pairs[i].second + 1 << " ";
    }
    cout << endl;
}


Measured memory_bytes: 2048
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>d(n);
	repp(i, 0, n)cin >> d[i];
	sort(d.begin(), d.end());
	cout << d[n / 2] - d[n / 2 - 1] << endl;
}


Measured memory_bytes: 640
s = input()
# RR...RL...LLとなる文字列ssに分割して考える
import math
# len(ss) % 2 == 0 の場合は、境界にlen(ss)/2ずつ
# 奇数の場合は、ss[0]大、ss[1]小、→ss[偶数]大、ss[奇数]小
ans = [0] * len(s)
ss = []
start = 0
for i in range(len(s) - 1):
  if (s[i]=="L" and s[i+1]=="R"):
    ss.append(s[start:i+1])
    start = i+1
  elif i == len(s) - 2:
    ss.append(s[start:i+2])  
#print(ss)
# rlposはr,lの位置
sumlenj = 0
for j in ss: 
  rlpos = j.find("RL")
  if len(j) % 2 == 0:
    ans[sumlenj+rlpos] = int(len(j)/2)
    ans[sumlenj+rlpos+1] = int(len(j)/2)
  else:
    if rlpos % 2 == 0:
      ans[sumlenj+rlpos] = int(math.ceil(len(j)/2))
      ans[sumlenj+rlpos+1] = int(math.floor(len(j)/2))
    else:
      ans[sumlenj+rlpos] = int(math.floor(len(j)/2))
      ans[sumlenj+rlpos+1] = int(math.ceil(len(j)/2))
  sumlenj += len(j)
print(*ans)
  
    
    

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

const int N = 5500;

int a[N], dp[N];
long long sum[N];

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n;
	long long K; cin >> n >> K;
	for (int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
	
	dp[0] = 1;
	int Max = 0, ans = 0;
	for (int i = n; i >= 1; i--) {
		if (Max >= K - sum[i]);
		else {
			ans = i;
			break;
		}
		for (int s = K; s >= 0; s--) if (dp[s] && s + a[i] <= K) dp[s + a[i]] = 1;
		for (int s = 0; s < K; s++) if (dp[s]) Max = max(Max, s);
	}
	cout << ans << "\n";
	
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD 998244353
typedef long long int lli;

int main(){
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < n; ++i){
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int x,i,y[10000]={0};
	for(x=0;10000>=x;x++){
			scanf("%d",&y[x]);
		if(y[x]==0){
			break;
	}}
		for(i=0;i<=x;i++){
			if(y[i]==0){
				break;}
				printf("Case %d: %d\n",i+1,y[i]);
		}
	return 0;
}

Measured memory_bytes: 2716
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <set>

#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define MOD 1000000007

using namespace std;

int pow_mod(int a, int b, int p) {
	if (b == 0)return 1;
	else if (b % 2 == 0)return (pow_mod(a*a, b / 2, p) % p);
	else return (pow_mod(a, b - 1, p)*a%p);
}

int factorial_mod(int a, int p) {
	if (!a)return 1;
	else return a * factorial_mod(a - 1, p) % p;
}

int sum_digit(int N) {
	int ans = 0;
	for (; N != 0;) {
		ans += N % 10;
		N /= 10;
	}
	return ans;
}

int a, b,x;

int main(){
	scanf("%d %d %d", &a, &b,&x);
	if (a <= x && x <= a + b)printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		// input
		Scanner scan = new Scanner(System.in);
		long a = scan.nextLong();
		long b = scan.nextLong();
		long c = scan.nextLong();

		scan.close();

		long halfa = 0;
		long halfb = 0;
		long halfc = 0;

		int count = 0;

		while (true) {
			if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
				break;
			}

			halfa = a / 2;
			halfb = b / 2;
			halfc = c / 2;

			a = halfb + halfc;
			b = halfa + halfc;
			c = halfa + halfb;

			count++;
			if (a == b && b == c) {
				count = -1;
				break;
			}
		}
		System.out.println(count);

	}
}


Measured memory_bytes: 24276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int a,b,c;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>a>>b>>c;
    if(c<=a+b){cout<<"Yes\n";}
    else cout<<"No\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define sz(a) (int)a.size()
#define mp(a, b) make_pair(a, b)
#define all(a) a.begin(), a.end()

using namespace std;
typedef long long ll;

const int MAXN = 200500;

struct DSU
{
  vector <int> p, w;

  void build(int n)
  {
    w.resize(n);
    p.resize(n);
    forn(i, n)
      w[i] = 1, p[i] = i;
  }

  int get_leader(int v)
  {
    return v == p[v] ? v : p[v] = get_leader(p[v]);
  }

  void Union(int a, int b)
  {
    a = get_leader(a);
    b = get_leader(b);

    if (a == b)
      return;
    if (w[a] < w[b])
      swap(a, b);
    p[b] = a;
    w[a] += w[b];
  }
};

int n, k, l;

map<pair<int, int>, int> res;

int main()
{
  ios_base::sync_with_stdio(0);
  cin >> n >> k >> l;
  DSU road, rail;
  road.build(n);
  rail.build(n);
  forn(i, k)
  {
    int a, b;
    cin >> a >> b;
    a--, b--;
    road.Union(a, b);
  }
  forn(i, l)
  {
    int a, b;
    cin >> a >> b;
    a--, b--;
    rail.Union(a, b);
  }

  forn(i, n)
    res[mp(road.get_leader(i), rail.get_leader(i))]++;

  forn(i, n)
    cout << res[mp(road.get_leader(i), rail.get_leader(i))] << ' ';

	return 0;
}


Measured memory_bytes: 15104
#include <iostream>

using namespace std;

int main(){
    
    int N = 0;
    int M = 0;

    cin >> N >> M;

    int L[100010];
    int R[100010];

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

    //seek min R and max L
    int minR=100010;
    for(int i=0;i<M;i++){
        if(R[i] < minR){
            minR = R[i];
        }
    }
    int maxL =0;
    for(int i=0;i<M;i++){
        if(L[i] > maxL){
            maxL = L[i];
        }
    }

    int ret = minR - maxL + 1;

    if(ret<0){
        cout << 0 <<endl;
    }else{
        cout << ret << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
// The very basic /////////////////////////////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;
#define ALL_H 1

// Debug it by D(x) ///////////////////////////////////////////////////////////
#define DEBUG 0
#if DEBUG
#define D(x) x
#else
#define D(x)
#endif

// Print elements of containers using << operator /////////////////////////////
// pair
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
  return s << "(" << p.first << ", " << p.second << ")";}
// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  for (auto &elem : v) {
    s << elem;
    if (&elem != &v.back()) s << " ";
  }
  return s;
}
// 2 dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  for (auto &elem : vv) {
    s << elem;
    if (&elem != &vv.back()) s << endl;
  }
  return s;
}
// map
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
  s << "{" << endl;
  for (auto &elem: m) {
    s << " " << elem.first << " : " << elem.second << endl;
  }
  s << "}";
  return s;
}
//set
template<typename T> ostream& operator<<(ostream& s, const set<T>& m) {
  s << "{ ";
  for (auto &elem: m) {
    s << elem << " ";
  }
  s << "}";
  return s;
}

// Convenient macros //////////////////////////////////////////////////////////

// types
#define ll long long
#define ld long double
#define int ll
#define Pi pair<int, int>
#define Graph vector<vector<int>>
#define WeightGraph vector<vector<Pi>>

// other
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

// update max or min //////////////////////////////////////////////////////////

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 (b<a) { a=b; return 1; } return 0; }

// gcd
int gcd(int a,int b){return b?gcd(b,a%b):a;}

// for grids
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

///////////////////////////////////////////////////////////////////////////////
//                             Start Coding Here                             //
///////////////////////////////////////////////////////////////////////////////

signed main() {
  int x, y, z; cin >> x >> y >> z;
  int spp = y + z;
  D(cout << x << " "<< spp << endl);
  D(cout << x - z << endl);
  cout << (x-z) / spp << endl;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextLong()
  val a = (1..n).map { sc.nextLong() }

  val map = mutableMapOf<Long, Int>()
  for (ai in a) {
    val tmp = map.getOrElse(ai) { 0 }
    map.put(ai, tmp+1)
  }

  val size = map.filter { it.value % 2 != 0 }.size
  println(size)

}


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

#define fast ios::sync_with_stdio(0); cin.tie(0)

bool isValidNumber(int N,set<char> &D){
  string num = to_string(N);
  for(int i=0; i<num.size(); ++i)
    if(D.count(num[i])==1)
      return false;
  return true;
}

int main(){
  int N, K, i;
  set<char> D;
  char c;
  cin>>N>>K;
  for(i=0; i<K; i++){
    cin>>c;
    D.insert(c);
  }
  while(!isValidNumber(N,D)){
    N++;
  }
  cout<<N<<endl;
  
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

count = [0]*(10**5+1)
for ai in a:
    count[ai] += 1

ans = sum(a)    

q = int(input())
for _ in range(q):
    b,c = map(int,input().split())
    ans += (c-b)*count[b]
    print(ans)
    count[c] += count[b]
    count[b] = 0


Measured memory_bytes: 20868
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <limits>
#include <sstream>
#include <numeric>

#define seq(i, n) for (int i = 0; i < (n); i++)
#define seq2(i, f, t) for (int i = (f); i < (n); i++)
#define rev(i, n) for (int i = (n); i >= 0; i--)
#define rev2(i, f, t) for (int i = (f); i >= t; i--)
#define all(x) (x).begin(),(x).end()
#define max(x, y) x > y ? x : y
#define min(x, y) x < y ? x : y

using namespace std;

using ll = long long;

struct S {
  int b;
  int c;
};

bool operator< (const S& s1, const S s2) {
  return s1.c < s2.c;
}
bool operator> (const S& s1, const S s2) {
  return s1.c > s2.c;
}

void solve() {
  int n,m;
  cin >> n >> m;

  vector<int> cs;
  priority_queue<S, vector<S>> a;
  seq(i, n) {
    int d;
    scanf("%d", &d);
    cs.push_back(d);
  }
  sort(all(cs));
  seq(i, m) {
    int b,c;
    cin >> b >> c;
    a.push({b, c});
  }
  a.push({10000000, 0});
  S s = a.top();
  long sum = 0;
  for (const int& i: cs) {
    if (s.b <= 0) {
      a.pop();
      s = a.top();
    }
    if (s.c > i) {
      sum += s.c;
      s.b--;
    } else {
      sum += i;
    }
  }
  cout << sum << endl;
}

int main() {
  solve(); 

  return 0;
}


Measured memory_bytes: 1784
#include <iostream>
using namespace std;
int main(){
  int N = 3;
  //cin >> N;
  string ans;
  int fcount = 0;
  int scount = 0;
  for(int t=0;t<N;t++)
  {
    int n;
    cin >> n;
    if(n == 5) fcount++;
    if(n == 7) scount++;
  }
  if(fcount == 2 && scount == 1){ ans = "YES";} else{ ans = "NO";}
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// Last Change: 06/29/2019 22:40:21.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  ll N, M, S, T;
  cin >> N >> M;
  vector<ll> node(N, -1);

  map<int, int> mp;

  ll u, v;
  vector<vector<ll>> edge(N);
  for (ll i = 0; i < M; ++i) {
    cin >> u >> v;
    --u;
    --v;
    edge[u].push_back(v);
    ++mp[v];
  }

  cin >> S >> T;
  --S;
  --T;

  if (mp[T] == 0) {
    cout << -1 << endl;
    return 0;
  }

  queue<pair<ll, ll>> q;
  q.push(make_pair(S, 0));
  node[S] = 0;
  while (!q.empty()) {
    ll temp = q.front().first;
    ll step = q.front().second + 1;
    // cout << " " << temp << endl;
    q.pop();
    for (auto &&e : edge[temp]) {
      if (node[e] == -1 or node[e] % 3 != step % 3) {
        node[e] = step;
        q.push(make_pair(e, step));
      }
    }
    // cout << "   " << node[T] << endl;
    if (node[T] % 3 == 0) {
      // cout << node[T] << endl;
      cout << node[T] / 3 << endl;
      //NS::LoopUntilZeroInpput();
      return 0;
    }
  }

  cout << -1 << endl;

  //NS::LoopUntilZeroInpput();
}


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

namespace ConsoleApp15
{
    class Class237
    {
        static int[] dy = new int[4] { 0, 1, 0, -1 };
        static int[] dx = new int[4] { 1, 0, -1, 0 };
        static void Main()
        {
            var HW = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int H = HW[0], W = HW[1];
            var map = new bool[H, W];
            var que = new Queue<Tuple<int, int, int>>();
            for(int i = 0; i < H; i++)
            {
                var r = Console.ReadLine();
                for(int j = 0; j < W; j++)
                {
                    if (r[j] == '#')
                    {
                        map[i, j] = true;
                        que.Enqueue(Tuple.Create(i, j, 0));
                    }
                }
            }

            while (que.Count > 0)
            {
                var p = que.Dequeue();
                for(int i = 0; i < 4; i++)
                {
                    int ny = p.Item1 + dy[i];
                    int nx = p.Item2 + dx[i];
                    int nc = p.Item3 + 1;

                    if (0 <= ny && ny < H && 0 <= nx && nx < W)
                    {
                        if (!map[ny, nx])
                        {
                            map[ny, nx] = true;
                            que.Enqueue(Tuple.Create(ny, nx, nc));
                        }
                    }
                }
                if (que.Count == 0) Console.WriteLine(p.Item3);
            }
        }
    }
}


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

#define F first
#define S second
#define pb push_back
#define mp make_pair

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

ll lcm(ll a, ll b){
	return (a/gcd(a, b))*b;
}

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

	ll n,i,j,ans = 0;

	cin >> n;
	ll a[n];

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

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

	cout << ans << endl;

}

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

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

    vector<int>p(n);
    vector<int>pp(n);
    rep(i,0,n){
        cin>>p[i];
        pp[i]=p[i];
    }

    sort(pp.begin(),pp.end());
    int count =0;

    for (int i=0;i<n;i++) {
        if(p[i]!=pp[i]){
            count++;
        }
    }

    if(count<=2){
        cout<<"YES"<<endl;
    }
    else {
        cout<<"NO"<<endl;
    }

}



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

int main() {
    char yoso[4];
    char real[4];
    int ans = 0;
    cin >> yoso >> real;

    for (int i = 0; i < 3; ++i) {
        if(yoso[i]==real[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    int h[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    ll m[n + 1];
    m[1] = 0;
    for (int i = 2; i <= n; i++) {
        ll mm = 1000000000; 
        for (int j = max(1, i - k); j <= i - 1; j++) {
            ll x = m[j] + abs(h[i] - h[j]);
            if (mm > x) {
                mm = x;
            }
        }
        m[i] = mm;
        /*
        ll x1 = m[i - 2] + abs(h[i] - h[i - 2]);
        ll x2 = m[i - 1] + abs(h[i] - h[i - 1]);
        m[i] = min(x1, x2);
        */
    }
    cout << m[n] << endl;
    return 0;
}

Measured memory_bytes: 4724
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())



if T1*A1+T2*A2 == T1*B1+T2*B2:
    print("infinity")
elif (T1*A1-T1*B1)*((T1*A1+T2*A2)-(T1*B1+T2*B2)) > 0:
    print("0")
else:
    if A1>B1:
        hoge = ((A1-B1)*T1)//(B1*T1+B2*T2-A1*T1-A2*T2) * 2 + 1
        if ((A1-B1)*T1)%(B1*T1+B2*T2-A1*T1-A2*T2) == 0:
            hoge -= 1
    else:
        hoge = ((B1-A1)*T1)//(A1*T1+A2*T2-B1*T1-B2*T2) * 2 + 1
        if ((B1-A1)*T1)%(A1*T1+A2*T2-B1*T1-B2*T2) == 0:
            hoge -= 1
    print(hoge)

Measured memory_bytes: 3064
import java.io.*;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        Task solver = new Task();
        int t = 1;
        while (t --> 0) solver.solve(1, scan, out);
        out.close();
    }

    static class Task {

        public void solve(int testNumber, FastReader scan, PrintWriter out) {
            long a = scan.nextInt(), b = scan.nextInt();
            out.print(a/gcd(a, b)*b);
        }

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

    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static void shuffle(long[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            long temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

        public FastReader(String s) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(new File(s)));
        }

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

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 22868
n = int(input())
vi = list(map(int, input().split()))

e = [0 for i in range(max(vi)+1)]
o = [0 for i in range(max(vi)+1)]

me = [0,0]
mo = [0,0]

me2 = [0,0]
mo2 = [0,0]

for i in range(n):
    if i%2 == 0:
        e[vi[i]] += 1
    else:
        o[vi[i]] += 1

for i in range(len(e)):
    if e[i] > me[0]:
        me2[0] = me[0]
        me2[1] = me[1]
        me[0] = e[i]
        me[1] = i
    elif e[i] > me2[0]:
        me2[0] = e[i]
        me2[1] = i

for i in range(len(o)):
    if o[i] > mo[0]:
        mo2[0] = mo[0]
        mo2[1] = mo[1]
        mo[0] = o[i]
        mo[1] = i
    elif o[i] > mo2[0]:
        mo2[0] = o[i]
        mo2[1] = i

if me[1] == mo[1]:
    num = 0
    if me[0] + mo2[0] > me2[0] + mo[0]:
        num = me[0] + mo2[0]
    else:
        num = me2[0] + mo[0]
    print(n - num)
else:
    num = me[0] + mo[0]
    print(n - num)



Measured memory_bytes: 14108
N, M = map(int,input().split())
H = []
L = [[] for k in range(M+1)]

for k in range(N):
    P = list(map(int,input().split()))[1:]
    H.append(P)
    for e in P:
        L[e].append(k+1)

G = [0 for k in range(N+1)]
G[1] = 1
Q = [H[0]]
while len(Q) > 0:
    ima = Q.pop()
    for tsugi in ima:
        for e in L[tsugi]:
            if G[e] == 0:
                G[e] = 1
                if len(H[e-1]) > 1:
                    Q.append(H[e-1])

for k in range(1,N+1):
    if G[k] == 0:
        print("NO")
        exit(0)
print("YES")


Measured memory_bytes: 74528
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int n;
  cin>>n;
  vector<double>a(n);
  rep(i,n)cin>>a[i];
  vector<double>d(n);
  rep(i,n){
    d[i]=1/a[i];
  }
  double s=0;
  rep(i,n)s+=d[i];
  printf("%.10f\n",1/s);
  return(0);
}


Measured memory_bytes: 256
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()



int main()
{
  int x;
  cin >> x;
  for(int a = -1000; a <= 1000 ; a++) {
    for(int b = -1000; b <= 1000; b++) {
      long long s = 1LL * a * a * a * a * a - 1LL * b * b * b * b * b;
      if(s == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3548
K, *A = map(int, open(0).read().split())
if A[-1]!=2:
  print(-1)
  import sys
  sys.exit()
S = 2
M = 2
for i in range(K-1,0,-1):
  c = A[i]
  p = A[i-1]
  ms = S
  mm = M+c-1
  ns = ms//p+1 if ms%p!=0 else ms//p
  nm = mm//p
  if ns*p>mm or nm*p<ms:
    print(-1)
    break
  M = nm*p
  S = ns*p
else:
  print(S,M+A[0]-1)

Measured memory_bytes: 14476
while True:
    a,ob,b=input().split()
    if ob=='?':
        break
    if ob=='+':
        print(int(a)+int(b))
    if ob=='-':
        print(int(a)-int(b))
    if ob=='/':
        k=int(a)/int(b)
        print(int(k))
    if ob=='*':
        print(int(a)*int(b))
    


Measured memory_bytes: 5592
import java.util.Scanner;

public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
     
       if(a < b && b < c){
           System.out.printf("Yes\n");
       }
       else {
    	   System.out.printf("No\n");
       }
   }
}


Measured memory_bytes: 26256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	string s, t;
	cin >> s >> t;
	s += s;
	if (s.find(t) != string::npos) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,a,b,c,cnt=0;
    scanf("%d%d%d",&a,&b,&c);
    for(i=a; i<=b; i++)
    {
        if(c%i==0)
        {
            cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}



Measured memory_bytes: 2060
#include <cstdio>
#include <algorithm>
#define LL long long
#define num (LL)1000000000000000000
using namespace std;
LL a[100010];
int main()
{
    int n,i;
    LL ans=1;
    scanf("%d",&n);
    for(i=1; i<=n; i++)
        scanf("%lld",&a[i]);
    sort(a+1,a+1+n);
    if(a[1]==0)
    {
        printf("0\n");
        return 0;
    }
    for(i=1; i<=n; i++)
        if(a[i]>num/ans)//转换思维，求他的除数，而不是一直下去，太大
        {
            printf("-1\n");
            return 0;
        }
        else
            ans*=a[i];
    printf("%lld\n",ans);
    return 0;
}

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

using namespace std;

using ll = long long;

const int MX = 100 * 1000 + 7;

pair<int, int> d[MX];
pair<int, int> nd[MX];

vector<tuple<int, int, int> > qq[MX];
vector<int> g[MX];

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n, m, q;
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    cin >> q;
    for (int i = 0; i < q; i++) {
        int u, d, c;
        cin >> u >> d >> c;
        qq[d].emplace_back(u, c, i);
    }
    for (int i = 1; i <= n; i++) {
        d[i] = {-1, -1};
        nd[i] = {-1, -1};
    }
    for (int i = 10; i >= 0; i--) {
        for (const auto& q : qq[i]) {
            int v, c, t;
            tie(v, c, t) = q;
            d[v] = max(d[v], make_pair(t, c));
        }
        for (int j = 1; j <= n; j++) {
            nd[j] = d[j];
        }
        if (i != 0) {
            for (int v = 1; v <= n; v++) {
                for (int to : g[v]) {
                    nd[to] = max(nd[to], d[v]);
                }
            }
        }
        for (int j = 1; j <= n; j++) {
            d[j] = nd[j];
        }
    }
    for (int i = 1; i <= n; i++) {
        if (d[i].first == -1) {
            cout << 0 << "\n";
        } else {
            cout << d[i].second << "\n";
        }
    }
}


Measured memory_bytes: 12408
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const double EPS = 1.0e-10;

class Point
{
public:
    double y, x;
    Point(){
        y = x = 0;
    }
    Point(double y0, double x0){
        y = y0;
        x = x0;
    }
    Point operator+(const Point& p) const{
        return Point(y + p.y, x + p.x);
    }
    Point operator-(const Point& p) const{
        return Point(y - p.y, x - p.x);
    }
    double dist(const Point& p) const{
        return sqrt(pow(y - p.y, 2) + pow(x - p.x, 2));
    }
    double dot(const Point& p) const{
        return y * p.y + x * p.x; // |a|*|b|*cos慮
    }
    double cross(const Point& p) const{
        return x * p.y - y * p.x; // |a|*|b|*sin慮
    }
};

double segmentPointDist(const Point& a1, const Point& a2, const Point& p)
{
    if((a2-a1).dot(p-a1) < 0)
        return a1.dist(p);
    else if((a1-a2).dot(p-a2) < 0)
        return a2.dist(p);
    else
        return abs((a2-a1).cross(p-a1)) / a1.dist(a2);
}

double segmentsDist(const Point& a1, const Point& a2, const Point& b1, const Point& b2)
{
    if(((a2-a1).cross(b1-a1) * (a2-a1).cross(b2-a1) < -EPS) && ((b2-b1).cross(a1-b1) * (b2-b1).cross(a2-b1) < -EPS))
        return 0.0;

    double ret = segmentPointDist(a1, a2, b1);
    ret = min(ret, segmentPointDist(a1, a2, b2));
    ret = min(ret, segmentPointDist(b1, b2, a1));
    ret = min(ret, segmentPointDist(b1, b2, a2));
    return ret;
}

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        Point s, e;
        cin >> s.x >> s.y >> e.x >> e.y;

        vector<vector<Point> > p(n, vector<Point>(4));
        vector<double> h(n);
        double ret = DBL_MAX;
        for(int i=0; i<n; ++i){
            for(int j=0; j<2; ++j)
                cin >> p[i][j*2].x >> p[i][j*2].y;
            cin >> h[i];

            p[i][1] = Point(p[i][0].y, p[i][2].x);
            p[i][3] = Point(p[i][2].y, p[i][0].x);

            if(p[i][0].x <= s.x && s.x <= p[i][2].x && p[i][0].y <= s.y && s.y <= p[i][2].y)
                ret = 0.0;
        }

        for(int i=0; i<n; ++i){
            for(int j=0; j<4; ++j){
                double d = segmentsDist(s, e, p[i][j], p[i][(j+1)%4]);
                if(d < EPS){
                    ret = 0.0;
                }else if(d < h[i]){
                    ret = min(ret, d);
                }else{
                    double r = (pow(h[i], 2.0) + pow(d, 2.0)) / (2 * h[i]);
                    ret = min(ret, r);
                }
            }
        }

        printf("%.10f\n", ret);
    }
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool is_loop[1000000] = {false};
int loop_nubmer = -1;

int main()
{
    int N;
    ll K;
    cin >> N >> K;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }

    vector<int> s;
    vector<int> ord(N + 1, -1);
    int c = 1;
    int l = 0;
    {
        int v = 1;
        while (ord[v] == -1)
        {
            ord[v] = s.size();
            s.push_back(v);
            v = a[v - 1];
        }
        c = s.size() - ord[v];
        l = ord[v];
    }

    if (K < l)
        cout << s[K] << endl;
    else
    {
        K -= l;
        K %= c;
        cout << s[l + K] << endl;
    }
    return 0;
}

Measured memory_bytes: 5888
#include<stdio.h>
#include<stdlib.h>

int main(){
    int N,A[100];
    int flg=0;
    scanf("%d",&N);
    for(int i = 0 ; i < N ;i++){
        scanf("%d",&A[i]);
    }
    for(int i = 0 ; i < N ;i++){
        if(A[i] % 2 == 0){
            if(A[i] % 3 != 0  && A[i] % 5 != 0){
                flg++;
            }
        }
    }
    if(flg == 0){
        printf("APPROVED");
    }else{
        printf("DENIED");
    }
    return 0;

}

Measured memory_bytes: 128
function main(input) {
  input = input.trim();
  const a = input.split("\n");
  const k = a[0].split(" ").map(Number);
  const ab = a[1].split(" ").map(Number);
  var ans = "NG";
  for (var i = ab[0]; i <= ab[1]; i++) {
				if (i % k[0] == 0) {
					ans = "OK";
					break;
				}
			}
	console.log(ans);
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29636
import heapq
from itertools import permutations
def dijkstra(n, tc_edges, s):
    
    min_dist = [float('inf')] * n
    min_dist[s] = 0
    next_v = []
    heapq.heappush(next_v, (0, s))
    
    while True:
        if len(next_v) == 0: break
        d, v = heapq.heappop(next_v)
        
        for u, d in tc_edges[v]:
            if min_dist[u] > min_dist[v] + d:
                min_dist[u] = min_dist[v] + d
                heapq.heappush(next_v, (min_dist[u], u))
                
    return min_dist
    
n, m, r = map(int, input().split())
r = list(map(int, input().split()))
edge = [[] for _ in range(n)]

for _ in range(m):
    a, b, c = map(int, input().split())
    edge[a-1].append([b-1, c])
    edge[b-1].append([a-1, c])

dist = [dijkstra(n, edge, i) for i in range(n)]

ans = float('inf')
for pr in permutations(r):
    temp = 0
    for i in range(len(r)-1):
        temp += dist[pr[i]-1][pr[i+1]-1]
        if temp >= ans: break
    
    ans = min(ans, temp)
    
print(ans)

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

using namespace std;

typedef long long int li;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}
    
int main()
{    
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);

        li n;cin>>n;

        string s;

        cin>>s;

        if(n&1)
        {
            cout<<"No";
        }
        else
        {
            bool ans=true;

            f(i,0,n/2-1)
            {
                ans&=(s[i]==s[i+(n/2)]);
            }

            if(ans)
                cout<<"Yes";
            else
                cout<<"No";
        }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  printf("%d",x);
#define pl(x)  printf("%lld",x);
#define pf(x)  printf("%.10lf",x);
#define ps(x)  printf("%s",x);
#define en() printf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define sp(x) fixed<<setprecision(x)
#define mod 1000000007
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define bug cout<<"Here"<<endl
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}



int main(){
fastio();
   int n;
   cin>>n;
   int arr[n];
   for(int i=0;i<n;i++) cin>>arr[i];
   int cnt=0;
   for(int i=0;i<n;i++)
   {
       if(i%2==0 && arr[i]%2)
       {
           cnt++;
       }
   }
   cout<<cnt<<endl;



return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N[] = new int[4];
		for (int i = 0; i < 4; i++) {
			N[i] = sc.nextInt();
		}
		boolean ans  = false;
		Arrays.sort(N);
		if (N[0] == 1 && N[1] ==4 && N[2]==7 && N[3]==9) {
			ans = true;
		}
		if (ans) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,s,n) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;

int gcd(int a,int b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
int lcm(int a,int b)
{return a*b/gcd(a,b);}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{
  cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;
}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
ll INF=10e12;
//------------------------------------------------------------
ll N;
void solve() {
  cin>>N;

  vector<ll> H(N);
  rep(i,0,N) cin >> H[i];

  vector<ll> v(N,0);

  ll count=0;
  rep(i,0,N)
  {
    if(i+H[i]<N) v[i+H[i]]++;

    if(i-H[i]>0)
    {
      count += v[i-H[i]];
    }
  }

  print(count);

  return;
}


Measured memory_bytes: 6324
#include <stdio.h>

int main(void)
{
    int i, N, flag, count=0;
    int a[200];

    scanf("%d", &N);

    for (i=0; i<N; i++) {
        scanf("%d", &a[i]);
    }

    do {
        flag = 1;
        for (i=0; i<N; i++) {
            if (a[i]%2 != 0) {
                flag = 0;
                break;
            }
        }
        if (flag) {
            for (i=0; i<N; i++) {
                a[i] /= 2;
            }
            count++;
        }
    } while (flag);

    printf("%d\n", count);

    return 0;
}

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

int main() {
  int k,a,b;
  cin >> k >> a >> b;
  bool flag;
  int i=1;
  while(true) {
    if(k*i > b) {
      flag = false;
      break;
    }
    if(k*i >= a && k*i <= b) {
      flag = true;
      break;
    }
    i++;
  }
  if(flag) cout << "OK" << endl;
  else cout << "NG" << endl;
}

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

#define ll long long
#define ld long double
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define int long long

using namespace std;
const int INF = 1e15;
const int MB = 30;
const int MOD = 1e9 + 7;

void solve() {
	int n, d;
	cin >> n >> d;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		double x, y;
		cin >> x >> y;
		if (sqrt(x * x + y * y) <= d) cnt++;
	}
	cout << cnt;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	srand(time(0));
	int t = 1;
	//int t;
	//cin >> t;
	while (t--) solve();
}

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

int h, w;

int main(void){
  cin >> h >> w;
  vector<string> a(h);
  for(int i = 0; i < h; i++) cin >> a[i];
  vector<vector<bool>> f(h, vector<bool>(w, true));
  for(int i = 0; i < h; i++){
    bool f1 = true;
    for(int j = 0; j < w; j++){
      if(a[i][j] == '#') f1 = false;
    }
    if(f1){
      for(int j = 0; j < w; j++){
        f[i][j] = false;
      }
    }
  }
  for(int j = 0; j < w; j++){
    bool f2 = true;
    for(int i = 0; i < h; i++){
      if(a[i][j] == '#') f2 = false;
    }
    if(f2){
      for(int i = 0; i < h; i++){
        f[i][j] = false;
      }
    }
  }
  vector<string> ans;
  for(int i = 0; i < h; i++){
    string s = "";
    for(int j = 0; j < w; j++){
      if(f[i][j]) s+=a[i][j];
    }
    if(s != "") ans.push_back(s);
  }
  for(int i = 0; i < ans.size(); i++) cout << ans[i] << endl;
  return 0;
}


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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using P = pair<int,int>;
//Write From this Line
#define pb(a) push_back(a)
#define print(x) cout<<x<<endl;
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define m0(x) memset(x,0,sizeof(x))
ll ans[200020];
vector<P> v;
vector<ll>vec[200020]; // 色とその位置
ll color[200020];
vector<ll> C;
ll dp[200020];
const int MOD = 1e9+7;
int main()
{
	ll N;
	cin >> N;
	rep(i,N) cin >> color[i];
	vec[color[0]].pb(1);
	C.pb(color[0]);
	int cnt = 1;
	For(i, 1, N){
		if(color[i] != color[i-1]) {
			cnt ++;
			C.pb(color[i]);
			vec[color[i]].pb(cnt);
			//
		}
	}
	m0(dp);
	dp[0] = 1;
	For(i, 1, cnt + 1) {
		(dp[i] += dp[i-1]) %= MOD;
		auto itr = lb(vec[C[i-1]],i);
		if (itr - vec[C[i-1]].begin() > 0){
			itr --;
			(dp[i] += dp[*itr])%=MOD;
		}
	}
	print(dp[cnt]);
}


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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010, M = 4 * N, INF = 0x3f3f3f3f;

int n, m;
int h[N], e[M], w[M], ne[M], idx;
int dist[N], q[N];

bool bfs(int u)
{
	int hh = 0, tt = -1;
	q[ ++ tt] = u;
	dist[u] = 0;
	
	while (hh <= tt)
	{
		int t = q[hh ++ ];
		for (int i = h[t]; ~i; i = ne[i])
		{
			int j = e[i];
			if (dist[j] == INF)
			{
				q[ ++ tt] = j;
				dist[j] = dist[t] + w[i];
			}
			else if (dist[j] != dist[t] + w[i]) return false;
		}
	}
	return true;
}

void add(int a, int b, int c)
{
	e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx ++ ;
}

int main()
{
	memset(h, -1, sizeof h);
	scanf("%d%d", &n, &m);
	while (m -- )
	{
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		add(a, b, c), add(b, a, -c);
	}
	
	memset(dist, 0x3f, sizeof dist);
	for (int i = 1; i <= n; i ++ )
		if (dist[i] == INF && !bfs(i))
		{
			puts("No");
			return 0;
		}
	puts("Yes");
    return 0;
}

Measured memory_bytes: 6144