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

using namespace std;

const int N = 500010;
int n, k;
int a[N];
int v[N];
vector<int> g[N];
int deg[N];

struct Node;
typedef Node* NP;
struct Node {
    NP l, r;
    int sz;
    int mi;
    Node(int _sz) : sz(_sz) {
        mi = N;
        if (sz == 1) return;
        l = new Node(sz/2);
        r = new Node(sz-sz/2);
    }

    void set(int k, int v) {
        if (sz == 1) {
            mi = v;
            return;
        }
        if (k < sz/2) {
            l->set(k, v);
        } else {
            r->set(k-sz/2, v);
        }
        mi = v;
    }
    int get(int a, int b) {
        if (b <= 0 || sz <= a) return N;
        if (a <= 0 && sz <= b) return mi;
        return min(l->get(a, b), r->get(a-sz/2, b-sz/2));
    }
};

void make(int x, int y) {
    if (y == N) return;
    y = a[y];
    deg[y]++;
    g[x].push_back(y);
}

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

    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x; x--;
        a[x] = i;
    }

    NP tr = new Node(n);
    for (int i = n-1; i >= 0; i--) {
        int cr = a[i];
        make(cr, tr->get(max(0, cr-k+1), cr));
        make(cr, tr->get(min(n, cr+1), min(n, cr+k)));
        tr->set(cr, i);
    }

    set<int> que;
    for (int i = 0; i < n; i++) {
        if (deg[i] == 0) {
            que.insert(i);
        }
    }
    int cr = 0;
    while (que.size()) {
        int c = *que.begin();
        que.erase(que.begin());
        v[c] = cr++;
        for (int i = 0; i < int(g[c].size()); i++) {
            int d = g[c][i];
            deg[d]--;
            if (deg[d] == 0) {
                que.insert(d);
            }
        }
    }

    for (int i = 0; i < n; i++) {
        cout << v[i]+1 << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;

const long long INF = 1LL << 60;

ll dp[1000001] = {};

int n, m;
vector<vector<int> > G;

int rec(int v) {
    if (dp[v] != -1) {
        return dp[v];
    }

    int res = 0;
    for (auto next_v : G[v]) {
        res = max(res, rec(next_v) + 1);
    }

    return dp[v] = res;
}

int main() {
    #ifdef MYLOCAL
        ifstream in("input.txt");
        cin.rdbuf(in.rdbuf());
    #endif

    cin >> n >> m;
    G.resize(n);
    for(int i = 0; i < m; ++i){
        int from, to; cin >> from >> to;
        --from;
        --to;
        G[from].push_back(to);
    }

    for(int i = 0; i <= n; ++i){
        dp[i] = -1;
    }

    int res = 0;
    for (int v = 0; v < n; ++v) {
        res = max(res, rec(v));
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 8576
import java.util.*;
import java.lang.*;

public class Main {
		public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		sc.nextLine();
		int[] heights = new int[n];
		for(int i = 0; i < n; i++) {
			heights[i] = sc.nextInt();
		}
		
		int[] dp = new int[n]; //min number of cost before reaching i
		for (int i = 0; i < dp.length; i++) {
			dp[i] = Integer.MAX_VALUE;
		}
		dp[0] = 0;
		for (int i = 0; i < n; i++) {
			for(int j = i+1; j <= i+k; j++) {
				if(j < n) {
					dp[j] = Math.min(dp[j], dp[i] + Math.abs(heights[i] - heights[j]));
				}
			}
			
		}
		System.out.println(dp[n-1]);
	}
	 
}

Measured memory_bytes: 50952
using System;
using System.Linq;

class C
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var t = read();

		var end = t.Select(x => x + h[1]).ToArray();
		for (int i = 1; i < h[0]; i++)
			end[i - 1] = Math.Min(end[i - 1], t[i]);
		Console.WriteLine(Enumerable.Range(0, h[0]).Sum(i => end[i] - t[i]));
	}
}


Measured memory_bytes: 30752
#[allow(unused_imports)]
use std::cmp::Ordering;

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get {
    ([$t: ty]) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let k = get!(usize);
    let (a, b) = get!(usize, usize);
    for i in a..b + 1 {
        if i % k == 0 {
            println!("OK");
            return;
        }
    }
    println!("NG");
}


Measured memory_bytes: 2244
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int gcd(int a, int b){
  if(a<b)swap(a,b);
  if(b==0)return a;
  return gcd(b,a%b);
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,K;cin >> N >> K;
  int g,m=0;
  rep(i,N){
    int x;cin >> x;
    m = max(m,x);
    if(i==0) g = x;
    else g = gcd(g,x);
  }
  if(m>=K && K%g==0)cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  return 0;
}


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if ((A == 5 && B == 5 && C == 7) || (A == 5 && B == 7 && C == 5) || (A == 7 && B == 5 && C == 5)){
        cout << "YES"  << endl;
    } 
    else{
        cout << "NO"  << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cout<<a[n-1]<<endl;
	return 0;
 } 

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

