akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int MD=1e9+7;
int n, k;
int A[110];
int dp[100007];

void add_self(int&a, int b){
     a=a+b;
     if(a>=MD)a=a-MD;
}

int main(){
     memset(dp, 0,sizeof(dp));
     cin>>n>>k;
     for(int i=1;i<=n;i++)cin>>A[i];
     dp[0]=1;
     for(int j=1;j<=k;j++)add_self(dp[j], dp[j-1]);
     for(int i=1;i<n;i++){
          for(int j=k;j>=0;j--){
               int temp=j-A[i]-1;
               if(temp>=0) dp[j]=(dp[j]-dp[temp]+MD)%MD;
          }
          for(int j=1;j<=k;j++)add_self(dp[j], dp[j-1]);

     }
    int temp=k-A[n]-1;
    if(temp>=0) dp[k]=(dp[k]-dp[temp]+MD)%MD;
     cout<<dp[k];
}



Measured memory_bytes: 640
n=int(input())
from collections import deque
d=deque()
e=deque()
d.append(("a",0))

alpha=list("abcdefghijklmnopqrstuvwxyz")
dic={alpha[i]:i for i in range(26)}
for i in range(n-1):
    while d:
        x,y=d.popleft() 
        for j in range(y+2):
            e.append((x+alpha[int(j)],max(y,j)))
    d=e
    e=deque()
d=list(d)
if n==1:
    print("a")
else:
    d=sorted(d,key=lambda x:x[0])
    for some in d:
        print(some[0])

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

using namespace std;

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


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

#define V vector
typedef long long ll;
typedef unsigned long long ull;

typedef V<int> vi;
typedef V<ll> vll;
typedef V<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define f(i,a) for(int i = 0 ; i < a ; i++)
#define fll(i,a) for(ll i = 0 ; i < a ;i++)
#define forab(i,a,b) for(int i = a ; i < b ; i++)
#define prec(x) cout<<fixed<<setprecision(x)
#define ff first
#define ss second

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1

ll M = 1e7 + 7;

ll binpow(ll a, long long b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a);
		a = (a * a);
		b >>= 1;
	}
	return res;
}



void solve() {
	int d , s , t;
	cin >> d >> t >> s;

	if (s * t >= d)
		cout << "Yes\n";
	else
		cout << "No\n";
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int t = 1;
	//cin >> t;

	while (t--)
		solve();
	return 0;
}





Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  int n;
  ll acc = 0;
  scanf("%d", &n);
  vector<ll> a(n), b(n);
  for(int i = 0; i < n; i++) scanf("%lld %lld", &a[i], &b[i]);
  for(int i = n - 1; i >= 0; i--) {
    a[i] += acc;
    if(a[i] % b[i]) acc += b[i] - a[i] % b[i];
  }
  printf("%lld\n", acc);
}

Measured memory_bytes: 1792
S = input()
T = input()
lenS = len(S)
lenT = len(T)

dp=[[0]*(lenT+1) for _ in range(lenS+1)]

for i in range(1,lenS+1):
    s = S[i-1]
    for j in range(1,lenT+1):
        t = T[j-1]
        if s==t:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1],dp[i-1][j-1]+1)
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])

"""
復元
"""
res = ''
n = lenS
m = lenT
while n != 0 and m != 0:
    if dp[n][m] == dp[n-1][m]:
        n -= 1
    elif dp[n][m] == dp[n][m-1]:
        m -= 1
    else:
        n -= 1
        m -= 1
        res = S[n] + res
print(res)

Measured memory_bytes: 113372
n, k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]

def abs(x):
    if x >= 0:
        return x
    return -x

c = [0]
c.append(abs(h[1] - h[0]))
for i in range(2, n):
    cmin = None
    for cur in range(i-1, i-1-k, -1):
        if cur < 0:
            break
        val = abs(h[i] - h[cur]) + c[cur]
        if cmin is None or val < cmin:
            cmin = val
    c.append(cmin)

print(c[-1])

Measured memory_bytes: 57952
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int x, y;
  cin >> x >> y;
  bool flag = false;
  rep(i, x+1) {
    rep(j, y+1) {
      if (i+j == x) {
        if (2*i+4*j == y) {
          coYes;
          flag = true;
        }
      }
    }
    if (flag) {
      break;
    }
  }
  if (!flag) {
    coNo;
  }
}



Measured memory_bytes: 3532
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt()
  val As = List.fill(N + 1)(sc.nextLong())
  val Bs = List.fill(N)(sc.nextLong()) :+ 0L
  val (acc, _) = As.zip(Bs).foldLeft(0L -> 0L) {
    case ((acc, diff), (a, b)) =>
      (acc + (diff + b).min(a)) -> (b - (a - diff).max(0L)).max(0L)
  }
  println(acc)
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define IMP cout << "IMPOSSIBLE" << endl
#define Imp cout << "Impossible" << endl
#define imp cout << "impossible" << endl
#define M1 cout << "-1" << endl
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    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 dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n = in();
    map<string, int> mp;
    rep(i, n)
    {
        string s;
        cin >> s;
        ++mp[s];
    }

    int ma = 0;
    for (auto e : mp)
    {
        ma = max(ma, e.se);
    }

    for (auto e : mp)
    {
        if (e.se == ma)
        {
            cout << e.fi << endl;
        }
    }
}

