akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
ll a, b, c;
ll suba, subb;

int main()
{

    cin >> a >> b >> c;
    suba = a * b * ((c + 1) / 2);
    subb = a * b * (c / 2);
    ll min = abs(suba - subb);

    suba = a * ((b + 1) / 2) * c;
    subb = a * (b / 2) * c;
    if (abs(suba - subb) < min)
    {
        min = abs(suba - subb);
    }

    suba = ((a + 1) / 2) * b * c;
    subb = (a / 2) * b * c;
    if (abs(suba - subb) < min)
    {
        min = abs(suba - subb);
    }
    cout << min << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	vector<int> b1(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	int i = 0, j = 0, k = 0;
	long long count = 0, count2 = 0, count3 = 0;
	while (j!=n&&k != n) {
		while (j!=n&&k!=n && b[j] >= c[k]) {
			k++;
		}
		b1[j] =  n - k;
		count2 += n - k;
		j++;
	}
	if (j == n) j--;
	j = 0;
	while (j != n && i != n) {
		while (j != n&&i != n && a[i] >= b[j]) {
			count3 += b1[j];
			j++;
		}
		count += count2 - count3;
		i++;
	}
	cout << count;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, m, i, j, k, s1 = 0, s2 = 0, s4 = 0;
	cin >> n >> m;
	string s;
	vector<int> ct(26, 0);
	for (i = 0; i < n; i++) {
		cin >> s;
		for (auto ch : s) ct[ch - 'a']++;
	}

	for (i = 0; i < 26; i++) {
		s4 += ct[i] / 4;
		ct[i] %= 4;
	}
	bool ans = false;

	if (s4 >= (n / 2) * (m / 2)) {
		s2 = (s4 - (n / 2) * (m / 2)) * 2;
		for (i = 0; i < 26; i++) {
			s2 += ct[i] / 2;
			ct[i] %= 2;
		}
		if (s2 >= ((n % 2) * (m - m % 2) + (m % 2) * (n - n % 2))/2) {
			s1 = (s2 - ((n % 2) * (m - m % 2) + (m % 2) * (n - n % 2)) / 2) * 2;
			for (i = 0; i < 26; i++) {
				s1 += ct[i];
			}

			if (s1 >= (n % 2) * (m % 2)) {
				ans = true;
			}
		}
	}

	if (ans) cout << "Yes\n";
	else cout << "No\n";


	return 0;
}


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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
// inline void CIN() {}
// template <class Head, class... Tail>
// inline void CIN(Head &&head, Tail &&... tail) {
//     cin >> head;
//     CIN(move(tail)...);
// }
// CIN(__VA_ARGS__)
// CIN(__VA_ARGS__)
// CIN(__VA_ARGS__)
// #define Yes(a) cout << (a ? "Yes" : "No") << "\n"
// #define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
// typedef priority_queue<int, V, greater<int>> PQG;

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

int n, q;
VL S;
map<ll, ll> T;

int main() {
    cin >> n;
    S.resize(n);
    REP(i, n) cin >> S[i];
    cin >> q;
    REP(i, q) { T[IN()]++; }
    int cnt = 0;
    REP(i, n) {
        if(T[S[i]]) {
            cnt++;
            T[S[i]] = 0;
        }
    }
    cout << cnt << "\n";
    return 0;
}



Measured memory_bytes: 12744
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N - 1; i++) {
			int a = sc.nextInt();
			A[a - 1]++;
		}
		sc.close();
		for(int i = 0; i < N; i++) {
			System.out.println(A[i]);
		}
	}
}

Measured memory_bytes: 55924
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define el "\n"
#define sp " "
typedef long long ll;

main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	vector<ll> a(n+1,1);
	for(ll i=2;i<=n;i++)
	{
		for(ll j=i;j<=n;j+=i)
			a[j]++;
	}
	ll ans=0;
	for(ll i=1;i<=n;i++)
		ans+=i*a[i];
	cout<<ans;
	


	


		

	
	
	

	
	
	
	
	
	

	
	
	

}

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

