akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i,s,n) for(ll i=(s);i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    int a,b,c,g;
    cin>>a>>b;
    g=__gcd(a,b);
    if(n==3){
        cin>>c;
        g=__gcd(c,g);
    }
    pqsin q;
    for(int i=1;i*i<=g;i++){
        if(g%i==0){
            q.push(i);
            if(i*i!=g)q.push(g/i);
        }
    }
    while(q.size()){
        cout<<q.top()<<endl;
        q.pop();
    }
}


Measured memory_bytes: 3160
N = int(input())
h = [*map(int, input().split())]
dp = [0, abs(h[1] - h[0])] + [0] * (N - 2)
for i in range(2, N):
	dp[i] = min(abs(h[i] - h[i-1]) + dp[i-1],abs(h[i] - h[i-2]) + dp[i-2])
print(dp[N-1])

Measured memory_bytes: 20588
#include<stdio.h>
#include<stdlib.h>

struct node{

  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node *Node;
Node root, NIL;

void insert(int k){

  int N;
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));

  z -> key = k;
  z -> left = NIL;
  z -> right = NIL;

  while(x != NIL){

    y=x;

    if(z -> key < x -> key)
      x = x->left;
    else
      x = x -> right;
    
  }

  z -> parent = y;

  if(y == NIL) root = z;

  else {
    if( z->key < y->key)
      y -> left = z;

    else {
      y -> right = z;
    }
    
  }
}

void inorder (Node u){

  if(u==NIL) return;

  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);

}

