akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

const int M = 1000005;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<int> cnt(M);
    for(int x : a){
        if (cnt[x] != 0){
            cnt[x] = 2;
            continue;
        }
        for (int i = x; i < M; i += x){
            cnt[i]++;
        }
    }

    int ans = 0;
    for (int x : a){
        if (cnt[x] == 1) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8016
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;


int main()
{
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif
 
    fastio
    ll n, d, x, y, ans=0;
    cin>>n>>d;
    for (int i = 0; i < n; ++i)
    {
        cin>>x>>y;
        if(sqrt(x*x + y*y)<=d)
            ans++;
    }
    cout<<ans;
}



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

int main() {
  int DIV = 1e+9 + 7;
  int N; cin >> N;
  int C[N];
  for (int i = 0; i < N; i++) cin >> C[i];
  sort(C, C + N);
  long res = 0;
  for (int i = 0; i < N; i++) {
    res += (long) (N + 1 - i) * (long) C[i];
    res %= DIV;
  }
  for (int i = 0; i < 2 * (N - 1); i++) {
    res *= 2;
    res %= DIV;
  }
  cout << res << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

int main(void)
{
  int N, x, y, z, i, j, k, l, ans = 0;
  scanf("%d", &N);
  for (i = 0; i < N; i++)
  {
    for (j = 0; j < (N / 6); j++)
    {
      x = j + 1;
      for (k = j; k < (N - x * x) / 6; k++)
      {
        y = k + 1;
        for (l = k; l < (N - x * x - y * y) / 6; l++)
        {
          z = l + 1;
          if ((x * x + y * y + z * z + x * y + y * z + z * x) > (i + 1))
          {
            break;
            break;
            break;
          }
          if ((x * x + y * y + z * z + x * y + y * z + z * x) == (i + 1))
          {
            if (x != y && y != z && z != x)
            {
              ans += 6;
            }
            else
            {
              if (x == y && y == z)
              {
                ans++;
              }
              else
              {
                ans += 3;
              }
            }
          }
        }
      }
    }
    printf("%d\n", ans);
    ans = 0;
  }
  return 0;
}


Measured memory_bytes: 1680
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    
    xy=list()
    A=list()
    for i in range(N):
        a=int(input())
        l=list()
        for _ in range(a):
            l.append(tuple(map(int, input().split())))
        A.append(a)
        xy.append(l)

    answer = 0
    for i in range(2**N):
        contradict=False
        count = 0
        for j in range(N):
            if (i>>j)&1 > 0:
                count += 1
                for x, y in xy[j]:
                    k = (i>>(x-1))&1
                    if (y==1 and k==0) or (y==0 and k==1):
                        contradict=True
                        break
            if contradict==True:
                break
        else:
            answer = max(answer, count)

    print(answer)

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc147","c",main)


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

vector<vector<int>> adj;
int dp[100005];
int n;

int dfs(int node){
	if(dp[node] != -1) 
		return dp[node];
	
	int mp = 0;
	for(auto x : adj[node]){
		mp = max(mp, dfs(x) + 1);
	}
	return dp[node] = mp;
}

int main(){
	int m;
	cin >> n >> m;
	
	memset(dp, -1, sizeof dp);
	adj.assign(n + 1, vector<int>());
	
	for(int i = 0; i < m; i++){
		int u, v;
		cin >> u >> v; 
		adj[u].push_back(v);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(dp[i] == -1)
			dfs(i);
		
		ans = max(ans, dp[i]);
	}
	
	cout << ans;
}





Measured memory_bytes: 8192
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

pub fn bsearch<F>(ok: i64, ng: i64, pred: F) -> Option<i64>
where
    F: Fn(i64) -> bool,
{
    let orig_ok = ok;
    let mut ok = ok;
    let mut ng = ng;
    while (ok - ng).abs() > 1 {
        let mid = (ok + ng) / 2;
        if pred(mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    if ok == orig_ok {
        None
    } else {
        Some(ok)
    }
}

// fn f(n: usize) -> usize {
//     let mut res = 0;
//     for x in 1..=n {
//         for y in 1..=n {
//             let z = bsearch((n + 1) as i64, 0, |z| {
//                 let z = z as usize;
//                 let sum = (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
//                 sum >= n
//             });
//             if let Some(z) = z {
//                 let z = z as usize;
//                 let sum = (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
//                 if sum == n {
//                     res += 1;
//                 }
//             }
//         }
//     }
//     res
// }

fn solve() {
    input! {
        n: usize
    };

    let mut res = vec![0; n + 1];
    for x in 1..=n {
        for y in 1..=n {
            if x * y > n {
                break;
            }
            let xy = x.pow(2) + y.pow(2) + x * y;
            for z in 1..=n {
                let xyz = xy + z.pow(2) + (x + y) * z;
                if xyz > n {
                    break;
                }
                res[xyz] += 1;
            }
        }
    }
    for n in 1..=n {
        println!("{}", res[n]);
    }
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2264
#include <cstdint>
#include <iostream>
#include <vector>
#include <algorithm>

bool check(uint32_t matrix[][3])
{
    if ((matrix[0][0]-matrix[0][1]) != (matrix[1][0]-matrix[1][1]) ||
        (matrix[1][0]-matrix[1][1]) != (matrix[2][0]-matrix[2][1]) ||
        (matrix[2][0]-matrix[2][1]) != (matrix[0][0]-matrix[0][1])) {
        return false;
    }

    if ((matrix[0][1]-matrix[0][2]) != (matrix[1][1]-matrix[1][2]) ||
        (matrix[1][1]-matrix[1][2]) != (matrix[2][1]-matrix[2][2]) ||
        (matrix[2][1]-matrix[2][2]) != (matrix[0][1]-matrix[0][2])) {
        return false;
    }

    if ((matrix[0][0]-matrix[0][2]) != (matrix[1][0]-matrix[1][2]) ||
        (matrix[1][0]-matrix[1][2]) != (matrix[2][0]-matrix[2][2]) ||
        (matrix[2][0]-matrix[2][2]) != (matrix[0][0]-matrix[0][2])) {
        return false;
    }

    return true;
}

int main(void)
{
    uint32_t matrix[3][3];

    for (uint32_t i = 0; i < 3; ++i) {
        std::cin >> matrix[i][0] >> matrix[i][1] >> matrix[i][2];
    }

    if (check(matrix)) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 384
n = gets.to_i
ans = Array.new(10**4 + 1, 0)

## x <= y <= zとする。

max_x = Math.sqrt(n/6).to_i + 1
max_y = Math.sqrt(n/3).to_i + 1
max_z = Math.sqrt(n).to_i + 1


(1..max_x).each do |x|
  (x..max_y).each do |y|
    (y..max_z).each do |z|
      result = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if x == y && x == z
	      plus_cnt = 1
      elsif x == y || y == z || z == x
          plus_cnt = 3
      else
          plus_cnt = 6
      end
	      ans[result] += plus_cnt if result <= n
    end
  end
end

(1..n).each do |i|
  puts ans[i]
end


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

int main() {
    ios::sync_with_stdio(false);
    long long n;
    cin >> n;
    long long last = 0;
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        long long t; cin >> t;
        if (last) {
            ans += max(0LL, last-t);
        }
        last = max(t, last);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3108
import java.util.*;

class Main {
    static int a;
    static int b;
    static int c;

    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      a = sc.nextInt();    
      b = sc.nextInt();    
      c = sc.nextInt(); 
      if (a>b) {
        System.out.println("No");
      } else if (a>c) {
        System.out.println("No");
      } else if (b>c) {
        System.out.println("No");
      } else if (a==b) {
        System.out.println("No");
      } else if (b==c) {
        System.out.println("No");
      } else if (c==a) {
        System.out.println("No");
      } else {
        System.out.println("Yes");
      } 
    }
}


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

int main(){
  int N;
  cin >> N;
  
  vector<int>vals = vector<int>(N);
  rep(i,N){
  	cin >> vals.at(i);
  }
  
  bool flag = true;
  int counter = 0;
  int memo1 = 0;
  int memo2 = 0;
  
  for(int i = 0;i < N-1;i++) {
    if (vals.at(i) != i+1){
      if (memo1 > 0) {
        if (memo1 == i+1 && vals.at(i) == memo2) {
          memo1 = 0; // swap 成功
          counter++;
        } else {
          flag = false;
          break;
        }
        
      } else if (counter > 0) {
        flag = false;
        break;
        
      } else {
        memo1 = vals.at(i);
        memo2 = i+1;
      }
    }
  }
  
  if (flag) cout << "YES";
  else cout << "NO";
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
			System.out.println("Possible");
		} else {
			System.out.println("Impossible");
		}
	}
}


Measured memory_bytes: 23764
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;



int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    vector<long> c(n),s(n),f(n);
    long i,j,k;
    for(i=1; i<n; i++) {
        scanf("%ld%ld%ld", &c[i], &s[i], &f[i]);
    }

    for(i=1; i<=n; i++) {
        long tt=0;
        for(j=i; j<=n-1;  j++) {
            if(tt<=s[j]) {
                tt=s[j]+c[j];
            }
            else {
                tt=((tt-1)/f[j]+1)*f[j]+c[j];
            }
        }
        printf("%ld\n", tt);
    }

    return 0;
}


Measured memory_bytes: 256
// AOJ 1576: Community Integration
// 2017.10.23 bal4u@uu

#include <stdio.h>

#define ABS(a) ((a)>=0?(a):-(a))

#define MAX 1001

/* UNION-FIND library */
int p[MAX], rank[MAX];
void make_set(int x) { p[x] = x, rank[x] = 0; }
void link(int x, int y) {
	if (rank[x] > rank[y]) p[y] = x;
	else { p[x] = y; if (rank[x] == rank[y]) rank[y] = rank[y] + 1;	}
}
int find_set(int x) { if (x != p[x]) p[x] = find_set(p[x]);	return p[x]; }
void union_set(int x, int y) { link(find_set(x), find_set(y)); }

int f[MAX];

int main() 
{
	int n, m, i, a, b;

	scanf("%d%d", &n, &m);
	for (i = 1; i <= n; i++) make_set(i);
	while (m-- > 0) {
		scanf("%d%d", &a, &b);
		union_set(a, b);
	}
	for (i = 1; i <= n; i++) f[find_set(i)]++;
	for (a = b = 0, i = 1; i <= n; i++) {
		if (f[i] == 1) a++; else if (f[i] > 1) b++;
	}
	printf("%d\n", ABS(a-b));
	return 0; 
}

Measured memory_bytes: 1868
import sys
input=lambda: sys.stdin.readline().rstrip()
n,k=map(int,input().split())
A=[int(i) for i in input().split()]
ct=0
while min(A)<n and ct<k:
  B=[0]*n
  for i,a in enumerate(A):
    l,r=max(0,i-a),min(n,i+a+1)
    B[l]+=1    
    if r<n:
      B[r]-=1
  A[0]=B[0]
  for i in range(1,n):
    A[i]=A[i-1]+B[i]
  ct+=1
print(*A)

Measured memory_bytes: 151144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 250;
int n;
int a[maxn];
int main()
{
    std::ios::sync_with_stdio(false);
    cin >> n;
    int ans = 0;
    for(int i = 0;i < n;i++) cin >> a[i];
    for(int i = 0;i < n;i++){
        for(int j = i + 1;j < n;j++){
            for(int k = j + 1;k < n;k++){
                if(a[i] == a[k] || a[i] == a[j] || a[j] == a[k]) continue;
                if(a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i] ){
                    ans ++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

struct UnionFind {
  vector<int> data;
  UnionFind(int n):data(n, -1){}
  int find(int x) {
    return data[x] < 0 ? x : data[x] = find(data[x]);
  }
  int size(int x) {
    return -data[find(x)];
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  void unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return;
    if(data[x] < data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  UnionFind uf(N+M);
  for(int i = 0; i < N; i++) {
    int K;
    cin >> K;
    for(int j = 0; j < K; j++) {
      int L;
      cin >> L;
      --L;
      uf.unite(i, N+L);
    }
  }
  bool flag = true;
  for(int i = 0; i < N; i++) {
    flag &= uf.same(0, i);
  }
  cout << (flag ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
#include <climits>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
        // setw(6) << setfill('0')
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << "(" << v.first << ", " << v.second << ")";
    return ostr;
}

vector<string> split(const string &s, char delim) {
    vector<string> result;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
        if (!item.empty()) {
            result.push_back(item);
        }
    }
    return result;
}

#define M map<int64, int64>
M f(int64 n) {
    M m;

    while (n % 2 == 0) {
        m[2]++;
        n = n / 2;
    }

    int64 c = 3;
    while (c * c <= n) {
        if (n % c == 0) {
            n = n / c;
            m[c]++;
        } else {
            c += 2;
        }
    }
    if (n != 1) m[n]++;
    return m;
}

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(m);
    vector<vector<int>> c(m, vector<int>());

    rep(i, m) {
        cin >> a[i];
        int b; cin >> b;

        c[i].resize(b);
        rep(j, b) cin >> c[i][j];
    }

    vector<vector<int>> dp(m+1, vector<int>(1 << n, INF));
    dp[0][0] = 0;
    reps(1, i, m+1) {
        rep(j, 1 << n) {
            if (dp[i-1][j] != INF) dp[i][j] = dp[i-1][j];
        }

        int p = 0;
        rep(j, c[i-1].size()) p = p | (1 << c[i-1][j]-1);

        rep(j, 1 << n) {
            if (dp[i-1][j] != INF) {
                dp[i][j|p] = min(dp[i][j|p], dp[i-1][j]+a[i-1]);
            }
        }
    }

    // cout << endl;
    // for (auto v : dp) cout << v << endl;

    cout << (dp[m][(1 << n)-1] == INF ? -1 : dp[m][(1 << n)-1]) << endl;
}


Measured memory_bytes: 16384
<?php
list($n, $m) = ints();
$A = ints();
$min = 10**10;
foreach($A as $a){
  if($min < $a){
    $d = $a - $min;
    if(!isset($map[$d]))$map[$d] = 0;
    $map[$d]++;
  }
  chmin($min, $a);
}
$max = max(array_keys($map));
$maxCount = $map[$max];
echo $maxCount,"\n";

function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}


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

using namespace std;
// #define int long long
mt19937 rnd(time(0));
typedef long long ll;
typedef long double ld;

// #define _GLIBCXX_DEBUG
#define f first
#define s second
#define pb push_back
#define pii pair<int, int> 
#define vi vector<int>
#define int ll

void solve(){
    int a, b, k;
    cin >> a >> b >> k;
    int z;
    a -= (z = min(a, k));
    k -= z;
    b -= min(b, k);
    cout << a << ' ' << b << endl;

}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int t = 1;
    while(t--){
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<bits/stdc++.h>
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e18
using ll = long long;
using namespace std;
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; }

int main(){
  ll n;  cin >> n;
  vll a(n);
  rep0(i,n){
    cin >> a[i];
  }
  ll ans = 0;
  ll check = 1;
  rep0(i,a.size()){
    if(a[i] == check){
      ans++;
      check++;
    }
  }
  if(ans == 0){
    cout << -1;
  }else{
    cout << n-ans;
  }
}


Measured memory_bytes: 1792
A1 = input().split()
A2 = input().split()
A3 = input().split()
A = [A1, A2, A3]
N = int(input())
B = []

for i in range(N):
    B.append(input())

K = [[0,0,0],
     [0,0,0],
     [0,0,0]]

for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            K[i][j] = 1

flag = 0

for i in range(3):
    if K[i][0] and K[i][1] and K[i][2]:
        flag = 1
        break
    if K[0][i] and K[1][i] and K[2][i]:
        flag = 1
        break

if K[0][0] and K[1][1] and K[2][2]:
    flag = 1

if K[0][2] and K[1][1] and K[0][2]:
    flag = 1

if flag == 1:
    print('Yes')
else:
    print('No')

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

#define N 100

int main() {
  int x,i,flag,temp,count = 0;
  int data[N];
  scanf("%d",&x);
  if(x < 0 || x > N) {
    exit(1);
  }
  
  for(i = 0; i < x; i++) {
    scanf("%d",&data[i]);
  }

  flag = 1;
  while(flag) {
    flag = 0;
    for(i = x - 1; i >= 1; i--) {
      if(data[i] < data[i - 1]) {
	temp = data[i - 1];
	data[i - 1] = data[i];
	data[i] = temp;
	count++;
	flag = 1;
      }
    }
  }

  for(i = 0; i < x; i++) {
    printf("%d",data[i]);
    if(i == x - 1) {
      break;
    }
    printf(" ");
  }
  printf("\n");
  printf("%d\n",count);

  return 0;
}
    



Measured memory_bytes: 2084
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define rep(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define irep(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define rrep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

const int MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    map<int, int> cnt;

    rep(i, 0, n) {
        int a;
        cin >> a;
        cnt[a]++;
    }
    int sumx = 0;
    for (auto key : cnt) {
        if (key.second % 2)
            sumx++;
    }
    cout << sumx << endl;

    return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string a;
  cin >> a;
  int b;
  b = a.size();
  int c = 0;
  int d = 0;
  for(int i = 0;i < b;++i)
  {if(a.at(i) == 'A' || a.at(i) == 'C' || a.at(i) == 'G' || a.at(i) == 'T'){
    c++;}
      else{c = 0;}
      if(c > d){
        d = c;}
      }
      cout << d << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>









const int N=2010;
int n,k,q,res,c,a[N];
bool b[N];
vector<int>v,v2;
map<int,vector<int>>m;
map<int,vector<int>>::iterator it;




void solve()
{
	cin>>n>>k>>q;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		m[a[i]].pb(i);
		b[i]=1;
		v.pb(a[i]);
	}
	sort(v.begin(),v.end());
	res=v[q-1]-v[0];
	for(it=m.begin();it!=m.end();it++)
	{
		for(int i=0;i<(it->nd).size();i++)b[(it->nd)[i]]=0;
		v.clear();
		v2.clear();
		for(int i=1;i<=n;i++)
		{
			if(b[i])
			{
				v2.pb(a[i]);
			}
			else
			{
				if(v2.size()>=k)
				{
					sort(v2.begin(),v2.end());
					c=v2.size()-k+1;
					for(int j=0;j<c;j++)v.pb(v2[j]);
				}
				v2.clear();
			}
		}
		if(v2.size()>=k)
		{
			sort(v2.begin(),v2.end());
			c=v2.size()-k+1;
			for(int j=0;j<c;j++)v.pb(v2[j]);
		}
		v2.clear();
		sort(v.begin(),v.end());
		if(v.size()>=q)res=min(res,v[q-1]-v[0]);
	}
	cout<<res<<"\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[3*n];
    for(int i=0;i<3*n;i++) a[i] = sc.nextLong();
    Arrays.sort(a);
    long sum=0;
    for(int i=0;i<n;i++) sum+=a[3*n-2-(i*2)];
    System.out.println(sum);
  }
}

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

int main(){
  int N, M;
  cin >> N >> M;
  std::vector<int> a(N), b(N);
  std::vector<int> c(M), d(M);

  for (int i = 0; i < N; i++) {
    cin >> a.at(i) >> b.at(i);
  }
  for (int i = 0; i < M; i++) {
    cin >> c.at(i) >> d.at(i);
  }

  for (int i = 0; i < N; i++) {
    int cnt=M-1;
    int dist=400000000;
    int k=0;
    for (int j = M-1; j > -1; j--) {
      k=abs(a.at(i)-c.at(j))+abs(b.at(i)-d.at(j));
      if(k<=dist){
        dist=k;
        cnt=j;
      }
    }
    cnt++;
    cout << cnt << endl;
  }
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
n,m = map(int,readline().split())
p = list(map(int,readline().split()))

#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#xが属するグループの要素全てを返す
def members(x):
    root = find(x)
    return [i for i in range(n) if find(i) == root]

#全ての根の要素をlistで返す(一個下の関数で使う)
def roots():
    return [i for i,x in enumerate(par) if x < 0]

#グループ数を返す
def group_count():
    return len(roots())

#根をkey,そのグループに含まれる要素をvalueとして全てを辞書型で返す
def all_group_members():
    return {r: members(r) for r in roots()}

#初期化
#根なら-size,子なら親の頂点
par = [-1]*n

"""
uniteでまとめ、findで見つける。
n(要素数)だけ最初に付け加えること。
"""

for i in range(m):
    x,y = map(int,readline().split())
    unite(x-1,y-1)

ans = 0

for i in range(n):
    if same(p[i]-1,i):
        ans += 1

print(ans)

Measured memory_bytes: 76956
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin >> n >> k;
  string temp;
  vector<string>v;
  
  while(n--){
    cin >> temp;
    v.push_back(temp);
  }
  sort(v.begin(),v.end());
  for(auto X: v)
    	cout << X;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Read();
            var ans = 0L;
            var idx = 0;
            var cnt = 0;
            while (idx < s.Length - 1)
            {
                if (s[idx] == 'A')
                {
                    cnt++;
                    idx++;
                }
                else if (s[idx] == 'B')
                {
                    if (s.Substring(idx, 2) == "BC")
                    {
                        ans += cnt;
                        idx += 2;
                    }
                    else
                    {
                        cnt = 0;
                        idx++;
                    }
                }
                else
                {
                    cnt = 0;
                    idx++;
                }
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

using namespace std;

long long n, k;
long long ho;

int main(void)
{
	scanf("%lld %lld", &n, &k);
	
	ho = n / k;
	n -= ho * k;
	
	printf("%lld", min(n, min(abs(n - k), n + k)));
	return 0;
}

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

struct city
{
  int pref;
  int year;
};

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

  vector<city> v;
  for (int i = 0; i < m; i++)
  {
    int p, y;
    cin >> p >> y;
    city c = {p, y};
    v.push_back(c);
  }

  map<int, vector<int>> table;
  for (int i = 0; i < m; i++)
  {
    if (table.count(v[i].pref))
    {
      table[v[i].pref].push_back(v[i].year);
    }
    else
    {
      vector<int> tmp = {v[i].year};
      table[v[i].pref] = tmp;
    }
  }

  for (auto it = table.begin(); it != table.end(); it++)
  {
    sort((it->second).begin(), (it->second).end());
  }

  for (int i = 0; i < m; i++)
  {
    auto it = lower_bound(table[v[i].pref].begin(), table[v[i].pref].end(), v[i].year);
    int index = distance(table[v[i].pref].begin(), it);

    cout << setfill('0') << right << setw(6) << v[i].pref;
    cout << setfill('0') << right << setw(6) << index + 1 << endl;
  }
}

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

using namespace std;

int main()
{
   string s;
   int size;
   int count, max;
   count = max = 0;

   cin >> s;

   size = s.size();;
   
   for(int i=0; i < size; i++){
      char c = s[i];
      if(c == 'A' || c == 'C' || c == 'G' || c == 'T'){
         count++;
         if(count > max) max = count;
      }else{
         count = 0;
      }
   }

   cout << max << endl;

   return 0;
}


Measured memory_bytes: 256
MOD = 10**9 + 7
H, W = [int(elem) for elem in input().split()]
grid = tuple(tuple(input()) for _ in range(H))
assert len(grid[0]) == W

dp = [[0] * W for _ in range(H)]
# for j in range(W):
#     if grid[]
dp[0][0] = 1
for i in range(H):
    for j in range(W):
        if j > 0 and grid[i][j - 1] == ".":
            dp[i][j] += dp[i][j - 1]
        if i > 0 and grid[i - 1][j] == ".":
            dp[i][j] += dp[i - 1][j]
        dp[i][j] %= MOD

print(dp[H - 1][W - 1])


Measured memory_bytes: 122204
import java.util.*

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()

    val g = Graph<Int>(N + 1, 0, 1e8.toInt()) {a, b -> a + b}

    for (i in 1 until N) {
        val (a, b) = readLine()!!.split(" ").map{it.toInt()}
        g.edges[a].add(Edge(a, b, 1))
        g.edges[b].add(Edge(b, a, 1))
    }

    val dist1 = dijkstra(g, 1).first
    var v = 1
    for (i in 1..N) {
        if (dist1[v] < dist1[i]) {
            v = i
        }
    }

    val dist2 = dijkstra(g, v).first
    val d = dist2.takeLast(N).max()!!

    if (d % 3 == 1) {
        println("Second")
    } else {
        println("First")
    }
}

data class Edge<T: Comparable<T>>(val from: Int, val to: Int, val weight: T): Comparable<Edge<T>> {
    constructor(from: Long, to: Long, weight: T) : this(from.toInt(), to.toInt(), weight)

    override fun compareTo(other: Edge<T>) = weight.compareTo(other.weight)
}

class Graph<T: Comparable<T>>(val n: Int, val zero: T, val inf: T, val plus: (T, T) -> T) {
    val edges = Array(n) { ArrayList<Edge<T>>() }
}

inline fun <reified T: Comparable<T>>dijkstra(g: Graph<T>, s: Int): Pair<Array<T>, Array<Int>> {
    val N = g.n
    val dist = Array(N) { g.inf }
    val prev = Array(N) {-1}

    val Q = PriorityQueue<Edge<T>>()

    dist[s] = g.zero
    Q.add(Edge(-2, s, g.zero))

    while(Q.isNotEmpty()) {
        val e = Q.peek()
        val v = e.to
        Q.poll()

        if (prev[v] != -1) continue
        prev[v] = e.from
        for (i in g.edges[v]) {
            val d = g.plus(dist[v], i.weight)
            if (dist[i.to] > d) {
                dist[i.to] = d
                Q.add(Edge(i.from, i.to, d))
            }
        }
    }

    return Pair(dist, prev)
}


Measured memory_bytes: 143300
n,q=list(map(int,input().split()))
s=input()
cnt=0
t=[0]*n

for i in range(n-1):
  cnt+=s[i:i+2].count("AC")
  t[i+1]=cnt
##  t[-1]=cnt
##print(t)

for i in range(q):
  l,r=list(map(int,input().split()))
  print(t[r-1]-t[l-1])
 

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

int main(){

    int r,g,b,i,j,k,sum;
    cin>>r>>g>>b;

    i=r*100,j=g*10,k=b;

    sum=i+j+k;

    (sum%4==0)?cout<<"YES"<<endl:cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 3560
EPS = 1e-12
MAX = 100000
ok = [0.0] * 32
ng = 0.0
ok[0] = 1.0

ans = [0.0] * (MAX + 1)
ans[1] = 1.0
sum = 1.0
(2..MAX).each do |i|
  cur_ok = [0.0] * 32
  cur_ok[0] = ng
  sum += ng
  cur_ng = 0.0
  p = 0.5
  (0...i).each do |k|
    cur_ng += ok[k] * (1 - p)
    okp = ok[k] * p
    break if okp > 0 && okp < EPS
    cur_ok[k + 1] = okp
    sum += okp
    p /= 2
  end
  ans[i] = sum
  ok = cur_ok
  ng = cur_ng
end

while n = gets.to_i
  break if n == 0
  printf "%.8f\n" % ans[n]
end

Measured memory_bytes: 10952
#include<bits/stdc++.h>
using namespace std;
const int M=1000000007;
long long fac[20000005],inv[20000005],h,w,k,i,ans;
long long qpow(long long a,long long b)
{
	long long s=a,ans=1;
	while(b)
	{
		if(b&1)
			ans=ans*s%M;
		s=s*s%M;
		b>>=1;
	}
	return ans;
}
long long C(long long n,long long m)
{
	if(n<0||m<0||n<m)
		return 0;
	return fac[n]*inv[m]%M*inv[n-m]%M;
}
int main()
{
	int i;
	cin>>h>>w>>k;
	fac[0]=1;
	for(i=1;i<=h+w;++i)
		fac[i]=fac[i-1]*i%M;
	inv[h+w]=qpow(fac[h+w],M-2);
	for(i=h+w-1;i>=0;--i)
		inv[i]=inv[i+1]*(i+1)%M;
	for(i=1;i<=k;++i)
		ans=(ans+fac[h+w-i]*inv[h+w-k]%M*fac[i]%M*(C(h+w-2,i-2)*h%M*w%M+C(h+w-1,i-1)*(h+w)%M+C(h+w,i)))%M;
	cout<<(ans%M+M)%M;
}


Measured memory_bytes: 312704
import math
def near_pow(n):
    if n <= 0:
        return 0
    elif (n & (n - 1)) == 0:
        ret = -1
        while n>0:
             ret += 1; n >>= 1
        return ret

    else:
        ret = 0
        while n>0:
             ret += 1; n >>= 1
        return ret
N,K = map(int,input().split())
ans = 0.0

for i in range(1,N+1):
    a = math.ceil(K/i)
    ans += (1/N)*(0.5**near_pow(a))
print(ans)

Measured memory_bytes: 3064
import math

a,b,h,m = map(int,input().split())

ang1 = (h%12+m/60) * 30
ang2 = m * 6
ang = abs(ang1-ang2)
if ang > 180:
    ang = 360 - ang

print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(ang))))


Measured memory_bytes: 9392
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n), b(n);
  auto can = [&](ll x) -> bool {
    ll reqd = 0;
    for(ll i = 0; i < n; i++) {
    	if(a[i] * b[i] <= x) continue;
    	ll isp = x/b[i];
    	reqd+= a[i] - isp;
    }
    return reqd <= k;
  };
  for(ll i = 0; i < n; i++) cin >> a[i];
  for(ll i = 0; i < n; i++) cin >> b[i];
  sort(all(a), greater<ll>());
  sort(all(b));
  ll low = 0, high = (ll)(1e18), ans = -1, mid;
  while(low <= high) {
  	mid = (low + high)/2;
  	if(can(mid)) {
  		ans =  mid;
  		high = mid - 1;
  	} else {
  		low = mid+1;
  	}
  }
  cout << ans << endl;
  return 0;
} //good night.

Measured memory_bytes: 3328
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

int main(){
  int N;
  scanf("%d", &N);
  std::vector<int > A(N);
  for (int i=0; i<N; i++){
    scanf("%d", &A[i]);
  }
  std::vector<long long > sum(N+1);
  sum[0]=0;
  for (int i=0; i<N; i++){
    sum[i+1] = sum[i] + (long long)A[i];
  }
  std::map<long long, int> mp;
  for (int i=0; i<=N; i++){
    mp[sum[i]]++;
  }
  long long ans = 0;
  for (auto &entry : mp){
    ans += (long long)entry.second*(entry.second-1)/2;
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    vector<ll> sumsum(n+1);
    sumsum[0] = 0;
    PREP(i, 1, n+1){
        sumsum[i] = sumsum[i-1] + i;
    }

    PREP(i, 1, n+1){
        ans += sumsum[i];
    }

    ll MIN = 1, MAX = n;
    REP(i, n-1){
        ll v, u;
        cin >> u >> v;
        if(u > v) swap(u, v);
        ans -= u * (MAX - v + 1);
    }
    cout << ans  << endl;


    return 0;
}

Measured memory_bytes: 4836
#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
#include <math.h> // sqrt
using namespace std;

int main() {
    int N;
    cin >> N;
    int ans = 1;
    if (N == 1) {
        cout << 1 << endl;
        return 0;
    }
    while (true) {
        ans *= 2;
        if (N < ans) {
            ans /= 2;
            break;
        }
    }
    cout << ans << endl;
}

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

#define INF (1 << 30) - 1 + (1 << 30)

int a[262144], n2, lazy[262144];

void lazyeval(int i) {
  if (lazy[i] == INF) return;
  a[i] = lazy[i];
  if (i < n2 - 1) {
    lazy[2 * i + 1] = lazy[2 * i + 2] = lazy[i];
  }
  lazy[i] = INF;
}

int findsingle(int i) {
  int j = i + n2 - 1;
  int val = a[i + n2 - 1];
  if (lazy[j] != INF) val = lazy[j];
  while (j > 0) {
    j = (j - 1) / 2;
    if (lazy[j] != INF) val = lazy[j];
  }

  return val;
}

void updaterange(int s, int t, int i, int l, int r, int x) {
  lazyeval(i);
  // cout << s << " " << t << " " << i << " " << l << " " << r << endl;
  if (s <= l && r <= t) {
    a[i] = x;
    if (i < n2 - 1) {
      lazy[2 * i + 1] = lazy[2 * i + 2] = a[i];
    }
    return;
  }
  if (t <= l || r <= s) return;
  updaterange(s, t, i * 2 + 1, l, (l + r) / 2, x);
  updaterange(s, t, i * 2 + 2, (l + r) / 2, r, x);

  a[i] = min(a[i * 2 + 1], a[i * 2 + 2]);
}

int main() {
  int n, q, com, s, t, x;

  cin >> n >> q;
  n2 = 1;
  while (n > n2) n2 *= 2;
  for (int i = 0; i < n2 * 2; i++) a[i] = lazy[i] = INF;

  for (int i = 0; i < q; i++) {
    cin >> com >> s;
    if (com == 0) {
      cin >> t >> x;
      updaterange(s, t + 1, 0, 0, n2, x);
    } else
      cout << findsingle(s) << endl;
  }
  return 0;
}


Measured memory_bytes: 5168
#include <iostream>
#include <cmath>

using namespace std;
long long int a[100000];
long long int dp[1000005];
//long long int dp2[1000001];
/*long long int dp(long long int current,long long int length){
if(current==length-2){
    return abs(a[length-1]-a[length-2]);
}
if(current==length-3){
    long long int numb1=abs(a[length-1]-a[length-3]);
    long long int numb2=abs(a[length-1]-a[length-2])+abs(a[length-2]-a[length-3]);

    if(numb1<numb2){
        return numb1;
    }
    else
       return numb2;
}
else{
    long long int numb1=dp(current+1,length);
    long long int numb2=dp(current+2,length);
    if(numb1<numb2){
        return abs(a[current+1]-a[current])+numb1;
    }
    else{
        return abs(a[current+2]-a[current])+numb2;
    }
}

}*/

int main()
{
    long long int length;
    cin >> length ;
    for(long long int i=0;i<length;i++){
        cin >>a[i];
    }
    dp[0] = 0;
    for(int i = 1; i < length; i++){
        dp[i] = dp[i-1] + abs (a[i] - a[i-1]);
        if(i > 1){
            dp[i] = min(dp[i], dp[i-2] + abs(a[i] - a[i-2]));
        }
    }
     cout<<dp[length-1]<<endl;

    //cout<<dp(0,length)<<endl;
}


Measured memory_bytes: 5156
#define DEBUG 0
/**
 * File    : B2.cpp
 * Author  : Kazune Takahashi
 * Created : 8/4/2019, 11:29:38 PM
 * Powered by Visual Studio Code
 */
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
using ll = long long;
class mint
{
public:
  static ll MOD;
  ll x;
  mint() : x(0) {}
  mint(ll x) : x(x % MOD) {}
  mint operator-() const { return x ? MOD - x : 0; }
  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= MOD)
    {
      x -= MOD;
    }
    return *this;
  }
  mint &operator-=(const mint &a) { return *this += -a; }
  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint &operator/=(const mint &a)
  {
    mint b{a};
    return *this *= b.power(MOD - 2);
  }
  mint operator+(const mint &a) const { return mint(*this) += a; }
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  mint operator/(const mint &a) const { return mint(*this) /= a; }
  bool operator<(const mint &a) const { return x < a.x; }
  bool operator==(const mint &a) const { return x == a.x; }
  const mint power(ll N)
  {
    if (N == 0)
    {
      return 1;
    }
    else if (N % 2 == 1)
    {
      return *this * power(N - 1);
    }
    else
    {
      mint half = power(N / 2);
      return half * half;
    }
  }
};
ll mint::MOD = 1e9 + 7;
istream &operator>>(istream &stream, mint &a) { return stream >> a.x; }
ostream &operator<<(ostream &stream, const mint &a) { return stream << a.x; }
class combination
{
public:
  vector<mint> inv, fact, factinv;
  static int MAX_SIZE;
  combination() : inv(MAX_SIZE), fact(MAX_SIZE), factinv(MAX_SIZE)
  {
    inv[1] = 1;
    for (auto i = 2; i < MAX_SIZE; i++)
    {
      inv[i] = (-inv[mint::MOD % i]) * (mint::MOD / i);
    }
    fact[0] = factinv[0] = 1;
    for (auto i = 1; i < MAX_SIZE; i++)
    {
      fact[i] = mint(i) * fact[i - 1];
      factinv[i] = inv[i] * factinv[i - 1];
    }
  }
  mint operator()(int n, int k)
  {
    if (n >= 0 && k >= 0 && n - k >= 0)
    {
      return fact[n] * factinv[k] * factinv[n - k];
    }
    return 0;
  }
};
int combination::MAX_SIZE = 3000010;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
// constexpr double epsilon = 1e-10;
// constexpr ll infty = 1000000000000000LL;
// constexpr int dx[4] = {1, 0, -1, 0};
// constexpr int dy[4] = {0, 1, 0, -1};
void Yes()
{
  cout << "Yes" << endl;
  exit(0);
}
void No()
{
  cout << "No" << endl;
  exit(0);
}

int main()
{
  int N;
  cin >> N;
  int ans = 0;
  for (auto i = 1; i <= N; i++)
  {
    stringstream SS;
    SS << i;
    string S{SS.str()};
    if (S.size() % 2 == 1)
    {
      ++ans;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys
import itertools

# import math

import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 ** 13

N = int(readline())
temp = INF
a = 0
b = 0
for i in range(1, int(N**.5)+1):
    if N % i == 0:
        if temp >= abs(i - N // i):
            temp = abs(i - N // i)
            a = i
            b = N // i
print(a+b-2)

Measured memory_bytes: 12516
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define mod 1e9+7
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rof(i,a,b) for(ll i=a;i>b;i--)

//int a[1001][1001] //aise global me hi

ll lcm(ll a, ll b){
    return a / __gcd(a, b) * b;
}
//memset can initialize to 0 or -1 ONLY //memset(str, 't', sizeof(str)); // string
//memset(a, 0, sizeof(a));  //1D array    // memset(a,0,sizeof(a[0][0])*n*n); //2D array
// set.insert(),find()    // sort(v.begin(),v.end(),compare)

void solve()
{
   int n;cin>>n;
   if(n%2==0) cout<<n/2;
   else cout<<n/2+1; 
    
}


int main()
{

ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t=1;
    //cin>>t;
    while(t--)
    {
    
    solve();
    
    }

}

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

int main() {
  int N; cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  for (int i = 0; i < N; i++) {
    if (A.at(i) == 0) { cout << 0 << endl; return 0; }
  }
  long long ans = 1;
  const long long MAX = 1000000000000000000;
  for (int i = 0; i < N; i++) {
    // ans * A[i] > 10^18
    if (A.at(i) > MAX / ans) { cout << -1 << endl; return 0; }
    ans *= A.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4052
import java.util.Scanner;
import java.util.stream.IntStream;

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

        int N = sc.nextInt();
        int[] h = new int[N];
        for (int i = 0; i < h.length; ++i) {
            h[i] = sc.nextInt();
        }

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

        sc.close();
    }

    static int solve(int[] h) {
        return IntStream.range(0, h.length).map(i -> (i == 0) ? h[i] : Math.max(0, h[i] - h[i - 1])).sum();
    }
}

Measured memory_bytes: 36396
n=int(input())
a=list(map(int,input().split()))
def gcd(x,y):
  while x%y>0:
    x,y=y,x%y
  return y
a.sort(reverse=True)
ans=a[0]
for j in range(n-1):
  ans=gcd(ans,a[j+1])
print(ans)
  

Measured memory_bytes: 14252
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

a,b,c = inputIL()

if (10*b+c)%4 == 0:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 63980
#include<iostream>
#include<cmath>

using namespace std;

int main(){
  int n;
  cin>>n;
  int prev = 0;
  for(int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    if(prev > tmp){
      cout<<"No"<<endl;
      return 0;
    }
    if(prev < tmp){
      prev = tmp-1;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256