akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,val) for(int i = 0; i < val; i++)

bool has_key(unordered_map<string, ll> &m, string s){
    if (m.find(s) == m.end()){
        return false;
    }
    else{
        return true;
    }
}


bool vector_find(std::vector<ll> vec, ll number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) {
    return true;
  }
  else {
    return false;
  }
}

int main() {
    
    ll N, M;
    cin >> N >> M;

    vector<ll> H(N);
    vector<ll> A(M);
    vector<ll> B(M);

    vector<vector<ll>> vec(N);

    for (ll i = 0; i < N; i++) {
        cin >> H.at(i);
    }

    for (ll i = 0; i < M; i++) {
        cin >> A.at(i);
        cin >> B.at(i);

        // cout << A.at(i) << " " << B.at(i) << endl;

        vec.at(A.at(i)-1).push_back(B.at(i));
        vec.at(B.at(i)-1).push_back(A.at(i));

    }

    ll ans = 0;

    for (ll i = 0; i < N; i++) {
        sort(vec.at(i).begin(), vec.at(i).end());
        vec.at(i).erase(unique(vec.at(i).begin(), vec.at(i).end()), vec.at(i).end());

        bool is_good = true;

        for (ll j = 0; j < vec.at(i).size(); j++) {
            // cout << i+1 << " " << vec.at(i).at(j) << " " << H.at(i) << " " << H.at(vec.at(i).at(j)-1) << endl;
            // // cout << H.at(3) << endl;
            // // cout << H.at(vec.at(i).at(j)-1) << endl;
            ll tmp = H.at(vec.at(i).at(j)-1);
            if (H.at(i) <= tmp) is_good = false;
        }
        // if (vec.at(i).size() == 0) is_good = true;
        if (is_good) {
            ans++;
            // cout << "good!" << endl;
        }

        // cout << "============" << endl;
    }
    




    cout << ans << endl;


    return 0;
}

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

int main() {
	int A,B,C;
	cin >> A >> B >> C;
  int nokori = A-B;
  cout << max(C - nokori,0) << endl;
}

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

ll n,a,b,c,d;

int main(){
    cin>>n>>a>>b>>c>>d;
    rep(i,n){
        ll j=n-i-1;
        if(c*i-d*j<=b-a&&b-a<=d*i-c*j){
            cout<<"YES\n";
            return 0;
        }
    }
    cout<<"NO\n";
}

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

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, int> psi;
typedef pair<string, ll> psl;
typedef pair<pii, int> tri;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<tri> viii;
 
typedef map<int,int> mii;
typedef map<char,int> mci;
typedef map<string, int> msi;
typedef map<string, vi> msv;
typedef unordered_map<int, int> umap;
typedef unordered_map<ll, ll> umapl;
typedef priority_queue<int> pq;

#define fi(i,a,b) for(auto i=a;i<b;i++)
#define fd(i,a,b) for(auto i=a;i>=b;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ss second
#define ff first
#define sz(a) a.size()
#define cini(a) int a; cin >> a;
#define cinii(a, b) int a, b; cin >> a >> b;
#define ciniii(a, b, c) int a, b, c; cin >> a >> b >> c;
#define cinl(a) ll a; cin >> a;
#define cinll(a, b) ll a, b; cin >> a >> b;
#define cinlll(a, b, c) ll a, b, c; cin >> a >> b >> c;
#define cinc(c) char c; cin >> c;
#define cins(s) string s; cin >> s;
#define cinss(s1, s2) string s1, s2; cin >> s1 >> s2;
#define cinvi(v, n) vi v(n, 0); fi(i, 0, n) cin >> v[i];
#define cinvl(v, n) vl v(n, 0); fi(i, 0, n) cin >> v[i];
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define flush fflush(stdout)

#define print(v) for (auto it = v.begin(); it != v.end(); ++it) cout << *it << ' '; cout << endl;
#define print2(v) for (auto it = v.begin(); it != v.end(); ++it) cout << *it << endl;
#define printmap(m) for (auto it = m.begin(); it != m.end(); ++it) cout << it->first<<' '<<it->second << endl; cout << endl;
#define disparr(arr,n) for(ll i=0;i<(n);++i)   cout<<arr[i]<<' ';  cout<<endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

#define LC(i) 2*(i)+1
#define RC(i) 2*(i)+2
#define MID(i,j) ((i)+(j))/2
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))

#define nn "\n"
#define sp << " " <<
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const int MOD = 1000000007;
const ll INF = 1e18;
const ld PI=3.141592653589793238462643383279502884197169399375105820974944;

