akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#define il inline
#define ri register
#define ll long long
#define Size 100050
using namespace std;
struct point{
	point*next;int to,w;
}*head[Size];
ll sum,ans;
int sz[Size],n,G[3],gt;
void dfs(int,int);
il void read(int&),link(int,int,int);
int main(){
	read(n);
	for(int i(1),u,v,w;i<n;++i)
		read(u),read(v),read(w),
			link(u,v,w),link(v,u,w);dfs(1,0);
	if(gt==2){
		for(point*i(head[G[1]]);i!=NULL;i=i->next)
			if(i->to==G[2]){ans=sum-i->w;break;}}
	else for(point*i(head[G[1]]);i!=NULL;i=i->next)
			 ans=max(ans,sum-i->w);
	return printf("%lld",ans),0;
}
void dfs(int x,int pa){int part(0);
	for(point*i(head[x]);i!=NULL;i=i->next){if(i->to==pa)continue;
		dfs(i->to,x),sz[x]+=sz[i->to],part=max(part,sz[i->to]),
			sum+=(ll)(min(sz[i->to],n-sz[i->to])<<1)*i->w;
	}++sz[x],part=max(part,n-sz[x]);if((part<<1)<=n)G[++gt]=x;
}
il void link(int u,int v,int w){
	head[u]=new point{head[u],v,w};
}
il void read(int &x){
	x^=x;ri char c;while(c=getchar(),c<'0'||c>'9');
	while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
}


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

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

  if (N % 10 ==3) {
    cout << "bon" << endl;
  }
  else if (((N % 10 == 0 || N % 10 ==1) || N%10==6 ) || N%10==8){
    cout << "pon" << endl;
  }
  else{
    cout << "hon" << endl;
  }

}


Measured memory_bytes: 3636
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    6月で水色になるぞ〜!!!
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{one, zero, One, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

pub const MOD: usize = 1000000007;
pub const MAX: usize = 1usize << 63usize;
pub const MIN: i64 = i64::MIN;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 'A' as u8;

// code...
// #[fastout]
fn main() {
    input! {
        v: [i32; 5]
    }

    for (i, a) in v.into_iter().enumerate() {
        if i as i32 + 1 != a {
            println!("{}", i + 1);
            break;
        }
    }
}


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

using namespace std;

int main(){
    vector<int> a(6);
    vector<int> b(6);
    vector<int> c(6);
    for(int i = 0; i < 6; i++){
        cin >> a[i];
    }
    for(int i = 0; i < 6; i++){
        cin >> b[i];
    }
    for(int i = 0; i < 6; i++){
        cin >> c[i];
    }
    int ah = 0;
    int am = 0;
    int as = 0;
    int bh = 0;
    int bm = 0;
    int bs = 0;
    int ch = 0;
    int cm = 0;
    int cs = 0;
    for(int i = 0; i < 1; i++){
        ah = a[3] - a[0];
        am = a[4] - a[1];
        as = a[5] - a[2];
        if(as < 0){
            am--;
            as += 60;
        }
        if(am < 0){
            ah--;
            am += 60;
        }
        cout << ah << " " << am << " " << as << endl;
    }
    for(int i = 0; i < 1; i++){
        bh = b[3] - b[0];
        bm = b[4] - b[1];
        bs = b[5] - b[2];
        if(bs < 0){
            bm--;
            bs += 60;
        }
        if(bm < 0){
            bh--;
            bm += 60;
        }
        cout << bh << " " << bm << " " << bs << endl;
    }
    for(int i = 0; i < 1; i++){
        ch = c[3] - c[0];
        cm = c[4] - c[1];
        cs = c[5] - c[2];
        if(cs < 0){
            cm--;
            cs += 60;
        }
        if(cm < 0){
            ch--;
            cm += 60;
        }
        cout << ch << " " << cm << " " << cs << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

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

    cout << 800*n - (n/15)*200 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
    int a,b,i;
    char x[10];
    char y[10];
    char z[10];
    scanf("%s %s",x,y);
    scanf("%d %d",&a,&b);
    scanf("%s",z);
    if(strcmp(x,z) == 0)
        {
            a = a-1;
        }
    else if(strcmp(y,z) == 0)
        {
            b = b-1;
        }
    printf("%d %d",a,b);
}

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

int main(){
    ll n; cin >> n;

    int ans = 15;

    for(ll i=1; i*i<=n; i++){
        if(n%i == 0){
            ll a = i, b = n/i;
            int len = max(to_string(a).size(), to_string(b).size());
            ans = min(ans, len);
        }
    }

    cout << ans << endl;

}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

ll pow_mod(ll a, ll p) {
  if (p == 0) {
    return 1;
  }
  if (p == 1) {
    return a % MOD;
  }

  if (p % 2 == 0) {
    ll t = pow_mod(a, p / 2);
    return (t * t) % MOD;
  } else {
    return (a * pow_mod(a, p - 1)) % MOD;
  }
}

ll combi_mod(ll n, ll k) {
  ll num = 1;
  ll den = 1;
  for (ll i = 1; i <= k; i++) {
    num = num * (n - i + 1) % MOD;
    den = (den * i) % MOD;
  }

  return (num * pow_mod(den, MOD - 2)) % MOD;
}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  ll ans = (pow_mod(2, n) - 1 + MOD) % MOD;
  ans = (ans - combi_mod(n, a) + MOD) % MOD;
  ans = (ans - combi_mod(n, b) + MOD) % MOD;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//#define NDEBUG

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) (((a) + (b) - 1) / (b))
#define tomax(a, b) ((a) = max((a), (b)))
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}

