akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main() {
	double wei;
	while( scanf("%lf", &wei)!=EOF ) {
		if (wei<=48.00) printf("light fly\n");
		if ( (48.00<wei)&&(wei<=51.00) ) printf("fly\n");
		if ( (51.00<wei)&&(wei<=54.00) ) printf("bantam\n");
		if ( (54.00<wei)&&(wei<=57.00) ) printf("feather\n");
		if ( (57.00<wei)&&(wei<=60.00) ) printf("light\n");
		if ( (60.00<wei)&&(wei<=64.00) ) printf("light welter\n");
		if ( (64.00<wei)&&(wei<=69.00) ) printf("welter\n");
		if ( (69.00<wei)&&(wei<=75.00) ) printf("light middle\n");
		if ( (75.00<wei)&&(wei<=81.00) ) printf("middle\n");
		if ( (81.00<wei)&&(wei<=91.00) ) printf("light heavy\n");
		if (91.00<wei) printf("heavy\n");
		if (wei<=0.0) break;
	}
	return 0;
}

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

int main() {
        string s;
        cin >> s;
        int n = stoi(s), sum = 0;
        for (int i = 0; i < s.size(); i ++) sum += s[i] - '0';
        puts(n % sum == 0 ? "Yes" : "No");
        return 0;
}


Measured memory_bytes: 256
// 自力で解答
//
// 5n + 2のタイプの素数ばかり集めると、
// どの素数を5個集めてもその和は必ず5で割り切れる

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

vector<ll> getPrimesFast(ll n){
    vector<ll> primes;
    if (n < 10000){
        primes.clear();
        if (n < 2){
            return primes;
        }
        primes.push_back(2);
        if (n == 2){
            return primes;
        }
        primes.push_back(3);
        if (n == 3){
            return primes;
        }
        for(ll i = 5; i <= n; i += 2){
            bool isPrime = true;
            for(int p = 0; p < (int)primes.size(); ++p){
                if (i % primes[p] == 0){
                    isPrime = false;
                    break;
                }
            }
            if (isPrime) {
                primes.push_back(i);
            }
        }
        return primes;
    }
    else{
        vector<ll> sieve = getPrimesFast(sqrt(n));

        vector<short> isPrime(n+1, 1);
        for(int i = 0; i < (int)sieve.size(); ++i){
            for(int j = sieve[i] * 2; j <= n; j += sieve[i]){
                isPrime[j] = 0;
            }
        }

        for(int i = 2; i <= n; ++i){
            if (isPrime[i]){
                primes.push_back(i);
            }
        }
        return primes;
    }
}

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;

    auto primes = getPrimesFast(55555);
    vector<int> ans;
    for(auto p: primes) {
        if (p % 5 == 2) {
            ans.pb(p);
            if (SIZE(ans) == N) break;
        }
    }
    cout << ans[0];
    FOR(n, 1, N) {
        cout << " " << ans[n];
    }
    cout << endl;

    return 0;
}


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

char s[1010];
int main(void)
{
	int n;
	cin >> n;
	cin >> s;
	int ans = 0;
	int h = 0;
	for(int i=0; i<n; ++i)
	{
		if(s[i]=='I')
			h++;
		else
			h--;
		ans = max(ans, h);
	}
	cout << ans << endl;
	
	return 0;
}

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

