akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX=1e5+10;
ll l[200];
int solve(){
    int n=0,m=0;
    cin>>n;
    for (int i = 0; i < n; ++i) {
        cin>>l[i];
    }
    //if (n<3) return cout<<m<<endl,0;
    for(int i=0;i<n;i++){
        for (int j = i+1; j < n; ++j) {
            for (int k = j+1; k < n; ++k) {
                if (l[i]!=l[j]&&l[j]!=l[k]&&l[i]!=l[k]){
                  if ((l[i]+l[j]>l[k])&&(l[i]+l[k]>l[j])&&(l[k]+l[j]>l[i]))
                      m++;
                }
            }
        }
    }
    cout<<m<<endl;
    return 0;
}
int main(){
    int _=1;
//    cin>>_;
    while(_--){
        solve();
    }
}


Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <utility>
#include <functional>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

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

	while (n != 0) {
		vector<int> point(n);
		for (int i = 0; i < n; i++) cin >> point[i];

		sort(point.begin(), point.end());
		int sum = 0;
		for (int i = 1; i < n - 1; i++) sum += point[i];

		cout << sum / (n - 2) << endl;

		cin >> n;
	}

	return 0;
}


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

int main()
{
	int64_t n;
	cin >> n;
	vector<int64_t> hs(n);
	for (auto &&h : hs)
	{
		cin >> h;
	}

	map<int64_t, int64_t> mp;

	int64_t ans = 0;

	for (int64_t i = 0; i < n; i++)
	{
		ans += mp[i - hs[i]];

		mp[hs[i] + i]++;
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
  int n;cin>>n;
  vector<int> arr(n);
  for(int i=0;i<n;++i)cin>>arr[i];
  int result = 0;
  for(int i = 1;i<n-1;++i){
    if(arr[i]>arr[i-1]&&arr[i]<arr[i+1]){
      result++;
    }
    if(arr[i]<arr[i-1]&&arr[i]>arr[i+1]){
      result++;
    }    
  }
  cout<<result<<endl;
  return 0;
}

Measured memory_bytes: 256
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define debug cout << "here!"
#define pii pair<int , int>
#define pdd pair<double , double>
#define F first
#define S second
const int maxn = 1e5 * 5 + 10 , inf = 1e9 , pi = 3.14159265;

void solve(){
    
}
void in(){
    string s; cin >> s;
    int l = 0 ,r = s.size() - 1;int ans = 0;
    while (l < r){
        if (s[l] != s[r]){
            ans ++;
        }
        l ++ , r --;
    }
    cout << ans << endl;
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    in();
    return 0;
}


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

using namespace std;

using llong = long long int;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define delete

const static int MOD = 1000000007;
const static int INF = 1<<30;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

template<typename T> struct UF {
    vector<int> par;
    vector<T> sz;

    UF(int n) {
        par.resize(n);
        sz.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            sz[i] = 1;
        }
    }

    int find_root(int x) {
        return par[x] == x ? x : par[x] = find_root(par[x]);
    }

    bool same(int x, int y) {
        return find_root(x) == find_root(y);
    }

    void unite(int x, int y) {
        x = find_root(x);
        y = find_root(y);
        if (x == y) return;
        
        if (sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }

    T size_of_tree(int x) {
        return sz[find_root(x)];
    }
};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    UF<int> uf(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        uf.unite(a, b);
    }

    int res = 0;
    map<int, int> M;
    rep(i, n) {
        if (M[uf.find_root(i)] == 0) {
            ++res;
            ++M[uf.find_root(i)];
        }
    }

    cout << res - 1 << endl;

    return 0;
}

Measured memory_bytes: 7840
n, m = gets.split.map(&:to_i)
hills = gets.split.map(&:to_i)
edges = []
m.times { edges << gets.split.map(&:to_i) }
graph = Array.new(n + 1) { Array.new }
edges.each do |from, to|
  graph[from] << to
  graph[to] << from
end
ans = 0
1.upto(n) do |i|
  height = hills[i - 1]
  max = 0
  graph[i].each do |to|
    max = hills[to - 1] if max < hills[to - 1]
  end
  ans += 1 if height > max
end
puts ans


Measured memory_bytes: 31484
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int n, k, a[max];
    long long int ht[max], bo=1, si=1;
    
    scanf("%d%d", &n, &k);
    rep(i, n){
        scanf("%d", &a[i]);
    }
    
    for (int i=k; i<n; i++) {
        if (a[i-k]<a[i]) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }
    
    return 0;
}


