akhauriyash/Code-Regression huggingface dataset:
use std::io::{Read, Write};
use std::cmp::{max, min};

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let mut g = vec![vec![]; n];
    for _ in 1..n {
        let a = it.next().unwrap().parse::<usize>().unwrap() - 1;
        let b = it.next().unwrap().parse::<usize>().unwrap() - 1;
        g[a].push(b);
        g[b].push(a);
    }
    let mut l = vec![-1_000_000; n];
    let mut r = vec![2_000_000; n];
    let k: usize = it.next().unwrap().parse().unwrap();
    let mut src = 0;
    for _ in 0..k {
        let v = it.next().unwrap().parse::<usize>().unwrap() - 1;
        let p: i32 = it.next().unwrap().parse().unwrap();
        l[v] = p;
        r[v] = p;
        src = v;
    }
    let mut q = vec![];
    let mut parent = vec![src; n];
    let mut stack = vec![src];
    while let Some(v) = stack.pop() {
        q.push(v);
        for &u in &g[v] {
            if u == parent[v] {
                continue;
            }
            parent[u] = v;
            stack.push(u);
        }
    }
    for &v in &q {
        for &u in &g[v] {
            if u == parent[v] {
                continue;
            }
            l[u] = max(l[u], l[v] - 1);
            r[u] = min(r[u], r[v] + 1);
        }
    }
    for &v in q.iter().rev() {
        let p = parent[v];
        l[p] = max(l[p], l[v] - 1);
        r[p] = min(r[p], r[v] + 1);
    }
    for &v in &q {
        for &u in &g[v] {
            if u == parent[v] {
                continue;
            }
            l[u] = max(l[u], l[v] - 1);
            r[u] = min(r[u], r[v] + 1);
        }
    }
    for i in 0..n {
        if l[i] > r[i] || (r[i] - l[i]) % 2 == 1 {
            println!("No");
            return;
        }
    }
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    writeln!(out, "Yes").unwrap();
    for i in 0..n {
        writeln!(out, "{}", r[i]).unwrap();
    }
}

fn main() {
    run();
}


Measured memory_bytes: 21372
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	vector<ll> a(3);
	REP(i, 3) cin >> a[i];
	if (a[0] % 2 == 0 or a[1] % 2 == 0 or a[2] % 2 == 0){
		cout << 0 << endl;
		return 0;
	}

	sort(ALL(a));

	cout << a[0] * a[1] << endl;




}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=5e5+100;
const int mod=998244353;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int fac[N],inv[N];
inline int C(int n,int m) {
	if (n<m||m<0) return 0;
	return 1LL*fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main()
{
	int n=gi(),k=gi(),i,ans=0;
	for (i=fac[0]=1;i<=k;i++)
		fac[i]=1LL*fac[i-1]*i%mod;
	for (i=2,inv[0]=inv[1]=1;i<=k;i++)
		inv[i]=mod-1LL*(mod/i)*inv[mod%i]%mod;
	for (i=3;i<=k;i++)
		inv[i]=1LL*inv[i-1]*inv[i]%mod;
	for (i=n;i<=k;i++)
		ans=((ans+C(k,i))%mod+mod-C(k,2*i-n+1))%mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4096
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	var a, _ = strconv.Atoi(nextLine())
	var b, _ = strconv.Atoi(nextLine())

	if a*b % 2 != 0 {
		fmt.Println("Odd")
	} else {
		fmt.Println("Even")
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<char> s(3);
    
  cin >> s.at(0) >> s.at(1) >> s.at(2);
  
  int count = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '1') {
      count++;
    }
  }
 
  cout << count << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

int main() {
    int n;
    cin >> n;
    long long ret = 0;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        ret += x - i;
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 3120
s=input()
a=int(s[:2])
b=int(s[2:])

if a in range(1,13) and b in range(1,13):
    print('AMBIGUOUS')
elif a in range(1, 13):
    print('MMYY')
elif b in range(1, 13):
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3064
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int n, x, ans;
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        x = sc.nextInt();
        while (n != 0 || x != 0) {
            ans = 0;
            for (int i = 1; i < n - 1; i++) 
                for (int j = i + 1; j < n; j++) 
                    for (int k = j + 1; k < n + 1; k++) 
                        if (i + j + k == x)
                            ans++;
            System.out.println(ans);
            n = sc.nextInt();
            x = sc.nextInt();
        }
    }
}


Measured memory_bytes: 26372
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define End return 0;
ll bb[200005];

