akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int , input().split()))
b = [0] * n
for i in reversed(range(1, n+1)):
    tmp = 0
    for j in range(2 * i, n+1, i):
        tmp += b[j-1]
    if tmp % 2 == 1 and a[i-1] == 1:
        b[i-1] = 0
        #print(-1)
        #exit()
    if tmp % 2 == 1 and a[i-1] == 0:
        b[i-1] = 1
    if tmp % 2 == 0 and a[i-1] == 1:
        b[i-1] = 1
    if tmp % 2 == 0 and a[i-1] == 0:
        b[i-1] = 0
#print(b)
print(sum(b))
ans = []
for i in range(n):
    if b[i] == 1:
        ans.append(i+1)
print(' '.join(map(str, ans)))

#    print(i, list(range(2 * i, n+1, i)))

    #for j in range(2 * i, n+1, i):



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

int main() {
    string s, p;

    getline(cin, s);
    getline(cin, p);
    s += s;
    if (s.find(p) == string::npos) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
    
    return 0;
}

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

int stack[1000];
int top = 0, bottom = 0;

void push(int value) {
    stack[++top] = value;
}

int pop(void) {
    return stack[top--];
}


int main() {
    char str[100];
    while (scanf("%s", str) != EOF) {
        switch (str[0]) {
            case '-': {
                int v1 = pop();
                int v2 = pop();
                push(v2 - v1);
                break;
            }
            case '+': {
                push(pop() + pop());
                break;
            }
            case '*': {
                push(pop() * pop());
                break;
            }
            default: {
                push(atoi(str));
                break;
            }
        }
    }
    printf("%d\n", pop());
    return 0;
}

Measured memory_bytes: 548
import math
A,B=map(int, input().split())
flag=False
for i in range(1250):
  A_X=math.floor(i*0.08)
  if(A_X==A):
    B_X=math.floor(i*0.10)
    if(B_X==B):
      print(i)
      flag=True
      break
if(flag==False):
  print(-1)

