akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut a = read::<i64>();
    let b = read::<i64>();
    
    if a < 10 && b < 10 {
        println!("{}", a*b);
    } else {
        println!("-1");
    }
}



Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <climits>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>

using namespace std;
using ll = long long;

template<typename T> void print(T t) { cout << t << endl; }

int main() {
	int N, Y;
	cin >> N >> Y;
	Y /= 1000;
	for (int m = 0; m <= N; m++) {
		for (int g = 0; g + m <= N; g++) {
			int s = N - g - m;
			if (10 * m + 5 * g + s == Y) {
				cout << m << " " << g << " " << s << endl;
				return 0;
			}
		}
	}

	cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstdio>

using namespace std;

const long long INF = 100000000;
const long long MOD = 1000000007;

std::vector<bool> IsPrime;

void sieve(size_t max)
{
  if (max + 1 > IsPrime.size())
  {                                // resizeで要素数が減らないように
    IsPrime.resize(max + 1, true); // IsPrimeに必要な要素数を確保
  }
  IsPrime[0] = false; // 0は素数ではない
  IsPrime[1] = false; // 1は素数ではない

  for (size_t i = 2; i * i <= max; ++i)     // 0からsqrt(max)まで調べる
    if (IsPrime[i])                         // iが素数ならば
      for (size_t j = 2; i * j <= max; ++j) // (max以下の)iの倍数は
        IsPrime[i * j] = false;             // 素数ではない
}

class Pointer{
public:
  long long p;
  long long w;
};

int main()
{
  string s;
  cin >> s;
  set<char> set;
  for (int i = 0; i < s.length(); i++)
  {
    set.insert(s[i]);
  }
  if(set.size()==s.length())
    cout << "yes" << endl;
  else
    cout << "no" << endl;
}


Measured memory_bytes: 256
N, X = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]

def solve(N, X, A):
    M = A[:]
    result = sum(M)
    for i in range(1, N):
        M = [min(M[j], A[(j-i)%N]) for j in range(N)]
        r = sum(M) + X * i
        result = min(result, r)
    return result

print(solve(N, X, A))


Measured memory_bytes: 3188
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int[] dx = new int[] { 0, 0, 1, -1 };
    static int[] dy = new int[] { 1, -1, 0, 0 };

    static void Solve()
    {
        var cnt = new Dictionary<string, int>();

        var n = sc.Int();

        for (int i = 0; i < n; i++) {
            var s = sc.Str();
            if (cnt.ContainsKey(s))
                cnt[s]++;
            else
                cnt.Add(s, 1);
        }

        var m = sc.Int();

        for (int i = 0; i < m; i++) {
            var s = sc.Str();
            if (cnt.ContainsKey(s))
                cnt[s]--;
        }

        var ans = cnt.Select(x => x.Value).Max();

        pr.WriteLine(ans >= 0 ? ans : 0);
    }

    class Node {
        public Node Prev;
        public Node[] To;

        public int cost;
    }

    static double F(double prev, double next, double t)
    {
        return Math.Pow(Math.Exp((next - prev) / t), 2);
    }

    static int[,] Mul(int[,] a, int[,] b)
    {
        var ret = new int[a.GetLength(0), b.GetLength(1)];
        for (int i = 0; i < a.GetLength(0); i++)
            for (int j = 0; j < b.GetLength(1); j++)
                for (int k = 0; k < a.GetLength(1); k++)
                    ret[i, j] += a[i, k] * b[k, j];

        return ret;
    }

    static int[,] Pow(int[,] a, int n)
    {
        var b = new int[a.GetLength(1), a.GetLength(0)];

        var f = n % 2 == 1;

        for (int i = 0; i < a.GetLength(0); i++)
            b[i, i] = 1;

        while (n > 0)
        {
            if (n % 2 == 1)
                b = Mul(a, b);


            n >>= 1;
        }

        return b;
    }

    class Coord
    {
        public int x;
        public int y;
    }

    static void Main(string[] args)
    {
        // pr.AutoFlush = true;
        Solve();
        pr.Flush();
        // Console.ReadKey();
    }

    static Scanner sc = new Scanner();
    static Printer pr = new Printer();
}

#region IO
class Scanner
{
    private int _i = 0;
    private string[] line = new string[0];

