akhauriyash/Code-Regression huggingface dataset:
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions 

#endif


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

    int N; cin >> N;
    vi X(N), Y(N), H(N);
    REP(i, N) cin >> X[i] >> Y[i] >> H[i];

    const int CXMAX = 100, CYMAX = 100;
    
    int hMax = 0;
    int hMaxIndex = 0;
    REP(i,N) {
        if (H[i] > hMax) {
            hMaxIndex = i;
            hMax = H[i];
        }
    }

    int ansX = 0, ansY = 0, ansH = 1;
    bool found = false;
    REP(cx,CXMAX+1) {
        REP(cy,CYMAX+1) {
            const int Height = abs(X[hMaxIndex] - cx) + abs(Y[hMaxIndex] - cy) + H[hMaxIndex];

            found = true;
            REP(i,N) {
                if (max(Height - abs(X[i] - cx) - abs(Y[i] - cy), 0)  != H[i]){
                    found = false;
                    break;
                }
            }

            if (found) {
                ansX = cx; ansY = cy; ansH = Height;
                break;
            }
        }
        if (found) break;
    }

    cout << ansX << " " << ansY << " " << ansH << endl;

    return 0;
}

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

int main()
{
  int n, a, b;
  cin >> n;
  vector<bool> vp(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a >> b;
    vp[i] = a == b;
  }
  for (int i = 2; i < n; i++)
  {
    if (vp[i - 2] && vp[i - 1] && vp[i])
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3624
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, T): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let t: Vec<usize> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let (res, _) = t[1..].iter().fold((0, t[0]), |(res, prev), &x| (res + std::cmp::min(T, x - prev), x));
    let ans = res + T;

    println!("{}", ans);
}


Measured memory_bytes: 10492
#include<bits/stdc++.h>
const int mod=1e9+7;
typedef long long ll;
const int N=2e5+5;
std::set<std::string> s;
int main()
{
	std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
	// freopen("a.in","r",stdin);
	// int T;scanf("%d",&T);while(T--){
	std::string s;std::cin>>s;
	int ans = 0;
	std::map<int,int>mp;
	int cnt = 0;
	mp[0] = 1;
	int bas = 1;
	for(int i = s.size() - 1; i >= 0; i--){
		ans = (ans + ll(s[i] - '0') * bas)%2019;
		cnt += mp[ans]++;
		bas = bas * 10 % 2019;
	}
	std::cout<<cnt<<'\n';
	// }
	return 0;
}


Measured memory_bytes: 3744
n=int(input())
A=list(map(int,input().split()) )

A.sort()

furui = [0] * (max(A) + 1)

for i in A:
    if furui[i] >= 2:
        continue
    
    for j in range(i,len(furui),i):
        furui[j] += 1

ans=0
for i in A:
    if furui[i]==1:
        ans+=1

print(ans)

Measured memory_bytes: 132132
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int num,stu[10000],cou;
double w,t,a;
int main(){
    while(scanf("%d,%lf,%lf",&num,&w,&t)!=EOF){
        a=t*t;
        stu[num]=w/a;
        cou++;
    }
    for(int i=1001;i<1001+cou;i++){
        if(stu[i]>=25)cout<<i<<endl;
    }
return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0; i<(n); i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define LL long long
#define ULL unsigned long long
using namespace std;

int h,w,t;
char a[10];

int main() {
	cin>>h>>w;
	REP(i,h) {
		cin>>a;
		t += count(a, a+10, '#');
	}
	cout<<(t==(h+w-1)?"Possible":"Impossible")<<endl;
}


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

using namespace std;


int main(void){

  int N;
  string S,A="";

  cin >> N >> S;

  for(int i = 0; i < N-1;i++){
    
    if(S[i]==S[i+1]){
      continue;
    }else{
      A += S[i];
    }
   
  }

  if(S[N-1]!=S[N]){
    A+=S[N];
  }

  
  cout << A.length() << endl;

  return 0;
}




Measured memory_bytes: 640
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;
import javax.xml.ws.WebEndpoint;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }

    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        int r=sc.nextInt();
        if(n>=10) {
        	ret(r);
        }
        out.println(r+(10-n)*100);
     	out.flush();
    }
   
    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x,y; double d;
//	P(int  x, int y, double d) {
//	  this.x=x;
//	  this.y=y;
//	  this.d=d;
//	}
//}


