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

int main() {
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            string s;
            cin >> s;
            if (s == "snuke") {
                char c = 'A' + j;
                cout << c << i + 1 << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main(void) {
	int n, h, w; cin >> h >> w;
	char a; int test[101][101] = { 0 };
	for (int i = 0; i < h; i++) {
		for (int k = 0; k < w; k++) {
			cin >> a;
			if (a == 'c') {
				test[i][k] = 1;
			}
			if (a == '.') {
				test[i][k] = 0;
			}
		}
	}
	for (int i = 0; i < h; i++) {
		int sum = 0;
		for (int k = 0; k < w; k++) {
			if (test[i][k] == 1) {
				cout << '0';
				sum = 1;
			}
			else if (sum == 0) {
				cout << "-1";
			}
			else {
				cout << sum;
				sum++;
			}
			if (k != w - 1) {
				cout << ' ';
			}
		}
		cout << endl;
	}
}


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

int main(){
 int n[4] = {0};
 int ans[4] = {1,9,7,4};
 int count = 0;
 for(int i=0;i<4;i++){
   cin >> n[i];
 }
 for(int i=0;i < 4;i++){
   if(n[i] == ans[0]){
     ans[0] = 10;
     count++;
   }else if(n[i] == ans[1]){
     ans[1] = 10;           
     count++;
   }else if(n[i] == ans[2]){ 
     ans[2] = 10;           
     count++; 
   }else if(n[i] == ans[3]){
     ans[3] = 10;
     count++;
   }
 }
 if(count == 4){
   cout << "YES\n";
 }else{
 cout << "NO\n";
 }
}


Measured memory_bytes: 256
a, b = map(int, input().split());

if a * b <= 0 : 
  print('Zero')
  exit(0)

if a > 0 and b > 0 :
  print('Positive')
  exit(0)

x = b - a + 1
if(x%2 == 0) : 
  print('Positive')
else :
  print('Negative')



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

int main() {

  vector<char> S(6);
  for (int i = 0; i < 6; i++) {
      cin >> S.at(i);
  }
  if(S.at(2)==S.at(3) && S.at(4)==S.at(5)) puts("Yes");
  else puts("No");
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define MOD 1000000007
 #define pi 3.14159265359
int main()
{
	fast;
	double a,b,c,d;
  cin>>a>>b>>c>>d;
    ll dd=c*30;
    
   double x=abs(0.5*(60.0*c+d)-6.0*d);
    x*=pi;
    x=x/(180*1.0);
  double mid=a*a+b*b;
  double mid2=cos(x);
  double mid1=2*a*b;
  double mid4=mid1*mid2;
   // cout<<mid4<<endl;
  double mid6=(double)(mid-mid4);
  //  cout<<mid6<<endl;
  cout << std::setprecision(10) << sqrt(mid6) <<endl;
 
}

Measured memory_bytes: 4176
using System;

namespace Calc
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] d = Console.ReadLine().Split(' ');
            int a = int.Parse(d[0]);
            int b = int.Parse(d[1]);

            string c_1 = (a * b).ToString();
            string c_2 = (a * 2 + b * 2).ToString();

            Console.WriteLine(c_1 + " " + c_2);
        }
    }
}

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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define each(i,mp) for(auto& i:mp)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const lb pi=acos(-1);
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll x[5];rep(i,0,5)cin>>x[i];

  rep(i,0,5){
    if(x[i]==0){
      out(i+1);
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3624
import java.lang.Math.max

fun main(args: Array<String>) = p38()

fun p38() {
    val q = readLine()!!.toInt()

    val answer = StringBuilder()

    repeat(q) {
        val x = readLine()!!
        val y = readLine()!!

        val dp = Array(x.length + 1) { IntArray(y.length + 1) }

        for ((xi, xc) in x.withIndex()) {
            for ((yi, yc) in y.withIndex()) {
                dp[xi + 1][yi + 1] = (if (xc == yc) dp[xi][yi] + 1 else max(dp[xi + 1][yi], dp[xi][yi + 1]))
            }
        }

        answer.appendln(dp.last().last())
    }

    print(answer)
}



Measured memory_bytes: 98516
package main

import "fmt"

func main() {
	var n, m, c int
	fmt.Scan(&n, &m, &c)
	b := make([]int, m)
	for i:=0; i<m; i++{
		fmt.Scan(&b[i])
	}

	// 二次元配列aの初期化
	a := make([][]int, n)
	for l:=0; l<len(a); l++{
		a[l] = make([]int, m)
		for j:=0; j<len(a[l]); j++{
			fmt.Scan(&a[l][j])
		}
	}

	result := make([]int, n)
	count := 0
	for q:=0; q<len(a); q++{
		for s:=0; s<len(a[q]); s++{
			result[q] += a[q][s] * b[s]
		}
		if result[q]+c > 0{
			count++
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < (n); i++)
using pint = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    ll p[a], q[b], r[c];
    rep (i, a) cin >> p[i];
    rep (i, b) cin >> q[i];
    rep (i, c) cin >> r[i];
    sort (p, p + a, greater<ll>());
    sort (q, q + b, greater<ll>());
    sort (r, r + c, greater<ll>());
    vector<ll> vec;
    rep (i, x) vec.push_back (p[i]);
    rep (i, y) vec.push_back (q[i]);
    rep (i, c) vec.push_back (r[i]);
    sort (vec.begin(), vec.end(), greater<ll>());
    ll ans = 0;
    rep (i, x + y) ans += vec[i];

    cout << ans << "\n";
}

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

int main() {
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    map<string, int> mapa;
    mapa[s] = a;
    mapa[t] = b;
    mapa[u]--;
    cout << mapa[s] << " " << mapa[t] << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int W,H,N,x,y,a,i,S;
	
	scanf("%d %d %d",&W,&H,&N);
	
	int x1=0,y1=0,x2=W,y2=H;
	
	for(i=0;i<N;i++){
		
		scanf("%d %d %d",&x,&y,&a);
		
		if(a==1)      {if(x>=x1&&x<=x2){x1=x;} else if(x>x2){ x1=0; x2=0;}}
		
		else if(a==2) {if(x>=x1&&x<=x2){x2=x;} else if(x<x1){ x1=0; x2=0;}}
		
		else if(a==3) {if(y>=y1&&y<=y2){y1=y;} else if(y>y2){ y1=0; y2=0;}}
		
		else if(a==4) {if(y>=y1&&y<=y2){y2=y;} else if(y<y1){ y1=0; y2=0;}}
	}
	S=(x2-x1)*(y2-y1);
	printf("%d\n",S);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>

#define ll long long

using namespace std;

int main()
{
    ll n,a,b,cnt,x;

    while(scanf("%lld %lld %lld",&n,&a,&b)==3)
    {
        cnt=0;
        
        while(n--)
        {
            scanf("%lld",&x);

            if(x<a||x>=b)
                cnt++;
        }

        printf("%lld\n",cnt);
    }

    return (0);
}


Measured memory_bytes: 256
N,M,Q = map(int,input().split())
iar=[]
for i in range(Q):

  ai,bi,ci,di=map(int,input().split())
  iar.append([ai,bi,ci,di])
kumi=[]
for i in range(1,M+1):
 kumi.append(i)
import itertools
alls=list(itertools.combinations_with_replacement(kumi, N))
maxi=None
maxnum=0
for i in alls:
  goukei=0
  for j in iar:

    abi=i[j[1]-1]
    aai=i[j[0]-1]
    if abi-aai==j[2]:
      goukei=goukei+j[3]
  if goukei>maxnum:
    maxnum=goukei
    maxi=i
#print(maxi)
print(maxnum)

Measured memory_bytes: 21468
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

ll N, M;
struct room {ll fp; ll len; vector<ll> ne;};
vector<room> p;
queue<ll> q;


#define MOD 1000000007LL

int main()
{
  ll A, B;
  ll r;
  ll pos;

  cin >> N >> M;

  p.resize(N+1);
  for (int i=1; i<=M; i++) {
    cin >> A >> B;
    p[A].ne.push_back(B);
    p[B].ne.push_back(A);
  }

  q.push(1);
  while(!q.empty()) {
    r = q.front();
//printf("pop %lld\n", r);
    q.pop();
    pos = p[r].len;
    for (auto it = p[r].ne.begin(); it != p[r].ne.end(); it++) {
//      if (p[*it].len == 0 || p[*it].len > pos+1) {
      if (p[*it].len == 0) {
        p[*it].len = pos+1;
        p[*it].fp = r;
        q.push(*it);
      }
    }
  }

/*
  for (int i=2; i<=N; i++) {
    if (p[i].fp == 0) {
      printf("No\n");
      return 0;
    }
  }
  */
  printf("Yes\n");
  for (int i=2; i<=N; i++) {
    cout << p[i].fp <<endl;
  }

  return 0;
}


Measured memory_bytes: 13752
#include<bits/stdc++.h>
using namespace std;
int main(){
  	int a,b,c,k;
  	string ans = "No";
      
    cin >> a >> b >> c >> k;
  
  	for(int i = 0;i < k;i++){
      if(b >= c){
        c *= 2;
      }else if(a >= b){
        b *= 2;
      }
      if(a < b && b < c){
        ans = "Yes";
        break;
      }
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 3612
<?php while($n = trim(fgets(STDIN)))
{
  if($n>91)
    $a = 'heavy';
  else if($n>81)
    $a = 'light heavy';
  else if($n>75)
    $a = 'middle';
  else if($n>69)
    $a = 'light middle';
  else if($n>64)
    $a = 'welter';
  else if($n>60)
    $a = 'light welter';
  else if($n>57)
    $a = 'light';
  else if($n>54)
    $a = 'feather';
  else if($n>51)
    $a = 'bantam';
  else if($n>48)
    $a = 'fly';
  else
    $a = 'light fly';
  echo $a . "\n";
}

Measured memory_bytes: 6552
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
	
	//未提出者
	/*
	int A[28];
	for(int i=0; i<28; i++){
		int a;
		cin >> a;

		A[i] = a;
	}
	sort(A,A+28);
	*/

	bool X[31];
	for(int i=0; i<31; i++){
		X[i] = false;
	}

	//int p=1;
	for(int i=0; i<28; i++){
		int a;
		cin >> a;
		X[a] = true;
		/*
		for(int j=1; j<=30; j++){
			if(A[i]==j){
				break;
			}
			else if(j==30){
				cout << A[i] << endl;
			}
		}
		*/
		/*
		if(A[i] != p){
			cout << p << endl;
			p++;
		}
		p++;
		*/
	}
	//X[0] = true;
	for(int i=1; i<31; i++){
		if(!X[i]){
			cout << i << endl;
		}
	}
	

	
return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define For(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
int main(){
	char c[10]; scanf("%s",c); int l=strlen(c);
	For(i,0,l-2) if (c[i]=='A'&&c[i+1]=='C') printf("Yes"),exit(0);
	printf("No");
	return 0;
}

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

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

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

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

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

ll dp[100100][13]; // i桁目まで見て、余りがjとなる場合の数

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  ll n=s.size();
  
  // 初期化: 0桁目で余り0となるのは1通り
  dp[0][0]=1;
  rep(i,n){
    if(s[i]!='?'){
      ll num=s[i]-'0';
      // i-1桁目までで余りがjとなる通り数から、i桁目がnumのときの場合へ遷移する
      rep(j,13){
        ll rem=(j*10+num)%13;
        (dp[i+1][rem]+=dp[i][j])%=MOD;
      }
    }else{
      // s[i]=='?'なら、numは0~10の全ての場合を数える
      rep(num,10){
        rep(j,13){
          ll rem=(j*10+num)%13;
          (dp[i+1][rem]+=dp[i][j])%=MOD;
        }
      }
    }
  }
  
  cout<<dp[n][5]<<endl;
  
}

Measured memory_bytes: 10704
from collections import Counter
import math

def nCr(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n = int(input())
a = list(map(int, input().split()))
a_t = [0]
for i in range(n):
    a_t.append(a[i] + a_t[i])
ac = Counter(a_t[1:])
ans = 0
for i in ac:
    if i == 0:
        ans += ac[i]
    if ac[i] > 1:
        ans += nCr(ac[i], 2)
print(ans)

Measured memory_bytes: 43356
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int m, k;
    cin >> m >> k;
    int n = pow(2, m);
    if(k >= n)
    {
        cout << -1 << endl;
        return 0;
    }
    if(m == 1 && k == 1)
    {
        cout << -1 << endl;
        return 0;
    }

    if(k == 0)
    {
        for(int i = 0; i < n; i++)
        {
            cout << i << " ";
            cout << i << " ";
        }
    }
    else
    {
        cout << "0 " << k << " 0 ";
        for(int i = n-1; i >= 1; i--)
        {
            if(i == k) continue;
            cout << i << " ";
        }
        cout << k << " ";
        for(int i = 1; i < n; i++)
        {
            if(i == k) continue;
            cout << i << " ";
        }
    }
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>

#define rep(X, Y) for( int (X) = 0; (X) < (Y); ++(X) )
#define rept(X, Y, Z) for( int (X) = (Y); (X) < (Z); ++(X) )
#define MOD 10007

int N, p, sum;
long long dp[10001][8];
char str[10001];
//j: 0, o: 1, i: 2
const std::string mem("JOI");

int main(){
	scanf( "%d%s", &N, str );

	rep( i, 1 << 3 ) if( i & (1 << mem.find(str[0])) && i & 1 ) dp[0][i] = 1;

	rept( i, 1, N ){
		p = 1 << mem.find(str[i]);

		rep( l, 1 << 3 ){
		
			if( !(l & p) ) continue;

			rep( m, 1 << 3 )
				if( l & m ) dp[i][l] = (dp[i][l] + dp[i - 1][m]) % MOD;
		}
	
	}

	rep( i, (1 << 3) - 1 ){
		sum = (sum + dp[N - 1][i + 1]) % MOD;
	}

	printf("%d\n", sum );
}

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

using namespace std;

int main()
{
    string n;
    cin >> n;
    for(int i = 0; i < n.size(); i++)
    {
        if(n[i] == '7')
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}


Measured memory_bytes: 3592
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;
typedef pair< int, int > pii;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n;
  cin >> n;

  bool ans = false;
  for(int i = 0; !ans && 4 * i <= n; i++){
    for(int j = 0; !ans && 4 * i + 7 * j <= n; j++){
      if(n == 4 * i + 7 * j){
        ans = true;
        break;
      }
    }
  }

  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
Xm = list(map(int, input().split()))
if n >= m:
    print(0)
else:
    Xm.sort()
    check = [Xm[i+1] - Xm[i] for i in range(m-1)]
    check.sort(reverse=True)
    print(sum(check) - sum(check[:n-1]))


Measured memory_bytes: 13968
package main

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

func isMonth(n int) bool {
	return 1 <= n && n <= 12
}

func main() {

	stdin := bufio.NewScanner(os.Stdin)

	// 一行目
	stdin.Scan()
	line1 := stdin.Text()
	head, _ := strconv.Atoi(line1[0:2])
	tail, _ := strconv.Atoi(line1[2:4])

	if isMonth(head) && isMonth(tail) {
		fmt.Println("AMBIGUOUS")
	} else if isMonth(head) {
		fmt.Println("MMYY")
	} else if isMonth(tail) {
		fmt.Println("YYMM")
	} else {
		fmt.Println("NA")
	}
}


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

int main(){

  long int AC=0,WA=0,TLE=0,RE=0,N;
  cin>>N;
  while(N--){
    string temp;
    cin>>temp;
    if(temp=="AC")
      AC++;
    else if(temp=="WA")
      WA++;
    else if(temp=="TLE")
      TLE++;
    else if(temp=="RE")
      RE++;
  }
  cout<<"AC x "<<AC<<'\n';
  cout<<"WA x "<<WA<<'\n';
  cout<<"TLE x "<<TLE<<'\n';
  cout<<"RE x "<<RE<<'\n';
  return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

const int INF = INT_MAX / 2;

int main(void) {
    string S, T;
    cin >> S >> T;
    const int slen = (int) S.size();
    const int tlen = (int) T.size();

    int ans = INF;
    for (int i = 0; i < slen - tlen + 1; i++) {
        int cnt = 0;
        for (int j = 0; j < tlen; j++) {
            if (S[i + j] != T[j]) {
                cnt++;
            }
        }
        chmin(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll res;
string str;
int main(void){
    // Your code here!
    cin >> str;
    res = str.length();
    for (ll i = 1; i < str.length(); i++) {
        if (str[i - 1] != str[i]) {
            res = min(res, max(i, (ll)str.length() - i));
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <unordered_map>
#include <cmath>
#include <iomanip>

int main() {
	int n;
	std::vector<int> a;
	
	std::cin >> n;
	for (int i = 0; i < n; i++)
	{
		int num;
		std::cin >> num;
		a.push_back(num);
	}
	long double denominator = 0.0;
	for (int i = 0; i < n; i++)
	{
		denominator += (long double)1.0 / a[i];
	}

	auto ans = (long double)1.0 / denominator;
    int val = std::to_string((int)std::floor(ans)).length();
	std::cout << std::setprecision(val + 6) << ans  << "\n";	
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> A(N);
  rep (i, N) cin >> A[i];
  sort(A.begin(), A.end());

  // 1 2 3 | 4 5 6
  // 1 2 | 3 4 5

  long plus_sum = 0;
  long minus_sum = 0;
  long plus_sum_2 = 0;
  long minus_sum_2 = 0;

  if (N % 2 == 0) {
    for (long i = 0; i < N / 2; i++) minus_sum += A[i];
    for (long i = 0; i < N / 2 - 1; i++) minus_sum += A[i];
    for (long i = N / 2; i < N; i++) plus_sum += A[i];
    for (long i = N / 2 + 1; i < N; i++) plus_sum += A[i];
  } else {
    for (long i = 0; i < N / 2; i++) minus_sum += A[i];
    for (long i = 0; i < N / 2; i++) minus_sum += A[i];
    for (long i = N / 2; i < N; i++) plus_sum += A[i];
    for (long i = N / 2 + 2; i < N; i++) plus_sum += A[i];

    for (long i = 0; i < N / 2 + 1; i++) minus_sum_2 += A[i];
    for (long i = 0; i < N / 2 - 1; i++) minus_sum_2 += A[i];
    for (long i = N / 2 + 1; i < N; i++) plus_sum_2 += A[i];
    for (long i = N / 2 + 1; i < N; i++) plus_sum_2 += A[i];
  }

  long ans = max(plus_sum - minus_sum, plus_sum_2 - minus_sum_2);

  cout << ans << endl;
}

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


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

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

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

int main() {
	int n; cin >> n;
	vector <int> a(n);
	rep(i, n) cin >> a[i], -- a[i];
	vector <int> ps(n);
	rep(i, n) ps[a[i]] = i;
	vector <int> f(n);
	rep(i, n) {
		if (i && ps[i - 1] < ps[i]) f[i] = f[i - 1];
		++ f[i];
	}
	int ans = 0;
	rep(i, n) ans = max(ans, f[i]);
	printf("%d\n", n - ans);
	return 0;
}


Measured memory_bytes: 2560
use proconio::{input, marker::Usize1};

struct SegmetTree {
    tree: Vec<u64>,
    leaf_size: usize,
}

impl SegmetTree {
    fn new(n: usize) -> SegmetTree {
        let mut ls = 1;
        while ls < n {
            ls <<= 1;
        }
        SegmetTree {
            tree: vec![0; 2 * ls - 1],
            leaf_size: ls,
        }
    }

    fn update_max(&mut self, i: usize, v: u64) {
        let mut i = i + self.leaf_size - 1;
        self.tree[i] = v;
        while i > 0 {
            i = (i - 1) / 2;
            self.tree[i] = self.tree[2 * i + 1].max(self.tree[2 * i + 2]);
        }
    }

    fn get_max(&self, e: usize, rng: Option<(usize, usize, usize)>) -> u64 {
        let (i, l, r) = if let Some(rng) = rng { rng } else { (0, 0, self.leaf_size) };
        if l >= e || r <= 0 {
            0
        } else if r <= e {
            self.tree[i]
        } else {
            let m = (l + r) / 2;
            let vl = self.get_max(e, Some((2 * i + 1, l, m)));
            let vr = self.get_max(e, Some((2 * i + 2, m, r)));
            vl.max(vr)
        }
    }
}

fn main() {
    input! {
        n: usize,
        h: [Usize1; n],
        a: [u64; n],
    }

    let mut dp = SegmetTree::new(n);
    dp.update_max(h[0], a[0]);
    for i in 1..n {
        let m = dp.get_max(h[i] + 1, None);
        dp.update_max(h[i], m + a[i]);
    }

    println!("{}", dp.get_max(n, None));
}


Measured memory_bytes: 11776
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>

using namespace std;

int main() {
    int N;
    int d[110];
    int count  = 0;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }

    int num[110] = {0};

    for (int i = 0; i < N; i++) {
        num[d[i]]++;
    }

    for (int i = 1; i <= 100; i++) {
        if (num[i]) {
            count++;
        }
    }

    cout << count  << endl;

    return 0;
}

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

int main() {

int tx,ty,sx,sy;
cin >> sx >> sy >> tx >> ty;

const int dx = tx -sx, dy = ty - sy;

cout << string(dy, 'U') << string(dx,'R');
cout << string(dy,'D') << string(dx,'L');
cout << "L" <<  string(dy+1, 'U') << string(dx+1,'R') << "D";
cout << "R" <<  string(dy+1, 'D') << string(dx+1,'L') << "U" << endl;
}

Measured memory_bytes: 256
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
		vector<ll>hehe(n);
	vector<ll>P(n),Q(n);
	for(ll i=0;i<n;i++)
	{
	    cin>>P[i];
	}
	for(ll i=0;i<n;i++)
	{
	    cin>>Q[i];
	}
	for(ll i=0;i<n;i++)
	{
	    hehe[i]=i+1;
	}
	ll a=0,b=0;
	ll lol=0;
	do
	{
	    lol++;
	    ll fl=1,fl1=1;
	    for(ll i=0;i<n;i++)
	    {
	        if(hehe[i]!=P[i])
	        {
	            fl=0;break;
	        }
	    }
	    for(ll i=0;i<n;i++)
	    {
	        if(hehe[i]!=Q[i])
	        {
	            fl1=0;break;
	        }
	    }
	    if(fl)
	    {
	        a=lol;
	    }
	    if(fl1)
	    {
	        b=lol;
	    }
	}while(next_permutation(hehe.begin(),hehe.end()));
	ll ans=abs(a-b);
	cout<<ans;
    return 0;
}


//252908XL

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include<fstream>
#include<map>
#include<bitset>
#include<unordered_map>
#include<cstring>
#include<cctype>
using namespace std;
#define  ll long long
#define  ull unsigned long long
#define  ul unsigned long
#define all(v) v.begin(),v.end()
#define sz(n) (int)n.size()
#define pb(s) push_back(s);
#define format(n) fixed<<setprecision(n)
#define finl "\n"
#define Mohammed_Atef_Hassan fast();
#define mod 1000000007
#define INF LLONG_MAX
#define PI acos(-1)
#define allr(v) v.rbegin(),v.rend()
#define clr(dp,n) memset(dp,n,sizeof dp)
#define ex(n) return cout<<n<<finl,0;
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
ll fix_mod(ll x, ll y)
{
	return (y + x % y) % y;
}
void fast() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);

#ifdef ONLINE_JUDGE
	//freopen("crosses.in", "r", stdin);

	//freopen("crosses.out", "w", stdout);
#endif
#ifndef ONLINE_JUDGE
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#endif
}
int main()
{
	Mohammed_Atef_Hassan
		int n;
	cin >> n;
	vector<ll>v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	for (int i = 1; i < n; i++)
		v[i] += v[i - 1];
	ll mn = LLONG_MAX;
	for (int i = 1; i < n; i++)
	{
		mn= min(mn,abs(v[n-1] - v[i - 1]-v[i-1]));
	}
	ex(mn);
}

Measured memory_bytes: 1792
#include<stdio.h>

int main() {
    // int A, B, tmp, r;
    unsigned long long int A, B, tmp, r, x;

    scanf("%llu %llu", &A, &B);

    x = A * B;

    if (A < B) {
        tmp = A;
        A = B;
        B = tmp;
    }

    r = A % B;
    while (r != 0) {
        A = B;
        B = r;
        r = A % B;
    }

    printf("%llu", x/B);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Output
template<class T, class S> std::ostream& operator <<(std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator <<(std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec; }
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H&& head){ std::cout << head << std::endl; }
template<typename H, typename... T> void print(H&& head, T&&... tail){
  std::cout << head << " ", print(std::forward<T>(tail)...);
}

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

  ll N;
  std::cin >> N;
  std::vector< ll > vx(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> vx[i];
  }

  ll ans = INF;
  for (ll p = 0; p <= 100; p++) {
    ll power = 0LL;
    for (ll i = 0; i < N; i++) {
      power += std::pow((vx[i] - p), 2);
    }
    ans = std::min(ans, power);
  }

  print(ans);
  return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h.at(i);
  int ans = 0;
  int pre = 0;
  for(int i=0;i<n;i++){
    if( h.at(i) >= pre ){
      ans += h.at(i) - pre;
      pre = h.at(i);
    }else if( h.at(i) < pre ){
      pre = h.at(i);
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
  ll k;
  cin >> k;
  ll mx = max(k + 1, 10LL);
  vector<ll> lun(mx);
  rep(i, 10) {
    lun[i] = i;
  }
  if (k >= 10) {
    int count = 10;
    int base = 1;
    do {
      ll fst = lun[base] % 10;
      for (ll i = -1; i <= 1; i++) {
        if (count > k) break;
        if (fst + i >= 0 && fst + i <= 9) {
          lun[count] = lun[base] * 10 + fst + i;
          count++;
        }
      }
      base++;
    } while (count <= k);

  }

  cout << lun[k] << endl;

  return 0;
}


Measured memory_bytes: 3868
#include<bits/stdc++.h>/// important code 3 :   state in 1/0
using namespace std;

int main()
{

int  p,q,r;
while(~scanf("%d %d %d",&p,&q,&r))
{
    int xiao=10000;

    if(xiao>p+q)
    {
        xiao=p+q;
    }
    if(xiao>p+r)
    {
        xiao=p+r;
    }
    if(xiao>q+r)
    {
        xiao=q+r;
    }


    printf("%d\n",xiao);

}



    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 1000000000000000000ll
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stuuu()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  
///////

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n,m;
	cin>>n>>m;
	int a[n+2]={};
	for(int i=0;i<m;++i)
	{
		int l,r;
		cin>>l>>r;
		a[l]++;
		a[r+1]--;
	}
	int c=0;
	int v=0;
	for(int i=1;i<=n;++i)
	{
		v+=a[i];
		if(v==m)
			++c;
	}
	cout<<c;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MAX_N = 100010;
bool is_prime[MAX_N + 1];

void Eratosthenes(const int N) {
    rep(i, N + 1) is_prime[i] = true;
    is_prime[0] = false;
    is_prime[1] = false;

    for (int i = 2; i <= N; i++) {
        if (is_prime[i]) {
            for (int j = 2 * i; j <= N; j += i) {
                is_prime[j] = false;
            }
        }
    }
}

int is_2017_like_number(int n) {
    if (is_prime[n] && is_prime[(n + 1) / 2]) {
        return 1;
    }
    return 0;
}

int main() {
    Eratosthenes(MAX_N);
    vector<int> sum = vector<int>(MAX_N + 1);
    rep(i, MAX_N) sum[i + 1] = sum[i] + is_2017_like_number(i);

    int Q;
    cin >> Q;
    rep(i, Q) {
        int l, r;
        cin >> l >> r;
        cout << sum[r + 1] - sum[l] << endl;
    }
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
    
    unsigned long long n,a,b,x,ans;
    cin >> n >> a >> b;
    x = a+b;
    ans = n/x * a;
    ans += min(n - n/x * x, a);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    cout << (n * (n - 1)) / 2;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstring>
using namespace std;
string s1, s2;
int a, b;
string s;
int main()
{
    cin >> s1 >> s2;
    cin >> a >> b;
    cin >> s;
    if (s == s1)
        a--;
    else
    {
        b--;
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, m, a, b;
    cin >> n >> m;
    vector<int> h(n);
    for(int i=0;i<n;++i) cin >> h[i];

    vector<bool> is_good(n, true);
    for(int i=0;i<m;++i) {
        cin >> a >> b;
        --a; --b;
        if(h[a] > h[b]) {
            is_good[b] = false;
        } else if(h[a] < h[b]) {
            is_good[a] = false;
        } else {
            is_good[a] = false;
            is_good[b] = false;
        }
    }

    int ans = 0;
    for(int i=0;i<n;++i) if(is_good[i]) ++ans;
    cout << ans << endl;
}


Measured memory_bytes: 3712
#include<iostream>
using namespace std;
int main(void)
{
  int a,b,c,tmp;
  cin>>a>>b>>c;
   
   if(a>b){tmp=a; a=b; b=tmp;}
   if(b>c){tmp=b; b=c; c=tmp;}
   if(a>b){tmp=a; a=b; b=tmp;}
   
   cout<<a<<' '<<b<<' '<<c<<'\n';
}

Measured memory_bytes: 3084
#include <cstdio>
#include <iostream>

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);
    int n, a;
    std::cin >> n;
    while (n--)
    {
        std::cin >> a;
        if (a % 2 == 0)
        {
            if ((a / 3) * 3 == a || (a / 5) * 5 == a)
                continue;
            else
            {
                std::cout << "DENIED";
                return 0;
            }
        }
    }
    std::cout << "APPROVED";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
//import java.math.BigInteger;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int[] a = new int[4];
        a[0] = str.charAt(0)-48;
        a[1] = str.charAt(1)-48;
        a[2] = str.charAt(2)-48;
        a[3] = str.charAt(3)-48;
        
        if((a[0]+a[1]+a[2]+a[3])==7){
            System.out.println(a[0]+"+"+a[1]+"+"+a[2]+"+"+a[3]+"=7");
        }else if((a[0]-a[1]+a[2]+a[3])==7){
            System.out.println(a[0]+"-"+a[1]+"+"+a[2]+"+"+a[3]+"=7");
        }else if((a[0]+a[1]-a[2]+a[3])==7){
            System.out.println(a[0]+"+"+a[1]+"-"+a[2]+"+"+a[3]+"=7");
        }else if((a[0]+a[1]+a[2]-a[3])==7){
            System.out.println(a[0]+"+"+a[1]+"+"+a[2]+"-"+a[3]+"=7");
        }else if((a[0]-a[1]-a[2]+a[3])==7){
            System.out.println(a[0]+"-"+a[1]+"-"+a[2]+"+"+a[3]+"=7");
        }else if((a[0]-a[1]+a[2]-a[3])==7){
            System.out.println(a[0]+"-"+a[1]+"+"+a[2]+"-"+a[3]+"=7");
        }else if((a[0]+a[1]-a[2]-a[3])==7){
            System.out.println(a[0]+"+"+a[1]+"-"+a[2]+"-"+a[3]+"=7");
        }else if((a[0]-a[1]-a[2]-a[3])==7){
            System.out.println(a[0]+"-"+a[1]+"-"+a[2]+"-"+a[3]+"=7");
        }
    }
}

Measured memory_bytes: 39464
#include <iostream>
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
long long dp[1<<13][1005];
vector < vector < int > >vec;
int  c[1005];
int  n,m;
bool ones(int mask){
   for(int i=0;i<n;i++){
     if(!((mask>>i)&1))return false;
   }
   return true;
}
int updatemask(int mask , int a){
    int p=mask;
  for(int i=0;i<vec[a].size();i++){
    mask=mask|(1<<(vec[a][i]-1));
  }
  if(mask==p)return -1;
  return mask;
}
long long solve(int a , int mask){
   if(a>=m){
    if(ones(mask))return 0;
    return 10000000000;
   }
   if(dp[mask][a]!=0)return dp[mask][a];
   long long x=solve(a+1,mask);
   int maskupdate=updatemask(mask,a);
   if(maskupdate==-1)return x;
   return dp[mask][a]=min( c[a]+solve(a+1,maskupdate), x);

}
int main()
{
   // cin>>n>>m;
           int k;
           int o;
   scanf("%d %d",&n,&m);
    vec.resize(m);
    for(int i=0;i<m;i++){
        //cin>>c[i];
        scanf("%d",&c[i]);
        //cin>>k;
        scanf("%d",&k);
        for(int j=0;j<k;j++){
           // cin>>o;
           scanf("%d",&o);
            vec[i].push_back(o);
        }
    }
    long long ans=solve(0,0);
    if(ans>=10000000000)cout<<-1;
    else cout<<ans;
    return 0;
}


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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 998244353;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  

double eps = .000000001;


int main ()
{
  prep();
  int n;
  cin >> n;
  int arr[n];
  for (int i=0; i<n; i++){
      cin >> arr[i];
  }
  long long sum = 0;
  for (int i=0; i<n; i++){
      for (int j=i+1; j<n; j++){
          sum += arr[i]*arr[j];
      }
  }
  cout << sum;
  return 0; 
}


Measured memory_bytes: 256
import sys

s = sys.stdin.read().lower()
table = {
    "a": 0,
    "b": 0,
    "c": 0,
    "d": 0,
    "e": 0,
    "f": 0,
    "g": 0,
    "h": 0,
    "i": 0,
    "j": 0,
    "k": 0,
    "l": 0,
    "m": 0,
    "n": 0,
    "o": 0,
    "p": 0,
    "q": 0,
    "r": 0,
    "s": 0,
    "t": 0,
    "u": 0,
    "v": 0,
    "w": 0,
    "x": 0,
    "y": 0,
    "z": 0,
}

for i in list(s):
    if i in table:
        table[i] += 1
    else:
        continue

for i in table:
    print('{} : {}'.format(i,table[i]))



Measured memory_bytes: 5576
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iterator>

int main(){
  int N;
  std::cin>>N;
  std::vector<int> V(N);
  std::vector<int> C(N);
  std::copy_n(std::istream_iterator<int>(std::cin),N,V.begin());
  std::copy_n(std::istream_iterator<int>(std::cin),N,C.begin());
  int max = 0;
  for(int i = 0; i < N ; i++){
    if(V[i]-C[i]>0) max += V[i] - C[i];
  }
  std::cout<<max<<std::endl;
  return 0 ;  
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
import heapq
import itertools


def solve(taro_cards, hanako_cards):
    sum_taro = sum(taro_cards)
    sum_hanako = sum(hanako_cards)
    candidates = []
    for t, h in itertools.product(taro_cards, hanako_cards):
        if sum_taro - t + h == sum_hanako - h + t:
            heapq.heappush(candidates, (t + h, [t, h]))
    if not candidates:
        return [-1]
    else:
        return candidates[0][1]


if __name__ == "__main__":
    while True:
        n, m = map(int, input().split())
        if n == 0 and m == 0:
            break
        else:
            taro_cards = array.array("B", (int(input()) for i in range(n)))
            hanako_cards = array.array("B", (int(input()) for i in range(m)))
            print(*solve(taro_cards, hanako_cards))

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

const int N = 1e5 + 5;
vector< int> conn[N];
int parent[N];
int dist[N];
int rong[N];

void dfs(int u, int p, int d) {
    parent[u] = p;
    dist[u] = d;

    for(int v: conn[u]) {
        if(v != p) dfs(v, u, d + 1);
    }
}


void dfs2(int u, int p, int c) {
    rong[u] = c;

    for(int v: conn[u]) {
        if(v == p) continue;
        if(rong[v] == c or rong[v] == 0) dfs2(v, u, c);
    }
}


int main() {
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n - 1; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        conn[a].emplace_back(b);
        conn[b].emplace_back(a);
    }

    dfs(1, 1, 0);
    int k = dist[n] - 1 - (dist[n] / 2);
    int x = n;
    rong[1] = 1;
    rong[n] = 2;


    while(k-- > 0) {
        x = parent[x];
        rong[x] = 2;
    }

    dfs2(1, 1, 1);
    dfs2(n, n, 2);

    int a = 0, b = 0;
    for(int i = 1; i <= n; ++i) {
        if(rong[i] == 1) a++; else b++;
    }
    if(a > b) puts("Fennec");
    else puts("Snuke");
}

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

const int N = 1e5 + 5;

int p[N], sz[N], a[N];

int get(int x) {
  return p[x] == x ? x : get(p[x]);
}

bool join(int a, int b) {
  a = get(a), b = get(b);
  if (a == b) return false;
  if (sz[a] >= sz[b]) sz[p[b] = a] += sz[b];
  else sz[p[a] = b] += sz[a];
  return true;
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    p[i] = i; sz[i] = 1;
  }
  for (int i = 1; i <= m; i++) {
    int x, y; scanf("%d%d", &x, &y); x++, y++;
    join(x, y);
  }
  vector<vector<int>> comp(n + 1);
  for (int i = 1; i <= n; i++) {
    comp[get(i)].push_back(a[i]);
  }
  int c = 0;
  for (int i = 1; i <= n; i++) if (comp[i].size()) c++;
  if (c == 1) {
    puts("0");
    return 0;
  }
  c = 2 * c - 2;
  long long ans = 0;
  vector<int> aux;
  for (int i = 1; i <= n; i++) if (comp[i].size()) {
    sort(comp[i].begin(), comp[i].end());
    ans += comp[i][0];
    c--;
    for (int j = 1; j < comp[i].size(); j++) {
      aux.push_back(comp[i][j]);
    }
  }
  if (c > aux.size()) {
    puts("Impossible");
    return 0;
  }
  sort(aux.begin(), aux.end());
  for (int i = 0; i < c; i++) {
    ans += aux[i];
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 6912
#include <iostream>
#include <string>
using namespace std;
int main(void)
{   
    //データ定義
   
    string str; //カードの山の並び
    int i;
    int shuffleCnt; //シャッフルする回数
    int shuffleData; //シャッフルデータ
    
    //データ入力
    cin >> str;
    
    //主処理
    while(str != "-"){
        //シャッフルする回数を入力
        cin >> shuffleCnt;
        
        //
        for(i = 0; i < shuffleCnt; i++){
            //シャッフルデータを入力
            cin >> shuffleData;
            //substr(a, b) a番目からb要素分だけ抜き出した部分文字列を返す
            str = str.substr(shuffleData, str.size() - shuffleData) + str.substr(0, shuffleData);
        }
        //結果出力
        cout << str << endl;
        
        //次のデータを入力
        cin >> str;
    }
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef set<ii> sii;
typedef set<int> si;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;

const int INF = 1000000010;
const ll MOD = 1000000007;

int main() {FIN
	
	int h, w, m, x, y, i, mx = 0, my = 0, c, r;
	cin >> h >> w >> m;
	sii its;
	vi sh(h), sw(w);
	for (i = 0; i < m; i++) {
		cin >> x >> y;
		--x, --y;
		sh[x]++;
		sw[y]++;
		its.insert(ii(x, y));
	}
	for (i = 0; i < h; i++) {
		if (i == 0 or sh[mx] < sh[i])
			mx = i;
	}
	for (i = 0; i < w; i++) {
		if (i == 0 or sw[my] < sw[i])
			my = i;
	}
	si xs, ys;
	for (i = 0; i < h; i++) {
		if (sh[mx] == sh[i]) xs.insert(i);
	}
	for (i = 0; i < w; i++) {
		if (sw[my] == sw[i]) ys.insert(i);
	}
	c = 0;
	for (auto it = its.begin(); it != its.end(); it++) {
		if (xs.find((*it).first) != xs.end() and ys.find((*it).second) != ys.end())
			c++;
	}
	r = sh[mx] + sw[my];
	if (c == ((int)xs.size() * (int)ys.size())) r--;
	
	cout << r << "\n";
	
	return 0;
}


Measured memory_bytes: 47732
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int gcd;

int main()
{
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	a--;
	ll g = c*d/__gcd(c,d);

	ll sum1 = b-(b/c+b/d)+b/g;
	ll sum2 = a-(a/c+a/d)+a/g;

	cout << sum1-sum2 << endl;

	return 0;
}


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

using namespace std;
using ll = long long;

const int MAX = 1000000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	COMinit();
	int x, y;
	cin >> x >> y;
	int m = -1, n = -1;
	for (int a = 0; a <= x; a++) {
		if ((x - a) % 2 == 1) continue;
		int b = (x - a) / 2;
		if (a * 2 + b == y) {
			m = a;
			n = b;
			break;
		}
	}
	ll ans = COM(m + n, m);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 27080
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()


def scr(inp):
	if inp == 'r':
		return P
	elif inp == 'p':
		return S
	else:
		return R


Score = 0
for i in range(N):
	if i >= K and T[i] == T[i-K]:
		if T[i-K] == 'z':
			Score += scr(T[i])
		else:
			T = T[:i] + 'z' + T[i + 1:]
	else:
		Score += scr(T[i])

print(Score)

Measured memory_bytes: 3452
/**
 *    author:  ykaka
 *    created: 01.08.2020 20:54:48       
**/
 
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i<(n);++i)
using namespace std;
using ll = long long;
 
int main(){
  int n, x, t;
  cin >> n >> x >> t;
  int b = n / x;
  if(n % x != 0){
    b += 1;
  }
  cout << b * t << endl;
  return 0;
}



Measured memory_bytes: 3632