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

int main(){
    int n;
    cin >>n;
    
    vector<int> vec(n);
    vector<int> vec2(200001);
    set<int> set3;
    int maxnum = 0;
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
        vec2.at(vec.at(i))++;
        set3.insert(vec.at(i));
        maxnum = max(vec.at(i),maxnum);
    }
    
    if (vec2.at(maxnum) >= 2) {
        for (int i = 0; i < n; i++) {
            cout << maxnum << endl;
        }
        return 0;
    } else {
        for (int i = 0; i < n; i++) {
            if (vec.at(i) != maxnum) {
                cout << maxnum << endl;
            } else {
                int secondnum = 0;
                for (int i = 0; i < n; i++) {
                    if(vec.at(i) == maxnum) {
                        continue;
                    } else {
                        secondnum = max(secondnum, vec.at(i));
                    }
                }
                cout << secondnum << endl;
            }
        }
    }
    
    return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

template<typename T>
void trace(T *a, int s, int n) {
    for (int i=s; i<n; i++) {
	cout<<a[i]<<" ";
    }
    cout<<endl;
}



typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



ll a,b,c;

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

    cin>>a>>b>>c;

    ll rhs = c - a - b;
    bool gt = rhs>0;
    rhs = rhs*rhs;

    //watch(rhs);
    
    if (4LL*a*b < rhs && gt) out("Yes");


    out("No");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long int
#define ff first
#define ss second
#define S size()
#define mod (ll)(1e9+7)
#define mset(a,k) memset(a,k,sizeof(a));
#define fr(i, x, y) for ( ll i = x; i < y;i++)
#define dr(i, x, y) for ( ll i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define pqueue priority_queue<ll>
#define mapcl map<char,ll>
#define mapll map<ll,ll>
#define mapsl map<string,ll>
#define vi vector<ll>
#define vs vector<string>
#define psi pair<string,ll>
#define pii pair<ll,ll>
#define piii pair<ll,pii>
#define vii vector<pii>
using namespace std;
void fast() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}
//----------------------------------------FUNCTIONS---------------------------------------------------
ll gcd(ll x, ll y )						{if (y == 0) return x; return gcd(y, x % y);}
ll lcm(ll a, ll b)						{return (a * b) / gcd(a, b);}
ll logx(ll base, ll num)				{int cnt = 0; while (num != 1) {num /= base; ++cnt;} return cnt;}
vi vin(ll n)							{vi a(n); fr(i, 0, n) cin >> a[i]; return a;}
void vout(vi a)							{for (int i = 0; i < (ll)a.S; i++) { cout << a[i] << " "; } cout << endl;}
void in(ll *a, ll n)        			{for (ll i = 0; i < n; i++)cin >> a[i];}
void in1(ll *a, ll n)        			{for (ll i = 1; i <= n; i++)cin >> a[i];}
void out1(ll *a, ll n)					{fr(i, 1, n + 1) {cout << a[i] << " ";} cout << '\n';}
void out(ll *a, ll n)					{fr(i, 0, n) {cout << a[i] << " ";} cout << endl;}
//----------------------------------------START--------------------------------------------------------

bool isprime(ll n)
{
	// Corner cases
	if (n <= 1)  return false;
	if (n <= 3)  return true;

	// This is checked so that we can skip
	// middle five numbers in below loop
	if (n % 2 == 0 || n % 3 == 0) return false;

	for (ll i = 5; i * i <= n; i = i + 6)
		if (n % i == 0 || n % (i + 2) == 0)
			return false;

	return true;
}
const ll maxN = (ll)(1 * 1e5 + 5 );
int main()
{
#ifndef ONLINE_JUDGE
	freopen ("inp4.txt", "r", stdin);
	freopen ("out4.txt", "w", stdout);
#endif
	fast();
	ll t = 1;
	//cin >> t;
	while (t--)
	{
		ll l, r, d;
		cin >> l >> r >> d;
		ll ans = 0;
		fr(i, l, r + 1)if (i % d == 0)ans++;
		cout << ans << '\n';
	}

}


