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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ll n, k;
    cin >> n >> k;
    int maxa = 200010;
    vector<int> v(n);
    REP(i, n){
        cin >> v[i];
    }
    v.push_back(0);

    vector<vector<int>> mp(maxa);
    vector<int> mp_inv(n);
    REP(i, n){
        mp[v[i]].push_back(i);
        mp_inv[i] = mp[v[i]].size() - 1;
    }

    bool two = (mp[v[n-1]].size() == 1);

    vector<vector<int>> dbl(60, vector<int>(n+1, -1));
    dbl[0][n] = 0;
    RREP(i, n){
        int p = i;
        while(true){
            int a = v[p];
            int x = mp_inv[p];
            int q = mp[a][(x + 1) % mp[a].size()];
            if(q <= p){
                p = q;
                break;
            }
            if(dbl[0][q + 1] != -1){
                dbl[0][i] = dbl[0][q + 1];
                break;
            }
            p = q + 1;
        }

        p++;
        if(dbl[0][i] == -1) dbl[0][i] = p;
    }

    REP(i, 59){
        REP(j, n+1){
            dbl[i+1][j] = dbl[i][dbl[i][j]];
        }
    }

    ll x = k - 1, pow = 0, p = 0;
    while(x > 0){
        if(x & 1){
            p = dbl[pow][p];
        }
        pow++;
        x >>= 1;
    }

    deque<int> deq;
    vector<bool> use(maxa, false);
    FOR(i, p, n){
        int a = v[i];
        if(!use[a]){
            use[a] = true;
            deq.push_back(a);
        }else{
            use[a] = false;
            while(deq.back() != a){
                use[deq.back()] = false;
                deq.pop_back();
            }
            deq.pop_back();
        }
    }

    for(auto i : deq) cout << i << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 61680
fun main() {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }

    if (a.size == 1) {
        print(1)
        return
    }

    var tmp = a[0]
    var answer = 1
    var status = 0 // 0: 初期状態 1: 増加中 2:減少中
    for (i in 1 until n) {
        if (tmp < a[i]) {
            tmp = a[i]
            if (status == 0) {
                status = 1
            }

            if (status == 2) {
                answer += 1
                status = 0
            }
        } else if (a[i] < tmp) {
            tmp = a[i]
            if (status == 0) {
                status = 2
            }
            if (status == 1) {
                answer += 1
                status = 0
            }
        }
    }

    print(answer)
}


Measured memory_bytes: 52636
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll N, A, B, C, D;
string S;

int main(){
  cin >> N >> A >> B >> C >> D;
  cin >> S;
  int n = S.size();
  for(int i = A - 1; i < C - 1; i++) {
      if(S[i] == '#' && S[i + 1] == '#') {
        cout << "No" << endl;
        return 0;
      }
  }
  for(int i = B - 1; i < D- 1; i++) {
      if(S[i] == '#' && S[i + 1] == '#') {
        cout << "No" << endl;
        return 0;
      }
  }

  if(C < D) {
    cout << "Yes" << endl;
    return 0;
  }

  // cout << S << endl;

  for(int i = B - 1; i < D; i++) {
    // cout << "i: " << i << ", S[i - 1]: " << S[i - 1] << ", S[i]: " << S[i] << ", S[i + 1]: " << S[i + 1] << endl;
    if(S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}



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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using P = pair<int,int>;
//Write From this Line

int main()
{
	ll x;
	cin >> x;
	ll now = 100;
	for(int i = 0;i < 10000;i++){
		if( now * 1.01 >= x){
			cout << i+1 << endl;
			return 0;
		}
		now *= 1.01;
	}
}


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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define REP64(i, s,  n) for(int64 i = s;i < (n);i++)
#define INF 999999999
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//---------------------------------------------------------------
//---------------------------------------------------------------

int N, K;
map<int, int> mp;
vector< pair<int, int> > pairs;

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> N >> K;
	int a;
	REP(i, 0, N) {
		cin >> a;
		mp[a]++;
	}
	
	// 見つかった数でソートする
	for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    	pairs.push_back(*itr);
	}
	sort(pairs.begin(), pairs.end(), 
		[=](pair<int, int>& a, pair<int, int>& b) {	return a.second > b.second; }
	);
	int ans = 0;
	int cnt = 0;
	for(auto p : pairs) {
//		cout << "first = " << p.first << "  second = " << p.second << endl;
		cnt++;
		if(cnt > K) {
		    ans += p.second;
		}
	}
    cout << ans << endl;	
	
	return 0;
}


