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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const long long MOD = 2;

int main(){
    int n, m;
    cin >> n >> m;
    vi k(m), s(n, 0);
    rep(i, m) {
        cin >> k[i];
        rep(j, k[i]) {
            int si;
            cin >> si;
            --si;
            s[si] |= 1<<i;
        }
    }
    int p = 0;
    rep(i, m) {
        int pi;
        cin >> pi;
        p |= pi<<i;
    }
    int ans = 0;
    rep(i, 1<<n) {
        int t = 0;
        rep(j, n) {
            if (i>>j&1) t ^= s[j];
        }
        if (t == p) ++ans;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){

  int N; cin >> N;
  int A[N+1], B[N];
  for(int i=0; i < N+1; i++){
    cin >> A[i];
  }
  for(int i=0; i < N; i++){
    cin >> B[i];
  }

  long long ans = 0;
  for(int i=0; i < N; i++){
      long v;
      v = min(A[i], B[i]);
      ans += v;
      B[i] = max(0, B[i]-A[i]);
      v = min(A[i+1], B[i]);
      ans += v;
      A[i+1] = max(0, A[i+1]-B[i]);
  }

  cout << ans << endl;

}

Measured memory_bytes: 1024
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e3 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
bool b[N];
int a[N][N], p[N];
 
signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n;	cin >> n;
	for(int i = 1; i <= n; i++){
		p[i] = 1;
		for(int j = 1; j <= n-1; j++)
			cin >> a[i][j];
	}	
	int d = 0;
	while(d<100000){
		for(int i = 1; i <= n; i++)
			b[i] = 0;
		d++;
		bool flag = 0;
		int c = 0;
		for(int i = 1; i <= n; i++){
			if(p[i] > n-1){
				c++;	
				continue;
			}
			int r = a[i][p[i]];
			if(a[r][p[r]] == i && !b[i] && !b[r]){
				flag = 1;
				p[i]++;	b[i] = 1;
				p[r]++;	b[r] = 1;
			}
		}
		if(c == n)
			return cout << d-1, 0;
		if(!flag)
			return cout << -1, 0;
	}
	cout << n*(n-1)/2;
	return 0;
}

Measured memory_bytes: 4224
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int graph[15][15];

int v=0;