signed main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 23808
#include <iostream>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define int long long
using namespace std;
int befp[1000100];
int c[1000100];
int gcd(int n, int m)
{
	return m ? gcd(m, n % m) : n;
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int N; 
	cin >> N;
	int i;
	for (i = 1; i <= 1000000; i++)
		befp[i] = i;
	for (i = 2; i <= 1000; i++)
	{
		if (befp[i] == i)
		{
			int j;
			for (j = i * i; j <= 1000000; j+=i)
			{
				if (befp[j]==j)
					befp[j] = i;
			}
		}
	}
	int gc = 0;
	for (i = 0; i < N; i++)
	{
		int a;
		cin >> a;
		gc = gcd(a, gc);
		while (a!=1)
		{
			int x = befp[a];
			c[x]++;
			while (befp[a] == x)
			{
				a /= x;
			}
		}
	}
	int su1 = 1;
	for (i = 1; i <= 1000000; i++)
	{
		if (c[i] > 1)
			su1 = 0;
	}
	if (su1)
		cout << "pairwise coprime";
	else if (gc == 1)
		cout << "setwise coprime";
	else
		cout << "not coprime";
}

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

int kind(string s){
  int r = 0;
  for(int i = 0; i < s.size(); i++){
    r = max(r, s.at(i) - 'a' + 1);
  }
  return r;
}


int main() {
  int n;
  cin >> n;
  vector<string> pre(0);
  vector<string> ans(0);
  pre.push_back("a");
  ans.push_back("a");
  for (int i = 1; i < n; i++){
    pre = ans;
    ans = {};
    for(int j = 0; j < pre.size(); j++){
      for(int k = 0; k < kind(pre.at(j)) + 1; k++){
        ans.push_back(pre.at(j) + (char)('a' + k));
      }
    }
  }
  for (int i = 0; i < ans.size(); i++){
    cout << ans.at(i) << endl;
  }
}
        

Measured memory_bytes: 9332
import math
def rot60(s,t):
    v = t -s
    a = 1/2 + complex(0,(math.sqrt(3)/2))
    return v * a + s

def pr(p):
    x = p.real
    y = p.imag
    print("%.10f %.10f" %(x,y))

def dfs(p1,p2,n):
    if n == 0:
        return
    s = (p2 - p1) * (1/3) + p1
    t = (p2 - p1) * (2/3) + p1
    u = rot60(s,t)
    dfs(p1,s,n-1)
    pr(s)
    dfs(s,u,n-1)
    pr(u)
    dfs(u,t,n-1)
    pr(t)
    dfs(t,p2,n-1)
    
n = int(input())
s = (0+0j)
t = (100+0j)
pr(s)
dfs(s,t,n)
pr(t)


Measured memory_bytes: 5720
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <cstring>
#define ll long long
using namespace std;

ll n,m,q;
ll up[233333],de[233333],dp[233333][23],fa[233333];
ll pn[233333],pg[233333],pv[233333],st[233333];
ll tot=0;

void init()
{
    memset(up,0,sizeof(up));
    memset(de,0,sizeof(de));
    memset(dp,0,sizeof(dp));
    memset(pn,0,sizeof(pn));
    memset(pg,0,sizeof(pg));
    memset(pv,0,sizeof(pv));
    memset(fa,0,sizeof(fa));

    return ;
}

void ins(int x,int y,int w)
{
    pv[++tot]=y;
    pg[tot]=w;
    pn[tot]=st[x];
    st[x]=tot;

    return;
}

void dfs(int x)
{
        dp[x][0]=fa[x];
        for(int i=1;i<20;i++)
        {
            dp[x][i]=dp[dp[x][i-1]][i-1];
         }

        for (int i=st[x];i;i=pn[i])
        {
             int cur=pv[i];
             if (cur==fa[x]) continue;
             de[cur]=de[x]+1;
             up[cur]=up[x]+pg[i];
             fa[cur]=x;
             dfs(cur);
        }

    return;
}

int lca(int x,int y)
{
    if (de[x]<de[y]) {
        int t=x;
        x=y;
        y=t;
    }

    for (int i=19;i>=0;i--)
    {
        if (de[dp[x][i]]>=de[y]) x=dp[x][i];
     }

    if (x==y) return x;

    for (int i=19;i>=0;i--)
    {
        if (dp[x][i]!=dp[y][i])
        {
            x=dp[x][i];
            y=dp[y][i];
        }
     }

    return dp[x][0];
}