//#define TEST

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

int main(){
    StarBurstStream

    int n;
    cin >> n;
    string s;
    cin >> s;
    s = " " + s;

    vector<int> l(n + 2), r(n + 2);
    for(int i = 1; i <= n; i++){
        if(s[i] == 'W') l[i]++;
        l[i] += l[i - 1];
    }
    for(int i = n; i > 0; i--){
        if(s[i] == 'E') r[i]++;
        r[i] += r[i + 1];
    }

    int ans = n;
    for(int i = 1; i <= n; i++){
        ans = min(ans, l[i - 1] + r[i + 1]);
    }
    cout << ans << "\n";

    return 0;
}

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

int main() {
        int n;
        scanf("%d", &n);
        int N = 101010;
        vector<vector<int>> g(2 * N);
        rep(i, n) {
                int x, y;
                scanf("%d%d", &x, &y);
                x --, y --;
                g[x].push_back(y + N);
                g[y + N].push_back(x);
        }
        vector<bool> used(2 * N);
        int x = 0, y = 0;
        function<void (int)> dfs = [&](int u) {
                if (u < N) x ++;
                else y ++;
                used[u] = true;
                for (auto v : g[u]) if (!used[v]) {
                        dfs(v);
                }
        };
        long long ans = -n;
        rep(i, 2 * N) {
                if (!used[i]) {
                        x = 0, y = 0;
                        dfs(i);
                        ans += (long long) x * y;
                }
        }
        printf("%lld\n", ans);
        return 0;
}


Measured memory_bytes: 11008
#include <iostream>

using namespace std;