int main()
{
	fastio; //Remove for interactive problems

	cini(x);
	if(x >= 30)
		cout << "Yes";
	else
	{
		cout << "No";
	}
	

	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
using namespace std;
//与えられた配列が最低何回で水やり可能かを返す。
int solve(int l,int r);
int h[100]={0};
int N;

int main(){
  int i,sum=0;
  cin>>N;
  for(i=0;i<N;i++){
    cin>>h[i];
  }
  int cnt=0;
  for(i=0;i<N;i++){
    if(h[i]==0 && cnt>0){
//      printf("main->solve(%d,%d)\n",i-cnt,i-1);
      sum+=solve(i-cnt,i-1);
      cnt=0;
    }else{
      cnt++;
    }
  }
//  printf("main->solve(%d,%d)\n",N-cnt,N-1);
  if(h[N-1]>0)sum+=solve(N-cnt,N-1);
  cout<<sum<<endl;
  return 0;
}

int solve(int l,int r){
  int i,cnt=0;
//1個の花の場合
  if(l==r){
//    printf("h[%d]だけ水やり\n",l);
    return h[l];
  }
//2個以上の花の場合
  int sum=1;
  bool flag=true;
//  printf("h[%d]~h[%d]だけ水やり\n",l,r);
  for(i=l;i<=r;i++){
    h[i]--;
    if(h[i]>0 && flag){l=i;flag=false;}
//    else if(flag)printf("h[%d]は終わり\n",i);
  } 
  
  for(i=l;i<=r;i++){
    if(h[i]==0 && cnt>0){
      sum+=solve(i-cnt,i-1);
       cnt=0;
    }else {
      cnt++;
    }      
  }
    
    
//  printf("*h[%d]~h[%d]だけ水やり\n",r-cnt+1,r);
  if(h[r]>0)sum+=solve(r-cnt+1,r);
  return sum;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) throws InterruptedException {
		    Scanner sc = new Scanner(System.in);	
			
			int in = sc.nextInt();
			int im = sc.nextInt();
			System.out.println(Recounciled(in,im));

		    sc.close(); }
	
	public static long Recounciled(int n , int m) {
		long ans = 1;
		if(Math.abs(n-m) >= 2){
			ans = 0;
		}else if(Math.abs(n-m) == 1){
			for(int i = 1; i <= n; i++){
				ans = (ans * i) % (1000000007);
			}
			for(int i = 1; i <= m; i++){
				ans = (ans * i) % (1000000007);
			}
		}else{
			for(int i = 1; i <= n; i++){
				ans = (ans * i) % (1000000007);
			}
			for(int i = 1; i <= m; i++){
				ans = (ans * i) % (1000000007);
			}
			ans = (ans * 2) % (1000000007);
		}
		return ans;
	}
}


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

#define int long long 
#define dou  double 
#define endl "\n"

const int MOD=1e9+7;

vector<int> adj[200005];
int vis[200005];

int dfs(int src,int cnt)
{
	vis[src]=1;
	for(int i=0;i<adj[src].size();i++)
	{
		int x = adj[src][i];
		if(!vis[x])
			cnt = dfs(x,cnt+1);
	}
	return cnt;
}

void solve()
{
	int n,m,i,x,y,mx=INT_MIN;
	cin >> n >> m;
	for(i=0;i<m;i++)
	{
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	for(i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			x = dfs(i,1);
			mx = max(mx,x);
		}
	}
	cout << mx << endl;
}

main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
}

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

using namespace std;

const int OO = 0x3f3f3f3f;
//const long long OO = (long long) 1e18L+7;
//const unsigned long long UOO = (long long) 10e18+7;
#define lp(i,a,n) for(long long i = a ; i < n ; ++i)
#define lpr(i,a,n) for(long long i = a ; i >= n ; --i)
#define rep(i,vec) for(ll i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(ll i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define EPS 1e-9
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef vector<int> vi ;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<pair<long long,long long>> vpll;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//int i=uniform_int_distribution<int>(1,n)(rng);
///-----------------------------------------------------------------------------

vi cnt(4);
int n;

double mem[305][305][305];


double dp(int ones, int twos, int threes){
    if(ones + twos + threes == 0 || ones < 0 || twos < 0 || threes < 0) return 0;
    double &ans = mem[ones][twos][threes];
    if(ans > -0.1) return  ans;
    double a =  double(ones) / n * (dp(ones-1,twos,threes) + 1);
    double b =  double(twos) / n * (dp(ones+1,twos-1,threes) + 1);
    double c =  double(threes) / n * (dp(ones,twos+1,threes-1) + 1);
    double d = double(n-ones-twos-threes) / n;
    ans = (a+b+c+d) * n / (ones + twos + threes);
    return ans;
}




///-----------------------------------------------------------------------------
int main()
{
    #ifndef ONLINE_JUDGE
    //   freopen( "output.txt" , "w" , stdout ) ;
    //   freopen( "input.txt" , "r" , stdin ) ;
    auto stTime = clock();
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
///-----------------------------------------------------------------------------------

    cin >> n;

    lp(i,0,n) {
        int t;
        cin >> t;
        ++cnt[t];
    }
    memset(mem,-1,sizeof mem);

    cout << fixed << setprecision(14) <<  dp(cnt[1],cnt[2],cnt[3]);




///------------------------------------------------------------------------------------
    #ifndef ONLINE_JUDGE
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif

    return 0;
}


Measured memory_bytes: 225436
n, k = map(int, input().split())
h = [int(input()) for i in range(n)]
h.sort()

h_min = h[0]
h_max = h[k-1]
for i in range(1, n-k+1):
    if h[k-1 + i] - h[i] < h_max - h_min:
        h_max = h[k-1 + i]
        h_min = h[i]
        
print(h_max - h_min)

Measured memory_bytes: 7388
/*
       Hi there <3 
──────▄▀▄─────▄▀▄
─────▄█░░▀▀▀▀▀░░█▄
─▄▄──█░░░░░░░░░░░█──▄▄
█▄▄█─█░░▀░░┬░░▀░░█─█▄▄█

*/
#include <bits/stdc++.h>
#define MOD 1000000007
#define re return
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define y0 y32479
#define y1 y95874
#define next next239
#define prev prev239
#define fill(x, y) memset(x, y, sizeof(x))
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define ba back()
#define popcount __builtin_popcountll
#define fastIO()                 \
    {                            \
        ios::sync_with_stdio(0); \
        cin.tie(0);              \
        cout.tie(0);             \
    }