class P implements Comparable<P>{
    int p,h,f; long m;
    P(int p,int h, int f, long m) {
    	this.p=p;
    	this.h=h;
    	this.f=f;
    	this.m=m;
    }

    public int compareTo(P p){
    	if(this.p==p.p) {
    		if(this.f==-1) return 1;
    		return -1;
    	}
        return this.p-p.p;
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 26452
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
 
 
int main()
{
	ll n, a[100005], b[100005], i, ans = 0;
 
	scanf("%lld", &n);
	for(i = 0; i < n; i++){
		scanf("%lld %lld", &a[i], &b[i]);
	}
 
	for(i = n - 1; i >= 0; i--){
		ans += ((a[i] + ans) % b[i] != 0)? b[i] - (a[i] + ans) % b[i] : 0;
	}
 
	printf("%lld\n", ans);
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(int argc, char** argv)
{
	int a, b, result[10000];
	char ope;

	int i = 0;
	while (1) {
		scanf("%d %c %d", &a, &ope, &b);

		if (ope == '+') {
			result[i] = a + b;
		}
		else if (ope == '-') {
			result[i] = a - b;
		}
		else if (ope == '*') {
			result[i] = a * b;
		}
		else if (ope == '/') {
			result[i] = a / b;
		}
		else if (ope == '?') {
			break;
		}
		i++;
	}

	int max_i = i;
	for (i = 0; i < max_i; i++) {
		printf("%d\n", result[i]);
	}
	return 0;
}

Measured memory_bytes: 608
#include<iostream>
using namespace std;
int main()
{
	int n,z;
	int h[101];
	int sq[101];

	while (1) {
		//cout << "??\???:";
		cin >> n;
		if (n == 0) break;
		for (int i = 1; i <= n+1; i++)	//???????????? +1
			cin >> h[i];

		for (z = 1; z <= n; z++) {	//	????????????????±???????
			int Flag = 0;
			for (int i = 1; i <= n; i++)
				sq[i] = h[i];
			for (int i = z; i <= n; i++) {
				sq[i] = h[i + 1];
			}

			/*cout << "??\????????????: ";
			for (int i = 1; i <= n; i++) cout << " " << sq[i];
			cout << endl;*/

			for (int i = 1; i < n; i++) {
				if (sq[i + 1] - sq[i] != sq[2] - sq[1])
					Flag = 1;
			}
			if (Flag == 0) break;
		}
		cout << h[z] << endl;
	}
}

Measured memory_bytes: 1160
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wsign-compare"

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

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	cout.tie (0);
	ll tc = 1; //cin >> tc;
	while (tc--)
	{
		ll i, j, n, sum = 0;
		cin >> n;
		vector <ll> inp (n), freq (n + 1, 0);
		trav (a, inp) cin >> a, ++freq[a];
		trav (a, freq) sum += a*(a-1)/2;
		trav (a, inp)
			cout << sum - freq[a]*(freq[a]-1)/2 + (freq[a]-1)*(freq[a]-2)/2 << '\n';
	}

	return 0;
}



Measured memory_bytes: 5760
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	x := -1
	for i := 2; ; i++ {
		if i*(i-1)/2 == n {
			x = i
			break
		} else if i*(i-1)/2 > n {
			break
		}
	}
	if x == -1 {
		fmt.Println("No")
	} else {
		p, q := 0, 1
		ans := make([][]int, x)
		for i := 1; i <= x*(x-1)/2; i++ {
			ans[p] = append(ans[p], i)
			ans[q] = append(ans[q], i)
			q++
			if q >= x {
				p++
				q = p + 1
			}
		}
		fmt.Println("Yes")
		fmt.Println(x)
		for _, v := range ans {
			fmt.Print(len(v))
			fmt.Print(" ")
			fmt.Println(strings.Trim(fmt.Sprint(v), "[]"))
		}
	}
}


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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;

int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<ll> hs(n);
    rep(i, n)cin >> hs[i] ;
    sort(all(hs));
    ll mi = numeric_limits<ll>::max();
    for(int i = k-1; i<n; i++){
        ll d = hs[i]-hs[i-(k-1)];
        mi = min(d, mi);
    }
    cout << mi << "\n";
    return 0;
}

Measured memory_bytes: 1024
Tap = input()
L_Tap = len(Tap)
 
Flag = 0
 
for i in range(L_Tap):
  if i % 2 == 0:
    if Tap[i] == 'R' or Tap[i] == 'U' or Tap[i] == 'D':
      Flag = 0
    else:
      Flag = 1
      break
  else:
    if Tap[i] == 'L' or Tap[i] == 'U' or Tap[i] == 'D':
      Flag = 0
    else:
      Flag = 1
      break
 