Measured memory_bytes: 3644
s = list(str(input()))
x,y = map(int,input().split())

i = 0
while i < len(s) and s[i] =="F":
    i += 1
x -= i
s = s[i:]

m = [[],[]]
num = 0

for i in range(len(s)):
    if s[i] == "F":
        m[num][-1] += 1
    else:
        num += 1
        num %= 2
        m[num].append(0)

#print("m",m)

sumx = sum(m[0])

dpx = [False]*(2*sumx+3) #index(sumx+1)が座標0
dpx[sumx+1] = True
#print("dpx",dpx)

for p in m[0]:
    dpx_pre = dpx[:]
    dpx = [False]*(2*sumx+3)
    for i in range(2*sumx+3):
        if i-p >= 0:
            dpx[i-p] = dpx_pre[i] or dpx[i-p]
            #print("dpx",dpx)
        if i+p < 2*sumx+3:
            dpx[i+p] = dpx_pre[i] or dpx[i+p]
            #print("dpx",dpx)
    #print("dpx",dpx)

sumy = sum(m[1])
dpy = [False]*(2*sumy+3) #index(sumy+1)が座標0
dpy[sumy+1] = True
#print("dpy",dpy)

for p in m[1]:
    dpy_pre = dpy[:]
    dpy = [False]*(2*sumy+3)
    for i in range(2*sumy+3):
        if i-p >= 0:
            dpy[i-p] = dpy_pre[i] or dpy[i-p]
        if i+p < 2*sumy+3:
            dpy[i+p] = dpy_pre[i] or dpy[i+p]
    #print("dpy",dpy)

if abs(x) > sumx+1 or abs(y) > sumy+1:
    print("No")
elif dpx[x+(sumx+1)] and dpy[y+(sumy+1)]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 53852
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main(){
	
	int N;
	cin >> N;
	
	int ret = 0;
	
	int hoge = N;
	
	while(N > 0){
		ret += N % 10;
		N /= 10;
	}
	
	if(hoge % ret == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
a,b,m=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=min(A)+min(B)
for _ in range(m):
  i,j,c=map(int,input().split())
  i-=1; j-=1
  ans=min(ans,A[i]+B[j]-c)
print(ans)

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

int main(){
    int a, b, c; cin >> a >> b >> c;
    if(a > b) swap(a, b);
    if(b > c) swap(b, c);
    if(a > b) swap(a, b);
    cout << a << " " << b << " " << c << endl;
    return 0;
}


Measured memory_bytes: 3100
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    for(int i = 1; i < n + 1; i++) {
      if(i % 3 == 0 || Integer.toString(i).contains("3")) {
        System.out.print(" " + i);
      }
    }
System.out.println();
  }
}



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

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


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let S: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let ans = (1..S.len()).fold(0, |res, i| if S[i - 1] != S[i] { res + 1 } else { res });

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