class Program
{
    public static void Main( )
    {

        var input = Console.ReadLine( ).Split( ).Select( int.Parse ).ToArray( );
        int A = input[ 0 ];
        int B = input[ 1 ];
        int C = input[ 2 ];
        int K = int.Parse( Console.ReadLine( ) );
        var x = new int[] { A, B, C };

        var permutations = GetDuplicatedPermutaions( new int[] { 0, 1, 2 }, K );
        foreach ( var p in permutations )
        {
            var thisTime = x.ToArray( );
            foreach ( int selected in p )
            {
                thisTime[ selected ] *= 2;
            }
            if( thisTime[0] < thisTime[1] && thisTime[1] < thisTime[ 2 ] )
            {
                Console.WriteLine("Yes");
                return;
            }
        }
        Console.WriteLine("No");

    }

    public static IEnumerable<List<int>> GetDuplicatedPermutaions( int[] candidates, int n, List<int> selectedElms = null )
    {

        selectedElms = selectedElms ?? new List<int>( );
        if ( selectedElms.Count >= n )
        {
            yield return selectedElms;
            yield break;
        }

        foreach ( int number in candidates )
        {
            var selected = new List<int>( ) { number };
            var duplicatedPermutations = GetDuplicatedPermutaions( candidates, n, selectedElms.Concat( selected ).ToList( ) );
            foreach ( var permutaion in duplicatedPermutations )
            {
                yield return permutaion;
            }
        }
    }


}

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



int main(){
    int N, M, Q;
    cin >> N >> M;
    vector<int> edges[100000];
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        edges[a-1].push_back(b-1);
        edges[b-1].push_back(a-1);
    }
    cin >> Q;
    vector<int> V(Q), D(Q), C(Q);
    for(int i=0; i<Q; i++){
        cin >> V[i] >> D[i] >> C[i];
        V[i]--;
    }

    vector<int> ans(N);
    bitset<11> done[100000];

    for(int i=Q-1; i>=0; i--){
        queue<pair<int, int>> que;
        que.push({V[i], D[i]});
        while(que.size()){
            auto p = que.front(); que.pop();
            int s = p.first, d = p.second;
            if(d < 0) continue;
            if(ans[s] == 0) ans[s] = C[i];
            if(done[s][d]) continue;
            done[s][d] = 1;
            for(int t : edges[s]) que.push({t, d-1});
        }
    }
    for(int a : ans) cout << a << endl;
}

Measured memory_bytes: 10104
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
template<typename T>void max_self(T &a,T b){a=max(a,b);}
template<typename T>void min_self(T &a,T b){a=min(a,b);}
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=4e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const long double PI = acos(-1),eps=1.0e-14;

