akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define INTMAX 2147483647LL
#define PII pair<int,int>
#define MP make_pair
#define fir first
#define sec second
#define pb push_back
#define re register
#define lc c[x][0]
#define rc c[x][1]
using namespace std;
typedef long long ll;
const double Pi=acos(-1.0);
const int Inf=0x3f3f3f3f;
const int MAXN=5e3+10;
const int Mod=1e9+7; 
inline int read(){
	re int x=0,f=1,ch=getchar();
	while(!isdigit(ch))f=ch=='-'?-1:1,ch=getchar();
	while(isdigit(ch))x=x*10+ch-48,ch=getchar();
	return x*f;
}
inline ll readll(){
	re ll x=0,f=1,ch=getchar();
	while(!isdigit(ch))f=ch=='-'?-1:1,ch=getchar();
	while(isdigit(ch))x=x*10+ch-48,ch=getchar();
	return x*f;
}

struct Node{int to,nxt;}e[MAXN<<1];
int cnt,head[MAXN];
inline void add_edge(int u,int v){e[++cnt].to=v;e[cnt].nxt=head[u];head[u]=cnt;}

int n;
int tmp[MAXN];
int fac[MAXN];
int siz[MAXN],f[MAXN][MAXN];

inline void dfs(int x,int fath){
	siz[x]=1;f[x][1]=1;
	for(int i=head[x],y;i;i=e[i].nxt){
		y=e[i].to;if(y==fath) continue;
		dfs(y,x);
		for(int j=0;j<=siz[x]+siz[y];++j) tmp[j]=0;
		for(int j=1;j<=siz[x];++j) 
			for(int k=0;k<=siz[y];++k)
				tmp[j+k]=(tmp[j+k]+1ll*f[x][j]*f[y][k]%Mod)%Mod;
			
		siz[x]+=siz[y];	
		for(int i=1;i<=siz[x];++i) f[x][i]=tmp[i];	
	}
	for(int i=1;i<=siz[x];++i) f[x][0]=(f[x][0]+1ll*f[x][i]*fac[i]%Mod+Mod)%Mod;
	f[x][0]=(-f[x][0]+Mod)%Mod;
}
inline void Init(){fac[0]=1;for(int i=2;i<=n;i+=2) fac[i]=1ll*fac[i-2]*(i-1)%Mod;}
int main(){
	n=read();Init();
	for(int i=1,u,v;i<n;++i){
		u=read();v=read();
		add_edge(u,v);add_edge(v,u);
	}
	dfs(1,0);
	printf("%d\n",(-f[1][0]+Mod)%Mod);
	return 0; 
}


Measured memory_bytes: 97024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	LL n, m; cin >> n >> m;
	
	vector<vector<int>> d(100010, vector<int>());
	for (int i = 0; i < n; i++) {
		LL a, b; cin >> a >> b;

		d[a].push_back(b);
	}

	priority_queue<LL> que;
	LL ans = 0;

	for (int i = 1; i < m+1; i++) {
		for (int j = 0; j < d[i].size(); j++) {
			que.push(d[i][j]);
		}

		if (!que.empty()) {
			ans += que.top();
			que.pop();
		}
		
	}

	cout << ans << endl;

	return 0;
}

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

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

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int a,b,c;cin >> a >> b >> c;
  cout << a+b+c - max(a,max(b,c)) << endl;
  return 0;
}


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

using namespace std;

int main(){
  string s;
  cin >> s;
  if (s == "Sunny") {
    cout << "Cloudy" << endl;
  }
  else if (s == "Cloudy") {
    cout << "Rainy" << endl;
  }
  else {
    cout << "Sunny" << endl;
  }
}

Measured memory_bytes: 256
a=0
while 1:
 OUT=0
 R=0
 P=0
 SET=0
 
 if a==0:
     b=int(input())
     a+=1
 if b==0:
     break
 
 
 while OUT<=2:
    n=input()
    
    if n=='HIT':
        R+=1
        if R>3:
            P+=1
            R=3
    if n=='OUT':
        OUT+=1
    if n=='HOMERUN':
        P+=R+1
        R=0

    
        
 b-=1
 print(P)
P=0