int main() {
    lli n;
    cin1(n);

    vector<char> ans;
    lli base = 1;
    while (n != 0) {
        if (n % (base * 2) == 0) {
            ans.push_back('0');
            //cout << 0 << endl;
        }
        else {
            ans.push_back('1');
            //cout << 1 << endl;
            n -= base;
        }
        base *= -2;
    }
    if (ans.size() == 0)
        ans.push_back('0');
    REPE_R(i,ans.size()-1, 0) {
        cout << ans[i];
    }
    cout << endl;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<map>
#define int long long int
int32_t main()
{
     string str;
     cin>>str;
     bool result=false;
     int j;
     int l=str.size();
     if(l==2)
     {
		 if(str[0]==str[1])
		     cout<<1<<" "<<2<<endl;
		 else
		    cout<<-1<<" "<<-1<<endl;
		 exit(0);
	 }
     int x,y;
     for(j=0;j<=l-3;j++)
     {
		 if(str[j]==str[j+1]||str[j+1]==str[j+2]||str[j]==str[j+2])
	     {
			 x=j;
			 y=j+2;
			 result=true;
			 break;
		 }
	 }
	 if(result)
	     cout<<x+1<<" "<<y+1<<endl;
	 else
	     cout<<-1<<" "<<-1<<endl;
}


Measured memory_bytes: 512
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int A, B; cin >> A >> B;
    cout << max({A+B, A-B, A*B}) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;class Main {public static void main(String[]z){Scanner s = new Scanner(System.in);int[]a=new int[10];int i,j=2,x,y;for(j=x=y=2;j-->0;y=x,x=a[9]+a[8]+a[7]){for(i=10;i-->0;)a[i]=s.nextInt();Arrays.sort(a);}System.out.println(y+" "+x);}}

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

//#define int long long
const int MOD = 1e9 + 7;
using ll = long long;
using intpair = pair<int, int>;
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    int n, m, x;
    cin >> n >> m >> x;
    int c[n], a[n][m];
    
    rep(i,n){
        cin >> c[i];
        rep(j,m) cin >> a[i][j];
    }
    
    bitset<20> b;
    int ans = INT_MAX;
    for(int bi = 0; bi < (1 << n); ++bi) {
        b = bi;
        vector<int> skill(m,0);
        int cost = 0;
        for(int i = 0; i < n; ++i) {
            if(b[i]) {
                cost += c[i];
                rep(j,m) skill[j] += a[i][j];
            }
        }
        if(all_of(ALL(skill), [&](int i){return i >= x;})){
            ans = min(ans, cost);
        }
    }
    
    if(ans == INT_MAX){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
}

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

#define INF 1e9
using namespace std;
using ll = long long;

int main() {

    int n; cin >> n;

    map<vector<ll>, ll> S;

    for (ll i = 0; i < n; ++i) {
        vector<ll> t(30, 0);

        string s;
        cin >> s;

        for (ll j = 0; j < s.size(); ++j) {
            ++t[s[j] - 'a'];
        }

        auto itr = S.find(t);
        if (itr != S.end()) {
            ++S[t];
        } else {
            S[t] = 1;
        }
    }

    ll ans = 0;

    for (auto itr = S.begin(); itr != S.end(); ++itr) {
        if (itr->second > 1) {
            ans += (itr->second * (itr->second - 1)) / 2;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 33024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] original = new string[8];

            for (int i = 0; i < 8; i++)
            {
                original[i] = Console.ReadLine();
            }

            char[,] right = new char[8, 8];
            char[,] rev = new char[8, 8];
            char[,] left = new char[8, 8];

            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    right[j, 7 - i] = original[i][j];
                    rev[7 - i, 7 - j] = original[i][j];
                    left[7 - j, i] = original[i][j];
                }
            }

            Console.WriteLine(90);
            Print(right);
            Console.WriteLine(180);
            Print(rev);
            Console.WriteLine(270);
            Print(left);
        }

        static void Print(char[,] map)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    sb.Append(map[i, j]);
                }
                sb.Append("\n");
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9016
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int d,t,s;
    cin>>d>>t>>s;

    if(d<=t*s)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


    



}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	string S;
	cin >> S;

	int ans = 0;
	rep(i, S.size()) ans += S[i] - '0';

	int pt = 0;
	while (S[pt] == '9' && pt < S.size()) {
		pt++;
	}

	if (pt == S.size()) {
		cout << 9 * S.size() << endl;
	} else {
		if (pt == 0) {
			S[pt]--;
			int ret = S[pt] - '0' + pt * 9;
			pt++;
			while (pt < S.size()) {
				ret += 9;
				pt++;
			}
			cout << max(ans, ret) << endl;
		} else {
			S[pt - 1]--;
			int ret = S[pt - 1] - '0' + (pt - 1) * 9;
			while (pt < S.size()) {
				ret += 9;
				pt++;
			}
			cout << max(ans, ret) << endl;
		}
	}

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define pii pair<int, int>
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e2 + 10;

bitset<N * N> dp;


int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	dp[0] = 1;
	for(int i=0; i<n; i++){
		int t; cin >> t;
		dp |= dp << t;
	}
	int ans = 0;
	for(int i=1; i<N*N; i++)
		if(dp[i] && (i % 10))ans = max(ans, i);
	cout << ans << endl;
}


Measured memory_bytes: 256
a,b = map(int,input().split())

if a == b:
    print(a)
    exit()
ansl = []
if a % 2 == 1:
    ansl.append(a)
    a += 1