void solve(){
    int n;
    cin>>n;
    int a[n],b[n];
    loop(n,i,0)
        cin>>a[i],b[i]=a[i];
    sort(all(b,n));
    loop(n,i,0){
        if(a[i]>=b[n/2])
            cout<<b[n/2-1]<<endl;
        else
            cout<<b[n/2]<<endl;
    }
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 5108
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;

const int MAXN = 100005;
int s[MAXN];
int N, rk[MAXN], SA[MAXN], height[MAXN], h[MAXN];
int cnt[MAXN + 1005], tmp[MAXN], newRank[MAXN];

void getSuffixArray(int s[], int SA[], int rk[], int height[], int h[]) {
	// s: the input string
	// SA, rk, height, h: output
	// SA[i] is the index of the i-th smallest suffix
	// rk[i] is the rking of suffix substring s[i .. N - 1]
	// height[i] is the length of longest common prefix of i-th and (i-1)-th smallest suffix
	// h[i] = height[rk[i]]
	int limit = 1005; // 128 suffices to deal with all characters
	// N = strlen(s);
	// Calculate SA and rk
	memset(cnt, 0, sizeof(int) * limit);
	for (int i = 0; i < N; ++i) ++cnt[rk[i] = s[i]];
	for (int i = 1; i < limit; ++i) cnt[i] += cnt[i - 1];
	for (int i = N - 1; i >= 0; --i) SA[--cnt[s[i]]] = i;
	for (int k = 1; k <= N; k <<= 1) {
		int j = 0;
		for (int i = N - 1; i >= N - k; --i) tmp[j++] = i;
		for (int i = 0; i < N; ++i) if (SA[i] >= k) tmp[j++] = SA[i] - k;
		memset(cnt, 0, sizeof(int) * limit);
		for (int i = 0; i < N; ++i) ++cnt[rk[i]];
		for (int i = 1; i < limit; ++i) cnt[i] += cnt[i - 1];
		for (int i = N - 1; i >= 0; --i) SA[--cnt[rk[tmp[i]]]] = tmp[i];
		newRank[SA[0]] = 0;
		for (int i = 1; i < N; ++i)
			newRank[SA[i]] = (SA[i] + k < N && SA[i - 1] + k < N
						&& rk[SA[i]] == rk[SA[i - 1]] && rk[SA[i] + k] == rk[SA[i - 1] + k])
						? newRank[SA[i - 1]] : newRank[SA[i - 1]] + 1;
		for (int i = 0; i < N; ++i) rk[i] = newRank[i];
		limit = rk[SA[N - 1]] + 1;
		if (limit >= N) break;
	}
	// Calculate h
	for (int i = 0; i < N; ++i) {
		if (0 == rk[i])
			h[i] = 0;
		else
			for (h[i] = ((0 == i || 0 == h[i - 1]) ? 0 : (h[i - 1] - 1));
				 s[i + h[i]] == s[SA[rk[i] - 1] + h[i]]; ++h[i]);
	}
	// Calculate height
	for (int i = 0; i < N; ++i) height[i] = h[SA[i]];
}

bool ok(int x) {
	int minX = N + 1, maxX = -1;
	for (int i = 0; i < N; ++i) {
		if (height[i] < x) {
			if (maxX - minX >= x) return true;
			minX = maxX = SA[i];
		}
		else
			minX = min(minX, SA[i]), maxX = max(maxX, SA[i]);
	}
	if (maxX - minX >= x) return true;
	return false;
}

int solve() {
	int l = 0, r = N;
	while (l + 1 < r) {
		int m = (l + r) >> 1;
		if (ok(m)) l = m;
		else r = m;
	}
	return l;
}

int main() {
	char x;
	scanf("%d", &N);
	getchar();
	for (int i = 0; i < N; ++i)
		scanf("%c", &x), s[i] = x;
	
	s[N] = '\0';
	//for(int i=0;i<N;++i)printf("%d\n",s[i]);
	getSuffixArray(s, SA, rk, height, h);
	printf("%d\n", solve());
	return 0;
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){
  int a[14]={1,3,1,2,1,2,1,1,2,1,2,1}, b, c;
  cin >> b >> c;
  b--;c--;
  if(a[b]==a[c]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int n,m;
	while(cin >> n >> m, n|m){
		vi l(n);
		vi r(m);
		int lsum = 0, rsum = 0;
		REP(i, n){
			cin >> l[i];
			lsum += l[i];
		}
		REP(i, m){
			cin >> r[i];
			rsum += r[i];
		}

		int min_value = 1e9;
		pii trade = {-1, -1};
		REP(i, n){
		REP(j, m){
			if(lsum - l[i] + r[j] == rsum - r[j] + l[i]){
				if (min_value > l[i] + r[j]){
					min_value = l[i] + r[j];
					trade = {l[i], r[j]};
				}
			}
		}
		}

		if(trade.first == -1)
			cout << -1 << endl;
		else
			cout << trade.first << " " << trade.second << endl;
	}
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    string s,t;cin>>s>>t;int ans=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 3916
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n,m,k;
    cin>>n>>m>>k;
    vl v,w;
    ll suma=0,sumb=0;
    v.pb(0);
    rep(i,n)
    {
        ll c;
        cin>>c;
        v.pb(c);
    }
    rep(i,m)
    {
        ll c;
        cin>>c;
        w.pb(c);
        sumb+=c;
    }
    int currb=m-1;
    ll ans=0;
    for(int i=0;i<=n;i++)
    {
        suma+=v[i];
        while(true)
        {
            if(currb==-1)
                    break;
            if((suma+sumb)>k)
            {
                sumb-=w[currb];
                currb--;
                if(currb==-1)
                    break;
            }
            else
                break;
        }
        if((sumb+suma)<=k)
        {
            ans=max(ans,(ll)i+currb+1);
        }
    }
    cout<<ans<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 19672
// 基本テンプレート
 
#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>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int 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;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int Q; cin >> Q;
    rep(z,0,Q) {
        int A, B; cin >> A >> B;
        if(A > B) swap(A, B);
        int X = A * B;

        if(A == B) cout << 2*A - 2 << endl;
        else if(A+1 == B) cout << 2*A - 2 << endl;
        else {
            int lb = 0, ub = 1000LL * 1000LL * 1000LL + 100;
            while(ub - lb > 1) {
                int mid = (ub + lb) / 2;
                if(mid * mid < X) {
                    lb = mid;
                }
                else {
                    ub = mid;
                }
            }

            int C = lb;
            if(C*(C+1) >= X) {
                cout << 2*C - 2 << endl;
            }
            else {
                cout << 2*C - 1 << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
res = n
W = [0] * n
E = [0] * n 
if s[0] == 'W':
    W[0] = 1
    E[0] = 0
else:
    W[0] = 0
    E[0] = 1
for i in range(1,n):
    if s[i] == 'W':
        W[i] = W[i-1]+1
        E[i] = E[i-1]
    else:
        W[i] = W[i-1]
        E[i] = E[i-1] + 1
for i in range(n):
    cnt = W[i] + E[-1] - E[i]
    if s[i] == 'W':
        cnt -= 1
    res = min(cnt, res)
print(res)


Measured memory_bytes: 17620
N = int(input())
mod = 10 ** 9 + 7
dp = [[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(N+1)]


def ng(a: int, b: int, c: int):
    return (a == 1 and b == 2 and c == 3)


# 初期状態の直近3文字はTTTであると見なして良い
dp[0][0][0][0] = 1
for i in range(N):
    for a in range(4):
        for b in range(4):
            for c in range(4):
                for d in range(4):
                    # 3文字パターン
                    if (ng(b, c, d) or ng(c, b, d) or ng(b, d, c)):
                        continue
                    # 4文字パターン
                    if ng(a, c, d) or ng(a, b, d):
                        continue
                    # NGパターンがなければ遷移先に足す
                    dp[i+1][b][c][d] = (dp[i][a][b][c] + dp[i+1][b][c][d]) % mod


ans = 0
for a in range(4):
    for b in range(4):
        for c in range(4):
            ans += dp[N][a][b][c] % mod


print(ans % mod)


Measured memory_bytes: 53616
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 1000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
bitset<maxx/2>vis;
vector<ll>prime;
void sieve(){
    ll x=maxx/2, y=sqrt(maxx)/2;
    for(ll i=1;i<=y;i++){
        if(vis[i]==0){
            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
                vis[j]=1;
        }
    }
    prime.push_back(2);
    for(ll i=3;i<maxx;i+=2)
        if(vis[i/2]==0)
        prime.push_back(i);
}
bool isprime(ll a)
{
    if(a==2){
        return true;
    }
    if(a%2==0){
        return false;
    }
    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++){
        if(a%prime[i]==0){
            return false;
        }
    }
    return true;
}
ll lcm(ll a,ll b)
{
    return (a*b)/__gcd(a,b);
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
map<ll,ll>arr;
void Dufaux()
{
    ll x,n;
    cin>>x>>n;
    ll number;
    for(int i=0;i<n;i++){
        cin>>number;
        arr[number]++;
    }
    if(!arr[x]){
        cout<<x<<endl;
    }
    else{
        for(int i=x-1,j=x+1;;i--,j++){
            if(!arr[i]){
                cout<<i<<endl;
                return;
            }
            if(!arr[j]){
                cout<<j<<endl;
                return;
            }
        }
    }
}
int main()
{
	FastIO;
	///sieve();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int main() {
    int N;
    string S;

    cin >> N >> S;

    int cnt_R = 0;
    int cnt_B = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'R') {
            cnt_R++;
        } else {
            cnt_B++;
        }
    }

    if (cnt_R > cnt_B) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9
#define MAX 1000

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;

int main(){
    ll N;
    cin >> N;
    ll a[N];
    ll M = N;
    ll ans = 1;
    Rep(i,N){
        cin >> a[i];
    }
    Rep(i,N-1){
        if(a[i] >= a[i+1])ans++;
    }
    cout << ans << endl << M << endl;
    //cin >> N;
}


Measured memory_bytes: 3868
s=input()

s_re=s[::-1]
s1=s[0:int((len(s)-1)/2)]
s2=s[int((len(s)+3)/2)-1::]
s1_re=s1[::-1]
s2_re=s2[::-1]

if s==s_re and s1==s1_re and s2==s2_re:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val n = in.readLine().toInt
    val as = in.readLine().split("\\s+").map(_.toInt)

    out.println(
      (as.min to as.max).foldLeft(Int.MaxValue) {
        case (min, t) =>
          Math.min(min, as.foldLeft(0) {
            case (sum, a) => sum + (a - t) * (a - t)
          })
      }
    )

    out.flush()
  }
}


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

def eratosthenes(n):
    import math
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
    return data

sosu = eratosthenes(55555)
ans = [i for i in sosu if i%5==1]

print(*ans[:n],sep=' ')


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

#define INF_LL (int64)1e18
//#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}


constexpr int64 mod = 1e9+7;

int main(void) {
    int64 N;
    cin >> N;
    vector<int64> H(N);
    REP(i, N) cin >> H[i];
    int64 now = -1;
    REP(i, N) {
        if (H[i] < now) {
            cout << "No" << endl;
            return 0;
        }
        if (H[i]-1 >= now) H[i]--;
        now = H[i];
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <complex>
using namespace std;

typedef complex<double> P;
P p[10010];
int done[10010];
int main(){
	int N,M;
	cin >> N >> M;
	priority_queue< pair<double,int> > Q;
	for(int i = 0 ; i < N ; i++){
		int a,b;
		cin >> a >> b;
		p[i] = P(a,b);
	}
	vector<int> e[10010];
	double sum = 0;
	for(int i = 0 ; i < M ; i++){
		int a,b;
		cin >> a >> b;
		a--,b--;
		e[a].push_back(b);
		e[b].push_back(a);
		
		sum += abs(p[a]-p[b]);
	}
	for(int s = 0 ; s < N ; s++){
		if( done[s] ) continue;
		Q.push(make_pair(0,s));
		while(Q.size()){
			pair<double,int> q = Q.top(); Q.pop();
			if( done[q.second]++ ){
				continue;
			}else{
				sum -= q.first;
			}
			for(int i = 0 ; i < e[q.second].size() ; i++)
				Q.push(make_pair(abs(p[q.second]-p[e[q.second][i]]),e[q.second][i]));
		}
	}
	printf("%.10lf\n",sum);
}

Measured memory_bytes: 2644
R,G,B,N = map(int,input().split())
ans = 0
for r in range(N+1):
    t1 = N - r*R
    if t1 < 0: break
    for g in range(N+1):
        t2 = t1 - g*G
        if t2 < 0: break
        if t2 % B == 0: ans += 1

print(ans)

Measured memory_bytes: 3060
h, w = gets.split.map(&:to_i)
n = gets.to_i
nums = gets.split.map(&:to_i)
array = []
nums.each.with_index(1) { |num, i| num.times { array << i.to_s } }
sliced = array.each_slice(w).to_a
1.step(h - 1, 2) { |i| sliced[i].reverse! }
sliced.each { |row| puts row.join(" ") }


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  vector<int> v(n); cin >> v;
  int want = 1;
  for(int e:v){
    if(e == want)want++;
  }
  if(want > 1)cout << n - want + 1 << endl;
  else cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h> 
 
using namespace std; 
#define rep(i,a,b) for(int i=int(a),nn=int(b);i<=nn;++i) 

typedef long long ll; 

int n, a[300100]; 

int main() { 
	ios::sync_with_stdio(false); 
	cin>>n; rep(i,1,n*3) cin>>a[i]; 
	sort(a+1,a+1+n*3); ll as=0; 
	for (int i=n*3-1,t=1; t<=n; ++t,i-=2) 
		as+=a[i]; 
	return cout<<as<<endl, 0; 
}
		

Measured memory_bytes: 1408
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
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;
}
const int dx[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int dy[8] = { 1, 1, 1, 0, 0, -1, -1, -1 };
const int lr[4] = { 0, 1, 0, -1 };
const int ud[4] = { 1, 0, -1, 0 };



//LOVE Ayane Sakura



using namespace std;



int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>>data(H , vector<char>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> data[i][j];
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int check = 0;
			for (int k = 0; k < 4; k++) {
				if (i + ud[k] < 0 || i + ud[k] >= H || j + lr[k] < 0 || j + lr[k] >= W) {
					continue;
				}
				if (data[i + ud[k]][j + lr[k]] == '#') {
					check++;
				}
			}
			if (data[i][j] == '#' && check == 0) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}


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

int main() {
    int n; scanf("%d", &n);
    vector<int> a(n);
    for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
    int s = 0;
    while (true) {
        if (count(a.begin(), a.end(), 1) == n) {
            if (s == 0) puts("Second");
            else puts("First");
            return 0;
        }
        if (count_if(a.begin(), a.end(), [&](int x) { return x % 2 == 0; }) % 2 == 1) {
            if (s == 0) puts("First");
            else puts("Second");
            return 0;
        }
        if (count_if(a.begin(), a.end(), [&](int x) { return x % 2 == 1; }) > 1) {
            if (s == 0) puts("Second");
            else puts("First");
            return 0;
        }
        int g = 0, cnt = 0;
        for (int i = 0; i < n; ++i) {
            if (a[i] % 2 == 1) {
                if (a[i] == 1) {
                    if (s == 0) puts("Second");
                    else puts("First");
                    return 0;
                }
                a[i]--, cnt++;
            }
            g = __gcd(g, a[i]);
        }
        assert(cnt == 1);
        for (int i = 0; i < n; ++i) a[i] /= g;
        s ^= 1;
    }
    return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int n = scan.nextInt();
		for(int i = 1; i <= n; i++){
			String si = String.valueOf(i);
			if(i % 3 == 0){
				System.out.printf(" %s", si);
			} else if(si.contains("3")){
				System.out.printf(" %s", si);
			}
		}
		System.out.printf("\n");
	}
}

Measured memory_bytes: 37328
# https://atcoder.jp/contests/abc089/tasks/abc089_d

H, W, D = map(int, input().split())
MAX = H * W + 1

d = [0] * (MAX + 1)
px = [None] * (MAX + 1)
py = [None] * (MAX + 1)

for h in range(H):
    Ah = list(map(int, input().split()))
    for w in range(W):
        px[Ah[w]] = h
        py[Ah[w]] = w

for i in range(D + 1, H * W + 1):
    d[i] = d[i - D] + abs(px[i] - px[i - D]) + abs(py[i] - py[i - D])

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    print(d[R] - d[L])

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

using ll = long long;
using namespace std;


int main()
{
    int n;
    string s;
    cin >> n >> s;
    for(auto &i : s) i -= '0';
    int cnt = 0;

    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            for(int k = 0; k < 10; k++){
                int f = 0;
                int ind = 0;
                for(; ind < n; ind++)if(s[ind] == i){f += 1;break;}
                ind++;
                for(; ind < n; ind++)if(s[ind] == j){f += 2;break;}
                ind++;
                for(; ind < n; ind++)if(s[ind] == k){f += 4;break;}
                if(f == 7)cnt++;
            }
        }
    }
    cout << cnt << endl;

}

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

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int min_num_changes = (1 << 29) - 1;

    // The first color is black
    int num_changes = 0;
    for (int i = 0; i < S.size(); i++) {
        char color = S.at(i);
        if ((i % 2 == 0 && color == '1') || 
            (i % 2 == 1 && color == '0')) {
            num_changes += 1;
        }
    }
    min_num_changes = min(min_num_changes, num_changes);

    // The first color is white
    num_changes = 0;
    for (int i = 0; i < S.size(); i++) {
        char color = S.at(i);
        if ((i % 2 == 0 && color == '0') ||
            (i % 2 == 1 && color == '1')) {
                num_changes += 1;
        }
    }
    min_num_changes = min(min_num_changes, num_changes);
    cout << min_num_changes << "\n";
}

Measured memory_bytes: 512
k,x = map(int,input().split())
if x + k - 1 > 1000000:
  up = 1000000
else:
  up = x + k - 1
    
if x - k + 1 < -1000000:
  down = -1000000
else:
  down = x - k + 1

for i in range(down, up+1):
  print(i, end = " ")



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

using namespace std;


int main() {
    int a, b;
    cin >> a >> b;
    stringstream ss;
    ss << a << b;
    int c;
    ss >> c;
    int d = sqrt(c);
    if (d * d == c) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

class Program
{
	static void Main()
	{
		Console.ReadLine();
		var partsA = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => long.Parse(number));
		var partsB = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => long.Parse(number));
		var partsC = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => long.Parse(number));

		Array.Sort(partsA);
		Array.Sort(partsB);
		Array.Sort(partsC);

		var uppers = new long[partsB.Length];
		var countA = 0;
		for(var i = 0; i < partsB.Length; ++i) {
			var b = partsB[i];
			if (i > 0) {
				uppers[i] = uppers[i - 1];
			}

			if (countA < partsA.Length) {
				while (countA < partsA.Length) {
					var a = partsA[countA];
					if (a < b) {
						++uppers[i];
						++countA;
					} else {
						break;
					}
				}
			} else {
				uppers[i] = uppers[i - 1];
			}
		}

		var totalUppsers = new long[partsB.Length];
		totalUppsers[0] = uppers[0];
		for (var i = 1; i < uppers.Length; ++i) {
			totalUppsers[i] = totalUppsers[i - 1] + uppers[i];
		}

		long totalCount = 0;
		var countB = 0;
		for (var i = 0; i < partsC.Length; ++i) {
			var c = partsC[i];
			if (c > partsB[countB]) {
				if (countB < partsB.Length - 1) {
					while (countB < partsB.Length - 1 && partsB[countB + 1] < c) {
						++countB;
					}
					totalCount += totalUppsers[countB];
				} else {
					totalCount += totalUppsers.Last();
				}
			}
		}

		Console.WriteLine(totalCount);
	}
}


