akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

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

using namespace std;

typedef long long int lli;
typedef pair<int, lli> pil;

int main () {
    int N;
    cin >> N;
    vector<vector<pil>> G(N);
    REP (i, 0, N - 1) {
        int a, b;
        lli c;
        cin >> a >> b >> c;
        a--;
        b--;
        G[a].push_back(make_pair(b, c));
        G[b].push_back(make_pair(a, c));
    }
    int Q, K;
    cin >> Q >> K;
    vector<lli> cost(N, 0LL);
    function<void(int, int)> bfs = [&](int now, int bef) -> void {
        REP (i, 0, G[now].size()) {
            if (G[now][i].first == bef) continue;
            cost[G[now][i].first] = G[now][i].second + cost[now];
            bfs(G[now][i].first, now);
        }
    };
    bfs(K - 1, -1);
    REP (i, 0, Q) {
        int x, y;
        cin >> x >> y;
        cout << cost[x - 1] + cost[y - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 17408
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

ll get_i(ll a, ll b, ll mx) {
  mx -= a;
  if (mx < 0) return -1;
  return mx / b;
}

ll pm(ll x, ll i, ll m) {
  if (i == 0) return 1;
  if ((i%2) == 1) return (x*pm(x,i-1,m)) % m;
  ll h = pm(x,i/2,m);
  return (h*h) % m;
}

using Mat = vector<vector<ll>>;
constexpr int sz = 3;

Mat mul(const Mat& lhs, const Mat& rhs, const ll m) {
  Mat res(sz, vector<ll>(sz, 0));
  REP(i,sz)REP(j,sz)REP(k,sz) {
    res[i][j] += lhs[i][k] * rhs[k][j];
    res[i][j] %= m;
  }
  return res;
}

Mat pow_m(const Mat& lhs, const ll rhs, const ll m) {
  if (rhs == 0) {
    Mat res(sz, vector<ll>(sz, 0));
    REP(i,sz) res[i][i] = 1;
    return res;
  } else if ((rhs % 2) == 1) {
    return mul(pow_m(lhs, rhs-1, m), lhs, m);
  } else {
    const auto h = pow_m(lhs, rhs/2, m);
    return mul(h, h, m);
  }
}

ll solve(ll l, ll d, ll a, ll b, ll m) {
  Mat A(sz, vector<ll>(sz, 0));
  A[0][0] = 1;
  A[0][1] = 1;
  A[1][1] = pm(10, d, m);
  A[1][2] = pm(10, d, m);
  A[2][2] = pm(10, d, m);
  Mat Al = pow_m(A, l, m);
  vector<ll> v(sz, 0);
  v[1] = a;
  v[2] = b;
  ll r = Al[0][0] * 0 + Al[0][1] * a + Al[0][2] * b;
  return r % m;
}

int main()
{
  ll l,a,b,m;
  cin>>l>>a>>b>>m;
  vector<ll> v;
  ll p = 1;
  REP(i,19) {
    v.push_back(min(l-1, get_i(a, b, p - 1)));
    p *= 10;
  }
  a %= m;
  b %= m;
  vector<ll> df(18);
  REP(i,18) {
    ll diff = v[i+1] - v[i];  
    df[i] = diff;
  }
  ll mul = 1;
  ll sum = 0;
  for(int i=17; i>=0; --i) {
    ll a2 = a + b * ((m + v[i+1]) % m);
    a2 %= m;
    sum += solve(df[i], i+1, a2, (m - b) % m, m) * mul;
    sum %= m;
    ll tmp = pm(10, df[i], m);
    mul *= pm(tmp, i+1, m);
    mul %= m;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

H,W = map(int, input().split())
HW = []
for i in range(H):
    instr = input()
    if instr.find('#') != -1:
        HW.append(list(instr))
    else:
        H -= 1

# 行列の入れ替え
HW2 = []
for x in zip(*HW):
    HW2.append(x)

HW3 = []
for i in range(W):
    instr = ''.join(HW2[i])
    if instr.find('#') != -1:
        HW3.append(HW2[i])

# もう1回入れ替えて戻す
HW4 = []
for x in zip(*HW3):
    HW4.append(x)

for i in range(H):
    print(''.join(HW4[i]))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
const int maxn=100000+10;

struct node{
    int l,r;
};

int m,n;
node a[maxn];
int kq;

int main(){
    cin>>n>>m;
    for(int i=1;i<=m;i++) cin>>a[i].l>>a[i].r;
    int L=0;for(int i=1;i<=m;i++) L=max(L,a[i].l);
    int R=n+1;for(int i=1;i<=m;i++) R=min(R,a[i].r);
    kq=max(0,R-L+1);
    cout<<kq;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long int
#define endl "\n"
#define pb push_back
#define arrinp(v) for(auto &i:v) cin>>i;
#define arrout(v) for(auto &i:v) cout<<i<<" ";
#define newline cout<<endl;
using namespace std;
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t=1;
    // cin >> t;
    while (t--) {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int m=max(a*c,a*d);
        int n=max(b*c,b*d);
        cout<<max(m,n)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3604
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val MAX = Math.pow(10, 5).toInt
    val Q = sc.nextInt()
    val L, R = new Array[Int](Q)
    (0 until Q) foreach { i =>
      val l, r = sc.nextInt()
      L(i) = l
      R(i) = r
    }

    def eratosthenes(n: Int): Seq[Int] = {
      val upper = Math.sqrt(n)
      def loop(lst: List[Int], used: List[Int]): List[Int] =
        if (lst.head < upper) {
          loop(lst.tail.filter(_ % lst.head != 0), lst.head :: used)
        } else used.reverse ++ lst
      loop((2 to n).toList, Nil)
    }

    val isPrime = new Array[Boolean](MAX + 1)
    eratosthenes(MAX).foreach { prime =>
      isPrime(prime) = true
    }

    val dp = new Array[Int](MAX + 1)
    (1 to MAX) foreach { n =>
      dp(n) = if (isPrime(n) && isPrime((n + 1) / 2)) dp(n - 1) + 1 else dp(n - 1)
    }

    val r = (0 until Q).map { i =>
      dp(R(i)) - dp(L(i) - 1)
    }. mkString("\n")

    println(r)
  }

}

Measured memory_bytes: 79492
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793




int main(){
    string s;
    cin >> s;
    if(s.size()==3){
        swap(s.at(0),s.at(2));
    }
    cout << s << endl;
}



    
   


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<string>
#include <math.h>
using namespace std;
string j(int a[3])
{

 if(pow(a[2],2)==pow(a[1],2)+pow(a[0],2))
		return "YES";
	else
		return "NO";
}
int main()
{
	int n;
	cin>>n;
	int a[n][3];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
		cin>>a[i][j];
	}
	for(int i=0;i<n;i++)
	{
		sort(a[i],a[i]+3);
    
	     cout<<j(a[i])<<endl;
	}
	return 0;
}

Measured memory_bytes: 3032
import java.util.*;
import java.io.*;
import java.math.*;
class Main{
	static int mod1 = (int)1e9+7;
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static void main(String sp[])throws IOException{
		FastReader sc = new FastReader();	
		int n = sc.nextInt();
		String s1 = sc.next();
		String s2 = sc.next();
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<n;i++){
			sb.append(s1.charAt(i)+""+s2.charAt(i));
		}
		System.out.println(sb.toString());

    }
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 998244353
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 55
#define M 1200010
using namespace std;
ll n,m,cons[N],mask,dp[N][M];
bool fd;
vector<pair<ll,ll> > vt[N];
void dfs(ll x,ll des,ll lst)
{
	ll i;
	if(x==des)
	{
		fd=true;
		return;
	}
	for(i=0;i<vt[x].size();i++)
	{
		if(vt[x][i].F!=lst)
		{
			dfs(vt[x][i].F,des,x);
			if(fd)
			{
				mask|=((ll)1<<vt[x][i].S);
				return;
			}
		}
	}
	return;
}
int main(){
	ll i,j,x,y;
	cin>>n;
	for(i=0;i+1<n;i++)
	{
		cin>>x>>y;
		x--;
		y--;
		vt[x].push_back(make_pair(y,i));
		vt[y].push_back(make_pair(x,i));
	}
	memset(cons,0,sizeof(cons));
	cin>>m;
	for(i=0;i<m;i++)
	{
		cin>>x>>y;
		x--;
		y--;
		fd=false;
		mask=0;
		dfs(x,y,-1);
		for(j=0;j+1<n;j++)
		{
			if(mask&((ll)1<<j))
			{
				cons[j]|=((ll)1<<i);
			}
		}
	}
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for(i=0;i+1<n;i++)
	{
		for(j=0;j<(1<<m);j++)
		{
			dp[i+1][j]+=dp[i][j];//white
			dp[i+1][(j|cons[i])]+=dp[i][j];//black
		}
	}
	cout<<dp[n-1][(1<<m)-1]<<endl;
	return 0;
}

Measured memory_bytes: 519300
#include<stdio.h>
#include<math.h>
int main(){
    int a,b,x;
    scanf("%d%d%d",&a,&b,&x);
    int c=a*a*b,m=a*a*a;
    double d=c/2,e,f;
    if(d>=x){
        e=a*b*b/2;
        e/=x;
        printf("%f\n",180*atan(e)/(atan(1.0)*4));
    }
    else{
        f=2*(c-x);
        f/=m;
        printf("%f\n",180*atan(f)/(atan(1.0)*4));
    }
    return 0;
}

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

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

   if(s == "ABC")
    cout << "ARC" << endl;
   else if(s == "ARC")
    cout << "ABC" << endl;
    
}

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int len=s.size();
	for(int i=0;i<len;i++)
	{
		if(s[i]==',')
		cout<<" ";
		else
		cout<<s[i];
	}
	return 0;
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
        n: usize,
        m: usize,
        ab: [(usize,usize);m]
    }
    let mut g = vec![vec![];n+1];
    for (a,b) in ab {
        g[a].push(b);
        g[b].push(a);
    }
    let mut d = vec![0;n+1];
    d[0]=1;
    let mut q = std::collections::VecDeque::new();
    q.push_back((1,1));
    while let Some((v,p))=q.pop_front() {
        if d[v]!=0 {continue;}
        d[v]=p;
        for &u in &g[v] { if d[u]==0 {
            q.push_back((u,v));
        }}
    }
    if d.iter().any(|&x|x==0) {
        println!("No");
    }
    else {
        println!("Yes");
        for v in &d[2..] {
            println!("{}",v);
        }
    }
}

Measured memory_bytes: 16040
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include<algorithm> 
#include <cassert>
#include <string>
//#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 9, M = 1e7, OO = 0x3f3f3f3f, eps = 0.001;
#define IO() assert(freopen("in.in", "rt", stdin)), assert(freopen("out.out", "wt", stdout))
#define ll long long int
#define FastIO() ios::sync_with_stdio(false), cin.tie(0);
void printar(int arr[], int n){
    for(int i = 0; i < n; i++)
    {
        cout << arr[i] << " ";
    }
    cout << endl;
}
// template <typename... T>
// void debug(T &... args)
// {
//     ((cerr << args << " "), ...);
//     cerr << endl;
// } 
// struct COMPARE { 
//   bool operator()(pair<string,ll> const& P1, pair<string,ll> const& P2) 
//     { 
        
//         return P1.first < P2.second;
//     }  
// };
// priority_queue<pair<string,ll>,vector<pair<string,ll>>,COMPARE >pq;
int s(int n){
    int x;
    int x1 = 0, x2 = 0, x3 = 0;
    while(n)
    {
        x = n % 10;
        n /= 10;
        if(!(x == 3 || x == 4 || x ==  7)){
            return 0;
        }
        if(x == 3) x1++;
        if(x == 4) x2++;
        if(x == 7) x3++;
    }
    if(x1 && x2 && x3) return 1;
}

int ss(char c1, char c2, char c3){
    int x = 0;
    x += c1 - '0';
    x *= 10;
    x += c2 - '0';
    x *= 10;
    x += c3 - '0';
    return abs(x - 753);
}
int main()
{     
    // icpctraining
    // IO();
    FastIO();
    string s; cin >> s;
    int j = 1, k = 2;
    int cnt = 999999;
    for(int i = 0; i < s.size() - 2; i++)
    {
        cnt = min(cnt, ss(s[i], s[j], s[k]));
        j++;
        k++;
    }
    cout << cnt;
    return 0;
    
}

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

using namespace std;

int main()
{
    string s;
    int n;
    cin >> n >> s;
    for (int i = 0; i < s.size(); ++i) {
        s[i] = (s[i] + n - 'A') % ('Z' - 'A' + 1) + 'A';
    }
    cout << s << '\n';
    return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
const ll MOD = 1000000007;

const int MAX = 1000005;
ll modFact[MAX];
ll modInv[MAX];
ll modFactInv[MAX];

// calc nCr % mod
ll comb(int n, int r) {
  return modFact[n] * (modFactInv[r] * modFactInv[n - r] % MOD) % MOD;
}

int main() {
  modFact[0] = modFact[1] = 1;
  modFactInv[0] = modFactInv[1] = 1;
  modInv[1] = 1;
  REP(i, 2, MAX) {
    modFact[i] = modFact[i - 1] * i % MOD;
    modInv[i] = MOD - modInv[MOD % i] * (MOD / i) % MOD;
    modFactInv[i] = modFactInv[i - 1] * modInv[i] % MOD;
  }

  ll x, y;
  cin >> x >> y;

  int n = 0;
  int r = 0;
  while (x > 0 && y > 0) {
    if (x <= y) {
      x -= 1;
      y -= 2;
      r++;
    } else {
      x -= 2;
      y -= 1;
    }
    n++;
  }

  if (x == 0 && y == 0) {
    cout << comb(n, r) << endl;
  } else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 23808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SIZE(x) ((ll)(x).size()) 
#define MAX(x) *max_element(ALL(x)) 
#define MIN(x) *min_element(ALL(x)) 
#define ALL(x) (x).begin(),(x).end() 

#define inf 1000000000000 
#define mod 1000000007 
#define MAXR 100000 

#define PB push_back 
#define MP make_pair 
#define F first 
#define S second 

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
    // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
bool is_prime(ll n){ //O(√n)
    int a = sqrt(n);
    if(n == 1 || n == 2 || n == 3) return true;
    else if(n % 2== 0) return false;
    else{
        bool frag = true;
        for(int i=3;i<a+1;i+=2){
            if(n % i == 0) frag = false;
        }
        return frag;
    }
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int q, l, r;
    cin >> q;
    vector<bool> pr(100001);
    vector<int> a(100001);
    FOR(i, 1, 100002) pr[i] = is_prime(i+1);
    a[0] = 0;
    a[1] = 0;
    FOR(i, 3, 100002){
        if(is_prime(i) && is_prime((i+1)/2) && (i % 2 == 1)) a[i] = a[i-1] + 1;
        else a[i] = a[i-1];
    }
    REP(i, q){
        cin >> l >> r;
        cout << a[r] - a[l-1] << endl;
    }
}

Measured memory_bytes: 3712
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Comparator;
import java.util.NoSuchElementException;


public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] A = sc.nextIntList(N);
		
		int[][] B = new int[N][2];
		for (int i = 0; i < N; i ++ ) {
			B[i][0] = i;
			B[i][1] = A[i];
		}
		Arrays.sort(B, new Comparator<int[]>() {

			@Override
			public int compare(int[] o1, int[] o2) {

				return o1[1] - o2[1];
			}
			
		});

		int count = 0;
		for (int i = 0; i < N; i ++) {
			if ((B[i][0] + i) % 2 == 1) {
				count ++;
			}
		}
		System.out.println(count / 2);
	}
}