if Flag == 0:
  print('Yes')
else:
  print('No')

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

int main()
{
    ll x ;
    cin >> x ;

    ll money = 100;
    int count = 0 ;
    while(money<x)
    {
        ++count ;
        money*=1.01 ;
    }
    cout << count << endl ;
}

Measured memory_bytes: 3624
S = input()
Q = int(input())
head = ""
tail = ""
reversed = False
for _ in range(Q):
    q = input().replace(" ","")
    if len(q) == 3:
        t, f, c = q[0],q[1],q[2]
    else:
        t = q[0]
    if t == "1":
        reversed = not reversed
    elif t == "2":
        if f == "1":
            #元の順のとき
            if not reversed:
                head = c + head
            #元とは逆順になっているとき
            else:
                tail = tail + c
        else:
            #元の順のとき
            if not reversed:
                tail = tail + c
            #元とは逆順になっているとき
            else:
                head = c + head
if reversed:
    print(tail[::-1],S[::-1],head[::-1],sep="")
else:
    print(head,S,tail,sep="")

Measured memory_bytes: 4060
#include <iostream>
#include <string>

using namespace std;

int main() {
	char S;
	cin >> S;
	if (S == 'T') {
		cout << 'A' << endl;
	} else if (S == 'A') {
		cout << 'T' << endl;
	} else if (S == 'C') {
		cout << 'G' << endl;
	} else {
		cout << 'C' << endl;
	}
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};



int main(){
    LL a, b, c, ans;
    cin >> a >> b >> c;
    ans = c;
    REP(i, 10) {
        ans = ans * a - b;
        cout << ans << endl;
    }
}


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

using namespace std;

using i64 = int64_t;

const i64 MOD = (i64)1e9 + 7;

const i64 INF = (i64)1e18 + 7;


template <i64 mod = MOD>
struct ModInt{
    i64 p;

    ModInt() : p(0){}
    ModInt(i64 x){p = x >= 0 ? x % mod : x + (-x + mod - 1) / mod * mod;}

    ModInt& operator+=(const ModInt& y){p = p + *y - ((p + *y) >= mod ? mod : 0); return *this;}
    ModInt& operator-=(const ModInt& y){p = p - *y + (p - *y < 0 ? mod : 0); return *this;}
    ModInt& operator*=(const ModInt& y){p = (p * *y) % mod; return *this;}
    ModInt& operator%=(const ModInt& y){if(y)p %= *y; return *this;}

    ModInt operator+(const ModInt& y) const{ModInt x = *this; return x += y;}
    ModInt operator-(const ModInt& y) const{ModInt x = *this; return x -= y;}
    ModInt operator*(const ModInt& y) const{ModInt x = *this; return x *= y;}
    ModInt operator%(const ModInt& y) const{ModInt x = *this; return x %= y;}

    friend ostream& operator<<(ostream& stream, const ModInt<mod>& x){
        stream << *x;
        return stream;
    }

    friend ostream& operator>>(ostream& stream, const ModInt<mod>& x){
        stream >> *x;
        return stream;
    }

    ModInt& operator++(){p = (p + 1) % mod; return *this;}
    ModInt& operator--(){p = (p - 1 + mod) % mod; return *this;}

    bool operator==(const ModInt& y) const{return p == *y;}
    bool operator!=(const ModInt& y) const{return p != *y;}

    const i64& operator*() const{return p;}
    i64& operator*(){return p;}

};

using mint = ModInt<>;


int solve(int _count){

    i64 n, k;
    cin >> n >> k;

    if(!static_cast<bool>(cin))
        return MOD;
#ifdef TEST
    cout << "Case: " << _count << endl;
#endif


    int m = n + 5;
    vector<vector<mint>> dp(m + 1, vector<mint>(m + 1, 0));
    dp[1][1] = 1;
    for(int i = 0; i < m; ++i)
        for(int j = 0; j < m; ++j){
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j + 1] += dp[i][j];
        }


    auto f = [&](i64 n, i64 r){
        if(n == 0 && r == 0)
            return mint(1);
        if(n < 0 || r < 0)
            return mint(0);
        return dp[n][r];
    };

    for(int t = 1; t <= k; ++t){
        mint b = f(k, t);
        mint a1 = f(n - k, t - 1);
        mint a2 = f(n - k, t);
        mint a3 = f(n - k, t + 1);
        // cout << b << " " << a1 << " " << a2 << " " << a3 << endl;
        cout << b * (a1 + a2 * 2 + a3) << endl;
    }

    return 0;
}


