akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }



void solve(long long N){
	ll res = N*N*N;
	cout << res << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    double p = 0;
    int mw = a;
    int ms = 0;
    int w = 0;
    int s = 0;
    bool q = false;

    rep(i, f/(100*b) + 1) {
        rep(j, f/(100*a) + 1) {
            w = i*b + j*a;

            if(w*100 >= f) {
                break;
            }

            rep(k, e*w/c + 1) {
                rep(l, e*w/d + 1) {
                    s = k*c + l*d;

                    if(w*100 + s > f) {
                        break;
                    }

                    if( w*100 + s <= f && w != 0 ) {
                        
                        if( w*e > s && p < s/(double)w ) {
                            mw = w;
                            ms = s;
                            p = s/(double)w;
                        }

                        if( w*e == s && p < s/(double)w ) {
                            mw = w;
                            ms = s;
                            p = s/(double)w;
                            q = true;
                            break;
                        }
                    }
                    if(q) { break; }
                }
                if(q) { break; }
            }
            if(q) { break; }
        }
        if(q) { break; }
    }

    cout << mw*100 + ms << " " << ms << endl;
    return 0;
}

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

typedef long long ll;

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        double k = i;
        k *= 1.08;
        int kk = k;
        if (kk == n) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  string S;
  cin >> S;
  string y="YES", n="NO";
  if (S.size()>9) {
    cout << n << endl;
  }
  else if (S=="KIHBR") {
    cout << y << endl;
  }
  else if (S=="AKIHBR") {
    cout << y << endl;
  }
  else if (S=="KIHABR") {
    cout << y << endl;
  }
  else if (S=="KIHBAR") {
    cout << y << endl;
  }
  else if (S=="KIHBRA") {
    cout << y << endl;
  }
  else if (S=="AKIHABR") {
    cout << y << endl;
  }
  else if (S=="AKIHBAR") {
    cout << y << endl;
  }
  else if (S=="AKIHBRA") {
    cout << y << endl;
  }
  else if (S=="KIHABAR") {
    cout << y << endl;
  }
  else if (S=="KIHABRA") {
    cout << y << endl;
  }
  else if (S=="KIHBARA") {
    cout << y << endl;
  }
  else if (S=="AKIHABAR") {
    cout << y << endl;
  }
  else if (S=="AKIHABRA") {
    cout << y << endl;
  }
  else if (S=="AKIHBARA") {
    cout << y << endl;
  }
  else if (S=="KIHABARA") {
    cout << y << endl;
  }
  else if (S=="AKIHABARA") {
    cout << y << endl;
  }
  else {
    cout << n << endl;
  }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 2000000000;

ll a, b;
ll n;
ll ans=0;

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

