akhauriyash/Code-Regression huggingface dataset:
#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 RFOR(i,b,a) for(int i = (b) - 1; i>= (a); i--)
                            #define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
                            #define FILL(a, value) memset(a, value, sizeof(a)

                            #define SZ(a) (int)a.size()
                            #define ALL(a) a.begin(), a.end()
                            #define PB push_back
                            #define MP make_pair
                            #define er erase
                            #define in insert
                            #define f first
                            #define s second



                            typedef  long long LL;
                            typedef vector<int> VI;
                            typedef vector<LL > VL;
                            typedef vector<vector<int > > VVI;
                            typedef vector<vector<LL>> VVL;
                            typedef vector <vector<pair<int, int >> >VVPI;
                            typedef vector<vector<pair<LL, LL >> >VVPL;
                            typedef vector<pair<LL, LL >> PL;
                            typedef vector<PL> VPL;
                            typedef pair<int, int> PII;
                            typedef vector<PII> VPI;

                            const double PI = acos(-1.0);
                            const int INF = 1e9;
                            const LL LINF = (LL)1e18;

                            const double EPS = 1e-7;
                            const int MAS =  3 *1e5 + 10;
                            const int mod = 998244353;
                            const int MOD =1e9+7;
                            const int LOG= 19;
                            const int ar = 1e5 +100;
                            const int MAX = 1e6 + 1e2;

                        int main() {
                            ios_base::sync_with_stdio(false);
                            cin.tie(NULL);
                            int  n ;
                            cin >> n;
                            VI a(n);
                            rep(i,n)cin >> a[i];
                            VI dp(n + 10);
                            dp[0] = 0 ;
                            dp[1] = abs(a[0] - a[1]);
                            FOR(i,2,n)
                            {
                                dp[i] = min(abs(a[i] - a[i - 1]) +dp[i - 1],abs(a[i] - a[i-2] ) + dp[i - 2] );
                            }
                            cout << dp[n -1];
                            }

















































Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;

int bu[30],cont,may;
char c;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    for(int i=0; i<4; i++){
        cin >> c;
        bu[ c-'A' ]++;
        if( bu[c-'A']==1 ) cont++;
        if( bu[c-'A']>1 ) may++;
    }

    if( cont==2 && may==2 ){
        cout << "Yes";
    }else{
        cout << "No";
    }

    return 0;
}


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

long long a, b, m = 1;
vector<long long> pa, pb;

int main()
{
	cin >> a >> b;

	for (long long i = 2; i * i <= a; i++) {
		if (a % i == 0) {
			pa.push_back(i);

			while (a % i == 0)
				a /= i;
		}
	}

	if (a > 1)
		pa.push_back(a);

	for (long long i = 2; i * i <= b; i++) {
		if (b % i == 0) {
			pb.push_back(i);

			while (b % i == 0)
				b /= i;
		}
	}

	if (b > 1)
		pb.push_back(b);

	for (int i = 0; i < pa.size(); i++) {
		for (int j = 0; j < pb.size(); j++) {
			if (pa[i] == pb[j])
				m++;
		}
	}

	cout << m << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  string s;
  int n=0,w=0,a=0,e=0;
  cin>>s;
  int sum=s.size();
  for(int i=0;i<sum;i++){
    if(s[i]=='N') n++;
    if(s[i]=='W') w++;
    if(s[i]=='S') a++;
    if(s[i]=='E') e++;
  }
  if((n!=0 && a!=0)||(n==0 && a==0)){
    if((w!=0 && e!=0)||(w==0 && e==0)){
      cout<<"Yes"<<'\n';
      return 0;
    }
  }
  cout<<"No"<<'\n';    
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

#define C(I) cout<<(I)<<endl

ll n,m,a,b,c,x,y,z,aa[100010],ba[100010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc;
vector<ll> va,vb,vc;
set<int> sta;
map<ll,ll> mpa;


int main(){
    cin>>n;
    a=0;
    
    for(int i=0;i<n;i++){
        cin>>aa[i];
        mpa[aa[i]]++;
        sta.insert(aa[i]);
    }
    
    for(int i:sta){
        if(i<=mpa[i]){
            a+=mpa[i]-i;
        }
        else{
            a+=mpa[i];
        }
    }
    C(a);
}

Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
ll N;
vector<ll> paths[100000];
map<l_l, ll> mp;
ll p0 = 1e9 + 7;
ll p1 = 4e9 + 7;
ll b0 = 18254964;
ll b1 = 14852534;
ll ans;


l_l dfs(int now, int from) {
    l_l val = {1, 1};
    for(auto to : paths[now]) {
        if(to == from) continue;
        auto tmp = dfs(to, now);
        tmp.first *= b0;
        tmp.second *= b1;
        val.first += tmp.first;
        val.second += tmp.second;
    }
    val.first %= p0;
    val.second %= p1;
    ans += mp[val];
    mp[val]++;
    return val;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 0; i < N - 1; i++) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        paths[a].push_back(b);
        paths[b].push_back(a);
    }
    dfs(0, -1);
    cout << ans << endl;
    return 0;
}


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

