akhauriyash/Code-Regression huggingface dataset:
use proconio::{input, fastout};

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

    let mut is_exist = false;
    for i in 0..n-2 {
        let (di1, di2) = d12[i];
        let (ndi1, ndi2) = d12[i+1];
        let (nndi1, nndi2) = d12[i + 2];
        if di1 == di2 && ndi1 == ndi2 && nndi1 == nndi2
        {
            is_exist = true;
        }
    }

    if is_exist {
        println!("Yes")
    } else {
        println!("No")
    }
}


Measured memory_bytes: 2196
program main 
   implicit none
   !integer,allocatable,dimension(:)::a
   integer::n,k
   integer::i,j
   read(*,*)n,k
   if((n+1)/2>=k)then
      write(*,"(a3)")"YES"
   else
      print "(a)","NO"
   endif
	!read(*,*)a
end program main


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
           int x,a,b;
		   cin>>x>>a>>b;
           if(a-b>=0)cout<<"delicious"<<endl;
           else if(b-a<=x)cout<<"safe"<<endl;
           else cout<<"dangerous"<<endl;
           
}

Measured memory_bytes: 3620
from math import sqrt, floor
n = int(input())
f = [0] * n
sn = floor(sqrt(n))
for x in range(1, sn+1):
    for y in range(x, sn+1):
        for z in range(y, sn+1):
            t = x * x + y * y + z * z + x * y + y * z + z * x
            if t <= n:
                s = set([x,y,z])
                if len(s) == 3:
                    f[t-1] += 6
                elif len(s) == 2:
                    f[t-1] += 3
                else: f[t-1] += 1
for i in f:
    print(i)


Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> k(m);
    vector<vector<int>> s(m);
    vector<int> p(m);
    for (int i = 0; i < m; i++)
    {
        cin >> k[i];
        for (int j = 0; j < k[i]; j++)
        {
            int tmp;
            cin >> tmp;
            s[i].push_back(tmp);
        }
    }
    for (int i = 0; i < m; i++)
    {
        cin >> p[i];
    }

    int ans = 0;

    for (int bit = 0; bit < (1 << n); bit++)
    {
        bool flg = true;
        for (int i = 0; i < m; i++)
        {
            int rec = 0; // onになってる電球の個数
            for (int j = 0; j < k[i]; j++)
            {
                if (bit & (1 << s[i][j] - 1))
                {
                    rec++;
                }
            }
            // cout << "on:" << rec << endl;
            if (rec % 2 != p[i])
            {
                flg = false;
            }
        }

        if (flg)
        {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    static long INF = (long)1e18;
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        
        // ans: 「1+2+...+k」がnの倍数である最小のk
        // -> k(k+1)/2 % n = 0
        // -> k(k+1) % 2n = 0
        // ex. 10*11 % 2*11 = 0
        
        // how:
        // a = 2nの約数, b = 2n/aとして、 (ex. n,a,b = 11,11,2)
        // ax + by = 1なる(x,y)を求めて、 (ex. 11*1 + 2*-5 = 1)
        // y < 0であるmin(-by)を求める。
        // <- これを全てのaで行いmin(min(-by))を出力する。
        
        if (n == 1) {
            System.out.println(1);
            return;
        }
        
        List<Long> list = divisorList(2*n);
        
        long ans = INF;
        for (Long a : list) {
            long b = 2*n/a;
            
            long[] eg = extgcd(a, b);
            
            long g = eg[0];
            long x = eg[1];
            long y = eg[2];
            
            if (x == 0 || y == 0) continue;
            
            if (g == 1) {
                if (y < 0) {
                    ans = Math.min(ans, -b*y);
                }
                // System.out.println(a + "*" + x + "+" + b + "*" + y + "=" + g);
            }
        }
        System.out.println(ans);
    }
    
    public static List<Long> divisorList(long n) {
        List<Long> res = new ArrayList<Long>();
        for (long i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                res.add(i);
                
                long j = n / i;
                if (j != i) {
                    res.add(j);
                }
            }
        }
        res.sort(Comparator.naturalOrder());
        
        return res;
    }
    
    // 拡張ユークリッド法: ax + by = gcdを解く
    public static long[] extgcd(long a, long b) {
        long x0 = 1, x1 = 0;
        long y0 = 0, y1 = 1;
        
        while (b != 0) {
            long q = a / b;
            long r = a % b;
            long x2 = x0 - q * x1;
            long y2 = y0 - q * y1;
        
            a = b; b = r;
            x0 = x1; x1 = x2;
            y0 = y1; y1 = y2;
        }
        
        return new long[]{a, x0, y0};
    }
}

