akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// #include<atcoder/all>
// using namespace atcoder;
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
//---------------------------------------------------------------------------------------------------

int main(void){
    // Your code here!
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    int x = 0;
    rep(i,n) {
        if (s[i] == 'I') x++;
        else x--;
        if (ans < x) ans = x;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3572
import scala.io.StdIn

object Main extends App {
  val Array(n, a, b)  = StdIn.readLine().split(" ").map(_.toInt)

  def solve(n: Int, a: Int, b: Int) :Int = {
    Array(a * n, b).min
  }

  println(solve(n, a, b))
}
  



Measured memory_bytes: 25424
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    string s,t;
    cin>>s;
    cin>>t;
    for(int i=0;i<t.length()-1;i++){
        
        if(s[i]!=t[i]){
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
    return 0;
}



Measured memory_bytes: 3592
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().solve();
    }

    void solve(){
	Scanner kbd = new Scanner(System.in);

	while(kbd.hasNext()){
	    String s = kbd.nextLine();
	    if(s.equals("0")) break; 
	    
	    //String[] pattern = new String[60000];
	    HashSet<String> set = new HashSet<String>();
	    int pcnt = 0;
	    //Stack stack = new Stack(s);
	    Queue<Worm> que = new LinkedList<Worm>();
	    que.add(new Worm(s, 0));
	    String a = s;
	    set.add(s);
	    //pattern[pcnt++] = a;
	    int t = 0;
	    while(!que.isEmpty() && !color(a)){
		//System.out.println(a+" "+color(a));
		Worm w = que.poll();
		a = w.getbody();
		t = w.getTime();
		for(int i=0; i<a.length()-1; i++){
		    if(!a.substring(i, i+1).equals(a.substring(i+1, i+2))){
			String b = change(a, i, i+1);  
			/*
			  int j=0;
			  while(j<pcnt && !pattern[j].equals(b)) j++;
			  if(pattern[j]==null){
			  //System.out.println(b);
			  pattern[j] = b;
			  stack.in(b, t+1);
			  pcnt++;
			  }
			*/
			if(set.contains(b)) continue;
			else{
			    que.add(new Worm(b, t+1));
			    set.add(b);
			}
		    }
		}
	    }
	    if(color(a))
		System.out.println(t);
	    else
		System.out.println("NA");
	}
    }

    boolean color(String x){
	String a = x.substring(0, 1);
	boolean ans = true;
	for(int i=0; i<x.length(); i++){
	    String y = x.substring(i, i+1);
	    ans = ans && a.equals(y);
	}
	return ans;
    }

    String change(String x, int s, int e){
	StringBuffer sb = new StringBuffer();
	//String ans = "";
	for(int i=0; i<x.length(); i++){
	    if(i==s){
		String a = x.substring(i, i+1);
		i++;
		String b = x.substring(i, i+1);
		a = select(a, b);
		sb.append(a+a);
	    }
	    else{
		sb.append(x.substring(i, i+1));
	    }
	}
	return sb.toString();
    }
	
    String select(String x, String y){
	if(x.equals("r") || y.equals("r")){
	    if(y.equals("b") || x.equals("b")){
		return "g";
	    }
	    else return "b";
	}
	else return "r";
    }
}

/*
class Stack {
    Worm[] stack = new Worm[60000];
    int sp;
    int out;
    public Stack(String s){
	sp = 0;
	out = 0;
	this.in(s, 0);
    }

    public  void in(String s, int t){
	Worm w = new Worm(s, t);
	stack[sp++] = w;
    }
    public Worm pop(){
	return stack[out++];
    }
    public boolean isEmpty(){
	return sp==out;
    }
}
*/

 class Worm{
    String body;
    int time;
    public  Worm(String s, int t){
	body = s;
	time = t;
    }
    public  String getbody(){
	return body;
    }
    public int getTime(){
	return time;
    }
}

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

int main(){
    int num;
    int i;
    double x1, y1, x2, y2, x3, y3, x4, y4;
    double cross;

    cin >> num;

    for(i = 0; i < num; i++){
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;

        cross = abs((x2 - x1) * (y4 - y3) - (y2 - y1) * (x4 - x3));
        if(cross < 1e-11){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll K;
    cin >> K;
    
    if(K%2==0 or K%5==0){
        cout << -1 << endl;
        return 0;
    }

    ll ans;
    ll a = 0;
    repe(i, 1, K + 1){
        a = (a * 10 + 7) % K;
        if(a==0){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    string S,T;
    cin >> S >> T;
    int L=S.length();
    bool alf[26][26]={};
    bool check=true;
    rep(i,L){
        int x=S[i]-'a',y=T[i]-'a';
        if(alf[x][y]){
            check=false;
            break;
        }
        else{
            rep(j,26) if(j!=y) alf[x][j]=true;
            rep(j,26) if(j!=x) alf[j][y]=true;
        }
    }
    if(check) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    string s1,s2;
cin >> s1 >> s2;
if(s1 == "H"){
 cout << s2 << endl;
}else{
if(s2 == "H") cout << "D" << endl;
else cout << "H" << endl;
}
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdlib>

using namespace std;

struct State {
  State(int64_t t, int64_t x_, int64_t y_) noexcept : time(t), x(x_), y(y_) {}

  int64_t time;
  int64_t x;
  int64_t y;
};

bool CanMove(const State &from, const State &to) noexcept {

  int64_t time = to.time - from.time;
  int64_t move = llabs(to.x - from.x) + llabs(to.y - from.y);

  return ((move <= time) && ((time - move) % 2 == 0));
}

int main() {

  int64_t n;

  cin >> n;

  State from{0, 0, 0};

  for (int64_t i = 0; i < n; ++i) {
    int64_t t, x, y;

    cin >> t >> x >> y;
    State to{t, x, y};

    if (!CanMove(from, to)) {
      cout << "No" << endl;
      return 0;
    }

    from = to;
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 888
import javax.swing.*;
import java.io.*;
import java.util.*;
import java.math.*;

import static java.util.Comparator.*;


public class Main {
    public static void main(String[] args) throws IOException {
        FastReader s = new FastReader();
        int a=s.nextInt();
        int b=s.nextInt();
        int numOfSock=1;
        int count=0;
        while(numOfSock<b)
        {
            numOfSock-=1;
            numOfSock+=a;
            count++;
        }

        System.out.println(count);


    }

}

class FastReader
{
    BufferedReader br;
    StringTokenizer st;

    public FastReader()
    {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }

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

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

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

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

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

Measured memory_bytes: 24656
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		long N = Long.parseLong(br.readLine());
		br.close();

		for (long h = 1; h <= 3500; h++) {
			for (long n = 1; n <= 3500; n++) {
				long x = h*n*N;
				long y = 4*h*n - n*N - h*N;
				if (y > 0 && x % y == 0) {
					System.out.println(h + " " + n + " " + x/y);
					return;
				}
			}
		}
	}
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    OP(max(min(b, d) - max(a, c), 0));

    return 0;
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
l.sort()
a=[]
tmp=l.pop(-1)
while len(a)<2 and len(l)>0:
  if tmp==l[-1]:
    a.append(tmp)
    l.pop(-1)
    if len(l)==0:
      break
    tmp=l.pop(-1)
  else:
    tmp=l.pop(-1)
if len(a)<2:
  print(0)
else:
  print(a[-1]*a[-2])

Measured memory_bytes: 14224
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	void solve() {
		Scanner sc = new Scanner(System.in);
		char[] c = sc.next().toCharArray();
		sc.close();

		char res = 0;
		if(c[0]=='A')res='T';
		else if(c[0]=='T')res='A';
		else if(c[0]=='C')res='G';
		else if(c[0]=='G')res='C';

		System.out.println(res);
	}

}


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

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;

    while(a || c){
        c-=b;if(c<=0){
        cout<< "Yes"<<endl;
        break;
        }
        a-=d;if(a<=0){
        cout<< "No"<<endl;
        break;
        }
    }
    return 0;
}


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

int main()
{
	int gcd_2(int x,int y);
	int gcd_3(int x,int y,int z);
	
	int k,sum=0;
	cin >> k;
	
	for(int i=1;i<=k;i++)
		for(int j=1;j<=k;j++)
			for(int h=1;h<=k;h++)
			{
				sum+=gcd_3(i,j,h);
			}
	
	cout << sum;
	return 0;
}
int gcd_2(int x,int y)
{
	int z=y;
	while(x%y!=0)
	{
		z = x%y;
		x = y;
		y = z;
	}
	return z;
}
int gcd_3(int x,int y,int z)
{
	int p;
	p = gcd_2(x,y);
	return gcd_2(p,z);
}

Measured memory_bytes: 3636
import collections


class MaxFlow:
    """Dinic Algorithm: find max-flow
       complexity: O(EV^2)
       used in GRL6A(AOJ)
    """
    class Edge:
        def __init__(self, to, cap, rev):
            self.to, self.cap, self.rev = to, cap, rev

    def __init__(self, V):
        """ V: the number of vertexes
            E: adjacency list
            source: start point
            sink: goal point
        """
        self.V = V
        self.E = [[] for _ in range(V)]

    def add_edge(self, fr, to, cap):
        self.E[fr].append(self.Edge(to, cap, len(self.E[to])))
        self.E[to].append(self.Edge(fr, 0, len(self.E[fr])-1))

    def dinic(self, source, sink):
        """find max-flow"""
        INF = float('inf')
        maxflow = 0
        while True:
            self.bfs(source)
            if self.level[sink] < 0:
                return maxflow
            self.itr = [0] * self.V
            while True:
                flow = self.dfs(source, sink, INF)
                if flow > 0:
                    maxflow += flow
                else:
                    break

    def dfs(self, vertex, sink, flow):
        """find augmenting path"""
        if vertex == sink:
            return flow
        for i in range(self.itr[vertex], len(self.E[vertex])):
            self.itr[vertex] = i
            e = self.E[vertex][i]
            if e.cap > 0 and self.level[vertex] < self.level[e.to]:
                d = self.dfs(e.to, sink, min(flow, e.cap))
                if d > 0:
                    e.cap -= d
                    self.E[e.to][e.rev].cap += d
                    return d
        return 0

    def bfs(self, start):
        """find shortest path from start"""
        que = collections.deque()
        self.level = [-1] * self.V
        que.append(start)
        self.level[start] = 0

        while que:
            fr = que.popleft()
            for e in self.E[fr]:
                if e.cap > 0 and self.level[e.to] < 0:
                    self.level[e.to] = self.level[fr] + 1
                    que.append(e.to)

V, E = map(int, input().split())
mf = MaxFlow(V)
source, sink = 0, V-1

for _ in range(E):
    s, t, c = map(int, input().split())
    mf.add_edge(s, t, c)
print(mf.dinic(source, sink))

Measured memory_bytes: 8360
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

using namespace std;

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

    int a, b;
    cin >> a >> b;

    switch( (a*b)%2 ){
        case 0:
        cout << "No";
        break;

        case 1:
        cout << "Yes";
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
 char a[2];
  
 scanf("%s",a);
    
 if(strcmp(a,"ABC") == 0){
  printf("ARC"); 
 }else{
  if(strcmp(a,"ARC") == 0){
  printf("ABC"); 
  } 
 }
 return 0;
}

Measured memory_bytes: 2148
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <fstream>
using namespace std;
#define INF 0x3f3f3f3f
bool f[105];
int main() {
	int a[3][3];
	for (int i = 0; i < 3; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];
	int n, x;
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> x, f[x] = true;
	for (int i = 0; i < 3; ++i)
		for (int j = 0; j < 3; ++j)
			if (f[a[i][j]]) a[i][j] = 0;
	bool flag = false;
	for(int i = 0;i < 3;++i)
		if (a[i][0] == a[i][1]&& a[i][0] == a[i][2]) {
			flag = true;
			break;
		}
		else if (a[0][i] == a[1][i]&&a[0][i] == a[2][i]) {
			flag = true;
			break;
		}
	if (a[0][0] == a[1][1]&&a[1][1] == a[2][2]) flag = true;
	if (a[0][2] == a[1][1]&&a[1][1] == a[2][0]) flag = true;
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define T second.first
#define C second.second
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int,pair<int,int>> piii;

const int N= 1e5+5, L = 14, OO = 0x3f3f3f3f;
const ll M=10 ;
const double ESP = 1e-8;

int n;
int A[N], mem[N];

int solve(int idx){
    if(idx == n-1)
        return 0;

    int& ret = mem[idx];
    if(~ret)
        return ret;

    ret = (idx+2<n)? solve(idx+2) + abs(A[idx]-A[idx+2]) : OO;
    return ret = min(ret, solve(idx+1)+ abs(A[idx]-A[idx+1]));
}

int main(){
    FIO
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    cin>>n;
    memset(mem, -1, sizeof mem);
    for(int i=0; i<n; i++)cin>>A[i];
    cout<<solve(0);

}


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

typedef long long ll;
typedef pair<int,int> P;
ll const INF = 1LL<<60;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int n;
ll dp[3010][3010];
int a[3010];

ll rec(int l,int r) {
    if (dp[l][r] > -INF) return dp[l][r];
    if (l > r) dp[l][r] = 0;
    else if ((l+n-r)&1) dp[l][r] = max(rec(l+1,r)+a[l],rec(l,r-1)+a[r]);
    else dp[l][r] = min(rec(l+1,r)-a[l],rec(l,r-1)-a[r]);
    return dp[l][r];
}

int main() {
    cin >> n;
    for (int i = 0;i < n;++i) cin >> a[i];
    for (int i = 0;i < n+1;++i) for (int j = 0;j < n+1;++j) dp[i][j] = -INF;
    cout << rec(0,n-1) << endl;
    return 0;
}

Measured memory_bytes: 70912
n = int(input())
a = [int(_) for _ in input().split(' ')]

if n % 3 == 0:
    a.sort()
    m = n // 3
    if a[0] == a[m - 1] and a[m] == a[2 * m - 1] and a[2 * m] == a[3 * m - 1]:
        if a[0] ^ a[m] ^ a[2 * m] == 0:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    if max(a) == min(a):
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 14212
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val aList = readLongList()

    var ans = 0L
    val mod = 1000000007L

    var sum = aList.sum() % mod
    for (a in aList) {
        sum = (((sum - a) % mod) + mod) % mod
        ans = (ans + (a * sum) % mod) % mod
    }
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 64000
/**Bismillahir Rahmanir Raheem
    Author:Refatul Fahad**/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
#define IOS  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define sz(s)  (int)s.size()
#define all(s)  s.begin(),s.end()
const int N = 1e5 + 5;
const ll M = (ll)1e9 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}

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

int main() {

    //IOS;
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);

    int test=1;
    //cin>>test;
    for(int cs=1; cs<=test; ++cs) {
        ll n,k,d,res;
        cin>>n>>k>>d;
        if(n<0ll)n*=-1ll;//cout<<;
        ll di=n/d;
        if(di>k){
            res=n-(d*k);
        }
        else{
            res=n%d;
        }
        k-=di;

        if(k>0) {
            if(k%2) {
                if(res==0ll) {
                    res+=d;
                } else {
                    res-=d;
                }
            }
        }
        cout<<abs(res)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3644
const Main = (input) => {
	var xs =input.trim().split(' ').map(v=>parseInt(v,10));
    var nums = xs[0]*xs[2]-xs[1];
    for(var i = 0; i<=9; i++){
    	const ans = (a,b,c) => {
    	return xs[0]*nums-xs[1];
    	}
        console.log(nums);
    	nums = ans(xs[0],nums,xs[1]);
    	
    }

}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7628
#include<stdio.h>
 
int main(){
	
  int A,B;
  scanf("%d",&A);
  scanf("%d",&B);
  
  if(A>B)
    printf("%d", 2*A-1);
  if(B>A)
    printf("%d", 2*B-1);
  if(A==B)
    printf("%d", A+B);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a==b)
        cout<<"Draw"<<endl;
    else if (a==1)
        cout<<"Alice"<<endl;
    else if (b==1)
        cout<<"Bob"<<endl;
    else if (a>b)
        cout<<"Alice"<<endl;
    else cout<<"Bob"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+10,mo=1e9+7;
#define ll long long 
ll f[N][10];
int n;
char s[N];
int nxt[9][2]={
	0,0,
	2,5,
	3,4,
	2,2,
	2,5,
	7,6,
	6,6,
	8,5,
	7,7
};
bool vis[N][10];
ll findans(int i,int k){
	if(i==n||vis[i][k]) return f[i][k];
	vis[i][k]=1;
	if(s[i+1]=='0') return f[i][k]=findans(i+1,nxt[k][0]);
	else if(s[i+1]=='1') return f[i][k]=findans(i+1,nxt[k][1]);
	else return f[i][k]=( findans(i+1,nxt[k][0])+findans(i+1,nxt[k][1]) )%mo;
}
int main()
{
	//freopen("022e.in","r",stdin);
	scanf("%s",s+1);
	n=strlen(s+1);
	f[n][5]=f[n][6]=1;
	findans(0,1);
	cout<<f[0][1]%mo;
	return 0;
}

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

int main()
{
    ll H,W;
    cin >> H >> W;
    if(H == 1 || W == 1){
        cout << "1" << endl;
    }else if(H%2 == 1 && W%2 == 1){
        cout << (H*W+1)/2 << endl;
    }else{
        cout << H*W/2 << endl;
    }
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


void solve() {
    //int i,j,k,l,r,x,y; string s;
    int i;
    bool exit = false;
    int N;
    cin>>N;
    vector <int> x,y;
    vector <ll> h;
    int Id=0;
    FOR(i,N){
        ll input;
        cin>>input;
        x.push_back(input);
        cin>>input;
        y.push_back(input);
        cin>>input;
        h.push_back(input);
        if(h[i] != 0)
            Id=i;
    }
    int Cx,Cy,retX=-1,retY=-1;
    ll H;
    ll zero=0;
    FOR(Cx,101){
        FOR(Cy,101){
            exit=false;
            FOR(i,N){
                if(i==Id) continue;
                if( max((abs(Cx-x[Id])+abs(Cy-y[Id])+h[Id])-abs(Cx-x[i])-abs(Cy-y[i]),zero)  != h[i] ){
                    //cout<<Cx<<" "<<Cy<<" "<<i<<endl;
                    exit=true;
                    break;
                }
            }
            if(exit==false){
                //cout<<Cx<<Cy<<endl;
                retX=Cx;
                retY=Cy;
            }
        }
    }
    cout<<retX<<" "<<retY<<" "<<abs(retX-x[Id])+abs(retY-y[Id]) + h[Id]<<endl;
    /*cin>>N;
    vector<ll> V;
    FOR(x,N+1) {
            FOR(y,N+1) {
                    ll ret=1;
                    FOR(i,x) ret*=2;
                    FOR(i,y) ret*=5;
                    V.push_back(ret);
            }
    }
    sort(ALL(V));
    FORR(v,V) cout<<v<<endl;*/
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}





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

int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  int cnt = 0;
  vector<long long> hw;
  for (int i = 0; i < N-1; i++) {
    if (A.at(i) == A.at(i+1)) {
      hw.push_back(A.at(i));
      cnt++;
      i++;
    }
  }
  if (cnt >= 2) cout << hw.at(0) * hw.at(1) << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;cin>>s;
  int l=0,r=s.size()-1;
  while(true){
    if(s[l]=='A')break;
    l++;
  }
  while(true){
    if(s[r]=='Z')break;
    r--;
  }
  cout<<r-l+1<<endl;
}

Measured memory_bytes: 640
n = int(input())
a, b = [], []
for i in range(n):
    a_, b_ = map(int, input().split())
    a.append(a_)
    b.append(b_)
ans = 0
for i in range(n - 1, -1, -1):
    if (a[i] + ans) % b[i] != 0:
        ans += b[i] - ((a[i] + ans) % b[i])
print(ans)

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p.at(i);
  }
  sort(p.begin(), p.end());
  int ans = 0;
  for(int i = 0; i < k; i++) {
    ans += p.at(i);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.000000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

int main()
{
    fast();
    ll n;
    cin>>n;
    vi a(n);
    cin>>a;

    vi count(1000001,0);
    for(ll i=0;i<n;i++)
        count[a[i]]++;

    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        bool possible=true;
        for(ll j=1;j*j<=a[i];j++)
        {
            if(a[i]%j==0)
            {
                ll fac1=a[i]/j;
                ll fac2=j;

                if(count[fac1]>0)
                {
                    if(fac1==a[i])
                    {
                        if(count[fac1]>1)
                            possible=false;
                    }
                    else
                    {
                        possible=false;
                        break;
                    }
                }
                if(count[fac2])
                {
                    if(fac2==a[i])
                    {
                        if(count[fac2]>1)
                            possible=false;
                    }
                    else
                    {
                        possible=false;
                    }
                }
            }
        }
        if(possible)
            ans++;
    }
    cout<<ans<<nl;
}


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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	string s;
	int k;
	cin >> k >> s;
	if(s.size() <= k) {
		finish(s);
	} else {
		M00(i, k) cout << s[i];
		cout << "...\n"; 
	}
}


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

int main()
{
    int a, b;
    cin >> a >> b;
    if (a >= 10 || b >= 10)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << a * b << endl;
    }

    return 0;
}

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

namespace Swapping_Two_Numbers
{
    class Program
    {
        static void Main(string[] args)
        {
            for (;;)
            {
                string[] str = Console.ReadLine().Split(' ');
                int x = int.Parse(str[0]);
                int y = int.Parse(str[1]);
                if (x == 0 && y == 0)
                    break;
                else if (x >= y)
                    Console.WriteLine(y + " " + x);
                else if (y > x)
                    Console.WriteLine(x + " " + y);

            }
        }
    }
}

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

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int l, r, d;
    cin >> l >> r >> d;
    int c = 0;
    for (int i = l; i <= r; i++)
    {
        if (i % d == 0)
        {
            c++;
        }
    }
    cout << c;
}

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

vector<ll> get_divisors(ll num)
{
    deque<ll> divisors;
    for (ll i = 1; i * i <= num; i++) {
        if (num % i == 0) {
            divisors.push_front(i);
            if (i * i < num) {
                divisors.push_back(num / i);
            }
        }
    }
    return vector<ll>(begin(divisors), end(divisors));
}

void main_()
{
    ll N, M;
    cin >> N >> M;

    auto Mdivs = get_divisors(M);

    ll ans = *max_element(begin(Mdivs), partition(begin(Mdivs), end(Mdivs), [border = M / N](auto n) { return n <= border; }));

    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<map>
#include<queue>
using namespace std;
int main(){
    int magic[3][3];
    cin >> magic[0][0] >> magic[0][1] >> magic[1][1];
    magic[2][1] = 2 * magic[1][1] - magic[0][1];
    magic[2][2] = 2 * magic[1][1] - magic[0][0];
    magic[1][0] = 2 * magic[2][2] - magic[0][1];
    magic[0][2] = (magic[1][0] + magic[2][1]) / 2;
    magic[2][0] = 2 * magic[1][1] - magic[0][2];
    magic[1][2] = 2 * magic[1][1] - magic[1][0];
    cout << magic[0][0] << " " << magic[0][1] << " " << magic[0][2] << endl;
    cout << magic[1][0] << " " << magic[1][1] << " " << magic[1][2] << endl;
    cout << magic[2][0] << " " << magic[2][1] << " " << magic[2][2] << endl;
endapp:
	//system("pause > nul");
	return 0;
}

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

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

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

int main() {
    int n, r;
    cin >> n >> r;
    if(n >= 10) {
        cout << r << endl;
    } else {
        cout << r +100 * (10 - n) << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, K;
    cin >> N >> K;
    int n = 1;
    rep(i, 0, N)
    {
        n = min(n * 2, n + K);
    }
    cout << n << endl;
}


Measured memory_bytes: 256
n = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))
ans = 0
def binary_search(S,key):  #昇順リストSからkeyを探す。
    n = len(S)             #存在したらindex,なかったら-1を返す
    left  = 0
    right = n
    while left < right:
        mid = (left+right) // 2
        if S[mid] == key:
            return mid
        elif S[mid] > key:
            right = mid
        else:
            left = mid + 1
    return -1
for i in range(q):
    if binary_search(S,T[i]) != -1:
        ans += 1
print(ans)


Measured memory_bytes: 16712
#include <iostream>

using namespace std;

int main(){
    char S[4], T[4];
    int c = 0;
    cin >> S >> T;
    for(int i = 0; i < 3; i++){
        if(S[i] == T[i])
            c++;
    }
    cout << c << endl;
    return 0;
}

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

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

ll N, th, cnt=0;
vll H;

void solve(){
    th = H[0];

    rep(i,N){
        if(H[i] >= th){
            th = H[i];
            cnt++;
        }
    }
    cout << cnt << endl;
}

int main(){
    cin >> N;
    H.resize(N,0);

    rep(i,N)
        cin >> H[i];

    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 998244353;


int main() {
    ll n;
    cin >> n;
    int cnt = 0; 
    ll p = 2;
    while(n > 1) {
        ll np = p;
        while (n%np == 0) {
            n /= np;
            np *= p;
            ++cnt;
        }
        while (n%p == 0) n /= p; 
        ++p;
        if (p > 3 && p*p > n)  break;
    } 
    if (n > 1) ++cnt;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(x!=a.x)
    return y>a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[101];
long long l[51][55][3333];
int j[1];

long long x,y,z,mod=1000000007;
//string r;
char r[21];

P u[1];
//queue<int> q;
//stack<int> s;
set<int> s;
map<long long,int> p;

vector<int> v;

bool as(P a,P b)
{
  //if(a.x!=b.x)
  //return a.x<b.x;
  return a.x<b.x;
}

long long f(int n,int m,int k)
{
  if(n>a)
  {
    if(k&&b*m==k) return 1;
    return 0;
  }
  if(l[n][m][k]>=0) return l[n][m][k];
  return l[n][m][k]=(f(n+1,m+1,k+o[n])+f(n+1,m,k));
}

int main()
{
  scanf("%d %d",&a,&b);
  for(int t=1;t<=a;t++)
    scanf("%d",&o[t]);
  memset(l,-1,sizeof(l));
  printf("%lld",f(1,0,0));
}
//2
//21



Measured memory_bytes: 73344
nv, ne, r = map(int, input().split(' '))
dist = [float('inf')] * nv
dist[r] = 0
edges = []
for i in range(ne):
    s, t, w = map(int, input().split(' '))
    edges.append((s, t, w))

for i in range(nv - 1):
    for s, t, w in edges:
        if dist[t] > dist[s] + w:
            dist[t] = dist[s] + w

for s, t, w in edges:
    if dist[t] > dist[s] + w:
        print("NEGATIVE CYCLE")
        exit()

[print(d) if d < float('inf') else print("INF") for d in dist]

Measured memory_bytes: 8172
#include<stdio.h>

int main()
{
	int a, b, x;

	scanf("%d%d%d", &a, &b, &x);

	if (a + b < x)
		printf("NO\n");
	else if (a>x)
		printf("NO\n");
	else
		printf("YES\n");

	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int main(){
	
	long long int N;
	
	cin >> N;
	
	long long int a[100];
	
	for(int i = 0; i < N; i++){
		cin >> a[i];
	}
	
	long long int ans = 0;
	
	while(true){
		long long int max = N - 1;
		long long int index = -1;
		for(int i = 0; i < N; i++){
			if(max < a[i]){
				max = a[i];
				index = i;
			}
		}
		if(index == -1){
			break;
		}
		long long int div = a[index] / N;
		ans += div;
		a[index] -= div * (N + 1);
		for(int i = 0; i < N; i++){
			a[i] += div;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 256
using System;

namespace tenki
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            string[] arr = Console.ReadLine().Split(' ');
            double average;

            double[] box = new double[num];
            for (int i = 0; i < num; i++)
            {
                box[i] = int.Parse(arr[i]);
            }

            Array.Sort(box);

            if (num < 1)

            {
                average = box[0];
            }
            else
            {
                average = (box[0] + box[1]) / 2;
                if (num > 2)
                {
                    for (int i = 2; i < num; i++)
                    {
                        average = (average + box[i]) / 2;
                    }
                }
            }
            Console.WriteLine(average);
        }

    }
}


Measured memory_bytes: 11348
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
	int n, u, k, tmp;
	int v[100];
	int ans[100][100] = {};
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> u >> k;
		for (int j = 0; j < k; j++)
		{
			cin >> tmp;
			ans[u - 1][tmp - 1] = 1;
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n-1; j++)
		{
			cout << ans[i][j] << " "; 
		}
		cout << ans[i][n - 1] << endl;
	}
	return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <sstream>
#include <tuple>
#include <fstream>
#include <numeric>

using namespace std;

#define fori(t) for(int i = 0; i < t; ++i)
#define forj(n) for(int j = 0; j < n; ++j)
#define fork(n) for(int k = 0; k < n; ++k)
#define forai(a) for(auto i : a)
#define foraj(a) for(auto j : a)
#define forak(a) for(auto k : a)
#define forp(s, n, d) for(int p = s; p < n; p += d)
#define fast cin.tie(0); cout.tie(0); std::ios_base::sync_with_stdio(0);
#define pb(a) push_back(a);
#define pob(a) pop_back(a);
#define sorti(a) sort(a.begin(), a.end());
#define sortm(a, n) sort(a, a + n);
#define reversi(a) reverse(a.begin(), a.end());
#define fi first
#define se second
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define ans(a) cout << a << '\n';
#define res(a, n) a.resize(n);
#define read(a, n) a.resize(n); fori(n) cin >> a[i];
//#define int long long
//#define double long double

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<long long, long long> llll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<int, pair<int, int>>> viii;
typedef pair<int, pair<int, int>> iii;
typedef vector<pair<long long, long long>> vllll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<char, char> cc;
typedef pair<pair<char, char>, char> ccc;
typedef vector<char> vc;
typedef pair<int, char> ic;
typedef pair<ii, char> iic;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef set<ii> sii;

const int INF = 2147483647;
const ll LONGINF = 9223372036854775807;
const ll MOD = 998244353;

void solve()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int count = 0;
    while (b <= a)
    {
        ++count;
        b *= 2;
    }
    while (c <= b)
    {
        ++count;
        c *= 2;
    }
    if (count > k) ans("No")
    else ans("Yes")
}

signed main()
{
    fast
    bool mult = false;
    if (mult)
    {
        int t;
        cin >> t;
        while (t--) solve();
    }
    else solve();
}


Measured memory_bytes: 3648
#include<bits/stdc++.h> 
using namespace std; 
int main() 
{
	int a, b; cin>>a>>b;
	if(a==b) cout<<0;else if((a % 10 + b % 10) % 2 != 0) cout<<"IMPOSSIBLE"; else cout<<(a + b) * 1LL / 2;
    return 0;
} 


Measured memory_bytes: 256
s = input()
s2 = ""
flag=0

#BCをDに変換
for i in range(len(s)-1):
    if(flag==0):
        if(s[i]=="B" and s[i+1]=="C"):
            s2 += "D"
            flag = 1
        else:
            s2 += s[i]
    else:
        flag=0
    if(len(s)<=i+2):
        break

#ADをDAに
anum = 0
ans = 0

for i in s2:
    if i=="A":
        anum += 1
    elif i=="D":
        ans += anum
    else:
        anum = 0

print(ans)

Measured memory_bytes: 3500
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n)      std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n)   std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1,p2)    ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)       fgets((p), sizeof(p), stdin)
#define CHOMP(p)        do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n') *_q = 0; } while(0)

#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)
#define DEQ(a,b) (abs((a)-(b)) < EPS)

inline D outprd(const P &a, const P &b){ return (conj(a) * b).Y; }
bool is_parallel(P &p1, P &p2, P &p3, P &p4){
    return DEQ(outprd(p1-p2, p3-p4), 0.0);
}

int main(){
    int n;
    cin >> n;
    REP(i,n){
        double x1, y1, x2, y2, x3, y3, x4, y4;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        P p1(x1,y1), p2(x2,y2), p3(x3,y3), p4(x4,y4);
        if(is_parallel(p1,p2,p3,p4)){
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1232
object Main {
    val x = scala.collection.mutable.Map[Char, Int]().withDefaultValue(0)
    def main(args: Array[String]) = {
        for (line <- io.Source.stdin.getLines; c <- line) x((c.toLower)) += 1
        ('a' to 'z').foreach(c => println(c + " : " + x(c)))
    }
}



Measured memory_bytes: 44720