Measured memory_bytes: 40784
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;

int main() {
  string S, T;
  cin >> S >> T;
  int sz = S.size();
  vector<vector<int>> p_t(26, vector<int>(26));
  vector<vector<int>> p_s(26, vector<int>(26));
  for (int i = 0; i < sz; i++) {
    p_t[T[i] - 'a'][S[i] - 'a'] = 1;
    p_s[S[i] - 'a'][T[i] - 'a'] = 1;
  }
  for (int i = 0; i < 26; i++) {
    if (accumulate(p_t[i].begin(), p_t[i].end(), 0) > 1 ||
        accumulate(p_s[i].begin(), p_s[i].end(), 0) > 1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main() {
	int N,min;
  	cin >> N;
  	min = 1000;
  	for(int i = 0; i < N; i++) {
    int a,b;
    cin >> a;
    b = 0;
    for(a; a%2 == 0 ; a /= 2) {
    b++;
    }
    if(min > b){
    min = b;
    }
    }
  cout << min << endl;
}


Measured memory_bytes: 256
#解説AC

n = int(input())
A = list(map(int, input().split()))

b1, b4 = 0, 0
for a in A:
    if a % 2:
        b1 += 1
    if a % 4 == 0:
        b4 += 1

b2 = min(1, n-(b1+b4))

if b1+b2-1 <= b4:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 20152
#C - 755
import sys
sys.setrecursionlimit(10**6)
N = input()

lis = ['3','5','7']
count = 0
def dfs(A):
    global lis
    global count
    if len(A) >= len(N):
        A_str = ''.join(A)
        A_int = int(A_str)
        N_int = int(N) 
        if N_int < A_int:
            return
    if len(set(A)) == 3:
        count += 1
    for v in range(3):
        A.append(lis[v])
        dfs(A)
        A.pop()
dfs([])    
print(count)    

Measured memory_bytes: 9196
int main(){
    int m,f,r;
    while (1){
        scanf("%d %d %d",&m,&f,&r);
        if (m+f+r==-3) break;
        if (m==-1 || f==-1) printf("F\n");
        else if (m+f>=80) printf("A\n");
        else if (m+f>=65) printf("B\n");
        else if (m+f>=50) printf("C\n");
        else if (m+f>=30 && r>=50) printf("C\n");
        else if (m+f>=30) printf("D\n");
        else if (m+f<30)  printf("F\n");
    }
    return 0;   
}


Measured memory_bytes: 2056
import java.util.Scanner;

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

		int n = sc.nextInt();
		sc.close();

		// 1 * i で表すことができる
		if (n < 10) {
			System.out.println("Yes");
			return;
		}
		for (int i = 2; i < 10; i++) {
			for (int j = 2; j < 10; j++) {
				if (i * j == n) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");

	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    while(cin>>n){
        vl a(n);
        forn(i,n) cin>>a[i];
        sort(all(a));
        ll ans = 0;
        fore(i,0,n){
            fore(j,i+1,n){
                fore(k,j+1,n){
                    if(a[i]<a[j]+a[k] && a[j]<a[i]+a[k] && a[k]<a[i]+a[j] && a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k]){
                        ++ans;
                    }
                }
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3644
N = int(input())
ans = 0
for i in range(N):
    a, b = map(str, input().split())
    if b == 'JPY': #日本円で貰った時
        ans += float(a)
    else: #ビットコインで貰った時
        ans += float(a) * 380000.0

print (ans)

Measured memory_bytes: 2940
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;

int N,M;
vector<int> edge[60];
int cnt;
void dfs(int node, vector<bool> visited){

    for(auto next: edge[node]){
        if(!visited[next]){
            visited[next] = true;
            bool flag=true;
            REP(i,0,N) {
                if(!visited[i]){
                    flag=false;
                    break;
                }
            }
            if(flag) cnt++;
            dfs(next,visited);
            visited[next] = false;
        }
    }
}

int main() {
    cin>>N>>M;
    REP(i,0,M){
        int a,b;
        cin>>a>>b;
        a--;b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    vector<bool> visited(N,false);
    visited[0]=true;
    dfs(0,visited);
    p(cnt);
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

class Main {
	public static void main(String[] args) throws Exception {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		ArrayList<String> list1 = new ArrayList<String>();
		int[] list2 = new int[3001];
		int[] list3 = new int[3001];
		int i = 0;
		while (true) {
			list1.add(br.readLine());

			list2[i] = Integer.parseInt(SubStringStart(list1.get(i)));//???????????°???
			list3[i] = Integer.parseInt(SubStringEnd(list1.get(i)));//????°??????°???
			if (list2[i] == 0 && list3[i] == 0) {
				for (int k = 0; k < list1.size(); k++) {
					if (list2[k] > list3[k]) {
						System.out.println(list3[k] + " " + list2[k]);
					} else if (list2[k] < list3[k]) {
						System.out.println(list2[k] + " " + list3[k]);
					} else if (list2[k] == list3[k] && list2[k] != 0 && list3[k] != 0) {
						System.out.println(list2[k] + " " + list3[k]);
					}
				}
				break;
			}
			i = i + 1;
		}
	}

	public static String SubStringStart(String str) {
		int index = str.indexOf(" ");
		return (str.substring(0, index));
	}

	public static String SubStringEnd(String str) {
		int index = str.indexOf(" ");
		return (str.substring(index + 1));
	}
}

Measured memory_bytes: 26500
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<numeric>
#include<limits.h>
#include<utility>
#include<cstdlib>
#define LP(i,n) for(int i=0;i<n;i++)
#define LPIN(n,a) for(int i=0;i<n;i++)cin >> a[i]
using namespace std;
 
int main(){
  int n;
  cin >> n;
  bool a = true,b =true;
  if(n %100 <= 0 || 13 <= n %100)a = false;
  if(n /100 <= 0 || 13 <= n /100)b = false;

if(a == true && b == true)cout << "AMBIGUOUS" << endl;
else if(a == true)cout << "YYMM" << endl;
else if(b == true)cout << "MMYY" << endl;
else cout << "NA" << endl;
return 0;
}

Measured memory_bytes: 256