signed main(){

    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int t = 0;
    while(solve(++t) != MOD);
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

// 素数判定
bool isPrime(int a)
{
    if (a == 1) return false;
    for (int i = 2; i * i <= a; i++)
	{
        if(a % i == 0) return false;
    }
    return true;
}

void solve()
{
	int x;
	cin >> x;
	for(int i = x; i < 2 * x; ++i)
	{
		if(isPrime(i))
		{
			cout << i;
			return;
		}
	}
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 256
mod = 10 ** 9 + 7

n, k = gets.to_s.split.map{|e|e.to_i}

# ans = (k..n+1).map{|i| i * (n + n - i + 1) / 2 - i * ( i - 1 ) / 2 + 1 }.sum % mod

puts (n * (n+1) * (n+2) / 6 - k * (k-1) * (3*n-2*k+4) / 6 + (n - k + 2)) % mod

Measured memory_bytes: 14336
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 1e18;
const ll fact_table = 1200008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
// #define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
 
ll mod = 998244353;
// ll mod = 1000000007;
  
ll mypow(ll number1,ll number2, ll mod){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
bool multicase = false;

ll n,m,num,sum,a,b,c,d,e,h,q,p;
ll w, ans;
ll k;
ll dp[2005][6005];

void solve(){
    cin >> n >> m;
    ll ans = 0;
    if(n >= 2)ans += n * (n - 1) / 2;
    if(m >= 2)ans += m * (m - 1) / 2;
    p(ans);
    return;
}

int main(){
    // init();
    // ios::sync_with_stdio(false);
    // cin.tie(nullptr);
    ll q;
    if(multicase){
        cin >> q;
    }else{
        q = 1;
    }
    while(q--){
        solve();
    }
    return 0;

}


















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

const int INF = (1 << 21);
int coin_num[4], tmp_coin_num[4], ans_coin_num[4], pay_coin_num[4];
int coins[4] = {10, 50, 100, 500};

void calc_change(int res) {
    for (int i = 3; i >= 0; i--) {
        while (res >= coins[i]) {
            res -= coins[i];
            tmp_coin_num[i]++;
        }
    }
}

int main(void) {
    int total;
    bool first = true;
    while (cin >> total, total) {
        if (!first) cout << endl;
        first = false;

        // 0: 10yen, 1: 50yen, 2: 100yen, 3: 500yen
        for (int i = 0; i < 4; i++) {
            cin >> coin_num[i];
            ans_coin_num[i] = 20; // ??¬??¨????????§?????°??§?????????
            pay_coin_num[i] = 0;
        }

        int pay;
        for (int i = 0; i <= coin_num[0]; i++) {
            for (int j = 0; j <= coin_num[1]; j++) {
                for (int k = 0; k <= coin_num[2]; k++) {
                    for (int l = 0; l <= coin_num[3]; l++) {
                        pay = i*10 + j*50 + k*100 + l*500;
                        if (pay >= total) {
                            for (int i = 0; i < 4; i++) tmp_coin_num[i] = coin_num[i];
                            tmp_coin_num[0] -= i;
                            tmp_coin_num[1] -= j;
                            tmp_coin_num[2] -= k;
                            tmp_coin_num[3] -= l;

                            calc_change(pay-total); // ?????£???????¨????

                            int tmp_num = 0, ans_num = 0;
                            for (int i = 0; i < 4; i++) {
                                tmp_num += tmp_coin_num[i];
                                ans_num += ans_coin_num[i];
                            }
                            if (ans_num > tmp_num) {
                                for (int i = 0; i < 4; i++) {
                                    ans_coin_num[i] = tmp_coin_num[i];
                                }
                                pay_coin_num[0] = i;
                                pay_coin_num[1] = j;
                                pay_coin_num[2] = k;
                                pay_coin_num[3] = l;
                            }
                        }
                    }
                }
            }
        }

        for (int i = 0; i < 4; i++) {
            if (pay_coin_num[i] > 0) {
                cout << coins[i] << " " << pay_coin_num[i] << endl;
            }
        }
    }

    return 0;
}

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

int cnt_digits(long N) {
  int digits=0;

  while(N>0) {
    N/=10;
    digits++;
  }
  return digits;
}

int main(void) {
  long N;
  cin >> N;

  int ans=cnt_digits(N);

  for(long A=1;A*A<=N;++A) {
    if(N%A!=0) continue;
    long B=N/A;

    int cur=max(cnt_digits(A), cnt_digits(B));

    if(ans>cur) ans=cur;
  }

  cout<<ans<<endl;
  return 0;
}


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

int main(){
    int n,sum=0;
    cin>>n;
    vector<int>arr;
    for(int i=0; i<n; i++){
        int x;
        cin>>x;
        x+=200;
        arr.push_back(x);
        sum+=x;
    }
    sum=round(double(sum)/(double)n);
    int ans=0;
    for(int i=0; i<arr.size(); i++){
        int tmp=sum-arr[i];
        if(tmp<0)tmp*=-1;
        ans+=(tmp*tmp);
    }
    cout<<ans;
return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#define rep(i,n) for(int i=0; i<(n); ++i)
int main(){
    int n; std::cin >> n;
    std::vector<int> v(n), p(n), q(n);
    rep(i,n) std::cin >> p[i];
    rep(i,n) std::cin >> q[i];
    std::iota(v.begin(),v.end(),1);
    int a=-1, b=-1, cnt=1;
    do{
        if(v == p) a=cnt;
        if(v == q) b=cnt;
        ++cnt;
    }while(std::next_permutation(v.begin(),v.end()));
    std::cout << std::abs(b-a) << std::endl;
    return 0;
}

Measured memory_bytes: 3580
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

minT = 651
ans = 1

for i in range(N):
  aveT = T - H[i] * 0.006
  minT = min(minT, abs(aveT - A))
  #print(minT)
  if minT == abs(aveT - A):
    ans = i + 1
    
print(ans)

Measured memory_bytes: 38384
/* Hello darkness my old friend, I've come to visit you again! */

#include<bits/stdc++.h>
#define lli long long int
#define FOR(i,a,b) for(i=a;i<b;i++)
#define FORB(i,b,a) for(i=b;i>=a;i--)
#define mod 1000000007
#define PI 2*acos(0.0)
#define gs getline(cin,s)
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pb push_back
#define eb emplace_back
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 1000000005
#define INF 1000000000000000005
#define io ios_base::sync_with_stdio(0);
#define ff first
#define ss second
using namespace std;

int main()
{
    io;
    cin.tie(0);
    cout.tie(0);
    int a,b;
    cin>>a>>b;
    if(a>8 || b>8)
        cout<<":(";
    else
        cout<<"Yay!";
    return 0;
}

/* This is the end, beautiful friend! */


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
   
   int n,d,ans=0;
   scanf("%d %d",&n,&d);
   double dis=0;
   for(int i=0;i<n;i++){
       double x,y;
       scanf("%lf %lf",&x,&y);
       dis=sqrt(x*x+y*y);
       if(dis<=d)ans++;
   }
   printf("%d\n",ans);
}

Measured memory_bytes: 2220
#include <stdio.h>
typedef long long ll;

ll power(int x);

int main()
{
    ll m, k;
    ll max_e;

    scanf("%lld %lld", &m, &k);
    max_e = power(m);

    ll s = 0;
    for (ll i = 0; i < max_e; i++) {
        if (i != k) {
            s ^= i;
        }
    }

    if (s != k && k != 0) {
        printf("-1\n");
        return 0;
    }

    for (ll i = 0; i < max_e; i++) {
        if (i != k || k == 0) {
            printf("%lld ", i);
        }
    }
    if (k != 0) {
        printf("%lld ", k);
    }
    
    for (ll i = max_e - 1; i >= 0; i--) {
        if (i != k || k == 0) {

            if (i == 0 && k == 0) {
                printf("%lld", i);
            }
            else {
                printf("%lld ", i);
            }
        }
    }
    if (k != 0) {
        printf("%lld", k);
    }
    
    putchar('\n');
    
    return 0;
}

ll power(int x)
{
    ll res = 1;
    ll mul = 2;

    while (x) {
        if (x & 1) {
            res *= mul;
        }

        mul *= mul;
        x = x >> 1;
    }

    return res;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	bool ans=true;;

	cin >>s;
	string b="hi";
	if(s.size()%2==1){
		ans=false;
		cout << solve(ans) << endl;
		return 0;
	}
	for(int i=0;i<s.size()-1;){
		if(s[i]=='h' and s[i+1]=='i'){
			
			i+=2;
		}else{
			ans=false;
			break;
		}

	}
	cout<<solve(ans)<<endl;
}

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

#define ll long long
#define fi first
#define se second
#define pb push_back

using namespace std;

ll q, p, x, y;
string t;
char c;

int main()
{
    cin >> t >> q;
    deque < char > s;
    for (auto &i:t) s.pb(i);
    while (q--)
    {
        cin >> p;
        if (p==1) x++; else
        {
            cin >> y >> c;
            if (x&1) y=y%2+1;
            if (y==1) s.push_front(c); else s.pb(c);
        }
    }
    if (x&1) while (s.size()) cout << s.back(), s.pop_back(); else
        while (s.size()) cout << s.front(), s.pop_front();
}


Measured memory_bytes: 1024
#import "stdio.h"

char exchange(char n) {
    switch (n){
        case '1':
            return '9';
        case '9':
            return '1';
        default:
            return n;
    }
}
int main(int argc, const char * argv[]) {
    @autoreleasepool {
        char a,b,c;
        scanf("%c%c%c", &a, &b, &c);
        printf("%c%c%c\n", exchange(a), exchange(b), exchange(c));
    }
    return 0;
}


Measured memory_bytes: 2276
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  long long n, k;
  cin>>n>>k;
  vector<long long> a(n);
  REP(i, n){
    cin>>a[i];
  }
  sort(ALL(a));
  long long l = -1e18;
  long long r = (long long)(1e18) + 1;
  while(r - l > 1){
    long long m = (l + r) / 2;
    long long cnt = 0;
    REP(i, n){
      if(a[i] > 0){
        long long ok = -1, ng = n;
        while(ng - ok > 1){
          long long mid = (ok + ng) / 2;
          if(a[i] * a[mid] < m){
            ok = mid;
          }else{
            ng = mid;
          }
        }
        cnt += ng;
        if(a[i] * a[i] < m)cnt--;
      }else if(a[i] < 0){
        long long ok = -1, ng = n;
        while(ng - ok > 1){
          long long mid = (ok + ng) / 2;
          if(a[i] * a[mid] >= m){
            ok = mid;
          }else{
            ng = mid;
          }
        }
        cnt += n - ng;
        if(a[i] * a[i] < m)cnt--;
      }else{
        if(0 < m){
          cnt += n - 1;
        }else{
          continue;
        }
      }
    }
    cnt /= 2;
    if(cnt < k){
      l = m;
    }else{
      r = m;
    }
  }
  cout<<l<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int a[200];
int main()
{
    int cnt=1;
    int f=1;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
        if(a[i]&1)
        {
            f=0;
        }
    }
    if(!f) {cout<<0<<endl;
            return 0;}
    while(1)
        {
            for(int i=0; i<n; i++)
            {
                a[i]=a[i]/2;
                if(a[i]&1)
                {
                    cout<<cnt<<endl;
                    return 0;
                }
            }
            cnt++;
        }
    return 0;
}


Measured memory_bytes: 256
N,A,B = map(int,input().split())
H = [int(input()) for i in range(N)]
H.sort(reverse=True)

def defeat(k):
    n = 0
    for h in H:
        if h <= B*k: break
        h -= B*k
        n += -(-h//(A-B))
        if n > k:
            return False
    return True

ok = 10**18
ng = 0
while ok-ng > 1:
    m = (ok+ng)//2
    if defeat(m):
        ok = m
    else:
        ng = m
print(ok)

Measured memory_bytes: 7384
#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<string> vec(N, string(26, '0'));
	map<string, long long> mp;
	string s(10, ' ');
	for (int i = 0; i < N; ++i)
	{
		cin >> s;
		for (int j = 0; j < 10; ++j)
			vec[i][s[j] - 'a']++;
		mp[vec[i]]++;
	}
	long long ct = 0;
	for (auto iter = mp.begin(); iter != mp.end(); ++iter)
	{
			ct += (iter->second*(iter->second - 1)) / 2;
	}
	cout << ct << endl;

	return 0;
}

Measured memory_bytes: 19840
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
vector <int> a;
signed main(void){
    int n; cin>>n;
    a.resize(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(),a.end());
    bool same = true;
    
    rep(i,n-1) if(a[i] != a[i+1]) same = false;
    if(abs(a[0] - a[n-1])>=2) {cout<<"No"<<endl; return 0;}
    if(same){
        if(a[0] == n-1 || 2*a[0] <=n) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }else{
        int p = count(all(a), a[0]);
        int q = n-p;
        if(p<a[n-1]&& 2*(a[n-1]-p)<=q) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<bool>> v(2,vector<bool>(n,false));
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    if(a>b) swap(a,b);
    if(a==0){v[0][b]=true;}
    if(b==n-1){v[1][a]=true;}
  }

  auto f = [&](){
    rep(i,n) if(v[0][i] & v[1][i]) return true;
    return false;
  };

  if(f()) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

class RunRun {
public:
	RunRun(long long K);
	~RunRun();
	long long main_calc();
private:
	long long make_Run(long long i);
	void recursive(long long k, long long num, long long bef);
private:
	const long long K;
	long long ci = 0;
	vector<long long> val;
};

RunRun::RunRun(long long K) : K(K){
	val.clear();
}

RunRun::~RunRun() {
}


void RunRun::recursive(long long k, long long num, long long bef) {
	long long dnum = num;
	if (k == 0) {
		val.push_back(num);
		return;
	}
	else {
		if (0 < bef) {
			dnum = num;
			dnum += (bef - 1) * (long long)pow(10, k - 1);
			recursive(k - 1, dnum, bef - 1);
		}
		dnum = num;
		dnum += bef * (long long)pow(10, k - 1);
		recursive(k - 1, dnum, bef);
		if (bef < 9) {
			dnum = num;
			dnum += (bef + 1) * (long long)pow(10, k - 1);
			recursive(k - 1, dnum, bef + 1);
		}
	}
}

long long RunRun::make_Run(long long i) {

	for (long j = 1; j <= 9; j++) {
		recursive(i - 1, j * (long long)pow(10, i - 1), j);
	}

	return val.size();
}

long long RunRun::main_calc() {

	long long sum = 0;
	long long i = 0;

	while (sum < K) {
		i++;
		sum = make_Run(i);
	}

	sort(val.begin(), val.end());

	return val[K - 1];
}

int main(){

	long long K;
	cin >> K;

	RunRun r(K);

	cout << r.main_calc() << endl;

	return 0;
}



Measured memory_bytes: 2420
#include <iostream>

using namespace std;

int main() {
    string s;
    int counter = 0;
    cin >> s;
    int s_len = s.length();
    for (int i = 0; i < s_len; i++) {
        if (s[i] != s[s_len - 1 - i])
            counter++;
    }
    
    cout << counter / 2;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

ll P = 1000000007;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<ll> c(1 << 26);
  ll n;
  string s;
  cin >> n >> s;

  for (int i = 0; i < n; i++) {
    c[s[i] - 'a']++;
  }
  ll ans = 1;
  for (int i = 0; i < 26; i++) {
    ans *= (c[i] + 1);
    ans %= P;
  }
  ans += P - 1;
  ans %= P;
  cout << ans << endl;

  return 0;
}


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

int main(){
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int ans=0;
  for(int i=0; i<=A; i++){
    for(int j=0; j<=B; j++){
      for(int k=0; k<=C; k++){
        if(500*i+100*j+50*k==X) ans++;
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
	int n,x; //nまでの数3つで和がx
	int num = 0;
	
	while (1) {
            num = 0; //激注意
	    cin >> n >> x;
	    if ( n == 0 && x == 0 ) break;
	    for ( int i = 1; i <= n - 2; i++ ) 
	        for ( int j = i + 1; j <= n - 1; j++ ) 
	            for ( int k = j + 1; k <= n; k++ ) {
	        	    if ( i + j + k == x ) num++;
	            }
	    cout << num << endl;
	}
}


Measured memory_bytes: 3108
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

using namespace std;

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

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

int n;
int cnt[100010];
ll sum;

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	cin>>n;for(int i=0;i<n;i++){int x;cin>>x;cnt[x]++;sum+=x;}
	
	int q;cin>>q;while(q--)
	{
		int a,b;cin>>a>>b;
		sum+=cnt[a]*(b-a);
		cnt[b]+=cnt[a];cnt[a]=0;cout<<sum<<endl;
	}
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


Measured memory_bytes: 3956
n,m,x = map(int, input().split())
c_a = []
for i in range(n):
      c_a.append(list(map(int, input().split())))

min_sum_answer = -1
for i in range(2**n):
      min_sum = 0
      get_score = []
      for v in range(m):
         get_score.append(0)   
      for j in range(n):
            if (i >> j) & 1 ==1:
                  min_sum += c_a[j][0]
                  for l in range(m):
                        get_score[l] += c_a[j][l+1]
     
      #print(i)
      #print(min_sum)
      pre = 0 
      for s in range(m):
            if(get_score[s] < x):
                  pre = 1
                  break
      
      if pre == 0:
            if min_sum_answer == -1:
                  min_sum_answer = min_sum 
            elif min_sum_answer > min_sum:
                  min_sum_answer = min_sum 

if min_sum_answer == 0:
      print(-1)
else:
      print(min_sum_answer)
            
                  

Measured memory_bytes: 9020
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

vi par;
vi ran;

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

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) return;
	if (ran[x] < ran[y]) {
		par[x] = y;
	}else {
		par[y] = x;
		if (ran[x] == ran[y]) ran[x]++;
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}


int main() {
	int n, m,a,b;
	cin >> n >> m;
	par.resize(n);
	rep(i, n) {
		par[i] = i;
	}
	ran.resize(n,0);
	rep(i, m) {
		cin >> a >> b;
		unite(a, b);
	}
	cin >> m;
	rep(i, m) {
		cin >> a >> b;
		cout << (same(a, b) ? "yes" : "no") << endl;
	}
}



Measured memory_bytes: 3544
# include <stdio.h> 
  int main() 
  {int n;
  

scanf("%d",&n);
if(10<=n&&n<=99)
{
if (n%10==9)
{printf("Yes\n");
}
 else if(n/10==9)
printf("Yes\n");
 else
	{ printf("No\n");
 }
} return 0;
  }

Measured memory_bytes: 128
#define nl              "\n"
#define ll              long long
#define ull             unsigned long long
#define pb              push_back
#define SIZE(a)         (int)a.size()
#define SORT(v)         sort(v.begin(),v.end())
#define RSORT(v)        sort(v.rbegin(),v.rend())
#define REV(v)          reverse(v.begin(),v.end())
#define ff              first
#define ss              second
#define sq(a)           ((a)*(a))
#define For(i,a,b)      for(i=a;i<=b;i++)
#define Rof(i,a,b)      for(i=a;i>=b;i--)
#define Rep(i,b)        for(i=0;i<b;i++)
#define MOD             1000000007
#define PI              acos(-1.0)
#define eps             1e-9
#define Linf            2e18
#define inf             1<<30
#define MX5             100005
#define MX6             1000006
#define GCD(a,b)	    __gcd(a,b)
#define Abs(a)		    abs(a)
#define input(a,b)	    scanf("%lld%lld",&a,&b)
#define in1(a)		    scanf("%lld",&a)
#define output(a)	    printf("%lld\n",a);
#define mem(a)          memset(a,-1,sizeof(a))
#define clr(a)          memset(a,0,sizeof a)
#define mk              make_pair
#define pLL             pair<ll,ll>
#define ff              first
#define ss              second
#define invcos(a)	    (acos(a)*(180/3.14159265))
#define pip		        printf("pip")
///4direction ->        int del_x[]={-1,0,1,0},del_y[]={0,1,0,-1};
///8direction ->        int del_x[]={-1,0,1,0,1,-1,-1,1},del_y[]={0,1,0,-1,-1,-1,1,1};


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

//ll bigmod(ll n,ll p){if(p==0) return 1;if(p==1)return (n+mod)%mod;if(p%2)return (bigmod(n,p-1)*n+mod)%mod;else{ll x=bigmod(n,p/2);return (x*x+mod)%mod;}}
//ll modinverse(ll n){return bigmod(n,mod-2)%mod;}

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/
int main()
{
    ll n,i,a,counter=0;
    vector<ll>v;
    in1(n);
    Rep(i,n)
    {
        in1(a);
        v.pb(a);
    }
    ll siz=v.size()-2;
    For(i,1,siz)
    {
        vector<ll>fe;
        fe.pb(v[i]);
        fe.pb(v[i-1]);
        fe.pb(v[i+1]);
        SORT(fe);
        if(fe[1]==v[i])
        {
            counter++;
        }
    }
    output(counter);
}



Measured memory_bytes: 256
s = raw_input()
#print s
l = len(s)

if l % 2 == 0:
    a = l/2 - 1
    b = a+1
else:
    a = l/2 - 1
    b = a+2

count = 0
while (a >= 0):
    #print "a=",a,"b=",b
    if s[a]!=s[b]:
        count += 1
    a = a-1
    b = b+1

print count


Measured memory_bytes: 2568