Measured memory_bytes: 39976
#include <stdio.h>
#include <vector>
using namespace std;
struct node{
    int l;
    int r;
    int parent;
    int s;
    int depth;
    int d;
    int height;
};
int max(int a,int b){
    if(a>b)return a;
    return b;
}
void build(int now,node tree[]){
    int l=-1,r=-1,d=0;
    if(tree[now].l!=-1){
        tree[tree[now].l].depth=tree[now].depth+1;
        build(tree[now].l,tree);
        l=tree[tree[now].l].height;
        d++;
    }
    if(tree[now].r!=-1){
        tree[tree[now].r].depth=tree[now].depth+1;
        build(tree[now].r,tree);
        r=tree[tree[now].r].height;
        d++;
    }
    tree[now].height=max(l,r)+1;
    tree[now].d=d;
    return ;
}
int main(){
    int n,temp;
    node tree[100];
    scanf("%d",&n);
    for(int i=0;i<n;i++)tree[i].parent=-1;
    for(int i=0;i<n;i++){
        scanf("%d",&temp);
        scanf("%d%d",&tree[temp].l,&tree[temp].r);
        if(tree[temp].l!=-1){
            tree[tree[temp].l].parent=temp;
            tree[tree[temp].l].s=tree[temp].r;
        }
        if(tree[temp].r!=-1){
            tree[tree[temp].r].parent=temp;
            tree[tree[temp].r].s=tree[temp].l;
        }
    }
    for(int i=0;i<n;i++){
        if(tree[i].parent==-1){
            tree[i].s=-1;
            tree[i].depth=0;
            build(i,tree);
        }
    }
    for(int i=0;i<n;i++){
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,tree[i].parent,tree[i].s,tree[i].d,tree[i].depth,tree[i].height);
        if(tree[i].parent==-1)printf("root\n");
        else if(tree[i].l==tree[i].r&&tree[i].l==-1)printf("leaf\n");
        else printf("internal node\n");
    }
     
}


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

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

    bool flag = false;

    for(int i = 0; i <= N/4; i++){
        for(int j = 0; j <= N/7; j++){
            if(4*i + 7*j == N) {
                flag = true;
                break;
            }
        }
    }

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

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int a, b;
    cin >> a >> b;
    string x[a], y[a];

    rep(i, 0, a)
    {
        cin >> x[i];
        y[i] = x[i];
    }

    rep(i, 0, a)
    {
        cout << x[i] << '\n';
        cout << y[i] << '\n';
    }

    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 rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  vector<int> x(0);
  vector<int> y(0);
  vector<int> h(0);
  rep(i,n){
    int a,b,c;
    cin >> a >> b >> c;
    if(c == 0) continue;
    x.push_back(a);
    y.push_back(b);
    h.push_back(c);
  }
  int m = x.size();
  for(int i=0;i<=100;i++){
    for(int j=0;j<=100;j++){
      map<int,int> check;
      rep(k,m) check[h[k] + abs(i-x[k]) + abs(j-y[k])]++;
      if(check.size() == 1){
        if(m == 1){
          cout << x[0] << " " << y[0] << " " << h[0] << endl;
          return 0;
        }
        cout << i << " " << j << " " << h[0]+abs(i-x[0])+abs(j-y[0]) << endl;
      }
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;


int main()
{
  int n;
  string x;
  cin >> n >> x;
  int base_pc = 0;
  vector<int> f(220000, 0);
  vector<int> pcs(220000, 0);
  reps(i, 1, n) {
    pcs[i] = pcs[i/2] + i%2;
    f[i] = f[i % pcs[i]] + 1;
  }
  rep(i, n) if (x[i] == '1') base_pc++;
  int one_pc = base_pc - 1;
  int zero_pc = base_pc + 1;
  int one_mod = 0;
  int zero_mod = 0;
  rep(i, n) {
    if (one_pc != 0) {
      one_mod = one_mod * 2 + (x[i] - '0');
      one_mod %= one_pc;
    }
    zero_mod = zero_mod * 2 + (x[i] - '0');
    zero_mod %= zero_pc;
  }
  vector<int> one_pow2_mod(220000, 1);
  vector<int> zero_pow2_mod(220000, 1);
  reps(i, 1, 220000) {
    if (one_pc != 0) {
      one_pow2_mod[i] = one_pow2_mod[i-1]*2 % one_pc; 
    }
    zero_pow2_mod[i] = zero_pow2_mod[i-1]*2 % zero_pc;
  }
  rep(i, n) {
    if (x[i] == '1') {
      if (one_pc == 0) {
        cout << 0 << endl;
        continue;
      }
      int one_ans = one_mod;
      one_ans -= one_pow2_mod[n-1-i];
      one_ans += one_pc;
      cout << f[one_ans % one_pc] + 1 << endl;
    } else {
      int zero_ans = zero_mod;
      zero_ans += zero_pow2_mod[n-1-i];
      cout << f[zero_ans % zero_pc] + 1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 6996
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>

using namespace std;

int main()
{
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  vector<int> v(N);
  v[0] = (S[0] == 'W' ? 1 : 0);
  for (int i = 1; i < N; ++i) {
    v[i] = v[i - 1] + (S[i] == 'W' ? 1 : 0);
  }
  
  vector<int> w(N);
  w[N - 1] = (S[N - 1] == 'E' ? 1 : 0);
  for (int i = N - 2; i >= 0; --i) {
    w[i] = w[i + 1] + (S[i] == 'E' ? 1 : 0);
  }

  int ans = N;
  for (int i = 0; i < N; ++i) {
    int count;
    if (i == 0) {
      count = w[i + 1];
    }
    else if (i == N - 1) {
      count = v[i - 1];
    }
    else {
      count = v[i - 1] + w[i + 1];
    }
    ans = min(ans, count);
  }

  cout << ans << endl;
  
  return 0;
}


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

int w, h, x, y, r;

int main()
{
    std::cin >> w >> h >> x >> y >> r;
    if (x - r < 0 || y - r < 0 || x + r > w || y + r > h)
        std::cout << "No" << std::endl;
    else
        std::cout << "Yes" << std::endl;
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, M;
int K[100010];
vector<int> G[100010];

int par[100010];

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

void merge(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y) return;
  par[y] = x;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> K[i];
    for (int j = 0; j < K[i]; j++) {
      int L;
      cin >> L;
      G[L - 1].emplace_back(i);
    }
  }
  for (int i = 0; i < N; i++) {
    par[i] = i;
  }
  for (int i = 0; i < M; i++) {
    if (G[i].size() < 2) continue;
    for (int j = 0; j < G[i].size(); j++) {
      merge(G[i][0], G[i][j]);
    }
  }
  int tmp = root(0);
  for (int i = 0; i < N; i++) {
    if (root(i) == tmp) continue;
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;

  return 0;
}

Measured memory_bytes: 4736
#include <iostream>

using namespace std;
struct card {
    char pict;
    int num;
    bool operator<=(card y){
        return num <= y.num;
    };
    bool operator>=(card y){
        return num >= y.num;
    };
    bool operator==(card y){
        return num == y.num;
    };
    bool operator!=(card y){
        return num != y.num;
    };
    bool operator<(card y){
        return operator<=(y) && operator!=(y);
    };
    bool operator>(card y){
        return operator>=(y) && operator!=(y);
    };
};

template<class T>
int partition(T* xs, int p, int r){
    T x = xs[r];
    int i = p-1;
    for(int j = p; j < r; ++j){
        if(xs[j] <= x){
            ++i;
            swap(xs[i], xs[j]);
        }
    }
    swap(xs[i+1], xs[r]);
    return i+1;
}

template<class T>
void quick_sort(T* xs, int p, int r){
    if(p < r){
        int q = partition(xs, p, r);
        quick_sort(xs, p, q-1);
        quick_sort(xs, q+1, r);
    }
}

template<class T>
int merge(T* xs, int l, int m, int r){
    int cnt = 0;
    T temp[r-l];
    int c1 = l;
    int c2 = m;
    int idx = 0;
    while(c1 < m || c2 < r){
        if(c1 == m){
            temp[idx] = xs[c2++];
        } else if(c2 == r){
            temp[idx] = xs[c1++];
        } else if(xs[c1] <= xs[c2]){
            temp[idx] = xs[c1++];
        } else {
            temp[idx] = xs[c2++];
        }
        ++cnt;
        ++idx;
    }
    for(int i = l; i < r; ++i){
        xs[i] = temp[i-l];
    }
    return cnt;
}

template<class T>
int merge_sort(T* xs, int l, int r){
    int cnt = 0;
    if(l+1 < r){
        int mid = (l+r)/2;
        cnt += merge_sort(xs, l, mid);
        cnt += merge_sort(xs, mid, r);
        cnt += merge(xs, l, mid, r);
    }
    return cnt;
}

int main(){
    int n;
    cin >> n;
    card xs[n];
    card ys[n];
    for(int i = 0; i < n; ++i){
        char ch;
        int v;
        cin >> ch >> v;
        xs[i] = card {ch, v};
        ys[i] = card {ch, v};
    }
    merge_sort(ys, 0, n);
    quick_sort(xs, 0, n-1);
    bool stable = true;
    for(int i = 0; i < n; ++i){
        if(xs[i].pict != ys[i].pict){
            stable = false;
        }
    }
    cout << (stable ? "Stable" : "Not stable") << endl;
    for(int i = 0; i < n; ++i){
        printf("%c %d\n", xs[i].pict, xs[i].num);
    }
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){

  CIN(n);VC1(3*n,a);
  sort(ALL(a),greater<ll>());
  //1,2,min 
  ll cou = 0;
  REP(i,n)
    cou += a[i*2+1];
  COUT(cou);

  return 0;
}

Measured memory_bytes: 2560
import sys,cmath,math
c=[]
for s in sys.stdin:
    x,y=map(float,s[:-1].split(","))
    c+=[complex(x,y)]
c0=c[0]
c1=c[1]
r1,a1=cmath.polar(c1-c0)
s=0
for e in c[2:]:
    r2,a2=cmath.polar(e-c0)
    s+=r1*r2*math.sin(abs(a1-a2))/2
    r1,a1=r2,a2
print s

Measured memory_bytes: 4512
l = int(input())
r = 0
g = []

while 2**r <= l:
    r += 1
for i in range(1,r):
    g.append((i,i+1,0))
    g.append((i,i+1,2**(i-1)))
n = r
l -= 2**(r-1)
edge = 2**(n-1)
while l > 0:
    if l < 2**(r-1):
        r -= 1
        continue
    l -= 2**(r-1)
    g.append((r,n,edge))
    edge += 2**(r-1)

print(n,len(g))
for a,b,c in g:
    print(a,b,c)


Measured memory_bytes: 3064
N, A,B = map(int, input().split())

if (A-B)%2==0:
    print((B-A)//2)

else:
    a1=A-1
    aN=N-A
    b1=B-1
    bN=N-B
    a = min(a1,b1,aN,bN)
    print(a+1+(B-A)//2)

Measured memory_bytes: 38384
using System;

namespace AtCoder
{
    internal static class Program
    {
        private static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            int res = 0;
            int highest = -1;

            for(int i = 0; i < N; i++)
            {
                int nbr = int.Parse(Console.ReadLine());
                res += nbr;

                if (nbr > highest)
                    highest = nbr;
            }

            res -= highest / 2;


            Console.WriteLine(res);
        }
    }
}

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

#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;

TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM T> inline istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }
TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { for (auto &_e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(8); } } pre__;

int main(void) {
	int S;
	cin >> S;
	int l = S / 100;
	int r = S % 100;
	bool f1 = 1 <= r && r <= 12;
	bool f2 = 1 <= l && l <= 12;
	string ans;
	if (f1&f2) {
		ans = "AMBIGUOUS";
	}
	else if (f1) {
		ans = "YYMM";
	}
	else if (f2) {
		ans = "MMYY";
	}
	else {
		ans = "NA";
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  string ans = "";
  for (auto c : s) {
    if (c == 'B') {
      if (!ans.empty()) ans.erase(ans.end() - 1);
    } else {
      ans += c;
    }
  }
  printf("%s", ans.c_str());
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


// int factrial(int n){
//   if(n == 0) return 1;
//   return n*factrial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   return fact(n) / (fact(n-k)*fact(k));
// }

int answer(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


int main(){
  int N;
  cin >> N;
  if(N%2==0) cout << N << endl;
  else cout << 2*N << endl;
}
  





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
typedef long long ll;
//プロトタイプ宣言
int gcd(int , int);


int main(){
  int n,ans=0;
  cin >> n;
  vector<int> h(n),count(n,0);
  rep(i,n) cin >> h[i];
  for(int i=n-2;i>=0;i--){
    if(h[i] >= h[i+1]) count[i] = count[i+1] + 1;
    else count[i] = 0;
    ans = max(ans,count[i]);
  }
  cout << ans << endl;
}








































//以下、ライブラリ
//ユークリッドの互除法

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
}



Measured memory_bytes: 1024
#![allow(unused_imports)]
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]

use std::{cmp, fmt};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};

fn main() {
    let (a, b, c1, x, y): (u64, u64, u64, u64, u64) = {
        let mut sc = InputScanOnce::new(io::stdin(), 1024);
        (sc.next(), sc.next(), sc.next(), sc.next(), sc.next())
    };
    let c2 = cmp::min(2 * c1, a + b);
    let t = cmp::min(x, y);
    let r1 = t * c2 + (x - t) * a + (y - t) * b;
    let r2 = cmp::max(x, y) * c2;
    println!("{}", cmp::min(r1, r2));
}

struct InputScanOnce {
    buf: Vec<u8>,
    pos: usize,
}

#[allow(dead_code)]
impl InputScanOnce {
    fn new<R: Read>(mut reader: R, estimated: usize) -> Self {
        let mut buf = Vec::with_capacity(estimated);
        let _ = io::copy(&mut reader, &mut buf).unwrap();
        InputScanOnce { buf: buf, pos: 0 }
    }

    #[inline]
    fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: fmt::Debug,
    {
        let mut start = None;
        loop {
            match (self.buf[self.pos], start.is_some()) {
                (b' ', true) | (b'\n', true) => break,
                (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                (_, false) => start = Some(self.pos),
            }
        }
        let target = &self.buf[start.unwrap()..self.pos];
        unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        T::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
        T3::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        T::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }

    fn strings_as_mat<T, F: FnMut(u8) -> T>(&mut self, h: usize, mut f: F) -> Vec<Vec<T>> {
        (0..h)
            .map(|_| {
                let l = self.next::<String>();
                l.as_bytes().iter().cloned().map(&mut f).collect()
            })
            .collect()
    }
}


Measured memory_bytes: 4352
//
// Created by watemus on 03.05.2020.
//

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

using namespace std;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff first
#define ss second

using ll = long long;
using ld = long double;
#define int ll

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;

#ifdef LOCAL
#else
#endif


void run() {
    int n, k;
    cin >> n >> k;
    set<int> s;
    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;
        while (d--) {
            int t;
            cin >> t;
            s.insert(t);
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (!s.count(i)) {
            ans++;
        }
    }
    cout << ans << "\n";
}

signed main() {
#ifdef LOCAL
    std::freopen("input.txt", "r", stdin);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    int t = 1;
//    cin >> t;
    while (t--) {
        run();
    }
    return 0;
}

Measured memory_bytes: 3668
package main

import "fmt"

func isOK(w []int, k, p int) bool {
	i := 0
	for j := 0; j < k; j++ {
		s := 0
		for s+w[i] <= p {
			s += w[i]
			i++
			if i == len(w) {
				return true
			}
		}
	}
	return i >= len(w)
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	w := make([]int, n)
	s := 0
	for i := range w {
		fmt.Scan(&w[i])
		s += w[i]
	}
	// (l, r]
	l := 0
	r := s
	for r-l > 1 {
		mid := (l + r) / 2
		if isOK(w, k, mid) {
			r = mid
		} else {
			l = mid
		}
	}
	fmt.Println(r)
}



Measured memory_bytes: 5928
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    vector<ll> sa(N);
    sa[0] = a[0];
    for (int i = 1; i < N; i++) sa[i] = sa[i - 1] + a[i];

    for (int q = 0; q < Q; q++) {
        ll x;
        cin >> x;
        ll cnt = 0;
        for (int i = 0; i < N; i++) {
            ll dst = i == 0? x: x + sa[i - 1];
            auto lit = begin(sa) + i;
            auto rit = upper_bound(lit, end(sa), dst);
            cnt += (ll)(rit - lit);
        }
        cout << cnt << endl;
    }

    return 0;
}

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

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

    int n, k;
    cin >> n >> k;
    vector<int> as(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> as[i];
        sum += as[i];
    }
    vector<int> ds;
    for (int i = 1; i * i <= sum; i++) {
        if (sum % i == 0) {
            ds.push_back(i);
            if (sum / i != i) {
                ds.push_back(sum / i);
            }
        }
    }
    sort(ds.rbegin(), ds.rend());
    for (int d : ds) {
        int tot = 0;
        vector<pair<int, int>> hoge;
        for (int i = 0; i < n; i++) {
            int a = as[i];
            if (a % d == 0) continue;
            int iran = a % d;
            int iru = d - iran;
            hoge.emplace_back(iran, iru);
            tot += iru;
        }
        sort(hoge.begin(), hoge.end());
        int cur = 0;
        for (int i = 0;; i++) {
            if (i >= hoge.size()) break;
            cur += hoge[i].first;
            tot -= hoge[i].second;
            if (cur > k) break;
            if (cur == tot) {
                cout << d << endl;
                return 0;
            }
        }
    }
    cout << 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  int N;
  cin >> N;
  int odd = 0;
  rep(i, N) {
    int A;
    cin >> A;
    if (A % 2) ++odd;
  }
  if (odd % 2)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long a, b, k;
    scanf("%ld%ld%ld", &a, &b, &k);

    long i;
    for(i=0; i<k; i++) {
        if(i%2==0) {
            b = b + a/2;
            a = a/2;
        }
        else {
            a = a + b/2;
            b = b/2;
        }
    }
    printf("%ld %ld\n", a, b);

    return 0;
}


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

ll power_mod(ll z, ll y){
    ll ans = 1; z %= MOD;
    while( y ){
        if(y & 1) ans = (ans * z) % MOD;
        z = (z * z) % MOD;
        y >>= 1;
    }
    return ans;
}

int main() {
    ll n, a, b;
    cin>>n>>a>>b;

    ll ans, temp;
    ans = power_mod(2, n);
    ans -= 1;

    ll t1 = 1, t2 = 1;
    for(ll i=1;i<=b;i++) {
        t1 = (t1 * (n - i + 1)) % MOD;
        t2 = (t2 * i) % MOD;

        if(i == a) {
            temp = (t1 * power_mod(t2, MOD - 2)) % MOD;
            ans = ((ans - temp + 2 * MOD) % MOD);
        }
    }
    temp = (t1 * power_mod(t2, MOD - 2)) % MOD;
    ans = ((ans - temp + 2 * MOD) % MOD);

    cout<<ans<<endl;

    return 0;
}




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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; ++i) {
    int x; cin >> x;
    ans += (i & 1) && (x & 1);
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3648
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n,y; cin >> n >> y;
  rep(i,n+1){
    for(int j = 0; j+i <= n;j++){
      if(i*10000+j*5000+1000*(n-i-j) == y){
        printf("%d %d %d",i,j,n-i-j);
        return 0;
      }
    }
  }
  
  printf("-1 -1 -1");
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 131072
int jl[MAXN];
int n,m;
long long P,hh;
void input(){
	cin>>n>>m;
	for(int i=0;i<n;++i){
		cin>>jl[i];
		hh+=jl[i];
	}
}
bool pd(int x){
	long long sum0=0;
	int v=1;
	for(int i=0;i<n;++i){
		if(sum0+jl[i]<=x) sum0+=jl[i];
		else if(jl[i]<=x){
			sum0=jl[i];
			v++;
		}
		else return false;
	}
	if(v>m) return false;
	else return true;
}
void syf(){
	long long l=0,r=hh;
	while(l<r){
	    long long mid=(r+l)/2;
	    if(pd(mid)) r=mid;
	    else l=mid+1;
	}
	cout<<l<<endl;
}
int main(){
	input();
	syf();
	return 0;
}

Measured memory_bytes: 3484
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		LinkedList<Integer> stack = new LinkedList<Integer>();
		String[] tokens = in.nextLine().split(" ");
		int a, b, result;
		for(String t : tokens){
			if(t.matches("[0-9]+")) {
				stack.push(Integer.parseInt(t));
			}else{
				a = stack.pop();
				b = stack.pop();
				result = 0;
				switch(t){
					case "+" : result = b + a;
						       break;
					case "*" : result = b * a;
						       break;
					case "-" : result = b - a;
						       break;
					case "/" : result = b / a;
				}
				stack.push(result);
			}
		}
		System.out.println(stack.pop());
		in.close();
	}
}

Measured memory_bytes: 26320
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	int N,i;
	cin>>N;
	vector<int> A(N);
	for (i=0;i<N;i++){
		cin>>A[i];
	}
	int ans=0;
	int No=1;
	for (i=0;i<N;i++){
		if (A[i]!=No){
		}else{
			ans++;
			No++;
		}
	}
	if (ans==0){
		cout<<-1<<endl;
		return 0;
	}
	cout<<N-ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"	
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define mod2 998244353
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)	
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define read(a) ll a; cin >> a;
	#define reads(s) string s; cin >> s;
	#define readb(a, b) ll a, b; cin >> a >> b;
	#define readc(a, b, c) ll a, b, c; cin >> a >> b >> c;
	#define readarr(a, n) int a[(n) + 1] = {}; forab(i, 0, (n-1)) {cin >> a[i];}
	#define readmat(a, n, m) int a[n + 1][m + 1] = {}; forab(i, 1, n) {forab(j, 1, m) cin >> a[i][j];}
	#define readv(A,n) vll A(n,0); forn(i,n) cin>>A[i]; 
	#define print(a) cout << a << endl;
	#define printarr(a, n) forab (i, 1, n) cout << a[i] << " "; cout << endl;
	#define printv(v) for (int i: v) cout << i << " "; cout << endl;
	#define printmat(a, n, m) forab(i, 1, n) {forab (j, 1, m) cout << a[i][j] << " "; cout << endl;}
	 
	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	bool isPowerOfTwo(int x) {
    return x && (!(x & (x - 1)));
	}
	int takemod(int x) {
    return (x % mod + mod) % mod;
	}
 
	int fpow(int base, int power, int MOD) {
    int result = 1;
    base = base % MOD;
    while (power) {
        if (power & 1)
            result = (result * base) % MOD;
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result;
	}
 
	int modinv(int x) {return fpow(x, mod - 2, mod);}
	void solve()
	{
		ll a,b,c,k;
		vll A(3);
		cin>>A[0]>>A[1]>>A[2]>>k;
			if(A[2]>A[1]&&A[1]>A[0])
			{
				cout<<"Yes"<<endl;
				return;
			}
		forn(i,k)
		{
			if(A[1]<=A[0])
			{
				A[1]*=2;
			}
			else if(A[2]<=A[1])
			{
				A[2]*=2;
			}

			if(A[2]>A[1]&&A[1]>A[0])
			{
				cout<<"Yes"<<endl;
				return;
			}
		}
		if(A[2]>A[1]&&A[1]>A[0])
			{
				cout<<"Yes"<<endl;
				return;
			}
		cout<<"No"<<endl;
	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
		//cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		return 0;
	}

	
	

Measured memory_bytes: 3648
using System;
using System.Data;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Linq;


class Program
{
    static void Main()
    {
        int[] a = new int[10];
        for (int i = 0; i < 10; i++)
        {
            a[i] = int.Parse(Console.ReadLine());
        }
        Array.Sort(a);
        Array.Reverse(a);
        for (int i = 0; i < 3; i++)
        {
            Console.WriteLine(a[i]);
        }
    }
}

Measured memory_bytes: 5756
import java.util.Scanner;
import java.util.Arrays;
public class Main{
public static void main(String args[]){
int N = 0;
int L[] = new int[200];
int ans = 0;
Arrays.fill(L, 1000);

Scanner scan = new Scanner(System.in);
N = scan.nextInt();
for(int i=0;i<2*N;i++){
L[i] = scan.nextInt();
}
Arrays.sort(L);
for(int i=0;i<2*N;i=i+2){
ans = ans+L[i];
}
System.out.println(ans);
}
}

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

using namespace std;

const int N = 100000 + 3;

int n, m;
bool vis[N];
vector<int> edges[N];
vector<int> topsorted;

//Tarjan topological sort
void dfs(int node) {
  if(vis[node]) return;
  vis[node] = true;
  //dont push here
  for(int adj: edges[node]) dfs(adj);
  //push here instead
  topsorted.push_back(node);
}

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

  for(int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    --u; --v;
    edges[v].push_back(u);
  }

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

  //for(int x: topsorted) cout << x + 1 << " "; cout << endl;

  vector<int> dp(n, 0);
  for(int v: topsorted) {
    for(int u: edges[v]) {
      dp[v] = max(dp[v], dp[u] + 1);
    }
  }

  int ans = 0;
  for(int x: dp) ans = max(ans, x);

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11256
#include <stdio.h>
#include <stdlib.h>
void YesOrNo( int * combination, int * array_a , int * array_m, int * ans, int number_a, int number_m )
{
        int sum = 0;
        int i = 0, j = 0;
        for ( i = 0 ; i < number_m ; i++ )
        {
                sum = 0;
                for ( j = 0 ; j < number_a ; j++ )
                {
                        sum = sum + combination[j] * array_a[j];
                }

                if ( sum == array_m[i] )
                {
                        ans[i] = ans[i] + 1;
                    
                }
        }
}


void Recycle( int * combination, int * array_a, int * array_m, int * ans, int status, int number_a, int number_m )
{
        if ( status < 0 )
        {
                YesOrNo( combination, array_a, array_m, ans, number_a, number_m );
        }
        else
        {
                combination[status] = 1;
                Recycle( combination, array_a, array_m, ans, status - 1, number_a, number_m );
                combination[status] = 0;
                Recycle( combination, array_a, array_m, ans, status - 1, number_a, number_m );
        }
}

int main()
{
        int number_a, number_m;
        scanf( "%d", &number_a );
        int array_a[number_a];
        int combination[number_a];
        int i = 0;
        for ( i = 0 ; i < number_a ; i++ )
        {
                scanf( "%d", &array_a[i] );
        }

        scanf( "%d", &number_m );
        int array_m[number_m];
        int ans[number_m];
        for ( i = 0 ; i < number_m ; i++ )
        {
                scanf( "%d", &array_m[i] );
                ans[i] = 0;
        }

        Recycle( combination, array_a, array_m, ans, number_a, number_a, number_m );
        for ( i = 0 ; i < number_m ; i++ )
        {
                if ( ans[i] > 0 )
                {
                        fprintf( stdout, "yes\n" );
                }
                else
                {
                        fprintf( stdout, "no\n" );
                }
        }
        return 0;
}

Measured memory_bytes: 576
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();  
        int N = r.i();
        String s = r.s();
        int rn = 0;
        for(int i = 0; i < N; i++)
            if(s.charAt(i) == 'R')
                rn++;
        println(N/2 < rn ? "Yes" : "No");
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}


Measured memory_bytes: 20564
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0075
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = "";
            while((str = Console.ReadLine()) != null)
            {
                double[] num = str.Split(',').Select(double.Parse).ToArray();
                double s = num[0];
                double w = num[1];
                double h = num[2];
                double BMI = w / Math.Pow(h, 2);

                if (BMI>=25)
                {
                    Console.WriteLine(s);
                }
            }
        }
    }
}



