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

int main() {

    int ans = 0;
    string s;
    cin >> s;
    
    for(int i = 0; i < 3; i++){
        if(s[i] == '1'){ 
            ans++;
        }
    }
    
    cout << ans << endl;

}

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> p(m), y(m);
	vector<vector<int>> py(n, vector<int>(0));
	for (int i = 0; i < m; i++) {
		cin >> p[i] >> y[i];
		p[i]--;
		py.at(p[i]).push_back(y[i]);
	}
	for (int i = 0; i < n; i++)
		sort(py.at(i).begin(), py.at(i).end());
	for (int i = 0; i < m; i++) {
		cout.width(6);
		cout.fill('0');
		cout << p[i] + 1;
		cout.width(6);
		cout.fill('0');
		cout << lower_bound(py.at(p[i]).begin(), py.at(p[i]).end(), y[i]) - py.at(p[i]).begin() + 1 << endl;
		}
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define vi vector<int>
#define vl vector<long long>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define vp vector<P>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPD(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORD(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define INF 1e18
#define INFTY 1e9
const int mod = 1e9+7;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

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

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

//cout << fixed << setprecision(10) << y << endl;
struct edge {int to, cost;};
vector< vector<edge> > es;
const int MAX_N = 10010;
vl is_prime;

int erat(ll n) {
    ll N = n;
    is_prime.resize((int)(sqrt(N)+1), 1);
    is_prime[0] = 0;
    is_prime[1] = 0;
    int res = 0;
    FOR(i, 2, (int)(sqrt(N)+1)) {
        if (is_prime[i]) {
            int cnt = 0;
            int pre = 0;
            while (n % i == 0) {
                n /= i;
                cnt += 1;
                if (cnt > pre) {
                    pre = cnt;
                    res += 1;
                    cnt = 0;
                }
            }
            for (int j = i*2; j < sqrt(N)+1; j += i) {
                is_prime[j] = 0;
            }
        }
    }
    if (N == 1) res = 0;
    else if (n == N) res = 1;
    else if (n > (int)sqrt(N)) res += 1;
    return res;
}

