akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
int bp(int pow, int n){
    int d = 1;
    while(n)
    {
        if(n%2==1)d=(d*pow)%mod;
        pow=(pow*pow)%mod;
        n/=2;
    }
    return d;
}
void solve(){
    int n, m;
    cin>>n>>m;
    if(n<=m)cout<<"unsafe";
    else cout<<"safe";
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

void solve(){
	string s;
	cin>>s;
	int n = s.size();
	vector<int> pre(n+1);

	for(int i=0;i<n;i++){
		string tmp = s.substr(i,7);
		if(tmp == "dreamer"){
			pre[i] += 1;
			pre[i+7] -= 1;
		}
		tmp = s.substr(i,6);
		if(tmp == "eraser"){
			pre[i] += 1;
			pre[i+6] -= 1;	
		}
		tmp = s.substr(i,5);
		if(tmp == "erase" || tmp == "dream"){
			pre[i] += 1;
			pre[i+5] -= 1;	
		}
	}

	for(int i=1;i<n;i++){
		pre[i] += pre[i-1];
		if(pre[i] == 0){
			cout<<"NO"<<endl;
			return;
		}
	}
	cout<<"YES"<<endl;
	
}	

int main(){
	fastread;
	int t = 1;
	// cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 848
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

void solve(){
    ll n;
    int x, m;
    cin >> n>>x>>m;

    vector<int> order;
    order.push_back(x);
    vector<bool> seen(m, false);

    for(int i = 0; i < n-1; ++i){
        int next = ((ll)order.back()*order.back())%m;

        if(!seen[next]){
            seen[next] = true;
            order.push_back(next);
        }
        else{
            int s = order.size();
            int j = s-1;
            while(order[j] != next) --j;

            vector<int> front, loop;
            for(int k = 0; k < j; ++k){
                front.push_back(order[k]);
            }
            ll loopsum = 0;
            for(int k = j; k < s; ++k){
                loop.push_back(order[k]);
                loopsum += order[k];
            }

            // for(int j : front) cout << j << " ";
            // cout << "\n";

            // for(int j : loop) cout << j << " ";
            // cout << "\n";

            ll sum = 0;
            for(int j : front) sum += j;

            ll left = n-(int)front.size();

            sum += (left/(int)loop.size()) * loopsum;

            int mod = (int)(left%(int)loop.size());

            for(int j = 0; j < mod; ++j){
                sum += loop[j];
            }

            cout << sum << "\n";
            return;
        }
    }

    ll sum = 0;
    for(int i : order){
        sum += i;
    }
    cout << sum << "\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3840
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a, cnt = 0;
    for (int i=1; i<=n; i++) {
        cin >> a;
        if (i%2 == 1 && a%2 == 1) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

int main(void) {
	int n;
	long long march[5]={0,0,0,0,0};
	cin >> n;
	string name;
	for(int i=0; i<n; i++){
		cin >> name;
		if(name[0]=='M')march[0]++;
		if(name[0]=='A')march[1]++;
		if(name[0]=='R')march[2]++;
		if(name[0]=='C')march[3]++;
		if(name[0]=='H')march[4]++;
	}
	long long ans=0;
	for(int i=0; i<5; i++){
		for(int j=i+1; j<5; j++){
			for(int k=j+1; k<5; k++){
				ans+=march[i]*march[j]*march[k];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <cstring>
using namespace std;
int main()
{
	int k;cin>>k;
	char s[102];
	cin>>s;
	if (strlen(s)<=k)
	{
		cout<<s;
	}
	else
	{
		for (int i = 0; i < k; ++i)
		{
			cout<<s[i];
		}
		cout<<"...";
	}
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using   namespace std;
const int maxn=2e5+100;
int A[maxn];
int n,x;
int main()
{
    while(cin>>n)
    {
        int sum=0;
        while(n--)
        {
            cin>>x;
            sum^=x;
        }
        cout<<(sum==0?"Yes":"No")<<endl;
    }
}

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

typedef long double ld;
const int N = 3005;

int n;
ld a[N];
ld f[N][N];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%Lf", a + i);
	}
	f[0][0] = 1.0;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= n; ++j) {
			f[i][j] += f[i - 1][j] * (1 - a[i]);
			f[i][j + 1] += f[i - 1][j] * a[i];
		}
	}
	ld ans = 0.0;
	for (int i = 1; i <= n; ++i) {
		if (i + i > n) {
			ans += f[n][i];
		}
	}
	cout << fixed << setprecision(11) << ans << '\n';
}

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

int main() {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      int z = s - (x + y);
      if (z >= 0 && z <= k) { cnt++; }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
# 最大公約数GCD(x,y)
def GCD(x,y):
    x,y=max(x,y),min(x,y)
    if x%y==0:
        return y
    else:
        return GCD(y,x%y)

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

L=(C*D)//GCD(C,D)
X=B//C-(A-1)//C
Y=B//D-(A-1)//D
Z=B//L-(A-1)//L
print((B-A+1)-(X+Y-Z))

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define rrep(i,n) for(int i=n; i>=1 ; i--)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define SP <<" "<<
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;



int main(){
    int a[5];
    rep(i,5) cin >> a[i];

    int k; cin >> k;

    bool ans = true;
    if(a[4] - a[0] > k) ans = false;
    if(ans) cout << "Yay!" << endl;
    else cout << ":(" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define r 1000000
int main(void) {
	int a[r];
	int s=0,c=0;
	scanf("%d",&s);
	a[0] = s;
	for(int i=1;i<=r;i++) {
		if (a[i - 1] % 2 == 0) {
			a[i] = a[i - 1] / 2;
		}
		else if (a[i - 1] % 2 == 1) {
			a[i] = a[i - 1]*3+1;
		}

		for (int j = 0; j < i; j++) {
			if (a[i] == a[j]) {
				c = i+1;
			}
		}

		if (c != 0) {
			break;
		}
	}
	printf("%d\n", c);
	
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1234567890

int main(){
    ll i,j;
    ll n;
    cin>>n;
    ll m=1;
    ll tw=2;
    while(n>tw){
        m++;
        tw++;
    }
    VVI used(n+1,VI(n+1,0));
    
    for(ll k=1;k<=m;k++){
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            if(used[i][j]==0){
                if(((i>>(k-1))^(j>>(k-1)))&1) used[i][j]=k;
            }
        }
    }
    }
    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++){
            if(j==i+1) cout<<used[i][j];
            else cout<<" "<<used[i][j];
        }
        cout<<endl;
    }

    return 0;   
}

Measured memory_bytes: 2432
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[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;


fn main() {
    input! {
        n: usize,
        a: [[i32; n]; 2],
    }

    let mut cnt1:i32 = 0;
    let mut ans:i32 = 0;
    for i in 0..n {
        cnt1 += a[0][i];
        let mut cnt2 = cnt1;
        for j in i..n {
            cnt2 += a[1][j];
        }
        ans = max(ans, cnt2);
    }
    println!("{}", ans);

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vector<ll>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const ll INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(ll i=0;i<(ll)(s.size());++i) {
    cout << s[i];
    if(i == (ll)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
signed main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  ll n, m, l; cin >> n >> m >> l;
  vector<vector<P>> g(n);
  for(ll i=0;i<m;++i) {
    ll a, b, c; cin >> a >> b >> c;
    a--; b--;
    g[a].push_back({b, c});
    g[b].push_back({a, c});
  }
  vector<vector<P>> dp(n, vector<P>(n, {LINF, 0}));
  for(ll i=0;i<n;++i) {
    priority_queue<pair<P, ll>> que;
    que.push({{0, l}, i});
    dp[i][i] = {0, -l};
    while(!que.empty()) {
      ll nowcnt = -que.top().first.first, nowfuel = que.top().first.second, now = que.top().second; que.pop();
      for(ll j=0;j<(ll)(g[now].size());++j) {
        ll cnt = nowcnt;
        ll next = g[now][j].first, cost = g[now][j].second;
        ll tmp = nowfuel;
        if(cost > l) continue;
        if(cost > tmp) {
          cnt++;
          tmp = l;
        }
        tmp -= cost;
        if(dp[i][next] > make_pair(cnt, -tmp)) {
          dp[i][next] = make_pair(cnt, -tmp);
          que.push({{-cnt, tmp}, next});
        }
      }
    }
  }
  ll q; cin >> q;
  while(q > 0) {
    q--;
    ll s, t; cin >> s >> t;
    s--; t--;
    cout << (dp[s][t].first == LINF ? -1 : dp[s][t].first) << endl;
  }
}


Measured memory_bytes: 5888
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//library zone!!!!!
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld mod_pow(ld x, ll n, ll p) {
	ld res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int x,y;
	cin>>x>>y;
	cout<<x+y/2<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define md 1000000007
#define ll long long 
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fastmap mp.reserve(1024);mp.max_load_factor(0.25);
#define fastset st.reserve(1024);st.max_load_factor(0.25);
ll int mpw(ll int a,ll int b,ll int m)
{
	ll int ans=1;
	if(a==0)return 0;
	if(a==1 || b==0)return 1;
	while(b)
	{
		if(b&1)
		{
			ans=(ans*a)%m;
		}
		a=(a*a)%m;
		b>>=1;
	}
	return ans;
}

ll int pw(ll int a,ll int b)
{
	ll int ans=1;
	if(a==0)return 0;
	if(a==1 || b==0)return 1;
	while(b)
	{
		if(b&1)
		{
			ans*=a;
		}
		a*=a;
		b>>=1;
	}
	return ans;
}

ll int mn(ll int a,ll int b)
{
	if(a<=b)
	{
		return a;
	}
	return b;
}

ll int mx(ll int a,ll int b)
{
	if(a>=b)
	{
		return a;
	}
	return b;
}
vector<vector<ll int>>D;
int main()
{
	fio
	int n;
	cin>>n;
	vector<int>nm(n);
	for(int i=0;i<n;++i)
	{
		cin>>nm[i];
	}
	vector<int>D(n,-1);
	D[0]=0;
	for(int i=1;i<n;++i)
	{
		if(i>=2)
		{
			D[i]=min(D[i-1]+abs(nm[i]-nm[i-1]),D[i-2]+abs(nm[i]-nm[i-2]));
		}
		else{
			D[i]=D[i-1]+abs(nm[i]-nm[i-1]);
		}
	}
	cout<<D[n-1]<<"\n";
	return 0;
}

Measured memory_bytes: 3988
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int A,B;
    R(A,B);
    W((A*B%2)?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = int.Parse(Console.ReadLine());

        var value = input / 3600;
        var hour = value;
        input -= value * 3600;

        value = input / 60;
        var minute = value;
        input -= value * 60;

        var second = input;

        Console.WriteLine(hour + ":" + minute + ":" + second);
    }
}

Measured memory_bytes: 9196
*lst,N = map(int, input().split())

lst.sort(reverse=True)
#print(lst)
count = 0
for i in range(N // lst[0] + 1):
    for j in range((N - i * lst[0]) // lst[1] + 1):
        if (N - i * lst[0] - j * lst[1]) % lst[2] == 0:
            count += 1
print(count)


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 200000;

int main() {
	int n;
	cin >> n;
	int a[N], b[N];
	rep(i, n) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b, b + n, greater<int>());
	rep(i, n) {
		if(a[i] != b[0]) {
			cout << b[0] << endl;
		}
		else {
			cout << b[1] << endl;;
		}
	}
}


Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

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

    if(n == 0){
        if(a[0] == 1)   cout << 1 << endl;
        else    cout << -1 << endl;
        return 0;
    }
    if(a[0] > 0){   // a_n >= 1
        cout << -1 << endl;
        return 0;
    }

    ll lb = a[n], ub = a[n];
    vector<pair<ll, ll>> bound(n + 1);
    bound[n] = make_pair(lb, ub);
    for(int i = n - 1; i >= 0; --i){
        lb = (lb + 1) / 2;
        lb += a[i], ub += a[i];
        bound[i] = make_pair(lb, ub);
    }
    // cout << "lb:" << lb << ",ub:" << ub << endl;
    if(lb > 1 || ub < 1){
        cout << -1 << endl;
        return 0;
    }
    bound[0] = make_pair(1, 1);
    ll ans = 1;
    ll cur = 1;
    lb = 1, ub = 2;
    for(int i = 1; i < n; ++i){
        ll l = bound[i].first, r = bound[i].second;
        lb = cur, ub = cur * 2;
        // cout << "cur:" << cur << endl;
        // cout << "l:" << l << ",r:" << r << ' ';
        // cout << "lb:" << lb << ",ub:" << ub << endl;
        if(l > ub || r < lb){
            cout << -1 << endl;
            return 0;
        }
        cur = min(r, ub);
        ans += cur;
        cur -= a[i];
        if(cur <= 0){
            cout << -1 << endl;
            return 0;
        }
    }
    ans += a[n];
    cout << ans << endl;
}

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

using namespace std;

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t a, b;
  std::cin >> a >> b;
  if (a <= 5) {
    std::cout << 0 << std::endl;
  } else if (a <= 12) {
    std::cout << b / 2 << std::endl;
  } else {
    std::cout << b << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

int main(){
    long long x, y;
    cin >> x >> y;

    long long ans = INF;
    if(y - x > 0) ans = min(ans, y - x);
    ans = min(ans, abs(-y - x) + 1);
    ans = min(ans, abs(y - x) + 2);

    assert(ans > 0);
    cout << ans << endl;
}


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

long long n,a,b,c,d;

int main(){
    scanf("%d%d%d%d%d",&a,&b,&c,&d,&n);
    long long min1=min(a*4,min(b*2,c));
    long long min2=min(min(a*8,b*4),min(c*2,d));
    long long ans=(n%2?(n-1)*min2/2+min1:n*min2/2);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }


int main() {
    ll d, t, s;
    cin >> d >> t >> s;
    if (d > t*s) cout << "No" << endl;
    else cout << "Yes" << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

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

int a, b;

int main() {
  cin >> a >> b;
  if (a == b) {
    cout << "Draw";
  } else if (a == 1) {
    cout << "Alice";
  } else if (b == 1) {
    cout << "Bob";
  } else {
    if (a > b) {
      cout << "Alice";
    } else {
      cout << "Bob";
    }
  }
}


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

int main(){
	int n;
  	ll m;
  	cin >> n >> m;
  	vector<int> a(n);
  	rep(i, n) cin >> a[i];
  	sort(a.begin(), a.end());
  
  	vector<ll> s(n + 1);
  	rep(i, n) s[i + 1] = s[i] + a[i];
  
  	auto calc = [&](int x){
  		ll tot = 0, num = 0;
      	rep(i, n){
        	int j = lower_bound(a.begin(), a.end(), x - a[i]) - a.begin();
          	num += n - j;
          	tot += s[n] - s[j];
          	tot += a[i] * ll(n - j);
        }
      	return make_pair(tot, num);
    };
  
  	int l = 0, r = 200005;
  	while(l + 1 < r){
    	int c = (l + r)>>1;
      	if(calc(c).second >= m) l = c;
      	else r = c;
    }
  
  	auto p = calc(l);
  	ll ans = p.first;
  	ans -= (p.second - m) * l;
  	cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;
using P3 = pair<ll,P>;
using PP = pair<P ,P>;
constexpr ll MOD = 998244353;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e6) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()


int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n), sum(n+1);
    for(int i=0;i<n;i++){
        cin >> a[i];
        a[i]--;
        sum[i+1] = (sum[i] + a[i]) % k;
    }
    map<ll,ll> cnt;
    ll ans = 0;
    for(int i=0;i<n;i++){
        cnt[sum[i]]++;
        if(i >= k-1) cnt[sum[i-k+1]]--;
        ans += cnt[sum[i+1]];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15872
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << endl;}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << endl;}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << endl;}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n, q;
	cin >> n >> q;
	string s;
	cin >> s;

	Vec a(n);
	rep(i, n){
		if(!i) continue;
		a[i] = a[i-1];
		if(s[i-1] == 'A' && s[i] == 'C') a[i]++;
	}

	rep(i, q){
		ll l, r;
		cin >> l >> r;
		co(a[r-1]-a[l-1]);
	}

	return 0;
}


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

using namespace std;

typedef long long LL;


const int N = 210;
int a[N];

int main() {
    LL n;
    cin >> n;
    int mx = 0; 
    while ((1ll<<mx)-1 <= n) mx++;
    mx--;
    n -= (1ll<<mx) - 1;
    int cur = 100;
    for (int i = 1; n; i++) {
        if (n & 1) a[i] = cur--;
        n >>= 1;
    }
    vector<int> ans;
    for (int i = 1; i <= mx; i++) {
        if (a[i]) ans.push_back(a[i]);
        ans.push_back(i);
    }
    for (int i = 1; i <= mx; i++) ans.push_back(i);
    for (int i = cur + 1; i <= 100; i++) ans.push_back(i);
    printf("%d\n", ans.size());
    for (int i = 0; i < int(ans.size()); i++) printf("%d%c", ans[i], " \n"[i == int(ans.size()) - 1]);
    return 0;
}


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

typedef struct node{
    int vertexCode;
    node* next;
}* nodeptr;

class chainTable {
private:
    // nothing :P
public:
    nodeptr head, tail;

    chainTable() : head(NULL), tail(NULL) {}

    void push(int newVC) {  //  VC = Vertex Code
        nodeptr tmp = new node();
        tmp->vertexCode = newVC;
        tmp->next = NULL;

        if (this->head == NULL) {
            this->head = this->tail = tmp;
        } else {
            this->tail = this->tail->next = tmp;
        }
    }

    bool canGoTo(int target) {
        nodeptr tmp = this->head;
        while (tmp != NULL) {
            if (tmp->vertexCode == target) return true;
            else tmp = tmp->next;
        }

        return false;
    }

//    void travel(int target) {
//        nodeptr tmp = this->head;
//        while (tmp != NULL) {
//            if (tmp->vertexCode == target) return true;
//            else cout << tmp->vertexCode;
//        }
//
//        return false;
//    }
};

int main() {
   // freopen("in.txt", "r", stdin);

    int n, u, k, v;
    cin >> n;

    vector<chainTable> aList(n + 1);  // aList = adjacency list

    for (int i = 0; i < n; ++i) {
        cin >> u >> k;
        for (int j = 0; j < k; ++j) {
            cin >> v;
            aList[u].push(v);
        }
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            if (aList[i].canGoTo(j)) {
                cout << "1";
            } else {
                cout << "0";
            }
            if (j != n) cout << " ";
        }
        cout << endl;
    }
//
//    cout << "--------------" << endl;
//    for (int i = 0; i < n; ++i) {
//        aList[i].travel();
//    }
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int N;
  cin >> N;
  vector<long long> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  if(N == 1){
    cout << 1 << endl;
    return 0;
  }
  int ans = 1;
  int dir;
  if(A[1] > A[0]) dir = 1;
  else if(A[1] == A[0]) dir = 0;
  else dir = -1;
  for(int i = 2; i < N; i++){
    int dd;
    if(A[i] > A[i - 1]) dd = 1;
    else if(A[i] == A[i - 1]) dd = 0;
    else dd = -1;
    if(dir == 0) dir = dd;
    else if(dir * dd < 0){
      dir = 0;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int[][] a = new int[3][3];
		int[][] answer = new int[3][3];
		for(int i = 0;i < 3;i++) {
			for(int j = 0;j < 3;j++) {
				a[i][j] = sc.nextInt();
			}
		}
		int n = sc.nextInt();
		int[] b  =new int[n];
		for(int i = 0;i < n;i++) {
			b[i] = sc.nextInt();
			escape:for(int j = 0;j < 3;j++) {
				for(int k = 0;k < 3;k++) {
					if(b[i] == a[j][k]) {
						answer[j][k] = 1;
						break escape;
					}
				}
			}
		}
		bingochecker(answer);

	}

	public static void bingochecker(int[][] bingocard) {
		if(bingocard[0][0] == 1 && bingocard[0][1] == 1 && bingocard[0][2] == 1) {
			System.out.println("Yes");
			return;
		}
		if(bingocard[1][0] == 1 && bingocard[1][1] == 1 && bingocard[1][2] == 1) {
			System.out.println("Yes");
			return;
		}
		if(bingocard[2][0] == 1 && bingocard[2][1] == 1 && bingocard[2][2] == 1) {
			System.out.println("Yes");
			return;
		}

		if(bingocard[0][0] == 1 && bingocard[1][0] == 1 && bingocard[2][0] == 1) {
			System.out.println("Yes");
			return;
		}
		if(bingocard[0][1] == 1 && bingocard[1][1] == 1 && bingocard[2][1] == 1) {
			System.out.println("Yes");
			return;
		}
		if(bingocard[0][2] == 1 && bingocard[1][2] == 1 && bingocard[2][2] == 1) {
			System.out.println("Yes");
			return;
		}

		if(bingocard[0][0] == 1 && bingocard[1][1] == 1 && bingocard[2][2] == 1) {
			System.out.println("Yes");
			return;
		}
		if(bingocard[2][0] == 1 && bingocard[1][1] == 1 && bingocard[0][2] == 1) {
			System.out.println("Yes");
			return;
		}

		System.out.println("No");

	}

}

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

#define ll long long
#define linf (1ll << 60)
#define all(x) (x).begin(), (x).end()

// -------- Main Code -------- //
void runcase() {
    int n; 
    cin >> n;
    vector<ll> arr(n, 0);
    for (auto& u: arr) cin >> u;
    ll pv = arr[0];
    ll he = pv;
    ll res = 0;
    for (int i=1; i<n; i++) {
        if (arr[i] < he) res += he - arr[i];
        he = max(he, arr[i]);
    }
    cout << res << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // int t;
    // cin >> t;
    // while (t-- > 0)
        runcase();
    return 0;
}


Measured memory_bytes: 4780
import math
n = input()
a = list(map(int, input().split()))
ans = 0

for shift in range(32):
    #print('Start outer loop')
    for i in a:
        #print(i>>shift)
        if (i>>shift) & 1 == 1:
            #print('-- BREAK inner loop')
            break
    else: #breakでループを抜けなかったとき
        #print('-- Finish inner loop without BREAK')
        ans += 1
        continue
    
    #print('BREAK outer loop')
    break

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  char aa;
  string s;
  int ww=0;
  cin>>s;
  for(int i=0;i<26;i++){
    aa='a'+i;
    for(int j=0;j<s.size();j++){
      if(s[j]==aa){
	ww=1;
	break;
      }
    }
    if(ww==0){
      cout<<aa<<endl;
      return(0);
    }
    ww=0;
  }
  cout<<"None"<<endl;
  return(0);
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  int a, b, c;
  std::cin >> a >> b >> c;
  if (a + b < c)
    std::cout << "No" << std::endl;
  else
    std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<climits>
using namespace std;
int main(){
  int a, b, k;

  cin >> a >> b >> k;

  int cnt = 0;
  for(int i = a; i <= b; i++){
    if(cnt >= 0 && cnt < k){
      cout << i << endl;
    }else if(cnt > b - a - k){
      cout << i << endl;
    }
    cnt++;
  }
}


Measured memory_bytes: 384
N = int(input())

ss = ['a']
for i in range(1, N):
    tmp = []
    # length i+1
    for s in ss:
        newc = ord(max(s)) + 1
        for j in range(ord('a'), newc+1):
            tmp.append(s + chr(j))
    ss = tmp

for s in sorted(ss):
    print(s)


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

int main(){
    int k,a,b;
    cin >> k >> a >> b;
    if(a%k==0)cout << "OK" << endl;
    else{
        if((a/k)*k+k<=b)cout << "OK" << endl;
        else cout << "NG" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
import java.util.*;

class Main{
  public static void main(String args[]){

    int i= 0;
    int key = 0;
    int n = 0;

    Scanner sc = new Scanner(System.in);
    n = sc.nextInt();
    int A [] = new int[n];
    //input
    for(int k = 0; k<n; k++){
      A[k] = sc.nextInt();
    }

    //insertion sort
    for(int j = 1; j<A.length;j++){
      key = A[j];
      i = j -1;
      for(int k = 0; k<A.length-1;k++){
        System.out.printf("%d ", A[k]);
      }
      System.out.printf("%d\n",A[A.length-1]);

      while(i>=0 && A[i]>key){
        A[i+1] = A[i];
        i--;
      }
      A[i+1] = key;
    }

    //output
    for(int k = 0; k<A.length-1;k++){
      System.out.printf("%d ", A[k]);
    }
    System.out.printf("%d\n",A[A.length-1]);

  }
}


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

signed main(void){
  int X; cin >> X;
  for(int a = -5e3; a <= 5e3; a++){
    for(int b = -5e3; b <= 5e3; b++){
      
      if( a*a*a*a*a - b*b*b*b*b == X ){
        
        cout << a << " "<< b << endl;
        
        return 0;
      }
    }
  }
  
  return 0;
}
  

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int MAXN = 100005;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n, X[MAXN], Y[MAXN], ans[40], tot;

void out(int x, int y) {
	for (int i = 1; i <= tot; ++i) {
		if (abs(x) > abs(y)) {
			if (x < 0) {
				putchar('L');
				x += ans[i];
			} else {
				putchar('R');
				x -= ans[i];
			}
		} else {
			if (y < 0) {
				putchar('D');
				y += ans[i];
			} else {
				putchar('U');
				y -= ans[i];
			}
		}
	}
	puts("");
}

void init() {
	read(n);
	for (int i = 1; i <= n; ++i) {
		read(X[i]); read(Y[i]);
		if (((X[i] + Y[i]) & 1) != ((X[1] + Y[1]) & 1)) {
			puts("-1"); exit(0);
		}
	}
}

void solve() {
	for (int i = 30; i >= 0; --i) {
		ans[++tot] = (1 << i);
	}
	if ((X[1] + Y[1]) % 2 == 0) {
		ans[++tot] = 1;
	}
	printf("%d\n", tot);
	for (int i = 1; i <= tot; ++i) {
		printf("%d ", ans[i]);
	}
	printf("\n");
	for (int i = 1; i <= n; ++i) {
		out(X[i], Y[i]);
	}
}

int main() {
	init();
	solve();
	return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long LL;
const int N=1e5+10;
char s[N];
int n,f[N],a[N],sum[N];
int find(int x){
	return x==f[x]?x:f[x]=find(f[x]);
}
int main()
{
	scanf("%s",s+1);
	scanf("%d",&n);
	int m=strlen(s+1);
	for(int i=1;i<=m+1;i++){
		a[i]=s[i]-s[i-1];
		f[i]=i;
	}
	for(int i=1;i<=m+1;i++)
		f[find(i)]=find(m+1-i+1);
	
	for(int i=0;i<n;i++){
		int l,r;
		scanf("%d%d",&l,&r);
		f[find(l)]=find(r+1);
	}
	for(int i=1;i<=m+1;i++)
		sum[find(i)]=(sum[find(i)]+a[i]%26+26)%26;
	
	int flag=1;
	for(int i=1;i<=m+1&&flag;i++){
		if(sum[find(i)])flag=0;
	}
		
	if(flag)printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }

  int next = 0,c=1;
  bool used[n]={false};
  bool can=true;
  for(int i=0;i<n;i++){
    used[next] = true;
    if(a[next] == 2){
      break;
    }else if(used[a[next]-1]){
      can = false;
      break;
    }
    next = a[next]-1;
    c++;
  }
  if(can){
    cout << c;
  }else{
    cout << -1;
  }
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i< (n); ++i)
const long long INF = 1LL<<58;

// aを常に小さい値にする　大きい値にする
template<class T> bool chmin(T &a, T b){ if(a>b) a = b; }
template<class T> void chmax(T &a, T b){ if(a<b) a = b; }

// 二分探索 前方のindexを返すもの（自分自身を含む） 前方: -INF側のこと
template<class T> int former(const vector<T> &v, T x){
    return upper_bound(v.begin(), v.end(), x) - v.begin() -1; // upper_bound : keyより大きい要素の内の一番左側のイテレータを返す
}
// 二分探索 後方のindexを返すもの（自分自身を含む）後方: INF側のこと
template<class T> int latter(const vector<T> &v, T x){
    return lower_bound(v.begin(), v.end(), x) - v.begin(); // lower_bound : key以上の要素の内の一番左側のイテレータを返す
}

// 最大公約数を求める GCD
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }


/*
 * dを最大公約数とすると d <= ai なので Nd <= M である
 *
 * よってまとめると答えは「M の約数 d のうち、Nd≤M を満たす最大のものになる。
 *
 *
 * 制約より、Mのとりうる最大値は109と大きいですが、M=ABとしたときの約数のペア(A, B)は高々√Mを境に対称なので、探索は√M以下までで十分です。
    対称というのはたとえば、M=100のとき、約数のペア(A, B)は、

    M = 1 * 100
    M = 2 * 50
    M = 4 * 25
    M = 5 * 20
    M = 10 * 10 (ここから対称)
    M = 20 * 5
    M = 25 * 4
    M = 50 * 2
    M = 100 * 1
    となるので、約数のペアを探すのに1~100まで探索しなくても、1~10までの探索でOKです。
 *
 * */

vector<ll> calc_divisor(ll m){
    vector<ll> res;
    for(ll i = 1LL; i*i <= m; i++){
        if(m % i == 0){
            res.push_back(i);
            ll j = m / i;

            if(j != i){
                res.push_back(j); // 約数のペアも格納
            }
        }
    }

    sort(res.begin(), res.end());
    return res;
}

int main() {

    ll N,M;
    cin >> N >> M;

    vector<ll> div = calc_divisor(M);

    // M の約数 d であって、d * N <= M となる最大の d を求める
    long long res = 1;
    for (auto d : div) {
        if (d * N <= M) res = max(res, d);
    }

    cout << res << endl;

}

Measured memory_bytes: 256
/*
 
*/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <deque>
 
#define ll long long
#define cint const int
#define ld long double
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
 
using namespace std;
 
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, long long> pil;
typedef pair <int, string> pis;
typedef pair <int, char> pic;
typedef pair <long long, int> pli;
typedef pair <long long, string> pls;
typedef pair <long long, char> plc;
typedef pair <string, int> psi;
typedef pair <string, long long> psl;
typedef pair <string, char> psc;
typedef pair <char, int> pci;
typedef pair <char, long long> pcl;
typedef pair <char, string> pcs;
 
int a, b, c;
 
int main () {
	cin >> a >> b >> c;
	if (a + b + c < 22) {
	    cout << "win";
	    return 0;
	}
	if (a + b + c >= 22) {
	    cout << "bust";
	    return 0;
	}
	return 0;
}

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

li = [int (i) for i in input().split()]

cnt = [0] * n

for i in li:
    cnt[i] += 1

ans = 1

for i in li[1:]:
    ans = ans*cnt[i-1]%998244353
if li[0] != 0:
    ans = 0

print(ans)



Measured memory_bytes: 13892
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int f[10000],i,j,k,a,s,d,g,h,z;
	scanf("%d %d %d %d",&a,&s,&d,&k);
	for(i=1;i<=a;i++)
		scanf("%d",&f[i]);
	for(i=1;i<=a;i++){
		for(j=i+1;j<=a;j++){
			if(f[i]<f[j]){
				g=f[i];
				f[i]=f[j];
				f[j]=g;
			}
		}
	}
	s+=d;
	h=k+f[1];
	z=h/s;
	for(i=2;i<=a;i++){
		s+=d;
		h+=f[i];
		if(z<h/s){
			z=h/s;
		}
	}
	printf("%d\n",z);
	return 0;
}

Measured memory_bytes: 2688
from collections import Counter

n = int(input())
d_input=list(map(int,input().split()))
m=int(input())
t_input=list(map(int,input().split()))

d_count = Counter(d_input)
t_count = Counter(t_input)

for key,value in t_count.items():
    if key not in d_count:
        print('NO');exit()
    if d_count[key]<value:
        print('NO');exit()
print('YES')


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

using namespace std;

using ll = long long;
ll N;

struct Axis {
    ll x, y;
    Axis (ll in_x, ll in_y){
        x = in_x;
        y = in_y;
    }
};

vector<Axis> A;



ll mandist (Axis a, Axis b){
    return abs(a.x - b.x) + abs(a.y - b.y);
}

ll solver(){
    ll mx = 0;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++) {
            ll md = mandist(A[i], A[j]);
            if(mx < md){
                mx = md;
            }
        }
    }
    return mx;
}

ll solver2() {

    // xi - yi
    ll max0 = LLONG_MIN, min0 = LLONG_MAX;
    ll max1 = LLONG_MIN, min1 = LLONG_MAX;
    for(int i = 0; i < N; i++){
        {
            ll num0 = A[i].x - A[i].y;
            if(max0 < num0) {
                max0 = num0;
            }
            if (min0 > num0) {
                min0 = num0;
            }
        }

        {
            ll num1 = A[i].x + A[i].y;
            if(max1 < num1) {
                max1 = num1;
            }
            if(min1 > num1){
                min1 = num1;
            }
        }
    }

    ll can0 = max0 - min0;
    ll can1 = max1 - min1;
    if(can0 > can1) return can0;
    return can1;
}

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

    for(int i = 0; i < N; i++){
        ll x, y;
        cin >> x >> y;
        A.push_back(Axis(x, y));
        cin.ignore();
    }
    cout << solver2() << endl;
    return 0;
}

Measured memory_bytes: 7292
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,v[300002];
bool check2(int a,int b)
{
	int l=1,r=a;
	while(l<=r)
	{
		if((v[l]+v[r])%m>b)return 0;
		l++,r--;
	}
	return 1;
}
bool check(int mid)
{
	int lb=1,rb=n,as=1;
	while(lb<=rb)
	{
		int md=(lb+rb)>>1;
		if(check2(md,mid))as=md,lb=md+1;
		else rb=md-1;
	}
	if(as==n)return 1;
	if(as&1)as--;
	int mnl=0,mxr=as;
	for(int i=n;i>n/2;i--)
	{
		int lb=0,rb=i,as=i;
		while(lb<=rb)
		{
			int mid1=(lb+rb)>>1;
			if(v[mid1]+v[i]>=m)as=mid1,rb=mid1-1;
			else lb=mid1+1;
		}
		if(mnl<as-(n-i+1))mnl=as-(n-i+1);
		lb=as,rb=i;
		if(v[as]+v[i]>m+mid)return 0;
		while(lb<=rb)
		{
			int mid1=(lb+rb)>>1;
			if(v[mid1]+v[i]<=m+mid)as=mid1,lb=mid1+1;
			else rb=mid1-1;
		}
		if(mxr>as-(n-i+1))mxr=as-(n-i+1);
		if(mnl&1)mnl++;
		if(as*2+i>=n&&mnl<=i*2-n-2&&mxr>=i*2-n-2)return 1;
	}
	return 0;
}
int main()
{
	scanf("%d%d",&n,&m);n*=2;
	for(int i=1;i<=n;i++)scanf("%d",&v[i]);
	sort(v+1,v+n+1);
	int lb=0,rb=m-1,as=m-1;
	while(lb<=rb)
	{
		int mid=(lb+rb)>>1;
		if(check(mid))as=mid,rb=mid-1;
		else lb=mid+1;
	}
	printf("%d\n",as);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int A,B,C;
  cin >> A >> B >> C;
  int d,e,f;
  d = A + B;
  e = A + C;
  f = B + C;
  int ans = min({d,e,f});
  cout << ans << endl;
}
  

Measured memory_bytes: 256