Measured memory_bytes: 11764
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <functional>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	vector<int> v(n);
	for (auto &x : v)
		scanf("%d", &x);
	vector<bool> dp(k + 1);
	for (int i = 1; i <= k; ++i)
		for (int j = 0; j < n; ++j)
			if (i >= v[j])
				dp[i] = dp[i] || !dp[i - v[j]];
	if (dp[k])
		puts("First");
	else
		puts("Second");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct BinaryIndexedTree {
    int n;
    vector<int> bit;

    BinaryIndexedTree(int _n) {
        n = _n;
        bit.resize(_n+1);
    }

    void add(int i, int x) {
        while (i <= n) {
            bit[i] += x;
            i += i & -i;
        }
    }

    int sum(int i) {
        int s = 0;
        while (i > 0) {
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }

    int getSum(int i, int j) {
        return sum(j) - sum(i-1);
    }
};

int main() {
    int n, q; cin >> n >> q;
    BinaryIndexedTree BIT(n);

    int t, x, y;
    rep(i, q) {
        cin >> t >> x >> y;
        if (t == 0) {
            BIT.add(x, y);
        } else {
            cout << BIT.getSum(x, y) << endl;
        }
    }
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define ri register int 
using namespace std;
typedef long long ll;
template <typename T> inline void exgcd(T a, T b, T &x, T &y) {
  if (!b) { x = 1, y = 0; return; }
  exgcd(b, a - a / b * b, y, x), y -= a / b * x;
}
namespace modular {
  const int mod = 998244353;
  int ret;
  inline int add(int a, int b) { return a < mod - b ? a + b : a - mod + b; }
  inline int dec(int a, int b) { return a < b ? a - b + mod : a - b; }
  inline int mul(int a, int b) { return (ll) a * b % mod; }
  inline void Add(int &a, int b) { a = a < mod - b ? a + b : a - mod + b; }
  inline void Dec(int &a, int b) { a = a < b ? a - b + mod : a - b; }
  inline void Mul(int &a, int b) { a = (ll) a * b % mod; }
  inline int ksm(int a, int p) { for (ret = 1; p; p >>= 1, Mul(a, a)) (p & 1) && (Mul(ret, a), 1); return ret; }
  inline int fix(int x) {
    x <= -mod || x >= mod ? x %= mod : 0;
    return x < 0 ? x + mod : x;
  }
  inline int Inv(int a) {
    static int x, y;
    return exgcd(a, mod, x, y), fix(x);
  }
}  using namespace modular;
const int N = 2e7 + 5;
int fac[N], ifac[N], n, A, B;
inline void init_fac(int lm) {
  fac[0] = fac[1] = ifac[0] = ifac[1] = 1;
  for (ri i = 2; i <= lm; ++i) fac[i] = mul(fac[i - 1], i);
  ifac[lm] = Inv(fac[lm]);
  for (ri i = lm - 1; i > 1; --i) ifac[i] = mul(ifac[i + 1], i + 1);
}
inline int C(int n, int m) { return n < m || m < 0 ? 0 : mul(fac[n], mul(ifac[m], ifac[n - m])); }
inline int Cal(int n, int m) { return dec(C(n + m, n), C(n + m, n + 1)); }
int main() {
  #ifdef ldxcaicai
  freopen("lx.in", "r", stdin);
  #endif
  cin >> n >> B >> A, init_fac(n << 1);
  if (!A) return cout << 1, 0;
  int res = 0;
  for (ri j, i = 0, k; i <= B && i <= n - A; ++i) {
    int t = Cal(A - 1, i);
    if (i + A == n) Add(res, i == B ? t : 0);
    else {
      j = n - A - i - 1, k = B - i + 1;
      Add(res, mul(t, C(j + k - 1, k - 1)));
    }
  }
  cout << res;
  return 0;
}

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

string s;
bool check(char c){
  for(int i=0;i<9;i+=3){
    if(s[i]==s[i+1]&&s[i+1]==s[i+2]&&s[i]==c){
      return true;
    }
  }
  for(int i=0;i<3;i++){
    if(s[i]==c&&s[i+3]==c&&s[i+6]==c){
      return true;
    }
  }
  if(s[0]==s[4]&&s[4]==s[8]&&s[0]==c){
    return true;
  }
  if(s[2]==s[4]&&s[4]==s[6]&&s[2]==c){
    return true;
  }
  return false;
}


int main(){
  while(cin>>s){
    bool o = check('o');
    bool x = check('x');
    if(o){
      cout<<"o"<<endl;
    }
    if(x){
      cout<<"x"<<endl;
    }
    if(!o&&!x){
      cout<<"d"<<endl;
    }
  }
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b;
  c = 0;
  
  for (int i = a; i <= b; i++) {
    if (i%10000/1000*10+i/10000 == i%100)
      c++;
  }
 
  cout << c << endl;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

string samePart(string a, string b){
  string stuck = "";

  REP(i, a.size()){
    REP(j, b.size()){
      if(a[i]==b[j]){
        stuck += b[j];
        b.erase(j, 1);
        break;
      }
    }
  }
  return stuck;
}



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

  ll n;
  cin >> n;

  vector<string> s(n);
  REP(i, n)
    cin >> s[i];

  string stuck = s[0];
  REP1(i, n)
    stuck = samePart(stuck, s[i]);

  sort(stuck.begin(), stuck.end());
  cout << stuck << endl;


  
  
}


Measured memory_bytes: 256
fn main(){
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).ok();
    let li:Vec<&str> = input.split_whitespace().collect();
    let n:i32 = li[0].parse().ok().unwrap();
    let l:i32 = li[1].parse().ok().unwrap();
    let ajimax = l + n - 1;
    let ajimin = l;
    let goukei = (0 .. n).fold(0,|sum,x| sum + l + x);
    let result = if ajimax * ajimin <= 0 {
        goukei
    }else if ajimax < 0 {
        goukei - ajimax
    }else{
        goukei - ajimin
    };
    println!("{}",result);

}


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

typedef long long ll;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

vector<vector<int> > tree(100001);
vector<pair<int, int> > ma(100001);

int tans(int g, int c, int m) {
  if(ma[g].first <= c) return 0;
  ma[g].first = c;
  ma[g].second = m;
  rep(i, 0, tree[g].size()) {
    tans(tree[g][i], c + 1, m);
  }
}

int main() {
  int n;
  cin >> n;
  rep(i, 0, n - 1) {
    int a, b;
    cin >> a >> b;
    tree[a - 1].pb(b - 1);
    tree[b - 1].pb(a - 1);
  }

  rep(i, 0, n) ma[i].first = 11451419;

  tans(0, 0, 1);
  tans(n - 1, 0, 2);

  int a = 0, b = 0;
  rep(i, 0, n) {
    if(ma[i].second == 1) a++;
    else if(ma[i].second == 2) b++;
  }

  cout << (a > b ? "Fennec" : "Snuke") << endl;
}


Measured memory_bytes: 11264
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

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

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long
#ifndef int
#define INF __INT32_MAX__
#else
#define INF __INT64_MAX__
#endif

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

signed main(void)
{
  char s[100]={};
  scanf("%s",s);
  if(s[0]=='Y'&&
     s[1]=='A'&&
     s[2]=='K'&&
     s[3]=='I')
    puts("Yes");
  else
    puts("No");
  
  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 gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define MOD 1000000007

char c[50][50];
int h,w;

int countChar(int i,int j) {
    int count=0;
    bool fi0=i-1>=0,fih=i+1<h,fj0=j-1>=0,fjw=j+1<w;
    if(fi0) {
        if(fj0) count+=(c[i-1][j-1]=='#')?1:0;
        count+=(c[i-1][j]=='#')?1:0;
        if(fjw) count+=(c[i-1][j+1]=='#')?1:0;
    }
    if(fj0) count+=(c[i][j-1]=='#')?1:0;
    if(fjw) count+=(c[i][j+1]=='#')?1:0;
    if(fih) {
        if(fj0) count+=(c[i+1][j-1]=='#')?1:0;
        count+=(c[i+1][j]=='#')?1:0;
        if(fjw) count+=(c[i+1][j+1]=='#')?1:0;
    }
    return count;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    rep(i,h) {
        rep(j,w) {
            cin >> c[i][j];
        }
    }
    rep(i,h) {
        rep(j,w) {
            if(c[i][j]!='#') {
                cout << (char)('0'+countChar(i,j));
            }
            else {
                cout << "#";
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n;
	scanf("%d", &n);

	std::vector<P> ans;
	REP(i, 1, n+1){
		REP(j, i+1, n+1){
			if(n%2==0 and i+j!=n+1) ans.emplace_back(i, j);
			if(n%2 and i+j!=n) ans.emplace_back(i, j);
		}
	}
	printf("%ld\n", ans.size());
	for(P p: ans) printf("%ld %ld\n", p.fi, p.se);
	return 0;
}



Measured memory_bytes: 512
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = LI()
    r = [0] * n
    r[1] = abs(a[0]-a[1])
    for i in range(2,n):
        t = r[i-2] + abs(a[i]-a[i-2])
        u = r[i-1] + abs(a[i]-a[i-1])
        if t < u:
            r[i] = t
        else:
            r[i] = u

    return r[-1]


print(main())


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

int main(){
	ll n;cin >> n;
	vector<ll> arr(n);
	for(int i = 0;i<n;i++)cin >> arr[i];
	ll p = pow(10,21);
	vector<vector<ll>> dp(n,vector<ll>(n,0));
	vector<ll> sum(n+1,0);
	
	for(int i = 1;i<=n;i++){
		sum[i] = sum[i-1]+arr[i-1];
	}
	
	for(int i = 0;i<n;i++){
		dp[i][i] = 0;
		if(i != 0){
			dp[i-1][i] = arr[i-1]+arr[i];
		}
	}
	for(int l = 3;l<=n;l++){
		for(int i = 0;i<=n-l;i++){
			int j = i+l-1;
			ll temp = p;
			for(int k = i;k<j;k++){
				temp = min(temp,dp[i][k]+dp[k+1][j]);
			}
			dp[i][j] = temp+sum[j+1]-sum[i];
		}
	}
	
	cout << dp[0][n-1] << endl;
	
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
 
vector<string>v[17];
int p;
string s;
 
int G1();
 
int get(){
  int res=0;
  if(s[p]=='(')p++,res=G1(),p++;
  else if(s[p]=='-')p++,res= !get();
  else if(s[p]=='0')p++,res=0;
  else if(s[p]=='1')p++,res=1;
  return res;
}
 
int G1(){
  int res=get();
  while(s[p]=='*'||s[p]=='^'){
    int tmp=p++;
    if(s[tmp]=='*') res&=get();
    if(s[tmp]=='^') res^=get();
  }
  return res;
}
 
int BNF(string x){
  p=0;
  s=x+'@';
  return G1();
}
 
int BIT(string s){
  int bit=0;
  r(i,(1<<4)){
    string t=s;
    r(j,t.size()){
      if(t[j]=='a') t[j]= (i&(1<<0))?'0':'1';
      if(t[j]=='b') t[j]= (i&(1<<1))?'0':'1';
      if(t[j]=='c') t[j]= (i&(1<<2))?'0':'1';
      if(t[j]=='d') t[j]= (i&(1<<3))?'0':'1';
    }
    bit |= (BNF(t) << i);
  }
  return bit;
}
 
set<int>st;
map<int,int>ans;
 
void MAKE(){
  for(int i=1;i<17;i++){
    vector<string>vv;
    if(i==1){
      vv.push_back("0");
      vv.push_back("1");
      vv.push_back("a");
      vv.push_back("b");
      vv.push_back("c");
      vv.push_back("d");
    }
    r(j,v[i-1].size()){
      vv.push_back("-"+v[i-1][j]);
    }
    int sz=i-3;
    for(int j=1;j<sz;j++){
      int k=sz-j;
      r(a,v[j].size()){
        r(b,v[k].size()){
          vv.push_back("("+v[j][a]+"^"+v[k][b]+")");
          vv.push_back("("+v[j][a]+"*"+v[k][b]+")");
        }
      }
    }
    r(j,vv.size()){
      int bit=BIT(vv[j]);
      if(!st.count(bit)){
        ans[bit]=i;
        st.insert(bit);
        v[i].push_back(vv[j]);
      }
    }
  }
}
 
int main(){
  MAKE();
  string s;
  while(cin>>s){
    if(s==".")break;
    cout<<ans[BIT(s)]<<endl;
  }
}


Measured memory_bytes: 4056
#include <stdio.h>
#include <math.h>
#include <string.h>

int gcd(int a,int b){
    if(a<b){
        int now=a;
        a=b;
        b=a;
    }

    int r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }

    return b;
}



/* 値を入れ替える関数 */
void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}



int main(void){
    int n;
    scanf("%d",&n);
    int all=0;
    int A[n];
    int i;
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
        all^=A[i];
    }

    for(i=0;i<n;i++){
        printf("%d ",A[i]^all);
    }
    printf("\n");
}

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

int main(){
   int w,h,x,y,r;
   cin >> w >> h >> x >> y >> r;
   if(0<=x-r && x+r<=w && 0<=y-r && y+r<=h){
      cout << "Yes" << endl;
   }else{cout << "No" << endl;}

}

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

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        double L = scan.nextDouble();
        double x = L / 3;
        double ans = x * x * x;
        System.out.printf("%.9f\n", ans);
    }
}


Measured memory_bytes: 25300
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.NoSuchElementException;



class Main {


	public static void main(String[] argv){
		FastScanner sc = new FastScanner();

		int k = sc.nextInt();
		int t = sc.nextInt();
		ArrayList<Integer> arrayList = new ArrayList<Integer>();

		for(int i = 0;i<t;i++){
			arrayList.add(sc.nextInt());
		}
		Collections.sort(arrayList);
		Collections.reverse(arrayList);

		int temp = arrayList.get(0);
		
		for(int i = 1;i<arrayList.size();i++){
			int num = arrayList.get(i);
			if(temp > num){
				temp -= num;
			}else{
				temp = num - temp;
			}
		}
		if(temp > 0) temp--;
		System.out.println(temp);

	}



}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


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

#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
typedef long long ll;
const ll inf = 2e9 + 7;

template <class T = int> T in() { T x; cin >> x; return (x); }

typedef pair<int, pair<int, int>> edge;

class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int N) { par = vector<int>(N, -1); }
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};



