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

using namespace std;

long long int n, ans = 0;

void jdg(long long int x) {
	long long int tmp = n;
	while (x < tmp) {
		if (tmp%x == 0) tmp /= x;
		else tmp -= x;
	}

	if (tmp == 1) {
		ans++;
		//cout << x << endl;
	}
}

int main(){

	int flag;
	long long int sqn, tmp;
	set<long long int> s;

	cin>> n;

	if (n < 10000) {
		for (long long int i = 2;i < n;i++) jdg(i);
		cout << ans + 1 << endl;
		return 0;
	}

	sqn = (long long int)sqrt(n);

	for (long long int i = 2;i <= sqn + 1;i++) {
		tmp = n;

		if ((n-1)%i == 0) {
			//cout << i << endl;
			s.insert(i);
			if ((n - 1) / i != i) s.insert((n - 1) / i);
		}

		flag = 0;
		while (tmp%i == 0) {
			tmp /= i;
			flag = 1;
		}
		if (tmp % i == 1 && flag) {
			//cout << i << endl;
			s.insert(i);
		}
	}
	s.insert(n-1);
	s.insert(n);

	cout << s.size() << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void qmax(int &x,int y) {if (x<y) x=y;}
void qmin(int &x,int y) {if (x>y) x=y;}
int read()
{
    char s;
    int k=0,base=1;
    while((s=getchar())!='-'&&s!=EOF&&!(isdigit(s)));
    if(s==EOF)exit(0);if(s=='-')base=-1,s=getchar();
    while(isdigit(s)){k=k*10+(s^'0');s=getchar();}
    return k*base;
}
void write(int x)
{
    if(x<0){putchar('-');write(-x);}
    else{if(x/10)write(x/10);putchar(x%10+'0');}
}
int n,m;
int fa[100100];
long long dis[100100];
long long l,r,d,D,X,Y;
int gf(int x)
{
	if (fa[x]==x) return x;
	int ft=fa[x];
	fa[x]=gf(fa[x]);
	dis[x]+=dis[ft];
	return fa[x];
}
int main()
{
	n=read();m=read();
	for (int i=1;i<=n;i++) fa[i]=i;
	for (int i=1;i<=m;i++)
	{
		l=read();r=read();d=read();
		if (gf(l)==gf(r))
		{
			D=dis[r]-dis[l];
			if (d!=D)
			{
				printf("No");
				return 0;
			}
		} else
		{
			int u=gf(l),v=gf(r);
			X=d+dis[l];
			Y=dis[r];
			if (X>=Y)
			{
				dis[v]=X-Y;
				fa[v]=u;
			} else
			{
				fa[u]=gf(v);
				dis[u]=Y-X;	
			}
		}
	}
	printf("Yes");
	return 0;
} 

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 1; i < n; i++)
 
