akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;


int main(int argc, const char * argv[]) {

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

	LL N;

	cin >> N;

	vector<pair<string, pair<int,int>>> SP(N);

	for(int i=0;i<N;i++){

		pair<string, pair<int,int>> p1;

		string wrk1;
		int wrk2;

		cin >> wrk1 >> wrk2;

		p1 = make_pair(wrk1,make_pair(-wrk2,i));

		SP.push_back(p1);

	}

	sort(SP.begin(),SP.end());

	for(int i=N ; i<N*2 ; i++){
		cout << SP[i].second.second + 1 << endl;
	}

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vvll vector<vll>
#define vvi vector<vector<int>>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define pii pair<int, int>
#define vpli vector<pair<long long, int>>
#define deb(x) cout << "deb " << #x << " " << x << endl;
#define all(x) x.begin(), x.end()
#define endl "\n"
const ll BIG = 3e5;
const int MOD =  998244353;

void swap(ll &a, ll &b)
{
    ll t = a;
    a = b;
    b = t;
}

ll Min(ll a, ll b, ll c)
{
    return min(a, min(b, c));
}

void printvec(vi &vec)
{
    for (int x : vec)
    {
        cout << x << " ";
    }
    cout << endl;
}

int sum(int a)
{
    int ans = 0;
    while (a)
    {
        ans += (a % 10);
        a = a / 10;
    }
    return ans;
}
void print(vi &mp)
{
    for (auto x : mp)
    {
        cout << x;
    }
    cout << endl;
}

void solve()
{
    int n,m;
    cin>>n>>m;
    vvi adj(n+1);
    int u,v;
    for(int i=0;i<m;i++)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    vb vis(n+1);
    vi dist(n+1,BIG);
    vis[1] = 1;
    dist[1] = 0;
    queue<int> q;
    q.push(1);
    while(!q.empty())
    {
        int s = q.front();
        q.pop();
        for(int x : adj[s])
        {
            if(!vis[x])
            {
                vis[x] = 1;
                dist[x] = s;
                q.push(x);
            }
        }
    }
    for(int i=1;i<=n;i++) if(!vis[i]){ cout<<"No\n";return;}
    cout<<"Yes\n";
    for(int i=2;i<=n;i++) cout<<dist[i]<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}
/*
#include<bits/stdc++.h>
using namespace std;
vector<int> adj[100001];
bool visited[100001];
int ans[100001];

void bfs(){
    queue<int> q;
    q.push(1);
    visited[1] = true;
    
    while(q.size()){
        int cur = q.front(); q.pop();
        for(auto i : adj[cur]){
            if(!visited[i]){
                ans[i] = cur;
                q.push(i);
                visited[i] = true;
            }
        }
    }
}
int main()
{
	memset(visited,false,sizeof(visited));
	memset(ans,0,sizeof(ans));
	int nodes,edges;
	cin >> nodes >> edges;
	for(int i=0;i<edges;i++)
	{
		int u,v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	bfs();
	cout << "Yes\n";
	for(int i=2;i<=nodes;i++)
		cout << ans[i] << "\n";
}
 
*/

Measured memory_bytes: 10304
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  for(int i=1; i<=9; ++i) {
    if(n%i==0){
      int m = n/i;
      if(m>=1 && m<=9) {
      cout <<"Yes"<<endl;
      return 0;
    	}
    }
  }
  cout <<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main(){	
    string S;
    cin>>S;
    for(int i=0;i<S.size();i++){
    	if(S[i]==S[i+1]){
    		cout<<"Bad"<<endl;
    		return 0;
    	}
    }
    cout<<"Good"<<endl;
    return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;


int main(void){
    string s;
    cin >> s;
    string ans = "Yes";
    for (int i = 0; i < (int)s.size(); i++)
    {
        if(i % 2 == 0){
            if(s[i] == 'L'){
                ans = "No";
                break;
            }
        }
        else
        {
            if(s[i] == 'R'){
                ans = "No";
                break;
            }
        }
    }
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int num;
	scanf("%d",&num);
	num >= 30 ? printf("Yes\n") : printf("No\n");
//	if (num >= 30){
//		printf("Yes\n");
//	}
//	else{
//		printf("No\n");
//	}
	return 0;
}


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

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(NULL);
#define endl            "\n"
#define NUM             1000005
typedef long long ll;

const ll MOD = 1e9+7;

int main()
{
    FastRead

    ll n,ans=0;

    cin>>n;

    vector<ll>v(n);

    for(ll i=0;i<n;i++)
        cin>>v[i];


    for(ll i=0;i<60;i++)
    {
        ll zero=0,one=0;
        for(ll j=0;j<n;j++)
        {
            if((v[j]>>i)&1)
                one++;
            else
                zero++;
        }

        ll temp = zero*one;

        temp%=MOD;

        for(ll j=0;j<i;j++)
            temp = (temp*2)%MOD;

        ans+=temp;
        ans%=MOD;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 2560
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }


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

    // ifstream fin(".in");
    // ofstream fout(".in");


int k;
string s;
cin>>k>>s;
if(s.size()>k)
{
  cout<<s.substr(0,k)+string(3,'.');
}
else cout<<s;

    return 0;
  }


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<string,ll>q;
ll k;
char a[11];
string x;

int main()
{
    ll s=0;
    cin>>k;
    getchar();
    for(ll i=0; i<k; i++)
    {
        cin>>a;
        sort(a,a+10);
        x=a;
        if(!q.count(x))
            q[a]=1;
        else
            q[a]++;
    }
   map<string,ll>::iterator it;
   for(it=q.begin();it!=q.end();it++)
    if(it->second==1)
        s+=0;
    else
        s+=(it->second)*(it->second-1)/2;
    cout<<s;


}


Measured memory_bytes: 11136
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll MOD = 1000000007;
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; }

ll com[2020][2020];

int main() {
    com[0][0]=1;
    for(int i=1; i < 2020; ++i){
        for(int j=0; j <= i; ++j){
            com[i][j] += com[i-1][j];
            if(j>0)com[i][j] += com[i-1][j-1];
            com[i][j] %= MOD;
        }
    }
    int N,K;
    cin >> N >> K;
    for(int i=1; i <= K; i++){ // iグループに分ける
        ll cnt = com[K-1][i-1] % MOD; // 青玉をiグループに分ける分け方
        ll cnt_red = 0;
        if(i==1){
            cnt_red += N-K+1;
        }else{
            for(int x=i-1; x<= N-K; x++){ // x は区切るのに使う赤玉
                ll cnt_red_x = max(com[x-1][i-2], 1LL);
                int a = N-K-x;// 区切るのに関係ない赤玉a個
                if(a > 0) cnt_red_x *= (ll)(a+1);
                cnt_red += cnt_red_x;
                cnt_red %= MOD;
            }
        }
        cnt *= cnt_red;
        cout << cnt % MOD << endl;
    }
    return 0;
}


Measured memory_bytes: 30720
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = br.readLine();
		long[] charCount = new long[26];
		long n = input.length();
		
		for(int i = 0; i < input.length() ; i++){
			charCount[input.charAt(i)-'a']++;
		}
		
		long result = 0;
		
		result = n*(n-1)/2;
		for(int i = 0; i < charCount.length ; i++){
			if(charCount[i] >= 2){
				result -= charCount[i]*(charCount[i] - 1)/2;
			}
		}
		
		result++;
		System.out.println(result);
	}

}