Measured memory_bytes: 5588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
int main() {
    ll n;
    cin >> n;
    vector<vector<int>>v(n,vector<int>(2));
    rep(i, n) cin >> v[i][0] >> v[i][1];
    double ans = 0;
    rep(i, n){
        rep(j, n){
            if (j == i) continue;
            ans += sqrt((v[i][0] - v[j][0])*(v[i][0] - v[j][0]) + (v[i][1] - v[j][1])*(v[i][1] - v[j][1]));
        
        }
    }
    ans /= n;
    cout << setprecision(15) << ans << endl;
    return 0;
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<ll, ll>
#define debug(var) cerr << "[" << #var << "] " << var << '\n'
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;
const int MAXN = 100005;

ll par[MAXN];
ll child[MAXN];
vector<int> to[MAXN];
ll dist[MAXN];

void dfs(int v, int p=-1) {
    for (int e: to[v]) {
        if (e==p) continue;
        dist[e] = dist[v] + 1;
        dfs(e, v);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin >> n;
    vector<P> d(n);
    rep(i, n) {
        cin >> d[i].fi;
        d[i].se = i;
    }
    sort(whole(d));

    rrep(i, n) {
        if (i==0) continue;
        ll x = d[i].fi - n+2 + child[i]*2;
        if (x==d[i].fi) {
            pr(-1);
            return 0;
        }
        //debug(d[i].fi);
        //debug(x);
        auto it = lower_bound(whole(d), P(x, 0));
        if (it==d.end() || it->fi!=x) {
            pr(-1);
            return 0;
        }
        par[i] = it-d.begin();
        child[par[i]] += child[i]+1; 
        to[i].pb(par[i]);
        to[par[i]].pb(i);
    }
    ll sum = 0;
    dfs(0, -1);
    rep(i, n) {
        sum += dist[i];
    }
    if (sum!=d[0].fi) {
        pr(-1);
        return 0;
    }

    rep(i, n) {
        if (i==0) continue;
        ll u = d[i].se + 1;
        ll v = d[par[i]].se + 1;
        cout << u << " " << v << "\n";
    }
    return 0;
}


Measured memory_bytes: 15620
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = pow(10, 9) + 7;

int main() {
    // source
    char c;
    cin >> c;
    cout << char(c + 1) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    ll q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    s = min(s, q * 4);
    s = min(s, h * 2);
    if(s * 2 < d){
        cout << s * n << endl;
    }else{
        cout << d * (n / 2) + (n % 2) * s << endl;
    }
    return 0;
}


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

using namespace std;

int main() {
    long long n,r,b,s, k=0,cat,rest;
    cin>>n>>b>>r;
    s=b+r;
    cat=n/s;
    k=cat*b;
    rest=n%s;
    if(rest>b){
        k+=b;
    }
    else{
        k+=rest;
    }
    cout<<k;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
#define forn(i,p,n); for(long long i=p;i<n;++i)
#define rofn(i,p,n); for(long long i=p;i>n;--i)
#define pb push_back
#define vi vector
#define ump unordered_map
void solve(){
    ll d,t,s;
    cin >> d >> t >> s;
    if(d/s>t) cout<<"No";
    else if(d/s==t){
        if(d%s)cout<<"No";
        else cout<<"Yes";
    }
    else cout<<"Yes";
}
 
int main()
{
    fast;
    //int test;
    //cin >> test;
    //while(test--){
        solve();
    //}
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long  long
int main()
{
    ll n,mw;
    cin>>n>>mw;
    ll i,w[n],v[n],z=0,j;
    for(i=0;i<n;i++)
    cin>>w[i]>>v[i];
    ll dp[n+1][mw+1];
      for(i=0;i<=n;i++) {
        for(j=0;j<=mw;j++)  
            dp[i][j]=0;
    }
    for(i=1;i<=n;i++) {
        for(j=1;j<=mw;j++)  {
            if(j-w[i-1]>=0)
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
            else
            dp[i][j] = dp[i-1][j];
        
        }
    }
    cout<<dp[n][mw];
}



Measured memory_bytes: 79104
//Atcoder-Begginer-Contest
//2018/10/1
//B

#include<stdio.h>

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

  for(i=1;i<10;i++){
    if(n<=(111*i)&&n>=111*(i-1)){
      printf("%d\n",111*i);
      break;
    }
  }


  return 0;
}


Measured memory_bytes: 128
// Author: Shusuke Ueda
// AtCoder Beginner Contest 135 - Problem C

#include <iostream>
#include <vector>

int main() {
    using lint = int64_t;

    int n;
    std::cin >> n;
    std::vector<lint> a(n + 1), b(n);
    for (auto& e: a) {
        std::cin >> e;
    }
    for (auto& e: b) {
        std::cin >> e;
    }

    lint ans = 0;
    for (int i = 0; i < n; i++) {
        lint atk = std::min(a[i], b[i]);
        ans += atk;
        b[i] -= atk;
        atk = std::min(a[i + 1], b[i]);
        ans += atk;
        a[i + 1] -= atk;
    }

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

Measured memory_bytes: 1792
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
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)*}};}
#[allow(unused_macros)]
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)*}};}
#[allow(unused_macros)]
macro_rules! read_value {($next:expr,($($t:tt),*)) => {($(read_value! ($next,$t)),*)}; ($next:expr, [$t:tt; $len:expr]) => {(0..$len).map(|_|read_value! ($next,$t)).collect::<Vec<_>>()}; ($next:expr,chars) => {read_value! ($next,String).chars().collect::<Vec<char>>()}; ($next:expr,usize1) => {read_value! ($next,usize)-1}; ($next:expr,$t:ty) => {$next().parse::<$t>().expect("Parse error")};}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX: usize = 100006;
#[allow(dead_code)]
const INF_U32: u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32: i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64: u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64: i64 = 1 << 62;
#[allow(dead_code)]
const MOD: i64 = 1e9 as i64 + 7;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(unused_imports)]
use std::f64;

