akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

string S;

set<int> X[3] = {{1,4,7},{2,8},{3,6,9}};

void solve() {
  int N = S.size();
  int ans = inf;
  rep(o, 2) {
    int res = 0;
    int s = 0;
    rep(i, N-1) {
      if((i+o+s)&1) {
        if(S[i] == 2 && X[0].count(S[i+1])) { res ++; s++; }
        if(S[i] == 8 && X[0].count(S[i+1])) { res ++; s++; }
        if(S[i] == 3 && X[0].count(S[i+1])) { res ++; s++; }
        if(S[i] == 6 && X[0].count(S[i+1])) { res ++; s++; }
        if(S[i] == 9 && X[0].count(S[i+1])) { res ++; s++; }
        if(S[i] == 3 && X[1].count(S[i+1])) { res ++; s++; }
        if(S[i] == 6 && X[1].count(S[i+1])) { res ++; s++; }
        if(S[i] == 9 && X[1].count(S[i+1])) { res ++; s++; }
      } else {
        if(S[i] == 1 && X[1].count(S[i+1])) { res ++; s++; }
        if(S[i] == 4 && X[1].count(S[i+1])) { res ++; s++; }
        if(S[i] == 7 && X[1].count(S[i+1])) { res ++; s++; }
        if(S[i] == 1 && X[2].count(S[i+1])) { res ++; s++; }
        if(S[i] == 4 && X[2].count(S[i+1])) { res ++; s++; }
        if(S[i] == 7 && X[2].count(S[i+1])) { res ++; s++; }
        if(S[i] == 2 && X[2].count(S[i+1])) { res ++; s++; }
        if(S[i] == 8 && X[2].count(S[i+1])) { res ++; s++; }
      }
    }
    minimize(ans, res);
  }
  cout << ans << endl;
}

int main() {

  for(; cin >> S;) {
    if(S == "#") { break; }
    int N = S.size();
    rep(i, N) S[i] -= '0';
    solve();
  }
  
  return 0;
}

Measured memory_bytes: 3308
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int main()
{
	int A, B;
	cin >> A >> B;
	if (!(A % 2) || !(B % 2)) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}



Measured memory_bytes: 256
from collections import defaultdict
import queue

def getlist():
	return list(map(int, input().split()))

class Graph(object):
    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, a, b, w):
        self.graph[a].append([b, w])
        self.graph[b].append([a,w])

    def get_nodes(self):
        return self.graph.keys()

class BFS(object):
    def __init__(self, graph, N):
        self.g = graph.graph
        self.dist = [0] * (N + 1)
        self.visit = [0] * (N + 1)
        self.Q = queue.Queue()
        self.visit[1] = 1
        self.Q.put(1)

        while not self.Q.empty():
            v = self.Q.get()
            for i, w in self.g[v]:
            	if self.visit[i] == 0:
            		self.dist[i] = self.dist[v] + w
            		self.Q.put(i)
            		self.visit[i] = 1

    def weight(self):
        return self.dist

N = int(input())
G = Graph()
for i in range(N - 1):
	u, v, w = getlist()
	G.add_edge(u, v, w)
XX = BFS(G, N)
ans = XX.weight()
for i in range(1, N + 1):
	if ans[i] % 2 == 0:
		print(0)
	else:
		print(1)


Measured memory_bytes: 56340
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int n, k; cin >> n >> k;
    REP(i, n){
        int a; cin >> a;
    }
    cout << (n-1 + (k-1) -1)/(k-1) << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC target("avx,avx2")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

long long a,b,c;

signed main(){
	read(a,b,c);
	puts(b*c>=a?"Yes":"No");
}

Measured memory_bytes: 3616
def get_cost_change_black(S):
    return S.count(".")

N = int(input())
S = str(input())

indexs = [i for i, x in enumerate(S) if x == "#"]
if len(indexs) == 0:
    print(0)
else:
    answer = 10000000000
    change_white = 0
    change_black = get_cost_change_black(S[indexs[0]:])
    for i, ind in enumerate(indexs):
        x = change_white + change_black
        if x < answer:
            answer = x
        change_white = change_white + 1
        if i == len(indexs) - 1:
            if change_white < answer:
                answer = change_white
            break
        change_black = change_black - (indexs[i+1] - indexs[i] - 1)
    print(answer)


Measured memory_bytes: 11368
#include<iostream>

using namespace std;

int countDivisor(int n){
	int count = 1;
	for(int i = 1; i<=n/2; i++){
		if(n%i == 0) count += 1;
	}
	return count;
}

int main(){
	int n, count = 0;
	cin >> n;
	for (int i = 1; i<=n; i++){
		if(i%2 == 1 && countDivisor(i) == 8) count++;
	}
	cout << count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG

 // 深さ優先探索
vector<bool> seen;
int dfs(const Graph &G, ll v) {
    seen[v] = true; // v を訪問済にする
    int score = 0; 

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー

        // 負荷さ優先探索中の処理



        dfs(G, next_v); // 再帰的に探索, 毎回mat渡してええの？
    }
    return score;
} 