int main()
{

    while(~scanf("%lld",&n))
    {
        init();
        int a,b,c;
        for (int i=1;i< n;i++)
        {
            scanf("%d%d%d",&a,&b,&c);
            ins(a,b,c);
            ins(b,a,c);
        }

         fa[1]=1;
         de[1]=up[1]=0;
         dfs(1);
         int k;

         scanf("%d%d", &q, &k);
         while(q--)
         {
             scanf("%d%d",&a,&b);

             printf("%lld\n",up[a]+up[k]-2*up[lca(a,k)] + up[k]+up[b]-2*up[lca(k,b)]);//求树上距离。
         }
    }

    return 0;
 }


Measured memory_bytes: 58624
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
	int tate,yoko,takasa,mn,md;
	int n;
	while(cin>>tate>>yoko>>takasa, tate|| yoko || takasa){
		cin>>n;
		int* r = new int [n];
		mn=min(min(tate , yoko) , takasa);
		if(tate>=yoko){
			if(yoko>=takasa) {
			    md=yoko;
			} else if (yoko<takasa) {
				if(tate>=takasa)  md=takasa;
				else if (tate<takasa)  md=tate;
			}
			
		} else if (tate<yoko){
			if (tate>=takasa){
				md=tate;
			} else if(tate<takasa){
				if(yoko>=takasa) md=takasa;
				else if(yoko<takasa) md=yoko;
			}
		}
		for(int i=0;i<n;++i){
			cin>> r[i];
			cout << ((r[i]*r[i]*4>mn*mn+md*md) ? "OK" : "NA") << endl;
		}
	}
	return 0; 
}

Measured memory_bytes: 1180
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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













template <typename T>
class SegmentTree {
private:
    int n;    // 配列の要素数
    T init;    // 配列を初期化するときの値
    vector<T> data;     // セグメントツリーを持つ配列
public:
    SegmentTree(int m, T init = 0) : n(1), init(init){
        while(n < m) n <<= 1;
        data.assign(2 * n - 1, init);
    }
    
    T operation(T t1, T t2){
        return t1 | t2;
    }
    
    void update(int k, T val){
        k += n - 1;
        data[k] = val;
        
        while(k > 0){
            k = (k - 1) / 2;
            data[k] = operation(data[k * 2 + 1], data[k * 2 + 2]);
        }
    }
    
    // [a, b) の値を求める
    T query(int a, int b){
        return query(a, b, 0, 0, n);
    }
    
    T query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return init;
        if(a <= l && r <= b){
            return data[k];
        }
        else{
            T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return operation(vl, vr);
        }
    }
};



int main(){
    ll n;
    string s;
    cin >> n >> s;
    SegmentTree<ll> tree(n);
    REP(i, n){
        tree.update(i, 1LL << (s[i] - 'a'));
    }
    ll Q;
    cin >> Q;
    REP(i, Q){
        ll num;
        cin >> num;
        if(num == 1){
            ll idx;
            char c;
            cin >> idx >> c;
            idx--;
            tree.update(idx, 1LL << (c - 'a'));
        }
        else{
            ll l, r;
            cin >> l >> r;
            l--;
            ll res = tree.query(l, r);
            ll cnt = 0;
            while(res){
                if(res & 1) cnt++;
                res >>= 1;
            }
            cout << cnt << endl;
        }
    }
}

Measured memory_bytes: 9092
N=int(input())
H=list(map(int,input().split()))
dp=[float('inf')]*N
dp[0],dp[1]=0,abs(H[1]-H[0])

for i in range(2,N):
    x=dp[i-1]+abs(H[i]-H[i-1])
    y=dp[i-2]+abs(H[i]-H[i-2])
    dp[i]=min(x,y)

print(dp[N-1])

Measured memory_bytes: 20580
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b.append(0)
before = a[:]
count = 0
#print(a, b)

for i in reversed(range(0, n+1)):
    dif = a[i] - b[i-1]
    if dif < 0:
        a[i] = 0
        b[i-1] = abs(dif)
    else:
        a[i] = dif
        b[i-1] = 0
    if i > 0:
        a[i-1] -= b[i-1]
        if a[i-1] < 0:
            a[i-1] = 0

for j in range(0, n+1):
    count += (before[j] - a[j])

#print(a, b)
print(count)


Measured memory_bytes: 18752
//#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
#include<time.h>



#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define sz(a) ((int)a.size())
#define getmid ((l+r)>>1)
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define lowbit(x) x&(-x)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
using namespace std;
#ifdef local
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // local

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-8;
const int mod=1e9+7;
const int maxn=3e5+100;
const int N=3e5+1000;
const int M=500+10;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