if b % 2 == 0:
    ansl.append(b)
    b -= 1

k = b - a + 1
k = k // 2
if k % 2 == 1:
    ansl.append(1)
if len(ansl) == 0:
    print(0)
elif len(ansl) == 1:
    print(ansl[0])
elif len(ansl) == 2:
    print(ansl[0] ^ ansl[1])
else:
    print(ansl[0] ^ ansl[1] ^ ansl[2])

Measured memory_bytes: 38256
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

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

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;
#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define all(x) x.begin(),x.end()
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


void solve()
{
    
    char c;
    cin>>c;
    c=c+1;
    cout<<c<<endl;
}
int32_t main()
{
    IOS;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl "\n"
#define p_b push_back
#define fastIO ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
template <class T> 
using _ost = tree<
		T, 
		null_type, 
		less<T>, 
		rb_tree_tag, 
        tree_order_statistics_node_update>;
// char alphabet[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
void swap(int* a,int* b){
    int temp = *a;
    *a=*b;
    *b=temp;
}	
int32_t main(){
 	fastIO;
 	int n,x,y;
 	cin>>n>>x>>y;
 	int ans[n]={0};
 	for(int i=1;i<n;i++){
 		for(int j=i+1;j<=n;j++){
 			int dist=j-i;
 			dist=min(dist,abs(i-x)+1+abs(j-y));
 			ans[dist]++;
 		}
 	}
 	for(int i=1;i<n;i++)cout<<ans[i]<<endl;
} 	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define debug(...) \
    { cerr << "# " << __VA_ARGS__ << "\n"; }
#else
#define debug(...)
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
   public:
    i64 d[5555], dd[5555];
    void solve() {
        int k, q;
        cin >> k >> q;
        for (int i = 0; i < k; ++i) cin >> dd[i];
        while (q--) {
            i64 n, x, m;
            cin >> n >> x >> m;
            i64 ans = n - 1;
            i64 c = (n - 1) / k, cc = (n - 1) % k;
            i64 add = 0;
            for (int i = 0; i < k; ++i) {
                d[i] = dd[i] % m;
                if (d[i] == 0)
                    ans -= c;
                if (d[i] == 0 && i + 1 <= cc)
                    ans--;
                if (i + 1 <= cc)
                    add += d[i] * c + d[i];
                else
                    add += d[i] * c;
            }
            i64 y = x + add;
            i64 cntR = y / m + 1, cntL;
            if (x == 0)
                cntL = 0;
            else
                cntL = (x - 1) / m + 1;
            ans -= cntR - cntL;
            if (x % m == 0)
                ans++;
            cout << ans << '\n';
        }
    }
} NSPACE;
int main() {
    FPEN;
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    NSPACE.solve();
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mp make_pair
const int maxn = 4e5+5;
const int MOD = 1e9+7;
#define mod(x) x % MOD
#define INF 0x3f3f3f3f

int a[maxn][4];
int dp[maxn][4];

int main(){
    int n = 0;
    while(~scanf("%d", &n)){
        for(int i = 1;i <= n;i++){
            for(int j = 1;j <= 3;j++){
                scanf("%d", &a[i][j]);
            }
        }
        dp[1][1] = a[1][1];
        dp[1][2] = a[1][2];
        dp[1][3] = a[1][3];
        for(int i = 2;i <= n;i++){
            dp[i][1] = max(dp[i-1][2], dp[i-1][3]) + a[i][1];//max(dp[i-1][1] + a[i][2], dp[i-1][1] + a[i][3]);
            dp[i][2] = max(dp[i-1][1], dp[i-1][3]) + a[i][2]; //max(dp[i-1][2] + a[i][1], dp[i-1][2] + a[i][3]);
            dp[i][3] = max(dp[i-1][1], dp[i-1][2]) + a[i][3]; //max(dp[i-1][3] + a[i][1], dp[i-1][3] + a[i][2]);
            //cout<<dp[i][1]<<" "<<dp[i][2]<<" "<<dp[i][3]<<endl;
        }
        /*for(int i = 1;i <= 3;i++){
            cout<<dp[n][i]<<" "<<endl;
        }*/
        printf("%d\n",max(max(dp[n][1], dp[n][2]), dp[n][3]));
    }
    return 0;
}

Measured memory_bytes: 3840
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <random>
#include <bitset>
#include <time.h>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
//#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define sp system("pause")
#define queuel queue<long long>
#define all(x) (x).begin(),(x).end()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(),v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for(auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for(ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for(int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for(int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for(int i = 0; i < n; ++i){int a; cin >> a; s.insert(a);}
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const ll INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000;
const ld PI = acos(-1.0);
const ll mod1 = inf + 7;
const ll mod2 = inf + 9;
const int MAXN = 500001;
const ld EPS = 1e-9;
int hp = 179;

signed main()
{
	fastio();
	string s;
	cin >> s;
	cout << count(all(s), '+') - count(all(s), '-');
	sp;
}

Measured memory_bytes: 504
import java.io.*;

/**
 * Created by Ayushi on 19 Apr 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long n = Integer.parseInt(br.readLine());
        br.close();
        double ans = n*2;
        ans = ans * Math.PI;
        System.out.println(ans);
    }
}


Measured memory_bytes: 33176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int r,g,b;
  cin >> r >> g >> b;
  if((10*g+b)%4==0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
a.insert(0,0)
a.append(0)

s = sum([abs(a[i] - a[i+1]) for i in range(len(a) - 1)])

for i in range(1, len(a)-1):
    tmp = s + abs(a[i-1] - a[i+1]) -(abs(a[i-1] - a[i]) + abs(a[i] - a[i+1]))
    print(tmp)

Measured memory_bytes: 14048
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	cout<<n*n*n;
    return 0;
}


//252908XL

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

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

  int ans = 0;

  ans += 1 * min(a, k);
  k -= a;
  if (k > 0) {
    k -= b;
    if (k > 0) {
      ans += -1 * min(c, k);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
int n;
ll a[105];
int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n);
	cout << a[n - 1] - a[0];
	return 0;
}

Measured memory_bytes: 256
var n,i:int64;
    c:char;
begin
readln(n);

while true do
 begin
  read(c);
  if (ord(c)<65) or (ord(c)>90) then break;
  if ord(c)+n>90 then write(chr(ord(c)+n-26))
  else write(chr(ord(c)+n));
 end;
 
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int maxn=5e3+10,maxm=5e5+10;
string s,str[maxm];
int len,k,cnt;
int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	cin>>s>>k;
	int len=s.length();
	for(register int i=0;i<len;++i){
		string tmp="";
		for(register int j=i;j<len&&j-i<=k;++j){
			tmp+=s[j];
			str[++cnt]=tmp;
		}
	}sort(str+1,str+cnt+1);
	unique(str+1,str+cnt+1);
	cout<<str[k];
	return 0;
}


Measured memory_bytes: 5504
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
// #include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}
string BinaryNum(int N)
{
        string S;
        while (N != 0)
        {
                if (N % 2 == 1)
                {
                        N--;
                        S = '1' + S;
                }
                else
                {
                        S = '0' + S;
                }
                N /= 2;
        }
        return S;
}

int main() //input->compute->output
{
        int N;
        cin >> N;

        vector<int> vec(N);
        rep(i, N) { cin >> vec[i]; }

        ll dp[100010];
        rep(i, N) { dp[i] = 1e9; }

        dp[0] = 0;
        dp[1] = abs(vec[1] - vec[0]);

        rep2(i, 2, N){
                dp[i] = min(dp[i - 2] + abs(vec[i - 2] - vec[i]), dp[i - 1] + abs(vec[i - 1] - vec[i]));
        }

        cout<< dp[N - 1] << endl;

        return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ppb pop_back
int main()
{
	int a[3];
	for(int i=0;i<3;i++)
	{
		cin>>a[i];
	}
	sort(a,a+3);
	cout<<a[1]+a[0];
	return 0;
}



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

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var h = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

        var x = 0;
        var ans = 0;
        for (int i = 1; i < n; i++)
        {
            if (h[i - 1] >= h[i])
            {
                x++;
            }
            else
            {
                x = 0;
            }

            ans = Math.Max(ans, x);
        }

        Console.WriteLine(ans);
    }
}


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

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            var a = inputLongArray[0];
            var b = inputLongArray[1];

            var c = a * b;

            var result = c * c;
            
            Console.WriteLine((result % 2) == 0 ? "No" : "Yes");

        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define loop(i,n) for(ll i=0 ; i<n ; i++)
#define rep(i,x,n) for(ll i=x ; i<=n ; i++)
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll N=3e3 + 5,M=5e5+5, MOD=1e9 + 7 , MAX=5e6,OO=1e9;

int memo[N][N],n,t;
pair<int,int> arr[N];

int dp(int i,int sum){
    if(i>=n)return 0;
    if(sum>=t)return 0;
    int &res=memo[i][sum];
    if(res!=-1)return res;
    return res=max(dp(i+1,sum+arr[i].first)+arr[i].second,
            dp(i+1,sum));
}
int main() {
#ifndef ONLINE_JUDGE
   // freopen("in.txt", "rt", stdin);
#endif
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    memset(memo,-1,sizeof(memo));
    cin>>n>>t;
    loop(i,n){
        cin>>arr[i].first>>arr[i].second;
    }
    sort(arr,arr+n);
    cout<<dp(0,0)<<endl;
}

Measured memory_bytes: 35712
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

typedef long long ll;
const ll INF = 1e17;




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

	int H[200000];
	for (int i = 1; i <= N; i++) {
		cin >> H[i];
	}

	int ans = 0;
	int mov = 0;

	for (int i = 1; i <= N-1; i++) {
		if (H[i + 1] <= H[i]) {
			mov++;
			if (ans < mov) { ans = mov; }
		}

		else { mov = 0; }
		

	}

	cout << ans;


	system("PAUSE");
}


Measured memory_bytes: 888
#include <iostream>
using namespace std;
int main(void){
    int n,h,a,sum=0;
    
    cin >> h >> n;
    
    for(int i=0;i<n;i++){
        cin >> a;
        
        sum+=a;
    }
    
    if(sum>=h) cout << "Yes";
    else cout << "No";
    
    cout << endl;
    
    return 0;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    int N;
    ll T;
    cin>>N>>T;
    vector<vector<double>> rab(N, vector<double>(3));
    rep(i, N) {
        cin>>rab[i][1]>>rab[i][2];
        rab[i][0] = (-1.0) * rab[i][1] / (rab[i][2] + 1.0);
    }
    sort(rab.begin(), rab.end());
    int r = N;
    rep(i, N) {
        if ((ll)rab[i][1] == 0) {
            r = i;
            break;
        }
    }

    vector<vector<ll>> dp(2, vector<ll>(28 + 1, T + 1));
    dp[0][0] = 0;
    dp[1][0] = 0;
    rep(i, r) {
        rep(j, 28) {
            dp[(i + 1) % 2][j + 1] = min(dp[i % 2][j + 1], dp[i % 2][j] + 1 + (dp[i % 2][j] + 1) * (ll)rab[i][1] + (ll)rab[i][2]);
            if (dp[(i + 1) % 2][j + 1] > T) break;
        }
    }

    vector<ll> a0;
    for (int i = r; i < N; ++i) a0.push_back((ll)rab[i][2]);
    vector<int> cnt(29);
    rep(i, 29) {
        if (dp[r % 2][i] > T) break;
        cnt[i] = i;
        for (auto a : a0) {
            dp[r % 2][i] += a + 1;
            if (dp[r % 2][i] > T) break;
            cnt[i]++;
        }
    }

    int ans = *max_element(cnt.begin(), cnt.end());
    cout<<ans<<endl;
}

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

int main(void){
	int N, Y;
	cin >> N;
	cin >> Y;

	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= (N-i); j++) {
			int k = N-(i+j);
			int total = 10000*i + 5000*j + 1000*k; 
			if (total == Y) {
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}

	cout << -1 << " " <<  -1 << " "  << -1 << endl;
	return 0;
}

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

#define FOR(i,v,n) for(int i=v ; i<=n ; i++)
#define SORT(v) sort(v.begin(),v.end())
#define si(n) scanf("%d",&n)
#define sii(n,m) scanf("%d %d",&n,&m)
#define sl(n) scanf("%lld",&n)
#define sll(n,m) scanf("%lld %lld",&n,&m)
#define ss(cad) scanf("%s",cad)
#define llenar(mat,val) memset(mat,val,sizeof mat)
#define M 1000000007
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vp;
typedef vector<vector<pi> > Grafo_p;
typedef vector<vector<int> > Grafo;

char cad[200010];
ll n,res,x;
int main()
{
	scanf("%s",cad);
	n=strlen(cad);
	res=0;
	x=0;
	for(int i=0;i<n;i++){
		if(cad[i]=='B')
			x++;
		else
			res+=x;
	}
	printf("%lld\n",res );
    return 0;
}


Measured memory_bytes: 384
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.ListIterator;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		int M = nextInt();

		int[][] AB = new int[N][2];
		for(int i=0;i<N;i++) {
			AB[i] = nextIntArray(2);
		}
		Arrays.sort(AB,(a1,a2)->Integer.compare(a2[1],a1[1]));
		Arrays.sort(AB,(a1,a2)->Integer.compare(a1[0],a2[0]));

		List<Integer> list = new ArrayList<Integer>(N);
		long sum = 0;
		int AB_i = 0;
		for(int l=1;l<=M;l++) {
			int Search_l = -1;
			while(AB_i<N&&AB[AB_i][0]==l) {
				int Insert_i = Search(list ,AB[AB_i][1],Search_l);
				if(M<Insert_i)break;// 候補外となるため挿入する必要なし
				list.add(Insert_i,AB[AB_i][1]);
				AB_i++;
				Search_l = Insert_i;
			}

			if(list.size()>0) {
				sum+=list.get(0);
				list.remove(0);
			}

			if(list.size()>M*2) {
				ListIterator<Integer> removeList = list.listIterator(M);
				while (removeList.hasNext()) {
					removeList.next();
					removeList.remove();
				}
			}
		}

		out.println(sum);
	}

	//二部探索
	static int Search(List<Integer> list, int k, int Search_l) {
		int l = Search_l;
		int r = list.size();
		while(r - l > 1) {
			int mid = (r + l) / 2;
			if(list.get(mid) <= k) r = mid;
			else l = mid;
		}
		return r;
	}


	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}

Measured memory_bytes: 63908
#include<stdio.h>
#include<string.h>

int main(void){
    char S[5];
    scanf("%s",&S[0]);
    // printf("%d",strlen(S));
    
    if(strlen(S) == 2) {
        printf("%c%c",S[0],S[1]);
        return 0;
    }

    if(strlen(S) == 3) {
        printf("%c%c%c",S[2],S[1],S[0]);
        return 0;
    }

}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

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

const int dy[] = {0,0,1,-1};
const int dx[] = {1,-1,0,0};
int main()
{
	string s;
	cin >> s;
	int n = s.size() - 1;
	string ans = "";
	if(s[n] != 's'){
		ans = "s";
	} else {
		ans = "es";
	}
	cout << s + ans << endl;
	
}


Measured memory_bytes: 3636
// Brijesh Panara (201601074)
// DAIICT (India)
#include <bits/stdc++.h>
#include <time.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FILL(a,b) memset((a),(b),sizeof((a)))
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<ll,vector<ll>,greater<ll> > 
#define maxQueue priority_queue<ll,vector<ll>,less<ll> > 

#define deb1(x) cout<<#x<<" : "<<x<<endl;
#define deb2(x,y) cout<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl;
#define deb3(x,y,z) cout<<#x<<" : "<<x<<"   "<<#y<<" : "<<y<<"  "<<#z<<" : "<<z<<endl;

#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define READ freopen("input.txt","r",stdin);
#define WRITE freopen("output.txt","w",stdout);
#define RANDOM srand(time(NULL));

#define MOD 1000000007
#define NAX 1000005
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN


ll solve()
{
    ll t1,t2,a1,a2,b1,b2;
    cin>>t1>>t2>>a1>>a2>>b1>>b2;

    ll dist1 = a1*t1+a2*t2;
    ll dist2 = b1*t1+b2*t2;

    if(dist1==dist2)
    {
        cout<<"infinity\n";
        return 0;
    }
    
    if(dist2>dist1)
    {
    	swap(a1,b1);
    	swap(a2,b2);
    }
    dist1 = a1*t1+a2*t2;
    dist2 = b1*t1+b2*t2;

    if(a1>b1)
    {
    	cout<<0<<"\n";
    	return 0;
    }

    ll diff = dist1-dist2;
    ll cnt = (t1*(b1-a1))/diff;
    ll ans = 2*cnt+1;
    
    if( (t1*(b1-a1))%diff == 0 )
    	ans--;

    cout<<ans<<"\n";
    return 0;
}


int main()
{
    FAST;
    
    ll t=1;
    // cin>>t;
    
    while(t--!=0)
    {
        ll stat = solve();
    }
    return 0;
}


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

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    int n;
    cin >> n;
    vector<int> a(n + 1);
    vector<int> b(n);
    rep(i, n + 1) cin >> a[i];
    rep(i, n) cin >> b[i];

    long ans =0;
    rep(i,n){
        ans += min(a[i],b[i]);
        b[i] = max(b[i]-a[i],0);
        ans += min(b[i],a[i+1]);
        a[i+1] = max(a[i+1]-b[i],0);
    }
    cout << ans<<endl;
}

Measured memory_bytes: 4048
import collections
n,p = map(int,input().split())
ans = 1
def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

c = collections.Counter(prime_factors(p))
for i in range(len(c.most_common())):
    if c.most_common()[i][1]>=n:
        ans *= int(c.most_common()[i][0]) ** (c.most_common()[i][1]//n)
print(ans)

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

int main() {

  string N;
  cin >> N;

  int N2 = 0;
  int N3 = 0;

  for (int i = 0; i< N.size(); i++) {
    N2 += (N[i] - '0') * pow(10, N.size() - 1 - i);  
    N3 += N[i] - '0';
  }

  if (N2 % N3 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}

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

int main(){
	long long l, r;
	cin >> l >> r;
	int ans = 2019;
 
	for (long long i = l; i < r; i++) {
		for (long long j = i + 1; j <= r; j++) {
    			ans = min(ans, (int)(i * j % 2019));
                if(ans == 0){
                    cout << 0 << endl;
                    return 0;
                }
        }
    }
 	cout << ans << endl;
 
	return 0;
}

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

typedef vector<int> Dice;
enum{TOP, FRONT, RIGHT, LEFT ,BACK, BOTTOM};
#define rotate_swap(x,a,b,c,d) swap(x[a],x[b]); swap(x[b],x[c]); swap(x[c],x[d]);
void rotate_r(Dice& dice){
	rotate_swap(dice, TOP, LEFT, BOTTOM, RIGHT);
}
void rotate_l(Dice& dice){
	rotate_swap(dice, TOP, RIGHT, BOTTOM, LEFT);
}
void rotate_f(Dice& dice){
	rotate_swap(dice, TOP, BACK, BOTTOM, FRONT);
}
void rotate_b(Dice& dice){
	rotate_swap(dice, TOP, FRONT, BOTTOM, BACK);
}
void rotate_w(Dice& dice){
	rotate_swap(dice, BACK, LEFT, FRONT, RIGHT);
}
void rotate_c(Dice& dice){
	rotate_swap(dice, BACK, RIGHT, FRONT, LEFT);
}
vector<Dice> generate_all(Dice dice){
	vector<Dice> res;
	for(int i=0;i<6;i++){
		for(int j=0;j<4;j++)
			res.emplace_back(dice), rotate_w(dice);
		if( i % 2 )rotate_f(dice);
		else rotate_r(dice);
	}
	return res;
}

bool solve(){
	int n;
	cin >> n;
	if(n == 0)return false;;
	Dice dice(6);
	dice[TOP] = 1;
	dice[FRONT] = 3;
	dice[BACK] = 4;
	dice[BOTTOM] = 6;
	dice[RIGHT] = 2;
	dice[LEFT] = 5;

	vector<vector<int>> h(202,vector<int>(202));
	vector<vector<int>> numbers(202,vector<int>(202));

	for(int i=0;i<n;i++){
		int t,f;
		cin >> t >> f;
		vector<Dice> dices = generate_all(dice);
		Dice d;
		for(int i=0;i<dices.size();i++){
			if( dices[i][TOP] == t && dices[i][FRONT] == f ){
				d = dices[i];
				break;
			}
		}
		int r = 100, c = 100;
		while(true){
			// cout << d[BOTTOM] << " " << d[BACK] << endl;
			//FRONT, RIGHT, LEFT ,BACK
			static int dr[] = {-100,-1,0,0,1};
			static int dc[] = {-100,0,-1,1,0};
			
			int maxNum = 0;
			int maxDir = 0;
			for(int dir=1;dir<=4;dir++){
				int nr = r + dr[dir];
				int nc = c + dc[dir];
				// cout << nr << " " << nc << endl;
				if( d[dir] >= 4 && h[r][c] > h[nr][nc] && d[dir] > maxNum){
					maxNum = d[dir];
					maxDir = dir;
				}
			}
			
			// rotate
			if(maxNum == 0){
				h[r][c]++;
				numbers[r][c] = d[TOP];
				break;
			}else{
				r = r + dr[maxDir];
				c = c + dc[maxDir];
				if(maxDir == FRONT)rotate_f(d);
				else if(maxDir == RIGHT)rotate_r(d);
				else if(maxDir == LEFT)rotate_l(d);
				else if(maxDir == BACK)rotate_b(d);
			}
		}
		// for(int i=-3;i<3;i++){
		// 	for(int j=-3;j<3;j++){
		// 		cout << h[i+100][j+100] << " ";
		// 	}cout << endl;
		// }
	}
	vector<int> ans(7);
	for(int j=0;j<202;j++)for(int k=0;k<202;k++){
		ans[numbers[j][k]]++;
	}
	for(int j=1;j<=6;j++){
		cout << ans[j];
		if(j != 6)cout << " ";
	}cout << endl;
	return true;
}

int main(void){
	while(solve()){}

	return 0;
}

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

int main() {
	int a = -1;
	int b;
	string s;
	cin >> s;
	int N = s.size();
	for (int i = 0; i < N; ++i){
		if(s[i] == 'A' and a == -1){
			a = i;
		}
		else if (s[i]=='Z')
		{
			b = i;
		}
	}
	cout << b-a+1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <complex>
#include <map>

#define forin(i, f, t) for(auto i = f; i < t; i++)

using namespace std;
using ll = long long;

int main() {
    ll n;
    cin >> n;
    string s;
    cin >> s;
    string ls = s.substr(0, n), rs = s.substr(n);
    reverse(rs.begin(), rs.end());
    
    map<pair<string, string>, ll> rm, lm;
    forin(j, 0, 1 << n) {
        string lr, lb, rr, rb;
        forin(i, 0, n) {
            if ((j >> i) & 1) {
                lr.push_back(ls[i]);
                rr.push_back(rs[i]);
            } else {
                lb.push_back(ls[i]);
                rb.push_back(rs[i]);
            }
        }
        lm[make_pair(lr, lb)]++;
        rm[make_pair(rr, rb)]++;
    }
    
    ll count = 0;
    for (auto &lmp : lm) {
        count += lmp.second * rm[lmp.first];
    }
    cout << count << endl;
    
    
}



Measured memory_bytes: 108288
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	long R,G,B,n,s=0,r,g;
	cin>>R>>G>>B>>n;
	for(r=0;r<=3000;r++)for(g=0;g<=3000;g++)
	{
		if(0<=n-r*R-g*G&&(n-r*R-g*G)%B==0)s++;
	}
	cout<<s<<endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back

struct Team {
    int num=0, ac=0, pen=0;
    int wa[15] = {0};
};

void solve(int T,int P,int R) {
    vector<Team> teams(T);
    rep(i,T) teams[i].num=i+1;
    rep(i,R) {
        int tm, prg, time;
        string msg;
        cin>>tm>>prg>>time>>msg;
        tm--; prg--;
        if(msg == "WRONG") {
            teams[tm].wa[prg]++;
        } else {
            teams[tm].ac++;
            teams[tm].pen += teams[tm].wa[prg] * 1200 + time;
        }
    }
    rep(i,T) rep(j,T-1) {
        if(teams[j].ac < teams[j+1].ac) swap(teams[j], teams[j+1]);
        if(teams[j].ac == teams[j+1].ac
                and teams[j].pen > teams[j+1].pen) swap(teams[j], teams[j+1]);
    }

    for(auto& team : teams) {
        cout << team.num << " " << team.ac << " " << team.pen << "\n";
    }
}

int main() {
    int T,P,R;
    while(cin>>T>>P>>R, T) solve(T,P,R);
    return 0;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// テーブルを作る前処理
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        ll num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    vector<ll> x(N);
    vector<ll> y(N);
    vector<ll> z(N);
    REP(i,N) cin >> x[i] >> y[i] >> z[i];

    ll ans = 0;
    REP(i,8) {
        ll op1,op2,op3;
        op1 = (i & 1 << 0?1:-1);
        op2 = (i & 1 << 1?1:-1);
        op3 = (i & 1 << 2?1:-1);

        vector<ll> v(N);
        REP(i,N) v[i] = op1*x[i] + op2*y[i] + op3*z[i];
        sort(all(v),greater<>());

        ll tmp_ans = 0;
        REP(i,M) tmp_ans += v[i];
        chmax(ans,tmp_ans);
    }

    pl(ans)

    return 0;
}


Measured memory_bytes: 256