int main() {
  int N;
  cin >> N;
  
  long long ans = 0;
  
  rep(i, N+1){
  	if (i % 3 != 0 && i % 5 != 0){
    	ans += i;
    }
  }
  
  cout << ans << endl;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    vector<int> v(N);
    rep(i, N) {
        cin >> v[i];
    }

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

    double div = v[0];
    repd(i, 1, N - 1) {
        div = (div + v[i]) / 2.0;
    }

    double ans = (div + v[N - 1]) / 2.0;

    cout << fixed << setprecision(5) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
#define int long long
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ

signed main(){
    int a,b; cin >> a >> b;
    cout << a*b << endl;
}


Measured memory_bytes: 3636
#[allow(unused_imports)]
use std::cmp::Ordering::{Equal, Greater, Less};
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;

// author: Seong Yong-ju <sei40kr@gmail.com>

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")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let x: i64;
    let y: i64;
    let z: i64;
    let k: i64;
    let As: Vec<i64>;
    let bs: Vec<i64>;
    let cs: Vec<i64>;

    input! {
        x: i64,
        y: i64,
        z: i64,
        k: i64,
        As: [i64; x as usize],
        bs: [i64; y as usize],
        cs: [i64; z as usize],
    };

    let mut abs = As
        .iter()
        .flat_map(|a| bs.iter().map(move |b| a + b))
        .collect::<Vec<_>>();
    abs.sort();

    let mut abcs = abs
        .iter()
        .rev()
        .take(k as usize)
        .flat_map(|ab| cs.iter().map(move |c| ab + c))
        .collect::<Vec<_>>();

    abcs.sort();

    for abc in abcs.into_iter().rev().take(k as usize) {
        println!("{}", abc);
    }
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

ll N, H;
vector<ll> A, B;

int main()
{
    cin >> N >> H;
    REP(i, N) {
        ll a, b;
        cin >> a >> b;
        A.push_back(a);
        B.push_back(b);
    }
    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    ll ans = 0;
    ll b_i = 0;
    while(H > 0) {
        if(b_i < N && B[b_i] > A[0]) {
            H -= B[b_i];
            b_i++;
        } else {
            if(H % A[0] == 0) { ans += H / A[0]; }
            else { ans += H / A[0] + 1; }
            break;
        }
        ans++;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2036
from itertools import product
tranps = [s+" "+str(n) for s, n in product(['S', 'H', 'C', 'D'], range(1, 14))]
n = int(raw_input())
tranp_in = [raw_input() for i in range(0,n)]
for tranp in tranps:
    if tranp in tranp_in:
        continue
    print tranp


Measured memory_bytes: 4704
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl

int main(){
  string s;cin>>s;
  int ans=700;
  rep(i,s.size()){
    if(s[i]=='o'){
      ans+=100;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000007
#define pi 3.14159265358979
//0=48,A=65,a=97

int main() {
    int n;cin >> n;
    cout << fixed << setprecision(10);
    cout << 2*n * pi << endl;

    return 0;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i, a, b) for(int i = (a); i<(b); ++i)
#define pb push_back
#define INF 10000000000000005
#define MOD 1000000007
#define all(v) v.begin(), v.end()

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

ll power(ll x, ll y, ll p = MOD){  
  ll res = 1LL; 
  x = x % p;
  if (x == 0) return 0;
  while (y > 0){
      if (y & 1LL)  
          res = (res*x) % p;
      y = y>>1LL; 
      x = (x*x) % p;  
  }  
  return res;  
}  

ll dp[3005][3005][4];
int r, c, k;

bool valid(int x, int y) {
	if(x < 0 || y < 0 || x >=r || y >=c) 	
		return false;
	return true;
}

int main(){
	// IO

	cin >> r >> c >> k;

	ll arr[r][c];

	memset(arr, 0LL, sizeof(arr));

	int x, y;
	ll v;
	bool p = false;
	for(int i = 0; i < k; ++i) {
		cin >> x >> y >> v;
		--x; --y;
		if(x == 0 && y == 0) {
			p = true;
		}
		arr[x][y] = v;
	}

	for(int i = 0; i<=r; ++i) {
		for(int j = 0; j<=c; ++j) {
			for(int k = 0; k<4; ++k) {
				dp[i][j][k] = 0;
			}
		}
	}

	for(int i = 1; i<=r; ++i) {
		for(int j = 1; j<=c; ++j) {
			for(int k = 0; k<4; ++k) {
				dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k]);
				if(k > 0 && arr[i - 1][j - 1]) {
					dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k - 1] + arr[i - 1][j - 1]);
				}
			}

			ll mxt = 0LL;
			for(int k = 0; k<4; ++k) {
				mxt = max(mxt, dp[i - 1][j][k]);
				dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][k]);
			}

			if(arr[i - 1][j - 1])
				dp[i][j][1] = max(dp[i][j][1], mxt + arr[i - 1][j - 1]);
			// debug(mxt);
		}
	}

	ll mx = 0;
	for(int i = 0; i<4; ++i) {
		mx = max(mx, dp[r][c][i]);
	}

	cout << mx << endl;

	return 0;
}

Measured memory_bytes: 355684
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

def main():
    S = input()
    T = input()

    count = 0

    for i in range(len(T)):
        if S[i] == T[i]:
            count += 1
    print(count)


if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>

