akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define MAX 500000
#define SENTINEL 2000000000
   
int L[MAX/2+2], R[MAX/2+2];
int count = 0;
   
void merge(int [], int, int, int, int);
void mergeSort(int [], int, int, int);
   
int main(){
  int A[MAX], n, i;
   
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d", &A[i]);
  }
  mergeSort(A, n, 0, n);
  for(i = 0;i < n;i++){
    if(i != 0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n", count);
  return 0;
}
   
void merge(int A[], int n, int left, int mid, int right){
  int n1, n2, i, j, k;
   
  n1 = mid - left;
  n2 = right - mid;
  for(i=0;i<n1;i++){
    L[i] = A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i] = A[mid+i];
  }
  L[n1] = R[n2] = SENTINEL;
  i = 0;
  j = 0;
  for(k=left;k<right;k++){
    count++;
    if(L[i] <= R[j]){
      A[k] = L[i++];
    }
    else A[k] = R[j++];
  }
}
   
void mergeSort(int A[], int n, int left, int right){
  int mid;
   
  if(left+1 < right){
    mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

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


int main(){
  int n;
  cin >> n;
  int n_temp = n;
  int sum = 0;

  while(n_temp>0){
    sum += n_temp%10;
    n_temp /= 10;
  }

  if (n%sum==0){
    cout << "Yes" <<endl;
  }else{
    cout << "No" <<endl;
  }

  return 0;
}

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

using namespace std;
int main()
{
    int N;
    int X;
    int Y;
    int min_work = 0;

    cin >> N;
    cin >> X;
    cin >> Y;
  
  X--;
  Y--;

    vector<int> Count(N);
//    vector<vector<int>> minDistance(N, vector<int>(N,0));

    for (int i = 0; i < N-1; i++) {
        for (int j = i+1; j < N; j++){
            min_work = min(j-i, abs(X-i)+1+abs(j-Y));
            min_work = min(min_work, abs(Y-i)+1+abs(j-X));
            Count.at(min_work) += 1;
        }
    }


    for (long i = 1; i < N; i++) {
        cout << Count.at(i) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,sum=0,max=0;
  string s;
  cin>>n>>s;
  for(int i=0;i<n;++i){
    if(s[i]=='I') ++sum;
    else --sum;

    if(sum>max) max = sum;
  }
  cout<<max;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s,t; cin>>s>>t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),[](auto a,auto b){return a>b;});
	cout<<(s<t?"Yes"s:"No"s)<<"\n"s;
}

Measured memory_bytes: 256
#include <cstdio>

int matrix[12][12];
int n;

int main() {
  while(scanf("%d", &n) != EOF, n) {
    for (int i=0; i<n; i++) {
      for (int j=0; j<n; j++) {
	scanf("%d", &matrix[i][j]);
      }
    }

    // output
    for (int i=0; i<n; i++) {
      int sum = 0;
      for (int j=0; j<n; j++) {
	sum += matrix[i][j];
	printf("%5d", matrix[i][j]);
      }
      matrix[i][n] = sum; 
      printf("%5d\n", sum);
    }

    for (int j=0; j<=n; j++) {
      int sum = 0;
      for (int k=0; k<n; k++) {
	sum += matrix[k][j];
      }
      printf("%5d", sum);
    }
    printf("\n");
  }
}

Measured memory_bytes: 2580
import sys
s = input()
if len(s) <= 1:
    print(-1, -1)
else:
    for i in range(len(s) - 1):
        if s[i] == s[i + 1]:
            print(i + 1, i + 2)
            exit(0)
    for i in range(len(s) - 2):
        if s[i] == s[i + 2]:
            print(i + 1, i + 3)
            exit(0)
    print(-1, -1)


Measured memory_bytes: 39408
# D - Lunlun Number

K = int(input())

N = [1, 2, 3, 4, 5, 6, 7, 8, 9]
i = 0

while len(N) < K:
    n = int(str(N[i]) + str(N[i])[-1:])
    if str(n)[-1:] == '0':
        N += [n, n + 1]
    elif str(n)[-1:] == '9':
        N += [n - 1, n]
    else:
        N += [n - 1, n, n + 1]
    i += 1

print(N[K - 1])

Measured memory_bytes: 7160
N = int(input())

S = [""] * N
T = [0] * N

for i in range(N):
    s, t = input().split()
    t1 = int(t)
    S[i] = s
    T[i] = t1

X = input()

ans = 0
flg = 0
for i in range(N):
    if flg == 1:
        ans += T[i]
    if S[i] == X:
        flg = 1

print(ans)

Measured memory_bytes: 3064
// CPP program to illustrate 
// std :: lower_bound 
#include<iostream> 
#include<vector>
#include<set>
#include<iterator>
#include<algorithm>
#include<map>
using namespace std;
#define ll long long 
// Driver code 
int main() 
{ 
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    printf("A%cC",s2[0]);
    return 0; 
} 


Measured memory_bytes: 3732
import java.util.Arrays;
import java.util.Scanner;

//Prime Number
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean[] f = new boolean[1000000];
		Arrays.fill(f, true);
		for(int i=2;i<1000000;i++)if(f[i])for(int j=i*2;j<1000000;j+=i)f[j]=false;
		while(sc.hasNext()){
			int n = sc.nextInt();
			int c = 0;
			for(int i=2;i<=n;i++)c+=f[i]?1:0;
			System.out.println(c);
		}
	}
}