/*
//桁数の計算
ll keta(ll num){
  ll ans= 0 ;
  ll rem;

  for (ll i = 4; i >= 0 ; i--){
    rem = pow(10,i);
    ans += (num / rem); 
    num = num % rem;
  }
  return ans;
}
*/

ll Lucas(ll N){
  if (N == 0){
    return 2;
  }else if(N == 1){
    return 1;
  }
  ll ans;
  ans = Lucas(N-1) + Lucas(N-2);

  return ans;

}


int main() {
  ll N, M, ans;
  cin >> N >> M;
  vector<ll> a(N);
  vector<ll> b(N);
  
  ll finish = 0;
  ll best = 0;
  for(ll i=0; i<N; i++){
    cin >> a[i] >> b[i];
    //finish += b[i];
    best = max(best, a[i]);
  }

  ll n_finish =0;
  for(ll i=0; i<N; i++){
    if(b[i] > best){
      finish += b[i];
      n_finish++;
    }
  }

  if((M - finish) > 0){
    ans = ceil((M - finish) / (double)best);
    ans = ans + n_finish;
    //cout << ans << endl;
  }else{
    sort(b.begin(), b.end(),greater<ll>());
    ans = 0;
    for(ll i=0; i< N; i++){
      M -= b[i];
      if(M <= 0){
        ans = i + 1;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>
#include<numeric>

using namespace std;

int n,x,y;
int s;

int main(){
  cin>>x>>y;
  if(x%y) cout<<"1"<<endl;
  else cout<<"0"<<endl;
  return 0;
}


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

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a*c %mod;}a=a*a %mod;b>>=1;}return c;}
vi calc(ll x){vi res; while(x>0){res.eb(x%10);x/=10;}reverse(all(res)); return res;}

void solve() {
  int a,b;
  cin>>a>>b;
  if(a>12) out(b);
  else if(a<6) out(0);
  else out(b/2);
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define elif else if
typedef long long ll;
typedef unsigned long long ull;
#define DEBUG(x) cout << (x) << endl
#define TGET(a, b) get<b>(a)

#define MODULE 998244353

int dp[3005] = {0};

int is_prime(ll n)
{
    double n_sqrt;
    if (n == 2 || n == 3)
    {
        return 1;
    }
    if (n <= 1 || n % 6 != 1 && n % 6 != 5)
    {
        return 0;
    }
    n_sqrt = double(sqrt((double)n));
    for (int i = 5; i <= n_sqrt; i += 6)
    {
        if (n % i == 0 | n % (i + 2) == 0)
        {
            return 0;
        }
    }
    return 1;
}

int arr[3005] = {0};

int main()
{
    int n;
    int s;
    scanf("%d %d", &n, &s);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", arr + i);
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {
        dp[0] += 1;
        for (int j = s; j >= arr[i]; j--)
        {
            dp[j] = dp[j] + dp[j - arr[i]];
            dp[j] %= MODULE;
        }
        ans += dp[s];
        ans %= MODULE;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
//#include<cmath>
using namespace std;

typedef long long llong;
const int MAX = 100010;
const int INFTY = 1000000001;
vector<pair<char, int> > card, card_merge;

int partition(int left, int right, int n)
{
	int i, j;
	pair<char, int> x;
	x = card[right];
	i = left - 1;
	for (j = left; j < right; j++) {
		if (card[j].second <= x.second) {
			i++;
			swap(card[i], card[j]);
		}
	}
	swap(card[i + 1], card[right]);
	return i + 1;
}

void quickSort(int left, int right, int n)
{
	if (left < right) {
		int k = partition(left, right, n);
		quickSort(left, k - 1, n);
		quickSort(k + 1, right, n);
	}
}

void merge(int left, int mid, int right)
{
	int n1 = mid - left, n2 = right - mid;
	vector<pair<char,int> >L(n1 + 1), R(n2 + 1);
	for (int i = 0; i < n1; i++)
		L[i] = card_merge[left + i];
	for (int i = 0; i < n2; i++)
		R[i] = card_merge[mid + i];
	L[n1].second = R[n2].second = INFTY;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		if (L[i].second <= R[j].second) {
			card_merge[k] = L[i];
			i += 1;
		}
		else {
			card_merge[k] = R[j];
			j += 1;
		}
	}
}

void mergeSort(int left, int right)
{
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(left, mid);
		mergeSort(mid, right);
		merge(left, mid, right);
	}
}

int main(void)
{
	int n, num;
	char C;
	bool ok = true;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> C >> num;
		card.push_back(make_pair(C, num));
		card_merge.push_back(make_pair(C, num));
	}
	quickSort(0, n - 1, n);
	mergeSort(0, n);
	for (int i = 0; i < n; i++) {
		if (card[i] != card_merge[i]) {
			ok = false;
			break;
		}
	}
	if (ok)
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;
	for (int i = 0; i < n; i++)
		cout << card[i].first << " " << card[i].second << endl;
	return 0;
}







Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
操作の逆順を考える
Codeforcesではscanfを使う
エラー出力は消す
エラー出力を消せ！！！！！
 */

int main() {
    int n;
    cin >> n;
    cout << (n-1)/2;
}

/*



 */


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

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

C.sort(key=lambda x:x[0])
C.sort(key=lambda x:x[1])

ok_time = 0
dame_time = 0

answer = "Yes"
for i in range(N):
    ok_time = C[i][1]
    dame_time += C[i][0]
    if dame_time > ok_time:
        answer = "No"
print(answer)

Measured memory_bytes: 96216
program ABC061B
    implicit none
    integer(8)::N,M,a,b,i,j,out
    integer(8),allocatable,dimension(:,:)::G
    read(5,*)N,M
    allocate(G(N,N))
    G=0

    do i=1,M
        read(5,*)a,b
        G(b,a)=G(b,a)+1
        G(a,b)=G(a,b)+1
    end do

    do i=1,N
        out=0
        do j=1,N
            out=out+G(j,i)
        end do
        print'(i0)',out
    end do        
end program ABC061B

Measured memory_bytes: 640
#include <bits/stdc++.h>
// #include <algorithm>
// #include <vector>
// #include <list>
// #include <string>
// #include <iostream>
#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

#define MAXN (1000*100)
int N;
// int A[MAXN+5];

typedef struct A {
	int id;
	int num;
} A;

A a[MAXN+5];

bool Acomp(const A &lhs, const A &rhs)
{
	if (lhs.num<rhs.num) {
		return true;
	}
	return false;
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);
	
	cin >> N;
	FOR(n,N) {
		cin >> a[n].num;
		a[n].id = n;
	}

	sort(&a[0], &a[N], Acomp);

	FOR(n,N) {
		cout << a[n].id+1 << " ";
	}
	cout << endl;

	return 0;
}




Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll maxn=1e5+1;
const ll INF=1e16;
const ll MOD=1e9+7;
void solve()
{
	ll X,Y,A,B,C;
	cin>>X>>Y>>A>>B>>C;
	vector<ll> p(A),q(B),r(C);
	for(ll i=0;i<A;i++)
	{
		cin>>p[i];
	}
	for(ll i=0;i<B;i++)
	{
		cin>>q[i];
	}
	for(ll i=0;i<C;i++)
	{
		cin>>r[i];
	}
	ll ans=0;
	sort(p.begin(),p.end(),greater<ll>());
	sort(q.begin(),q.end(),greater<ll>());
	sort(r.begin(),r.end(),greater<ll>());
	vector<ll> res;
	for(ll i=0;i<X;i++)
	{
		res.push_back(p[i]);
	}
	for(ll j=0;j<Y;j++)
	{
		res.push_back(q[j]);
	}
	sort(res.begin(),res.end());
	for(ll i=0;i<C;i++)
	{
		if(r[i]>res[i])
		{
			res[i]=r[i];
		}
		else
		{
			break;
		}
	}
	for(ll i=0;i<res.size();i++)
	{
		ans+=res[i];
	}
	cout<<ans<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1;
	//cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 4852
/*??? ???? ?????? ??????*/
/*“Dengan menyebut nama Allah yang Maha Pengasih lagi Maha Penyayang”*/
/*“In the name of Allah, Most Gracious, Most Merciful”*/
/*Link Problem : */
/*Author : Althafa Dhia Syauqi */
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_n(i,n) for(int i=1;i<=(n);i++)
#define endl '\n'
#define mod 1e9+7
#define pb push_back
using namespace std;
void optimization()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll a,b,c;

int main()
{
	/*freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	gunakan saat OJ membutuhkan file eksternal */
	optimization();
    cin >> a>> b;
    cout <<(a*3+b)/2<<endl;
    return 0;
}



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

int main(){

  int n, a[210];

  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];

  int c=0;
  while(1){
    for(int i=0;i<n;i++){
      if(a[i]%2){
        cout<<c<<endl;
        return 0;
      }else a[i]/=2;
    }
    c++;
  }

  return 0;
}


