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

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> d(k);
	vector<bool> ok(10, true);
	for(int i =0 ;i < k; i++) {
		cin >> d[i];
		ok[ d[i] ] = false;
	}
	int j=0;
	int minim = 9;
	for(int i = 0; i< 10; i++) {
		if(ok[i] == true) {
			minim = i;
			break;
		}
	}
	int a[5];
restart:
	a[0] = n%10;
	a[1] = (n/ 10) % 10; 
	a[2] = (n/ 100) % 10;
	a[3] = (n/ 1000) % 10;
	a[4] = (n/ 10000);
	int tmp;
	for(j = 4; a[j] == 0; j--) ;
	if(ok[ a[j] ] == false) {
		bool flg = false;
	    for(int i = j-1; i>=0;i--)
	   		a[i] = minim;
		for(int i = a[j]+1; i< 10 ; i++) {
			if(ok[i] == true) {
				a[j] = i;
				flg = true;
				break;
			}
		}
		if(flg == true) {
			goto owari;
		}
      a[j]  =minim;
		if(minim != 0) 
          a[j+1] = minim;
      	else
          a[j+1] = 1;
		goto owari;
	}
	for(;j>=0; j--) {
		if(ok[ a[j] ] == false) {
			n += (int)pow(10,j); 

			goto restart;
		}
	}
	
owari:
	cout << a[4] * 10000 + a[3] * 1000 + a[2] * 100 + a[1] * 10 + a[0] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int n;
	scanf("%d",&n);
	int s=n;
	int dig;
	int sum = 0;
	while(n){
		dig = n % 10;
		sum = sum + dig;
		n = n / 10;
	}
	if( s%sum == 0){
		printf("Yes");
		return 0;
	}else{
		printf("No");
		return 0;
	}
	return 0;
}

Measured memory_bytes: 128
#ifdef LOCAL111
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		auto ans = make_v<int>(n, n);

		function<void(int, int, int)> rec = [&](int l, int r, int d) {
			if(r <= l + 1) return;
			DEBUG(l); DEBUG(r);
			int m = (l + r) / 2;
			FOR(i, l, m) {
				FOR(j, m, r) {
					ans[i][j] = d;
				}
			}
			rec(l, m, d + 1);
			rec(m, r, d + 1);
		};
		rec(0, n, 1);
		REP(i, n - 1) {
			FOR(j, i + 1, n) {
				if(j < n - 1) {
					cout << ans[i][j] << ' ';
				} else {
					cout << ans[i][j] << endl;
				}
			}
		}
	}
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;

double EPS=1e-9;
int INF=1000000005;
long long INFF=1000000000000000005ll;
double PI=acos(-1);
int dirx[8]={ -1, 0, 0, 1, -1, -1, 1, 1 };
int diry[8]={ 0, 1, -1, 0, -1, 1, -1, 1 };
const ll MOD = 1000000007;

#define DEBUG fprintf(stderr, "====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define OUT(x) cout << x << endl
#define OUTH(x) cout << x << " "
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define READ(x) for(auto &(z):x) cin >> z;
#define FOR(a, b, c) for (int(a)=(b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a)=(b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a)=(b); (a) >= (c); --(a))
#define FORSQ(a, b, c) for (int(a)=(b); (a) * (a) <= (c); ++(a))
#define FORC(a, b, c) for (char(a)=(b); (a) <= (c); ++(a))
#define EACH(a, b) for (auto&(a) : (b))
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FORN(i, 1, n)
#define MAX(a, b) a=max(a, b)
#define MIN(a, b) a=min(a, b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PERMUTE next_permutation
#define TC(t) while (t--)
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)


void solve() {

}

int main()
{
    FAST_INP;
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt","r", stdin);
//    freopen("output.txt","w", stdout);
//    #endif

//    int tc; cin >> tc;
//    TC(tc) solve();
	int n, l;
	cin >> n >> l;
	int sum=0;
	for(int i=1;i<=n;i++) sum+=(l+i-1);
	int d=INT_MAX, ans=0;
	for(int i=1;i<=n;i++) {
		if(abs(sum-(sum-(l+i-1)))<d){
			d=abs(sum-(sum-(l+i-1)));
			ans=sum-(l+i-1);
		}
	}
	OUT(ans);
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define int long long
#define moder 1000000007
#define inf 5000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
int n,a[100005],b[100005],c[100005];
signed main() {
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>b[i];
	rep(i,n)cin>>c[i];
	sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n);
	int ans=0;
	rep(i,n){
		ans+=(lower_bound(a,a+n,b[i])-a)*(n-(upper_bound(c,c+n,b[i])-c));
	}
	cout<<ans<<endl;
}


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