map<string, int> atoms;

bool match(char c, string s)
{
	rep(i, 0, s.length()) if (s[i] == c) return true;
	return false;
}

int parse(string s, int &i)
{
	int ret = 0;

	while (!match(s[i], ")="))
	{
		int a;

		if (s[i] == '(')
		{
			i++;
			a = parse(s, i);
			if (a < 0) return -1;
			i++;
		}
		else
		{
			int j = i;
			i++;
			while ('a' <= s[i] && s[i] <= 'z') i++;

			string ss = s.substr(j, i - j);
			//cout << ss << endl;
			if (atoms.find(ss) == atoms.end()) return -1;
			a = atoms[ss];
		}

		int b;
		if ('0' <= s[i] && s[i] <= '9')
		{
			b = 0;
			while ('0' <= s[i] && s[i] <= '9')
			{
				b = b * 10 + s[i] - '0';
				i++;
			}
		}
		else
		{
			b = 1;
		}

		ret += a * b;
	}

	return ret;
}

int main()
{
	while (1)
	{
		string s; cin >> s;
		if (s == "END_OF_FIRST_PART") break;

		int sn; cin >> sn;
		atoms[s] = sn;
	}

	while (1)
	{
		string s; cin >> s;
		if (s[0] == '0' && s.length() == 1) return 0;
		s += "=";

		int i = 0;
		int ans = parse(s, i);
		if (ans < 0)
			cout << "UNKNOWN" << endl;
		else
			cout << ans << endl;
	}
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k;
  cin >> k;
  int odd,even;
  for(int i = 1;i<=k;i++){
    if( i % 2 == 0){
      odd++;
    }
    else{
      even++;
    }
  }
  cout << odd*even;
}

Measured memory_bytes: 256
from collections import defaultdict

n, m = map(int, input().split())
A = list(map(int, input().split()))
A_rui = [0, A[0]]
for i in range(1,n):
    A_rui.append(A[i]+A_rui[-1])

A_rui_mod = [x % m for x in A_rui]
mod_m_count = defaultdict(int)

ans = 0
for i in range(n+1):
    mod_m = A_rui_mod[i]
    ans += mod_m_count[mod_m]
    mod_m_count[mod_m] += 1

# print(mod_m_count)
# print(A_rui)
print(ans)

Measured memory_bytes: 18852
#include <iostream>
#include <string>