Measured memory_bytes: 256
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef pair <int, int> pii;
#define pb push_back
#define f first
#define s second
#define sz(x) (int)x.size()
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	cout.tie(0);
	int n, ans = 0;
	cin >> n;
	while(n){
		ans += n % 10;
		n /= 10;
	}
	cout << (ans == 1 ? 10 : ans) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

struct brick{
    ll w,s,v;
    bool operator<(const brick& rhs) const{
        return s+w < rhs.s+rhs.w;
    }
};

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n;
    cin >> n;
    vector <brick> arr(n);
    ll maxi = 0;
    for (int z=0;z<n;z++){
        cin >> arr[z].w >> arr[z].s >> arr[z].v;
        maxi = max(maxi,max(arr[z].w,arr[z].s));
    }
    sort(arr.rbegin(),arr.rend());
    vector <vector<ll>> dp(n,vector<ll>(maxi+1,0));
    dp[0][arr[0].s] = arr[0].v;
    for (int z=1;z<n;z++){
        dp[z][arr[z].s] = arr[z].v;
        for (int x=0;x<=maxi;x++){
            dp[z][x] = max(dp[z-1][x],dp[z][x]);
            if (dp[z][x] == 0) continue;
            if (x >= arr[z].w) 
            dp[z][min(x-arr[z].w,arr[z].s)] = max(dp[z][min(x-arr[z].w,arr[z].s)],dp[z-1][x]+arr[z].v);
        }
    }
    // for (int z=0;z<n;z++){
    //     for (int x=0;x<=maxi;x++){
    //         cout << dp[z][x] << " ";
    //     } cout << endl;
    // }
    ll ans = 0;
    for (int z=0;z<=maxi;z++){
        ans = max(ans,dp[n-1][z]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 78592
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
    int n;
    cin>>n;
    V<ll> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    V<ll> dp(n,inf);
    for(int i=0;i<n;i++){
        *lower_bound(all(dp),a[i])=a[i];
    }
    cout<<lower_bound(all(dp),inf)-dp.begin()<<"\n";
}


Measured memory_bytes: 4400
#include <iostream>
#include <bitset>

using ll = long long;

#define DEB {std::cout << __LINE__ << std::endl;}
#define DEB1(X) {std::cout << __LINE__  << ": " << (X) << std::endl;}


const int MOD = 1e9+7;

ll dp[60][2][4]; //けた, vがN以下確定, その桁の和

int main() {
    ll n;

    std::cin >> n;
    
    ll cnt = 0;
    {
        auto p = n; 
        while(p != 1) p >>= 1, ++cnt;
    }

    dp[cnt][1][0] = 1;
    dp[cnt][0][1] = 1;
    
    for(int i = cnt - 1; i >= 0; --i) {
        {//vがN以下不確定
            if(n & (1ll << i)) {
                dp[i][1][0] += dp[i + 1][0][0] + dp[i + 1][0][1] + dp[i + 1][0][2];
                dp[i][0][1] += dp[i + 1][0][0] + dp[i + 1][0][1] + dp[i + 1][0][2];
                dp[i][1][2] += dp[i + 1][0][1] + dp[i + 1][0][2] + dp[i + 1][0][3];
                dp[i][0][3] += dp[i + 1][0][1] + dp[i + 1][0][2] + dp[i + 1][0][3];
            }else {
                dp[i][0][0] += dp[i + 1][0][0] + dp[i + 1][0][1] + dp[i + 1][0][2];
                dp[i][0][2] += dp[i + 1][0][1] + dp[i + 1][0][2] + dp[i + 1][0][3];
            }
        }
        {
            dp[i][1][0] += dp[i + 1][1][0] + dp[i + 1][1][1] + dp[i + 1][1][2];
            dp[i][1][1] += dp[i + 1][1][0] + dp[i + 1][1][1] + dp[i + 1][1][2];
            dp[i][1][2] += dp[i + 1][1][1] + dp[i + 1][1][2] + dp[i + 1][1][3];
            dp[i][1][3] += dp[i + 1][1][1] + dp[i + 1][1][2] + dp[i + 1][1][3];
        }
        for(int j = 0; j < 2; ++j) {
            for(int k = 0; k < 4; ++k) {
                dp[i][j][k] %= MOD;
            }
        }
    }

    long long ans = 0;
    for(int i = 0; i < 2; ++i) {
        for(int j = 0; j < 3; ++j) {
            ans += dp[0][i][j];

            ans %= MOD;
        }
    }

    std::cout << ans << std::endl;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loop2(num) for (lli j = 0 ; j < num ; j ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }
#define looppu(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . push_back (x) ;}
#define loopin(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . insert (x) ;}

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back ()
#define pof pop_front ()

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

void solve ()
{
    st s ; cin >> s ;
    (s.find("7") < 3 ? Yes : No) ;
}

signed main ()
{
    fastio
    solve ();
    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 3640
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque};
fn main() {
    input!(s:String);
    let mut s: String = s;
    let mut alphabets = HashSet::new();
    for c in s.chars() {
        alphabets.insert(c);
    }
    
    for x in 0..26 {
        let mut c = b'a' + x;
        if !alphabets.contains(&(c as char)) {
            println!("{}", c as char);
            return;
        }
    }
    println!("None");
}


Measured memory_bytes: 2312
#include <unordered_set>
#include <cstring>
#include <functional>
#include <queue>
#include <vector>
#include <unordered_map>
#include <iostream>
using namespace std;

int main() {
    int n, m; cin >> n >> m;
    unordered_map<int, vector<int> > adj[n];
    struct edge { int src, dst, col; };
    edge edges[m];
    for (int i = 0; i < m; i++) {
        int p, q, c; cin >> p >> q >> c;
        p--; q--;
        edges[i] = {p, q, c};
        adj[p][c].push_back(i);
        adj[q][c].push_back(i);
    }
    int dist[n];
    constexpr int INF = 1<<30;
    fill(dist, dist+n, INF);
    dist[0] = 0;
    queue<int> q;
    q.push(0);
    unordered_set<int> used[n];
    function<void(int, int, int)> dfs = [&](int i, int col, int d) {
        auto it = adj[i].find(col);
        if (it == adj[i].end()) return;
        if (used[i].find(col) != used[i].end()) return;
        else used[i].insert(col);
        for (int e : it->second) {
            int j = (edges[e].src == i ? edges[e].dst : edges[e].src);
            if (dist[j] > d) {
                dist[j] = d;
                q.push(j);
            }
            if (dist[j] >= d) dfs(j, col, d);
        }
    };

    while (!q.empty()) {
        int i = q.front();
        q.pop();
        for (auto &x : adj[i]) {
            dfs(i, x.first, dist[i] + 1);
        }
    }
    cout << (dist[n-1] == INF ? -1 : dist[n-1]) << endl;
}


Measured memory_bytes: 70144
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
const long long INF = 1LL << 60;
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; }

int main(){
    int N, X;
    cin >> X >> N;
    vector<int> p(N);
    rep(i, N) cin >> p.at(i);
    int ans;
    long long min_dis = INF;
    for(int i=0;i<=101;i++){
        bool check = false;
        rep(j, N){
            if(p.at(j) == i) check = true;
        }
        if(check) continue;
        if(abs(i-X)<min_dis){
            ans = i;
            min_dis = abs(i-X);
        }
    }
    cout << ans << endl;
    return 0;    
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#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=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin>>a>>b;
	cout<<(a<=8 && b<=8 ? "Yay!" : ":(")<<'\n';
	return 0;
}


Measured memory_bytes: 256
// ABC155B - Papers, Please

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

int main() {
	int N;
	cin >> N;
//	cout << "N=" << N << endl;

	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}

	bool answer = true;

	for (int i = 0; i < N; i++) {
		if (A.at(i) % 2 == 0) {
			if ((A.at(i) % 3 != 0)&&(A.at(i) % 5 !=0)) {
				answer = false;
				break;
			}
		}
	}

	if (answer) {
		cout << "APPROVED" << endl;
	} else {
		cout << "DENIED" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main(void)
{
	int N, A[100], work, minj, cou = 0;
	bool flag = 1;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		minj = i;
		for (int j = i; j < N; j++) {
			if (A[j] < A[minj]) {
				minj = j;
			}
		}
		if (minj != i) {
			work = A[i];
			A[i] = A[minj];
			A[minj] = work; 
			cou++;
		}
	}
	for (int i = 0; i < N; i++) {
		cout << A[i];
		if (i != N - 1)  cout << " ";
		else cout << endl;
	}
	cout << cou << endl;
}

Measured memory_bytes: 1164
import Data.List
main = do
  s <- getLine :: IO String
  putStrLn $ if f s then "AC" else "WA" 
  
f :: String -> Bool
f s
  | head s /= 'A' = False
  | (length $ elemIndices 'C' s) /= 1 = False
  | 'C' `elem` take 2 s = False
  | 'C' `notElem` (init $ drop 2 s) = False
  | last s == 'C' = False
  | otherwise =
      all (&&True) $ map (`elem` ['a'..'z']) $ delete 'A' $ delete 'C' s

Measured memory_bytes: 380
n, $k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
f = gets.split.map(&:to_i).sort.reverse
$cost = []
n.times do |i|
  $cost << [a[i], f[i], a[i] * f[i]]
end
$cost.sort_by! { |c| -c[2] }

def check(x) # x以下のコストにできるか
  cnt = 0
  $cost.each do |c|
    if c[2] > x
      cnt += (c[0] - x / c[1])
    else
      break
    end
  end
  cnt <= $k
end

ok = 10**12
ng = -1
while (ok - ng).abs > 1
  mid = (ok + ng) / 2
  if check(mid)
    ok = mid
  else
    ng = mid
  end
end
p ok


Measured memory_bytes: 47032
package main

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

const maxBuf = 200100

var buf []byte = make([]byte, maxBuf)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

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

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readFloat64() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

/* #### main #### */
func main() {
	a := readInt()
	fmt.Println(a + a*a + a*a*a)
}


Measured memory_bytes: 1780
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
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 ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

VI tree_diameter(VVI &e){
    int n = e.size();
    VI dist(n, -1);
    queue<int> que;
    que.push(0);
    dist[0] = 0;
    while (!que.empty()){
        int x = que.front();
        que.pop();
        for (int y : e[x]){
            if (dist[y] == -1){
                dist[y] = dist[x] + 1;
                que.push(y);
            }
        }
    }
    int r = max_element(ALL(dist)) - dist.begin();
    dist.assign(n, -1);
    que.push(r);
    dist[r] = 0;
    while (!que.empty()){
        int x = que.front();
        que.pop();
        for (int y : e[x]){
            if (dist[y] == -1){
                dist[y] = dist[x] + 1;
                que.push(y);
            }
        }
    }
    int s = max_element(ALL(dist)) - dist.begin();
    VI ret;
    while (s != r){
        ret.push_back(s);
        for (int x : e[s]){
            if (dist[x] == dist[s] - 1){
                s = x;
                break;
            }
        }
    }
    ret.push_back(r);
    return ret;
}

VI calc(VI d, VVI e){
    int n = e.size();
    VI a({0});
    FOR(i,1,d.size()-2){
        int p = e[d[i]].size() - 2;
        int x = a.size();
        a.push_back(x + p);
        REP(j,p) a.push_back(x + j);
    }
    a.push_back(n - 1);
    VI ret(n);
    REP(i,n) ret[a[i]] = i;
    return ret;
}

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

    VVI e(n);
    REP(i,n-1){
        int u = in() - 1, v = in() - 1;
        e[u].push_back(v);
        e[v].push_back(u);
    }

    VI d = tree_diameter(e);
    VI on(n);
    for (int x : d) on[x] = 1;

    REP(i,n){
        if (!on[i] && e[i].size() != 1){
            cout << -1 << endl;
            return 0;
        }
    }

    VI ans1 = calc(d, e);
    reverse(ALL(d));
    VI ans2 = calc(d, e);
    VI ans = min(ans1, ans2);

    REP(i,n) cout << ans[i] + 1 << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 14288
#include <bits/stdc++.h>
#define MOD 924844033
#define N 800001
#define ll long long
#define mod MOD
#define clz(n) __builtin_clz(n)
using namespace std;
int n,E,sz[N],fir[N],nex[N],to[N];
int b[N],ret[N],pos[N];
long long inv[N],ijc[N],jc[N];
typedef double ld;
struct C{
	ld x,y;
	inline C(ld x=0,ld y=0):x(x),y(y){}
	C operator - (const C&a)const{return C(x-a.x,y-a.y);}
	C operator + (const C&a)const{return C(x+a.x,y+a.y);}
	C operator * (const ld&a)const{return C(x*a,y*a);}
	C operator / (const ld&a)const{return C(x/a,y/a);}
	C operator * (const C&a)const{return C(x*a.x-y*a.y,x*a.y+y*a.x);}
	C conj()const{return C(x,-y);}
}s1[N],omg_[N],s2[N];
int n_,lgn_;
int rev_[N];
void FFT_init(int n){
	lgn_=32-clz(n);n_=1<<lgn_;
	rev_[0]=0;omg_[0]=C(1,0);
	for(int i=1;i<n_;i<<=1)omg_[i]=C(cos(2.*i*M_PI/n_),sin(2.*i*M_PI/n_));
	for(int i=1;i<n_;i++){
		omg_[i]=omg_[i^(i&-i)]*omg_[i&-i];
		rev_[i]=rev_[i/2]>>1|(i&1)<<lgn_-1;
	}
}
C ww[N];
void FFT(C*a){
	for(int i=0;i<n_;i++)if(rev_[i]<i)swap(a[i],a[rev_[i]]);
	register int t;
	register C s;
	for(int i=0;i<lgn_;i++){
		t=1<<i;
		for(register int j=0;j<t;++j)ww[j]=omg_[j<<lgn_-i-1];
		for(register int j=0;j<n_;j+=t<<1){
			register C* at=a+j,*bt=a+j+t;
			for(register int k=0;k<t;++k){
				s=bt[k]*ww[k];
				bt[k]=at[k]-s;
				at[k]=at[k]+s;
			}
		}
	}
}
C s3[N],s4[N];
void mul(int*a,int*b,int n,int m){
	FFT_init(n+m-2);memset(s1,0,sizeof s1);memset(s2,0,sizeof s2);
	for(int i=0;i<n;i++)s1[i]=C(a[i]&32767,a[i]>>15);
	for(int i=0;i<m;i++)s2[i]=C(b[i]&32767,b[i]>>15);
	FFT(s1);FFT(s2);
	for(int i=0;i<n_;i++){
		int j=(n_-1)&(n_-i);
		C da,db,dc,dd;
		da = (s1[i] + s1[j].conj()) * C(0.5, 0);
		db = (s1[i] - s1[j].conj()) * C(0, -0.5);
		dc = (s2[i] + s2[j].conj()) * C(0.5, 0);
		dd = (s2[i] - s2[j].conj()) * C(0, -0.5);
		s3[j] = da*dc+da*dd*C(0,1);
		s4[j] = db*dc+db*dd*C(0,1);
	}
	FFT(s3);FFT(s4);
	for(int i=0;i<n_;i++){
		int da = (ll)(s3[i].x / n_ + 0.5) % mod;
		int db = (ll)(s3[i].y / n_ + 0.5) % mod;
		int dc = (ll)(s4[i].x / n_ + 0.5) % mod;
		int dd = (ll)(s4[i].y / n_ + 0.5) % mod;
		a[i] = (da + ((ll)(db + dc) << 15) + ((ll)dd << 30)) % mod;
		(a[i]+=mod)%=mod;
	}
}
void add(int x,int y)
{
	to[++E]=y;nex[E]=fir[x];fir[x]=E;
}
int build(int now,int fat)
{
	sz[now]=1;
	for(int i=fir[now];i;i=nex[i])
	if(to[i]!=fat)
		sz[now]+=build(to[i],now);
	return sz[now];
}
void Solve()
{
	int c[N],d[N];
	memset(c,0,sizeof c);memset(d,0,sizeof d);
	for(int i=0;i<n;i++)
		c[i]=b[n-i]*jc[n-i]%MOD,
		d[i]=ijc[i];
	mul(c,d,n,n);
	for(int i=0;i<n;i++)
	{
		ret[i]+=c[i];
		ret[i]%=MOD;
	}
}
int main()
{
	scanf("%d",&n);
	inv[1]=jc[1]=ijc[1]=jc[0]=ijc[0]=1;
	for(int i=2;i<=n;i++)
		inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD,
		jc[i]=jc[i-1]*i%MOD,
		ijc[i]=ijc[i-1]*inv[i]%MOD;
	for(int i=1;i<n;i++)
	{
		int p,q;
		scanf("%d%d",&p,&q);
		add(p,q);add(q,p);
	}
	build(1,0);
	for(int i=2;i<=n;i++)
		b[sz[i]]++;
	Solve();
	memset(b,0,sizeof b);
	for(int i=2;i<=n;i++)
		b[n-sz[i]]++;
	Solve();
	for(int i=0;i<n-i;i++)
		swap(ret[i],ret[n-i]);
	for(int i=1;i<=n;i++)
		ret[i]=ret[i]*ijc[i]%MOD;
	for(int i=1;i<=n;i++)
		printf("%lld\n",(n*jc[n]%MOD*ijc[i]%MOD*ijc[n-i]%MOD-ret[i]+MOD)%MOD);
	return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)


int main() {
	ll x;
	cin >> x;
	ll tmp = x % 11;
	ll cnt = x / 11;
	ll res = cnt * 2;
	if (tmp != 0) {
		if (tmp <= 6) {
			res++;
		}else{
			res += 2;
		}
	}
	pv(res)
	return 0;
}

Measured memory_bytes: 3632
n,k=map(int,input().split())
drr=map(int,input().split())
digits = set(map(str,set([0,1,2,3,4,5,6,7,8,9])-set(drr)))
#print(digits)
for i in range(n,100000):
#    print(i,set(str(i)))
    if set(str(i)).issubset(digits):
        print(i)
        break

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

long long gc(long long a,long long b){
	if(a<=b) swap(a,b);
	if(a%b==0) return b;
	else return gc(b,a%b);
}

int main() {
  int T;
  cin>>T;
  int i,j;
  long long a,b,c,d;
  for(i=0;i<T;i++){
	cin>>a>>b>>c>>d;
	if(b>d) cout<<"No"<<endl;
	else if(b>a) cout<<"No"<<endl;
	else{
		long long e=gc(b,d);
		long long f=(a-c)/e;
		f-=1;
		long long k=a-e*f;
		if(k-e>c) k-=e;
		if(k<b) cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
 	
	}
  }
  return 0;
}     


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL);
using namespace std;
vector<pll>vec[100006];
ll dist[100006];
ll INF=2000000000000000000;
ll n,a,b,c,q,k;
void dijkstra(ll node)
{
    fill(dist,dist+n+1,INF);
    priority_queue<pll,vector<pll>,greater<pll>>que;
    que.push({node,0});
    while(que.size()){
        pll p=que.top();
        que.pop();
        ll u=p.ff,cost=p.ss;
        if(dist[u]<cost)continue;
        for(ll v=0;v<vec[u].size();v++){
            pll x=vec[u][v];
            if(dist[x.ff]>cost+x.ss){
                dist[x.ff]=cost+x.ss;
                que.push({x.ff,dist[x.ff]});
            }
        }
    }
}
int main()
{
    fastio
    cin>>n;
    for(int i=1;i<=n-1;i++){
        cin>>a>>b>>c;
        vec[a].pb({b,c});
        vec[b].pb({a,c});
    }
    cin>>q>>k;
    dijkstra(k);
    while(q--){
        cin>>a>>b;
        cout<<dist[a]+dist[b]<<endl;
    }
    return 0;
}