Measured memory_bytes: 4352
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

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

    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    sort(a.begin(), a.end());
    sort(c.begin(), c.end());

    LL ans = 0;
    for (int y: b) {
        auto ia = lower_bound(a.begin(), a.end(), y);
        LL ac = ia - a.begin();
        auto ic = lower_bound(c.begin(), c.end(), y+1);
        LL cc = c.end() - ic;
        ans += ac * cc;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4520
#include "bits/stdc++.h"

using namespace std;

void solve()
{
	int N, P;
	cin >> N >> P;
	double res = 0;
	vector<double> ps(N);
	for (int i = 0; i < N; i++)
	{
		double w, b;
		cin >> w >> b;
		ps[i] = ((100 - P) * w + P * b) / 100;
		res -= P * b / 100;
	}
	sort(ps.rbegin(), ps.rend());
	int ans = 0, idx = -1;
	while(res + ps[idx+1] < 0 && idx < N)
	{
		ans++;
		res += ps[++idx];
	}
	ans++;
	cout << ans << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int A, B; cin >> A >> B;

	int res = (A - 1) * (B - 1);

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
    var alp [30]int
    var s string

    fmt.Scan(&s)

    for i := 0; i < len(s); i++ {
        alp[s[i]-'a']++
    }
    for i := 0; i < 26; i++ {
        if alp[i] % 2 == 1 {
            fmt.Println("No")
            return
        }
    }
    fmt.Println("Yes")
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int a, b;
int main() {
	cin >> a >> b;
	int val = a*b;
	if (val % 2 == 0) puts("Even");
	else puts("Odd");
}










Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SC second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}


int main()
{
  int a, b, c, x, y ;
  cin >> a >> b >> c >> x >> y ;
  int d, e, f ;
  
  d = max(x,y)*2*c ;
  e = min(x,y)*2*c + (x-min(x,y))*a + (y-min(x,y))*b ;
  f = a*x + b*y ;
  
  cout << min({d,e,f}) <<endl ;
  
  return 0 ;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a,b,c,x,y,z,aa[100010],ba[100010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1000][1000];
vector<ll> va,vb,vc;

bool spa(string ss){
    bool rr=true;
    if(ss.size()%2)return false;
    for(int i=0;i<ss.size()/2;i++){
        rr=rr and ss[i]==ss[i+ss.size()/2];
    }
    return rr;
}


int main(){
    cin>>s;
    
    do{
        s.pop_back();
        //C s E;
        n=s.size();
    }while(!spa(s));
    C n E;
    
}

Measured memory_bytes: 256
#include <iostream>

#include <string>

using std::cin;
using std::cout;
using std::endl;

using std::string;

int
main()
{
  string s;
  cin >> s;
  cout << (s[0] + std::to_string(s.size() - 2) + s[s.size() - 1]) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{
speed_up;
string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  int l1, l2, l3;
  l1 = s1.size();
  l2 = s2.size();
  l3 = s3.size();
  int cnt1, cnt2, cnt3;
  cnt1 = cnt2 = cnt3 = 0;
  char t = 'A';
  while(true) {
    if(t == 'A' && cnt1 == l1 || t == 'B' && cnt2 == l2 || t == 'C' && cnt3 == l3) break;
    if(t == 'A') {
      if(s1[cnt1] == 'b') t = 'B';
      else if(s1[cnt1] == 'c') t = 'C';
      ++cnt1;
    } else if(t == 'B') {
      if(s2[cnt2] == 'a') t = 'A';
      else if(s2[cnt2] == 'c') t = 'C';
      ++cnt2;
    } else {
      if(s3[cnt3] == 'a') t = 'A';
      else if(s3[cnt3] == 'b') t = 'B';
      ++cnt3;
    }
  }

  cout << t << endl;

  return 0;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int N,A,B;cin>>N>>A>>B;
    cout<<min(N*A,B)<<endl;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define mp(i,j) make_pair(i,j)

typedef long long ll;

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

typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
string rows[55];
int min_path[55][55];

void Main()
{
	int H, W; cin >> H >> W;
	rep(i,H) cin >> rows[i];
	memset(min_path, -1, sizeof(min_path));
	min_path[0][0] = 0;
	queue<P> q;
	q.push(mp(0, 0));
	while (!q.empty()) {
		auto p = q.front(); q.pop();
		rep(i,4) {
			int ny = p.first + dy[i];
			int nx = p.second + dx[i];
			if (ny >= 0 && nx >= 0 && ny < H && nx < W && rows[ny][nx] != '#' && min_path[ny][nx] == -1) {
				min_path[ny][nx] = min_path[p.first][p.second] + 1;
				q.push(mp(ny, nx));
			}
		}
	}
	if (min_path[H - 1][W - 1] == -1) {
		cout << -1 << endl;
		return; 
	}
	int sharp_cnt = 0;
	rep(i,H) {
		rep(j,W) {
			if (rows[i][j] == '#') ++sharp_cnt;
		}
	}
	cout << (W * H - sharp_cnt - min_path[H - 1][W - 1] - 1) << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


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

int main(){
  int x,y,z;
  int n;
  cin>>n;
   for(int i=1;i<=n;i++){
     int counter=0;
     
     for (x=1;x<=41;x++){
       for(y=x;y<100;y++){
         for(z=y;z<100;z++){
           if(i==x*x+y*y+z*z+x*y+y*z+z*x && x==y && y==z) counter=counter+1;
           else if(i==x*x+y*y+z*z+x*y+y*z+z*x && x==y && y!=z) counter=counter+3;
           else if(i==x*x+y*y+z*z+x*y+y*z+z*x && x!=y && y==z) counter=counter+3;
           else if(i==x*x+y*y+z*z+x*y+y*z+z*x ) counter=counter+6;
           
         }
       }
     }
      cout<<counter<<endl;
   }
}


Measured memory_bytes: 3552
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt();
		if (1200 > R) {
			System.out.println("ABC");
		} else if (2800 > R) {
			System.out.println("ARC");
		} else {
			System.out.println("AGC");
		}
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
vector<pair<int,int> > ga[100100];
int u,v,w;
int n;
int cnt[18];
int dq;
int xo[262144],dp[262144];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<n;i++){
		cin>>u>>v>>w;
		ga[u].push_back(make_pair(v,w));
		ga[v].push_back(make_pair(u,w));
	}
	for(int i=0;i<n;i++){
		dq=0;
		for(int j=0;j<ga[i].size();j++){
			dq^=ga[i][j].second;
		} 
		cnt[dq]++;
	}
	int cc=0;
	cc+=cnt[0];
	int zt=0;
	for(int i=1;i<=15;i++){
		cc+=cnt[i]/2;
		cnt[i]%=2;
		if(cnt[i])
			zt+=(1<<i);
	}
	for(int i=0;i<(1<<16);i++){
		for(int j=0;j<=15;j++){
			if(testbit(i,j)){
				xo[i]^=j;
			}
		}
	}
	for(int i=0;i<(1<<16);i++){
		for(int j=i;j>0;j=(j-1)&i){
			if(xo[j]==0)
				dp[i]=max(dp[i],dp[i^j]+1);
		}
	}
	cc+=dp[zt];
	cout<<n-cc<<endl;
	return 0;
}


Measured memory_bytes: 7028
def insertion_sort(a, n, g):
    cnt = 0
    for i in range(1, n):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j + g], a[j] = a[j], a[j - g]
            j -= g
            cnt += 1

        a[j + g] = v
    return cnt


def shell_sort(a, n):
    g = []
    k = n - 1
    cnt = 0
    while k > 1:
        g.append(k)
        k //= 2
    g.append(1)
    for v in g:
        cnt += insertion_sort(a, n, v)

    return cnt, g


def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    cnt, g = shell_sort(a, n)
    print(len(g))
    print(' '.join(map(str, g)))
    print(cnt)
    for i in a:
        print(i)


if __name__ == '__main__':
    main()



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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  int A[N]; rep(i,N) { cin >> A[i]; A[i]--; }
  int B[N]; rep(i,N) cin >> B[i];
  int C[N-1]; rep(i,N-1) cin >> C[i];
  int result = 0;
  rep(i,N) {
    result += B[A[i]];
    if (i!=0 && A[i]==A[i-1]+1) result += C[A[i-1]];
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	for (int z = 0; z < n; z++) {
		int x, y, o, p;
		double sum = 0;
		cin >> x >> y >> o >> p;
		int h = o*x + p*y;
		sum = min(h, (max(5, o)*x+max(2, p)*y)*4/5);
		cout << sum << endl;
	}
}

Measured memory_bytes: 3272
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int h, w, n, sy, sx;
    cin >> h >> w >> n >> sy >> sx;

    sy = h - sy;
    sx--;

    string s, t;
    cin >> s >> t;

    int l = 0, r = w - 1, u = h - 1, d = 0;


    for (int i = n - 1; i >= 0; i--) {
        {
            char c = t[i];
            if (c == 'U') {
                d = max(d - 1, 0);
            } else if (c == 'D') {
                u = min(u + 1, h - 1);
            } else if (c == 'R') {
                l = max(l - 1, 0);
            } else {
                r = min(r + 1, w - 1);
            }
        }

        {
            char c = s[i];
            if (c == 'U') {
                u--;
            } else if (c == 'D') {
                d++;
            } else if (c == 'R') {
                r--;
            } else {
                l++;
            }
        }

        if (r < l || u < d) {
            cout << "NO" << endl;
            ret();
        }

    }

    if (l <= sx && sx <= r && d <= sy && sy <= u) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

}


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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  string n;cin>>n;
  for(int i=0;i<3;i++){
    if(n[i]=='7'){
      puts("Yes");return 0;
    }
  }
  puts("No");
  
  return 0;
}


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