#define in(x) \
    int x;    \
    cin >> x;
#define in1(x) \
    int x;     \
    cin >> x;  \
    x--;
#define inll(x) \
    ll x;       \
    cin >> x;
#define ins(x) \
    string x;  \
    cin >> x;

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef pair<double, double> pdd;
typedef long double LD;
typedef double D;

void Solve()
{
    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    ll total = 0;
    if (a - k >= 0)
    {
        total +=k;
        k = 0;
    }
    else
    {
        total += a;
        k = k - a;
    }

    if (k > 0)
    {
        if (b - k >= 0)
        {
            k = 0;
        }
        else
        {
            k=k-b;
        }
        
    }
    if (k > 0)
    {
        total=total+(-1*(k));
    }
    cout<<total<<endl;
}

int main()
{
    fastIO();
    int t;
    t = 1;
    while (t--)
    {
        Solve();
    }
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    vi x(n), l(n);
    rep(i,n){
        cin >> x[i] >> l[i];
    }

    vector<P> vec(n);
    rep(i,n){
        int s = x[i] - l[i];
        int g = x[i] + l[i];
        vec[i].first = g;
        vec[i].second = s;
    }
    sort(vec.begin(), vec.end());

    int cur = -1e9;
    int ans = 0;
    rep(i,n){
        if (vec[i].second >= cur){
            cur = vec[i].first;
            ans++;
        }
    }

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


Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e9+5;
int hs[100100];
ll dp[100100];

void solve() {
    int N, K;
    cin >> N >> K;
    for (int i = 1; i <= N; ++i) cin >> hs[i];
    dp[1] = 0;
    for (int i = 2; i <= N; ++i) {
        int h = hs[i];
        ll m = INF;
        for (int k = 1; k <= K; ++k) {
            if (0 < i - k) {
                ll x = dp[i - k] + abs(h - hs[i - k]);
                m = min(m, x);
            }
        }
        dp[i] = m;
    }
    cout << dp[N] << endl;
}

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


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;

char str[N];
int to[N << 1],nex[N << 1],beg[N],col[N],totb[N],sz[N],In[N],val[N];
int Max[N],deg[N];
int e,res = -INF;

inline void add(int x,int y) {
	to[++e] = y,nex[e] = beg[x],beg[x] = e;
}

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

inline void dfs(int x,int fa) {
	totb[x] = col[x];
	for(int i = beg[x];i;i = nex[i]) {
		if(to[i] == fa) continue;
		dfs(to[i],x);
		if(totb[to[i]]) sz[x] += sz[to[i]],totb[x] += totb[to[i]],deg[x] ^= 1;
	}
	if(totb[x]) sz[x]++,In[x] = true,deg[x] ^= 1;
}

inline void Dp(int x,int fa) {
	Max[x] = max(0,val[x]);
	for(int i = beg[x];i;i = nex[i]) {
		if(to[i] == fa || !In[to[i]]) continue;
		Dp(to[i],x);
		chkmax(res,Max[x] + Max[to[i]]);
		chkmax(Max[x],Max[to[i]] + val[x]);
	}
}

int main() {

	int n = read(),id = 0;
	For(i,1,n - 1) {
		int x = read(),y = read();
		add(x,y),add(y,x);
	}
	scanf("%s",str + 1);
	bool flag = false;
	For(i,1,n) {
		col[i] = (str[i] == 'W');
		if(col[i]) flag = true,id = i;
	}
	if(!flag) return puts("0"),0;
	dfs(id,0);deg[id] ^= 1;
	if(sz[id] == 1) return puts("1"),0;
	int ans = (sz[id] - 1) * 2;
	For(i,1,n) {
		if((deg[i] ^ col[i]) == 0) val[i] = 0;
		else val[i] = 2,++ans;
	}
	memset(Max,-63,sizeof(Max));
	Dp(id,0),ans -= res;

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
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; }
const int INF = 1e9;
const long long INFL = 1LL<<60;

int main() {
  int n, m;
  cin >> n >> m;
  ll time = 0;
  time += 100 * (n - m);
  time += 1900 * m;

  int num_try = pow(2, m);

  cout << time * num_try << endl;

  return 0;
}


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

string f(string S){

  string ans = "Yes";
  for(int i= 0; i < S.size(); i++){
    if((i % 2 == 0) && (S[i] == 'L')){
      return "No";
    }
    if ((i % 2 == 1) && (S[i] == 'R')){
      return "No";
    }
  }
  return ans;
}

int main(){
  string S;
  cin >> S;
  string ans = f(S);
  cout << ans << endl;
}


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

#define ll long long

int main(){
    ll x;
    cin>>x;
    for (ll i = -118;i<=119;++i){
        for (ll j = -119;j<=118;++j){
            if ((ll)pow(i,5)-(ll)pow(j,5)==x){
                cout<<i<<" "<<j;
                return 0;
            }
        }
    }
    // cout<<count;
}

Measured memory_bytes: 4096
import bisect
N = int(input())
A = list(map(int, input().split()))

A_sum = []
tmp = 0
for a in A:
  tmp += a
  A_sum.append(tmp)

ans = 10**10
for part_mid in range(1,N-2):
  sum_l = A_sum[part_mid]
  part_lft = bisect.bisect_right(A_sum, (A_sum[part_mid]+0)//2)-1
  if part_lft == -1 or abs(2*A_sum[part_lft+1] - A_sum[part_mid]) < abs(2*A_sum[part_lft] - A_sum[part_mid]):
    part_lft += 1
  
  part_rgt = bisect.bisect_right(A_sum, (A_sum[N-1]+A_sum[part_mid])//2)-1
  if part_rgt < part_mid or abs(2*A_sum[part_rgt+1] - (A_sum[N-1]+A_sum[part_mid])) < abs(2*A_sum[part_rgt] - (A_sum[N-1]+A_sum[part_mid])):
    part_rgt += 1
  s = [A_sum[part_lft], A_sum[part_mid] - A_sum[part_lft], A_sum[part_rgt]-A_sum[part_mid], A_sum[N-1] - A_sum[part_rgt]]
  ans = min(ans, max(s) - min(s))
  #print(s, part_mid, A_sum)
  
print(ans)
  
  
         

Measured memory_bytes: 100224
#define _CRT_SECURE_NO_WARNINGS

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

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (ll)(4e18) + 9;
const int MOD = (int)(1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { D, R, U, L , dr, ur, dl, ul };
int dx[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiouy"; //and sometimes "aeiouy"

template<typename X, typename Y> bool ckmin(X& a, Y b) { return a > b ? a = b, true : false; }
template<typename X, typename Y> bool ckmax(X& a, Y b) { return a < b ? a = b, true : false; }
bool cklex(string &a, string b) {
	if (b == "") return false;
	if (a == "") return a = b, true;
	if (sz(a) < sz(b)) return false;
	if (sz(b) < sz(a)) return a = b, true;
	if (a < b) return false;
	return a = b, true;
}

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
int conv_2_1(int r, int c, int nCol) { return (nCol*r) + c + 1; } //convert index from 2D array to 1D array. (Zero-indexed)
ii conv_1_2(int n, int nCol) { return{ n / nCol, n % nCol }; } //convert index from 1D array to 2D array (row, col). (Zero-indexed)
template<typename T> void inter(T X) { cout << X << endl; fflush(stdout); }


void solveF() {

}

void solveE() {

}

void solveD() {

}

void solveC() {

}

void solveB() {

}

void solveA() {
	int a, b;
	cin >> a >> b;
	int sum = 1, ans=0;
	while (sum < b) sum += a - 1, ans++;
	cout << ans << endl;
}


int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int t = 1;
	//cin >> t;
	while (t--) {
		solveA();
		//solveB();
		//solveC();
		//solveD();
		//solveE();
		//solveF();
	}


	return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  string a, b;
  while(cin>>a>>b, a != "0"){
    int ans1 = 0;
    int ans2 = 0;

    REP(i,4){
      REP(j,4){
        if(a[i] == b[j]){
          if(i == j) ans1++;
          else ans2++;
        }
      }
    }

    cout << ans1 << " "
         << ans2 << endl;
  }
  return 0;
}

Measured memory_bytes: 916
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = nk[0];
        var k = nk[1];
        var seqP = Console.ReadLine().Split().Select(x => float.Parse(x)).ToArray();

        var es = new double[seqP.Length + 1];
        for (int i = 1; i < es.Length; ++i)
        {
            var x = (1 + seqP[i - 1]) * seqP[i - 1] / 2 / seqP[i - 1];
            es[i] = x < es[i - 1] ? x + es[i - 1] : es[i - 1] + x;
        }

        var max = new Transitive<double>(0);
        for (int i = k; i < es.Length; ++i)
        {
            max += es[i] - es[i - k];
        }

        Console.WriteLine($"{max}");
    }

    struct Transitive<T>
    where T : IComparable<T>
    {
        public T Value;
        public Transitive(T value)
        {
            Value = value;
        }

        public override string ToString() => Value.ToString();

        public static implicit operator Transitive<T>(T value) => new Transitive<T>(value);
        public static Transitive<T> operator -(Transitive<T> x, Transitive<T> y) => x.Value.CompareTo(y.Value) < 0 ? x : y;
        public static Transitive<T> operator +(Transitive<T> x, Transitive<T> y) => x.Value.CompareTo(y.Value) > 0 ? x : y;
    }
}


Measured memory_bytes: 35304
D=int(input())
c=[]
c=list(map(int,input().split()))
s=[]
for i in range(D):
    s.append(list(map(int,input().split())))

for i in range(D):
    mamax=max(s[i])
    ans=s[i].index(mamax)+1
    print(ans)


Measured memory_bytes: 67908
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define N 3
#define N2 9
#define LEN 10000000

typedef struct Puzzle{
  int f[N2];
  int space;
  int path;
} Puzzle ;

int V[LEN];
static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
//static const char dir[4]={'u','l','d','r'};

struct Puzzle Q[LEN];
int head = 0, tail = 0;

void enqueue(Puzzle x){
   Q[tail]=x;
   tail=(tail+1)%LEN;
}

Puzzle dequeue(){
  Puzzle x=Q[head];
  head=(head+1)%LEN;
  return x;
}

int chim(Puzzle p){
  int i, j,muri, count,n=0;
  for(i=0,muri=1;i<N2;muri*=++i){
    for(j=0,count=0;j<i;j++){
      if(p.f[j]<p.f[i])count++;
    }
    n+=count*muri;
  }
  return n;
}

int isTarget(Puzzle p){
  for(int i = 0; i < N2; i++){
  	if(p.f[i] != (i+1)) return 0;
  }
  return 1;
}

int bfs(Puzzle spc){
  struct Puzzle u,v;
  spc.path=0;
  enqueue(spc);
  V[chim(spc)]=1;
  
  while(head != tail){ 
  int sx,sy,tx,ty,z,r;
    u=dequeue();
    if(isTarget(u)){
        return u.path;
    }
     sx=u.space/N;
     sy=u.space%N;
    for(r=0;r<4;r++){
       tx=sx+dx[r];
       ty=sy+dy[r];
      if(tx<0 || ty<0 || tx>=N || ty>= N)continue;
      v=u;
      z=v.f[u.space];
      v.f[u.space]=v.f[tx*N+ty];
      v.f[tx*N+ty]=z;
      v.space=tx*N+ty;
      if(V[chim(v)] != 1){
	V[chim(v)] = 1;
	v.path++;//=dir[r];
	enqueue(v);
      }
    }
  }

  return -1;
}

int main(){
  Puzzle in;
  
  for(int i = 0; i < N2; i++){
    scanf("%d",&in.f[i]);
    if(in.f[i] == 0){
      in.f[i] = N2;
      in.space = i;
    }
  }
int answer;
answer = bfs(in);
printf("%d\n",answer );
return 0;
}



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

typedef pair<int,int> PII;

int a[31];

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

	for (int i = 0; i < n; ++i){
		int k;
		cin>>k;
		for (int j = 0; j < k; ++j){
			int num;
			cin>>num;
			a[num]++;
		}
	}

	int ans=0;
	for (int i = 1; i <= m; ++i){
		if(a[i]==n)
			ans++;
	}

	cout<<ans<<endl;

}

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

int main(){
    int N,K;
    cin>>N>>K;
    vector<ll> x(N);
    rep(i,N){cin>>x[i];}


    ll res = 1e+18;
    for(int i=0;i<N-K+1;i++){
        ll tmp = min(abs(x[i])+abs(x[i+K-1]-x[i]),abs(x[i+K-1])+abs(x[i+K-1]-x[i]));
        res = min(res,tmp);
    }
    cout<<res;
}

Measured memory_bytes: 1024
# include<iostream>
# include<vector>
# include<algorithm>

int main(){
    int n;
    std::cin >> n;
    std::vector<int> A(n),B(n);
    // 入力
    for(int i = 0;i < n;i++){
        std::cin >> A.at(i) >> B.at(i);
    }
    // 中央値を考えるためにソート
    std::sort(A.begin(),A.end());
    std::sort(B.begin(),B.end());
    // 奇数の時は1ごと、偶数の時は1/2ずつ値を取るので場合分け
    if(n%2 == 1){
        std::cout << B.at(n/2) - A.at(n/2) + 1 << std::endl;
        // 奇数の時、中央値は前からn//2番目(0-index)
    }
    else{
        std::cout << (B.at(n/2) + B.at(n/2-1)) - (A.at(n/2) + A.at(n/2 - 1)) + 1 << std::endl;
        // 偶数の時、中央値は前からn//2-1番目とn//2番目の平均(0-index)
    }
}

Measured memory_bytes: 4772
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;
#define input(N) cin >> N ;

signed main() {
ll N,ans=1,p=1;
cin >> N;
vector<ll> A(N);
REP(i,18){
p = p * 10;
}
REP(i,N){
    cin >> A[i];
    if(A[i]==0){
         ans = 0;
        answer(ans);
        return 0;
    }
}
REP(i,N){
    if(p/ans < A[i]){
        ans = -1;
        answer(ans);
        return 0;
    }
    ans = ans * A[i];
}

/*if(ans > p){
    ans =-1;
}*/
answer(ans);

}


Measured memory_bytes: 4052
sa = input()
sb = input()
sc = input()
ia = -1
ib = -1
ic = -1
c = 'a'
while True:
  if c == 'a':
    ia += 1
    try:
      c = sa[ia]
    except:
      print('A')
      break
  elif c == 'b':
    ib += 1
    try:
      c = sb[ib]
    except:
      print('B')
      break
  else:
    ic += 1
    try:
      c = sc[ic]
    except:
      print('C')
      break

Measured memory_bytes: 3064
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	Scanner scanner = new Scanner(System.in);
	boolean Judge = true;
  	String end = "-";
  	String work;
  	
  	
  	while( Judge ){
		String deck = scanner.next();		//最初の文字
  		//終わる処理と変換
  		if( deck.equals(end) ){
  			Judge = false;
  			break;
  		}
		int shuffle = scanner.nextInt();	//シャッフル回数
  		//シャッフル
  		for( int i = 0; i < shuffle ; i ++ ) {
			int num = scanner.nextInt();	//シャッフル開始位置
			String substr = deck.substring(0, num);
			work = deck.replaceFirst(substr, "");
			deck = work.concat(substr);
  		}
  	  	//結果出力
  		System.out.println(deck);
  	}
  	
	
  	//後処理
	scanner.close();
  }
}