int main ()
{
    ll n;
    cin>>n;
    ll aa[n];
    for(ll i=0; i<n; i++)
        cin>>aa[i];
    sort(aa,aa+n);
    for(ll i=0; i<n; i++){
        if(aa[i]==aa[i+1]){
            cout<<"NO"<<endl;
            End;
        }
    }
    cout<<"YES"<<endl;

    End;
}
/* pray for me
All is well
*/




Measured memory_bytes: 1792
a,b,c,x,y=map(int,input().split())
minpr=10e+10
memo=None
if x>=y:
  for i in range(x+1):
    price= i*a+ 2*(x-i)*c+ max(0,y-(x-i))*b
    minpr=min(price,minpr)
  print(minpr)
else:
  
  for i in range(y+1):
    price= i*b+ 2*(y-i)*c+ max(0,x-(y-i))*a
    minpr=min(price,minpr)
  print(minpr)

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

int main()
{
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  string ans = "win";
  if (A1 + A2 + A3 >= 22)
    ans = "bust";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
int Llen[MAXN];
int Rlen[MAXN];
int ans[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>S;

    n = strlen(S);

    for(int i=1;i<=n;i++){
        if(S[i-1]=='R')Rlen[i] = Rlen[i-1]+1;
        else Rlen[i] = 0;
    }

    for(int i=n;i>=1;i--){
        if(S[i-1]=='L')Llen[i] = Llen[i+1]+1;
        else Llen[i] = 0;
    }

    for(int i=1;i<n;i++){
        if(S[i-1]=='R'&&S[i]=='L'){
            ans[i] = (Rlen[i]+1)/2+(Llen[i+1])/2;
            ans[i+1] = (Rlen[i])/2+(Llen[i+1]+1)/2;
        }
    }

    for(int i=1;i<=n;i++)
        cout<<ans[i]<<" ";

    return 0;
}


Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    map<int, int> mp;
    while (n--)
    {
        int x;
        cin >> x;
        if (mp[x]++)
        {
            cout << "NO" << endl;
            return;
        }
    }
    cout << "YES" << endl;
}

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


Measured memory_bytes: 9600
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include <random>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


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

