akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)	
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll int
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = pow(10,8);
ll modulo = pow(10,9)+7  ;
#define ld long double
#define MAX (int)(pow(10,5)+ 10)

 
void deal(){
	ll n ;
	cin>>n;
	vector<ll> arr(n);
	fori(n)
		cin>>arr[i];
	vector<ll> dp(n);
	dp[0] = 0;
	dp[1] = fabs(arr[1] - arr[0]);
	for(ll i =2; i<n; i++)
		dp[i] = min(fabs(arr[i]-arr[i-2])+dp[i-2], fabs(arr[i]-arr[i-1]) + dp[i-1]);
	cout<<dp[n-1];
}
 
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}
 
/*
 
5 1
1 2 3 4 5


*/

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define ll unsigned long long int
#define test long int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
#define mm 1000000007

bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int binaryExponentiation(int x, int n) //function to calculate x raise to power n
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x;
		x = x * x;
		n = n / 2;
	}
	return result;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-______________________________________________________________________________


	int r;
	cin >> r;
	cout << fixed << setprecision(4) << 2 * (pi)*r << en;

	return 0;
}


Measured memory_bytes: 3804
//In the name of ALLAH
#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
const bool DEBUG = false;
#define cerr if(DEBUG)cerr
using namespace std;

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

const long long maxn = 2e5 + 5;
const long long INF = 1e18 + 1;
const long long M = 1e9 + 7;
const int Z = 26;

string s, k;
int n, t[Z];

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> s;
	n = s.size();
	if(s == "zyxwvutsrqponmlkjihgfedcba")
		return cout << -1 << endl, 0;
	if(s.size() == 26){
		string k = s, ans = "zzz";
		vector<char> v;
		v.pb(s[25]);
		s.pop_back();
		for(int i = n - 2; i >= 0; i--){
			for(auto u : v){
				if(u > k[i + 1]){
					s.pb(u);
					ans = min(ans, s);
					s.pop_back();
				}
			}
			v.pb(s[i]);
			s.pop_back();
		}
		s = k;
		string ans1 = "zzz";
		if(s[0] != 'z'){
			ans1.clear();
			ans1.pb(s[0] + 1);
		}			
		return cout << min(ans1, ans) << endl, 0;		
	}
	for(char i = 'a'; i <= 'z'; i++){
		bool flag = 1;
		for(int j = 0; j < s.size(); j++)
			if(s[j] == i)
				flag = 0;
		if(flag){
			s.pb(i);
			break;
		}
	}
	cout << s << endl;
	return 0;
}


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

// A - Poor
int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B && A != C) {
        cout << "Yes";
        return 0;
    }
    if (A == C && A != B) {
        cout << "Yes";
        return 0;
    }
    if (B == C && B != A) {
        cout << "Yes";
        return 0;
    }
    cout << "No";
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int main(void){
	int N, L;
	cin >> N >> L;

	vector<int> vec(N);
	int min = INF;
	int sum = 0;
	for(int i = 0; i < N; i++){
		vec[i] = L + i;
		sum += vec[i];
		if(abs(min) > abs(vec[i])) min = vec[i];
	}

	cout << sum - min << '\n';

	return 0;
}

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

int main() {
  int n;
  vi a, inds;
  cin >> n;
  int entra;
  cin >> entra;
  a.push_back(entra);
  for (int i = 1; i < n; i++) {
    cin >> entra;
    a.push_back(entra);
    if (a[i] == a[i-1]+1) inds.push_back(a[i]-1);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> entra;
    ans += entra;
  }
  for (int i = 1; i < n; i++) {
    cin >> entra;
    if (find(begin(inds), end(inds), i) != end(inds))
      ans += entra;
  }
  printf("%d\n", ans);
  return 0;}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def abc080_c():
    N = int(readline())  # 他店の数
    # 他店の営業パターン：店→日付→営業01
    F = [list(map(int, readline().split())) for _ in range(N)]
    # 他店と何回重なると利益がどうなるか：店→重複回数→利益
    P = [list(map(int, readline().split())) for _ in range(N)]
    ans = -10**12  # 最悪 100 * -10**7

    # bit全探索
    from itertools import product
    from operator import mul
    for mask in product(range(2), repeat=10):
        if mask.count(1) == 0: continue
        profit = 0
        for i in range(N):
            # 他店iの営業パターンと、自店の営業パターンmaskと、の要素積は、重複する営業日
            #overlap = sum(x * y for x, y in zip(F[i], mask))
            overlap = sum(map(mul, F[i], mask))
            profit += P[i][overlap]
        ans = max(profit, ans)
    print(ans)

abc080_c()

Measured memory_bytes: 3188
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        for(int i = 1;i <= n;i++){
            String tmp = String.valueOf(i);
            if(tmp.length()%2==1)ans++;
        }
        
        
        System.out.print(ans);
        
        
    }
    
}


Measured memory_bytes: 28116
n, m, k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