Measured memory_bytes: 38768
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REP1(i,n) for(int i=1;i<=(int)(n);i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;

void calc(ll N,int* ans,int count){
  N--;
  ans[count]=N%26;
  count++;
  if(N>25){
    calc(N/26,ans,count);
  }
}


int main(){
  ll N;
  cin >> N;
  vector<int> ans(15,100);
  int count=0;

  calc(N,&ans[0],count);

  reverse(ans.begin(),ans.end());
  REP(i,ans.size()){
    if(ans.at(i)<26){
      printf("%c",97+ans.at(i));
    }
  }
  cout << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int a[5];
    rep(i, 5) cin >> a[i];
    sort(a, a + 5);
    reverse(a, a + 5);
    int ans = 0;
    rep(i, 5)
    {
        int cost = max(10LL, a[i]);
        if (cost % 10 != 0)
            cost += 10 - cost % 10;
        ans += cost;
    }
    int tmp = 0;
    rep(i, 5)
    {
        if (a[i] % 10 == 0)
            continue;
        tmp = max(tmp, 10 - a[i] % 10);
    }
    ans -= tmp;
    cout << ans << endl;
}

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

#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int, int>>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int, int>
#define int long long int
#define inf INT_MAX
#define _inf INT_MIN
#define whilet int t;cin>>t;while(t--)
const int N = 100005;
const int mod = 1e9 + 7;

vi value(101);
vi weights(101);


int knapsack_2(int n, int w, int max_value) {

	int dp[n + 1][n * max_value + 1];

	for (int j = 0; j <= n * max_value; j++) dp[1][j] = inf;

	dp[1][value[1]] = weights[1];
	dp[1][0] = 0;

	for (int i = 2; i <= n; i++) {
		for (int j = 0; j <= n * max_value; j++) {
			dp[i][j] = dp[i - 1][j];
			if (j - value[i] >= 0 ) dp[i][j] = min( dp[i][j] , dp[i - 1][j - value[i]] + weights[i] );
		}
	}

	int res = 0;

	for (int j = 0; j <= n * max_value; j++) {
		if (dp[n][j] <= w) res = max(res, j);
	}
	return res;
}


void solve() {


	int n, w;
	cin >> n >> w;

	int max_value = 0;

	for (int i = 1; i <= n; i++) {
		cin >> weights[i] >> value[i];
		max_value = max(max_value , value[i]);
	}

	cout << knapsack_2( n,  w,  max_value);
}

void init() {
	ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("../input.txt", "r", stdin);
	freopen("../output.txt", "w", stdout);
#endif
}


int32_t main()
{
	init();
	// whilet solve();
	solve();
}

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


int main(){
    int n;
    cin>>n;
    int L[n];
    int cnt=0;
    for(int i=0;i<n;i++)cin>>L[i];
    int flag =1;
    while(flag){
        flag=0;
        for(int i=n-1;i>=1;i--){
        if(L[i]<L[i-1]){
            swap(L[i],L[i-1]);
            flag=1;
            }
        }
    }
    
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(L[i]!=L[j]&&L[j]!=L[k]){
                    if(L[j]-L[i]<L[k]&&L[k]<L[i]+L[j])cnt++;
                }
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}

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

int main() {
  int x,y,z,k;
  cin>>x>>y>>z>>k;
  vector<long> a(x);
  vector<long> b(y);
  vector<long> c(z);
  for (size_t i = 0; i < x; i++) {
    cin>>a[i];
  }
  for (size_t i = 0; i < y; i++) {
    cin>>b[i];
  }
  for (size_t i = 0; i < z; i++) {
    cin>>c[i];
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  
  vector<long> d;
  x--;y--;z--;
  for (int i = 0; i < min(k,x+1); i++) {
    for (int j = 0; j < min(k-i,y+1); j++) {
      d.push_back(a[x-i]+b[y-j]);
    }
  }
  int l = d.size()-1;
  sort(d.begin(), d.end());
  vector<long> e;
  for (int i = 0; i < min(k,l+1); i++) {
    for (int j = 0; j < min(k,z+1); j++) {
      e.push_back(d[l-i]+c[z-j]);
    }
  }
  sort(e.begin(), e.end());
  for (size_t i = 0; i < k; i++) {
    cout << e[e.size()-1-i] << endl;
  }
}

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

int A, B;

int main()
{
  cin >> A >> B;
  cout << A*B << endl;
}

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

#define ll long long
#define pp pair<int, int>
#define FOR(i, n) for(int i = 0; i < n; i++)
#define FORU(i, a, b, s) for(int i = a; i < b; i += s)
#define FORD(i, a, b, s) for(int i = a; i > b; i -= s)
#define endl "\n"

ll INF = 2e18;
ll MOD = 1e9 + 7;
int i, j, k;

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

Measured memory_bytes: 3628
#include<stdio.h>
int main(){
char S[10];
int i;
int a=0;
  int b=0;
  int count=0;
  int nagasa=0;
  int x=0;
  scanf("%s",S);
  for(i=0;i<11;i++){

    if(count==0){
   if(S[i]=='A'||S[i]=='T'||S[i]=='C'||S[i]=='G'){
     a=i;
     count++;
   }
  }
    else if(count==1){
     if(S[i]!='A'&&S[i]!='T'&&S[i]!='C'&&S[i]!='G'){
       b=i;
       count=0;
       nagasa=b-a;
       if(x<nagasa)
         x=nagasa;
     }
    }
  }
   if(x<nagasa)
         x=nagasa;
    printf("%d",x);
return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
    int N, X, T;
    cin >> N >> X >> T;
    int minutes;
    if (N % X == 0) {
        minutes = (N / X) * T;
    } else {
        minutes = (N / X + 1) * T;
    }
    cout << minutes << endl;
}

Measured memory_bytes: 3532
a, b, c, k = map(int, input().split())

# ak = (2 * (2**(k-1) + (-1)**k) // 3)
# bk = ((2**k - (-1)**k) // 3)
# ans = int((ak*a + bk*b) - (bk*a + ak*b))

if k % 2 == 0:
    ans = a-b
else:
    ans = -(a-b)
if ans <= 10**18:
    print(ans)
else:
    print('Unfair')


Measured memory_bytes: 2940
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int H, W, K;
	cin >> H >> W >> K;

	vector <string> c(H);
	for (int ii = 0; ii < H; ++ii){
		cin >> c[ii];
	}

	int ans = 0;
	for (int n = 0; n < (1<<H); ++n){
		bitset< 1<<6 > bs1(n);
		for (int m = 0; m < (1<<W); ++m){
			bitset< 1<<6 > bs2(m);

			int cnt = 0;
			for (int ii = 0; ii < H; ++ii){
				if (bs1[ii]) continue; 
				for (int jj = 0; jj < W; ++jj){
					if (bs2[jj]) continue;
					if (c[ii][jj] == '#') cnt++;
				}
			}

			if (cnt == K){
				ans++;
			}
		}
	}

	cout << ans << "\n";

	return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> B(N-1);
    for(int i = 0;i < N-1;i++){
        cin >> B[i];
    }
    int sum = B[0]+B[N-2];
    for(int i = 1;i < N-1;i++){
        sum += min(B[i],B[i-1]);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
matrix = [input() for i in range(H)] 
ans = ""  
for h in range(H):
        for w in range(W):
                bomb = 0 
                for i in range(-1, 2): 
                        if 0 <= h - 1 and 0 <= w + i < W:
                                if matrix[h - 1][w + i] == "#":
                                        bomb += 1
                        if h + 1 < H and 0 <= w + i < W:
                                if matrix[h + 1][w + i] == "#":
                                        bomb += 1
                for i in range(-1, 2, 2): 
                        if 0 <= w + i < W:
                                if matrix[h][w + i] == "#":
                                        bomb += 1
                if matrix[h][w] == "#":
                        ans += "#" 
                else:
                        ans += str(bomb)
                if W - 1 > 0:
                        if w % (W - 1) == 0 and w != 0:
                                ans += "\n"
                else:
                                ans += "\n"
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 1
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll


signed main(){
  int n,m; cin>>n>>m;
  
  int ans=-1;
  for(int i=1; i*i<=m; i++){
    if(m%i) continue;
    int c=m/i;
    if(c>=n) ans=max(ans,i);
    if(i>=n) ans=max(ans,c);
  }
  cout<<ans<<en;
}



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

struct StCity
{
  StCity() : m_nPref(0), m_nYear(0) { }

  int m_nPref;
  int m_nYear;
};

void fnInput(int& rnPrefSiz, vector<StCity>& rvoCity)
{
  int nCitySiz;
  cin >> rnPrefSiz >> nCitySiz;
  rvoCity.resize(nCitySiz);

  for (StCity& roCity : rvoCity)
  {
    cin >> roCity.m_nPref >> roCity.m_nYear;
    --roCity.m_nPref;
  }
}

void fnIdNum(int nPrefSiz, const vector<StCity>& cnrvoCity)
{
  vector<vector<int>> vvnCity(nPrefSiz);
                                           // vvnCity[ nPref ] に nYear を保存 
  for (int i = 0; i < cnrvoCity.size(); ++i)
    vvnCity[ cnrvoCity[i].m_nPref ].push_back( cnrvoCity[i].m_nYear );

  for (int i = 0; i < vvnCity.size(); ++i)
  {                                        // vvnCity[ nPref ] 毎に nYear を昇順に sort
    sort( begin(vvnCity[i]), end(vvnCity[i]) );
                                           // vvnCity[ nPref ] 毎に nYear の重複を除く
    vvnCity[i].erase( unique( begin(vvnCity[i]), end(vvnCity[i]) ), end(vvnCity[i]) );
  }

  for (int i = 0; i < cnrvoCity.size(); ++i)
  {
    int nPref = cnrvoCity[i].m_nPref;
    cout << setfill('0') << setw(6) << nPref + 1;
                   // nYear で sort済の vvnCity[ nPref ] に対して、求める nYear を二分索引して
                   // イテレータを算出し、vvnCity[ nPref ]の begin イテレータを削除し、
                   // nYear が小さい方から何番目かを取得する
    int nIdNum = lower_bound( begin( vvnCity[ nPref ] ), end( vvnCity[ nPref ] ), 
                              cnrvoCity[i].m_nYear ) - begin( vvnCity[ nPref ] ); 
    cout << setfill('0') << setw(6) << nIdNum + 1 << endl;
  }
}
  
int main()
{
  int nPrefSiz;
  vector<StCity> voCity;
  
  fnInput(nPrefSiz, voCity);
  fnIdNum(nPrefSiz, voCity);

  return 0;
}

Measured memory_bytes: 9428
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cstdio>
using namespace std;

struct Node {
	Node() {
		id = 0;
		parent = -1;
		depth = 0;
		degree = 0;
		left = -1;
		right = -1;
		height = 0;
		sibling = -1;
	}
	vector<int> children;
	int id;
	int parent;
	int depth;
	int sibling;
	int degree;
	int height;
	int left;
	int right;
};

void calc_dep(Node node[], int root) 
{
	for(int i = 0; i < node[root].degree; i++) {
		node[node[root].children[i]].depth = node[root].depth+1;
		calc_dep(node, node[root].children[i]);
	}

}

void calc_height(Node node[], int height, int parent)
{
	node[parent].height = max(node[parent].height, height+1);
	if(node[parent].parent != -1) {
		calc_height(node, height+1, node[parent].parent);
	}
}

int main() {
	Node node[100];
	
	int input_id, left, right;
	int n;
	cin >> n;

	for(int i = 0; i < n; i++) {
		scanf("%d", &input_id);
		scanf("%d", &left);
		scanf("%d", &right);
		//int degree = 0;
		if(right != -1) {
			node[input_id].degree++;
			node[input_id].right = right;
			node[right].parent = input_id;
			node[input_id].children.push_back(right);
			if(left != -1) {
				node[right].sibling = left;
			}
		}

		if(left != -1) {
			node[input_id].degree++;
			node[input_id].left = left;
			node[left].parent = input_id;
			node[input_id].children.push_back(left);
			if(right != -1) {
				node[left].sibling = right;
			}
		}
	//	cout << "input " << input_id << " " << "node.deg " << node[input_id].degree << endl;	
		//node[input_id].degree = degree;
	}
	

	int find_root = 0;
	for(find_root = 0; find_root < n; find_root++) {
	//	cout << node[find_root].parent << endl;
		if(node[find_root].parent == -1) {
			break;
		}
	}
	
	if(n > 1) {
		calc_dep(node, find_root);

		for(int i = 0; i < n; i++) {
			if(node[i].degree == 0) {
				calc_height(node, 0, node[i].parent);
			}
		}
	}

	for(int i = 0; i < n; i++) {
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,", i, node[i].parent, node[i].sibling, node[i].degree, node[i].depth, node[i].height);		if(node[i].parent == -1) {
			cout << " root\n";
		}
		else if(node[i].degree == 0) {
			cout << " leaf\n";
		}
		else {
			cout << " internal node\n";
		}
	}


	return 0;
}




Measured memory_bytes: 3232
N, L = map(int, input().split())

res = []
ans = 0

for i in range(N):
    res.append(L+i)
    ans += L + i

if max(res)<0:
    eaten = max(res)
elif min(res)>0:
    eaten = min(res)
else:
    eaten = 0

print(ans - eaten)


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void Main(){
    int N; cin >> N;
    bool a[N];
    REP(i,N){
        int d1,d2; cin >> d1 >> d2;
        a[i] = d1 == d2;
    }

    REP(i,N-2){
        if(a[i] && a[i+2] && a[i+1]){
            cout << "Yes" << en;
            return;
        }
    }
    cout << "No" << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3660
#include <cstdio>
#include <cstring>

const int maxn = 10 + 3;
char arr[maxn];

int main() {
  //freopen("input.txt", "r", stdin);
  memset(arr, 0, sizeof(arr));
  while (~scanf("%s", arr)) {
    bool yes = false;
    for (int i = 0; i < strlen(arr); i++)
      if (arr[i] == '7') {
        yes = true; break;
      }
    yes ? puts("Yes") : puts("No");
    memset(arr, 0, sizeof(arr));
  }
  return 0;
}


Measured memory_bytes: 1644
n = int(input())
p = list(map(int, input().split()))
i = 1
cnt = 0
while i < len(p) - 1:
  l = sorted([p[i - 1], p[i], p[i + 1]])
  if l[1] == p[i]:
    cnt += 1
  i += 1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
int n, x, y;
ll sum;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n, y = INT_MAX;
    for(int i = 0;i < n - 1;++i)
        cin >> x, sum += min(x, y), y = x;
    cout << sum + x;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
long long ans;
char a[12];
map<string,int>mp;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%s",a);
		sort(a,a+10);
		ans+=mp[a];
		mp[a]++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 11136
#include <stdio.h>
#include <stdlib.h>
int fw(const void *a, const void *b)
{
    return *(long int *)a - *(long int *)b;
}
int bw(const void *a, const void *b)
{
    return *(long int *)b - *(long int *)a;
}
int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    if (b == 1)
    {
        printf("0");
    }
    else
    {
        printf("%d", a - b);
    }
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  if(s.find('7') != string::npos) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

using namespace std;

#define LL long long

int main() {
    // freopen("a.txt", "r", stdin);
    int mod = 998244353;
    int N, S, res = 0;
    cin >> N >> S;

    vector<int> A(N + 1, 0);
    for(int i = 1; i <= N; ++i) cin >> A[i];

    vector<int > dp(S+1, 0);
    for(int i = 1; i <= N; ++i) {
        for(int j = S; j >= A[i]; --j) dp[j] = (dp[j] + dp[j - A[i]]) % mod;
        if(S>=A[i]) dp[A[i]] = (dp[A[i]] + i) % mod;
        res = (res + 1ll * dp[S] * (N - i + 1)) % mod;
        dp[S] = 0;
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Iterator;
import java.util.Stack;

public class Main {

	public static void main(String[] args) throws IOException {
		
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));		
		String profile = reader.readLine();
		
		Stack<Integer> stackDown = new Stack<Integer>();
		Stack<Integer> stackArea = new Stack<Integer>();
		Stack<Integer> stackEdge = new Stack<Integer>();
		int totalArea = 0;
		int pos = 0;
		int lv = 0;
		
		for (char c : profile.toCharArray()) {
			if (c == '\\') {
				lv--;
				stackDown.push(pos);
			} else if (c == '/') {
				lv++;
				if (!stackDown.empty()) {
					int start = stackDown.pop();
					int tempArea = pos - start;
					totalArea += tempArea;
					if (stackArea.empty()) {
						stackArea.push(tempArea);
						stackEdge.push(lv);
					} else {
						int lastArea = 0;
						while (!stackEdge.empty() && stackEdge.peek() < lv) {
							lastArea += stackArea.pop();
							stackEdge.pop();
						}
						stackArea.push(lastArea + tempArea);
						stackEdge.push(lv);
					}
				} else {
					if (!stackArea.empty()) {
						stackEdge.pop();
						stackEdge.push(lv);
					}
				}
			}
			pos++;
		}

		System.out.println(totalArea);
		System.out.print(stackArea.size());
		if (stackArea.size() != 0) {
			System.out.print(" ");
		}
		Iterator<Integer> itr = stackArea.iterator();
		while (itr.hasNext()) {
			System.out.print(itr.next());
			if (itr.hasNext()) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	}
}



Measured memory_bytes: 26292
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int MO=998244353;
int n,m;
LL ans,fac[3000010],inv[3000010];
LL pw(LL x,LL y){
	LL t=1;
	for (;y;y>>=1){
		if (y&1) t=t*x%MO;
		x=x*x%MO;
	}
	return t;
}
LL C(int x,int y){
	return fac[x]*inv[y]%MO*inv[x-y]%MO;
}
int main(){
	fac[0]=1;
	FOR(i,1,3000000) fac[i]=fac[i-1]*i%MO;
	inv[3000000]=pw(fac[3000000],MO-2);
	FORD(i,2999999,0) inv[i]=inv[i+1]*(i+1)%MO;
	cin>>n>>m;
	ans=C(m*3+n-1,n-1);
	(ans-=1ll*n*C(m+n-2,n-1))%=MO;
	FOR(i,m+1,n) if ((m*3-i>=0) && (m*3-i)%2==0) (ans-=C(n,i)*C((m*3-i)/2+n-1,n-1))%=MO;
	ans=(ans%MO+MO)%MO;
	cout<<ans<<endl;
	return 0;
}

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

struct TCard
{
	int Number;
	char Mark;
    bool operator<(const TCard& Y)const;
	bool operator<=(const TCard& Y)const;
    bool operator==(const TCard& Y)const;
};

bool TCard::operator<(const TCard& Y)const
{
	return Number < Y.Number;
}

bool TCard::operator<=(const TCard& Y)const
{
	return Number <= Y.Number;
}

bool TCard::operator==(const TCard& Y) const
{
	return Mark == Y.Mark;
}

int Partition(vector<TCard>& A, int p, int r)
{
	int i = p-1;
	for(int j = p; j < r; j++){
		if(A[j] <= A[r]){
			i++;
			swap(A[i], A[j]);
		}
	}
	swap(A[i+1], A[r]);
	return i+1;
}

void QuickSort(vector<TCard>& A, int p, int r)
{
	if(p < r){
		int q = Partition(A, p, r);
		QuickSort(A, p, q-1);
		QuickSort(A, q+1, r);
	}
}

int main()
{
	int n;
	cin >> n;
	vector<TCard> A(n);
	for(int i = 0; i < n; i++){
		cin >> A[i].Mark >> A[i].Number;
	}
	vector<TCard> B = A;
	std::stable_sort(B.begin(), B.end());
	QuickSort(A, 0, n-1);
	if(A == B){
		cout << "Stable" << endl;
	}else{
		cout << "Not stable" << endl;
	}
	for(int i = 0; i < n; i++){
		cout << A[i].Mark << ' ' << A[i].Number << endl;
	}
	return 0;
}

Measured memory_bytes: 4748
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int n,k,q,cnt[100001],i,a;
	scanf("%d %d %d",&n,&k,&q);
	for(i=1;i<=n;i++)	cnt[i]=0;
	for(i=0;i<q;i++)	{
		scanf("%d",&a);
		cnt[a]++;
	}
	for(i=1;i<=n;i++)	{
		if(k-q+cnt[i]>0)	{
			printf("Yes\n");
		}
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 896
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const double PI = acos(-1.0);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> A(N),B(N);
    rep(i,N) cin >> A[i] >> B[i];

    ll val = 1e18;
    rep(i,N) {
        if (A[i] > B[i]) chmin(val,B[i]); 
    }
    if (val == 1e18) {
        cout << 0 << ln;
    } else {
        cout << accumulate(all(A),-val) << ln;
    }
}


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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SIZE(x) ((ll)(x).size()) 
#define MAX(x) *max_element(ALL(x)) 
#define MIN(x) *min_element(ALL(x)) 
#define ALL(x) (x).begin(),(x).end() 

#define INF 1000000000000 
#define MOD 1000000007 
#define MAXR 100000 

#define PB push_back 
#define MP make_pair 
#define F first 
#define S second 

ll gcd(ll a, ll b)
{
   if (a%b == 0){
       return(b);
   }else{
       return(gcd(b, a%b));
   }
}

bool is_prime(ll n){
    int a = sqrt(n);
    if(n == 1 || n == 2 || n == 3) return true;
    else{
        bool frag = true;
        FOR(i, 2, a+1){
            if(n % i == 0) frag = false;
        }
        return frag;
    }
}


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(200005);
    REP(i, n) cin >> a[i];
    int b = a[0];
    FOR(i, 1, n) b = b ^ a[i];
    vector<int> c;
    REP(i, n) c.PB(a[i] ^ b);
    REP(i, n) cout << c[i] << " ";
}

Measured memory_bytes: 4948
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long unsigned int ull;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
    string T;
    cin >> T;
    // char t1,t2;
    // t1 = T[0];
    // if(T.length()==1){
    //     if(t1=='?'){
    //         cout << 'P' << endl;
    //     }else{
    //         cout << t1 << endl;
    //     }
    //     return 0;
    // }
    // t2 = T[1];
    // if(T.length()==2){
    //     if(t1=='?'){
    //         if(t2== '?'){
    //             cout << "PD" << endl;
    //         }else if(t2=='P'){
    //             cout << 'D' << t2 << endl;
    //         }else{
    //             cout << 'P' << t2 << endl;
    //         }
    //     }else if(t2 == '?'){
    //         cout << t1 << 'D' << endl;
    //     }else{
    //         cout << T << endl;
    //     }
    //     return 0;
    // }
    for (int i = 0; i < T.length(); i++)
    {
        if(T[i]=='?'){
            T[i] = 'D';
        }
    }
    
    // if(t1=='?'){
    //     T[0] = 'P';
    // }
    // for (int i = 1; i < T.length(); i++)
    // {
    //     t2 = T[i];
    //     if(t2 =='?'){
    //         if(t1=='P'){
    //             T[i] = 'D';
    //         }else{
    //             if(i<T.length()-1){
    //                 char t3 = T[i+1];
    //                 if(t3=='D'){
    //                     T[i] = 'D';
    //                 }else{
    //                     T[i] = 'D';
    //                 }
    //             }else{
    //                 T[i] = 'D';
    //             }
    //         }
    //     }
    //     t1 = T[i];
    // }
    cout << T << endl;
}

Measured memory_bytes: 3756
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    
    long ans = 0;
    int bit = 1 << S.length()-1;
    for (int i = 0; i < bit; i++) {
      ans += solve(S, i);
    }
    
    System.out.println(ans);
  }
  
  private static long solve(String s, int bit) {
    long sum = 0;
    long a = 0;
    for (int i = 0; i < s.length(); i++) {
      a = a*10 + (s.charAt(i)-'0');
      if ((bit>>i)%2 == 1) {
        sum += a;
        a = 0;
      }
    }
    sum += a;
    return sum;
  }
}

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