class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 14340
#include <stdio.h>
void print_edge(int w) //端を描く関数
{
    for (int i = 0; i < w; i++)
    {
        printf("#");
    }
    printf("\n");
}
void print_middle(int h, int w) //中間を描く関数
{
    for (int i = 0; i < h - 2; i++)
    {
        printf("#");
        for (int j = 0; j < w - 2; j++)
        {
            printf(".");
        }
        puts("#");
    }
}
int main(void)
{
    int h, w;

    while (1)
    {
        scanf("%d %d", &h, &w);
        if (h == 0 && w == 0)
        {
            break;
        }

        print_edge(w);
        print_middle(h, w);
        print_edge(w);
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2608
#include<stdio.h>
int main(void){
	int a,b,c,t;
	scanf("%d %d %d",&a,&b,&c);
	if(b<a){
		t=a;
		a=b;
		b=t;
	}
	if(c<b){
		t=b;
		b=c;
		c=t;
	}
	if(b<a){
		t=a;
		a=b;
		b=t;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
typedef pair<ll,ll> l_l;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back


ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll n;cin>>n;
    double ans=0;
    double i;
    for(i=0;i<100000;i=i+1){
        if(i*1.08>=n && i*1.08<n+1){
            ans=i;
            break;
        }
    }
    if(i<60000){
        cout<<ans<<endl;
    }else{
        cout<<":("<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	      Scanner scan = new Scanner(System.in);
	      int k = scan.nextInt();
	      String s = scan.next();
	      if(s.length()<=k) {
	    	  System.out.println(s);
	      }else {
	    	  String a = s.substring(0,k);
	    	  System.out.println(a+"...");
	      }
	}
}


Measured memory_bytes: 38416
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <tuple>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; --i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int a[21];
int b;
int c[21];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;

  REP(i, n) {
    cin >> a[i];
  }

  int ans = 0;
  REP(i, n) {
    cin >> b;
    ans += b;
  }

  fill(c, c + n + 1, 0);
  REP(i, n - 1) {
    cin >> c[i];
  }

  int x = a[0];
  FOR(i, 1, n) {
    if(x + 1 == a[i]) {
      ans += c[x - 1];
    }
    x = a[i];
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ll n, all_xor;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) {
    cin >> a[i];
    if (i == 0)
      all_xor = a[i];
    else
      all_xor ^= a[i];
  }
  REP(i, n) { cout << (all_xor ^ a[i]) << "\n"; }
  return 0;
}


Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define str string
#define pb push_back
#define vc vector
#define ci cin
#define co cout
ll vis[1000010];
// remove fropen in online judge
int main()
{ 
     #ifndef ONLINE_JUDGE 
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
     freopen("error.txt","w",stderr);
    #endif 

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    memset(vis,0,sizeof(vis));
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        vis[a[i]]++;
    }ll ct=0;
    for(int j=0;j<n;j++)
    {  ll p=a[j];
        ll f=0;
           for (int i=1; i<=sqrt(a[j]); i++) 
    { 
        if (p%i == 0) 
        { 
            // If divisors are equal, print only one 
           if (p/i == i) 
                {
                	if(i==a[j]&&vis[i]>1)
                	{
                		f=1;
                		break;
                	}
                	else if(i!=a[j]&&vis[i]>0)
                	{
                		f=1;
                		break;
                	}
                }
  
            else // Otherwise print both 
                {
                	if(i==a[j]&&vis[i]>1)
                	{
                		f=1;
                		break;
                	}
                	else if(i!=a[j]&&vis[i]>0)
                	{
                		f=1;
                		break;
                	}
                    if(p/i==a[j]&&vis[p/i]>1)
                	{
                		f=1;
                		break;
                	}
                	else if(p/i!=a[j]&&vis[p/i]>0)
                	{
                		f=1;
                		break;
                	}
                }
        } 
    } 
    if(f==0)
    {
    //	cout<<a[j]<<" ";
    ct++;}
    }
    cout<<ct;

    
}


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

const ll M = 998244353;

vector<ll> fac(300001);
vector<ll> ifac(300001);

ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

long myPow(long x, long n, long m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int main(){
  fac[0] = 1;
  ifac[0] = 1;
  for(ll i = 0; i<300000; i++){
    fac[i+1] = fac[i]*(i+1) % M; 
    ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; 
  }
  ll n, m, k;
  cin >> n >> m >> k;
  ll sum = 0;
  for(int i=0; i<=k; i++){
    ll ans=0;
  	ans = comb(n-1, i)%M;
    ans *= m;
    ans %= M;
    ans *= myPow(m-1, n-1-i, M);
    ans %= M;
    sum += ans;
    sum %= M;
  }
  cout << sum << endl;
  return 0;
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A=LI()
    from collections import defaultdict
    dd = defaultdict(int)
    
    for i in range(N):
        dd[A[i]]+=1
        
    eat=0
    for k,v in dd.items():
        if v!=1:
            eat+=v-1
    if eat%2==1:
        eat+=1        
    
    print(N-eat)

main()


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

int main() {
    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;
    if (S == U)
    A--;
    else
    B--;
    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int N, M, L, f, lx, ly, x, y, i;
char A[51][51], B[51][51];
int main(void){
	scanf("%d %d\n", &N, &M);
	for(i=0; i<N; i++){
		scanf("%s\n", A[i]);
	}
	for(i=0; i<M; i++){
		scanf("%s\n", B[i]);
	}
	L=N-M+1;
	for(lx=0; lx<L; lx++){
		for(ly=0; ly<L; ly++){
			f=1;
			for(y=0; y<M; y++){
				for(x=0; x<M; x++){
					if(A[ly+y][lx+x]!=B[y][x]){f=0; break;}
				}
				if(!f){break;}
			}
			if(f){
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
    long long a,b,n;
    cin>>a>>b>>n;
    if(b>n)
    {
        cout<<((a*n)/b)<<endl;
    }
    else
    {
        cout<<((a*(b-1))/b)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define int long long
#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++)
using namespace std;;

int cnt = 0; //比較回数のカウンター

void MergeSort(vector<int> &A, int l, int m, int r) {
    
    //要素数
    int n1 = m - l + 1; //左側
    int n2 = r - m; //右側
    //格納用vectorの宣言→格納
    vector<int> L(n1);
    vector<int> R(n2);
    rep(i, n1) L[i] = A[l + i];
    rep(i,n2) R[i] = A[m + 1 + i];

    //indexの宣言(i : L, j : R, k : A)
    int i = 0, j = 0, k = l;
    //比較しながらAに再度格納
    //L,R両方に要素が残っている場合
    while (i < n1 && j < n2) {
        if (L[i] <= R[j]) {
            A[k] = L[i];
            i++;
        }
        else {
            A[k] = R[j];
            j++;
        } 
        k++;
        cnt++; //while内部の比較回数をカウント
    }
    //この時点でL,R両方に要素が残っていることはない

    //Lに要素が残っている場合
    while (i < n1) {
        A[k] = L[i];
        i++;
        k++;
        cnt++; //？？？
    }
    //Rに要素が残っている場合
    while (j < n2) {
        A[k] = R[j];
        j++;
        k++;
        cnt++; //？？？
    }
}

void Marge(vector<int> &A, int l, int r) {
    // l == r のときに再帰ストップ
    if (l < r) {
        int m = (l + r)/ 2;
        Marge(A, l, m);
        Marge(A, m + 1, r);
        MergeSort(A, l, m, r);
    }
}

signed main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    vector<int> vec(n);
    rep(i,n) cin >> vec[i];
    //マージソート
    Marge(vec, 0, n - 1);
    //ソート済のvecの出力
    cout << vec[0];
    rep2(i, 1, n) {
        cout << " " << vec[i];
    }
    //比較回数の出力
    cout << endl << cnt << endl;
    return 0;
}


Measured memory_bytes: 10568
package main

import (
	"fmt"
	"os"
)

func printArray(array []int) {
	n := len(array)
	for i := 0; i < n; i++ {
		fmt.Printf("%d", array[i])
		if i < n-1 {
			fmt.Printf(" ")
		}
	}
	fmt.Printf("\n")
}

func insertionSort(array []int) {
	printArray(array)

	n := len(array)
	// 長さ1のときは何もせずに終了
	// 2つ以上の長さを持つときに実行
	for i := 1; i < n; i++ {
		// i番目の要素
		a_i := array[i]
		j := i - 1

		// 0〜iの間で、
		for j >= 0 && array[j] > a_i {
			array[j+1] = array[j]
			j--
		}
		array[j+1] = a_i

		printArray(array)
	}
}

func main() {
	var n int

	if _, err := fmt.Scan(&n); err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	}

	array := make([]int, n)
	for i := 0; i < n; i++ {
		if _, err := fmt.Scan(&array[i]); err != nil {
			fmt.Printf("%s\n", err)
			os.Exit(1)
		}
	}

	insertionSort(array)
}



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

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

  for (int i = 0; i < n; i++) {
    char a;
    cin >> a;
    if (i+1 == k) {
      cout << char(a + 0x20);
    } else {
      cout << a;
    }
  }
  cout << "\n";

  return 0;
}


Measured memory_bytes: 256
def get_prime_list(n)
  sn = (n**(0.5)).to_i
  is_prime = [false, false] + [true]*(n-1)

  (2..sn).each do |i|
    next if !is_prime[i]
    (i*i).step(n, i) do |j|
      is_prime[j] = false
    end
  end
  co = 0
  return (0..n).map do |i|
    co += 1 if is_prime[i]
    co
  end
end
list = get_prime_list(999999)

while gets do
  max = $_.to_i
  puts list[max]
end

Measured memory_bytes: 29468
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N;
  cin >> N;
  vector<ll> A(N), B(N);
  vector<P> BA(N);
  REP(i, N) {
    cin >> A[i] >> B[i];
    BA[i].first = B[i];
    BA[i].second = A[i];
  }
  sort(ALL(BA));
  ll t = 0;
  bool ok = true;
  REP(i, N) {
    t += BA[i].second;
    if (BA[i].first < t) ok = false;
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}

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

int main(){
	int n,m,num[8];
	bool edge[8][8] = {};
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		int a,b;
		cin >> a >> b; a--; b--;
		edge[a][b] = true;
		edge[b][a] = true;
	}
	for(int i = 0;i < n;i++) num[i] = i;
	int res = 0;
	do{
		bool flag = true;
		for(int i = 0;i < n - 1;i++){
			if(!edge[num[i]][num[i + 1]]) flag = false;
		}
		if(flag) res++;
	}while(next_permutation(num + 1,num + n));
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
using System;


    class MainClass
    {
    public static void Main(string[] args)
    {

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


        //long sum = (1 + N) * N / 2;

        //int a = N / 3;

        //long b = 3 * (1 + a) * a / 2;

        //int c = N / 5;

        //long d = 5 * (1 + c) * c / 2;

        //int e = N / 15;

        //long f = 15 * (1 + e) * e / 2;


        //sum = sum - b - d + f;

        long sum = 0;


        for(int i = 1; i <= N; i++)
        {
            if (i % 3 != 0)
            {
                if (i % 5 != 0)
                {
                    sum += i;
                }
            }

        }



        Console.WriteLine(sum);


    }
}


Measured memory_bytes: 27536
#include<stdio.h>
#include<stdlib.h>
int main(){
	int N,i,s[100],sum=0,j,k =111,temp;
	scanf("%d",&N);
	
	for(i = 0;i<N;i++){
		scanf("%d",&s[i]);
		sum+=s[i];
	}
	for (i = 0; i < (N - 1); i++) {
    for (j = (N - 1); j > i; j--) {
      if (s[j-1] > s[j]) {
        temp = s[j-1];
        s[j-1] = s[j];
        s[j] = temp;
      }
    }
  }
	for(i = 0;i<N;i++){
		if(s[i] != 0 && s[i] <10 && k==111){
			
			k=i;
		}else
		if(s[i] % 10 != 0 && k==111){
			k=i;
		}
	}
	if(sum % 10 != 0){
		printf("%d\n",sum);
	}else if(k!=111){
		printf("%d\n",sum-s[k]);
	}else{
		printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000000



int main(){
	
	long long A;
	cin>>A;
	
	double B;
	cin>>B;
	
	B*=100;
	long long b = round(B);
	
	A *= b;
	cout<<A/100<<endl;
	
	return 0;
}

Measured memory_bytes: 3776
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    string s;
    char pad = 'a' - 1;
    cin >> s;
    s += pad;
    for (char c = 'z'; c >= 'a'; --c) if (s.find(c) == string::npos) s += c;
    if (next_permutation(s.begin(), s.end())) {
        s.erase(s.begin() + s.find(pad), s.end());
        cout << s << endl;
    } else cout << -1 << endl;
    return 0;
}


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

using namespace std;

const int N = 200005;

int n, tab[N], res[N];

int main() {
    
    scanf("%d", &n);
    
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &tab[i]);
        res[tab[i]] = res[tab[i] - 1] + 1;
        ans = max(ans, res[tab[i]]);
    }
    
    printf("%d\n", n - ans);
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

ll modpow(ll a,ll n,ll mod){
  if(n == 0) return 1LL;
  if(n % 2 == 0){
    ll d = modpow(a,n/2,mod) % mod;
    return (d*d) % mod;
  }
  return (a % mod) * (modpow(a,n-1,mod) % mod) % mod;
}

int main(){
  ll n; cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  ll sum = 0;
  ll times = 0;
  while(times < 65){
    ll cnt1 = 0,cnt0 = 0;
    ll b_sum = 0;
    for(int i = 0; i < n; i++){
      if(a[i] % 2 == 1) cnt1++;
      a[i]/=2;
    }
    cnt0 = n-cnt1;
    b_sum = cnt0*cnt1%MOD;
    ll res = modpow(2,times,MOD)*b_sum;
    sum += res%MOD;
    sum %= MOD;
    times++;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 5520
function main(input) {
  const inputs = input.split('\n');
  const counts = inputs[0].split(' ').map( x => parseInt(x, 10) );
 
  const n = counts[0];
  const k = counts[1];
 
  const input_numbers = inputs[1].split('').map( x => parseInt(x, 10) );
 
if(n==1){
  console.log(1);
  return;
}
 
  var compressed_numbers = [];
  if(input_numbers[0]==0){compressed_numbers=[0];}
 
  var pre_count = 1;
  var pre_number=input_numbers[0];
 
  pre_numbers = [input_numbers[0]];
  for(var  i=1 ; i<n ; i=i+1){
    if(pre_number!=input_numbers[i]){
      compressed_numbers.push(pre_count);
      pre_count = 1;
      pre_number = input_numbers[i]
    }else{
      pre_count = pre_count+1;
    }
  }
  compressed_numbers.push(pre_count);
 
  var accumulation_sum_array = [0];
  for(var i=0;i<compressed_numbers.length;i++){
    accumulation_sum_array[i+1] = accumulation_sum_array[i] + compressed_numbers[i]
  }
 
//console.log(compressed_numbers);
//console.log(accumulation_sum_array);
 
  var answer=0;
  var sub_array=[];
  const a_a_length = accumulation_sum_array.length;
  const fetch_count = k*2+1;
  for(var  i=0 ; i<compressed_numbers.length ; i+=2){
    // k * 2 + 1 要素をとってくる
    if( i+fetch_count > a_a_length-1 ){
      answer = Math.max(accumulation_sum_array[a_a_length-1] - accumulation_sum_array[i], answer)
    } else {
      answer = Math.max(accumulation_sum_array[i+fetch_count] - accumulation_sum_array[i], answer)
    }
  }
 
  console.log(answer);
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main()
{
	int N;
	cin>>N;
  	vector<int> vec(N);
  	vector<int> dp(N,0);
  	for(int i=0;i<N;i++)
    {
      	cin>>vec[i];
    }
  	for(int i=1;i<N;i++)
    {
      dp[i]=min(dp[i-1]+abs(vec[i-1]-vec[i]),i>1?dp[i-2]+abs(vec[i-2]-vec[i]):INT_MAX);
    }
    cout<<dp[N-1]<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
  int pt[100000];
  int i,n,k,q,a;
  scanf("%d%d%d", &n, &k, &q);
  for(i=0;i<n;i++) pt[i]=k-q;
  for(i=0;i<q;i++){
    scanf("%d",&a);
    pt[a-1]+=1;
  }
  for(i=0;i<n;i++){
    if(pt[i]>0) printf("Yes\n");
    else printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
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 int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    int ans = 0;
    vector<int> A(n);
    rep(i, n) {
        cin >> A[i];
    }
    rep(i, n) {
        rep(j, i) {
            ans += A[i] * A[j];
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3656
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MAX = 10**18
MIN = -10**18
MOD = 998244353


def judge(li):
    c = int(s[0])
    for i in range(len(li)):
        if li[i] == "-":
            c -= int(s[i+1])
        else:
            c += int(s[i+1])
    return c
s = input()

n = len(s)-1
for i in range(2**n):
    li = ["+"]*n
    for j in range(n):
        if (i>>j)&1:
            li[n-j-1] = "-"
    if judge(li) == 7:
        ans = s[0]
        for i in range(len(li)):
            ans += li[i] + s[i+1]
        print(ans+"=7")
        sys.exit()


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

using namespace std;

const int N = 100010;
int a[N], n, cnt[2];

bool gao() {
  for (int i = 1; i <= n; i++)
    if (a[i] & 1) a[i]--;
  cnt[0] = cnt[1] = 0;
  int gcd = a[1];
  for (int i = 2; i <= n; i++) gcd = __gcd(a[i], gcd);
  for (int i = 1; i <= n; i++) cnt[(a[i] /= gcd) & 1]++;
  if (cnt[0] & 1)
    return 1;
  else if (cnt[1] > 1)
    return 0;
  else {
    for (int i = 1; i <= n; i++)
      if (a[i] == 1) return cnt[0] & 1 ? 1 : 0;
    return gao() ^ 1;
  }
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d", a + i), cnt[a[i] & 1]++;
  if (cnt[0] & 1)
    puts("First");
  else if (cnt[1] > 1)
    puts("Second");
  else {
    for (int i = 1; i <= n; i++)
      if (a[i] == 1) {
        puts(cnt[0] & 1 ? "First" : "Second");
        return 0;
      }
    puts(gao() ^ 1 ? "First" : "Second");
  }
  return 0;
}


Measured memory_bytes: 640
n,m,R = gets.chomp.split(" ").map(&:to_i)
r = gets.chomp.split(" ").map(&:to_i)
dp = Array.new(n){Array.new(n,1000000000)}
m.times do |i|
  a,b,c = gets.chomp.split(" ").map(&:to_i)
  dp[a-1][b-1] = c if dp[a-1][b-1] > c
  dp[b-1][a-1] = c if dp[b-1][a-1] > c
end
n.times do |k|
  n.times do |i|
    n.times do |j|
      dp[i][j] = dp[i][k]+dp[k][j] if dp[i][j] > dp[i][k]+dp[k][j]
    end
  end
end
min = 1000000000
r.permutation(R) do |x|
  d = 0
  (R-1).times do |i|
    d += dp[x[i]-1][x[i+1]-1]
  end
  min = d if min > d
end
puts min

Measured memory_bytes: 14920
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

typedef long long lint;

using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	cout<<(a+b<24?a+b:a+b-24)<<endl;
}

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

ll h;

int main(){

	cin >> h;

	ll res = 0;
	ll base = 1;
	while( h ){
		res += base;
		h >>= 1;
		base *= 2;
	}

	cout << res << endl;

}


Measured memory_bytes: 256
n = int(input())
mod = pow(10, 9)+7
ans1 = 1
ans2 = 1
ans3 = 1
for i in range(n):
    ans1 = (ans1*10)%mod
    ans2 = (ans2*8)%mod
    ans3 = (ans3*9)%mod
print((ans1+ans2-ans3*2)%mod)


Measured memory_bytes: 9160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double p = 0;
		if(n % 2 == 0){
			p = 0.5;
		}else{
			p = (double)(n / 2 + 1) / n;
		}
		System.out.println(p);
	}
}


Measured memory_bytes: 23764
import java.util.*;

public class Main {
    private static final int INF = 1000000000;

    public static void main(String[] args) {
        // read inputs
        Scanner in = new Scanner(System.in);
        String cs = in.next();
        final int N = cs.length();
        // System.out.printf("cs = %s\n", cs);

        // solve dp
        int[][] dpss = new int[N + 1][];
        for (int i = 0; i <= N; i++) {
            dpss[i] = new int[26];
        }
        // initialize
        for (int j = 0; j < 26; j++) {
            dpss[N][j] = 0;
        }
        // solve
        for (int i = N - 1; i >= 0; i--) {
            final char ci = cs.charAt(i);
            int jmin = 0;
            for (int j = 0; j < 26; j++) {
                if (dpss[i + 1][j] < dpss[i + 1][jmin]) {
                    jmin = j;
                }
            }
            for (int j = 0; j < 26; j++) {
                final char cj = (char) ((int) 'a' + j);
                if (ci == cj) {
                    dpss[i][j] = dpss[i + 1][jmin] + 1;
                } else {
                    dpss[i][j] = dpss[i + 1][j];
                }
            }
        }
        StringBuilder builder = new StringBuilder();
        int K = INF;
        char c = 'a';
        for (int j = 0; j < 26; j++) {
            if (dpss[0][j] < K) {
                K = dpss[0][j];
                c = (char) ((int) 'a' + j);
            }
        }
        int i = 0;
        for (int k = 0; k < K; k++) {
            final int j0 = (int) c - 'a';
            while (i < N && cs.charAt(i) != c) {
                i++;
            }
            if (i >= N) {
                break;
            }
            for (int j = 0; j < 26; j++) {
                final char cj = (char) ((int) 'a' + j);
                if (dpss[i][j0] == dpss[i + 1][j] + 1) {
                    builder.append(c);
                    c = cj;
                    break;
                }
            }
            i++;
        }
        builder.append(c);
        System.out.printf("%s\n", builder);
    }
}


Measured memory_bytes: 57132
let () =
  Scanf.scanf "%d" @@ fun n ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  Array.init (n-2) (fun i -> a.(i), a.(i+1), a.(i+2))
  |> Array.fold_left (fun v (x,y,z) -> if (x < y && y < z) || (x > y && y > z) then v+1 else v) 0
  |> Printf.printf "%d\n"



Measured memory_bytes: 384
S = input()
N = len(S)
count = 0
i = 0
last = ""

while i < N:
    if i == 0:
        last = S[i]
        i += 1
        count += 1
    elif i != 0 and last == S[i]:
        if i > N-2:
            break
        last = S[i:i+2]
        i += 2
        count += 1
    elif i != 0 and last != S[i]:
        last = S[i]
        i += 1
        count += 1

if i == N-1 and last != S[N-1]:
    count += 1
print(count)


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

typedef long long ll;

int main(){
    ll a, b, x;
    cin >> a >> b >> x;
    
    ll low, high;
    if(a % x == 0) low = a;
    else           low = (a/x+1ll) * x;
    
    high = (b/x) * x;  

    cout << (high-low)/x + 1ll << endl;

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	vector<int> con;
	
	cin>>N;
	
	con.resize(N);
	
	for(int i = 1; i < N; i++){
		int A;
		
		cin>>A;
		
		A--;
		
		con[A]++;
	}
	
	for(int i = 0; i < N; i++){
		cout<<con[i]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 4780
//
// Created by kuroneko on 2019-07-06.
//

#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>

typedef long long ll;
using namespace std;

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

    int ans = 0, cnt = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            cnt++;
          	if (i == int(s.size()) - 1) ans = max(ans, cnt);
        } else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256