int main(){
  cin >> a >> b;
  n = gcd(a, b);
  set<int> ans;
  for(ll i = 2; n > i*i&&n>1; i++){
    if(n%i==0){
      ans.insert(i);
      while(n%i==0) n = n/i;
    }
  }
  ans.insert(n);
  ans.insert(1);
  cout <<  ans.size() <<endl;//1
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

void solve(int test_case) {
	int n,m;
	cin>>n>>m;
	map<int,int> arr;
	while(m--) {
		int a,b;
		cin>>a>>b;
		arr[a]++;
		arr[b]++;
	}
	for(int i=1;i<=n;i++) {
		cout<<arr[i]<<"\n";
	}
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


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

namespace _0298
{
    class Program
    {
        static void Main(string[] args)
        {
            SortedSet<string> times = new SortedSet<string>();
            int[] n = RArInt();
            for (int i = 1; i < n[0] * 2; i += 2)
            {
                times.Add(n[i].ToString("00") + ":" + n[i + 1].ToString("00"));
            }
            int[] m = RArInt();
            for (int i = 1; i < m[0] * 2; i += 2)
            {
                times.Add(m[i].ToString("00") + ":" + m[i + 1].ToString("00"));
            }

            Console.WriteLine(WAr(times.Select(x => x.Split(':')).Select(y => int.Parse(y[0]).ToString() + ":" + y[1])));
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 19744
#include <bits/stdc++.h>
using namespace std;
int main(){
  long int H, K;
  long int x=1;
  long int t=0;
  cin >> H;
  
  while (H != 0) {
    if(H/2>=1) {
      t++;
      H = H/2;
    }
    else break;
  }
  for(long int i=0; i<t; i++) {
    x += pow(2, i+1);
  }
  
  cout << x << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int 		long long
#define ull 		unsigned long long
#define vi 			vector<int>
#define vvi			vector<vi>
#define pb			push_back
#define mii  		map<int, int>
#define pii 		pair<int, int>
#define pq 			priority_queue<int>
#define pqs 		priority_queue<int, vi, greater<int>>
#define mod 		1000000007
#define inf 		1e18
#define ps(x, y) 	fixed<<setprecision(y)<<x
#define w(t)		int t; cin>>t; while(t--)
#define rep(i,a,b)	for(int i = a; i < b; i++)
#define repd(i,a,b)	for(int i = a; i>= b; i--)
int32_t main()
{
	int n, a, b, i;
    cin>>n;
    bool dp[n];
    for(i = 0; i < n; i++)
    {
        cin>>a>>b;
        dp[i] = (a==b);
    }
    for(i = 0; i < n - 2; i++)
        if(dp[i] && dp[i+1] && dp[i+2])
            break;
    if(i == n -2)
        cout<<"No";
    else
        cout<<"Yes";
	return 0;
}

Measured memory_bytes: 3628
import sys
input = sys.stdin.readline
S,T=input().rstrip().split()

def resolve():
    print(T+S)

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """oder atc"""
        output = """atcoder"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """humu humu"""
        output = """humuhumu"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Measured memory_bytes: 6704
#pragma GCC optimize("O3") 
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") 
#define __USE_MINGW_ANSI_STDIO 0
#include<bits/stdc++.h>                               
using namespace std;

#define PI acos(-1)
#define pb push_back
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(c) (c).begin(), (c).end()
#define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock()/CLOCKS_PER_SEC)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair <int, int> pii;
typedef vector <vi> vvi;
typedef vector <pii> vpii;
typedef vector<string> vs;

const int MAXN = 5e3 + 9;
const int MOD = (int)(1e9 + 7);
const int INF = 100500;

int n, k;
ll sum;
int aa[MAXN];
bitset < 5009 > dp;

void input() {
	cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> aa[i];
}

bool ok(int x) {
	dp.reset();
	dp.set(0);
	for(int i = 0; i < n; i++) {
		if(i != x) dp |= dp << aa[i];
	}
	if(aa[x] > k) return 1;
	for(int i = k - aa[x]; i < k; i++) {
		if(dp[i]) return 1;
	}
	return 0;
}	

void solve() {
	sort(aa, aa + n);
	int l = -1, r = n;                                 
	while(r - l > 1) {
		int m = (l + r) / 2;
		if(ok(m)) r = m;
		else l = m;
	}
	cout << r;	
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef LOCAL
	freopen("xxx.in", "r", stdin);
	freopen("xxx.out", "w", stdout);
#else
	//freopen("xxx.in", "r", stdin);
	//freopen("xxx.out", "w", stdout);
#endif	
	input();
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint 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(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }

        
  int main(){
      vector<lint> x;
        vector<lint> ans;
        lint n;
        cin>>n;
        rep(i,n){
            lint f;
            cin>>f;
            x.push_back(f);
        }
        while(x.size()!=0){
            repm(i,x.size()){
                if((i+1)==x[i]){
                    ans.push_back(x[i]);
                    x.erase(x.begin()+i);
                    break;
                }
                if(i==0){
                    cout<<-1<<endl;
                    return 0;
                }
            }
        }
        repm(i,ans.size())cout<<ans[i]<<endl;
     }
  

  
     
  

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <iomanip>
#include <string.h>
#include <set>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LL MOD = 1000000007;
const int INF = 1000000007;
const LL LINF = 1LL * INF * INF;
const int MAXN = 10007;
const LD EPS = 1e-7;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("sparse.in", "r", stdin);
	//freopen("sparse.out", "w", stdout);
	int n, l = 0, r;
	string S, Sl;
	cin >> n;
	r = n - 1;
	cout << "0\n";
	cout.flush();
	cin >> S;
	if (S == "Vacant")
		return 0;
	Sl = S;
	while (r - l > 1)
	{
		int m = (l + r) >> 1;
		cout << m << '\n';
		cout.flush();
		cin >> S;
		if (S == "Vacant")
			return 0;
		if (((m - l) & 1) ^ (S == Sl))
		{
			l = m;
			Sl = S;
		}
		else
			r = m + 1;
	}
	cout << r << '\n';
	cout.flush();
	cin >> S;
	if (S == "Vacant")
		return 0;
	cout << l << '\n';
	cout.flush();
	cin >> S;
	//cout << endl; system("pause");
	return 0;
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define vll vector<long long>
#define ll long long
#define pii pair<int,int>
const int mod=1e9+7;
int n,W;
ll solve(int i,int j,vector<vector<ll>> &dp,int* w,ll *v,ll we){
    //cout<<i<<" "<<j<<"\n";
    if(j<=0) return 0;
    if(i==n){
        return INT_MAX;
    }
    if(dp[i][j]!=-1) return dp[i][j];
    dp[i][j]=min(solve(i+1,j,dp,w,v,we),w[i]+solve(i+1,j-v[i],dp,w,v,we-w[i]));
    return dp[i][j];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("inputf.txt","r",stdin);
    freopen("outputf.txt","w",stdout);
#endif

    cin>>n>>W;
    int w[n];
    ll v[n];
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
        //cout<<w[i]<<" "<<v[i]<<"\n";
    }
    vector<vector<ll>> dp(n,vector<ll>(100001,-1));
    ll ans=0;
    for(int i=100000;i>=0;i--){
        if(solve(0,i,dp,w,v,W)<=W){
            ans=i;
            break;
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 82396
#include<iostream>

using namespace std;

int main() {
    int A1, A2, A3;

    cin >> A1 >> A2 >> A3;

    if (A1 + A2 + A3 <= 21) {
        cout << "win" << endl;
    } else {
        cout << "bust" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
#include <sstream>
using namespace std;
const constexpr int INF = 1e9;
#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9+7;
struct Less{
   bool operator()(const pair<string, int>&a, const pair<string, int>&b){
        if(a.first==b.first){
            return a.second < b.second;
        }
       return a.first < b.first;
    }
};

ll extGCD(ll a, ll b, ll& x, ll& y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a/b*x;
    return d;
}
ll GCD(ll a, ll b){
    if(a<b) swap(a, b);
    if(b==0) return a;
    return GCD(b, a%b);
}
int par[100010], rr[100010];
void init(){
    for(int i=0; i<100010; ++i){
        par[i]=i;
        rr[i]=0;
    }
}
int root(int x){
    return par[x] == x ? x:par[x] = root(par[x]);
}
bool same(int x, int y){
    return root(x)==root(y);
}
void unite(int x, int y){
    x = root(x);
    y = root(y);
    if(x==y) return ;
    
    if(rr[x]<rr[y]){
        par[x] = y;
    }else{
        par[y] = x;
        if(rr[x]==rr[y]) rr[x]++;
    }
}

ll pow_mod(ll x, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res*x%MOD;
        }
        x = x*x%MOD;
        n>>=1;
    }
    return res;
}
ll a[5];
int main() {
    int N; cin >> N;
    REP(i, N){
        string s; cin >> s;
        if(s[0]=='M') a[0]++;
        if(s[0]=='A') a[1]++;
        if(s[0]=='R') a[2]++;
        if(s[0]=='C') a[3]++;
        if(s[0]=='H') a[4]++;
    }
    
    ll ans =0;
    for(int i=0; i<5; ++i){
        for(int j=i+1; j<5; ++j){
            for(int k=j+1; k<5; ++k){
                ans += a[i]*a[j]*a[k];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

typedef long long ll;
typedef pair<int,int> pii;

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 50, M = 500, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int n, ma, mb, a[N], b[N], c[N], dp[N][M][M];

int solve(int i, int sa, int sb){
    if(i == n){
        if(sa && sb){
            int g = __gcd(sa, sb);
            sa /= g, sb /= g;
        }
        return (sa == ma && sb == mb) ? 0 : OO;
    }

    int &ret = dp[i][sa][sb];
    if(~ret)    return ret;

    return ret = min(solve(i + 1, sa, sb), c[i] + solve(i + 1, sa + a[i], sb + b[i]));
}

int main(){
    init();

    cin >> n >> ma >> mb;
    for(int i = 0;i < n;i++)    cin >> a[i] >> b[i] >> c[i];
    memset(dp, -1, sizeof dp);
    cout << (solve(0, 0, 0) == OO ? -1 : solve(0, 0, 0));
}

Measured memory_bytes: 49152
using System;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            int N;
            int[] A = new int[210];

            N = int.Parse(Console.ReadLine());

            // N個分のAを手に入れる
            string str = Console.ReadLine();
            string[] strA = str.Split(' ');
            for (int i = 0; i < strA.Length; ++i)
            {
                A[i] = int.Parse(strA[i]);
            }

            // すべて偶数ならば、すべて2で割った答えで置き換える
            // 何回割り切れたか出力する
            int res = 0;
            while (true)
            {
                // すべて偶数かチェック
                bool existOdd = false;
                for (int i = 0; i < N; ++i)
                {
                    if (A[i] % 2 != 0) existOdd = true;
                }
                if (existOdd) break;

                // 2で割って置き換える
                for (int i = 0; i < N; ++i)
                {
                    A[i] /= 2;
                }

                ++res;
            }

            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 11092
import sys
x = int(input())
pow5s = [i ** 5 for i in range(-200, 201)]
for ap200, a5 in enumerate(pow5s):
    for bp200, b5 in enumerate(pow5s):
        if a5 - b5 == x:
            print(int(ap200 - 200), int(bp200 - 200))
            sys.exit()

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

int d[3][4]={{0,4,5,1},{0,2,5,3},{4,2,1,3}};//d,u,l,r

void dice(int a[6], int n){
	int tmp = a[d[n][0]];
	a[d[n][0]] = a[d[n][1]];
	a[d[n][1]] = a[d[n][2]];
	a[d[n][2]] = a[d[n][3]];
	a[d[n][3]] = tmp;
}

int check(int a[6], int b[6]){
	for(int i = 0;i < 6;i++)if(a[i] != b[i])return 0;
	return 1;
}

int func(int a[6], int b[6]){
	for(int i = 0;i < 6;i++){
		for(int j = 0;j < 4;j++){
			dice(b, 0);
			if(check(a, b))return 1;
		}
		if(i%2 == 0)dice(b, 1);
		else{
			dice(b, 2);
		}
	}
	return 0;
}

int main(){
	int a[6], b[6];
	for(int i = 0;i < 6;i++)cin >> a[i];
	for(int i = 0;i < 6;i++)cin >> b[i];
	
	/*for(int i = 0;i < 6;i++)cout << a[i] << " ";
	cout << endl;
	for(int i = 0;i < 6;i++)cout << b[i] << " ";
	cout << endl;*/
	
	if(func(a, b))cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
int n, m;
int d[3];
int x ,y, w, h, r;
int p = 1;
int main(){
    while(scanf("%d %d", &n, &m), n||m){
        int max = n > m ? n : m;
        int min = n < m ? n : m;

        printf("%d %d\n", min, max);
    }
    return 0;
}


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

using namespace std;

int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	bool inside = true;
	inside &= x + r <= W;
	inside &= x - r >= 0;
	inside &= y + r <= H;
	inside &= y - r >= 0;

	if (inside) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	cout << endl;
}


Measured memory_bytes: 3088
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;
const ll MOD = 1000000007;

int main(){
  int A,B;
  cin >> A >> B;
  cout << max(0,A-2*B) << endl;
  
}

Measured memory_bytes: 3524
a,b,k = map(int, input().split())
for i in range(k):
  if i%2 == 0:
    if a%2 == 1:
      a = a-1
    b = b + a/2
    a = a/2
  else:
    if b%2 == 1:
      b = b-1
    a = a + b/2
    b = b/2
print(str(int(a))+" "+str(int(b)))

Measured memory_bytes: 3060
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n; cin >> n;
    vector<int> a(n);
    int sum = 0, mi = INF;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
        chmin(mi, a[i]);
    }
    if(n % 2 == 1) {
        if(sum % 2 == 0) {
            cout << "Second" << endl;
        } else {
            cout << "First" << endl;
        }
    } else {
        if(mi % 2 == 0) {
            if(sum % 2 == 0) {
                cout << "Second" << endl;
            } else {
                cout << "First" << endl;
            }
        } else {
            cout << "First" << endl;
        }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}


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

using namespace std;

bool flgs[100005];

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) scanf("%d", &A[i]);

    int ptr = 0, ans = 0;
    while (!flgs[ptr]) {
        flgs[ptr] = true;
        ptr = A[ptr];
        ptr--;
        ans++;
        if (ptr == 1) {
            cout << ans << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 768
# -*- coding: utf-8 -*-
"""
C - Energy Drink Collector
https://atcoder.jp/contests/abc121/tasks/abc121_c

"""
import sys


def solve(stores, M):
    total_price = 0
    for s in stores:
        if M <= s[1]:
            return total_price + (s[0] * M)
        total_price += (s[0] * s[1])
        M -= s[1]
    return -1


def main(args):
    N, M = map(int, input().split())
    stores = sorted([[int(i) for i in input().split()] for _ in range(N)])
    ans = solve(stores, M)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 22372
#include <iostream>
#include <queue>

typedef std::pair<int, int> Pair;

constexpr int MAX_HW = 1000;
constexpr int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int H, W;
int field[MAX_HW][MAX_HW];
int tmp[MAX_HW][MAX_HW];

void bfs(int h, int w);

int main(){
	
	std::cin >> H >> W;
	
	for(int i = 0; i < H; ++i){
		for(int j = 0; j < W; ++j){
			std::cin >> field[i][j];
		}
	}
	
	int ans = 0;

	for(int i = 0; i < H; ++i){
		for(int j = 0; j < W; ++j){
			bool flag = true;
			for(int k = 0; k < 4; ++k){
				int nh = i + dx[k], nw = j + dy[k];
				if(nh < 0 || nw < 0 || nh >= H || nw >= W){
					continue;
				}
				if(field[nh][nw] < field[i][j]){
					flag = false;
					break;
				}
			}
			if(flag){
				bfs(i, j);
			}
		}
	}

	for(int i = 0; i < H; ++i){
		for(int j = 0; j < W; ++j){
			if(tmp[i][j] > 1){
				++ans;
			}
		}
	}

	std::cout << ans << std::endl;

	return 0;
}

void bfs(int h, int w){
	bool is_reached[MAX_HW][MAX_HW] = {};
	std::queue<Pair> que;
	que.push(Pair(h, w));

	while(!que.empty()){
		Pair cur = que.front(); que.pop();
		for(int i = 0; i < 4; ++i){
			int nh = cur.first + dx[i], nw = cur.second + dy[i];
			if(nh < 0 || nw < 0 || nh >= H || nw >= W){
				continue;
			}
			if(field[nh][nw] > field[cur.first][cur.second] && !is_reached[nh][nw]){
				que.push(Pair(nh, nw));
				is_reached[nh][nw] = true;
				++tmp[nh][nw];
			}
		}
	}
}



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

int main() {
  int P, Q, R;
  cin >> P >> Q >> R;
  int pq, qr, rp;
  pq = P+Q;
  qr = Q+R;
  rp = R+P;
  int out;
  if(pq <= qr){
    out = pq;
  }else{
    out = qr;
  }
  if(out > rp){
    out = rp;
  }
  cout << out;
}

Measured memory_bytes: 256
n = int(input())
Act = [list(map(int,input().split())) for i in range(n)]

dp = [[0,0,0] for i in range(n)]
dp[0] = [Act[0][j] for j in range(3)]

for i in range(1,n):
  for j in range(3):
    s = 0 
    for k in range(3):
      s = max(s,(dp[i-1][k]+Act[i][j])*int(j!=k))
    dp[i][j] = s

print(max(dp[n-1][0],dp[n-1][1],dp[n-1][2]))

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

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

  long ans = 0;
  for (int i = 0, cnt = 0, b = 0; i < S.size(); i++) {
    if (S.at(i) == 'B') b = 1;
    if (S.at(i) == 'W') {
      if (b) ans += max(0, i - cnt);
      cnt++;
    }
  }

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


Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

ans = INF
for i in range(N):
	tmp = 0
	while A[i]%2 == 0:
		tmp += 1
		A[i] = A[i]//2
	ans = min(ans, tmp)
print(ans)


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

signed main(void)
{
	int n, k;
	cin >> n >> k;
	int v[n];
	ll ans;

	rep(i, n) cin >> v[i];
	ans = 0;
	for(int l = 0; l <= k; l++)
	{
		for(int r = 0; r + l <= k; r++)
		{
			if (l + r > n) continue;

			vector<int> vec;
			ll sum = 0;
			rep(i, l)
			{
				sum += v[i];
				vec.push_back(v[i]);
			}
			rep(i, r)
			{
				sum += v[n - 1 - i];
				vec.push_back(v[n - 1 - i]);
			}
			sort(vec.begin(), vec.end());
			for(int i = 0; i < k - l - r; i++)
			{
				if (i >= vec.size()) break;
				if (vec[i] < 0)
					sum -= vec[i];
			}
			ans = max(ans, sum);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n)
	fmt.Scan(&k)

	max := (n - 1) * (n - 2) / 2

	if k > max {
		fmt.Println("-1")
		return
	}

	var ms [][]int
	for i := 2; i <= n; i++ {
		ms = append(ms, []int{1, i})
	}

	c := max - k

	for i := 2; i < n; i++ {
		if c == 0 {
			break
		}
		for j := i + 1; j <= n; j++ {
			ms = append(ms, []int{i, j})
			c--
			if c == 0 {
				break
			}
		}
	}

	fmt.Println(len(ms))
	for i := 0; i < len(ms); i++ {
		fmt.Printf("%d %d\n", ms[i][0], ms[i][1])
	}
}


Measured memory_bytes: 1152
def kiriage(a):
  if a%10 == 0:
    return a
  else:
    return (a//10+1)*10
  
times = [int(input()) for i in range(5)]

age_times = sum([kiriage(i) for i in times])
lastdish = max([(10-j%10)%10 for j in times])

print(age_times - lastdish)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
//#include <vector>
//#include <cstdlib>
//#include <algorithm>
//#include <cmath>
using namespace std;
 
int main() {
    string s;
    int count_A=0;
    int count_Z=0;    
    cin >> s;
    
  //cout << s << "s.size=" << s.size() << endl;
   for(int i=0; i<s.size(); i++){
        if(s[i] == 'A'){
             count_A=i;
             break;
        }
    }
    
    for(int i=s.size(); i>0; i--){
        if(s[i] == 'Z'){
             count_Z=i;
             break;  
        }
    }
    
    //cout << "count_A=" << count_A << endl;
    //cout << "count_Z=" << count_Z << endl;
    cout << count_Z - count_A + 1 << endl;

    return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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 ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll N;
    string S;
    cin >> N >> S;
    vector<ll> R, G, B;
    map<ll, ll> checkr, checkg, checkb;
    ll r = 0, g = 0, b = 0;
    rep(i, S.size()) {
        if (S[i] == 'R') {
            R.push_back(i);
            checkr[i] = 1;
            r++;
        }
        else if (S[i] == 'G') {
            G.push_back(i);
            checkg[i] = 1;
            g++;
        }
        else {
            B.push_back(i);
            checkb[i] = 1;
            b++;
        }
    }

    ll ans = 0;
    rep(i, N - 2) {
        repd(j, i + 1, N - 1) {
            int diff = j - i;
            ll cnt = 0;
            if (S[i] == S[j]) continue;
            if (S[i] == 'R') {
                if (S[j] == 'G') {
                    ll index = lower_bound(all(B), j) - B.begin();
                    cnt = b - index;
                    if (checkb.count(j + diff) != 0) cnt--;
                }
                else {
                    ll index = lower_bound(all(G), j) - G.begin();
                    cnt = g - index;
                    if (checkg.count(j + diff) != 0) cnt--;
                }
            }
            else if (S[i] == 'G') {
                if (S[j] == 'B') {
                    ll index = lower_bound(all(R), j) - R.begin();
                    cnt = r - index;
                    if (checkr.count(j + diff) != 0) cnt--;
                }
                else {
                    ll index = lower_bound(all(B), j) - B.begin();
                    cnt = b - index;
                    if (checkb.count(j + diff) != 0) cnt--;
                }
            }
            else {
                if (S[j] == 'R') {
                    ll index = lower_bound(all(G), j) - G.begin();
                    cnt = g - index;
                    if (checkg.count(j + diff) != 0) cnt--;
                }
                else {
                    ll index = lower_bound(all(R), j) - R.begin();
                    cnt = r - index;
                    if (checkr.count(j + diff) != 0) cnt--;
                }
            }
            ans += cnt;
        }
    }

    cout << ans << endl;
    return 0;
}

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

int main(){
	int N, ans, cnt;
	cin >> N;
	ans = 0;
	for(int i=1; i<=N; i+=2){
		cnt = 0;
		for(int j=1; j<=i; j++){
			if(i%j == 0){
				cnt++;
			}
		}
		if(cnt == 8){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <cmath>
#include <limits>
#include<iomanip>

using namespace std;

int main() {
    int n; cin >> n;
    int k; cin >> k;
    int x;
    double count = 0;
    double ans = 0;

    for (int i = 1; i < n+1; i++){
        x = i;
        count = 0;
        while(x < k){
            x *= 2;
            count++;
        }
        ans += pow(0.5,count);

    }
    // cout << setprecision(12);
    cout << fixed << setprecision(12)<< ans / (double)(n) << endl;
    return 0;
}

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

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

  int N, M;
  cin >> N >> M;
  int ans = max(0, N - 2*M);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
    //入力
    int n,d,x;
    cin>>n>>d>>x;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];

    int ans=0,cnt;
    for(int i=0;i<n;i++)
    {
      cnt=(d-1)/a[i];
      ans+=(cnt+1);
    }

    cout<<ans+x<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
int arr[maxn];
ll gcd(ll a,ll b){
    return b==0?a:gcd(b,a%b);
}
int main()
{
    int n,k;
    cin>>n>>k;
    int maxv = 0;

    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
        maxv = max(maxv,arr[i]);
    }
    if(k>maxv||(n==1&&arr[1]!=k))
    {
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }
    int greaterdiv = 1e9+5;
    for(int i=1;i<n;i++)
    {
        int cnt = gcd(arr[i],arr[i+1]);
        greaterdiv = min(greaterdiv,cnt);
    }
    if(k%greaterdiv==0||n==1)
    {
        cout<<"POSSIBLE"<<endl;
        return 0;
    }
    else
    {
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 640
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
using System.IO.Pipes;

class Program
{
    static char[] abc = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
    static long mod = 1000000007;
    static void Main(string[] args)
    {

        var NK = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var N = NK[0];
        var K = NK[1];
        var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

        var used = new long[N + 1];
        var now = 0L;
        var next = 1L;
        while (used[next] == 0)
        {
            used[next] = now;
            now++;
            next = A[next - 1];
        }
        var rep = now - used[next];

        var kko = K % rep;
        long ans = 0;

        if (K < used[next])
        {
            for (long i = 1; i <= N; i++)
            {
                if (used[i] == K)
                {
                    ans = i;
                    break;
                }
            }
        }
        else
        {
            for (long i = 1; i <= N; i++)
            {
                if (used[i] - used[next] == (K - used[next]) % rep)
                {
                    ans = i;
                    break;
                }
            }
        }




        Console.WriteLine(ans);
    }



}


Measured memory_bytes: 45356
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5,mod=1e9+7;
int n;
long long ans;
int a[maxn],fact[maxn],inv[maxn],s[maxn];
int dec(int a,int b)
{
	return a-b<0?a-b+mod:a-b;
}
int Inv(int a)
{
	int b=mod-2,ans=1;
	while (b)
	{
		if (b&1)ans=1ll*ans*a%mod;
		a=1ll*a*a%mod;
		b>>=1;
	}
	return ans;
}
int main()
{
	scanf("%d",&n);
	fact[0]=1;
	for (int i=1;i<=n;i++)fact[i]=1ll*fact[i-1]*i%mod;
	for (int i=1;i<=n;i++)inv[i]=Inv(i),s[i]=(s[i-1]+inv[i])%mod;
	for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)
	{
		int s1=s[n-i+1],s2=dec(s[i],s[1]);
		int sum=(s1+s2)%mod;
		ans=(ans+1ll*a[i]*sum%mod)%mod;
	}
	printf("%lld",ans*fact[n]%mod);
	return 0;
}

Measured memory_bytes: 5384
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#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 <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
struct BIT{
    vector<int> bit;
    int n;
    /*
     * 1 ~ nまでのBITを作る
     */
    BIT(int n){
        bit.resize(n+1,0);
        this->n = n;
    }
    int sum(int i){
        int s = 0;
        while(i > 0){
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }
    void add(int i,int x){
        while(i <= n){
            bit[i] += x;
            i += i & -i;
        }
    }
};


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

    int N;
    cin >> N;
    vector<int> a,b,v;
    rep(i,0,N){
        int tmp;
        cin >> tmp;
        if(i % 2){
            b.push_back(tmp);
        }else{
            a.push_back(tmp);
        }
    }

    sort(all(a));
    sort(all(b));

    rep(i,0,N){
        if(i % 2){
            v.push_back(b[i/2]);
        }else{
            v.push_back(a[i/2]);
        }
    }




    vector<int> w;
    w = v;
    sort(all(w));
    map<int,int> za;
    rep(i,0,w.size()){
        za[w[i]] = i+1;
    }
    vector<int> zv(N);//座圧された後のv

    rep(i,0,N){
        zv[i] = za[v[i]];
    }

//    rep(i,0,zv.size()){
//        cout << zv[i] << " ";
//    }
    int cnt = 0;
    rep(i,0,zv.size()){
        if( (i+1) % 2 != zv[i] % 2 ){
            cnt++;
        }
    }

    cout << cnt / 2 << endl;




    return 0;
}


Measured memory_bytes: 6520
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
 
int main(){
  int m;
  cin >> m;
 
  for(int i=0;i<m;i++){
    string train;
    cin >> train;
    set<string> st;
    for( int i = 1, length = train.length() ; i < length ; ++i ){
      string f, b;
      f = train.substr(0,i);
      b = train.substr(i, length-i);
      st.insert(f+b);
      st.insert(b+f);
      reverse(b.begin(), b.end());
      st.insert(f+b);
      st.insert(b+f);
      reverse(f.begin(), f.end());
      st.insert(f+b);
      st.insert(b+f);
      reverse(b.begin(), b.end());
      st.insert(f+b);
      st.insert(b+f);
    }
    cout << st.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
#if defined(LOCAL)
#include "prettyprint.h"
#endif

using namespace std;

using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
const int INF = numeric_limits<int>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(b); a > l(c); a--)

#if defined(LOCAL)
const bool enable_log = true;
#else
const bool enable_log = false;
#endif
struct VoidStream { void operator&(std::ostream&) { } };
#define LOG !(enable_log) ? (void) 0 : VoidStream() & cerr

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  // solution
  l n, a, b;
  while (cin >> n >> a >> b) {
    if (a > b or (n == 1 and a != b)) {
      cout << 0 << lf;
      continue;
    }
    l lo = a * (n - 1) + b;
    l hi = a + (n - 1) * b;
    cout << (hi - lo + 1) << lf;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

void make_combination_list(int cmb[4001]) {
	int count = 0, minus, n, s, i;

	for (i = 0; i < 1001; i++) {
		count += (i+1) * (i+2) / 2;
		cmb[i] = cmb[4000-i] = count;
	}

	minus = n = s = 0;
	for (i = 1001; i < 2001; i++) {
		count += (i+1) * (i+2) / 2;
		n++;
		s += n;
		minus += 4 * s;
		cmb[i] = cmb[4000-i] = count - minus;
	}
}


int main(void) {
	int ans[4001], n;

	make_combination_list(ans);

	while (scanf("%d", &n) != EOF) {
		printf("%d\n", ans[n]);
	}
	return 0;
}

Measured memory_bytes: 612
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

void solve() {
    cini(a);
    cini(b);
    cini(c);
    cini(d);

    int ans1=b*d;
    int ans2=a*d;
    int ans3=b*c;
    int ans4=a*c;

    cout<<max(ans1, max(ans2, max(ans3, ans4)))<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
////////////////////////////////////////////////
int main()
{
    char c;
    cin >> c;
    if (islower(c))
        cout << 'a' << endl;
    else
        cout << 'A' << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

const int N = 1e5+100;

int dp[N];
int n;
int h[N];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n;
    for(int i = 1; i<=n; i++) cin>>h[i];
    
    dp[1] = 0;
    dp[2] = abs(h[2]-h[1]);
    for(int i = 3; i<=n; i++){
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
        //cout<<i<<" "<<dp[i]<<endl;
    }
    
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 3968
import math

result = 0

N, D = map(int, input().split())

for i in range(N):
    X, Y = map(int, input().split())
    if X < 0:
        X = X * -1
    if Y < 0:
        Y = Y * -1
    if math.sqrt(X**2 + Y**2) <= D:
        result += 1

print(result)

Measured memory_bytes: 9196
using System;
using System.IO;
using System.Linq;
using System.Runtime;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] p = Enumerable.Repeat(0, n).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        Console.WriteLine(p.Sum() - p.Max() / 2);
    }
}

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

int main(){
  int n;
  cin >> n;
  vector<ll> h(n+1);
  rep(i,n) cin >> h[i+1];
  h[0] = h[1];
  vector<ll> dp(n+1);
  dp[0] = 0; dp[1] = 0;
  for(int i=1; i<n; i++){
    dp[i+1] = min(dp[i] + abs(h[i+1]-h[i]), dp[i-1] + abs(h[i+1]-h[i-1]));
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long n,a,b;
	cin>>n>>a>>b;
	if(a>b) swap(a,b);
	long long ans=1e18+1;
	if((b-a)%2==0){
		ans=min(ans,(b-a)/2);
	}
	else{
		ans=min(ans,a+(b-a-1)/2);
		ans=min(ans,(n-b)+(b-a-1)/2+1);
	}
	cout<<ans;
}

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

int main(){
	string str;
	
	while( getline(cin,str) ){
		for(int i=0 ; i<str.size() ; i++){
			if(str[i] >= 'a' && str[i] <= 'z'){
				str[i] = str[i] - 'a' + 'A';
			}
		}
		cout << str << endl;
	}
	return 0;
}

Measured memory_bytes: 0