Measured memory_bytes: 14040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		sc.close();

		if((a.substring(a.length()-1, a.length()).equals(b.substring(0, 1)))
				&& (b.substring(b.length()-1, b.length()).equals(c.substring(0, 1)))) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}

}

Measured memory_bytes: 21844
import java.util.*;

public class Main {
	private static final String TEST = "";
	Scanner sc;
	int N;
	int[] A;
	int[] B;
	
/*-------------
 * constructor
 */
	public Main() {
		sc = new Scanner(System.in);
	}
	public Main(String input) {
		sc = new Scanner(input);
	}
	
/*------------------
 * instance methods
 */
	void out(Object o) {
		System.out.println(o);
		System.out.flush();
	}
	
	public void exec() throws Exception {
		// 読み込み
		N = sc.nextInt();
		A = new int[N+1];
		B = new int[N+1];
		for (int i = 0; i < N+1; i++) {
			A[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}
		
		// 処理 A[i] は上書きする
		int remainPower = 0;
		
		long destroyCnt = 0;
		for (int i = 0; i < N+1; i++) {
			// まず remainPower でやっつける
			if (A[i] < remainPower) remainPower = A[i];
			A[i] -= remainPower;
			destroyCnt += remainPower;
			// その上で勇者が戦う
			if (A[i] > B[i]) {
				// 魔物が多い。倒して力尽きる
				destroyCnt += B[i];
				remainPower = 0;
			} else {
				// 力があまる
				destroyCnt += A[i];
				remainPower = B[i] - A[i];
			}
		}
		out(destroyCnt);
	}
	
/*------
 * main
 */
	public static void main(String[] args) throws Exception {
		Main m = new Main();
		m.exec();
	}
}

	

Measured memory_bytes: 87696
using System;

namespace abc115A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int D = int.Parse(Console.ReadLine());
            if (D == 22)
                Console.WriteLine("Christmas Eve Eve Eve");
            else if (D == 23)
                Console.WriteLine("Christmas Eve Eve");
            else if (D == 24)
                Console.WriteLine("Christmas Eve");
            else
                Console.WriteLine("Christmas ");
        }
    }
}