int main()
{
	std::string S;

	std::cin >> S;

	int numofRainyDay = 0;
	for (int i = 0; i < S.size(); i++)
	{
		if (S[i] == 'R')
		{
			numofRainyDay++;
		}
	}

	int answer;
	if (S[1] == 'S' && numofRainyDay > 0)
	{
		answer = 1;
	}
	else
	{
		answer = numofRainyDay;
	}
	std::cout << answer;

	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/


signed main() {
	int a; string s; cin >> a >> s;
	if (a >= 3200)cout << s << endl;
	else cout << "red" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.StringJoiner;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int N = sc.nextInt();
		int X = sc.nextInt() - 1;
		int Y = sc.nextInt() - 1;
		int[] counter = new int[N - 1];
		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				int itoj = j - i;
				int i_x_y_j = Math.abs(X - i) + Math.abs(Y - j) + 1;
				int i_y_x_j = Math.abs(Y - i) + Math.abs(X - j) + 1;
				int min = Math.min(itoj, Math.min(i_x_y_j, i_y_x_j));
				counter[min - 1] += 1;
			}
		}
		StringJoiner out = new StringJoiner("\n");
		for (int x : counter) {
			out.add(String.valueOf(x));
		}
		System.out.println(out.toString());
	}
}

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

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
int main() {
    int n;cin >> n;
    map<int,int> mp;
    rep(i, n) {
        int a;cin  >> a;
        mp[a]++;
    }
    int count = 0;
    // rep1(i, n) count+=mp[i]%i;
    for(auto p:mp) {
        if(p.first==1) count+=mp[p.first] - 1;
        count += mp[p.first]%p.first;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 8012
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    for i in range(1, N):
        if A[i-1] > A[i]:
            ans += A[i-1] - A[i]
            A[i] = A[i-1]
    
    print(ans)
    
resolve()

Measured memory_bytes: 94232
#include <cstdio>
#define ll long long
ll mod = 1000000007;
ll big(ll b, ll p){
	if (p == 1) return b;
	ll h = big(b, p / 2);
	ll res = (h * h) % mod;
	if (p % 2 == 1) res = (res * b) % mod;
	return res;
}
int main(){
	ll n, k;
	scanf("%lld %lld", &n, &k);
	ll a[k + 1], ans = 0;
	for (int i = k; i >= 1; i--){
		a[i] = big(k / i, n);
		for (int j = 2; i * j <= k; j++){
			(a[i] += mod - a[i * j]) %= mod;
		}
	}
	for (int i = 1; i <= k; i++){
		(ans += (i * a[i]) % mod) %= mod;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 2512
#include <iostream>

using namespace std;

int gcd(int a, int b) {
    if (a < b) {
        int d = b % a;

        if (d == 0) {
            return a;
        }

        return gcd(a, d);
    } else if (b < a) {
        int d = a % b;

        if (d == 0) {
            return b;
        }

        return gcd(d, b);
    } else {
        return a;
    }
}

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

    long long sum = 0;

    for (int i = 1; i <= K; ++i) {
        for (int j = 1; j <= K; ++j) {
            int g = gcd(i, j);

            for (int l = 1; l <= K; ++l) {
                sum += gcd(g, l);
            }
        }
    }

    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> all;
  for(int i = 1 ;i < 10 ; i++){
    for(int j = 1; j < 10 ; j++){
      all.push_back(i*j);
    }
  }
  int n;cin>>n;
  for(int i = 0 ; i < all.size() ; i++){
    if(all[i] == n){cout<<"Yes";return 0;}
  }
  cout<<"No";
  return 0;
}

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

int main() {

int x;cin>>x;
for(int a=-120;a<=119;a++)
{
  for (int b = 0; b <= 119; b++)
  {
    if(a*a*a*a*a+b*b*b*b*b==x)
    {cout << a<<" "<<-b<<endl;return 0;}
  }
  
}

}
/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   long int n;
   cin>>n;

   vector<pair<long int,long int>> v(n);

   for(long int i = 0; i < n; i++)
   	 	cin>>v[i].first>>v[i].second;

   long int ans = 0;

   for(long int i = 0; i < n; i++){
   	if(v[i].first == v[i].second){
   		ans++;
   		if(ans >= 3)
   			return cout<<"Yes",0;
   	}
   	else
   		ans = 0;
   }

   cout<<"No";

   return 0;
}

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

#define LL long long
#define mod 1000000007

LL n, k, ans;

LL power(LL x, LL y) { 
    LL res = 1;
    x = x % mod;

    while (y > 0) { 
        if (y & 1) 
            res = (res*x) % mod; 
        y = y>>1;
        x = (x*x) % mod; 
    } 
    return res; 
} 

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

    cin >> n >> k;
    LL dp[k + 1];

    for(int i = k; i > 0; i--) {
    	dp[i] = power(k / i, n);
    	for(int j = i + i; j <= k; j += i) dp[i] -= dp[j];
    	ans = (ans + (1LL * i * dp[i]) % mod) % mod;
    }
    cout << (ans + mod) % mod;
}

Measured memory_bytes: 4440
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    ll N, X, M;
    cin >> N >> X >> M;

    ll n1 = X, key, cnt = 0, ans = 0;
    map<ll, bool> ma;
    vector<ll> v, vv;
    while (1) {
        if (cnt == N) {
            cout << ans << endl;
            return 0;
        }
        if (ma[n1]) {
            key = n1;
            break;
        }

        cnt++;
        ans += n1;
        v.push_back(n1);
        ma[n1] = true;
        n1 = (n1 * n1) % M;
    }

    N -= (cnt + 1);
    bool judge = 0;
    for (int i = 0; i < v.size(); i++) {
        if (v[i] == key)
            judge = 1;
        if (judge) {
            vv.push_back(v[i]);
        }
    }

    rep(i, vv.size() - 1) { vv[i + 1] += vv[i]; }

    ans += (N / (ll)vv.size()) * (ll)vv.back() + vv[N % (ll)vv.size()];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7504
#include<stdio.h>
int gcd(int a, int b)
{
	int r = a % b;
	while (r > 0)
	{
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
int main()
{
	int k;
	scanf("%d", &k);
	int a, b, c;
	int ans = 0;
	for (a = 1; a <= k; a++)
		for (b = 1; b <= k; b++)
			for (c = 1; c <= k; c++)
				ans += gcd(a, gcd(b, c));
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1736
class Dice:
    def __init__(self, dice):
        self.dice = dice
        self.face = {'head':1, 'tail':4, 'left':3, 'right':2, 'above':0, 'below':5}
    
    def roll(self, ch):
        dice = self.dice
        face = self.face
        if ch == 'S':
            tmp = dice[face['head']]
            dice[face['head']] = dice[face['above']]
            dice[face['above']] = dice[face['tail']]
            dice[face['tail']] = dice[face['below']]
            dice[face['below']] = tmp
        elif ch == 'N':
            tmp = dice[face['head']]
            dice[face['head']] = dice[face['below']]
            dice[face['below']] = dice[face['tail']]
            dice[face['tail']] = dice[face['above']]
            dice[face['above']] = tmp
        elif ch == 'W':
            tmp = dice[face['left']]
            dice[face['left']] = dice[face['above']]
            dice[face['above']] = dice[face['right']]
            dice[face['right']] = dice[face['below']]
            dice[face['below']] = tmp
        else:
            tmp = dice[face['left']]
            dice[face['left']] = dice[face['below']]
            dice[face['below']] = dice[face['right']]
            dice[face['right']] = dice[face['above']]
            dice[face['above']] = tmp

    def top(self):
        dice = self.dice
        face = self.face
        return dice[face['above']]
    
    def find_right(self, a, b):
        dice = self.dice
        face = self.face
        order = 'NNNNWNNNWNNNENNNENNNWNNN'
        for ch in order:
            self.roll(ch)
            if dice[face['above']] == a and dice[face['head']] == b:
                break
        return dice[face['right']]

    def equal(self, dice2):
        dice = self.dice
        dice2 = dice2.dice
        tag = False
        order = 'NNNNWNNNWNNNENNNENNNWNNN'
        for ch in order:
            self.roll(ch)
            flag = True
            for i in range(6):
                if dice[i] != dice2[i]:
                    flag = False
                    break
            if flag:
                tag = flag
                break
        return tag

n = int(input())
dices = []
for i in range(n):
    dices.append(Dice([*map(int, input().split())]))
flag = True
for i in range(n):
    if flag != True:
        break
    for j in range(i):
        if dices[i].equal(dices[j]):
            flag = False
            break
print(['No', 'Yes'][flag])



Measured memory_bytes: 5624
import java.util.*;
 
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int ac = 0;
        int wa = 0;
        int tle = 0;
        int re = 0;

        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            String str = sc.next();
            if (str.equals("AC")) {
                ac++;
            } else if (str.equals("WA")) {
                wa++;
            } else if (str.equals("TLE")) {
                tle++;
            } else {
                re++;
            }
        }

        System.out.println("AC x " + ac);
        System.out.println("WA x " + wa);
        System.out.println("TLE x " + tle);
        System.out.println("RE x " + re);
	}
}


Measured memory_bytes: 58536
#include <iostream>
#include <algorithm>

using std::cout;
using std::endl;
using std::cin;
using std::max;

int A[3][110];
int cumulative[3][110];

/* Return sum of [ A[row][lo]..A[row][hi] ]
 */
int query_closed(int row, int lo, int hi) {
	return cumulative[row][hi+1] - cumulative[row][lo];
}

int main() {
	// Input
	int N;
	cin >> N;
	for(int i = 0; i < N; ++i) cin >> A[0][i];
	for(int i = 0; i < N; ++i) cin >> A[1][i];
	// Preparation
	for(int i = 0; i < N; ++i) {
		cumulative[0][i+1] = cumulative[0][i] + A[0][i];
		cumulative[1][i+1] = cumulative[1][i] + A[1][i];
	}
	// Calculation
	// -- c(0,[0..k]) + c(1,[k..N-1])
	int ans = 0;
	for(int i = 0; i < N; ++i) {
		int u = query_closed(0, 0, i);
		int d = query_closed(1, i, N-1);
		int c = u + d;
		ans = max(ans, c);
	}
	// Output
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 764
#include <stdio.h>
#include <stdlib.h>

#define MAX_NODE (100000)

int parent[MAX_NODE] = {0};
int* tree_cache[MAX_NODE];
int t_size[MAX_NODE];

void init_tree(int root, int* leafs, int leaf_size) {
    int i,j,node,id;
    int cache[MAX_NODE];
    
    // 葉の要素だけ実体化する
    for(i=0;i<leaf_size;i++) {
        id = leafs[i];
        cache[0] = id;
        for(j=1;j<MAX_NODE;j++) {
            node = parent[cache[j-1]];
            cache[j] = node;
            if(node == root) {
                t_size[id] = j + 1;
                break;
            }
        }
        tree_cache[id] = (int*)malloc(t_size[id]*sizeof(int));
        for(j=0;j<t_size[id];j++) tree_cache[id][j] = cache[j];

        // 途中の要素はポインタを設定
        for(j=1;j<t_size[id];j++) {
            node = tree_cache[id][j];
            tree_cache[node] = &tree_cache[id][j];
            t_size[node] = t_size[id] - j;
        }
    }
}

int binary_search(int left, int right, int* so, int* si, int root) {
    int i, node;
    int middle = (left + right) / 2;
    if(right - left < 40) {
        for(i=left,node=root;i<=right;i++) {
            if(so[i] == si[i]) {
                return so[i];
            }
        }
        return node;
    }
    
    if(so[middle] != si[middle]) {
        return binary_search(middle, right, so, si, root);
    }
    
    return binary_search(left, middle, so, si, root);
}

int solve(int source, int sink, int root) {
    int node;
    int last;
    int* p_so_list;
    int* p_si_list;
    int so, si;
    if(source == sink) return source;
    so = si = 0;

    p_so_list = tree_cache[source];
    so = t_size[source];
    p_si_list = tree_cache[sink];
    si = t_size[sink];

    if(si > so) {
        last = si - so;
        return binary_search(0, so, p_so_list, &p_si_list[last], root);
    }
    
    last = so - si;
    return binary_search(0, si, &p_so_list[last], p_si_list, root);
    
}

int main(void) {
    int i, j, m, n, t, q;
    int source, sink;
    int is_root[MAX_NODE] = {0};
    int leafs[MAX_NODE];
    int leaf_size = 0;
    int root;

    scanf("%d\n", &n);
    for(i=0;i<n;i++) {
        scanf("%d", &m);
        if(m == 0) leafs[leaf_size++] = i;

        for(j=0;j<m;j++) {
            scanf("%d", &t);
            is_root[t] = -1;
            parent[t] = i;
        }
    }
    
    // ルート
    root = 0;
    for(i=0;i<n;i++) {
        t_size[i] = -1;
        if(is_root[i] == 0) {
            root = i;
            break;
        }
    }

    init_tree(root, leafs, leaf_size);
    
    scanf("%d\n", &q);
    for(i=0;i<q;i++) {
        scanf("%d %d\n" ,&source, &sink);
        printf("%d\n", solve(source, sink, root));
    }

    return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int n;
    cin >> n;
    int cnt_ac, cnt_wa, cnt_tle, cnt_re;
    cnt_ac = 0;
    cnt_wa = 0;
    cnt_tle = 0;
    cnt_re = 0;
    string s;
    rep(i, n)
    {
        cin >> s;
        if(s == "AC")
            cnt_ac++;
        else if(s == "WA")
            cnt_wa++;
        else if(s == "TLE")
            cnt_tle++;
        else if(s == "RE")
            cnt_re++;

    }
    cout << "AC x " << cnt_ac << endl;
    cout << "WA x " << cnt_wa << endl;
    cout << "TLE x " << cnt_tle << endl;
    cout << "RE x " << cnt_re << endl;
    
        return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

ll A, B;

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

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

  std::cin >> A >> B;

  ll g = gcd(A, B);

  int cnt = 1;

  for(ll i=2;i*i<=g;++i){
      if(g % i == 0){
          cnt += 1;
          while(g % i == 0){
              g /= i;
          }
      }
  }

  if(g > 1){
      cnt += 1;
  }

  std::cout << cnt << std::endl;
}


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

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 100011

int n, i;
char s[maxN];

int say[maxN];
int tp[maxN];

void check() {
    for (i = 2; i <= n + 1; i++)
        tp[i + 1] = tp[i] ^ say[i] ^ tp[i - 1];

    if (tp[1] != tp[n + 1]) return;
    if (tp[2] != tp[n + 2]) return;

    for (i = 1; i <= n; i++)
        printf("%c", (tp[i] ? 'W' : 'S'));

    exit(0);
}

int main()
{
    //freopen("test.in","r",stdin);

    scanf("%d\n%s", &n, s + 1);
    s[n + 1] = s[1];
    s[n + 2] = s[2];

    for (i = 1; i <= n + 2; i++) say[i] = (s[i] == 'o' ? 0 : 1);

    tp[1] = 0;
    tp[2] = 0;
    check();

    tp[1] = 0;
    tp[2] = 1;
    check();

    tp[1] = 1;
    tp[2] = 0;
    check();

    tp[1] = 1;
    tp[2] = 1;
    check();

    printf("-1");



    return 0;
}


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

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = 0;
		while(true) {
			int W = sc.nextInt();
			if (W == 0) 
				break;
			
			System.out.printf("Case %1$d:", ++count);
			System.out.println();
			
			int n = sc.nextInt();
			int[] p = new int[n];
			int[] w = new int[n];
			sc.nextLine();
			
			for (int i = 0; i < n; i++) {
				String[] line = sc.nextLine().split(",");
				
				p[i] = Integer.parseInt(line[0]);
				w[i] = Integer.parseInt(line[1]);
			}
			
			nap(W, n, p, w);
		}
	}
	
	public static void nap(int W, int n, int[] p, int[] w) {
		int[][] map = new int[n+1][W+1];
		for (int i = 0; i < n; i++) {
			Arrays.fill(map[n], -1);
		}
		
		map[0][0] = 0;
		
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= W; j++) {
				if (map[i][j] < 0) 
					continue;
				
				// iを使わない
				map[i+1][j] = Math.max(map[i][j], map[i+1][j]);
				
				// iを使う
				int weight = j + w[i];
				if (weight > W)
					continue;
				
				map[i+1][weight] = Math.max(map[i][j] + p[i], map[i+1][weight]);
			}
		}
		
		int maxP = 0;
		int maxW = 0;
		for (int j = 0; j <= W; j++) {
			if (map[n][j] > maxP) {
				maxP = map[n][j];
				maxW = j;
			}
		}
		System.out.println(maxP);
		System.out.println(maxW);
	}
}