Measured memory_bytes: 13000
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
//* vamsicool007    You are never wrong to do the right thing    vamsicool007 *
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
#include<bits/stdc++.h>
using namespace std;
#define flash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl "\n"
#define int long long
typedef long long ll;
typedef long double ld;
const int mod = 1000000007;
bool isPrime(ll n){for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
ll factorial(ll n){return (n==1 || n==0) ? 1:n*factorial(n-1);}
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res%mod;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (a/gcd(a,b)*b);}
ll max(ll a,ll b){ll ans=a>b?a:b;return ans;}
ll min(ll a,ll b){ll ans=a<b?a:b;return ans;}
 
signed main()
{
	
    int t=1;
    //cin>>t;
    while(t--)
    {
    	int a,b,c;
    	cin>>a>>b>>c;
    	if(c<=a)
    		cout<<a-c<<" "<<b;
    	else
    	{
    		c=c-a;
    		a=0;
    		if(c>b)
    			cout<<"0 0";
    		else
    			cout<<a<<" "<<b-c;
    	}
    }
	return 0;
}
  


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if((a+b)>=(a-b)&&(a+b)>=(a*b))cout<<a+b;
    else if((a-b)>=(a+b)&&(a-b)>=(a*b))cout<<a-b;
    else cout<<a*b;
}


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


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

    int max = *max_element( a.begin(), a.end() );
    int min = *min_element( a.begin(), a.end() );
    
    cout << 2*N - 1 << endl;
    if( abs(max) > abs(min) ){
        int maxi = distance( a.begin(), max_element( a.begin(), a.end() ) ) + 1;
        for( int i = 1; i <= N; ++i ) cout << maxi << " " << i << endl;
        for( int i = 1; i <  N; ++i ) cout << i << " " << i+1 << endl;
    }else{
        int mini = distance( a.begin(), min_element( a.begin(), a.end() ) ) + 1;
        for( int i = 1; i <= N; ++i ) cout << mini << " " << i << endl;
        for( int i = N; i >= 2; --i ) cout << i << " " << i-1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
K2 = 2*K
R = []

# (x, y) と (x, y+K)の色は必ず異なるので、すべて黒の要求に変換できる。
# 2Kずらすと必ず色が同じになるので、2Kでmodをとってよい。
for i in range(N):
    xi, yi, ci = input().split()
    if ci == "W":
        yi = int(yi) + K

    xi, yi = int(xi), int(yi)
    R.append([yi % K2, xi % K2])


class Ruisekiwa2D:
    def __init__(self, h, w):
        self.H = h
        self.W = w
        self.G = [[0] * w for _ in range(h)]

    def load(self, points):
        # 問題によってイメージしやすいよう書き換えてください
        for x, y in points:
            self.G[x][y] += 1

        self.calc()

    def load_imos(self, points):
        # pointsは[[左上h, 左上w, 右下h, 右下w], ...]であること
        for i1, j1, i2, j2 in points:
            self.G[i1][j1] += 1  # 左上
            if j2 + 1 < self.W:  # 右上
                self.G[i1][j2+1] -= 1
            if i2 + 1 < self.H:
                self.G[i2+1][j1] -= 1  # 左下
            if j2 + 1 < self.W and i2 + 1 < self.H:  # 右下
                self.G[i2+1][j2+1] += 1

        self.calc()

    def calc(self):
        for y in range(self.W):
            for x in range(1, self.H):
                self.G[x][y] += self.G[x-1][y]

        for y in range(1, self.W):
            for x in range(self.H):
                self.G[x][y] += self.G[x][y-1]

    def get(self, i1, j1, i2, j2):
        if i1 > i2 or j1 > j2 or i1 < 0 or j1 < 0 or i2 < 0 or j2 < 0:
            return 0
        elif i1 > 0 and j1 > 0:
            return self.G[i2][j2] - self.G[i1-1][j2] - self.G[i2][j1-1] + self.G[i1-1][j1-1]
        elif i1 <= 0 < j1:
            return self.G[i2][j2] - self.G[i2][j1-1]
        elif j1 <= 0 < i1:
            return self.G[i2][j2] - self.G[i1 - 1][j2]
        else:
            return self.G[i2][j2]


R2D = Ruisekiwa2D(K2, K2)
R2D.load(R)

ans = 0
for i in range(K):
    for j in range(K):
        tmp = 0
        tmp += R2D.get(0, 0, i-1, j-1)  # 左上
        tmp += R2D.get(0, j+K, i-1, K2-1)  # 右上
        tmp += R2D.get(i+K, j+K, K2-1, K2-1)  # 右下
        tmp += R2D.get(i+K, 0, K2-1, j-1)  # 左下
        tmp += R2D.get(i, j, i+K-1, j+K-1)  # 真ん中

        ans = max(ans, tmp, N-tmp)
print(ans)


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];
#define int long long