Measured memory_bytes: 11092
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

// a^b % m
long long PowerMod(long long a, long long b, int m)
{
    long long res = 1;

    for (int i = 0; b > 0; i++) {
        if (b & 1) {
            res = (res * a) % m;
        }
        a = (a * a) % m;
        b >>= 1;
    }

    return res;
}

// a! % m
long long FactorialMod(long long a, int m)
{
    long long res = 1;
    for (int i = a; i > 0; i--) {
        res = (res * i) % m;
    }
    return res;
}

// nCr % m
long long CombinationMod(long long n, long long r, int m)
{
    if (r > n / 2) {
        r = n - r;
    }

    long long res = 1;
    for (int i = 0; i < r; i++) {
        res = (res * (n - i)) % m;
    }
    res *= PowerMod(FactorialMod(r, m), m - 2, m);
    res %= m;

    return res;
}

void PrimeFactorization(int x, vector<pair<int, int> >& y)
{
    int xrest = x;

    for (int i = 2; i < x; i++) {
        if (i > xrest) {
            break;
        }
        if (xrest % i == 0) {
            y.push_back(make_pair(i, 1));
            xrest /= i;
            while (1) {
                if (xrest % i == 0) {
                    y.back().second++;
                    xrest /= i;
                } else {
                    break;
                }
            }
        }
    }

}