fn main() {
    input!{a:i64,b:i64,c:i64};
    println!("{}", if (a==b && b==c && c==a) || (a!=b && b!=c && c!=a) {"No"} else {"Yes"});
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define MAX ((ll)(1e18 + 5))
#define pi (2*acos(0))
#define mp make_pair
#define M ((int)(1e9 + 7))
#define xx first
#define yy second
#define NN ((ll)(1e6+2))
#define N ((int)(1e4 + 5))
#define eps 0
#define log 20
#define pb push_back
#define MOD 998244353


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long lu;

typedef tree < ll,  null_type,  less < ll >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;

char s[N];

int dp[2][101][N], n;

int call(bool cmp, int mod, int i)
{
    if(s[i]=='\0'){
        if(mod==0) return 1;
        return 0;
    }
    if(dp[cmp][mod][i]!=-1) return dp[cmp][mod][i];
    dp[cmp][mod][i] = 0;
    int d = 9;
    if(cmp) d = s[i]-'0';
    for(; d>=0; d--){
        if(d<s[i]-'0' || cmp==0) dp[cmp][mod][i] += call(0,(mod+d)%n,i+1);
        else dp[cmp][mod][i] += call(1,(mod+d)%n,i+1);
        if(dp[cmp][mod][i]>=M) dp[cmp][mod][i] -= M;
    }
    return dp[cmp][mod][i];
}

int main()
{
    memset(dp,-1,sizeof dp);
    scanf("%s %d",s,&n);
    printf("%d\n",(M-1+call(1,0,0))%M);
    return 0;
}


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

#define rep3(i, s, n ,a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

#define MOD 1000000007

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c;
    vector<vector<int>> a;
    rep(i, n){
        int cost;
        cin >> cost;
        c.push_back(cost);
        vector<int> tmp;
        rep(j, m){
            int A;
            cin >> A;
            tmp.push_back(A);
        }
        a.push_back(tmp);
    }
    int check = 2 << n;
    int minim = INT32_MAX;

    rep(i, check){
        vector<int> und(m, 0);
        int cost=0;
        rep(j, n){
            if(i&(2<<j)){
                cost += c[j];
                rep(k, m){
                    und[k] += a[j][k];
                }
            }
        }
        bool flag=true;
        rep(j, m){
            if(und[j]<x){
                flag = false;
                break;
            }
        }
        if(flag){
            minim = min(cost, minim);
        }
    }

    if(minim!=INT32_MAX)cout << minim << endl;
    else cout << -1 << endl;
    return 0;
}

// int binary_square(int x, int n){
//     int m = MOD;
//     int ans = 1;
//     while(n){
//         if(n%2==1){
//             ans = ans * x % m;
//         }
//         x = x * x % m;
//         n >>= 1;
//     }
//     return ans % m;
// }

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	int n;
	cin >> n;
	int a[n],b[n],c[n];
	REP(i,n) cin >> a[i];
	REP(i,n) cin >> b[i];
	REP(i,n-1) cin >> c[i];
	int prev = -1;
	int ret = 0;
	REP(i,n){
		ret += b[a[i]-1];
		if(prev+1 == a[i]){
			ret += c[a[i]-2];
		}
		prev = a[i];
	}
	println(ret);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int gcd(int a, int b){
    if(!b) return a;
    return gcd(b, a%b);
}
vector<int> arr;
int main () {
    int N, K;
    scanf("%d%d", &N, &K);
    arr.resize(N+1);
    for(int i=1;i<=N;i++) {
        scanf("%d", &arr[i]);
    }
    int g = arr[1], mx = arr[1];
    for(int i=2;i<=N;i++) {
        g = gcd(g, arr[i]);
        mx = max(mx, arr[i]);
    }
    
    if(mx < K || K%g!= 0) {
        cout << "IMPOSSIBLE";
    } else {
        cout << "POSSIBLE";
    }
    
    return 0;
}

Measured memory_bytes: 640
from math import ceil
def f(x):
  xor_cnt=ceil(x/2)
  res=0
  if x%2==1:
    if xor_cnt%2==0:
      res=0
    else:
      res=1
  else:
    if xor_cnt%2==0:
      res=0^x
    else:
      res=1^x
  return res

a,b=map(int,input().split())
print(f(b)^f(a-1))


Measured memory_bytes: 3060
import math


n,k,s = map(int,input().split())

for i in range(k):
    print(s,end=" ")





blank = pow(10,9)-1
if s == blank:
    blank = 1

for i in range(k,n):
    text = " "
    if  i == n-1:
        text = ""
    print(blank,end=text)
print()

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

using namespace std;
#define ll long long