signed main(){
    int N, K; cin >> N >> K;
    vector<int> h(N);
    collect(h, N);
    sort(all(h));
    int shortest = INT_MAX;
    rep(i,N-K+1){
        shortest = min(shortest, h[i+K-1]-h[i]);
    }
    cout << shortest << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int main()
{
    int N, ans = 0, anum = 0, bnum = 0, abnum = 0, add;
    cin >> N;
    vector<string> s(N);
    rep(i, N)
    {
        cin >> s[i];
        rep(j, s[i].size() - 1)
        {
            if (s[i][j] == 'A' and s[i][j + 1] == 'B')
            {
                ans++;
            }
        }
        if (s[i].front() == 'B' and s[i].back() == 'A')
        {
            abnum++;
        }
        else
        {
            if (s[i][0] == 'B')
            {
                bnum++;
            }
            if (s[i].back() == 'A')
            {
                anum++;
            }
        }
    }
    if (anum + bnum == 0)
    {
        add = max(0, abnum - 1);
    }
    else
    {
        add = min(anum, bnum) + abnum;
    }
    cout << ans + add;
    return 0;
}

Measured memory_bytes: 768
import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

class Dice {
    int F[6];
    this(int[] F) { this.F = F.dup; }
    Dice dup() { return new Dice(F); }
    override bool opEquals(Object o) { 
        auto d = cast(Dice)o;
        return F == d.F;
    }
    void roll(int d) {
        const R = [
            [1, 2, 4, 3], /* 0 - 5軸 */
            [0, 2, 5, 3], /* 1 - 4軸 */
            [0, 1, 5, 4]  /* 2 - 3軸 */
        ];
        auto p = F[ R[d][0] ];
        foreach (i; 0 .. 3) {
            F[ R[d][i] ] = F[ R[d][(i + 1) % 4] ];
        }
        F[ R[d][3] ] = p;
    }
    void roll(int d, int n) {
        foreach (_; 0 .. n) roll(d);
    }
    override size_t toHash() const {
        size_t ret = 0;
        foreach (i; 0 .. 6) {
            ret = ret * 10 + F[i];
        }
        return ret;
    }
    override int opCmp(Object o ) const {
        auto d = cast(Dice)o;
        return cast(int)toHash() - cast(int)o.toHash();
    }
    override string toString() const {
        return "(" ~ F[].map!(to!string).join(" ") ~ ")";
    }
    static Dice[] allStates(Dice d) {
        Dice[] ret;
        foreach (i; 0 .. 6) {
            d.roll(i % 2);
            foreach (j; 0 .. 4) {
                d.roll(2);
                ret ~= d.dup;
            }
        }
        return ret;
    }
}

int H, W;
int[][] F;
int sx, sy, gx, gy;
bool input() {
    scanf("%d %d\n", &H, &W);
    if (H == 0 && W == 0) return false;
    F = new int[][](H, W);
    foreach (i; 0 .. H) foreach (j; 0 .. W) scanf("%d", &F[i][j]);
    scanf("%d %d %d %d", &sy, &sx, &gy, &gx);
    return true;
}

const dy  = [-1, 0, 1, 0],
      dx  = [0, 1, 0, -1],
      dir = [ [2, 1], [1, 3], [2, 3], [1, 1] ];

struct State {
    int id, y, x, cost;
}

const INF = 1 << 28;

void solve() {
    auto init = new Dice([1, 2, 3, 4, 5, 6]);
    int[Dice] M; int id = 0;
    foreach (state; Dice.allStates(init)) {
        M[state] = id++;
    }
    auto N = new Dice[24];
    foreach (k, v; M) { N[v] = k; }

    BinaryHeap!(Array!State, "a.cost > b.cost") PQ;
    PQ.insert(State(M[init], sy, sx, 0));
    auto D = new int[][][](24, H, W);
    foreach (i; 0 .. 24) foreach (j; 0 .. H) D[i][j][] = INF;
    D[M[init]][sy][sx] = 0;
    while (!PQ.empty) {
        auto s = PQ.front; PQ.removeFront;
        foreach (i; 0 .. 4) {
            auto ny = s.y + dy[i],
                 nx = s.x + dx[i];
            if (ny < 0 || H <= ny || nx < 0 || W <= nx) continue;
            auto nd = N[s.id].dup;
            nd.roll(dir[i][0], dir[i][1]);
            auto ncost = nd.F[5] * F[ny][nx] + s.cost;
            auto nid = M[nd];
            if (D[nid][ny][nx] > ncost) {
                D[nid][ny][nx] = ncost;
                PQ.insert(State(nid, ny, nx, ncost));
            }
        }
    }
    int ans = INF;
    foreach (i; 0 .. 24) {
        ans = min(ans, D[i][gy][gx]);
    }
    writeln(ans);
}

void main() {
    while (input) solve;
}

Measured memory_bytes: 2104
class Bit(object):
    def __init__(self, N):
        self.N = N
        self.bit = [0] * (N + 1)

    def add(self, a: int, w: int):
        x: int = a
        while x <= self.N:
            self.bit[x] += w
            x += x & -x

    def sum(self, a: int):
        ret: int = 0
        x: int = a
        while x > 0:
            ret += self.bit[x]
            x -= x & -x

        return ret

    def range_sum(self, x, y):
        ret1 = self.sum(y)
        ret2 = self.sum(x - 1)

        return ret1 - ret2


N, q = input().split()
N = int(N)
q = int(q)
bit = Bit(N)

for _ in range(q):
    mode, x, y = input().rstrip().split()
    if mode == "0":
        bit.add(int(x), int(y))
    else:
        ret = bit.range_sum(int(x), int(y))
        print(ret)



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

using namespace std;


int main(){
    long long L[88];
    L[0]=2;
    L[1]=1;
    for(int i=2;i<=86;i++){
        L[i]=L[i-2]+L[i-1];
    }
    int n;
    cin >> n;
    cout << L[n] <<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
static const int N = 1000;
 
void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
      printf("%d", A[i]);
  }   
  printf("\n");
}
 