int main() {
    ll x,y;
    cin>>x>>y;
    while(1){
        ll tmp1=max(x,y);
        ll tmp2=min(x,y);
        x=tmp2;
        y=tmp1%tmp2;
        if(y==0){
            cout<<x<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        for(int i = 0; i < n; i++) {
            int s = sc.nextInt();
        }
        int ans = (int)Math.ceil((double)(n - 1) / (k - 1));

        System.out.println(ans);

    }
}

Measured memory_bytes: 48124
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
 
// cout<<fixed<<setprecision(10);
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}
 
int main() {
    int n; cin >> n;
    map<string, int> strs;
    int mx = 0;
    rep(i, n) {
        string st; cin >> st;
        strs[st] += 1;
        mx = max(mx, strs[st]);
    }
    for(auto a : strs) {
        if(a.second == mx) {
            cout << a.first << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

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

int n;
vector<int> l;

void input(){
    cin >> n;
    l.resize(2*n);
    for(int i=0;i<2*n;i++) cin >> l[i];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    sort(l.begin(), l.end());
    int ans = 0;
    for(int i=0;i<2*n;i+=2){
        ans += l[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

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

	let mut c = vec![0; n-1];
	let mut s = vec![0; n-1];
	let mut f = vec![0; n-1];
	for i in 0..n-1 {
		c[i] = a[i].0;
		s[i] = a[i].1;
		f[i] = a[i].2;
	}

	for i in 0..n-1 {
		let mut t = s[i];
		for j in i..n-1 {
			if t < s[j] {
				t = s[j] + c[j];
			}
			else {
				if t % f[j] == 0 {
					t = t + c[j];	
				}
				else {
					t = t + c[j] + f[j]-(t%f[j]);
				}
			}
		}
		println!("{}", t);
	}
	println!("0");
}



Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
#define mod 1000000007

ll ans = 0;
int N,M;
vint a;
vint dp;



int main()
{
    
    cin>>N>>M;
    vint c(N+1);
    a.resize(M);
    dp.resize(N+1);

    rep(i,M)
    {
        cin>>a[i];
        c[a[i]]++; 
    }
    dp[0] = 1;
    dp[1] =(c[1] == 0);
    rep(i,N-1)
    {
        if(c[i+2]==0)
        {
        dp[i+2] = (dp[i]+dp[i+1])%mod;
        }

    }
    cout<<dp[N];
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007

int fn(int A,int B,int C)
{
  return abs(A-B) + abs(B-C) + abs(C-A);
}

void solve(void)
{
  int N;
  int ANS = 0;
  cin>>N;
  for (int i = 0; i < N; i++)
  {
    int A,B;
    cin>>A>>B;
    ANS += B - A + 1;
  }

  cout<<ANS<<endl;
  
}



int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // std::cout << std::fixed;
  // std::cout << std::setprecision(8);

  solve();

 
  return 0;
}

Measured memory_bytes: 256
fun main(arg: Array<String>) {
    var S = next()
    val K = listOf("dream", "dreamer", "erase", "eraser")
    while (true) {
        if (S.length == 0) return println("YES")
        var f = false
        for (n in K.indices)
            if (S.endsWith(K[n])) {
                S = S.substring(0, S.length - K[n].length)
                f = true
                break
            }
        if (!f) return println("NO")
    }
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)


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

ans = 0
if B != 1:
    if N < B:
        ans = int(A*N/B) - A * int(N/B)
    else:
        x = N//B * B - 1
        ans = int(A*x/B) - A * int(x/B)

print(ans)


Measured memory_bytes: 8940
// Balance_128_B

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] W = new int[N];
		int[] sub = new int[N];
		int ans;

		for(int i=0;i<N;i++) {
			W[i] = scan.nextInt();
			}

		for(int i=0;i<N;i++) {
			int S1=0,S2=0;
			for(int k=i;k>=0;k--) {
				S1 = S1 + W[k];
			}
			for(int k=i+1;k<N;k++) {
				S2 = S2 + W[k];
			}
//			System.out.println(i+"回目, S1, S2="+S1+", "+S2);
			sub[i] = Math.abs(S1-S2);
		}

		ans = sub[0];

		for(int n:sub) {
			if(ans>n) {
				ans = n;
			}
		}

//		for(int n:sub) {
//			System.out.print(n+" ");
//		}

		System.out.println(ans);

		scan.close();
	}

}


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

int main(){
    string s;
    cin >> s;
    string ans(s.size(),'x');
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
   char s[4];

   int m=0, i;

   scanf("%s", s);

   for(i=0;i<4;i++){
      if(s[i]=='+')
        m++;

      else m--;
      }

   printf("%d\n", m);
   
   return 0;
}

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

int main(void){

    string S;
    int w;
    
    cin >> S;
    cin >> w;
    
    for(int i = 0; i < S.size(); i += w){
        cout << S.substr(i,1);
    }
    cout << endl;
        
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();

    int R = sc.nextInt();
    double ans = 2* R * Math.PI ;

    System.out.println(ans);

  }
}

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte()) {
      return buffer[ptr++];
    } else {
      return -1;
    }
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  private void skipUnprintable() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
      ptr++;
    }
  }

  public boolean hasNext() {
    skipUnprintable();
    return hasNextByte();
  }

  public String next() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public int nextInt() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    int n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public long nextLong() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }
}

