akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m;
  cin>>n>>m;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  double sum=0;
  for(int i=0;i<n;i++){
    sum += a.at(i);
  }
// cout<<sum<<endl;
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
//  cout<<a[0]<<a[1]<<endl;
  int count=0;
//  cout <<a.at(1)<<endl;
  for(int j=0;j<m;j++){
    if((a.at(j))<(sum/(4*m))){
        count=count+1;
    }
  }
  if(count==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 21:05:25 2020

@author: Kanaru Sato
"""

s = input()
days = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

for i in range(7):
    if days[i] == s:
        print(7-i)
        break

Measured memory_bytes: 38256
<?php
fscanf(STDIN,'%d',$A);
fscanf(STDIN,'%d',$B);
fscanf(STDIN,'%d',$C);
fscanf(STDIN,'%d',$D);
fscanf(STDIN,'%d',$E);
$Q=[$A,$B,$C,$D,$E];
$Ap=$A%10;
$Bp=$B%10;
$Cp=$C%10;
$Dp=$D%10;
$Ep=$E%10;
$P=[$Ap,$Bp,$Cp,$Dp,$Ep];
$min;
$sum=0;
if(array_sum($P)==0){
  echo array_sum($Q);
}else{
  for ($i=0; $i <=4 ; $i++) {
    // code...
    if($P[$i]==0){
      $P[$i]=10;
    }
  }
  $min=min($P);
  for ($i=0; $i <=4 ; $i++) {
    // code...
    if($Q[$i]%10==0){
      $sum+=$Q[$i];
    }else{
      $sum+=ceil($Q[$i]/10)*10;
    }
  }
  echo $sum-10+$min;
}
echo "\n";


 ?>


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

struct res {
	int num, p;
	string s;

	bool operator < (const res & rhs) const
	{
		return s < rhs.s || (s == rhs.s && p > rhs.p);
	}

};

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

	vector<res> v(n);

	for (int i = 0; i < n; i++) {
		v[i].num = i + 1;
		cin >> v[i].s >> v[i].p;
	}

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

	for (int i = 0; i < n; i++)
		cout << v[i].num << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

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

  ll n, k; cin >> n >> k;
  vector<ll> bucket(100010);

  int a, b;
  rep(i, n) {
    cin >> a >> b;
    bucket[a] += b;
  }

  for(int i = 1; i < 100010; ++i) {
    if(k <= bucket[i]) {
      cout << i << '\n';
      return 0;
    }
    k -= bucket[i];
  }
  return 0;
}


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

const int MAXN = 400 + 10;

int n;
ll a[MAXN], f[MAXN][MAXN], suf[MAXN];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) f[i][j] = LONG_LONG_MAX >> 1;
    for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
    for (int i = 1; i <= n; ++i) suf[i] = suf[i - 1] + a[i], f[i][i] = 0;
    for (int len = 2; len <= n; ++len) {
        for (int l = 1; l <= n - len + 1; ++l) {
            int r = l + len - 1;
            for (int mid = l; mid < r; ++mid) {
                f[l][r] = min(f[l][r], f[l][mid] + f[mid + 1][r] + suf[r] - suf[l - 1]);
            }
        }
    }
    printf("%lld\n", f[1][n]);
    return 0;
}

Measured memory_bytes: 1536
use strict;
use warnings;
use utf8;

my ($N) = split /\s/, <STDIN>;

my @x = split //, $N;

my $y = 0;
my @y;
foreach my $x (@x) {
    push @y, $y;
    $y = 1 - $y;
}

#use Data::Dumper;
#print Dumper \@x;

my $cnt0 = 0;
my $cnt1 = 0;
my $prev = 0;
for (my $i = 0; $i < @x; $i++) {
    if ($x[$i] == $y[$i]) {
        $cnt0++;
    } else {
        $cnt1++;
    }
}

printf "%s\n", $cnt0 < $cnt1 ? $cnt0 : $cnt1;



Measured memory_bytes: 17376
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
 
const ll inf = int(1e18);
const int mod = 256;
const int N = 1e6 + 555;
const long double PI = acos(-1.0);
 
void solve()
{
	int n;
	cin >> n;
	int a[n + 1], b[n];
	for(int i = 0; i < n + 1; ++i){
		cin >> a[i];
	}
	ll sum = 0;
	for(int i = 0; i < n; ++i){
		cin >> b[i];
		int cur = min(b[i], a[i]);
		sum += cur;
		b[i] -= cur;
		cur = min(b[i], a[i + 1]);
		sum += cur;
		a[i + 1] -= cur;
	}
	cout << sum;
}
int main()
{
	Red;
	solve();
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
using namespace std;

struct cube {
    int x, y, z, w;
    cube() {}
    cube(int a, int b, int c, int d): x(a), y(b), z(c), w(d) {}

    int overlap_area(cube o) {
        int ox = w - abs(x - o.x);
        int oy = w - abs(y - o.y);
        int oz = w - abs(z - o.z);

        if (ox < 0 || oy < 0 || oz < 0) {
            return -1;
        }

        return 2 * (ox * oy + oy * oz + oz * ox);
    }
};

int main() {
    int N, K, S;
    while (true) {
        cin >> N >> K >> S;
        if (N == 0 && K == 0 && S == 0) break;

        vector<cube> cubes;
        vector<vector<int>> graph(N);

        for (int j = 0; j < N; ++j) {
            int x, y, z; cin >> x >> y >> z;
            cubes.emplace_back(x, y, z, S);
        }

        if (K == 1) {
            cout << 6*S*S << endl;
            continue;
        }

        for (int j = 0; j < N; ++j) {
            for (int k = j+1; k < N; ++k) {
                int area = cubes[j].overlap_area(cubes[k]);
                if (area >= 0) {
                    graph[j].push_back(k);
                    graph[k].push_back(j);
                }
            }
        }

        vector<int> visited(N, 0);
        function<int(int)> get_start = [&](int v) -> int {
            visited[v] = 1;
            for (int w: graph[v]) {
                if (!visited[w])
                    return get_start(w);
            }
            return v;
        };

        int ans = -1;

        for (int j = 0; j < N; ++j) {
            if (visited[j])
                continue;
            int s = get_start(j);

            vector<int> chain;
            function<bool(int, int)> set_chain = [&](int v, int prev) -> bool {
                chain.push_back(v);
                visited[v] = 1;
                for (int w: graph[v]) {
                    if (w == prev) continue;
                    if (w == s) return true; 
                    return set_chain(w, v);
                }
                return false;
            };
            bool loop = set_chain(s, -1);

            const int L = chain.size();
            if (L < K) continue;

            int area = 6*S*S;
            for (int j = 1; j < ((loop && L > K) ? 2*L : L); ++j) {
                if (j >= K) {
                    int v0 = chain[(j-K)%L], v1 = chain[(j-K+1)%L];
                    area -= 6*S*S - cubes[v0].overlap_area(cubes[v1]);
                }

                area += 6*S*S - cubes[chain[(j-1)%L]].overlap_area(cubes[chain[j%L]]);
                if (loop && L == K && j == L-1) {
                    area -= cubes[chain[j%L]].overlap_area(cubes[chain[(j+1)%L]]);
                }

                if (j+1 >= K) ans = (ans == -1) ? area : min(ans, area);
            }
        }

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

Measured memory_bytes: 3212
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long n, k, a[200009];

bool fun(long long cur)
{//统计比cur小的pair数量
	long long cnt = 0;
	for (int i = 0; i < n - 1; i++) {
		if (a[i] < 0) {
			if (a[i] * a[i + 1] < cur) {
				cnt += n - 1 - i;
				continue;
			}
			int l = i + 1, r = n;
			while (l + 1 < r) {
				int mid = (l + r) / 2;
				if (a[i] * a[mid] >= cur) l = mid;
				else r = mid;
			}
			cnt += n - 1 - l;
		}
		else {
			if (a[i] * a[i + 1] >= cur) {
				continue;
			}
			int l = i + 1, r = n;
			while (l + 1 < r) {
				int mid = (l + r) / 2;
				if (a[i] * a[mid] < cur) l = mid;
				else r = mid;
			}
			cnt += l - i;
		}
	}
	if (cnt < k) return true;
	else return false;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	long long l = -1e18, r = 1e18 + 1;
	while (l + 1 < r) {
		long long mid = (l + r) / 2;
		if (fun(mid)) l = mid;
		else r = mid;
	}
	cout << l << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
static const int N=100;

int main()
{
    int M[N][N];
    int n,u,k,v;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            M[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
            cin>>u>>k;
            u--;
            for(int j=0;j<k;j++){
                cin>>v;
                v--;
                M[u][v]=1;
            }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j) cout<<" ";
            cout<<M[i][j];
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
int a[100001];
int main() {
	int n,m,k,l;
	int ara[100000];
	cin>>n;
	long long int s=0;
	for (int i=0;i<n;i++){
		cin>>ara[i];
		a[ara[i]]+=1;
		s=s+ara[i];
	}
	cin>>m;
	for (int i=0;i<m;i++){
		cin>>k>>l;
		long long int r=(l-k)*a[k];
		
		a[l]+=a[k];
		a[k]=0;
		s=s+r;
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 4420
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int H, W, A[123][123], B[123][123], C[123][123];
bitset<80 * 160> S[123][123];

int main() {

	cin >> H >> W;
	rep(i, H) {
		rep(j, W) {
			cin >> A[i][j];
		}
	}
	rep(i, H) {
		rep(j, W) {
			cin >> B[i][j];
		}
	}

	rep(i, H) {
		rep(j, W) {
			C[i][j] = abs(A[i][j] - B[i][j]);
		}
	}

	rep(i, H) {
		rep(j, W) {
			if (i == 0 && j == 0) {
				S[i][j].set(C[0][0]);
				continue;
			}
			if (!i) {
				bitset<80 * 160> orig;
				if (j) {
					rep(t, 80 * 160)
						if (S[i][j - 1][t]) orig.set(t);
				}
				rep(t, 80 * 160) {
					if (orig[t]) {
						S[i][j].set(abs(t + C[i][j]));
						S[i][j].set(abs(t - C[i][j]));
					}
				}
			}
			if (i) {
				if (j) {
					rep(t, 80 * 160)
						if (S[i][j - 1][t]) S[i - 1][j].set(t);
				}
				rep(t, 80 * 160) {
					if (S[i - 1][j][t]) {
						S[i][j].set(abs(t + C[i][j]));
						S[i][j].set(abs(t - C[i][j]));
					}
				}
			}
		}
	}

	rep(t, 80 * 160)
		if (S[H - 1][W - 1][t]) {
			cout << t << endl;
			return 0;
		}

	return 0;
}

Measured memory_bytes: 16128
N, M = map(int, input().split())
a = [0]*M
for i in range(M):
    a[i] = int(input())
    
cnt_1 = 1
cnt_2 = 0
for i in range(1,N+1):
    tmp = cnt_1
    if a != [] and a[0] == i:
        cnt_1 = 0
        a.pop(0)
    else:
        cnt_1 += cnt_2
    cnt_2 = tmp

print(cnt_1 % 1000000007)

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

void Solve(){
	int n,t,e;
	cin >> n >> t >> e;
	rep(i,0,n){
		int x; cin >> x;
		if(t-e<=t/x*x||(t+x-1)/x*x<=t+e){
			cout << i+1 << endl;
			return;
		}
	}
	cout << -1 << endl;
}

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

Measured memory_bytes: 1196
#include<iostream>
#include<stdio.h>
using namespace std;

int main() {
    int x, y;
    while(true) {
        cin >> x >> y;
        if (x == 0 && y == 0) {
            break;
        }
        (x < y) ? printf("%d %d\n", x, y) : printf("%d %d\n", y, x);
    }
    return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
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; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
int main(){
    string s; cin >> s;
    int n = s.size();
    vector<char> a(n), b(n); 
    rep(i,n){
      if(i%2==0) {a[i] = '1'; b[i] = '0';}
      else {a[i] = '0'; b[i] = '1';}
    }
    int cnt1=0,cnt2=0;
    rep(i,n){
        if(a[i]!=s[i]) cnt1++;
        if(b[i]!=s[i]) cnt2++;
    }
    cout << min(cnt1,cnt2); 
     
    return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }



int main()
{
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif

    int H,W,N;    
    cin >> H >> W >> N;
    int ans;
    ans = N/max(H,W)+(N%max(H,W)!=0);
    cout << ans << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

  int n;
  string s;
  cin >> n >> s;

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

  int ans = 1e9;
  reverse(E.begin(), E.end());
  for(int i = 1; i <= n; ++i) {
    ans = min(ans, W[i-1]+E[i+1]);
  }

  cout << ans << '\n';
  return 0;
}


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



//ボーナス取る、取らないに注目して全探索
int main(void){
    int d,goal;
    cin >> d >> goal;

    vector<int> num(d);  //問題数
    vector<int> bonus(d);    //ボーナス点
    for(int i=0;i<d;i++){
        cin >> num.at(i) >> bonus.at(i);
    }

    int sum = 0;
    int mincount = 100000;
    int count = 0;
    vector<int> tmp = num;
    for(int i=0;i<(1<<d);i++){
        bitset<10> b(i);    //0ビットを難易1,9ビットを難易10に対応
        //cout << b << endl;
        for(int j=0;j<10;j++){
            if(b.test(j)){
                sum += num.at(j)*(j+1)*100 + bonus.at(j);
                count += num.at(j); 
                num.at(j) = 0;
                //cout << "correntscore: " << sum << endl;
            }
        }
        for(int j=d-1;j>=0;j--){
            if(goal-sum<=0) break;
            if(b.test(j)) continue;
            while(num.at(j)>0){
                count++;
                num.at(j)--;
                sum += (j+1)*100;
                if(goal-sum<=0) break;
            }
        }
        
        if(count<mincount){
            mincount = count;
            //cout << sum << endl;
        }
        //cout << "finalscore: " << sum << endl;

        sum = 0;
        num = tmp;
        count = 0;
    }

    cout << mincount << endl;
}

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

using namespace std;

using ll = long long;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"

const int N = 1e6;
int cnt[1 + N];
int many[1 + N];
int a[1 + N];

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

    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    for (int d = 1; d <= N; d++) {
        for (int i = d; i <= N; i += d)
            many[i] += cnt[d];
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++)
        ans += (many[a[i]] == 1);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 12120
#include <iostream>
#include <numeric>
using namespace std;
int main(){
    int x,a,b;
    cin>>x>>a>>b;
    a-=x;
    if(a<0)a*=-1;
    b-=x;
    if(b<0)b*=-1;
    if(a<b)cout<<"A"<<endl;
    else cout<<"B"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifdef DEBUG
#include <boost/core/demangle.hpp>
#define dump(x) cerr << "L" << __LINE__ << ": in " << __PRETTY_FUNCTION__ << " \e[32;1m" << boost::core::demangle(typeid(x).name()) << "\e[37m" << " " << (#x) << " = " << (x) << "\e[m" << endl;
#else
#define dump(x)
#endif
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T> ostream& operator<<(ostream &os, vector<T> &v){os << "{";ITR(i,v){if(i!=v.begin())os << ","; os << *i;}os << "}"; return os;}
template <typename T, typename U> ostream& operator<<(ostream& os, pair<T,U> &p){os << "(" << p.first << "," << p.second << ")"; return os;}

template <typename T> T& chmin(T &a, const T &b){return a = min(a,b);}
template <typename T> T& chmax(T &a, const T &b){return a = max(a,b);}

int dp[101000];
bool visit[101000];


int dfs(vector<vector<int>> &graph, int cur){
  if(visit[cur]) return dp[cur];
  visit[cur] = true;

  for(auto next : graph[cur]){
    chmax(dp[cur], dfs(graph, next)+1);
  }
  return dp[cur];
}

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

  int N,M; cin >> N >> M;
  vector<vector<int>> graph(N);
  REP(i,M){
    int x,y; cin >> x >> y;
    --x, --y;
    graph[x].push_back(y);
  }

  REP(i,N){
    if(visit[i]) continue;
    dfs(graph, i);
  }

  int ans = 0;
  REP(i,N) chmax(ans, dp[i]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8320
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

bool isPossible(int num,int *arr,int k){
    vector<int> dp(k+1,0);
    
    dp[0] = 0;
    for(int i=1;i<=k;i++){
        // cout<<"Running";
        for(int j=0;j<num;j++){
            if(arr[j]>i){
                continue;
            }
            if(dp[i-arr[j]]==0){
                dp[i] = 1;
            }
        }
    }
    return dp[k]==1;
}

int main()
{
    int num,k;
    cin>>num>>k;
    int *arr = new int[num];
    for(int i=0;i<num;i++){
        cin>>arr[i];
    }
    
    if(isPossible(num,arr,k)){
        cout<<"First";
    }
    else{
        cout<<"Second";
    }
    
    return 0;
}


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

int cnt[10][10];

signed main () {
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		string s = to_string(i);
		++cnt[s.front() - '0'][s.back() - '0'];
	}
	long long ans = 0;
	for (int i = 1; i <= n; ++i) {
		string s = to_string(i);
		ans += cnt[s.back() - '0'][s.front() - '0'];
	}
	cout << ans << '\n';
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define oo 1e8
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e6 + 5, M = 2 * N + 5;


int main(){
    int l, r;
    scanf("%d%d", &l, &r);
    if(r - l >= 2019){
        puts("0");
        return 0;
    }
    ll mn = 2019;
    for(ll i = l ; i <= r ; ++i)
        for(ll j = i + 1 ; j <= r ; ++j)
            mn = min(mn, (i * j) % 2019LL);
    printf("%lld\n", mn);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

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

    cout << N - i + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
n, q = map(int, input().split())

from collections import deque

ls = []
for i in range(n):
    ls.append(list(input().split()))

que = deque(ls)

elapse = 0
while len(que)>0:
    name, time = que.popleft()
    time = int(time)
    if time <= q:
        elapse += time
        print('%s %d'%(name, elapse))
    else:
        elapse += q
        time -= q
        que.append([name, time])


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

ans = sum(s)
if ans % 10 != 0:
  print(ans)
  exit()

min_s = 10000
for i in s:
  if i % 10 != 0:
    min_s = min(min_s,i)

if min_s == 10000:
  print(0)
else:
  print(ans - min_s)

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

int main() {
	int h, w;
	cin >> h >> w;
	int costs[10][10];
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> costs[i][j];
		}
	}
	for (int k = 0; k < 10; k++) {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				costs[i][j] = min(costs[i][j], costs[i][k] + costs[k][j]);
			}
		}
	}
	unsigned long long ans = 0;
	for (int i = 0; i < h * w; i++) {
		int a;
		cin >> a;
		if (a == -1) continue;
		ans += costs[a][1];
	}
	cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;

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

    ll N;
    vector<ll> X;
    ll L;

    cin >> N;
    X.resize(N);

    for (ll i = 0; i < N; ++i) {
        cin >> X[i];
    }
    sort(X.begin(), X.end());

    cin >> L;

    vector< vector<ll> > d; // doubling
    d.resize(N);
    for (ll i = 0; i < N; ++i) {
        d[i].resize(32);
    }

    for (ll i = 0; i < N; ++i) {
        d[i][0] = upper_bound(X.begin(), X.end(), X[i] + L) - X.begin() - 1;
    }

    for (ll j = 1; j < 32; ++j) {
        for (ll i = 0; i < N; ++i) {
            d[i][j] = d[ d[i][j-1] ][j-1];
        }
    }

    //for (ll i = 0; i < N; ++i) {
    //    cout << i << " " << X[i] << " " << d[i][0] << endl;
    //}

    ll Q;
    cin >> Q;

    while (Q--) {
        ll a;
        ll b;

        cin >> a >> b;
        a--;
        b--;

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

        ll s = 0;
        
        for (ll i = 31; i >= 0; --i) {
            if (d[a][i] < b) {
                a = d[a][i];
                s += (1LL << i);
            }
        }

        cout << s+1 << endl;
    }
}


Measured memory_bytes: 30592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
using namespace std;

int main() {
    string a;
    cin >> a;
    vector<bool> s(26);
    int f = a.size();
    for (int i = 0; i < f; i++) {
        s.at(a.at(i) - 'a') = true;
    }
    for (int i = 0; i < 26; i++) {
        if (s.at(i) == false) {
            cout << a;
            char t = 'a';
            for (int j = 0; j < i; j++) {
                t += 1;
            }
            cout << t << endl;
            break;

        }
    }
    if (a.size() == 26) {
        for (int i = 25; i > -1; i--) {
            char v = 'Z';
            for (int j = i + 1; j < 26; j++) {
                if (a.at(i) < a.at(j)) {
                    if (v == 'Z')v = a.at(j);
                    else v = min(a.at(j), v);
                }
            }
            if (v != 'Z') {
                for (int j = 0; j < i; j++) {
                    cout << a.at(j);
                }
                cout << v << endl;
                break;
            }
        }
        if (a == "zyxwvutsrqponmlkjihgfedcba")cout << -1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
#define mp make_pair
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

long long fac[COMMAX], finv[COMMAX], inv[COMMAX];

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcd(int a,int b){return a*b / gcd(a,b);}
// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};

const int MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, long long h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};

int main(){
  int a,b;
  cin >> a >> b;
  int res = -1;
  rep(i,0,1010){
    if(i*8/100 == a and i/10 == b){
      res = i;
      break;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n,u,v;
	std::cin >> n >> u >> v;
	u--;v--;
	std::vector<std::vector<int> > g(n,std::vector<int>());
	rep(i,n-1) {
		int a,b;
		std::cin >> a >> b;
		a--;b--;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}
	// get dist from aoki
	std::vector<int> dist(n);
	std::function<void(int,int,int)> dfs = [&] (int i,int par,int d) {
		dist[i] = d;
		for(int to:g[i]) {
			if(to==par) continue;
			dfs(to,i,d+1);
		}
	};
	// find where takahashi can go
	int max = 0;
	std::function<void(int,int,int)> dfs2 = [&] (int i,int par,int d) {
		if(dist[i]-d<=0) return;
		max = std::max(max,dist[i]);
		for(int to:g[i]) {
			if(to==par) continue;
			dfs2(to,i,d+1);
		}
	};
	dfs(v,-1,0);
	dfs2(u,-1,0);
	print(max-1);

	return 0;
}


Measured memory_bytes: 14336
N, W =map(int,input().split())
 
#INF = 10**10
#dp = [[INF]*100000]*(N*100)#余分に
dp = [[0 for i in range(W+1)] for j in range(N+1)]

for i in range (N):
    dp[i][0] =0
for j in range (W+1):
    dp[0][j] =0
    

for i in range (N):
    v, w = map(int,input().split())
    for j in range (W+1):
        if j-w>=0:
            dp[i+1][j] = max(dp[i][j],dp[i][j-w]+v,dp[i+1][j-w]+v)
        else:
            dp[i+1][j] = dp[i][j]


print(dp[N][W])


Measured memory_bytes: 16124
N,K=map(int,input().split())
L=[0]*K
R=[0]*K
for i in range(K):
    L[i],R[i]=map(int,input().split())
    
MOD=998244353
dp=[0]*(N+1)
dpsum=[0]*(N+1)
dp[1]=1
dpsum[1]=1

for i in range(2,N+1):
    for j in range(K):
        Li=i-R[j]
        Ri=i-L[j]

        if Ri<0:
            continue
        else:
            Li=max(Li,1)
            dp[i]=(dp[i]+dpsum[Ri]-dpsum[Li-1])%MOD
    
    dpsum[i]=dpsum[i-1]+dp[i]

print(dp[N])

Measured memory_bytes: 76908
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    while (true) {
        string s;
        scan(s);

        if (s == "#") return;

        solve(s);
    }
}

void solve(string s) {
    auto h = "qwertasdfgzxcvb";

    int res;

    foreach (int i, ch; s) {
        if (i == 0) continue;
        res += h.canFind(ch) ^ h.canFind(s[i-1]);
    }

    writeln(res);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 2436
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double inf = 1e20;
inline double sqr (double k) {return k * k;}
inline int sgn (double p) {
    if (fabs (p) < eps) return 0;
    if (p < 0) return -1;
    return 1;
}
struct point {
    double x, y;
    point (){}
    point (double _x, double _y) {
        x = _x, y = _y;
    }
    void input () {
        scanf ("%lf %lf", &x, &y);
    }
    bool operator == (point b) const {
        return sgn (x - b.x) == 0 && sgn (y - b.y) == 0;
    }
    point operator - (const point &b) const {
        return point (x - b.x, y - b.y);
    }
    double operator * (const point &b) const {
        return x * b.x + y * b.y;
    }
    double operator ^ (const point &b) const {
        return x * b.y - y * b.x;
    }
    double len () {
        return hypot (x, y);
    }
    double len2 () {
        return x * x + y * y;
    }
    double distance (point p) {
        return hypot (x - p.x, y - p.y);
    }
    point operator + (const point &b) const{
        return point (x + b.x, y + b.y);
    }
    point operator * (const double &b) const {
        return point (x * b, y * b);
    }
    point operator / (const double &b) const {
        return point (x / b, y / b);
    }
    double cross (point a, point b) {
        return (a - *this) ^ (b - *this);
    }
    double dot (point a, point b) {
        return (a - *this) * (b - *this);
    }
    bool on_seg (point a, point b) {
        return sgn (cross (a, b)) == 0 && dot (a, b) <= 0;
    }
};
bool seg (point a, point b, point c, point d) {
    if (a.on_seg (c, d) || b.on_seg (c, d) || c.on_seg (a, b) || d.on_seg (a, b)) return true;
    if (a.cross (b, d) * a.cross (b, c) < 0 && c.cross (d, b) * c.cross (d, a) < 0) return true;
    return false;
}
int main () {
//    freopen ("in.txt", "r", stdin);
    int Q;
    cin >> Q;
    while (Q --) {
        int flag1 = 0, flag2 = 0, ans;
        double u, k;
        point s1, e1, s2, e2, a, b, c;
        s1.input (), e1.input ();
        s2.input (), e2.input ();
        if (seg (s1, e1, s2, e2)) cout << 1 << endl;
        else cout << 0 << endl;
    }
    return 0;
}



Measured memory_bytes: 3312
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int l[60]={};
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    sort(l,l+n,greater<int>());
    int ans=0;
    for(int i=0;i<k;i++){
        ans+=l[i];
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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 test; cin >> test;
  rep(t, test){
    int n; cin >> n;
    vector<vector<pll>> L(n), R(n);
    ll sum = 0;
    rep(i, n){
      ll k, l, r; cin >> k >> l >> r; k--;
      if(k==n-1 || l == r){
        sum += l;
      }else if(l > r){
        L[k].push_back({l - r, l});
      }else if(l < r){
        R[k+1].push_back({r - l, r});
      }
    }
      priority_queue<pll, vector<pll>> que;
      rep(i, n){
        for(auto a: R[i])que.push(a);
        if(!que.empty()){
          auto tmp = que.top(); que.pop();
          sum += tmp.second;
        }
      }
      while(!que.empty()){
        auto tmp = que.top(); que.pop();
        sum += tmp.second - tmp.first;
      }
      for(int i=n-1; i>=0; i--){
        for(auto a: L[i])que.push(a);
        if(!que.empty()){
          auto tmp = que.top(); que.pop();
          sum += tmp.second;
        }
      }
      while(!que.empty()){
        auto tmp = que.top(); que.pop();
        sum += tmp.second - tmp.first;
      } 
    cout << sum << ln;
  }
}


Measured memory_bytes: 18464
#include <iostream>

using namespace std;

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

	if ((a == 0 || b == 0) || (a < 0 && b > 0)) cout << "Zero" << endl;
	else if (a > 0 && b > 0) cout << "Positive" << endl;
	else
	{
		if (abs(a + b) % 2 == 0)cout << "Negative" << endl;
		else cout << "Positive" << endl;
	}


	return 0;
}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000003;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,i,j,k;cin>>n;
	vector<bitset<2000>>towin(n);
	for(i=1;i<n;i++){
		string str;cin>>str;
		for(j=0;j<i;j++){
			if(str[j]=='1'){towin[i][j]=1;}
			else{towin[j][i]=1;}
		}
	}
	vector<bitset<2001>>Lwin(n);//どこまで勝てるか 自分より小さい側
	vector<bitset<2001>>Rwin(n);//どこまで勝てるか 自分より大きい側
	for(i=0;i<n;i++){
		Lwin[i][i]=1;
		Rwin[i][i+1]=1;
		bitset<2001>cha;
		for(j=i-1;j>=0;j--){
			if(towin[i][j]&&((Lwin[i]&Rwin[j]).any()))
				{Lwin[i]|=Lwin[j];}
			if(((cha&Rwin[j]).any())||(towin[j][i]&&((Lwin[i]&Rwin[j]).any())))
				{Rwin[j][i+1]=1;cha[j+1]=1;}
		}
	}
	int ans=0;
	for(i=0;i<n;i++){
		/*for(j=0;j<=n;j++){
			if(Lwin[i][j]||Rwin[i][j]){cerr<<'1';}
			else{cerr<<'0';}
		}
		cerr<<endl;*/
		if(Lwin[i][0]&&Rwin[i][n]){ans++;}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <queue>
#include <stack>
using namespace std; 
typedef pair<long long int,long long int> pa;
#define resize(A) A.resize(unique(A.begin(), A.end()) - A.begin())
#define pb push_back
#define  MAX 1000005
long long int MOD=1e9+7;
long long int INF=1e18;
                                                 /*:-]*/
long long  int modulo(long long int a,long long  int b,long long  int n)
{
    long long int  x=1, y=a; 
    while (b > 0) 
    {
        if (b%2 == 1) 
        {
              x = (x*y) % n;
        }
        y = (y*y) % n; 
        
        b /= 2;
    }
    return x % n;
}


int main()
{
         ios_base::sync_with_stdio(false); 
         cin.tie(NULL);
         cout.tie(NULL);
         long long int i,j,k=0,l=0,r=0,m=0,n,c,p=0,cnt=0,cnt1=0,x,y,z=0,a,b,low,mid,high,ans=0,maxi=0,mini=INF,t,x1,y1;
         string s;
    cin>>n;
    p=-1;
    for(i=1;i<=9;i++)
    {
        if(n%i==0)
        {
            if(n/i<=9)
                p=1;
        }
    }
    if(p==-1)
        cout<<"No\n";
    else
        cout<<"Yes\n";
    
}

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

int z, x;
int a[111][111];

int main() {
cin >> z >> x;
for (int i = 0; i < z; ++i)
for (int j = 0; j < x; ++j)
cin >> a[i][j]; 
int all = 0; 
for (int i = 0; i < z; ++i) {
int sum = 0;
for (int j = 0; j < x; ++j)
{
cout << a[i][j] << ' ';
sum += a[i][j];
all += a[i][j];
}
cout << sum << "\n";
}

for (int j = 0; j < x; ++j) {
int sum = 0;
for (int i = 0; i < z; ++i) 
sum += a[i][j];
cout << sum << ' ';
}

cout << all << "\n";
return 0;
}

Measured memory_bytes: 3100
#include <iostream>
using namespace std;
int main() {
    int N, ans = 0;
    cin >> N;
    for (int i = 0, a, prev = 0, cnt = 1; i < N; i++) {
        cin >> a;
        if (a == prev) cnt++;
        if (a != prev || i == N - 1) {
            ans += cnt / 2;
            cnt = 1;
        }
        prev = a;
    }
    cout << ans << endl;
}


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

const double PI = acos(-1.0);

class Point
{
public:
    double y, x;
    Point(){
        y = x = 0.0;
    }
    Point(double y0, double x0){
        y = y0;
        x = x0;
    }
    Point(double theta){
        y = sin(theta);
        x = cos(theta);
    }
    Point operator+(const Point& p) const{
        return Point(y + p.y, x + p.x);
    }
    Point operator-(const Point& p) const{
        return Point(y - p.y, x - p.x);
    }
    Point operator*(double a) const{
        return Point(y * a, x * a);
    }
    Point operator/(double a) const{
        return Point(y / a, x / a);
    }
    double length() const{
        return sqrt(y * y + x * x);
    }
    double dist(const Point& p) const{
        return sqrt(pow(y - p.y, 2) + pow(x - p.x, 2));
    }
    double dot(const Point& p) const{
        return y * p.y + x * p.x; // |a|*|b|*cosθ
    }
    double cross(const Point& p) const{
        return x * p.y - y * p.x; // |a|*|b|*sinθ
    }
    double angle() const{
        return atan2(y, x);
    }
};

double polygonArea(const vector<Point>& p)
{
    int n = p.size();
    double ret = 0.0;
    for(int i=0; i<n; ++i)
        ret += p[i].cross(p[(i+1)%n]);
    return abs(ret) / 2.0;
}

int main()
{
    double angle = 0;
    vector<Point> p(10);
    for(int i=0; i<9; ++i){
        p[i+1] = p[i] + Point(angle);
        angle -= (180 - (i%2==0 ? 252 : 36)) / 180.0 * PI;
    }

    Point pMin(DBL_MAX, DBL_MAX);
    for(int i=0; i<10; ++i){
        pMin.y = min(pMin.y, p[i].y);
        pMin.x = min(pMin.x, p[i].x);
    }
    for(int i=0; i<10; ++i)
        p[i] = p[i] - pMin;
    double area = polygonArea(p);

    int n;
    cin >> n;
    for(int i=0; i<n; ++i){
        double s;
        cin >> s;
        double a = sqrt((s + 0.5) / area);

        cout << (i + 1) << endl;
        for(int j=9; j>=0; --j){
            double y = -5000 + (i / 10) * 1000 + p[j].y * a;
            double x = -5000 + (i % 10) * 1000 + p[j].x * a;
            printf("%.9f %.9f\n", x, y);
        }
    }

    return 0;
}

Measured memory_bytes: 1300
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var raw = ReadLine().Split().Select(int.Parse).ToArray();
            var N = raw[0];
            var M = raw[1];

            var drink = new Drink[N];
            for (int i = 0; i < N; i++)
            {
                var raw2 = ReadLine().Split().Select(long.Parse).ToArray();
                drink[i].Price = raw2[0];
                drink[i].Number = raw2[1];
            }

            drink = drink.OrderBy(d => d.Price).ToArray();

            var ans = 0L;
            var sum = 0L;
            foreach (var item in drink)
            {
                if (sum + item.Number >= M)
                {
                    WriteLine(ans + (M - sum) * item.Price);
                    return;
                }
                else
                {
                    ans += item.Number * item.Price;
                    sum += item.Number;
                }
            }
        }
    }

    struct Drink
    {
        public long Number;
        public long Price;
    }
}


Measured memory_bytes: 26936
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var A = one[0];
  var B = one[1];
  if(A >= 13){
    myout(B); 
  }else if(A <= 12 && A >= 6){
    myout(B / 2);
  }else{
    myout(0);
  }
}

Measured memory_bytes: 7372
#coding utf-8

n,k = map(int, input().split())
# d = list(map(int,input().split()))

x = list()
x.append(k)

for i in range(1,n):
    x.append(k-i)
    x.append(k+i)

x.sort()

for i in x:
    print(i ,end=' ')
print()

Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split()))
flag = True
for i in range(N):
  if A[i] % 2 == 0:
    if not (A[i] % 3 == 0 or A[i] % 5 == 0): flag = False
  if not flag: break
if flag:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3188