akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

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

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

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


#define y0 y3487465
#define y1 y8687969

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

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

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

int N, K;
string S;

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

  if(S[K - 1] == 'A') S[K - 1] = 'a';
  else if(S[K - 1] == 'B') S[K - 1] = 'b';
  else S[K - 1] = 'c';

  cout << S << endl;

  return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/agc024/tasks/agc024_d
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

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


fn doit(g: &Vec<Vec<usize>>, roots: Vec<usize>) -> (i64, i64) {
    let n = g.len();
    let mut deq = VecDeque::new();
    let mut ccnt = 1;
    if roots.len() == 1 {
        deq.push_back((roots[0], n));
    } else {
        deq.push_back((roots[0], roots[1]));
        deq.push_back((roots[1], roots[0]));
        ccnt = 2;
    }

    let mut depth = 0;
    loop {
        depth += 1;
        let mut next_deq = VecDeque::new();
        let mut max_children = 0;
        for (v, par) in deq {
            let mut cn = 0;
            for &t in &g[v] {
                if t == par {
                    continue;
                }
                cn += 1;
                next_deq.push_back((t, v));
            }
            max_children = max(cn, max_children);
        }
        if max_children == 0 {
            break;
        }
        ccnt *= max_children;
        deq = next_deq;
    }
    return (depth, ccnt);
}

fn main() {
    input! {
        n: usize,
        edges: [(usize1, usize1); n-1]
    };

    let mut g = vec![vec![]; n];
    for &(u, v) in &edges {
        g[u].push(v);
        g[v].push(u);
    }

    let mut dls = vec![];
    for i in 0..n {
        let (d, l) = doit(&g, vec![i]);
        dls.push((d, l));
    }
    for &(u, v) in &edges {
        let (d, l) = doit(&g, vec![u, v]);
        dls.push((d, l));
    }

    let mut depth = 100000;
    let mut leaf = 0;
    for (d, l) in dls {
        if d < depth || (d == depth && l < leaf) {
            depth = d;
            leaf = l;
        }
    }


    println!("{} {}", depth, leaf);
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stack>
#include<map>
#include<queue>
#include<vector>
#include<cmath>
#include<set>

const int maxn=1e5+5;

using namespace std;

char s[5];

int main()
{
    scanf("%s",&s);
    if(s[0]==s[1]&&s[0]==s[2])
        printf("No\n");
    else
        printf("Yes\n");
}

Measured memory_bytes: 128
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: f64,
        m: f64,
        d: f64
    }
    println!(
        "{}",
        if d == 0f64 {
            (m - 1f64) / n
        } else {
            2f64 * (m - 1f64) / n * (n - d) / n
        }
    );
}


Measured memory_bytes: 2156
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

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

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

string s[50];
set<string> ss;

signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase >= 0;testcase++){
    int(n);
    if(!n)break;
    scn(n, s);
    rep1(k, 60){
      bool fl = true;
      ss.clear();
      rep(i, n){
        string t;
        t += s[i][0];
        int cnt = 1;
        rep1(j, s[i].size()){
          if(k == cnt)break;
          if(s[i][j - 1] == 'a' || s[i][j - 1] == 'i' || s[i][j - 1] == 'u' ||
           s[i][j - 1] == 'e' || s[i][j - 1] == 'o'){
            t += s[i][j]; cnt++;
          }
        }
        if(ss.find(t) == ss.end())ss.insert(t);
        else{ fl = false; break; }
      }
      if(!fl)continue;
      if(i == n)break;
    }
    if(k == 60)pri(-1);
    else pri(k);
  }
  return 0;
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n; cin>>n;
	string s; cin>>s;
	n-=2;
	int ans=0;
	rep(i,0,n){
		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
			ans++;
		}
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3540
#include <iostream>
#include <vector>
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define INF 999999999
using namespace std;

int  main(){
          int N;
          cin >> N;
          vector<int> v;
          REP(i,N){
                    int z;
                    cin >> z;
                    z--;
                    v.push_back(z);
          }

          int now=0,c=0;
          for ( ; ; ){
                    if (now == 1){
                              cout << c << endl;
                              break;
                    }
                    if (c >= N){
                              cout << -1 << endl;
                              break;
                    }
                    c++;
                    now = v[now];
          }
          return 0;
}


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

int N;
int x[10], y[10];

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

void solve() {
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> x[i] >> y[i];
    }
    double sum = 0.0;
    vector<int> v(N);
    for (int i = 0; i < N; i++) {
        v[i] = i + 1;
    }

    do {
        for (int i = 0; i < N - 1; i++) {
            sum += dist(v[i], v[i + 1]);
        }
    } while (next_permutation(v.begin(), v.end()));

    int Factorial = 1;
    for (int i = 2; i <= N; i++) Factorial *= i;
    cout << fixed << setprecision(10) << sum / Factorial << endl;
}
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 4184
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