Measured memory_bytes: 25368
#include <iostream>
    #include <cmath>
    #include <iomanip>
    #include <vector>
    #include <algorithm>
     
    using namespace std;
     
    int main()
    {
     
        int N, K;
     
        cin >> N >> K;
     
        int count = max(0, N - K);
        int p = 0;
     
        for(int i = min(N, K); i > 0; --i){
            int f = (int)ceill(log2l((long double)K / i));
            while(p < f){
                ++p;
                count *= 2;
            }
            count += 1;
        }
     
        cout<< setprecision(14) << (long double)count / N / powl(2, p) << endl;
     
        return 0;
    }

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define PI 3.14159265358979323846264338327
#define NUM 1000000007
#define ss second
#define ff first
using namespace std;

int m, k;
int main(){
	ios::sync_with_stdio(0);	
	
	cin >> m >> k;
	
	int x = pow(2, m);
	if (k >= x)
		cout << "-1\n";
	else if (m == 1){
		if (k == 0){
			for (int i = 0; i < x; i++){
				cout << i << " " << i;
				i + 1 == x ? cout << "\n" : cout << " ";
			}
		}
		else cout << "-1\n";
	}
	else {
			cout << k << " ";
			for (int i = 0; i < x; i++)
				if (i != k)
					cout << i << " ";
			cout << k;
			for (int i = x - 1; i >= 0; i--)
				if (i != k)
					cout << " " << i;
			cout <<"\n";
	}
	return 0;
}

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