int main() {
    ll n;
    cin >> n;
    int res = erat(n);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 11116
#include <stdio.h>
int main(void){
	int a,b,c,check=0;
	scanf("%d%d%d",&a,&b,&c);
	if((a+b==c)||(b+c==a)||(c+a==b)){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}	

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

struct UnionFind
{
	vector<int> par;
	UnionFind(int n){
		FOR(i,0,n)par.pb(i);
	}
	int root(int x){
		if(par[x] == x)return x;
		return par[x] = root(par[x]);
	}
	void unite(int x, int y){
		x = root(x);
		y = root(y);
		if(x == y)return;
		par[x] = y;
	}
	bool same(int x, int y){
		return root(x) == root(y);
	}
};

int main()
{
	int n,k,l;
	cin >> n >> k >> l;
	UnionFind road(n);
	FOR(i,0,k){
		int p,q;
		cin >> p >> q;
		road.unite(p-1,q-1);
	}
	UnionFind railway(n);
	FOR(i,0,l){
		int r,s;
		cin >> r >> s;
		railway.unite(r-1,s-1);
	}
	map<pii,int> ans;
	FOR(i,0,n){
		ans[mp(road.root(i), railway.root(i))]++;
	}
	FOR(i,0,n){
		cout << ans[mp(road.root(i), railway.root(i))];
		if(i != n-1)cout << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 13556
#include <stdio.h>

int main(void){

	int a, b, c, d;
	int n, i;

	while(scanf("%d",&n) != EOF){
		i=0;
		for(a=0; a<=9; a++)
			for(b=0; b<=9; b++)
				for(c=0; c<=9; c++)
					for(d=0; d<=9; d++)
						if(a+b+c+d == n)
							i++;
		printf("%d\n",i);
	}
	return 0;
}

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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

const int N = 100005;
int n , ara[N], pos[N];
int main()
{
    cin >> n;
    for(int i = 1;i <= n;i++)cin >> ara[i] , pos[ara[i]] = i;

    set<int>st;
    st.insert(0);
    st.insert(n + 1);
    LL ans = 0;
    for(int i = n;i >= 1;i--){
        auto rt = st.lower_bound(pos[i]);
        auto lt = rt;lt--;
        if(rt != --st.end()){
            int r1 = *rt;
            int r2 = *(++rt);
            LL R = abs(r2 - r1) ;
            LL L = abs(pos[i] - *lt) ;
            ans = ans + (L * R * i);
            --rt;
        }
        if(lt != st.begin()){
            int l2 = *lt;
            int l1 = *(--lt);
            LL L = abs(l1 - l2) ;
            LL R = abs(pos[i] - *rt);
            ans = ans + (L * R * i);
        }
        st.insert(pos[i]);
    }
    cout << ans << "\n";

}



Measured memory_bytes: 5760
import heapq

N, M = map(int,input().split())
A = list(map(int,input().split()))
q = []

for aa in A:
    heapq.heappush(q,-aa)

for _ in range(M):
    x = heapq.heappop(q)
    heapq.heappush(q,x/2)

print(sum(-int(x) for x in q))


Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

int main() {
	const int a[] = { 1, 5, 10, 50, 100, 500 };
	int b = 1000;
	for ( int i = 0; i < 6; i++ ) {
		int c;
		scanf( "%d", &c );
		b = max( 0, b - c * a[ i ] );
	}
	printf( "%d\n", !b );
	return 0;
}

Measured memory_bytes: 1188
import java.util.*;
class Main{
    static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int N = sc.nextInt();
        int M = sc.nextInt();
        int A=0;
        for(int i=0;i<M;i++){
        A=A+ sc.nextInt();
        }
        if((N-A)>=0)
        System.out.println(N-A);
        else
        System.out.println(-1);
    }
}

Measured memory_bytes: 46476
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;

namespace IO {
  static const int SZ = 1 << 20;
  static FILE *fin = stdin, *fout = stdout;
  static char ibuf[SZ], *is = ibuf, *it = ibuf;
  static char obuf[SZ], *os = obuf, *ot = obuf + SZ;

  inline char nextChar() {
    if (is == it) {
      it = (is = ibuf) + fread(ibuf, sizeof(char), SZ, fin);
      if (is == it)
        return EOF;
    }
    return *is++;
  }
  template <typename T>
  inline void readInt(T &x) {
    x = 0;
    T flag(1);
    char ch;
    for (ch = nextChar(); isspace(ch); ch = nextChar())
      ;
    if (ch == '-')
      ch = nextChar(), flag = -flag;
    for (; isdigit(ch); ch = nextChar())
      x = x * 10 + ch - '0';
    x *= flag;
  }
  inline void readCh(char &now) {
    for (now = nextChar(); isspace(now); now = nextChar())
      ;
  }

  inline void flushBuffer() {
    fwrite(obuf, sizeof(char), os - obuf, fout);
    os = obuf;
  }
  inline void printChar(char ch) {
    if (os == ot)
      flushBuffer();
    *os++ = ch;
  }
  template <typename T>
  inline void printInt(T x) {
    static int dig[20], cnt;
    if (os + 20 > ot)
      flushBuffer();
    if (x < 0)
      *os++ = '-', x = -x;
    cnt = 0;
    do {
      dig[++cnt] = x % 10;
      x /= 10;
    } while (x);
    for (int i = cnt; i > 0; --i)
      *os++ = dig[i] + '0';
  }
}

using namespace IO;

const int N = 55;

int n, m, ecnt;

struct Edge { int u, v; } e[1500];
struct DisjointSet {
  int fa[N];
  inline void makeSet() {
    for (int i = 0; i < N; ++i)
      fa[i] = i; 
  }
  int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
  inline bool same(int x, int y) { return find(x) == find(y); }
  inline void merge(int x, int y) {
    int fx = find(x), fy = find(y);
    if (fx != fy)
      fa[fx] = fy;
  }
} ds;

int main() {
#ifdef LOCAL_DEBUG
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
#endif
  readInt(n), readInt(m);
  for (int i = 1; i <= m; ++i)
    readInt(e[i].u), readInt(e[i].v);
  int ans = 0;
  for (int i = 1; i <= m; ++i) {
    ds.makeSet();
    for (int j = 1; j <= m; ++j) {
      if (i == j)
        continue;
      ds.merge(e[j].u, e[j].v); 
    }
    if (!ds.same(e[i].u, e[i].v))
      ++ans;
  }
  printInt(ans);
  printChar('\n');
  flushBuffer();
  return 0;
}

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

bool isp(int n) {
  if (n < 2) return false;
  else if (n == 2) return true;
  else if (n % 2 == 0) return false;
  for (int i = 3; i <= (int)sqrt(n); i += 2) if (n % i == 0) return false;
  return true;
}

int main() {
  int N;
  cin >> N;
  for (int i = 0, cnt = 0; i <= 55555; i++) {
    if (isp(i) && i % 5 == 1) {
      cout << i << "\n";
      cnt++;
      if (cnt == N) break;
    }
  }
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
int n,m;
struct Edge{
	int v,nxt;
}e[4010];int tot;
int first[2010];
void build(int u,int v)
{
	e[++tot]=(Edge){v,first[u]};
	first[u]=tot;
	return ;
}
queue<pair<int,int> >q;
int col[2010][2010];
int fa[2010][2010];
bool book[2010][2010];
void ins(int u,int v)
{
	if(u==v)return ;
	if(book[u][v])return ;
	q.push(make_pair(u,v));
	book[u][v]=book[v][u]=true;
	return ;
}
//get fa
void dfs(int u,int o,int lst)
{
	fa[o][u]=lst;
	for(int i=first[u];i;i=e[i].nxt)
		if(e[i].v!=lst)dfs(e[i].v,o,u);
	return ;
}
//color
void work(int u,int o,int c)
{
	if(col[o][u]){
		if(u!=c)ins(c,u);
		return ;
	}
	col[o][u]=c;
	for(int i=first[u];i;i=e[i].nxt)
		if(e[i].v!=fa[o][u])work(e[i].v,o,c);
	return ;
}
int cnt=0;
void getnum(int u,int o,int lst)
{
	if(col[o][u]){
		cnt++;
		getnum(u,u,lst);
		return ;
	}
	for(int i=first[u];i;i=e[i].nxt)
		if(e[i].v!=lst)getnum(e[i].v,o,u);
	return ;
}
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d %d",&u,&v);
		build(u,v);
		build(v,u);
	}
	for(int i=1;i<=n;i++)
		dfs(i,i,0);
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d %d",&u,&v);
		ins(u,v);
	}
	while(!q.empty())
	{
		int u=q.front().first;
		int v=q.front().second;
		q.pop();
		if(u==v)continue;
		if(col[u][v])ins(col[u][v],v);
		else if(col[v][u])ins(col[v][u],u);
		else{
			work(v,u,v);
			work(u,v,u);
		}
	}
	for(int i=1;i<=n;i++)
		getnum(i,i,0);
	printf("%d\n",cnt/2);
	return 0;
}

Measured memory_bytes: 35840
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int N, tmp;
  cin >> N;
  vector<int> a(N, 0);

  rep(i, N - 1){
    cin >> tmp;
    a[tmp-1]++;
  }

  rep(i, N){
    cout << a[i] << endl;
  }

}