    private T[] Enumerate<T>(int n, Func<T> f)
    {
        T[] ret = new T[n];
        for (int i = 0; i < n; i++)
            ret[i] = f();
        return ret;
    }

    public string Str()
    {
        if (line.Length <= _i)
        {
            line = Console.ReadLine().Split(' ');
            _i = 0;
        }

        return line[_i++];
    }

    public int Int() => int.Parse(Str());
    public long Long() => long.Parse(Str());
    public double Double() => double.Parse(Str());
    public int[] Int(int n) => Enumerate(n, Int);
    public long[] Long(int n) => Enumerate(n, Long);
    public double[] Double(int n) => Enumerate(n, Double);
    public string[] Str(int n) => Enumerate(n, Str);
}

class Printer : StreamWriter
{
    public Printer() : base(Console.OpenStandardOutput())
    {
        AutoFlush = false;
    }
}
#endregion

Measured memory_bytes: 13280
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e:t) fill_v(e, v);
}

typedef pair<int, int> P;

class BAlgae {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int r, D, x;
        cin >> r >> D >> x;

        REP(i, 10) {
            x = r * x - D;
            cout << x << endl;
        }

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BAlgae solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 888
import java.util.Arrays;

public class Main {

  private static void solve() {
    int n = ni();
    long k = nl();

    int[][] p = ntable(n, 2);
    Arrays.sort(p, (o1, o2) -> o1[0] - o2[0]);

    long now = 0;
    for (int[] v : p) {
      now += v[1];
      if (now >= k) {
        System.out.println(v[0]);
        return;
      }
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 45420
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int N;
    int a;
    vector<int> v, vorg;
    int vmax;
    int vmax2;

    scanf("%d", &N);
    for(int i = 0; i < N; i++){
        scanf("%d", &a);
        v.push_back(a);
        vorg.push_back(a);
    }
    auto vmax_iter = max_element(begin(v),end(v));
    vmax = *vmax_iter;
    int vmax2nd = vmax / 2;
    *vmax_iter = -1;
    for(int i = 0; i < N; i++){
        if(v[i] > vmax2nd) v[i] = vmax - v[i];
    }
    auto vmax2_iter = max_element(begin(v),end(v));
    vmax2 = vorg[vmax2_iter - begin(v)];

    printf("%d %d\n",vmax,vmax2);
}


Measured memory_bytes: 1908
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define N 200002
int n,a[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2*n;i++)scanf("%d",&a[i]);
	sort(a+1,a+1+2*n);
	int ans=0;
	for(int i=1;i<=2*n;i+=2)ans+=a[i];
	printf("%d\n",ans);
}


Measured memory_bytes: 256
from collections import defaultdict


def divisors(num):
    array = []
    limit = int(num ** 0.5) + 1
    for i in range(1, limit):
        if num % i == 0:
            div1 = i
            div2 = num//i
            array.append(div1)
            if div1 != div2:
                array.append(div2)
    array.sort(reverse=True)
    return array


n, k = map(int, input().split())
mod = 10**9 + 7
ans = 0

counts = [0] * (k+1)
counts[1] = pow(k, n, mod)

for t in range(k, 1, -1):
    multiple_t = k // t
    pattern = pow(multiple_t, n, mod)
    counts[t] += pattern
    divs = divisors(t)
    for div in divs:
        if div == t:
            continue
        counts[div] -= counts[t]
        counts[div] %= mod

ans = 0
for value, count in enumerate(counts):
    ans += value * count % mod
    ans %= mod

print(ans)

Measured memory_bytes: 70572
#include <stdio.h> 
int main(){
  int n;
  while(scanf("%d",&n)!=EOF){
    int a,b,c,d,k=0;
    for(a=0;a<=9;a++){
      for(b=0;b<=9;b++){
	for(c=0;c<=9;c++){
	  for(d=0;d<=9;d++){
	    if(a+b+c+d==n)k++;
	  }
	}
      }
    }
    printf("%d\n",k);
  }
  return 0;
}

Measured memory_bytes: 596
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;

class Iroha
{
    public Iroha() { }
    public static int Main()
    {
        new Iroha().calc();
        return 0;
    }

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int W = 300000;
        int C = W / 2;