int cntx[N],cnty[N],x[N],y[N];
int main()
{
#ifdef local
    freopen("in.txt","r",stdin);
#endif // local
    IOS;cout.tie(0);
    int n,m,k;cin>>n>>m>>k;
    int mx=0,my=0;
    for(int i=1;i<=k;++i)
    {
        cin>>x[i]>>y[i];
        cntx[x[i]]++;mx=max(mx,cntx[x[i]]);
        cnty[y[i]]++;my=max(my,cnty[y[i]]);
    }
    ll t1=0,t2=0,t=0;
    for(int i=1;i<=n;++i) if(cntx[i]==mx) t1++;
    for(int i=1;i<=m;++i) if(cnty[i]==my) t2++;
    t=t1*t2;
    for(int i=1;i<=k;++i)
    {
        if(cntx[x[i]]==mx&&cnty[y[i]]==my) t--;
    }
    if(t) cout<<mx+my<<endl;
    else cout<<mx+my-1<<endl;
    return 0;
}



Measured memory_bytes: 8348
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    int n=s.size();
    for(int i=n;i<15;i++)s+='o';
    int cnt=0;
    for(int i=0;i<15;i++){
        if(s[i]=='o')cnt++;
    }
    if(cnt>=8)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

using namespace std;

int main(){
    long long int N,now=0,j=1,ans=1,gou=1;
    bool flag = true;

    cin >> N;

    vector<int> D(N);
    vector<int> sum(N,0);

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

    if(D[0]!=0){
        flag = false;
    }

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

    if(D[1]==0){
        flag = false;
    }

    while(j!=N){
        if(D[j]==now){
            sum[now]++;
            j++;
        }else{
            now = D[j];
        }
    }
    
    if(D[N-1]!=1){

    for(int i=1;i<N-1;i++){
        if(sum[i+1]==0 || sum[i]==0){
            flag = false;
            break;
        }
    for(int ff=0;ff<sum[i+1];ff++){
        ans %= 998244353;
        ans *= sum[i];
        ans %= 998244353;
    }
        gou+= sum[i];
        if((gou+sum[i+1])==N){
            break;
        }
    }
    }

    if(!flag){
        cout << 0 << endl;
    }else if(D[N-1]==1 || N == 1){
        cout << 1 << endl;
    }else{
        cout << ans << endl;
    }
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int T = Integer.parseInt(sc.next());

        int minc = 1001;
        for (int i = 0 ; i < N ; i++) {
            int c = Integer.parseInt(sc.next());
            int t = Integer.parseInt(sc.next());
            if (t <= T && c < minc) {
                minc = c;
            }
        }

        if (minc == 1001) {
            System.out.println("TLE");
            return;
        }
        
        System.out.println(minc);
    }

}


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

using namespace std;

int main() {
    string s;
    cin >> s;

    bool ret = s[0] == 'A';

    int count = 0;
    for (int i = 2; i < s.size() - 1; i++) {
        if (s[i] == 'C')count++;
    }
    if (count != 1)ret = false;

    count = 0;
    for (int i = 0; i < s.size(); i++) {
        if (islower(s[i]))count++;
    }
    if (count != s.size() - 2)ret = false;

    cout << (ret ? "AC" : "WA") << endl;
    return 0;
}

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

typedef long long int ll;
#define rep(i,n) for(int i = 0; i < n; i++)

int main() {
  ll r,d,x;
  cin >> r >> d >> x;
  rep(i,10) {
    x = r*x-d;
    printf("%lld\n",x);
  }
  return 0;
}


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

string IntToStr(int tmp){
    ostringstream out;
    out << tmp;
    return out.str();
}


int main() {
    string s;
    cin>>s;
    stack<char>st;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='B'){
            if(!st.empty())st.pop();
        }
        else st.push(s[i]);
    }
    vector<char>v;
    while(!st.empty()){
        v.push_back(st.top());
        st.pop();
    }
    reverse(v.begin(),v.end());
    for(int i=0; i<v.size();i++){
        cout<<v[i];
    }cout<<endl;
}


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

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

    vector<int64_t> x(N), y(N);
    for (int64_t i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }

    int64_t min_value = min(*min_element(x.begin(), x.end()), *min_element(y.begin(), y.end()));
    int64_t max_value = max(*max_element(x.begin(), x.end()), *max_element(y.begin(), y.end()));

    int64_t R_min = min_value;

    int64_t ans = LLONG_MAX;
    {
        //B_max = max_valueの場合
        int64_t B_max = max_value;
        int64_t R_max = min_value, B_min = max_value;
        for (int64_t i = 0; i < N; i++) {
            R_max = max(R_max, min(x[i], y[i]));
            B_min = min(B_min, max(x[i], y[i]));
        }
        ans = min(ans, (R_max - R_min) * (B_max - B_min));
    }
    {
        //R_max = max_valueの場合
        int64_t R_max = max_value;
        vector<pair<int64_t, int64_t>> xy;
        for (int64_t i = 0; i < N; i++) {
            xy.emplace_back(min(x[i], y[i]), max(x[i], y[i]));
        }
        sort(xy.begin(), xy.end(), [](pair<int64_t, int64_t>& lhs, pair<int64_t, int64_t>& rhs){
            return lhs.first < rhs.first;
        });

        multiset<int64_t> blues;
        blues.insert(xy[0].second);
        for (int64_t i = 1; i < N; i++) {
            blues.insert(xy[i].first);
        }
        int64_t B_width = *(--blues.end()) - *blues.begin();
        for (int64_t i = 1; i < N; i++) {
            blues.erase(blues.find(xy[i].first));
            blues.insert(xy[i].second);
            B_width = min(B_width, *(--blues.end()) - *blues.begin());
        }
        ans = min(ans, (R_max - R_min) * B_width);
    }

    cout << ans << endl;
}

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