Measured memory_bytes: 4052
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

typedef vector<int> vertex;
typedef vector<vertex> graph;

ll n, m;
graph g;

void add_edge(int a, int b){
	g[a].push_back(b);
	g[b].push_back(a);
}

int used[100000];

ll cnt(ll u, ll d, bool &tr){
	if(used[u]){
		if(used[u]!=2-d) tr = true;
		return 0;
	}
	used[u] = 2-d;
	ll res = 0;
	if(d==0) res++;
	for(int v: g[u]){
		res += cnt(v, !d, tr);
	}
	return res;
}

int main(){
	cin>>n>>m;
	g = graph(n);
	rep(i, m){
		int a, b;
		cin>>a>>b;
		a--; b--;
		add_edge(a, b);
	}
	bool tr = false;
	ll t = cnt(0, 0, tr);
	if(tr) cout<<n*(n-1)/2-m<<endl;
	else cout<<t*(n-t)-m<<endl;
	return 0;
}


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

typedef long long ll;

int main() {
    ll N, C;
    cin >> N >> C;
    vector<ll> x(N), v(N), s(N + 1, 0), t(N + 1, 0);
    vector<ll> s0(N + 1, 0), s1(N + 1, 0);
    vector<ll> t0(N + 1, 0), t1(N + 1, 0);
    rep(i, N) cin >> x[i] >> v[i];
    rep(i, N) {
        s[i + 1] = s[i] + v[i];
        s0[i + 1] = max(s0[i], s[i + 1] - x[i]);
        s1[i + 1] = max(s1[i], s[i + 1] - 2 * x[i]);
        t[N - 1 - i] = t[N - i] + v[N - 1 - i];
        t0[N - 1 - i] = max(t0[N - i], t[N - 1 - i] - C + x[N - 1 - i]);
        t1[N - 1 - i] = max(t1[N - i], t[N - 1 - i] - 2 * (C - x[N - 1 - i]));
    }
    ll ans = 0;
    rep(i, N + 1) {
        ans = max(ans, s0[i] + t1[i]);
        ans = max(ans, s1[i] + t0[i]);
    }
    cout << ans << endl;
}

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

int main() {
  int N;
  cin >>N;
  vector<int> vec1(N);
  for(int i=0 ;i <N; i++){
    cin >>vec1.at(i);
  }
  int total =0;
  int hozon =0;
  for(int i=0; i<N-1;i++){
    if(vec1.at(i)>=vec1.at(i+1)){
      hozon++;
    }
    else{
      if(total <= hozon){
        total = hozon;
        hozon =0;
      }
      else{
        hozon =0;
      }
    }
  }
  if(total <= hozon){
    total =hozon;
  }
    cout <<total <<endl;    
}
  

Measured memory_bytes: 640
process.stdin.resume();
process.stdin.setEncoding('utf8'); 
var lines = [];
var reader = require('readline').createInterface({
	input: process.stdin,
	output: process.stdout
});
 
reader.on('line', (line) => {
	lines.push(line);
});

reader.on('close', () => {
	"use strict"
	const ABT = lines[0].split(" ").map(Number);
	const A = ABT[0];
	const B = ABT[1];
	const T = ABT[2];
	
	console.log(Math.floor(T/A)*B);
});