using namespace std;
int main() {
	int n;
	cin >> n;
  int flg = 0;
  int ans = 1;
  int a, b;
  for (int i=0;i<n;i++){
    if (flg == 0){
      cin >> a;
      b = a;
      flg = 1;
    }else if (flg == 1){
      cin >> b;
      if (a>b){
        flg = 2;
      }else if(a<b){
        flg = 3;
      }
    }else if (flg==2){
      cin >> b;
      if(a<b){
        flg=1;
        ans++;
      }
    }else{
      cin >> b;
      if(a>b){
        flg=1;
        ans++;
      }
    }
        a = b;
  }
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,m,x;
  cin >> n >> m >> x;
  vi c(n);
  vvi a(n, vi(m));
  rep(i, n){
    cin >> c[i];
    rep(j, m){
      cin >> a[i][j];
    }
  }
  int ans = 10000000;
  for(int i = 1; i < (1 << n); i++){
    int score = 0;
    vi cnt(m);
    rep(j, n){
      if((i >> j) & 1){
        score += c[j];
        rep(k, m){
          cnt[k] += a[j][k];
        }
      }
    }
    bool ok = true;
    rep(k, m){
      if(cnt[k] < x) ok = false;
    }
    if(ok) ans = min(ans, score);
  }
  if(ans == 10000000) cout << -1 << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    double sum = max(0.0, 1 - (double)(k - 1) / n), flip = 1.0;
    int prev = k;
    while (k != prev || k != 1) {
        k = (k + 1) / 2;
        flip /= 2.0;
        //cerr << ' ' <<  k << prev << ' ' << flip << ' ' << sum << '\n';
        if (n >= k) {
            sum += ((double)(min(prev,n+1) - k) / (double)n) * flip;
        }
        prev = k;
    }
    cout << setprecision(15) << sum << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
  
int main(){
  int n;
  ll T, t, reset = 0, cur = 0;
  cin >> n >> T;
  for(int i = 0; i < n; i++){
    cin >> t;
    if(t - cur <= T) cur = t;
    else reset += t - cur - T, cur = t;
  }
  cout << cur + T - reset << endl;
  return 0;
}

Measured memory_bytes: 256
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision; 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second
#define pb push_back
#define REP(i,a,b) for(long long int i=a ; i<b ; i++)
#define mp make_pair
#define INF 1000000000000000000
#define mod 1000000007
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define vi vector<ll>
#define vd vector<ld>
#define vvi vector<vi>
#define vvd vector<vd>
#define vpi vector<pi>
#define vpd vector<pd>
#define us unordered_set<ll>
#define um unordered_map<ll,ll>
#define sortA(a) sort(a.begin(),a.end())
#define sortD(a) sort(a.begin(),a.end(),greater<ll>())
#define all(a) a.begin(),a.end()
#define N 100005


#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define in insert
#define fbo find_by_order
#define ook order_of_key


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

ll powmod(ll x,ll y)
{
	if(x==0)
		return 0;
	if(y==0 || x==1)
		return 1;
	if(y%2==0)
		return powmod((x*x)%mod,y/2)%mod;
	return (x*powmod(x,y-1)%mod)%mod;
}
void print1D(vi a)
{
	for(ll i=0;i<a.size();++i)
	{
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
void print2D(vector<vi> a)
{
	for(ll i=0;i<a.size();++i)
	{
		for(ll j=0;j<a[i].size();++j)
		{
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
}
vvi T(N);
vvi dp(N,vi(2));
void dfs(ll i,ll par)
{
	dp[i][0]=1;
	dp[i][1]=1;
	for(ll j=0;j<T[i].size();++j)
	{
		if(T[i][j]!=par)
		{
			dfs(T[i][j],i);
			dp[i][0]=(dp[i][0]*dp[T[i][j]][1])%mod;
			dp[i][1]=(dp[i][1]*(dp[T[i][j]][0]+dp[T[i][j]][1])%mod)%mod;
		}
	}
}
void solve()
{
	ll n;
	cin>>n;
	for(ll i=1;i<=n-1;++i)
	{
		ll u,v;
		cin>>u>>v;
		u--;
		v--;
		T[u].pb(v);
		T[v].pb(u);
	}
	dfs(0,0);
	cout<<(dp[0][0]+dp[0][1])%mod<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
	ll t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}


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

int main(){
  int N;
  cin >> N;
  long long M=1000000007;
  vector<int> A(N);
  long long sum=0;
  long long res=0;
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    sum+=A.at(i);
  }
  for(int i=0;i<N;i++){
    sum-=A.at(i);
    long long B=sum%M;
    long long C=(A.at(i)*B)%M;
    res=(res+C)%M;
  }
  cout << res << endl;
}
    
    

Measured memory_bytes: 3964
#include <algorithm>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using Pair = std::pair<long long, int>;

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<long long> l(m), r(m), d(m);
  for (int mi = 0; mi < m; ++mi) std::cin >> l[mi] >> r[mi] >> d[mi];
  std::vector<std::vector<Pair>> edges(n);
  for (int mi = 0; mi < m; ++mi) {
    edges[l[mi] - 1].push_back(Pair(d[mi], r[mi] - 1));
    edges[r[mi] - 1].push_back(Pair(-d[mi], l[mi] - 1));
  }
  std::vector<int> has_visited(n, false);
  for (int ni = 0; ni < n; ++ni) {
    if (has_visited[ni]) continue;
    std::queue<Pair> q;
    std::set<Pair> line;
    has_visited[ni] = true;
    line.insert(Pair(0, ni));
    q.push(Pair(0, ni));
    while (not q.empty()) {
      long long pos = q.front().first;
      int nj = q.front().second;
      q.pop();
      for (auto e : edges[nj]) {
        long long npos = pos + e.first;
        int nk = e.second;
        if (has_visited[nk]) {
          if (not line.count(Pair(npos, nk))) {
            std::cout << "No" << std::endl;
            return 0;
          }
        } else {
          line.insert(Pair(npos, nk));
          has_visited[nk] = true;
          q.push(Pair(npos, nk));
        }
      }
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}

Measured memory_bytes: 25320
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n ,k,cnt =0;
  cin >> n >> k;

  for(int i=0;i<n;i++)
    {
cnt++;
  if((k - 1) * (cnt - 1) + k >= n)break;
    }

  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ull unsigned ll
#define pb push_back
#define popb pop_back
#define mt make_tuple
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define piiii pair <pii,pii>
#define plll pair <pair <ll, ll>, ll>
#define rep0(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,x,y) for(ll i=x;i<=y;i++)
#define reprev(i,n) for(ll i=n;i>=0;i--)
#define all(c) c.begin(),c.end()
#define print(a) rep0(i,a.size()) cout << a[i] << " "
#define hi() cout << "\nHello, I am error. Can you find me? :):):)\n"
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_eppoch().count())
 
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;

const int mod = 1e9+7;
const long double pi = acos(-1);

ll power(ll x, ll y){
	x %= mod;
	if(y == 0) return 1;
	if(y == 1) return x;
	ll num = power(x,y/2) % mod;
	if(y%2 == 0) return (num*num)%mod;
	else return (((num*num)%mod)*x)%mod;
}

void solve(){

	int n,k;
	cin >> n >> k;
	vector <int> a(n);
	rep0(i,n) cin >> a[i];
	sort(all(a));

	int mx = 2000000000;
	rep0(i,n-k+1){
		mx = min(mx, a[i+k-1]-a[i]);
	}
	cout << mx;

	return;
}

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		// cout << "Case #" << t << ": ";
		solve();
		// cout << "\n";
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

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

int main()
{
  vector<int> v(7);
  int n, i;
  while (cin>>n, n) {
    fill(v.begin(), v.end(), 0);
    for (i = n; i > 0; i--) {
      cin>>n;
      if (n>60) n = 60;
      v[n/10]++;
    }
    for (i = 0; i < 7; i++) cout<<v[i]<<endl;
  }

  return 0;
}

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

const double PI = 3.1415926535897932;
const int INF = (int)1e9;
const ll LINF = 1e18;
const ll MOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

int main(void)
{
    int x, n;
    cin >> x >> n;
    
    v_int p(101);
    irep(i, n)  {
        int tmp;
        cin >> tmp;
        p[tmp]++;
    }

    int ans = 0;
    int diff = INF;
    for(int i = 2*x; i >= -2*x; i--) {
        int d = abs(x-i);
        
        if(diff >= d && !p[i]) {
            if(diff == d) {
                ans = min(ans, i);
            } else {
                ans = i;
            }
            diff = d;
        }
    }
    cout << ans << endl;

    return 0;
}

/*atcoder*/


Measured memory_bytes: 3620
def call(n):

    for i in range(1, n+1):
        x=i
        if x % 3==0:
            print(' {0}'.format(i), end='')
        else:
            while x>0:
                if x%10==3:
                    print(' {0}'.format(i), end='')
                    break
                x //= 10

    print()

call(int(input()))


Measured memory_bytes: 5880
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    new Main().b();

  }

  private void b() {
    try (Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)))) {

      long a = in.nextLong();
      long b = in.nextLong();
      long x = in.nextLong();

      System.out.println(solve(a, b, x));
    }
  }

  private long solve(long a, long b, long x) {
    long b_x = b / x;
    long a_x = a / x;
    if (a % x != 0) {
      a_x++;
    }
    return b_x - a_x + 1;
  }
}