const int N = 55;
int n, m, fa[N], dep[N];
ll ans, s[22];
vector<int> e[N];
void dfs(int u){
	for(int v:e[u]) if(v!=fa[u]) fa[v]=u, dep[v]=dep[u]+1, dfs(v);
}
int main() {
	scanf("%d", &n);
	for(int i=1, x, y; i<n; ++i)
		scanf("%d%d", &x, &y), e[x].push_back(y), e[y].push_back(x);
	dfs(1);
	scanf("%d", &m);
	for(int i=0, x, y; i<m; ++i){
		scanf("%d%d", &x, &y);
		if(dep[x]<dep[y]) swap(x, y);
		while(dep[x]>dep[y]) s[i]|=1ll<<x>>1, x=fa[x];
		while(x!=y) s[i]|=(1ll<<x>>1)|(1ll<<y>>1), x=fa[x], y=fa[y];
	}
	for(int i=0; i<1<<m; ++i){
		int cnt=0, cnt2=0;
		ll ss=0;
		for(int j=0; j<m; ++j) if(i>>j&1) ++cnt, ss|=s[j];
		for(int j=0; j<n; ++j) if(ss>>j&1) ++cnt2;
		ans+=(cnt&1?-1:1)*(1ll<<(n-1-cnt2));
	}
	printf("%lld\n", ans);
	return 0;
}


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

using namespace std;

using ll = long long;

// Graph template
template <class... Args> struct Edge {
  int from, to;
  tuple<Args...> values;
  Edge(int from, int to, Args... values)
      : from(from), to(to), values(values...) {}
};
template <class E> auto operator<(const E &e, const E &f) {
  return e.values > f.values;
}

template <class... Args> class Graph {
  using Edges = vector<Edge<Args...>>;
  vector<Edges> graph_;

public:
  Graph(int n) : graph_(n) {}
  size_t size() { return graph_.size(); };
  size_t size() const { return graph_.size(); };
  auto &operator[](unsigned int x) { return graph_[x]; }
  const auto &operator[](unsigned int x) const { return graph_[x]; }
  void AddEdge(int s, int t, Args... v) { graph_[s].emplace_back(s, t, v...); }
};

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  c = min(a + b + 1, c);
  cout << b + c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x, a, b;
	cin >> x >> a >> b;
	if(b <= a) cout << "delicious" << endl;
	else if(b <= a + x) cout << "safe" << endl;
	else cout << "dangerous" << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int long long int
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mii map<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define FORD(i,a,n) for(int i=n-1;i>=0;i--)
using namespace std;
 
 
int32_t main(){
 
    
    int n,wt,v[101],w[101],sum=0;
    cin>>n>>wt;
    for(int i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
        sum+=v[i];
    }

    int dp[n+1][sum+1];  //dp[i][j] reps ith tak value j ka weight
    
    for(int i=0;i<=sum;i++)
    {
        dp[1][i]=MOD;
    }
    dp[1][0]=0;
    dp[1][v[1]]=w[1];

    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<=sum;j++)
        {
            if(j-v[i]>=0)
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    int ans=0;
    for(int i=0;i<=sum;i++)
    {
        if(dp[n][i]<=wt)
            ans=max(ans,i);
    }

    cout<<ans;
 
    return 0;
 
}


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

int main() {
    int K,N; cin >> N >> K;
    vector<int> L(N);
    rep(i,N) cin >> L.at(i);
    sort(L.begin(),L.end(),greater<int>());
    int ans = 0;
    rep(i,K) ans += L.at(i);
    cout << ans << endl;
}

Measured memory_bytes: 256
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE

signed main()
{   



      
      senky_bansal
      IIIT_ALLAHABAD
      
      // pre();
      ll t;
      // cin>>t;
      t=1;
      while(t--)
      { 
         
          ll n;
          cin>>n;
          ll p1 = n/500;
          n-=500*p1;
          ll ans = 1000*p1;
          p1 = n/5;
          ans+=5*p1;
          cout<<ans<<endl;
         

      }
      






}



























Measured memory_bytes: 256
import java.io.*;
import java.util.*;
@SuppressWarnings("unused")
public class Main{
    static long val[];
    static int wt[];
    public static void main(String args[]) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        String s[] = br.readLine().trim().split(" ");
        int n = Integer.parseInt(s[0]);
        int w = Integer.parseInt(s[1]);
        val = new long[n];
        wt = new int[n];
        for(int i=0;i<n;i++) {
            String st[] = br.readLine().trim().split(" ");
            wt[i] = Integer.parseInt(st[0]);
            val[i] = Integer.parseInt(st[1]);
        }
        dp = new long[n+1][(int)w+1];
        for(int i=0;i<=n;i++) {
            for(int j=0;j<=w;j++) {
                if(i==0 || j==0) dp[i][j]=0;
                else if(wt[i-1] > j) dp[i][j] = dp[i-1][j];
                else dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-wt[i-1]]+val[i-1]);
            }
        }
        out.println(dp[n][w]);
        out.flush();
    }
    static long dp[][];
    
    public static long find(int n, int w) {
        if(dp[n][w]!=-1) return dp[n][w];
        if(n==0 || w==0) return dp[n][w] = 0;
        if(wt[n-1] > w) return dp[n][w] = find(n-1, w);
        return dp[n][w] = Math.max( find(n-1, w), val[n-1] + find(n-1, w-wt[n-1]));
    }
}

