akhauriyash/Code-Regression huggingface dataset:
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

def main():
    P, Q, R = map(int, input().split())
    lists = []
    lists.append(P + Q)
    lists.append(Q + R)
    lists.append(P + R)
    print(min(lists))


if __name__ == '__main__':
    main()

Measured memory_bytes: 21896
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
using namespace std;

int main()
{
	string s, t; cin >> s >> t;
	for (int i = 0; i < s.length(); i++) {
		s = s[s.length() - 1] +
			s.substr(0, s.length() - 1);
		if (s == t) {
			cout << "Yes" << endl;
			break;
		}
		else if (i == s.length() - 1) {
			cout << "No" << endl;
		}
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
const ll mod = 1e9 + 7;
int main()
{
	SPEED
	int K;
	cin >> K;
	int ans = 0;

	for (int i = 1; i <= K; ++i)
	{
		for (int j = 1; j <= K; ++j)
		{
			int temp1 = __gcd(i, j);

			for (int k = 1; k <= K; ++k)
			{
				ans += __gcd(temp1, k);
			}
		}
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(long.Parse).ToArray();
        var a = ReadLine().Split().Select(long.Parse).ToArray();
        var t = new Tuple<long, long>[n[0]];
        for(int i = 0; i < n[0]; i++)
        {
            t[i] = new Tuple<long, long>(a[i], a[i] + n[1]);
        }
        var sum = 0L;
        for(int i = 0; i < n[0] - 1; i++)
        {
            if(t[i].Item2 > t[i + 1].Item1)
                t[i] = new Tuple<long, long>(t[i].Item1, t[i + 1].Item1);
        }
        for(int i = 0; i < n[0]; i++)
        {
            sum += t[i].Item2 - t[i].Item1;
        }
        WriteLine(sum);
    }
}


Measured memory_bytes: 52736
from sys import stdin
import math
import fractions
from collections import deque

INF = 10 ** 10

N = int(stdin.readline().rstrip())
s = [stdin.readline().rstrip() for _ in range(N)]

endA_num = 0
startB_num = 0
endA_startB_num = 0

cnt = 0
for si in s:
    if si[-1] == "A":
        endA_num += 1
        if si[0] == "B":
            endA_startB_num += 1
    if si[0] == "B":
        startB_num += 1

    for i in range(len(si)-1):
        if si[i] == "A" and si[i+1] == "B":
            cnt+=1

alpha = 0
if endA_num > 0 and startB_num > 0:
    if endA_num == startB_num and endA_num == endA_startB_num:
        endA_num -= 1
    alpha = min(endA_num, startB_num)

print(cnt+alpha)



Measured memory_bytes: 68716
#include<bits/stdc++.h>
#define ll long long
#define N 2000005
using namespace std;
ll n,m;
ll a[N*2],v[N],b[N*2];
int main()
{
//	freopen("in.txt","r",stdin);
	scanf("%lld%lld",&n,&m);
	ll ans=0;
	for(int i=1;i<=n;i++)scanf("%lld",&v[i]);
	for(int i=2;i<=n;i++)
	{
		if(v[i]>v[i-1])ans+=v[i]-v[i-1];
		else ans+=m-v[i-1]+v[i];
		if(v[i]>v[i-1])
		{
			a[v[i-1]+2]++;
			a[v[i]+1]--;
			a[v[i-1]+2+m]++;
			a[v[i]+m+1]--;
		}
		else
		{
			b[v[i-1]+2]++;
			b[v[i]+m+1]--;
		}
	}
//	cout<<ans<<endl;
	ll mx=0;
	for(int i=2;i<=2*m;i++)a[i]+=a[i-1];
	
	for(int i=2;i<=2*m;i++)b[i]+=b[i-1];
	for(int i=2;i<=n;i++)
	{
		if(v[i]>v[i-1])
		{
			a[v[i]+1]-=v[i]-v[i-1]-1;
			a[v[i]+m+1]-=v[i]-v[i-1]-1;
		}
		else
		{
			b[v[i]+m+1]-=(v[i]+m-v[i-1]-1);
		}
	}
	for(int i=2;i<=2*m;i++)a[i]+=a[i-1];
	for(int i=2;i<=2*m;i++)b[i]+=b[i-1];
	for(int i=1;i<=m;i++)
	{
		mx=max(mx,a[i]+b[i+m]+b[i]);
	}
	printf("%lld\n",ans-mx);
	return 0;
}

Measured memory_bytes: 7936
import math as mt
import sys, string
from collections import Counter, defaultdict
input = sys.stdin.readline

# input functions
I = lambda : int(input())
M = lambda : map(int, input().split())
ARR = lambda: list(map(int, input().split()))

a, b, c, d = M()
print(max(a*c, a*d, b*c, b*d))

Measured memory_bytes: 71884
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;

char henk1[30], henk2[30];
char s[200001], t[200001];

int main() {
  for (int i = 0; i < 30; i++) henk1[i] = henk2[i] = 0;
  scanf("%s%s", s, t);
  int i = 0;
  bool flag = true;
  while (s[i] != 0) {
    if (henk1[s[i]-'a'] != 0 && henk1[s[i]-'a'] != t[i]) {
      flag = false;
      break;
    }
    if (henk2[t[i]-'a'] != 0 && henk2[t[i]-'a'] != s[i]) {
      flag = false;
      break;
    }
    henk1[s[i]-'a'] = t[i];
    henk2[t[i]-'a'] = s[i];
    i++;
  }
  if (flag) printf("Yes\n");
  else printf("No\n");
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
int main() {
	string s;
	cin >> s;
	for(int i=0;i<4;i++) {
		cout << s[i];
	}
	cout << " ";
	for(int i=4;i<s.size();i++) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from bisect import bisect_left
input = sys.stdin.readline


def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()
    ans = 0
    for a in range(N-1):
        for b in range(a+1, N):
            l = b + 1
            r = bisect_left(L, L[a]+L[b])
            ans += (r - l)
    print(ans)


if __name__ == '__main__': main()

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		while (sc.hasNext()) {
			double N = sc.nextDouble();
			double K = sc.nextDouble();

			if (N%K == 0) {
				System.out.println(0);
			} else {
				System.out.println(1);
			}
		}
	}

}


Measured memory_bytes: 23124
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque

n,m = [int(x) for x in stdin.readline().rstrip().split()]

d = {}
for i in range(m):
    a,b = [int(x) for x in stdin.readline().rstrip().split()]

    if a not in d:
        d[a] = [b]
    else:
        d[a].append(b)

    if b not in d:
        d[b] = [a]
    else:
        d[b].append(a)

sol = {}

m = [1]
while True:
    next_m = []
    for mm in m:
        b = d[mm]
        for bb in b:
            if bb not in sol:
                sol[bb] = mm
                next_m.append(bb)

    if len(next_m) == 0: break
    m = next_m

sol = sorted(sol.items())

print("Yes")
for v in sol[1:]:
    print(v[1])

Measured memory_bytes: 55012
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
string s;

int main() {
  INCANT;
  cin >> s;
  int a = s.size()-2;
  string b="";
  cout << s[0];
  if (a>9) cout << a/10;
  a%=10;
  cout << a;
  cout << s[s.size()-1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}


int main(){
  string a,b;
  cin>>a>>b;
  if(a.length()>b.length())cout<<"GREATER"<<endl;
  else if(a.length()<b.length())cout<<"LESS"<<endl;
  else{
    int flag = 0;
    for(int i = 0; i < a.length();i++){
      if(a[i]>b[i]){
        flag = 1;
        break;
      }
      else if(a[i]<b[i]){
        flag = 2;
        break;
      }
    }
    if(flag == 0) cout<<"EQUAL"<<endl;
    else if(flag == 1) cout<<"GREATER"<<endl;
    else cout<<"LESS"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string.h>
using namespace std;
int main(){
    char s[20];
	cin>>s;
    int n=strlen(s);
    if(n<4){
    	cout<<"No"<<endl;
	}else{
        if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I'){
        	cout<<"Yes"<<endl;
		}else{
        	cout<<"No"<<endl;
		}
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <map>
#include <vector>
//#include <unordered_map>
//#include <unordered_set>
#include <stack>
#include <set>
#include <queue>
#include <list>
#define LL long long
#define N 100100
#define M 110
#define MOD 1000000007
#define FOR(i,l,r) for (int i = (l); i <= (r); i ++)
#define CLR(a,x) memset(a,x,sizeof(a))
#define INF 0x3f3f3f3f
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define X first
#define Y second
using namespace std;
const int maxn=100005;
int main()
{
    int n;
    scanf("%d",&n);
    if((n%10)==(n/100)) puts("Yes");
    else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	int a, b, t;
	cin >> a >> b >> t;
 
	int ans = 0;
	for (int i = a; i < t + 0.5; i+=a) {
		ans += b;
	}
 
	cout << ans << endl;
	return 0;
}


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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll a,b;cin>>a>>b;
  ll x=1;
  ll cnt=0;
  while(1){
    if(x>=b)break;
    else{
      cnt++;
      x+=a-1;
    }
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

int a[100001];

int main() {
	int n,i;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	a[n] = 1000000009;
	std::sort(a, a + n);
	int s=0, ans = 0;
	for (i = 1; i <= n; i++) {
		if (a[i - 1] < a[i]) {
			if (i - s < a[i - 1]) {
				ans += i - s;
			}
			else {
				ans += i - s - a[i - 1];
			}
			s = i;
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))
ans = 1000

for i in range(1, n):
    stock = 0
    if a[i - 1] < a[i]:
        stock = ans // a[i - 1]
    ans += (a[i] - a[i - 1]) * stock

print(ans)


Measured memory_bytes: 9076
#include<iostream>

using namespace std;

int main()
{
	int A,B,C;

	cin >> A >> B >> C;

	if( (A < C && C < B) || (A > C && C > B)  )
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
using System;

namespace Project
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			string s = Console.ReadLine();
			string[] sar = s.Split(' ');
			int n = int.Parse(sar[0]);
			int m = int.Parse(sar[1]);
			int l = int.Parse(sar[2]);
			long[,] c = new long[n, l];
			int[,] a = new int[n, m];
			int[,] b = new int[m, l];
			for (int i = 0; i < n; i++)
			{
				string ss = Console.ReadLine();
				string[] ssar = ss.Split(' ');
				for (int j = 0; j < m; j++)
				{
					a[i, j] = int.Parse(ssar[j]);
				}
			}
			for (int i = 0; i < m; i++)
			{
				string ss = Console.ReadLine();
				string[] ssar = ss.Split(' ');
				for (int j = 0; j < l; j++)
				{
					b[i, j] = int.Parse(ssar[j]);
				}
			}
			for (int i = 0; i < n; i++)
			{
				for (int j = 0; j < l; j++)
				{
					for (int k = 0; k < m; k++)
					{
						c[i, j] += a[i, k] * b[k, j];
					}
				}
			}

			for (int i = 0; i < n; i++)
			{
				for (int j = 0; j < l; j++)
				{
					Console.Write(c[i,j]);
					if (j == l - 1) { break;}
					Console.Write(" ");
				}
				Console.Write("\n");
			}
		}
	}
}

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

typedef long long ll;
const ll mod = 1e9+7;
const ll N = 3e5;
ll sum[65][N+100],arr[N+100];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> arr[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<60;j++){
			sum[j][i] = sum[j][i-1];
		}
		int cnt = 0;
		ll tmp = arr[i];
		while(tmp)
		{
			if(tmp%2){
				sum[cnt][i]++;
			}
			cnt++;
			tmp/=2;
		}
	}
	ll ans = 0;
	for(int i=1;i<n;i++){
		ll tmp = arr[i];
		for(int j=0;j<60;j++){
			if(tmp%2){
				ll t1 = (1ll<<j)%mod;
				ll t2 = (n-i-sum[j][n]+sum[j][i])%mod;
				ans = (ans+(t1*t2)%mod)%mod;
			}
			else{
				ll t1 = (1ll<<j)%mod;
				ll t2 = (sum[j][n]-sum[j][i])%mod;
				ans = (ans+(t1*t2)%mod)%mod;
			}
			tmp/=2;
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 143616
#include "iostream"

using namespace std;

int main() {
	int n, a[2][100], ans;
	ans = 0;
	cin >> n;
	for (int i = 0; i<n; i++) {
		cin >> a[0][i];
	}
	for (int i = 0; i<n; i++) {
		cin >> a[1][i];
	}

	int t, tmp;
	tmp = 0;
	t = n;
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < t; i++) {
			tmp += a[0][i];
		}
		for (int i = t-1; i < n; i++) {
			tmp += a[1][i];
		}
		t--;
		if (ans < tmp) {
			ans = tmp;
		}
		tmp = 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
#define MAX 2020
inline ll read()
{
	ll x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
struct Line{int v,next;}e[MAX*MAX];
int h[MAX],cnt=1,dg[MAX];
vector<int> E[MAX];
inline void Add(int u,int v){e[cnt]=(Line){v,h[u]};h[u]=cnt++;dg[v]+=1;}
inline void ADD(int u,int v){E[u].push_back(v);}
int n;
ll a[MAX];
priority_queue<int> Q;
bool vis[MAX];
void dfs(int u)
{
	vis[u]=true;
	for(int v:E[u])if(!vis[v])dfs(v),Add(u,v);
}
int main()
{
	n=read();
	for(int i=1;i<=n;++i)a[i]=read();
	sort(&a[1],&a[n+1]);
	for(int i=1;i<=n;++i)
		for(int j=i+1;j<=n;++j)
			if(__gcd(a[i],a[j])>1)ADD(i,j),ADD(j,i);
	for(int i=1;i<=n;++i)if(!vis[i])dfs(i);
	for(int i=1;i<=n;++i)if(!dg[i])Q.push(i);
	while(!Q.empty())
	{
		int u=Q.top();Q.pop();printf("%lld ",a[u]);
		for(int i=h[u];i;i=e[i].next)
			if(!--dg[e[i].v])Q.push(e[i].v);
	}
	return 0;
}


Measured memory_bytes: 17664
top = 0
def push(x):
    global top
    L.append(x)
    top += 1
def pop():
    global top
    x = L.pop(top)
    top -= 1
    return x

L = [0]
S = input().split()
for i in S:
    if i == "+":
        a = pop()
        b = pop()
        push(a + b)
    elif i == "-":
        a = pop()
        b = pop()
        push(b - a)
    elif i == "*":
        a = pop()
        b = pop()
        push(a * b)
    else:
        push(int(i))

print(str(pop()))

Measured memory_bytes: 7696
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

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

int main() {
	string str;
	cin >> str;
	for(int i = 0;i < str.size();i++){
		if(str[i] != ',') cout << str[i];
		else cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#require 'pp'
    
n = gets.chomp!.to_i
a_n = gets.split.map(&:to_i)
    
digit_max = 61
memo = Array.new(digit_max)
digit_max.times do |i|
    memo[i] = [0, n]
end
    
digit_max.times do |d|
    x = 0
    y = n
    a_n.each do |a|
        if a[d] == 1
            x += 1
            y -= 1
        end
    end

    memo[d][0] = x
    memo[d][1] = y
end

MOD = (10 ** 9) + 7
sum = 0
count = Array.new(digit_max, 0)
digit_max.times do |dig|
    s = (2 ** dig) * (memo[dig][0] * memo[dig][1])
    sum = (sum + s) % MOD
end
    
puts sum


Measured memory_bytes: 34828
# https://atcoder.jp/contests/abc113/tasks/abc113_c
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


N, M = read_ints()
data = []
for i in range(M):
    data.append(list(map(int, read().split())) + [i])

data.sort()
ans = []
cnt = [0] * (N + 1)  # それぞれの出現回数をカウントする →x番目を取得するため
for p, y, i in data:
    cnt[p] += 1
    x = cnt[p]
    ans.append((i, str(p).zfill(6) + str(x).zfill(6)))

ans.sort()
for _, a in ans:
    print(a)


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

using namespace std;

#define INF 1000000000
#define pb(a) push_back(a)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x;
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i)
#define FORVEC(i, v) for(int i = 0;i < sz(v);++i)

#define fil0(i,n) cout<<swet(n)<<setfill('0')<<i<<resetiosflags(ios_base::floatfield)


int main(){
    int n;
    int cnt=0;
    int buf;

    cin>>n;
    REP(i,n){
        cin>>buf;
        while(!(buf%2)){
            buf/=2;
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int h[200005]={0};
int a[200005]={0};
int main(){
	int n,k,i;
	scanf("%d %d",&n,&k);
	for(i=1;i<=n;i++){
		scanf("%d",&h[i]);
	}
	int x,y;
	for(i=1;i<=k;i++){
		scanf("%d %d",&x,&y);
		if(h[x]>h[y]) a[y]++;
		else if(h[x]<h[y]) a[x]++;
		else {
			a[x]++;
			a[y]++;
		}
	}
	int ans=0;
	for(i=1;i<=n;i++){
		if(a[i]==0) ans++;
	}
	printf("%d",ans);
}

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

typedef long long ll;
#define PI 2 * acos (0.0)

ll MOD = 1e9 + 7 ;
ll arr[100005] ;

int main()
{
  ll a, b ;
  bool flag[3] ;
  memset(flag, false, sizeof flag) ;
  cin >> a >> b ;
  flag[a - 1] = true, flag[b - 1] = true ;
  for(int i = 0; i < 3; i++) {
    if(!flag[i]) cout << (i + 1) << endl ;
  }

}


Measured memory_bytes: 256
s = input()
ok = True

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == 'L':
            ok = False
            break
    else:
        if s[i] == 'R':
            ok = False
            break
if ok:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define isin(i,a,b) ((a) <= (i) && (i) < (b))
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll  = long long;
using unit= unsigned;
using ull = unsigned long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vvi = vector<vi>;
using vp  = vector<P>;
void _main(); int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b){ if (a<b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if (b<a){ a = b; return 1; } return 0; }
template<class T>T gcd(T a, T b){ if (b==0){ return a; }else{ return gcd(b, a%b); }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
constexpr double eps = 1e-10;
constexpr int inf = INT_MAX / 2;
constexpr ll infl = 1LL << 60;

void _main() {
  int N;
  cin >> N;
  vi p(N);
  rep(i, 0, N) cin >> p[i];

  int ans = 0;
  rep(i, 1, N-1) {
    if ((p[i-1] < p[i] && p[i] < p[i+1]) ||
        (p[i-1] > p[i] && p[i] > p[i+1])) ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main()
{
	double r;
	double circum, area;
	
	scanf("%lf", &r);
	
	circum = 2 * M_PI * r;
	area   = M_PI * r * r;
	
	printf("%.6f %.6f\n", area, circum);
	
	return 0;
}


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

// limit
#define mod1 22439423LL
#define mod2 42342432LL
#define mod3 56454765LL
#define mod4 66867574LL
#define oo 1000000007LL
#define OO 1000000000000000007LL
#define maxN 100007

// loop
#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define fdtoa(i, x, y, a) for(int i = (x); i >= (y); i -= a)
#define ftosqrt(i, x, y) for(int i = (x); i*i <= (y); ++i)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define fdtoit(rit, var) for (__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); ++rit)

// debug
#define debug cout << "*" << endl;
#define bug1d(a, x, y) { cout << #a << ": "; fto(_, x, y) cout << a[_] << ' '; cout << endl; }
#define bug2d(a, x, y, u, v) { cout << #a << ": " << endl; fto(i, x, y) {fto(j, u, v) cout << a[i][j] << ' '; cout << endl;}; cout << endl;}
#define bug(a) cout << #a << " = " << a << endl;
#define bug2(a, b) cout << #a << " = " << a << "; "; cout << #b << " = " << b << endl;
#define bug3(a, b, c) cout << #a << " = " << a << "; "; cout << #b << " = " << b << "; "; cout << #c << " = " << c << endl;

// operation
#define mp make_pair
#define pb push_back
#define pf push_front
// structure
#define ii pair<int, int>
#define iii pair<ii, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define matrix vector<vi>

// get value
#define FF first
#define SS second

// data type
#define ll long long
#define ull unsigned long long

// function
#define lb lower_bound
#define ub upper_bound

// const value
#define pi 3.14159265358979323846264338327950288419716939937510

using namespace std;

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T min(T a, T b, T c, T d) {
    return min(a, min(b, min(c, d)));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

template <class T>
T max(T a, T b, T c, T d) {
    return max(a, max(b, max(c, d)));
}

bool cmp(const ii& a, const ii& b) {return (a.FF > b.FF || (a.FF == b.FF && a.SS >= b.SS));}
ll GCD(ll a, ll b) {return (a%b) ? GCD(b, a%b) : b;}

const string namePro = "tmp";

int main() {
    /*#ifndef ONLINE_JUDGE
        freopen((namePro+".inp").c_str(), "r", stdin);
        freopen((namePro+".out").c_str(), "w", stdout);
    #endif // ONLINE_JUDGE*/

    string a, b, c;
    cin >> a >> b >> c;
    a[0] = a[0]-'a'+'A';
    b[0] = b[0]-'a'+'A';
    c[0] = c[0]-'a'+'A';

    cout << (char)a[0] << (char)b[0] << (char)c[0] << endl;
    return 0; 
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class Q {
  public int k;
  public int v;
  public Q(int k2,int v2){k=k2;v=v2;}
}

class M {static void Main(string[] _){
  Console.ReadLine();
  var A = Console.ReadLine().Split(' ');
  var B0 = A.Where( (a,i) => i % 2 == 0 );
  var B1 = A.Where( (a,i) => i % 2 == 1 );
  var C0 = B0.GroupBy(i=>i).OrderByDescending(i=>i.Count()).Select( i => new Q( int.Parse(i.Key) , i.Count() ) ).ToList();
  var C1 = B1.GroupBy(i=>i).OrderByDescending(i=>i.Count()).Select( i => new Q( int.Parse(i.Key) , i.Count() ) ).ToList();
  
  var K0 = C0[0].k;
  var K1 = C1[0].k;
  if ( C0.Count() == 1 ) {
    C0.Add( new Q( K0 + 1 , 0 ) );
  }
  if ( C1.Count() == 1 ) {
    C1.Add( new Q( K1 + 1 , 0 ) );
  }

  if ( K0 == K1 ) {
    var v0 = C0[0].v;
    var v1 = C1[0].v;
    if ( v0 < v1 ) {
      K0 = C0[1].k;
    }
	if ( v1 < v0 ) {
      K1 = C1[1].k;
    }
	if ( v0 == v1 ) {
      var v2 = C0[1].v;
      var v3 = C1[1].v;
      if ( v3 < v2 ) {
	      K0 = C0[1].k;
      } else {
	      K1 = C1[1].k;
      }
    }    
  }
    
  int E0 =B0.Where( i => int.Parse(i) != K0 ).Count();
  int E1 =B1.Where( i => int.Parse(i) != K1 ).Count();  
  int R = E0 + E1;
  Console.Write(R);
  
}}



Measured memory_bytes: 38052
using System;
using System.Collections.Generic;
class Program
    {
        static void Main(string[] args)
    	{
            string s = Console.ReadLine();
            char[] c = s.ToCharArray();
            Array.Sort(c);
            if (c[0] == c[1] && c[1] != c[2] && c[2] == c[3])
            {
                Console.WriteLine("Yes");
            }
            else Console.WriteLine("No");
            
            
        }
    
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 11348
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define endl "\n"
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int r,c,k;
int dp[3005][3005][4];
int a[3005][3005];
int calc(int i,int j,int val)
{
    if(i>r || j>c || val<0)
    return 0;
    if(dp[i][j][val]!=-1)return dp[i][j][val];
    int ans=0;
    if(val == 0)
    {
        ans=calc(i+1,j,3);
        ans=max(ans,calc(i,j+1,val));
    }
    else
    {       //debug(i,j,val);
            ans=max(ans,max((a[i][j]+calc(i,j+1,val-1)),calc(i,j+1,val)));
            ans=max(ans,max((a[i][j]+calc(i+1,j,3)),calc(i+1,j,3)));
    }
    //debug(i,j,val,ans);
    return dp[i][j][val]=ans;

}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   cin>>r>>c>>k;
   for(int i=0;i<k;i++)
   {
       int x,y,z;
       cin>>x>>y>>z;
       a[x][y]=z;
   }
   memset(dp,-1,sizeof(dp));
   cout<<calc(1,1,3)<<endl;

}



Measured memory_bytes: 356664
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll a, b;
    while(cin >> a >> b)
    {
        cout << a + b << "\n";
    }
    return 0 ;
}



Measured memory_bytes: 3100
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String n = saori.nextHayami();
		boolean flg = true;
		for (int i = 1; i < n.length(); i++) {
			if(n.charAt(i)!='9') {
				flg = false;
				break;
			}
		}
		char c = flg?'0':'1';
		int ans = (int)(n.charAt(0)-c) + (n.length() - 1) * 9;
		System.out.println(ans);
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 23120
n = int(input())
ans = 0
for i in range(1, int(n ** 0.5) + 1):
    k = n // i
    ans += i * k * (k + 1) // 2
    if i != k:
        l = n // (i + 1)
        ans += i * (i + 1) * (k + l + 1) * (k - l) // 4
print(ans)


Measured memory_bytes: 9436
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>

#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

using namespace std;
string s;
char wha[100];
int cnt;

int main() {
	cin >> s;
	rep(i, s.size()){
		wha[i] = s[i];
	}

	rep(i, s.size()/2){
		if (wha[i] != s[s.size()-1-i]){
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007ll
#define INF (1 << 28)    // for x <= 10^9
#define INFL (1ll << 60) // for x <=10^19
#define EPS (1e-10)

using namespace std;

using ll = long long;

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

  int allTaste = 0;
  int ateTaste = L;
  for (int i = 1; i <= N; i++) {
    int taste = L + i - 1;
    allTaste += taste;
    ateTaste = (abs(ateTaste) > abs(taste)) ? taste : ateTaste;
  }
  int ans = allTaste - ateTaste;
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int min = 0;
		int count=0;
		long[] array = new long[n];

		for(int i=0;i<n;i++) {
			array[i]=sc.nextLong();

		}
		for(int i=0;i<n;i++) {
			min = i;
			for(int j=i+1;j<n;j++) {
				if(array[j] < array[min]) {
					min = j;
				}
			}
			if(min!=i) {
				long temp = array[i];
				array[i] = array[min];
				array[min] = temp;
				count ++;
			}
			
		}

		for(int i=0;i<n;i++) {
			if(i!=n-1) {
				System.out.print(array[i] + " ");
			}else {
				System.out.println(array[i]);
			}
		}

		System.out.println(count);

	}

	public static long max(long[] array,int j) {
		long temp,max=-9999999;
		for(int i=j+1;i<array.length;i++) {
			temp = array[i] - array[j];
			if(temp > max) {
				max = temp;
			}
		}
		return max;
	}
}



Measured memory_bytes: 26388
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    ll n=in();
    string s;cin>>s;
    ll ans=0;
    for(ll i=0;i<1000;++i){
        auto p1=s.find_first_of((char)('0'+i/100));
        auto p2=s.find_first_of((char)('0'+i/10%10),p1+1);
        auto p3=s.find_first_of((char)('0'+i%10),p2+1);
        if(p1!=string::npos&&p2!=string::npos&&p3!=string::npos){
            ++ans;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


int main() {
    Int A,B,C;

    cin >>A >> B >> C;

    Int D= C+B;

    if(D>A){
        cout << D-A << endl;
    }else{
        cout << 0 << endl;
    }





    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

bool comp(const pii &a, const pii &b) {
	if (a.fi != b.fi)
		return a.fi > b.fi;
	else
		return a.se > b.se;
}

int main() {
	fast_io;
	int n;
	cin >> n;
	string s[n];
	for (int i = 0;i < n;i++)
		cin >> s[i];
	vii po, ne;
	for (int i = 0;i < n;i++) {
		int del = 0, low = 0;
		for (auto c : s[i]) {
			if (c == '(')
				del++;
			else
				del--;
			low = min(low, del);
		}
		if (del >= 0)
			po.pb({low, del});
		else
			ne.pb({low - del, -del});
	}
	sort(all(po), comp);
	sort(all(ne), comp);
	int cur1 = 0, cur2 = 0;
	bool ans = 1;
	for (auto x : po) {
		if (x.fi + cur1 < 0)
			ans = 0;
		cur1 += x.se;
	}
	for (auto x : ne) {
		if (x.fi + cur2 < 0)
			ans = 0;
		cur2 += x.se;
	}
	if (cur1 != cur2)
		ans = 0;
	(ans && cout << "Yes\n") || cout << "No\n";
}


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

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[] player = new int[n];
			int i = 0;
			int ba = 0;
			char[] c = scanner.next().toCharArray();
			int count = 0;
			while (count != 100) {
				if (c[count] == 'M') {
					player[i]++;
				} else if (c[count] == 'S') {
					ba += player[i] + 1;
					player[i] = 0;
				} else {
					player[i] += ba + 1;
					ba = 0;
				}
				count++;
				i = (i + 1) % n;
			}
			Arrays.sort(player);
			for (int j = 0; j < n; j++)
				System.out.print(player[j] + " ");
			System.out.println(ba);
		}
	}
}

Measured memory_bytes: 21672
#include <iostream>

using namespace std;

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

  // 500円の使用枚数
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <= c; k++) {
        if (500 * i + 100 * j + 50 * k == x) {
          ans++;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std; 

int main(){
	
	int n; 
	
	int t, a; 
	
	cin >> n >> t >> a; 
	
	vector<int> container(1001);
	
	
	for(int i=0;i<n;i++){
		cin >> container[i];
	}
	
	double ans = 1e9+7;
	
	int ixd = 0;
	
	for(int i=0;i<n;i++){
		
		double val = t - container[i] * 0.006;
		
		if(abs(val-a)<ans){
			ans = abs(val-a);
			ixd = i;
		} 
	}
	
	cout << ixd + 1 << endl;	

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void add(int&,int);
int mul(int,int);
int powz(int,int);

template<typename A> ostream& operator<<(ostream&,vector<A>&);
 
const int N=1000002;

void solve(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	vector<int>a(2*n);
	for(int i=0;i<2*n;i++){
		a[i]=(s[i]=='W'?0:1);
	}
	int moves=0;
	if(a[0]==0){
		cout<<0;
		return;
	}
	int ans=1;
	for(int i=0;i<2*n;i++){
		if((a[i]+moves)%2){
			moves++;
		}
		else{
			ans=mul(ans,moves);
			moves--;
		}
		if(moves<0||moves>n){
			cout<<0;
			return;
		}
	}
	if(moves||a[2*n-1]==0){
		cout<<0;
		return;
	}
	for(int i=1;i<=n;i++){
		ans=mul(ans,i);
	}
	cout<<ans;
			
	
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
    int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;
}


Measured memory_bytes: 1428
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define all(x) x.begin(),x.end()
using namespace std;
const int MX = 505;
int a[MX],n,sum=0,k;
vector<int> v;
int main(){
    cin >> n >> k;
    for(int i=0 ; i<n ; ++i){
        cin >> a[i];
        sum += a[i];
    }
    for(int i=1 ; i*i <= sum ; ++i){
        if(sum % i == 0){
            v.push_back(i);
            v.push_back(sum/i);
        }
    }
    sort(all(v));
    reverse(all(v));
    int ans = 0;
    for(auto el : v){
        vector<int> arr;
        for(int i=0 ; i<n ; ++i)
            arr.push_back(a[i]%el);
        sort(all(arr));
        int l = 0, r = n-1 , m = k;
        while(l<r && m > 0){
            int num = min(arr[l],el-arr[r]);
            //cout << num << " " << m << "\n";
            if(num > m)break;
            arr[l] -= num;
            arr[r] += num;
            m -= num;
            if(arr[l] == 0)l++;
            if(arr[r] == el)r--;
        }
        if(l >= r){
            ans = el;
            break;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

struct UnionFind {
vector<int> d;
UnionFind(int n=0): d(n,-1) {}
int find(int x) {
  if (d[x] < 0) return x;
  return d[x] = find(d[x]);
}
bool unite(int x, int y) {
  x = find(x); y = find(y);
  if (x == y) return false;
  if (d[x] > d[y]) swap(x,y);
  d[x] += d[y];
  d[y] = x;
  return true;
}
bool same(int x, int y) { return find(x) == find(y);}
int size(int x) { return -d[find(x)];}
};

int main(){
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  map <int, bool> mp;
  REP(i,m){
    int a, b;
    cin >> a >> b;
    --a, --b;
    uf.unite(a,b);
    mp[a] = true;
    mp[b] = true;
  }  

  int minx = 0;
  REP(i,n){
    //if(!mp[i]) continue;
    minx = max(uf.size(i),minx);
  }

  cout << minx << endl;

  return 0;
}

Measured memory_bytes: 13560
n = int(input())
arr = list(map(int, input().split()))
cnt = 0
for i in range(len(arr)):
    Min = i
    for j in range(i, len(arr)):
        if arr[j] < arr[Min]:
            Min = j
    if i != Min:
        arr[i], arr[Min] = arr[Min], arr[i]
        cnt += 1
print(*arr)
print(cnt)


Measured memory_bytes: 5608
import java.util.*;

public class Main{
    public static void main(String []args){
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = a * b;

        if(a < 10 && b < 10){
            System.out.println(c);
        }else{
            System.out.println("-1");
        }
    }
}

Measured memory_bytes: 23892
use std::io::stdin;
use std::vec::Vec;

mod utils {
    use std::io::BufRead;
    use std::str::{self, FromStr};

    pub struct StdinReader<R: BufRead> {
        reader: R,
        buf: Vec<u8>,
    }

    impl<R: BufRead> StdinReader<R> {
        pub fn new(reader: R) -> StdinReader<R> {
            StdinReader {
                reader: reader,
                buf: Vec::new(),
            }
        }

        #[allow(unused)]
        #[inline]
        pub fn reads<T: FromStr>(&mut self) -> T {
            self.read_until(b' ')
        }

        #[allow(unused)]
        #[inline]
        pub fn readl<T: FromStr>(&mut self) -> T {
            self.read_until(b'\n')
        }

        #[allow(unused)]
        #[inline]
        pub fn read_vec<T: FromStr>(&mut self) -> Vec<T> {
            return self.read_until::<String>(b'\n').trim().split_whitespace().map(|c| c.parse().ok().unwrap()).collect();
        }

        #[inline]
        pub fn read_until<T: FromStr>(&mut self, delim: u8) -> T {
            loop {
                self.buf.clear();
                let len = self.reader
                    .read_until(delim, &mut self.buf)
                    .expect("failed reading bytes");
                match len {
                    0 => panic!("early eof"),
                    1 if self.buf[0] == delim => (),
                    _ => {
                        if self.buf[len - 1] == delim {
                            self.buf.truncate(len - 1);
                        }
                        break;
                    }
                }
            }

            let elem = unsafe { str::from_utf8_unchecked(&self.buf) };
            elem.parse().unwrap_or_else(|_| panic!(format!("failed parsing: {}", elem)))
         }
    }
}


fn main(){
    let stdin = stdin();
    let mut r = utils::StdinReader::new(stdin.lock());
    let n:i16 = r.readl();
    let a_s:Vec<i64> = r.read_vec();
    let mut res:i64 = 0;
    let mut is_looped = true;

    while(is_looped) {
        for a in &a_s {
            if(a % pow(2,res) != 0) {
                is_looped = false;
                res -= 2;
                break
            }
        }
        res += 1;
    }

    println!("{}",res);
}

fn pow(left: i64, right:i64) -> i64 {
    let mut res:i64 = 1;
    for i in 0..right {
        res *= left;
    }
    res
}



Measured memory_bytes: 4352