Measured memory_bytes: 22204
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
//use proconio::marker::*;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
//use std::cmp::*;
//use std::num;
//use petgraph::unionfind::UnionFind;

fn main() {
    input! {
        N:usize,X:[i32;N]
    }
    let mut ans = 10000000;
    for p in 1..101i32 {
        let mut total = 0;
        for i in 0..N {
            let y = X[i] - p;
            total += y * y;
        }
        //println!("p:{},total:{}", p, total);
        ans = std::cmp::min(ans, total)
    }
    println!("{}", ans);
}


Measured memory_bytes: 2128
#ABC098C
N=int(input())
S=list(str(input()))
W=[0]*N
Turn=[0]*N
for i in range(N):
    if S[i]=="W":
        if i==0:
            W[i]=1
        else:
            W[i] = W[i - 1] + 1
    else:
        if i==0:
            W[i]=0
        else:
            W[i]=W[i-1]
for i in range(N):
    if i==0:
        Turn[i]=0+((N-1-i)-(W[N-1]-W[i]))
    else:
        Turn[i]=W[i-1]+((N-1-i)-(W[N-1]-W[i]))
print(min(Turn))

Measured memory_bytes: 29284
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int a[N];
    long long sum=0;
    int max=0;
    for (int i=0 ;i<N;i++){
        cin >> a[i];
        sum=sum+a[i];
        if(a[i]>=max){max=a[i];
            }
    }
    sum=sum-max;
             if(max<sum){
                 cout << "Yes" << endl;}
                 else {cout << "No" << endl;}
        
         
    
return 0;}

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