Measured memory_bytes: 138688
#include<bits/stdc++.h>
using namespace std;
int  main(){
	ios::sync_with_stdio(false);
	int n,c;
	cin>>n>>c;
	int a[3][34];
	int d[34][34];
	for(int i=0;i<34;i++){
		a[0][i]=0;a[1][i]=0;a[2][i]=0;
	}
	for(int i=1;i<=c;i++){
		for(int j=1;j<=c;j++){
			cin>>d[i][j];
		}
	}
	int tmp;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>tmp;
			for(int k=1;k<=c;k++){
				a[(i+j)%3][k]+=d[tmp][k];
			}
		}
	}
	int mini=INT_MAX;
	for(int i=1;i<=c;i++){
		for(int j=1;j<=c;j++){
			if(i==j)continue;
			for(int k=1;k<=c;k++){
				if(i==k||j==k)continue;
				mini=min(mini,a[0][i]+a[1][j]+a[2][k]);
			}
		}
	}
	cout<<mini<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main() {
  long long X, K, D;
  cin >> X >> K >> D;
  
  X = abs(X);
  if (X / D > K) {
  	cout << X - K * D << endl;
  } else {
    K -= X / D;
    if (K % 2 == 0) cout << X % D << endl;
    else cout << abs(X % D - D) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 7;
int inf = 1e9 + 7;


int x[maxn], y[maxn];
pair<int, int> p[maxn];
bool my_cmp2(pair<int, int> x, pair<int, int> y){
    if(x.second < y.second)return true;
    if(x.second > y.second)return false;
    if(x.first > y.first)return true;
    return false;
}
bool my_cmp(pair<int, int> x, pair<int, int> y){
    if(x.first < y.first)return true;
    if(x.first > y.first)return false;
    if(x.second > y.second)return true;
    return false;
}
int main() 
{
    int n;
    cin >> n;
    int f1 = 0, f2 = 0, f3 = 0;
    int s1 = 0, s2 = 0;
    int mxa = 0, mxb = 0;
    vector<pair<int, int>> vl, vr;
    for(int i = 1; i <= n; ++i){
        string s;
        cin >> s;
        int a = 0, b = 0;
        for(int j = 0; j < s.size(); ++j){
            if(s[j] == '('){
                a++;
            }
            else{
                if(a > 0)--a;
                else ++b;
            }
        }
        if(a == 0 && b == 0) ++f3;
        else if(a == 0) f1 = 1;
        else if(b == 0) f2 = 1;
        s1 += a;
        s2 += b;
        p[i] = make_pair(a, b);
        x[i] = a;
        y[i] = b;
        if(a > b)mxa += a - b;
        else mxb += b - a;
        if(a > b){
            vl.push_back(make_pair(b, a - b));
        }
        else{
            vr.push_back(make_pair(a, b - a));
        }
    }
    int flag = 1, now = 0;
    sort(vl.begin(), vl.end(), my_cmp);
    now = 0;
    for(int i = 0; i < vl.size(); ++i){
        if(now < vl[i].first){
            flag = 0;
            break;
        }
        now += vl[i].second;
    }
    sort(vr.begin(), vr.end(), my_cmp);
    now = 0;
    for(int i = 0; i < vr.size(); ++i){
        if(now < vr[i].first){
            flag = 0;
            break;
        }
        now += vr[i].second;
    }
    //for(int i = 0; i < vr.size(); ++i)cout << vr[i].first << " " << vr[i].second << '\n';
    /*
    for(int i = 1; i <= n; ++i){
        int a = x[i], b = y[i], ma = mxa, mb = mxb;
        if(a > b)ma -= a - b;
        else mb -= b - a;
        if(ma < b)flag = 0;
        if(mb < a)flag = 0;
    }
    for(int i = 1; i <= n; ++i){
        int a = x[i], b = y[i];
        if(s2 - b < a)flag = 0;
        if(s1 - a < b)flag = 0;
    }
    */
    if((f3 == n || f1 + f2 == 2) && s1 == s2 && flag == 1)cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 26924
n,m = map(int,input().split())
now = {(0,0,0)}
for i in range(n):
    a,b = map(int,input().split())
    gone = set()
    for num,nu,key in now:
        if key == 0:
            if a == 1:
                gone.add((num,nu,0))
                gone.add((num+1,nu+100*(i+1)+b,0))
            else:
                for j in range(1,a):
                    gone.add((num+j,nu+100*(i+1)*j,1))
                gone.add((num,nu,0))
                gone.add((num+a,nu+100*(i+1)*a+b,0))
        else:
            gone.add((num,nu,1))
            gone.add((num+a,nu+100*(i+1)*a+b,1))
    now = gone
ans = 10 ** 20
for num,nu,key in now:
    if nu >= m:
        ans = min(ans,num)
print(ans)


Measured memory_bytes: 72016
n = gets.chomp.to_i
i = 0
arr = ("a".."z").to_a
ans = []
# p arr
while n > 0
  n-=1
  po = n%26.to_f
  ans << arr[po]
  n = n/26
  i += 1
  #p "po:#{po}  arr[po-1]:#{arr[po]}  n:#{n}"
end
puts ans.reverse.join

Measured memory_bytes: 14432
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

constexpr ll inf = 1e15;

ll solve(int N,vector<vector<ll>> A){
    for(int i=0;i<N;i++) for(int j=i+1;j<N;j++){
        A[j][i] = A[i][j];
    }

    auto check = [&](auto& self,int now,int pre,int par,vector<vector<int>>& g,vector<int>& par_edges,vector<int>& vis) -> ll{
        vis[now] = 1;
        ll res = 0;
        for(auto x:(now==par? par_edges:g[now])) if(x!=pre && x!=par){
            if(vis[x]) return inf;
            ll r = self(self,x,now,par,g,par_edges,vis);
            if(r>=inf) return inf;
            res += abs(A[now][x])+r;
        }
        return res;
    };

    ll ans = inf;
    for(int leaf=0;leaf<N;leaf++){
        vector<vector<int>> edges(N);
        for(int i=0;i<N;i++) for(int j=i+1;j<N;j++){
            if((A[i][j]>0)^(A[i][leaf]>0)^(A[j][leaf]>0)){
                edges[i].push_back(j);
                edges[j].push_back(i);
            }
        }
        for(int par=0;par<N;par++) if(leaf!=par){
            vector<int> par_edges;
            vector<int> exist_edges(N,0);
            for(auto x:edges[par]) exist_edges[x] = 1;
            for(int j=0;j<N;j++) if(j!=par && !exist_edges[j]) par_edges.push_back(j);
            vector<int> vis(N,0);
            vis[leaf] = 1;
            ll res = abs(A[leaf][par])+check(check,par,leaf,par,edges,par_edges,vis);
//            cerr << leaf << " " << par << " " << res << endl;
            int cnt = count(vis.begin(),vis.end(),1);
            if(cnt==N) ans = min(ans,res);
        }
    }
    return (ans!=inf? ans:-1);
}

int main(){
    int N;
    while(cin >> N && N){
        vector<vector<ll>> A(N,vector<ll>(N));
        for(int i=0;i<N;i++) for(int j=i+1;j<N;j++) cin >> A[i][j];
        cout << solve(N,A) << endl;
    }
}


Measured memory_bytes: 4760
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,s,right=20,left=20,ans=0,d;
	cin>>n;
	for(int p=0;p<n;p++){
		ans=0;
		right=0;
		left=0;
		for(int q=0;q<10;q++){
			//cout<<right<<"   "<<left<<endl;
			if(right>left){//rightのほうが必ず小さい
				d=right;
				right=left;
				left=d;
			}
			cin>>s;
			if(s>left){
				left=s;
			}else if(s<right){
				ans=2;
				right=s;
			}else{
				right=s;
			}
		}
		if(ans==2){
			cout<<"NO"<<endl;
		}else{
			cout<<"YES"<<endl;
		}
	}
}


Measured memory_bytes: 3080
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

A, B, C, D = map(int, input().split())
ans = B // C + B // D - B // (C * D // gcd(C, D))
ans -= (A - 1) // C + (A - 1) // D - (A - 1) // (C * D // gcd(C, D))
print(B - A + 1 - ans)


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

int main(){
int a,b,c,d,e;
cin>>a>>b>>c>>d>>e;

if(a<40) a = 40;
if(b<40) b = 40;
if(c<40) c = 40;
if(d<40) d = 40;
if(e<40) e = 40;

int A = (a+b+c+d+e)/5;


cout<<A<<endl;

return 0;
}




Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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; }
const ll INF = 1LL << 60;
//Binary Indexed Tree
template<class T>
struct BIT{
    int n; //length of array
    vector<T> d; //each content of BIT node
    BIT(int n=0):n(n), d(n+1){} //d is initialized by 0.
    void add(int i, T x=1){ //add x to index i
        for(i++; i<=n; i+=i&-i){
            d[i] += x;
        }
    }
    T sum(int i){ //calculate the sum of index 0 - i.
        T ans=0;
        for(i++; i; i-=i&-i){
            ans+=d[i];
        }
        return ans;
    }
};
int main(){
    int n,q;
    string s;
    cin >> n >> s >>q;
    BIT<int> bit[26];
    rep(i,26)bit[i] = BIT<int>(n);
    rep(i,n){
        bit[s[i]-'a'].add(i);
    }
    rep(qi,q){
        int a;
        cin >> a;
        if(a==1){
            int i; char c;
            cin >> i >> c;
            i--;
            bit[s[i]-'a'].add(i,-1);
            s[i]=c;
            bit[c-'a'].add(i);
        }else{
            int l,r;
            cin >> l >> r;
            l--; r--;
            int ans=0;
            rep(i,26){
                if(bit[i].sum(r)-bit[i].sum(l-1)>0)ans++;
            }
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 51844
def main():
    from collections import deque, namedtuple
    from operator import attrgetter
    import sys
    input = sys.stdin.readline

    Mon = namedtuple('Mon', 'x h')  # 座標xにライフh
    Eff = namedtuple('Eff', 'x cnt')  # [,x]区間にcnt回爆発

    N, D, A = map(int, input().split())

    ms = []
    for _ in range(N):
        x, h = map(int, input().split())
        m = Mon(x=x, h=h)
        ms.append(m)

    ms.sort(key=attrgetter('x'))

    dq = deque()

    effect = 0
    cnt = 0
    for m in ms:
        while dq and dq[0].x < m.x:
            e = dq.popleft()
            effect -= e.cnt * A
        need_dmg = max(0, m.h - effect)
        if need_dmg:
            need_cnt = (need_dmg + A - 1) // A
            e = Eff(x=m.x + D * 2, cnt=need_cnt)
            dq.append(e)
            effect += need_cnt * A
            cnt += need_cnt
    print(cnt)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 97372
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,X;
    cin >> N >> X;
    if(X == 1 || X == N * 2 - 1){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;

    int ans[N * 2 - 1];
    int num = X-1;
    rep(i,0,3){
        ans[i + N - 2] = num;
        num = (num == N * 2 - 1 ? 1 : num+1 );
    }
    rep(i,0,N-2){
        ans[i] = num;
        num = (num == N * 2 - 1 ? 1 : num+1 );
    }
    rep(i,N+1,N*2-1){
        ans[i] = num;
        num = (num == N * 2 - 1 ? 1 : num+1 );
    }
    rep(i,0,N*2-1)cout << ans[i] << endl;
}

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

int main(){
  int H, W;  // H=高さ, W=幅
  cin >> H >> W;

  char Pic;
  vector <char>  Frame1(W+1,'#');
  vector <char>  Frame2(W+1,'#');

  for ( int i=0; i<=W+1; i++){
    cout << '#' ;
  }
  cout << endl;

  for (int j=0; j<H; j++){
    cout << '#' ;
    for (int i=0; i<W; i++){
      cin >> Pic;
      cout << Pic;
    }
    cout << '#' << endl;
  }

  for ( int i=0; i<=W+1; i++){
    cout << '#' ;
  }
  cout << endl;
}



Measured memory_bytes: 256
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end
n, a, b = gets_i_list

if (b-a).even?
  puts (b-a)/2
else
  puts [a - 1, n - b].min + 1 + (b - a - 1)/2
end

Measured memory_bytes: 14544
n = int(input())
num = []
for i in range(n):
    a = int(input())
    num.append(a)

idx = num.index(max(num))
max_a = max(num)

num_c = num
num_c[idx] = 0
idx_2 = num_c.index(max(num_c))
max_a2 = max(num_c)

for i in range(n):
    if i == idx:
        print(max_a2)
    else:
        print(max_a)

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

class Program
{
	static void Main(string[] args)
	{
		var columnsCount = int.Parse(Console.ReadLine());
		var candiesCounts = Enumerable.Range(0, 2)
			.Select(_ => Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number)))
			.ToList();

		var maxCount = 0;
		for (var x = 0; x < columnsCount; ++x) {
			var currentCount = candiesCounts[0].Take(x + 1).Sum() + candiesCounts[1].Skip(x).Sum();
			maxCount = Math.Max(currentCount, maxCount);
		}

		Console.WriteLine(maxCount);
	}
}

Measured memory_bytes: 13524
#include <iostream>
#include <string>

using namespace std;

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

    Node(int k) : key(k), parent(NULL), left(NULL), right(NULL) {}
};

void insert(Node** T, int k)
{
    Node* n = *T;
    Node* parent = NULL;
    Node* new_node = new Node(k);

    while (n != NULL) {
        parent = n;
        if (new_node->key < n->key)
            n = n->left;
        else
            n = n->right;
    }
    new_node->parent = parent;

    if (parent == NULL)
        *T = new_node;
    else if (new_node->key < parent->key)
        parent->left = new_node;
    else
        parent->right = new_node;
}

void inorder(Node* T)
{
    if (T == NULL)
        return;

    inorder(T->left);
    cout << ' ' << T->key;
    inorder(T->right);
}

void preorder(Node* T)
{
    if (T == NULL)
        return;

    cout << ' ' << T->key;
    preorder(T->left);
    preorder(T->right);
}

void print(Node* T)
{
    inorder(T);
    cout << '\n';
    preorder(T);
    cout << '\n';
}

void delete_tree(Node* T)
{
    if (T == NULL)
        return;

    delete_tree(T->left);
    delete_tree(T->right);
    delete T;
}

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

    Node* T = NULL;
    for (int i = 0; i < m; ++i) {
        string instruction;
        cin >> instruction;
        if (instruction == "insert") {
            int k;
            cin >> k;
            insert(&T, k);
        } else {
            print(T);
        }
    }

    delete_tree(T);
}



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