int main(){
	int a,b,c,buf;
	cin >> a >> b >> c;
	if(a>b){
		buf=a;
		a=b;
		b=buf;
	}
	if(b>c){
		buf=b;
		b=c;
		c=buf;
	}
	if(a>b){
		buf=a;
		a=b;
		b=buf;
	}
	cout << a << " "<< b << " " << c << endl;
	
	return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define int long long



struct listnode{
 int val;
 listnode*  next;};
 vector<int> func( vector<int> a,vector<int>l,int sum){
      vector<int>k,val;
       for(int i=0;i<l.size();i++)
           if(l[i]==0){
            k.push_back(i);
            val.push_back(a[i]);}
   if(sum<0)
   return a;
  else {
      sort(val.rbegin(),val.rend());
      for(int i=0;i<k.size();i++)
         a[k[i]]=val[i];}
         return a;

 }
 


int32_t main(){
 int m=1000000007;
 
     int n;
     cin>>n;
    int temp=n;
    int ans1=1,ans2=1;
    int ans=1;
     while(temp--!=0){
         ans1=(ans1*9)%m;
         ans2=(ans2*8)%m;
         ans=(ans*10)%m;
         
     }
     int a=(ans-(2*ans1)%m)%m;
    a=(a+ans2)%m;
     cout<<(a+m)%m<<endl;
     

return 0;
}

Measured memory_bytes: 3624
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    s = str(readline().rstrip().decode('utf-8'))
    d = {v: 7 - i for i, v in enumerate(["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"])}
    print(d[s])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38256
A_HP, A_ATK, B_HP, B_ATK = map(int, input().split())

f = False
while A_HP > 0 and B_HP > 0:
  # First
  B_HP -= A_ATK

  if B_HP <= 0:
    f = True
    break

  # Second
  A_HP -= B_ATK

if f:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 9032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return (a/g*b);
}
int main() {
    int n,flg[4] = {},cnt = 0;
    cin >> n;
    string s;
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
        if(s[i] == 'P') flg[0] = 1;
        if(s[i] == 'W') flg[1] = 1;
        if(s[i] == 'G') flg[2] = 1;
        if(s[i] == 'Y') flg[3] = 1;
    }
    for (int i = 0; i < 4; ++i) {
        if(flg[i] == 1) cnt++;
    }
    if(cnt == 3) cout << "Three" << endl;
    else cout << "Four" << endl;
    return 0;
}

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



int main() {
	long A[210];
	int n, ans=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	while (1) {
		int cun = 0;
		for (int i = 0; i < n; i++) {
			if (A[i]>0&&A[i] % 2 == 0)cun++;
		}
		if (cun == n) {
			for (int i = 0; i < n; i++) {
				A[i] /= 2;
			}
			ans++;
		}
		else {
			cout << ans << endl;
			return 0;
		}
	}



	return 0;
}

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

void printVector(vector<int> v) {
    for (auto x : v) {
        cout << x << ' ';
    }
    cout << '\n';
}

void printArray(ll A[], int size) {
    for (int i = 0; i <= size - 1; i++) cout << A[i] << ' ';
}

int main() {
    char c;
    cin >> c;
    if (c == 'A') cout << 'T';
    else if (c == 'T') cout << 'A';
    else if (c == 'C') cout << 'G';
    else cout << 'C';
    return 0;
}

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

#define ll      long long
#define MAX     1000007
#define inf     99999999999999
#define MOD     1000000007
#define pii     pair<int,int>
#define FIN     freopen("input.txt","r",stdin);
#define FOUT    freopen("output.txt","w",stdout);

int main ()
{
    ll n,a,b;
    scanf("%lld %lld %lld",&n,&a,&b);

    ll res = (n-max(a,b));
    ll mn = min(a,b);
    ll mx = max(a,b);
    mn += res;
    mn = (n-mn-1);
    if(mn&1)
    {
        printf("Alice\n");
    }
    else
    {
        printf("Borys\n");
    }
    return 0;
}


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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;

typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

//constexpr long long MOD = (ll) 1e9+7;
constexpr long long MOD = 998244353;

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;
}