int main(){
  int n, i, j,v;
  int A[N+1];
  scanf("%d", &n);
 
  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
   
  trace(A, n);
 
  for(i=2;i<=n;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }
    trace(A, n);
  }
    
  return 0;
}

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

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int k = Integer.parseInt(br.readLine());
        
        String[] input = br.readLine().split(" ");
        int a = Integer.parseInt(input[0]);
        int b = Integer.parseInt(input[1]);
        
        String ans = "NG";
        
        for(int i = a; i <= b; i++){
            if(i % k == 0){
                ans = "OK";
                break;
            }
        }
        
        out.println(ans);
        
        out.close();
        
    }
}

Measured memory_bytes: 32812
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main()
{
	string a;
	cin>>a;
	int tmp=a.find("ST");
	while(a.length()>0&&tmp>=0)
	{
		a.erase(tmp,2);
		int x=max(tmp-1,0);
		tmp=a.find("ST",x);
		if(tmp==string::npos&&(a[tmp]!='S'||a[tmp+1]!='T'))
			tmp=-1;
	}
	cout<<a.length()<<endl;
	return 0;
} 

Measured memory_bytes: 832
#include <iostream>
#include <algorithm>

int main(void) {
	for (;;) {
		int x, y;
		std::cin >> x >> y;
		if (x == 0 && y == 0)
			break;
		if (x > y)
			std::swap(x, y);
		std::cout << x << " " << y << std::endl;
	}
	return 0;
}

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

using namespace std;

#define M_DEBUG if (0)

typedef unsigned long long int ullint;

void print_equiv_str(int n, string s, char s_max)
{
    if (s.size() == n)
    {
        cout << s << endl;
    }
    else
    {
        for (char c = 'a'; c <= s_max; c++)
        {
            char next_max = (c == s_max) ? s_max + 1 : s_max;
            print_equiv_str(n, s + c, next_max);
        }
    }
}

/******************************************************************************
	Main
******************************************************************************/
int main()
{
    int n = 0;
    cin >> n;
    assert(n >= 1 && n <= 10);
    print_equiv_str(n, "", 'a');
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int x;
	cin>>x;
	if(x==0)	
	{
		cout<<1;
		return 0;
	}
	cout<<0;
	return 0;
}

