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

ll h;

ll rec(ll x){
    if(x == 1) return 1;
    else{
        return (rec(x/2)*2)+1;
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>h;
    ll ans;
    ans = rec(h);
    cout<< ans <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9+5)
#define INFLL ((LL)4e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1 << (x))
using namespace std;

int main(){
	string str;
	cin >> str;
	vector<vector<LL>> dp(str.size()+1, vector<LL>(13, 0));
	dp[0][0]=1;
	REP(i, str.size()){
		REP(j, 13){
			if(str[i]=='?'){
				REP(k, 10){
					dp[i+1][(j*10+k)%13]+=dp[i][j];
					dp[i+1][(j*10+k)%13]%=MOD;
				}
			}else{
				dp[i+1][(j*10+str[i]-'0')%13]+=dp[i][j];
				dp[i+1][(j*10+str[i]-'0')%13]%=MOD;
			}
		}
	}
	cout << dp.back()[5] << endl;
	return 0;
}


Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back

void setIO(string s) 
{
	//ios_base::sync_with_stdio(0); cin.tie(0); 

	//freopen((s+".in").c_str(),"r",stdin);
	//freopen((s+".out").c_str(),"w",stdout);
}
int n, k;
vector<int> a;
bool can(int tar)
{
    int cnt = 0;
    for(int it: a)
    {
        cnt += it / tar;
        if (it % tar == 0) --cnt;
        if (cnt > k) return false;
    }
    return true;
}
void solve()
{
    scanf("%lld%lld", &n, &k);
    a.resize(n);
    forn(i, n) scanf("%lld", &a[i]);
    int lf = 1, rg = 1e12;
    int ans = 0;
    while(lf <= rg)
    {
        int mid = (lf + rg) / 2;
        if (can(mid))
        {
            rg = mid - 1;
            ans = mid;
        }
        else
        {
            lf = mid + 1;
        }
    }
    printf("%lld\n", ans);
}
signed main(void)
{
    //setIO("exercise");
    int T = 1; //scanf("%lld", &T);
    while(T--) solve();
    return 0;
}

Measured memory_bytes: 4744
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int solve() {
  int N; cin >> N;
  if(N == 0) return 1;

  double ideal = 22.0;
  double mi = 1e9; int id = -1;
  for(int i=0; i<N; i++) {
    int p; double h, w; cin >> p >> h >> w;
    h /= 100.0;
    double bmi = w / (h * h);

    double sub = fabs(ideal - bmi);
    if(sub < mi) {
      mi = sub;
      id = p;
    }
  }
  cout << id << endl;
  return 0;
}

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



Measured memory_bytes: 3180
N, X = map(int, input().split())
L = list(map(int, input().split()))
count = 0
D = 0
for i in range(N+1):
    if i == 0:
        count += 1
    else:
        D +=L[i-1]
        if D <= X:
            count += 1
        else:
            break
print(count)

Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))

sum = abs(a[0]) + abs(a[n-1])
for i in range(n-1):
    sum += abs(a[i+1] - a[i])

for i in range(n):
    num = sum
    if i == 0:
        num += abs(a[1]) - abs(a[0]) - abs(a[1] - a[0])
    elif i == n-1:
        num += abs(a[n-2]) - abs(a[n-2] - a[n-1]) - abs(a[n-1])
    else:
        num += abs(a[i-1] - a[i+1]) - abs(a[i-1] - a[i]) - abs(a[i] - a[i+1])
    print(num)


Measured memory_bytes: 14172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<int> X(4);
string S;

string dfs(int i,int sum,string op){
    if (i == 4) {
        if (sum == 7) return op;
        else return "";
    }
    string opP = dfs(i + 1,sum + X[i],op + "+");
    if (opP != "") return opP;
    string opM = dfs(i + 1,sum - X[i],op + "-");
    if (opM != "") return opM;
    return "";
}