int main(void){
	int n;
	while(cin >> n,n){
		rep(i,15)rep(j,15) graph[i][j]=(i==j)?0:inf;
		v=-1;
		rep(i,n){
			int a,b,c;
			cin >> a >> b >> c;
			v=max(v,max(a,b)+1);
			graph[a][b]=graph[b][a]=c;
		}
		rep(k,v)rep(i,v)rep(j,v){
			graph[i][j]=min(graph[i][j],graph[i][k]+graph[k][j]);
		}
		int ansv=-1,anst=inf;

		rep(i,v){
			int cur=0;
			rep(j,v) cur+=graph[i][j];
			if(cur<anst)
				anst=cur,ansv=i;
		}

		cout << ansv <<  " " << anst << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
W, H, x, y = list(map(int,input().split()))
judge = 0
#綺麗に二等分するのが面積は最善である。
area = float(W * H / 2)
#(x,y)を通るときもう一点は自動的に(y,x)になる。だがx == yの時は別に考える。
"""
・図形を二等分する直線が二つ以上ある
・その二つの直線の中点が重なりそれが点(x,y)となる
この二つの条件を満たせば複数の分割法があると言える。
これを考えるとW,Hが偶数値で、x,yはそれぞれx = W/2, y = H/2でなくてはならない
"""
if W % 2 == 0 and H % 2 == 0:
  if x == int(W / 2) and y == int(H / 2):
    judge += 1
#結果
print(area, judge)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

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

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];
int s[11][11];

int main() {
	int n, m;
	cin >> n >> m;
	ll ans = 1900*m+(n - m) * 100;
	rep(i, m) {
		ans *= 2;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
  int x, y;

  while( cin >> x >> y && (x != 0 || y != 0) )
    {
      if ( x < y )
        {
          cout << x << " " << y << endl;
        }
      else
        {
          cout << y << " " << x << endl;
        }
    }
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<algorithm>
#include <iostream>
using namespace std;
typedef long long LL;

int main(){
	int n,x;
    while(~scanf("%d %d", &n,&x)){
        int a[n];
		for(int i = 0; i < n; i++){
            scanf("%d",&a[i]);
        }
        LL ans = 0;
        if ( a[0] > x ){
        	ans = a[0] - x;
            a[0] = a[0] - ans;
        }
        for(int i = 1; i < n; i++){
            if(a[i]+a[i-1] > x){
                ans += a[i]+a[i-1]-x;
                a[i] =a[i]-(a[i]+a[i-1]-x);
            }
        }
        printf("%lld\n",ans);
    }
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);

int N, A, B;
bool solve(vector<int>h, const int S) {
	int ans = 0;
	rep(i, N) {
		h[i] -= S*B;
		h[i] = (h[i] + A - 1) / A;
		ans += max(int(0), h[i]);
	}
	if (ans <= S)return true;
	return false;
}

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

	cin >> N >> A >> B;
	A -= B;
	vector<int>h(N);
	rep(i, N)cin >> h[i];

	sort(ALL(h), greater<int>());

	int lb = 0, ub = 1000000000;
	while (lb + 1 < ub) {
		int mid = (lb + ub) / 2;
		if (solve(h, mid)) {
			ub = mid;
		}
		else lb = mid;
	}
	cout << ub << endl;


	return 0;
}





Measured memory_bytes: 1792
//Rishabh Sethi @lostground97

#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define in insert
#define mod 1000000007
#define vpair vector< pair <ll,ll> >

ll modexp(ll x, ll y)
{
	ll ans = 1;
	x = x%mod;
	while(y>0)
	{
		if(y%2==1)
			ans = (ans%mod*x%mod)%mod;
		y = y/2;
		x = (x%mod*x%mod)%mod;
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, t;
	cin>>n>>t;
	int c = 1005;
	for(int i=0; i<n; i++)
	{
		int x, y;
		cin>>x>>y;
		if(y<=t)
		{
			if(c>x)
			{
				c = x;
			}
		}
	}
	if(c==1005)
	{
		cout<<"TLE\n";
	}
	else
	{
		cout<<c<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(ll i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
//const ll MOD = 1000000007ll;
const ll MOD = 998244353ll;
const dou pi=3.141592653589793;

//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう
class Radix { //n進数に変換
// Radix rと宣言してからr.to(a,b)で変換
//pをq進数にする
private:
  const char* s;
  int a[100000];
public:
  Radix(const char* s = "0123456789ABCDEF") : s(s) {
    int i;    for(i = 0; s[i]; ++i)

      a[(int)s[i]] = i;
  }
  std::string to(long long p, int q) {
    int i;
    if(!p)
      return "a";
    char t[64000] = { };
    for(i = 62000; p; --i) {
      t[i] = s[p % q];
      p /= q;
    }
    return std::string(t + i + 1);
  }
  std::string to(const std::string& t, int p, int q) {
    return to(to(t, p), q);
  }
  long long to(const std::string& t, int p) {
    int i;
    long long sm = a[(int)t[0]];
    for(i = 1; i < (int)t.length(); ++i)
      sm = sm * p + a[(int)t[i]];
    return sm;
  }
};
int main(){
    int n,k;
    std::cin >> n>>k;
    Radix r;
    string d=r.to(n,k);
    std::cout << d.size() << std::endl;
}



Measured memory_bytes: 256
n = int(input())
s = []
for i in range(n):
    s.append(input())

dic = {}
dic['AC'] = 0
dic['WA'] = 0
dic['TLE'] = 0
dic['RE'] = 0

for i in s:
    if i =='AC':
        dic['AC'] += 1
    elif i =='WA':
        dic['WA'] += 1
    elif i == 'TLE':
        dic['TLE'] += 1
    else:
        dic['RE'] += 1

print('AC x ' + str(dic['AC']))
print('WA x ' + str(dic['WA']))
print('TLE x ' + str(dic['TLE']))
print('RE x ' + str(dic['RE']))


Measured memory_bytes: 16196
K = int(input())
li = [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]
print(li[K-1])

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int x = scanner.nextInt();
        int pos = 0;
        int ans = 1;
        for (int i = 0; i < n; i++) {
            pos += scanner.nextInt();
            if (pos <= x) {
                ans++;
            }

        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.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(){
  vector <string> s_vec{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string s; cin >> s;
  int res = 0;
  for(int i = 0; i < s_vec.size(); i++){
    if(s == s_vec[i]){
      res = 7 - i;
    }
  }
  cout << res;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
ll h,w,k;
vector<ll>a(9);
vector<vector<vector<ll> > >dp(110,vector<vector<ll> >(9,vector<ll>(9,-1)));
ll solve(ll d,ll s,ll g){
    if(dp[d][s][k]>=0)return dp[d][s][k];
    ll ret=0;
    ll r=max(0LL,w-s-1),l=max(0LL,s-2);
    if(s>=2)ret=(ret+a[l]*solve(d-1,s-1,g)%inf*a[r+1]%inf)%inf;
    if(s<=w-1)ret=(ret+a[r]*solve(d-1,s+1,g)%inf*a[l+1]%inf)%inf;
    ret=(ret+solve(d-1,s,g)*a[l+1]%inf*a[r+1]%inf)%inf;
    dp[d][s][k]=ret;
    return ret;
}
int main(){
    cin>>h>>w>>k;
    a[0]=1;
    a[1]=1;
    a[2]=2;
    a[3]=3;
    REP(i,4,9){
        a[i]=(a[i-2]+a[i-1])%inf;
    }
    rep(i,9){
        rep(j,9){
            if(i==j)dp[0][i][j]=1;
            else dp[0][i][j]=0;
        }
    }
    ll ans=solve(h,1,k);
    REP(i,1,w+1){
        rep(j,h+1){
            //cout<<i<<' '<<j<<' '<<dp[j][i][k]<<endl;
        }
    }
    cout<<ans<<endl;
}

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

int c[200],ans;
string s;
int main() {
  cin >> s;
  for(int i=0; i<s.size(); i++) c[(int)s[i]]++;
  for(int i=0,d=0; i<s.size(); i++,d=0) {
    for(int j=0; j<200; j++) {
      if(c[j]) {
        d++;
        c[j]--;
      } else {
        ans+=min(d,3);
        d=0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define x3 dflgkg
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
#define y3 dfhgdh
#define SQ 320
#define PI 3.14159265359
typedef int ll;
using namespace std;
ll n,i,j,k,x,y,z,m,q,h,r,timer,mx,l,sum;
ll a[100500];
vector<string> f;
set<string> g;
int main() {
    //freopen("input.txt","r",stdin);
    string s;
    cin >> s;
    cin >> k;
    n = s.size();
    for (int i = 0; i < n; i++) {
        string x = "";
        for (int j = i; j < min(i+7, n); j++) {
            x.push_back(s[j]);
            if (g.find(x) == g.end()) {
                g.insert(x);
                f.push_back(x);
            }
        }
    }
    sort(f.begin(), f.end());
    cout << f[k-1] << endl;
    return 0;
}


Measured memory_bytes: 2812
#include<stdio.h>

int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a==b) printf("%d\n",a+b);
  if(a==b-1) printf("%d\n",a+b);
  if(b==a-1) printf("%d\n",a+b);
  if(a<=b-2) printf("%d\n",b+(b-1));
  if(b<=a-2) printf("%d\n",a+(a-1));
  return 0;
}


Measured memory_bytes: 128
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,k=nii()
p=lnii()
c=lnii()

ans=-10**18
for i in range(n):
  ini_x=i
  x=i
  point=[]

  t_ans=0
  cnt=0
  t_max=-10**18
  while True:
    x=p[x]-1
    t_point=c[x]
    point.append(t_point)
    t_ans+=t_point
    t_max=max(t_max,t_ans)
    cnt+=1
    if x==ini_x:
      break

  if t_ans<0:
    ans=max(ans,t_max)
  else:
    num=k//cnt
    num-=1
    zan=k-(num*cnt)
    c_ans=t_ans*num
    for j in range(zan):
      x=p[x]-1
      c_ans+=c[x]
      ans=max(ans,c_ans)

print(ans)

Measured memory_bytes: 81060
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;
int a[10];
int main(){
  IOS;
  int n; cin >> n;
  // rep(k,n){
  //   rep(i, 10)scanf("%d", &a[i]);
  //   rep(i,1<<10){
  //     stack<int>s[2];
  //     rep(j, 10){if(s[(i>>j)&1].empty() || a[j] > s[(i>>j)&1].top())s[(i>>j) & 1].push(a[j]);cout<<s[0]<<" "<<s[1]<<endl;}
  //     if(s[0].size()+s[1].size()==10){cout << "YES";break;}
  //     if(i==(1<<10)-1){cout<<"NO"<<endl;break;}
  //   }
  //
  // }
  int b[10];
  rep(j,n){
    int flag=0;
    rep(i,10){
      cin>>b[i];
    }
    stack<int>ta, tb;
    ta.push(b[0]);
    tb.push(0);
    repn(k,9){
      if(b[k]>ta.top()){ta.push(b[k]);}
      else if(b[k]>tb.top()){tb.push(b[k]);}
      else{ flag++;break;}
    }
    if(flag==0)cout<<"YES"<<endl;
    else{cout<<"NO"<<endl;}
  }
  return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,M,MIN=1000000,AM=1000000,BM=1000000;
  cin>>A>>B>>M;
  int a[A],b[B],x[M],y[M],c[M];
  for(int i=0;i<A;i++){
    cin>>a[i];AM=min(AM,a[i]);
  }
  for(int j=0;j<B;j++){
    cin>>b[j];BM=min(BM,b[j]);
  }
  for(int i=0;i<M;i++){
    cin>>x[i]>>y[i]>>c[i];
    x[i]--;y[i]--;
    MIN=min(MIN,a[x[i]]+b[y[i]]-c[i]);
  }
  cout<<min(MIN,AM+BM)<<endl;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
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(void) {
	int n; cin >> n;
	vi a(26,1);
	rep(i,n){
		char c; cin >> c;
		a[c-'a']++; 
	}
	mint ans = 1;
	rep(i,26) ans = ans*a[i];
	ans = ans-1;
	cout << ans << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr uint64_t INF = 1e18;

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

  int N;
  cin >> N;
  vector<int64_t> L(N);
  for (auto& l : L) {
    cin >> l;
  }
  sort(L.begin(), L.end());
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (L[i] == L[j]) continue;
      for (int k = j + 1; k < N; k++) {
        if (L[j] == L[k]) continue;
        if (L[i] + L[j] <= L[k]) continue;
        cnt++;
      }
    }
  }
  cout << cnt << endl;



  return 0;
}


Measured memory_bytes: 3640
N,M = map(int,input().split())
P = list(map(lambda x: int(x)-1,input().split()))
tree = list(range(N))

def root(n):
    O = {n}
    while True:
        if tree[n] == n:
            for o in O:
                tree[o] = n
            return n
        n = tree[n]
        O.add(n)

for i in range(M):
    x,y = map(lambda x: int(x)-1,input().split())
    rx = root(x)
    ry = root(y)
    if rx == ry:
        continue
    tree[rx] = ry

print(sum(map(lambda x: root(x)==root(P[x]),range(N))))

Measured memory_bytes: 14008
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
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()
#define ll long long int
typedef vector<int> vi;
typedef vector < pair<int, int > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
int n, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;
 
/*--------------------template--------------------*/
 
int main() {
	int n, m;
	int ans[100];
	REP(i,100)
	{
		ans[i] = 0;
	}
	cin >> n >> m;
	REP(i,2*m)
	{
		int a;
		cin >> a;
		a--;
		ans[a]++;
	}
	REP(i,n)
	{
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
7
2 1
0 0
1 2
2 2
4 2
1 3
3 3

output:
5
0 0
2 1
4 2
3 3
1 3
"""

import sys
from operator import attrgetter

EPS = 1e-9


def cross(a, b):
    return a.real * b.imag - a.imag * b.real


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


def check_ccw(p0, p1, p2):
    a, b = p1 - p0, p2 - p0
    if cross(a, b) > EPS:
        # print('COUNTER_CLOCKWISE')
        flag = 1
    elif cross(a, b) < -1 * EPS:
        # print('CLOCKWISE')
        flag = -1
    elif dot(a, b) < -1 * EPS:
        # print('ONLINE_BACK')
        flag = 2
    elif abs(a) < abs(b):
        # print('ONLINE_FRONT')
        flag = -2
    else:
        # print('ON_SEGMENT')
        flag = 0
    return flag


def convex_check_Andrew(_polygon):
    upper, lower = list(), list()
    _polygon.sort(key=attrgetter('real', 'imag'))

    upper.extend((_polygon[0], _polygon[1]))
    lower.extend((_polygon[-1], _polygon[-2]))

    for i in range(2, points):
        n1 = len(upper)
        while n1 >= 2 and check_ccw(upper[n1 - 2], upper[n1 - 1], _polygon[i]) == 1:
            n1 -= 1
            upper.pop()
        upper.append(_polygon[i])

    for j in range(points - 3, -1, -1):
        n2 = len(lower)
        while n2 >= 2 and check_ccw(lower[n2 - 2], lower[n2 - 1], _polygon[j]) == 1:
            n2 -= 1
            lower.pop()
        lower.append(_polygon[j])

    # change to counter-clockwise inplace
    lower.reverse()
    # find bottom-left of the hull and split the lower part
    lower_min = min(lower, key=attrgetter('imag', 'real'))
    min_index = lower.index(lower_min)
    lower_right = lower[min_index:]
    lower_left = lower[:min_index]

    return lower_right + upper[-2:0:-1] + lower_left


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    points = int(_input[0])
    p_info = map(lambda x: x.split(), _input[1:])

    polygon = [int(x) + int(y) * 1j for x, y in p_info]
    ans = convex_check_Andrew(polygon)
    print(len(ans))
    for ele in ans:
        print(int(ele.real), int(ele.imag))

Measured memory_bytes: 31020
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);

	while(scan.hasNext()) {
	    int n = scan.nextInt();
	    int r = scan.nextInt();

	    if (0 == n && 0 == r)
		break;

	    int[] yama = new int[n]; // 花札の山
	    for (int i=0; i<n; i++)
		yama[i] = n-i;

	    // カット
	    for (int i=0; i<r; i++) {
		int p = scan.nextInt();
		int c = scan.nextInt();
		cut(yama,p,c);
	    }

	    System.out.println(yama[0]);
	}    
    }

    private static void cut(int[] array, int p, int c) {
	int[] temp = new int[p-1];

	for (int i=0; i<p-1; i++)
	    temp[i] = array[i];

	for (int i=0; i<c; i++) 
	    array[i] = array[p-1+i];

	for (int i=0; i<p-1; i++)
	    array[c+i] = temp[i];
    }
}

Measured memory_bytes: 28232
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)) {
            while(sc.hasNext()) {
                int D = sc.nextInt();
                int E = sc.nextInt();
                if(D+E==0) break;
                
                double r = Double.MAX_VALUE;
                for(int i=0; i<D; i++) {
                    int j = D - i;
                    r = Math.min(r, Math.abs(Math.sqrt(i*i+j*j)-E));
                }
                System.out.println(r);
            }
        }
    }
}



Measured memory_bytes: 26392
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>


using namespace std;
typedef long long ll;
ll N;

int main(){

    ll N, W;
    cin >> N >> W;

    vector<pair <ll, ll > > p;

    for(ll i = 0; i < N; i++){
        ll w, v;
        cin >> w >> v;
        p.push_back(make_pair(w, v));
    }

    sort(p.begin(), p.end());

    map<ll, ll> dp;
    dp[0] = 0;
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        vector<pair <ll, ll > > tmp;
        auto begin = dp.begin(), end = dp.end();
        for (auto iter = begin; iter != end; iter++) {
            //cout << iter -> first << " " <<  iter -> second << endl;
            tmp.push_back(make_pair(iter->first, iter->second));
            if(p[i].first + iter->first <= W ){
                tmp.push_back(make_pair(p[i].first + iter->first, p[i].second + iter->second));
            }
            
        }
        //更新
        for (ll j = 0; j < tmp.size(); j++) {
            dp[tmp[j].first] = max(tmp[j].second, dp[tmp[j].first]);
            ans = max(ans, dp[tmp[j].first]);
        }       
    }

    cout << ans << endl;

}

Measured memory_bytes: 644
module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.math;
import std.stdio;
import std.string;

struct Input
{
	ulong a,b;
}

void parseInput(T)(out Input input, T file)
{
	with (file) with (input)
	{
		auto ab = readln().strip().split();
		a = ab[0].to!ulong;
		b = ab[1].to!ulong;
	}
}

T gcm(T)(T i1, T i2)
{
	T large = i1 < i2 ? i2 : i1;
	T small = i1 < i2 ? i1 : i2;

	while (small != 0)
	{
		T q = large % small;

		large = small;
		small = q;
	}

	return large;
}

auto main2(Input* input)
{
	ulong[] primes = [2];

	auto gcm = gcm(input.a, input.b);

	if (input.a == input.b)
	{

	}

	bool isPrime(ulong n)
	{
		auto r = floor(sqrt(cast(real)n));
		foreach (p; primes)
		{
			if (p > r)
				return true;

			if (n % p == 0)
				return false;
		}
		return true;
	}

	uint result = 1;
	
	{
		bool contains = false;
		while (gcm % 2 == 0)
		{
			gcm /= 2;
			contains = true;
		}

		if (contains)
			result++;
	}

	for (ulong n = 3; gcm != 1; n+=2)
	{
		if (isPrime(n))
			primes ~= n;
		else
		{
			if (n > sqrt(floor(cast(real)gcm)))
			{
				result++;
				break;
			}

			continue;
		}

		bool contains = false;
		while (gcm % n == 0)
		{
			gcm /= n;
			contains = true;
		}

		if (contains)
			result++;
	}

	return result;
}

unittest { writeln("begin unittest"); }

unittest // example1
{
	string example =
`12 18`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == 3);
}

unittest // example2
{
	string example =
`420 660`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == 4);
}

unittest // example3
{
	string example =
`1 2019`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == 1);
}

unittest { writeln("end unittest"); }

void parseExample(out Input input, string example)
{
	struct Adapter
	{
		string[] _lines;
		this(string input) { _lines = input.splitLines(); }
		string readln() { auto line = _lines[0]; _lines = _lines[1..$]; return line; }
	}
	parseInput(input, Adapter(example));
}

void main()
{
	Input input = void;
	parseInput(input, stdin);
	auto result = main2(&input);
	writeln(result);
}


Measured memory_bytes: 892
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = (1953125 << 9);
const ll maxn = 1 * 1e5 + 5;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//	freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout);

	ll a, b, c, aa, bb;
	cin >> a >> b >> c;
	aa = a, bb = b;

	if (a == b)
		return cout << a, 0;
	set<ll> ss;

	for (int i = 0; i < min(c, abs(aa - bb)); ++i)
	{
		ss.insert(a++);
	}
	for (int i = 0; i < min(c, abs(aa - bb)); ++i)
	{
		ss.insert(b--);
	}
	for (auto it : ss)
		cout << it << endl;

}


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

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

    int n, q;
    cin >> n >> q;

    for(int i = 0; i < q; i++){
        int v, w;
        cin >> v >> w;
        if(n == 1){
            cout << min(v, w) << endl;
        }else{
            while(true){
                if(v < w) swap(v, w);
                int p = (v + n - 2) / n;
                if(p == w){
                    cout << p << endl;
                    break;
                }
                v = p;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1280
s = input()
n = len(s)
n1 = int((n - 1) / 2)
s1 = s[:n1]
n2 = int((n + 3) / 2) - 1
s2 = s[n2:]
if s == s[::-1] and s1 == s1[::-1] and s2 == s2[::-1]:
    print("Yes")
else:
    print("No")

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll a,b;
    cin>>a>>b;
    Yes(a!=2&&b!=2);
    return  0;
}


Measured memory_bytes: 256
x, n = map(int, input().split())
if n==0:
    print(x)
else:
    p = input().split()
    p = [int(i) for i in p]
    if not(x in p):
        print(x)
    else:
        for i in range(101):
            if not(x-i in p):
                print(x-i)
                break
            elif not(x+i in p):
                print(x+i)
                break
            else:
                continue

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
long long n;
bool cmp(pair < long long , long long > tmp1,pair < long long , long long > tmp2)
{
    return tmp1.first<tmp2.first;
}
void solve()
{
    long long i,ans=0;
    vector < pair < long long , long long > > a(n);
    for (i=0;i<n;i++)
    {
        cin>>a[i].first;
        a[i].second=i+1;
    }
    sort(a.begin(),a.end(),cmp);
    for (i=0;i<n;i++)
        if (a[i].second!=i+1) ans++;
    if (ans<=2) puts("YES");
    else puts("NO");
}
int main()
{
    while(cin>>n)
        solve();
}

Measured memory_bytes: 256
function Main(input){
    var xs = input.trim().split(' ').map(v=>parseInt(v,10));
    
    a = xs[0];
    b = xs[1];
    c = xs[2];
    d = xs[3];
    
    if((Math.abs(a-c) <=d) || (Math.abs(a-b) <=d && Math.abs(b-c) <=d)){
      console.log('Yes');
    }else{
      console.log('No');
    }
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 21444
import sys, re

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7


R, G, B, N = MAP()
count = 0
for i in range(N+1):
	for j in range(int((N-i*R)//G)+1):
		# print(r, g, b)
		# if R*i + G*j + B*int(max(0, (N - i*R - j*G))/B) == N:
		# 	count += 1
		if (N - i*R - j*G) % B == 0:
			count += 1
print(count)


Measured memory_bytes: 3188
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		long HP[] = new long[N];
		long HPtotal = 0;
		for(int i=0; i<N; i++) {
			HP[i] = sc.nextLong();
		}
		//入力したHPを昇順（小さい順）に並び替える
			Arrays.sort(HP);
		//K回分の必殺技は後ろのHPが高いモンスターに使えばよい
		//→後ろのモンスターは除いて、N-K体のモンスターのHPを合計して表示すればよい
         for(int j=0; j<N-K; j++) {
			HPtotal+=HP[j];
		}
      		System.out.println(HPtotal);
	}		
}

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

int main(void){
    int c[3][3];
    int m;
    int i, j;
    for(i = 0; i < 3; i++){
        for(j = 0; j < 3; j++){
            cin >> c[i][j];
        }
        m = min({c[i][0], c[i][1], c[i][2]});
        for(j = 0; j < 3; j++){
            c[i][j] -= m;
        }
    }
    
    for(j = 0; j < 3; j++){
        if(!(c[0][j] == c[1][j] && c[1][j] == c[2][j])){
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    
    return 0;
}


Measured memory_bytes: 256
n, m, q = map(int, input().split())
T = [[0] * n for i in range(n)]
for i in range(m):
    l, r = map(int, input().split())
    T[l - 1][r - 1] += 1

for i in range(n):
    for j in range(1, n):
        T[i][j] += T[i][j - 1]

for j in range(n):
    for i in range(n - 2, -1, -1):
        T[i][j] += T[i + 1][j]

for i in range(q):
    p, q = map(int, input().split())
    print(T[p - 1][q - 1])


Measured memory_bytes: 9332
import itertools
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
#print(l)
ans=0
r=list(itertools.permutations([i for i in range(n)]))
for i in range(len(r)):
    r[i]=list(r[i])
    #print(r[i])
    for j in range(n-1):
        ans+=((l[r[i][j]][0]-l[r[i][j+1]][0])**2+(l[r[i][j]][1]-l[r[i][j+1]][1])**2)**(1/2)
A=1
for i in range(1,n+1):
    A*=i
#print(ans,A)
print(ans/A)

Measured memory_bytes: 50156
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define ios ios_base::sync_with_stdio(0); cin.tie(0);
#define open freopen("input.in", "r", stdin); freopen("output.out", "w", stdout);
using namespace std; typedef long long ll; typedef long double ld; mt19937 rnd(time(0));

#define int ll

const int N = 15;
int dpf[N][10];

int k;

void ans(int len, int ch){
    if (len == 0)
        return;
    cout << ch;
    for (int i = ch - 1; i <= ch + 1; i++){
        if (i < 0 || i > 9)
            continue;
        if (dpf[len - 1][i] >= k){
            ans(len - 1, i);
            break;
        }else{
            k -= dpf[len - 1][i];
        }
    }
}

void solve(){
    cin >> k;
    for (int i = 0; i < 10; i++)
        dpf[1][i] = 1;
    for (int i = 2; i < N; i++){
        for (int ch = 0; ch < 10; ch++){
            dpf[i][ch] = dpf[i - 1][ch];
            if (ch - 1 >= 0)
                dpf[i][ch] += dpf[i - 1][ch - 1];
            if (ch + 1 < 10)
                dpf[i][ch] += dpf[i - 1][ch + 1];
        }
    }
    for (int len = 1; len < N; len++){
        for (int ch = 1; ch <= 9; ch++){
            if (dpf[len][ch] >= k) {
                ans(len, ch);
                return;
            }
            k -= dpf[len][ch];
        }
    }
    cout << endl;
}

signed main(){
    ios;
    // open;
    ll t = 1;
    // cin >> t;
    cout.precision(16);
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
mul,f = 1, 0
input()
l = list(map(int, input().split()))
if l.__contains__(0):
    print(0)
    f = 1
else:
    for i in l:
        mul = mul * i
        if mul>1000000000000000000:
            print(-1); break;
    else:
        print( mul)

Measured memory_bytes: 21700
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n,a,b=get_i
if a*n>b
  puts b
else
  puts a*n
end

Measured memory_bytes: 1788
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <numeric>

template <
  typename Monoid,
  typename Container = std::vector<typename Monoid::first_type>
>
class dual_segment_tree {
public:
  using size_type = size_t;
  using first_type = typename Monoid::first_type;
  using second_type = typename Monoid::second_type;
  using value_type = first_type;
  using binary_operation = typename Monoid::binary_operation;
  using external_binary_operation = typename Monoid::external_binary_operation;
  using container = Container;

private:
  size_type M_base_size;
  binary_operation M_op1;
  external_binary_operation M_op2;
  container M_c;

public:
  dual_segment_tree() = default;
  dual_segment_tree(dual_segment_tree const&) = default;
  dual_segment_tree(dual_segment_tree&&) = default;

  dual_segment_tree(size_type n):
    M_base_size(n),
    M_op1(binary_operation()),
    M_op2(external_binary_operation()),
    M_c(n+n, M_op1.identity)
  {}

  dual_segment_tree(size_type n, first_type const& x):
    M_base_size(n),
    M_op1(binary_operation()),
    M_op2(external_binary_operation()),
    M_c(n+n, M_op1.identity)
  {
    modify(0, n, x);
  }

  template <typename InputIt>
  dual_segment_tree(InputIt first, InputIt last):
    M_base_size(std::distance(first, last)),
    M_op1(binary_operation()),
    M_op2(external_binary_operation()),
    M_c(M_base_size*2)
  {
    for (size_type i = M_base_size; first != last; ++i)
      M_c[i] = *first++;
  }

  dual_segment_tree& operator =(dual_segment_tree const&) = default;
  dual_segment_tree& operator =(dual_segment_tree&&) = default;

  void modify(size_type l, size_type r, second_type const& x) {
    l += M_base_size;
    r += M_base_size;
    while (l < r) {
      if (l & 1) M_c[l] = M_op2(std::move(M_c[l]), x), ++l;
      if (r & 1) --r, M_c[r] = M_op2(std::move(M_c[r]), x);
      l >>= 1;
      r >>= 1;
    }
  }

  value_type get(size_type i) const {
    i += M_base_size;
    value_type res = M_c[i];
    while (i > 1) {
      i >>= 1;
      res = M_op1(std::move(res), M_c[i]);
    }
    return res;
  }
};

template <typename Tp>
struct single_get_range_add {
  using first_type = Tp;
  using second_type = Tp;
  struct binary_operation {
    first_type identity{};
    first_type operator ()(first_type const& x, first_type const& y) const {
      return x + y;
    }
  };
  struct external_binary_operation {
    first_type operator ()(first_type const& x, second_type const& y) const {
      return x + y;
    }
  };
};

int main() {
  size_t n, q;
  scanf("%zu %zu", &n, &q);

  dual_segment_tree<single_get_range_add<intmax_t>> st(n);
  for (size_t i = 0; i < q; ++i) {
    int tp;
    scanf("%d", &tp);

    if (tp == 0) {
      size_t s, t;
      intmax_t x;
      scanf("%zu %zu %jd", &s, &t, &x);
      --s, --t;
      st.modify(s, t+1, x);
    } else if (tp == 1) {
      size_t j;
      scanf("%zu", &j);
      --j;
      printf("%jd\n", st.get(j));
    }
  }
}



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

typedef long long lli;

const int MAXH = 105;
const int MAXW = 3;
const lli mod = 1000000LL;

int N, M;
lli dp[MAXH][MAXW][1<<MAXW];

int main() {
  while(cin >> N >> M) {
    fill(dp[0][0], dp[MAXH][0], 0LL);
    dp[0][0][1<<0] = 1LL;
    int H = N+1;
    int W = M+1;
    for(int i = 0; i < H; ++i) {
      for(int k = 0; k < (1<<W); ++k) {
        for(int j = 0; j < W; ++j) {
          if(dp[i][j][k] == 0) continue;
          // right or left
          for(int dj = -1; dj <= 1; dj += 2) {
            int nj = j + dj;
            if(nj < 0 || nj >= W) continue;
            if(k & (1<<nj)) continue;
            dp[i][nj][k|(1<<nj)] += dp[i][j][k];
            dp[i][nj][k|(1<<nj)] %= mod;
          }
          // down
          for(int di = 1; di == 1; ++di) {
            int ni = i + di;
            if(ni < 0 || ni >= H) continue;
            dp[ni][j][1<<j] += dp[i][j][k];
            dp[ni][j][1<<j] %= mod;
          }
          // S ji
          if(W == 3 && j != 1 && k == (1<<j)) {
            for(int di = 1; i+di < H; ++di) {
              int ni = i + di;
              dp[ni][2-j][(1<<W)-1] += dp[i][j][k];
              dp[ni][2-j][(1<<W)-1] %= mod;
            }
          }
        }
      }
    }

    int ans = 0;
    for(int k = 0; k < (1<<W); ++k) {
      ans += dp[H-1][W-1][k];
      ans %= mod;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1184
import collections

N=int(input())
L=list(map(int,input().split()))
L=sorted(L)
M=collections.Counter(L)
M=sorted(M.items())
ans=max(M[i][1] for i in range(len(M)))
if len(M)==2:
	if M[0][0]+1==M[1][0] or M[0][0]+2==M[1][0]:
		ans=M[0][1]+M[1][1]
for i in range(1,len(M)-1):
	tmp=0
	tmp+=M[i][1]
	if M[i-1][0]==M[i][0]-1:
		tmp+=M[i-1][1]
	if M[i+1][0]==M[i][0]+1:
		tmp+=M[i+1][1]
	ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 16072
s=input()
flag=0
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        print(i+1,i+2)
        flag+=1
        break

if flag==0:
    for i in range(len(s)-2):
        if s[i]==s[i+2]:
            print(i+1,i+3)
            flag+=1
            break


if flag==0:
    print(-1,-1)

Measured memory_bytes: 9176
sum = 0
x = []
5.times do
  i = gets.to_i
  sum += (i / 10) * 10
  x << i % 10
end

x -= [0]
x.sort!

if x.size >= 2
  sum += (x.size - 1) * 10
end

puts sum + (x[0] || 0)

Measured memory_bytes: 1788
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader r =
            new BufferedReader(new InputStreamReader(System.in), 1);
        String is = r.readLine();
        if(!is.contains(" "))
            return;
        String[] sp = is.split(" ");
        int a = Integer.parseInt(sp[0]);
        int b = Integer.parseInt(sp[1]);
        if(a>b)
            System.out.println("a > b");
        else if(a<b)
            System.out.println("a < b");
        else if (a==b)
            System.out.println("a == b");
        else;
      }
}

Measured memory_bytes: 24108