Measured memory_bytes: 3648
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

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 &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int n=in(),i;
	for(i=0;i<n;i++){
		double xa,ya,ra,xb,yb,rb;
		cin>>xa>>ya>>ra>>xb>>yb>>rb;
		if((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb)<(ra-rb)*(ra-rb)){
			if(ra>rb)cout<<2;
			else cout<<-2;
		}else if((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb)>(ra+rb)*(ra+rb))cout<<0;
		else cout<<1;
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
import Control.Applicative

standardDeviation :: [Int] -> Double
standardDeviation s = (sqrt . (/ realToFrac(length s)) . sum . map ((**2) . (`subtract` m) . realToFrac)) s
                    where{
                    m = realToFrac(sum s) / realToFrac(length s)
                    };

main = do{
    l <- lines <$> getContents;
    let{
    l' = [ (standardDeviation . map (read::String->Int) . words) (l!!n) | n<-[1..(length l)-1], n`mod`2==1 ]
    };
    mapM_ putStrLn $ (map show) l'
}

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

int main() {
  int c[3][3];
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin >> c[i][j];
    }
  }

  int a[3][2];
  for(int i=0; i<3; i++){
    for(int j=1; j<3; j++){
        a[i][j-1] = c[i][j] - c[i][j-1];
        if(i != 0){
          if(a[i][j-1] != a[i-1][j-1]){
            cout << "No" << endl;
            return 0;
          }
        }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
def examB():
    St = S()
    ans = St[0] + str(len(St)-2) + St[-1]
    print(ans)

import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 3444
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
    int d, s;
    while(scanf("%d", &d) != EOF) {
        s = 0;
        for (int i = d; i <= 600; i+=d) s+= d * pow((i-d), 2);
        printf("%d\n", s);
    }
    return 0;
}



Measured memory_bytes: 2612
#include <iostream>
#include <math.h>
using namespace std;
using ull = unsigned long long;

int main(){
    ull N;
    cin >> N;
    ull rootN = (int)(sqrt(N));
    int ans = 0;
    for(int i = 1; i <= rootN; ++i){
        if(N % i == 0){
            ans = 1 + log10(N / i);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
template <class T> vector<T> make_vec(size_t a, T val) {
    return vector<T>(a, val);
}
template <class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec(ts...))>(a, make_vec(ts...));
}
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
template <typename T> struct edge {
    int to;
    T cost;
    edge(int t, T c) : to(t), cost(c) {}
};
template <typename T> using WGraph = vector<vector<edge<T>>>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;
// UnionFind
struct UnionFind {
    vector<ll> par;
    vector<ll> siz;

    UnionFind(ll N) : par(N), siz(N, 1LL) {
        for(int i = 0; i < N; i++)
            par[i] = i;
    }
    int root(int x) {
        if(par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry)
            return;
        if(siz[rx] < siz[ry])
            swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
    }
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    ll size(ll x) { return siz[root(x)]; }
};

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        uf.unite(a, b);
    }
    set<int> se;
    rep(i, N) { se.insert(uf.root(i)); }
    cout << se.size() - 1 << endl;
}

Measured memory_bytes: 8424
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{
    static class Program
    {
        static void Main()
        {
            //ここから

            var vs = IO.ReadLineToLongList();
            var A = vs[0];
            var B = vs[1];
            var C = vs[2];
            var X = vs[3];
            var Y = vs[4];

            long min = long.MaxValue;

            for (var i = 0; i <= 100000; i++)
            {
                long sum = 0;
                sum += 2 * C * i;
                sum += A * Math.Max(0, X - i);
                sum += B * Math.Max(0, Y - i);

                min = Math.Min(min, sum);
            }
                    

            //ここまで

            Console.WriteLine(min);
            Console.ReadKey();
        }

    }

    static class Func
    {
        static public long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(long a, long b) { return (long)a * b / GCD(a, b); }
        static public long Factorial(long a) { return a == 1 ? a : a * Factorial(a - 1); }


        public static double ToAngle(this double radian)
        {
            return (double)(radian * 180 / Math.PI);
        }

        public static double ToRadian(this double angle)
        {
            return (double)(angle * Math.PI / 180);
        }

        static public long Conbination(long n,long m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * Conbination(n - 1, m - 1) / m;
        }

        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    static class IO
    {
        static public string ReadLineToString() { return Console.ReadLine(); }
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }

        static public List<double> ReadLineToDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }

        static public void WriteStrings(object[] strings) { foreach (var o in strings) { Console.Write(o + " "); } }
    }
}

Measured memory_bytes: 13268
S=input()
Sgusu=[S[i] for i in range(0,len(S),2)]
Skisu=[S[i] for i in range(1,len(S),2)]
answer1=Sgusu.count("1")+Skisu.count("0")
answer2=Sgusu.count("0")+Skisu.count("1")
answer=min([answer1,answer2])
print(answer)

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }


long long usu[1000006];
char s[100003];
long long n,sol,act;

int main()
{

    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        cin>>(s+1);
        
        // cout << s << "\n";
        //  FOR(l, 10)
        //  	cout << s[l] << ' ';

        sort(s+1,s+10+1);
		        
        for(int j=1;j<=10;++j) usu[i]=usu[i]*26+(s[j]-'a');
    }

    sort(usu+1,usu+n+1);
    act=1;
    for(int i=2;i<=n;++i)
    {
        if(usu[i]==usu[i-1])
        {
            ++act;
            continue;
        }
        else
        {
            sol+=(act-1)*act/2;
            act=1;
            continue;
        }
    }
    sol+=(act-1)*act/2;
    cout<<sol;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int a,n;
	scanf("%d",&a);
	if(a%7==0){
		printf("thu\n");
	}
	else if(a%7==1){
		printf("fri\n");
	}
	else if(a%7==2){
		printf("sat\n");
	}
	else if(a%7==3){
		printf("sun\n");
	}
	else if(a%7==4){
		printf("mon\n");
	}
	else if(a%7==5){
		printf("tue\n");
	}
	else if(a%7==6){
		printf("wed\n");
	}
	
	return 0;
}


