akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <stack>
#include <string>
#include <vector>

int main(int argc, char const* argv[]) {
  std::stack<int>                  S1;
  std::stack<std::pair<int, int> > S2;
  std::string                      lake_st;

  std::cin >> lake_st;
 
  int sum = 0;

  for (int i = 0; i < lake_st.length(); i++) {
    if (lake_st[i] == '\\') {
      S1.push(i);
    } else if (lake_st[i] == '/' && S1.size() > 0) {
      int j = S1.top();  // S1のtopの値を取得
      S1.pop();          //取り出したので消す
      int dist = i - j;  //距離出す
      sum += dist;       //距離を足す
      while (S2.size() > 0 && S2.top().first > j) {
        dist += S2.top().second;
        S2.pop();
      }
      S2.push(std::make_pair(j, dist));
    }
  }

  std::vector<int> ans;
  while (S2.size() > 0) {
    ans.push_back(S2.top().second);
    S2.pop();
  }

  reverse(ans.begin(), ans.end());
  std::cout << sum << std::endl;
  std::cout << ans.size();

  for (int i = 0; i < ans.size(); i++) { std::cout << " " << ans[i]; }
  std::cout << std::endl;
  return 0;
}



Measured memory_bytes: 3308
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <sstream>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)
#define rrep(i, a) RREP(i, a, 0)
#define RREP(i, a, b) for(int i = a; i >= b; --i)
#define repll(i, a) REPLL(i, 0, a)
#define REPLL(i, a, b) for(ll i = a; i < b; ++i)
#define rrepll(i, a) RREPLL(i, a, 0)
#define RREPLL(i, a, b) for(ll i = a; i >= b; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<int, P> PP;
const double PI = 3.14159265358979323846;
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+18 + 10;

ll a, b;
ll mod = (ll)1e+9 + 7;

ll func(ll m, ll n){
	if (n == 0)return 1;
	ll ret = func(m * m % mod, n / 2);
	if (n & 1)ret = (ret * m) % mod;
	return ret;
}