Measured memory_bytes: 26776
#include <bits/stdc++.h>
using namespace std;
int MOD;
inline int add(int a,int b)
{a+=b;return a>=MOD?a-MOD:a;}
inline int sub(int a,int b)
{a-=b;return a<0?a+MOD:a;}
inline int mul(int a,int b)
{return 1ll*a*b%MOD;}
int ksm(int a,int b)
{
	int ans=1;
	for(;b;b>>=1,a=mul(a,a))
		if(b&1)ans=mul(ans,a);
	return ans;
}
const int Q=255;
int f[Q][Q];
int fac[Q+1],ifac[Q+1];
int G(int n,int m,int k)
{
	if(n>k||m>k)return 0;
	memset(f,0,sizeof(f));
	for(int j=0;j<=min(m-1,k-n);j++)
		f[1][j]=1;
	for(int i=1;i<n;i++){
		for(int j=0;j<=m;j++){
			if(!f[i][j])continue;
			int r=min(i+k-n,m),l=max(j,m-k+i);
			if(l<=r)f[i+1][l]=add(f[i+1][l],f[i][j]),f[i+1][r+1]=sub(f[i+1][r+1],f[i][j]);
		}
		for(int j=1;j<=m;j++)
			f[i+1][j]=add(f[i+1][j],f[i+1][j-1]);
	}
	int als=0;
	for(int j=0;j<=m;j++)
		als=add(als,f[n][j]);
	return mul(als,fac[n+m]);
}
int main()
{
	int n,kk;
	scanf("%d%d%d",&n,&kk,&MOD);
	fac[0]=1;
	for(int i=1;i<=Q;i++)
		fac[i]=mul(fac[i-1],i);
	ifac[Q]=ksm(fac[Q],MOD-2);
	for(int i=Q;i;--i)
		ifac[i-1]=mul(ifac[i],i);
	int als=mul(kk==n-1,fac[n]);
	for(int d=0;d<kk;d++)
		for(int i=1;i<=n-d-2;i++)
			als=add(als,mul(mul(fac[n],ifac[n-d]),G(i,n-d-i-1,kk-d)));
	printf("%d\n",als);
	return 0;
}