int main(){
    cin >> S;
    for (int i = 0;i < 4;i++) X[i] = S[i] - '0';
    string op = dfs(1,X[0],"");
    if (op != "") cout << X[0] << op[0] << X[1] << op[1] << X[2] << op[2] << X[3] << "=7" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
# D - String Equivalence 
def dfs(s, mx):
    if len(s)==n:
        print(s)
        return
    for c in range(ord('a'), ord(mx)+1):
        dfs(s+chr(c), (chr(ord(mx)+1) if ord(mx)==c else mx))

n=int(input())
dfs('','a')


Measured memory_bytes: 4516
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 100100100100100100;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;
 
int main () {
    
    string s,t; cin >>s>>t;

    vector<vector<int> > dp(3010, vector<int>(3010, 0));
    vector<vector<int> > prev_i(3010, vector<int>(3010, 0));
    vector<vector<int> > prev_j(3010, vector<int>(3010, 0));

    for (int i = 0; i < s.length(); i++) {
        for (int j = 0; j < t.length(); j++) {
            if (s[i] == t[j]) {
                dp[i+1][j+1] = dp[i][j] + 1;
                prev_i[i+1][j+1] = i;
                prev_j[i+1][j+1] = j;
            } else {
                if (dp[i+1][j] > dp[i][j+1]) {
                    dp[i+1][j+1] = dp[i+1][j];
                    prev_i[i+1][j+1] = i+1;
                    prev_j[i+1][j+1] = j;
                } else {
                    dp[i+1][j+1] = dp[i][j+1];
                    prev_i[i+1][j+1] = i;
                    prev_j[i+1][j+1] = j+1;
                } 
            }
        }
    }

    int i = s.length();
    int j = t.length();
    string ans = "";
    while (!(i == 0 && j == 0)) {
        int next_i = prev_i[i][j];
        int next_j = prev_j[i][j];
        if (next_i < i && next_j < j) {
            ans = s[next_i] + ans;
        } 
        i = next_i;
        j = next_j;
    }
    cout << ans << endl;
    return 0;
}


 

Measured memory_bytes: 106752
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int r;
	cin >> r;
	put(r * r);
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		List<Integer> x = new ArrayList<Integer>();
		List<Integer> y = new ArrayList<Integer>();

		for (;;) {
			int xNum = scan.nextInt();
			int yNum = scan.nextInt();
			if (xNum == 0&& yNum == 0) {
				break;
			}
			x.add(xNum);
			y.add(yNum);
		}

		for (int i = 0; i < x.size(); i++) {
			System.out.println(x.get(i) < y.get(i) ? x.get(i) + " " + y.get(i) : y.get(i) + " " + x.get(i));
		}
		scan.close();

	}

}

Measured memory_bytes: 27876
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