        int[] Lsum = new int[W];
        int[] Rsum = new int[W];
        Lsum[C] = Rsum[C] = 1;

        int[] L = new int[N];
        int[] R = new int[N];
        for (int i = 0; i < N; i++)
        {
            L[i] = cin.nextInt() + C;
            R[i] = cin.nextInt() + C;
            Lsum[L[i]]++; Rsum[R[i]]++;
        }

        for (int i = 1; i < W - 1; i++)
        {
            Rsum[i] += Rsum[i - 1];
            Lsum[W - i - 1] += Lsum[W - i];
        }

        long ans = 0;
        for (int i = 1; i < W - 2; i++)
        {
            ans += Math.Min(Lsum[i + 1], Rsum[i]);
        }

        Console.WriteLine(ans * 2);
    }
    


}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 18124
#include<iostream>

int main(){
    int N;
    std::cin >> N;
    for(int i= 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            if(i * j == N){
                std::cout << "Yes" << std::endl;
                return 0;
            }
        }
    }
    std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int n, x, cnt;
  while(cin >> n >> x && n || x) {
    cnt=0;
    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) cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
	int n, w;
	cin >> n >> w;

	int wt[n], val[n];
	ll sum_value = 0;
	for(int i=0;i<n;i++){
		cin >> wt[i] >> val[i];
		sum_value += val[i];
	}

	vector<ll> dp(sum_value+1, 1e18); // min weight with val i
	dp[0] = 0;
	for(ll i=0;i<n;i++){
		for(int j=sum_value;j>=val[i];j--){
			dp[j] = min(dp[j], dp[j-val[i]]+wt[i]);
		}
	}

	ll res = -1;
	for(ll i=0;i<=sum_value;i++){
		if(dp[i] <= w){
			res = max(res, i);
		}
	}

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 4032
#include "stdio.h"
#include<iostream>
#include<string>
#include<algorithm>

#define MAX 1000

using namespace std;

int lcs(string input1, string input2){
  int m = input1.length();
  int n = input2.length(); 

  input1 = " " + input1;
  input2 = " " + input2; 

  //Singleton?
  int c[MAX+1][MAX+1];
    
  for(int i=0;i<=m;i++){
    c[i][0] = 0;
  }
  for(int j=0;j<=n;j++){
    c[0][j] = 0;
  }

  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      
      if(input1[i] == input2[j]){
        c[i][j] = c[i-1][j-1] + 1;
      }else{
        c[i][j] = max(c[i-1][j], c[i][j-1]);
      }
    
    }     
  }
  return c[m][n];
}

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

  string  input1, input2;

  for(int i=0;i<N;i++){
    cin >> input1;
    cin >> input2;
    printf("%d\n", lcs(input1, input2));
  }

  return 0;
}