ll powMod(ll x, ll n) {
  if (n == 0) return 1;
  ll r = powMod(x, n / 2);
  if (n % 2 == 0) return (r * r) % MOD;
  return (r * r % MOD) * x % MOD;
}

int main(void) {

  int h, w, n;
  cin >> h >> w >> n;
  int x = max(h, w);
  if (n % x == 0) cout << n / x << endl;
  else cout << n / x + 1 << endl;

  return 0;

}
  


Measured memory_bytes: 256
n = list(input())

if len(n) == 1:
    print(n[0])
elif n[0] == '1':
    if n.count('9') == len(n) - 1:
        print(1 + 9 * (len(n) - 1))
    else:
        print(9 * (len(n) - 1))
elif n.count('9') == len(n):
    print(9 * len(n))
elif n.count('9') == len(n) - 1:
    if n[0] != '9':
        print((int(n[0])) + (9 * (len(n) - 1)))
    else:
        print(9 * (len(n) - 1) + 8)
else:
    print((int(n[0]) - 1 ) + (9 * (len(n) - 1))) 

Measured memory_bytes: 9232
// ------------------------------------
// Date:2018/ 3/ 8
// Problem:Tenka1ProgrammerContest 4 /N c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

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

  ll N;
  cin >> N;
  
  FOR(hi, 1, 3501) {
    FOR(ni, 1, 3501) {
      ll tmp1 = N * hi * ni;
      ll tmp2 = 4 * hi * ni - N * ni - N * hi;
      if (tmp2 == 0) continue;
      if (not(tmp1 % tmp2 == 0)) continue;
      ll w = tmp1 / tmp2;
      // w
      if (w > 0 and w <= 3500) {
	// ok
        cout << hi << " " << ni <<  " " << w << endl;
	return 0;
	}
    }
  }
  
  return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int main()
{
    int n,w;
    cin>>n>>w;
    int weight[n],value[n];
    REP(i,n)cin>>weight[i]>>value[i];
    vector<vector<ll>>dp(n+1,vector<ll>(w+1,0));
    REP(i,n)
        for(int j=0;j<=w;j++)
            dp[i+1][j]=j>=weight[i]?max(dp[i][j],dp[i][j-weight[i]]+value[i]):dp[i][j];
    cout<<dp[n][w]<<endl;
}

Measured memory_bytes: 80256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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