Measured memory_bytes: 10320
use proconio::{fastout, input};
use std::cmp;

#[fastout]
fn main() {
    input! {
        n: i64,
        m: usize,
        gates: [(i64, i64); m],
    }

    let mut min = 1;
    let mut max = n;
    for (l, r) in gates {
        min = cmp::max(min, l);
        max = cmp::min(max, r);
    }
    let ans = cmp::max(0, max - min + 1);
    println!("{}", ans);
}


Measured memory_bytes: 4656
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    string s,t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    vvi v(n,vi(26,INF));
    vvi alph(26);
    rep(i,n){
        alph[s[i]-'a'].push_back(i);
    }
    rep(i,n)rep(j,26)if(alph[j].size()){
        int p = upper_bound(all(alph[j]),i)-alph[j].begin();
        if(p == alph[j].size()){
            p = 0;
        }
        if(i == alph[j][p])v[i][j] = n;
        else v[i][j] = (n + alph[j][p] - i)%n;
        //cout << i << " " << j << " " << v[i][j] << endl;
    }
    int ans = n-1;
    rep(i,m){
        //cout << ans << " " << ans%n << endl;
        int num = t[i] - 'a';
        //次はv[ans%n][num]個先
        if(v[ans%n][num] > n){
            cout << -1 << endl;
            return 0;
        }
        ans += v[ans%n][num];
    }
    cout << ans - (n-1) << endl;
}