Measured memory_bytes: 7072
#include <iostream>
    #include <string.h>
     
    using namespace std;
     
    int main(){
        string a, b, c;
        cin >> a;
        cin >> b;
        cin >> c;
     
        if(b == a){
            if(b==c) {
                cout << "Yes" << endl;
            }
            else {
                cout << "No" << endl;
            }
        }
    else {
           cout << "No" << endl;
    }
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define s second 
#define f first
#define mk make_pair
bool used[100001],du[100001];
vector<int>a[100001],x;
int n,m;
 main(){
	cin>>n>>m;
	r(i,m){
		int p1,p2;
		scanf("%d%d",&p1,&p2);
		a[p1].push_back(p2);
		a[p2].push_back(p1);
	}
	pair<int,int> o[n];
	r(i,n)o[i]=mk(a[i+1].size(),i+1);
	sort(o,o+n);
	r(i,n)x.push_back(o[i].s);
	queue<int>l;
	queue<int>q;
	r(j,n){if(du[x[j]])continue;
		r(i,n+1)used[i]=0;
	    used[x[j]]=1;
	q.push(x[j]);
	vector<int>b;int p;
	r(i,a[x[j]].size())b.push_back(a[x[j]][i]);
	while(!q.empty()){
		p=q.front();q.pop();
		l.push(p);
		r(i,a[p].size()){
				if(!used[a[p][i]]){
					used[a[p][i]]=1;
					q.push(a[p][i]);goto L;
				}
		}L:;
	}
	int ccc=0;
	r(i,a[p].size())b.push_back(a[p][i]);
	r(i,b.size())if(!used[b[i]])ccc++;
	if(!ccc)goto PP;
	while(!q.empty())q.pop();
	while(!l.empty())l.pop();
	du[p]=1;
    }PP:;
	cout<<l.size()<<endl;int cc=0;
	while(!l.empty()){
		if(cc)cout<<' ';
		cout<<l.front();l.pop();
		cc++;
	}
}

Measured memory_bytes: 7928
#include <iostream>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int, int> P;

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

int main()
{
    while(true){
        int w, h;
        cin >> w >> h;
        if(w == 0 && h == 0) break;
        int rl[33][33], bf[33][33];
        for(int j = 0; j < w; j++) bf[0][j] = 1;
        for(int i = 0; i < h - 1; i++){
            rl[i][0] = rl[i][w] = 1;
            for(int j = 1; j < w; j++) cin >> rl[i][j];
            for(int j = 0; j < w; j++) cin >> bf[i + 1][j];
        }
        rl[h - 1][0] = rl[h - 1][w] = 1;
        for(int j = 1; j < w; j++) cin >> rl[h - 1][j];
        for(int j = 0; j < w; j++) bf[h][j] = 1;
        int d[33][33];
        for(int i = 0; i < 33; i++){
            for(int j = 0; j < 33; j++) d[i][j] = 10000;
        }
        d[1][1] = 1;
        queue<P> que;
        que.push(P(1, 1));
        while(que.size()){
            P now = que.front();
            que.pop();
            int i = now.first;
            int j = now.second;
            if(rl[i - 1][j] == 0){
                if(d[i][j + 1] > d[i][j] + 1){
                    d[i][j + 1] = d[i][j] + 1;
                    que.push(P(i, j + 1));
                }
            }
            if(bf[i][j - 1] == 0){
                if(d[i + 1][j] > d[i][j] + 1){
                    d[i + 1][j] = d[i][j] + 1;
                    que.push(P(i + 1, j));
                }
            }
            if(rl[i - 1][j - 1] == 0){
                if(d[i][j - 1] > d[i][j] + 1){
                    d[i][j - 1] = d[i][j] + 1;
                    que.push(P(i, j - 1));
                }
            }
            if(bf[i - 1][j - 1] == 0){
                if(d[i - 1][j] > d[i][j] + 1){
                    d[i - 1][j] = d[i][j] + 1;
                    que.push(P(i - 1, j));
                }
            }
        }
        if(d[h][w] == 10000) cout << 0 << endl;
        else cout << d[h][w] << endl;
    }
}


Measured memory_bytes: 3048
#include <stdio.h>

int main() {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);

    if ((a == b && b == c) || (a != b && b != c && a != c)) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }
}

Measured memory_bytes: 128
def prepare(n, MOD):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


n, k = map(int, input().split())
aaa = list(map(int, input().split()))
aaa.sort()
MOD = 10 ** 9 + 7
facts, invs = prepare(n, MOD)

max_sum = 0
min_sum = 0
for i, a in enumerate(aaa):
    lo = i
    hi = n - i - 1
    if lo >= k - 1:
        max_sum = (max_sum + facts[lo] * invs[k - 1] * invs[lo - k + 1] % MOD * a) % MOD
    if hi >= k - 1:
        min_sum = (min_sum + facts[hi] * invs[k - 1] * invs[hi - k + 1] % MOD * a) % MOD
print((max_sum - min_sum) % MOD)


Measured memory_bytes: 15184
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int a, b; cin >> a >> b;
    int ans = a * (a - 1) / 2;
    ans += b * (b - 1) / 2;
    cout << ans << endl;
}

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

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

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> a(n + 1, 0);
    for (int i = 1; i < n+1; i++) {
        std::cin >> a[i];
    }

    std::vector<int> s(n + 1, 0);
    for (int i = 1; i < n + 1; i++) {
        s[a[i]] = i;
    }

    for (int i = 1; i < n; i++) {
        std::cout << s[i] << " ";
    }
        std::cout << s[n] << std::endl;

    return 0;
}


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

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