class Kruskal {
private:
	UnionFind *uf;
	vector<edge> e;
public:
	vector<edge> mst;
	Kruskal(int N) { uf = new UnionFind(N); }
	void add(int x, int y, ll z);
	void run();
};



//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

ll UnionFind::size(int x) {
	return -par[find(x)];
}

void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}

bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}



//----Kruskal-------------------------------
void Kruskal::add(int x, int y, ll z) {
	e.push_back({ z,{x,y} });
}

void Kruskal::run() {
	sort(e.begin(), e.end());
	for (auto x : e) {
		if (uf->same(x.second.first, x.second.second)) {
			continue;
		}
		else {
			mst.push_back(x);
			uf->unite(x.second.first, x.second.second);
		}
	}
}

typedef struct {
	ll x, y;
	int I;
} pos;

//左から右へ
bool cmpx(pos &a, pos &b) {
	if (a.x != b.x) return a.x < b.x;
	else return a.y < b.y;
}

//下から上へ
bool cmpy(pos &a, pos &b) {
	if (a.y != b.y) return a.y < b.y;
	else return a.x < b.x;
}

int main() {
	int n = in();
	vector<pos> tate, yoko;
	tate = vector<pos>(n); yoko = vector<pos>(n);
	REP(i, n) {
		yoko[i].I = tate[i].I = i;
		yoko[i].x = tate[i].x = in();
		yoko[i].y = tate[i].y = in();
	}
	sort(yoko.begin(), yoko.end(), cmpx);
	sort(tate.begin(), tate.end(), cmpy);
	Kruskal ks(n);
	ks.add(yoko[0].I, yoko[1].I, min(abs(yoko[1].x - yoko[0].x), abs(yoko[1].y - yoko[0].y)));
	ks.add(yoko[n - 1].I, yoko[n - 2].I, min(abs(yoko[n - 1].x - yoko[n - 2].x), abs(yoko[n - 1].y - yoko[n - 2].y)));
	ks.add(tate[0].I, tate[1].I, min(abs(tate[1].x - tate[0].x), abs(tate[1].y - tate[0].y)));
	ks.add(tate[n - 1].I, tate[n - 2].I, min(abs(tate[n - 1].x - tate[n - 2].x), abs(tate[n - 1].y - tate[n - 2].y)));
	FOR(i, 1, n - 1) {
		ks.add(yoko[i].I, yoko[i - 1].I, min(abs(yoko[i].x - yoko[i - 1].x), abs(yoko[i].y - yoko[i - 1].y)));
		ks.add(yoko[i].I, yoko[i + 1].I, min(abs(yoko[i].x - yoko[i + 1].x), abs(yoko[i].y - yoko[i + 1].y)));
		ks.add(tate[i].I, tate[i - 1].I, min(abs(tate[i].x - tate[i - 1].x), abs(tate[i].y - tate[i - 1].y)));
		ks.add(tate[i].I, tate[i + 1].I, min(abs(tate[i].x - tate[i + 1].x), abs(tate[i].y - tate[i + 1].y)));
	}
	ks.run();
	ll ans = 0;
	for (auto x : ks.mst) {
		ans += x.first;
	}
	cout << ans << endl;
}