Measured memory_bytes: 18408
fn main() {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: i64 = s.next().unwrap().parse().unwrap();
	let x: i64 = s.next().unwrap().parse().unwrap();
	let d: i64 = s.next().unwrap().parse().unwrap();

	if d == 0 {
		println!("{}", if x == 0 { 1 } else { n + 1 });
		return;
	}

	let mut mp = std::collections::BTreeMap::new();
	for k in 0..n + 1 {
		let l = k * (k - 1) / 2;
		let r = k * (n - 1 + n - k) / 2;
		let rem = (k * x % d + d.abs()) % d;
		mp.entry(rem).or_insert(vec![]).push(((k * x - rem) / d + l, (k * x - rem) / d + r));
	}
	let mut ans = 0;
	for (_, vec) in mp.iter() {
		let mut ev = vec.iter().flat_map(|&(l, r)| vec![(l, 1), (r + 1, -1)]).collect::<Vec<(i64, i64)>>();
		ev.sort();
		ans += ev.into_iter().fold((0, 0, 0), |s, (p, cnt)|{
			(s.0 + if s.1 != 0 { p - s.2 } else { 0 }, s.1 + cnt, p)
		}).0;
	}
	println!("{}", ans);
}


Measured memory_bytes: 37116
import sys
readline = sys.stdin.readline

