akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define ll long long
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    int n;
    cin >> n;
    vector<int>xn(n);
    double sum = 0;
    for(int i = 0; i < n; i++){
        cin >> xn.at(i);
        sum += xn.at(i);
    }
    int ave;
    ave = round(sum / n);
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans += (xn.at(i) - ave) * (xn.at(i) - ave);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        
        int A[][] = new int[3][3];
        boolean B[][] = new boolean[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                A[i][j] = in.nextInt();
                B[i][j] = false;
            }
        }
        
        int N = in.nextInt();
        for (int n = 0; n < N; n++) {
            int a = in.nextInt();
            for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 3; j++) {
                    if (A[i][j] == a) {
                        B[i][j] = true;
                        continue;
                    }
                }
            }
        }        
        
        for (int i = 0; i < 3; i++) {
            if (B[i][0] && B[i][1] && B[i][2]) {
                System.out.println("Yes");
                return;
            }
            
            if (B[0][i] && B[1][i] && B[2][i]) {
                System.out.println("Yes");
                return;
            }
        }
        
        if (B[0][0] && B[1][1] && B[2][2]) {
            System.out.println("Yes");
            return;
        }
        
        if (B[0][2] && B[1][1] && B[2][0]) {
            System.out.println("Yes");
            return;
        }
         
        System.out.println("No");
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long H, long long W, long long N, std::vector<long long> a)
{
    ll ans[H][W];
    ll tmpIndex = N-1;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (a[tmpIndex] == 0)
            {
                tmpIndex--;
            }
            if (i % 2 == 0)
            {
                ans[i][j] = tmpIndex + 1;
            }
            else
            {
                ans[i][W - j - 1] = tmpIndex + 1;
            }
            a[tmpIndex]--;
        }
    }

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}

int main()
{
    long long H;
    scanf("%lld", &H);
    long long W;
    scanf("%lld", &W);
    long long N;
    scanf("%lld", &N);
    std::vector<long long> a(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &a[i]);
    }
    solve(H, W, N, std::move(a));
    return 0;
}


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