Measured memory_bytes: 14060
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  int n,x;
  vi a(101,0);
  rep(i,101) {
    a.at(i) = i+1;
  }
  while(true) {
    cin >> n >> x;
    if(n==0 and x==0) break;

    ll ans = 0;
    rep(i,n) {
      srep(j,i+1,n) {
        srep(k,j+1,n) {
          int t;
          t = a.at(i) + a.at(j) + a.at(k);
          if(x==t) ans++;
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}



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

using namespace std;

typedef long long int ll;
typedef pair<int,int> ii;

const int N = 1e5 + 5;

int n,a[N];
bool flag;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n;
  for (int i = 1 ; i <= n ; i++)
    cin >> a[i];
  sort(a + 1 , a + n + 1,greater <int>());
  for (int i = 1 ; i <= n ; i++) {
    if (i + 1 > a[i + 1]) {
      int go = i;
      while (go < n && a[go + 1] >= i)
        go++;
      if ((a[i] - i) % 2 == 1 || (go - i) % 2 == 1)
        cout << "First\n";
      else
        cout << "Second\n";
      return 0;
    }
  }

}

Measured memory_bytes: 640
#include<stdio.h>
int isPrime(int x) {
    int i;
    if (x < 2) return 0;
    else if (x == 2) return 1;
    if (x % 2 == 0) return 0;
    for (i = 3; i * i <= x; i++) {
        if (x % i == 0) return 0;
    }
    return 1;
}

int main() {
    int n, x, i;
    int count = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &x);
        if (isPrime(x)) count++;
    }
    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 2144
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
int main(void){
    int n,m,k=0;
    P p[100000];
    cin>>n>>m;
    for(int i=0;i<n;i++){
        ll a;
        int b;
        cin>>a>>b;
        p[i]=P(a,b);
    }
    sort(p, p+n);
    ll c=0;
    for(int i=0;i<n&&k<m;i++){
        ll a=p[i].first;
        int b=p[i].second;
        c+=a*min(b, m-k);
        k+=min(b, m-k);
    }
    cout<<c<<endl;
}


Measured memory_bytes: 1792
/* *
 *
 * Author: Hamkor
 *
 * */
 
#include <bits/stdc++.h>

using namespace std;

/* * * *   * * *   	* * * */
#define ll long long
#define ld long double
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VI vector<int>
#define VII vector<pair<int, int>>
#define VLL vector<pair<ll, ll>>
#define PB push_back()
#define B begin()
#define E end()
#define F first
#define S second
#define SZ size()
#define P complex <ll> 
#define X real()
#define Y imag()
const int oo = 1e9;
const ll mod = 1e7;
/* * * *   * * *   	* * * */

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n; cin>>n;
	VI f(n);
	for (int i=0; i<n; ++i) cin>>f[i];
	int t = 0, c = 0;
	for (int i=0; i<n; ++i){
		if (c >= f[i]) c=f[i];
		else{t+=(f[i] - c); c = f[i];}
	}
	cout<<t;
	return 0;
}


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

