akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

    using namespace std;

    #define int long long
    #define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
    #define pb push_back
    #define ff first
    #define ss second
    #define vi vector<int>
    #define all(x) (x).begin(), (x).end()
//    #define for(i,a,b)  for(int i=a;i<b;++i)
//    #define rev(i,a) for(int i=a-1;i>=0;i--)
    #define fill(a,b) memset(a, b, sizeof(a))
    #define lld long double
    #define mii map<int, int>
    #define mci map<char, int>
    #define msi map<string, int>
    #define pii pair<int, int>
    #define mod 1000000007 //998244353
    #define maxn        1000005

    //clear adj and visited vector declared globally after each test case
    //check for long long overflow
    //while adding and subs check if mod becomes -ve
    //while using an integer directly in a builtin function add ll
    //Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
    //Dont keep array name as size or any other key word


    using namespace std;
    int power(int a, int b, int p)
        {
            if(a==0)
            return 0;
            int res=1;
            a%=p;
            while(b>0)
            {
                if(b&1)
                res=(res*a)%p;
                b>>=1;
                a=(a*a)%p;
            }
            return res;
        }


    int lcm(int a, int b)
    {
        int g=__gcd(a, b);
        return a/g*b;
    }

int solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	if (count(a.begin(), a.end(), a[0]) == n) {
		cout << 1 << endl;
		for (int i = 0; i < n; ++i) {
			cout << 1 << " ";
		}
		cout << endl;
		return 0;
	}

	if (n % 2 == 0) {
		cout << 2 << endl;
		for (int i = 0; i < n; ++i) {
			cout << i % 2 + 1 << " ";
		}
		cout << endl;
		return 0;
	}

	for (int i = 0; i < n; ++i) {
		if (a[i] == a[(i + 1) % n]) {
			vector<int> ans(n);
			for (int j = 0, pos = i + 1; pos < n; ++pos, j ^= 1) {
				ans[pos] = j + 1;
			}
			for (int j = 0, pos = i; pos >= 0; --pos, j ^= 1) {
				ans[pos] = j + 1;
			}
			cout << 2 << endl;
			for (int pos = 0; pos < n; ++pos) {
				cout << ans[pos] << " ";
			}
			cout << endl;
			return 0;
		}
	}

	cout << 3 << endl;
	for (int i = 0; i < n - 1; ++i) {
		cout << i % 2 + 1 << " ";
	}
	cout << 3 << endl;
    return 0;
}

int32_t main() {

int q=1;
//cin >> q;
for (int qq = 0; qq < q; qq++) {
    string a,b;
    cin >> a >> b;
    int c=0;
    for(int i=0;i<max(a.length(),b.length());i++)
    {
        if(a[i]!=b[i])
            c++;
    }
    cout << c << endl;
}

	return 0;
}


Measured memory_bytes: 3920
import sys

if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    m = 10 ** 9 + 7
    s = sum(a) % m
    ans = 0
    running = 0
    for i in range(n):
        running += a[i]
        ans += (a[i] * (s - running))
        ans %= m
    ans %= m
    print(ans)
    return



n = RN()
a = RA()
solve()


Measured memory_bytes: 96080
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1e9+7;
ll const maxn=1e3+5;
ll const inf=1e18;
ll add(ll a,ll b){
    return ((a%mod)+(b%mod))%mod;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}
ll powm(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}
bool prime(ll x){
    if(x<2)return false;
    for(int i=2;i<=sqrt(x);i++){
        if(x%i==0)return false;
    }
    return true;
}
int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    ll n=s.size();
    ll m=t.size();
    ll dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i-1]==t[j-1]){
                dp[i][j]=1+dp[i-1][j-1];
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    string x="";
    ll a=n,b=m;
    while(a>0 and b>0){
        if(s[a-1]==t[b-1]){x+=s[a-1];a--;b--;}
        else if(dp[a-1][b]>dp[a][b-1])a--;
        else b--;
    }
    reverse(x.begin(),x.end());
    cout<<x;
    return 0;
}


Measured memory_bytes: 70656
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];

  map<int, int> mp;
  vi h;
  rep(i, n){
    mp[a[i]]++;
    if (mp[a[i]] > 1 and mp[a[i]]%2 == 0){
      h.push_back(a[i]);
    }
  }
  sort(h.rbegin(), h.rend());
  if (h.size() < 2){
    cout << 0 << endl;
    return 0;
  }

  cout << (ll) h[0] * h[1] << endl;
  return 0;
}

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

#define int long long

