akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
	var l, r int
	fmt.Scan(&l, &r)
	//2019個以上ならおけ
	w := r-l+1
	if w%2019 == 0{
		fmt.Println(0)
		return
	}
	ans := 2019
	for i:=l; i<=r ; i++ {
		for j :=i+1; j<=r; j++ {
			mod := (i*j)%2019
			if ans > mod {
				ans = mod
			}
			if ans == 0{
				fmt.Println(0)
				return
			}
		}
	}
	fmt.Println(ans)
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

void solve(int h){
    vector<vector<int> > mp(5,vector<int>(h));
    for(int i = h-1; i >= 0; i--){
        for(int j = 0; j < 5; j++){
            cin >> mp[j][i];
        }
    }
    ll ans = 0;
    ll pre_ans = 0;
    int ch = h;
    // cout << "inputted" << endl;
    while(true){
        for(int i = ch-1; i >= 0; i--){
            int str = 0;
            int pre = 0;
            int j;
            for(j = 0; j < 5; j++){
                if(mp[j].size() <= i || (str != 0 && mp[j][i] != pre)){
                    if(str >= 3) break;
                    str = 1;
                    pre = mp[j][i];
                    continue;
                }
                if(mp[j][i] == pre){
                    str++;
                } else {
                    pre = mp[j][i];
                    str = 1;
                }
            }
            // cout << "evaluated" << endl;
            // cout << "i:" << i << " j:" << j << " str:" << str << endl;
            if(str >= 3){
                int st = j-str;
                for(int k = st; k < j; k++){
                    auto it = mp[k].begin();
                    it+=i;
                    ans+=(*it);
                    mp[k].erase(it);
                }
            }
        }

        int tmp = 0;
        for(int i = 0; i < 5; i++){
            int height = mp[i].size();
            tmp = max(tmp,height);
        }
        ch = tmp;

        if(ans == pre_ans) break;
        else pre_ans = ans;

        
        // cout << "in while" << endl;
    }

    cout << ans << endl;
}

int main(){
    while(true){
        int h;
        cin >> h;
        if(h == 0) break;
        else solve(h);
    }
    return 0;
}


Measured memory_bytes: 3136
sx, sy, tx, ty = map(int, input().split())

dx = tx - sx
dy = ty - sy

ans = ""
for i in range(dx):
  ans += "R"
for i in range(dy):
  ans += "U"
for i in range(dx):
  ans += "L"
for i in range(dy+1):
  ans += "D"
for i in range(dx+1):
  ans += "R"
for i in range(dy+1):
  ans += "U"
ans += "LU"
for i in range(dx+1):
  ans += "L"
for i in range(dy+1):
  ans += "D"
ans += "R"

print(ans)

Measured memory_bytes: 3064
#include<queue>
#include <iostream>
#include <algorithm>
#include<cmath>
#include<map>
typedef unsigned long long ll;
using namespace std;
int main()
{
  ll n,k,h,sum=0;
  cin>>n>>k;
  ll arr[n];
  for(int i=0;i<n;i++)
  {
      cin>>h;
      arr[i]=h;
  }
  if(k>n)
  {
      cout<<0;
      return 0;
  }
  sort(arr,arr+n);
  for(int i=0;i<n-k;i++)
  {
      sum+=arr[i];
  }
  cout<<sum;
}


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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        B[i] = A[i];
    }
    sort(B.begin(),B.end());
    map<ll,int> mp;
    for(int i=0;i<N;i++){
        mp[B[i]] =i;
    }

    ll  canNotMove =0;
    for(int i=0;i<N;i++){
        int act = i;
        int ideal = mp[A[i]];
        // cerr <<"act=" << act << "ideal=" << ideal << endl;
        if(act%2 != ideal%2){
            canNotMove++;
        }
    }
    cout << canNotMove/2 << endl;


    return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define int long long
using namespace std;
int a[10];
 main()
{
    int n,b,r;
    cin>>n>>b>>r;
    int ans = n/(r+b);
    int mode = n%(r+b);
    int cur = ans*b + min(mode,b);
    cout<<cur<<endl;


    return 0;
}


Measured memory_bytes: 256
a, b = input().split(' ')
a = int(a)
b = int(b)
if (a<=0 and b>=0) or a==0 or b==0:
  print('Zero')
elif a>0 and b>0:
  print('Positive')