const int MAXN = 110000;
LL x[MAXN], y[MAXN];
int k[MAXN];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!

    int N;
    cin >> N;
    const LL INF = 1ll<<60;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
        y[i] += INF;
        k[i] = __builtin_ffsll(y[i])-1;
        y[i] >>= k[i];
    }
    LL l = -4e17, r = 4e17;
    while (l < r) {
        LL m = (l+r)/2;
        if (m == r) m--;
        bool cnt_leq = false;
        for (int i = 0; i < N; i++) {
            if (m < x[i]) continue;
            LL t = (m-x[i])>>k[i];
            cnt_leq ^= !(t&1) and (t&y[i])==t;
        }
        if (cnt_leq) r = m;
        else l = m+1;
    }
    cout << l << "\n";
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int n,m;
bool used[100000];
vector<int> path[100000];
vector<int> ans;
int dp[100000];

void dfs(int u){
  if(used[u]) return;
  used[u]=true;
  for(int v:path[u]) dfs(v);
  ans.push_back(u);
}

int main(){
  cin>>n>>m;
  rep(i,0,m){
    int a,b;
    cin>>a>>b;
    path[a-1].push_back(b-1);
  }
  rep(i,0,n) used[i]=false;
  rep(i,0,n) dfs(i);
  reverse(ans.begin(),ans.end());
  for(int j:ans){
    for(int k:path[j]){
      dp[k]=max(dp[k],dp[j]+1);
    }
  }
  int ans=0;
  rep(i,0,n) ans=max(ans,dp[i]);
  cout<<ans<<endl;
}