Measured memory_bytes: 25856
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  int A=0;
  int B=0;
  cin >> n;
  vector<int>a(n);
  rep(i,n) cin >> a.at(i);
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  rep(i,n){
    if(i%2 == 0) A+= a.at(i);
    else B+= a.at(i);
  }
  cout << A-B<<endl;
}

Measured memory_bytes: 256
#include <cstdio>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

#define MAXN 3004

int N;
double P[MAXN];

bool cached[MAXN][MAXN];
double memo[MAXN][MAXN];
double F(int n, int h, int t) {
   if (n >= N)
      return h > t ? 1.0 : 0.0;
   if (t-h >= N-n)
      return 0.0;
   if (!cached[n][h]) {
      double& res = memo[n][h];
      res = F(n+1, h+1, t) * P[n] + F(n+1, h, t+1) * (1-P[n]);
      cached[n][h] = true;
   }
   return memo[n][h];
}

int main(int argc, char* argv[]) {
   scanf("%d", &N);
   REP(i, N)
      scanf("%lf", &P[i]);

   double res = F(0, 0, 0);
   printf("%.10f\n", res);

   return 0;
}


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

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> member(n, k - q);
    int tmp;
    for(int i = 0; i < q; i++){
        cin >> tmp;
        member.at(tmp - 1)++;
    }

    for(int i = 0; i < member.size(); i++){
        if(member.at(i) > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 3756
#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
using namespace std;

int main(){
    int K,N;
    cin>>K>>N;
    vector<int>A(N);
    for(int i=0;i<N;i++)cin>>A[i];
    sort(A.begin(), A.end());
    priority_queue<int>x;
    x.push(A[0]+K-A[N-1]);
    for(int i=0;i<N-1;i++)
    {
        x.push(A[i+1]-A[i]);
    }
cout<<K-x.top();

return 0;
}

Measured memory_bytes: 2424
#include <bits/stdc++.h>
#define Rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef int64_t intl;


intl modpow(intl a, intl n, intl p){
  intl res = 1;
  while (n > 0){
    if (n&1){res = (res * a) % p;}
	a = (a * a) % p;
    n >>= 1;
  }
  return res;
}

intl modinv(intl a, intl p){
  if (a==0){
    cout << "/0 at modinv"<<endl;
    exit(0);
  }
  if (a < 0){
    cout << "/- at modinv" <<endl;
    exit(0);
  }
  if (a==1){return 1;}
  if (a > p){return modinv(a%p, p);}

  return p - ( modinv(p%a,p) * (p/a) ) % p;
}

intl modcomb(intl n, intl k, intl p){
  if (k > n || k < 0 || n < 0){
    cout << "error at modcomb"<<endl;
    exit(0);
  }
  if (2*k > n){ k = n-k;}
  if (k ==0){return 1;}
  intl c=1;
  for (intl i = 0; i < k; i++){
    c =( c * ( (n-i) % p ) % p ) * modinv(i+1,p) % p;
  }
  return c;
}

int main(){
  intl N,M;
  cin >> N >> M;
  cout << N * (N-1)/2 + M * (M-1)/2;
}

Measured memory_bytes: 256
import java.util.*;

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

    int max = 0;
    int tmp = 0;

    for (int i=0; i<s.length(); i++)
    {
        if (s.charAt(i) == 'R')
            tmp++;
        else
            tmp = 0;
        
        if (tmp > max)
            max = tmp;
    }

    System.out.println(max);

  }
}

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

int main() {

	string S;
    
    cin >> S;
    
    int count = 0;
    
    for(int i = 0; i < 3; i++){
    	if(S.at(i) == 'R'){
 			count++;
            }
    }
    if(count==3)
    	cout << 3 <<endl;
            
    else if(count==2 && S.at(1)=='R')
	 	cout << 2 <<endl;
            
  	else if(count == 0)
    	cout << 0 <<endl;
        
    else
    	cout << 1 <<endl;
}        
            


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

unsigned nChoosek( unsigned n, unsigned k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    int result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
    }
    return result;
}

int main() 
{
    ll n;
    cin >> n;
    vector<ll> v(5,0);
    ll sum=0;
    for (ll i=0; i<n; i++)
    {
        string s;
        cin >> s;
        char x = s[0];
        if (x=='M') v[0]++;
        if (x=='A') v[1]++;
        if (x=='R') v[2]++;
        if (x=='C') v[3]++;
        if (x=='H') v[4]++;
    }
    for (int i=0; i<5; i++)
        for (int j=i+1; j<5; j++)
            for (int k=j+1; k<5; k++)
                sum += v[i]*v[j]*v[k];
    cout << sum;
    return 0;
}

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

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	s = sys.stdin.readline().rstrip()
	if s == "ABC":
		print("ARC")
	else:
		print("ABC")
	