Measured memory_bytes: 2440
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end
k = gets_i

if k.even?
  puts "-1"
  exit
end

num = 0

1.upto(k) do |i|
  num = num * 10 + 7
  num %= k
  if num == 0
    puts i
    exit
  end
end

puts "-1"

Measured memory_bytes: 14656
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

int main() {
	fastIO;
#ifdef LOCAL
	freopen("input.in", "rt", stdin);
#endif
	ll a, b, x;
	cin >> a >> b >> x;
	ll bb = b - 1;
	bb = min(bb, x);
	ll ans = (a * bb) / b - a * (bb / b);
	bb += b;
	bb = min(bb, x);
	ll ans2 = (a * bb) / b - a * (bb / b);
	cout << max(ans, ans2);
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  if (n == (ll)0) {
    cout << 0 << endl;
    return 0;
  }
  
  vector<int> ans;
  ll res = 1;
  while (n != 0) {
    if (abs(n) % (abs(res) * 2) == abs(res)) {
      ans.push_back(1);
      n -= res;
    }
    else ans.push_back(0);
    res *= -2;
  }

  int m = ans.size();
  repr(i, m - 1) cout << ans[i];
  cout << endl;
  

  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
	int N;
	cin >> N;
    int mn = N+1, ans = 0, p;
    rep(i,N) {
        cin >> p;
        mn = min(mn, p);
        if (p==mn) ans++;
    }
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/* eABC131-A
   Yuta Takayanagi  */

#include<stdio.h>
int main(void){
    int number, bit1, bit2, i;

    scanf( "%d" , &number);

    bit1 = number % 10;
    number = (number - bit1) / 10;

    for(i=0; i < 3; i++){

        bit2 = number % 10;
        number = (number - bit2) / 10;

        if(bit1==bit2){

            printf( "Bad\n" );

            return 0;

        }

        bit1 = bit2;

    }

    printf( "Good\n" );

    return 0;

}

Measured memory_bytes: 128
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin>>s;
    int n = s.length();
    vector<bool> v(4,false);
    REP(i,n){
        if(s[i]=='E') v[0] = true;
        else if(s[i]=='W') v[1] = true;
        else if(s[i]=='S') v[2] = true;
        else if(s[i]=='N') v[3] = true;
    }
    string ans = "Yes";
    REP(i,4){
        if(v[0]!=v[1]) ans = "No";
        else if(v[2]!=v[3]) ans = "No";
    }
    print(ans);
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
	ll q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;
	h = min(h, q * 2);
	s = min(s, h * 2);
	if (s * 2 < d) {
		cout << s*n << endl;
	}
	else {
		int x = n % 2;
		cout << d*(n / 2) + x*s << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  unsigned long long int
#define pb push_back
#define sx 300007
int main()
{
    int n,cnt=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int val;
        cin>>val;
        if((val%2!=0)&&(i%2!=0))
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<stack>
#include<queue>
#include<map>
#include<cstring>
#include<functional>

using namespace std;

int main()
{
	//freopen("input.txt", "r", stdin);

	int k;
	bool r[1000001] = { 0, };

	scanf("%d", &k);

	int cur = 7 % k;
	int cnt = 1;

	r[cur] = true;

	while (cur)
	{
		cur = (cur * 10 + 7) % k;

		if (r[cur])
		{
			printf("-1\n");

			return 0;
		}

		r[cur] = true;

		cnt++;
	}

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

	return 0;
}

Measured memory_bytes: 2708
///////////////////////////////////////////
//root@NULLCT$(☝ ՞ਊ ՞)☝  << "Be accept!!"//
///////////////////////////////////////////
//#define BOOST
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int66_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   //setfill(char)
#include <ios>       //left,right
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
#ifdef BOOST
#include <boost/multiprecision/cpp_int.hpp> // cpp_int
using namespace boost::multiprecision;
#endif
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
int setup(void) { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); return 0; }
int lenght(char* str) { int i = 0; while (str[i])i++; return i; }
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); }
int iinput(void) { int a = 0; cin >> a; return a; }
int dinput(void) { double a = 0; cin >> a; return a; }
string sinput(void) { string a = ""; cin >> a; return a; }
int kuriup(double a) { int b = int(a); if (a != b) { return b + 1; } else { return b; } }
int kuridown(double a) { int b = int(a); return b; }
int run(void);
int main() { setup(); run(); return 0; }
/////////////////////////////////////////////////////////////////////////////////////////
int run(void) {

  string s = sinput();

  if(int(s.length())%2 != 0){
    cout<<"No"<<endl;
    return 0;
  }

  for(int i=0;i < int(s.length());i+=2){
    if(s[i]!='h' || s[i+1]!='i'){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;

  return 0;
}



Measured memory_bytes: 256
import heapq

def dijkstra(s, edge):
    cost = [float('inf')] * n
    cost[s] = 0
    hq = [(0, s)]
    heapq.heapify(hq)
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]:
            continue
        for d, u in edge[v]:
            if c + d < cost[u]:
                heapq.heappush(hq, (c + d, u))
                cost[u] = c + d
    return cost

n, m, s, t = map(int, input().split())
s -= 1
t -= 1
yen = [[] for _ in range(n)]
snuuk = [[] for _ in range(n)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    u -= 1
    v -= 1
    yen[u].append((a, v))
    yen[v].append((a, u))
    snuuk[u].append((b, v))
    snuuk[v].append((b, u))
py = dijkstra(s, yen)
ps = dijkstra(t, snuuk)
res = [-1] * n
tmp = 10 ** 16
for i in range(n-1, -1, -1):
    if py[i] + ps[i] < tmp:
        tmp = py[i] + ps[i]
    res[i] = 10 ** 15 - tmp
print(*res, sep='\n')

Measured memory_bytes: 81732
#include<stdio.h>
int main(){
  int A,B,C,X,Y;
  scanf("%d%d%d%d%d",&A,&B,&C,&X,&Y);
  int Z;
  Z=0;
  if(C*2>=A+B){
  Z=A*X+B*Y;
  }else{
  if(X>=Y){
    if(A<C*2){
      Z=C*2*Y+A*(X-Y);
      }else{
      Z=C*2*X;
      } 
    }else{
    if(B<C*2){
      Z=C*2*X+B*(Y-X);
      }else{
      Z=C*2*Y;
      } 
    }
  }
  printf("%d\n",Z);
}

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

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

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

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

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

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

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

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

fn main(){

    input!{
        h: usize,
        w: usize,
        k: usize,
        mat: [chars; h],
    }

    // let mut cnt = 0;
    let mut ans = 0;

    // for x in 0..h+1 {
    //     for y in 0..w+1 {
    //         for i in 0..h {
    //             if x==i {
    //                 continue;
    //             } else {
    //                 for j in 0..w {
    //                     if y==j{
    //                         continue;
    //                     } else {
    //                         if mat[i][j]=='#' {
    //                             cnt += 1;
    //                         }
    //                     }
    //                 }
    //             }
    //         }
    //         print!("{}, ",x);
    //         print!("{}, ",y);
    //         println!("{}",cnt);
    //         if cnt==k{
    //             ans += 1;
    //         }
    //         cnt = 0;
    //     }
    // }
    
    for maskR in 0..(1<<h) {
        for maskC in 0..(1<<w) {
            let mut black = 0;
            for i in 0..h {
                for j in 0..w {
                    if (((maskR>>i) & 1)==0) && (((maskC>>j) & 1)==0) && mat[i][j]=='#' {
                        black += 1;
                    }
                }
            }
            if black==k {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}

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

int main() {
  int a,b;
  cin>>a>>b;
  int man=10000;
  int gosen=5000;
  int sen=1000;
  if(b>man*a){
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
    return 0;
  }
  for(int i=0;i<b/man+1;i++){
    for(int j=0;j<b/gosen+1;j++){
      for(int k=0;k<b/sen+1;k++){
        if(i*man+j*gosen+k*sen>b)break;
        if(i+j+k>a)break;
        if(i*man+j*gosen+k*sen==b&&i+j+k==a){
          cout<<i<<" "<<j<<" "<<k<<endl;
          return 0;
        }
      }
    } 
  }
  cout<<-1<<" "<<-1<<" "<<-1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <scoped_allocator>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
using namespace std;
string s;
vector<ll> v;
vector<ll> v1;
vector < pair<ll, ll > > vp;
vector < pair<ll, ll > > vp1;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
set<ll> st;
map<char, ll> mp;

/*--------------------template--------------------*/


int main()
{
	string a, b, c;
	cin >> a >> b >> c;
	a = toupper(a[0]);
	b = toupper(b[0]);
	c = toupper(c[0]);
	cout << a[0] << b[0] << c[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if(C >= A && C <= B){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n, m = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(m)]

ans = [1] * (n + 1)

prev = [0] * (n + 1)

xy.sort()
for x, y in xy:

    temp = ans[y] + ans[y + 1] - prev[y]
    ans[y] = temp
    ans[y + 1] = temp
    prev[y] = temp

print(" ".join(list(map(str, ans[1:]))))



Measured memory_bytes: 40568
#include <bits/stdc++.h>
#define endl '\n'
#define INF 1e9 + 5

//This solution is  recursive but slow

using namespace std;

int main() { 
    int n; cin >> n;
    int k;cin>>k;
    int jumps[n];
    vector<int> dp(n, INF); 
    int aux = 0;
    //Reading data
    for (int i = 0; i < n; i++) cin >> jumps[i];
    //Initialize base cases
    dp[0] = 0;
    //Initialize dp
    for ( int i = 0; i < n; i++ ) {
        for ( int j = i + 1; j <= i + k; j++ ) {
            if (j < n)
                dp[j] = min(dp[j], dp[i] + abs( jumps[j] - jumps[i]));
        } 
    }
    cout << dp[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 4016
import sys
from math import sqrt
from collections import Counter

input = sys.stdin.readline


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    n = I()
    a = I()

    if n % 500 <= a:
        print("Yes")
    else:
        print("No")

    pass


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,n=0;
  double w=0;
  std::cin >> x>>y;
  if(x>y)x%=y;
  if(x>abs(x-y))x=abs(x-y);
  std::cout << x << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define PDD pair<LD,LD>
#define eps 1e-9
#define HH1 402653189
#define HH2 1610612741

int n, a, b;
LL v[55], dp[55][55], way[55][55], best, ans;

int main () {
	
	scanf("%d%d%d", &n, &a, &b);
	
	FOE(i, 1, n) scanf("%lld", v + i);
	
	way[0][0] = 1;
	
	FOE(i, 1, n) {
		FOE(j, 0, n) {
			dp[i][j] = dp[i - 1][j];
			way[i][j] = way[i - 1][j];
		}
		FOE(j, 1, n) {
			LL val = dp[i - 1][j - 1] + v[i];
			if (val > dp[i][j]) {
				dp[i][j] = val;
				way[i][j] = way[i - 1][j - 1];
			} else
			if (val == dp[i][j]) {
				way[i][j] += way[i - 1][j - 1];
			}
		}
	}
	
	best = a;
	
	FOE(i, a, b) {
//			dp[n][i] / i > dp[n][best] / best
		if (dp[n][i] * best > dp[n][best] * i) {
			best = i;
			ans = way[n][i];
		} else
		if (dp[n][i] * best == dp[n][best] * i) {
			ans += way[n][i];
		}
	}
	
	printf("%.10Lf\n%lld\n", dp[n][best] / (LD)best, ans);
	
	return 0;
	
}

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

struct UnionFind{
    vll par;
    vll rank;
    vll num;
    //* member functions
    UnionFind(ll n){
        par = vll(n);
        rank = vll(n, 0);
        num = vll(n, 1);
        for(ll i=0; i< n; i++) 
            par[i] = i;
    }

    int find(ll x){
        if(par[x] == x) return x;
        else{
            return par[x] = find(par[x]);
        }
    }

    void unite(ll x, ll y){
        x = find(x); y = find(y);
        if(x == y) return;

        if(rank[x] < rank[y]){
            par[x] = y; //* new root is y
            num[y] += num[x];
        }
        else {
            par[y] = x; //* new root is x
            num[x] += num[y];
            if(rank[x] == rank[y]) rank[x] ++;
        }
    }

    ll get_number(ll x){
        x = find(x);
        return num[x];
    }

    bool same(ll x, ll y){
        return find(x) == find(y);
    }
};

void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B){
    stack<ll> ans;
    ll cnt = N * (N-1) /2;
    UnionFind uf(N);
    for(ll i= M-1; i>=0; i--){
        ans.push(cnt);
        ll u = A[i]-1, v = B[i]-1;
        if(!uf.same(u, v)){
            cnt -= uf.get_number(u)*uf.get_number(v);
            uf.unite(u, v);
        }
    }
    while(!ans.empty()){
        cout << ans.top() << endl;
        ans.pop();
    }
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 5788
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <ctime>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#include <cmath>
#include <functional>
#include <map>
#include <set>
using namespace std;
const long INF = 1000000009;

long m, n;

int main(){
	cin >> n >> m;
	long ans = 1;
	for(int i = 0; i < m; i++){
		ans *= 2;
	}
	ans *= 100*(n-m) + 1900*m;
	cout << ans << endl;
	return 0;
}

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

int main(void) 
{
  int n, m, k, i, j, b, ans;
  scanf("%d %d", &n, &m);
  unsigned int list = UINT_MAX, a;
  for(i = 0; i < n; ++i) {
    scanf("%d", &k); a = 0u;
    for(j = 0; j < k; ++j){
      scanf("%d", &b); a |= 1u << b;
    }
    //printf("a = %d, ", a);
    list &= a;
    //printf("%d\n", list);
  }
  
  ans = 0;
  for(i = 0; i < 31; ++i) {
    //printf(" check: %d result: %d\n", 1u << i, list & (1u<<i) );
    if( (list & (1u << i)) != 0) { ++ans; }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn is_palindrome<T: AsRef<[u8]>>(s: T) -> bool {
    let t = s.as_ref();
    for i in 0..t.len() / 2 {
        if t[i] != t[t.len() - 1 - i] {
            return false;
        }
    }
    return true;
}
fn main() {
    input!{
        s: String,
    }
    println!("{}", if is_palindrome(&s) && is_palindrome(&s[0..s.len() / 2]) && is_palindrome(&s[1 + s.len() / 2..]) { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include<iostream>
#include<queue>
#include<functional>
#include<climits>
#include<map>
#include<set>
#include<cmath>
#include<cstdlib>
#include<cassert>

#define M 61
#define H 11
#define W 11

using namespace std;

const int infty = INT_MAX;
const int di[] = {-1,0,1,0};
const int dj[] = {0,1,0,-1};

struct state{
  int o,i,j,cost;
  int l,r;
  state():o(0),i(-1),j(-1),cost(infty),l(-1),r(-1){}
  state(int o,int i,int j,int l, int r,int cost):o(o),i(i),j(j),cost(cost),l(l),r(r){}
  bool operator>(const state &t)const{return cost>t.cost;}
};

bool isinside(int i, int j, int h, int w){ return 0<=i&&i<h&&0<=j&&j<w; }

int dijkstra(int o, int maxO, int maxC, int h, int w, int g[H][W])
{
  int ret = infty;
  priority_queue<state,vector<state>,greater<state> > pq;
  static int A[M][H][W][W][W];
  static bool vis[M][H][W][W][W];

  o=min(maxO,o);

  for(int i = 0; i < M; ++i){
    for(int j = 0; j < H; ++j){
      for(int k = 0; k < W; ++k){
	for(int l = 0; l < W; ++l){
	  for(int m = 0; m < W; ++m){
	    A[i][j][k][l][m] = infty;
	    vis[i][j][k][l][m] = false;
	  }
	}
      }
    }
  }

  for(int stj = 0; stj < w; ++stj){
    int ic;
    int io;
    if(o<=1) return infty;
    if(g[0][stj]>0){ic=0;io=min(maxO,o+g[0][stj]-1);}
    else{ic=-g[0][stj];io=o-1;}
    state init(io,0,stj,stj,stj,ic);
    A[io][0][stj][stj][stj] = ic;
    pq.push( init );
  }
  
  while(!pq.empty()){
    state nst = pq.top(); pq.pop();

    if( vis[nst.o][nst.i][nst.j][nst.l][nst.r] ) continue;
    else vis[nst.o][nst.i][nst.j][nst.l][nst.r] = true;

    if(nst.i == h-1 && nst.o >= 1 )
      ret = min(ret, nst.cost);
    
    // printf("(%d,%d) with oxygen %d cost = %d\n", nst.i, nst.j, nst.o, nst.cost);
    
    for(int k=1;k<4;++k){
      state next = nst;
      next.i += di[k];
      next.j += dj[k];
      if( isinside( next.i, next.j, h, w ) ){
	if( next.o - 1 <= 0 ) continue;
	if( k == 2 ){
	  next.l = W+1;
	  next.r = -1;
	}
	if( g[next.i][next.j] > 0 ){
	  int d_o = g[next.i][next.j];
	  if( next.l <= next.j && next.j <= next.r )
	    d_o = 0;
	  next.o += d_o;
	}else{
	  int d_c = -g[next.i][next.j];
	  if( next.l <= next.j && next.j <= next.r )
	    d_c = 0;
	  next.cost += d_c;
	}
	next.o = min( maxO, next.o-1 );
	next.l = min( next.l, next.j);
	next.r = max( next.r, next.j);
	if( next.cost > maxC ) continue;
	
	if( next.o > 0 ){
	  if( next.cost < A[next.o][next.i][next.j][next.l][next.r] ){
	    A[next.o][next.i][next.j][next.l][next.r] = next.cost;
	    if( !vis[next.o][next.i][next.j][next.l][next.r] )
	      pq.push(next);
	  }
	}
      }
    }
  }
  return ret;
}

int main()
{
  while(true){
    int w,h;
    int g[H][W];
    int f,m,o;
    int res=infty;
    scanf("%d%d", &w, &h);
    if( w==0 && h==0 ) break;
    scanf("%d%d%d", &f, &m, &o);

    for(int i = 0; i < h; ++i){
      for(int j = 0; j < w; ++j){
	scanf("%d", &g[i][j]);
      }
    }

    res=dijkstra(o,m,f,h,w,g);
    if(res>f){
      puts("NA");
    }else{
      printf("%d\n",res);
    }
  }
  return 0;
}

Measured memory_bytes: 5456
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n,m;
	cin >> n >> m;

	cout << max(0,n - 2*m) << endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    A = [int(x) for x in input().split()]
    money = 1000
    kabu_c = 0
    l = list()
    for i in range(n-1):
        if A[i+1] - A[i] > 0:
            l.append(1)
        else:
            l.append(0)
    for idx, i in enumerate(l):
        if i == 1 and money - A[idx] >= 0:
            kabu_c = money // A[idx]
            money = money - (kabu_c * A[idx])
        if i == 0:
            money = money + (kabu_c * A[idx])
            kabu_c = 0
    if kabu_c > 0:
        money = money + (kabu_c * A[n-1])
    print(money)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9184
#include <iostream>
#include <queue>
#include <vector>
#include <functional>
#include <cmath>

using namespace std;

int main() {
	int n, m;
	while (cin >> n >> m) {
		if (n == 0 && m == 0) {
			break;
		}
		priority_queue< long long int, vector<long long int>, greater<long long int> >pq;
		long long int a;
		for (int i = 0; i < n; i++) {
			cin >> a;
			pq.push(a);
		}
		for (int i = 0; i < m; i++) {
			cin >> a;
			pq.push(a);
		}
		a = pq.top();
		pq.pop();
		long long int MAX = a;
		while (!pq.empty()) {
			long long int b = pq.top();
			pq.pop();
			MAX = max(MAX, b-a);
			a = b;
		}
		cout << MAX << endl;
	}
	return 0;
}

Measured memory_bytes: 1600
#include<cstdio>
long long f[3005][3005][4];
long long value[3005][3005];

long long max(long long a,long long b){ return a>b?a:b; }

int main(){
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    for(int i = 1; i <= k; i++){
        int r,c; long long v;
        scanf("%d%d%lld",&r,&c,&v);
        value[r][c] = v;
    }
    f[1][1][0] = 0; f[1][1][1] = value[1][1];
    long long ans = max(f[1][1][0],f[1][1][1]);
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(i==j && j==1) continue;
            long long lasti = -1;
            for(int k = 0; k <= 3; k++){
                if(i!=1) lasti = max(lasti,f[i-1][j][k]);
            }
            for(int k = 0; k <= 3; k++){
                f[i][j][k] = 0;
                if(i!=1){
                    f[i][j][k] = max(f[i][j][k],lasti);
                    if(k!=0) f[i][j][k] = max(f[i][j][k],lasti+value[i][j]);
                }
                if(j!=1){
                    f[i][j][k] = max(f[i][j][k],f[i][j-1][k]);
                    if(k!=0) f[i][j][k] = max(f[i][j][k],f[i][j-1][k-1]+value[i][j]);
                }
                if(i==n && j==m) ans = max(ans,f[i][j][k]);
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 353808
#include <stdio.h>
int main(){
  int a,b;
  scanf("%d %d", &a, &b);
  if(a < b){
    printf("a < b\n");
  }
  else if(a > b){
    printf("a > b\n");
  }
  else{
    printf("a == b\n");
  }

  return 0;
}



Measured memory_bytes: 2072
N, K = map(int, input().split())
S = input()
block = []
prev = 1
cnt = 0

for s in S:
    if str(prev) != s:
        prev = 1 - prev
        block.append(cnt)
        cnt = 1
    else:
        cnt += 1
else:
    if cnt != 0:
        block.append(cnt)
if len(block) %2 == 0:
    block.append(0)

length = 2 * K + 1
left = 0
right = min(length, len(block))
tmp = sum(block[left:right])
ans = tmp

for i in range(2,len(block),2):
    new_left = left + 2
    tmp -= sum(block[left:new_left])
    left = new_left
    new_right = min(right+2, len(block))
    tmp += sum(block[right:new_right])
    right = new_right
    ans = max(tmp, ans)
print(ans)

Measured memory_bytes: 47212
#include <iostream>

int num_stack[1000];
int num_stack_idx = 0;

void Push(int in)
{
    num_stack[num_stack_idx] = in;
    num_stack_idx++;
}

void Pop(int &out)
{
    out = num_stack[num_stack_idx - 1];
    num_stack_idx--;
}

int main(int argc, char* argv[])
{
    std::string input_str;
    while (std::cin >> input_str) {
        
        if (input_str == "+") {
            int out_1, out_2;
            Pop(out_1);
            Pop(out_2);
            int res = out_2 + out_1;
            Push(res);
        } else if (input_str == "-") {
            int out_1, out_2;
            Pop(out_1);
            Pop(out_2);
            int res = out_2 - out_1;
            Push(res);
        } else if (input_str == "*") {
            int out_1, out_2;
            Pop(out_1);
            Pop(out_2);
            int res = out_2 * out_1;
            Push(res);
        } else {
            Push(std::stoi(input_str));
        }
    }

    int res;
    Pop(res);
    std::cout << res << std::endl;

    return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    VI p(N+1); REP(i,N) {
        cin >> p[i];
        p[i]--;
    }
    int ans = 0;
    REP(i,N){
        if(p[i] == i) {
            p[i+1] = p[i];
            ans++;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 640
#include <cstdio>
int main(){int a,b,c,d;scanf("%d%d%d", &a, &b, &c);c-=60;d=a+b;
while((c+=60)<3600)
if(0<=c%d&&c%d<=a)
break;
printf("%d\n",c>3599?-1:c);return 0;}

Measured memory_bytes: 2756
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace atcoder;
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

struct S {
    ll num;
    ll o, z;
    ll rev(){
        ll a = o + z;
        ll res = a * (a - 1) / 2;
        res -= num;
        res -= o * (o - 1) / 2 + z * (z - 1) / 2;
        return res;
    }
};
S op(S l, S r){
    return S{l.num + r.num + l.o * r.z, l.o + r.o, l.z + r.z};
}

S e(){
    return S{0, 0, 0};
}

S mapping(bool is_rev, S x){
    return is_rev ? S{x.rev(), x.z, x.o} : x;
}

bool composition(bool f, bool g){
    return f ^ g;
}

bool id(){
    return false;
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,q; cin >> n >> q;
    vector<S> a(n);
    rep(i,0,n){
        ll t; cin >> t;
        if(t)a[i] = S{0, 1, 0};
        else a[i] = S{0, 0, 1};
    }

    lazy_segtree<S, op, e, bool, mapping, composition, id> lseg(a);

    rep(i,0,q){
        ll t; cin >> t;
        if(t == 1){
            ll l,r; cin >> l >> r;
            l--;
            lseg.apply(l, r, true);
        }
        else{
            ll l,r; cin >> l >> r;
            l--;
            cout << lseg.prod(l, r).num << "\n";
        }
    }
}

Measured memory_bytes: 20392
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r,D,X;
  cin >> r>>D>>X;
  cout<<r*X-D<<endl;
  cout<<r*(r*X-D)-D<<endl;
  cout<<r*(r*(r*X-D)-D)-D<<endl;
  cout<<r*(r*(r*(r*X-D)-D)-D)-D<<endl;
  cout<<r*(r*(r*(r*(r*X-D)-D)-D)-D)-D<<endl;
  cout<<r*(r*(r*(r*(r*(r*X-D)-D)-D)-D)-D)-D<<endl;
  cout<<r*(r*(r*(r*(r*(r*(r*X-D)-D)-D)-D)-D)-D)-D<<endl;
  cout<<r*(r*(r*(r*(r*(r*(r*(r*X-D)-D)-D)-D)-D)-D)-D)-D<<endl;
  cout<<r*(r*(r*(r*(r*(r*(r*(r*(r*X-D)-D)-D)-D)-D)-D)-D)-D)-D<<endl;
  cout<<r*(r*(r*(r*(r*(r*(r*(r*(r*(r*X-D)-D)-D)-D)-D)-D)-D)-D)-D)-D<<endl;
}

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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    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 pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    ll ans = 0;

    rep(i,n) rep(j, n) rep(k, n) {
        ans += gcd(gcd(i+1, j+1), k+1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define float long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define endl '\n'
#define pii pair<int, int>
#define min3(a,b,c) min(a, min(b, c))
#define max3(a,b,c) max(a, max(b, c))
#define all(x) x.begin(), x.end()
#define fill(a,b) memset(a, b, sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

signed main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

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

    for(int i=1;i<=5;i++){
        int x; cin>>x;
        if(x==0){
            cout<<i<<endl;
            return 0;
        }
    }

}

Measured memory_bytes: 3604
#include <iostream>
#include <tuple>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define REP(var, num) for(int var = 0; var < num; var++)
typedef signed long long sll;
typedef unsigned long long ull;

int main() {
    sll d;
    cin >> d;

    switch (d) {
        case 25: cout << "Christmas" << endl; break;
        case 24: cout << "Christmas Eve" << endl; break;
        case 23: cout << "Christmas Eve Eve" << endl; break;
        case 22: cout << "Christmas Eve Eve Eve" << endl; break;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(size_t i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(size_t i=(b)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))

int main(){
	string S;
	cin >> S;
	int box[26] = { 0 };
	Foreach(item, S) {
		box[item - 'a']++;
	}
	Foreach(item, box) {
		if (item > 1) {
			out("no");
			return 0;
		}
	}
	out("yes");
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a,b,d,r;
    double f;
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	printf("%d %d %lf",d,r,f);
	return 0;
}

Measured memory_bytes: 636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = ip(br.readLine());
        int[] list = createListInt(br.readLine());
        bubbleSort(list.clone(), n);
    }

    static void checkStable(Card[] list1, Card[] list2) {
        for (int i = 0; i < list1.length; i++) {
            if (list1[i].serialN != list2[i].serialN) {
                System.out.println("Not stable");
                return;
            }
        }
        System.out.println("Stable");
    }

    static void bubbleSort(int[] list, int n) {
        int count = 0;
        boolean flag = true;
        while (flag) {
            flag = false;
            for (int i = n - 1; i > 0; i--) {
                if (list[i] < list[i - 1]) {
                    swap(list, i, i - 1);
                    count++;
                    flag = true;
                }
            }
        }
        print(list);
        System.out.println(count);
    }

    private static void print(int[] list) {
        int n = list.length;
        String[] str = new String[n];
        for (int i = 0; i < n; i++) {
            str[i] = String.valueOf(list[i]);
        }
        System.out.println(String.join(" ", str));
    }

    static void swap(Card[] list, int a, int b) {
        Card temp = list[a];
        list[a] = list[b];
        list[b] = temp;
    }

    static void swap(int[] list, int a, int b) {
        int temp = list[a];
        list[a] = list[b];
        list[b] = temp;
    }

    static int[] createListInt(String line) {
        String[] lines = line.split(" ");
        int n = lines.length;
        int[] list = new int[n];
        while (n-- > 0) {
            list[n] = Integer.parseInt(lines[n]);
        }
        return list;
    }

    static long[] createListLong(String line) {
        String[] lines = line.split(" ");
        int n = lines.length;
        long[] list = new long[n];
        while (n-- > 0) {
            list[n] = Long.parseLong(lines[n]);
        }
        return list;
    }

    static int ip(String s) {
        return Integer.parseInt(s);
    }

    static long lp(String s) {
        return Long.parseLong(s);
    }
}

class Card {
    static int n = 0;
    int serialN;
    char suit;
    int rank;

    Card(char suit, int rank) {
        serialN = n++;
        this.suit = suit;
        this.rank = rank;
    }

}

Measured memory_bytes: 24308
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 998244353;

int main(void){
  int n,k;
  cin >> n >> k;
  cout << n - k + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s;
    cin>>s;
    if(s[0]=='a'||s[0]=='e'||s[0]=='i'||s[0]=='o'||s[0]=='u') cout<<"vowel"<<endl;
    else cout<<"consonant"<<endl;
}

Measured memory_bytes: 256