int main() {
  string S,T;
  cin >> S >> T;
  int a,count = 0;
  
  a = S.size();
  for (int i = 0; i < a; i++ ) {
    if (S.at(i) != T.at(i))
      count++;
  }
  if (count > 0)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
    
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader s = new FastReader();
        int T = s.nextInt();
        double pi = 2 * Math.acos(0.0);
        System.out.println(2*pi*T);
    }

    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

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

int main() {
	vector<vector<int>> A(3, vector<int>(3));
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> A.at(i).at(j);
		}
	}
	int N;
	cin >> N;
	vector<int> b(N);
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (A.at(j).at(k) == tmp) A.at(j).at(k) = -1;
			}
		}
	}
	int flag = 0;
	for (int i = 0; i < 3; i++) {
		if (A.at(i).at(0) == -1 && A.at(i).at(1) == -1 && A.at(i).at(2) == -1) flag++;
		else if (A.at(0).at(i) == -1 && A.at(1).at(i) == -1 && A.at(2).at(i) == -1) flag++;
	}
	if (A.at(0).at(0) == -1 && A.at(1).at(1) == -1 && A.at(2).at(2) == -1) flag++;
	else if (A.at(0).at(2) == -1 && A.at(1).at(1) == -1 && A.at(2).at(0) == -1) flag++;

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