main()

Measured memory_bytes: 9900
#include <bits/stdc++.h>
using namespace std;
long long int cal(vector<long long int> &A,long long int N,long long int money,long long int flag){
    int copy=flag;
    for(int i=flag;i<N-1;i++){
        if(i==N-2) break;
        if(A.at(i)>A.at(i+1)) break;
        flag++;
    }
    flag++;
    if(flag==N-1&&A.at(flag-1)>A.at(flag)&&A.at(flag-2)<=A.at(flag-1)) return money+(money/A.at(copy))*(A.at(flag-1)-A.at(copy));
    if(flag==N-1&&A.at(flag-1)>A.at(flag)) return money;
    if(flag==N-1) flag++;
    money+=(money/A.at(copy))*(A.at(flag-1)-A.at(copy));
    if(flag==N) flag--;
    //cout << money << endl;
    if(flag==N-1){
        return  money;
    }else{
        //cout << N << " " << money <<" "<<flag<< endl;
        return cal(A,N,money,flag);
    } 
} 
int main(void){
    long long int N;
    long long int money=1000;
    cin >> N;
    vector<long long int> A(N,0);
    for(int i=0;i<N;i++){
        cin >> A.at(i);
    }
    long long int flag=0;
    money=cal(A,N,money,flag);
    cout << money;
}

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