const int M = 1e6;
int p[M + 1];

int main(){
	int a, d, n;
	fill(p, p + M + 1, 1);
	p[0] = p[1] = 0;
	for(int i = 2;i < sqrt(M + 1);++i){
		if(p[i]){
			for(int j = i + i;j <= M;j += i){
				p[j] = 0;
			}
		}
	}
	while(cin >> a >> d >> n, a){
		int c = 0, t;
		for(t = a;c < n;t += d){
			c += p[t];
		}
		cout << t - d << endl;
	}
	return 0;
}

Measured memory_bytes: 5064
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	bool ans = false;
	string S;

	cin >> S;

	for (int i = 0; i < 3; i++) {
		if (S[i] == S[i + 1]) {
			ans = true;
		}
	}

	if (ans) {
		cout << "Bad" << endl;
	} else {
		cout << "Good" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
minMP = 100000


def make_patterns(nowstr, count0, count1, count2, count3, rest):
    if count0 > N - 2:
        return
    if count1 > N - 2:
        return
    if count2 > N - 2:
        return
    if count3 > N - 3:
        return
    if rest == 0:
        if 0 == count0:
            return
        if 0 == count1:
            return
        if 0 == count2:
            return
        do_calc(list(nowstr), count0, count1, count2)
        return
    make_patterns(nowstr+"0", count0+1, count1, count2, count3, rest-1)
    make_patterns(nowstr+"1", count0, count1+1, count2, count3, rest-1)
    make_patterns(nowstr+"2", count0, count1, count2+1, count3, rest-1)
    make_patterns(nowstr+"3", count0, count1, count2, count3+1, rest-1)
    return


def do_calc(pattern_list, c0, c1, c2):
    global minMP
    # print(pattern_list)
    tempA = 0
    tempB = 0
    tempC = 0
    tempcost = (c0+c1+c2-3)*10
    for i in range(N):
        num = int(pattern_list[i])
        if num == 0:
            tempA += L_list[i]
        if num == 1:
            tempB += L_list[i]
        if num == 2:
            tempC += L_list[i]
    tempcost += abs(A - tempA) + abs(B - tempB) + abs(C - tempC)

    if tempcost < minMP:
        minMP = tempcost


N, A, B, C = map(int, input().split())

L_list = [int(input()) for i in range(N)]

# print(L_list)
make_patterns("", 0, 0, 0, 0, N)

print(minMP)


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

int main() {
  int y,m,d;
  char a,b;
  cin>>y>>a >>m >>b >>d;
  
  if(m<=4){
    cout<<"Heisei" <<endl;
  }
  else{
    cout <<"TBD" <<endl;
  }
}
		

Measured memory_bytes: 256
t,k = map(int,input().split())

ans = 0

n = 0

for i in range(1,t+1):
	#print(i)
	n = 0
	while i*2**n < k:
		n = n + 1
	#print(i,n,0.5**n)
	ans = ans + (0.5**n)/t
	#print(ans)

print(ans)
	



	

Measured memory_bytes: 38996
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  if (0) {
    int n = 100000;
    cout << n << endl;
    for (int i = 0; i < n; i++) {
      cout << i + 1 << " ";
    }
    cout << endl;
    return 0;
  }

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

  vector<int> as(n);
  for (auto &a : as)
    scanf("%d", &a);

  vector<int64_t> ans(n);

  //   int prev = 0;
  //   for (int i = 0; i < n; i++) {
  //     int cur = as[i];
  //     if (cur <= prev)
  //       continue;

  //     int64_t sum = 0;

  //     // #pragma unroll
  //     for (int j = i; j < n; j++) {
  //       //   sum += min<int>(as[j], cur) - min<int>(as[j], prev);

  //       sum += min<int>(as[j], cur) - min<int>(as[j], prev);
  //     }
  //     prev = cur;

  //     ans[i] = sum;
  //   }

  vector<pair<int64_t, int>> ord(n);
  for (int i = 0; i < n; i++) {
    ord[i].first = as[i];
    ord[i].second = i;
  }

  sort(ord.rbegin(), ord.rend());

  vector<pair<int, int>> vs;
  vs.push_back(make_pair(0, -1));

  int prev = 0;
  for (int i = 0; i < n; i++) {
    int cur = as[i];
    if (cur > prev) {
      prev = cur;
      vs.push_back(make_pair(cur, i));
    }
  }

  reverse(vs.begin(), vs.end());

  int64_t ceil = 0;
  int curi = 0;

  for (int i = 0; i + 1 < vs.size(); i++) {
    int curv = vs[i].first;
    int nexv = vs[i + 1].first;

    int64_t sum = 0;
    sum += (int64_t)ceil * (curv - nexv);
    while (curi < n && ord[curi].first > nexv) {
      sum += ord[curi].first - nexv;
      ceil++;
      curi++;
    }

    ans[vs[i].second] = sum;
  }

  for (auto &s : ans)
    printf("%lld\n", s);

  return 0;
}


Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
#define modulo N
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<pair<int,int>> ans;
	
	for(int i=1;true;i++){
		ans.emplace_back(i,mod(i-(2*i-1)));
		if((i+1)*2*2>N){
			int l = i+1;
			int r = mod(i-(2*i-1)-1);
			int m = (l+r)/2;
			for(int j=1;j<N;j++){
				ans.emplace_back(m-j,m+j);
			}
			break;
		}
	}
	
	for(int i=0;i<M;i++){
		cout<<ans[i].first+1<<' '<<ans[i].second+1<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 5224
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  vl a(n + 1, 0);
  rep(i, n) {
    ll c;
    cin >> c;
    a[c]++;
  }
  sort(all(a), greater<ll>());
  rep(i, n + 1) {
    if(i < k) continue;
    ans += a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4820
#include <iostream>
using namespace std;
int sx, sy, tx, ty;
int main(void){
    // Your code here!
    cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx, dy = ty - sy;
    for (int i = 0; i < dx; i++) cout << 'R';
    for (int i = 0; i < dy; i++) cout << 'U';
    for (int i = 0; i < dx; i++) cout << 'L';
    for (int i = 0; i < dy; i++) cout << 'D';
    cout << 'D';
    for (int i = 0; i <= dx; i++) cout << 'R';
    for (int i = 0; i <= dy; i++) cout << 'U';
    cout << 'L' << 'U';
    for (int i = 0; i <= dx; i++) cout << 'L';
    for (int i = 0; i <= dy; i++) cout << 'D';
    cout << 'R' << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(int)(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) ((flag)?1:0)
#define YN(flag) cout<<(flag?"YES":"NO")<<endl;
#define Yn(flag) cout<<(flag?"Yes":"No")<<endl;
#define yn(flag) cout<<(flag?"yes":"no")<<endl;
#define Cout(v) cout<<(v)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

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

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

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

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ===================

// Template End =========================

int main(void){
  int n,k; cin>>n>>k; --k; string s; cin>>s;
  locale l=locale::classic();
  rep(i,n) cout<<(i==k?tolower(s[i],l):s[i]);
}












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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

inline void Main() {
  // code
  int n;
  string s;
  cin >> n >> s;
  rep(i, s.size()) {
    int ds = (s.at(i) - 'A' + n) % 26;
    cout << (char)(ds + 'A');
  }
  cout << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  int A, B, C, D;
  std::cin >> A >> B >> C >> D;  
  
  if((A + B) < (C + D)){
    std::cout << "Right";
  }
  else if((A + B) > (C + D)){
    std::cout << "Left";
  }
  else{
    std::cout << "Balanced";
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define EPS 0.00000001
using namespace std;

int main(){
 
    double x1, y1, x2, y2, x0, y0, dx, dy, m, X, Y;
    int q;
    cin >> x1 >> y1 >> x2 >> y2 >> q;
    dx = x1 - x2;
    dy = y1 - y2;
    while (q--){
      cin >> x0 >> y0;
      X=(dx*dx*x0+dy*dy*x1-dx*dy*(y1-y0))/(dx*dx+dy*dy);
      Y = !(-EPS<=dx && dx<=EPS) ? Y=dy/dx*(X-x1)+y1 : Y=y0;
  		printf("%.8lf %.8lf\n",X,Y);
    }
}


Measured memory_bytes: 3292
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;
// << fixed << setprecision(0) <<

int main() {
double a,b,x;
cin >> a >> b >> x;
double y,theta;
if(2*x>=a*a*b) {
  y=2*(a*a*b-x)/(a*a);
  theta=180*atan(y/a)/M_PI;
} else {
  y=(2*x)/(a*b);
  theta=180*atan(b/y)/M_PI;
}
cout << fixed << setprecision(10) << theta << endl;
return 0;
}


Measured memory_bytes: 384
N,D = map(int,input().split())
L = [list(map(int,(input().split()))) for _ in range(N)]

ans = 0
for i in range(N):
    d = (L[i][0]**2 + L[i][1]**2) ** 0.5
    if d <= D:
       ans += 1
print(ans)

Measured memory_bytes: 45784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll a;
    cin >>a;
    
    cout << a*(1+a*(1+a)) << endl;


    return 0;
    

}

Measured memory_bytes: 3600
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    A, B, C = map(int, readline().split())
    if A + B >= C:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9236
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

string s;
stack<char> q;
vector<string> ans;

int main(){
	while(1){
		while(q.size())q.pop();
		getline(cin,s);
		if(s==".")break;
		for(int i=0;i<s.size();i++){
			if(s[i]=='['||s[i]=='('){
				q.push(s[i]);
			}else if(s[i]==')'){
				if(q.size()&&q.top()=='('){
					q.pop();
				}else{
					ans.push_back("no");
					
					goto A;
				}
			}else if(s[i]==']'){
				if(q.size()&&q.top()=='['){
					q.pop();
				}else{
					
					ans.push_back("no");
					goto A;
				}
			}
		}
		if(q.empty()){
		ans.push_back("yes");
		}else{
			ans.push_back("no");
		}
		A:;
	}
	while(ans.size()){
		cout<<ans.front()<<endl;
		ans.erase(ans.begin());
	}
	return 0;
}


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

#define tc		int t;cin>>t;while(t--)
#define int		long long
#define pb 		push_back
#define mp		make_pair	
#define ff		first
#define ss		second
#define pii		pair<int,int>
#define vi		vector<int>
#define pqi		priority_queue<int>
#define pqd		priority_queue<int,vi,greater<int>>
#define inf		LLONG_MAX
#define mod		1000000007


int cost(vi height,int n,int k){

	vi dp(n+1);
	dp[1]=0;
	for(int i=2;i<=n;i++){
		dp[i]=inf;
		for(int j=i-1; j>=i-k && j>0; j--){
			dp[i]=min(dp[i],dp[j]+abs(height[i]-height[j]));
		}
	}
	return dp[n];
}

int32_t main(){

	int n,k;
	cin>>n>>k;
	vi height(n+1);
	for(int i=1;i<=n;i++){
		cin>>height[i];
	}
	cout<<cost(height,n,k)<<endl;

	return 0;

}

Measured memory_bytes: 2560
#!/usr/bin/env python3
from sys import stdin


def solve(tc):
    n = int(stdin.readline().strip())
    if n<1000:
        print('ABC')
    else:
        print('ABD')
    pass


LOCAL_TEST = not __debug__
if LOCAL_TEST:
    infile = __file__.split('.')[0] + "-test.in"
    stdin = open(infile, 'r')

tcs = (int(stdin.readline().strip()) if LOCAL_TEST else 1)
tc = 1
while tc <= tcs:
    solve(tc)
    tc += 1

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int size = scanner.nextInt();
        int N = scanner.nextInt();
        int arr[] = new int[size];
        for (int i = 0; i < size; i++) {
            arr[i] = scanner.nextInt();

        }
        System.out.println((getWinner(arr, N) == 1 ? "Second" : "First"));

    }

    public static int getWinner(int arr[], int N) {
        Arrays.sort(arr);
        int index = 0;
        int ans[][] = new int[N + 1][2];
        for (int i = 0; i < ans.length; i++) {
            if (i == 0) {
                ans[0][0] = 1;
                ans[1][0] = 0;
                continue;
            }
            if (index < arr.length && i == arr[index]) {
                ans[i][0] = 0;

                ans[i][1] = 1;
                index++;
                continue;

            }

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

                ans[i][j] = -1;

            }
        }

        for (int i = 0; i < ans.length; i++) {

            for (int j = 0; j < 2; j++) {
                index = 0;
                int tempAns = -1;
                int o = j == 1 ? 0 : 1;
                ans[i][j] = o;
                while (index < arr.length && i - arr[index] >= 0) {
                    tempAns = ans[i - arr[index]][o];
                    if (tempAns == j) {
                        ans[i][j] = j;
                        break;
                    }
                    index++;
                }

            }
        }

       
        return ans[ans.length - 1][0];

    }
}


Measured memory_bytes: 40032
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node{
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

Node * find(Node *u, int k){
    while(u!=NIL && k!=u->key){
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

Node * treeMinimum(Node *x){
    while(x->left != NIL) x = x->left;
    return x;
}

Node * treeSuccessor(Node *x){
    if(x->right != NIL) return treeMinimum(x->right);
    Node *y = x->parent;
    while (y!=NIL && x == y->right){
        x=y;
        y=y->parent;
    }
    return y;
}

void treeDelete(Node *z){
    Node *y;
    Node *x;

    if(z->left==NIL || z->right == NIL) y=z;
    else y = treeSuccessor(z);

    if(y->left != NIL){
        x = y->left;
    } else {
        x = y->right;
    }

    if(x!=NIL){
        x->parent = y->parent;
    }

    if (y->parent == NIL){
        root = x;
    } else {
        if(y==y->parent->left){
            y->parent->left = x;
        } else {
            y->parent->right = x;
        }
    }

    if(y!=z){
        z->key = y->key;
    }

    free(y);
}

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x!=NIL){
        y=x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    z->parent = y;
    if(y==NIL){
        root = z;
    } else {
        if(z->key < y->key){
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u){
    if(u==NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u){
    if(u==NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n,i,x;
    string com;

    scanf("%d",&n);

    for(i=0;i<n;i++) {
        cin >> com;

        if (com[0] == 'f')
        {
            scanf("%d",&x);
            Node *t = find(root, x);
            if(t!=NIL) printf("yes\n");
            else printf("no\n");
        } else if (com == "insert") {
            scanf("%d", &x);
            insert(x);
        } else if (com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } else if (com == "delete"){
            scanf("%d", &x);
            treeDelete(find(root,x));
        }
    }
    return 0;
}


Measured memory_bytes: 22048
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n + 1];

        for (int i = 0; i < n + 1; i++) {
            a[i] = sc.nextInt();
        }

        long sum = 0;

        for (int i = 0; i < n; i++) {
            int b = sc.nextInt();
            int buster = Math.min(a[i], b);
            int secondBuster = Math.min(a[i + 1], b - buster);
            a[i + 1] -= secondBuster;
            sum += buster + secondBuster;
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 64420
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}

int main(){
	int n,m,x,l=0,r=0;
	cin>>n>>m>>x;
	rep(i,m){
		int t;
		cin>>t;
		if(t<x)l++;
		else r++;
	}
	cout<<min(l,r);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, ans=0;
    cin >> n;
    if(n>=105)ans++;
    if(n>=135)ans++;
    if(n>=165)ans++;
    if(n>=189)ans++;
    if(n>=195)ans++;
    cout << ans << endl;
    return 0;
}


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

int main() {
	int n,ans=0;
	int d[100000];
	cin >> n;
	for (int i = 0; i < n; i++)cin >> d[i];
	sort(d, d + n);
	ans = d[n / 2] - d[n / 2 - 1];
	cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Set<Integer> set = new HashSet<Integer>();
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if (set.contains(a)) {
				set.remove(a);
			} else {
				set.add(a);
			}
		}
		sc.close();

		System.out.println(set.size());
	}
}


Measured memory_bytes: 62572
import java.util.Arrays;
import java.util.Scanner;

public class Main{
    private static int h[] = new int[(int) (1e5 + 1)];
    private static int dp[] = new int[(int) (1e5 + 1)];
    private static int n;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        for (int i = 0;i < n;i++)
            h[i] = sc.nextInt();
        Arrays.fill(dp,0,n,-1);
        System.out.println(dp(0));
    }

    private static int dp(int idx) {
        if(idx == n - 1)
            return 0;
        if(dp[idx] != -1)
            return dp[idx];
        if(idx + 1 < n)
            dp[idx] = Math.abs(h[idx] - h[idx + 1]) + dp(idx + 1);
        if(idx + 2 < n){
            dp[idx] = Math.min(dp[idx],Math.abs(h[idx] - h[idx + 2]) + dp(idx + 2));
        }
        return dp[idx];
    }
}

Measured memory_bytes: 76148
N = int(input())
if N >= 0:
  if N == 0:
    print(0)
  elif N == 1:
    print(1)
  else:
    s = 2
    j = 2
    i = 1
    while s + j**2 <= N:
      i += 1
      s += j**2
      j*= 2
  
    k = 2 * i + 1
    a  = bin(int('10'*i, 2)^(N-s))[2:]
    if len(a) < k-1:
      a = '0'*(k-1-len(a)) + a
    print('1' + a)
else:
  s = -1
  j = -2
  i = 1
  while N <= s + j:
    s += j
    j *= 4
    i += 1
  k = 2 * i
  print(bin(int('10'*i, 2)^(N-(s+j)-1))[2:])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define V vector
#define L long long
#define W V<L>
#define Z V<W>
#define R(n) for(L i=0;i<n;i++)
W S(Z&p,L E){if(!E){return{1,0};}V<Z>T(2);for(W x:p){T[x[1]&1].push_back({x[0]/2,x[1]/2});if(x[0]&1){T[(x[1]+1)&1].push_back({x[0]/2,(x[1]+1)/2});}}Z c(4,W(3));c[3]=W(3,1);R(2){for(W x:T[i]){L Q=(2*x[0]+x[1])%3;c[i][Q]^=1;}}R(2){if(c[!i]==c[2]||c[!i]==c[3]){W ans=S(T[i],E-1);ans[0]*=2;ans[1]*=2;ans[1]+=i;return ans;}}for(W&v:p){v[0]++;}W A=S(p,E);A[0]--;return A;}
int main(){L M=2e17;L n;cin>>n;V<W>p(n);R(n){L a,b;cin>>a>>b;p[i]={a+M,b+M};}W Q=S(p,70);cout<<Q[0]-M<<" "<<Q[1]-M;}

Measured memory_bytes: 37052
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N=200005;
const long double pi=acos(-1);
int X1,X2,Y1,Y2,n,fx=1,fy=1,st[N],top;
pair<int,int>p[N];
int main()
{
	scanf("%d%d%d%d",&X1,&Y1,&X2,&Y2);
	if(X1>X2)
		fx=-1,X1*=-1,X2*=-1;
	if(Y1>Y2)
		fy=-1,Y1*=-1,Y2*=-1;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&p[i].fi,&p[i].se);
		p[i].fi*=fx,p[i].se*=fy;
		if(!(X1<=p[i].fi&&p[i].fi<=X2&&Y1<=p[i].se&&p[i].se<=Y2))n--,i--;
	}
	sort(p+1,p+1+n);
	for(int i=1;i<=n;i++)
		if(!top||p[i].se>st[top])
			st[++top]=p[i].se;
		else
			*upper_bound(st+1,st+1+top,p[i].se)=p[i].se;
	long double ans=100.0L*(X2-X1+Y2-Y1)+(pi-4)*5*top;
	if(top==min(X2-X1+1,Y2-Y1+1))ans+=pi*5;
	printf("%.20Lf\n",ans);
	return 0;
}


Measured memory_bytes: 2560
use std::fmt::Debug;
use std::io;
use std::str::FromStr;

fn read_and_divide_line<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut target_line = String::new();
    io::stdin().read_line(&mut target_line).unwrap();
    target_line
        .trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

fn main() {
    let kind_num: Vec<i64> = read_and_divide_line();
    let coupon_kind_num = kind_num[2];

    let refrigerator_prices: Vec<i64> = read_and_divide_line();
    let microwave_prices: Vec<i64> = read_and_divide_line();

    let mut each_price_combination: Vec<Vec<i64>> = vec![];

    for _ in 0..coupon_kind_num {
        each_price_combination.push(read_and_divide_line());
    }

    let min_refrigerator_price = {
        let mut tmp_refrigerator_prices = refrigerator_prices.clone();
        tmp_refrigerator_prices.sort();
        tmp_refrigerator_prices[0]
    };

    let min_microwave_price = {
        let mut tmp_microwave_prices = microwave_prices.clone();
        tmp_microwave_prices.sort();
        tmp_microwave_prices[0]
    };

    let mut min_price = min_refrigerator_price + min_microwave_price;

    for combination in each_price_combination {
        let now_price = refrigerator_prices[(combination[0] as usize) - 1]
            + microwave_prices[(combination[1] as usize) - 1]
            - combination[2];
        if now_price < min_price {
            min_price = now_price;
        }
    }

    println!("{}", min_price);
}


Measured memory_bytes: 15348
import java.util.*;
public class Main {

	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
      String ans ="";	
      ans = getAns(s);
      System.out.println(ans);
	}
  
  public static String getAns(String s){
    String a = "";  
    for(int i=0;i<s.length();i++){
      String t = s.substring(i,i+1) ; 
      //奇数番目の文字。iは偶数
        if(i%2==0){
          if(t.equals("L")){
            a = "No";
            return a;
          }/*else{
          	continue;
          }*/
        }else{
          if(t.equals("R")){
          	a ="No";
            return a;
          }/*else{
          	continue;
          }*/
        }  
      }
    a ="Yes";
      return a;
  }
      
}