int main() {
  string S;
  cin >> S;
  bool n = S.find('N') != S.npos;
  bool e = S.find('E') != S.npos;
  bool w = S.find('W') != S.npos;
  bool s = S.find('S') != S.npos;

  cout << (n == s && w == e ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<string>

using namespace std;
long long n;
int a[10+10][100+10],dp[10+10][100+10];
int main()
{
	cin>>n;
	for(int i=1;i<=2;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=2;i++)
	{
		for(int j=1;j<=n;j++)
		{
			dp[i][j]=max(dp[i-1][j],dp[i][j-1])+a[i][j];
		}
	}
	cout<<dp[2][n];
	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
ans=0
lis=[0 for i in range(n)]
for i in range(k):
  d=int(input())
  ll=list(map(int,input().split()))
  #print(ll)
  for j in ll:
    lis[j-1]+=1
for i in lis:
  if i==0:
    ans+=1
    
print(ans)

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct UF{
    vector<int>par,sz;
    void init(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};

signed main(){
    int V,d;
    while(cin>>V>>d){
        int a=1,b=1;
        UF uf;uf.init(V);
        int F[1000];
        rep(i,V){
            F[i]=(a+b)%1001;

            b=a;a=F[i];
        }
        rep(i,V)rep(j,V)if(abs(F[i]-F[j])<d)uf.unite(i,j);
        int ans=0;
        rep(i,V)if(uf.find(i)==i)ans++;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 2984
#include<stdio.h>
#define MAX 500000

void maxHeapify(int A[], int i,int N)
{
  int l,r,temp,largest;

  l=i*2;
  r=i*2+1;

  if(l<=N && A[l]>A[i]) largest=l;
  else largest=i;

  if(r<=N && A[r]>A[largest]) largest=r;

  if(largest!=i){
    temp=A[i];
    A[i]=A[largest];
    A[largest]=temp;
    maxHeapify(A, largest, N);
  }
  
}
    
int main()
{
  int i;
  int N,A[MAX];
  
  scanf("%d",&N);
  for(i=1;i<N+1;i++) scanf("%d",&A[i]);

  for(i=N/2;i>0;i--) maxHeapify(A, i, N);

  for(i=1;i<N+1;i++) printf(" %d",A[i]);
  printf("\n");

  return 0;

}





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

 int main() {
 int a, b, c, k;
 cin >> a >> b >> c >> k;
 if(k <= a) cout << k << endl;
 else if(k <= a + b) cout << a << endl;
 else cout << a - (k - a - b) << endl;
 return 0;
}

Measured memory_bytes: 3600
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
int a[1234];
int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int i;
    rep(i,n){
    	cin>>a[i];
    }
    int ans=0;
    int col=1000;
    f(i,1,n){
    	if(a[i]==a[i-1]){
    		ans++;
    		a[i]=-1;
    	}
    }
    cout<<ans<<endl;
    return 0;  
    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main(){
  int a, b;
  cin >> a >> b;
  cout << a*b << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9

using ll = long long;
const ll mod = 100000000+7;
const ll MAX_N = 1000;

int d[110][110],a[1010],b[1010],c[1010];
int n,m,x,y,z,ans;
int main(){
  cin>>n>>m;

  rep(i,n)rep(j,n){
    if(i==j)d[i][j]=0;
    else d[i][j]=INF;
  }

  rep(i,m){
    cin>>x>>y>>z;
    x--;y--;
    a[i]=x;
    b[i]=y;
    c[i]=z;
    d[x][y]=z;
    d[y][x]=z;
  }





  rep(k,n)rep(i,n)rep(j,n)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);

  ans=m;
  for(int i=0;i<m;i++){
    bool flag=false;
    for(int j=0;j<n;j++){
      if(d[j][a[i]]+c[i]==d[j][b[i]])flag=true;
    }
    if(flag)ans--;
  }
  cout<<ans<<endl;
}


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

using namespace std;

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

  if (abs(c - a) <= d) {
    cout << "Yes" << endl;
  } else if (abs(c - b) <= d && abs(b - a) <= d) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# sys.stdin.readline()
import sys
input = sys.stdin.readline
import math
a,b,N = map(int,input().split())
ans = 0
if b <= N :
    ans = math.floor(a*(b-1)/b)-a*math.floor((b-1)/b)
elif b > N:
    ans = math.floor(a*N/b)-a*math.floor(N/b)


print(ans)

Measured memory_bytes: 9184
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def f(n):
    if n % 2 == 0:
        a = n // 2
        if a % 2 == 0:
            return n
        else:
            return n ^ 1
    else:
        a = n // 2
        if a % 2 == 0:
            return 1
        else:
            return 0


def main():
    A, B = map(int, input().split())
    a = f(A - 1)
    b = f(B)
    answer = a ^ b

    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int N;cin>>N;
    vector<vector<int>> G(N);
    vector<pair<int,int>> edge;
    int a,b;
    REP(i,N-1){
        cin>>a>>b;a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
        edge.push_back(make_pair(a,b));
    }
    vector<int> parent(N,-1);
    vector<int> color(N,-1);
    queue<int> que;
    color[0]=0;
    que.push(0);
    while(!que.empty()){
        int nc=1;
        int v=que.front();que.pop();
        for(auto w:G[v]){
            if(color[w]==-1){
                if(nc==color[v])nc++;
                parent[w]=v;
                color[w]=nc;
                nc++;
              	que.push(w);
            }
        }
    }
	int K=1;REP(i,N)K=max(K,color[i]);
  cout<<K<<endl;
    REP(i,N-1){
        int p=edge[i].first,q=edge[i].second;
        cout<<(parent[p]==q?color[p]:color[q])<<endl;
    }
    return 0;
}

Measured memory_bytes: 7668
// Copyright 2020 yaito3014
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for (auto& e : A) std::cin >> e;
  std::sort(rbegin(A), rend(A));
  std::map<int, int, std::greater<int>> m;
  ++m[A[0]];
  long long ans = 0;
  for (int i = 1; i < N; ++i) {
    ans += cbegin(m)->first;
    --begin(m)->second;
    m[A[i]] += 2;
    if (cbegin(m)->second == 0) m.erase(cbegin(m));
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 8792
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

point = 0

for i in range(n):
    num = a[i] -1
    point += b[num]
    
    j = i -1
    
    if a[i] == a[j]+1 and a[i] > a[j] and j >=0:
        
        k = a[i] - 1 - 1 
        point += c[k]
    
print(point)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
    int i, n, num, min, max;
    long long total;

    cin >> n;
    cin >> num;

    min = num;
    max = num;
    total = num;

    for (i = 1; i < n; i++) {
        cin >> num;
        if (num < min) min = num;
        if (num > max) max = num;
        total += num;
    }

    cout << min << " " << max << " " << total << endl;
     
    return 0;
}


Measured memory_bytes: 3092
require 'pp'
     
n, q = gets.chomp!.split(" ").map(&:to_i)
$tree = {}

# O(n)
(n - 1).times do |i|
    a, b = gets.chomp!.split(" ").map(&:to_i)
    $tree[a] ||= {}
    $tree[a][b] = 0
end
 
# O(n)
scores = {}
n.times do |i|
    scores[i+1] = 0
end
    
# O(q)
operations = []
q.times do |_|
    p, x = gets.chomp!.split(" ").map(&:to_i)
    scores[p] += x
end
    
#pp scores
#pp $tree
ans = Array.new(n - 1, 0)
tmp = [[1, 0]]
while tmp.empty?.!
    d, score = tmp.pop
    ans[d - 1] = score + scores[d]
    
    next unless $tree[d]
    $tree[d].each do |k, _|
        tmp.push([k, ans[d - 1]])
    end
end

puts ans.join(" ")


Measured memory_bytes: 91132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main ()
{
    int N, Max = 0, ans = 0;
    cin >> N;
    int H[N];
    for (int i = 0; i < N;i++)
    {
        cin >> H[i];
    }
    for (int i = 0; i < N-1;i++)
    {
        if (H[i] >= H[i + 1])
        {
            Max++;
        }else {
            Max = 0;
        }
        ans = max(ans,Max);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr front()
#define tp top()
typedef long long int ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <pii, int> ppi;
typedef pair <int, pii> pip;
#define iofast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define iofile freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
const ll LLINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1);
const int SIZE = 100005;

string S;
int cnt[26];

int main (){
	
	memset(cnt,0,sizeof(cnt));
	iofast;
	
	cin>>S;
	int n=S.size();
	for(int i=0;i<n;i++){
		cnt[S[i]-'a']++;
	}
	int Mn=min(cnt[0],min(cnt[1],cnt[2]));
	int Mx=max(cnt[0],max(cnt[1],cnt[2]));
	if(Mx-1==Mn || Mx==Mn){
		cout<<"YES"<<endl;
	} else cout<<"NO"<<endl;
	
	return 0;
}

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

int main ()
{

	int a, b;
	cin >> a >> b;
	if( a < b ){
		cout << "a < b" << endl;
}
    else if ( a > b ){
    	cout << "a > b" << endl;
}
    else if ( a == b ){
	    cout << "a == b" << endl;
}
}

Measured memory_bytes: 1156
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	int N,K;
	int[] V;
	
	int[] f(int a, int b) {
		int[] result = new int[a+b];
		
		for(int i=0;i<a;i++) {
			result[i] = V[i];
		}
		for(int i=0;i<b;i++) {
			result[result.length-i-1] = V[V.length-i-1];
		}
		return result;
	}
	
	int negNum(int[] a) {
		int result = 0;
		for(int i=0;i<a.length;i++) {
			if(a[i] < 0) {
				result++;
			}else {
				break;
			}
		}
		return result;
	}
	
	int solv() {
		int ans = Integer.MIN_VALUE;
		for(int a=0;a<=Math.min(N, K);a++) {
			for(int b=0;b<=Math.min(N, K)-a;b++) {
				int[] arr = f(a,b);
				Arrays.sort(arr);
				int nn = negNum(arr);
				int sum = 0;
				for(int i=Math.min(nn, K-(a+b)); i<arr.length; i++) {
					sum += arr[i];
				}
				ans = Math.max(ans, sum);
			}
		}
		return ans;
	}
	
	
	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		N = sc.nextInt();
		K = sc.nextInt();
		
		V = new int[N];
		
		for(int i=0;i<N;i++) {
			V[i] = sc.nextInt();
		}
		
		out.println(solv());
		
		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 24660
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int[] c = new int[N];
		for (int i = 0; i < N; i++) {
			c[i] = i + 1;
		}
		int[] a = new int[N];
		for (int i = 0; i < N; i++) {
			a[i] = in.nextInt();
		}
		int[] b = new int[N];
		for (int i = 0; i < N; i++) {
			b[i] = in.nextInt();
		}

		int P = 0;
		int Q = 0;
		int count = 1;
		do {
			if (Arrays.equals(c, a)) {
				P = count;
			}
			if (Arrays.equals(c, b)) {
				Q = count;
			}
			count++;
		} while (nextPermutation(c));
		System.out.println(Math.abs(P - Q));
		in.close();
	}

	static boolean nextPermutation(int[] array) {
		int i = array.length - 1;
		while (i > 0 && array[i - 1] >= array[i])
			i--;

		if (i <= 0)
			return false;

		int j = array.length - 1;
		while (array[j] <= array[i - 1])
			j--;

		int temp = array[i - 1];
		array[i - 1] = array[j];
		array[j] = temp;

		j = array.length - 1;
		while (i < j) {
			temp = array[i];
			array[i] = array[j];
			array[j] = temp;
			i++;
			j--;
		}

		return true;
	}
}

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

map<int, int> fac(int n) {
    map<int, int> A;
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) A[i]++, n /= i;
    }
    if (n != 1) A[n]++;
    return A;
}

signed main() {
    int n;
    cin >> n;
    map<int, int> m = fac(n);
    int ans = 0;
    for (auto i : m) {
        int t = 1;
        while (i.second - t >= 0) i.second -= t, t++, ans++;
    }
    cout << ans;
}


Measured memory_bytes: 3632
n = int(input())
x = [(i, int(j)) for i, j in enumerate(input().split())]
x.sort(key=lambda x:x[1])
l = x[n//2-1][1]
r = x[n//2][1]
ans = [None]*n
for ind, (i, j) in enumerate(x):
    if ind<n//2:
        ans[i] = r
    else:
        ans[i] = l

for i in ans:
    print(i)

Measured memory_bytes: 45496
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;
const int NN = 11000;
typedef long long ll;

int k;
int a[100] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
	//freopen("a.in", "r", stdin);
	//freopen("a.out", "w", stdout);
	
	scanf("%d", &k);
	//for (int i=0; i<20; i++) printf("%d ", a[i]);
	printf("%d", a[k-1]);
	
	return 0;
} 

Measured memory_bytes: 256
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N,A,B = MI()
X = LI()

# 左から考えていく

print(sum(min(B,A*(X[i+1]-X[i])) for i in range(N-1)))


Measured memory_bytes: 85412
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin >> n;
    pair<long long,long long> d[n];
    for(int i=0;i<n;i++)cin >> d[i].second >> d[i].first;
    sort(d,d+n);
    int count=0;
    int flag=1;
    for(int i=0;i<n;i++){
        count+=d[i].second;
        if(count>d[i].first)flag=0;

    }
    if(flag)cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3328
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <random>
#include <chrono>
using namespace std;

const int mod = 998244353;

const int maxn = 3005;

int dp[maxn][maxn];

void add(int &a, int b){
    a += b;
    if(a > mod)
        a -= mod;
}

int n, s, a[maxn];

int main(){
    cin >> n >> s;
    for(int i = 1;i <= n;i++){
        scanf("%d", &a[i]);
    }
    for(int i = 1;i <= n;i++){
        for(int j = 1;j < s;j++){
            dp[i][j] = dp[i - 1][j];
        }
        add(dp[i][a[i]], i);
        for(int j = a[i] + 1;j <= s;j++){
            add(dp[i][j], dp[i - 1][j - a[i]]);
        }
    }
    int ans = 0;
    for(int i = 1;i <= n;i++){
        //cout << dp[i][s] << endl;
        add(ans, 1LL * dp[i][s] * (n + 1 - i) % mod);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 35456
#include <stdio.h>

int main(){
  long A,B,V,W,T;
  scanf("%ld %ld", &A, &V);
  scanf("%ld %ld", &B, &W);
  scanf("%ld", &T);
  if(A<B){
    if (A+V*T>=B+W*T){
        printf("YES");
      }
    else{
        printf("NO");
      }
  }

  if(A>B){
    if (A-V*T<=B-W*T){
        printf("YES");
      }
    else{
        printf("NO");
      }
  }

  return 0;
}


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

int main () {
    int count = 0;
    string L;
    cin >> L;

    for (int i = 0; i < L.size(); i++) {
        if (L.at(i) == '1') {
            count++;
        }
    }
  
    cout << count << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x,y;
  cin>>x>>y;
  if(x==1 &&(y==2||y==4)) cout<<"Yes\n";
  else if(x>1 && y%2==0 && y>=2*x && y<=4*x) cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}


Measured memory_bytes: 3548
#include <stdio.h>

int main()
{
	int ts, h, m, s;
	scanf("%d", &ts);

	s = ts % 60;
	m = ts / 60 % 60;
	h = ts / 60 / 60;
	
	printf("%d:%d:%d\n", h, m, s);

	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,i,f,r;
	bool c[21][21];
	char ch;
	while(cin>>i,i){
		memset(c,0,sizeof(c));
		while(i--)cin>>a>>b,c[a][b]=1;
		cin>>i,a=b=10;c[a][b]=0;
		while(i--){
			cin>>ch>>f;
			while(f--){
				switch (ch) {
					case 'N':b++;break;
					case 'E':a++;break;
					case 'S':b--;break;
					case 'W':a--;break;
				}
				c[a][b]=0;
			}
		}
		a=b=20,f=0;
		while(a--)for(r=0;r<21;r++)if(c[a][r])f++;
		cout<<(f?"No":"Yes")<<endl;
	}
}

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

int main() {
    //入力
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for (int i = l; i <= r; i++) {
        if (i % d == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main() {
	long double xa, xb, xc, xd, ya, yb, yc, yd;
	while (cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd) {
		if (xa == xb) {
			if (yc == yd)cout << "YES\n";
			else cout << "NO\n";
		}
		else if (xc == xd) {
			if (ya == yb)cout << "YES\n";
			else cout << "NO\n";
		}
		else if (ya == yb || yc == yd)cout << "NO\n";
		else {
			long double ab = (ya - yb) / (xa - xb);
			long double cd = (yc - yd) / (xc - xd);
			if (ab*cd == -1)cout << "YES\n";
			else cout << "NO\n";
		}
	}
}

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

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

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string s;cin >> s;
  vector<vector<int> > v(26);
  int ans = MAX_I;
  rep(i,26){
    int pre = 0;
    int a = 0;
    char c = 'a'+i;
    rep(i,s.length()){
      if(s[i] == c){
        a = max(a,i-pre);
        pre = i+1;
      }
    }
    a = max(a,(int)s.length()-pre);
    ans = min(ans,a);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
data = [[int(i) for i in l] for l in data]
data.insert(0, [0, 0, 0])
for i, l in enumerate(data):
    if i == 0:
        continue
    distance = abs(l[1]-data[i-1][1])+abs(l[2]-data[i-1][2])
    step_diff = l[0]-data[i-1][0]
    if step_diff%2 == distance%2 and distance <= step_diff:
        continue
    else:
        print('No')
        sys.exit()
print('Yes')


Measured memory_bytes: 50256
import sys


RS = lambda: sys.stdin.readline()[:-1]
RI = lambda x=int: x(RS())
RA = lambda x=int: map(x, RS().split())
RSS = lambda: RS().split()


def solve():
    ans = []
    for i in s:
        if i == "P":
            ans.append("P")
        else:
            ans.append("D")
    print("".join(ans))
    return



s = RS()
solve()

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

int gcd(int x, int y);

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int main() {
    int n;
    cin >> n;
    vector<ll> a(3 * n);
    rep(i,3 * n) cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = 0;

    for (int i = 3 * n - 2; i >= n; i -= 2) {
        ans += a[i];
    }

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

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

Measured memory_bytes: 2560
package main

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

var (
	h, w int
	s    []string
	ch   = make(chan [][]int, 4)
)

func calcLeft() {
	ls := make([][]int, h)
	for i := range ls {
		ls[i] = make([]int, w)
		for j := 0; j < w; j++ {
			if s[i][j] == '#' {
				ls[i][j] = 0
				continue
			}
			if j == 0 {
				ls[i][j] = 1
				continue
			}
			ls[i][j] = ls[i][j-1] + 1
		}
	}
	ch <- ls
}

func calcRight() {
	rs := make([][]int, h)
	for i := range rs {
		rs[i] = make([]int, w)
		for j := w - 1; j >= 0; j-- {
			if s[i][j] == '#' {
				rs[i][j] = 0
				continue
			}
			if j == w-1 {
				rs[i][j] = 1
				continue
			}
			rs[i][j] = rs[i][j+1] + 1
		}
	}
	ch <- rs
}

func calcTop() {
	ts := make([][]int, h)
	for i := range ts {
		ts[i] = make([]int, w)
	}
	for j := 0; j < w; j++ {
		for i := 0; i < h; i++ {
			if s[i][j] == '#' {
				ts[i][j] = 0
				continue
			}
			if i == 0 {
				ts[i][j] = 1
				continue
			}
			ts[i][j] = ts[i-1][j] + 1
		}
	}
	ch <- ts
}

func calcDown() {
	ds := make([][]int, h)
	for i := range ds {
		ds[i] = make([]int, w)
	}
	for j := 0; j < w; j++ {
		for i := h - 1; i >= 0; i-- {
			if s[i][j] == '#' {
				ds[i][j] = 0
				continue
			}
			if i == h-1 {
				ds[i][j] = 1
				continue
			}
			ds[i][j] = ds[i+1][j] + 1
		}
	}
	ch <- ds
}

func main() {
	fmt.Scan(&h, &w)

	sc := bufio.NewScanner(os.Stdin)
	s = make([]string, h)
	for i := range s {
		sc.Scan()
		s[i] = sc.Text()
	}

	go calcLeft()
	go calcRight()
	go calcTop()
	go calcDown()

	s1 := <-ch
	s2 := <-ch
	s3 := <-ch
	s4 := <-ch
	ans := 0
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if v := s1[i][j] + s2[i][j] + s3[i][j] + s4[i][j] - 3; v > ans {
				ans = v
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 138256
#include<stdio.h>
int main(){
  int w,n,a[100],b[100],l[100],i,j,m;
  scanf("%d %d",&w,&n);
  for(i=0;i<w;i++){
    l[i]=i+1;
  }
  for(i=0;i<n;i++){
    scanf("%d,%d",&a[i],&b[i]);
    }
  for(i=0;i<n;i++){

    m=l[b[i]-1];
    l[b[i]-1]=l[a[i]-1];
    l[a[i]-1]=m;
    
  }
  for(i=0;i<w;i++){
    printf("%d\n",l[i]);
  }
  return (0);
}
    

Measured memory_bytes: 596
import sys
S = list(input())
T = [int(a) for a in S]
N = len(T)

if N == 1:
  print(T[0])
  sys.exit()
  
ans = 0
for i in range(2 ** (N-1)):
  i_ = i
  j = 1
  tmp = T[0]
  while j < N:
    #print(i,i_,j,N)
    if i_ % 2 == 0:
      tmp *= 10
      tmp += T[j]
    if i_ % 2 == 1:
      ans += tmp
      tmp = T[j]
    i_ = i_ >> 1
    j += 1
  ans += tmp
  #print(ans,i)
    
print(ans)  

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 998244353LL
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll n,x,m;cin>>n>>x>>m;
  if(x==0){cout<<0<<endl; return 0;}

  vector<ll>l;
  ll c = x;
  map<int, int>mm;

  rep(i, 100000*4){
    mm[c]++;
    l.push_back(c);
    c = c*c%m;
  }

  if(n<=100000){
    ll result = 0;
    rep(i, n)result += l[i];
    cout<<result<<endl;

    return 0;
  }


  int loop_len = 0;
  ll loop_sum=0;
  for(auto p:mm)if(p.second>2){
    loop_len++;
    loop_sum += p.first;
  }
  int first_amari=0;
  ll first_sum=0;
  rep(i, m)if(mm[l[i]]==1){
    first_amari++;
    first_sum += l[i];
  }

  vector<ll>loop;
  rep(i, m*4){
    if(mm[l[i]]>1)loop.push_back(l[i]);
    if(loop.size()>1 && loop[0]==l[i])break;
  }

  ll result = first_sum;
  n -= first_amari;
  result += n/loop_len*loop_sum;
  n%=loop_len;
  rep(i, n)result += loop[i];

  cout<<result<<endl;

  return 0;
}


Measured memory_bytes: 9652
N, C = map(int, input().split())

STC = [tuple(map(int, input().split())) for i in range(N)]
STC.sort()

rec = []
for i in range(N):
    isFree = False
    for j in range(len(rec)):
        if (rec[j][0] < STC[i][0] and rec[j][1] != STC[i][2]) or (rec[j][0] <= STC[i][0] and rec[j][1] == STC[i][2]):
            isFree, rec[j] = True, (STC[i][1], STC[i][2])
            break
    if not isFree:
        rec.append((STC[i][1], STC[i][2]))

print(len(rec))


Measured memory_bytes: 17820
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int n,m,q;
int a[55],b[55],c[55],d[55];
int check(vector<int> v){
    int ret = 0;
    rep(i,q){
        if(v[b[i]] - v[a[i]] == c[i])ret += d[i];
    }
    return ret;
}
int dfs(int d,vector<int> &v){
    if(d == n)return check(v);
    int ret = 0;
    for(int i = 1;i <= m;i++){
        if(v.size() && v.back() > i)continue;
        v.push_back(i);
        ret = max(ret,dfs(d+1,v));
        v.pop_back();
    }
    return ret;
}
signed main(){
    cin >> n >> m >> q;
    rep(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;b[i]--;
    }
    vector<int> v;
    cout << dfs(0,v) << endl;

    return 0;
}

Measured memory_bytes: 3600
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, m: usize,
        xy: [(Usize1, Usize1); m]
    }

    let mut graph = vec![Vec::new(); n];
    for (x, y) in xy {
        graph[x].push(y);
    }

    let mut dp = vec![1<<30; n];
    let mut ans = 0;
    for node in 0..n {
        ans = max(ans, rec(node, &graph, &mut dp));
    }
    println!("{}", ans);
}

fn rec(node: usize, graph: &[Vec<usize>], dp: &mut [usize]) -> usize {
    if dp[node] < 1<<30 {
        return dp[node];
    }
    let mut res = 0;
    for &next in &graph[node] {
        res = max(res, rec(next, graph, dp) + 1);
    }
    dp[node] = res;
    res
}


Measured memory_bytes: 12504
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl


/*--------------------template--------------------*/


int main() {
    cin >> s;
    if (s[0] == '9' || s[1] == '9') {
        cout << "Yes" << Endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//  
//

#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)

using ll = long long;

template<class T> inline bool chmin(T& a, T b){ if(a>b){a=b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b){ if(a<b){a=b; return 1;} return 0;}

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
// const double PI=3.1415926535897932;

//#define __DBG__


void solve(void){
  
  int N;
  
  cin >> N;
  
  vector<double> A(N);
 
  double sum=0;
  REP(i,N){
    double tmp;
    cin >> tmp;
    A[i]=1/tmp;
    sum+= A[i];
  }
  
  double ans=1/sum;
  
  cout << fixed << setprecision(15);
  cout << ans << endl;
  
  
  return;
   
}


int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();
 
    return 0;
}





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

int main(){
  int x,y;
  cin >> x >> y;
  int g1[7] = {1,3,5,7,8,10,12};
  int g2[4] = {4,6,9,11};
  int g3[1] = {2};
  bool f1 = false,f2 = false;
  for(int i=0;i < 7;i++){
    if(g1[i] == x)
      f1 = true;
    if(g1[i] == y)
      f2 = true;
    if(f1 & f2){
      cout << "Yes" << endl;
      return 0;
    }
  }
  f1 = false;
  f2 = false;
  for(int i=0;i < 4;i++){
    if(g2[i] == x)
      f1 = true;
    if(g2[i] == y)
      f2 = true;
    if(f1 & f2){ 
      cout << "Yes" << endl;
      return 0; 
    }
  }  
  if(x == 2 && y == 2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
} 


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

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

	return 0;
}


Measured memory_bytes: 3076
N = int(input())
vH = list(map(int, input().split()))

vR = [0,]
p = vH[0]
tmpcnt = 0
for i in range(1, N):
    if p >= vH[i]:
        tmpcnt += 1
        p = vH[i]
    else:
        vR.append(tmpcnt)
        p = vH[i]
        tmpcnt = 0
vR.append(tmpcnt)

# print(vR)

res = max(vR)
print(res)


Measured memory_bytes: 15020
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d long double
#define pii pair<int,int>
#define pb push_back
#define pf push_front
#define cases int t;cin>>t;while(t--)
#define N 100003
#define M 103
#define inf LLONG_MAX
//int mod=1e9+7;
//int mod=998244353;

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    d x[6];
    int i,j,a;
    for(i=1;i<=5;++i)
        cin>>x[i];

    sort(x+1,x+6);
    int ans=inf,temp;
    do
    {
        temp=0;
        for(i=1;i<=4;++i)
        {
            temp+=ceil(x[i]/10.0)*10.0;
        }
        temp+=x[5];
        ans=min(ans,temp);
    }while(next_permutation(x+1,x+6));
    cout<<ans;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;


int main() {
  string s;
  cin >> s;
  if (s.substr(5,2) > "04"){
    cout << "TBD" << endl;
    return 0;
  }
  else cout << "Heisei" << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

string cut_head(string s){
    if(s.size()>1){
        return s.substr(1);
    }else{
        return "";
    }
}

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

    // input
    string sa, sb, sc;
    cin >> sa >> sb >> sc;

    char c = 'a';
    
    while(true){
        if(c=='a'){
            if(sa.size()==0){
                p('A');
                return 0;
            }
            c = sa[0];
            sa = cut_head(sa);
        }
        else if(c=='b'){
            if(sb.size()==0){
                p('B');
                return 0;
            }
            c = sb[0];
            sb = cut_head(sb);
        }
        else if(c=='c'){
            if(sc.size()==0){
                p('C');
                return 0;
            }
            c = sc[0];
            sc = cut_head(sc);
        }        
    }
    
    return 0;
}

Measured memory_bytes: 256
/*
 * Created by KeigoOgawa
 */


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <cmath>

#define INF (int)1e8
#define EPS 1e-10
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define debug(x) cout << #x << ": " << x << endl
#define all(a) (a).begin(), (a).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;

const int MAX_N = 1e5;
int N, L;
int a[MAX_N];

void solve() {
  int s = -1;
  REP(i, N - 1) {
    if (a[i] + a[i + 1] >= L) {
      s = i + 1;
      break;
    }
  }
  if (s == -1 ) {
    cout << "Impossible" << endl;
  } else {
    cout << "Possible" << endl;
    RFOR(i, s, N - 1) {
      cout << i+1 << endl;
    }
    FOR(i, 0, s) {
      cout << i+1 << endl;
    }
  }
}

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

  cin >> N >> L;
  REP(i, N) {
    cin >> a[i];
  }
  solve();
  return 0;
}


Measured memory_bytes: 1280