Measured memory_bytes: 30988
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    h = [frozenset()]
    for c in S:
        h.append(h[-1] | frozenset(c))
    t = [frozenset()]
    for c in reversed(S):
        t.append(t[-1] | frozenset(c))
    return max(len(hh & tt) for hh, tt in zip(h, reversed(t)))

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    print(solve(N, S))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll x;
    cin>>x;
    if(x>=500)
    {
        cout<<(((x/500)*1000)+((x-((x/500)*500))/5)*5)<<endl;
    }
    else
        cout<<(x/5)*5<<endl;

    }


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

int main(){
	int a,b,c;
	int tmp;
	cin>> a >> b >> c;
	
	if( a > b ){
		tmp = a;
		a = b;
		b = tmp;
	}
	if( b > c ){
		tmp = b;
		b = c;
		c = tmp;
	}
	if( a > b ){
		tmp = a;
		a = b;
		b = tmp;
	}
	
	cout << a << " " << b << " " << c << endl;
	
    return 0;
}

Measured memory_bytes: 3084
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
void printv(vector<int>& v){
    for(auto item: v)
        cout<<item<<" ";
    cout<<endl;
}
int main(){
  int A, B, C;
  cin >> A >> B >> C;

  cout << ((A == B && B == C) ? "Yes":"No")
  << endl;
}