int main() {
  int x, a, b;
  cin >> x >> a >> b;

  if(a >= b) cout << "delicious" << endl;
  else if(b-a <= x) cout << "safe" << endl;
  else cout << "dangerous" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
using namespace std;

int main() {
    char a;
    cin >> a;
    if (isupper(a)) {
        cout << "A" << endl;
    } else {
        cout << "a" << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
const ll MAX = 1000000000000 + 10;


int main() {
    ll h;
    cin >> h;
    vector<ll> dp = { 0,1 };
    ll i = 1;

    for (i = 1; (ll)1<<i <= h; i++)
    {
        dp.push_back(1 + dp[i] + dp[i]);
    }
    cout << dp[i] << endl;
    return 0;
}

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int n, m, q;
vector<int> as, bs, cs, ds;
vector<int> arr;
int func(int num, int idx){
    if(idx == (int)arr.size()){
        int ret = 0;
        for(int i = 0; i < q; i++){
            if(arr[bs[i] - 1] - arr[as[i] - 1] == cs[i]){
                ret += ds[i];
            }
        }
        return ret;
    }
    arr[idx] = num;
    int maxi = 0;
    for(int i = num; i <= m; i++){
        maxi = max(maxi, func(i, idx + 1));
    }
    return maxi;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> n >> m >> q;
    arr.resize(n);
    as.resize(q), bs.resize(q), cs.resize(q), ds.resize(q);
    for(int i = 0; i < q; i++){
        cin >> as[i] >> bs[i] >> cs[i] >> ds[i];
    }
    cout << func(1, 0) << '\n';
}


Measured memory_bytes: 3192
n = gets.chomp.to_i

s = []
p = []
cities = {}

n.times{|i|
  sp = gets.chomp.split(' ')
  s[i] = sp[0]
  p[i] = sp[1].to_i
  cities[s[i]] = [] if cities[s[i]].nil?
  cities[s[i]].push([i, p[i]])
}

cities.keys.sort.each{|c|
  cities[c].sort{|a, b| b[1] <=> a[1] }.each{|e| puts e[0] + 1 }
}


Measured memory_bytes: 1788
n = gets.to_i
a = gets.split.map(&:to_i)

print a.join(" "), "\n"
(1..(n-1)).each do |i|
	key = a[i]
	j = i
	while (j-=1) >= 0 && a[j] > key do
		a[j+1] = a[j]
	end
	a[j+1] = key
	print a.join(" "), "\n"
end

Measured memory_bytes: 6108
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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 x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  ll n,d,a;
  cin>>n>>d>>a;

  map<ll,ll> mon;
  set<ll> za;
  rep(i,n){
    ll x,h;
    cin>>x>>h;
    ll kai=(h+a-1)/a;
    mon[x]=kai;
    za.insert(x);
    za.insert(x+2*d+1);
  }

  vector<ll> ba;
  for(auto z : za){
    ba.pb(z);
  }
  
  sort(all(ba));

  map<ll,ll> gen;

  ll ans=0;
  ll now=0;
  rep(i,ba.size()){
    if(gen.count(ba[i])) {
      now-=gen.at(ba[i]);
    }
    if(mon.count(ba[i])) {
      ll bom=max(0ll,mon.at(ba[i])-now);
      ans+=bom;
      gen[ba[i]+2*d+1]=bom;
      now+=bom;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 49932
<?php
$ans = 1;
fscanf(STDIN, "%d %d", $D, $N);

if($N != 100){
	if($D>0){
		for($i=0;$i<$D;$i++){
				$ans = $ans * 100;
		}
		$ans = $ans * $N;
	}else{
			$ans = $N;
	}
}else{
	if($D>0){
		for($i=0;$i<$D;$i++){
				$ans = $ans * 100;
		}
		$ans = $ans * ($N+1);
	}else{
			$ans = $N+1;
	}
}
echo $ans;
?>

Measured memory_bytes: 4728
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<iostream> 
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define ll long long
#define ull unsigned long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define lowbit(x) (x& -x)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define eps 1e-18
#define maxn 100010
inline ll read(){ll tmp=0; char c=getchar(),f=1; for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1; for(;'0'<=c&&c<='9';c=getchar())tmp=(tmp<<3)+(tmp<<1)+c-'0'; return tmp*f;}
inline ll power(ll a,ll b){ll ans=1; for(;b;b>>=1){if(b&1)ans=ans*a%mod; a=a*a%mod;} return ans;}
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void swap(int &a,int &b){int tmp=a; a=b; b=tmp;}
using namespace std;
int x[110],y[110],d[110];
int a[30],base[30];
int n,m,l;
int main()
{
    l=read();
    if(l<=2){//特判是因为若l<=2，下面建图是时图只有一个点，无法连边
        printf("2 %d\n",l);
        for(int i=0;i<l;i++)
            printf("1 2 %d\n",i);
        return 0;
    }
    int len=0;
    while(1<<len<=l)++len;
    n=len; m=0;
    for(int i=0;i<len-1;i++){//二进制拆分
        x[++m]=i+1; y[m]=i+2; d[m]=0;
        x[++m]=i+1; y[m]=i+2; d[m]=1<<i;
    }
    for(int i=len-2;i>=0;i--)
        if(l&(1<<i)){//其实和数位dp一样啦
            x[++m]=i+1; y[m]=n; d[m]=l>>(i+1)<<(i+1);
        }
    printf("%d %d\n",n,m);
    for(int i=1;i<=m;i++)
        printf("%d %d %d\n",x[i],y[i],d[i]);
    return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
import fractions

from math import factorial
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

def main():
    _,P = map(int, input().split())
    A = list(map(int, input().split()))
    even = 0
    odd = 0
    for a in A:
        if a%2 == 0:
            even += 1
        else:
            odd += 1
    x = 0
    if P==0:
        for i in range(0,odd+1,2):
            x += combinations_count(odd, i)
        print(2**even*x)
    else:
        for i in range(1,odd+1,2):
            x += combinations_count(odd, i)
        if x == 0:
            print(0)
        else:
            print(2**even*x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5048
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll n,m,s=0; cin>>n>>m;
	vector<ll> arr(n);
	for(auto i=0;i<n;++i){
		cin>>arr[i];
		s+=arr[i];
	}
	ll cnt=0;
	for(auto i=0;i<n;++i){
		if(arr[i]*4*m>=s){
			++cnt;
		}
	}
	if(cnt>=m)cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}


int main(){
 int N,M;
 cin >> N >> M;
 vector<vector<int>> S(M);
 vector<int> L(M);
 for(int i = 0;i < M;i++){
    int k;cin >> k;
    L[i] = k;
    for(int j = 0;j < k;j++){
       int a;cin >> a;
       S[i].push_back(a);
    }
 }
 vector<int> P(M);
 for(int i = 0;i < M;i++){
    cin >> P[i];
 }
 for(int i = 0;i < M;i++){
    //cout << P[i];
 }
 //cout << endl;
 int ans = 0;
 for(int i = 0;i < (1 << N);i++){
    bitset<10> B(i);
    vector<int> cnt(M,0);
    //cout << B << endl;
   for(int j = 0;j < M;j++){
      for(int k = 0;k < L[j];k++){
         if(B.test(S[j][k]-1)){
            cnt[j]++;
         }
      }
   }
   bool frag = 1;
   for(int j = 0;j < M;j++){
      if(cnt[j] % 2 != P[j]){
         frag = 0;
      }
     // cout << cnt[j] % 2;
   }
   //cout << endl;
   if(frag){
      //cout <<  '/' << B << endl;
      ans++;
   }
 }
 cout << ans << endl;
}


Measured memory_bytes: 256
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const K = Number(input[0][0]);
  const [A, B] = input[1].map(Number);

  for (let i = A; i <= B; i++) {
    if (i % K === 0) {
      return "OK";
    }
  }

  return "NG";
};

console.log(main(read()));


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

int main(){
    int n; cin >> n;
    vector<ll> lis(n);
    for(int i = 0; i < n; i++){
        cin >> lis[i];
    }
    sort(lis.begin(), lis.end(), greater<>());
    ll max1 = 0, max2 = 0;
    for(int i = 0; i < n-1; i++){
        if(max1 == 0 && lis[i] == lis[i+1]){
            max1 = lis[i];
            i += 2;
        }
        if(i > n-1){break;}
        if(max2 == 0 && lis[i] == lis[i+1]){
            max2 = lis[i];
        }
    }
    cout << max1 * max2 << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void) {
  int n;
  cin >> n;
  vector<int> v(n),c(n);
  for(auto &x: v) cin >> x;
  for(auto &x: c) cin >> x;
  int answer = 0;
  REP(i,n) answer += max(0, v[i]-c[i]);
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <float.h>
using namespace std;
typedef long long ll;
#define loop(i, N) for(int i=0; i<N; ++i)


int main(void) {
	int n;
	double v[60];
	cin >> n;
	loop(i, n) cin >> v[i];

	sort(v, v + n, greater<double>());
	for (int i = n-2; i >= 0; i--)
	{
		v[i] = (v[i] + v[i + 1]) / 2.0;
	}
	cout << v[0] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a;
deque < long long > a2;
long long ans=1;
int main()
{
	long long n;
	cin>>n;
	for(long long i=0;i<n;i++)
	{
		cin>>a;
		a2.push_back(a);
		if(a==0)
		{
			cout<<"0"<<endl;
			return 0;
		} 
	}
	while(a2.size()!=0)
	{
		if(a2[0]>1000000000000000000/ans)
		{
			cout<<"-1"<<endl;
			return 0;
		}
		ans*=a2[0];
		a2.pop_front();
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4240
a, b, k, = map(int, input().split())

if a > 0 and k > 0:
    eat = a
    if a > k:
        eat = k
    a -= eat
    k -= eat

if b > 0 and k > 0:
    eat = b
    if b > k:
        eat = k
    b -= eat
    k -= eat

print("{} {}".format(a, b))

Measured memory_bytes: 9156
s = input()

ans = True
for i in range(len(s)):
    if i % 2 == 1 and s[i] == 'R':
        ans = False
        break
    elif i % 2 == 0 and s[i] == 'L':
        ans = False
        break

if ans:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int gcd(int m,int n){
  if(n==0)
    return m;
  else
    return gcd(n,m%n);
}

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int g = gcd(a,b);
  if(c%g==0){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }

  return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    int arr[n+k+1];
    int dp[n+k+1];
    for(int i=0; i<=k+1; i++)
        dp[i] = 0;

    for(int i=k+1; i<=k+n; i++)
    {
        cin >> arr[i];
    }
    dp[k+2] = abs(arr[k+2]- arr[k+1]);
    for(int i=k+3; i<=k+n; i++)
    {
        dp[i] = dp [i-1] + abs(arr[i] - arr[i-1]);
        for(int j=2; j<=k; j++)
        {
            int x = i-j;
            if(x>=k+1)
                dp[i] = min(dp[i], dp[x]+abs(arr[i]- arr[x]));
        }
    }
    cout << dp[k+n] << endl;
    return 0;
}




Measured memory_bytes: 1024
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

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

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

fn main() {
    input! {
        n: usize,
    }
    let prod = n / 100;
    println!("{}", if (n - prod * 100) <= 5 * prod { 1 } else { 0 });
}


Measured memory_bytes: 4352
from collections import defaultdict
from itertools import accumulate
N, W = map(int, input().split())
w = [0] * N; v = [0] * N
d = defaultdict(list)
for i in range(N):
    w[i], v[i] = map(int, input().split())
    d[w[i]].append(v[i])

for i in range(4):
    d[w[0]+i].sort(reverse=True)
    d[w[0]+i].insert(0, 0)
    d[w[0]+i] = list(accumulate(d[w[0]+i]))


ans = 0
for i in range(len(d[w[0]])):
    for j in range(len(d[w[0]+1])):
        for k in range(len(d[w[0]+2])):
            for l in range(len(d[w[0]+3])):
                if i * w[0] + j * (w[0] + 1) + k * (w[0] + 2) + l * (w[0] + 3) <= W:
                    ans = max(ans, d[w[0]][i] + d[w[0]+1][j] + d[w[0]+2][k] + d[w[0]+3][l])
print(ans)


Measured memory_bytes: 3316
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) printf("Case #%d: ",i);
using namespace std;
typedef long long int ll;
typedef complex<double> com;
typedef pair<int, int> P;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main(){
	int n, m, r; cin >> n >> m >> r;
	vector<int> a(r);
	rep(i, 0, r) cin >> a[i];
	sort(a.begin(), a.end());
	vector<vector<ll>> dist(n);
	rep(i, 0, n) dist[i].resize(n, INF);
	rep(i, 0, m) {
		int p1, p2, p3; cin >> p1 >> p2 >> p3;
		dist[p1 - 1][p2 - 1] = p3;
		dist[p2 - 1][p1 - 1] = p3;
	}
	rep(k, 0, n)rep(i, 0, n)rep(j, 0, n) {
		dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
	}
	ll ans = INF;
	do
	{
		ll sub = 0;
		rep(i, 0, r - 1) sub += dist[a[i] - 1][a[i + 1] - 1];
		ans = min(ans, sub);
	} while (next_permutation(a.begin(),a.end()));
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>

using namespace std;

int main(){
    long long N;
    cin >> N;
    long long ans=0;
    vector<long long> v(5,0);
    for(int i=0;i<5;i++){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    int nannka=0;
    if(N%v[0]!=0){
        N-=N%v[0];
        nannka++;;
    }
    ans=N/v[0]+4+nannka;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int n;
vector<int> ans;

int main(){
	cin >> n;
	for(int i = 0;i < n; i++){
		int y,m,d;
		int count=0;
		cin >> y >> m >> d;
		
		if(y % 3 == 0){
			count += 20 - d + 1;
			count += 20*(10 - m);
 		}else{
 			if(m % 2 == 1){
 				count += 20 - d + 1;
 			}else{
 				count += 19 - d + 1;
 			}
 			for(int i = m+1; i <= 10;i++){
 				if(i % 2 == 1){
 					count += 20;
 				}else{
 					count += 19;
 				}
 			}
 		}
 		for(int i = y + 1;i < 1000;i++){
 			if(i % 3 == 0){
 				count += 200;
 			}else{
 				count += 195;
 			}
 		}
		ans.push_back(count);
	}
	for(int i = 0;i < ans.size();i++) cout << ans[i] << endl;
}

Measured memory_bytes: 3088
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		ArrayList<Long> maxOptions = new ArrayList<Long>();
		int X = input.nextInt();
		int Y = input.nextInt();
		int A = input.nextInt();
		int B = input.nextInt();
		int C = input.nextInt();
		long[] a = new long[A];
		long[] b = new long[B];
		long ans = 0;
		for (int i = 0; i < A; i++) {
			a[i] = input.nextLong();
		}
		for (int i = 0; i < B; i++) {
			b[i] = input.nextLong();
		}
		for (int i = 0; i < C; i++) {
			maxOptions.add(input.nextLong());
		}
		Arrays.sort(a);
		Arrays.sort(b);
		for (int i = A-1; i >=A-X; i--) {
			maxOptions.add(a[i]);
		}
		for (int i = B-1; i >=B-Y; i--) {
			maxOptions.add(b[i]);
		}
		Collections.sort(maxOptions);
		for (int i = maxOptions.size()-1; i >= maxOptions.size()-X-Y; i--) {
			ans+=maxOptions.get(i);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 95872
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
const int oo=2139063143;
const int N=1010000;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<20|1],*p1=buf,*p2=buf,obuf[1<<20|1],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar(' '); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }
int n;
#define pb push_back
vector <int> G[N];
int calc (int u,int fa,int x)
{
	if (u> x) return 0;
	int ans=1;
	for (int v:G[u]) if (v!=fa)
		ans+=calc (v,u,x);
	return ans;
}
int ma[N],f[N],g[N],s[N];
void dfs0 (int u,int fa)
{
	ma[u]=max (u,ma[fa]);
	for (int v:G[u]) if (v!=fa)
		dfs0 (v,u);
	if (u==ma[u])//u为前缀最大值
	{
		s[u]=1;
		for (int v:G[u]) if (v!=fa)
		{
			f[v]=calc (v,u,u);
			g[v]=calc (v,u,ma[fa]);
			s[u]+=g[v];
		}
	}
}
int ans[N];
void dfs1 (int u,int fa)
{
	for (int v:G[u]) if (v!=fa)
	{
		ans[v]=ans[u];
		if (v==ma[v]) ans[v]+=s[v];
		else if (u==ma[u]) ans[v]+=f[v]-g[v];
		dfs1 (v,u);
	}
}

int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	sc(n);
	for (int i=1; i< n; i++)
	{
		int x,y; sc(x),sc(y);
		G[x].pb (y),G[y].pb (x);
	}
	dfs0 (1,0),dfs1 (1,0);
	for (int i=2; i<=n; i++)
		pr(ans[i]);

    return 0;
}


Measured memory_bytes: 61568
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>

using namespace std;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,int> pli;
typedef pair<lli,lli> pll;

char str[30];
int n,arr[30];

int main() {
	scanf("%s",str);
	n=strlen(str);
	for(int i=0;i<n;i++) arr[str[i]-'a']++;
	
	int c=0;
	for(int i=0;i<26;i++) if(arr[i]) c++;

	if(c!=26) {
		for(int i=0;i<26;i++) if(!arr[i]) {
			printf("%s%c\n",str,i+'a');
			return 0;
		}
	}
	else {
		arr[str[25]-'a']--;
		for(int i=24;i>=0;i--) {
			if(str[i] < str[i+1]) {
				for(int j=0;j<i;j++) printf("%c",str[j]);
				for(int j=0;j<26;j++) if(!arr[j] && str[i]-'a' < j) {
					printf("%c",j+'a');
					return 0;
				}
			}
			arr[str[i]-'a']--;
		}
		puts("-1");
	}
	return 0;
}


Measured memory_bytes: 256
N = gets.to_i
as = gets.split.map &:to_i
#p "as = #{as}"
bs = Array.new(N+1,0)
bs[N] = as[N-1]
(N-1).downto(1){|i|
    now_index = 2 * i
    sum = 0
    while now_index <= N
       sum += bs[now_index]
       now_index += i
    end
    if sum % 2 == as[i-1]
        bs[i] = 0
    else
        bs[i] = 1
    end
}

m = bs.count(1)
if m == 0
    puts 0
else
    puts m
    list = []
    bs.each.with_index(0){|k,index|
        list.push(index) if k == 1
    }
    puts list.join(" ")
end

Measured memory_bytes: 22084
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    boolean[] col = new boolean[8];
    int sp = 0;
    for (int i = 0; i < n; i++) {
      int k = sc.nextInt();
      if (k < 400) {
        col[0] = true;
      } else if (k < 800) {
        col[1] = true;
      } else if (k < 1200) {
        col[2] = true;
      } else if (k < 1600) {
        col[3] = true;
      } else if (k < 2000) {
        col[4] = true;
      } else if (k < 2400) {
        col[5] = true;
      } else if (k < 2800) {
        col[6] = true;
      } else if (k < 3200) {
        col[7] = true;
      } else {
        sp++;
      }
    }
    int min = 0;
    for (boolean c : col) {
      min += c ? 1 : 0;
    }
    System.out.println(Math.max(1, min) + " " + (min + sp));
  }
}

Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

template<class T> inline bool chMax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b){ if (a > b) { a = b; return true; } return false; }

int main(){
	ll N, T;
	vector<pair<ll, ll>> keiro;
	cin >> N >> T;

	rep(i, 0, N){
		ll temp1, temp2;
		cin >> temp1 >> temp2;
		keiro.push_back(make_pair(temp1, temp2));
	}
	sort(begin(keiro), end(keiro));
	rep(i, 0, N){
		if (keiro[i].second <= T){
			cout << keiro[i].first << endl;
			return 0;
		}
	}
	cout << "TLE" << endl;
	return 0;
}


Measured memory_bytes: 384
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let N = lines.shift().split(/\s/).map((v) => v - 0)[0];
    if (N == 1) {
        console.log("Hello World");
    } else {
        let A = lines.shift().split(/\s/).map((v) => v - 0)[0];
        let B = lines.shift().split(/\s/).map((v) => v - 0)[0];
        console.log(A + B);
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
import numpy as np

N = int(input())
an = list(map(int,input().split()))

for i in range(N):
    an[i] = an[i] - (i+1)
    
b = int(np.median(an))

k = []
for i in range(N):
    y = abs(an[i] - b)
    k.append(y)
ans = sum(k)

print(ans)
    

Measured memory_bytes: 49484
#include <cstdio>
int q1, b, c1, c2, q2;
int main() {
  while (scanf("%d", &q1)) {
	if (q1 == 0) break;
	scanf("%d%d%d%d",&b,&c1,&c2,&q2);
	int jidori = b / c1;
	jidori = (jidori < q2 ? jidori : q2);
	b -= jidori * c1;
	int normal = b / c2;
	b -= normal * c2;
	while (jidori + normal < q1) {
	  if (jidori <= 0) break;
	  jidori--; b += c1;
	  int temp = b / c2;
	  normal += temp;
	  b -= c2 * temp;
	}
	if (jidori <= 0) puts("NA");
	else printf("%d %d\n",jidori,normal);
  }
}

Measured memory_bytes: 1040
n = int(input())
x = [int(i) for i in input().split()]
sx = sorted(x)
s1, s2 = sx[n//2-1], sx[n//2]
m = (s1 + s2) / 2
for i in x:
    if m > i: print(s2)
    else: print(s1)


Measured memory_bytes: 25220
import itertools
N = input()
l = list(map(int,input().split(" ")))
l.sort(reverse=True)
N = int(N)
i = 0
hen =[]

while True:
    if i >= N-1 or len(hen) == 2:
        break
    if l[i] == l[i+1]:
        hen.append(l[i])
        i+=1
    i+= 1

if len(hen )< 2:
    print(0)
else:
    print(hen[0]*hen[1])

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

int main() {
  vector<int> cnt(4);
  for (int i = 0; i < 6; ++i) {
    int n;
    cin >> n;
    cnt[--n]++;
  }

  int m = 0;
  for (auto c : cnt)
    m = max(m, c);

  if (m < 3)
    puts("YES");
  else
    puts("NO");
}

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

typedef long long ll;

const int MOD = 2019;


int main() {
    int l, r, res = MOD;
    
    cin >> l >> r;
    
    for(int i = 0; i < 2 * MOD && l + i <= r; i++) {
        for(int j = 0; j < 2 * MOD && l + j <= r; j++) {
            int x = l + i;
            int y = l + j;
            if(x != y) {
                res = min(res, ((x % MOD) * (y % MOD)) % MOD);
            }
        }
    }

    cout << res;
    
    return 0;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
long long n,x,ans=0;
vector<long long> a,pt;
int main(){
	long long i,pos;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>x;
		a.push_back(x);
	}
	for(i=0;i<n;i++)
	{
		pos=lower_bound(pt.begin(),pt.end(),a[i])-pt.begin();
		if(pos==0)
		{
			pt.insert(pt.begin(),a[i]);
		}
		else
		{
			pt[pos-1]=a[i];
		}
	}
	cout<<pt.size()<<endl;
	return 0;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ppb pop_back()
#define fi first
#define se second
#define pi pair<int, int>
#define rep(i, a, n) for(int i = a; i <= n; i++)
#define REP(i, a, n) for(int i = a; i < n; i++)
#define Y "Yes"
#define N "No"
using namespace std;

int T, n;

void solve() {
	cin >> n;
	if (n >= 30) cout << Y;
	else cout << N;
}
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	//freopen("in.txt", "r", stdin);

	///cin >> T;
	//while (T--) {
		solve();
		//cout << '\n';
	//}
}

Measured memory_bytes: 3608
#071_C
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = Counter(a).most_common()
edges = []
for l, cnt in c:
    if cnt < 2:
        break
    else:
        edges.append(l)
        if cnt > 3:
            edges.append(l)
edges.sort(reverse= True)
if len(edges) < 2:
    print(0)
else:
    print(edges[0] * edges[1])

Measured memory_bytes: 21668
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,h,m; cin >>a >>b >>h >>m;
  long double deg=abs(acos(-1)*(60*h-11*m)/360);
  cout <<fixed<<setprecision(10)<<sqrt(a*a+b*b-2*a*b*cos(deg));
return 0;}

Measured memory_bytes: 4152
#include<bits/stdc++.h>
using namespace std;
void shinobu(int a[],int n){
  for(int i=0;i<n;++i) cout<<a[i]<<(i==n-1?"\n":" ");
}
void bubbleSort(int a[],int n){
  int i,tmp,flag=1,cnt=0;
  while(flag){
    flag=0;
    for(i=n-1;i>0;--i){
      if(a[i]<a[i-1]){
	tmp=a[i];
	a[i]=a[i-1];
	a[i-1]=tmp;
	flag=1;
	cnt++;
      }
    }
  }
  shinobu(a,n);
  cout<<cnt<<endl;
}
int main(){
  int i,n,a[101];
  cin>>n;
  for(i=0;i<n;++i) cin>>a[i];
  bubbleSort(a,n);
  return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
#define int long long

signed main() {
  int n;
  cin >> n;
  int t[n + 1];
  t[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
    t[i] += t[i - 1];
  }

  int v[n];
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  int T = t[n] * 2;
  double f[n + 2][T + 1];
  for (int i = 0; i < n + 2; i++) {
    for (int j = 0; j < T + 1; j++) {
      if (i == 0) {
        f[i][j] = j / 2.0;
      } else if (i == n + 1) {
        f[i][j] = (T - j) / 2.0;
      } else {
        int l = t[i - 1] * 2;
        int r = t[i] * 2;
        if (j < l) {
          f[i][j] = v[i - 1] + (l - j) / 2.0;
        } else if (j > r) {
          f[i][j] = v[i - 1] + (j - r) / 2.0;
        } else {
          f[i][j] = v[i - 1];
        }
      }
    }
  }
  double V[T + 1];
  fill(V, V + T + 1, 1 << 29);
  for (int j = 0; j < T + 1; j++) {
    for (int i = 0; i < n + 2; i++) {
      V[j] = min(V[j], f[i][j]);
    }
  }
  double ans = 0.0;
  for (int i = 0; i + 1 < T + 1; i++) {
    ans += (V[i] + V[i + 1]) * 0.5 / 2;
  }
  printf("%.4f\n", ans);
  return 0;
}


Measured memory_bytes: 32384
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int          long long int
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     __gcd((a),(b))
#define     lcm(a,b)     ((a)*(b))/gcd((a),(b))
#define     pb           push_back
#define     ins          insert
#define     F            first
#define     S            second

const int inf=1e18,MOD=1e9+7;

int n,m;
vector<string> w;


void f(string s,int in)
{
 if(in==n-1)
 {
  w.pb(s);
  return;
 }

 f(s+"0",in+1);
 f(s+"1",in+1);
}

void solve()
{
 cin>>n>>m;

 vector<int> v[m],p(m);

 int k,x;
 for(int i=0;i<m;++i)
 {
  cin>>k;

  for(int j=0;j<k;++j)
  {
   cin>>x;
   v[i].pb(x);
  }
 }

 for(int i=0;i<m;++i)
 cin>>p[i];

 f("0",0);
 f("1",0);

 int sz=w.size(),sum,cnt,ans=0;
 for(int i=0;i<sz;++i)
 {
  cnt=0;
  for(int j=0;j<m;++j)
  {
   sum=0;
   for(auto c:v[j])
   sum+=w[i][c-1]-48;
   if(sum%2==p[j])
   ++cnt;
  }
  if(cnt==m)
  ++ans;//cout<<w[i]<<"\n";
 }

 cout<<ans;
}

int32_t main()
{
 //fast();

 int t=1;
 //cin>>t;
 while(t--)
 {
  solve();
 }

 return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int r = sc.nextInt();
		int D = sc.nextInt();
		int x = sc.nextInt();

		for (int i = 0; i < 10; i++) {
			x = r * x - D;
			System.out.println(x);
		}
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
  long n;
  cin >> n;
  long ans = 0;
  if(n%2==1)cout<<0;
  else{
    while(n>=10){
      ans+=n/10;
      n/=5;
    }
    cout<<ans;
  }
}


Measured memory_bytes: 256
n,a,b = (int(i) for i in input().split())
if a >b:
  print(0)
  exit()
elif n == 1 and a!=b:
  print(0)
  exit()
if n<= 2:
  print(1)
else:
  mi = a*(n-1)+b
  ma = a+(n-1)*b
  print(ma-mi+1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	int N;	cin>>N;
	string S;	cin>>S;
	string T;
	T=S.substr(0,N/2);
	T=T+T;
	if(N%2==0 && S==T) 	cout<<"Yes"<<endl;
	else				cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3652
import sys

N = input()
a = []
b = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
c = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
l = list(N)
if N =='zyxwvutsrqponmlkjihgfedcba':
  print(-1)
elif len(N) != 26:
  for i in range(len(N)):
    c.remove(l[i])
  N = N[0: i+1] + c.pop(0)
  print(N)
else:
  for i in range(len(N)-1,0,-1):
    a.append(l[i])
    if ord(l[i]) > ord(l[i-1]):
      for j in range(len(a)):
        if l[i-1] < a[j]:
          print(N[0:i-1]+a[j])
          sys.exit()

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

int main() {
    int a, b, ans;
    cin >> a >> b;
    ans = a + b;
    if(a + b >= 10) cout << "error\n";
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256