int main()
{
    const int MOD = 1e9 + 7;

    int N, M;
    cin >> N >> M;

    vector<pair<int, int> > v;
    PrimeFactorization(M, v);

    long long ans = 1;
    for (int i = 0; i < v.size(); i++) {
        ans *= CombinationMod(v[i].second + N - 1, v[i].second, MOD);
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define fst first
#define snd second
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'

typedef long long ll;

int main() {
  string s, t; cin >> s >> t;
  string r = t.substr(0, t.size() - 1);
  if(s == r) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const ll mod = 1e9 + 7;
const ll INF = 1LL << 60;
//ここから書き始める

int main()
{
	cout <<setprecision(10);
	ll n , k ;
	cin >> n >> k;
	vector<ll> v(n);
	rep(i,n) cin >> v[i];
	ll naka = 0;
	rep(i,n){
		For(j,i+1,n){
			if(v[i] > v[j]){
				naka ++; //その文字列1区画の中での転倒数の数
			}
		}
	}
	ll soto = 0;
	rep(i,n){
		rep(j,n){
			if(v[i] > v[j]){
				soto ++;
			}
		}
	}
	//内部の転倒数は文字列の繰り返し分だけ。
	//外の転倒数は繰り返しk を用いて (k-1)+(k-2)+...+(1)
	naka %= mod;
	naka *= k%mod;
	naka%= mod;
	soto %= mod;
	ll roop = (k-1)*k / 2;
	roop %= mod;
	soto *= roop ;
	soto %= mod;
	ll ans = naka+soto;
	ans %= mod;
	cout << ans << endl;


}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, R;
    scan(N, R);
    writeln((10 <= N) ? R : R + 100 * (10 - N));
}


Measured memory_bytes: 256