Measured memory_bytes: 25988
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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



int a[1000000];
int b[1000000];
int M = 10;
int mod;
int main(){
  int N ,K ,Q;
  cin >> N >> K >>Q;
  rep(i,Q){
    cin >> a[i];
    a[i]--;
    b[a[i]]++;
  }
  rep(i,N){
    b[i] = b[i] - Q + K ;
    if(b[i] > 0 ) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 5120
#include <stdio.h>
#define INFTY 1000000001

int comp_count;

void merge(int S[], int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1], R[n2];
    for(int i=0; i<n1; i++){
        L[i] = S[left + i];
    }
    for(int i=0; i<n2; i++){
        R[i] = S[mid + i];
    }
    L[n1] = INFTY;
    R[n2] = INFTY;

    int i=0;
    int j=0;
    for(int k=left; k<right; k++){
        if(L[i] <= R[j]){
            S[k] = L[i];
            i++;
        }else{
            S[k] = R[j];
            j++;
        }
    }
    comp_count += right - left;
}

void mergeSort(int S[], int left, int right){
    if(left + 1 < right){
         int mid = (left + right) / 2;
        mergeSort(S, left, mid);
        mergeSort(S, mid, right);
        merge(S, left, mid, right);
    }
}

int main(void){
    int n;
    scanf("%d", &n);
    int S[n];
    for(int i=0; i<n; i++){
        scanf("%d", &S[i]);
    }
    comp_count = 0;

    mergeSort(S, 0, n);
    for(int i=0; i<n; i++){
        printf("%d", S[i]);
        if(i != n-1) printf(" ");
    }
    printf("\n");
    printf("%d\n", comp_count);
    return 0;
}


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

class Progaram
{
    static void Main(string[] args)
    {
        var cards = new List<char>[3];
        for (var i = 0; 3 > i; i++)
        {
            cards[i] = Console.ReadLine().ToCharArray().ToList();
        }
        var now = 'a';
        var s = 0;
        while (true)
        {
            if (cards[s].Count == 0)
            {
                Console.WriteLine((s == 0) ? 'A' : (s == 1) ? 'B' : 'C');
                break;
            }
            now = cards[s][0];
            cards[s].RemoveAt(0);
            s = (now == 'a') ? 0 : (now == 'b') ? 1 : 2;
        }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD=1000000007;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
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;
}
int main()
{
    ll N;
    cin >>N;

    vector<pair<ll,ll>> pairs;
    for ( ll i = 1; i * i <= N; ++ i ){
        if ( (N%i) == 0 ){
            pairs.push_back({i, N/i});
        }
    }
    #ifdef SOURCE_TEST
        for ( auto& p : pairs ){
            cout << p.first << ":" << p.second << endl;
        }
    #endif

    ll digit = 0;
    auto ansPair = pairs[pairs.size()-1];
    for ( ll i = ansPair.second; i > 0; i /= 10 )    digit++;

    cout << digit << endl;
    return 0;
}

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

int cost_a (int n) {
  int r = (n % 5) * 380;
  r += (n - (n%5)) * 38 * 8;
  return r;
}

int cost_b (int n) {
  int r = (n % 4) * 550;
  r += (n - (n % 4)) * 55 * 85 / 10;
  return r;
}

int cost_c (int n) {
  int r = (n%3)*850;
  r += (n-(n%3)) * 88 * 85 / 10;
  return r;
}

int main() {
  for (;;) {
    int c; cin >> c;
    if (c == 0) break;
    c /= 100;
    int mc = INF;
    rep (i, 1 + c/2) {
      rep (j, 1 + c/3) {
        rep (k, 1 + c/5) {
          if (2 * i + 3 * j + 5 * k == c) {
            int cc = cost_a(i) + cost_b(j) + cost_c(k);
            mc = min(mc, cc);
          }
        }
      }
    }
    cout << mc << endl;
  }
  return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

inline int topbit(unsigned long long x){
	return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
	return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
	return __builtin_parity(x);
}

int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}

int lcm(int a,int b){
	return a/gcd(a,b)*b;
}

signed main(){
	int a;cin>>a;
	cout<<lcm(360,a)/a<<endl;
	return 0;
}

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

int main(int, char**) {
        std::string input;
        std::cin >> input;
        if (input=="AAA" || input=="BBB") {
                std::cout << "No" << std::endl;
        } else {
                std::cout << "Yes" << std::endl;
        }
        return 0;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k, z, N;
string s, t, d, c;


// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> x >> y >> z ;
	if(y-x == z-y) cout<<"YES";
	else cout<<"NO";
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n;cin>>n;
    
    ll a[100];
    
    a[0]=1,a[1]=1;
    
    for(int i=2;i<=n;++i){
        a[i]=a[i-1] + a[i-2];
    }
    
    cout<<a[n]<<endl;
    
    return 0;
}


Measured memory_bytes: 3084
import sys
input = sys.stdin.readline

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

bs = 0
ans = 0

i = 0
while i < n:
    if a[i] <= k:
        k -= a[i]
        bs += 1
        ans = max(ans, bs)
    else:
        break
    i += 1
i -= 1

j = 0
while j < m:
    while i >= 0 and b[j] > k:
        k += a[i]
        bs -= 1
        i -= 1
    if b[j] <= k:
        k -= b[j]
        bs += 1
        ans = max(ans, bs)
    else:
        break
    j += 1

print(ans)


Measured memory_bytes: 108656
#include <bits/stdc++.h>
using namespace std;
int a[105][2];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,ans=0;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i][0];
	for(int i=0;i<n;i++)cin>>a[i][1];
	for(int i=1;i<n;i++)a[i][0]+=a[i-1][0];
	for(int i=n-2;i>=0;i--)a[i][1]+=a[i+1][1];
	for(int i=0;i<n;i++)ans=max(ans,a[i][0]+a[i][1]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
dp = [[0]*10 for _ in range(10)]

for i in range(1, N+1):
  if i%10==0: continue
  strI = str(i)
  f,l = strI[-1], strI[0]
  dp[int(f)][int(l)] += 1

res = 0
for i in range(1,10):
  for j in range(1,10):
    res += dp[i][j] * dp[j][i]

print(res)

Measured memory_bytes: 40620
#include<bits/stdc++.h>
#define db double
#define RE register
#define ll long long
#define P=1000000009
#define INF 1000000000
#define get(x) x=read()
#define pair<ll,int> PLI
#define pb(x) push_back(x)
#define pair<int,int> PII
#define ull unsigned long long
#define put(x) printf("%d\n",x)
#define getc(a) scanf("%s",a+1)
#define putl(x) printf("%lld\n",x)
#define rep(i,x,y) for(RE int i=x;i<=y;++i)
#define fep(i,x,y) for(RE int i=x;i>=y;--i)
#define go(x) for(int i=link[x],y=a[i].y;i;y=a[i=a[i].next].y)
using namespace std;
const int N=2010;
ll f[N][N],n;
struct wy{int id;ll v;}a[N]; 
inline int read()
{
	int x=0,ff=1;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') ff=-1;ch=getchar();}
	while(isdigit(ch)) {x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*ff;
}
inline bool cmp(wy x,wy y) {return x.v>y.v;}
int main()
{
	//freopen("1.in","r",stdin);
	get(n);
	rep(i,1,n) get(a[i].v),a[i].id=i;
	sort(a+1,a+n+1,cmp);
	memset(f,0xef,sizeof(0xef));f[0][0]=0;
	rep(i,1,n) rep(j,0,i) 
	{
		int k=i-j;
		if(j) f[j][k]=max(f[j][k],f[j-1][k]+a[i].v*(ll)abs(a[i].id-j));
		if(k) f[j][k]=max(f[j][k],f[j][k-1]+a[i].v*(ll)abs((n-k+1)-a[i].id));
	}
	ll ans=0;
	rep(i,0,n) ans=max(ans,f[i][n-i]);
	putl(ans);
	return 0;
}




Measured memory_bytes: 26428
#include <iostream>

using namespace std;
long long dp[110][4][5][4] = {},mod = 1000000007;
int main(){
	int i,j,k,l,n;
	cin >> n;
	dp[0][0][4][3] = 1; //TAGC AG AC GA AT ATG AGT AGG
	for(i=1;i<=n;i++){
		for(j=0;j<4;j++){
			for(k=0;k<5;k++){
				for(l=0;l<4;l++){
					if(j==1){
						(dp[i][0][3][3] += dp[i-1][j][k][l]) %= mod;
					}else if(k==0){
						(dp[i][0][4][1] += dp[i-1][j][k][l]) %= mod;
					}else{
						(dp[i][0][4][3] += dp[i-1][j][k][l]) %= mod;
					}
					if(j==2){
						(dp[i][1][2][3] += dp[i-1][j][k][l]) %= mod;
					}else{
						(dp[i][1][4][3] += dp[i-1][j][k][l]) %= mod;
					}
					if(k!=1){
						if(j==1){
							(dp[i][2][0][3] += dp[i-1][j][k][l]) %= mod;
						}else if(k==3){
							(dp[i][2][4][0] += dp[i-1][j][k][l]) %= mod;
						}else if(k==0){
							(dp[i][2][4][2] += dp[i-1][j][k][l]) %= mod;
						}else{
							(dp[i][2][4][3] += dp[i-1][j][k][l]) %= mod;
						}
					}
					if(k!=0 && k!=2 && l==3){
						if(j==1){
							(dp[i][3][1][3] += dp[i-1][j][k][l]) %= mod;
						}else{
							(dp[i][3][4][3] += dp[i-1][j][k][l]) %= mod;
						}
					}
				}
			}
		}
	}
	long long sum = 0;
	for(i=0;i<4;i++){
		for(j=0;j<5;j++){
			for(k=0;k<4;k++){
				(sum += dp[n][i][j][k]) %= mod;
			}
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<string> v;
  rep(i,N){
    string s;
    cin >> s;
    v.push_back(s);
  }

  rep(i,26){
    char c = (char)('a'+i);
    int cnt = 0;
    rep(j,v.size()){
      rep(k,v[j].size()){
        if(v[j][k] == c){
          cnt++;
          v[j][k] = '-';
          break;
        }
      }
    }
    if(cnt == v.size()){
      cout << c;
      i--;
    }
  }

  cout << endl;
  
  return 0;
}



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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) (x).begin(),(x).end()
#define Ceil(x, n) (((((x))+((n)-1))/n))
#define CeilN(x, n) (((((x))+((n)-1))/n)*n)

#define INF 2e7
#define INF_LL 1LL<<60
#define ll long long
typedef pair<ll, ll>    P;

int h, w;
string s[400];
int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};

bool isIn(int x, int y) {
    if(0 <= x && x < h && 0 <= y && y < w){
        return true;
    } else {
        return false;
    }
}

vector<bool> visit(400* 400);

ll black, white;
void dfs(int pos) {
    int x = pos / w;
    int y = pos % w;
    REP(i, 4) {
        int x_ = x + dx[i];
        int y_ = y + dy[i];
        if(isIn(x_, y_)) {
            if(s[x][y] != s[x_][y_]) {
                if(!visit[x_*w + y_]) {
                    visit[x_*w + y_] = true;
                    if(s[x_][y_] == '#') black++;
                    else white++;
                    dfs(x_*w + y_);
                }
            }
        }
    }
}




int main(){
    ll ans = 0;
    cin >> h >> w;

    REP(i, h) cin >> s[i];

    REP(i, h*w) {
        black = 0, white = 0;
        if(visit[i]) continue;
        if(s[i/w][i%w] == '#') black++;
        else white++;
        visit[i] = true;
        dfs(i);
        ans += black * white;
        //cout << black << " " << white << endl;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 18048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> a(n),b(n);
	rep(i,n) cin>>a[i];
	rep(i,n) cin>>b[i];
	vector<vector<int>> dp(1<<n,vector<int>(n,INF));
	rep(j,n) dp[0][j]=0;
	rep(S,1<<n){
		int cnt=__builtin_popcount(S);
		int ind=cnt;
		vector<int> now(n,-1);
		rep(j,n){
			if(S & 1<<j) continue;
			now[j]=ind++;
		}
		rep(j,n){
			if(dp[S][j]==INF) continue;
			rep(k,n){
				if(S & 1<<k) continue;
				int be=a[j],ne=a[k];
				if((cnt-1)%2!=j%2) be=b[j];
				if(cnt%2!=k%2) ne=b[k];
				if(S!=0){
					if(be<=ne) chmin(dp[S|(1<<k)][k],dp[S][j]+abs(now[k]-cnt));
				}else{
					chmin(dp[1<<k][k],abs(now[k]-cnt));
				}
			}
		}
	}
	int ans=INF;
	rep(j,n) chmin(ans,dp[(1<<n)-1][j]);
	if(ans!=INF) cout<<ans<<endl;
	else cout<<-1<<endl;
}

Measured memory_bytes: 26880
N = int(input())
t = [0] * N
x = [0] * N
y = [0] * N

for i in range(N):
    t[i],x[i],y[i] = map(int,input().split())
flag = True
for i in range(N):
    if not(t[i] >= x[i] + y[i] and (x[i] + y[i]) %2 == t[i] %2):
        flag = False
        
print('Yes') if flag else print('No')

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
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++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    ll N; cin >> N;
    vector<ll> a(N);
    ll sum = 0;
    unordered_map<ll, ll> m;
    rep(i, N){
        cin >> a[i];
        sum += a[i];
        m[a[i]]++;
    }
    ll Q; cin >> Q;
    vector<ll> res(Q);
    rep(i, Q){
        ll b, c; cin >> b >> c;
        sum += m[b]*(c-b);
        m[c] += m[b];
        m[b] = 0;
        res[i] = sum;
    }
    rep(i, Q){
        cout << res[i] << endl;
    }
}

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


Measured memory_bytes: 12760
#include <string>
#include <vector>
#include <map>
#include <iostream>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <climits>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;
int main(){
	long double d,d2,ans;
	cin>>d;
	d2=d*sqrt(2);
	ans=max(floor(d+1),d2);
	cout<<setprecision(16)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1292
#include <stdio.h>

int main(){
  int A,B,C,D;
  scanf("%d %d %d %d",&A,&B,&C,&D);
  int turn=1;
    while(A > 0 && C > 0){
      if(turn== 1){
      C=C-B;
      }else if(turn == -1){
      A=A-D;
    }
      turn=-turn;
    }
  if(A>0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1644
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


S = input()

print('ARC' if S == 'ABC' else 'ABC')

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

int main()
{
    string s;cin>>s;
    int c=0,a=0;
   for(int i=2;i<s.size()-1;i++){
    if(s[i]=='C'){c++;}
   }
   for(int i=1;i<s.size();i++){
    if(s[i]=='C'){c++;}
    else if(islower(s[i])){a++;}
   }
   if(c==2&&s[0]=='A'&&a==s.size()-2){cout<<"AC";}
   else{cout<<"WA";}
    return 0;
}


Measured memory_bytes: 256
loop do
  n = gets.to_i
  break if n == 0
  s = (1..Math.sqrt(n)).each_with_object([]) { |m, arr|
    n % m == 0 ? arr << m << n / m : arr
  }.uniq.reduce(:+) - n
  if n > s then puts "deficient number"
  elsif n < s then puts "abundant number"
  else puts "perfect number"
  end
end

Measured memory_bytes: 8652
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define ld long double
#define MOD 1000000007
#define nl cout << bl
#define rt ll Q[100005] = {0}
#define mp make_pair
#define test() \
    ull t;     \
    cin >> t;  \
    while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<ll>())
#define oa(a, n)               \
    for (ll i = 0; i < n; i++) \
        cout << a[i] << " ";
#define cn(a, n)               \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define ov(a, n)                    \
    for (ll i = n - 1; i >= 0; i--) \
        cout << a[i] << " ";        \
    nl
#define ovp(a, n)              \
    for (ll i = 0; i < n; i++) \
        cout << a[i].ff << " " << a[i].ss << bl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define present(c, x) ((c).find(x) != (c).end())
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
typedef pair<int, int> pii;
ll fast_exp(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res % MOD;
}
ll fib(ll n)
{
    if (n < 2)
        return n;
    ll a = 0, b = 1, pre;
    int i = 1;
    while (i < n)
    {
        pre = (a + b) % MOD;
        a = b;
        b = pre;
        i++;
    }
    return pre;
}
ll fac(ll n)
{
    if (n % 2 == 0)
        return 2;

    for (ll i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return i;
    }

    return n;
}
ll fact(ll n)
{
    if (n > 1)
        return n * fact(n - 1);
    else
        return 1;
}
bool sortbysec(const tuple<int, int, int> &a,
               const tuple<int, int, int> &b)
{
    return (get<1>(a) < get<1>(b));
}
int last_digit(int n)
{
    int ans = 0;
    while (n != 0)
    {
        ans = n % 10;
        n /= 10;
    }
    return ans;
}
int main()
{
    fastio();
    ll x, k, d;
    cin >> x >> k >> d;
    ll times = abs(x) / d;
    if (times <= k)
    {
        ll pos = abs(x) - times * d;
        k -= times;
        if (k % 2 == 0)
        {
            cout << pos;
        }
        else
        {
            cout << abs(min(pos - d, pos + d));
        }
    }
    else
    {
        cout << abs(x) - k * d;
    }
}


Measured memory_bytes: 3612
N = int(input())

alphabets = list('Zabcdefghijklmn')
s = ['a']
ss = []
for i in range(2, N + 1):
    subset = alphabets[1:i + 1]
    for j in range(len(s)):
        for k in subset:
            ss.append(s[j] + k)
            if s[j].find(k) == -1:
                break
    # print('s, ss', s, ss)
    s = ss
    ss = []
print(*s, sep='\n')
# for i in s:
#     print(i)


Measured memory_bytes: 14788
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;
ll mod9 = 1000000009;

signed main(){
    string n;
    cin>>n;
    bool f=false;
    rep(i,3){
        if(n[i]=='7') f=true;
    }
    if(f) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	string s,t;
	cin>>s>>t;
	int cnt=0;
	rep(i,s.size()){
		if(s[i]!=t[i]){
			cnt++;
		}
	}
	cout<<cnt;
	re 0;
}

Measured memory_bytes: 3892
/*
 * Author       : YangDavid
 * Created Time : 2019年10月05日 星期六 20时20分48秒
 */

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int maxn = 222;
int G[maxn][maxn], n;

int gao(int root) {
    int res = 0;
    vector<int> vis(maxn, 0);
    queue<int> q({root}); vis[root] = ++res;
    while(!q.empty()) {
        int f = q.front(); q.pop();
        for(int i = 1; i <= n; ++i) if(G[f][i]) {
            if(vis[i]) {
                if(vis[i] - vis[f] == 1 || vis[i] - vis[f] == -1) continue;
                return -1;
            } else {
                if(vis[f] == res) vis[i] = ++res;
                else vis[i] = vis[f] + 1;
                q.push(i);
            }
        }
    }
    return res;
}
int main() {
    scanf("%d\n", &n);
    rep(i, n) rep(j, n) scanf("%1d", &G[i][j]);
    int ans = -1;
    for(int i = 1; i <= n; ++i)
        ans = max(ans, gao(i));
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;
typedef long long ll;
int main() {
  ll N, Y;
  cin >> N >> Y;
  ll tmp = 10000 * N - Y;
  for(ll i = 0; 5000 * i <= tmp; i++) {
    for(ll j = 0; 9000 * j <= tmp; j++) {
      if(5000 * i + 9000 * j == tmp && N - i - j >= 0) {
	cout << N - i - j <<" "<<i<<" "<<j<<endl;
	return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
 
}


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

int main(){
	int n;cin >>n;
  vector<int> a(n);
  for(auto&& w:a)cin>>w;
  int ans=0;
  for(auto&& w:a)ans+=w;
  ans-=n;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <limits>
#include <utility>
#include <vector>
#include <string>
#include <stdlib.h>
#include <vector>
#include <algorithm>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
typedef long double ld;
int t=1000000000000000000;
signed main(){
unsigned long long n=0,an=1;
cin >>n;
vector<int> a(n);
REP(i,n){
    cin >> a[i];
  }
  SORT(a);
   if(a[0]==0){
    cout <<"0";
return 0;
  }
   REP(i,n){
    int b=an;
      an*=a[i];
   if(an/a[i]!=b){
    cout  <<"-1"; 
    return 0;
   }
  }
   if(a[n]>t){
    cout <<"-1";
return 0;
  }if(an>t){
    cout  <<"-1"; 
    return 0;
}
cout << an;

}

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

int main(){

  string r = "yuiophjklnm";
  string str;

  while(1){
    cin >> str;
    int flag = 1, ans = 0;
    if(str[0] == '#') break;
    char c = str[0];
    if(r.find(c) == string::npos) flag = 0;
    for(int i = 1; i < str.size(); i++){
      c = str[i];
      if(r.find(c) == string::npos){
        if(flag == 1){
          ans++;
          flag = 0;
        }
      }else{
        if(flag == 0){
          ans++;
          flag = 1;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3112
n=int(input())
lista=list(map(int,input().split()))
listb=list(map(int,input().split()))
listc=list(map(int,input().split()))
list=[]
for i in range(2,n+1):
  if lista[i-1]==lista[i-2]+1:
    list.append(lista[i-2])
vonus=0
for x in list:
  vonus+=listc[x-1]
print(sum(listb)+vonus)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
 
int main(){
  int n;
  cin >> n;
  vi d(n);
  rep(i,n) cin >> d.at(i);
  int ans =0;
  rep(i,n){
    rep(j,n){
      if(i == j){
        continue;
      }else{
        ans += d.at(i)*d.at(j);
      }
    }
  }

  cout << ans/2 << endl;

}

Measured memory_bytes: 256
import itertools

def is_same(A, B):
    for a, b in zip(A, B):
        if a != b:
            return False
    return True

def main():
    N = int(input())

    P = list(map(int, input().split()))
    Q = list(map(int, input().split()))

    p = 0
    q = 0
    D = list(itertools.permutations(range(1, N+1)))
    for i, d in enumerate(D):
        if is_same(d, P):
            p = i
        if is_same(d, Q):
            q = i
    print(abs(p-q))

if __name__ == '__main__':
    main()

Measured memory_bytes: 8052
#include<iostream>
using namespace std;
int main()
{
  int n,i,days;
  cin>>days>>n;
  int arr[n];
  for(i=0;i<n;i++)
  {
    cin>>arr[i];
    days-=arr[i];
  }
  if(days>=0)
    cout<<days;
  else
    cout<<"-1";
  return 0;
}

Measured memory_bytes: 3676
p = 10**9+7
N = int(input())
T = list(map(int,input().split()))
A = list(map(int,input().split()))
H = [0 for _ in range(N)]
flag = 0
if T[N-1]!=A[0]:
    flag = 1
hmax = A[0]
if flag==0:
    indmaxT=0
    H[0] = T[0]
    for i in range(1,N):
        if T[i]>T[i-1]:
            H[i] = T[i]
            if H[i]==hmax:
                indmaxT = i
                break
    indmaxA = N-1
    H[N-1] = A[N-1]
    for i in range(N-2,-1,-1):
        if A[i]>A[i+1]:
            H[i]=A[i]
            if H[i]==hmax:
                indmaxA = i
                break
    if indmaxA<indmaxT:
        flag = 1
if flag==1:
    print(0)
else:
    cnt = 1
    cur = 0
    for i in range(1,indmaxT):
        if H[i]==0:
            cnt = (cnt*H[cur])%p
        elif H[i]>0:
            cur = i
    cur = N-1
    for i in range(N-2,indmaxA,-1):
        if H[i]==0:
            cnt = (cnt*H[cur])%p
        elif H[i]>0:
            cur = i
    for i in range(indmaxT+1,indmaxA):
        cnt = (cnt*hmax)%p
    print(cnt)

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

int main() {

	int K,i;
	int odd_c=0,even_c=0;
	cin >> K;

	for (i = 1; i <= K; i++) {
		if (i % 2 == 0) {
			even_c++;
		}
		else {
			odd_c++;
		}
	}

	cout << odd_c * even_c;

	return 0;
}

Measured memory_bytes: 504
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var n, m int
	fmt.Fscan(read, &n, &m)

	a := make([]int, n)
	sum := 0
	for i := range a {
		fmt.Fscan(read, &a[i])
		sum += a[i]
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))

	if a[m-1]*4*m < sum {
		fmt.Fprintln(write, "No")
	} else {
		fmt.Fprintln(write, "Yes")
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <iomanip> 
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;


void slimes()
{
  int n;
  string s;
  cin >> n >> s;

  int rest = 0;
  for (int i = 0; i < n; ++i)
  {
    if (s[i] != s[i + 1]) ++rest;
  }
  cout << rest << '\n';
}


void walk_on_multiplication_table()
{
  long long int n;
  cin >> n;

  long long int ans = n;
  for (int i = 1; i <= sqrt(n); ++i)
  {
    if (n % i == 0 && ans > (i - 1) + (n / i - 1))
    {
      ans = (i - 1) + (n / i - 1);
    }
  }

  cout << ans << '\n';
}


void average_length()
{
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i];

  double sum = 0;
  for (int i = 0; i < n; ++i)
  {
    for (int j = 0; j < n; ++j)
    {
      if (i == j) continue;
      sum += sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
    }
  }

  cout << setprecision(14) << sum / n << '\n';
}


int calc_digits(long long int n)
{
  int digits = 0;
  while (n >= 1)
  {
    n /= 10;
    ++digits;
  }

  return digits;
}


void buy_an_interger()
{
  long long int a, b;
  long long int x;
  cin >> a >> b >> x;

  long long int left = 0, right = 1000000001;
  long long int mid;
  while (right - left > 1)
  {
    mid = left + (right - left) / 2;
    if (a * mid + b * calc_digits(mid) <= x) left = mid;
    else right = mid;
  }

  cout << left << '\n';
}


void honest_or_unkind2()
{
  //後回し
}


long long int gcd(int a, int b)
{
  if (a < b) 
  {
    int tmp;
    tmp = a;
    a   = b;
    b   = tmp;
  }

  int r = a % b;
  while (r != 0)
  {
    a = b;
    b = r;
    r = a % b;
  }

  return b;
}


long long int lcm(long long int a, long long int b)
{
  return a * b / gcd(a, b);
}


void snack()
{
  long long int a, b;
  cin >> a >> b;

  cout << lcm(a, b) << "\n";
}


bool is_prime(int n)
{
  if (n <= 1) return false;
  if (n == 2) return true;

  if (n % 2 == 0)return false;

  for (int i = 3; i * i <= n; i += 2)
  {
    if (n % i == 0) return false;
  }

  return true;
}


void next_prime()
{
  int x;
  cin >> x;

  int prime = x;
  while (!is_prime(prime)) ++prime;

  cout << prime << "\n";
}


int factorial(int n)
{
  int fact = 1;
  for (int i = n; i > 0; --i) fact *= i;
  return fact;
}


int calc_order(int n, vector<int> x)
{
  int cnt = 0;
  for (int i = 0; i < n; ++i)
  {
    cnt += (x[i] - 1) * factorial(n - 1 - i);
    for (int j = i + 1; j < n; ++j) {
      if (x[j] > x[i]) --x[j];
    }
  }
  return cnt;
}


void count_order()
{
  int n;
  cin >> n;

  vector<int> p(n);
  vector<int> q(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  for (int i = 0; i < n; i++) cin >> q[i];

  int p_cnt = 0, q_cnt = 0;
  p_cnt = calc_order(n, p);
  q_cnt = calc_order(n, q);

  cout << abs(p_cnt - q_cnt);
}




int main()
{
  slimes();
  //walk_on_multiplication_table();
  //average_length();
  //buy_an_interger();
  //cout << calc_digits(1000000000) << '\n';
  //honest_or_unkind2();
  //snack();
  //next_prime();
  //count_order();
}


Measured memory_bytes: 512