Measured memory_bytes: 4064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define loops(i, s, n) for (int i = s; i < n; i++)
#define loop(i, n) for (int i = 0; i < n; i++)
#define eps 1e-9
#define loopitr(mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define even_set 0xAAAAAAAA ... 1010101010
#define odd_set 0x55555555 ... 01010101
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vall(v) v.begin(), v.end()
#define mkp make_pair
#define ret return
#define cont continue
#define ff first
#define ss second
#define cnt_bits __builtin_popcount
const int mod = 1000000007;

int main()
{

    fastio;


    int n, w;
    cin >> n >> w;
    ll arr[n+1][2];
    loops(j,1,  n+1)
    {
        cin >> arr[j][0] >> arr[j][1];
    }

    ll dp[n+1][w+1];
    loop(j, w+1)
      dp[0][j] = INT32_MIN;

    loop(j ,n+1)  
      dp[j][0] = 0;

    loops(i, 1, n+1){
        loops(j, 1, w+1){
            dp[i][j] = dp[i-1][j];
            dp[i][j] = max(dp[i][j] ,((j-arr[i][0] >=0 )? dp[i-1][j-arr[i][0]] + arr[i][1] : INT32_MIN));
        }
    }

    ll ans = INT32_MIN;
    loops(j, 1, w+1 ){
        ans = max(ans, dp[n][j]);
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 79104
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<cstdio>

using namespace std;

#define rep(i, n) for(long int i = 0; i < n; i++)
#define P pair<long int, long int>

int const MAX_N = 100000;
int par[MAX_N]; // 親
int depth[MAX_N]; // 木の深さ

// n要素で初期化
void init(int n){
    for(int i = 0; i < n; i++){
        par[i] = i;
        depth[i] = 0;
    }
}

// 木の根を求める
int find(int x){
    if (par[x] == x) {
        return x;
    }else{
        return par[x] = find(par[x]);
    }
}

// xとyの属する集合を合併
void unite(int x, int y){
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (depth[x] < depth[y]) {
        par[x] = y;
    }else{
        par[y] = x;
        if (depth[x] == depth[y]) depth[x]++;
    }
}

// xとyが同じ集合に属するか否か
bool same(int x, int y){
    return find(x) == find(y);
}



int main(){
    int n, m;
    cin >> n >> m;
    int x[m], y[m], z[m];
    rep(i, m) {
        cin >> x[i] >> y[i] >> z[i];
        x[i]--; y[i]--;
    }

    init(n);
    rep(i, m){
        unite(x[i], y[i]);
    }
    int ans = 0;
    rep(i, n) if (par[i] == i) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 2176
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    ll n; cin >> n;

    if(n % 2 == 1){
        cout << 0 << endl;
        return 0;
    }

    vector<ll> pow5;
    ll temppow = 2;
    rep(i, 30){
        temppow *= 5;
        if(temppow > 1e18) break;
        pow5.push_back(temppow);
    }

    // rep(i, pow5.size()){
    //     cout << pow5[i] << endl;
    // }

    ll ans = 0;
    rep(i, pow5.size()){
        ans += n / pow5[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    static const double pi = 3.141592653589793;
 typedef pair<int64_t,int64_t> P;
#define rep(i, n) for (int i = 0; i < (n); i++)
 #define all(v) (v).begin(),(v).end()
 using ll = long long;
using Graph = vector<vector<int>>;
const int MAX = 510000;
const int MOD = 1000000007;
 const int NINE=1000000000;
 
 
int main(){
ll N,K;
  cin>>N>>K;
  vector<ll>op(N);
  rep(i,N){
  ll a;
    cin>>a;
  op[i]=a;
  }
set<ll>S;
  if(N==K) cout<<1;
  else{
    ll ans=1;
  rep(i,K+1) S.insert(op[i]);
 for(ll i=K;i<N;i++) 
 {
   S.insert(op[i]);
 if(op[i]==*rbegin(S) && op[i-K]==*begin(S)){
 S.erase(op[i-K]);
 }
 else{
 ans++;
 S.erase(op[i-K]);
 }
  
 }
  ll t=0;
    ll g=1;
    rep(i,N-1){
    if(op[i]<op[i+1]) g++;
    else g=1;
      if(g==K){
        t++;
      }
    }
    
    if(t>1) ans=ans-(t-1);
  cout<<ans;
  
  } 
  
  
  
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int sum = 0;
    rep(i, n) sum += a[i];
    if (sum % 10 != 0)
    {
        cout << sum << endl;
        return 0;
    }
    int MIN = sum;
    rep(i, n) if (a[i] % 10 != 0) MIN = min(MIN, a[i]);
    cout << sum - MIN << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

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; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

  int k;
  cin >> k;
  ll ans = 0;

  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= k; j++) {
      int tmp = gcd(i, j);
      for (int l = 1; l <= k; l++) {
        ans += gcd(tmp, l);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int n,m,q;
vector<int> vec;
long long int ans=0;
void saiki(int i,vector<vector<int>> hoge){
  if(i==n){
    long long int pre=0;
    for(int i=0; i<q; i++){
      if(vec.at(hoge.at(i).at(1)-1)-vec.at(hoge.at(i).at(0)-1)==hoge.at(i).at(2)){
        pre+=hoge.at(i).at(3);
      }
      ans=max(ans,pre);
    }
  }else{
    for(int j=1; j<=m; j++){
      if(i!=0&&vec.at(i-1)>j){
        continue;
      }
      vec.at(i)=j;
      saiki(i+1,hoge);
    }
  }
}
int main(void){
  cin>>n>>m>>q;
  vec.resize(n);
  vector<vector<int>> hoge(q,vector<int> (4));
  for(int i=0; i<q; i++){
    for(int j=0; j<4; j++){
      cin>>hoge.at(i).at(j);
    }
  }

  saiki(0,hoge);
  cout<<ans<<endl;
}

Measured memory_bytes: 3640
n,m=map(int,input().strip().split())

likeList=[]
for i in range(n):
    ai=list(map(int,input().strip().split()))[1:]
    likeList.extend(ai)
like=0
for i in range(m):
    if likeList.count(i+1)==n:
        like+=1
print(like)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
template <typename T = int>
T in() {
    T temp; cin >> temp; return temp;
}

template <typename VType = int>
list<VType> const LR(VType start, VType end) {
    list<VType> ret; for (VType i = start; i < end; i++) ret.push_back(i); return move(ret);
}

int main() {
    int const n(in());
    multiset<int> d;

    for (int i = 0; i < n; i++) {
        int temp(in());
        d.insert(temp);
    }

    multiset<int>::iterator ite = d.cbegin();
    for (int i = 0; i < (n/2 -1 ); i++) {
        
        ite++;
    }
    auto next = ite;
    next++;
    cout << *next - *ite << endl;


    return 0;
}




Measured memory_bytes: 4992
//******\\
||udc321||	 
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<queue>
#include<map>
#include<set>
#include<fstream>
#define ll long long
#define fr(e,r,v) for(int e=r;e<v;e++)
#define bc(e,r,v) for(int e=r;e>v;e--)
#define all(n) (n.begin(),n.end())
#define ft first
#define sd second
#define pb push_back
#define lb lower_bound
#define mpr make_pair
#define db  double
using namespace std;
ll mod=1000000007;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	 ll n;
	 cin>>n;
	 ll a[n];
	 ll s[n];
	 fr(j,0,n)
	 {cin>>a[j];
	 	if(j==0){s[j]=a[j];continue;}
	 	else{s[j]=s[j-1]+a[j];}

	 }
	 ll an=0;
	 fr(j,1,n)
	 {
	 	an+=(a[j]*(s[j-1]%mod))%mod;
	 }
	 cout<<(an)%mod<<endl;
	}


Measured memory_bytes: 6700
using System;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram{
    class AtCoder{
        static void Main(){
            var A = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
            var N = A[0];
            var K = A[1];
            var H = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);

            Array.Sort(H);
            long sum=0;
            for(var i=0;i<N-K;i++){
                sum += H[i];
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 33792
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n, arr[105], ar[105], k, z=0, x;
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> arr[i];
    }
    for(int i=n; i>=1; i--){
        k=i;
        x=i;
        while(x>=1 && arr[x]!=x){
            x--;
        }
        if(arr[x]==x){
            ar[k]=arr[x];
            for(int j=x; j<=i; j++){
                arr[j]=arr[j+1];
            }
        }
        else{
            x=-1;
            cout << x << endl; 
            return 0;
        }
    }
    for(int i=1; i<=n; i++){
        cout << ar[i] << endl;
    }
    return 0;
}

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

int main(){
 int A,B,C,D;
  cin>>A>>B>>C>>D;
 int Left=A+B;
 int Right=C+D;
   if(Left>Right){
     cout<<"Left";
   }else if(Left<Right){
     cout<<"Right";
   }else{
     cout<<"Balanced";
   }
}

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

int main(void) {
    
    long long int n, a , b, remind, divide;
    cin >> n >> a >> b;
    
    divide = n / (a + b);
    remind = n % (a + b);
    
    remind = (remind > a) ? a : remind;
   
    cout << (divide * a) + remind << endl;

    return 0;
}


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

using namespace std;

int main(){

long long n;
cin>>n;

vector<long long> x(n);
vector<long long> xp(n);


for(long long i=0;i<n;i++){
  cin>>x.at(i);
  xp.at(i) = x.at(i);
}

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

long long m;
m = floor((xp.at(n/2) + xp.at((n/2)-1))/2);

for(long long i=0;i<n;i++){
  if(x.at(i)<=m){
    cout<<xp.at(n/2)<<endl;
  }else{
    cout<<xp.at((n/2)-1)<<endl;
  }
}



}


Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long int ll;
int main(){
  ll a,b,c;
  cin >>a>>b>>c;
  if(a*a+b*b==c*c){
    cout << (a*b)/2<<endl;
    return 0;
  }
  if(a*a+c*c==b*b){
    cout << (a*c)/2<<endl;
    return 0;
  }
  if(b*b+c*c==a*a){
    cout << (c*b)/2<<endl;
    return 0;
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <limits>
#include <numeric>
#include <functional>
#include <map>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
using namespace std;

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

	int N, T, A, h;
	int count = 0;
	double diff = 1111111111;
	
	cin >> N >> T >> A;

	REP(i, N)
	{
		cin >> h;
		double tmp = abs(A - (T - h * 0.006));

		if (diff > tmp)
		{
			diff = tmp;
			count = i;
		}
	}

	cout << count + 1 << endl;

	return 0;
}

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

int N, M;
vector<vector<pair<int, long long>>> g;
vector<long long> pos;

bool dfs(int i) {
    if (pos[i] == numeric_limits<long long>::max()) pos[i] = 0;
    for (auto& p : g[i]) {
        if (pos[p.first] != numeric_limits<long long>::max()) {
            if (pos[p.first] != pos[i] + p.second) return false;
            continue;
        }
        pos[p.first] = pos[i] + p.second;
        dfs(p.first);
    }
    return true;
}

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

    g.resize(N);
    pos.assign(N, numeric_limits<long long>::max());

    for (int i = 0; i < M; ++i) {
        int l, r, d;
        cin >> l >> r >> d;
        --l, --r;
        g[l].emplace_back(r, d);
        g[r].emplace_back(l, -d);
    }

    bool ans = true;
    for (int i = 0; i < N; ++i) {
        ans &= dfs(i);
    }

    cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 16512
class Splice
  attr_accessor :start_node, :last_node

  def initialize(n)
    @start_node = Array.new(n)
    @last_node = Array.new(n)

    n.times do |i|
      @start_node[i] = List.new("START")
      @last_node[i] = @start_node[i]
    end
  end

  class List
    attr_accessor :data, :nnext

    def initialize(data=nil, nnext=nil)
      @data = data
      @nnext = nnext
    end
  end

  def insert(t, x)
    current_node = @last_node[t]
    new_node = List.new(x)
    current_node::nnext = new_node
    @last_node[t] = new_node
  end

  def dump(t)
    current_node = @start_node[t]

    if current_node::nnext.nil?
      puts ""
    else
      current_node = current_node::nnext
      while true
        print current_node::data
          if current_node::nnext.nil?
            print "\n"
            break
          end
        print " "
        current_node = current_node::nnext
      end
    end
  end

  def splice(s, x)
    join_node = @last_node[x]
    push_node = @start_node[s]
    join_node::nnext = push_node::nnext
    @last_node[x] = @last_node[s]
    push_node::nnext = nil
    @last_node[s] = @start_node[s]
  end
end

n, q = gets(chomp:true).split.map(&:to_i)
splice = Splice.new(n)

q.times do
  o, t, x = gets(chomp:true).split.map(&:to_i)
  case o
  when 0
    splice.insert(t, x)
  when 1
    splice.dump(t)
  when 2
    splice.splice(t, x)
  end
end


Measured memory_bytes: 47068
#include <bits/stdc++.h>
//#ifndef ONLINE_JUDGE
//#  define LOG(x) (cerr << #x << " = " << (x) << endl)
//#else
//#  define LOG(x) 0
//#endif
#define pb push_back
#define mod 1000000007
#define endl '\n'
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

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

const integer NN = 200005;
int ar[NN];
int n, m, k;


integer main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> k;
    set<int> S;
    for (int i = 0; i < n; i++){
        S.insert(i+1);
    }
    for (int i = 0; i < k; i++){
        int d;
        cin >> d;
        for (int j = 0; j < d; j++){
            int a;
            cin >> a;
            if (S.count(a))
                S.erase(a);
        }
    }
    cout << S.size() << endl;

}


Measured memory_bytes: 3652
#include <stdio.h>

int main(void)
{

  int K,N,i,ans;
  int dis_max = 0;
  scanf("%d %d",&K,&N);
  int a[N];
  int d[N];
  for(i=0;i<N;i++)
  {
    scanf("%d",&a[i]);
  }
  for(i=0;i<N-1;i++)
    d[i] = a[i+1] - a[i];
  
  d[N-1] = a[0] - a[N-1] + K;
  
  for(i=0;i<N;i++)
    if(dis_max < d[i])
      dis_max = d[i];

  ans = K - dis_max;
  

  printf("%d\n",ans);
  return 0;
}

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

int main(){
  long long N, A, B;
  cin >> N >> A >> B;
  long long roop = N/(A+B);
  long long hasuu = N%(A+B);
  
  long long ans = roop*A;
  
  if(hasuu >= A){
    ans += A;
  }else{
    ans += hasuu;
  }
  
  cout << ans << endl;
}
    
  

Measured memory_bytes: 256