const int N = 100;
int n, m;
vector<int> data[N];
 
int main(){
  while(cin >> n >> m && (n|m)){
    for(int i=0;i<n;i++){
      data[i].clear();
      while(1){
        int in;
        cin >> in;
        if(in == 0) break;
        data[i].push_back(in);
      }
    }
    int ans = 0, rem[N], idx[N];
    priority_queue<pair<int, int> > q;
    bool flag[N];
    for(int i=0;i<n;i++) rem[i] = data[i][0];
    fill(idx, idx+n, 0);
    fill(flag, flag+n, false);
    for(int k=0;k<m;k++){
      pair<int, int> tmp = make_pair(1, 1);
      if(q.size()){ tmp = q.top(); q.pop(); }
      for(int i=0;i<n;i++){
        if(!flag[i]){
          rem[i]--;
          if(rem[i] == 0){
            idx[i] = (idx[i] + 1) % data[i].size();
            rem[i] = data[i][idx[i]];
            flag[i] = true;
            q.push(make_pair(-k, -i));
          }
        }else{
          if(-tmp.second == i){
            rem[i]--;
            if(rem[i] == 0){
              idx[i] = (idx[i] + 1) % data[i].size();
              rem[i] = data[i][idx[i]];
              flag[i] = false;
            }else q.push(tmp);
          }else ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main()
{
	int r, g, b;
	cin >> r >> g >> b;
	if ((g * 10 + b) % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

template <int mod>
struct ModInt {
    ll x;
    ModInt() : x(0) {}
    ModInt(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod - p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = 1LL * x * p.x % mod; return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        ll a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
    ModInt pow(ll n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }
};
const int mod = 1000000007;
using mint = ModInt<mod>;

template <typename T>
struct Combination {
    vector<T> _fac, _finv, _inv;

    Combination(int n) : _fac(n+1), _finv(n+1), _inv(n+1){
        _fac[0] = _finv[n] = _inv[0] = 1;
        for (int i = 1; i <= n; ++i) _fac[i] = _fac[i-1] * i;
        _finv[n] /= _fac[n];
        for (int i = n-1; i >= 0; --i) _finv[i] = _finv[i+1] * (i+1);
        for (int i = 1; i <= n; ++i) _inv[i] = _finv[i] * _fac[i-1];
    }
    inline T fac(int k) const { return _fac[k]; }
    inline T finv(int k) const { return _finv[k]; }
    inline T inv(int k) const { return _inv[k]; }

    T perm(int n, int k) const {
        return (k < 0 || n < k) ? 0 : fac(n) * finv(n-k);
    }
    T comb(int n, int k) const {
        return (k < 0 || n < k) ? 0 : fac(n) * finv(k) * finv(n-k);
    }
};
Combination<mint> C(2010);

int main(){
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= k; ++i) {
        cout << C.comb(n-k+1, i) * C.comb(k-1, i-1) << endl;
    }
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main()	{
  int n;
  cin>>n;
  vector<int>t(110000);
  vector<int>x(110000);
  vector<int>y(110000);
  x[0]=t[0]=y[0]=0;
  rep(i,n){
    cin>>t[i+1]>>x[i+1]>>y[i+1];
  }
  bool planex=true;
  rep(i,n){
    int dt=t[i+1]-t[i];
    int f=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
    if(f>dt) planex=false;
    if(f%2 != dt%2) planex=false;
  }
  if(planex==false) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

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

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

using namespace std;

typedef long long ll;

int main()
{
    ll a, b ,c;
    cin >> a >> b >> c;
    ll diff = c - a - b;
    string ans;
    if (diff < 0)
    {
        ans = "No";
    }
    else
    {
        if (diff * diff - 4 * a * b > 0) ans = "Yes";
        else ans = "No";
    }

    cout << ans << endl;
}


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

int main() {
  int a,b;
  int value=0;
  cin >>a;
  vector<string> blue(a);
  
  for(int i=0;i<a;i++){
    cin >> blue.at(i);
  }
  
  cin >>b;
  vector<string> red(b);
  for(int i=0;i<b;i++){
    cin >> red.at(i);
  }
  
  for(int i=0;i<a;i++){
    int cnt =0;
    for(int j=0;j<a;j++){
      if(blue.at(i)==blue.at(j))
        cnt++;
    }
    for(int k=0;k<b;k++){
      if(blue.at(i)==red.at(k))
        cnt--;
    }
    value=max(value,cnt);
  }
  cout << value <<endl;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 100100;

vector<PII> g[MAX];
int SZ[MAX];

void dfsSZ(int x, int p)
{
	SZ[x] = 1;
	FOR (i, 0, SZ(g[x]))
	{
		int to = g[x][i].first;
		if (to == p) continue;
		dfsSZ(to, x);
		SZ[x] += SZ[to];
	}
}

int get()
{
	dfsSZ(0, -1);
	int x = 0;
	int p = -1;
	int szAll = SZ[0];

	while(true)
	{
		int w = -1;
		FOR (i, 0, SZ(g[x]))
		{
			int to = g[x][i].first;
			if (to == p) continue;

			if (SZ[to] * 2 > szAll)
			{
				w = to;
				break;
			}
		}

		if (w == -1) break;

		p = x;
		x = w;
	}

	return x;
}

LL dfs(int x, int p)
{
	LL res = 0;
	FOR (i, 0, SZ(g[x]))
	{
		int to = g[x][i].first;
		int c = g[x][i].second;
		if (to == p) continue;

		res += c * (LL)SZ[to] * 2;

		res += dfs(to, x);
	}

	return res;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n;
	scanf("%d", &n);
	FOR (i, 0, n - 1)
	{
		int x, y, c;
		scanf("%d%d%d", &x, &y, &c);
		x--;
		y--;

		g[x].PB(MP(y, c));
		g[y].PB(MP(x, c));
	}

	int x = get();

	dfsSZ(x, -1);
	LL res = dfs(x, -1);

//	cout<<x<<endl;
//	FOR (i, 0, n)
//	{
//		cout<<SZ[i]<<' ';
//	}
//	cout<<endl;
//	cout<<res<<endl;

	int mn = INF;
	PII mx = MP(-INF, -INF);

	FOR (i, 0, SZ(g[x]))
	{
		int to = g[x][i].first;
		int c = g[x][i].second;

		mx = max(mx, MP(SZ[to], c));
		mn = min(mn, c);
	}

//	cout<<mx.first<<' '<<mx.second<<endl;

	if (mx.first * 2 == n) mn = mx.second;
	res -= mn;
	cout<<res<<endl;

}


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

ans = "No"
if N < 4:
    ans = "No"
elif N%4 == 0 or N%7 == 0:
    ans = "Yes"
else:
    for a in range(0, 25):
        for b in range(0, 15):
            if 4*a + 7*b == N:
                ans = "Yes"
                break
print(ans)


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

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;

    vector<vector<char>> grid(h, vector<char> (w));
    int white = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> grid[i][j];
            if (grid[i][j] == '.') white++;
        }
    }

    queue<pair<int, int>> que;
    vector<vector<int>> dist(h, vector<int> (w, 0));
    que.push(make_pair(0, 0));
    dist[0][0] = 1;

    vector<int> addy = {-1,  0,  1,  0};
    vector<int> addx = { 0,  1,  0, -1};

    int l = 0;
    while (!que.empty()) {
        int y, x;
        tie(y, x) = que.front();
        que.pop();
        for (int i = 0; i < 4; i++) {
            int newy = y + addy[i];
            int newx = x + addx[i];
            if (0 <= newy && newy < h && 0 <= newx && newx < w) {
                if (!dist[newy][newx] && grid[newy][newx] == '.') {
                    que.push(make_pair(newy, newx));
                    dist[newy][newx] = dist[y][x] + 1;
                    if (newy == h - 1 && newx == w - 1) l = dist[newy][newx];
                }
            }
        }
    }

    if (dist[h - 1][w - 1]) cout << white - l << endl;
    else cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val wordList = mutableListOf<String>()
    wordList.add(readLine()!!)
    var before = wordList.last().last()
    for (i in 1 until n) {
        val word = readLine()!!
        val after = word.first()
        if (after != before || wordList.contains(word)) {
            println("No")
            return
        }
        wordList.add(word)
        before = word.last()
    }
    println("Yes")
}


Measured memory_bytes: 33836
// https://www.spoj.com/problems/KNAPSACK/

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

typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define pb(x) push_back(x)
#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend()) 
#define mp(x, y) make_pair(x, y)
#define INF 1000000000
#define MOD 1000000007
#define F(i, a, n) for(i=a;i<n;i++)
#define B(i, a, n) for(i=n-1;i>=0;i--)
#define SI(x) cin>>x
#define DI(x, y) cin>>x>>y
#define TI(x, y, z) cin>>x>>y>>z
#define FI(w, x, y, z) cin>>w>>x>>y>>z
#define SO(x) cout<<x<<endl
#define DO(x, y) cout<<x<<" "<<y<<endl
#define TO(x, y, z) cout<<x<<" "<<y<<" "<<z<<endl
#define FO(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<endl
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)



int main(void)
{
    ll i, j;
    ll s, n;
    DI(n, s);
    vii items;
    F(i, 0, n)
    {
        ll x, y;
        DI(x, y);
        items.pb(mp(x, y));
    }
    ll dp[s + 1][n + 1];
    F(i, 0, n + 1)
        dp[0][i] = 0;
    F(i, 0, s + 1)
        dp[i][0] = 0;
    ll w = s;
    F(i, 1, w + 1)
    {
        F(j, 1, n + 1)
        {
            if(i >= items[j - 1].first)
                dp[i][j] = max(dp[i - items[j - 1].first][j - 1] + items[j - 1].second, dp[i][j - 1]);
            else
                dp[i][j] = dp[i][j - 1];
        }
    }
    SO(dp[w][n]);
    return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
const ll LINF = 0x1fffffffffffffff;
#define name3(_1,_2,_3,name,...) name
#define rep1(n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=0;i<(n);++i)
#define rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) name3(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__)
#define rrep(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define each(i,a) for(auto &i : a)
#define sum(a) accumulate(all(a), 0LL)
#define all(i) begin(i), end(i)
template<class T, class U> inline bool chmin(T &a, const U &b){ if(a > b) { a = b; return 1; } else return 0; }
template<class T, class U> inline bool chmax(T &a, const U &b){ if(a < b) { a = b; return 1; } else return 0; }


int main(){
    string s, t;
    cin >> s >> t;
    ll n=t.size(),m=s.size();
    vector<ll>a(n);
    ll at=-1;
    rep(n){
        at++;
        while(at<m&&s[at]!=t[i])at++;
        if(at==m)return!puts("no");
        a[i]=at;
    }
    reverse(all(s));
    reverse(all(t));
    at=-1;
    rep(n){
        at++;
        while(at<m&&s[at]!=t[i])at++;
        if(a[n-1-i]!=m-1-at)return!puts("no");
    }
    puts("yes");
}


Measured memory_bytes: 7912
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;

ll mod_pow(ll x, ll n) {
	ll ret = 1;
	while (n > 0) {
		if (n % 2)ret = ret * x%mod;
		x = x * x%mod; n >>= 1;
	}
	return ret;
}
struct perm {
private:
	int sz;
	vector<ll> p, invp;
public:
	perm(int n) {
		sz = n + 1;
		p.resize(sz), invp.resize(sz);
		p[0] = 1;
		rep1(i, sz - 1) {
			p[i] = p[i - 1] * i%mod;
		}
		invp[sz - 1] = 1;
		ll cop = mod - 2, x = p[sz - 1];
		while (cop) {
			if (cop % 2)invp[sz - 1] = invp[sz - 1] * x%mod;
			cop >>= 1; x = x * x % mod;
		}
		per(i, sz - 1) {
			invp[i] = invp[i + 1] * (i + 1) % mod;
		}
	}
	ll comb(ll x, ll y) {
		if (x < y || y < 0)return 0;
		ll ret = p[x];
		(ret *= invp[y]) %= mod;
		(ret *= invp[x - y]) %= mod;
		return ret;
	}
	ll combP(ll x, ll y) {
		if (x < y || y < 0)return 0;
		return p[x] * invp[x - y] % mod;
	}
};
perm p(1 << 20);
ll calc(int n, int m, int r) {
	ll res = 0;
	//cout << "hello" << endl;
	for (int t = 1; t <= r; t++) {
		int s = r - m * t;
		if (s < 0)break;
		ll sum = 0;
		for (int j = 0; j <= n - m; j++) {
			int ss = s - t * j;
			if (ss < 0)break;
			ll csum = p.comb(n - m, j)*p.comb(n + ss, n) % mod;
			if (j % 2 == 0) {
				sum += csum;
			}
			else {
				sum -= csum;
			}
		}
		sum = (sum%mod + mod) % mod;
		s -= m;
		if (s >= 0) {
			for (int j = 0; j <= n - m; j++) {
				int ss = s - t * j;
				if (ss < 0)break;
				ll csum = p.comb(n - m, j)*p.comb(n + ss, n) % mod;
				if (j % 2 == 0) {
					sum -= csum;
				}
				else {
					sum += csum;
				}
			}
		}
		sum = (sum%mod + mod) % mod;
		res += sum;
		//cout << sum << endl;
	}
	res %= mod;
	res = res * p.comb(n, m) % mod;
	ll orians = p.comb(n + r, n);
	//cout << res << " " << orians << endl;
	orians -= res; if (orians < 0)orians += mod;
	return orians;
}
void solve(){
	int n, m, l, r;
	cin >> n >> m >> l >> r;
	ll ans = calc(n, m, r) - calc(n, m, l - 1);
	if (ans < 0)ans += mod;
	cout << ans << endl;
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(5);
	//init();
	solve();

	//cout << "finish" << endl;
	//stop
	return 0;
}

Measured memory_bytes: 16640
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define INF 9223372036854775807LL
#define N 150
vector<int> g[N];
int dep[N],a[N],n,i,u[N],v[N],rt,rt2,j,psz;
bool zw;
void dfs(int now,int lst)
{
	int cnt=0;
	for (int ii=0;ii<g[now].size();ii++) if (g[now][ii]!=lst) cnt++;
	dep[now]=dep[lst]+1;a[dep[now]]=max(a[dep[now]],cnt);if (dep[now]>psz) zw=true;
	for (int ii=0;ii<g[now].size();ii++) if (g[now][ii]!=lst) dfs(g[now][ii],now);
}	
int main()
{
	scanf("%d",&n);
	for (i=1;i<n;i++){
		int x,y;scanf("%d%d",&x,&y);u[i]=x;v[i]=y;
		g[x].push_back(y);g[y].push_back(x);
	}rt=1;dfs(1,0);for (i=1;i<=n;i++) if (dep[i]>dep[rt]) rt=i;
	dfs(rt,0);rt2=rt;for (i=1;i<=n;i++) if (dep[i]>dep[rt2]) rt2=i;
	psz=dep[rt2]+1>>1;printf("%d ",psz);
	long long ans=INF;
	if (dep[rt2]&1){
	for (i=1;i<=n;i++){zw=false;
		for (j=1;j<=psz;j++) a[j]=1;
		dfs(i,0);
		long long tot=1;
		for (j=1;j<=psz;j++) if (tot>=ans/a[j]) zw=true;else tot=tot*a[j];
		if (!zw) ans=tot;
	}
	}
	for (i=1;i<n;i++){zw=false;
		for (j=1;j<=psz;j++) a[j]=1;
		dep[v[i]]=0;dfs(u[i],v[i]);dep[u[i]]=0;dfs(v[i],u[i]);
		long long tot=2;
		for (j=1;j<=psz;j++) if (tot>=ans/a[j]) zw=true;else tot=tot*a[j];
		if (!zw) ans=tot;
	}printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>

using namespace std;

void func(int d,long long val,vector<long long> &all){
    
    all.push_back(val) ;

    if(d==10) return ;

    for (int i = -1; i <= 1; i++)
    {
        int add = (val%10) + i ;
        if(add>=0 && add<=9) func(d+1,val*10+add,all) ;
    }
}

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

  vector<long long> all ;

  for (int i = 1; i <= 9 ; i++)
  {
      func(1,i,all) ;
  }

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

  cout << all[k-1] << endl ;  
  
}

Measured memory_bytes: 2420
#include<stdio.h>

void doit(int n){
  int m=n*n;
  int i,j;
  int p=1;
  int a[n][n];
  int b[n][n];
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      b[i][j]=0;
    }
  }
  i=n/2+1;
  j=n/2;
  while(p<=m){
    if(j>=n){
      j=0;
    }
    else if(j<0){
      j=n-1;
    }
    else if(i>=n){
      i=0;
    }
    else if(b[i][j]==1){
      i++;
      j--;
    }
    else{
      a[i][j]=p;
      b[i][j]=1;
      p++;
      i++;
      j++;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%4d",a[i][j]);
    }
    printf("\n");
  }
}

int main(){
  int n;
  scanf("%d",&n);
  while(n!=0){
    doit(n);
    scanf("%d",&n);
  }
  return 0;
}

Measured memory_bytes: 616
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#define N 105
using namespace std;
typedef long long ll;
int a, b;
int main() {
	cin>>a>>b;
	if (a+b>=10) cout<<"error"<<endl;
	else cout<<a+b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
int n,temp,i;
int l[100];
  int max=0;
  int sum=0;
 scanf("%d",&n);
  for(i=0;i<n;i++){
   scanf("%d",&temp);
    if(temp>max){
      max =temp;
      l[i]=temp;
  }else{
     l[i]=temp;
    }
 }
  for(i=0;i<n;i++){
  sum = sum+l[i];
  }
  sum= sum-max;
 if(max<sum){
printf("Yes");
 }else{
   printf("No");
 }

}

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

int main(){

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

    s=s.back()+s+s[0];//1~nまで

    string c[4];

    if(s[1]=='o'){
        c[0]="SSS";
        c[1]="WSW";
        c[2]="SWW";
        c[3]="WWS";
        for(int i=0;i<4;i++){
            for(int j=2;j<=n;j++){
                if(c[i][j]=='S'){
                    if(s[j]=='o'){
                        c[i].push_back(c[i][c[i].size()-2]);
                    }else{
                        if(c[i][c[i].size()-2]=='S'){
                            c[i].push_back('W');
                        }else{
                            c[i].push_back('S');                            
                        }
                    }
                }else{
                    if(s[j]=='o'){
                        if(c[i][c[i].size()-2]=='S'){
                            c[i].push_back('W');
                        }else{
                            c[i].push_back('S');                            
                        }
                    }else{
                        c[i].push_back(c[i][c[i].size()-2]);
                    }
                }
            }
        }
    }else{
        c[0]="SSW";
        c[1]="WSS";
        c[2]="SWS";
        c[3]="WWW";
        for(int i=0;i<4;i++){
            for(int j=2;j<=n;j++){
                if(c[i][j]=='S'){
                    if(s[j]=='o'){
                        c[i].push_back(c[i][c[i].size()-2]);
                    }else{
                        if(c[i][c[i].size()-2]=='S'){
                            c[i].push_back('W');
                        }else{
                            c[i].push_back('S');                            
                        }
                    }
                }else{
                    if(s[j]=='o'){
                        if(c[i][c[i].size()-2]=='S'){
                            c[i].push_back('W');
                        }else{
                            c[i].push_back('S');                            
                        }
                    }else{
                        c[i].push_back(c[i][c[i].size()-2]);
                    }
                }
            }
        }
    }   

    for(int i=0;i<4;i++){
        if(c[i][0]==c[i][c[i].size()-2]&&c[i][1]==c[i].back()){
            //cout << c[i][0] << " " << c[i].back() <<endl;
            c[i].erase(c[i].begin());
            c[i].pop_back();
            cout << c[i]<<endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 1020
#include<stdio.h>
int main()
{
    int n,k,x,y,s;
    scanf("%d%d%d%d",&n,&k,&x,&y);
    if (n<=k){
        s=n*x;
    }
    else if(n>k){
        s=k*x+(n-k)*y;
    }
    printf("%d\n",s);

    return 0;

}


Measured memory_bytes: 128
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

#define ll long long
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}


ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(){
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(), a.end());
  if(a[0] == 5 && a[1] == 5 && a[2] == 7) cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

int main() {
  ll n; cin >> n;
  ll sum = 0;
  ll sum2 = 0;
  for(ll i = 1; i<=n; i++){
    sum+=i;
  }
  for(ll i = 1; i<=n; i++){
    if(i%3==0 || i%5==0){
      sum2+=i;
    }
  }
  cout << sum-sum2 << endl;
  
  return 0;
}

Measured memory_bytes: 3616
N, K, Q = map(int, input().split())
a = list(map(int, input().split()))
ans = float("inf")
for i in range(N):
    tmp = []
    rec = []
    for j in range(N):
        if a[i] <= a[j]:
            tmp.append(a[j])
        else:
            if len(tmp) >= K:
                tmp = sorted(tmp)
                rec += tmp[:len(tmp) - K + 1]
            tmp = []

    if len(tmp) >= K:
        tmp = sorted(tmp)
        rec += tmp[:len(tmp) - K + 1]
    if Q <= len(rec):
        rec = sorted(rec)
        ans = min(ans, rec[Q - 1] - rec[0])
print(ans)

Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(10**7)
n,m=map(int,input().split())
g=[[] for _ in range((n+m))]
for i in range(n):
    a=[int(i)-1 for i in input().split()][1:]
    for l in a:
        g[i].append(n+l)
        g[n+l].append(i)

par=[i for i in range(n+m)]

def root(x):
    if x==par[x]:
        return x
    else:
        par[x]=root(par[x])
        return par[x]
        
def connect(x,y):
    rx=root(x)
    ry=root(y)
    if rx!=ry:
        par[rx]=ry
    return

for i in range(n+m):
    for nb in g[i]:
        connect(i,nb)

p=par[0]
ans='YES'
for i in range(n):
    if par[i]!=p:
        ans='NO'

print(ans)

Measured memory_bytes: 61368
#include<iostream>
#include<vector>
#include<cstdlib>
#include <cmath>
 
 
#define INF 100000000
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; }
 
using namespace std;
 
int main(){
  int x,i,j,k,n,d,a[100009],b[100009];
  long count =0;
  cin >>n;
  for(i=0;i<n+1;i++){cin >> a[i];}
  for(i=0;i<n;i++){cin >> b[i];}
 
  for(i=0;i<n;i++){
    x=0;
 
    if(a[i]<b[i]){
 
      x=b[i]-a[i];
      count+=a[i];
 
      if(x>a[i+1]){
        count+=a[i+1];
        a[i+1]-=x;
        if(a[i+1]<0)a[i+1]=0;
      }
      else {
        count +=x;
        a[i+1]-=x;
      }
    }else{
      count+=b[i];
    }
  }
  cout << count <<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int a, b, c;
   cin >> a >> b >> c;
   int x, y;
   cin >> x >> y;
   int ans = 1e9 + 1;
   for (int i = 0; i <= 2 * max(x, y); i += 2) {
      int sum = a * max(0, (x - i / 2));
      sum += b * max(0, (y - i / 2));
      sum += c * i;
      chmin(ans, sum);
   }
   cout << ans << endl;
   return 0;
}

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

const int N = 110;

char S[N * 2];
int K;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> S >> K;
	int n = strlen(S);
	for (int i = 0; i < n; i++) S[n + i] = S[i];
	long long ans;
	if (count(S, S + n, S[0]) == n) ans = (long long)n * K / 2;
	else {
		int k = 0;
		for (; S[0] == S[k]; k++);
		ans = k / 2;
		for (int i = k, j; i < n; i = j) {
			for (j = i; j < n && S[i] == S[j]; j++);
			ans += (j - i) / 2;
		}
		for (int i = k, j; i < n + k; i = j) {
			for (j = i; j < n + k && S[i] == S[j]; j++);
			ans += (long long)(j - i) / 2 * (K - 1);
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};

bool srt(int a , int b){
    return a > b ;
}


int main(){
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    int a[n];
    int s1=0,s2=0;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(int i=n-1;i>=0;i--){
        if(i%2==0)s1+=a[i];
        else s2+=a[i];
    }
    cout<<abs(s1-s2);

}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	nums := []uint64{2, 1}
	for {
		if len(nums) >= n+1 {
			fmt.Println(nums[n])
			break
		} else {
			nums = append(nums, nums[len(nums)-1]+nums[len(nums)-2])
		}
	}
}


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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	while(true){
		int H=read();
		if(H==0) break;
		
		int table[H][5]={0};
		REP(i,H){
			REP(j,5){
				table[i][j]=read();
			}
		}
		
		int point=0;
		while(true){
			REP(i,H){
				int count=1;
				int tmpvalue=0;
				FOR(j,1,5){
					if(table[i][j]==table[i][j-1]){
						count++;
						tmpvalue=table[i][j];
					}
					else if(count>=3){
						REP(k,count){
							table[i][j-1-k]=0;
						}
						point+=count*tmpvalue;
						count=1;
					}
					else count=1;
					
					if(j==4&&count>=3){
						REP(k,count){
							table[i][j-k]=0;
						}
						point+=count*tmpvalue;
						count=0;
					}
				}
			}
			bool flag=true;
			REP(j,5){
				for(int i=H-2;i>=0;i--){
					for(int k=0;k+i<H-1;k++){
						if(table[i+k][j]!=0&&table[i+1+k][j]==0){
							flag=false;
							table[i+1+k][j]=table[i+k][j];
							table[i+k][j]=0;
						}
					}
				}
			}
			
			/*REP(i,H){
				REP(j,5){
					cout << table[i][j];
				}
				cout << endl;
			}
			cout << endl;*/
			if(flag) break;
		}
		cout << point << endl;
	}
}

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

bool match(string *s1, string *s2, int idx)
{
    for(int i = 0; i < (*s2).length(); i++)
    {
        if((*s1)[(i+idx) % (*s1).length()] != (*s2)[i])
            return false;
    }

    return true;
}

int main()
{
    string s, p;

    getline(cin, s);
    getline(cin, p);

    bool found = false;
    for(int i = 0; i < s.length(); i++)
    {
        if(match(&s, &p, i))
        {
            found = true;
        }
    }

    if(found)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3148
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var n = F();
		var a = 0;
		while (n > 1)
		{
			n >>= 1;
			a++;
		}
		Console.WriteLine(1 << a);
	}
}


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

int main() {
  int A,N=0;
  cin >> A;
  for (int Y = A; Y > 0; Y/=10){
    N += Y % 10;
  }
  if(A%N==0){
    cout <<  "Yes";
  }
  else {
    cout << "No";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
 
int main() {
	int n; cin >> n;
	ll ans=0;
	for(int i=1;i<=n;i++){
		if(i%3!=0&&i%5!=0)
			ans+=i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3596
#include<iostream>
using namespace std;
int main(){
    int A,B,sum=0,i,t,a=0;
    cin>>A>>B;
    for(i=A;i<=B;i++){
      t=i;
     while(i>0){
        a=a*10+i%10;
        i=i/10;
    }
    if(a==t){
        sum++;
    }
    a=0;
    i=t;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n, a, b);
    Cout(min(a, b), " ", max(a+b-n, 0));
}





Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    long long a[n], b[n]; for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    long long ans = 0;
    for (int i = n-1; i >= 0; i--) {
        long long r = (a[i] + ans) % b[i];
        if (r > 0) ans += b[i] - r;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
# -*- coding:utf-8 -*-
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = Counter(a)
ans = 0
for tmp in list(set(a)):
    if b[tmp] > tmp:
        ans += b[tmp]-tmp
    elif b[tmp] < tmp:
        ans += b[tmp]
    else:
        continue
else:
    print(ans)

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

int main () {
  long long A, B, K;
  cin >> A >> B >> K;
  if (A >= K) cout << A-K << " " << B << endl;
  else if (A+B >= K) cout << "0 " << A+B-K << endl;
  else cout << "0 0" << endl;
}

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


int main(void)
{
    int a, b;
    cin >> a >> b;
    if(a < b)
    {
        rep(i, b)
        {
            cout << a;
        }
        cout << endl;
        return 0;
    }
    else
    {
        rep(i, a)
        {
            cout << b;
        }
        cout << endl;
        return 0;
    }
    
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream&
operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream&
operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream&
operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        int N, L; cin >> N >> L;
        if(N == 0) return 0;
        L *= 2;
        vector<int> D(N);
        vector<vector<int>> G[2];
        rep(i, 2) G[i].resize(L);
        rep(i, N) {
            char d;
            int p;
            cin >> d >> p;
            p *= 2;
            D[i] = d == 'L' ? -1 : 1;
            G[0][p].push_back(i);
        }
        int left = N;
        int time = 0;
        while(left > 0) {            
            int now = time % 2;
            int nxt = (now + 1) % 2;
            rep(i, L) G[nxt][i].clear();
            // go
            for(int i = L - 1; i > 0 ; i--) {
                while(G[now][i].size()) {
                    int idx = G[now][i].back(); G[now][i].pop_back();
                    int nxt_p = i + D[idx];
                    if(nxt_p == 0 or nxt_p ==L) {
                        left--;
                        if(left == 0) {
                            cout << time / 2 + 1 << " " << idx + 1 << endl;
                        }
                    } else {
                        G[nxt][nxt_p].push_back(idx);
                    }
                }
            }
            // check        
            for(int i = 0; i < L; i += 2) {
                assert(G[nxt][i].size() <= 2);
                if(G[nxt][i].size() == 2) {
                    swap(D[G[nxt][i][0]], D[G[nxt][i][1]]);
                }
            }
            time++;
        }    
    }
    return 0;
}

Measured memory_bytes: 3216
# -*- coding: utf-8 -*-
import numpy as np
import itertools
import time
n, k = list(map(int, input().split()))
MOD = 10 ** 9 + 7
result = 0
for x in range(k, n + 2):

    # print('選ぶ数', _k)
    min_value = x*(x-1)//2
    max_value = (n + n-x+1)*x//2
    # print(min_value, max_value)
    result += max_value - min_value + 1
print(int(result) % MOD)


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

#define INF INT_MAX/2;
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long ;

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

   int X;
   cin>>X;
   if(X==3||X==5||X==7)cout<<"YES";
   else cout<<"NO";
   return 0; 
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}
ll n;
void pk()
{
    cin>>n;
    ll arr[n][3];
    ll dp[n][3];
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<3;j++)
           cin>>arr[i][j];
    }
    for(ll i=0;i<3;i++)
    {
        dp[0][i]=arr[0][i];
    }
    for(ll i=1;i<n;i++)
    {
    
            dp[i][0]=arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
            dp[i][1]=arr[i][1]+max(dp[i-1][0],dp[i-1][2]);
            dp[i][2]=arr[i][2]+max(dp[i-1][0],dp[i-1][1]);            
    
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));

}
int main() 
{ 
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
    //cin>>t;
    while(t--)
    {
        pk();
    }
} 


Measured memory_bytes: 8312