int main()
{
    int n;
    int a[212345];
    int p[50];
    unordered_map<int, int> mp;
    vector<int> v;

    cin >> n;
    REP(i, n)
    {
        cin >> a[i];
        if (!mp[a[i]])
            v.push_back(a[i]);
        mp[a[i]]++;
    }

    SORT(v);

    bool used[212345] = {false};

    p[0] = 1;
    REP(i, 32)
    p[i + 1] = p[i] * 2;

    int res = 0;

    for (int i = v.size() - 1; i >= 0; i--)
    {
        if (!mp[v[i]])
            continue;

        int t = 1;
        while (t <= v[i])
            t *= 2;

        if (!mp[t - v[i]])
            continue;

        if (t - v[i] == v[i])
        {
            res += mp[v[i]] / 2;
        }
        else
        {
            int t_ = min(mp[t - v[i]], mp[v[i]]);
            res += t_;
            mp[t - v[i]] -= t_;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 18408
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
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; }

//i=桁数
//j=未満フラグ
ll dp[65][2];

int main(){
  int n; ll k;
  cin>>n>>k;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];

  //DP初期化
  rep(i,65)rep(j,2)dp[i][j]=-1;
  dp[0][0]=0;

  //桁DP
  for(int i=0; i<60; ++i){
    for(int j=0; j<2; ++j)if(dp[i][j]>=0){

      //見てるbit
      int d=60-1-i;
      ll msk=1LL<<d;

      //そのbitの0,1の数
      int zero=0,one=0;
      rep(i,n){
        if(a[i]&msk)one++;
        else zero++;
      }

      //kのi桁目が1のとき、i桁目を0にしたら未満フラグ成立
      int j2=j;
      if(k&msk)j2=1;

      //そのbitを0にするとき
      chmax(dp[i+1][j2],dp[i][j]+one*msk);

      //そのbitを1にするとき(未満フラグが立っている or kのi桁目が1)
      if((k&msk)||j==1){
        chmax(dp[i+1][j],dp[i][j]+zero*msk);
      }
    }
  }
  //未満フラグ立ってる方と立ってない方のmaxを取る
  cout<<max(dp[60][0],dp[60][1])<<endl;
}

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

using namespace std;

int main() {
	int p, q, r, min;
	int flg = 0;
	cin >> p >> q >> r;
	
	vector<int> N{p, q, r};
	
	for (int i = 0; i < 2; i++) {
		for (int j = i+1; j < 3; j++) {
			if (flg == 0) {
				min = N.at(i) + N.at(j);
				flg = 1;
			} else {
				if (min > N.at(i) + N.at(j)) {
					min = N.at(i) + N.at(j);
				}
			}
		}
	}
	
	cout << min << endl;
	
	return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;
typedef pair<int,int> P;
int w,h,n;
int fie[101][101];
int dist[101][101];
int ix,iy,ox,oy;
int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};

int bfs(){
	queue<P> que;
	memset(dist,-1,sizeof(dist));
	que.push(P(ix,iy));
	dist[iy][ix]=0;
	while(que.size()){
		P q=que.front();
		que.pop();
		for(int i=0;i<4;i++){
			int nx=q.first+dx[i],ny=q.second+dy[i];
			if(fie[ny][nx]==0){
				nx+=dx[i];
				ny+=dy[i];
				if(dist[ny][nx]!=-1)continue;
				dist[ny][nx]=dist[q.second][q.first]+1;
				que.push(P(nx,ny));
			}
		}
	}
	return dist[oy][ox];
}

int main(void){
	scanf("%d %d %d",&w,&h,&n);
	w*=2;
	h*=2;
	for(int i=0;i<=h;i++){
		fie[i][0]=1;
		fie[i][w]=1;
	}
	for(int i=0;i<=w;i++){
		fie[0][i]=1;
		fie[h][i]=1;
	}
	for(int i=0;i<n;i++){
		int sx,sy,ddx,ddy;
		scanf("%d %d %d %d",&sx,&sy,&ddx,&ddy);
		if(sx>ddx)swap(sx,ddx);
		if(sy>ddy)swap(sy,ddy);
		sx*=2;
		sy*=2;
		ddx*=2;
		ddy*=2;
		for(int j=sx;j<=ddx;j++){
			fie[ddy][j]=1;
			fie[sy][j]=1;
		}
		for(int j=sy;j<=ddy;j++){
			fie[j][ddx]=1;
			fie[j][sx]=1;
		}
	}
	scanf("%d%d",&ix,&iy);
	scanf("%d%d",&ox,&oy);
	ix=ix*2+1;
	iy=iy*2+1;
	ox=ox*2+1;
	oy=oy*2+1;
	int prev=bfs();
	int res=prev;
	for(int i=1;i<h;i+=2){
		for(int j=0;j<w;j+=2){
			if(fie[i][j]==0){
				fie[i][j]=1;
				int di=bfs();
				if(di!=-1)res=max(di,res);
				fie[i][j]=0;
			}
		}
	}
	for(int i=0;i<h;i+=2){
		for(int j=1;j<w;j+=2){
			if(fie[i][j]==0){
				fie[i][j]=1;
				int di=bfs();
				if(di!=-1)res=max(di,res);
				fie[i][j]=0;
			}
		}
	}
	printf("%d\n",res-prev);
	return 0;
}

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

int main(){
  long long N, X;
  cin >> N >> X;
  vector<long long> x(N);
  for (long long i=0; i<N; i++) cin >> x[i];
  vector<long long> xsum(N);
  for (long long i=0; i<N; i++){
    if (i==0) xsum[i] = x[i];
    else xsum[i] = x[i] + xsum[i-1];
  }
  long long ans=(long long)0;
  for (long long i=1;i<=N;i++){
    long long tmp = X*N+i*X+xsum[N-1]*(long long)5;
    int flag = 0;
    for (long long j=N-1-i*2; j>-1; j-=i){
      tmp += xsum[j]*(long long)2;
      if (tmp<0) flag++;
    }
    if (ans == 0) ans = tmp;
    else if (flag==0) ans = min(ans, tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s; cin >> s;
    int n = s.size();
    long long ans = 0;
    if (n <= 2) {
        cout << 0 << endl;
        return 0;
    }
    long long aseq = 0;
    for (int i = 0; i < n-2; i++) {
        if (s[i] == 'A') aseq++;
        else aseq = 0;
        if (aseq && s[i+1] == 'B' && s[i+2] == 'C') {
            ans += aseq; swap(s[i], s[i+2]); i++;
            aseq--;
        } 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 644
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int n, k, a, s, c[200005];
vector<int> v;
int main() {
	int i;
	scanf("%d%d", &n, &k);
	for(i=1; i<=n; i++) scanf("%d", &a), c[a]++;
	for(i=1; i<=n; i++) if(c[i]) v.push_back(c[i]);
	sort(v.begin(), v.end());
	for(i=0; i<(int)v.size()-k; i++) s += v[i];
	printf("%d", s);
	return 0;
}


Measured memory_bytes: 2168
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> num = new ArrayList<Integer>();
		ArrayList<String> param = new ArrayList<String>();

		while (sc.hasNext()) {
			if (sc.hasNextInt()) {
				num.add(sc.nextInt());
			} else {
				param.add(sc.nextLine());
			}
		}
		Method(num, param);
	}
	
	static void Method(ArrayList<Integer> num, ArrayList<String> param) {

		if(num.get(0) > num.get(1)) {
			int day = num.get(0) - num.get(1);
			System.out.println(num.get(2) * num.get(1) + num.get(3) * day);
		} else {
			System.out.println(num.get(2) * num.get(0));
		}
	}
}

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

int main(){
  string str;
  cin >> str;
  int count[3] = {0,0,0};

  for(int i = 0 ; i < str.size() ; i++){
    count[str[i]-'a']++;
  }

  int mini = 1e9;
  for(int i = 0 ; i < 3 ; i++){
    mini = min(mini,count[i]);
  }

  for(int i = 0 ; i < 3 ; i++){
    count[i] = count[i] - mini;
  }

  bool flag = true;
  for(int i = 0 ; i < 3 ; i++){
    if(count[i] >= 2){
      flag = false;
    }
  }
  cout << (flag ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main()
{
	int a,b,c,i;
	scanf("%d%d%d", &a, &b, &c);
	for( i = 0;;i++)
	{
		if(i * a > b)break;
	}
	i--;
	if(i <= c)printf("%d",i);
	else printf("%d",c);
	return 0;
}

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

int tt,tx,ty,x,y,t,f;
int n;

int main()
{
	cin >> n;
	for(int i=0;i<n;i++)
	{
		cin >> tt >> tx >> ty;
		if((((tt-t)-(abs(tx-x)+abs(ty-y)))%2!=0||abs(tx-x)+abs(ty-y)>tt-t))
		{
			f=1;
		}
		t=tt,x=tx,y=ty;
	}
	if(f) cout << "No";
	else cout << "Yes";
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private struct Pair<T> { public T x, y; public Pair(T x, T y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        List<Tuple<int, int>> _xy = new List<Tuple<int, int>>();
        for (int i = 0; i < N; i++) { _xy.Add(new Tuple<int, int>(NextInt(), NextInt())); }
        var xy = _xy.OrderBy(x => x).ToList();
        Dictionary<long, Dictionary<long, int>> d = new Dictionary<long, Dictionary<long, int>>();
        for (int i = 0; i < N; i++)
        {
            for (int j = i + 1; j < N; j++)
            {
                int _x = xy[j].Item1 - xy[i].Item1;
                int _y = xy[j].Item2 - xy[i].Item2;
                if (!d.ContainsKey(_x)) d[_x] = new Dictionary<long, int>();
                if (!d[_x].ContainsKey(_y)) d[_x][_y] = 0;
                d[_x][_y]++;
            }
        }
        int max = 0;
        foreach (var e in d)
            foreach (var f in e.Value)
                max = Math.Max(max, f.Value);
        Console.WriteLine(N - max);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}


public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13536
#include <stdio.h>
 
int main(void){
	int a,n,i,j,c = 0,m;
	int s[100];
	scanf("%d",&n);
	for(i = 0; i < n; i++){
		scanf("%d",&s[i]);
		a = s[i] - 1;
		c = c + a * a;
	}
	for(j = 2; j <= 100; j++){
		m = 0;
		for(i = 0; i < n; i++){
			a = s[i] - j;
			m = m + a * a;
		}
		if(m < c){
			c = m;
		}
	}
	
	printf("%d",c);
	
	return 0;
}


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

using namespace std;

bool dp[100100];

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

    vector<int> a(N);
    for(int i=0; i<N; ++i){
        cin >> a[i];
    };

    dp[0] = false;
    for(int i=1; i<=K; ++i){
        for(int j=0; j<N; ++j){
            if(i - a[j] >= 0 && dp[i-a[j]] == false ){
                dp[i] = true;
                break;
            }
        }
    }

    if(dp[K] == true){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }

}

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

int main()
{
	long N; //参加者人数
	cin >> N;

	vector<vector<long>> chukeip(N);
	vector<vector<long>> chukeim(N);

	vector<long> A(N); //参加者の伸長
	for (long i = 0; i < N; i++)
	{
		cin >> A[i];

		long tmp = i - A[i];
		if (tmp >= 0)
			chukeim[tmp].emplace_back(i);

		tmp = i + A[i];
		if (tmp < N)
			chukeip[tmp].emplace_back(i);
	}

	long result = 0;
	for (long i = 0; i < N; i++)
	{
		result += chukeim[i].size() * chukeip[i].size();
	}
	cout << result << endl;



	return 0;
}



Measured memory_bytes: 22580
#include <bits/stdc++.h>
using namespace std;
#define pr(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define all(v) (v).begin(), (v).end()
#define int long long
#define sz(v) (int)(v).size()
#define mod 1000000007 // ((a- b)% mod+ mod)% mod

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int dp[3001][3001][2];

void solve() {
        int n; cin >> n;
        vector<int> v(n);

        for (auto& i: v) cin >> i;

        memset(dp, -1, sizeof(dp));

        function<int(int, int, bool)> calc= [&](int i, int j, bool pl)->int{
                if (i> j) {
                        return 0;
                }

                int &ret1= dp[i][j][pl];
                if (ret1!= -1) return ret1;

                if (pl) {
                        ret1= -1e18;
                        ret1= max(ret1, calc(i+ 1, j, pl^1)+ v[i]);
                        ret1= max(ret1, calc(i, j- 1, pl^1)+ v[j]);
                        return ret1;
                }else {
                        ret1= 1e18;
                        ret1= min(ret1, calc(i+ 1, j, pl^1)- v[i]);
                        ret1= min(ret1, calc(i, j- 1, pl^1)- v[j]);
                        return ret1;
                }
        };
        cout << calc(0, n- 1, 1);
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int T= 1;
        //cin >> T;
        while ( T-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 144740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
string YES[2] = {"NO", "YES"};
string yes[2] = {"No", "Yes"};

int main(){
    double a, b, x; cin >> a >> b >> x;
    double res=0;
    if(x>a*a*b/2.0){
        res = atan(2*(a*a*b-x)/(a*a*a));
    }else{
        res = atan(a*b*b/(2*x));
    }
    res = res*180/PI;
    cout << fixed << setprecision(15) << res << endl;
}


Measured memory_bytes: 4052
<?php
$array = ["a", "b", "c", "d", "e", "f", "g","h", "i", "j"];


fscanf(STDIN, "%d", $n);
$int = 0;
$max = [0,0,0,0,0,0,0,0,0,0,0];
$last = [0,0,0,0,0,0,0,0,0,0,0];
$maxint = pow(10,$n-1);
while($int < $maxint){

    putstr($int, $n);
    $k=0;
    while($last[$k] >= $max[$k+1] + 1 ){
        $k++;
    }
    if($k == 0){
        $int++;
        $last[0]++;
    }else{
      	$pow = pow(10,$k);
        $int += $pow;
        $int = intdiv($int, $pow)* $pow;
        $last[$k]++;
        $max[$k] = max($max[$k], $last[$k]);
        for($j = $k-1; $j>=0; $j--){
            $last[$j] = 0;
            $max[$j] = $max[$k];
        }
    }
}


function putStr($int, $n){
    global $array;

    $str = str_pad($int,$n,0,STR_PAD_LEFT);
        $map = str_split($str);
    foreach($map as $value) {
        echo $array[$value];
    }
    echo PHP_EOL;
}

Measured memory_bytes: 5880
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cctype>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define FORR(i,a,b) for (int i = a; i > b; i--)
#define pi acos(-1.0)

#define MAX 1000000000
#define MIN 1

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

VI a;

int main(){
    string a, b;
    cin >> a >> b;
    if(a.length() > b.length()) {
        cout << "GREATER" << endl;
    } else if(a.length() < b.length()) {
        cout << "LESS" << endl;
    } else {
        for(int i = 0; i < a.length(); i++) {
            if(a[i] > b[i]) {
                cout << "GREATER" << endl;
                return 0;
            } else if(a[i] < b[i]) {
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }
    
    return 0;
}










Measured memory_bytes: 256
#include <iostream>
  
inline unsigned insertion_sort(unsigned a[], unsigned n, unsigned gap){
  unsigned count = 0;
  for(unsigned i = gap; i < n; i++){
    unsigned v = a[i];
    int j = i - gap;
    while(j >= 0 && a[j] > v){
      a[j+gap] = a[j];
      j -= gap;
      count++;
    }
    a[j+gap] = v;
  }
  return count;
}
  
inline void shell_sort(unsigned a[], unsigned n){
  const unsigned gaps[] = {1,8,23,77,281,1073,4193,16577,65921,262913,1050113};
  // generated from pow(4,i)+3*pow(2,i-1)+1 (prefixed with 1)
  
  unsigned gap_num = 0, count = 0;
  while(gaps[gap_num+1] < n) gap_num++;
  
  for(int i = gap_num; i >= 0; i--) count += insertion_sort(a,n,gaps[i]);
  
  std::cout << (gap_num+1) << '\n';
  
  for(int i = gap_num; i; i--) std::cout << gaps[i] << ' ';
  std::cout << gaps[0] << '\n';
  
  std::cout << count << '\n';
}
  
int main(){
  std::ios::sync_with_stdio(false);
  unsigned n;
  unsigned a[1000000];
  std::cin >> n;
  for(unsigned i = 0; i < n; i++) std::cin >> a[i];
  shell_sort(a,n);
  for(unsigned i = 0; i < n; i++) std::cout << a[i] << '\n';
}

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

int main() {
    string s;
    string t;
    string u;
    cin >> s >> t >> u;
    
    char x = s[0];
    bool flag1 = false;
    bool flag2 = false;
    bool flag3 = false;
    int cnta = 0;
    int cntb = 0;
    int cntc = 0;

    while(flag1 == false && flag2 == false && flag3 == false) {
        if(x == 'a') {
            x = s[cnta];
            cnta++;   
            if(cnta-1 == s.size()) flag1 = true;
        }
        else if(x == 'b') {
            x = t[cntb];
            cntb++;
            if(cntb-1 == t.size()) flag2 = true;
        }
        else if(x == 'c') {
            x = u[cntc];
            cntc++;
            if(cntc-1 == u.size()) flag3 = true;
        }
    }

    if(flag1 == true) cout << 'A' << endl;
    else if(flag2 == true) cout << 'B' << endl;
    else if(flag3 == true) cout << 'C' << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  ll at = 1, aa = 1;
  rep(i, n){
    ll t, a;
    cin >> t >> a;
    ll al1 = (at+t-1)/t;
    ll al2 = (aa+a-1)/a;
    ll al = max(al1, al2);
    at = al*t;
    aa = al*a;
    // cerr << al1 << " " << al2 << " " << at << " " << aa << endl;
  }
  cout << at+aa  << endl;
  return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> memo = {-1};
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        int n = memo.size();
        int ok = n, ng = -1;
        while (ok - ng != 1) {
            int med = (ok + ng) / 2;
            if (memo[med] < a) {
                ok = med;
            } else {
                ng = med;
            }
        }
        if (ok == n) {
            memo.push_back(a);
        } else {
            memo[ok] = a;
        }
    }
    cout << memo.size() << endl;
}


Measured memory_bytes: 892
n = int(input())
a = list(map(int, input().split()))

m = 0
b = []
for i in range(n):
    if a[i] < 0:
        m += 1
        b.append(-a[i])
    else:
        b.append(a[i])

if m % 2 == 1:
    print(sum(b) - 2*min(b))
else:
    print(sum((b)))


Measured memory_bytes: 14412
direc = ((1,0),(-1,0),(0,1),(0,-1))


#d = [[[[0 for i in range(Y+1)] for i in range(X+1)] for i in range(Y+1)] for i in range(X+1)]
#d[1][1][2][2]=3
# print(d)
while 1:
    X, Y = list(map(int,input().split()))
    if X == 0: break

    ftx, fty = list(map(lambda x: x-1, map(int, input().split())))
    fkx, fky = list(map(lambda x: x-1, map(int, input().split())))

    m = [list(map(int, input().split())) for i in range(Y)]

    d = {(ftx, fty, fkx, fky): 0}

    s = [[0, (ftx, fty, fkx, fky)]]
    res = 'NA'
    while len(s) > 0:
        spm = s.pop(0)
        cnt = spm[0] + 1
        if cnt > 100:
            break

        def search_move():
            for i in range(4):
                #print('--' + str(spm[1]))
                tx = spm[1][0]+direc[i][0]
                ty = spm[1][1]+direc[i][1]
                kx = spm[1][2]-direc[i][0]
                ky = spm[1][3]-direc[i][1]


                hm = 0
                if tx < 0 or tx >= X or ty < 0 or ty >= Y or m[ty][tx] == 1:
                    tx = spm[1][0]
                    ty = spm[1][1]
                    hm += 1
                if kx < 0 or kx >= X or ky < 0 or ky >= Y or m[ky][kx] == 1:
                    kx = spm[1][2]
                    ky = spm[1][3]
                    hm += 1

                if hm == 2: continue
                tpl = (tx,ty,kx,ky)
                if tpl in d and d[tpl] <= cnt:
                    continue

                #print(tpl)
                if tx == kx and ty == ky:
                    return True
                else:
                    s.append([cnt,tpl])
                    d[tpl] = cnt
            return False
        if search_move():
            res = str(cnt)
            break
    print(res)

Measured memory_bytes: 41232
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		for(; sc.hasNext();){
			LinkedList<Integer> a=new LinkedList<Integer>();
			LinkedList<Integer> b=new LinkedList<Integer>();
			for(int i=0; i<4; i++)
				a.add(sc.nextInt());
			for(int i=0; i<4; i++)
				b.add(sc.nextInt());
			int hit=0, brow=0;
			for(int i=0; i<4; i++){
				if(a.get(i)==b.get(i))
					hit++;
				else if(a.contains(b.get(i)))
					brow++;
			}
			println(hit+" "+brow);
		}
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 12000
from collections import deque
from itertools import product
import sys
input=sys.stdin.readline


def solve():
    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())

    l = [[1 if i=="#" else 0 for i in input()] for _ in range(H)]
    q = deque([(0, (Ch-1, Cw-1))])
    INF = 10**12
    costs = [[INF]*W for _ in range(H)]
    costs[Ch-1][Cw-1] = 0

    while q:
        cost, pos = q.popleft()
        h, w = pos

        for dh, dw in product(range(-2,3), repeat=2):
            hh, ww = h+dh, w+dw
            if not (0<=hh<H and 0<=ww<W):
                continue
            if l[hh][ww]:
                continue
            
            if ((abs(dh)==1 and dw==0) or (dh==0 and abs(dw)==1)) and costs[hh][ww] > costs[h][w]:
                costs[hh][ww] = costs[h][w]
                q.appendleft((cost, (hh, ww)))
            elif costs[hh][ww] > costs[h][w]+1:
                costs[hh][ww] = costs[h][w]+1
                q.append((cost+1, (hh, ww)))

    ans = costs[Dh-1][Dw-1]
    print(ans if ans!=INF else -1)


solve()


Measured memory_bytes: 125524
#include<iostream>
#include<cstdlib>
#include<utility>
#include<tuple>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
using namespace std;
using ll = long long;

int main() {
	
	ll a, b;

	cin >> a >> b;

	if (a == b) {
		cout << a << endl;
		return 0;
	}

	ll ans = a * b;

	if (a < b) swap(a, b);

	int c;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}

	cout << ans / b << endl;

	return 0;
}

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

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

    int res=0;
    for(int i=n; !res; ++i) {
        int x=i;
        bool ok=true;
        while (x) {
            if (a[x%10]) { ok=false; break; }
            x/=10;
        }
        if (ok) res=i;
    }
    cout<<res<<endl;
}


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

int main()
{
    double a,b,c,d,e,f;
    while (~scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)) {
        double y = (f*a-c*d)/(a*e-d*b);
        double x = (c-b*y)/a;
        printf("%.3f %.3f\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 1080
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int MAX = 999999999;

int main(){
    int n, m, x;
    cin >> n >> m >> x;

    vector<int> nums(m);
    rep(i, m) cin >> nums[i];

    int min_val = MAX;
    int sum = 0;
    repi(i, x, n+1){
        if(find(all(nums), i) != nums.end()) sum ++;
    }
    min_val = min(min_val, sum);

    sum = 0;
    for(int i = x; i >= 0; i--){
        if(find(all(nums), i) != nums.end()) sum++;
    }
    min_val = min(min_val, sum);

    cout << min_val << endl;
}

Measured memory_bytes: 256
from bisect import bisect_right

n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

sA=[0]
for i in range(n):
    sA.append(sA[-1]+A[i])
sB=[B[0]]
for i in range(1,m):
    sB.append(sB[-1]+B[i])

ans=0
for i in range(n+1):
    temp=k-sA[i]
    if temp<0:
        break
    add=bisect_right(sB,temp)
    ans=max(ans,i+add)

print(ans)





Measured memory_bytes: 47544
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

constexpr lli inf = 10000 * 10000;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {


	int a, b;
	cin >> a >> b;

	if (a > b) {
		swap(a,b);
	}


	for (int i = 0; i < b; i++) {
		cout << a;
	}

	return 0;
}


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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;

  vvll f(n, vll(10));
  vvll p(n, vll(11));

  rep(i, n) {
    rep(j, 10) {
      cin >> f[i][j];
    }
  }

  rep(i, n) {
    rep(j, 11) {
      cin >> p[i][j];
    }
  }

  ll ans = -INF;
  REP(ptn, 1 << 10) {
    ll v = 0;
    vll cnt(n);
    rep(j, 10) {
      if (bit(j) & ptn) {
        rep(i, n) {
          if (f[i][j]) {
            cnt[i]++;
          }
        }
      }
    }

    rep(i, n) {
      v += p[i][cnt[i]];
    }
    chmax(ans, v);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;int num=0;
    cin>>s;
    for(int i=0;i<s.size();++i)
    {
        if(s[i]=='o') num++;
    }
    num+=15-s.size();
    if(num>=8)puts("YES");
    else puts("NO");
}


Measured memory_bytes: 256
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 5121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
int p[410];
int q[410];
int dp[410][2][410][410];
int main(){
	int a;scanf("%d",&a);
	init_C(1200);
	for(int i=0;i<a;i++)scanf("%d%d",p+i,q+i);
	int S=0;
	for(int i=0;i<a;i++){
		S+=p[i];
	}
	dp[0][0][0][0]=1;
	for(int i=0;i<a;i++){
		for(int j=0;j<2;j++){
			for(int k=0;k<=400;k++){
				for(int l=0;l<=400;l++){
					if(!dp[i][j][k][l])continue;
					dp[i+1][j][k][l]=(dp[i+1][j][k][l]+dp[i][j][k][l])%mod;
					long long ks=1;
					for(int m=0;m<q[i];m++){
						dp[i+1][!j][k+m][l+p[i]]=(dp[i+1][!j][k+m][l+p[i]]+dp[i][j][k][l]*ks%mod*finv[m])%mod;
						ks=ks*p[i]%mod;
						// ks=ks*inv[S]%mod;
					}
				}
			}
		}
	}	
	long long ret=0;
	for(int i=0;i<2;i++){
		for(int j=0;j<=400;j++){
			for(int k=1;k<=400;k++){
				long long val=0;
				if(!dp[a][i][j][k])continue;
				val=dp[a][i][j][k]*fact[j]%mod*inv[k]%mod*S%mod;
				val=val*pw(inv[k],j)%mod;
				if(i%2){
					ret=(ret+mod-val)%mod;
				}else{
					ret=(ret+val)%mod;
				}
			}
		}
	}
	ret%=mod;
	printf("%lld\n",(mod-ret)%mod);
}


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

using namespace std;

int main(void)
{
	string S; cin>>S;
	int len = S.size();
	for(int i = 0; i <= (len-1)/2; i++){
		if(S[i] != S[len-i-1]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	
	int i = (len+3)/2;
	i--;
	int j =  len - 1;
	while(i <= j){
		if(S[i] != S[j]){
			cout<<"No"<<endl;
			return 0;
		}
		i++;
		j--;
	}
	
	cout<<"Yes"<<endl;
	return 0;
}



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

int main(){
    int h,n;
    cin >> h >> n;
    vector<int> a(n),b(n);
    rep(i,n) cin >> a.at(i) >> b.at(i);
    priority_queue<int> pq;
    vector<int> mp(h+1);
    rep(i,h){
        mp.at(i) = INF;
    }
    mp.at(h) = 0;
    pq.push(h);
    // ll cnt = 0;
    while(pq.size()){
        // cnt++;
        auto x = pq.top(); pq.pop();
        rep(i,n){
            int nh = max(x-a.at(i),0);
            int nm = mp.at(x)+b.at(i);
            if(mp.at(nh) == INF) {
                pq.push(nh);
            }
            mp.at(nh) = min(mp.at(nh), nm);
        }
    }
    // cout << "cnt:" << cnt << endl;
    // rep(i,h+1){
    //     cout << "hp:" << i << " mp:" << mp.at(i) << endl;
    // }
    cout << mp.at(0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
#include <cctype>

using namespace std;

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

bool isPrime(int num)
{
	// if(num < 2) return false;
	if(num == 2) return true;
	if(num%2 == 0) return false;

	// +1 重要
	for(int i = 3; i < sqrt(num) + 1; i += 2) {
		if(num % i == 0) return false;
	}
	return true;
}

int main()
{
	int N;
	int count = 0;
	int num;

	cin >> N;

	REP(i, N) {
		cin >> num;
		if(isPrime(num)) ++count;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1160
function Main (input) {
  input = input.split("\n");
  input.pop();
  input[0] = input[0].split(" ").map(Number);
  var h = input[0];
  var w = input[1];
  input.shift();
  var sk = "##";
  for (var i of input[0].split("")) {
    sk += "#";
  }

  console.log(sk);
  for (var j of input) {
    console.log("#" + j + "#");
  }
  console.log(sk);
}

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

Measured memory_bytes: 7756
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

const int MAX_N = 1e5 + 10;
ll h[MAX_N];
vector<int> g[MAX_N];

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i ++) {
        cin >> h[i];
    }
    for(int i = 0; i < m; i ++) {
        int a, b;
        cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }
    ll cnt = 0;
    for(int i = 0; i < n; i ++) {
        bool bad = false;
        for(auto it : g[i]) {
            if(h[i] <= h[it]) {
                bad = true;
            }
        }
        if(!bad) {
            cnt ++;
        }
    }
    cout << cnt << endl;
    return 0;

}



Measured memory_bytes: 9512
#include<stdio.h>
int main(void){
 
  int i,j,n,k,t,s;
  int d[1000];

  scanf("%d %d", &n,&k);


  for(i = 1;i<=n;i++){
  scanf("%d", &d[i]);
  }

    for(i = 1; i <= n - 1; i++ ){
        for(j = i + 1; j <= n; j++ ){
            if( d[i] > d[j] ){
                t=d[i];
                d[i]=d[j];
                d[j]=t;
            }
        }
    }

s=0;
for(i = 1 ; i <= k ; i++){
    s=s+d[i];
}
printf("%d\n",s);
}


Measured memory_bytes: 1732
#include <iostream>
using namespace std;
int sum(int x){
    return x*(x+1)/2;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X; cin >> X;
    for(int i = 1;; ++i){
        if(sum(i) >= X){
            cout << i <<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3656
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


n, k = inpl()
a = inpl()
for i in range(n - k):
    if a[i] < a[i + k]:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 94572
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    S = input()
    if S[2] == S[3] and S[4] == S[5]:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<b){
		if(b<c){
			printf("Yes\n");
		}else{
			printf("\No\n");
		}
	}else{
		printf("No\n");
	}
	return 0;;
	
}


Measured memory_bytes: 2064