else:
  X = (abs(a) - abs(b))
  if X%2 == 0:
    print('Negative')
  else:
    print('Positive')

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

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	
	string s;
	int n; cin >> n;
	map<string, int> a;
	while (n--) {
		cin >> s;
		a[s]++;
	}
	cin >> n;
	while (n--) {
		cin >> s;
		a[s]--;
	}
	int ans = 0;
	for (auto it = a.begin(); it != a.end(); it++) {
		ans = max(ans, it->second);
	}
	cout << ans;
	
	return 0;
}

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

typedef long long int64;
int n, k;
int64 dp[105][5][2];
char a[105];

int64 F(int i, int c, int eq) {
	if(c > k)
		return 0;
	
	if(i == n + 1)
		return c == k;

	int64 &ans = dp[i][c][eq];

	if(ans != -1)
		return ans;

	ans = 0;

	int lim = eq ? (a[i] - '0') : 9;

	for(int d = 0; d <= lim; d++) {
		int neq = eq && d == (a[i] - '0');
		ans += F(i + 1, c + (d > 0), neq);
	}

	return ans;
}

int main() {
	scanf("%s%d", a + 1, &k);
	n = strlen(a + 1);

	memset(dp, -1, sizeof(dp));

	printf("%lld\n", F(1, 0, 1));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;

/**
 * 不安なら ll を使う.
 * 小数は double を忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 * pair<型, 型> 変数名
 * map<型, 型> 変数名  // 連想配列
 * priority_queue<型> 変数名  // 最大値から出てくるヒープ
 * 比較するときは型まで注意
 * 区間の計算は累積和
*/

/* ===== コーナーケースに気をつけろ ===== */

int main()
{
    string S;
    cin >> S;
    if (S.at(2) == S.at(3) && S.at(4) == S.at(5))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main (void)
{
    long long   X;
    long long money=100;
    long long count=0;

    scanf("%lld",&X);

    while(1){
        money*=1.01;
        count++;

        if(money>=X){
            break;
        }
    }

    printf("%lld",count);

    return 0;
}

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

ll bunkatu(int high, vector<ll> &A){
    ll cut=0;
    for(int i=0; i<A.size(); i++){
        cut += (A[i]-1)/high;
    }

    return cut;
}

int main(){
    ll N,K; cin>>N>>K;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    
    int a=0,b=0;
    for(int i=0; i<N; i++){
        b = max(b, int(A[i]));
    }

    while(a+1 != b){
        int high = (a+b)/2;
        ll cutnum = bunkatu(high, A);
        if(cutnum > K){
            a = high;
        }else{
            b = high;
        }
    }
    cout << b << endl;

}


Measured memory_bytes: 4824
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FOD(i,a,b) for(ll i=(a);i>=(b);--i)
#define name "a"
#define pb push_back
typedef pair < ll , ll > ii;
const ll maxn=1e5+7,oo=1e18,mod=1e9+7;
string s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen(name".inp","r",stdin);
    //freopen(name".out","w",stdout);
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{

    long int n, a, b;
    cin >> n >> a >> b;
    long int ans = 0;
    ans += (n / (a + b)) * a;
    n = n % (a + b);
    if (a > n)
    {
        ans += n;
    }
    else
    {
        ans += a;
    }
    cout << ans << endl;
}

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

int main()
{
    int arr[9], i, j, n, number, count=0, x;
    bool res=false;

    for(j=0; j<9; j++){
        cin>>arr[j];
    }

    cin>>n;

    for(i=0; i<n; i++){
        cin>>x;
        for(j=0; j<9; j++){
            if(x == arr[j])
                arr[j] = 0;
        }
    }

    for(i=0; i<9; i=i+3){
        if(arr[i] == arr[i+1] && arr[i] == arr[i+2])
            res = true;
    }

    for(i=0; i<3; i++){
        if(arr[i] == arr[i+3] && arr[i] == arr[i+6])
            res = true;
    }

    if(arr[0] == arr[4] && arr[0] == arr[8])
        res = true;

    if(arr[2] == arr[4] && arr[2] == arr[6])
        res = true;


    if(res)
        cout<<"Yes";
    else
        cout<<"No";

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

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

  int sum = 0;
  int mi = 0;
  int MIN = INF;
  REP(i, N){
    sum += abs(A[i]);
    if(A[i] < 0) mi++;

    chmin(MIN, abs(A[i]));
  }

  if(mi%2 == 0){
    cout << sum << "\n";
  }else{
    cout << sum-2*MIN << "\n";
  }

  return 0;
}

Measured memory_bytes: 1024
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int n,a;

main(){
	cin>>n;
	rep(i,n){
		cin>>a;
		if(a%2==1){
			dump("first");
			return 0;
		}
	}
	dump("second");
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	int r, g, b, k;
	cin >> r >> g >> b;
	cin >> k;
	int cnt = 0;
	while(r >= g){
		g *= 2;
		cnt++;
	}
	while(g >= b){
		b *= 2;
		cnt++;
	}
	if(cnt <= k){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


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

const int MAX = 100000;

int partition(int A[], int p, int r) {
    int x = A[r];
    int i = p - 1;
    for (int j  = p; j < r; j++) {
        if (A[j] <= x) {
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i + 1], A[r]);
    return i + 1;
}

int main(void) {
    int n, A[MAX];
    cin >> n;

    for (int i = 0; i < n; i++) cin >> A[i];

    int q = partition(A, 0, n - 1);
    for (int i = 0; i < n; i++) {

        if (i) cout << " ";
        if (i == q) cout << "[";
        cout << A[i];
        if (i == q) cout << "]";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1548
#include<bits/stdc++.h>
            using namespace std;
            #define rep(i,b) for(i=0;i<b;++i)
            #define repp(i,a,b) for(i=a;i<b;++i)
            #define endl "\n"
            //#define LLONG_MAX 99999999999999
            typedef long long int lli;
            int main(){
                //ios_base::sync_with_stdio(false);
                //cin.tie(NULL);
                lli t,n,i,j,b,a,q,m;
                cin>>n>>m;
                if(n>m){
                    cout<<"safe"<<endl;
                }
                else{
                    cout<<"unsafe"<<endl;
                }
                

            }



Measured memory_bytes: 3636
h,w=map(int,input().split())
g_list=[]
w_count=[0]*w

for i in range(h):
  a=input()
  if '#' in a:
    g_list.append(list(a))
    a_char=list(g_list[len(g_list)-1])
    for j in range(len(a_char)):
      if a_char[j] == '#':
        w_count[j] +=1

for k in range(len(w_count)):
  if w_count[len(w_count)-k-1] == 0:
    for l in range(len(g_list)):
      g_list[l].pop(len(w_count)-k-1)


for m in range(len(g_list)):
  print(''.join(g_list[m]))


Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;


int main() {
    int n,m;
    int ans = 0;
    cin >> n >> m;
    vector<vector<int>> g(n+1);
    for (int i=0; i<m; i++) {
        int a,b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for (int i=1; i<=n; i++) sort(g[i].begin(), g[i].end());
    vector<int> path(n-1);
    iota(path.begin(), path.end(), 2);

    do {
        bool f = true;
        int u = 1;
        for (int i=0; i<n-1; i++) {
            int v = path[i];
            auto it = lower_bound(g[u].begin(), g[u].end(), v);
            if (it == g[u].end() || *it != v) f = false;

            u = v;
        }
        if (f) ans++;
    } while (next_permutation(path.begin(), path.end()));

    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
ABS = []
for _ in range(N):
    a, b = map(int, input().split())
    ABS.append((a, b, a + b))
ABS.sort(key=lambda x: x[2], reverse=True)
print(sum([x[0] for x in ABS[::2]]) - sum([x[1] for x in ABS[1::2]]))


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

int main(){
    int n;
    bool flag=true;
    cin >> n;
    vector<string>a(n);
    rep(i,n){
        string s;
        cin >> s;
        a[i]=s;
        if(i!=0){
            if(s[0]!=a[i-1][a[i-1].length()-1]) flag=false;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(a[i]==a[j]) flag=false;
        }
    }
    if(flag) cout << "Yes" <<endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <unordered_map>
#include<iostream>

int main()
{
    std::unordered_map<std::string, int> mp;       // ローカル変数として、mp を生成
    std::string s;
    
    int count=0;
    int N;
    std::cin >> N;
    for(int i=0;i<N;i++){
      std::cin>>s;
      auto itr = mp.find(s);        // "xyz" が設定されているか？
      if( itr == mp.end() ) {
        mp[s]=1;
        count++;
      }
    }
  
    std::cout<<count<<std::endl;
    
}

Measured memory_bytes: 17728
def main():
    N, C = list(map(int, input().split(' ')))
    progams = [list(map(int, input().split(' '))) for _ in range(N)]
    progams.sort(key=lambda p: p[0])  # sort in ascending order of start time
    recorders = [[0, 0] for _ in range(C)]  # (end time, channel)
    for prog in progams:
        s, t, c = prog
        for i in range(C):
            can_record = (c == recorders[i][1] and recorders[i][0] <= s) or \
                (c != recorders[i][1] and recorders[i][0] < s)
            if can_record:
                recorders[i][0] = t
                recorders[i][1] = c
                break
    ans = 0
    for i in range(C):
        if recorders[i][0] > 0:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

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

int main() {

    int sum, t, curr;
    for (; ;) {
        scanf("%d", &sum);
        if (sum == 0) break;
        curr = 0;
        for (int i = 0; i < 9; i++) {
            scanf("%d", &t);
            curr+= t;
        }
        printf("%d\n", sum-curr);
    }
    return 0;
}


Measured memory_bytes: 2756
d = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
str_n = input()
n = int(str_n)
print(d[n-1])


Measured memory_bytes: 2940
$n = <>;
@A = split / /, <>;

$base = shift @A;
$flg = 0;
$count = 1;

for my $a (@A) {
    next if $base == $a;

    if ($a > $base ) {
        if ($flg == -1) {
            $count++;
            $flg = 0;
        }
        else {
            $flg = 1;
        }
    }
    else {
        if ($flg == 1) {
            $count++;
            $flg = 0;
        }
        else {
            $flg = -1;
        }
    }

    $base = $a;
}

print $count;


Measured memory_bytes: 11724
#include<bits/stdc++.h>
 
#define INF 1000000007
#define LINF 1000000000000000007
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;


string s;

int main(){
	cin >> s;
	
	int cnt = 0;
	for(int i = 0; i < 6 ;i++){
		if(s[i] == '1') cnt++;
	}
	
	cout << cnt << endl;
	
	return 0;
}

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

int main()
{
  string S;
  int i, sum=0;
  
  while(true)
  {
  	sum=0;
    cin >> S;
    
    if(S.at(0)=='0')
      break;
    
    for(i=0;i<S.size();i++)
    {
      sum += S.at(i) - '0';
    }
    //i=0;
    //while(S.at(i) != '\0')
    //{
      //sum += S.at(i) - '0';
      //i++;
    //}
    cout << sum << endl;
  }
  
  return 0;
}



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


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

    int N;
    cin >> N;
    int A[N];
    rep(i,N){
        cin >> A[i];
    }
    int B[N];
    rep(i,N){
        B[i]=A[i];
    }
    sort(B,B+N);
    if(B[N-1]==B[N-2]){
        rep(i,N){
            cout << B[N-1] << endl;
        }
    }
    else{
        rep(i,N){
            if(A[i]==B[N-1]){
                cout << B[N-2] << endl;
            }
            else cout << B[N-1] << endl;
        }
    }
}




Measured memory_bytes: 3200
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

int main() {
	fast_cin();
	int n; cin >> n;
	int ans = 0;
	int c1 = 0, c2 = 0, c3 = 0;
	for (int i = 0; i < n; ++i) {
		string s; cin >> s;
		int m = s.length();
		for (int j = 0; j < m - 1; ++j) {
			if (s[j] == 'A' and s[j + 1] == 'B') {
				++ans;
			}
		}
		if (s[0] == 'B' and s[m - 1] == 'A') {
			++c3;
		} else if (s[0] == 'B') {
			++c2;
		} else if (s[m - 1] == 'A') {
			++c1;
		}
	}
	if (c3) {
		ans += c3 - 1;
		if (c1) {
			++ans;
			--c1;
		}
		if (c2) {
			++ans;
			--c2;
		}
	}
	ans += min(c1, c2);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

#ifndef U_L_LONG
typedef unsigned long long U_L_LONG;
#endif
#ifndef L_LONG
typedef long long L_LONG;
#endif


static void ABC109C_task();

#if 1
int main()
{
	ABC109C_task();

	fflush(stdout);
	return 0;
}
#endif

template <class _Ty> _Ty tp_gcd(_Ty first, _Ty second)
{
	_Ty num1 = first, num2 = second;
	_Ty remainder = 0, common = 0;

	if (!num1) return num2;
	if (!num2) return num1;

	while (!common) {
		remainder = num1 % num2;

		if (remainder == 0) {
			common = num2;
		}
		else {
			num1 = num2;
			num2 = remainder;
		}
	}
	return(common);
}

static void ABC109C_task()
{
	int N, X;

	scanf(" %d %d", &N, &X);

	auto xpoint = new int[N + 2];
	for (int i = 0; i < N; i++) {
		scanf(" %d", &xpoint[i]);
	}
	xpoint[N] = X;

	std::sort(xpoint, xpoint + N + 1);

	int diff = 0, bfrDiff = 0, gcd = 0;
	for (int i = 0; i < N; i++) {
		diff = xpoint[i + 1] - xpoint[i];
		gcd = tp_gcd<int>(diff, gcd);
	}

	printf("%d\n", gcd);

	delete[] xpoint;
}


Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
#define INF 999999999
#define lint long long
#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define rep0(i, n) for(int i = 0; i < (int)(n); i++)
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
    lint N;
    lint T=0, A=0;
    cin >> N;
    rep(i, N){
        lint t, a;
        cin >> t >> a;
        if (i==1){T=t; A=a;}
        lint m = max(T/t+(T%t==0?0:1), A/a+(A%a==0?0:1));
        T=t*m; A=a*m;
    }
    cout << T+A;
    return 0;
}

Measured memory_bytes: 256
import math
import sys
s = input()
n = int(len(s))

if s[0:math.floor(n/2)] != s[math.ceil(n/2):]:
  print('No')
  sys.exit()

j = int((n-1)/2)-1
for i in range(int((n-1)/2)):
  if s[i] != s[j]:
    print('No')
    sys.exit()
  j -= 1

j=-1
for i in range(int((n+3)/2-1),n):
  if s[i] != s[j]:
    print('No')
    sys.exit()
  j -= 1

print('Yes')


Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<cstring>
#define MAX 10010

using namespace std ;

int main ( )
{
    int n;
    while(scanf("%d", &n) == 1)
    {
        long long sum = 0;
        for(int i = 0; i < n; ++ i)
        {
            int a, b;
            char c[10];
            scanf("%d %s %d", &a, c, &b);
            if(c[0] == '(') sum += b;
            else sum -= b;
            if(sum == 0) puts("Yes");
            else puts("No");
        }
    }
    return 0 ;
}

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

a = list(map(int,input().split()))

for i in range(n):
    for j in range(n):
        if a[i] < a[j]:
            work = a[i]
            a[i] = a[j]
            a[j] = work

s1 = 0
s2 = 0

for i in range(0,n,2):
    s1 += a[i]

for i in range(1,n,2):
    s2 += a[i]

output = s2-s1

if output < 0:
    output *= -1

print(output)

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

int main()
{
    string s, t;
    cin >> s >> t;
    int count = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] != t[i])
            count++;
    }
    cout << count;
    return 0;
}


Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> dp(N+1,INF);
    vector<ll> h(N+1);
    REP(i,N) cin >> h[i+1];
    dp[1] = 0;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=2;j++){
            if(i-j>=0) chmin(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
        }
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		int maxv = Integer.MIN_VALUE;
		int minv = Integer.MAX_VALUE;
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		int input;

		for (int j = 0; j < n; j++) {
			input = scanner.nextInt();
			if (j == 0) {
				minv = input;
			} else {
				maxv = Math.max(maxv, input - minv);
				minv = Math.min(minv, input);
			}
		}

		System.out.println(maxv);
	}
}

Measured memory_bytes: 94324
#include <iostream>
#include <cstring>
using namespace std;
int main(){
	int N;
	while( cin >> N, N ){
		int i, j, k, l;
		int W, H, S, T;
		cin >> W >> H;
		char field[100][100];
		memset(field, '.', sizeof(field));
		for( i = 0; i < N; i++ ){
			int X, Y;
			cin >> X >> Y;
			field[X-1][Y-1] = '*';
		}
		cin >> S >> T;
		int max = 0;
		for( i = 0; i < W-S+1; i++ ){
			for( j = 0; j < H-T+1; j++ ){
				int sum = 0;
				for( k = 0; k < S; k++ ){
					for( l = 0; l < T; l++ ){
						if( field[i+k][j+l] == '*' ){
							sum++;
						}
					}
				}
				if( max < sum ){ max = sum; }
			}
		}
		cout << max << endl;
	}
}

Measured memory_bytes: 1176
x=[]
y=[]
z=[]
while True:
    try:
        n=int(input())
        x.append(n)
    except EOFError:
        break
    
Counter = [0] * 101

for n in x:
    Counter[n] += 1
    y.append(Counter[n])
#    print(n)
    
#print(y)
#print(x)

y_len=len(y)
for i in range(y_len):
#    print(i,x[i],y[i])
    if y[i]==max(y):
#        print(x[i])
        z.append(x[i])
#print(z)
z.sort()
z_len=len(z)
for i in range(z_len):
    print(z[i])
    
    


Measured memory_bytes: 5592
#include <stdio.h>

int main(){
    int A, B;
    do{
        scanf("%d %d", &A, &B);
    }while(A<1|| A>3||B<1|| B>3);
    if((A*B)%2!=0){
        printf("Yes");
    }
    else{
       printf("No");
    }

    return 0;
}


Measured memory_bytes: 128
import fractions

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

A -= 1

Z = ((C * D) // fractions.gcd(C, D))

A_C = A // C
A_D = A // D
A_Z = A // Z

A_num = A - (A_C + A_D - A_Z)

B_C = B // C
B_D = B // D
B_Z = B // Z


B_num = B - (B_C + B_D - B_Z)


print(B_num - A_num)



Measured memory_bytes: 5076
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll vis[200003]={0};
ll vis2[200003]={0};
vector<ll>adj[200003];
vector<ll>x;
ll ans[200003];
ll n;
void dfs(ll k,ll count)
{
    vis[k]=1;
    vis2[k]=1;
    for(ll i=0;i<adj[k].size();i++)
    {
           if(vis[adj[k][i]]==0)
           {
               count++;
               dfs(adj[k][i],count);
           }
    }
    for(ll i=1;i<=n;i++)
    {
        if(vis2[i]==1)
            {ans[i]=count;
              vis2[i]=0;
            }
    }

}

int main()
{
   ll n;
   cin>>n;
   set<string>s;
   ll i;
   for(i=0;i<n;i++)
   {
       string t;
       cin>>t;
       s.insert(t);
   }
   cout<<s.size()<<endl;

}


Measured memory_bytes: 23812
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

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;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(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()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N,M;
bitset<701> adj[701];
int vis[701];
vi x[3];

void dfs(int a, int b) {
    if (vis[a]) {
        if (vis[a] != b) {
            cout << -1;
            exit(0);
        }
        return;
    }
    vis[a] = b; x[b].pb(a);
    FOR(i,1,N+1) if (adj[a][i]) dfs(i,b^3);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> M;
    FOR(i,1,N+1) FOR(j,i+1,N+1) adj[i][j] = adj[j][i] = 1;
    F0R(i,M) {
        int a,b; cin >> a >> b;
        adj[a][b] = adj[b][a] = 0;
    }
    bitset<701> posi; posi[0] = 1;
    FOR(i,1,N+1) if (!vis[i]) {
        x[1].clear(), x[2].clear();
        dfs(i,1);
        posi = (posi<<sz(x[1]))|(posi<<sz(x[2]));
    }
    ll ans = INF;
    F0R(i,N+1) if (posi[i]) ans = min(ans,(ll)i*(i-1)/2+(N-i)*(N-i-1)/2);
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

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

int main(){
	int n;
	int d[110];
	cin >> n;
	int num[110] = {0};
	rep(i,n){
		cin >> d[i];
		num[d[i]]++;
	}
	int ans = 0;
	for(int i = 1;i<=100;++i){
		if(num[i]) ++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#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>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N, M;
    cin >> N >> M;
    ll adj[10][10] = {{}};
    rep(i, M) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        adj[a][b] = 1;
        adj[b][a] = 1; 
    }
    ll v[10];
    rep(i, 10) v[i] = i;
    ll ans = 0;
    do{
        if (v[0] != 0) continue;
        bool flag = false;
        rep(i, N-1) {
            if (adj[v[i]][v[i+1]] == 0) flag = true; 
        }
        if (!flag) {
            ans++;
        }
    }while(next_permutation(v,v+N));
    print(ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  map<int,int> a,b;
  rep(i,n){
    int c;
    cin >> c;
    if(i%2 == 0) a[c] ++;
    else b[c] ++;
  }
  vector<P> a_p(0);
  vector<P> b_p(0);
  for(auto i : a){
    P tmp = make_pair(i.second, i.first);
    a_p.push_back(tmp);
  }
  for(auto i : b){
    P tmp = make_pair(i.second, i.first);
    b_p.push_back(tmp);
  }
  sort(a_p);
  reverse(a_p);
  sort(b_p);
  reverse(b_p);
  int ans;
  if(a_p[0].second == b_p[0].second){
    int cand1 = n - a_p[0].first - b_p[1].first;
    int cand2 = n - a_p[1].first - b_p[0].first;
    ans = min(cand1,cand2);
  }else{
    ans = n - a_p[0].first - b_p[0].first;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6136
n = int(input())
h = list(map(int, input().split()))
a = [0]
i = 0
while i < n - 1:
  k = 0
  p = h[i]
  for j in range(i + 1, n):
    if p >= h[j]:
      p = h[j]
      k += 1
    else:
      break
  i = j
  a.append(k)
print(max(a))

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V  = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class H> void rsz(V<T> &v, H h) { v.resize(h); }
template<class T, class H, class... R> void rsz(V<T> &v, H h, R... r) { v.resize(h); for (auto&& i : v) rsz(i, r...); }
using P = pair<int, int>;
struct QF {
  V<> par; V< set<int> > chi;
  QF(int n) { par.resize(n); chi.resize(n); for (int i = 0; i < n; i++) par[i] = i, chi[i].insert(i); }
  bool same(int x, int y) { return par[x] == par[y]; }
  void _merge(int x, int y) { for (int i : chi[y]) par[i] = x; chi[x].insert(chi[y].begin(), chi[y].end()); chi[y].clear(); }
  void unite(int x, int y) { if (chi[par[x]].size() < chi[par[y]].size()) swap(x, y); if (!same(x, y)) _merge(par[x], par[y]); }
};

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  V<> k(n); VV<> l(n);
  for (int i = 0; i < n; i++) {
    cin >> k[i];
    l[i].resize(k[i]); for (int j = 0; j < k[i]; j++) cin >> l[i][j];
  }
  V<P> a;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < l[i].size(); j++) a.emplace_back(l[i][j], i);
  }
  sort(a.begin(), a.end());
  QF qf(n);
  for (int i = 0; i < a.size() - 1; i++) {
    if (a[i].first == a[i + 1].first) qf.unite(a[i].second, a[i + 1].second);
  }
  cout << (qf.chi[qf.par[0]].size() == n ? "YES" : "NO") << '\n';
}

Measured memory_bytes: 16888
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	/* ----- 変数宣言 ----- */
	string s;
	int abc[3] = { 0,0,0 };

	/* ----- 入力 ----- */
	cin >> s;

	/* ----- 計算 ----- */
	sort(s.begin(), s.end());

	/* ----- 出力 ----- */
	if (s == "abc")		cout << "Yes" << endl;
	else				cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  long n,m,i,j,x[100010],y[100010],g=0,ans=0;
  const long mod=1e9+7;
  cin >> n >> m;
  for (i=0;i<n;i++) cin >> x[i];
  for (j=0;j<m;j++) cin >> y[j];
  for (i=0;i<n-1;i++) g=(g+(x[i+1]-x[i])*(i+1)*(n-i-1))%mod;
  for (j=0;j<m-1;j++) ans=(ans+(g*(y[j+1]-y[j]))%mod*(j+1)*(m-j-1))%mod;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
n,m=map(int,input().split())
UF=UnionFind(n+m)
s=set()
for i in range(n):
    l=list(map(int,input().split()))
    for j in l[1:]:
        UF.Unite(i,n+j-1)
        s.add(j)
print("YES" if UF.Count(0)-len(s)==n else "NO")

Measured memory_bytes: 11060
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
 	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int length = arr.length;
		int[] counts = new int[length];
		boolean isRight = true;
		int rightCount = 0;
		for (int i = 0; i < length; i++) {
		    if (isRight) {
		        if (arr[i] == 'R') {
		            rightCount++;
		        } else {
		            counts[i] += rightCount / 2;
		            counts[i - 1] += rightCount - rightCount / 2;
		            isRight = false;
		            rightCount = 0;
		        }
		    } else {
		        if (arr[i] == 'R') {
		            isRight = true;
		            rightCount++;
		        }
		    }
		}
		boolean isLeft = true;
		int leftCount = 0;
		for (int i = length - 1; i >= 0; i--) {
		    if (isLeft) {
		        if (arr[i] == 'L') {
		            leftCount++;
		        } else {
		            counts[i] += leftCount / 2;
		            counts[i + 1] += leftCount - leftCount / 2;
		            isLeft = false;
		            leftCount = 0;
		        }
		    } else {
		        if (arr[i] == 'L') {
		            isLeft = true;
		            leftCount++;
		        }
		    }
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < length; i++) {
		    if (i != 0) {
		        sb.append(" ");
		    }
		    sb.append(counts[i]);
		}
		System.out.println(sb);
   }
}




Measured memory_bytes: 28024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,t;
char ch;
int mp[12],sz[12];
vector<int> a,b;
	set<string> rs;
string s;
void permut()
{
	ch='a';	

	memset(mp,0,sizeof(mp));
	for (int i = 0; i < a.size(); ++i)
	{
		// cout<<a[i]<<" ";
		if(mp[a[i]]==0)
			mp[a[i]]=ch++;
		s[i]=mp[a[i]];
	}
	// cout<<"\n";
	rs.insert(s);
}
void solve(int p,int mx)
{
	if(p==(n))
	{
		permut();
	}else
	{
		for (int i = 0; i <= mx+1; ++i)
		{
			if( sz[i]!=0)
			{
				sz[i]--;
				a[p]=i;
				solve(p+1,max(i,mx));
				sz[i]++;
			}
		}	
	}

}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	a.resize(n);
	s.resize(n);
	for (int i = 0; i < n; ++i)
	{
		sz[i]=n-i;
	}
	solve(0,-1);
	// cout<<rs.size()<<"\n";
	// sort(rs.begin(),rs.end());
	for(auto c:rs)
	{
		cout<<c<<"\n";
	}
	return 0;
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001

const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint = Fp<MOD>;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    ll sum = 0;
    rep(i,N){
        sum += A[i];
        sum %= MOD;
    }
    ll ans = 0;
    rep(i,N){
        sum -= A[i];
        if(sum < 0) sum += MOD;
        ans += sum * A[i] % MOD;
        ans %= MOD;
    }
    cout << ans % MOD << endl;
}


Measured memory_bytes: 4844
# https://atcoder.jp/contests/abc058/tasks/arc071_a
# 共通要素を抜き出しソート

from collections import Counter, defaultdict
from functools import reduce
n = int(input())
S = []
for _ in range(n):
    S.append(Counter(input()))


def f(x, y):
    '''各文字数のminをとる、最大公約数的なね'''
    ret = defaultdict(lambda: 0)
    for key in set(list(x.keys()) + list(y.keys())):
        ret[key] = min(x[key], y[key])
    return ret


res = reduce(f, S)
ans = []
for key in sorted(res.keys()):
    ans.append(key * res[key])
print(''.join(ans))


Measured memory_bytes: 9612
from collections import deque
C=[list(map(int,input().split())) for _ in range(3)]

for i in range(1):
    q=deque([C[0][0]-i,C[0][1]-i,C[0][2]-i,C[0][0]-i,C[0][1]-i,C[0][2]-i])
    flag=0
    for j in range(1,3):
        d=set()
        for k in range(3):
            d.add(C[j][k]-q.popleft())
        if len(d)==1:
            flag+=1
    if flag==2:
        print('Yes')
        exit()

print('No')

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long int a,b,c,p,q,x,y,z;
	cin>>a>>b>>c;
	x=abs(a-b)+abs(a-c);
	y=abs(b-c)+abs(b-a);
	z=abs(c-a)+abs(c-b);
	p=min(y,z);
	q=min(p,x);
	cout<<q<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
  int i,len;
  string a;
  char b,c;
  cin >> a;
  len = a.length();
  b = a[0];
  c = a[len-1]; 
  cout << b << len-2 << c;
  return 0;
}

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


int main()
{

    string s[] = {"SUN" ,"MON" , "TUE" , "WED" , "THU" , "FRI" , "SAT"};


    string st;



    cin >> st;

    for(int i=0; i<7; i++)
    {
        if(st==s[i])
        {
            cout << 7-(i+1) + 1 << endl;
            return 0;
        }

    }






    return 0;
}


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

int main(){
  long long int cnt=0,ans=0,N;
  vector<long long int> A(100010);
  
  cin>>N;
  A.resize(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  int i=0;
  while(i<N){
    int aa=A.at(i);
    cnt=0;
    while(i<N&&aa==A.at(i)){
      i++;
      cnt++;
      
     // cout<<cnt<<endl;
    }
    ans+=cnt%2;
  }
  cout<<ans<<endl;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

ll x,y;

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

	cin>>x>>y;
	if(x<y) {
		if(x*y>=0) cout<<abs(y-x)<<endl;
		else cout<<abs(x+y)+1<<endl;
	}
	else {
		if(x*y>0) cout<<abs(x-y)+2<<endl;
		else cout<<abs(x+y)+1<<endl;
	}

	return 0;
}


Measured memory_bytes: 256