Measured memory_bytes: 8824
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>

using namespace std;

typedef long long ll;

const ll q = 10000000000 + 7;

int main() {
	
	string s;
	cin >> s;
	int length = s.length();

	bool yes = true;
	for (int i = 0; i < length; i++)
	{
		if (i % 2 == 0) {
			if (s[i] == 'L') {
				yes = false;
				break;
			}
		}
		else {
			if (s[i] == 'R') {
				yes = false;
				break;
			}
		}
	}

	if (yes) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

int main()
{
    int n, total = 0;
    short m, ai;
    cin >> n >> m;
    for (; m > 0; m--) 
    {
        cin >> ai;
        total += ai;
    }
    if (n < total) cout << -1;
    else cout << n - total;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
  int t1, t2;
  cin >> t1 >> t2;
  ll a1, a2;
  cin >> a1 >> a2;
  ll b1, b2;
  cin >> b1 >> b2;
  if (a1 > b1) {
    swap(a1, b1);
    swap(a2, b2);
  }
  ll diff = t1*(a1-b1)+t2*(a2-b2);
  if (diff == 0) {
    cout << "infinity" << endl;
    return 0;
  }
  if (diff < 0) {
    cout << 0 << endl;
    return 0;
  }
  // cout << diff << endl;
  ll d1 = t1*(b1-a1);
  ll d2 = t2*(a2-b2);
  ll ans = 2* (d1/diff);
  if (d1 % diff > 0) {
    ans += 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.BitSet

fun main(args: Array<String>) {
    var N = readInputLine().toLong()
    
    if (N == 0L) {
        println(0)
        return
    }
    
    val ans = BitSet()
    
    var base = -2L
    
    for (i in 0..60) {
        if (N % base != 0L) {
            ans.set(i)
            N -= base / -2L
        }
        base *= -2L
    }
    
    val ansStr = CharArray(ans.size(), {'0'})
    
    for (i in 0 until ans.size()) {
        if (ans.get(i)) {
            ansStr[ans.size() - i - 1] = '1'
        }
    } 
    
    println(ansStr.joinToString("").trimStart{it == '0'})
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 35772
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>
#include <math.h>

#define nl '\n'

using namespace std;

int a, b, c;

int main(){
    
    cin >> a >> b >> c;

    if(c >= a && c <= b){
        cout << "Yes";
        return 0;
    }

    cout << "No";


}

//g++ -std=c++14 comp.cpp -o b; ./b.exealso

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

int main()
{
  int n, k;
  cin >> n >> k;
  int a[n];
  rep(i, n) cin >> a[i];
  sort(a, a + n);
  int ans = 1000000005;
  rep2(i, 0, n - k + 1) ans = min(ans, a[i + k - 1] - a[i]);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3992
using System;

class Program
{
    static void Main()
    {
        int count = 0;
        string[] N_D = Console.ReadLine().Split(' ');
        int N = int.Parse(N_D[0]);
        int D = int.Parse(N_D[1]);

        int[,] XY = new int[N, 2];

        for (int i = 0; i < N; i++)
        {
            string[] str = Console.ReadLine().Split(' ');
            for (int j = 0; j < 2; j++)
            {
                XY[i, j] = int.Parse(str[j]);
            }
        }

        for (int i = 0; i < N; i++)
        {
            double a = Math.Sqrt(Math.Pow(XY[i, 0],2) +Math.Pow(XY[i, 1],2));
            if (a<=D)
            {
                count++;
            }
        }

        Console.WriteLine(count);
    }
}

Measured memory_bytes: 23060
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>
using namespace std;

int main(){
  int H,W;

  while(1){
    cin>>H>>W;
    if(H==0) break;
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        if((i + j) % 2 == 0){
          printf("#");
        }else{
          printf(".");
        }
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 3064
import numpy as np
n, x, y = map(int, input().split())

dist_cnt = [0] * (n-1)

for i in range(1, n+1):
    for j in range(i+1, n+1):
        dist1 = j - i
        dist2 = abs(x - i) + 1 + abs(y - j)
        dist_cnt[min(dist1, dist2)-1] += 1

for cnt in dist_cnt:
    print(cnt)


Measured memory_bytes: 21148
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
    unsigned short *a,*b;

    int c[VMAX+1];
    int n,i,j;
    scanf("%d",&n);

    a=malloc(sizeof(short)*n+1);
    b=malloc(sizeof(short)*n+1);

    for(i=0;i<=VMAX;i++)c[i]=0;

    for(i=0;i<n;i++){
        scanf("%hu",&a[i+1]);
        c[a[i+1]]++;
    }

    for(i=1;i<=VMAX;i++)c[i]=c[i]+c[i-1];

    for(j=1;j<=n;j++){
        b[c[a[j]]]=a[j];
        c[a[j]]--;
    }

    for(i=1;i<=n;i++){
        if(i>1)printf(" ");
        printf("%d",b[i]);
    }
    printf("\n");

    return 0;
}


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

int main(void){
    int N; cin >> N;
    int minA=1000000000, maxA=0;

    for(int i=0; i<N; i++){
        int a; cin >> a;
        minA=min(minA,a); maxA=max(maxA,a);
    }

    cout << maxA-minA << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] L = new int[m];
		int[] R = new int[m];
		for(int i = 0; i < m; i++) {
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		}
		int lmax = L[0];
		int rmin = R[0];
		for(int i = 1; i < m; i++) {
			lmax = Math.max(lmax, L[i]);
			rmin = Math.min(rmin, R[i]);
		}
		int ans = Math.max(rmin - lmax + 1, 0);
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 72080
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int n;
	cin>>n;
	cout<<(n%2?2*n:n)<<endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc112b()
}

fun abc112b() {
    val (n, time) = readLine()!!.split(" ").map { it.toInt() }
    val costTimes = (1..n).map { readLine()!!.split(" ").map { it.toInt() } }
        .map { CostTime(it[0], it[1]) }

    val answer = costTimes.filter { it.time <= time }.minBy { it.cost }?.cost

    println(answer ?: "TLE")
}

class CostTime(val cost: Int, val time: Int)

Measured memory_bytes: 37988
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


signed main() {
  int n, w;
  cin >> n >> w;
  int k[100001] = {};
  rep(i, 0, 100001) k[i] = 1145141919;
  k[0] = 0;
  rep(i, 0, n) {
    int ww, v;
    cin >> ww >> v;
    dep(j, 100000, 0) {
      if(k[j] + ww <= w) {
        k[j + v] = min(k[j + v], k[j] + ww);
      }
    }
  }
  int ans = 0;
  rep(i, 0, 100001) {
    if(k[i] != 1145141919) ans = max(ans, i);
  }
  cout << ans << endl;
}


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

int main()
{
	int n, x, t;
	cin >> n >> x >> t;
	cout <<fixed << setprecision(0) <<  ceil((double)n / x)*t;
}

Measured memory_bytes: 3772
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int min = sc.nextInt();
		int max = sc.nextInt();
		int result = 0;
		for (int i = min; i <= max; i++) {
			String[] values = String.valueOf(i).split("");
			if (values[0].equals(values[4]) && values[1].equals(values[3])) {
				result++;
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 63144
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
//#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	int H,W;
	cin>>H>>W;
	char S[100][100];
	for(int i=0;i<H;i++)
		cin>>S[i];
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++){
			bool flag=0;
			if(S[i][j]=='.')
				continue;
			for(int k=0;k<4;k++){
				if(S[i+dx[k]][j+dy[k]]=='#')
					flag=1;
			}
			if(flag==0){
				cout<<"No"<<endl;
				return 0;
			}
		}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int ans = 0;

void rec(vector<int> a, int cur) {
  if (cur == n) {
    int p = 1;
    for (int i = 0; i < n; ++i) {
      p *= a[i];
    }
    if (p % 2 == 0) ans++;
    return;
  }

  rec(a, cur + 1);
  a[cur]++;
  rec(a, cur + 1);
  a[cur] -= 2;
  rec(a, cur + 1);
}

int main() {
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];

  rec(a, 0);
  cout << ans << '\n';
  return 0;
}


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

int main() {

  int n;
  cin >> n;

  vector<vector<pair<int,int>>> axy;

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

    int a;
    cin >> a;

    vector<pair<int, int>> xy(a);
    for (int j = 0; j < a; j++) {
      cin >> xy[j].first >> xy[j].second;
    }

    axy.push_back(xy);

  }

  set<string> st;

  for (int i = 0; i < (1 << n); i++) {
    
    bitset<16> s(i);

    bool flg = true;

    for (int j = 0; j < n; j++)  {

      int t = s[j];
      int c = axy[j].size();

      if (t == 1){
        for (int l = 0; l < c; l++) {
          if (s[axy[j][l].first - 1] != axy[j][l].second) {
            flg = false;
            break;
          }
        }
      } else {
        /*
        for (int l = 0; l < c; l++) {
          if (s[axy[j][l].first - 1] == axy[j][l].second) {
            flg = false;
            break;
          }
        }*/
      }

      if (!flg) {
        break;
      }

    }
    
    if (flg){
      st.insert(s.to_string());
    }
    
  }

  int answer = 0;

  for(auto x : st) {
    int count = 0;
    string x2 = x.substr(16 - n);
    for (int i = 0; i < n; i++) {
      if (x2[i] == '1'){
        count++;
      }
    }
    answer = max(answer, count);
  }

  cout << answer << endl;

}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,k;
	cin >> n >> k;
	n=n%k;
	if(n<=k/2.0)
	cout << n << endl;
	else{
		cout << k-n << endl;
	}
	return 0;
} 

Measured memory_bytes: 256