Measured memory_bytes: 256
local n, m = io.read("*n", "*n")
local as, bs = {}, {}
local parent = {}
local sz = {}
for i = 1, n do
  parent[i] = i
  sz[i] = 1
end
local ret = n * (n - 1) // 2
for i = 1, m do
  as[i], bs[i] = io.read("*n", "*n")
end

local function uf_findroot(idx)
  local idx_update = idx
  while parent[idx] ~= idx do
    idx = parent[idx]
  end
  while parent[idx_update] ~= idx do
    parent[idx_update], idx_update = idx, parent[idx_update]
  end
  return idx
end
local ans = {}
for i = 1, m do
  ans[i] = 0
end
for i = m, 1, -1 do
  ans[i] = ret
  local a, b = as[i], bs[i]
  local ra, rb = uf_findroot(a), uf_findroot(b)
  if ra ~= rb then
    local sza, szb = sz[ra], sz[rb]
    ret = ret - sza * szb
    sz[ra] = sza + szb
    parent[rb], parent[b] = ra, ra
  end
end
print(table.concat(ans, "\n"))


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

int main(){
	  while(1){
			int N;
			cin >> N;
			if(!N) break;

			vector<set<int> > list(N);
			for(int i=0; i<N; i++){
				  int M; cin >> M;
				  for(int j=0; j<M; j++){
						int tmp; cin >> tmp;
						list[i].insert( tmp );
				  }
			}
			int K; cin >> K;
			vector<int> l(K);
			for(int i=0; i<K; i++)  cin >> l[i];

			int hannin = -2;
			for(int i=0; i<N; i++){
				  for(int j=0; j<K; j++){
						if(list[i].find( l[j] ) == list[i].end()) goto L1; // ????????§??????
				  }
				  if(hannin == -2) hannin = i;
				  else{
						hannin = -2;
						goto L2;
				  }
			L1:;
			}
			
			
	  L2:
			cout << hannin+1 << endl;
			
	  }
}