struct Edge {
	int to, cap, rev;
	Edge(int _to, int _cap, int _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
	G[from].push_back(Edge(to, cap, G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}

//素因数分解
void factoring(ll n, vector<P>& vec) {
 	for (ll i = 2; i * i <= n; i++) {
        ll con=0;
  		while (n % i == 0) {
   			con++;
   			n /= i;
  		}
        if(con>0) vec.push_back({i,con});
 	}
 	if (n != 1) vec.push_back({n,1});
}


//最大公約数
ll gcd(ll m, ll n) {
 if (n == 0)return m;
 return gcd(n, m % n);
}//gcd

//最小公倍数
ll lcm(ll m, ll n) {
 return m / gcd(m, n) * n;
}

class Combination {
public:
 Array fact;//n！
 Array inv;//n!の逆元
 ll mod;
 Combination(ll n, ll _mod) {
  mod = _mod;
  fact.resize(n + 1);
  fact[0] = 1;
  REP(i, n) {
   fact[i + 1] = (fact[i] * (i + 1LL)) % mod;
  }
  inv.resize(n + 1);
  inv[n] = mod_inv(fact[n]);
  for(int i=n;i>0;i--) {
   inv[i - 1] = inv[i] * i % mod;
  }
 }
 //modの逆元
 ll mod_inv(ll x) {
  ll n = mod - 2;
  ll res = 1LL;
  while (n > 0) {
   if (n & 1) res = res * x % mod;
   x = x * x % mod;
   n >>= 1;
  }
  return res;
 }
 ll nCr(ll n, ll r) {
  return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod;
 }
 ll nPr(ll n, ll r) {
  return (fact[n] * inv[n - r]) % mod;
 }
 ll nHr(ll n, ll r) {
  //重複組み合わせ：n種類のものからr種類選ぶ
  return nCr(r + n - 1, r);
 }
};

Combination comb(101010,MOD);


ll check(vec<P> x) {
    ll sum=0;
    ll mul=1;
    for(auto i:x){
        (sum+=i.second)%=MOD;
        (mul*=comb.fact[i.second])%=MOD;
    }
    return comb.fact[sum]*comb.mod_inv(mul)%MOD;
}

void solve() {
    ll n;
    cin>>n;
    Array a(n);
    REP(i,n) cin>>a[i];
    set<ll> st;
    REP(i,n){
        if(st.find(a[i])==st.end())st.insert(a[i]);
        else st.erase(a[i]);
    }
    cout<<st.size()<<en;
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


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

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

    string s;
    cin >> s;

    int count = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
        {
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int N = scanner.nextInt();
        int[] h = new int[N];
        for(int i = 0; i < N; i++) h[i] = scanner.nextInt();
        int[] dp = new int[N+1];
        for(int i = 1; i < N; i++) {
            dp[i] = dp[i-1] + Math.abs(h[i]-h[i-1]);
            if (i-2>=0) dp[i] = Math.min(dp[i], dp[i-2] + Math.abs(h[i]-h[i-2]));
        }
        out.println(dp[N-1]);
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        
        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }
    }
}


Measured memory_bytes: 34092
#include <bits/stdc++.h>
using namespace std;
multiset<long long> a;
int main(){
    int n,m;
    long long x;
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++){
        scanf("%lld",&x);
        a.insert(x);
    }
    for(int i=0;i<m;i++){
        auto b=prev(a.end());
        x=*b;
        a.erase(b);
        x/=2;
        a.insert(x);
    }
    long long t=0;
    for(auto i=a.begin();i!=a.end();i++){
        t+=*i;
    }
    printf("%lld",t);
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

int main(void){
    string s; cin >> s;
    int K; cin >> K;
    REP(i,s.size()){
        if(s[i] == 'a') continue;
        if('z'-s[i]+1 <= K){
            K -= 'z'-s[i]+1;
            s[i] = 'a';
        }
    }
    s[s.size()-1] += K%26;
    cout << s << endl;
    return 0;
}

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

struct schedule{
    int front;
    int back;
};

template <typename T>void swap(T* a,T* b){
    T t=*b;
    *b=*a;
    *a=t;
}

template <typename T>int partition(T* R,int left,int right){
    int i=left-1;
    for(int j=left;j<=right-1;j++){
        if(R[j].back<=R[right].back){
            i++;
            swap(&R[j],&R[i]);
        }
    }
    swap(&R[i+1],&R[right]);
    return i+1;
}

template <typename T>void qsort(T *R,int Left,int Right){
    if(Left<Right){
        int middle=partition(R,Left,Right);
        qsort(R,Left,middle-1);
        qsort(R,middle+1,Right);
    }
}

int main(){
    int N,M;
    cin >> N>>M;
    schedule d[M];
    for(int i=0;i<M;i++){
        cin >> d[i].front>>d[i].back;
    }
    qsort(d,0,M-1);
    int count =1;
    int rec=d[0].back;
    for(int i=0;i<M;i++){
        if(rec<=d[i].front){
            count ++;
            rec=d[i].back;
        }
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+100;
const int mod=1e9+7;
ll n;ll dp[N],m;
int main(){
    scanf("%lld",&n);
    dp[n]=n;m=n-1;
    for(int i=n-1;i;i--){
        dp[i]=(1ll*(n-1)*(n-1))%mod;
        dp[i]=(dp[i]+dp[i+1])%mod;
        dp[i]=(dp[i]+m)%mod;
        m+=((i+2>n?1:dp[i+2])-1)%mod;
    }
    printf("%lld\n",dp[1]%mod);
    //system("pause");
}

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

using namespace std;

int main()
{
    cout<<setprecision(18);
    int n;
    cin>>n;
    vector<double>p(n);
    for(int i=0;i<n;i++)
    {
        cin>>p[i];
    }
    double m[n+1][n+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            m[i][j]=0.0;
        }

    }
    m[0][0]=1.0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(j==0)
            m[i][j]+=(1.0-p[i-1])*(m[i-1][j]);
            else if(j>=1)
            m[i][j]+=((p[i-1]*(m[i-1][j-1]))+((1.0-p[i-1])*(m[i-1][j])));
        }
    }
    /*for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            cout<<m[i][j]<<' ';
        }
        cout<<endl;
    }
    return 0;
    */
    double ans=0.0;
    int k=(n/2)+1;
     for(int j=0;j<=n;j++)
        {
            if(j>=k)
                ans+=m[n][j];
        }
    cout<<fixed<<ans<<endl;
    return 0;
}


Measured memory_bytes: 70528
N, K = map(int,input().split())
ans = 0

ev = 0
ev2 = 0
od = 0
if K % 2 == 1:
    print((N//K)**3)
else:
    ans = N//K
    for i in range(1,N+1):
        if i % K == (K//2):
            ev += 1
    print(ans**3 + ev**3)

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

int main(){
	int n, n1, n2, n3, n4;
  	int flag;
  	cin >> n;
  	n1 = n/1000;
  	n2 = n%1000/100;
  	n3 = n%100/10;
  	n4 = n%10;
  	if(n1 == n2 && n2 == n3 || n2 == n3 && n3 == n4){
    	cout << "Yes" << endl;
    }else cout << "No" << endl;
  	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<vector>

using namespace std;

#define N 1000100
#define ll long long
#define RG register

inline int read(){
    RG int x=0,o=1; RG char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=((x<<3)+(x<<1))+ch-'0',ch=getchar();
    return x*o;
}

int n;

int main(){
	ll a=read(),b=read(),c=read();
	if(c<=(a+b)) printf("%lld\n",b+c);
	else printf("%lld\n",a+b+b+1);
}


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

int main(int argc, const char * argv[]) {
    // insert code here...
    int x;
    cin >> x;
    
    if (x < 1200) cout << "ABC" << endl;
    else cout << "ARC" << endl;
    
    return 0;
}


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

long long cnt, s, i;
string a;
int main()
{
	cin >>a;
	for (i = 0; i < a.size(); i++) {
		if (a[i] == 'B') cnt++;
		else s += cnt;
	}
    cout << s;
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

class B {
    public static final char[] keyence = "keyence".toCharArray();

    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        final char[] S = sc.next().toCharArray();
        int prefix = 0;
        while (prefix < S.length && prefix < keyence.length && S[prefix] == keyence[prefix])
            prefix++;
        int suffix = 0;
        while (suffix < S.length && suffix < keyence.length && S[S.length - suffix - 1] == keyence[keyence.length - suffix - 1])
            suffix++;
        System.out.println(prefix + suffix >= keyence.length ? "YES" : "NO");
    }
}
public class Main {
    public static void main(String... args) {
        B.main();
    }
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  stack<char> st;
  cin >> s;
  int n = s.size(), cnt = 0;
  for(int i=0; i<n; i++){
    if(st.empty()){
      st.push(s[i]);
      continue;
    }
    if(st.top() != s[i]){
      cnt += 2;
      st.pop();
    }else{
      st.push(s[i]);
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int n;
    cin >> n;
    for(int i = 1;i <= n;i++){
        int counter = 0;
        int limit = sqrt(i);
        for(int x = 1;x < limit;x++){
            for(int y = x;y < limit;y++){
                for(int z = y;z < limit;z++){
                    if(x * x + y * y + z * z + x * y + y * z + z * x == i){
                        int weight = 6;
                        if(x == y && y == z){
                            weight = 1;
                        }else if(x == y || y == z){
                            weight = 3;
                            }
                        counter += weight;
                    }
                }
            }
        }
        cout << counter << endl;
    }
    return 0;
}


Measured memory_bytes: 3648
import Control.Monad

main :: IO ()
main = do
  n <- readLn :: IO Int
  as <- replicateM 2 $ fmap (map read . words) getLine

  ans <- fmap maximum $ forM [0..n-1] $ \i -> do
    return $ sum $ take (i+1) (as !! 0) ++ drop i (as !! 1)

  print ans

Measured memory_bytes: 1020
#include <iostream>
typedef long long int lli;
using namespace std;
int ans = 0;
lli N;

void dfs(lli x, bool flag3, bool flag5, bool flag7)
{
	if (x > N)return;
	if (flag3&&flag5&&flag7)ans++;

	dfs(10 * x + 3, true, flag5, flag7);
	dfs(10 * x + 5, flag3, true, flag7);
	dfs(10 * x + 7, flag3, flag5, true);
}

int main(void)
{
	cin >> N;

	dfs(0, 0, 0, 0);
	cout << ans << endl;

	return 0;
}

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

int main(){
	int K, A, B;
	cin >> K >> A >> B;

	for (int i = A; i <= B; i++){
        if (i%K == 0){
            cout << "OK" << endl;
            return 0;
        }
        else{
            continue;
        }
	}
	cout << "NG" << endl;
	return 0;
}

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

using namespace std;

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

int main(int argc, char const *argv[]) {
	int a,b,c;
	std::cin >> a >> b >> c;
	if (b-a == c-b) {
		std::cout << "YES" << '\n';
	}
	else {
		std::cout << "NO" << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::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>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

struct edge { int to; long long weight;};

struct range_edge_graph {
    int n;
    vector<vector<edge>> g;
    
    range_edge_graph(int n_) {
        n = 1;
        while (n < n_) n <<= 1;
        g.resize(4*n);
        for (int i = 1; i < n; ++i) {
            int c1 = i<<1|0, c2 = i<<1|1;
            g[i].push_back({c1, 0});
            g[i].push_back({c2, 0});
            g[c1+2*n].push_back({i+2*n, 0});
            g[c2+2*n].push_back({i+2*n, 0});
        }
        for (int i = n; i < 2*n; ++i) {
            g[i].push_back({i+2*n, 0});
        }
    }

    // from [l1, r1) to [l2, r2)
    void add_edge(int l1, int r1, int l2, int r2, int w) {
        int id = g.size();
        l1 += n, r1 += n;
        while (l1 < r1) {
            if (l1 & 1) g[l1+2*n].push_back({id, 0}), l1++;
            if (r1 & 1) --r1, g[r1+2*n].push_back({id, 0});
            l1 >>= 1, r1 >>= 1;
        }
        vector<edge> res;
        l2 += n, r2 += n;
        while (l2 < r2) {
            if (l2 & 1) res.push_back({l2, w}), l2++;
            if (r2 & 1) --r2, res.push_back({r2, w});
            l2 >>= 1, r2 >>= 1;
        }
        g.push_back(res);
    }
};

vector<long long> dijkstra(int s, vector<vector<edge>>& g) {
    vector<long long> dist(g.size(), numeric_limits<long long>::max());
    dist[s] = 0;
    using P = pair<long long, long long>;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (dist[v] < p.first) continue;
        for (edge e : g[v]) {
            if (dist[e.to] > dist[v] + e.weight) {
                dist[e.to] = dist[v] + e.weight;
                que.push(P(dist[e.to], e.to));
            }
        }
    }
    return dist;
}

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

    int n, m;
    cin >> n >> m;
    range_edge_graph graph(n);

    rep(i, m) {
        int l, r, c;
        cin >> l >> r >> c;
        l--; r--;
        graph.add_edge(l, r+1, l, r+1, c);
    }
    
    auto dist = dijkstra(0+graph.n, graph.g);
    ll ans = dist[n-1+graph.n];
    if (ans > 1e18) cout << -1 << endl;
    else cout << ans << endl;
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 2000000000000000000LL
#define EPS 1e-9
#define debug(a) cerr<<#a<<"="<<(a)<<"\n"
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long ll;
typedef unsigned long long ull;
typedef complex<double> cd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void printArray(const int *arr, int n);
void printArray(const vector<int> &arr);

const ll mod = 1e9+7;
const double PI = acos(-1);

int n,i,j,k,t;
vector<pii> adj[100003];
int col[100003];

void dfs(int v, int p, int d){
    col[v] = d;
    for(const pii &x : adj[v]){
        if(x.fi == p) continue;
        dfs(x.fi, v, (d + x.se)&1);
    }
}

int main(){
	scanf("%d", &n);
    for(int i=1;i<n;++i){
        int a,b,c;
        scanf("%d %d %d", &a, &b, &c);
        --a, --b;
        adj[a].pb({b, c});
        adj[b].pb({a, c});
    }
    dfs(0, 0, 0);
    for(int i=0;i<n;++i){
        printf("%d\n", col[i]);
    }
	return 0;
}

/* Template Function */
void printArray(const int * a, int n){
	for(int i=0;i<n;++i){
		printf("%d ", a[i]);
	}
	puts("");
}

void printArray(const vector<int> &arr){
	for(int x : arr){
		printf("%d ", x);
	}
	puts("");
}

Measured memory_bytes: 8320