int N, M, K;
int dp[50][100];

int dfs(int n, int sum) {
  if ( n == N ) return max(1LL, sum-K);
  if ( dp[n][sum] ) return dp[n][sum];

  int ret = 0;
  for ( int i = 1; i <= M; i++ ) ret += dfs(n+1, sum+i);

  return dp[n][sum] = ret;  
}
	
signed main() {
  cout << fixed << setprecision(10);
  
  while ( cin >> N >> M >> K, N ) {
    fill_n(*dp, 50*100, 0);    
    double ans = 0;
    ans = (double)dfs(0, 0);
    for ( int i = 0; i < N; i++ ) {
      ans /= M;      
    }

    cout << ans << endl;
  }

  return 0;
}



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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> p(M);
    vector<string> S(M);
    rep(i, M){
			int P;
			string s;
			cin >> P >> s;
			P--;
			p[i] = P;
			S[i] = s;
		}

    vector<bool> acs(N, false);
    vector<int> wans(N, 0);

    rep(i, M) {
        if (!acs[p[i]] && S[i] == "WA") {
            wans[p[i]]++;
        } else if (!acs[p[i]] && S[i] == "AC") {
            acs[p[i]] = true;
        }
    }

    int a = 0;
    int w = 0;
    rep(i, N) {
        if (acs[i]) {
            a++;
            w += wans[i];
        }
    }
    cout << a << " " << w << endl;
}

Measured memory_bytes: 6528
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include <math.h>
using namespace std;

int main()
{
    int M, D, m, d;
    cin >> M >> D >> m >> d;
    if(M == m) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

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

int main() {
	int n, m;
	int sn[100] = { 0 };
	int	 sm[100] = { 0 };
	int sum_n, sum_m, ofs;

	while (true) {
		int outn = 1000;
		int outm = 1000;
		int flag = 0;
		sum_n = 0;
		sum_m = 0;
		cin >> n >> m;
		if (n == 0 || m == 0) break;

		for (int i = 0; i < n; i++) {
			cin >> sn[i], sum_n += sn[i];
		}
		for (int i = 0; i < m; i++) {
			cin >> sm[i], sum_m += sm[i];
		}
		ofs = sum_n - sum_m;
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				//if (ofs == (sn[i] - sm[j]) * 2) cout << sn[i] << " " << sm[j] << endl, flag = -1;
				if (ofs == (sn[i] - sm[j]) * 2) {
					if (outn + outm > sn[i] + sm[j]) outn = sn[i], outm = sm[j], flag = -1;
				}
			}
		}
		if (flag == -1) cout << outn << " " << outm << endl;
		else cout << -1 << endl;
	}
	return 0;
}

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

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

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