Measured memory_bytes: 256
import java.util.Scanner


object Main {
  def read() = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val row = sc.next()
    (n, row)
  }


  def main(args: Array[String]): Unit = {
    val (n, row) = read()

    // 0番目の人について
    val numChangeLeader0 = row.substring(1, n).count(c => c == 'E')
    val numChangeArray: Array[Int] = Array.fill(n)(0)
    numChangeArray(0) = numChangeLeader0

    for (i <- 1 until n) {
      //numChangeArray(i)の計算をnumChangeArray(i-1)から行う
      numChangeArray(i) = numChangeArray(i - 1) + (if (row(i - 1) == 'W') 1 else 0) + (if (row(i) == 'W') 0 else -1)
    }

    val result = numChangeArray.min
    println(result)
  }
}

Measured memory_bytes: 38040
//package com.company;

import java.util.*;
import java.io.*;

public class Main{
    private static Scanner sc = new Scanner(System.in);
    private static PrintWriter out = new PrintWriter(System.out, true);
    private static int n, m;

    private static void Input() {
        n = sc.nextInt();
        m = sc.nextInt();
    }

    private static void Solve() {
        if (n == m) out.println("Yes");
        else out.println("No");
    }

    public static void main(String[] args)  {
        Input();
        Solve();
    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define LL long long
#define M 1000000007
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
	fastio;
	int a, b;
	cin>>a>>b;
	cout<<max(0, (a-(2*b)))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007
#define MEM_SIZE = 1e5+5;

template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}




//-----CODE------//


void solve(void)
{
  int N;
  cin>>N;
  int A,B;
  cin>>A>>B;
  for (int i = 0; i < N-1; i++)
  {
    int X,Y;
    cin>>X>>Y;
    
    if(X < A || Y < B)
    {
      int M = max( A%X?A/X+1:A/X ,B%Y?B/Y+1:B/Y );
      X = X*M;
      Y = Y*M; 
    }
    A = X;
    B = Y;
  }
  cout<<A+B<<endl;
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <time.h>
#include <complex>
#include <cstdint>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
#define mod 1000000007
typedef long long ll;

unsigned gcd(int a, int b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}


ll comb(int n, int r) {
	if (r * 2 > n) r = n - r;
	uintmax_t dividend = 1;
	uintmax_t divisor = 1;
	for (unsigned int i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}

int main(){

	//int N, M, *A, *B, i, j, *W, *flag, sum=0, start, end, length, tmp;
	ll i, j, k, l, m, n, len, a, b, c;
	ll *A, *B, C, Ntemp, M, K,num_R,num_G,num_B;
	ll sum = 0, sum_B = 0, sum_C = 0, max, min, count, N, S, W;
	ll **dp;
	double ans;

	scanf("%lld %lld", &S ,&W);

	if (S > W){
		printf("safe\n");

	}
	else{
		printf("unsafe\n");

	}
	return 0;

}
    

Measured memory_bytes: 3760
# include <bits/stdc++.h>
# define rr register
const int N=100010,INF=0x3f3f3f3f;
inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-')f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;
}
int main(void){
	double L=read();
	double Sqrt=L/3.0;
	printf("%.9lf",Sqrt*Sqrt*Sqrt);
	return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
count = [0]*m
for i in range(n):
  food = list(map(int,input().split()))
  for j in range(1,food[0]+1):
    count[food[j]-1] += 1
ans = 0
for i in range(m):
  if count[i]==n:
    ans += 1
print(ans)

Measured memory_bytes: 3060
#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(){
	ll a,b,k;
	cin >> a >> b >> k;
	if(k > a){
		ll nokori = k-a;
		a = 0;
		b -= nokori;
	}
	else{
		a -= k;
	}
	if(b < 0) b = 0;
	cout << a << " " << b << endl;
}

Measured memory_bytes: 3624
import collections
N,Q = map(int,input().split())

Cnt = [0 for i in range(N+1)]
G = [[] for i in range(N+1)]
for i in range(N-1):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a) #親ノードの保存意味ある？
for i in range(Q):
    p,x = map(int,input().split())
    Cnt[p] += x

q = collections.deque()
q.append(1)
flag = [False for i in range(N+1)]
while q:
    v = q.pop()
    flag[v] = True
    for i in G[v]:
        if flag[i]:
            continue
        Cnt[i] += Cnt[v]
        q.append(i)

print(*Cnt[1:])

Measured memory_bytes: 56128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mmax(a,b,c) max(a,max(b,c))
#define mmin(a,b,c) min(a,min(b,c))
#define M 1000000007
#define V vector
#define F(a,b,c) for (a=b;a<=c;++a)
#define I cin
#define O cout
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second

ll binpow(ll a, ll b) {
    a %= M;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % M;
        a = a * a % M;
        b >>= 1;
    }
    return res;
}