Measured memory_bytes: 1628
#include <cstdio>

using namespace std;

int n,v[50],a[50];

int main()
{
    int ret = 0;

    scanf( "%d\n", &n );
    for( int i = 0; i < n; i++ )
    {
        scanf( "%d ", &v[i] );
    }
    for( int i = 0; i < n; i++ )
    {
        scanf( "%d ", &a[i] );
    }
    
    for( int i = 0; i < n; i++ )
    {
        v[i] -= a[i];
        if( 0 < v[i] )
        {
            ret += v[i];
        }
    }
    printf( "%d\n", ret );
    return 0;
    
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <stdlib.h>

#define INC(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define DEC(i, a, b) for(int (i) = (a); (i) > (b); --(i))
#define REP(i, n)    INC(i, 0, n)
#define comp(a, b) int comp(const void *(a), const void *(b))

typedef unsigned int uint;
typedef unsigned long ul;
typedef long long  ll;
typedef unsigned long long ull;

const int MOD = 1e9 + 7;

using namespace std;

void TFprint(bool b, std::string T, std::string F){
    if(b){
        cout << T << endl;
    }else{
        cout << F << endl;
    }
}

int abs(int x){
    return x > 0? x : -x;
}

int max(int a, int b){
    return a > b? a : b;
}

int min(int a, int b){
    return a < b? a : b;
}


int main(){
    int a, b; cin >> a >> b;
    int n = b - a;
    int h = (n-1)*n/2;
    cout << h - a << endl;
    return 0;
}

Measured memory_bytes: 256
use proconio::{input, fastout};
// use itertools::Itertools;

fn rec(v: &mut Vec<u64>, cur: u64, d: usize) {
  v.push(cur);
  if d == 10 {
    return;
  }

  let a = cur % 10;
  if a > 0 {
    rec(v, cur * 10 + a-1, d+1);
  }
    rec(v, cur * 10 + a, d+1);
  if a+1 <= 9 {
    rec(v, cur * 10 + a+1, d+1);
  }

}

#[fastout]
fn main() {
  input!{
    k: usize
  };
  let mut v = Vec::new();
  for i in 1..10 {
    rec(&mut v, i, 1);
  }
  v.sort();
  println!("{}", v[k-1]);
}


Measured memory_bytes: 4348
N, M = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
as.map!{|a| a - 1}

imos = Array.new(M, 0)
pena = Array.new(M, 0)

(N - 1).times do |i|
    s = as[i]
    t = as[i+1]
    next if (t - s) % M == 1
    if s < t
        imos[(s+2) % M] += 1 if s + 2 < M
        imos[(t+1) % M] -= 1 if t + 1 < M
    else
        imos[(s+2) % M] += 1 if s + 2 < M
        imos[0] += 1
        imos[(t+1) % M] -= 1 if t + 1 < M
    end

    pena[(t+1) % M] += (t - s) % M - 1 if (t + 1) % M > 0
end

(M - 1).times do |i|
    imos[i+1] += imos[i]
end

xs = Array.new(M)
xs[0] = 0

(N - 1).times do |i|
    s = as[i]
    t = as[i+1]
    if s > t
        xs[0] += t + 1
    else
        xs[0] += (t - s)
    end
end

(M - 1).times do |i|
    xs[i+1] = xs[i] - imos[i+1] + pena[i+1]
end

puts xs.min

Measured memory_bytes: 10396
#include <iostream>

const int maxn = 1e5+7;

int fa[maxn];

void init(int n) {
	for (int i = 1; i <= n; i++) fa[i] = i;
}

int find(int u) {
	return fa[u] == u ? fa[u] : fa[u] = find(fa[u]);
}

void unin(int u, int v) {
	fa[find(v)] = find(u);
}

int main(int argc, char *argv[]) {  
	int n, p[maxn], x, y, m;
	std::cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		std::cin >> p[i];
	}
	init(n);
	for (int i = 0; i < m; i++) {
		std::cin >> x >> y;
		unin(x, y);
	}
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (find(i) == find(p[i])) cnt++;
	}
	std::cout << cnt;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  int k,n,i,j;
  cin>>k>>n;
  int a[n];
  int s1=0,s2=0,ans=INT_MAX;
  rep(i,0,n){
    cin>>a[i];
    if(i>0)
      s1+=a[i]-a[i-1];
  }
  ans=s1;