Measured memory_bytes: 2700
n,k = map(int,input().split())

l = list(map(int,input().split()))


for i in range(n):
    if l[i] >= 0:
        ind = i

left = min(n-1,i+k)

ans = 1e10

while left >= k-1:
    if l[left]*l[left-k+1]>=0:
        d = max(abs(l[left]),abs(l[left-k+1]))
    else:
        a = abs(l[left])
        b = abs(l[left-k+1])
        d = min(2*a+b,a+2*b)
    if d < ans:
        ans=d
    left -=1

print(ans)
    


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

typedef long long ll;

int main(){
  ll n, t; cin >> n >> t;

  ll cnt=t;
  ll before, after=1e9+5; cin >> before;
  for(int i=0; i<n-1; i++){
    cin >> after;
    cnt += min(after-before, t);
    before = after;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <math.h>

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

using namespace std;
int main()
{
    int R;
    cin >> R;
    if (R < 1200)cout << "ABC" << endl;
    else if (R < 2800) cout << "ARC" << endl;
    else if (2800 <= R) cout << "AGC" << endl;

    return 0;
}

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

using namespace std;
typedef unsigned long long ull;

int main(){
	ull v = 0;
	const int MAX_N = 50;
	int X1[MAX_N], Y1[MAX_N], D1[MAX_N], X2[MAX_N], Y2[MAX_N], D2[MAX_N];
	int N, K;

	cin >> N >> K;

	vector<int> X(2 * N), Y(2 * N), D(2 * N);

	for (int i = 0; i<N; i++){
		cin >> X1[i] >> Y1[i] >> D1[i] >> X2[i] >> Y2[i] >> D2[i];
		X[i]     = X1[i];
		X[i + N] = X2[i];
		Y[i]     = Y1[i];
		Y[i + N] = Y2[i];
		D[i]     = D1[i];
		D[i + N] = D2[i];
	}
//	clock_t st = clock();
	sort(X.begin(), X.end());
	sort(Y.begin(), Y.end());
	sort(D.begin(), D.end());

	for (size_t i = 0, n = X.size()-1; i<n; i++){
	for (size_t j = 0; j<n; j++){
	for (size_t k = 0; k<n; k++){
		int kind = 0;
		for (int l = 0; l < N; l++){
			if (X1[l] <= X[i] && X[i+1] <= X2[l] && 
				Y1[l] <= Y[j] && Y[j+1] <= Y2[l] && 
				D1[l] <= D[k] && D[k+1] <= D2[l]) kind++;
		}
		if (kind >= K) v += (ull)(X[i+1] - X[i]) * (Y[j+1] - Y[j]) * (D[k+1] - D[k]);
	}
	}
	}

	cout << v << endl;
//	clock_t ed = clock();
//	cout << (double)(ed - st) / CLOCKS_PER_SEC << endl;
	return 0;
}

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

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

    sort(A.begin(), A.end());
    int lastPossibleIndex = 0;
    long long size = 0;
    for (int i = 0; i < N - 1; i++) {
        size += A[i];
        if (size * 2 < A[i + 1]) {
            lastPossibleIndex = i + 1;
        }
    }

    cout << N - lastPossibleIndex << endl;
    return 0;
}

Measured memory_bytes: 640
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
#define ALL(a) a.begin(), a.end()
using namespace std;

#define MaxN 100001
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
template<typename T> T abs(T val){return val>0?val:-val;}
inline int max2(int a, int b) {return ((a > b)? a : b);}
inline int min2(int a, int b) {return ((a < b)? a : b);}
inline int max3(int a, int b, int c) {return max2(a, max2(b, c));}
inline int min3(int a, int b, int c) {return min2(a, min2(b, c));}

int N,M;
int A[303][303];

int CNT[303];
int vis[303];
void solve()
{
    int ans = INF;
    CLR(vis);
    for(int i=1;i<=M;i++)
    {
        CLR(CNT);
        for(int j=1;j<=N;j++)
        {
            for(int k=1;k<=M;k++)
            {
                if(vis[A[j][k]]) continue;
                CNT[A[j][k]]++;
                break;
            }
        }
        int mx = 0,loc;
        for(int j=1;j<=M;j++) if(CNT[j]>mx) mx = CNT[j], loc = j;
        ans = min(ans, mx);
        vis[loc] = 1;   
    }
    printf("%d\n", ans);
}
int main()
{
    //std::ios::sync_with_stdio(false);
    while(~scanf("%d%d", &N, &M))
    {
        for(int i=1;i<=N;i++)
        for(int j=1;j<=M;j++)
        scanf("%d", &A[i][j]);
        solve();
    }
    //system("pause");
    //printf("%lld\n", ((x)%mod+mod)%mod );
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int line[3][4] = {{1,2,4,3},{0,3,5,2},{0,1,5,4}}; 

struct dice {
	int f2n[6];
};

bool check_equal_dice(dice& d1, dice& d2) {
	for (int f = 0; f < 3; ++f) {
		if ((d1.f2n[0] == d2.f2n[f])&&(d1.f2n[5] == d2.f2n[5-f])) {
			for (int i = 0; i < 4; ++i) {
				bool seq = true;
				for (int j = 0; seq && j < 4; ++j) {
					if (d1.f2n[line[0][j]] != d2.f2n[line[f][(i+j)%4]]) {
						seq = false;
					}
				}
				if (seq) {
					return true;
				}
			}
		}
		else if ((d1.f2n[0] == d2.f2n[5-f])&&(d1.f2n[5] == d2.f2n[f])) {
			for (int i = 0; i < 4; ++i) {
				bool seq = true;
				for (int j = 0; seq && j < 4; ++j) {
					int next = i-j;
					if (next < 0) {
						next = 4 + (i-j);
					}
					if (d1.f2n[line[0][j]] != d2.f2n[line[f][next]]) {
						seq = false;
					}
				}
				if (seq) {
					return true;
				}
			}
		}
	}
	return false;
}

int main(void) {
	int n;
	cin >> n;
	vector<dice> d(n);
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < 6; ++j) {
			cin >> d[i].f2n[j];
		}
	}
	bool find = false;
	for (int i = 0; !find && i < n-1; ++i) {
		for (int j = i+1; !find && j < n; ++j) {
			find = check_equal_dice(d[i],d[j]);
		}
	}

	if (!find) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 3120
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	string res = "AC";
	string S; cin >> S;
	long mylen = S.length();

	if (S[0] != 'A') res = "WA";

	if (count(next(S.begin(), 2), prev(S.end(), 1), 'C') != 1) res = "WA";

	for (int i = 1; i <= mylen - 1; i++) if (S[i] < 97 && S[i] != 'C') res = "WA";
	
	cout << res << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int T;
	cin >> T;
	rep(t, T) {
		int N;
		cin >> N;
		
		ll saishou = 0;
		vector<pair<int, int>> L, R;
		int kazu = 0;
		rep(i, N) {
			int k, l, r;
			cin >> k >> l >> r;

			if (l < r) {
				R.pb(mp(k + 1, r - l));
				saishou += l;
			}
			else {
				L.pb(mp(k, l - r));
				saishou += r;
				kazu++;
			}
		}

		sort(R.begin(), R.end());
		sort(L.begin(), L.end());

		int nokori = N - kazu;
		priority_queue<int> PQ;
		int i = 0;
		while (i < nokori && R[i].first < kazu) {
			PQ.push(R[i].second); 
			i++;
		}
		for (int j = kazu; j <= N; j++) {
			while (i < nokori&& R[i].first <= j) {
				PQ.push(R[i].second);
				i++;
			}

			if (PQ.size()) {
				auto q = PQ.top();
				PQ.pop();
				saishou += q;
			}
		}

		PQ = priority_queue<int>();
		i = kazu - 1;
		while (i >= 0 && L[i].first > kazu) {
			PQ.push(L[i].second);
			i--;
		}
		for (int j = kazu - 1; j >= 0; j--) {
			while (i >= 0 && L[i].first > j) {
				PQ.push(L[i].second);
				i--;
			}

			if (PQ.size()) {
				auto q = PQ.top();
				PQ.pop();
				saishou += q;
			}
		}

		co(saishou);
	}








	Would you please return 0;
}