void preorder(Node u){
  
  if(u==NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
  
}

int main(){

  int i,n,x;
  char array[20];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",array);
    if(strcmp(array,"insert") == 0){
      scanf("%d",&x);
      insert(x);
    }

    else if(strcmp(array,"print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 25148
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int D;
  cin >> D;
  string str = "Christmas";
  for(int i=D; i<25; i++) {
    str += " Eve";
  }
  cout << str << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>  
#include<math.h>  
  
//#include<map>   
//#include<set>
#include<deque>  
#include<queue>  
#include<stack>  
#include<bitset> 
#include<string>  
#include<iostream>  
#include<algorithm>  
using namespace std;  
  
#define ll long long  
#define INF 0x3f3f3f3f  
#define mod 1000000
#define clean(a,b) memset(a,b,sizeof(a))// 水印 

struct node{
	int to,next,dis,cost;
}edge[40100];
int head[10100];
int dis[10100],cost[10100];
bool vst[10100];
int n,m,k;

void spfa(int x)
{
	clean(dis,INF);
	clean(cost,INF);
	clean(vst,0);
	queue<int> q;
	dis[x]=0;
	cost[x]=0;
	q.push(x);
	while(!q.empty())
	{
		x=q.front();q.pop();
		vst[x]=0;
		for(int i=head[x];i!=-1;i=edge[i].next)
		{
			node b=edge[i];
			if(dis[b.to]>dis[x]+b.dis)
			{
				if(!vst[b.to])
				{
					vst[b.to]=1;
					q.push(b.to);
				}
				dis[b.to]=dis[x]+b.dis;
				cost[b.to]=b.cost;
			}
			else if(dis[b.to]==dis[x]+b.dis)
			{
				if(cost[b.to]>b.cost)
					cost[b.to]=b.cost;
			}
		}
	}
}

void add(int a,int b,int dis,int cost)
{
	edge[k].to=b;
	edge[k].dis=dis;
	edge[k].cost=cost;
	edge[k].next=head[a];
	head[a]=k;
	k++;
}

int main()
{
	while(cin>>n>>m&&n!=0||m!=0)
	{
		clean(head,-1);
		k=0;
		for(int i=0;i<m;++i)
		{
			int a,b,d,c;
			cin>>a>>b>>d>>c;
			add(a,b,d,c);
			add(b,a,d,c);
		}
		spfa(1);
		ll res=0;
		for(int i=1;i<=n;++i)
			res=res+cost[i];
		cout<<res<<endl;
	}
}


Measured memory_bytes: 3880
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;

int main(void){
	scanf("%d",&n);
	printf("%d\n",n+n*n+n*n*n);
	return 0;
}



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

using namespace std;

int main( ) {
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	char ch1,ch2;
	t = 1;
	while(t--) {
	 cin >> ch1 >> ch2;
	 if(ch1 == 'D') {
	  if(ch2 == 'H')
	   cout << 'D' << endl;
	  else
	   cout << 'H' << endl;
	 }
	 else
	  cout << ch2 << endl;
	}
	return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, T) = readLine()!!.split(" ").map(String::toInt)
    val ct = Array(N) { readLine()!!.split(" ").map(String::toInt) }

    ct.filter { it[1] <= T }.minBy { it[0] }?.let { it[0] }.let {
        (it ?: "TLE").let(::println)
    }
}

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

#define pb(n) push_back(n)
#define maxn 200010
#define inf 1000000000

using namespace std;

bool czy [maxn], special [maxn], czy1[maxn];
int bdistance [maxn], ojciec[maxn], ile[maxn];
vector<int> red[maxn], blue[maxn];

int Find (int x)
{
	if (ojciec[x]!=x)
		ojciec[x]=Find(ojciec[x]);
	return ojciec[x];
}

void join (int a, int b)
{
	a = Find(a);
	b = Find(b);
	if (a != b)
	{
		ojciec[a]=b;
		ile[b] += ile[a];
	}
}

void calculate_blue (int x)
{
	czy[x]=true;
	int s = (int)blue[x].size();
	for (int i = 0; i<s; ++i)
	{
		if(!czy[blue[x][i]])
		{
			bdistance[blue[x][i]] = bdistance[x] + 1;
			calculate_blue(blue[x][i]);
		}
	}
	czy[x]=false;
}

void calculate_special (int x, int y)
{
	//cout << "S" << x << endl;
	czy[x]=true;
	int s = (int)red[x].size();
	for(int i=0; i<s; ++i)
	{
		if (czy[red[x][i]])
		{
			int odl = bdistance[x] + bdistance[red[x][i]] - 2 * bdistance[Find(red[x][i])];
			//cout << Find(red[x][i]) << endl;
			//cout << x << " " << red[x][i] << " " << odl << endl;
			if (odl >= 3)
				special[x] = special[red[x][i]] = true;
		}
	}
	s = (int) blue[x].size();
	for (int i = 0; i<s; ++i)
	{
		if(!czy[blue[x][i]])
			calculate_special (blue[x][i], x);
	}
	join (x, y);
}

int answer (int x, int y)
{
	czy1 [x] = true;
	if (special[x] && bdistance [x] > y)
		return inf;
	if (bdistance [x] <= y)
		return y;
	int odp = bdistance [x];
	int s = (int)red[x].size();
	for (int i = 0; i<s; ++i)
	{
		if (!czy1[red[x][i]])
		{
			odp = max(answer (red[x][i], y + 1), odp);
		}
	}
	return odp;	
}


int main()
{
	int n, x, y,a,b;
	cin >> n >> x >> y;
	for(int i=1; i<n; ++i)
	{
		cin >> a >> b;
		red[a].pb(b);
		red[b].pb(a);
		ojciec[i]=i;
		ile[i]=1;
	}
	ojciec[n]=n;
	ile[n]=1;
	for(int i=1; i<n; ++i)
	{
		cin >> a >> b;
		blue[a].pb(b);
		blue[b].pb(a);
	}
	calculate_blue (y);
	calculate_special (y, y);
	int ans = answer (x, 0);
	if (ans == inf)
		puts ("-1");
	else
		cout << 2 * ans << endl;
	return 0;
}



Measured memory_bytes: 33660
#include<bits/stdc++.h>
#define LL long long
#define int long long
inline LL read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	LL k=0,kk=1;if (c=='-')c=getchar(),kk=-1;
	while (c>='0'&&c<='9')k=k*10+c-'0',c=getchar();return kk*k;
}using namespace std;
void write(LL x){if (x<0)x=-x,putchar('-');if (x/10)write(x/10);putchar(x%10+'0');}
void writeln(LL x){write(x);puts("");}
int n,ans;
signed main(){
	n=read();while (n)ans+=n%10,n/=10;
	if (ans==1)writeln(10);else writeln(ans);
}


Measured memory_bytes: 256
def m(L,R):
 T=[]
 for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
 return R+T[::-1]
def d(A):
 l=len(A);global c;c+=l
 s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A
c=-int(input())
print(*d(list(map(int,input().split()))))
print(c)


Measured memory_bytes: 63688
#include <iostream>
using namespace std;
int solvemax(int n, int a, int b)
{
    if (a <= b)
    {
        return a;
    }
    else
    {
        return b;
    }
}
int solvemin(int n, int a, int b)
{
    if (a + b <= n)
    {
        return 0;
    }
    else
    {
        return a + b - n;
    }
}
int main()
{
    int n, a, b;
    int ans1, ans2;
    cin >> n >> a >> b;
    ans1 = solvemax(n, a, b);
    ans2 = solvemin(n, a, b);
    cout << ans1 << " " << ans2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
map<string,int>dp;
int dx[4]={1,-1,4,-4};
void bfs()
{
	queue<string>que;
	string p;
	p="01234567";
	dp[p]=0;
	que.push(p);
	while(que.size())
	{
		string q;
		q=que.front(); que.pop();
		int k;
		for(int i=0;i<8;i++)
		{
			if(q[i]=='0')
			{
				k=i;
				break;
			}
		}
		for(int i=0;i<4;i++)
		{
			int x;
			x=k+dx[i];
			if(x>=0&&x<=7&&!(k==3&&i==0)&&!(k==4&&i==1))
			{
				string pp;
				pp=q;
				swap(pp[x],pp[k]);
				if(dp.find(pp)==dp.end())
				{
					dp[pp]=dp[q]+1;
					que.push(pp);
				}
			}
		}
	}
}
int main()
{
	bfs();
	string s;
	while(getline(cin,s))
	{
		s.erase(remove(s.begin(),s.end(),' '),s.end());
		cout<<dp[s]<<endl;
	}
	return 0;
}


Measured memory_bytes: 5372
#include<bits/stdc++.h>
#define EM 100000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
using vint = vector<int>;
using vLL = vector<LL>;
int MOD = 1e9+7;
 
const int MAX = 1000000;
 
vLL fac(MAX), finv(MAX), inv(MAX);
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
LL COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
	LL N, M, K;
	cin >> N >> M >>K;
	COMinit();
	LL S = COM(N*M-2, K-2);
	LL ans = 0;
	LL dsum = 0;
	for(int i = 1;i < N;i++){
		dsum += i*(N-i);
		dsum %= MOD;
	}
	LL cnt = M*M%MOD;
	LL res = dsum*cnt%MOD;
	ans += res;
	ans %= MOD;
	
	dsum = 0;
	for(int i = 0;i < M;i++){
		dsum += i*(M-i);
		dsum %= MOD;
	}
	
	cnt = N*N%MOD;
	res = dsum*cnt%MOD;
	ans += res;
	ans %= MOD;
	ans *= S;
	ans %= MOD;
	cout << ans << endl;
}

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

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    
    ll  ans=0;

    //rep(i,n) cout << a[i] << endl;
    sort( a.begin(), a.end(), greater<ll>() );

    for( ll i = 0; i < a.size(); i++ ){
      if(a[i]%2 == 0 ){
        int tmp = a[i];
        while(1){
          if( tmp < 1 || tmp%2 != 0 ) break;
          tmp /= 2;
          ans ++;
        }
      }
      //cout << a[i] << " " << ans << endl;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int board[510][510];
signed main() {
    int H, W, h, w; cin >> H >> W >> h >> w;
    if(H % h == 0 and W % w == 0) {
        cout << "No" << endl;
    }
    else {
        int cntA = 0, cntB = 0;
        for(int i=0; i<H; i+=h) {
            for(int j=0; j<W; j+=w) {
                cntA++;
                int r = i+h-1;
                int c = j+w-1;
                if(r < H and c < W) {
                    cntB++;
                }
            }
        }

        int A = cntB * 2, B = cntA * 2 - 1;
        for(int i=0; i<H; i+=h) {
            for(int j=0; j<W; j+=w) {
                board[i][j] = A;
                int r = i+h-1;
                int c = j+w-1;
                if(r < H and c < W) {
                    board[r][c] = -B;
                }
            }
        }

        cout << "Yes" << endl;
        for(int i=0; i<H; i++) {
            for(int j=0; j<W; j++) {
                cout << board[i][j] << " \n"[j+1 == W];
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;
const ll mmod = 998244353;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<string> g;
vector<vector<ll>> dp;


int main() {
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll n;
    cin >> n;
    vector<P> v(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i].first >> v[i].second;
    }
    v.push_back(P(mod, mod));
    sort(v.begin(), v.end());
    
    vector<ll> dp(n + 1);
    dp[n] = 1;
    stack<P> s;
    s.push(P(mod, n));
    for (int i = n - 1; i >= 0; --i)
    {
        ll m = v[i].first + v[i].second;
        ll next = i + 1;
        while (s.size() > 0)
        {
            P cur = s.top();
            if (cur.first < m)
            {
                next = cur.second;
            }
            else
            {
                break;
            }
            s.pop();
        }
        s.push(P(v[i].first, next));
        dp[i] += dp[next];
        dp[i] %= mmod;
        dp[i] += dp[i + 1];
        dp[i] %= mmod;
    }
    
    cout << dp[0] << endl;
    
    return 0;
}

Measured memory_bytes: 8520
#include <stdio.h>
#include <stdlib.h>

#define LEN 100005

typedef struct pp
{
  char name[100];
  int t;
} P;

P Q[LEN];
int head,tail,n;

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

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

int min(int a,int b){return a<b?a:b;}

int main(){
int elaps=0,c;
int i,q;
P u;
scanf("%d %d",&n,&q);
for(i=1;i<=n;i++){
scanf("%s",Q[i].name);
scanf("%d",&Q[i].t);
}
head=1;
tail=n+1;

while(head!=tail){
u=deque();
c=min(q,u.t);
u.t-=c;
elaps+=c;

if(u.t>0){
enque(u);
}

else{
  printf("%s %d\n",u.name,elaps);
}
}

return 0;
}



Measured memory_bytes: 11924
#include<bits/stdc++.h>
using namespace std;
const int mx=500000;
#define ll long long
#define p push_back
#define ff first
#define ss second
ll n,m,d ,t,q,temp1,temp2,temp3,d2;
long double a,b,c,e,f,g,h,qq,sum,nn,doo=2,yek=1,mmm;
int main(){
    cin>>n>>m>>d;
    nn=n;
    mmm=m;
    mmm-=yek;
    d2=n-d*2;
    cout<<fixed<<setprecision(9);
    q=max(temp1,d2);
    h=n-q;
    qq=q;
    qq*=doo;
    if(d!=0){
    sum+=(qq/nn)*(yek/nn);
    sum+=(h/nn)*(yek/nn);
    sum*=mmm;
    cout<<sum;}
    else{
        sum+=(yek/nn);
        sum*=mmm;
        cout<<sum;
    }
    return 0;
}


Measured memory_bytes: 256
import math

A, B = map(int, input().split())

ans = -1
for i in range(1, 10001):
    tax_8 = math.floor(i * 0.08)
    tax_10 = math.floor(i * 0.10)
    if tax_8 == A and tax_10 == B:
        ans = i
        break

print(ans)

Measured memory_bytes: 3060
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4,avx2,abm,fma")
#include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;

const char nl = '\n';
const ll INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9+7;
const ld EPS = 1e-13;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

const int N = 5000 + 1;
ll d[N], dk[N];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(10);

	ll k, q;
	cin >> k >> q;

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

	while(q--) {
		ll n, x, m;
		cin >> n >> x >> m;
		n -= 1;
		x %= m;

		ll len = 0;
		for(int i=0; i<k; i++) {
			dk[i] = d[i] % m;
			if(dk[i] == 0) dk[i] = m;
			len += dk[i];
		}

		ll step = len % m;
		int bad = 0;

		if(step != 0) {
			ll slen = step * (n/k);
			bad += (x + slen) / m;
		}

		bad += (len / m) * (n / k);
		x = (x + step * (n/k)) % m;
		for(int i=(n/k)*k; i<n; i++) {
			ll nx = (x + dk[i%k]) % m;
			if(nx <= x) bad++;
			x = nx;
		}

		cout << n-bad << nl;
	}

	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
typedef long long LL;
typedef unsigned long long ULL;
using namespace std;

int main() {
	LL A, P, ans = 0;
	cin >> A >> P;
	ans = (A * 3 + P) / 2;
	cout << ans << endl;
	return 0;
}

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 rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

template<typename T,bool directed>
struct Dinic{
    struct edge{
        int to,rev; T cap;
        edge(int to,T cap,int rev):to(to),cap(cap),rev(rev){}
    };
    vector<vector<edge>> G;
    vector<int> level,iter;
    Dinic(int n):G(n),level(n),iter(n){}
    int add_edge(int from,int to,T cap){
        G[from].emplace_back(to,cap,G[to].size());
        G[to].emplace_back(from,directed?0:cap,G[from].size()-1);
        return G[to].back().rev;
    }
    void bfs(int s){
        fill(all(level),-1);
        queue<int> que;
        level[s]=0;
        que.emplace(s);
        while(!que.empty()){
            int v=que.front(); que.pop();
            for (auto &e:G[v]){
                if (e.cap>0&&level[e.to]<0){
                    level[e.to]=level[v]+1;
                    que.emplace(e.to);
                }
            }
        }
    }
    T dfs(int v,int t,T f){
        if (v==t) return f;
        for (int &i=iter[v];i<G[v].size();++i){
            edge &e=G[v][i];
            if (e.cap>0&&level[v]<level[e.to]){
                T d=dfs(e.to,t,min(f,e.cap));
                if (d==0) continue;
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
        return 0;
    }
    T max_flow(int s,int t,T lim){
        T flow=0;
        while(true){
            bfs(s);
            if (level[t]<0||lim==0) break;
            fill(all(iter),0);
            while(true){
                T f=dfs(s,t,lim);
                if (f==0) break;
                flow+=f;
                lim-=f;
            }
        }
        return flow;
    }
    T max_flow(int s,int t){
        return max_flow(s,t,numeric_limits<T>::max()/2);
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W; cin >> H >> W;
    vector<string> field(H);
    rep(i,H) cin >> field[i];
    Dinic<int,false> di(H+W+2);
    int sh,sw,th,tw;
    rep(i,H) rep(j,W){
        if (field[i][j]!='.'){
            di.add_edge(i,H+j,1);
        }
        if (field[i][j]=='S') sh=i,sw=j;
        if (field[i][j]=='T') th=i,tw=j;
    }
    if (sh==th||sw==tw){
        cout << -1 << endl;
        return 0;
    }
    di.add_edge(H+W,sh,INF);
    di.add_edge(H+W,H+sw,INF);
    di.add_edge(H+W+1,th,INF);
    di.add_edge(H+W+1,H+tw,INF);
    cout << di.max_flow(H+W,H+W+1) << endl;
}

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

int main() {
	int n;
	vector<int> r;
	while(true)
	{
		cin >> n;
		if (n==0)
			break;
		int cnt=0;
		for(int i=1; i<=n; i++)
		{
			int tmp=i;
			while(true)
			{
				if (tmp%5==0)
				{
					cnt++;
					tmp/=5;
				} else {
					break;
				}
			}
		}
		r.push_back(cnt);
	}
	for(int i=0; i<r.size(); i++)
	{
		cout << r[i] << endl;
	}
	return 0;
}

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

//def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

    string s;
    cin >> s;
    if (s[2] == s[3] and s[4] == s[5])
        CYES;
    else
        CNO;
    return 0;
}


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

signed main(){

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

    int n; string s;
    cin >> n >> s;
    rep(i,s.size()){
        int l = (s[i] + n - 'A') % 26; 
        cout << char('A' + l);
    }
    cout << endl;
    return 0;
}

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

int main() {
    long long N,A,B;
    cin >> N >> A >> B;
    long long S;
    S=(B-A);
    if (S%2==0)
        cout << S/2 << endl;
    else if (S%2==1)
        if (A+B>N)
            cout << N-B+1+(S-1)/2 << endl;
        else if (A+B<=N)
            cout << A-1+1+(S-1)/2 << endl;
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

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

    double X = 1;
    bool flg = false;
    rep(i, 50000) {
        if(floor(X * 1.08) == N) {
            cout << X << endl;
            flg = true;
            break;
        }
        X++;
    }
    if(!flg) cout << ":(" << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n), idx(n+1);
  rep(i,n) cin >> a[i], idx[a[i]] = i + 1;

  ll res = 0;

  set<int> st;
  st.insert(0);
  st.insert(n+1);

  for (int a = 1; a <= n; a++) {
    auto itr = st.upper_bound(idx[a]);
    int r = *itr;
    int l = *(--itr);
    res += ll(a) * (idx[a] - l) * (r - idx[a]);
    st.insert(idx[a]);
  } 
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 11264
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  int n; in(n);
  vector<ll> A(n+1),B(n);
  loop(i,0,n+1) in(A[i]);
  loop(i,0,n) in(B[i]);
  
  ll ans = 0;
  loop(i,0,n) {
    ll &a1 = A[i]; ll &a2 = A[i+1]; ll &b = B[i];
    ll d = min(a1, b);
    a1 -= d; b -= d;
    ll d2 = min(a2, b);
    a2 -= d2; b -= d2;
    ans += d + d2;
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 4676
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    constexpr i64 mod = 1000000007;
    int n;
    std::cin >> n;
    std::vector<i64> p2(n + 1);
    p2[0] = 1;
    for (int i = 1; i <= n; i++) p2[i] = p2[i - 1] * 2 % mod;

    int zero = 0;
    std::map<std::pair<i64, i64>, i64> v;
    for (int i = 0; i < n; i++) {
        i64 a, b;
        std::cin >> a >> b;
        if (!a && !b) {
            zero++;
            continue;
        }
        const i64 g = std::gcd(llabs(a), llabs(b));
        a /= g;
        b /= g;
        if (a < 0) {
            a = -a;
            b = -b;
        } else if (!a && b < 0) {
            b = -b;
        }
        v[std::make_pair(a, b)]++;
    }

    i64 ret = 1;
    std::map<std::pair<i64, i64>, i64> done;
    for (const auto [d, left] : v) {
        if (done[d]) continue;
        const auto e = d.second >= 0 ? std::make_pair(d.second, -d.first) : std::make_pair(-d.second, d.first);
        const i64 right = v[e];
        ret = (p2[left] + p2[right] - 1) % mod * ret % mod;
        done[d] = done[e] = 1;
    }

    std::cout << (ret + zero + mod - 1) % mod << std::endl;

    return 0;
}


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

int main(){
    int N, K;
    int l[60];
    cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> l[i];
    sort(l, l + N, greater<int>());
    int dist = 0;
    for (int i = 0; i < K; ++i){
        dist += l[i];
    }
    cout << dist << endl;
}

Measured memory_bytes: 256
n = gets.to_i

m = 0
a = 0
r = 0
c = 0
h = 0

pool = []

n.times do
  input = gets.chomp
  case input[0]
    when "M"
      m += 1
    when "A"
      a += 1
    when "R"
      r += 1
    when "C"
      c += 1
    when "H"
      h += 1
    else
      # type code here
  end
end

count = 0
count += m*a*r
count += m*a*c
count += m*a*h
count += m*r*c
count += m*r*h
count += m*c*h
count += a*r*c
count += a*r*h
count += a*c*h
count += r*c*h

puts count

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define x first
#define y second
int d[2005];
int main()
{
	ios_base::sync_with_stdio(0);
	multiset<int> s1 , s2;
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	for(int i = 0; i < a; i++)
	{
		int v;
		cin >> v;
		s1.insert(v);
	}
	for(int i = 0; i < b; i++)
	{
		int v;
		cin >> v;
		s2.insert(v);
	}
	while(s1.size() > x)
		s1.erase(s1.begin());
	while(s2.size() > y)
		s2.erase(s2.begin());
	vector<int> C(c);
	for(auto &x : C)
		cin >> x;
	sort(C.begin() , C.end());
	for(auto x : s2)
		s1.insert(x);
	for(int i = 0; i < c; i++)
	{
		int x = C[i];
		if(*s1.begin() < x)
		{
			s1.erase(s1.begin());
			s1.insert(x);
		}
	}
	ll tot = 0;
	for(auto x : s1)
		tot += x;
	cout << tot;
	
}


Measured memory_bytes: 13312
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define MOD 1000000007
#define vec vector
using namespace std;
int main()
{
	int n;
	cin>>n;
	int h[n], i;
	for(i=0;i<n;i++)
		cin>>h[i];
	int dp[n];
	dp[0]=0, dp[1] = abs(h[0]-h[1]);
	for(i=2;i<n;i++)
	{
		dp[i] = min(dp[i-2] + abs(h[i]-h[i-2]), dp[i-1] + abs(h[i]-h[i-1]));
	}
	cout<<dp[n-1];
}

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

int main()
{
    int a,b,c,d,e,f,g;
    cin>>a>>b>>c>>d;
    e=abs(a-c);
    f=abs(a-b);
    g=abs(b-c);
    if(e<=d || (f<=d && g<=d)) cout<<"Yes";
    else cout<<"No";

    return 0;
}


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

using namespace std;

const int maxn = 2e5 + 10;

typedef long long ll;

ll a[maxn],b[maxn];

int main(){
    ll n,m,k;
    cin>>n>>m>>k;
    
    for(int i = 1; i <= n; i++){
        ll x;
        cin>>x;
        
        a[i] = a[i-1] + x;
    }
    
    for(int i = 1; i <= m; i++){
        ll x;
        cin>>x;
        
        b[i] = b[i-1] + x;
    }
    
    int j = m;
    
    int ans = 0;
    
    for(int i = 0; i <= n; i++){
        if(a[i] > k)
            break;
            
        while(j >= 0 && b[j] > k - a[i])
            j--;
        ans = max(ans, i + j);
    }
    cout<<ans;
}

Measured memory_bytes: 6644
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#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) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

void ng(){
  cout << "No" << endl;
  exit(0);
}

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

  string s;
  cin >> s;

  REP(i,s.size()){
    if(i%2){
      if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D') continue;
      ng();
    }
    else{
      if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D') continue;
      ng();
    }
  }

  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define N 10000

int str_len(char str[]) {

    int i;

    i = 0;
    while (str[i] != '\0') {
        i++;
    }

    return i;

}

int main(void) {

    int i, len;
    char str1[N], str2[N], new_str1[2*N];

    i = 0;
    len = 0;
    for (i = 0; i < N; i++) {
        str1[i] = 0;
        str2[i] = 0;
    }
    for (i = 0; i < 2*N; i++) new_str1[i] = 0;

    scanf("%s", str1);
    scanf("%s", str2);
    len = str_len(str1);

    for (i = 0; i < len; i++) {
        new_str1[i] = str1[i];
        new_str1[len + i] = str1[i];
    }

    if (strstr(new_str1, str2) == NULL) {
        printf ("No\n");
    } else {
        printf ("Yes\n");
    }

    return 0;

}

Measured memory_bytes: 564
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
int main(void){
    long long a;
    double b;
    cin >> a >> b;
    a *= (int) ((b+0.001)*100);
    cout << (a/100) << endl;
}


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

using namespace std;
long long A,B,C,D;
long long lcm(long long a,long long b){
	return a*b/__gcd(a,b);
}
long long solve(long long x){
	return (x)-(x/C+x/D-x/lcm(C,D));
}
int main(){
	cin>>A>>B>>C>>D;
	cout<<solve(B)-solve(A-1)<<endl; 
	return 0;
}

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

int main(void)
{
	long long int a=0,b=0,c=0,x=0,y=0;
	cin>>a>>b>>c>>x>>y;
	
	long long int sum=0;
	long long int maxn=2*max(x,y);
	long long int minn=0;
	long long int ia=0,ib=0;
	
	for(int i=0;i<=maxn;i+=2)
	{
		ia=x-i/2;
		if(ia<0)
		{
			ia=0;
		}
		
		ib=y-i/2;
		if(ib<0)
		{
			ib=0;
		}
		
		sum=i*c+a*ia+b*ib;
		if(sum<minn||minn==0)
			minn=sum;
	} 
	cout<<minn<<endl;
	return 0;
}

 

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

int main(){
  ll n,ans=0;cin>>n;
  double x=(n+1)/1.08,y=n/1.08;
  drep(i,n,y-1){
    if(i<x&&i>=y){ans=i;break;}
  }
  if(ans==0){cout<<":("<<endl;}
  else{cout<<ans<<endl;}
}



Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)

struct Proc {
    string name;
    int remain;
    Proc(const string& n, int r) : name(n), remain(r) {}
};

void read_problem(queue<Proc>& que, int& quant)
{
    int n;
    scanf("%d %d\n", &n, &quant);

    REP(_, n) {
        char name[64];
        int remain;
        scanf("%s %d\n", name, &remain);
        que.push(Proc(name, remain));
    }
}

void schedule(queue<Proc>& que, int quant)
{
    int t = 0;

    while(!que.empty()) {
        Proc proc = que.front();
        que.pop();
        if(proc.remain > quant) {
            t += quant;
            proc.remain -= quant;
            que.push(proc);
        }
        else{
            t += proc.remain;
            printf("%s %d\n", proc.name.c_str(), t);
        }
    }
}

int main()
{
    queue<Proc> que;
    int quant;

    read_problem(que, quant);

    schedule(que, quant);

    return 0;
}

Measured memory_bytes: 5800
def main():
    N, K = map(int, input().split())
    V = list(map(int, input().split()))
    L = [(0, [])]
    R = [(0, [])]

    mp = 0
    mn = []
    for _, v in zip(range(K), V):
        if v >= 0:
            mp += v
        else:
            mn.append(v)
            mn.sort()
        L.append((mp, tuple(mn)))

    mp = 0
    mn = []
    for _, v in zip(range(K), reversed(V)):
        if v >= 0:
            mp += v
        else:
            mn.append(v)
            mn.sort()
        R.append((mp, tuple(mn)))

    mval = 0
    for l, (lp, ln) in enumerate(L):
        for r, (rp, rn) in zip(range(K - l + 1), R):
            if l + r > len(V):
                break
            val = rp + lp
            n = K - l - r
            if len(ln) + len(rn) > n:
                t = list(ln) + list(rn)
                t.sort()
                val += sum(t[n:])
            mval = max(mval, val)
    print(mval)


main()


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

int main() {
  string s;
  cin >> s;
  bool hitachi = false;
  
  if (s == "hi") hitachi = true;
  else if (s == "hihi") hitachi = true;
  else if (s == "hihihi") hitachi = true;
  else if (s == "hihihihi") hitachi = true;
  else if (s == "hihihihihi") hitachi = true;
  
  if (hitachi) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std;
int V,E;
struct edge{
  int from,to,cost;
};
int comp(edge& a,edge& b){
  if(a.cost>b.cost)return 1;
  else if(a.cost<b.cost)return -1;
  else return 0;
}
int par[10001];
int Rank[10001];
void init(int n){
  for(int i=0;i<n;i++){
    par[i]=i;
    Rank[i]=0;
  }
}
int find(int a);
bool same(int a,int b){
  return find(a)==find(b);
}
int find(int a){
  if(par[a]==a)return a;
  else find(par[a]);
}
void unite(int a,int b){
  if(find(a)==find(b))return;
  if(Rank[a]>Rank[b])par[b]=a;
  else {
    par[a]=b;
    if(Rank[a]==Rank[b])Rank[b]++;
  }
}
void Union(int a,int b){
  unite(find(a),find(b));
}
vector<pair<int,pair<int,int> > > e;
int main(){
  cin>>V>>E;
  for(int i=0;i<E;i++){
    int a,b,c;cin>>a>>b>>c;
    e.push_back(make_pair(c,make_pair(a,b)));
  }
  sort(e.begin(),e.end());
  //for(int i=0;i<E;i++)cout<<e[i].fi<<endl;
  ll ans=0;
  init(V);
  for(int i=0;i<E;i++){
    if(!same(e[i].se.fi,e[i].se.se)){
      //cout<<e[i].fi<<endl;
      ans+=e[i].fi;
      Union(e[i].se.fi,e[i].se.se);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4528
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }


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

  string s = "1";
  rep(i, k - 1) {
    bool f = false;
    FORR(i, s.length() - 1, 1) {
      if (s[i] != '9' && s[i] < s[i - 1] + 1) {
        s[i]++;
        f = true;
        FOR(j, i + 1, s.length()) {
          if (s[j - 1] != '0') {
          char c = s[j - 1] - 1;
          s[j] = c;
        }
        else s[j] = '0';
        }
        break;
      }
    }
    if (f) continue;
    if (s[0] != '9') {
      s[0]++;
      FOR(i, 1, s.length()) {
        if (s[i - 1] != '0') {
          char c = s[i - 1] - 1;
          s[i] = c;
        }
        else s[i] = '0';
      }
    }
    else {
      s[0] = '1';
      FOR(i, 1, s.length()) {
        if (s[i - 1] != '0') {
          char c = s[i - 1] - 1;
          s[i] = c;
        }
        else s[i] = '0';
      }
      if (s[s.length() - 1] != '0') s += s[s.length() - 1] - 1;
      else s += '0';
    }
  }
  cout << s << endl;

  
  return 0;
}

Measured memory_bytes: 256
a = [str(i) for i in input()]

if len(a) > 10:
	print("NO")
	exit()

for bit in range(2 ** (len(a)+1)):
	s = a.copy()

	for i in range(0,len(a)+1):
		if (bit >> i) & 1:
			s.insert(i*2, "A")
			
	if "".join(s) == "AKIHABARA":
		print("YES")
		exit()

print("NO")

	

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

int main() {
  string str;
  cin >> str;
  int xCounter = 0;
  int oCounter = 0;
  for(int i=0; i<str.length(); i++){
    if(str[i] == 'x'){
      xCounter++;
    }else if(str[i] == 'o'){
      oCounter++;
    }
  }
  if(15 - str.length() + oCounter >= 8){
    cout << "YES";
  }else{
    cout << "NO";
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
  
typedef long long ll; 
typedef pair<ll, ll> pll;
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
 
#define MOD 1000000007  
#define ffor(a, b, c) for (ll(a) = (b); (a) < (c); ++(a))  
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL)); 
#define rep(i, n) ffor(i, 0, n) 
#define ff first 
#define ss second  
#define pb push_back 
#define ALL(v) v.begin(), v.end()  
#define TC(t) while (t--) 
#define N 200005
#define inf 1e18
#define modd 998244353
#define pp(var) cout<<var<<"\n";
#define pm(var1, var2) cout<<var1<<" "<<var2<<"\n"; 


int main(){
    fast;
    ll l,r,i,j,m,k,a,b,c,q,t,x,y,d,n;
    string s;
    cin>>s;
    ll ans = 0;
    vl dp(2019,0);
    for(auto &c : s){
        vl dp2(2019,0);
        for(i=0;i<2019;++i){
            dp2[(i*10 + c - '0')%2019]+= dp[i];
        }
        ans += dp2[0];
        dp.swap(dp2);
        dp[c-'0']++;
    }
    pp(ans);
}

Measured memory_bytes: 3800
#include<iostream>

using namespace std;

int sx, sy, tx, ty;

int main() {
    cin >> sx >> sy >> tx >> ty;
    int x = sx, y = sy;
    for(int i=sy; i<ty; ++i){
        cout<<"U";
    }
    for(int i=sx; i<tx; ++i){
        cout<<"R";
    }
    for(int i=sy; i<ty; ++i){
        cout<<"D";
    }
    for(int i=sx; i<tx; ++i){
        cout<<"L";
    }
 
    cout<<"L";
    for(int i=sy; i<ty+1; ++i){
        cout<<"U";
    }
    for(int i=sx; i<tx+1; ++i){
        cout<<"R";
    }
    cout<<"D";
 
    cout<<"R";
    for(int i=sy; i<ty+1; ++i){
        cout<<"D";
    }
    for(int i=sx; i<tx+1; ++i){
        cout<<"L";
    }
    cout<<"U";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
 
#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;


int main(){
  ll MOD = 1000000007;
  ll N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> modest(N);
  rep(i,N){
    cin >> A.at(i);
    if(i>0){
      modest.at(i) = modest.at(i-1) + A.at(i);
      modest.at(i) %= MOD;
    }
    else{
      modest.at(i) = A.at(i);
    }
  }
  ll ans = 0;
  rep(i,N-1){
    ll wa = modest.at(N-1)-modest.at(i);
    wa = (wa+MOD)%MOD;
    ans += wa*A.at(i);
    ans %= MOD;
  }
  cout << ans << endl;
}



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

const int INF=1e8;
vector<int> cost;
struct synthesize{
  int goal;
  vector<int> start;
  synthesize(int g, vector<int> s):
    goal(g), start(s) {}
  void update(){
    int tot=0;
    for(int ii : start) tot=max(tot, cost[ii]);
    if(tot==INF) return;

    int c=start.size(), use=tot;
    priority_queue<int> pq;
    for(int ii : start) pq.push(cost[ii]);
    while(!pq.empty()){
      int v=pq.top(); pq.pop();
      if(use<v){
        tot++;
        use++;
      }
      use--;
    }
    cost[goal]=min(tot, cost[goal]);
  }
}; 

int main(){
	int n, e, t; cin >> n >> e >> t;
  cost.assign(n+1, INF);
  for(int i=1; i<=n; i++){
    int tmp; cin >> tmp;
    if(tmp==1) cost[i]=1;
  }
  vector<synthesize> vec;
  for(int i=0; i<e; i++){
    int g, c; cin >> g >> c;
    vector<int> s(c);
    for(int j=0; j<c; j++) cin >> s[j];
    vec.push_back(synthesize(g, s));
  }

  for(int i=0; i<n; i++){
    for(int j=0; j<e; j++){
      vec[j].update();
    }
  }

  cout << (cost[t] != INF ? cost[t] : -1) << endl; 
}


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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (b <= c || d <= a)
		cout << 0 << endl;
	else
		cout << min(b, d) - max(a, c) << endl;
	return 0;
}

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

int main(){
	string A,B;
	cin >> A >> B;
	if(A.length()==B.length()){
		for(int i=0; i<A.length(); i++){
			if(A[i]-'0' < B[i]-'0') {
				cout << "LESS" << endl;
				break;
			}
			else if(A[i]-'0' > B[i]-'0'){
				cout<< "GREATER" << endl;
				break;
			}
			if(i==A.length()-1){
				cout << "EQUAL" << endl;
			}
		}
	}
	else if(A.length()>B.length()){
		cout << "GREATER" << endl;
	}
	else {
		cout << "LESS" << endl;
	}
}






			



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int max = sc.nextInt() + 1;
		int[] facs = new int[max];

		for (int i = 2; i < max; ++i) {
		    for (int j = i; j < max; j += i) {
		        facs[j]++;
		    }
		}
		int count = 0;
		for (int i = 0; i < max; ++i)
		    if (facs[i] == 7 && i%2 == 1)//1 is a factor of all number so check for count 7
		        count++;
		System.out.println(count);

	}

}


Measured memory_bytes: 27088
$<.readlines.each do |l|
  x1, y1, x2, y2, x3, y3, xp, yp = l.split.map(&:to_f)
  xa, ya = xp - x1, yp - y1
  xb, yb = x3 - x1, y3 - y1
  xc, yc = x2 - x3, y2 - y3
  r = xb * yc - xc * yb
  s = (yc * xa - xc * ya) / r
  u = (xb * ya - yb * xa) / r
  t = u / s
  puts((0 < s and s < 1 and 0 < t and t < 1) ? "YES" : "NO")
end


Measured memory_bytes: 6880
import java.util.Scanner;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            ans += i;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
n, a, b, c, d = map(int, input().split())
s = list(input())
last = ""
for i in range(a, c):
    if last == "#" and s[i] == "#":
        print("No")
        exit()
    last = s[i]
last = ""
for i in range(b, d):
    if last == "#" and s[i] == "#":
        print("No")
        exit()
    last = s[i]
last = ""
if c > d:
    flag = True
    s[b - 1] = "#"
    for i in range(a, c):
        if last == "#" and s[i] == "#":
            flag = False
        last = s[i]
    s[b - 1] = "."
    count = 0
    for i in range(b - 1, d+1):
        if s[i] == ".":
            count += 1
            if count == 3:
                flag = True
        else:
            count = 0
    if flag:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")


Measured memory_bytes: 4916