akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;

#ifndef LOCAL
#pragma GCC optimize ("O2")
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

ll pwr(ll a,ll b, ll mod){
    a %= mod;
    int ans = 1;
    while(b){
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

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

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

const int N = 1e5 + 5;
int x[N], v[N], post[N];
void solve(){
	int n, c;
	cin >> n >> c;
	fr(i, 1, n){
		cin >> x[i] >> v[i];
	}
	int ans = 0;
	int z = 0, val = 0;
	for(int i = n; i >= 1; i--){
		z += v[i];
		post[i] = z - (c - x[i]);
		post[i] = max(post[i], post[i + 1]);
	}
	fr(i, 1, n){
		val += v[i];
		ans = max(ans, val - x[i]);
		ans = max(ans, val - 2 * x[i] + post[i + 1]);
	}
	fr(i, 1, n){
		x[i] = c - x[i];
	}
	reverse(x + 1, x + n + 1);
	reverse(v + 1, v + n + 1);
	val = 0;
	z = 0;
	for(int i = n; i >= 1; i--){
		z += v[i];
		post[i] = z - (c - x[i]);
		post[i] = max(post[i], post[i + 1]);
	}
	fr(i, 1, n){
		val += v[i];
		ans = max(ans, val - x[i]);
		ans = max(ans, val - 2 * x[i] + post[i + 1]);
	}
	cout << ans;
}
signed main(){
    IO;
    #ifdef LOCAL
        freopen("inp.txt","r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    cout << setprecision(10) << fixed;
    int t = 1;
    // cin >> t;
    fr(tt, 1, t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 2560
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  vector<ll>a(m);
  rep(i,0,m)cin>>a[i];
  rep(i,0,m)res+=a[i];
  ans(res>n,-1,n-res);
  return 0;
}

Measured memory_bytes: 3700
import sys
import random

def rd():
        return sys.stdin.readline().rstrip()

def rdi():
        return [ int(x) for x in rd().split() ]


def calc(T, t):
        acc = 0
        start = 0
        end = 0
        for i in range(len(t)):
                s = t[i]
                if s >= end:
                        acc += end - start
                        start = s
                end = s + T
        acc += end - start
        print acc

N, T = rdi()
t = rdi()
calc(T, t)

Measured memory_bytes: 20332
#include <algorithm>

template <typename ForwardIterator>
void parted_rotate(ForwardIterator first1, ForwardIterator last1,
                   ForwardIterator first2, ForwardIterator last2) {
  if (first1 == last1 || first2 == last2) return;
  auto next = first2;
  while (first1 != next) {
    std::iter_swap(first1++, next++);
    if (first1 == last1) first1 = first2;
    if (next == last2) {
      next = first2;
    } else if (first1 == first2) {
      first2 = next;
    }
  }
}

template <typename BidirectionalIterator>
bool next_combination_imp(BidirectionalIterator first1,
                          BidirectionalIterator last1,
                          BidirectionalIterator first2,
                          BidirectionalIterator last2) {
  if (first1 == last1 || first2 == last2) return false;
  auto target = last1;
  --target;
  auto last_elem = last2;
  --last_elem;
  while (target != first1 && !(*target < *last_elem)) --target;
  if (target == first1 && !(*target < *last_elem)) {
    parted_rotate(first1, last1, first2, last2);
    return false;
  }
  auto next = first2;
  while (!(*target < *next)) ++next;
  std::iter_swap(target++, next++);
  parted_rotate(target, last1, next, last2);
  return true;
}

template <typename BidirectionalIterator>
inline bool next_combination(BidirectionalIterator first,
                             BidirectionalIterator mid,
                             BidirectionalIterator last) {
  return next_combination_imp(first, mid, mid, last);
}

#include <iostream>
#include <iterator>
#include <vector>

using namespace std;

void solve(int N, int M, int Q, vector<int> a, vector<int> b, vector<int> c,
           vector<int> d) {
  vector<int> A;
  for (auto i = 0; i != M; ++i) {
    fill_n(back_inserter(A), N, i);
  }

  int ma{0};
  do {
    int score = 0;
    for (auto q = 0; q != Q; ++q) {
      if (A[b[q] - 1] - A[a[q] - 1] == c[q]) score += d[q];
    }
    ma = max(ma, score);
  } while (next_combination(A.begin(), A.begin() + N, A.end()));

  cout << ma << endl;
}

int main() {
  int N;
  cin >> N;
  int M;
  cin >> M;
  int Q;
  cin >> Q;
  vector<int> a(Q);
  vector<int> b(Q);
  vector<int> c(Q);
  vector<int> d(Q);
  for (int i = 0; i < Q; i++) {
    cin >> a[i];
    cin >> b[i];
    cin >> c[i];
    cin >> d[i];
  }
  solve(N, M, Q, move(a), move(b), move(c), move(d));
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define inchar			getchar
#define outchar(x)		putchar(x)
#define ll long long 
#define int long long //
#define all(v) v.begin(), v.end()
#define SP outchar(' ')
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
#define LN outchar('\n')
using namespace std;

template<typename T> void inpos(T &x){x=0;register T c=inchar();while(((c<48)||(c>57))&&(c!='-'))c=inchar();bool neg=0; if(c=='-')neg=1;for(;c<48||c>57;c=inchar());for(;c>47&&c<58;c=inchar())x=(x<<3)+(x<<1)+(c&15);if(neg)x=-x;}
template<typename T> void outpos(T n){if(n<0){outchar('-');n*=-1;}char snum[65];int i=0;do{snum[i++]=n%10+'0';n/=10;}while(n);i=i-1;while(i>=0)outchar(snum[i--]);}
inline void instr(char *str){register char c=0;register int i=0;while(c<33)c=inchar();while(c!='\n'&&c!=' '&&c!=EOF){str[i]=c;c=inchar();++i;}str[i]='\0';}


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

	int n;cin>> n;
	vector < vector <int> > dp(n+1, vector <int> (3) );
	dp[0][0] = 0;dp[0][1] = 0;dp[0][2] = 0;
	int a, b, c;
	for (int i = 0; i<n;i++) {
		cin >> a >> b >> c;
		dp[i+1][0] = max(dp[i][1] , dp[i][2]) + a;
		dp[i+1][1] = max(dp[i][0] , dp[i][2])+ b;
		dp[i+1][2] = max(dp[i][0], dp[i][1]) + c; 
	}
	
	cout << *max_element(all(dp[n])) <<endl; 
	
}

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

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  if ((a - b) % 2 == 0) cout << (b - a) / 2 << endl;
  else {
    cout << min((a + b - 1) / 2, n - b + 1 + (b - a - 1) / 2) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if((a==1 && b==2) || (a==2 && b==1))
    cout<<"3";
  else if((a==2 && b==3) || (a==3 && b==2))
    cout<<"1";
  else 
    cout<<"2";
  
  return 0;
}

Measured memory_bytes: 256
lst = []
for i in range(0, 5):
	lst.append(int(input()))
K = int(input())
lst.sort(reverse = True)
ans = 'Yay!'
for i in range(0, 5):
	for j in range(i+1, 5):
		if lst[i] - lst[j] > K:
			ans = ':('
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    char a,b; cin >> a >> b;
    string s = "", t = "";
    rep(i,b-'0') {
        s += a;
    }
    rep(i,a-'0') {
        t += b;
    }
    cout << min(s,t) << endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::io::{stdin, Read, StdinLock};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::{HashSet, HashMap, BinaryHeap};
#[allow(unused_imports)]
use std::vec::Vec;

#[allow(dead_code)]
const INF: i32 = 1000_000_000;
#[allow(dead_code)]
const INFLL: i64 = 1000_000_000_000_000_000;
#[allow(dead_code)]
const EPS: f64 = 1.0e-10;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    #[allow(dead_code)]
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    #[allow(dead_code)]
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    #[allow(dead_code)]
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let s: String = sc.read();
    let mut s: Vec<char> = s.chars().collect();
    loop {
        s.pop(); s.pop();
        let mid = s.len() / 2;
        let mut ok = true;
        for i in 0..mid {
            ok &= s[i] == s[i + mid];
        }
        if ok {
            println!("{}", s.len());
            break;
        }
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define _boost ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define fi first
#define se second
#define clz __builtin_clz
#define clzll __builtin_clzll
#define bp __builtin_popcount
#define _unique(x) sort((x).begin(),(x).end()),(x).erase(unique((x).begin(), (x).end()),(x.end()))
#define all(x) (x).begin(),(x).end()
#define _rand(i,j) uniform_int_distribution<int>(i, j)(rng___)
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;
template < typename _T, typename _T2> string to_string(pair<_T,_T2> x) {return "<"+to_string(x.fi)+", "+to_string(x.se)+">";}
template < typename _T> string to_string(vector<_T> vec) {string s="[ "; for(auto el:vec)s+=to_string(el)+", "; s[s.size()-1]=']';s[s.size()-2]=' '; return s;}
string to_string(string s) {return s;}
template < typename _T> string to_string(set<_T> vec) {string s="{ "; for(auto el:vec)s+=to_string(el)+", "; s[s.size()-1]='}';s[s.size()-2]=' '; return s;}
template < typename _T, typename _T2> string to_string(map<_T,_T2> vec) {string s="{ "; for(auto el:vec)s+="mp["+to_string(el.fi)+"]= "+to_string(el.se)+", "; s[s.size()-1]='}';s[s.size()-2]=' '; return s;}
template < typename _T > inline void _DBG(const char *s, _T x){cerr << s << " = " << to_string(x) << "\n";}
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a){while(*s != ',') cerr << *s++;cerr << " = " << to_string(x) << "\n";_DBG(s + 1, a...);}
#ifdef LOCAL
#define _print(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define _print(...) ;//cout<<2;//(__VA_ARGS__)
#endif
mt19937 rng___(chrono::steady_clock::now().time_since_epoch().count());


const LL MOD = 1e9+7;//998244353;
const LL LLINF = 1e18+7;
const int N=1e5+8;


int main()
{
    _boost;
    int n;
    cin>>n;
    vector<int> vec(n);
    for(int i=0;i<n;i++)cin>>vec[i];
    vector<vector<LL>> dp(n,vector<LL>(n,0));
    for(int i=0;i<n;i++)dp[i][i]=vec[i];
    for(int d=1;d<n;d++)
    {
        for(int i=0;i<n;i++)
        {
            if(i+d>=n) continue;
            dp[i][i+d]=max(-dp[i][i+d-1]+vec[i+d],-dp[i+1][i+d]+vec[i]);
        }
    }
    cout<<dp[0][n-1];
}




Measured memory_bytes: 70784
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }




int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll A, B, K;
    cin >> A >> B >> K;
    ll ans1 = max(0LL, A - K);
    ll ans2 = B;
    if(K > A)
        ans2 = max(0LL, B - (K - A));
    cout << ans1 << " " << ans2 << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    string s;cin>>s;
    while(s.size()>=2){
        s.erase(s.size()-2,2);
        string a=s.substr(0,s.size()/2),b=s.substr(s.size()/2,s.size()/2);
        if(a==b){
            cout<<s.size()<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	int n,p; cin >> n >> p;
	vector<int> a(n);
	int odd=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(a[i]%2==1)odd++;
	}
	ll ans;
	if(p==1&&odd==0){
		cout << 0 << endl;
		return 0;
	}
	else if(p==0&&odd==0){
		ans=pow(2,n);
	}
	else{
		ans=pow(2,n-1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int n; cin >> n;
    vector<pair<int, int>> v;
    for(int i = 0; i < n; i++)
    {
        int x, y; cin >> x >> y;
        v.push_back(make_pair(x, y));
    }
    sort(v.begin(), v.end());
    double ans = 0.0;
    int cnt = 0;
    do
    {
        for(int i = 1; i < v.size(); i++)
        {
            ans += sqrt(pow(v[i].first - v[i - 1].first, 2) + pow(v[i].second - v[i - 1].second, 2));
        }
        cnt++;
    } while (next_permutation(v.begin(), v.end()));
    cout << fixed << setprecision(10);
    cout << ans / (double)cnt << endl;
    
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    x,y=map(int,input().split())
    if x==y or x%y==0:
        print(-1)
        sys.exit()
    else:
        for i in range(2,10*6):
            if x*i % y!=0:
                print(x*i)
                sys.exit()

if __name__=='__main__':
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define endl endl;cf
#define be begin()
#define sz size()
#define en end()
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0)
#define forn(i,a,b) for(ll i=1;i<=b;++i)
#define forr(i,a,b) for(ll i=0;i<b;++i)
#define rngx mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define cf cout.flush()
int main()
{
    ios;
    ll a , b ;
    cin >>a >> b ;
    if(b % a ==0){
        cout << a+b <<endl;
    }
    else cout << b-a <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define moder (1000000007)
#define pie acos(-1)
#define P std::pair<int,int>
#define prique priority_queue
#define ggr getchar();getchar();return 0;
using namespace std;
int a,b,c,d,e,f,g,h;
signed main(){
    while(cin>>a>>b>>c>>d>>e>>f>>g>>h){
        int x=0;
        if(a==e)x++;
        if(b==f)x++;
        if(c==g)x++;
        if(d==h)x++;
        cout<<x<<" ";
        int y=0;
        if(a==f||a==g||a==h)y++;
        if(b==e||b==g||b==h)y++;
        if(c==e||c==f||c==h)y++;
        if(d==e||d==f||d==g)y++;
        cout<<y<<endl;
    }
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define ull unsigned long long
#define ll long long

void add(int &a,int b){
    a+=b;
    if(a>=mod)
        a-=mod;
}
int nCr(long long m, long long n){

    //6 * 5 * 4 *../ 1*2*3*...
    int ans = 1;
    for (long long i = 1; i <= n; i++){
        ans = ans * (m - i + 1) / i;
 
    }
    return ans;
}

int32_t main()
{
    int n;cin>>n;
    vi a(n);
    int xo=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        xo^=a[i];
    }
    for(int i=0;i<n;i++){
        a[i]=(a[i]^xo);
        cout<<a[i]<<" ";
    }cout<<endl;
    return 0;
}


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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n;cin>>n&&n;){
		vi a(n),b(n);
		rep(i,n) cin>>a[i];
		rep(i,n) cin>>b[i];

		int res=0;
		rep(k,29){
			vi d=b;
			rep(i,n)
				d[i]&=(1<<k+1)-1;
			sort(all(d));
			int cnt=0;
			rep(i,n){
				int c=a[i]&(1<<k+1)-1;
				if(c<1<<k){
					int l=lower_bound(all(d),(1<<k)-c)-begin(d);
					int r=lower_bound(all(d),(2<<k)-c)-begin(d);
					cnt+=r-l;
				}
				else{
					int l=lower_bound(all(d),(2<<k)-c)-begin(d);
					int r=lower_bound(all(d),(3<<k)-c)-begin(d);
					cnt+=n-(r-l);
				}
			}
			res|=(cnt&1)<<k;
		}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 2672
/**
 * @author      : cromarmot (yexiaorain@gmail.com)
 * @license     : GPL
 * @created     : 星期六 9月 28, 2019 20:16:00 CST
 */

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

typedef long long ll;
#define ten5 100000+10
#define MOD 1000000007
#define rep(i,a,n) for (int i=a;i<n;i++)
#define iif(c,t,f) ((c)?(t):(f))
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
const double pi = acos(-1.0);

int n;

// m keys

int m;

int price[1010];
int keyv[1010];

int dp[1010][10000]; // idx state

int main(){
  cin>>n>>m;
  rep(i,0,m){
    scanf("%d",price+i);
    int b;
    scanf("%d",&b);
    rep(j,0,b){
      int k;
      scanf("%d",&k);
      keyv[i] |= (1<<(k-1));
    }
  }
  rep(i,0,m){
    rep(state,0,(1<<n)){
      dp[i][state] = -1;
    }
  }
  dp[0][0] = 0;
  dp[0][keyv[0]] = price[0];
  rep(i,1,m){
    rep(state,0,(1<<n)){
      dp[i][state] = dp[i-1][state];
    }
    rep(state,0,(1<<n)){
      if(dp[i-1][state] == -1)continue;
      if(dp[i][state | keyv[i]] == -1 ||
          (dp[i][state | keyv[i]] > dp[i-1][state] + price[i]) ){
        dp[i][state | keyv[i]] = dp[i-1][state] + price[i];
      }
    }
  }
  cout<<dp[m-1][(1<<n)-1]<<endl;
  return 0;
}

/*
 *
 * hash prime
   61,83,113,151,211,281,379,509683,911
   1217,1627,2179,2909,3881,6907,9209
   12281,16381,21841,29123,38833,51787,69061,92083
   122777,163729,218357,291143,388211,517619,690163,999983
   1226959,1635947,2181271,2908361,3877817,5170427,6893911,9191891
   12255871,16341163,21788233,29050993,38734667,51646229,68861641,91815541
   122420729,163227661,217636919,290182597,386910137,515880193,687840301,917120411
   1000000007,1000000009
 * */



Measured memory_bytes: 38272
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;
#define pi 3.141592653589793283462
int main(){
	int n;
	int i=1;
	while (1)
	{
		cin>>n;
		if(n==0)
			break;
		cout<<"Case "<<i<<": "<<n<<endl;
		i++;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=(a),ed=(b);i<=ed;++i)
typedef long long ll;
inline int read(){
    register int x=0,f=1;register char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch)){x=x*10+(ch^'0');ch=getchar();}
    return f?x:-x; 
}

const int N=1e6+10;
int n,ans;char s[N],t[N];

int main(){
    //freopen("in.in","r",stdin);
    n=read();scanf("%s%s",s+1,t+1);
    int flg=1;for(int i=1;i<=n&&flg;++i)flg=(s[i]==t[i]);
    if(flg){puts("0");return 0;}
    queue<int> q;
    int down=n,up=n;
    while(down){
	while(down>1&&t[down]==t[down-1])--down;
	while(up&&(up>down||s[up]^t[down]))--up;
	if(!up){puts("-1");return 0;}
	while(!q.empty()&&q.front()-(int)q.size()+1>down)q.pop();
	if(up^down)q.push(up);
	ans=max(ans,(int)q.size()+1);
	--down;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 6272
struct SegmentTree {
  offset : usize,
  data : Vec<usize>,
}

impl SegmentTree {
  fn new(n : usize) -> SegmentTree {
    let offset = n.next_power_of_two();
    let data = vec![0; offset * 2];
    SegmentTree{offset, data}
  }
  
  fn update(&mut self, i : usize, x : usize) {
    let offset = self.offset;
    let data = &mut self.data;

    data[offset + i] = x;
    let mut j = (offset + i) / 2;
    while j > 0 {
      data[j] = data[2 * j] + data[2 * j + 1];
      j /= 2;
    }
  }

  fn range_sum(&self, a : usize, b: usize) -> usize {
    self.range_sum_recursive(a,b,1,0,self.offset).unwrap_or(0)
  }

  fn range_sum_recursive(&self, a:usize, b:usize, k:usize, l:usize, r:usize) -> Option<usize> {
    if r <= a || b <= l {
      return None;
    }
    
    if a <= l && r <= b {
      return Some(self.data[k]);
    }
    let mid = (l + r) / 2;
    
    Some( self.range_sum_recursive(a,b,2 * k, l, mid).unwrap_or(0) 
      + self.range_sum_recursive(a,b,2 * k + 1, mid, r).unwrap_or(0))
  }
}

#[allow(non_snake_case, unused_variables)]
fn main(){  
  use std::io::Read;
  use std::collections::*;
  
  let mut buf = String::new();
  
  std::io::stdin().read_to_string(&mut buf).unwrap();
  let uvec : Vec<usize> = buf.split_whitespace().map(|s| s.parse().unwrap()).collect();

  let N = uvec[0];
  let M = uvec[1];
  let C = &uvec[2 .. N + 2].to_vec();
  let Q :Vec<(usize, usize)>= uvec[N + 2 .. ].chunks(2).map(|ch| (ch[0], ch[1]) ).collect();
  let mut st = SegmentTree::new(N + 1);
  let mut A = vec![0_usize; M];
  
  
  let mut Qi:VecDeque<usize> = {
    let mut i : Vec<usize> = (0 .. M).into_iter().collect();
    i.sort_by_key(|i|{ Q[*i].1 });
    i.into_iter().collect()
  };
  let mut Ci = vec![0_usize; N + 1];

  for i in 1 ..= N {
    let c = C[i - 1];
    let k = Ci[c];
    
    Ci[c] = i;    
    st.update(k, 0);
    st.update(i, 1);
    
    loop {
      if let Some(&j) = Qi.front() {
        let (l,r) = Q[j];
        if r > i {
          break;
        }
      } else {
        break;
      }
      
      if let Some(j) = Qi.pop_front() {
        let (l,r) = Q[j];
        A[j] = st.range_sum(l, r + 1);
      }
    }
  }
  for ans in A {
    println!("{}", ans);
  }
}




Measured memory_bytes: 56724
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2015

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cassert>
using namespace std;

int table[2][1510][1510];
int habas[2][1500010];

int main() {
  int N[2];
  while (scanf("%d%d", &N[0], &N[1]) != EOF && N[0]) {
    fill(&table[0][0][0], &table[0][0][0]+2*1510*1510, 0);
    fill(&habas[0][0], &habas[0][0]+2*1500010, 0);
    for (int k=0; k<2; k++) {
      for (int i=1; i<=N[k]; i++) {
	int hw;
	scanf("%d", &hw);
	table[k][i][i] = hw;
	habas[k][hw]++;
      }
      for (int i=1; i<=N[k]; i++) {
	for (int j=1; j<i; j++) {
	  table[k][j][i] = table[k][j][i-1] + table[k][i][i];
	  habas[k][table[k][j][i]]++;
	}
      }
    }
    int ans = 0;
    for (int i=0; i<1500010; i++) {
      ans += habas[0][i] * habas[1][i];
    }
    printf("%d\n", ans);
  }
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int dp[200];
signed main(void) {
  REP(i, 200) dp[i] = INF;
  REP(i, 50) REP(j, 50) REP(k, 50) {
    int tmp = i * 2 + j * 3 + k * 5,
        ret = i / 5 * 5 * 304 + (i % 5) * 380 + j / 4 * 4 * 550 * 0.85 +
              (j % 4) * 550 + k / 3 * 3 * 850 * 0.88 + (k % 3) * 850;
    if(tmp <= 50) {
      dp[tmp] = min(dp[tmp], ret);
    }
  }

  int n;
  while(1) {
    cin >> n;
    if(n == 0) break;
    cout << dp[n/100] << endl;
  }

  return 0;
}

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

class Main{

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int num = Integer.parseInt(br.readLine());
		int[] x = new int[num];
		int[] y = new int[num];
		String[] x_token = br.readLine().split(" ");
		String[] y_token = br.readLine().split(" ");

		for(int i = 0; i < num; i++){
			x[i] = Integer.parseInt(x_token[i]);
			y[i] = Integer.parseInt(y_token[i]);
		}

		double[] ans = new double[4];

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

			double sum = 0;
			double max = 0;

			for(int j = 0; j < num; j++){
				sum = sum + Math.pow(Math.abs(x[j] - y[j]), i + 1);
				max = Math.max(max, Math.abs(x[j] - y[j]));
			}

			switch(i){
				case 0:
					ans[i] = sum;
					break;
				case 1:
					ans[i] = Math.sqrt(sum);
					break;
				case 2:
					ans[i] = Math.cbrt(sum);
					break;
			}

			ans[3] = max;

		}

		for(int i = 0; i < ans.length; i++){
			System.out.printf("%.8f\n", ans[i]);
		}

	}
}

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

int main()
{
char h = 0;
cin >> h;
switch (h)
{
  case 'A' : cout << "T";
    break;
  case 'T' : cout << "A";
    break;
  case 'G' : cout << "C";
    break;
  case 'C' : cout << "G";
    break;
  default:
    break;
}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int dp[2][2020];
int main(){
	string s;
	ll ans=0;
	cin>>s;
	for(int i=0;i<s.length();i++){
		for(int j=0;j<2019;j++)dp[(i+1)%2][j]=0;
		int k=s[i]-'0';
		dp[(i+1)%2][k]=1;
		for(int j=0;j<2019;j++)dp[(i+1)%2][(j*10+k)%2019]+=dp[i%2][j];
		ans+=dp[i%2][0];
	}
	ans+=dp[s.length()%2][0];//ans累加
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3760
'''
https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_e
'''
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    mod = 10**9 + 7

    n = int(input())
    a = list(map(int, input().split()))
    cnt = [3] + [0]*n
    res = 1
    for i in a:
        if cnt[i] == 3:
            res *= 3
        if cnt[i] == 2:
            res *= 2
        if cnt[i] == 0:
            res *= 0
        cnt[i] -= 1
        cnt[i+1] += 1
        res %= mod
    print(res)
        
if __name__ == '__main__':
    main()


Measured memory_bytes: 14140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

// #define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << " "
#define dumpL(x) cout << #x << " : " << x << '\n'
#define LINE cout << "line : " << __LINE__ << " "
#define LINEL cout << "line : " << __LINE__ << '\n'
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << " "
#define dumpVL(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) 
#define dumpL(x) 
#define LINE 
#define LINEL 
#define dumpV(v) 
#define dumpVL(v) 
#define STOP assert(false)
#endif
#define mp make_pair
 
namespace std {
template<class S, class T>
ostream &operator <<(ostream& out, const pair<S, T>& a) {
    out << '(' << a.fi << ", " << a.se << ')';
    return out;
}
}

int main(){
    ll a, b, c, x, y;
    cin >> a >> b >> c >>x >> y;
    ll ans = a * x + b * y;
    dumpL(ans);
    ll z = max(x, y) * 2;
    rep(i, z + 1) {
        ll tmp = 0;
        tmp += max(0LL, x - i/2) * a;
        tmp += max(0LL, y - i/2) * b;
        tmp += i * c;
        dump(i);dumpL(ans);
        chmin(ans, tmp);
    } 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string[] str = Console.ReadLine().Split();
		long[]A = new long[N];
		for(var i=0;i<N;i++){
			A[i] = long.Parse(str[i]);
		}
		long[,]D = new long[N,16];
		for(var i=0;i<16;i++){
			D[N-1,i] = i;
		}
		for(var i=N-2;i>=0;i--){
			long x1 = A[i];
			long x2 = A[i+1];
			if(x1<x2){
				long ct = 0;
				while(x1<x2){
					x1 *= 4;
					ct++;
				}
				for(var j=0;j<=ct-1;j++){
					D[i,j] = D[i+1,0]+j;
				}
              	if(x1>x2){
                	for(var j=ct;j<16;j++){
                      D[i,j] = D[i+1,j-ct+1]+j;
                    }
                } else {
                  	D[i,ct] = D[i+1,0]+ct;
                    for(var j=ct+1;j<16;j++){
                      D[i,j] = D[i+1,j-ct+1]+j;
                    }
                }
			} else {
				long ct = 0;
				while(x1>x2){
					x2 *= 4;
					ct++;
				}
				for(var j=0;j<16;j++){
					if(j+ct<16){
						D[i,j] = D[i+1,j+ct]+j;
					} else {
						D[i,j] = D[i+1,15]+j+(j+ct-15)*(N-i-1);
					}
				}
            }
		}
		Array.Reverse(A);
		long[,]E = new long[N,16];
		for(var ia=0;ia<16;ia++){
			E[N-1,ia] = ia;
		}
		for(var ia=N-2;ia>=0;ia--){
			long x1 = A[ia];
			long x2 = A[ia+1];
			if(x1<x2){
				long ct = 0;
				while(x1<x2){
					x1 *= 4;
					ct++;
				}
				for(var j=0;j<=ct-1;j++){
					E[ia,j] = E[ia+1,0]+j;
				}
              	if(x1>x2){
                	for(var j=ct;j<16;j++){
                      E[ia,j] = E[ia+1,j-ct+1]+j;
                    }
                } else {
                  	E[ia,ct] = E[ia+1,0]+ct;
                    for(var j=ct+1;j<16;j++){
                      E[ia,j] = E[ia+1,j-ct+1]+j;
                    }
                }
			} else {
				long ct = 0;
				while(x1>x2){
					x2 *= 4;
					ct++;
				}
				for(var j=0;j<16;j++){
					if(j+ct<16){
						E[ia,j] = E[ia+1,j+ct]+j;
					} else {
						E[ia,j] = E[ia+1,15]+j+(j+ct-15)*(N-ia-1);
					}
                }
			}
		}
		long min = D[0,0]*2;
		for(var ib=1;ib<N-1;ib++){
			long ans = D[ib,0]*2 + E[N-ib-1,0]*2 + ib;
			min = Math.Min(ans,min);
		}
		min=Math.Min(min,E[0,0]*2+N-1);
		Console.WriteLine(min);
      	for(var i=0;i<N;i++){
          for(var j=0;j<16;j++){
            //Console.Write(D[i,j]+" ");
          }
          //Console.WriteLine();
        }
		for(var i=0;i<N;i++){
          for(var j=0;j<16;j++){
           //Console.Write(E[i,j]+" ");
          }
          //Console.WriteLine();
        }
	}
}

Measured memory_bytes: 79912
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>
#include <queue>

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> h(n);
	rep(i, 0, n)cin >> h[i];
	sort(h.begin(), h.end());
	ll ans = INF;
	rep(i, 0, n-k+1) {
		ans = min(ans, h[i + k - 1] - h[i]);
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    string s1,s2;
    cin >> s1 >> s2;
    int n = s1.size();
    for(int i = 0;i < n;i++)
    {
        if(s1 == s2)
        {
            cout << "Yes";
            return 0;
        }
        string s3 = s1.substr(0,n - 1);
        s1 = s1[n - 1] + s3;
    }
    cout << "No";
}


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

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

real = 1000
unreal = 0

for i in range(n-1):

    if a[i] < a[i+1]:
        get_unreal, real = divmod(real, a[i])
        unreal += get_unreal

    elif a[i] > a[i+1]:
        real += (unreal * a[i])
        unreal = 0

    else:
        continue

real += unreal * a[n-1]
print(real)

Measured memory_bytes: 61748
import sys
N = list(map(int, input()))
op = ['+','-']
for i in op:
    tmp = 0 
    ans = []
    for j in op:
        for k in op:
            if i == '+':
                tmp = N[0] + N[1]
                ans.append('+')
            else:
                tmp = N[0] - N[1]
                ans.append('-')

            if j == '+':
                tmp += N[2]
                ans.append('+')
            else:
                tmp -= N[2]    
                ans.append('-')

            if k == '+':
                tmp += N[3]
                ans.append('+')
            else:
                tmp -= N[3]
                ans.append('-')

            if tmp == 7:
                print(str(N[0])+ans[0]+str(N[1])+ans[1]+str(N[2])+ans[2]+str(N[3])+"=7")
                sys.exit()
            else:
                tmp = 0
                ans = []

Measured memory_bytes: 3064
# スペース区切りの整数入力
h,n = map(int, input().split())
# スペース区切りの整数をリストに入力
a = [int(x) for x in input().split()]
aa = 0
for i in a:
    aa = aa + i

if h > aa:
    print("No")
else:
    print("Yes")



Measured memory_bytes: 13964
n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())

def solve(i, m):
    if m == 0:
        return True
    if n <= i or sum(A) < m:
        return False
    x = (solve(i+1, m) or solve(i+1, m-A[i]))
    return  x
 
for m in M:
    if solve(0, m):
        print "yes"
    else:
        print "no"

Measured memory_bytes: 6444
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn f(nv: Vec<u32>, k: u32) -> u32 {
    let mut ret;
    let l = nv.len() as u32;

    // println!("nv : {:?}, k : {}", nv, k);

    if k == 1 {
        if l < 1 {
            ret = 0;
        } else {
            ret = nv[0] + (nv.len() as u32 - 1) * 9;
        }
    } else if k == 2 {
        if l < 2 {
            ret = 0;
        } else {
            let mut mv = vec![];
            let mut b = false;
            for i in 1..l as usize {
                if !b {
                    if nv[i] != 0 {
                        b = true;
                        mv.push(nv[i]);
                    }
                } else {
                    mv.push(nv[i]);
                }
            }
            ret = f(mv, k - 1);
            ret += (nv[0] - 1) * 9 * (l as u32 - 1);
            ret += 9 * 9 * (l - 1) * (l - 2) / 2;
        }
    } else {
        if l < 3 {
            ret = 0;
        } else {
            let mut mv = vec![];
            let mut b = false;
            for i in 1..l as usize {
                if !b {
                    if nv[i] != 0 {
                        b = true;
                        mv.push(nv[i]);
                    }
                } else {
                    mv.push(nv[i]);
                }
            }
            ret = f(mv, k - 1);
            ret += (nv[0] - 1) * 9 * 9 * (l - 1) * (l - 2) / 2;
            ret += 9 * 9 * 9 * (l - 1) * (l - 2) * (l - 3) / 6;
        }
    }

    ret
}

fn main() {
    let s: String = read();
    let nv: Vec<u32> = s.chars().map(|c| c as u32 - '0' as u32).collect();
    let k: u32 = read();

    println!("{}", f(nv, k));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
        cin >> n;
        char a_one[n/2];
        char b_one[n/2];
        
        bool ans = true ;
        if(n % 2 == 0)
        {       
                for(int i = 0; i< (n/2); i++)
                {
                        cin >>a_one[i];
                }
                for(int i =0; i< (n/2);i++)
                {
                        cin >> b_one[i];
                }
                for(int i = 0; i< n/2; i++)
                {
                        if(a_one[i] != b_one[i])
                        {
                                ans= false;
                        }
                }
        }
        else if(n % 2 !=0)
        {
                ans = false;
        }

        if(ans == false)
        {
                cout << "No" << endl;
        }
        else if(ans ==true)
        {
                cout << "Yes" << endl;
        }
}

Measured memory_bytes: 256
PROGRAM ATCODER

implicit none
integer :: n,k,x,y,ans,i

read(*,*) n,k,x,y    !ここが入力欄

! ここに計算式
ans = 0
do i = 1, n
	if(i <= k)then
		ans = ans + x
	else
		ans = ans + y
	end if
end do

! ここに出力結果
write(*,'(i0)') ans

END PROGRAM ATCODER

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

int main(){

  string str[] = {"Sunny",
                  "Cloudy",
                  "Rainy"};
  
  string in;
  
  cin >> in;
  
  rep(i,3){
    if(str[i] == in){
      cout << str[ (i + 1) % 3];
    }
  }
  
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+1;
vector<int> h(N);
const int INF=1e9+5;
vector<int> dp(N,INF);
int n,k;
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;++i){
        scanf("%d",&h[i]);
    }
    dp[1]=0;
    for(int i=1;i<=n;++i){
        for(int j=i+1;j<=i+k;++j){
            if(j<=n){
                dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
            }
        }
    }
    cout<<dp[n];
    // while(1);
    return 0;
}

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

int main () {
  int X;
  cin >> X;
  int i = X;
  while (true){
    int count = 0;
    for (int j = 2; j <= i; j++){
      if (i%j == 0) count ++;
    }
    if (count == 1) break;
    if (i%2 == 0) i++;
    else i += 2;
  }
  cout << i << endl;
}

Measured memory_bytes: 256
import numpy as np
import copy

a = map(int,raw_input().split())

def myfunc(A):
  A.sort(reverse=True)
  if (A[0]%2 != 0 and A[1]%2 !=0 and A[2]%2 != 0):
    print A[1]*A[2]
  else:
    print 0

myfunc(a)

Measured memory_bytes: 10420
#include "stdio.h"
#include "stdlib.h"

#define size 100

int sp;
int stack[size];

void init_stack()
{
	sp = -1;
}

void push(int x)
{
	if(sp < size - 1) stack[++sp] = x;
}

int pop()
{
	if(sp >= 0) return stack[sp--];
}

int main()
{
	int n;

	init_stack();

	while(scanf("%d", &n) != EOF){
		if(n == 0) printf("%d\n", pop());
		else push(n);
	}

	return 0;
}

Measured memory_bytes: 600