int main(void){
	string b[9] = {
		".,!? ",
		"abc",
		"def",
		"ghi",
		"jkl",
		"mno",
		"pqrs",
		"tuv",
		"wxyz",
	};

	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string s; //char s[100];
		cin>>s;
		int len = s.length();

		//OÌ¶ before
		//beforeª½ñ±¢½© count
		char before = '0';
		int count = 0;
		for(int i=0;i<len;i++){
			if(s[i] == '0' && before != '0'){
				cout<<b[before - '1'][(count - 1) % b[before - '1'].length()];
				before = '0';
				count = 0;
			}
			else if('1' <= s[i] && s[i] <= '9'){
				before = s[i];
				count++;
			}
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(int argc, char *argv[])
{
  char S[4];
  int ans=700;

  scanf("%s",S);

  for(int i=0;i<=2;i++){
    if(S[i] == 'o'){
      ans += 100;
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	bit := getNextInt(scanner)
	n := 1 << uint(bit)
	aa := make([]int, n)

	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	ysp48 := make([][]Pair, bit+1)
	for i := 0; i < bit+1; i++ {
		ysp48[i] = make([]Pair, n)
	}
	for i := 0; i < n; i++ {
		ysp48[0][i].top = aa[i]
	}

	for b := 0; b < bit; b++ {
		for i := 0; i < n; i++ {
			if ysp48[b+1][i].second > ysp48[b][i].top {
				continue
			}
			ysp48[b+1][i].second = ysp48[b][i].top
			if ysp48[b+1][i].second > ysp48[b+1][i].top {
				ysp48[b+1][i].second, ysp48[b+1][i].top = ysp48[b+1][i].top, ysp48[b+1][i].second
			}
			if ysp48[b+1][i].second > ysp48[b][i].second {
				continue
			}
			ysp48[b+1][i].second = ysp48[b][i].second
		}
		for i := 0; i|1<<uint(b) < n; i++ {
			if i>>uint(b)&1 == 1 {
				continue
			}
			if ysp48[b+1][i|1<<uint(b)].second > ysp48[b][i].top {
				continue
			}
			ysp48[b+1][i|1<<uint(b)].second = ysp48[b][i].top
			if ysp48[b+1][i|1<<uint(b)].second > ysp48[b+1][i|1<<uint(b)].top {
				ysp48[b+1][i|1<<uint(b)].second, ysp48[b+1][i|1<<uint(b)].top = ysp48[b+1][i|1<<uint(b)].top, ysp48[b+1][i|1<<uint(b)].second
			}
			if ysp48[b+1][i|1<<uint(b)].second > ysp48[b][i].second {
				continue
			}
			ysp48[b+1][i|1<<uint(b)].second = ysp48[b][i].second
		}
	}

	var max int64
	for i := 1; i < n; i++ {
		ans := int64(ysp48[bit][i].top) + int64(ysp48[bit][i].second)
		if max < ans {
			max = ans
		}
		fmt.Fprintln(writer, max)
	}
	writer.Flush()
}

type Pair struct {
	top, second int
}


Measured memory_bytes: 89728
n = int(input())
li = list(map(int, input().split()))

arr = li.copy()
arr += [i - 1 for i in li]
arr += [i + 1 for i in li]

arr.sort()

ans = 1
cnt = 1
tmp = arr[0]
for a in arr[1:]:
    if a != tmp:
        if cnt > ans:
            ans = cnt
        tmp = a
        cnt = 1
    else:
        cnt += 1

print(ans)

Measured memory_bytes: 18776
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)


int main() {
	double a, b, c, d, e=0, f,i, g,l[100];
	cin >> a >> b>>c>>d;
	f = a*b/2;
	cout << f << " ";
	if (c == a / 2 && d == b / 2)cout << 1;
	else cout << 0;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//t時間で(0,0)から目的地にたどり着けるか
bool checker(int t, int x, int y){
  //偶数奇数の条件
  if((t - x - y) % 2 != 0) return false;

  //最短で向かっても無理なら無理
  if(abs(x) + abs(y) > t) return false;

  return true;
}

int main(){
  int N;
  cin >> N;
  vector<int> t(N), x(N), y(N);
  vector<int> dt(N), dx(N), dy(N); 
  for(int i = 0; i < N; i++){
    cin >> t.at(i) >> x.at(i) >> y.at(i);
  }
  dt = t, dx = x, dy = y;
  if(N >= 2){
    for(int i = 1; i < N; i++){
      dt.at(i) = t.at(i) - t.at(i-1);
      dx.at(i) = x.at(i) - x.at(i-1);
      dy.at(i) = y.at(i) - y.at(i-1);
    }
  }
  
  bool flag = true;
  for(int i = 0; i < N; i++){
    if(!checker(dt.at(i), dx.at(i), dy.at(i))) flag = false;
  }
    
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n, m, k;
typedef vector<vi> M;
M operator*(const M &a, const M &b){
	M c(a.size(), vi(a.size()));
	rep(i, n) rep(j, n) c[i][j] = max(a[i][j], b[i][j]);
	rep(l, n) rep(i, n) rep(j, n) if(a[i][l] >= 0 && b[l][j] >= 0){
		c[i][j] = max(c[i][j], a[i][l] + b[l][j]);
		if(c[i][j] >= k) c[i][j] = k;
	}
	return c;
}
int dp[128][150], prev[128][150];
void solve(const M &e, int it){
	memset(dp, -1, sizeof(dp));
	rep(i, n) dp[0][i] = 0;
	int ai, al, mx = 0;
	
	rep(i, it) rep(j, n) if(dp[i][j] >= 0){
		rep(l, n) if(e[j][l] >= 0 && dp[i + 1][l] < dp[i][j] + e[j][l]){
			dp[i + 1][l] = dp[i][j] + e[j][l];
			prev[i + 1][l] = j;
			if(dp[i + 1][l] >= k && dp[i + 1][l] > mx){
				ai = i + 1; al = l; mx = dp[i + 1][l];
			}
		}
	}
	END:
	vi ans;
	for(; ai >= 0; ai--){
		ans.pb(al);
		if(ai > 0) al = prev[ai][al];
	}
	reverse(all(ans));
	rep(i, ans.size()) cout << ans[i] << (i == ans.size() - 1 ? "\n" : " ");
}
int main(){
	cin >> n >> m >> k;
	M e(n, vi(n, -1)), p(n, vi(n, -1));
	M pw[20];
	
	rep(i, m){
		int a, b, c;
		cin >> a >> b >> c;
		e[a][b] = max(e[a][b], c);
	}
	
	rep(i, n) p[i][i] = 0;
	pw[0] = e;
	rep(i, 19) pw[i + 1] = pw[i] * pw[i];
	
	int ans = 0;
	bool can = 0;
	for(int i = 19; i >= 0; i--){
		M pp = p * pw[i];
		
		bool ok = 0;
		rep(j, n) rep(l, n) if(pp[j][l] >= k) ok = can = 1;
		if(!ok) p = pp, ans += 1 << i;
	}
	if(!can){
		cout << -1 << endl;
		return 0;
	}
	ans++;
	cout << ans << endl;
	if(ans <= 100) solve(e, ans);
	return 0;
}

Measured memory_bytes: 3352
public partial class IntroductionToProgramming{
	public static void Main(){
		string[] line = System.Console.ReadLine().Split(' ');
		int m = int.Parse(line[0]);
		int f = int.Parse(line[1]);
		int r = int.Parse(line[2]);

		while (!(m == -1 && f == -1 && r == -1))
		{
			string grade = "";
			if (m == -1 || f == -1)
			{
				grade = "F";
			}
			else
			{
				if(m + f >= 80)
				{
					grade = "A";
				}
				else if(m + f >= 65)
				{
					grade = "B";
				}
				else if(m + f >= 50)
				{
					grade = "C";
				}
				else if (m + f >= 30 && r >= 50)
				{
					grade = "C";
				}
				else if (m + f >= 30)
				{
					grade = "D";
				}
				else
				{
					grade = "F";
				}
			}
			System.Console.WriteLine(grade);

			string[] line2 = System.Console.ReadLine().Split(' ');
			m = int.Parse(line2[0]);
			f = int.Parse(line2[1]);
			r = int.Parse(line2[2]);
		}
	}
}

Measured memory_bytes: 5300
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

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

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		int[] arr = new int[3 * N];

		SubArray sa1 = new SubArray(SubArray.ASC);
		SubArray sa2 = new SubArray(SubArray.DESC);

		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
			sa1.add(arr[i]);
		}
		for (int i = N, M = 2 * N; i < M; i++) {
			arr[i] = sc.nextInt();
		}
		for (int i = 2 * N, M = 3 * N; i < M; i++) {
			arr[i] = sc.nextInt();
			sa2.add(arr[i]);
		}

		long[] first = new long[N + 1];
		long[] second = new long[N + 1];

		for (int k = 0; k <= N; k++) {
			int j1 = N + k;
			int j2 = 2 * N - k - 1;

			first[k] = sa1.total;
			sa1.add(arr[j1]);
			sa1.removeTop();

			second[N - k] = sa2.total();
			sa2.add(arr[j2]);
			sa2.removeTop();
		}

		long score = first[0] - second[0];
		for (int i = 1; i <= N; i++) {
			score = Math.max(score, first[i] - second[i]);
		}
		System.out.println(score);
		sc.close();
	}

	class SubArray {
		public static final int ASC = 1;
		public static final int DESC = -1;
		private PriorityQueue<Integer> pq;
		private long total;

		public SubArray(int sortOrder) {
			total = 0;
			if (sortOrder == ASC) {
				pq = new PriorityQueue<Integer>();
			} else if (sortOrder == DESC) {
				pq = new PriorityQueue<>(new Comparator<Integer>() {
					@Override
					public int compare(Integer o1, Integer o2) {
						// TODO Auto-generated method stub
						return o2 - o1;
					}
				});
			} else {
				throw new IllegalArgumentException();
			}
		}

		public void add(int x) {
			this.pq.add(x);
			this.total += x;
		}

		public int removeTop() {
			int r = pq.poll();
			this.total -= r;
			return r;
		}

		public long total() {
			return this.total;
		}
	}

}


Measured memory_bytes: 100280
MOD = 1_000_000_007

N = gets.to_i
A = gets.split.map(&:to_i)

R = Array.new(N)
A.each_with_index do |x, i|
  if R[x]
    J = R[x] + N - i
    break
  else
    R[x] = i
  end
end

Frac = (2..(N + 1)).inject([1, 1]) {|ar, x| ar << ar.last * x % MOD; ar}

def modPow(x, n)
  if n == 0
    1
  elsif n & 1 == 0
    modPow(x * x % MOD, n >> 1)
  else
    x * modPow(x * x % MOD, n >> 1) % MOD
  end
end

CASH = {}
def elem_inv2(a, p)
  CASH[a] ||= modPow(a, p - 2)
end

def nCr(n, r)
  m = n - r
  (Frac[n] * (elem_inv2(Frac[r], MOD) * elem_inv2(Frac[m], MOD)) % MOD) % MOD
end

(1..(N + 1)).each do |k|
  if k == 1
    puts N
  elsif k - 1 > J
    puts nCr(N + 1, k)
  else
    puts (nCr(N + 1, k) - nCr(J, k - 1) + MOD) % MOD
  end
end

  
    

Measured memory_bytes: 19724
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
 
int main(){

	int a,b;
    string c="",d="";
    cin >> a >> b;
  	for(int i=0;i<b;i++){
    	c = c + to_string(a);
    } 
    for(int i=0;i<a;i++){
    	d= d + to_string(b);
    } 
    if(c < d){
    	cout << c << endl;
    }else{
    	cout << d << endl;
    }
    return 0;
}

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

int main()
{
    int a,b,i;
    string g="";
    cin>>a>>b;
    string x=to_string(a);
    string y=to_string(b);
    if(a>b)
        for(i=0;a>i;i++)
            g+=y;
    else
        for(i=0;b>i;i++)
            g+=x;
    cout<<g;
}   

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

int main(){ 
  int N;
  vector<int> x(10), y(10);

  cin >> N;
  for(int i=0; i<N; i++) cin >> x[i] >> y[i];

  vector<int> p = {0,1,2,3,4,5,6,7,8};

  double sum = 0;
  do{
    for(int i=1; i<N; i++){
      int dx = x[p[i]]-x[p[i-1]], dy = y[p[i]]-y[p[i-1]];
      sum += sqrt(dx*dx+dy*dy);
    }
  }while(next_permutation(p.begin(), p.begin()+N));

  for(int i=1; i<=N;i++) sum /= (double)i;

  cout << setprecision(10);
  cout << sum << endl; 
}

Measured memory_bytes: 256
N, H = map(int, input().split())
l = []
A = []
B = []
for i in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)

B.sort(reverse=True)
ans = 0
n = max(A)
flag = True
for i in range(N):
  if B[i] > n:
    ans += 1
    H -= B[i]
    if H <= 0:
      flag = False
      break
  else:
    break
if flag:
  ans += H // n
  if H % n != 0:
    ans += 1
print(ans)

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

ll gcd(ll a, ll b) { //最大公約数
    if (a%b == 0) return b;
    else return gcd(b,a%b);
}

int main(){
    int n;
    ll ans;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ans=a[0];
    for (int i=1; i<n; i++) {    
       ans=gcd(ans,a[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;

int dx[] = { 1,1,1,0,-1,-1,-1,0 };
int dy[] = { 1,0,-1,-1,-1,0,1,1 };
int main(void)
{
	for (;;)
	{
		int h, w; cin >> h >> w;
		if (!h)break;
		vector<string>donut;
		for (int i = 0; i < h; ++i)
		{
			string s; cin >> s;
			donut.push_back(s);
		}
		map<string, int>dic;
		for (int i = 0; i < h; ++i)
		{
			for (int j = 0; j < w; ++j)
			{
				for (int dir = 0; dir < 8; ++dir)
				{
					int ii = i, jj = j;
					set<pair<int, int>>st;
					string str;
					for (;;)
					{
						if (st.count({ ii,jj }))break;
						st.insert({ ii,jj });
						str.push_back(donut[ii][jj]);
						dic[str]++;
						ii += dx[dir]; jj += dy[dir];
						ii += h;
						jj += w;
						ii %= h;
						jj %= w;
					}
				}
			}
		}
		string ans = "0";
		for (auto page : dic)
		{
			if (page.second > 1)
			{
				const string& s = page.first;
				if (s.size() > ans.size())
				{
					ans = s;
				}
				else if (s.size() == ans.size())
				{
					if (s < ans)ans = s;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 38000
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<u64> = procon_read();
	let n = v[0];
	let mut k = 1;
	while (k+1)*(k+1) <= n {
		k +=1 ;
	}
	println!("{}", k*k);
}

Measured memory_bytes: 4476
#!/usr/bin/env python3
import sys


def solve(S: str):
    return "Heisei" if S <= "2019/04/30" else "TBD"

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    print(solve(S))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x,ll y,ll m) 
{
    ll res = 1; 
    x = x % m;                
    if (x == 0)
        return 0; 
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

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

void solve()
{
    int n,m;
    cin>>n>>m;
    vector<int> v(n);
    vector<vector<int>> a(n);
    for(int i=0;i<n;i++) {
        cin>>v[i];
    }
    for(int i=0;i<m;i++) {
        int x,y;
        cin>>x>>y;
        a[x-1].pb(y-1);
        a[y-1].pb(x-1);
    }
    int count=0;
    for(int i=0;i<n;i++) {
        bool f=true;
        for(int x:a[i]) {
            if(v[i]<=v[x]) {
                f=false;
                break;
            }
        }
        if(f) {
            count++;
        }
    }
    cout<<count;
    
}

int main()
{
    fastio;
    int t;
    t=1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        //cout<<newl;
    }

    return 0;
}

Measured memory_bytes: 8740
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  while(n>9)
    n %= 10;
  switch(n){
    case 0:
      cout<<"pon"<<endl;
      break;
    case 1:
      cout<<"pon"<<endl;
      break;
    case 2:
      cout<<"hon"<<endl;
      break;
    case 3:
      cout<<"bon"<<endl;
      break;
    case 4:
      cout<<"hon"<<endl;
      break;
    case 5:
      cout<<"hon"<<endl;
      break;
    case 6:
      cout<<"pon"<<endl;
      break;
    case 7:
      cout<<"hon"<<endl;
      break;
    case 8:
      cout<<"pon"<<endl;
      break;
    case 9:
      cout<<"hon"<<endl;
      break;
  }
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define TR(X) ({ if(1) cerr << "Trace: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll n; cin >> n;
	vector<double> inp(n);
	for(ll i = 0; i < n; i++) {
		ll k; cin >> k;
		inp[i] = double(1)/k;
	}
	double res = accumulate(all(inp), double(0));
	cout << fixed << setprecision(10) << double(1)/res << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,k,i,j,s=0,temp;
    long long int sum=0;
    int ara[1001];
    scanf("%d %d",&n,&k);
    for(s=0;s<n;s++)
    {
        scanf("%d",&ara[s]);
    }
    for(i=0;i<n-1;i++)
    {
        for(j=i+1;j<n;j++)
        {
            if(ara[i]>ara[j])
            {
                temp=ara[i];
                ara[i]=ara[j];
                ara[j]=temp;
            }
        }
    }
    for(s=0;s<k;s++)
    {
        sum=sum+ara[s];
    }
    printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 1708
n = int(input())
ns = list(map(int, input().split()))
abs_ns = [abs(i) for i in ns]
total = sum(abs_ns)
if sum(1 for i in ns if i < 0) % 2 == 0:
    print(total)
else:
    print(total - 2 * min(abs_ns))

Measured memory_bytes: 14332
#include<iostream>

using namespace std;

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

int main(){
    int n;
    cin >> n;
    int b[n];
    rep(i, n - 1) cin >> b[i];
    b[n-1] = 100000;
    int ans = 0;
    ans += b[0];
    for(int i = 1; i < n; i++){
        ans += min(b[i-1], b[i]);
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var ret = r.Count(x => x == 5) == 2 && r.Any(x => x == 7);
            Console.WriteLine(ret ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 13396
// https://atcoder.jp/contests/abc085/tasks/abc085_c
#include <iostream>
using namespace std;

void checkSet(int n, int y, int bill_set[3])
{
  for (size_t i = 0; i <= n; i++)
  {
    for (size_t j = 0; j <= n - i; j++)
    {
      int k = n - i - j;
      if (i * 10 + j * 5 + k == y / 1000)
      {
        bill_set[0] = i;
        bill_set[1] = j;
        bill_set[2] = k;
        return;
      }
    }
  }
  return;
}

int main()
{
  int n, y, // N, Y
      bill_set[3] = {-1, -1, -1};

  cin >> n >> y;

  checkSet(n, y, bill_set);

  cout << bill_set[0] << ' ' << bill_set[1] << ' ' << bill_set[2] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	long long int N,M,K,X,sum=0;
	cin>>N>>M>>K;
	
	if((M==1)||(K==1))
	X=1;
	else if(M<=K)
	X=M-1;
	else
	X=K;
	
	
	sum=(long long int)((N*X)/M)-N*(long long int)(X/M);
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3592
/*
lakshaygpt28
Lakshay Gupta
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
using vll = vector < ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;


#ifndef ONLINE_JUDGE
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 5e3 + 10;

pll e[N];
ll w[N], d[N], p[N];
vll path, g[N];
bool vis[N];
void dfs(ll n);

int main() {
    fast_io();
    ll n, m, P;
    cin >> n >> m >> P;
    for (ll i = 1; i <= n; i++) {
        d[i] = INF;
    }
    for (ll i = 0; i < m; i++) {
        cin >> e[i].first >> e[i].second >> w[i];
        g[e[i].first].eb(e[i].second);
        w[i] = -w[i] + P;
    }
    d[1] = 0;
    ll u, v;
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < m; j++) {
            u = e[j].first;
            v = e[j].second;
            if (d[u] < INF) {
                if (d[v] > d[u] + w[j]) {
                    d[v] = min(d[v], d[u] + w[j]);
                    p[v] = u;
                    if (i == n - 1) {
                        dfs(v);
                    }
                    if (vis[n]) {
                        cout << -1 << "\n";
                        return 0;
                    }
                    memset(vis, 0, n + 5);
                }
            }
        }
    }
    cout << max(0ll, -d[n]) << "\n";
    return 0;
}

void dfs(ll n) {
    vis[n] = true;
    for (auto x : g[n]) {
        if (!vis[x]) {
            dfs(x);
        }
    }
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b) swap(a,b);
    if(a>c) swap(a,c);
    if(b>c) swap(b,c);
    cout<<a<<" "<<b<<" "<<c<<endl;

return 0;

}



Measured memory_bytes: 3080
# D - Cake 123

import heapq
import itertools

x, y, z, k = map(int, input().split())

A = list(int(a) for a in input().split())
B = list(int(b) for b in input().split())
C = list(int(c) for c in input().split())


A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

hq = []
for i in range(x):
    for j in range(y):
        for l in range(z):
            if (i+1)*(j+1)*(l+1)<=k:
                heapq.heappush(hq, (A[i]+B[j]+C[l])*-1)
            else:
                break

'''
hq = []
for i, j in itertools.product(A, B):
    heapq.heappush(hq, (i+j)*-1)

AB = []
while len(hq)>0 and len(AB)<=k:
    AB.append(heapq.heappop(hq)*-1)

hq = []
for i, j in itertools.product(AB, C):
    heapq.heappush(hq, (i+j)*-1)
'''

for _ in range(k):
    print(heapq.heappop(hq)*-1)


Measured memory_bytes: 8508
const chunks = [];
process.stdin.on("data", (chunk) => {
  chunks.push(chunk);
});
process.stdin.on("end", () => {
  const data = Buffer.concat(chunks).toString("utf8").trim();
  const lines = data.split("\n");
  const N = parseInt(lines[0], 10);
  const S = lines.slice(1, N + 1);
  solve(N, S);
});

class Counter extends Map {
  increment(key) {
    if (this.has(key)) {
      this.set(key, this.get(key) + 1);
    } else {
      this.set(key, 1);
    }
  }
}

function solve(N, S) {
  const counter = new Counter();
  for (const s of S) {
    counter.increment(s);
  }
  const keys = ["AC", "WA", "TLE", "RE"];
  for (const key of keys) {
    console.log(`${key} x ${counter.get(key) || 0}`);
  }
}


Measured memory_bytes: 41220
#include <bits/stdc++.h>
#include <boost/math/constants/constants.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

int main(){
    using namespace std;
    long double pi = boost::math::constants::pi<long double>();
    constexpr unsigned long dig = 20;
    unsigned long N, L;
    cin >> N >> L;
    vector<unsigned long> T(N);
    copy_n(istream_iterator<unsigned long>(cin), N, T.begin());
    long double x{0}, y{0};
    vector<long double> C(N), S(N);
    transform(T.begin(), T.end(), C.begin(), [&pi, &L](auto t){return cos(pi * t / L);});
    transform(T.begin(), T.end(), S.begin(), [&pi, &L](auto t){return sin(pi * t / L);});
    for(long i = 1; i < N; ++i){
        for(long j = 0; j < i; ++j){
            long t = N + 2 * (j - i);
            x += t * (C[i] * C[j] - S[i] * S[j]);
            y += t * (C[i] * S[j] + C[j] * S[i]);
        }
    }
    unsigned long t = N * (N - 1) * (N - 2) / 6;
    x /= t;
    y /= t;
    cout << setprecision(15) << fixed << endl;
    cout << x << " " << y << endl;
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    string s, t, ans;
    cin >> s >> t;

    REP(i, s.size() - t.size() + 1) {
        bool f   = false;
        string a = s;
        REP(j, t.size()) {
            if (a[i + j] == '?')
                continue;
            if (a[i + j] != t[j])
                f = true;
        }
        if (f)
            continue;
        REP(j, t.size()) a[i + j]              = t[j];
        REP(j, s.size()) if (a[j] == '?') a[j] = 'a';
        if (ans.empty())
            ans = a;
        else
            ans = min(ans, a);
    }

    if (ans.empty())
        cout << "UNRESTORABLE" << endl;
    else
        cout << ans << endl;

    return 0;
}

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

int main(){
  int n; cin>>n;
  vector<double> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  
  sort(v.begin(),v.end());
  
  for(int i=0;i<n-1;i++){
    v[i+1]=(v[i]+v[i+1])/2;
  }
  cout<<v[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N; std::cin >> N;
  std::vector<int> b(N);
  for (int i = 0; i < N; ++i) std::cin >> b[i];

  std::vector<int> ans;
  for (int i = 0; i < N; ++i) {
    int index = -1;
    for (int j = 0; j < b.size(); ++j) {
      if (j + 1 == b[j]) index = j;
    }

    if (index<0) {
      std::cout << -1 << std::endl;
      return 0;
    }

    ans.push_back(b[index]);
    b.erase(b.begin() + index);
  }

  for (auto it = ans.rbegin(); it != ans.rend(); ++it) {
    std::cout << *it << std::endl;
  }
}


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

int main() {
  string s,t;
  cin >> s >> t;
  vector<int> start(26,-1);
  vector<int> goal(26,-1);
  rep(i,s.size()){
    int a=s[i]-'a';
    int b=t[i]-'a';
    if(start[a]!=-1 || goal[b]!=-1){
      if(start[a]!=b || goal[b]!=a){
        cout << "No" << endl;
        return 0;
      }
    }
    start[a]=b;
    goal[b]=a;
  }
  cout << "Yes" << endl;
  return 0;
}

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

int main() {
	int n; cin >> n;
	bool ans = false;
	while (n > 0) {
		int last = n % 10;
		if (last == 7) { 
			cout << "Yes";
			return 0;
		}
		n /= 10;
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 3620
import java.io.*;
import java.util.*;

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

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

public class Main {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        int r = in.nextInt();
        int g = in.nextInt();
        int b = in.nextInt();
        if ((r * 100 + g * 10 + b) % 4 == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21076
#include <stdio.h>
#include <stdlib.h>

int ordena (const void *a, const void *b){
  int x= (*(int *)a);
  int y= (*(int *)b);

  if(x<y){
    return -1;
  } else if (x>y){
    return 1;
  } else {
    return 0;
  }
}

int main () {
  int n,level[112345];

  scanf("%d", &n);
  for (int i=0; i<n; i++)
  {
    scanf("%d", &level[i]);
  }

  qsort(level,n,sizeof(int),ordena);

  printf("%d\n", level[n/2]- level[n/2-1]);

  return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=100000+100;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

namespace My_Math{
	#define N 100000

	int fac[N+100],invfac[N+100];

	int add(int x,int y) {return x+y>=maxd?x+y-maxd:x+y;}
	int dec(int x,int y) {return x<y?x-y+maxd:x-y;}
	int mul(int x,int y) {return 1ll*x*y%maxd;}
	ll qpow(ll x,int y)
	{
		ll ans=1;
		while (y)
		{
			if (y&1) ans=mul(ans,x);
			x=mul(x,x);y>>=1;
		}
		return ans;
	}
	int getinv(int x) {return qpow(x,maxd-2);}

	int C(int n,int m)
	{
		if ((n<m) || (n<0) || (m<0)) return 0;
		return mul(mul(fac[n],invfac[m]),invfac[n-m]);
	}

	void math_init()
	{
		fac[0]=invfac[0]=1;
		rep(i,1,N) fac[i]=mul(fac[i-1],i);
		invfac[N]=getinv(fac[N]);
		per(i,N-1,1) invfac[i]=mul(invfac[i+1],i+1);
	}
	#undef N
}
using namespace My_Math;

struct node{int to,nxt;}sq[N<<1],sq1[N<<1];
int head[N],head1[N],all=0,all1=0;
int n,m,a[N],b[N],c[N],fa[N],id[N];
ll f[N],sum[N]; 
bool vis[N];

bool cmp(int x,int y) {return c[x]<c[y];}

int find(int x)
{
	if (fa[x]==x) return fa[x];
	fa[x]=find(fa[x]);
	return fa[x];
}

void addedge(int u,int v)
{
	all++;sq[all].to=v;sq[all].nxt=head[u];head[u]=all;
}

void addedge1(int u,int v)
{
	all1++;sq1[all1].to=v;sq1[all1].nxt=head1[u];head1[u]=all1;
}

void dfs(int u)
{
	sum[u]=b[u];
	for (int i=head1[u];i;i=sq1[i].nxt)
	{
		int v=sq1[i].to;
		dfs(v);sum[u]+=sum[v];
	}
	f[u]=sum[u]+c[u];
	for (int i=head1[u];i;i=sq1[i].nxt)
	{
		int v=sq1[i].to;
		f[u]=min(f[u],sum[u]-sum[v]+max((ll)c[u],f[v]));
	}
}

int main()
{
	n=read();m=read();
	rep(i,1,n)
	{
		a[i]=read();b[i]=read();
		c[i]=max(a[i]-b[i],0);
	}
	rep(i,1,m)
	{
		int u=read(),v=read();
		addedge(u,v);addedge(v,u);
	}
	rep(i,1,n) id[i]=fa[i]=i;
	sort(id+1,id+1+n,cmp);
	rep(i,1,n)
	{
		int u=id[i];vis[u]=1;
		go(u,i)
		{
			if (vis[v])
			{
				int fx=find(u),fy=find(v);
				if (fx!=fy)
				{
					fa[fy]=fx;addedge1(fx,fy);
				}
			}
		}
	}
	dfs(id[n]);printf("%lld",f[id[n]]);
	return 0;
}
					
	



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll MOD = 1e9 + 7;
struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint& operator+=(const mint a) {if ((x += a.x) >= MOD) x -= MOD;return *this;}
  mint& operator-=(const mint a) {if ((x += MOD-a.x) >= MOD) x -= MOD;return *this;}
  mint& operator*=(const mint a) {(x *= a.x) %= MOD;return *this;}
  mint operator+(const mint a) const {mint res(*this);return res+=a;}
  mint operator-(const mint a) const {mint res(*this);return res-=a;}
  mint operator*(const mint a) const {mint res(*this);return res*=a;}
  mint pow(ll b) const {
    mint res(1), a(*this);
    while (b) {
      if (b & 1) res *= a;
      a *= a;
      b >>= 1;
    }
    return res;
  }
  // for prime MOD
  mint inv() const {return pow(MOD-2);}
  mint& operator/=(const mint a) {return (*this) *= a.inv();}
  mint operator/(const mint a) const {mint res(*this);return res/=a;}
};
ostream& operator<<(ostream& os, const mint& a) {os << a.x; return os;}


int main2() {
  int N = nextLong();
  vector<ll> a(N);
  REP(i, N) a[i] = nextLong();

  ll S = 0;
  REP(i, N) S += a[i];
  S %= MOD;

  mint ans = (S * S) % MOD;
  REP(i, N) {
    ans -= mint((a[i] * a[i]) % MOD);
  }
  ans /= 2;
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 4840
#include<stdio.h>
int F[1024];

int fibonacci(int n){
  if(n==0 || n==1){
    return F[n]=1;
  }

  if(F[n]!=0){
    return F[n];
  }

  return F[n] = fibonacci(n-2)+fibonacci(n-1);
}

int main(){
  int n;
  scanf("%d", &n);

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

  return 0;
}

Measured memory_bytes: 1820
#include <iostream>

using namespace std;

int main() {
	int n, i;
	int a[100];
	cin >> n;
	for (i = n-1; i >= 0; i--) {
		cin >> a[i];
	}
	for (i = 0; i < n; i++) {
		cout << a[i];
		if (i == n - 1) {
			break;
		}
		cout << " ";
	}
	cout << endl;


	return 0;
}


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

using namespace std;

struct Graph {
    using CT = int; static const CT INF = 0x3f3f3f3f;
    //using CT = long long; static const CT INF = 0x3f3f3f3f3f3f3f3f;
    struct Edge {
        int u, v;
        CT cost;
        Edge(int _u, int _v, CT _cost) : u(_u), v(_v), cost(_cost) {}
    };
    int n, m;
    bool is_digraph;
    vector<vector<int>> g;
    vector<Edge> e;

    Graph(int _n) : n(_n), m(0) {
        assert(n >= 1);
        g.resize(n);
        set_di(false);
    }
    Graph(int _n, int _m, bool _di=false) : n(_n), m(0), deg(n,0), co(n), trk(n,false) {
        assert(n >= 1);
        g.resize(n);
        e.reserve(_m);
        set_di(_di);
        input(_m);
    }
    void set_di(bool _di) {
        pos = vector<int>(n, 0);
        is_digraph = _di;
    }
    vector<int> deg;
    inline void add(int u, int v, CT cost=1) {
        assert(0 <= u && u < n);
        assert(0 <= v && v < n);
        if (is_digraph) {
            //outdeg[u]++; indeg[v]++;
            g[u].emplace_back(m);

        } else {
            deg[u]++; deg[v]++;
            g[u].emplace_back(m);
            g[v].emplace_back(m);
        }
        e.emplace_back(u, v, cost);
        m++;
    }
    void input(int _m) {
        int u, v;// CT c;
        for (int i = 0; i < _m; i++) {
            cin >> u >> v;// >> c;
            u--; v--; // input 1-based
            add(u, v);//, c);
        }
    }
    vector<int> pos;
    vector<int> co;
    vector<bool> trk;
    int k;
    void dfs(int u, int x) {
        trk[u] = true;
        for (; pos[u] < (int)g[u].size(); pos[u]++) {
            int i = g[u][pos[u]];
            int v = e[i].u ^ e[i].v ^ u;
            // rule
            if (!trk[v]) {
                (x+=1)%=k;
                co[i] = x;
                dfs(v, x);
            }
        }
    }
    
    void run() {
        int rt = max_element(deg.begin(), deg.end()) - deg.begin();
        k = deg[rt];
        dfs(rt, 0);
        cout << k << "\n";
        for (int i = 0; i < n-1; i++) {
            cout << co[i]+1 << "\n";
        }
    }
};

void solve() {
    int n; cin >> n;
    Graph g(n, n-1);
    g.run();
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 8448
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 19 + 7
EPS = 10 ** -10

def build_grid(H, W, intv, _type, space=True, padding=False):
    # 入力がスペース区切りかどうか
    if space:
        _input = lambda: input().split()
    else:
        _input = lambda: input()
    _list = lambda: list(map(_type, _input()))
    # 余白の有無
    if padding:
        offset = 1
    else:
        offset = 0
    grid = list2d(H+offset*2, W+offset*2, intv)
    for i in range(offset, H+offset):
        row = _list()
        for j in range(offset, W+offset):
            grid[i][j] = row[j-offset]
    return grid

def bfs(grid, src):
    """ BFS(グリッド、重みなし) """
    from collections import deque

    H, W = len(grid), len(grid[0])
    directions = ((1, 0), (-1, 0), (0, 1), (0, -1))
    dist = list2d(H, W, INF)
    que = deque()
    for h, w in src:
        que.append((h, w))
        dist[h][w] = 0
    while que:
        h, w = que.popleft()
        for dh, dw in directions:
            nh = h + dh
            nw = w + dw
            if grid[nh][nw] == '#':
                continue
            if dist[nh][nw] <= dist[h][w]:
                continue
            dist[nh][nw] = dist[h][w]
            que.appendleft((nh, nw))
        for nh in range(h-2, h+3):
            if nh < 0 or nh >= H:
                continue
            for nw in range(w-2, w+3):
                if nw < 0 or nw >= W:
                    continue
                if grid[nh][nw] == '#':
                    continue
                if dist[nh][nw] <= dist[h][w] + 1:
                    continue
                dist[nh][nw] = dist[h][w] + 1
                que.append((nh, nw))
    return dist

H, W = MAP()
sh, sw = MAP()
th, tw = MAP()
grid = build_grid(H, W, '#', str, space=0, padding=1)

res = bfs(grid, [(sh, sw)])
ans = res[th][tw]
if ans == INF:
    print(-1)
else:
    print(ans)


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

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  int x;
  cin >> x;
  cout << (x == 0 ? 1 : 0) << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3648