int main()
{
	map<string,int>m;
	long long n,sum=0;
	cin >> n;
	while(n--){
		char a[11];
		string s1;
		cin >>a;
		sort(a,a+10);
		for(int i = 0;i <10;i++){
			s1+=a[i];
		}
		m[s1]++;
	}
	map<string,int>::iterator it;
	for(it = m.begin();it!=m.end();it++){
		for(int i = 1;i <= it -> second-1;i++){
			sum+=i;
		}
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 12800
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

const COMMAX int = 200001
const MOD int = 998244353

var fac [COMMAX]int
var finv [COMMAX]int
var inv [COMMAX]int

// テーブル作成
func COMinit() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < COMMAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

// 二項係数nCk
func COM(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func modPow(a, n, mod int) int {
	ret := 1
	for n > 0 {
		if n&1 == 1 {
			ret = (ret * a) % mod
		}
		a = (a * a) % mod
		n >>= 1
	}
	return ret
}

func modInv(a, mod int) int {
	b := mod
	u, v := 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		u -= t * v
		a, b = b, a
		u, v = v, u
	}
	u %= mod
	if u < 0 {
		u += mod
	}
	return u
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	COMinit()

	n, m, k := nextInt(), nextInt(), nextInt()

	ans := 0
	pow := modPow(m-1, n-1-k, MOD)
	for ; k >= 0; k-- {
		add := ((m * COM(n-1, k) % MOD) * pow) % MOD
		ans += add
		ans %= MOD
		pow *= m - 1
		pow %= MOD
	}

	puts(ans)
}


Measured memory_bytes: 6488
#pragma GCC optimize ("03")
#pragma GCC target("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
 
#define sz(x) (ll)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define nl "\n"
 
const int mod=10e7+7;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int x, a, b ;
	cin >> x >> a >> b;
	int eat=-a+b;
	//fifth day after it was expired
	int ex=-a+x;
	//expires on the -4th day
	if(eat<=0) {
		cout << "delicious";
	}else if(eat<=x) {
		cout << "safe";
	}else {
		cout << "dangerous";
	}
}


Measured memory_bytes: 3660
#include<stdio.h>

 int max(int a[], int N){
        int i;
        int max = a[0];
        for(i=0;i<N;i++){
            if(a[i] > max){
                max = a[i];
            }
        }
   return max;
    }

int main()
{
  int K,X;

    scanf("%d", &K);
    scanf("%d", &X);

  
 	int first,last;
  	int a,b;
  	a = X -(K-1);
  	b = X +(K-1);
  if(a > -1000000){
  	first = a;
  }else{
   	first = -1000000; 
  }
  if(b < 1000000){
	last = b;

  }else{
    last = 1000000;
  }
  int sum;
  sum = (K-1)+(K-1)+1;
  int i=0;
  for(i=first;i<last;i++){
	printf("%d ",i);
    
  }
  printf("%d",last);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define For(i,j,k) for (int i=j;i<=k;i++)
using namespace std;
const int N=200005;
void GG(){
	puts("No");
	exit(0); 
}
int t[N],n;
void add(int x,int v){
	for (;x<=n;x+=x&(-x))
		t[x]+=v;
}
int ask(int x){
	int s=0;
	for (;x;x-=x&(-x))
		s+=t[x];
	return s;
}
int pos[N];
int findp(int x){
	return pos[x]+ask(pos[x]);
}
int ans[N],rev[N],tmp[N];
void work1(){
	memset(t,0,sizeof(t));
	memset(rev,0,sizeof(rev));
	For(i,1,n) pos[abs(ans[i])]=i;
	For(i,1,n) if (i&1){
		int Pos=findp(i)+i-1;
		add(pos[i],-2);
		if (i!=Pos)
			rev[i+1]^=1,rev[Pos]^=1;
	}
	For(i,1,n) rev[i]^=rev[i-1];
	For(i,1,n) if (!(i&1)&&rev[i]) ans[i]*=-1;
	For(i,1,n) if (i&1)
		if (abs(abs(ans[i])-i)%4==2)
			tmp[abs(ans[i])]=-ans[i];
		else tmp[abs(ans[i])]=ans[i];
	For(i,1,n) if (i&1) ans[i]=tmp[i];
}
void work2(){
	memset(t,0,sizeof(t));
	memset(rev,0,sizeof(rev));
	For(i,1,n) pos[abs(ans[i])]=i;
	For(i,1,n) if (!(i&1)){
		int Pos=findp(i)+i-1;
		add(pos[i],-2);
		if (i!=Pos)
			rev[i+1]^=1,rev[Pos]^=1;
	}
	For(i,1,n) rev[i]^=rev[i-1];
	For(i,1,n) if ((i&1)&&rev[i]) ans[i]*=-1;
	For(i,1,n) if (!(i&1))
		if (abs(abs(ans[i])-i)%4==2)
			tmp[abs(ans[i])]=-ans[i];
		else tmp[abs(ans[i])]=ans[i];
	For(i,1,n) if (!(i&1)) ans[i]=tmp[i];
}
int a[N],b[N],c[N];
int s1,s2,mp[N*3];
int main(){
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&a[i]);
	For(i,1,n) scanf("%d",&b[i]);
	For(i,1,n) scanf("%d",&c[i]);
	For(i,1,n){
		if (mp[a[i]]||mp[b[i]]||mp[c[i]]) GG();
		if (a[i]%3==1&&b[i]%3==2&&c[i]%3==0){
			if (a[i]+1!=b[i]||b[i]+1!=c[i]) GG();
			if ((i&1)!=((c[i]/3)&1)) GG();
			else ans[i]=c[i]/3;
		}
		else if (a[i]%3==0&&b[i]%3==2&&c[i]%3==1){
			if (c[i]+1!=b[i]||b[i]+1!=a[i]) GG();
			if ((i&1)!=((a[i]/3)&1)) GG();
			else ans[i]=-(a[i]/3); 
		}
		else GG();
	}
	work1(); work2();
	For(i,1,n)
		if (i&1) s1^=ans[i]<0;
		else s2^=ans[i]<0;
	puts(!s1&&!s2?"Yes":"No");
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
long long n, m;

int main() {
    cin >> n >> m;
    vector<bool> ac(100010, false);
    vector<int> wa(100010, 0);
    long long acnt = 0;
    long long wcnt = 0;
    for(int i = 0; i < m; ++i) {
        long long p;
        string s;
        cin >> p >> s;
        p--;
        if(!ac.at(p)) {
            if(s == "AC") {
                acnt++;
                ac.at(p) = true;
            }else {
                wa.at(p)++;
            }
        }
    }

    for(int i = 0; i < n; ++i) {
        if(ac.at(i)) wcnt += wa.at(i);
    }

    cout << acnt << " " << wcnt << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include "atcoder/all"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////
using mint = atcoder::modint998244353;
void solve(){
    ll n,m;
    cin >> n >> m;
    vector<mint> a(n,0),b(m,0);
    rp(i,n){
        int aa;
        cin >> aa;
        a[i] += aa;
    }
    rp(i,m) {
        int bb;
        cin >> bb;
        b[i] += bb;
    }
    vector<mint> c = atcoder::convolution(a,b);
    for(auto& ci:c){
        princ(ci.val());
    }
    cout << endl;
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 19068
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
   int n;
   cin>>n;
   double h[n];
   for(int i = 0;i<n;i++) cin>>h[i];
   sort(h, h+n); 
   double sin = (h[0]+h[1])/2;
   double g;
   for(int i =2;i<n;i++){
     sin = (sin+h[i])/2;
   }
   cout<<sin;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int ans=1,n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        ans=min(ans*2,ans+k);
    }
    cout<<ans<<endl;
    return 0;
}

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

int cnt=0,K;
string s;

void dfs(string subs){
  if(cnt==K){
    cout << subs << endl;
  }
  else if(cnt<K){
    for(char c='a';c<='z';++c){
      if(s.find(subs+c)>=0 && s.find(subs+c)<s.size()){
        cnt++;
        dfs(subs+c);
      }
    }
  }
}

int main(){
  cin>>s>>K;
  dfs("");
}

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

using namespace std;
int main()
{
  int N,A[100002],i,j,res=0,bsum[100002];
  scanf("%d",&N);
  for(i=1;i<=N;i++)
    scanf("%d",&A[i]);
  A[0] = 0;
  bsum[0] = 0;
  for(i=1;i<=N;i++)
    bsum[i] = bsum[i-1] + abs(A[i]-A[i-1]);
  bsum[N+1] = bsum[N] + abs(A[N]);
  for(i=1;i<=N;i++)
    printf("%d\n", (bsum[N+1] - bsum[i+1]) + bsum[i-1] +abs(A[i+1]-A[i-1]));
  return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];
    for(int i = 0; i < n; ++i)  cin >> b[i];
    for(int i = 0; i < n; ++i)  cin >> c[i];
    sort(a.begin(), a.end());
    sort(c.begin(), c.end());
    ll ans = 0;
    for(int i = 0; i < n; ++i){
        int na = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        int nc = c.end() - upper_bound(c.begin(), c.end(), b[i]);
        ans += (ll)na * nc;
    }
    cout << ans << endl;
}

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

int main() {
    while (true) {
        int N; cin >> N;
        
        if (N==0) {
            break;
        }
        
        string S; cin >> S;
        int ans[N];
        int ba = 0;
        
        for (int i=0; i<N; i++) {
            ans[i] = 0;
        }
        
        for (int i=0; i<100; i++) {
            if (S[i]=='M') {
                ans[i%N]++;
            }
            else if (S[i]=='S') {
                ba += ans[i%N]+1;
                ans[i%N] = 0;
            }
            else {
                ans[i%N] += ba+1;
                ba = 0;
            }
        }
        
        sort(ans, ans+N);
        
        for (int i=0; i<N; i++) {
            cout << ans[i] << " ";
        }
        
        cout << ba << endl;
    }
}


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

struct shop{
    int idx;
    string s;
    int p;

    shop(int inputed_index, string inputed_s, int inputed_p){
        idx = inputed_index;
        s = inputed_s;
        p = inputed_p;
    }

    bool operator<(const shop &cmp)const{
        return (s==cmp.s) ? (p>cmp.p) : (s<cmp.s);
    }
};

int main() {
	int n;
    vector<shop> shops;
    cin >> n;
    for(int i=0; i<n; i++){
        string str;
        int point;
        cin >> str >> point;
        shops.push_back(shop(i+1, str, point));
    }
    sort(shops.begin(),shops.end());
  
    for(int i=0; i<n; i++){
      cout << shops[i].idx << endl;
    }
  
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**5)
N,M,K = list(map(int,input().split(' ')))

friend_list = [0]*(N+1)
bad_list = [0]*(N+1)
group = {}

parent = [i for i in range(N+1)]
rank = [0]*(N+1)

def union(x,y):
    x = find(x)
    y = find(y)
    if x==y:
        return
    if rank[x]<rank[y]:
        parent[x]=y
    else:
        parent[y]=x
        if rank[x]==rank[y]:
            rank[x]+=1

def find(x):
    if parent[x] == x:
        return x
    else:
        parent[x]= find(parent[x])
        return parent[x]





for i in range(M):
    A,B = list(map(int,input().split(' ')))
    friend_list[A]+=1
    friend_list[B]+=1
    
    union(A,B)

for i in range(1,N+1):
    oya = find(i)
    if oya in group:
        group[oya] = group[oya]+1
    else:
        group[oya]=1

for i in range(K):
    A,B = list(map(int,input().split(' ')))
    if find(A)==find(B):
        bad_list[A]+=1
        bad_list[B]+=1


kouho = [0]*N

for i in range(1,N+1):
    oya = find(i)
    abc = group[oya]-friend_list[i]-bad_list[i]-1
    kouho[i-1] = abc

for k in kouho:
    print(k,end=" ")
print()

Measured memory_bytes: 21416
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

S = raw_input()
T = raw_input()
ms = {}
mt = {}
for i in range(len(S)):
    if S[i] in ms and ms[S[i]] != T[i]:
        print "No"
        exit()
    else:
        ms[S[i]] = T[i]
    if T[i] in mt and mt[T[i]] != S[i]:
        print "No"
        exit()
    else:
        mt[T[i]] = S[i]

print "Yes"

Measured memory_bytes: 9560
<?php
$N = trim(fgets(STDIN));
$I = explode(' ', trim(fgets(STDIN)));

$r = null;

$min = min($I);
$max = max($I) + 1;

for (; $min < $max; ++$min) {

    $c = 0;

    for ($i = 0; $i < $N; ++$i) {
        $c += pow($I[$i] - $min, 2);
    }

    if ($r == null || $r > $c) $r = $c;
}

echo $r;


Measured memory_bytes: 4604