ll lcm(ll a,ll b){
    ll g =gcd(a,b);
    return a/g*b;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,a[100010],b[100010];
    ll suma=0,sumb=0;
    cin>>n;
    rep(i,n){
        cin>>a[i];
        suma+=a[i];
    }
    rep(i,n){
        cin>>b[i];
        sumb+=b[i];
    }
    ll cnt=sumb-suma;
    ll cnt2=0,cnt1=0;
    rep(i,n){
        if(a[i]<b[i]){
            if((b[i]-a[i])%2==1) cnt--;
            cnt2+=(b[i]-a[i])/2;
        }
        else{
            cnt1+=(a[i]-b[i]);
        }
    }
    if(cnt<0||cnt<max(cnt1,cnt2)){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  char c;
  set<char> s;
  for(int i = 0;i < 4;i++){
    cin >> c;
    s.insert(c);
  }
  if(s.size() == 2)cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

auto cansame = [&](char a, char b){
    if(a != '?' && b != '?' && a != b) return false;
    return true;
};

int main(){
    string S[3];
    for(int k=0; k<3; k++) cin >> S[k];

    int ans = 1e9;
    vector<int> order = {0, 1, 2};
    do{
        string A = S[order[0]], B = S[order[1]], C = S[order[2]];
        int X = A.size(), Y = B.size(), Z = C.size();
        for(int k=0; k<4100; k++){
            A.push_back('?');
            B.push_back('?');
            C.push_back('?');
        }
        bitset<6300> AB, AC, BC;
        AB.set(), AC.set(), BC.set();
        for(int p=0; p<2000; p++){
            for(int i=0; i<Y; i++){
                if(!cansame(A[i+p], B[i])) AB[p] = 0;
            }
            for(int i=0; i<Z; i++){
                if(!cansame(A[i+p], C[i])) AC[p] = 0;
                if(!cansame(B[i+p], C[i])) BC[p] = 0;
            }
        }

        for(int b=0; b<=2000; b++) for(int c=b; c<=4000; c++){
            bool ok = AB[b] & AC[c] & BC[c-b];
            if(ok){
                int res = max({X, b+Y, c+Z});
                ans = min(ans, res);
            }
        }
    }while(next_permutation(order.begin(), order.end()));
    cout << ans << endl;
    return 0;
}


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

int main() {
    long long n, k, sum = 0;
    cin >> n >> k;
    vector<int> lst(n);
    for(int i = 0; i < n; i++){
        cin >> lst[i];
    }
    sort(lst.begin(), lst.end());
    for(int i = 0; i < n - k; i++){
        sum += lst[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=2e3+10;
char s[maxn][maxn];
int a[maxn],stk[maxn],tmp,l[maxn],r[maxn];
int main(){
	int n=read(),m=read();
	REP(i,1,n) scanf("%s",s[i]+1);
	int ans=max(n,m);
	--n,--m;
	DREP(i,n,1){
		REP(j,1,m){
			if((s[i][j]=='#')^(s[i+1][j]=='#')^(s[i][j+1]=='#')^(s[i+1][j+1]=='#')){a[j]=0;continue;}
			++a[j];
		}
		stk[tmp=0]=0;
		REP(j,1,m){
			while(tmp && a[stk[tmp]]>=a[j]) --tmp;
			l[j]=stk[tmp]+1;
			stk[++tmp]=j;
		}
		stk[tmp=0]=m+1;
		DREP(j,m,1){
			while(tmp && a[stk[tmp]]>=a[j]) --tmp;
			r[j]=stk[tmp]-1;
			stk[++tmp]=j;
		}
		REP(j,1,m) chkmax(ans,(r[j]-l[j]+2)*(a[j]+1));
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 4348
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int MAX = 2e5+4;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
	}
	int dp[MAX];
	dp[1]=0;
	for(int i=2;i<=n;i++)
	{
		dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
		if(i>=3) dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout << dp[n];
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
using namespace std;
long long s[100000+5];
int main()
{
	long long n,x=0,y=0,z=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
		if(s[i]%4==0)
		x++;
		if(s[i]%2==0&&s[i]%4!=0)
		y++;
		if(s[i]!=0)
		z++;
	}
	if(x>=(n/2)||n-x*2-y<=0)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DEC(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  char s;
  for(auto e: S) {
    if (e == s) {
      cout << "Bad" << endl;
      return 0;
    }
    s = e;
  }
  cout << "Good" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;

int main(){
    string S;  cin >>  S;
    int count=0,max=0;
    for(auto s: S){
        if(s=='A'||s=='G'||s=='C'||s=='T') {
            count++;
            if(count > max) max = count;
        }
        else count = 0;
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
ll a,p;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>a>>p;
    cout<<(3 * a + p) / 2;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;

typedef pair<string, int> P;
typedef pair<int, P> P2;

int main(){
	
	int N, Q;
	
	while(true){
		cin >> N >> Q;
		
		if(N == 0 && Q == 0){
			break;
		}
		
		map<int, P> m;
		
		for(int i = 0; i < N; i++){
			string str;
			int num1, num2;
			cin >> str >> num1 >> num2;
			P p;
			p.first = str;
			p.second = num1;
			m[num2] = p;
		}
		
		for(int i = 0; i < Q; i++){
			int num;
			cin >> num;
			map<int, P>::iterator ite;
			ite = m.lower_bound(num);
			if(ite == m.end()){
				cout << "Unknown" << endl;
				continue;
			}
			int num2 = ite->first;
			string str = ite->second.first;
			int num1 = ite->second.second;
			if(num2 - num <= num1 - 1){
				cout << str << " " << num1 - (num2 - num) << endl;
			}else{
				cout << "Unknown" << endl;
			}
		}
		
	}
	return 0;
}

Measured memory_bytes: 3184
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

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

  int ret = 1;
  auto cc = S[0];
  for(auto c: S) {
    if (cc != c) {
      ++ret;
      cc = c;
    }
  }

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 512
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll n;
  cin >> n;
  map<ll,ll> m;

  rep(i,n)
  {
    ll buf;
    cin >> buf;
    m[buf]++;
  }

  ll first = 0;
  ll second = 0;
  vector<pair<ll,ll>> ab;
  for(auto it:m)
  {
    ab.push_back(it);
  }

  auto comp = [](auto a,auto b)
  {
    return a.first > b.first;
  };

  sort(all(ab),comp);

  for(auto it:ab)
  {
    if(it.second > 1)
    {
      if(first == 0)
      {
        first = it.first;
        if(it.second > 3)
        {
          second = it.first;
          break;
        }
      }
      else
      {
        second = it.first;
        break;
      }
    }
  }

  cout << first * second << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 8696
#include<stdio.h>
int main(void)
{
	int i,a[5],sum;
	sum=0;
	for(i=0;i<5;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<5;i++){
		if(a[i]<40){
			a[i]=40;
		}
		sum+=a[i];
	}
	printf("%d\n",sum/5);
	return 0;
}


Measured memory_bytes: 2696
import sys

def main():
    input = sys.stdin.readline
    n = int(input())
    a = [int(x) for x in input().split()]
    
    if n == 0:
        if a[0] > 1:
            print(-1)
        else:
            print(a[0])
        sys.exit()
    
    if a[0] != 0:
        print(-1)
        sys.exit()
    
    sum_a = sum(a)
    b = [0]*(n+1)
    for i in range(n):
        b[i+1] = b[i]+a[i+1]
    
    ans = 0
    key = 1
    for i in range(n+1):
        if a[i] > key:
            print(-1)
            sys.exit()
        
        ans += a[i]
        key -= a[i]
        ans += min([key, sum_a-b[i]])
        key *= 2
    
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 20028
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
string s[55];

int n;
int a[55];
int al[55][40];
int main()
{
	cin>>n;
	rep(i,n)
	{
		cin>>s[i];
		rep(j,s[i].size())
		{
			al[i][(int)(s[i][j]-'a')]++;
		}
	}
	rep(j,26)
	{
		rep(i,n)
		{
			if(i==0)a[j]=al[i][j];
			else a[j]=min(a[j],al[i][j]);
		}
	}
	rep(i,26)
	{
		rep(j,a[i])cout<<(char)('a'+i);
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
#import time
from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n, m = rl()
lis=[[] for _ in range(n+1)]
shi=[tuple(rl()) for _ in range(m)]
ans=dict()

for i in shi:
    lis[i[0]].append(i[1])

for i, com in enumerate(lis):
    if len(com)==0:continue

    for j,num in enumerate(sorted(com)):
        ans[num]="0"*(6-len(str(i)))+ str(i) + "0"*(6-len(str(j+1)))+str(j+1)

for i in shi:
    print(ans[i[1]])

Measured memory_bytes: 131052
import math

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

c = []
for i in range(N):
    c.append(list(map(int, input().split())))

ans = 0
for i in range(N):
    for j in range(i + 1, N):

        a = 0
        for k in range(D):
            a += (c[i][k] - c[j][k]) ** 2
    
        a = math.sqrt(a)
        if a.is_integer() == True:
            ans += 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

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

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	string S;
	std::cin >> S;
	std::cout << S.substr(0, 3) << endl;


	return 0;
}


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

#define int long long
#define inf 1000000007LL

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1LL; i >= 0; i--)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rep1(i, n) for(int i = 1LL; i <= (n); i++)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)
/*
class Dinic {
public:
  vector<vector<pair<int, int>>> v;
  vector<int> e;

  vector<int> k;
  vector<int> j;

  void init(int n) {
    v = vector<vector<pair<int, int>>>(n);
    e = vector<int>();
    k = vector<int>(n);
    j = vector<int>(n);
  }
  void add_edge(int a, int b, int atob, int btoa = 0) {
    v[a].push_back(make_pair(b, e.size()));
    e.push_back(atob);
    v[b].push_back(make_pair(a, e.size()));
    e.push_back(btoa);
  }
  void dyk(int s) {
    for(auto& i : k) {
      i = inf;
    }
    queue<pair<int, int>> pq;
    pq.push(make_pair(0, s));
    while(!pq.empty()) {
      int w = pq.front().first;
      int b = pq.front().second;
      pq.pop();
      if(k[b] > w) {
        k[b] = w;
        for(auto i : v[b]) {
          if(e[i.second] > 0) {
            pq.push(make_pair(w + 1LL, i.first));
          }
        }
      }
    }
  }
  int dfs(int s, int t, int p, int c) {
    if(p == t) {
      return c;
    }
    int all = 0;
    while(c > all && j[p] < v[p].size()) {
      if(k[v[p][j[p]].first] == k[p] + 1LL) {
        int r = dfs(s, t, v[p][j[p]].first, min(c - all, e[v[p][j[p]].second]));
        e[v[p][j[p]].second] -= r;
        e[v[p][j[p]].second ^ 1LL] += r;
        if(r < c - all) {
          j[p]++;
        }
        all += r;
      }
      else {
        j[p]++;
      }
    }
    return all;
  }
  int solve(int s, int t) {
    int all = 0;
    while(1LL) {
      dyk(s);
      for(auto& i : j) {
        i = 0;
      }
      int r = dfs(s, t, s, inf);
      if(r == 0) {
        return all;
      }
      all += r;
    }
  }
};
*/

class Bit {
public:
  vector<int> d;
  void init(int n) {
    d.resize(n + 10, 0);
  }
  void add(int b, int x) {
    for(int i = b + 1; i <= d.size(); i += (i & -i)) {
      d[i - 1] = (d[i - 1] + x) % inf;
    }
  }
  int sum(int b) {
    int ret = 0;
    for(int i = b + 1; i > 0; i -= (i & -i)) {
      ret = (ret + d[i - 1]) % inf;
    }
    return ret;
  }
};

int z[334334];
pair<int, int> tmp[334334];

pair<int, int> d[334334];

signed main() {
  int n;
  cin >> n;
  rep(i, n) {
    cin >> tmp[i].first >> tmp[i].second;
    z[i] = tmp[i].second;
  }
  sort(tmp, tmp + n);
  sort(z, z + n);
  int now = 0;
  rep(i, n) {
    now = max(now, tmp[i].second);
    d[i].first = lower_bound(z, z + n, now) - z + 1;
  }
  now = inf;
  rrep(i, n) {
    now = min(now, tmp[i].second);
    d[i].second = lower_bound(z, z + n, now) - z + 1;
  }
  sort(d, d + n);
  Bit dp;
  dp.init(n);
  dp.add(0, 1);
  rep(i, n) {
    dp.add(d[i].first, (dp.sum(d[i].first) - dp.sum(d[i].second - 2) + inf) % inf);
  }
  cout << (dp.sum(n) - dp.sum(n - 1) + inf) % inf << endl;
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

vector<ll> divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main()
{
  ll n;
  cin >> n;
  vector<ll> d = divisor(n);
  vector<ll> ans = divisor(n - 1);
  for (ll i: d) {
    if (i == 1) continue;
    ll a = n;
    while(a % i == 0) {
      a /= i;
    }
    if (a % i == 1) {
      ans.push_back(i);
    }
  }
  cout << ans.size() - 1 << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<queue>
#include<vector>
using namespace std;


int main(){
  int N,T,ta,tb,ans=0;
  cin>>N>>T;
  cin>>ta;
  for(int i=1;i<N;i++){
    cin>>tb;
    if(T>tb-ta){
      ans+=tb-ta;
    }else{
      ans+=T;
    }
    ta=tb;
  }
  ans+=T;
  cout<<ans<<endl;
  
  return 0;
}


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

int main()
{
	string s;
	cin >> s;

	string t = "keyence";
	bool crit = true;
	int length = s.size();

	auto pos = std::search(s.begin(), s.end(), t.begin(), t.end());
	if(pos != s.end()){
		bool crit1 = (std::string(s.begin(), pos) == "");
		bool crit2 = (std::string(pos, s.end()) == t);
		if((crit1==false)&&(crit2==false)) crit = false;
	}
	else{
		string t1 = "keyenc";
		auto pos = std::search(s.begin(), s.end(), t1.begin(), t1.end());
		if(pos != s.end()){
			if(std::string(s.begin(), pos) != "") crit = false;
			else if(s.substr(length-1,1) != "e") crit = false;
		}
		else{
			t1 = "keyen";
			auto pos = std::search(s.begin(), s.end(), t1.begin(), t1.end());
			if(pos != s.end()){
				if(std::string(s.begin(), pos) != "") crit = false;
				else if(s.substr(length-2,2) != "ce") crit = false;
			}
			else{
				t1 = "keye";
				auto pos = std::search(s.begin(), s.end(), t1.begin(), t1.end());
				if(pos != s.end()){
					if(std::string(s.begin(), pos) != "") crit = false;
					else if(s.substr(length-3,3) != "nce") crit = false;
				}
				else{
					t1 = "key";
					auto pos = std::search(s.begin(), s.end(), t1.begin(), t1.end());
					if(pos != s.end()){
						if(std::string(s.begin(), pos) != "") crit = false;
						else if(s.substr(length-4,4) != "ence") crit = false;
					}
					else{
						t1 = "ke";
						auto pos = std::search(s.begin(), s.end(), t1.begin(), t1.end());
						if(pos != s.end()){
							if(std::string(s.begin(), pos) != "") crit = false;
							else if(s.substr(length-5,5) != "yence") crit = false;
						}
						else{
							t1 = "k";
							auto pos = std::search(s.begin(), s.end(), t1.begin(), t1.end());
							if(pos != s.end()){
								if(std::string(s.begin(), pos) != "") crit = false;
								else if(s.substr(length-6,6) != "eyence") crit = false;
							}
							else{
								crit = false;
							}
						}
					}
				}
			}
		}
	}

	if(crit) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}


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

int main()
{
    string s;
    cin >> s;
    long long ans = 0;
    for (int i = 0; i < (1 << (s.size() - 1)); i++) {
        long long sum = 0;
        vector<int> where_plus;
        where_plus.push_back(0);
        for (int j = 0; j < s.size() - 1; j++) {
            if (i >> j & 1) { where_plus.push_back(j + 1); }
        }
        where_plus.push_back(s.size() + 1);

        for (int j = 0; j < where_plus.size() - 1; j++) {
            int l = where_plus[j];
            int r = where_plus[j + 1];
            sum += stoll(s.substr(l, r - l));
        }
        ans += sum;
    }
    cout << ans << endl;
}

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

int main()
{
    int n;
    cin>>n;
    int A[100][2];
    for(int i=0;i<n;i++)
        cin>>A[i][0]>>A[i][1];

    long long int cnt=0;
    for(int i=0;i<n-2;i++)
    {
        if(A[i][0]==A[i][1] && A[i+1][0]==A[i+1][1] &&A[i+2][0]==A[i+2][1])
         {
             cout<<"Yes\n";
             return 0;
         }
    }
        cout<<"No\n";

}


Measured memory_bytes: 3616
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd${0:#:TARGET}

string funami(string a, string b)
{
    if (a == "T" && b == "F") {
        return "F";
    } else {
        return "T";
    }
}

string mmnmm(int yui, string left)
{
    if (yui) {
        string right;
        cin >> right;
        return mmnmm(yui-1, funami(left, right));
    } else {
        return left;
    }
}

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

    Int(n);
    string st; cin >> st;
    cout << mmnmm(n-1, st) << endl;

    return 0;
}



Measured memory_bytes: 23468
n = int(input())
l = [int(i) for i in input().split()]
ans = [0 for _ in range(9)]
free = 0
for i in l:
    if i < 3200:
        ans[i//400] += 1
    else:
        free += 1
        
ans = [i for i in ans if i != 0]
print(len(ans) if ans else 1,len(ans) + free)


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;
ll mod = 998244353;

int main(void){
    int N; cin >> N;
    ll cnt[N] = {};
    rep(i, N){
        int temp; cin >> temp;
        if(i == 0){
            if(temp != 0){
                cout << 0 << endl;
                return 0;
            }
        }
        cnt[temp]++;
    }
    ll ans = 1;
    if(cnt[0] >= 2){
        cout << 0 << endl;
    }
    else{
        for(int i = 1; i < N-1; i++){
            if(cnt[i] == 0 && cnt[i-1] != 0 && cnt[i+1] != 0){
                cout << 0 << endl;
                return 0;
            }
        }
        for(int i = N-1; i >= 1; i--){
            ll op = 1;
            ll mul = cnt[i-1];
            rep(j, cnt[i]) op = (op*mul) % mod;
            ans = (ans * op) % mod;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
    int a,b,c,d,count[4],k;
    
    k=0;
    scanf("%d",&a);
    b=a%10;
    c=(a%100-b)/10;
    d=a/100;
    count[0]=b;
    count[1]=c;
    count[2]=d;
    for(int i=0;i<=3;i++)
    {
    if(count[i]==1)
    {
        k++;
    }
    }
    printf("%d",k);
}

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

const int INF = 1e8;
int N;
vector<int> c;
int dp[111111];

int main() {
    cin >> N;

    // コインの種類を配列に追加
    c.push_back(1);
    for (int i = 6; i <= N; i*=6) { c.push_back(i); }
    for (int i = 9; i <= N; i*=9) { c.push_back(i); }

    // DPテーブルを初期化
    fill(dp, dp+N+1, INF);
    dp[0] = 0;

    // DP
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j < c.size(); j++) {
            if (i >= c[j]) {
                dp[i] = min(dp[i], dp[i-c[j]]+1);
            }
        }
    }

    cout << dp[N] << endl;

    return 0;
}

Measured memory_bytes: 640
[A, B, C, D] = list(map(int, input().split()))

flg = 0
for i in range(1000) :
    C -= B
    if C <= 0 :
        flg = 1
        break
    A -= D
    if A <= 0 :
        flg = -1
        break

if flg == 1 :
    print("Yes")
elif flg == -1 :
    print("No")

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}

vector<int> to[200010];
vector<int> ans;
void dfs(int v, int p = -1){
	for(int u: to[v]){
		if(u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}
int main(){
	int n, q; cin >> n >> q;
	for(int i = 1; i < n; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	ans.resize(q);
	for(int i = 0; i < q; i++){
		int p, x;
		cin >> p >> x;
		p--;
		ans[p] += x;
	}
	dfs(0);
	for(int i = 0; i < n; i++){
		cout << ans[i] <<" ";
	}
	cout << endl;
}



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

using namespace std;

#define int int64_t

const int maxn = 1e5 + 42;
vector<int> g[maxn];
int used[maxn];

int dfs(int a, int b, int p, vector<int> &path)
{
    if(a == b)
    {
        path.push_back(a);
        used[a] = 1;
        return 1;
    }
    for(auto u: g[a])
    {
        if(u == p)
            continue;
       if(dfs(u, b, a, path))
       {
           path.push_back(a);
           used[a] = 1;
           return 1;
       }
    }
    return 0;
}

int dfs_cn(int v)
{
    used[v] = 1;
    int ret = 1;
    for(auto u: g[v])
        if(!used[u])
            ret += dfs_cn(u);
    return ret;
}

signed main()
{

    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> path;
    dfs(1, n, 1, path);
    reverse(begin(path), end(path));
    int m = path.size() / 2 + path.size() % 2;
    int cnt = 0;
    for(int i = 0; i < m; i++)
        cnt += dfs_cn(path[i]);
    cout << (cnt > (n - cnt) ? "Fennec" : "Snuke") << endl;
}


Measured memory_bytes: 13944
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define nl '\n'
#define sp ' '
#define zero '0'
#define r(a,b,c) for(ll a=(b);a<(c);++a)
#define v(a,b,c) for(ll a=(b);a>(c);--a)
#define f(a) cout<<fixed<<setprecision(10)<<a
#define d(a,b,c) cout<<setfill(a)<<setw(b)<<right<<c
#define hasten cin.tie(0);ios::sync_with_stdio(false)
ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,s,t,u,v,w,x,y,z;

const int prime[15]=
{2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};

inline void in(){}
template<class T,class...A>
inline void in(T&&t,A&&...a){cin>>t;in(move(a)...);}

template <class T>inline void out(T t){cout<<t<<nl;}
template <class T, class...A>
inline void out(T t,A...a){cout<<t<<' ';out(move(a)...);}

inline ll dig(ll a){ll d=1;while(a/=10)++d;return d;}

inline ll gcd(ll a,ll b)
{ll c;while(a){c=a;a=b%a;b=c;}return b;}

inline bool isp(ll a){
	if(a<48){r(i,0,15)if(prime[i]==a)return 1;}
	else if(a<2809)return gcd(614889782588491410,a)==1;
	else {out("Error:Argument is Over-2808!");exit(1);}
	return 0;
}

int main(){
	hasten;
	in(a,b);
	ll an[a],bn[a];
	r(i,0,a)in(an[i],bn[i]);
	m=*max_element(an,an+a);
	sort(bn,bn+a);
	p=a;
	c=0;
	s=0;
	while(p&&bn[p-1]>m){
		s+=bn[--p];
		++c;
		if(b<=s){out(c);return 0;}
	}
	out(c+(b-s+m-1)/m);
	

}

Measured memory_bytes: 1792
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <set>
#include <cstring>
#include <map>
#include <bitset>
#include <random>
#include <stack>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <ctime>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define sc second
#define fs first
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template<class T> T sqr(T x) { return x*x; }
ld pi = 3.1415926535897932384626433832795;
ll mod = 1e9 + 7;
const int N = 3e5 + 10;

typedef vector<vector<ll> > mtrx;

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

int X, K, rr[N], Q, a[N], t[N];
int d[N];
int l[N], r[N], lp[N], rp[N];

int main()
{	

	cin >> X >> K;
	for (int i = 0; i < K; i++) cin >> rr[i+1];
	cin >> Q;
	for (int i = 0; i < Q; i++) cin >> t[i] >> a[i];
	l[0] = 0, r[0] = X;
	lp[0] = 0, rp[0] = X;
	int o = 0;
	for (int i = 1; i <= K; i++) {
		int d = rr[i] - rr[i-1];
		int lf = l[i - 1], rt = r[i - 1], lfp = lp[i - 1], rtp = rp[i - 1];
		if (o == 0) { // from A
			int h_to_d = d;
			if (h_to_d <= lfp) { // just shift
				lfp -= d, rtp -= d;
			}
			else if (h_to_d > lfp && h_to_d < rtp) {
				lf = lf + h_to_d - lfp, lfp = 0, rtp -= d;
			}
			else if (h_to_d >= rtp) { // all in one point
				lfp = 0, rtp = 0, lf = X, rt = X;
			}
		}
		else { // to A
			int f_r_t = X - rtp, f_l_t = X - lfp;
			if (d <= f_r_t) { // just shift
				lfp += d, rtp += d;
			}
			else if (d > f_r_t && d < f_l_t) {
				rt = rt - (d - f_r_t), lfp += d, rtp = X;
			}
			else if (d >= f_l_t) { // all in one point
				lfp = X, rtp = X, lf = X, rt = X;
			}
		}
		o ^= 1;
		l[i] = lf, r[i] = rt, lp[i] = lfp, rp[i] = rtp;
	}
	
	for (int i = 0; i < Q; i++) {
		int k = lower_bound(rr, rr + K, t[i]) - rr;
		if (rr[k] > t[i]) k--;

		int lf = l[k], rt = r[k];
		int ans, o = k % 2;

		int d = -1;
		if (o) d *= d;
		
		if (a[i] <= lf) {
			ans = lp[k] + d*(t[i] - rr[k]);
		}
		else if (a[i] > lf && a[i] < rt) {
			ans = a[i] - lf + lp[k] + d*(t[i] - rr[k]);
		}
		else if (a[i] >= rt) {
			ans = rp[k] + d*(t[i] - rr[k]);
		}
		ans = min(ans, X);
		ans = max(ans, 0);

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 8576
#include<stdio.h>
int main(){
  int i,N,j;
  int a[100];
  scanf("%d",&N);
  for(i=N-1;i>=0;i--){
    scanf("%d",&a[i]);
  }
  for(j=0;j<=N-1;j++){
  if(j == N - 1) {
    printf("%d\n",a[j]);
  }
  else{
    printf("%d ", a[j]);
  }
  }
     return 0;
}

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

N_len = len(list(str(N)))

def sn(n):
    if n==1:
        return 9
    else:
        return 9 * (1-100**n)//(1-100)

N_len_fix = (N_len+1)//2
if N_len%2==0:
    print(sn(N_len_fix))
else:
    print(sn(N_len_fix-1) + N - 10**(N_len-1)+1)


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

using namespace std;

int main(void){
    int n,l;
    cin >> n >> l;
    int sum = 0;
    int res;
    int delta = 1000000;
    vector<int> a;
    for(int i=1;i<=n;i++){
        sum += l+i-1;
        a.push_back(l+i-1);
    }
    for(int i=0;i<n;i++){
        if(abs(a[i]) < delta){
            delta = abs(a[i]);
            res = sum - a[i];
        }
    }
    cout << res << endl;
}

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

signed main(){
    int N, K;
    
    cin >> N >> K;
    
    vector<int> A(N);
    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }
    
    cout << (N - 1 - 1) / (K - 1) + 1 << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  string n;
  cin >>n;
  while(n!="0000"){
    int a[4];
    for(int i=0;i<4;i++){
      stringstream ss;
      ss <<n[i];
      ss >>a[i];
    }
    if((a[0]==a[1])&&(a[1]==a[2])&&(a[2]==a[3])){
      cout <<"NA"<<endl;
      cin >>n;
      continue;
    }
    for(int i=0;i<100;i++){
      if(n=="6174"){
        cout <<i <<endl;
        break;
      }
      sort(a,a+4);
      int l=a[0]+a[1]*10+a[2]*100+a[3]*1000;
      int s=a[3]+a[2]*10+a[1]*100+a[0]*1000;
      int n1=l-s;
      stringstream ss;
      ss << n1;
      ss >> n;
      if(n1<10){
        n.resize(4);
        n[3]=0;
        n[2]=0;
        n[1]=0;
      }else if(n1<100){
        n.resize(4);
        n[3]=0;
        n[2]=0;
      }else if(n1<1000){
        n.resize(4);
        n[3]=0;
      }
        for(int j=0;j<4;j++){
        stringstream ss1;
        ss1 <<n[j];
        ss1 >>a[j];
      }
    }
    cin >>n;
  }
  return 0;
}

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

using namespace std;

int main() {
  string S;
  cin >> S;

  if (S == "Sunny") {
    cout << "Cloudy" << endl;

  } else if (S == "Cloudy") {
    cout << "Rainy" << endl;

  } else {
    cout << "Sunny" << endl;
  }

  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    map<string, int> mp;
    while (n--)
    {
        string s;
        cin >> s;
        mp[s]++;
    }
    int maxi = 0;
    for (auto x:mp)
        maxi = max(maxi, x.second);
    for (auto x:mp)
        if (x.second == maxi)
            cout << x.first << endl;
    return 0;
}

Measured memory_bytes: 25216
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define ll long long
#define pal pair<ll,ll>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

long long MODPOW(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


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

	for(ll i=k;i<n;i++){
		if(a[i]<=a[i-k]){
			cout << "No" << endl;
		}else{
			cout << "Yes" << endl;
		}
	}
}

Measured memory_bytes: 4836