int main(){
	std::cin >> a >> b;
	std::cout << func(a, b) << std::endl;

	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
#include <stack>
using namespace std;

int main()
{
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	
	cout << min(n,k) * x + (n-k>0 ? n-k:0) *y << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] spl1 = sc.nextLine().split(" ");
		int N = Integer.parseInt(spl1[0]);
		int X = Integer.parseInt(spl1[1]);
		String[] spl2 = sc.nextLine().split(" ");
		int[] L = new int[N];
		for(int i = 0;i < N;i++) {
			L[i] = Integer.parseInt(spl2[i]);
		}

		int D = 0;//D0 初期値
		int cnt = 1;//カウンタ
		for(int i = 0;i < N;i++) {
			D += L[i];
			if(D > X) break;
			cnt++;
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 22868
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>  //for bool
#include <stdlib.h> // abs,labs,llabs
#include <limits.h>
#include <ctype.h>

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld; //%Lf

int main(void) {
  int n, k, i, ans = 0, x;
  scanf("%d %d", &n, &k);
  for (i = 0; i < n; i++) {
    scanf("%d", &x);
    if (x >= k) {
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
const int mo=1e9+7;

struct Node
{
	int key,act,t;
	Node(int _key=0,int _act=0,int _t=0):key(_key),act(_act),t(_t){}
};

struct Node_Less
{
	bool operator() (const Node &a,const Node &b) const {return a.act>b.act || (a.act==b.act && a.t>b.t);}
};

tree<Node,null_type,Node_Less,rb_tree_tag,tree_order_statistics_node_update> T;
map<int,string> NS;
map<int,int> tn,ta;
map<string,int> HASH;int HASHcnt;

int Hash(string s)
{
	long long xx=1;
	int res=0;
	for (int i=0;i<(int)s.length();i++)
	{
		res=(res+xx*s[i])%mo;
		xx=xx*19410817%mo;
	}
	return res;
	return HASH[s]?HASH[s]:HASH[s]=++HASHcnt;
}

int n;

void Init()
{
	std::ios::sync_with_stdio(false);
	cin >> n;
	for (int i=1;i<=n;i++)
	{
		string s;
		int x;
		cin >> s;
		cin >> x;
		NS[Hash(s)]=s;
		T.insert(Node(Hash(s),x,i));
		tn[Hash(s)]=i;
		ta[Hash(s)]=x;
	}
}

void Solve()
{
	int m,cnt=n;
	cin >> m;
	for (int t=n+1;t<=n+m;t++)
	{
		char ch;
		string s;
		int x;
		cin >> ch >> s;
		NS[Hash(s)]=s;
		if (ch=='+') cin >> x;
		if (ch=='+')
		{
			tn[Hash(s)]=t;
			ta[Hash(s)]=x;
			if (cnt<=4)
			{
				cnt++;
				T.insert(Node(Hash(s),x,t));
				int tmp=T.order_of_key(Node(Hash(s),x,t));
				if (cnt < 5 || tmp > 0) cout << s << " is not working now." << endl;
				if (cnt == 5) cout << NS[T.find_by_order(0)->key] << " is working hard now." << endl;
			}
			else
			{
				auto tmp=T.find_by_order(cnt/5-1);
				cnt++;
				T.insert(Node(Hash(s),x,t));
				if (cnt%5==0)
				{
					if ((int)T.order_of_key(Node(Hash(s),x,t)) <= cnt/5-1)
					{
						cout << s << " is working hard now." << endl;
					}
					else
					{
						cout << s << " is not working now." << endl;
						cout << NS[T.find_by_order(cnt/5-1)->key] << " is working hard now." << endl;
					}
				}
				else
				{
					if ((int)T.order_of_key(Node(Hash(s),x,t)) <= cnt/5-1)
					{
						cout << s << " is working hard now." << endl;
						cout << NS[tmp->key] << " is not working now." << endl;
					}
					else
					{
						cout << s << " is not working now." << endl;
					}
				}
			}
		}
		else
		{
			auto tmp=T.find_by_order(cnt/5-1);
			string tmps=NS[tmp->key];
			T.erase(Node(Hash(s),ta[Hash(s)],tn[Hash(s)]));
			cnt--;
			if (s==tmps)
			{
				if (cnt%5==4) continue;
				if (cnt>4) cout << NS[T.find_by_order(cnt/5-1)->key] << " is working hard now." << endl;
			}
			else
			{
				if (cnt%5==4)
				{
					if ((int)T.order_of_key(*tmp)>cnt/5-1)
					{
						cout << NS[tmp->key] << " is not working now." << endl;
					}
				}
				else
				{
					if (cnt<5) continue;
					if (T.find_by_order(cnt/5-1)->key == tmp->key) continue;
					cout << NS[T.find_by_order(cnt/5-1)->key] << " is working hard now." << endl;
				}
			}
		}
	}
}

int main()
{
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 18016
#include <stdio.h>
 
int main(void){
  int i,e;
  static int n[26];
  char st,al[53] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
   
  do{
    e = scanf("%c", &st);
 
    for(i=0;i<52;i++)
      if(al[i] == st){
        n[ i%26 ]++;
      }
 
  }while(e != EOF);
 
  for(i=0;i<26;i++)
    printf("%c : %d\n", al[i] , n[i]);
 
  return 0;
}


Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define int long long
#define ff first
#define ss second
#define pi pair<int,int>


int32_t main() {
	boost;
	string s, t;
	cin >> s >> t;
	vector<int>v[26];
	for(int i = 0; i < s.size(); i++)
		v[s[i] - 'a'].push_back(i);

	int pre = -1,ans = 0,cnt = 0;;
	for(int i = 0;i < t.size(); i++) {
		int cur = t[i] - 'a';
		if(v[cur].empty()) {
			cout << -1 << endl;
			return 0;
		}

		if(v[cur].back() <= pre){
			pre = -1;
			cnt++;
		}

		auto it = lower_bound(v[cur].begin(),v[cur].end(),pre+1) - v[cur].begin();
		pre = v[cur][it];
		ans = cnt*s.size() + pre + 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4592
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		int home[][][] = new int[4][3][10];

		Scanner std = new Scanner(System.in);
		int n = Integer.parseInt(std.next());
		for (int i=1; i<=n; i++){
			int b = Integer.parseInt(std.next());
			int f = Integer.parseInt(std.next());
			int r = Integer.parseInt(std.next());
			int v = Integer.parseInt(std.next());
			home[b-1][f-1][r-1] += v;
		}
		for (int j=0; j<=4-1; j++){
			for(int k=0; k<=3-1; k++){
				String line = "";
				for(int l=0; l<=10-1; l++){
					line += " "+home[j][k][l];
				}
				System.out.println(line);
			}
			if(j!=3){System.out.println("####################");}
		}
	}
}

Measured memory_bytes: 28428
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

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

    vi b(m), a(m);
    int ans = 0;
    rep(i, 0, m) cin >> b[i];
    rep(i, 0, n)
    {
        int sum = 0;
        rep(j, 0, m)
        {
            cin >> a[j];
            sum += a[j] * b[j];
        }
        sum += c;
        if (sum > 0)
            ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 100000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mood;
		}
		x = x * x % mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n;
string s[200];
vector<int> vec[210];
bool used[210];
int cnt[210];
bool bl;
int ans;

void bfs(int n) {
	queue<P> que;
	que.push({ n,1 });
	while ((int)que.size()) {
		P p = que.front(); que.pop();
		int x = p.first;
		int y = p.second;
		if (used[x]) {
			if ((y - cnt[x]) % 2) {
				bl = false;
				return;
			}
		}
		else {
			used[x] = true;
			cnt[x] = y;
			for (int i = 0; i < (int)vec[x].size(); i++) {
				que.push({ vec[x][i],y + 1 });
			}
		}
	}
	return;
}

int ma(int n) {
	int res = 0;
	for (int i = 1; i <= n; i++)res = max(res, cnt[i]);
	return res;
}

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		for (int j = 0; j < n; j++) {
			if (s[i][j]=='1') {
				vec[i + 1].push_back(j + 1);
			}
		}
	}
	bl = true;
	for (int i = 1; i <= n; i++) {
		fill(used, used + n + 5, false);
		fill(cnt, cnt + n + 5, 0);
		bfs(i);
		if (!bl) {
			cout << -1 << endl;
			return 0;
		}
		ans = max(ans, ma(n));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;

int main(void) {
  int n;
  scanf("%d", &n);
  if(((n-1) & n) == 0) {
    puts("No");
    return 0;
  }
  puts("Yes");
  for(int i = 2; i+1 <= n; i += 2) {
    printf("%d %d\n", 1, i);
    printf("%d %d\n", i, i+1);
    printf("%d %d\n", 1, n+i+1);
    printf("%d %d\n", n+i+1, n+i);
  }
  if(n % 2 == 0) {
    int cur = n;
    int t = 1;
    while(true) {
      if(cur / (t*2) == 0) {
        break;
      }
      t *= 2;
    }
    printf("%d %d\n", n, t);
    printf("%d %d\n", n + n, n + (n ^ t ^ 1));
  }
  printf("%d %d\n", n+1, 3);
  
  return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <vector>

using namespace std;

int main() {

	long long int n;
	cin >> n;

	vector<long long int> a(n);
	for (long long int i = 0; i < n; i++) {
		cin >> a[i];
	}

	long long int ans = 0;

	for (long long int i = 0; i < n; i++) {
		while (a[i] % 2 == 0) {
			ans++;
			a[i] /= 2;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <P,P> PP;
typedef pair <int,PP> PPP;

static const double eps = 1e-8;

static const int moveTo[][2] = {{1,0},{0,-1},{-1,0},{0,1}};
static const int moveToRev[][2] = {{-1,0},{0,1},{1,0},{0,-1}};

int stage[50][50];
int costTable[50][50][50][50];

int bfs(int tx,int ty,int kx,int ky,int w,int h){
	priority_queue<PPP,vector<PPP>,greater<PPP> > que;
	que.push(PPP(0,PP(P(tx,ty),P(kx,ky))));	
	memset(costTable,0x3,sizeof(costTable));

	int res = INF;
	costTable[tx][ty][kx][ky] = 0;
	while(!que.empty()){
		int cost = que.top().first;
		if(res <= cost || cost > 100){
			que.pop(); continue;
		}

		int tx = que.top().second.first.first;
		int ty = que.top().second.first.second;
		int kx = que.top().second.second.first;
		int ky = que.top().second.second.second;

		if(tx==kx && ty == ky) res = min(res,cost);

		que.pop();

		for(int i=0;i<4;i++){
			int tdx = tx + moveTo[i][0];
			int tdy = ty + moveTo[i][1];

			if((tdx < 0 || tdx >= w || tdy < 0 || tdy >=h) || stage[tdy][tdx]) {
				tdx = tx;
				tdy = ty;
			}

			int kdx = kx + moveToRev[i][0];
			int kdy = ky + moveToRev[i][1];

			if((kdx < 0 || kdx >= w || kdy < 0 || kdy >=h) || stage[kdy][kdx]) {
				kdx = kx;
				kdy = ky;
			}
			if(costTable[tdx][tdy][kdx][kdy] <= cost + 1) continue;
			costTable[tdx][tdy][kdx][kdy] = cost + 1;
			que.push(PPP(cost+1,PP(P(tdx,tdy),P(kdx,kdy))));
		}
	}

	return res;
}

int main(){

	int w,h;
	while(~scanf("%d %d",&w,&h)){
		if(w == h && h==0) break;
		int tx,ty;
		scanf("%d %d",&tx,&ty);
		int kx,ky;
		scanf("%d %d",&kx,&ky);
		for(int y=0;y<h;y++){
			for(int x=0;x<w;x++){
				scanf("%d",&stage[y][x]);
			}
		}

		int res = bfs(tx-1,ty-1,kx-1,ky-1,w,h);
		if(res >= 100) printf("NA\n");
		else printf("%d\n",res);
	}
}

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

int ceil(int n) {
	return (n / 50 + (n % 50 > 0)) * 50;
}
int cost[][7]{
	{0,300,500,600,700,1350,1650},
	{0,0,350,450,600,1150,1500},
	{0,0,0,250,400,1000,1350},
	{0,0,0,0,250,850,1300},
	{0,0,0,0,0,600,1150},
	{0,0,0,0,0,0,500},
};
int dist[][7]{
	{},
	{6},
	{13,7},
	{18,12,5},
	{23,17,10,5},
	{43,37,30,25,20},
	{58,52,45,40,35,15}
};
int main() {
	int d;
	while (scanf("%d", &d), d) {
		int hd, md, a, ha, ma; scanf("%d%d%d%d%d", &hd, &md, &a, &ha, &ma);
		d--; a--;
		if (((1050 <= hd * 60 + md&&hd * 60 + md <= 1170) || (1050 <= ha * 60 + ma&&ha * 60 + ma <= 1170)) && dist[max(d, a)][min(d, a)] <= 40)
			printf("%d\n", ceil(cost[min(d, a)][max(a, d)] / 2));
		else printf("%d\n", cost[min(d, a)][max(a, d)]);
	}
}

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

int main() {
  int n;
  cin >> n;
  set<pair<char, int>> s;
  for (int i = 0; i < n; i++) {
    char c;
    int x;
    cin >> c >> x;
    s.insert(make_pair(c, x));
  }
  string cards = "SHCD";
  for (int i = 0; i < 4; i++) {
    for (int j = 1; j <= 13; j++) {
      if (!s.count(make_pair(cards[i], j))) cout << cards[i] << ' ' << j << endl;
    }
  }
}



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

int a[500][500];

int main(){
  int n, i, j, m;
  cin >> n >> m;
  for(i = 0; i < n; i++){
    for(j = 0; j < m; j++){
      cin >> a[i][j];
    }
  }
  vector <pair<int, int>> from, to;
  for(i = 0; i < n; i++){
    if(i%2 == 0){
      for(j = 0; j < m; j++){
        if(a[i][j]%2){
          if(j == m-1 && i < n-1){
            from.push_back({i,j});
            to.push_back({i+1,j});
            a[i+1][j]++;
          }
          if(j < m-1){
            from.push_back({i,j});
            to.push_back({i,j+1});
            a[i][j+1]++;
          }
        }
      }
    }
    else{
      for(j = m-1; j >= 0; j--){
        if(a[i][j]%2){
          if(j == 0 && i < n-1){
            from.push_back({i,j});
            to.push_back({i+1,j});
            a[i+1][j]++;
          }
          if(j > 0){
            from.push_back({i,j});
            to.push_back({i,j-1});
            a[i][j-1]++;
          }
        }
      }
    }
  }
  cout << from.size() << endl;
  for(i = 0; i < from.size(); i++){
    cout << from[i].first+1 << " " << from[i].second+1 << " " << to[i].first+1 << " " << to[i].second+1 << endl;
  }
}

Measured memory_bytes: 5228
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 1000
//<<fixed << setprecision(9)
 
int main()
{
    int n,i,j,t,a;
    boost;

    cin>>a>>t;
    cout<<(a*3+t)/2;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	 double t=0;
	for(int i=1;i<=n;i++)
	{
		double a1;
		string a2;
		cin>>a1>>a2; 
		if(a2=="JPY")    t+=a1;
		if(a2=="BTC")    t+=(a1*380000.0);
	}
	cout<<t<<endl;
	return 0;
}

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

int main()
{
    int n;cin>>n;
    vector<int> a(n);
    int i;
    for(i=0;i<n;i++)cin>>a.at(i);
    sort(a.begin(),a.end());
    int ans=0;
    int now=a.at(0);
    int count=1;
    for(i=1;i<n;i++)
    {
        if(a.at(i)==now)
        {
            count++;
        }
        else
        {
            if(count>=now)ans+=count-now;
            else ans+=count;
            now=a.at(i);
            count=1;
        }
    }
    if(count>=now)ans+=count-now;
    else ans+=count;
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define PI_INT 3.14159265358979323846
#define PI acos(-1.0)
#define LL long long
#define N 100000007
#define MOD 10000007
#define MX numeric_limits<long long>::max();
#define MN numeric_limits<long long>::min();
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define FILL(v, n) fill(v.begin(), v.end(), n);
#define FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
#define PRINT(v) for(int i=0; i<v.size(); i++) cout<<v[i]<<" "; cout<<endl;
#define SCAN(v) for(int i=0; i<n; i++) { int temp; cin>>temp; v.push_back(temp); }
#define SORT(v) sort(v.begin(), v.end())
#define VECT(v) vector<int>v

using namespace std;

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

    LL x;
    cin >> x;

    LL ans=0;

    ans+=(b/x);
    ans-=(a/x);

    if(a%x==0) ans++;

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


Measured memory_bytes: 3580
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  int arr[5]={a,b,c,d,e};
  for(int i=0;i<sizeof(arr);i++)
  {
    if(arr[i]==0){
      cout<<i+1;
      break;}
  }
}
  

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1234567890
#define pii pair<LL,LL>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    LL n, k;
    cin >> n >> k;
    LL p[n+5];
    for (LL i=1;i<=n;i++) cin >> p[i];
    LL c[n+5];
    for (LL i=1;i<=n;i++) cin >> c[i];

    bool vis[n+5];
    memset (vis,0,sizeof(vis));

    LL ans = INT_MIN;
    for (LL i=1;i<=n;i++) {
        if (vis[i]) continue;
        vis[i] = 1;
        stack<LL> s;
        s.push(i);
        vector<LL> v;
        v.pb(c[i]);
        while (!s.empty()) {
            LL cur = s.top();
            s.pop();
            LL next = p[cur];
            if (!vis[next]) {
                s.push(next);
                vis[next] = 1;
                v.pb(c[next]);
            }
        }
        LL sum = 0;
        for (auto x : v) {
            sum += x;
        }
        vector<LL> w;
        for (auto x : v) {
            w.pb(x);
        }
        for (auto x : v) {
            w.pb(x);
        }

        // for (auto x : v) {
        //     cout << x << " ";
        // }
        // cout << sum;
        // cout << endl;

        LL limit = 0;
        if (k >= v.size()) limit = v.size();
        else limit = k;

        LL sesuatu = INT_MIN;
        for (LL j=1;j<w.size();j++) w[j] += w[j-1];
        for (LL j=0;j<w.size();j++) {
            for (LL l=j;l<min(j+limit, (LL)w.size());l++) {
                if (j > 0) sesuatu = max(sesuatu, w[l]-w[j-1]);
                else sesuatu = max(sesuatu, w[l]);
            }
        }

        LL sesuatu2 = INT_MIN;
        for (LL j=0;j<w.size();j++) {
            for (LL l=j;l<min(j+(k%(LL)v.size()), (LL)w.size());l++) {
                if (j > 0) sesuatu2 = max(sesuatu2, w[l]-w[j-1]);
                else sesuatu2 = max(sesuatu2, w[l]);
            }
        }

        if (sum >= 0) { // positive cycle
            ans = max(ans, k/(LL)v.size() * sum + sesuatu2);
            ans = max(ans, (k/(LL)v.size()-1) * sum + sesuatu);
        } else {
            ans = max(ans, sesuatu);
        }
    }
    cout << ans << endl;
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 3880
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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


int main(){
    string S;
    cin>>S;
    ll N = S.size();
    vector<vector<ll>> dp(2,v(N+1));

    dp[1][0] = 1;
    dp[0][0] = 0;
    rep(i,0,N){
        ll now = ll(S[i]-'0');
        dp[0][i+1] = min(dp[1][i] + 10 - now, dp[0][i] + now); 
        dp[1][i+1] = min({dp[0][i] + now + 1, dp[1][i] + 10 - now - 1 }); 
    }
    cout<<dp[0][N];
    return 0;
}

Measured memory_bytes: 24836
use std::cmp::min;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let w:usize = read();
    let mut weight = Vec::with_capacity(n);
    let mut value = Vec::with_capacity(n);
    for _ in 0..n {
        weight.push(read::<usize>());
        value.push(read::<usize>());
    }
    let mut dp = vec![vec![1<<60; 100100]; n+1];

    dp[0][0] = 0;

    for i in 0..n {
        for sum_v in 0..100100 {
            if sum_v >= value[i] {
                dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v - value[i]] + weight[i]);
            }
            dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }

    let mut ans = 0;

    for sum_v in 0..100100 {
        if dp[n][sum_v] <= w {
            ans = sum_v;
        }
    }
    println!("{}", ans);
}


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

ll ans = 0;
vector<vector<ll>> g;
int n, k;
ll dfs(ll pos, ll par) {
	ll maxi = 0;
	rep(i,g[pos].size()) {
		if(g[pos][i] == par) continue;
		if(g[pos][i] == pos) continue;
		maxi = max(maxi, dfs(g[pos][i], pos) + 1);
	}
	if(maxi == k - 1 && pos != 0 && par != 0) {
		ans++;
		maxi = -1;
	}
	return maxi;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	rep(i,n) a[i]--;
	if(a[0] != 0) {
		ans++;
		a[0] = 0;
	}
	g.resize(n);
	rep(i,n) {
		if(i == 0) continue;
		g[a[i]].pb(i);
	}
	dfs(0, -1);
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;

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

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int ab,bc,ca;
	cin >> ab >> bc >> ca;
	cout << (ab*bc)/2 << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int n,i,a[200005];
  ll ans=0;
  
  cin >> n;
  for (i=0;i<n;i++) cin >> a[i];
  
  if (a[0]!=0){
    cout << -1 << endl;
    return 0;
  }
  
  for (i=0;i<n-1;i++){
    if (a[i+1]-a[i]>1){
      cout << -1 << endl;
      return 0;
    }
  }
  
  while (i>=0){
    ans+=a[i];
    while (i>=0 && a[i]-a[i-1]==1) i--;
    i--;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1152
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

const int MAX = 1000000;

int main()
{
	vi prime(MAX+1, 1);
	prime[0] = prime[1] = 0;
	for(int i=2; i*i<=MAX; ++i){
		if(prime[i]){
			for(int j=i*2; j<=MAX; j+=i)
				prime[j] = 0;
		}
	}
	reep(i, 1, MAX+1)
		prime[i] += prime[i-1];
	
	int n;
	while(scanf("%d", &n), n){
		int sum = 0;
		rep(i, n){
			int p, m;
			scanf("%d%d", &p, &m);
			sum += prime[min(p+m, MAX)] - prime[max(p-m-1, 0)];
		}
		
		printf("%d\n", sum - n);
	}
	
	return 0;
}

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

using namespace std;

const int N = 123456;

int n, m, color[N], number[3], number_e;
vector<pair<int, int>> adj[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  long long answer = 0;
  for (int i = 1, x, y; i <= m; ++i) {
    cin >> x >> y;
    adj[x].emplace_back(y, 1);
    adj[y].emplace_back(x, -1);
  }
  bool ok;
  function<void (int, int)> dfs = [&] (int x, int z) {
    ++number[color[x] = z];
    for (auto e : adj[x]) {
      int y = e.first;
      if (e.second == 1) {
        ++number_e;
      }
      if (!~color[y]) {
        dfs(y, (z + e.second + 3) % 3);
      } else if (color[y] != (z + e.second + 3) % 3) {
        ok = false;
      }
    }
  };
  memset(color, -1, sizeof color);
  for (int i = 1; i <= n; ++i) {
    if (!~color[i]) {
      memset(number, 0, sizeof number);
      number_e = 0;
      ok = true;
      dfs(i, 0);
      if (ok && (!number[0] || !number[1] || !number[2])) {
        answer += number_e;
      } else if (ok) {
        answer += (long long) number[0] * number[1];
        answer += (long long) number[1] * number[2];
        answer += (long long) number[2] * number[0];
      } else {
        int all = number[0] + number[1] + number[2];
        answer += (long long) all * all;
      }
    }
  }
  cout << answer << '\n';
  return 0;
}

Measured memory_bytes: 13056
# ABC 152 A
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
snm = lambda: map(str, input().split())
nl = lambda: list(map(int, input().split()))
n,m=nm()
if m/n==1.0:
    print('Yes')
else:
    print('No')

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



struct S {
  int c;
  int r;
  double v;
  double x;
  double prex;
  bool operator < (const S &s) const {
    if(v != s.v) return v < s.v;
    return false;
  }
};

const double eps = 1e-5;
const int MAX_N = 54;
const double inf = 1e100;
int N;
vector<S> v;

bool equals(double a, double b) {
  return abs(a-b) < eps;
}

void input(){
  v.clear();
  for(int i = 0; i < N; i++){
    S s;
    int t, c;
    cin >> t >> c;
    s.c = c;
    s.r = 0;
    s.v = 1.0/(double)t;
    s.x = 0;
    s.prex = 0;
    v.push_back(s);
  }
  sort(v.begin(), v.end());
}

bool check() {
  for(int i = 0; i < v.size(); ++i) {
    if(v[i].c != 0) return false;
  }
  return true;
}

void next(int res) {
  for(int i = 0; i < v.size(); ++i) {
    if(v[i].c == 0) continue;
    v[i].prex = v[i].x;
    double begin = v[i].x;
    v[i].x += v[i].v;
    double end = v[i].x;
    for(int j = 0; j < i; ++j) {
      if(v[j].c == 0) continue;
      if(v[i].r != v[j].r) continue;
      if(equals(v[i].prex, 0.0) && equals(v[j].prex, 0.0)) continue;
      if(!equals(v[j].prex, v[i].prex) && v[j].prex < v[i].prex) {
	continue;
      }
      if(!equals(begin,v[j].x) && begin < v[j].x && v[j].x < end) {
	v[i].x = min(v[i].x, v[j].x);
	//cout << res << ":" << v[i].x << endl;
      }
    }
    v[i].x = min(v[i].x, 1.0);
    if(equals(1.0, v[i].x)) {
      v[i].x = 0;
      if(v[i].r == 1) {
	--v[i].c;
      }
      v[i].r = 1 - v[i].r;
    }
  }
}

void solve(){
  input();
  int res;
  for(res = 0 ; ; res++){
    /*
    cout << res << endl;
    for(int i = 0; i < v.size(); ++i) {
      cout << i << ": remain lap=" << v[i].c << ", x=" << v[i].r+v[i].x << endl;
    }
    cout << endl;
    */
    if(check()) break;
    next(res);
  }
  cout << res << endl;
}

int main(){
  while(cin >> N && N){
    solve();
  }
  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int> g[100005];

// int f(vector<int> g[], int r, int c, int p){
//     int ans = 1;
//     if(c==0){
//         for(int i=0;i<g[r].size();i++){
//             if(g[r][i]==p) continue;
//             ans = ans * (f(g,g[r][i],0,r)+f(g,g[r][i],1,r));
//         }
//     }
//     else{
//         for(int i=0;i<g[r].size();i++){
//             if(g[r][i]==p) continue;
//             ans = ans * f(g,g[r][i],0,r);
//         }
//     }
//     return ans;
// }
int dp[100005][2];
int m=1e9+7;
void dfs(int r, int p){
    dp[r][0]=1;
    dp[r][1]=1;
    for(int i=0;i<g[r].size();i++){
        if(g[r][i]==p) continue;
        dfs(g[r][i],r);
        dp[r][0]=(dp[r][0]*(dp[g[r][i]][0]+dp[g[r][i]][1])%m)%m;
        dp[r][1]=(dp[r][1]*(dp[g[r][i]][0]))%m;
    }
    return;
}

int32_t main() {
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int x, y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    
    //cout<<f(g,1,0,-1)+f(g,1,1,-1);
    dfs(1,-1);
    cout<<(dp[1][0]+dp[1][1])%m;
}

Measured memory_bytes: 14208
#include <stdio.h>
 #include <iostream>
 #include <vector>
 #include <stdlib.h>
 #include <algorithm>
 #define rep(i, n) for (int i = 0; i < n; ++i)
 using namespace std;

 int main(){
     int N,W;
     cin >> N >> W;
     //vector<long long int> w(N+2),v(N+2);
     long long int w[N+2],v[N+2];
     rep(i,N) {
         cin >> w[i] >> v[i];
     }
     //vector<vector<long long int>> dp(N, vector<long long int>(W,0));
     long long int dp[N+2][W+2];
     rep(i,N+1){
         rep(j,W+1){
             dp[i][j] = 0;
         }
     }

     rep(i,N+1){
         rep(j,W+3){
             if (j >= w[i]) {dp[i+1][j] = max(dp[i][j-w[i]] + v[i], dp[i][j]);}
             else {dp[i+1][j] = dp[i][j];}
         }
     }

     cout << dp[N][W];

     return 0;
 }

Measured memory_bytes: 79872
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] TA = Console.ReadLine().Split(' ');
            double T = int.Parse(TA[0]); double A = int.Parse(TA[1]);
            double[] inputH = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();

            double min = double.MaxValue;
            int ans = 0;
            for (int i = 0; i < N; i++)
            {
                double temperAve = T - inputH[i] * 0.006;
                if(Math.Abs(A-temperAve) < min)
                {
                    min = Math.Abs(A - temperAve);
                    ans = i +1;
                }

            }

            Console.WriteLine(ans);
        }
    }
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
using G=vector<vector<int>>;

int dp[10050];
int main(){
    int h,w;
    cin >> h >> w;
    vector<int> grid(h*w);
    rp(i,h*w){
        char ch;
        cin >> ch;
        if(ch=='#') grid[i]=1;
        if(ch=='.') grid[i]=0;
    }
    fill(dp,dp+h*w,10000000);
    dp[0]=grid[0];
    for(int i=1; i<h*w; i++){
        if(i%w){
            if(grid[i-1]==0&&grid[i]==1) dp[i]=min(dp[i],dp[i-1]+1);
            else dp[i]=min(dp[i],dp[i-1]);
        }
        if(i>=w){
            if(grid[i-w]==0&&grid[i]==1) dp[i]=min(dp[i],dp[i-w]+1);
            else dp[i]=min(dp[i],dp[i-w]);
        }
    }
    cout << dp[h*w-1] << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

pll pc[15];

vector<vector<int>> s;
int D;
bool c = false;
ll sum = 0;
ll sumI = 0;
ll n;

inline void dfs(vector<int> v)
{
	if (v.size() == D)
	{
		s.push_back(v);
		return;
	}
	IREP(i, D - 1)
	{
		c = false;
		REP(j, v.size())
		{

			if (v[j] == i)
			{
				c = true;
				break;
			}
		}
		if (c)continue;

		v.push_back(i);
		dfs(v);
		v.pop_back();
	}
	return;
}

int main()
{

	ll G;
	cin >> D >> G;
	vector<ll> v(D);//! 全部解いたら何点？
	ll t = 1;
	REP(i, D)
	{
		t *= (i + 1);
		cin >> pc[i].first >> pc[i].second;
		v[i] = (i + 1) * pc[i].first * 100 + pc[i].second;
	}

	vector<int> tmp;
	dfs(tmp);


	ll ans = INF;

	REP(i, s.size())
	{
		sum = 0;
		sumI = 0;
		REP(j, D)
		{
			int index = s[i][j];
			ll n = (G - sum + 100 * (1 + index) - 1) / (100 * (1 + index));
			if (n < pc[index].first)
			{
				sum += 100 * (1 + index)*n;
				sumI += n;
			}
			else
			{
				sum += v[index];
				sumI += pc[index].first;
			}
			if (sum >= G)
			{
				ans = std::min(ans, sumI);
				break;
			}
			if (ans <= sumI)
			{
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    string st;
    cin >> st;
    
    int ud = 0, lr = 0;
    rep(i, n) {
        if ('A' <= st[i] && st[i] <= 'M') {
            ud++;
        } else if ('N' <= st[i] && st[i] <= 'Z') {
            ud--;
        } else if ('a' <= st[i] && st[i] <= 'm') {
            lr++;
        } else if ('n' <= st[i] && st[i] <= 'z') {
            lr--;
        }
    }

    string ans = "";
    if (ud < 0) {
        rep(i, -ud) {
            ans += "N";
        }
    } else {
        rep(i, ud) {
            ans +="A";
        }
    }

    if (lr < 0) {
        rep(i, -lr) {
            ans += "n";
        }
    } else {
        rep(i, lr) {
            ans += "a";
        }
    }

    cout << ans.size() << endl;
    cout << ans << endl;

    return 0;
}



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

const int kMod = 1'000'000'000 + 7;

int main() {
    int n; scanf("%d", &n);
    int c[3] = {0, 0, 0}, ans = 1;
    for (int i = 0; i < n; ++i) {
        int a, v = 0; scanf("%d", &a);
        for (int j = 0; j < 3; ++j) v += c[j] == a;
        ans = 1LL * ans * v % kMod;
        for (int j = 0; j < 3; ++j) {
            if (c[j] == a) {
                c[j]++;
                break;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define N 100005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
int h,w,k;
string s[15];
main()
{
    fast;
    cin>>h>>w>>k;
    for(int i=0;i<h;i++)
        cin>>s[i];
    int ans=1e9;
    for(int mask=0;mask< (1<<(h-1));mask++)
    {
        vector<int>v;
        int mp[h];
        int c=0;
        for(int i=0;i<=h-1;i++)
        {
            mp[i]=c;
            if(mask&(1<<i))
            {
                v.push_back(i);
                c++;
            }
        }
        int cut=0;
        vector<int>sum(v.size()+1);
        fill(sum.begin(),sum.end(),0);
        bool f=false;
        for(int i=0;i<w;i++)
        {
            vector<int>now(v.size()+1);
            fill(now.begin(),now.end(),0);
            for(int j=0;j<h;j++)
            {
                now[mp[j]]+=(s[j][i]=='1');
                if(now[mp[j]]>k)
                    f=true;
            }
            if(f)
                break;

            for(int i=0;i<now.size();i++)
            {
                sum[i]+=now[i];
                if(sum[i]>k)
                {
                    cut++;
                    sum=now;
                    break;
                }
            }

        }
        if(!f)
            ans=min(ans,cut+(int)v.size());
    }
    cout<<ans;
}


Measured memory_bytes: 384
n=int(input())

t1=2
comb=set()
while t1*t1<=n:
    if n%t1==0:
        t2=n//t1

        m=t1-1
        if t2==n%m:
            comb.add(m)
        m=t2-1
        if t1==n%m:
            comb.add(m)
    t1+=1

if n>2:
    print(sum(comb)+n-1)
else:
    print(sum(comb))

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

int main(){
	while(1){
		int x, y;
		cin >> x >> y;
		if(x==0 && y==0) break;
		
		if(x>y){
			int tmp = x;
			x = y;
			y = tmp;
		}
		cout << x << " " << y <<endl;
	}
}


Measured memory_bytes: 3024
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int>v(n, 0);
	deque<pair<int, int>>deq;
	deq.push_front(make_pair(1, 1));
	while (!deq.empty()) {
		auto mon = deq.front();
		deq.pop_front();
		if (v[mon.first] > 0) continue;
		v[mon.first] = 1;
		if (mon.first == 0) {
			cout << mon.second << endl;
			return 0;
		}
		deq.push_front(make_pair((mon.first * 10) % n, mon.second));
		deq.push_back(make_pair((mon.first + 1) % n, mon.second + 1));
	}
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <cmath>
#include <math.h>
#include <ctime>
#include <cstring>
#include <climits>
#include <sstream>
#include <array>
#include <tuple>
#include <set>
#include <iterator>
#include <cstdio>
#include <string>
#include <stack>
#include <valarray>
#include <utility>
#include <iomanip>
#include <list>
#include <numeric>
#include <regex>
#include <map>
#include <queue>
#include <deque>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll          long long
#define PI          3.1415926535
#define pb          push_back
#define ins         insert
#define INF         LLONG_MAX
#define mk          make_pair
#define lb(v,x)     lower_bound(all(v),x)
#define ub(v,x)     upper_bound(all(v),x)
#define ff          first
#define ss          second
#define rev         reverse
#define uset        unordered_set
#define umap        unordered_map
#define endl        "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a)       (ll)a.size()
#define double      long double
#define minpq       priority_queue <ll,vector<ll>,greater<ll> > 
#define fill(x,y)   memset(x,y,sizeof(x))
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define MOD         1000000007 //1e9+7
#define bp(n)       __builtin_popcountll(n)
#define mxt(a)      *(max_element(a.begin(),a.end()))
#define mnt(a)      *(min_element(a.begin(),a.end())
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define rep(i, a, b) for(ll i = (a); i<= (b); ++i)
#define trav(a, x) 	 for(auto &a : x)
#define re(i,n)      for(ll i = 0; i < n; ++i) 
const ll N = 2e5 + 7;
typedef pair<ll,ll>   pii;
typedef vector<pii>   vpii;
typedef vector<ll>    vll;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
template<typename T> T gcd(T a,T b){ if(a==0) return b; return gcd(b%a,a); }
template<typename T> T powm(T a,T b, ll m){T cnt=1; while(b>0){ if(b%2==1) cnt=(cnt*a)%m; b/=2; a=(a*a)%m; }return cnt%m;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
ll sqr(ll x) { return x * x;}
// always use 1ll*ans to avoid signed integer overflow; 
void prec(){

}
void solve(){
	string s,t;
	cin>>s;
	cin>>t;
	if(t.substr(0,sz(s))==s) cout<<"Yes\n";
	else cout<<"No\n";
}

int main()
{
    ios;
    int tc=1;
    //cin>>tc;
    prec();
    while(tc--)
    	solve();
    return 0; 
}


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

int main(){
    int n,m,l;
    scanf("%d %d %d",&n,&m,&l);
    int A[n][m],B[m][l];
    long long int C[n][l];
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            C[i][j] = 0;
        }
    }
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			scanf("%d",&A[i][j]);
		}
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<l;j++){
			scanf("%d",&B[i][j]);
		}
	}
    for(int i=0;i<n;i++){
        for(int k=0;k<l;k++){
            for(int j=0;j<m;j++){
                C[i][k] += A[i][j]*B[j][k];
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int k=0;k<l-1;k++){
            printf("%lld ",C[i][k]);
        }
        printf("%lld\n",C[i][l-1]);
    }
}


Measured memory_bytes: 2824
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        long count = 0;
        String words[] = new String[n];
        
        for(int i = 0; i < n; i++){
            String s = stdIn.next();
            char c[] = s.toCharArray();
            Arrays.sort(c);
            words[i] = String.valueOf(c);
        }
        
        Arrays.sort(words);
        
        for(int i = 0; i < n - 1; i++){
            int num = 0;
            for(int j = i + 1; j < n; j++){
                if(words[i].equals(words[j])){
                    count++;
                    num++;
                }else{
                    break;
                }
            }
            
            if(num != 0){
                for(int j = num - 1; j >= 1; j--){
                    count = count +  j; 
                }
                i += num;
            }
        }
        
        System.out.println(count);
    }
}


Measured memory_bytes: 51904
#include <iostream>
#include <stdio.h>

using namespace std;
typedef long long int lint;

void answer()
{
	int n, m;
	cin >> n >> m;

	int** mat = new int*[n];
	for (int i = 0; i < n; i++) mat[i] = new int[m];

	int* vec = new int[m];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> mat[i][j];
		}
	}
	for (int j = 0; j < m; j++) {
		cin >> vec[j];
	}

	int sum;
	for (int i = 0; i < n; i++) {
		sum = 0;
		for (int j = 0; j < m; j++) {
			sum += mat[i][j] * vec[j];
		}
		cout << sum << endl;
	}

}

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

Measured memory_bytes: 1228
n,m=map(int,input().split())
l=list(map(int,input().split()))
ans=[1]*n
for i in range(m):
    a,b=map(int,input().split())
    if l[a-1]<l[b-1]:
        ans[a-1]=0
    elif l[a-1]>l[b-1]:
        ans[b-1]=0
    else:
        ans[a-1]=0
        ans[b-1]=0
print(sum(ans))


Measured memory_bytes: 20024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  for(auto& s : S){
    cin >> s;
  }
  sort(S.begin(), S.end());
  for(auto& s : S){
    cout << s;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
p_trump = [a + ' {}'.format(b) for a in ['S', 'H', 'C', 'D'] for b in range(1, 14)]
n = int(input())
trumps = []
for i in range(n):
    trumps.append(input())
for i in p_trump:
    if not i in trumps:
        print(i)



Measured memory_bytes: 5600
#include <iostream>

#define MAX 100005
#define NIL -1

using namespace std;

struct Node
{
    int parent;
    int depth;
    int left;
    int right;
};

struct Node T[MAX];
int n;

int rec(int u, int p){
    T[u].depth = p;
    if(T[u].right != NIL) rec(T[u].right, p);
    if(T[u].left != NIL) rec(T[u].left, p+1);
}

void printNode(int u){
    int i,c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "depth = " << T[u].depth << ", ";

    if(T[u].parent == NIL) cout << "root, ";
    else  if(T[u].left == NIL) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";
    for(i=0, c = T[u].left; c!=NIL; ++i, c=T[c].right){
        if(i) cout << ", ";
        cout << c;
    }

    cout << "]" << endl;

}

int main(){
    int d,v,c,l,r;
    cin >> n;
    for(int i=0; i<n; ++i) T[i].parent = T[i].left = T[i].right = NIL;

    for(int i=0; i<n; ++i){
        cin >> v >> d;
        for(int j=0; j <d; ++j){
            cin >> c;
            if(j==0) T[v].left = c;
            else T[l].right = c;
            l = c;
            T[c].parent = v;
        }
    }
    for(int i = 0; i<n;++i){
        if(T[i].parent == NIL) r = i;
    }

    rec(r,0);

    for(int i=0; i<n; ++i) printNode(i);

    return 0;

}


Measured memory_bytes: 7776