rep(i,0,n)
{
  if(i+1<n)
  s2= a[i]+k-a[n-1]+a[n-1]-a[i]-a[i+1]+a[i];
 else
  s2= a[i]+k-a[n-1]+a[n-1]-a[i]-a[0]+a[i];
  ans=min(ans,s2);
  //cout<<ans<<endl;
}
cout<<ans;
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  t=1;
  //cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=5010,P=998244353;
inline char gc(){
    static char buf[N],*s=buf,*t=buf;
    return s==t&&(t=(s=buf)+fread(buf,1,N,stdin),s==t)?EOF:*s++;
}
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
int n,a[N],du[N],L,h[N],ne[N*N],to[N*N],v[N],e[N][N];
#include<queue>
struct cmp{bool operator() (int x,int y){return a[x]<a[y];}};
priority_queue<int,vector<int>,cmp>q;
inline void addl(int x,int y){
	ne[++L]=h[x];h[x]=L;to[L]=y;du[y]++;
}
void dfs(int x){
	v[x]=1;
	for(int y=1;y<=n;y++)
	if(!v[y]&&e[x][y])addl(x,y),dfs(y);
}
int main(){
	int i,k,x;
	n=read();
	for(i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);
	for(i=1;i<=n;i++)
	for(k=i+1;k<=n;k++)
	if(__gcd(a[i],a[k])>1)e[i][k]=e[k][i]=1;
	for(i=1;i<=n;i++)if(!v[i])dfs(i);
	for(i=1;i<=n;i++)if(!du[i])q.push(i);
	for(i=1;i<=n;i++){
		x=q.top();q.pop();
		printf("%d ",a[x]);
		for(k=h[x];k;k=ne[k])
		if(!(--du[to[k]]))q.push(to[k]);
	}puts("");
	return 0;
}