Measured memory_bytes: 5656
unittest
{
	assert( [ "3", "0 0", "1 0", "0 1" ].parse.expand.solve == "2.276142" );
	assert( [ "2", "-879 981", "-866 890" ].parse.expand.solve == "91.923882" );
	assert( [ "8", "-406 10", "512 859", "494 362", "-955 -475", "128 553", "-986 -885", "763 77", "449 310" ].parse.expand.solve == "7641.981782" );
}



import std.algorithm;
import std.conv;
import std.format;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto xys = new long[ 2 ][ n ];
	foreach( ref xy; xys )
	{
		input.popFront;
		xy = input.front.split.to!( long[] );
	}
	return tuple( xys );
}

auto solve( long[ 2 ][] xys )
{
	auto f1 = reduce!( ( a, b ) => a * b )( iota( 1L, xys.length.signed ) );
	auto f2 = f1 * xys.length.signed;
	auto ans = 0.0L;
	foreach( i, a; xys )
	{
		foreach( b; xys[ i + 1 .. $ ] )
		{
			auto d = ( ( a[ 0 ] - b[ 0 ] ) ^^ 2 + ( a[ 1 ] - b[ 1 ] ) ^^ 2 ) ^^ 0.5L;
			ans += d * ( f1 * 2 );
		}
	}
	ans /= f2;
	return format( "%0.6f", ans );
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
	int total_n;
	int i;
	
	cin >> total_n;

	vector<int> A(total_n);
	vector<int> B(total_n);
	for (i=0; i<total_n; i++) {
		cin >> A[i];
	}
	for (i=0; i<total_n; i++) {
		cin >> B[i];
	}
	int ans = 0;
	for (i=0; i<total_n; i++) {
		if (A[i] > B[i])
			ans += A[i]-B[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
char s[maxn]; 
int main()
{
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	int ans = 0;
	for(int i = 1; i <= n; ++i)
		if(s[i] == 'p') --ans;
	ans += n / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3744
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define pi pair<int,int> 
#define pii pair<pi,int>
#define ull unsigned long long
#define vi vector<int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a >= mod)a %= mod;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	vi v(n);
	rep(i,n){
		cin>>v[i];
	}
	ll sum = 0;
	rep(i,n){
		repa(j,i+1,n){
			int temp = v[i]*v[j];
			sum += temp;
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3644
<?php
list($n,$k)=explode(" ",trim(fgets(STDIN)));
list($r,$s,$p)=explode(" ",trim(fgets(STDIN)));
$t=trim(fgets(STDIN));
$ans=0;
$i=0;
while($i<$n){
  if($t[$i]=="r"){
    $v=$p;
  }elseif($t[$i]=="s"){
    $v=$r;
  }else{
    $v=$s;
  }
  if($i<$k){
    $ans+=$v;
  }else{
    if($t[$i]==$t[$i-$k]){
      $t[$i]="q";
    }else{
      $ans+=$v;
    }
  }
  ++$i;
}
echo $ans;

Measured memory_bytes: 4728
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        String alphabets="abcdefghijklmnopqrstuvwxyz";
        int[] albox=new int[alphabets.length()];
        while(scanner.hasNext()){
            String s=scanner.nextLine();
            s=s.toLowerCase();
            String[] chars=s.split("");
            for(String c:chars){
                int index=alphabets.indexOf(c);
                if(index==-1) continue;
                albox[index]++;
            }
        }
        for(int i=0;i<alphabets.length();i++){
            System.out.println(alphabets.charAt(i)+" : "+albox[i]);
        }
    }

}



Measured memory_bytes: 26552
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  ll n;
  cin>>n;
  vi x(n),l(n);
  rep(i,n) cin>>x[i]>>l[i];
  vector<P> v(n);
  rep(i,n){
    v[i]=make_pair(x[i]+l[i],x[i]-l[i]);
  }
  sort(all(v));
  ll ans=0;
  ll now=v[0].fi;
  ans++;
  REP(i,1,n){
    if(now>v[i].se) continue;
    else{
      ans++;
      now=v[i].fi;
    }
  }
  out(ans);
}

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


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define N 505
#define INF 0x3f3f3f3f
int n;
int a[N][N];
int c[N], d[N], inq[N];
char s[N][N];
queue < int > Q;
void SPFA()
{
    for (int i = 1; i <= n; i ++)
        if (d[i] == 0)
        {
            Q.push(i);
            inq[i] = 1;
        }
    while (! Q.empty())
    {
        int x = Q.front();
        Q.pop();
        inq[x] = 0;
        for (int i = 1; i <= n; i ++)
            if (d[i] > d[x] + 1)
            {
                d[i] = d[x] + 1;
                if (! inq[i])
                {
                    Q.push(i);
                    inq[i] = 1;
                }
            }
    }
}
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i ++)
        scanf("%s", s[i] + 1);
    int mx = 0;
    for (int i = 1; i <= n; i ++)
        for (int j = 1; j <= n; j ++)
        {
            a[i][j] = (s[i][j] == '#');
            c[i] += a[i][j];
            mx = max(mx, c[i]);
        }
    if (!mx)
    {
        puts("-1");
        return 0;
    }
    for (int i = 1; i <= n; i ++)
        d[i] = INF;
    for (int i = 1; i <= n; i ++)
        for (int j = 1; j <= n; j ++)
        if (a[i][j])
            d[j] = 0;
    SPFA();
    int tmp = 0x3f3f3f3f, id = 0;
    for (int i = 1; i <= n; i ++)
    {
        if (d[i] != 0x3f3f3f3f && n - c[i] < tmp)
        {
            tmp = min(tmp, n - c[i] + d[i]);
            id = i;
        }
    }
    for (int j = 1; j <= n; j ++)
    {
        for (int i = 1; i <= n; i ++)
        {
            if (! a[i][j])
            {
                tmp ++ ;
                break;
            }
        }
    }
    printf("%d\n", tmp);
    return 0;
}


Measured memory_bytes: 1536
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using lb = long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

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

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
//最小化問題(DP)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//最大化問題(DP)
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/*-------------ここまで---------------------------------------------*/
int main(){
    int x;
    cin >> x;
    if (x == 7 || x == 5 || x == 3) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3568