int main() {
    I.sync_with_stdio(false);
    I.tie(0);
    ll a,b,q,i,j,k;
    I>>a>>b;
    O << a * b;
    return 0;
}


Measured memory_bytes: 3652
fun main(args: Array<String>) {
	val (n, m) = (readLine() ?: return).split(" ").map { it.toInt() }.toIntArray()
	var min = 0
	var max = n
	for (i in 0 until m) {
		val (l, r) = (readLine() ?: return).split(" ").map { it.toInt() }.toIntArray()
		min = Math.max(min, l)
		max = Math.min(max, r)
	}
	if (max - min + 1 < 0) println(0)
	else println(max - min + 1)
}

Measured memory_bytes: 53760
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

ll mod = 1e9+7;

int main(){
    ll n;
    cin >> n;
    
    cout << n * n * n << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n;cin>>n;
  string s;cin>>s;
  int fp = 0;
  for(int i = 0; s.size() > i; i++){
    if(s[i] == 'E')fp++;
  }
  int mn = fp;
  for(int i = 0; s.size() > i; i++){
    if(s[i] == 'E')fp--;
    mn = min(mn,fp);
    if(s[i] == 'W')fp++;
  }
  cout << mn << endl;
}

Measured memory_bytes: 900
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]

ans = True
for i in range(H):
    for j in range(W):
        if s[i][j] == '.': continue
        #
        ans_tmp = False
        if i > 0 and s[i - 1][j] == "#": ans_tmp = True
        if j > 0 and s[i][j - 1] == "#": ans_tmp = True
        if i < H - 1 and s[i + 1][j] == "#": ans_tmp = True
        if j < W - 1 and s[i][j + 1] == "#": ans_tmp = True
        #
        ans = ans & ans_tmp

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

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n / 10 == 9 || n % 10 == 9) {
			System.out.println("Yes");
			;
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n, m; cin >> n >> m;
	vector<ll> a(n);
	for( auto &k : a ) cin >> k;
	sort( a.begin(), a.end() );
	vector<pair<ll, int>> vp;
	for( int i = 0; i < m; ++i ){
		int b; ll c; cin >> b >> c;
		vp.emplace_back(c, b);
	}
	sort( vp.begin(), vp.end(), greater<pair<int, int>>() );
	int pointer = 0;
	for( int i = 0; i < n; ++i ){
		if( vp[pointer].second == 0 ) ++pointer;
		if( pointer == m ) break;
		ll value = vp[pointer].first;
		--vp[pointer].second;
		if( a[i] > vp[pointer].first ) break;
		a[i] = vp[pointer].first;
	}
	cout << accumulate( a.begin(), a.end(), 0ll ) << endl;
	return 0;
}

Measured memory_bytes: 3188