int main() {
	int x, y;
	scanf("%d %d", &x, &y);
	if (x % y == 0) puts("-1");
	else printf("%d\n", x);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using hset = unordered_set<T>;
template<class Key, class T> using hmap = unordered_map<Key, T>;

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

int main() {
    int N, A, B, C, X, Y, f;
    while (cin >> N >> A >> B >> C >> X) {
        f = 0;
        if (N == 0) break;
        for (int i = 0; i < N; i++) {
            if (i > 0) {
                f++;
                X = (A*X + B) % C;
            }

            cin >> Y;
            for (; f <= 10000; f++) {
                if (Y == X) break;
                else X = (A*X + B) % C;
            }
        }
        cout << (f > 10000 ? -1 : f) << endl;
    }

    return 0;
}

Measured memory_bytes: 3040
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;

int main() {
	double a, b, C;
	cin >> a >> b >> C;
	cout << fixed << 0.5 * a * b * sin(C * acos(-1.0) / 180.0) << endl << a + b + sqrt(a * a + b * b - 2.0 * a * b * cos(C * acos(-1.0) / 180.0)) << endl << b * sin(C * acos(-1.0) / 180.0) << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}
int main()
{
  //flash;
	ll a;
	cin>>a;
	cout<<pow(a,3)+pow(a,2)+a;
  return 0;
}
//code the AC sol !
// BS/queue/map

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

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> a(n+1);
    rep(i, 0, m){
        int j;
        cin >> j;
        a[j]++;
    }
    int sum_1 = 0, sum_2 = 0;
    rep(i, 0, x){
        if(a[i]) sum_1++;
    }
    rep(i, x, n){
        if(a[i]) sum_2++;
    }
    cout << min(sum_1, sum_2) << endl;
    return 0;
    
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct Node{
  int key;
  struct Node *right,*left,*parent;
};

typedef struct Node Node;
Node *root,*NIL;

Node *find(Node *x,int k){
  while(x!=NIL && k!=x->key){
    if(k < x->key) x=x->left;
    else x=x->right;
  }
  return x;
}

Node *treeMinimum(Node *x){
  while(x->left!=NIL) x=x->left;
  return x;
}

Node *treeSuccessor(Node *x){
  if(x->right!=NIL){return treeMinimum(x->right);}
  Node *y=x->parent;
  while(y!=NIL && x==y->right ){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node *x){
  Node *y,*z;
  if(x->left==NIL || x->right==NIL){y=x;}
  else {y=treeSuccessor(x);}
  if(y->left!=NIL) {z=y->left;}
  else {z=y->right;}

  if(z!=NIL){z->parent=y->parent;}
  if(y->parent==NIL){root=z;}
  else {
    if(y==y->parent->left){y->parent->left=z;}
    else{y->parent->right=z;}
  }

  if(y!=x) x->key=y->key;
  free(y);
}

void insert(int k){
  Node *y=NIL;
  Node *x=root;
  Node *z;
  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL) root=z;
  else {
    if(z->key < y->key) y->left=z;
    else y->right=z;
  }
}

void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int i,n,x;
  char ch[100];
  char *pt="print";
  char *it="insert";
  char *dt="delete";
  Node *t;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",ch);
    if(ch[0]=='f'){
      scanf("%d",&x);
      t=find(root,x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(ch,it)==0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(ch,pt)==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(strcmp(ch,dt)==0){
      scanf("%d",&x);
      treeDelete(find(root,x));
    }
  }

  return 0;
}


Measured memory_bytes: 20452
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, int num=0){
  if(num == 0) num = (int)v.size();
  if(is_reverse) for(int i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<" ";}
  else for(int i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<" ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, int num=0){
  if(num == 0) num = (int)v.size();
  for(int i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

using P = pair<double, double>;

const double ROOT3_half = 0.8660254038;//√3/2 sin(60)に相当
void triangle(vector<P> &d, P p0, P p4){
  
}
void Koch_Curve(int n, P p0, P p4){
  if(n == 0) return;
  P p1, p2, p3;
  p1.first  = (2*p0.first  + 1*p4.first)  / (1+2.0);//1:2に内分
  p1.second = (2*p0.second + 1*p4.second) / (1+2.0);//1:2に内分
  
  p3.first  = (1*p0.first  + 2*p4.first)  / (2+1.0);//2:1に内分
  p3.second = (1*p0.second + 2*p4.second) / (2+1.0);//2:1に内分

  //  p1の座標 + p1を中心にp3を60度回転 
  p2.first  = p1.first    +   (p3.first-p1.first) *  (1/2.0)       -   (p3.second-p1.second) * ROOT3_half;
  p2.second = p1.second   +   (p3.first-p1.first) * ROOT3_half   +   (p3.second-p1.second) *  (1/2.0);

  

  Koch_Curve(n-1, p0, p1);
  cout << p1.first << " " << p1.second << endl;
  Koch_Curve(n-1, p1, p2);
  cout << p2.first << " " << p2.second << endl;
  Koch_Curve(n-1, p2, p3);
  cout << p3.first << " " << p3.second << endl;
  Koch_Curve(n-1, p3, p4);
}

int main(){
  int n;
  cin >> n;
  // cout << fixed;//小数点を確実に8桁で表示するためのもの
  // cout << setprecision(8); 
  P p0, p4;
  cout << p0.first << " " << p0.second << endl;
  p0.first = 0;   p0.second = 0;
  p4.first = 100; p4.second = 0;
  Koch_Curve(n, p0, p4);
  cout << p4.first << " " << p4.second << endl;
  return 0;
}




Measured memory_bytes: 3276
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

#define all(A) A.begin(), A.end()

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

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

ll id(char c) {
	return c - 'a';
}

template<class t, class u>
ostream& operator<<(ostream& os, const pair<t, u>& p) {
	return os << "{" << p.first << "," << p.second << "}";
}

template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
	os << "{";
	for (auto e : v)os << e << ",";
	return os << "}";
}

int main() {
	ll N, K;
	cin >> N >> K;

	multiset<ll> m;

	vi P(N);
	rep(i, N) {
		cin >> P[i];
	}

	rep(i, K) {
		m.insert(P[i]);
	}


	ll len = 1;
	vector<bool> conn(N - K + 1);
	vector<bool> sim(N - K + 1);

	repa(i, 1, N) {
		if (P[i - 1] < P[i]) {
			len++;
			if (len >= K) {
				conn[i - K + 1] = true;
			}
		}
		else {
			len = 1;
		}
	}

	for (ll i = 0; i < N - K; i++) {
		auto minitr = m.begin();
		auto maxitr = prev(m.end());
		ll min = *minitr;
		ll max = *maxitr;

		if (min == P[i] && max < P[i + K]) {
			sim[i + 1] = true;
		}

		m.erase(P[i]);
		m.insert(P[i + K]);
	}

	ll count = 0;
	bool flag = false;
	rep(i, N - K + 1) {
		if (sim[i] == false) {
			if (conn[i]) {
				flag = true;
			}
			else {
				count++;
			}
		}
	}

	if (flag) {
		count++;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define INF 1000000000

int main() {
    int N, M;
    cin >> N >> M;
    int s = 1 << N;
    int dp[s];
    REP(i, s) dp[i] = INF;
    dp[0] = 0;

    REP(i, M) {
        int a, b, c = 0;
        cin >> a >> b;
        REP(i, b) {
            int tmp;
            cin >> tmp;
            c |= 1 << (tmp - 1);
        }
        RREP(j, s) {
            int index = j | c;
            dp[index] = min(dp[index], dp[j] + a);
        }
    }
    if (dp[s - 1] == INF) cout << -1 << endl;
    else cout << dp[s - 1] << endl;
    return 0;
}

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

const long MOD = 1'000'000'007;

int main() {
	long n; string s;
	cin >> n >> s;
	long r, g, b;
	r = g = b = 0;
	for (long i = 0; i < n; i++) {
		switch (s[i]) {
			case 'R':
				r++;
				break;
			case 'G':
				g++;
				break;
			case 'B':
				b++;
				break;
		}
	}
	long ans = r * g * b;
	for (long i = 0; i < n; i++) {
		for (long j = i+1; j < n; j++) {
			long k = j + (j - i);
			if (k < n) {
				if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) {
					ans--;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3160
package main

import (
	"fmt"
)

func main() {
	var n, l int
	fmt.Scanf("%d %d", &n, &l)
	originCount := ((1 + l - 1) + (n + l - 1)) * n / 2
	min := 1 + l - 1
	max := n + l - 1
	if max >= 0 && min <= 0 {
		fmt.Println(originCount)
	} else if max < 0 {
		fmt.Println(originCount - max)
	} else if min > 0 {
		fmt.Println(originCount - min)
	}
}


Measured memory_bytes: 512
n=int(input())
a=list(map(int,input().split()))
d={}
x=[0,0]
for i in range(n):
    try:
        d[a[i]]+=1
        if d[a[i]]==2 or d[a[i]]==4:
            x.append(a[i])
    except:
        d[a[i]]=1


x.sort()
x.reverse()
print(x[0]*x[1])


Measured memory_bytes: 18216
//package atcoder.beginner144;

import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
//        try {
//            FastScanner in = new FastScanner(new FileInputStream("src/input.in"));
//            PrintWriter out = new PrintWriter(new FileOutputStream("src/output.out"));
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        boolean can = false;
        if(n > 81) {
            can = false;
        }
        for(int i = 1; i <= 9; i++) {
            if(n % i == 0 && n / i <= 9) {
                can = true;
                break;
            }
        }
        out.println(can ? "Yes" : "No");
        out.close();

//        }
//        catch (IOException e) {
//            e.printStackTrace();
//        }
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}




Measured memory_bytes: 21204
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>

#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v){
    if(!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}
//---------


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //CLion Standard Input
    //--------------------------------------------------------------------------
//    ifstream in("/Users/ryo/Dropbox/competition/CompetitiveProgramming/in.txt");
//    cin.rdbuf(in.rdbuf());
    //--------------------------------------------------------------------------

    ll x;
    cin >> x;

    ll ans = x / 11 * 2;
    ll rem = x % 11;
    if(rem != 0 && rem <= 6) ans++;
    else if(rem !=0) ans += 2;
    cout << ans << endl;


}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define INF 100000000000000000

int main(){
  long long n,x;
  cin >> n >> x;
  long long a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  long long ans = 0;
  sort(a,a+n);
  for(int i=0;i<n-1;i++){
    if(x < a[i]) break;
    x -= a[i];
    ans += 1;
  }
  if(x == a[n-1]) ans += 1;
  cout << ans << endl;

  return 0;
}


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

int x[8] = { -1,-1,0,1,1,1,0,-1 };
int y[8] = { 0,-1,-1,-1,0,1,1,1 };

vector<string> Henkan(vector<string> s, int H, int W) {
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int cnt = 0;
			if (s[i][j] == '.') {
				for (int k = 0; k < 8; k++) {
					int xx = j + x[k], yy = i + y[k];
					if (xx < 0 || W <= xx || yy < 0 || H <= yy) continue;
					if (s[yy][xx] == '#') cnt++;
				}
				s[i][j] = cnt + '0';	// int -> char
			}
		}
	}
	return s;
}

int main(void) {
	int H, W;
	cin >> H >> W;
	vector<string> s(H);
	for (int i = 0; i < H; i++) cin >> s[i];

	s = Henkan(s, H, W);
	
	for (int i = 0; i < H; i++) {
		cout << s[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10000)
INF = float('inf')


class WeightedUnionFind:
    def __init__(self, size):
        """
        :param collections.Iterable nodes:
        """
        self._parents = [i for i in range(size)]
        self._ranks = [0 for _ in range(size)]
        self._sizes = [1 for _ in range(size)]
        # 直近の親からの重み。root なら 0
        self._weights = [0 for _ in range(size)]

    def unite(self, x, y, w):
        """
        x が属する木と y が属する木を併合
        :param x:
        :param y:
        :param w: x と y の重みの差; (重み y) - (重み x)
        :return:
        """
        rx = self.find(x)
        ry = self.find(y)
        if rx == ry:
            return

        # rank が小さい方が下
        if self._ranks[rx] > self._ranks[ry]:
            # x が root
            self._parents[ry] = rx
            self._sizes[rx] += self._sizes[ry]
            # root 間の重みに変換
            self._weights[ry] = w + self._weights[x] - self._weights[y]
        else:
            # y が root
            self._parents[rx] = ry
            self._sizes[ry] += self._sizes[rx]
            # root 間の重みに変換
            self._weights[rx] = -w + self._weights[y] - self._weights[x]
            if self._ranks[rx] == self._ranks[ry]:
                self._ranks[ry] += 1

    def find(self, x):
        """
        x が属する木の root
        :param x:
        :return:
        """
        if self._parents[x] == x:
            return x
        root = self.find(self._parents[x])
        self._weights[x] += self._weights[self._parents[x]]
        self._parents[x] = root
        return root

    def size(self, x):
        """
        x が属する木のノード数
        :param x:
        :return:
        """
        return self._sizes[self.find(x)]

    def weight(self, x):
        """
        :param x:
        :return:
        """
        # 経路圧縮
        self.find(x)
        return self._weights[x]

    def diff(self, x, y):
        """
        (y の重み) - (x の重み)
        :param x:
        :param y:
        :return:
        """
        if self.find(x) == self.find(y):
            return self._weights[y] - self._weights[x]
        return float('inf')


N, M = list(map(int, input().split()))

uf = WeightedUnionFind(N + 1)

ok = True
for _ in range(M):
    l, r, d = list(map(int, input().split()))
    if uf.find(l) == uf.find(r) and uf.diff(l, r) != d:
        ok = False
        break
    uf.unite(l, r, d)

if ok:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 10800
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >> p.second;
	return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
	rep(i, v.size()) { is >> v[i]; }
	return is;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
// union by size + path having
class UnionFind {
public:
	vector<long long> par;  // 各元の親を表す配列
	vector<long long> siz;  // 素集合のサイズを表す配列(1 で初期化)

	// Constructor
	UnionFind(long long sz_) : par(sz_), siz(sz_, 1LL) {
		for (long long i = 0; i < sz_; ++i) par[i] = i;  // 初期では親は自分自身
	}
	void init(long long sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (long long i = 0; i < sz_; ++i) par[i] = i;  // 初期では親は自分自身
	}
	// Member Function

	// Find
	long long root(long long x) {  // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]];  // x の親の親を x の親とする
		}
		return x;
	}
	// 結合(Unite, Merge)
	bool merge(long long x, long long y) {
		x = root(x);
		y = root(y);
		if (x == y) {
			return false;
		}
		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) {
			swap(x, y);
		}
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}

	// 連結判定(つながっているときはture,つながっていなければfalse)
	bool issame(long long x, long long y) { return root(x) == root(y); }

	// 素集合のサイズ
	long long size(long long x) { return siz[root(x)]; }
};
int main() {
	int n, m;
	cin >> n >> m;
	int a, b;
	int ans = 1;
	UnionFind dis(n);
	rep(i, m) {
		cin >> a >> b;
		dis.merge(a - 1, b - 1);
		chmax(ans, (int)dis.size(a - 1));
	}
	cout << ans << endl;
}

Measured memory_bytes: 6420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 100000;

int n, m;

bool pos = true;
ll loc[N];
vector<pair<int, pair<int, int>>> conn[N];
bitset<N> vis;


void dfs(ll v, ll x) {
    vis[v] = true;
    loc[v] = x;
    for (auto u : conn[v]) {
        ll to = u.first, dist = u.second.first, dir = u.second.second;
        if (vis[to] && x + dist * dir != loc[to]) {
            pos = false;
            return;
        } else if (!vis[to]) {
            dfs(to, x + dist * dir);
        }
    }
}

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        ll l, r, d;
        cin >> l >> r >> d;
        --l; --r;
        conn[l].push_back({r, {d, 1}});
        conn[r].push_back({l, {d, -1}});
    }

    vis.reset();
    for (int i = 0; i < n; ++i) {
        if (!vis[i]) dfs(i, 0);
    }
    
    pos ? cout << "Yes" : cout << "No";
}
        





Measured memory_bytes: 18396
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    string S;
    cin >> S;
    rep(i, S.size()) {
        S[i] = S[i] + N;
        if (S[i] > 0x5a) {
            S[i] = (S[i] - 0x5a) + 0x40;
        }
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

typedef pair<int,int> PII;
const int M=1e5+5;
vector<PII> g[M];
int ans[M];
int mc;
void dfs(int u,int fa,int fac)
{
	int c=1;
	for(auto p:g[u])
	{
		int v=p.first,id=p.second;
		if(v==fa) continue;
		if(c==fac) c++;
		ans[id]=c;
		dfs(v,u,c);
		mc=max(mc,c++);
	}
}

int main()
{
	int n;
	scanf("%d",&n);
	int a,b;
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&a,&b);
		g[a].emplace_back(b,i);
		g[b].emplace_back(a,i);
	}
	mc=0;
	dfs(1,0,0);
	printf("%d\n",mc);
	for(int i=1;i<n;i++)
		printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 9344
#include <iostream>
#include <cstdio>
#define ll long long
using namespace std;
ll n,x;

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

int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("B.inp","r",stdin);
	//freopen("B.out","w",stdout);
	cin >> n >> x;
	cout << 3*(n-gcd(n,x));
}

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

using namespace std;

int main() {
    int n, x, l = 0, ans = 1;
    cin >> n >> x;
    rep(i, n) {
        int tmp;
        cin >> tmp;
        l += tmp;
        if (l <= x)
            ans++;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

int main(){
    int N,X,T; cin >> N >> X >> T;

    cout << (N+(X-1))/X*T << endl;
}

Measured memory_bytes: 3592
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
price = 0

for i in sorted(AB):
    if M > i[1]:
        price += i[0]*i[1]
        M -= i[1]
    elif M == i[1]:
        price += i[0]*i[1]
        break
    else:
        price += i[0]*M
        break

print(price)

Measured memory_bytes: 28652
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    int n, q;
    cin >> n >> q;

    vector<int> v(n);  // v[i] : クエリにおいてiが現れた回数の偶奇
    rep(i, q) {
        int a, b;
        cin >> a >> b;
        a--;  b--;
        v[a]++;  v[b]++;
        v[a] %= 2;  v[b] %= 2;
    }

    rep(i, n) {
        if(v[i] == 1) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 640
import sys
readline = sys.stdin.readline

class BIT:
    #1-indexed
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
        self.p = 2**(n.bit_length() - 1)
        self.dep = n.bit_length()
    def get(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
    
    def bl(self, v):
        if v <= 0:
            return -1
        s = 0
        k = self.p
        for _ in range(self.dep):
            if s + k <= self.size and self.tree[s+k] < v:
                s += k
                v -= self.tree[s+k]
            k //= 2
        return s + 1

N, K = map(int, readline().split())
MOD = 998244353
P = list(map(int, readline().split()))

r = (K-1)*pow(K, MOD-2, MOD)

L = [pow(r, max(0, i-K+1), MOD) for i in range(N)]
Linv = [pow(l, MOD-2, MOD) for l in L]
T1 = BIT(N)
T2 = BIT(N)

ans = 0
asum = 0
ti = (MOD+1)//2
for i in range(N):
    ans += i - T2.get(P[i])
    g1 = T1.get(P[i])
    ans = (ans + ti*L[i]*(2*g1-asum))%MOD
    T2.add(P[i], 1)
    T1.add(P[i], Linv[i])
    asum = (asum + Linv[i]) % MOD
print(ans)

Measured memory_bytes: 111224
#include <bits/stdc++.h>
using namespace std;
template < typename T > std::string to_string( const T& n ){
	std::ostringstream stm ;
	stm << n ;
	return stm.str() ;
}


int main(void){
	char s;
	while(s!=10){
		scanf("%c",&s);
		if(65 <= s && s<= 90)printf("%c",s+32);
		else if(97 <= s && s<= 122)printf("%c",s-32);
		else printf("%c",s);
	}
	return 0;
}


Measured memory_bytes: 3060
let rec judge lst = match lst with
    [] -> (0, 0, 0, 0)
  | first :: rest ->
      let judge_rest = judge rest in
      match judge_rest with
        (ac, wa, tle, re) -> if first = "AC" then (ac + 1, wa, tle, re)
                             else if first = "WA" then (ac, wa + 1, tle, re)
                             else if first = "TLE" then (ac, wa, tle + 1, re)
                             else (ac, wa, tle, re + 1) (* AC,WA,TLE,RE *)
                             
let rec result_list n =
  if n = 0 then []
  else read_line () :: result_list (n - 1)

let ans =  judge (result_list (read_int ()))

let () = match ans with
  (ac, wa, tle, re) ->
    (print_string @@ "AC x " ^ (string_of_int ac); print_newline();
     print_string @@ "WA x " ^ (string_of_int wa); print_newline();
     print_string @@ "TLE x " ^ (string_of_int tle); print_newline();
     print_string @@ "RE x " ^ (string_of_int re);print_newline();
    )



Measured memory_bytes: 12848
#include<iostream>
#include <cstddef>
#include<set>
#include<stack>
#include <deque>
#include<queue>
#include<utility>
#include<vector>
#include<map>
#include<cmath>
#include<cstring>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#define  ll  long long
#define ull unsigned long long
#define  sl(a)  scanf("%lld",&a)
#define  si(a)  scanf("%d",&a)
#define mem(n,m) memset(n,m,sizeof(n))
#define PI acos(-1)
#define pb    push_back
#define pf    push_front
#define vll   vector<ll>
#define pll   pair<ll,ll>
#define mp  make_pair
#define vpll vector< pair <ll,ll> >
#define vplpll vector<pair<ll,pair<ll,ll> > >
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S(X) ( (X) * (X) )
#define forab(i, a, b) for(i = a; i <= b; i++)
#define forn(i, n) for(i = 0; i < n; i++)
#define print(a,b) printf("Case %lld: %lld\n",a,b)
using namespace std;
ll powd(ll a,ll b){if(b==1){return a;}if(b%2==1){return powd(a,b-1)*a;}else{ll x=powd(a,b/2); return x*x;}}
ll powm(ll a,ll b,ll m){if(b==0){return 1;}if(b==1){return a%m;}if(b%2==1){return ((powm(a,b-1,m)%m)*(a%m))%m;}else{ll x=powm(a,b/2,m); return ((x%m)*(x%m))%m;}}
ll gcd(ll a,ll b){if(a==0){return b;}return gcd(b,a%b);}
ull a[200005],b[200005];
int main()
{
    ll n,mod=1000000007;
    scanf("%llu",&n);
    ull sum=0;
    for(ll i=1;i<=n;i++)
    {
        scanf("%llu",&a[i]);
        b[i]=(b[i-1]+a[i]);
        sum+=a[i];
    }
    ull sum1=0;
    for(ll i=1;i<=n;i++)
    {
        ull t=(sum-b[i])%mod;
        ull u=(a[i]*t)%mod;
        sum1=(u+sum1)%mod;
    }
    cout<<sum1<<endl;
    return 0;
}

Measured memory_bytes: 6760
import math


n,m = map(int,input().split())
total = (n *(n -1)) //2
bridges  = []
for _ in range(m):
    (a,b) = map(lambda x:int(x) -1 ,input().split())
    bridges.append((a,b))
bridges.reverse() 
pars = {x:(x,1) for x in range(n)}

def union(x,pars):
    a = x[0]
    b = x[1]
    roota = root(a,pars)
    rootb = root(b,pars)
    if roota != rootb:
        u1 = roota[1]
        u2 = rootb[1]
        pars[max(roota[0],rootb[0])] = (min(roota[0],rootb[0]),roota[1] +rootb[1])
        pars[min(roota[0],rootb[0])] = pars[max(roota[0],rootb[0])]
        return (u1,u2)
    else:
        return (0,0)


ans = []     
def root(num,pars):
    if num == pars[num][0]:
        return pars[num]
    else:
        pars[num] = pars[pars[num][0]]
        return root(pars[num][0],pars)

for x in bridges:
    (u1,u2) = union(x,pars)
    ans.append(u1*u2)
ans.reverse()
ans1 = 0
for i in ans:
    ans1 += i
    print(ans1)

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

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  int man1=-1,sen5=-1,sen1=-1;
  int N,goukei;

  cin>>N>>goukei;

  for(int i=0;i<=N;i++){
    for(int j=0;j<=(N-i);j++){
      int k=N-i-j;
      //cout<<i<<','<<j<<','<<k<<endl;
      if(i*10000+j*5000+k*1000==goukei){
        man1 = i;
        sen5 = j;
        sen1 = k;
      }
    }
  }

  cout<<man1<<' '<<sen5<<' '<<sen1<<' '<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = false;

int main(){

    ll N;
    cin >> N;

    ll ans = N;
    for(ll i = 1; i * i <= N; i++ ){
        if(N % i == 0){
            ans = min(ans, (i - 1) + (N / i - 1) );
        }
    }
    cout << ans << endl;


}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static List<String> list = new ArrayList<>();
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String P = "";
		for (int i = 0; i < N; i++) {
			P += sc.next();
		}
		String Q = "";
		for (int i = 0; i < N; i++) {
			Q += sc.next();
		}
		permutation(P,"");
		Collections.sort(list);
		int a = list.indexOf(P) + 1;
		int b = list.indexOf(Q) + 1;
		System.out.println(Math.abs(a - b));
		
	}
	
	public static void permutation(String q, String ans){
		if(q.length() <= 1) {
			list.add(ans + q);
		}
		else {
			for (int i = 0; i < q.length(); i++) {
				permutation(q.substring(0, i) + q.substring(i + 1),
						ans + q.charAt(i));
			}
		}
	}
}

Measured memory_bytes: 45756
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */
 
    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(int i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(int i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(int i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 103000;
    
    void solve() {
        ll n, m, cnt = 0;
        cin >> n >> m;
        
        ll a[n][m];
        rep(i, n) rep(j, m) cin >> a[i][j];
        rep(i, n) for(ll j = i+1; j < n; j++) {
            //cout << i << " " << j << endl;
            ll dis = 0;
            rep(k, m) dis += pow(a[i][k] - a[j][k], 2);
            ll s = sqrt(dis);
            if(s*s == dis) cnt++;
        }
        cout << cnt << endl;
    }
 
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      //te
      solve();
      return 0;
    } 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rrep(i,n) for(long long i=(n);i>=0;--i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

// ========== debug ==========
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif
// ===========================

int main() {
  int N;
  ins(N);

  vi A(N);
  ll sum = 0;
  rep(i, N) {
    cin >> A[i];
    sum ^= A[i];
  }
  rep(i, N) {
    cout << (sum ^ A[i]) << endl;
  }

  return 0;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;



int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if (a+b==c || a+c==b || a==b+c){
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
}


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

int main()
{
    int A, B, X;
    scanf("%d %d %d", &A, &B, &X);
    if(X>A+B)
    {
        printf("NO");
    }
    else if(X<A)
    {
        printf("NO");
    }
    else 
    {
        printf("YES");
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<int64_t> A(N);
  for(auto& Ai: A) std::cin >> Ai;
  std::sort(A.rbegin(), A.rend());
  int64_t ans = 0;
  int j = 0;
  for(int k = 0; k < N; ++k) {
    ans += A[k];   if(++j == N-1) break;
    ans += A[k+1]; if(++j == N-1) break;
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 5224
n=int(input())
ans=1
mod=10**9+7
A=[0,0]
AB=[]
for i in range(n):
  a=int(input())
  AB.append((a,0))
for i in range(n):
  b=int(input())
  AB.append((b,1))
AB.sort(key=lambda x:x[0])
for i in range(2*n):
  a,b=AB[i]
  if b==0:
    if A[1]>0:
      ans=(ans*A[1])%mod
      A[1]-=1
    else:
      A[0]+=1
  else:
    if A[0]>0:
      ans=(ans*A[0])%mod
      A[0]-=1
    else:
      A[1]+=1
print(ans)

Measured memory_bytes: 27056