#define REP(i, l, n) for(ll i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    ll a, v, b, w, t; cin >> a >> v >> b >> w >> t;
    if(abs(a-b) <= t * (v - w)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

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

int main() {
  int n; cin >>n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n-1);
  rep(i,n){
    cin >> a[i];
  }
  rep(i,n){
    cin >> b[i];
  }
  rep(i,n-1){
    cin >> c[i];
  }
  int ans = 0;
  rep(i, n) {
    ans += b[a[i]-1];
  }
  rep(i,n-1) {
    if (a[i+1] == a[i] + 1) {
      ans += c[a[i]-1];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int yaku(int a, int b, int c){
  int d=min({a,b,c});
  int y=0;
  int x=0;
  for(int i=1;i<=d;++i){
    
    if(a%i==0 && b%i==0 && c%i==0){
      x=i;
      y=max(y,x);
    }
  }
  
  return y;
}

int main() {
  int K;
  cin>>K;
  
  ll ans=0;
  for(int a=1;a<=K;++a){
    for(int b=1;b<=K;++b){
      for(int c=1;c<=K;++c){
        ans+=yaku(a,b,c);
      }
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 3624
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DDigitsParade solver = new DDigitsParade();
        solver.solve(1, in, out);
        out.close();
    }

    static class DDigitsParade {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            String s = new StringBuilder(sc.nextLine()).reverse().toString();
            int n = s.length();
            long[][] dp = new long[n + 1][13];
            int[] seq = {1, 10, 9, 12, 3, 4};
            int mod = (int) (1e9) + 7;
            if (s.charAt(0) == '?') {
                for (int i = 0; i < 10; i++) {
                    dp[0][i] = 1;
                }
            } else {
                dp[0][s.charAt(0) - '0'] = 1;
            }

            for (int i = 1; i < n; i++) {
                if (s.charAt(i) == '?') {
                    for (int j = 0; j < 10; j++) {
                        int rem = ((seq[i % 6]) * j) % 13;
                        for (int k = 0; k < 13; k++) {
                            if (k >= rem) {
                                dp[i][k] += dp[i - 1][k - rem];
                            } else {
                                dp[i][k] += dp[i - 1][k - rem + 13];
                            }
                            dp[i][k] %= mod;
                        }
                    }
                } else {
                    int act = s.charAt(i) - '0';
                    int rem = ((seq[i % 6]) * act) % 13;
                    for (int j = 0; j < 13; j++) {
                        if (j >= rem) {
                            dp[i][j] += dp[i - 1][j - rem];
                            dp[i][j] %= mod;
                        } else {
                            dp[i][j] += dp[i - 1][j - rem + 13];
                            dp[i][j] %= mod;
                        }
                    }
                }
            }

            out.println(dp[n - 1][5]);

        }

    }

    static class inputClass {
        BufferedReader br;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

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

    }
}



Measured memory_bytes: 35980
N,A,B,C=map(int,input().split())
l=[]
for _ in range(N):
    l.append(int(input()))

def dfs(counter,a,b,c):
    if counter==N:
        #lの中の適当な棒を持った時点から正味スタート
        if a>0 and b>0 and c>0:
            offset=10*3
            return abs(A-a)+abs(B-b)+abs(C-c)-offset
        else:
            #棒を持っていないものは候補外
            return 10**9
    #合成魔法
    #何もしなかった分も含めて、ちょっと足りない、ちょっと長すぎは
    #上のif内で調整
    ret0=dfs(counter+1,a,b,c)
    ret1=dfs(counter+1,a+l[counter],b,c)+10
    ret2=dfs(counter+1,a,b+l[counter],c)+10
    ret3=dfs(counter+1,a,b,c+l[counter])+10
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define ff first
#define pb push_back
#define ss second
#define maxn 500005
using namespace std;


int main(){

    int x, y, res = 0;
    cin >> x >> y;
    if(x == 1 && y == 1){
        res += 400000;
    }
    if(x == 1) res += 300000;
    if(x == 2) res += 200000;
    if(x == 3) res += 100000;
    if(y == 1) res += 300000;
    if(y == 2) res += 200000;
    if(y == 3) res += 100000;
    cout << res << endl;
    return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<int, int>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

template<typename T, typename U>
inline decltype(auto) Getmultivector(T n, U v) noexcept {
	static_assert(is_integral<T>::value, "1st argument is not integer type");
	return vector<U>(forward<T>(n), forward<U>(v));
}

template<typename T, typename... Args>
inline decltype(auto) Getmultivector(T n, Args ...args) noexcept {
	static_assert(is_integral<T>::value, "1st argument is not integer type");
	return vector<decltype(Getmultivector(forward<Args>(args)...))>(forward<T>(n), Getmultivector(forward<Args>(args)...));
}

template<typename T, llong N, typename enable_if<(N > 0), nullptr_t>::type = nullptr>
struct multivector_impl {
	using type = vector<typename multivector_impl<T, N-1>::type>;
};
template<typename T>
struct multivector_impl<T, 1> {
	using type = vector<T>;
};

template<typename T, size_t N>
using multivector = typename multivector_impl<T, N>::type;

constexpr array<llong, 9> nw = {0, 1, 0, -1, -1, 1, 1, -1, 0};
constexpr array<llong, 9> nh = {1, 0, -1, 0, 1, 1, -1, -1, 0};

llong H, W;
vector<string> area;

multivector<int, 2> bfs(int h, int w) {
	auto ret = Getmultivector(H, W, -1);
	if (area[h][w] == '#') return ret;

	queue<lpair> que;
	ret[h][w] = 0;
	que.push(lpair(h, w));
	while (que.size()) {
		lpair now = que.front();
		que.pop();

		for (int i = 0; i < 4; ++i) {
			lpair next(now.first + nh[i], now.second + nw[i]);
			if (next.first < 0 || next.second < 0 || next.first >= H || next.second >= W) continue;
			if (area[next.first][next.second] == '#') continue;
			if (ret[next.first][next.second] == -1) {
				ret[next.first][next.second] = ret[now.first][now.second] + 1;
				que.push(next);
			}
		}
	}

	return ret;
}

int main() {

	cin >> H >> W;
	area.resize(H);
	for (auto &in: area) {
		cin >> in;
	}

	int ans = 0;
	for (int h = 0; h < H; ++h) {
		for (int w = 0; w < W; ++w) {
			auto res = bfs(h, w);
			for (int hh = 0; hh < H; ++hh) {
				for (int ww = 0; ww < W; ++ww) {
					ans = max(ans, res[hh][ww]);
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <map>
#include <deque>
#include <queue>
#include <tuple>

using namespace std;

namespace myLib {

#define prec(i) cout << fixed << setprecision(i)

	void output_yn(bool isYes) {
		if (isYes)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}

	const long long MOD = 1000000007;

	long long fact(long long k) {
		long long sum = 1;
		for (long long i = 2; i <= k; i++)
			sum *= i;

		return sum;
	}

	long long fact_mod(long long k) {
		long long sum = 1;
		for (long long i = 2; i <= k; i++)
			sum = (sum * i) % MOD;

		return sum;
	}

	int ctoi(char c) {
		if (c >= '0' && c <= '9')
			return c - '0';
		else
			return -1;
	}

	long long pow_mod(int a, int b) {
		long long ans = 1;
		for (int i = 0; i < b; i++)
			ans = (ans * a) % MOD;

		return ans;
	}

	long long powll(long long a, long long  b) {
		long long ans = 1;
		for (long long i = 0; i < b; i++)
			ans = ans * a;

		return ans;
	}

	long long modinv(long long a) {

		long long b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= MOD;
		if (u < 0) u += MOD;

		return u;
	}

	long long _gcd(long long a, long long b)
	{
		if (a < b)
			swap(a, b);

		if (a % b == 0)
			return b;
		else
			return _gcd(b, a % b);
	}

	long long _lcm(long long a, long long b)
	{
		return (((a * b) % MOD) * modinv(_gcd(a, b))) % MOD;
	}

	long long ncr(long long n, long long r) {
		long long sum = 1;
		for (long long i = r + 1; i <= n; i++)
			sum *= i;

		return sum;
	}

	vector<vector<int>> graph;
	vector<bool> seen;
	vector<int> grpCnt;

	void dfs(const vector<vector<int>> graph, int v, int group) {
		seen[v] = true;
		grpCnt[group]++;
		for (auto next_v : graph[v]) {
			if (seen[next_v])
				continue;
			dfs(graph, next_v, group);
		}
	}
}

using namespace myLib;

int main()
{
	
	int n;
	cin >> n;

	cout << 1 - n << endl;

	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll n;
ll a[200010];

int main(){
  cin>>n;
  rep(i,n)cin>>a[i];
  ll res=0;
  if(a[0]>0){
    cout<<-1<<endl;
    return 0;
  }
  rep(i,n-1){
    if(a[i+1]-a[i]>1){
      cout<<-1<<endl;
      return 0;
    }
  }
  for(int i=0;i<n-1;i++){
    if(a[i]+1==a[i+1]){

    }else{
      res+=a[i];
    }
  }
  res+=a[n-1];
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 1792
import sys
input=sys.stdin.readline

def BellmanFord(Edges,num_v,source):
    inf=float('inf')
    dist=[inf for _ in range(num_v)]
    dist[source]=0
    for i in range(num_v):
        for edge in Edges:
            if edge[0]!=inf and dist[edge[1]]>dist[edge[0]]+edge[2]:
                dist[edge[1]]=dist[edge[0]]+edge[2]
                if i==num_v-1:
                    before_dist=dist[num_v-1]
                    for _ in range(num_v):
                        for edge in Edges:
                            if edge[0]!=inf and dist[edge[1]]>dist[edge[0]]+edge[2]:
                                dist[edge[1]]=dist[edge[0]]+edge[2]
                    if before_dist!=dist[num_v-1]:
                        return -1
    return dist

n,m,p=map(int,input().split())
Edges=[]
for _ in range(m):
    a,b,c=map(int,input().split())
    a-=1; b-=1
    Edges.append((a,b,-(c-p)))
d=BellmanFord(Edges,n,0)
print(-1 if d==-1 else max(0,-d[-1]))

Measured memory_bytes: 45880
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int N;
  long long K;
  const long long MOD = 1000000007LL;
  cin >> N >> K;
  long long *A = new long long[N];
  for(int i = 0; i < N; i++) cin >> A[i];
  long long X = 0, Y = 0;
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      if(A[i] > A[j]) X++;
      if(A[i] < A[j]) Y++;
    }
  }
  //cout << X << " " << Y << endl;
  Y += X;
  long long ans = X * K;
  ans %= MOD;
  if(K % 2 == 0) ans += Y * K / 2 % MOD * (K - 1) % MOD;
  else ans += Y * K % MOD * (K - 1) / 2 % MOD;
  cout << ans % MOD << endl;
  return 0;
}


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

int main(){
    int A[10000], i;
    
    for(i = 1; i <= 10000; i ++) cin >> A[i];
    
    for(i = 1; i <= 10000; i ++){
        if(A[i] != 0){
            cout << "Case " << i << ": " << A[i] << endl;
        }else{
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int N; cin >> N;
  vector<int> A(N); cin >> A;
  int v = 0;
  for (int i = 0; i < N; ++i) {
    v ^= A[i];
  }
  for (int i = 0; i < N; ++i) {
    int w = v ^ A[i];
    cout << w << " ";
  }
  cout << endl;
}


Measured memory_bytes: 3948
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  ll A,B,C,K;
  cin>>A>>B>>C>>K;

  ll ans=0;
  if(K<=A) ans=K;
  else if(K<=A+B) ans=A;
  else ans=A-(K-(A+B));

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  sort(s.begin(),s.end());
  for(int i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      cout<<"no"<<endl;
      return 0;
    }
  }
  cout<<"yes"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  int H, W, h, w;
  while (cin >> H >> W >> h >> w) {
    int res = (H - h) * (W - w);
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
cost = 0

for A, B in sorted(AB):
    if M >= B:
        cost += A*B
        M -= B
        if M == 0:
            break
    else:
        cost += A*M
        break

print(cost)


Measured memory_bytes: 28652
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
  multi(ll first, ll second, ll third)
      : first(first), second(second), third(third) {}
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string S;
  cin >> S;
  vl DP(26, 0);
  REP(i, 4) { DP[S[i] - 'A']++; }
  bool ok = true;
  REP(i, 26) {
    if (DP[i] != 0 && DP[i] != 2)
      ok = false;
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    double n,m,d;
    cin>>n>>m>>d;
    double sum=n-d;
    double p=2;
    if(d==0) p=1;
    cout<<setprecision(12)<<fixed<<sum*p*(m-1)/(n*n)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int N;
	cin >> N;
	int64_t res = 0;
	vector<vector<int64_t>> num(10, vector<int64_t>(10));
	for (int i = 1; i <= N; i++) {
		string str = to_string(i);
		int a = ctoi(str[str.length()-1]);
		int b = ctoi(str[0]);

		if (a == 0)continue;
		num[a][b]++;
	}
	for (int a = 1; a < 10; ++a) {
		for (int b = 1; b < 10; ++b) {
			res += num[a][b] * num[b][a];
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
        int k;
        long long int a,b,c;

        scanf("%lld%lld%lld%d",&a,&b,&c,&k);
        if(k-a<=0) printf("%lld\n",k);
        else {
                if(k-a-b<=0) printf("%lld\n",a);
                else printf("%lld\n",a-(k-a-b));
        }

        return 0;
}


Measured memory_bytes: 1736
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N;
string S;
set<string> st[5];
/*==================================================*/
/*function*/

/*==================================================*/

int main() {

    cin>>N;
    REP(i,0,N){
        cin>>S;
        if(S[0] == 'M'){
            st[0].insert(S);
        }else if(S[0] == 'A'){
            st[1].insert(S);
        }else if(S[0] == 'R'){
            st[2].insert(S);
        }else if(S[0] == 'C'){
            st[3].insert(S);
        }else if(S[0] == 'H'){
            st[4].insert(S);
        }
    }

    ll ans = 0LL;

    REP(i,0,5){
        REP(j,i+1,5){
            REP(k,j+1,5){
                ans += (ll)st[i].size() * (ll)st[j].size() * (ll)st[k].size();
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 6528
import java.util.Scanner;

 class Main{
	public void solve(){
		Scanner sc = new Scanner(System.in);
		int x,y,b,p,kin;
	    int n = sc.nextInt();
	    
		for(int i=0; i<n; i++){
			 x=sc.nextInt();
			 y=sc.nextInt();
			 b=sc.nextInt();
			 p=sc.nextInt();
			
			 kin = x*b + y*p;
              
            if(b>=5 && p>=2){
                kin = (x*b + y*p)*4/5;
            }else{
                if(b<5){
                b=5;
                }
                if(p<2){
                p=2;
                }
                int wari = (x*b + y*p)*4/5;
                  
                if(kin>wari){
                    kin = wari;
                }
            }
            System.out.println(kin);
        }
    }
		
	public static void main(String[] args){
        Main obj =new Main();
        obj.solve();
    }
}

Measured memory_bytes: 23292
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int x, a, b;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> x >> a >> b;
	if (a >= b) cout << "delicious" << endl;
	else if (b-a <= x) cout << "safe" << endl;
	else cout << "dangerous" << endl;
	return 0;
}

Measured memory_bytes: 256
Q,H,S,D = map(int, input().split())
N = int(input())

ans = 0
if N >= 2:
    ans += N//2 * min(Q*8, H*4, S*2, D)
    N %= 2
if N == 1:
    ans += min(Q*4, H*2, S)
print(ans)

Measured memory_bytes: 3068
n = int(input())
times = list(map(int, input().split()))
m = int(input())
drinks = []
for _ in range(m):
    drink = list(map(int, input().split()))
    drinks.append(drink)

for drink in drinks:
    time = 0
    copy = times.copy()
    copy[drink[0]-1] = drink[1]
    for i in copy:
        time += i
    print(time)

Measured memory_bytes: 9144
#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
char a[53][53],b[53][53];
int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;++i){
		scanf("%s",a[i]);
	}for(int i=0;i<m;++i){
		scanf("%s",b[i]);
		
	}for(int i=0;i<n;++i){
		for(int j=0;j<n;++j){
			bool found=true;
			for (int k=i,k2=0;k<m+i;++k,++k2){
				for(int l=j,l2=0;l<m+j;++l,++l2){
					if(a[k][l]!=b[k2][l2])
					found=false;
				}
			}if (found==true){puts("Yes");
			return 0;
			}
		}
	}
	puts("No");
	
}

Measured memory_bytes: 256