Measured memory_bytes: 21844
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S =sc.next();
        int a=0,b=0,c=0;
        for(int d=0;d<3;d++){
            if(S.charAt(d)=='a') a++;
            else if(S.charAt(d)=='b')b++;
            else c++;
        }
        if(a<=1&&b<=1&&c<=1) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end())
#define pb push_back
#define mp make_pair
#define MODP(A,B) A=(A+B)%mod
typedef pair<ll,ll> P;
typedef pair<double,double> Pd;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

int main(){
    string S; cin>>S;
    bool ans=true;
    ll N=S.size();
    ll K=(N-1)/2;
    rep(i,K) if(S.at(i)!=S.at(N-1-i)) ans=false;
    ll X=K/2;
    rep(i,X) if(S.at(i)!=S.at(K-1-i)) ans=false;
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        S: chars,
    }
    let mut ans = 0;
    let mut tmp = 0;
    for i in 0..N{
        if S[i]=='I'{
            tmp += 1;
        }else{
            tmp -= 1;
        }
        ans = max(ans,tmp);
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <stdio.h>

int main()
{
    int matrix[101][101];
    int i,j;
    for(i=0;i<101;i++){
        for(j=0;j<101;j++){
            matrix[i][j]=0;
        }
    }
    int t,y;
    scanf("%d %d\n",&t,&y);
    for(i=0;i<t;i++){
        for(j=0;j<y;j++){
            if(j==y-1){
                scanf("%d\n",&matrix[i][j]);
            }else{
                scanf("%d ",&matrix[i][j]);
            }
        }
    }
    for(i=0;i<t;i++){
        for(j=0;j<y;j++){
            matrix[i][y]+=matrix[i][j];
        }
    }
    for(j=0;j<y;j++){
        for(i=0;i<t;i++){
            matrix[t][j]+=matrix[i][j];
        }
    }
    for(j=0;j<y;j++){
        matrix[t][y]+=matrix[t][j];
    }
    for(i=0;i<=t;i++){
        for(j=0;j<=y;j++){
            if(j!=y){
                printf("%d ",matrix[i][j]);
            }else{
                printf("%d\n",matrix[i][j]);
            }
        }
    }
    return 0;
}


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

#define MaxN 2005
#define INF 2140000000
#define MOD 1000000007

using namespace std;

int N,K,Min=MaxN,X,Y;
vector<int> Graph[2*MaxN];
bool found[2*MaxN];
int DFS(int node,int depth)
{
    int ans=(int)(depth>K&&node<=N);
    found[node]=1;
    for(int i=0;i<Graph[node].size();i++)
        if(!found[Graph[node][i]])
            ans+=DFS(Graph[node][i],depth+1);
    return ans;
}
int main()
{
    cin>>N>>K;
    for(int i=1;i<N;i++)
    {
        cin>>X>>Y;
        Graph[X].push_back(N+i);
        Graph[N+i].push_back(Y);
        Graph[N+i].push_back(X);
        Graph[Y].push_back(N+i);
    }
    for(int i=1;i<2*N;i++)
        memset(found,0,sizeof found),Min=min(Min,DFS(i,0));
    cout<<Min;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
int main() {
	fast;
	lli l,r,d,i,count=0;;
	cin>>l>>r>>d;
	for(i=l;i<=r;i++)
	{
		if(i%d==0)
			count++;
	}
	cout<<count;
	
	return 0;
}		

Measured memory_bytes: 3604
#include<stdio.h>

int solve(int, int);

int n, A[2000];

int main(){
  
  int q, Q[2000], i;
  
  scanf("%d", &n);
  for(i = 0; i < n; i++)
    scanf("%d", &A[i]);
  
  scanf("%d", &q);
  for(i = 0; i < q; i++)
    scanf("%d", &Q[i]);


  for(i = 0; i < q; i++){
    if(solve(0, Q[i]) == 1)   printf("yes\n");
    else                      printf("no\n");
  }

  return 0;
}

int solve(int i, int m){
  int res;

  if(m == 0)    return 1;
  if(i >= n)    return 0;
  
  res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  //printf("i + 1 = %d, m = %d res = %d\n", i + 1, m, res);

  return res;
}

Measured memory_bytes: 588
from sys import stdin
ans=0
rans=0
c=0
check=True
S = input().rstrip()
def countans(s,rans,check):
  if (s=='A' or s=='C' ) or (s=='G'or s=='T'):
    rans+=1
  else:
    check=False
  return rans,check

for s in range(len(S)):
  rans=0
  check = True
  while True:
    if check:
      rans, check = countans(S[s],rans,check)
      if s>=len(S)-1:
        break
      s+=1
    else:
      break
  if ans<rans:
    ans =rans

print(ans)


Measured memory_bytes: 61992
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<b?(a=b,1):0)
#define chmin(a,b) (a>b?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<30;

int n,m;
struct Cat {
  int x,y,C;
  Cat() {}
  Cat(int x, int C) :x(x),C(C) {}
  bool operator<(const Cat &b) const {
    return x != b.x ? x<b.x : C<b.C;
  }
} cat[1000];
int X[1000];
int dp[1000];
int sum[1001];
int numL[1000][1000];
int numR[1000][1000];

bool ok(int k) {
  REP(i,m) dp[i] = INF;
  int c = upper_bound(cat,cat+n,Cat(X[m-1],INF))-cat;
  dp[m-1] = sum[n]-sum[c];
  for (int i=m-1; i>=0; --i) {
    for (int j=i+1; j<m; ++j) {
      if (numR[i][j]+dp[j] <= k)
        chmin(dp[i], numL[i][j]);
    }
    int a = upper_bound(cat,cat+n,Cat(X[i],INF))-cat;
    if (dp[i] + sum[a] <= k) return 1;
  }
  return 0;
}

int main() {
  while(cin>>n>>m,n||m) {
    REP(i,n) cin>>cat[i].x>>cat[i].y>>cat[i].C;
    sort(cat,cat+n);
    REP(i,m) cin>>X[i];
    sort(X,X+m);
    REP(i,n) {
      sum[i+1] = sum[i] + cat[i].C;
    }
    // int id=0;
    // REP(i,m) {
    //   while(id<n && cat[id].x<=X[i]) id++;
    //   sum2[i] = sum[id];
    // }
    for (int i=0; i<m-1; ++i) {
      for (int j=i+1; j<m; ++j) {
        int a = upper_bound(cat,cat+n,Cat(X[i],INF))-cat;
        int mid = (X[i]+X[j])/2;
        if (X[i]+X[j]<0) mid = (X[i]+X[j]-1)/2;
        int b = upper_bound(cat,cat+n,Cat(mid,INF))-cat;
        int c = upper_bound(cat,cat+n,Cat(X[j],INF))-cat;
        numL[i][j] = sum[b]-sum[a];
        numR[i][j] = sum[c]-sum[b];
        // cout << i << " " << j << " " << numL[i][j] << " " << numR[i][j] << endl;
      }
    }
    int low=-1,high=INF;
    while(low+1<high) {
      int mid = (low+high)/2;
      if (ok(mid)) high = mid;
      else low = mid;
    }
    cout << high << endl;
  }
}

Measured memory_bytes: 9016
/*
g++ -std=c++14 -O2 -Wall a.cpp -o a && a
*/

//  io
#include <iostream>
//#include <fstream> //http://www.cplusplus.com/reference/fstream/fstream/
//#include <cstdio>
//#include <iomanip> //http://www.cplusplus.com/reference/iomanip/
//  util
#include <string>
//#include <cstring>
#include <algorithm>
//#include <utility>
//#include <functional> //http://www.cplusplus.com/reference/functional/
//#include <cstdlib>
//#include <cmath>
//#include <complex>
//#include <random>
//#include <bitset>
//  containers https://en.cppreference.com/w/cpp/container
#include <vector>
//#include <queue>
//#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//  time
//#include <ctime>
//#include <chrono>
//                  https://en.cppreference.com/w/cpp/header/chrono
//                  http://www.cplusplus.com/reference/chrono/

using namespace std;
typedef vector<int> arri;
typedef vector<float> arrf;
typedef pair<int, int> pairi;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 0x7fffffffffffffff;
const ll infneg = -0x7fffffffffffffff;

//int modadd(int a, int b) { return ((a += b) < mod) ? a : (a - mod); }
//int modmult(int a, int b) { return (int)((a * b) % mod) }

//file input routed to stdinout
/*
std::ifstream inFile("input.txt");
std::ofstream outFile("output.txt");
std::cin.rdbuf(inFile.rdbuf());
std::cout.rdbuf(outFile.rdbuf());
*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k, x;
    cin >> k >> x;

    for (int i = x - k + 1; i < x + k; i++)
    {
        cout << i << " ";
    }
}


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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	while(true){
		int N=read(),A=read(),B=read(),C=read(),X=read();
		if(N||A||B||C||X){
			int Y[N];
			REP(i,N){
				Y[i]=read();
			}
			
			int frame = 0;
			int reel = 0;
			while(true){
				if(Y[reel] == X) reel++;
				if(reel == N) break;
				X = (A*X+B)%C;
				frame++;
				if(frame > 10000){
					frame = -1;
					break;
				}
			}
			cout << frame << endl;
		}
		else break;
	}
	return 0;
}

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main(){
int n,i,j;
cin >> n;
for(i=1;i<=9;i++){
for(j=1;j<=9;j++){
if(i*j==n){
cout << "Yes" <<endl;
return 0;
}
}
}
cout << "No" <<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

// a^n modを計算する(二分累乗法)
ll modpow (ll a, ll n, ll mod) {
  ll res = 1;
  while (n>0) {
    if (n&1) res = res*a%mod;
    a = a*a%mod;
    n >>= 1;
  }
  return res;
}

// 負の数にも対応した%演算
ll modminus(ll val, ll m) {
  ll res = val%m;
  if (res<0) res += m;
  return res;
}

int main() {
  ll N;
  cin >> N;
  cout << (modminus(modpow(10, N, MOD)-modpow(9, N, MOD)*2%MOD, MOD)+modpow(8, N, MOD))%MOD << endl;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    int n,k;
    cin >> n >> k;
    double ans = 0.0;
    for(int i = 1;i <= n;i++){
        int p = i;
        int a = 1;
        while(1 <= p && p <= k-1){
            p *=2;
            a *= 2;
        }
        ans += 1.0/a/n;
    }
    printf("%.15lf\n",ans);


    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc126.contest.atcoder.jp/tasks/abc126_a

Measured memory_bytes: 256