Measured memory_bytes: 44672
#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>

using namespace std;

typedef long long ll;

int N;
ll X;
vector<ll> a;
vector<ll> cost[2000 + 10];

vector<ll> Slide_minimum(const vector<ll>& ar, int k) {
	//k=1の時は普通にa[i]を参照する。
	int n = ar.size();
	vector<ll> ret;
	deque<ll> deq;
	for (int i = 0; i < n; i++) {
		while (deq.size() && ar[deq.back()] > ar[i])deq.pop_back();
		deq.push_back(i);
		if (k <= i + 1) {
			ret.push_back(ar[deq.front()]);
			if(deq.front() == i - k + 1)deq.pop_front();
		}
	}
	return ret;
}

int main() {
	cin >> N >> X;
	a.resize(2 * N);
	for (int i = 0; i < N; i++)cin >> a[i], a[i + N] = a[i];

	for (int k = 0; k < N; k++) {
		cost[k] = Slide_minimum(a, k + 1);
	}

	ll ans = 1145141919810893;
	for (int k = 0; k < N; k++) {
		ll spend = k * X;
		for (int i = 0; i < N; i++) {
			spend += cost[k][(N + i - k) % N];
		}
		ans = min(ans, spend);
	}
	cout << ans << endl;
	return 0;
}

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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In,' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var r = cin.ReadInt;
            var D = cin.ReadInt;
            var x2000 = cin.ReadInt;

            var X1 = x2000;
            var X2 = 0;

            for(var i=0;i<10;i++){
                X2 = r * X1 - D;
                WriteLine(X2);
                X1 = X2;
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream,char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0;i < tmp.Length;i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }

}


Measured memory_bytes: 13268
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long a = GetLong();
		WriteLine(a + a * a + a * a * a);
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 27544
#include <bits/stdc++.h>
using namespace std;
int main() {
  char a, b, c, d; cin >> a >> b >> c >> d;
  cout << ((((a == b && c == d) || (a == c && b == d) || (a == d && b == c)) && !(a == b && b == c)) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import math
import bisect
from functools import lru_cache
import itertools

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def main():
    # N = int(input())
    N, M = [int(a) for a in input().split()]

    D = (M - 1) // 2 + 1
    D2 = M - D

    for ii in range(M):

        if ii % 2 == 0:
            j = (ii) // 2
            a = D - 1 - j
            b = a + 2 * j + 1
        else:
            j = (ii - 1) // 2
            a = 2 * D + (D2 - 1 - j)
            b = a + 2 * j + 2
        print(a + 1, b + 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10052
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#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<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
char t[1 << 18], d[1 << 18];
 
int n, q; string s;
int sta(int x) {
	rep(i, q) {
		if (s[x] == t[i]) {
			if (d[i] == 'L')x--;
			else x++;
		}
		if (x < 0)return 1;
		else if (x >= n)return 2;
	}
	return 0;
}
void solve() {
	cin >> n >> q >> s;
	rep(i, q) {
		cin >> t[i] >> d[i];
	}
	int le = 0, ri = n;
	while (ri - le > 1) {
		int mid = (le + ri) / 2;
		if (sta(mid) == 1)le = mid;
		else ri = mid;
	}
	int cle = 0, cri = n;
	while (cri - cle > 1) {
		int mid = (cle + cri) / 2;
		if (sta(mid) == 2)cri = mid;
		else cle = mid;
	}
	int ans = cle - ri + 1;
	if (ans < 0)ans = 0;
	cout << ans << endl;
}
int main() {
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 1028
import copy
L=[[j for j in range(10)] for i in range(10)]
H,W=map(int,input().split())
costs=list()
costs2=list()
for i in range(10):
  L1=list(map(int,input().split()))
  costs.append(L1[1])
  costs2.append(L1[1])
  L[i]=L1
for i in range(12):#繰り返し
  for j in range(10):#costsのそれぞれに対し
    for k in range(10):#costs[j]=min(costs[j],costs[k]+jからkのコスト
      costs2[j]=min(costs2[j],costs[k]+L[j][k])
  costs=copy.copy(costs2)
costs.append(0)
s=0
for i in range(H):
  A=list(map(int,input().split()))
  s+=sum([costs[i] for i in A])
print(s)

Measured memory_bytes: 9296