int main(void){
    string s[3],str;
    int j = 0;
    cin >> s[0] >> s[1] >> s[2];
    str = s[0];
    while( 1 ){
        if(s[j].empty() != 0){
            cout << (char)(j + 'A') << endl;
            break;
        }
        if(str[0] == 'a'){
            s[j] = s[j].substr(1);
            j = 0;
        } else if(str[0] == 'b'){
            s[j] = s[j].substr(1);
            j = 1;
        } else {
            s[j] = s[j].substr(1);
            j = 2;
        }
        str = s[j];
    }
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 1; i <= 9; i++ {
		for j := 1; j <= 9; j++ {
			if i*j == n {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import Counter

s = read().rstrip().decode()
if max(Counter(list(s)).values()) <= (len(s) + 2) // 3:
    print('YES')
else:
    print('NO')


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


int main(){
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int ret = 0;
  rep(i,N/R+1){
    rep(j,N/G+1){
      ll x = i*(ll)R + j*(ll)G;
      if(x > N) continue;
      if((N-x)%B == 0) ret++;
    }
  }

  cout << ret << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s[101],d,f,g,h,j,k,i;
	scanf("%d",&a);
	d=0;
	for(i=0;i<a;i++){
		scanf("%d",&s[i]);
		d+=s[i];
	}
	for(i=0;i<a-1;i++){
		for(j=i+1;j<a;j++){
			if(s[i]>s[j]){
				f=s[i];
				s[i]=s[j];
				s[j]=f;
			}
		}
	}
	f=0;
//	for(i=0;i<a;i++) printf("%d %d\n",i,s[i]);
	for(i=0;i<a;i++){
		if(d%10!=0) break;
		if(s[i]%10!=0) d-=s[i];
		if(s[i]%10==0) f++;
	}
	if(f==a) d=0;
	printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 128
## subroutines

def is_invalid?(a)
  x = 1
  while 2 * (x * x + x) <= a
    if (a - x) % (2 * x + 1) == 0
      return false
    end
    x += 1
  end
  true
end

### main

n = gets.strip.to_i
count = 0

n.times do
  a = gets.strip.to_i
  count +=1 if is_invalid?(a)
end

puts count

Measured memory_bytes: 6092
<?PHP
  fscanf(STDIN,"%s", $S);
  fscanf(STDIN,"%s", $T);
  $length = strlen($S);
  $S_1 = str_split($S);
  $T_1 = str_split($T);

  for ($i=0, $count=0; $i < $length; $i++) { 
    if ($S_1[$i] === $T_1[$i]) {
      
    }else {
      $count += 1;
    }
  }
  echo $count;
?>

Measured memory_bytes: 41328
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

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

  vector<int> h(n);
  r(i,n){
    cin>>h.at(i);
  }
  string ans="Yes";
  for(int i=n-1;i>0;i--){
    if(h.at(i)>=h.at(i-1)){}
    else if(h.at(i)+1==h.at(i-1)){
      h.at(i-1)--;
    }
    else ans="No";
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> t(N+1),x(N+1),y(N+1);
    t[0] = x[0] = y[0] = 0;
    for(int i = 1; i <= N;i++){
        cin >> t[i] >> x[i] >> y[i];
    }
    for(int i = 1; i <= N;i++){
        if(t[i] - t[i-1] < abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])){
            cout << "No" << endl;
            return 0;
        }
        if(((t[i] - t[i-1]) - abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]))%2 == 1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


int n, a[101010];

int main(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	int cnt = 0;
	for(int i = 1; i <= n; i++){
		if(a[a[i]] == i) cnt++;
	}
	
	cout << cnt/2 << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;


int main(){
	int N;
	ll S;
	cin>>N>>S;
	V<ll> x(N);
	V<ll> p(N);
	rep(i,N) cin>>x[i]>>p[i];
	ll res = 0;
	int s = 0, t = N-1;
	while(s<=t){
		if(S<x[s]){
			res += x[t]-S;
			break;
		}
		if(x[t]<S){
			res += S-x[s];
			break;
		}
		if(p[s]>=p[t]){
			res += x[t]-x[s];
			while(s<t && p[s]>=p[t]){
				p[s] += p[t];
				t--;
			}
		}else{
			res += x[t]-x[s];
			while(s<t&&p[s]<p[t]){
				p[t] += p[s];
				s++;
			}
		}
	}
	cout<<res<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n;
	std::cin >> n;
	int a[100];
	int count=0;
	for (int i = 0; i < n; i++) {
		std::cin >> a[i];
	}
	sort(a, a + n, greater<int>());
	for (int i = 0; i < n-1; i++) {
		if(a[i]==a[i+1]) {
			count++;
		}
	}
	cout << n - count;

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

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
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= 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
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  ll n, m;
  cin >> n >> m;
  ll ans;
  for(ll i = m/n;; --i) if(m%i == 0) {
    cout << i << endl;
    return 0;
  }
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

vector<vector<pair<int,int>>> G;
vector<int> color;
void dfs(int start, int parent){
    int stcolor = color.at(start);
    
    for (pair<int,int> i : G.at(start)){
        if(i.first == parent) continue;
        if(i.second == 1){
            color.at(i.first) = 1 - color.at(start);
        }
        else{
            color.at(i.first) = color.at(start);
        }
        dfs(i.first, start);
    }
}

int main(){
    int N;
    cin >> N;
    int u,v;
    ll w;
    G.resize(N);
    color.resize(N);
    for(int i = 0; i < N-1; i++){
        cin >> u >> v >> w; u--; v--;
        w = w % 2;
        G.at(u).push_back(make_pair(v, w));
        G.at(v).push_back(make_pair(u, w));
    }
    
    color.at(0) = 0;
    dfs(0, -1);
    for (int i = 0; i < N; i++)
    {
        printf("%d\n", color.at(i));
        
    }
    
}

Measured memory_bytes: 8960
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
  int a,b,c,d,sum,n,count=0,num;
  vector<int> nl;
  while(cin >> n){
    nl.push_back(n);
  }

  for(int j=0; j<nl.size(); j++){
    count = 0;
    n = nl[j];
    for(int i=0; i < 10000; i++){
      num = i;
      a = num/1000;num%=1000;
      b = num/100;num%=100;
      c = num/10;num%=10;
      d = num;
      sum = a+b+c+d; 
      if(n == sum){
        count++;
      }
    }

    cout << count << endl;
  }
}

Measured memory_bytes: 1208
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main(void)
{
    long long x;
    cin >> x;
    long long m = 100;
    long long i = 0;
    for (i = 0; m < x; i++)
    {
        m += m / 100;
    }
    cout << i << endl;
    return 0;
}


Measured memory_bytes: 3604
#pragma GCC optimize("O3") //コンパイラ最適化用

#define _GLIBCXX_DEBUG //配列に[]でアクセス時のエラー表示
#include <algorithm>   //sort,二分探索,など
#include <bitset>      //固定長bit集合
#include <chrono>      //実行時間計測
#include <cmath>       //pow,logなど
#include <complex>     //複素数
#include <deque>       //両端アクセスのキュー
#include <functional>  //sortのgreater
#include <iomanip>     //setprecision(浮動小数点の出力の誤差)
#include <iostream>    //入出力
#include <iterator>    //集合演算(積集合,和集合,差集合など)
#include <map>         //map(辞書)
#include <numeric>     //iota(整数列の生成),gcdとlcm,accumulate
#include <queue>       //キュー
#include <set>         //集合（順序保持）
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility> //pair
#include <vector>  //可変長配列
using namespace std;
typedef long long ll;
typedef long double ld;

#define REP(i, n) for (int i = 0; i < ll(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < ll(b); i++)
#define FORD(i, a, b) for (int i = a; i > ll(b); i--)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size()) // sizeをsize_tからllに直しておく

#define INF 1000000000000 // 10^12:極めて大きい値,∞
const int MOD = 1000000007;
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define Umap unordered_map
#define Uset unordered_set
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000

void add(long long &a, long long b) {
    a += b;
    if (a >= MOD)
        a -= MOD;
}
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {

    int n, time_limit;
    cin >> n >> time_limit;
    vector<vector<int>> time_pleasure(n, vector<int>(2, 0));
    REP(i, n) {
        int a, b;
        cin >> a >> b;
        time_pleasure[i][0] = a;
        time_pleasure[i][1] = b;
    }

    // 第i列を軸にしてvvをソート
    sort(ALL(time_pleasure),
         [](const vector<int> &alpha, const vector<int> &beta) {
             return alpha[0] < beta[0];
         });

    vector<vector<int>> dp(n + 3, vector<int>(time_limit + 3, 0));
    // dp[i][j]:=i番目(1idx)までの料理の中からj分までの注文で得られる美味しさの最大値

    int ans = 0;

    REP(ni, n) {
        REP(ti, time_limit) {
            chmax(dp[ni + 1][ti], dp[ni][ti]);
            int new_t = ti + time_pleasure[ni][0];
            if (new_t <= time_limit) {
                chmax(dp[ni + 1][new_t], dp[ni][ti] + time_pleasure[ni][1]);
            }
        }
        int ni_last = dp[ni][time_limit - 1] + time_pleasure[ni][1];
        chmax(ans, ni_last);
    }
    cout << ans << endl;
}


Measured memory_bytes: 38888
#include <iostream>

bool judgement(int a, int b, int c)
{
	if (a*a == b*b + c*c) {
		return true;
	} else {
		return false;
	}
}

int main()
{
    int x;
	int y;
    int z;
	bool flag[3];
	int n;
	std::cin >> n;
	while (n > 0) {
	    std::cin >> x >> y >> z;
	    flag[0] = judgement(x, y, z);
	    flag[1] = judgement(y, z, x);
	    flag[2] = judgement(z, x, y);
	    if (flag[0] || flag[1] || flag[2]) {
	    	std::cout << "YES" << std::endl;
	    	} else {
	    		std::cout << "NO" << std::endl;
	    		}
	    n --;
	   }
}
	

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n)   for (int i = 0; i < (n); i++)
#define sz(x)       (int)x.size()
#define eb          emplace_back
#define pb          push_back
#define all(x)      x.begin(), x.end()
#define rall(x)     x.rbegin(), x.rend()
#define fi          first
#define se          second

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("io\\in.txt", "r", stdin);
    freopen("io\\out.txt", "w", stdout);
#endif

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    while (k--) {
        if (a >= b) b *= 2;
        else c *= 2;
    }

    cout << (c > b && b > a ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  cin >> s >> t;
  int S=s.size();
  int T=t.size();
  vector<char> a(S),b(T);
  for(int i=0;i<S;i++){a[i]=s[i];}
  for(int i=0;i<T;i++){b[i]=t[i];}
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  for(int i=0;i<S;i++){s[i]=a[i];}
  for(int i=0;i<T;i++){t[i]=b[T-1-i];}
  if(s<t){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
}

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

int h, w;

int dist(int i, int j) {
    return min(i, h - i - 1) + min(j, w - j - 1);
}

int main() {
    int n; cin >> h >> w >> n;
    int ci, cj; cin >> ci >> cj; ci--, cj--;
    string s, t; cin >> s >> t;
    int ch;
    int ci_min = ci, ci_max = ci;
    int cj_min = cj, cj_max = cj;
    for (int i = 0; i < n; i++) {
        // 落としたい S
        ch = s[i];
        if (ch == 'U') ci_min--;
        if (ch == 'D') ci_max++;
        if (ch == 'L') cj_min--;
        if (ch == 'R') cj_max++;
        if (ci_min < 0 || ci_max >= h || cj_min < 0 || cj_max >= w) {
            cout << "NO" << endl;
            return 0;
        }
        ch = t[i];
        if (ch == 'U') ci_max = max(ci_max - 1, 0);
        if (ch == 'D') ci_min = min(ci_min + 1, h - 1);
        if (ch == 'L') cj_max = max(cj_max - 1, 0);
        if (ch == 'R') cj_min = min(cj_min + 1, w - 1);
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <unordered_map>
#include <queue>
#include <set>

using namespace std;

#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

struct Node{
    int number;
    vector<pair<int, ll> > connected_nodes;
};

vector<int> answer;

void check_nodes(int root, vector<struct Node> &node_list){
    int root_color = answer[root];
    for (auto i : node_list[root].connected_nodes){
        if (answer[i.first] != -1) continue;
        if (i.second % 2 == 0) answer[i.first] = root_color;
        else answer[i.first] = (root_color - 1) * (- 1);
        check_nodes(i.first, node_list);
    }
}

int main(){
    int n;
    cin >> n;
    answer = vector<int>(n + 1, -1);
    int u, v;
    ll w;
    vector<struct Node> node_list;
    for (int i = 0; i <= n; i++){
        struct Node n;
        n.number = i;
        node_list.push_back(n);
    }
    for (int i = 1; i <= n - 1; i++){
        cin >> u >> v >> w;
        node_list[u].connected_nodes.push_back(make_pair(v, w));
        node_list[v].connected_nodes.push_back(make_pair(u, w));
    }
    answer[1] = 0;
    check_nodes(1, node_list);
    for (int i = 1; i <= n; i++){
        if (answer[i]) cout << "1" << endl;
        else cout << "0" << endl;
    }
    return 0;
}

Measured memory_bytes: 10476
#include<bits/stdc++.h>
#define ll long long
#define MAXN 200005
#define INF 0x3f3f3f3f
#define ld long double
using namespace std;
set<string>s;
int main(){
    ios::sync_with_stdio(false);
    #define int ll
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string a;
        cin>>a;
        s.insert(a);
    }
    cout<<s.size()<<endl;
    return 0;
}


Measured memory_bytes: 19244
import sys
input=sys.stdin.readline
n=int(input())

l=[[] for _ in range(n)]
ab=[]
for _ in range(n-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    l[a].append(b)
    l[b].append(a)
    ab.append((a,b))

ans=[0]*n

from collections import deque

c=list(map(int,input().split()))
c.sort(reverse=True)
c=deque(c)
q=deque()
q.append([0])
while q:
    ll=q.popleft()
    for v in ll:
        if ans[v]!=0:
            continue
        ans[v]=c.popleft()
        q.append(l[v])

x=0
for a,b in ab:
    x+=min(ans[a],ans[b])

print(x)
print(*ans)


Measured memory_bytes: 47728
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
        String s1 = sc.next();
        String s2 = sc.next();
        String ans = "";
        for(int i = 0; i < n; i++){
        	ans += s1.substring(i, i + 1);
            ans += s2.substring(i, i + 1);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 39572
import sys

IDX_TBL = {1:[2,3,5,4], 2:[3,1,4,6], 3:[1,2,6,5],
           4:[1,5,6,2], 5:[1,3,6,4], 6:[2,4,5,3]}

l1=["_"] + raw_input().split(" ")
l2=["_"] + raw_input().split(" ")

if l1[1] in l2:
    idx_list = [i for i,x in enumerate(l2) if x==l1[1]]

    for idx in idx_list:
        nums1 = "".join([l1[i] for i in IDX_TBL[1]])
        nums2 = "".join([l2[i] for i in IDX_TBL[idx]])
        if nums2 in nums1*2:
            print "Yes"
            sys.exit(0)
print "No"

Measured memory_bytes: 4252
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;

int main(){
  int a,b;
  cin >> a >> b;
  if((a*b)%2)cout << "Odd" << endl;
  else  cout << "Even" << endl;
}


Measured memory_bytes: 256
# include<iostream>
using namespace std;
int main ()
{
	 int a,b;
	 cin>>a>>b;
	 if(b>a)
	 {
	 	int temp = a;
	 	a=b;
	 	b=temp;
	 }
	 for(int i=0;i<a;i++)
	 {
	 	cout<<(char)('0'+b); 
	 }
	 cout<<endl;
	 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  ll N;
  cin>>N;
  cout<<(N-1)*N/2<<endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner
var out *bufio.Writer

func main() {
	sc = bufio.NewScanner(os.Stdin)
	//bytes, _ := ioutil.ReadFile("./stdin.txt")
	//sc = bufio.NewScanner(strings.NewReader(string(bytes)))
	out = bufio.NewWriter(os.Stdout)
	buf := make([]byte, 1<<20)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	n, a, b, c := nextInt(), nextInt(), nextInt(), nextInt()
	l := nextInts(n)

	fmt.Fprintln(out, dfs(l, 0, a, b, c, 0, 0, 0))
}

func dfs(l []int, i, sa, sb, sc, a, b, c int) int {
	if i == len(l) {
		if min(a, b, c) > 0 {
			return abs(sa-a) + abs(sb-b) + abs(sc-c) - 30
		}
		return 1 << 31
	}

	return min(
		dfs(l, i+1, sa, sb, sc, a, b, c),
		dfs(l, i+1, sa, sb, sc, a+l[i], b, c)+10,
		dfs(l, i+1, sa, sb, sc, a, b+l[i], c)+10,
		dfs(l, i+1, sa, sb, sc, a, b, c+l[i])+10,
	)
}

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func min(a ...int) int {
	ret := a[0]
	for i := 1; i < len(a); i++ {
		if a[i] < ret {
			ret = a[i]
		}
	}
	return ret
}
func max(a ...int) int {
	ret := a[0]
	for i := 1; i < len(a); i++ {
		if a[i] > ret {
			ret = a[i]
		}
	}
	return ret
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


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

#define MAX 1000000001
#define SIZE 500001

int S[SIZE];
int count = 0;
int n;

void print(){
    for(int i = 0; i < n; i++){
        if(i != 0)  cout << " ";
        cout << S[i];
    }
    cout << endl;
    cout << count << endl;
}

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

    int li = 0;
    int ri = 0;

    for(int i = left; i < right; i++){
        if(L[li] <= R[ri]){
            A[i] = L[li];
            li++;
        }else{
            A[i] = R[ri];
            ri++;
        }
        count++;
    }
}

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

int main(){
    cin >> n;
    for(int i = 0; i < n; i++)  cin >> S[i];
    mergeSort(S,0,n);
    print();
    return 0;
}


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

#define ll long long
#define vec vector<ll>
#define sortv(a); sort(a.begin(), a.end());
#define rev(a); reverse(a.begin(), a.end());
#define FOR(i,a,b) for (ll i = (ll)(a); i < (b); i++)
#define ROF(i,a,b) for (ll i = (ll)(b)-1; i >= (a); i--)

ll MOD = 1000000007;
ll INF = 1LL << 60;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int h,w,a,b;cin>>h>>w>>a>>b;
	FOR(i,0,b) {
		FOR(j,0,a) {
			cout<<'0';
		}
		FOR(j,a,w) {
			cout<<'1';
		}
		cout<<'\n';
	}
	FOR(i,b,h) {
		FOR(j,0,a) {
			cout<<'1';
		}
		FOR(j,a,w) {
			cout<<'0';
		}
		cout<<'\n';
	}
}

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

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == s[i + 1]) ans++;
    }
    
    cout << min(ans + 2 * k, n - 1) << "\n";
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
    int N;
    string S;
    cin>>N>>S;
    int len=S.size();
    rep(i,len){
        S[i]+=N;
        if(S[i]>'Z'){
            S[i]-=26;
        }
    }
    cout<<S<<endl;
}




Measured memory_bytes: 3632
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
        n:usize,m:usize,s:usize,
    uvab : [(Usize1,Usize1,usize,usize);m],// city,city,fee, transit time
    cd:[(usize,usize);n],// money, time
    }
    let mut G = vec![Vec::new(); n + 1];
    for &(u, v, a, b) in uvab.iter() {
        G[u].push((v, a, b));
        G[v].push((u, a, b));
    }
    let mut s = s;
    /**
     * 銀貨は最大でも2500枚あればよい -> 制約ゆるくなる
     * */
    let MAX = 2500usize;
    if s >= MAX {
        s = MAX;
    }
    // [頂点, 金]への最大値
    let mut dp = vec![vec![INF as usize; MAX + 1]; n];
    let mut qq = BTreeSet::new();
    dp[0][s] = 0;
    // ダイクストラの拡張
    qq.insert((0, 0, s));
    while qq.len() > 0 {
        let tp = *qq.iter().next().unwrap();
        qq.remove(&tp);
        let time = (tp.0) as usize;
        let v = (tp.1) as usize;
        let ss = (tp.2) as usize;
        // 最大より時間がかかるなら無視
        if time > dp[v][ss] {
            continue;
        }
        // 両替する
        if ss + cd[v].0 <= MAX {
            let ns = ss + cd[v].0;
            let ntime = time + cd[v].1;
            if dp[v][ns] > ntime {
                dp[v][ns] = ntime;
                qq.insert((ntime, v, ns));
            }
        }
        for &e in G[v].iter() {
            if ss < e.1 {
                continue;
            }
            let nv = e.0;
            let ns = ss - e.1;
            let ntime = time + e.2;
            if dp[nv][ns] > ntime {
                dp[nv][ns] = ntime;
                qq.insert((ntime, nv, ns));
            }
        }
    }
    for v in 1..n {
        let mut res = INF as usize;
        for s in 0..=MAX {
            res = min(res, dp[v as usize][s as usize]);
        }
        println!("{}", res);
    }
}

const INF: usize = 1 << 60;


Measured memory_bytes: 6096
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

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


answer = 0
for i in range(n):
    temp=0
    for j in range(i+1,n):
        temp+=d[j]
    answer+=d[i]*temp

print(answer)

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

    using namespace std;
    typedef long long ll;
    # define M_PI  3.14159265358979323846
    const int MOD=1e9+7;

    void solve(){
        int x,n;
        cin>>x>>n;
        set<int>s;
        for(int i=0;i<n;i++){
            int k;
            cin>>k;
            s.insert(k);
        }
        int index;
        int mini=INT_MAX;
        for(int i=x;i>=-1000;i--){
            if(s.count(i)==0){
                if(mini>abs(x-i)){
                    mini=abs(x-i);
                    index=i;
                    break;
                }
            }
        }
        for(int i=x;i<=1000;i++){
            if(s.count(i)==0){
                if(mini>abs(x-i)){
                    mini=abs(x-i);
                    index=i;
                    break;
                }
            }
        }
        cout<<index;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


Measured memory_bytes: 3668