class Dualsegtree:
    def __init__(self, A, intv, initialize = True):
        self.N = len(A)
        self.N0 = 2**(self.N-1).bit_length()
        self.intv = intv
        if initialize:
            self.data = [intv]*self.N0 + A + [intv]*(self.N0 - self.N)
            for i in range(self.N0-1, 0, -1):
                self.data[i] = self.segf(self.data[2*i], self.data[2*i+1]) 
        else:
            self.data = [intv]*(2*self.N0)
    
    def segf(self, a, b):
        return min(a, b)
    
    def query(self, k):
        k += self.N0
        s = self.data[k]
        while k > 0:
            k >>= 1
            s = self.segf(s, self.data[k])
        return s
    
    def update(self, l, r, x):
        L, R = l+self.N0, r+self.N0
        while L < R:
            if R & 1:
                R -= 1
                self.data[R] = x
            if L & 1:
                self.data[L] = x
                L += 1
            L >>= 1
            R >>= 1

N, Q = map(int, readline().split())
INF = 10**9+7
H, W = Dualsegtree([N-1]*(N-1), INF, initialize = True), Dualsegtree([N-1]*(N-1), INF, initialize = True)

ans = 0


mw = N
mb = N

for _ in range(Q):
    t, x = map(int, readline().split())
    x -= 1
    if t == 1:
        st = H.query(x)
        ans += st-1
        if mw > x:
            mw = x
            W.update(0, st, x)
    else:
        st = W.query(x)
        ans += st-1
        if mb > x:
            mb = x
            H.update(0, st, x)
print((N-2)*(N-2)-ans)

Measured memory_bytes: 108972
from functools import lru_cache
import math

K = int(input())

M = [[math.gcd(i,j) for i in range(0, K+1)] for j in range(0,K+1)]
# @lru_cache(maxsize=4095)
# def gcd(a,b,c):
#     return math.gcd(math.gcd(a,b), c)
res = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            res += M[i][M[j][k]]
print(res)

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

int main(){
	int H, W;
	while(1){
	cin >> H >> W;
	if( H == 0 && W == 0 ) return 0;
	for( int i = 0; i < H; i++ ){ for( int j = 0; j < W; j++){cout << "#";} cout << "\n";}
	cout << endl;
	}
return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll c[2005][2005];
const ll mod=1e9+7;

int main()
{
    c[0][0]=1;
    for(int i=1;i<=2000;i++)
    {
        c[i][0]=1;
        for(int j=1;j<=i;j++)
        {
            c[i][j] = c[i-1][j-1]+c[i-1][j];
            c[i][j]%=mod;
        }
    }

    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=k;i++)
    {
        ll ans=c[k-1][i-1]*c[n-k+1][i]%mod;
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 30080