total = 0
count = 0
flag = n-1
for i in range(n):
    total += a[i]
    if total > k:
        total -= a[i]
        flag = i-1
        break
    count += 1
ans = count
for i in range(m):
    if b[i] > k:
        break
    total += b[i]
    count += 1
    while total > k:
        if flag == -1:
            break
        else:
            total -= a[flag]
            flag -= 1
            count -= 1
    if total > k: 
        break
    ans = max(ans, count)

print(ans)

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

int main(){
  string N;
  
  cin >> N;
  
  if((N[0] == N[1] && N[0] == N[2]) || 
     (N[1] == N[2] && N[1] == N[3])){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int x, y;
  
  cin >> x >> y;
  
  int b = ( y - 2 * x) / 2;
  int a = x - b;
  
  if (a + b == x && (2 * a + 4 * b == y) && a >= 0 && b >= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3644
/*
        Choo Lo jo mujhe tum kabhi, kho na jaoon main raat din
    Nazaron mein tum ho basey
        Keh do jo tum ek baar, Mere ho bas tum mere
    Nazaron mein tum ho basey
*/
 
#include<bits/stdc++.h>
#include<cstdio>
 
#define deb(x) cout << #x << " -> " << x << el
#define db double
#define ll long long int
#define ull unsigned long long int
#define umap unordered_map
#define sc(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define sclu(x) scanf("%llu", &x)
#define scd(x) scanf("%lf", &x)
#define pass cout<<"pass\n"
#define vi vector<int>
#define pb push_back
#define vec vector
#define el "\n"
#define pii pair<int, int>
#define pll pair<long long, long long>
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define umap unordered_map
#define f(i,x,y) for(int i=x;i<y;++i)
#define ff(i,x,y) for(int i=x;i<=y;++i)
#define mem(x) memset(x, 0, sizeof(x))
#define mems(x,y) memset(x, y, sizeof(x))
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ppi pair<int, pii>
#define mat vector<vector<ll> > 
#define mod 1000000007
#define MAX 100005
 
using namespace std;

int n, m;
vi g[MAX];
int dist[MAX];
bool vis[MAX];

int dfs(int src) {
	if(vis[src]) return dist[src];
	vis[src] = true;

	dist[src] = 0;

	int d;
	for(int ch: g[src]) {
		if(vis[ch]) d = dist[ch];
		else d = dfs(ch);
		
		dist[src] = max(dist[src], 1 + d);
	}
	return dist[src];
}

void solve() {
	cin >> n >> m;

	f(i,0,m) {
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
	}

	ff(i,1,n) if(!vis[i]) dist[i] = dfs(i);
	cout << *max_element(dist + 1, dist + n + 1) << el;
}

int main() {
    // freopen("inp.txt", "r", stdin);
    int ccc = 1;
    // sc(ccc);
    while(ccc--) {
        solve();
    }
 
    return 0;
}


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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const int INF = 100000000;

int main() {

    string S, T;
    cin >> S >> T;
    string T_ = T.substr(0, T.length()-1);

    if(S == T_)cout << "Yes";
    else cout << "No";



}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 200;
vector<int> g[1 + nmax];
int dist[1 + nmax];

int solve(int node, int n){
  for(int i = 1; i <= n; i++)
    dist[i] = 0;
  dist[node] = 1;
  queue<int> q;
  q.push(node);

  while(0 < q.size()){
    node = q.front();
    q.pop();
    for(int h = 0; h < g[node].size(); h++){
      int to = g[node][h];
      if(dist[to] == 0){
        dist[to] = dist[node] + 1;
        q.push(to);
      } else if(dist[to] == dist[node])
        return -1;
    }
  }

  int maxdist = 1;
  for(int i = 1;i <= n; i++)
    maxdist = max(maxdist, dist[i]);
  return maxdist;
}

int main()
{
  int n;
  cin >> n;
  for(int i = 1;i <= n; i++)
    for(int j = 1;j <= n; j++){
      char ch;
      cin >> ch;
      if(ch == '1')
        g[i].push_back(j);
    }
  int result = -1;
  for(int i = 1;i <= n; i++)
    result = max(result, solve(i, n));
  cout << result;
  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

class Main{
	public void solve(){
	     Scanner sc=new Scanner(System.in);
         int x;
		 x=sc.nextInt();
		 System.out.println(x*x*x);
	}
	public static void main(String[]args){
		Main obj=new Main();
		obj.solve();
	}
}

Measured memory_bytes: 17172
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7ffffffe
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define mod 1000000007
typedef long long ll;
typedef long double dl;
using namespace std;
#define int long long
int n;
int dp[1010][40010],w[1010],s[1010],v[1010];
struct block{
	int w,s,v;
};
block a[1010];
inline void chkmax(int& a,int b){
	a=max(a,b);
}
inline void fread(int& n){
	int res=0;bool f=0;
	char ch=getchar();
	if(ch=='-'){
		f=1;
	}
	else{
		res=ch-'0';
	}
	while(1){
		ch=getchar();
		if(ch==' '||ch=='\n'){
			n=f?-res:res;
			return;
		}
		res*=10;
		res+=(ch-'0');
	}
	n=res;
}
inline bool cmp(block x,block y){
	return x.s+x.w<y.s+y.w;
}
//dp[i][j]=max{dp[i-1][j],dp[i-1][j-w[i]]+v[i](s[i]>=j-w[i])};
signed main(void){
	cin>>n;
	forn(i,n){
		cin>>a[i].w>>a[i].s>>a[i].v;
	}
	sort(a+1,a+n+1,cmp);
	forn(i,n){
		w[i]=a[i].w;
		s[i]=a[i].s;
		v[i]=a[i].v;
	}
	forn(i,n){
		rep(j,40010){
			chkmax(dp[i][j],dp[i-1][j]);
			if(s[i]>=j-w[i]&&j-w[i]>=0){
				chkmax(dp[i][j],dp[i-1][j-w[i]]+v[i]);
			}
		}
	}
	int ans=0;
	forn(i,n){
		rep(j,40010){
			chkmax(ans,dp[i][j]);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
    int n;
    cin>>n;
    int a,b;
    cin>>a>>b;
    bool cr=false;
    for(int i=a;i<=b;i++)
    {
        if(i%n==0)cr=true;
    }
    if(cr)cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll a;
  string b;
  cin>>a>>b;
  if(b=="10.00"){
    cout<<a*10<<endl;
    return 0;
  }
  
  ll c=stoi(b.erase(1,1));
  ll ans=a*c;
  string s=to_string(ans);
  if(s.size()<=2){
    cout<<0<<endl;
    return 0;
  }
  string t= s.substr(0,s.size()-2);
  cout<<t<<endl;
  
}

Measured memory_bytes: 3660
#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int f[9];
void factorial() {
  f[0] = 1;
  for (int i = 1; i < 9; i++)
    f[i] = f[i - 1] * i;
}

int dictionary(int *a, int size) {
  if (size <= 1) return 0;
  int i=0;
  while (a[i] == i+1) i++;
  if (i == 0) {
    int b[size-1];
    for (int i=0; i<size-1; i++) {
      if (a[i+1] > a[0]) b[i] = a[i+1] - 1;
      else b[i] = a[i+1];
    }
    return (a[0]-1) * f[size-1] + dictionary(b, size-1);
  }
  int b[size - i];
  for (int j=0; j<size-i; j++) {
    if (a[i+j] > a[i-1]) b[j] = a[i+j] - a[i-1];
    else b[j] = a[i+j];
  }
  return dictionary(b, size-i);
}

int main() {
  int n;
  scanf("%d", &n);
  int p[n], q[n];
  for (int i = 0; i < n; i++)
    scanf("%d", p + i);
  for (int i = 0; i < n; i++)
    scanf("%d", q + i);
  factorial();
  int po = dictionary(p, n);
  int qo = dictionary(q, n);
  printf("%d\n", abs(po - qo));
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int k = sc.nextInt();
		sc.close();
		String ans = "";
		char sel = s.charAt(k - 1);
		for (int i = 0; i < n; i++) {
			if (s.charAt(i) == sel) {
				ans += s.charAt(i);
			} else {
				ans += '*';
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22100
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
LL N,A,B;
LL X[100001];
LL ans=0;
int main(){
    cin>>N>>A>>B;
    REP(i,N){
        cin>>X[i];
    }
    REP(i,N-1){
        ans+=min(B,A*(X[i+1]-X[i]));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int n, minp, tmp;
	cin >> n;
	minp = 100000000;
	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int p = 1; p <= 100; p++) {
		tmp = 0;
		for (int i = 0; i < n; i++) {
			tmp += (v[i] - p)*(v[i] - p);
		}
		if (minp > tmp)	minp = tmp;
	}
	cout << minp << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(it, ff, ee) for (int it = (ff); it <= (ee); ++it)
#define per(it, ff, ee) for (int it = (ff); it >= (ee); --it)
const int MAXN = 2e5 + 5;
const int SIZE = (int) sqrt(MAXN);
int h[MAXN], v[MAXN];
lint dp[MAXN], Value[SIZE + 5];
template <typename T>
inline void chkMAX(T & x, T y) {
	x < y ? x = y : 0;
}
inline lint query(int r) {
	lint res = 0;
	int now = 0;
	for (int i = 0; now + SIZE <= r; ++i, now += SIZE) {
		chkMAX(res, Value[i]);
	}
	while (now < r) {
		chkMAX(res, dp[now++]);
	}
	return res;
}
inline void modify(int p, lint v) {
	chkMAX(Value[p / SIZE], dp[p] = v);
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int n;
	cin >> n;
	rep (i, 1, n) {
		cin >> h[i];
	}
	rep (i, 1, n) {
		cin >> v[i];
	}
	rep (i, 1, n) {
		modify(h[i], query(h[i]) + v[i]);
	}
	lint res = 0;
	rep (i, 1, n) {
		chkMAX(res, dp[i]);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3456
/*
[abc168] F - . (Single Dot)
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 1000;
const int K = 6 * MAX_N + 6;
const int INF = 1e9 + 7;

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

int N, M;
int A[MAX_N], B[MAX_N], C[MAX_N], D[MAX_N], E[MAX_N], F[MAX_N];
int m[K][K];
vector<ll> xs, ys;

void solve() {
    xs.push_back(0), xs.push_back(-INF), xs.push_back(INF);
    ys.push_back(0), ys.push_back(-INF), ys.push_back(INF);
    for (int i = 0; i < N; i++) {
        xs.push_back(A[i]);
        xs.push_back(B[i]);
        ys.push_back(C[i]);
    }
    for (int i = 0; i < M; i++) {
        xs.push_back(D[i]);
        ys.push_back(E[i]);
        ys.push_back(F[i]);
    }
    sort(ALL(xs));
    sort(ALL(ys));
    xs.erase(unique(ALL(xs)), xs.end());
    ys.erase(unique(ALL(ys)), ys.end());
    int xl = xs.size(), yl = ys.size();
    xs.resize(xl * 2);
    ys.resize(yl * 2);
    for (int i = xl - 1; i >= 0; i--) xs[i * 2 + 1] = xs[i * 2] = xs[i];
    for (int i = yl - 1; i >= 0; i--) ys[i * 2 + 1] = ys[i * 2] = ys[i];

    for (int i = 0; i < N; i++) {
        int a = lower_bound(ALL(xs), A[i]) - xs.begin(),
            b = lower_bound(ALL(xs), B[i]) - xs.begin(),
            c = lower_bound(ALL(ys), C[i]) - ys.begin();
        for (int x = a; x <= b; x++) {
            m[x][c] = -1;
        }
    }
    for (int i = 0; i < M; i++) {
        int d = lower_bound(ALL(xs), D[i]) - xs.begin(),
            e = lower_bound(ALL(ys), E[i]) - ys.begin(),
            f = lower_bound(ALL(ys), F[i]) - ys.begin();
        for (int y = e; y <= f; y++) {
            m[d][y] = -1;
        }
    }

    ll ans = 0;
    queue<pii> q;
    int xz = lower_bound(ALL(xs), 0) - xs.begin(),
        yz = lower_bound(ALL(ys), 0) - ys.begin();
    q.push(pii(xz, yz));
    while (!q.empty()) {
        int x = q.front().first, y = q.front().second;
        q.pop();
        if (x == -1 || x == K || y == -1 || y == K) {
            cout << "INF" << endl;
            return;
        }
        if (m[x][y] != 0) continue;
        m[x][y] = 1;
        ans += abs(xs[x + 1] - xs[x]) * abs(ys[y + 1] - ys[y]);
        for (int d = 0; d < 4; d++) {
            int nx = x + dx[d], ny = y + dy[d];
            q.push(pii(nx, ny));
        }
    }

    cout << ans << endl;
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i] >> C[i];
    }
    for (int i = 0; i < M; i++) {
        cin >> D[i] >> E[i] >> F[i];
    }

    solve();

    return 0;
}


Measured memory_bytes: 144436
import sys
import copy

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    N, S = in_nn()
    A = in_nl()

    dp = [0] * (S + 1)
    dp[0] = 1

    mod = 998244353
    for i in range(N):
        next_dp = [0] * (S + 1)
        for j in range(S + 1):
            next_dp[j] += dp[j] * 2
            next_dp[j] %= mod
            if j + A[i] <= S:
                next_dp[j + A[i]] += dp[j]
                next_dp[j + A[i]] %= mod

        dp = next_dp

    print(dp[S])


if __name__ == '__main__':
    main()


Measured memory_bytes: 74476
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	ll ans;

	for (int i = 1; i <= sqrt(n); i++){
		ans = i * i;
	}
	cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> numbers(N);
  for (int i = 0; i < N; i++) {
    cin >> numbers.at(i);
  }
  
  sort(numbers.begin(), numbers.end());
  reverse(numbers.begin(), numbers.end());
  
  int Alice = 0;
  int Bob = 0;
  for (int i = 0; i < N; i += 2) {
    Alice += numbers.at(i);
  }
  for (int i = 1; i < N; i += 2) {
    Bob += numbers.at(i);
  }
  
  cout << Alice - Bob << endl;
}


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

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var D = new HashSet<int>();
        for (var i = 0; i < N; i++)
        {
            D.Add(int.Parse(Console.ReadLine()));
        }

        Console.WriteLine(D.Count);
    }
}

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

using namespace std;

int sum(int x) {
  string s = to_string(x);
  int ret = 0;
  for (int i = s.size() - 1; i >= 0; --i) {
    ret += s[i] - '0';
  }

  return ret;
}

int main()
{
  int N, A, B; cin >> N >> A >> B;

  int ret = 0;
  for (int i = 1; i <= N; ++i) {
    int x = sum(i);
    if (x >= A and x <= B) {
      ret += i;
    }
  }

  cout << ret;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int N , i , count = 0 ;
    scanf("%d", &N);
    for(i = 0 ; i<2 ; i++){
        if(N%10 == 9){
            count++ ;
        }
         if(N/10 == 9){
            count++ ;
        }
    }
    if(count>0){
        printf("Yes");
    }else{
        printf("No");
    }
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n,a[110];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n,greater<int>());
  int alice=0;
  int bob=0;
  for(int i=0;i<n;i++){
    if(i%2==0){
      alice+=a[i];
    }else{
      bob+=a[i];
    }
  }
  cout<<alice-bob<<endl;
}


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

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

int main () {
    long long a, b;
    long long d = 0;
    long long ret = 0;
    cin >> a >> b;

    d = gcd(a, b);
    ret = a / d * b;
    cout << to_string(ret) << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n,m;
    cin >> n >> m;
    vector<P> vec(m);
    REP(i,m){
        cin >> vec[i].second >> vec[i].first;
    }
    sort(ALL(vec));
    int ans = 0, t = 0;
    REP(i,m){
        if(vec[i].second >= t){
            ans++;
            t = vec[i].first;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main{

	//static long[] a;
	static	int N ;
	static	int M ;
	static long[][] dp;
	static int ans = 100000000;
	static	boolean[] flag ;

	public static void main(String[] args) {


		Scanner s = new Scanner(System.in);			//文字の入力
		N = s.nextInt();

		dp = new long[N+1][N+1];
		int[][] subdp =  new int[N+1][N+1];

		for(int i = 1;i < N+1;i++){
			for(int j = 1;j < N+1;j++){
				int x= s.nextInt();
				dp[i][j] = x;
			}
		}


		for(int k = 1;k < N+1;k++){
			for(int i = 1;i < N+1;i++){
				for(int j = 1;j < N+1;j++){
					if(dp[i][j] >dp[i][k] + dp[k][j] ){
						System.out.println("-1");
						return;
					}
				}
			}
		}
		long ans = 0;


		for(int i = 1; i < N+1;i++){
			for(int j = 1;j < N+1;j++){
				boolean flag = true;
				for(int k = 1;k < N+1;k++){
					if(i != k&& j != k && dp[i][j] == dp[i][k]+dp[k][j]){
						flag = false;
					}
				}
				if(flag) ans += dp[i][j];
			}
		}

		System.out.println(ans/2);
		

	}

	

	


}




Measured memory_bytes: 64044
import java.util.*;

public class Main {
    public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
      int n = Integer.parseInt(sc.next());
      int d = Integer.parseInt(sc.next());
      int ans = 0;
      double sum = 0;
      
      double[][] ary = new double[n][d];
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
          ary[i][j] = Double.parseDouble(sc.next());
        }
      }
      
      for (int i = 0; i < n -1; i++) {
        for (int k = 1;k < n-i;k++) {
          sum = 0;
          for (int j = 0; j < d; j++) {
            sum += Math.pow((ary[i][j]-ary[i+k][j]),2);
          }
          if (Math.sqrt(sum) % 1 == 0) {
            ans += 1;
          }
        }
      }
      System.out.print(ans);
    }
}



Measured memory_bytes: 23124
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::*;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let s: String = read!();
    let n: usize = read!();
    let s = s.chars().collect_vec();

    let len = s.len();

    let mut buf = String::new();
    for i in 0..=len {
        if len  <= i * n {
            break;
        }

        buf.push(s[i * n]);
    }

    println!("{}", buf);
}


Measured memory_bytes: 2132
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,ans=0,val;
  cin >> n;
  ll a[n];
  ll bcc[n][70];
  fill(bcc[0],bcc[n],0);
  for(int i=0;i<n;i++){
    cin >> a[i];
    ll tmp = a[i];
    for(int j=0;j<70;j++){
      bcc[i][j]+=tmp%2;
      tmp /= 2;
    }
  }
  for(int i=1;i<n;i++){
    for(int j=0;j<70;j++){
      bcc[i][j] += bcc[i-1][j];
    }
  }
  val = 1;
  for(int i=0;i<n;i++){
    ll tmp = a[i];
    ll v;
    val = 1;
    for(int j=0;j<70;j++){
      if(tmp%2==0){
        v = bcc[n-1][j]-bcc[i][j];
      }else{
        v = (n-i-1-(bcc[n-1][j]-bcc[i][j]));
      }
      v %= MOD;
      v *= val; 
      v %= MOD;
      ans += v;
      ans %= MOD;
      val *= 2;
      val %= MOD;
      tmp /=2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 166656
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>

#define MOD 1000000007


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

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

	long long 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) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}

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

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

	return true;
}




int main()
{
	int q;
	cin >> q;
	
	vector<int> l(q);
	vector<int> r(q);

	for (int i = 0; i < q; i++) {
		cin >> l[i];
		cin >> r[i];
	}

	int ruiseki[100001];
	ruiseki[0] = 0;
	bool wk_isPrime;

	//累積和作成
	for (int i = 1; i <= 100000; i++) {
		wk_isPrime = isPrime(i) && isPrime((i + 1) / 2);

		if (wk_isPrime) {
			ruiseki[i] = ruiseki[i - 1] + 1;
		}
		else {
			ruiseki[i] = ruiseki[i - 1];
		}
	
	}

	int wk;
	for (int i = 0; i < q; i++) {
		wk = ruiseki[r[i]] - ruiseki[l[i] - 1];
		cout << wk << endl;


	}



	return 0;

}



Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
int main(void){
	int a,b;
	int c,d,i;
	int e=1;
	scanf("%d %d",&a,&b);
	if(a>=b){
		c=a;
		d=b;
	}
	else{
		c=b;
		d=a;
	}
	for(i=1;i<c;i++){
		e=e*10+1;
	}
	printf("%d",d*e);
	return 0;
	}


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

int main() {
	int h,w,i,j;
	cin>>h>>w;
	char c[h][w];
	int dp[h][w]={0};
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		cin>>c[i][j];
	}
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			if(c[i][j]=='#')
			dp[i][j]=0;
			else if(i==0&&j==0)
			dp[i][j]=1;
			else if(i==0)
			dp[i][j]=dp[i][j-1];
			else if(j==0)
			dp[i][j]=dp[i-1][j];
			else
			{
				dp[i][j]=dp[i-1][j]%1000000007+dp[i][j-1]%1000000007;
			    dp[i][j]=dp[i][j]%1000000007;
			}
			
		}
	}
	cout<<dp[h-1][w-1]%1000000007<<endl;
	return 0;
}

Measured memory_bytes: 8492
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN = 1000000;
bool isPrime[MAXN];
int main(){
  fill(isPrime,isPrime+MAXN,true);
  isPrime[0] = isPrime[1] = false;
  isPrime[2] = true;
  for(int i = 0;i < MAXN;i++){
    if(isPrime[i]){
      for(int j = i*2;j < MAXN;j+=i){
        isPrime[j] = false;
      }
    }
  }
  vector<int> primes;
  for(int i = 0;i < MAXN;i++){
    if(isPrime[i])primes.push_back(i);
  }
  int n;

  while(cin >> n){
    auto a = upper_bound(primes.begin(),primes.end(),n);
    cout << a - primes.begin() << endl;
  }
}

Measured memory_bytes: 2564
class Integer
  def popcount
    to_s(2).count('1')
  end
end

def f(n)
  c = 0
  while n > 0
    n %= n.popcount
    c += 1
  end
  c
end

def modpow(base, n, mod)
  result = 1
  while n > 0
    if n.odd?
      result = result * base % mod
    end

    base = (base * base) % mod

    n /= 2
  end
  result % mod
end

n = gets.to_i
x = gets.chomp
x_int = x.to_i(2)
base_popcount = x.count('1')

mod_zero = x_int % (base_popcount + 1)
mod_one  = x_int % (base_popcount - 1) unless base_popcount == 1

0.upto(n - 1) do |index|
  if x[index] == '1' && base_popcount == 1
    puts 0
    next
  end

  shift = n - index - 1
  mod =
    if x[index] == '0'
      popcount = base_popcount + 1
      (mod_zero + modpow(2, shift, popcount)) % popcount
    else
      popcount = base_popcount - 1
      (mod_one  - modpow(2, shift, popcount)) % popcount
    end

  puts f(mod) + 1
end


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

using namespace std;

using LL = long long;

void solver() {
    int N; cin >> N;

    vector< LL > f(N + 1);

    for(int i = 1; i <= N; ++i) {
        for(int j = 1; j * i <= N; ++j) {
            f[i * j]++;
        }
    }

    LL ans = 0;

    for (int i = 1; i <= N; ++i) {
        ans += i * 1LL * f[i];
    }

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



int main() {

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

    int t;
    //cin >> t;
    t = 1;

    while(t--)
        solver();

    return 0;
}

Measured memory_bytes: 81328
#include <bits/stdc++.h>		//线段树维护区间和
#define ll long long
#define inf 0x3f3f3f3f 
using namespace std;
const int maxn = 1e5+10;

int main(){
	ll n,d;
	scanf("%lld%lld", &n, &d);
	int ans = 0;
	for(int i = 1; i <= n; i ++){
		ll a,b;
		scanf("%lld%lld", &a, &b);
		if(a*a + b*b <= d*d) ans++;
	}
	printf("%d", ans);

	return 0;
}



Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
const ll INF=1LL<<60;
const ll mod=1E9+7;


int main(){
  string s,t;
  cin >> s >> t;
  bool f=true;
  rep(i,s.size()){
    if(s[i]!=t[i])f=false;
  }
  if(s.size()+1!=t.size())f=false;
  if(f)cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 3596
N = gets.to_i
XYs = readlines.map{|l| l.split.map(&:to_i)}
M = 998244353

sub = ->(a, b){(a - b) % M}
t = 1
dd = [t]
N.times do
  t = 2*t % M
  dd << t
end
xs, ys = XYs.transpose
ini = N.times.sort_by{|n| xs[n]}
N.times.sort_by{|n| ys[n]}.each_with_index{|yi, i| ys[yi] = i}
nys = ini.map{|i| ys[i]}
tree = [0]*(N + 1)
r = 0
nys.each_with_index do |y, i|
  j = y + 1
  while j <= N
    tree[j] += 1
    j += j & -j
  end
  d = 0
  j = y
  while j > 0
    d += tree[j]
    j -= j & -j
  end
  c = i - d
  b = (N - 1) - y - c
  a = (N - 1) - b - c - d
  r = (r + sub[dd[b + c] + dd[c + d] + dd[d + a] + dd[a + b], dd[a] + dd[b] + dd[c] + dd[d]]) % M
end
puts sub[dd[N]*N % M, (r + N) % M]

Measured memory_bytes: 43484
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main(){
  int N;
  cin >> N;
  vector<string> s(N);
  rep(i, N){
    cin >> s.at(i);
  }
  int M;
  cin >> M;
  vector<string> t(M);
  rep(i, M){
    cin >> t.at(i);
  }
  sort(all(s));
  int cnt = 1;
  int g = 0;
  rep(i, N-1){
    if(s.at(i) == s.at(i+1)){
      cnt++;
    }
    else if(cnt > g){
      rep(j, M){
        if(t.at(j) == s.at(i)){
          cnt--;
        }
      }
      if(cnt > g){
        g = cnt;
      }
      cnt = 1;
    }
    else{
      cnt = 1;
    }
  }
  if(cnt > g){
    rep(j, M){
      if(t.at(j) == s.at(N-1)){
        cnt--;
      }
    }
    if(cnt > g){
      g = cnt;
    }
  }
  if(g > 0){
    cout << g << endl;
  }
  else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<set>
#include<utility>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<stack>
#include<iomanip>

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

#define P pair<int, int>

typedef long long ll;

using namespace std;

#include <string>
#include <cctype>
typedef string::const_iterator State;
class ParseError {};


int main() {
	int a;
	cin >> a;
	if ('A' <= a && a <= 'Z') cout << 1 << endl;
	else if ('a' <= a && a <= 'z') cout << 2 << endl;
	else cout << 0 << endl;

	return 0;
}



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

from itertools import combinations


def main():
    n = int(input())
    d = list(map(int, input().split()))

    ans = 0
    for pat in combinations(d, 2):
        ans += pat[0] * pat[1]

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
N,K=[int(i) for i in input().split(" ")]
sunuke=[i for i in range(1,N+1)]
for i in range(K):
    d=[int(input())]
    A=[int(i) for i in input().split(" ")]
    for a in A:
        for i in range(len(sunuke)):
            if sunuke[i]==a:
                del sunuke[i]
                break
print(len(sunuke))


Measured memory_bytes: 9196
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FOOR(i,a,b) for(int i=a;i<=b;i++)
#define FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
using namespace std;
//
int main(){
  long long H,W;
  cin>>H>>W;
  long long SA,SB,SC;
  long long m=1e15+7;
  FOR(i,1,H+1){
    SA=i*W;
    SB=(H-i)*(W/2);
    SC=(H-i)*(W-W/2);
    m=min(m,max(SA,max(SB,SC))-min(SA,min(SB,SC)));
    SB=((H-i)/2)*W;
    SC=((H-i)-(H-i)/2)*W;
    m=min(m,max(SA,max(SB,SC))-min(SA,min(SB,SC)));
  }
  FOR(i,1,W+1){
    SA=i*H;
    SB=(W-i)*(H/2);
    SC=(W-i)*(H-H/2);
    m=min(m,max(SA,max(SB,SC))-min(SA,min(SB,SC)));
    SB=((W-i)/2)*H;
    SC=((W-i)-(W-i)/2)*H;
    m=min(m,max(SA,max(SB,SC))-min(SA,min(SB,SC)));
  }
  cout<<m<<endl;
  return 0;
}


Measured memory_bytes: 256
N = gets.chomp.to_i
a = Array.new(N)
str = gets.split
for i in 0...N do
    a[i] = str[i].to_i
end
a.sort!
i = 1
while i < N
    if a[i] == a[i-1]
        puts "NO"
        exit
    end
    i += 1
end
puts "YES"

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

constexpr int MAX_N = 41, MAX_VOL = 410, INF = 1e4;

int dp[MAX_N][MAX_VOL + 20][MAX_VOL + 20];

int a[MAX_N], b[MAX_N], c[MAX_N];

int main()
{
    int n, ma, mb;
    std::cin >> n >> ma >> mb;

    for (int i = 1; i <= n; ++i)
        std::cin >> a[i] >> b[i] >> c[i];

    for (int i = 0; i <= n; ++i)
    {
        for (int j = 0; j <= MAX_VOL; ++j)
        {
            for (int k = 0; k <= MAX_VOL; ++k)
                dp[i][j][k] = INF;
        }
    }

    dp[0][0][0] = 0;

    for (int i = 1; i <= n; ++i)
    {
        for (int j = 0; j <= MAX_VOL; ++j)
        {
            for (int k = 0; k <= MAX_VOL; ++k)
            {
                if (dp[i - 1][j][k] != INF)
                    dp[i][j + a[i]][k + b[i]] =
                        std::min(dp[i][j + a[i]][k + b[i]], dp[i - 1][j][k] + c[i]);
                dp[i][j][k] = std::min(dp[i][j][k], dp[i - 1][j][k]);
            }
        }
    }

    int ans = INF;

    std::cerr << "DEBUG:BEGIN" << std::endl;

    for (int i = 1; i * ma <= MAX_VOL && i * mb <= MAX_VOL; ++i)
    {
        ans = std::min(ans, dp[n][i * ma][i * mb]);
        std::cerr << i << ' ' << dp[n][i * ma][i * mb] << std::endl;
    }

    std::cerr << "DEBUG:END" << std::endl;

    std::cout << ((ans == INF) ? -1 : ans) << std::endl;

    return 0;
}

Measured memory_bytes: 29696
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  vpll A(n);
  ll ans=0;
  FOR(i,0,n){
	ci(A[i].fi>>A[i].se)
    A[i].fi+=A[i].se;
    ans-=A[i].se;
  }
  SORT(A);
  REV(A);
  FOR(i,0,n){
    if(i%2==0){
    ans+=A[i].fi;
  }
  }
  co(ans)
}

Measured memory_bytes: 1792
using System;

class _0055 {
    public static void Main() {
        double a, sum;
        while(double.TryParse(Console.ReadLine(), out a)) {
            sum = a;
            for(int i = 0; i < 4; i++) {
                a *= 2.0;
                sum += a;
                a /= 3.0;
                sum += a;
            }
            sum += a * 2.0;
            Console.WriteLine(sum.ToString("F8"));
        }
    }
}

Measured memory_bytes: 9056
#include<stdio.h>
#include<string.h>
#include<math.h>
int ara[100000];
int main()
{
    int i,j,k,l,n,t,df,v;
    while(scanf("%d",&n)!=EOF)
    {
        for(i=0;i<7;i++)
        {
            l=pow(2,i);
            if(l>n)
            {
                break;
            }
            k=l;
        }
        printf("%d\n",k);
    }
    return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<math.h>

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

int main() {
	int n; cin >> n;
	string s; cin >> s;
	if (n % 2 != 0) {
		puts("No");
		return 0;
	}

	rep(i, n / 2) {
		if (s[i] != s[i + n / 2]) {
			puts("No");
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> L;
  tools::read(L, N);

  std::sort(L.begin(), L.end());
  std::cout << (L.back() < std::accumulate(L.begin(), L.end() - 1, static_cast<i64>(0)) ? "Yes" : "No") << std::endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# 文字列を一文字ずつのリストに代入 test は['t', 'e', 's', 't']
m = list(input())
answer = 0
for i in range(4):
    if m[i] == '+':
        answer += 1
    else:
        answer -= 1

print(answer)


Measured memory_bytes: 21804
N,K=list(map(int,input().split()))
n_l=list(map(int,input().split()))
ans=0
mod=10**9+7
for i in range(N):
   A=n_l[i]
   ans+=len([j for j in n_l[i+1:] if j < A])
ans2=0
for i in n_l:
   ans2+=len([k for k in n_l if i > k])
f_a=ans*K%mod+K*(K-1)//2*ans2%mod
print(f_a%mod)

Measured memory_bytes: 3188
import sys
input = sys.stdin.readline
mod=10**9+7
n,m=map(int,input().split())
A=set()
for i in range(m):
  A.add(int(input()))
S=[0]*(n+1)
S[0]=1
if 1 not in A:
  S[1]=1
for i in range(2,n+1):
  if i in A:
    S[i]=0
  else:
    S[i]=(S[i-1]+S[i-2])%mod
print(S[n]%mod)


Measured memory_bytes: 11884
n = int(input())
res = n
for i in range(n+1):
    cnt = 0
    tmp = i
    while tmp > 0:
        t = 0
        while 6**t <= tmp:
            t += 1
        tmp -= 6**(t-1)
        cnt += 1
    tmp = n-i
    while tmp > 0:
        t = 0
        while 9**t <= tmp:
            t += 1
        tmp -= 9**(t-1)
        cnt += 1
    res = min(res, cnt)
print(res)

Measured memory_bytes: 41452
n = int(input())
a = list(map(int, input().split()))

d = {}

for i in a:
    if not i in d.keys():
        d[i] = 1
        continue
    d[i] += 1

for j in range(1, n+1):
    if not j in d.keys():
        print(0)
    else:
        print(d[j])

Measured memory_bytes: 33532