const long long mod = 1e9 + 7;
long long power(long long x, long long y)
{
	long long res = 1;
  	x %= mod;
  	if(x == 0) return 0;
  	while(y)
    {
     	if(y&1) res = res * x % mod;
      	y = y >> 1;
      	x = x * x % mod;
    }
  	return res % mod;
}

int main()
{
  	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 	long long n;
  	cin >> n;
  	
  	cout << (((power(10LL, n) - ((2LL * power(9LL, n)) % mod)) % mod) + power(8LL, n) + mod) % mod;
}

Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll, ll> lltpl;



/******************************************************************************************/


const ll MOD = 1e9 + 7;
int dp[45][1 << 18];

int main() {

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

	ll n, x, y, z;
	cin >> n >> x >> y >> z;


	ll ng = 1LL << z;
	ng |= (1LL << (y + z));
	ng |= (1LL << (x + y + z));
	

	ll mask = (1LL << (x + y + z + 1)) - 1;

	dp[0][1] = 1;

	for (ll i = 0; i < n; i++)
	{
		for (ll now = 0; now <= mask; now++)
		{
			//前の状態
			for (ll j = 1; j <= 10; j++)
			{
				int next = ((now << j) & mask) + 1;
				if ((next & ng) == ng) continue;
				dp[i + 1][next] += dp[i][now];
				dp[i + 1][next] %= MOD;


			}
		}
	}

	ll ans = 1LL;
	for (int i = 0; i < n; i++) {
		ans *= 10;
		ans %= MOD;
	}

	for (int i = 0; i < mask; i++) {
		ans -= dp[n][i];
		ans %= MOD;
	}

	if (ans < 0) {
		ans = (ans + MOD) % MOD;
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 42240
#include <bits/stdc++.h>
using namespace std;
const int N = 100 + 10;
char s[N];
int a[N];
int f[N][2][4];
int dfs(int pos,int up,int k){
    if(k<0) return 0;
    if(pos==-1) return k==0;
    int &ans = f[pos][up][k];
    if(ans!=-1) return ans;
    ans = 0;
    for(int i=0;i<=(up?a[pos]:9);i++){
        ans += dfs(pos-1,up&&i==a[pos],k-(!!i));
    }
    return ans;
}
int main(){
    int k; cin>>s>>k;
    int len = strlen(s);
    for(int i=0;i<len;i++) a[i] = s[len-i-1]-'0';
//    for(int i=0;i<len;i++) cout<<a[i]<<' '; cout<<endl;
    memset(f,-1,sizeof(f));
    cout<<dfs(len-1,1,k)<<endl;
}


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

int main() {
  int N;
  cin>>N;
  
  vector<int> t(N+1);
  vector<int> x(N+1);
  vector<int> y(N+1);
  
  t[0]=x[0]=y[0]=0;
  
  for(int i=1;i<=N;i++){
    cin>>t[i]>>x[i]>>y[i];
  }
  
  bool flag=true;
  for(int i=0;i<N;i++){
    int tmp=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
    int tmp2=(t[i+1]-t[i])-tmp;
    if(tmp2<0||tmp2%2==1){
       flag=false;
       break;
    }
  }
  cout<<(flag?"Yes":"No")<<endl;
}



Measured memory_bytes: 1408
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n,m;
    cin >> n >> m;
    if(m <= 2*n) cout << m/2 << endl;
    else cout<< (2*n +m)/4<<endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
/* author:hellojim */
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int n,m;
bool used[100100];
vector<int>v[100100];
void dfs(int now)
{
	used[now]=1;
	rep(i,v[now].size())
		if(!used[v[now][i]])dfs(v[now][i]);
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	cin>>n>>m;
	rep(i,m)
	{
		int x,y;
		cin>>x>>y;
		x--,y--;
		v[x].pb(y);
		v[y].pb(x);
	}
	int ans=-1;
	rep(i,n)
	{
		if(!used[i])
		{
			ans++;
			dfs(i);
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 9716
#include<stdio.h>

int main(void)
{
  int i,j,x,xx,y,yy,s,S,S1;

  while(1)
    {
      scanf("%d%d%d",&x,&y,&s);
      if(x==0 && y==0 && s==0) break;
      S1=0;
      for(i=1;i<=s-1;i++)
	{
	  xx=i*(100+x)/100;
	  for(j=s-1 ; j>=1; j--)
	    {
	      yy=j*(100+x)/100;
	      if(xx+yy==s)
		{
	          S=i*(100+y)/100+j*(100+y)/100;
	          if(S>=S1)
	            {
	              S1=S;
	            }	    
	        }
	    }
	}
      printf("%d\n",S1);
    }
  return 0;
}

Measured memory_bytes: 600
x1, x2, x3, x4, x5 = map(int, input().split())

if x1 == 0:
    print(1)
elif x2 == 0:
    print(2)
elif x3 == 0:
    print(3)
elif x4 == 0:
    print(4)
elif x5 == 0:
    print(5)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){	
	ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    int n;
	    cin >> n;
	    string s;
	    cin >> s;
	    if(s.size() % 2)
	    {
	    	
	    	cout << "No" << endl;
	    	return 0;
	    }
	    for(int i = 0 ; i < s.size()/2 ; i++){
	    	if(s[i] != s[i + (s.size()/2)]){
	    		cout << "No" << endl;
	    		return 0;
	    	}
	    }
	    cout << "Yes" << endl;
		return 0; 
}

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

int main(){

	int num[30];
	int n[2];
	int c = 0;
	num[28] = num[29] = 40;
	for(int i = 0; i < 28; i++){
		cin >> num[i];
	}
	sort(num, num+30);
	
	for(int i = 0; i < 30; i++){
		if(num[i] != i+1){
			c == 0 ? num[28] = i+1 : num[29] = i+1;
			n[c] = i+1;
			c++;
			sort(num, num+30);
		}
	}
	
	for(int i = 0; i < 2; i++){
		cout << n[i] << endl;
	}
	
	return 0;
}

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

vector<int> edges[100001];
int n,m;
bool *visited = new bool[100001]();

void dfs(int ind){
	
	visited[ind] = true;
	for(int i=0;i<edges[ind].size();i++){
		if(!visited[edges[ind][i]]){
			dfs(edges[ind][i]);
		}
			
	}
	
}

int main() {
	// your code goes here

	cin>>n>>m;
	
	for(int i=0;i<m;i++){
		int f,s;
		cin>>f>>s;
		edges[f].push_back(s);
		edges[s].push_back(f);
	}
	int cnt = 0;
	for(int i=1;i<=n;i++){
		if(!visited[i]){
			cnt++;
			dfs(i);
		}	
	}
	cout<<cnt-1;
	return 0;
}

Measured memory_bytes: 9684
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int x;
    cin >> x;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    bool flag = true;
    while (flag) {
        flag = false;
        for (int j = n - 1; j > 0; j--) {
            if (a[j] < a[j - 1]) {
                int x = a[j];
                a[j] = a[j - 1];
                a[j - 1] = x;
                flag = true;
                //counter++;
            }
            /*
            for (int i = 0; i < n; i++) {
                cout << a[i] << " ";
            }
            cout << endl;
            */
        }
    }
    int m = 0;

    for (int i = 0; i < n; i++) {
        x = x - a[i];
        if (x < 0) {
            break;
        }
        m++;
    }
    if (x > 0) {
        m--;
    }
    cout << m << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int n, m;
vector<int> data[100];

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

	      rem[i] = data[i][idx[i]];
	      flag[i] = false;
	    }else{
	      q.push(tmp);
	    }
	  }else{
	    ans++;
	  }
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#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(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


const int N_MAX = 100001;
set<int> prime_set;
void generate_prime() {
    prime_set.insert(2); 
    FOR(i, 3, N_MAX) {
        for(auto p : prime_set) {
            if(i % p == 0) break;
            if(p > sqrt(i)) {
                prime_set.insert(i);
                break;
            }
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    generate_prime();
    set<int> prime2;
    for(auto& p : prime_set) {
        if(p == 2) continue;
        if(prime_set.count((p + 1) / 2) == 1) prime2.insert(p);
    }
    VI ans(N_MAX);
    ans[0] = 0;
    FOR(i, 1, N_MAX - 1) {
        if(prime2.count(i) == 1) ans[i] = ans[i - 1] + 1;
        else ans[i] = ans[i - 1];
    }
    
    int q;
    cin >> q;
    REP(i, q) {
        int l, r;
        cin >> l >> r;
        cout << ans[r] - ans[l - 1] << '\n';
    }
    return 0;
}


Measured memory_bytes: 1536
n,a,b = [int(x) for x in input().split()]
def func(num):
  r = 0
  while num > 0:
    r += num % 10
    num = num // 10
  return r
total = 0
for i in range(1, n+1):
  num = func(i)
  if num >= a and num <= b:
    total += i
print(total)


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

const int maxn=1e5+10;
const int mo=1e9+7;

int n,m,x[maxn];

struct matrix{
	int v[3][3];

	void init(int a,int b,int c,int d,int e,int f,int g,int h,int i)
	{
		v[0][0]=a; v[0][1]=b; v[0][2]=c;
		v[1][0]=d; v[1][1]=e; v[1][2]=f;
		v[2][0]=g; v[2][1]=h; v[2][2]=i;
	}

	matrix operator * (const matrix &m) const
	{
		matrix Ans;
		memset(Ans.v,0,sizeof(Ans.v));
		int i,j,k;
		for (i=0;i<3;i++)
		for (j=0;j<3;j++)
		for (k=0;k<3;k++)
			(Ans.v[i][j]+=(LL)v[i][k]*m.v[k][j]%mo)%=mo;
		return Ans;
	}
}mat,mat0,mat1,one;

matrix power(matrix x,int k)
{
	matrix res=one;
	while (k)
	{
		if (k&1) res=res*x;
		x=x*x;
		k>>=1;
	}
	return res;
}

int main()
{
#ifdef h10
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
	one.init(1,0,0,0,1,0,0,0,1);
	mat0.init(1,2,1,0,1,1,0,0,1);
	mat1.init(1,2,1,0,1,1,1,2,2);
	mat=one;
	int i;
	scanf("%d%d",&m,&n);
	for (i=1;i<=n;i++) scanf("%d",&x[i]);
	x[++n]=m;
	for (i=n;i>=1;i--) x[i]-=x[i-1];
	for (i=1;i<=n;i++)
		mat=mat*mat0*power(mat1,x[i]-1);
	printf("%d\n",mat.v[0][2]);
}


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

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

    int count = 0;
    for (int x = 1; x <= b; x++) {
        if (a * x % b == c) {
            count++;
        }
    }

    cout << (count ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;
	if (B%A == 0) {
		cout << A + B;
	}
	else {
		cout << B - A;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
#define REP(i,b,e) for(int i=b;i<(int)e;i++)
typedef long long ll;
typedef map<ll,ll> mll;
typedef vector<ll> vll;
ll INF=1e18;
int inf=1e9+1000;


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

    ll a[1001],b[1001],c[1001],dist[106][106];
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--; b[i]--;
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j){
                dist[i][j]=0;
            }
            else dist[i][j]=inf;
        }
    }

    for(int i=0;i<m;i++){
        dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]);
        dist[b[i]][a[i]]=min(dist[b[i]][a[i]],c[i]);
    }

    Rep(k,n){
        Rep(i,n){
            Rep(j,n){
                dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }


    int ans=m;

    Rep(i,m){
        bool shortest=false;
        Rep(j,n){
            if(dist[j][a[i]]+c[i]==dist[j][b[i]]) shortest=true;
        }
        if(shortest){
            ans=ans-1;
        }
    }
    cout<<ans<<endl;

    
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char a = str.charAt(0);
		char b = str.charAt(1);
		char c = str.charAt(2);
		char d = str.charAt(3);
		if (a == b && c == d && a != c || a == c && b == d && a != b || a == d && b == c && a != b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <complex>

int main(void) {
  // x = a, y = b の順位をとったとして、
  // 得点が下回る人数は、 k = abなるkをとり、 k > xy となる整数xyの総数
  using namespace std;
  int Q;
  cin >> Q;
  for(int i = 0; i < Q; i++) {
    unsigned long long a, b;
    cin >> a >> b;
    unsigned long long k = a * b;
    unsigned long long k_rt = (unsigned long long) sqrt(k);
    int same = 1;
    if(k_rt * (k_rt + 1) >= k) same = 2;
    if(k_rt * k_rt == k && (k_rt != a && k_rt != b)) same = 3;
    cout << 2 * k_rt - same << endl;
  }
  return 0;
}


Measured memory_bytes: 888
'use strict'

const main = input => {
	const args = input.split('\n')
	const n = parseInt(args[0], 10)
	const k = parseInt(args[1], 10)
	const x = parseInt(args[2], 10)
	const y = parseInt(args[3], 10)
	let sum = 0
	for (let i = 1; i <= n; i++) {
		if (i <= k) sum += x 
		else sum += y
	}
	console.log(sum)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

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

  vector<int> T(N), A(N);
  rep(i, N) cin >> T[i] >> A[i];

  ll t = 1, a = 1;
  rep(i, N) {
    ll n = max((t + T[i] - 1) / T[i], (a + A[i] - 1) / A[i]);
    t = T[i] * n;
    a = A[i] * n;
  }

  cout << t + a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int n;
    cin >> n;
    map <int, int> a;
    for (int i=0; i<n; i++){
        int th;
        cin >> th;
        a[th] = i;
    }

    int m1 = 1;
    int max = 0;
    int k1 = a[1];
    for (int i=2; i<=n; i++){
        if (k1 > a[i]){
            if (m1>max){
                max = m1;
            }
            k1 = a[i];
            m1 = 1;
        }
        else {
            k1 = a[i];
            m1++;
        }
    }
    if (m1>max) max = m1;
    cout << n-max;
    return 0;
}

Measured memory_bytes: 9600
# -*- coding: utf-8 -*-
import sys
from decimal import *
input = sys.stdin.readline


def main():
    n = int(input())
    result = Decimal(0)
    for i in range(1, n + 1):
        if not i % 3 == 0 and not i % 5 == 0:
            result += Decimal(i)

    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10004
#include <bits/stdc++.h>
using namespace std;
int main(){
    long sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    long difx=tx-sx,dify=ty-sy;
    for(int i=0; i<dify; i++)
        cout<<"U";
    for(int i=0; i<difx; i++)
        cout<<"R";
    for(int i=0; i<dify; i++)
        cout<<"D";
    for(int i=0; i<difx; i++)
        cout<<"L";
    cout<<"L";
    for(int i=0; i<=dify; i++)
        cout<<"U";
    for(int i=0; i<=difx; i++)
        cout<<"R";
    cout<<"D";
    cout<<"R";
    for(int i=0; i<=dify; i++)
        cout<<"D";
    for(int i=0; i<=difx; i++)
        cout<<"L";
    cout<<"U";
}

Measured memory_bytes: 256