int max(int a, int b) { return a < b ? b : a; }

int lcs(string x, string y) {
    int c[1001][1001] = {0};
    int m = x.size();
    int n = y.size();
    int maxl = 0;
    x = ' ' + x;
    y = ' ' + y;
    for (int i = 1; i <= m; ++i) {
        for (int j = 1; j <= n; ++j) {
            if (x[i] == y[j]) {
                c[i][j] = c[i - 1][j - 1] + 1;
            } else {
                c[i][j] = max(c[i - 1][j], c[i][j - 1]);
            }
            maxl = max(maxl, c[i][j]);
        }
    }

    return maxl;
}

int main() {

    int n;
    cin >> n;
    string s1, s2;
    for (int i = 0; i < n; ++i) {
        cin >> s1 >> s2;
        cout << lcs(s1, s2) << endl;
    }

    return 0;
}

Measured memory_bytes: 5136
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e12;
const int MOD = 1e9 + 7;

#define MAX_V 300

ll dist[MAX_V][MAX_V];//辺が存在しない場合はINF、ただしdist[i][i] = 0とする
int V;

void warshall_floyd(){
    for(int k = 0; k < V; k++){
        for(int i = 0; i < V; i++){
            if(dist[i][k] == INF) continue;
            for(int j = 0; j < V; j++){
                if(dist[k][j] == INF) continue;
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
}
//負の閉路があるかないかは、dist[i][i]が負になる頂点iがあるかどうかで判別できる

signed main(){
    int m,l;
    cin >> V >> m >> l;
    REP(i,V){
        REP(j,V){
            if(i == j){
                dist[i][j] = 0;
            }else{
                dist[i][j] = INF;
            }
        }
    }
    int a,b;
    ll c;
    REP(i,m){
        cin >> a >> b >> c;
        a--;
        b--;
        dist[a][b] = dist[b][a] = c;
    }
    warshall_floyd();
    REP(i,V){
        REP(j,V){
            if(dist[i][j] == 0){
                dist[i][j] = 0;
            }else if(dist[i][j] <= l){
                dist[i][j] = 1;
            }else{
                dist[i][j] = INF;
            }
        }
    }
    warshall_floyd();
    int q;
    cin >> q;
    int s,t;
    REP(i,q){
        cin >> s >> t;
        s--;
        t--;
        if(dist[s][t] == INF){
            cout << -1 << endl;
        }else{
            cout << dist[s][t] - 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
  if(a % b == 0)return b;
  else{
     return(gcd(b,a% b));
  }
}
int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll res = 0;
  res = b - b / c - b / d + b / (c / gcd(c,d) * d);
  //cout << res << endl;
  res -= (a - 1) - (a - 1) / c - (a - 1) / d + (a - 1) / (c / gcd(c,d) * d);
  cout << res << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

vector<lli> g[N];

void solve()
{

    lli n, m;
    cin>>n>>m;
    lli a[n + 1];
    for(int i = 1; i <= n; i ++) {
        cin>>a[i];
    }
    for(int i = 0; i < m; i ++) {
        lli x, y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }


    lli ans = 0;
    for(int i = 1; i <= n; i ++) {
        bool ok = 1;
        for(auto it : g[i]) {
            if(a[it] >= a[i]) {
                ok = 0;
                break ;
            }
        }
        if(ok) {
            ans ++;
        }
    }

    cout<<ans;

    cout<<"\n";
    return ;
}

/*
*/

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

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


Measured memory_bytes: 14960
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;

const int MAX_V = 100010;
const int MAX_LOG_V = 18;
vector<int> G[MAX_V];
int root;//根の番号

int parent[MAX_LOG_V][MAX_V];//親を2^k回辿って到達する頂点
int depth[MAX_V];

void dfs(int v, int p, int d) {
	parent[0][v] = p;
	depth[v] = d;
	for (int i = 0; i < G[v].size(); i++) {
		if (G[v][i] != p)dfs(G[v][i], v, d + 1);
	}
}

void init(int V) {
	dfs(root, -1, 0);
	for (int k = 0; k + 1 < MAX_LOG_V; k++) {
		for (int v = 0; v < V; v++) {
			if (parent[k][v] < 0)parent[k + 1][v] = -1;
			else parent[k + 1][v] = parent[k][parent[k][v]];
		}
	}
}

int lca(int u, int v) {
	if (depth[u] > depth[v]) {
		swap(u, v);
	}
	for (int k = 0; k < MAX_LOG_V; k++) {
		if ((depth[v] - depth[u]) >> k & 1) {
			v = parent[k][v];
		}
	}
	if (u == v)return u;
	for (int k = MAX_LOG_V - 1; k >= 0; k--) {
		if (parent[k][u] != parent[k][v]) {
			u = parent[k][u];
			v = parent[k][v];
		}
	}
	return parent[0][u];
}
int dist(int u,int v){
	int par = lca(u, v);
	return depth[u] + depth[v] - 2 * depth[par];
}

void solve() {
	int N;
	cin >> N;
	root = 0;
	REP(i, N - 1) {
		int u, v; cin >> u >> v;
		u--, v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	init(N);
	int f = 0, s = 0;
	REP(i, N) {
		if (dist(0, i) <= dist(N - 1, i))f++;
		else s++;
	}
	if (f > s) {
		print("Fennec");
	}
	else print("Snuke");
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}


Measured memory_bytes: 24192
#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 FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,m;
	cin >> n >> m;
	int ans = 0;
	if(n>0) ans += n*(n-1)/2;
	if(m>0) ans += m*(m-1)/2;
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 256
def main():
    a, b = input().split()
    if a == "H" and b == "H":
        ans = 'H'
    elif a == 'D' and b == 'H':
        ans = 'D'
    elif a == "D" and b == "D":
        ans = "H"
    else:
        ans = "D"
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940