akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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 string YES = "Yes";
const string NO = "No";

int main() {
    int N;
    cin >> N;
    deque<int> r;
    for (int i = 0; i < (1 << N); i++) {
        int a;
        cin >> a;
        r.push_back(a);
    }
    sort(r.rbegin(), r.rend());


    queue<int> items[20];
    for (int i = 0; i < N; i++) items[i].push(r.front());
    r.pop_front();

    while (r.size()) {
        int j = -1;
        for (int i = 19; i >= 0; i--) {
            if (!items[i].empty() && items[i].front() > r.front()) {
                items[i].pop();
                j = i;
                break;
            }
        }
        if (j == -1) {
            cout << "No" << endl;
            return 0;
        }

        for (int i = 0; i < j; i++) {
            items[i].push(r.front());
        }
        r.pop_front();


    }
    cout << "Yes" << endl;
    // Failed to predict input format
    return 0;
}


Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = Input.num;
        var ar = new List<long>();
        ar.Add(int.MinValue);
        ar.AddRange(Input.arL);
        var max = ar.Max();
        ar.Add(int.MaxValue);
        ar = ar.OrderBy(v => v).ToList();
        var low = Search.LowerBound(ar.ToArray(), max / 2);
        if (ar[low] == max)
            WriteLine($"{max} {ar[low - 1]}");
        else
        {
            var dif1 = Abs(max / 2 - ar[low]);
            var dif2 = Abs(max / 2 - ar[low - 1]);
            if (dif1 > dif2)
                WriteLine($"{max} {ar[low - 1]}");
            else WriteLine($"{max} {ar[low]}");
        }
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const double eps = 1e-11;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

public class Search
{
    public static int UpperBound<T>(T[] array,T value)
        where T:IComparable<T>
    {
        var low = 0;
        var high = array.Length;
        while (high > low)
        {
            var mid = (high + low) / 2;
            if (array[mid].CompareTo(value) == 1) high = mid;
            else low = mid + 1;
        }
        return low;
    }

    public static int LowerBound<T>(T[] array,T value)
        where T : IComparable<T>
    {
        var low = 0;
        var high = array.Length;
        while (high > low)
        {
            var mid = (high + low) / 2;
            if (array[mid].CompareTo(value) != -1) high = mid;
            else low = mid + 1;
        }
        return low;
    }
}


Measured memory_bytes: 27488
#include <iostream>
#include <cmath>

using pair = std::pair<int, int>;

constexpr int max_hw = 100;

int a, b;
char field[max_hw][max_hw];

int main(){

	std::cin >> a >> b;

	std::cout << max_hw << ' ' << max_hw << std::endl;
	pair diff[max_hw][max_hw]; //diff 1:w 2:b
	for(int i = 0; i < max_hw; ++i){
		for(int j = 0; j < max_hw; ++j){
			if(j >= max_hw / 2){
				field[i][j] = '#';
			}
			else{
				field[i][j] = '.';
			}
		}
	}

	int x = 51, y = 0;
	while(a > 1){
		if(x < max_hw && y < max_hw && x >= 51 && y >= 0){
			field[y][x] = '.';
			x += 2;
			--a;
		}
		else{
			x = 51, y += 2;
		}
	}

	x = 0, y = 0;
	while(b > 1){
		if(x < max_hw / 2 - 1 && y < max_hw && x >= 0 && y >= 0){
			field[y][x] = '#';
			x += 2;
			--b;
		}
		else{
			x = 0, y += 2;
		}
	}

	for(int i = 0; i < max_hw; ++i){
		for(int j = 0; j < max_hw; ++j){
			std::cout << field[i][j];
		}
		std::cout << std::endl;
	}

	return 0;
}


Measured memory_bytes: 384
import io
import sys


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
80
'''


def MAIN():
  # T_IN()
  A()


def A():
  r = IN_I()
  print (3 * r * r)
  return None
 

def B():
  return None


def C():
  return None


MAIN()


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

using namespace std;
int main(){
    long n;
    cin >> n;
    long sum=0;
    int ans;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
               ans=__gcd(i,j);
               sum+=__gcd(ans,k);
            }
        }
    }
    cout << sum << endl;
   return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,K;
  cin >> N >> K;
  int V[N];
  for (int i = 0; i < N; i++) cin >> V[i];
  int ans = 0;

  for (int i = 0; i <= N; i++) {
    for (int j = 0; j + i <= N; j++) {
      int res = 0;
      // i : 左側から取り出す宝石
      // j : 右側から取り出す宝石
      if (i + j > K) {
        continue;
      }
      vector<int> minus;
      for (int k = 0; k < N; k++) {
        if (k < i || k >= N - j) {
          res += V[k];
          if (V[k] < 0) {
            minus.push_back(V[k]);
          }
        }
      }
      sort(minus.begin(),minus.end());
      for (int k = 0; k < min(K - (i + j),(int)minus.size()); k++) {
        res -= minus[k];
      }
      ans = max(ans,res);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
	int n, m, x, y, b,count=0;
	vector<int> xx, yy;
	cin >> n >> m >> x >> y;
	for (int i = 0; i < n; i++)
	{
		cin >> b;
		xx.push_back(b);
	}
	for (int i = 0; i < m; i++)
	{
		cin >> b;
		yy.push_back(b);
	}
	sort(xx.rbegin(), xx.rend());
	sort(yy.begin(), yy.end());
	if (xx[0] < yy[0] && x < y)
	{
		for (int i = (xx[0] + 1); i < yy[0] + 1; i++)
		{
			if (x < i&&i <= y)
			{
				count = 1;
			}
		}
		if(count==1)
			cout << "No War";
		else
			cout << "War";
	}
	else
	{
		cout << "War";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>

//     MLE,TLE魔
//↓↓↓↓↓↓↓↓↓↓↓↓
#define int long long
//↑↑↑↑↑↑↑↑↑↑↑↑
//     MLE,TLE魔
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
struct edge { int to, cost; };
int dx[5] = { 0,1,0,-1 }, dy[5] = { 1,0,-1,0 };
map<int, int>factor(int x) {
	map<int, int>res;
	for (int i = 2; i*i <= x; i++) {
		while (x%i == 0) {
			x /= i;
			res[i]++;
		}
	}
	if (x != 1)res[x]++;
	return res;
}
/*--------Library Zone!--------*/


signed main() {
	int x, y;
	cin >> x >> y;
	if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) {
		if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	else if (x == 2) {
		if (y == 2)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else {
		if (y == 4 || y == 6 || y == 9 || y == 11)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	endre;
}

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

using namespace std;

int ans = (int)1e9, t[5];

int main(){
	for(int i = 0; i < 5; ++i) cin >> t[i];
	
	do{
		int time = 0;
		for(int i = 0; i < 5; ++i){
			if(i == 4){
				time += t[i];
				break;
			}
			if(t[i] % 10 != 0) time += t[i] / 10 * 10 + 10;
			else time += t[i] / 10 * 10;
		}
		ans = min(ans, time);
	}while(next_permutation(t, t + 5));
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

const long long int INF=99999999999999,inf=199999;
const long long int mod=1000000007;


long long int n,m,a,b,c,res=0,h[200005];
int main() {
    int count=0;
    string str,str2;
    map<long long int,long long int>mp;
	cout << fixed << setprecision(10);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    res=h[1];
    for(int i=2;i<=n;i++){
        res=max(h[i],res);
        if(res-1>h[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    
    cout<<"Yes";
    
} 


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N >> A;
  if(N <= A){
    
    
  cout << "Yes" << endl;
  }
  else {
    int x;
    x = N % 500;
      if(x <= A){
        cout << "Yes" << endl;
      }
    else {
  cout << "No" << endl;
    }
    }
}

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

using namespace std;

int main(){
  int N;
  cin >>N;
  if(N<=111) cout <<111;
  else  if(N<=111) cout <<111;
  else  if(N<=222) cout <<222;
  else  if(N<=333) cout <<333;
  else  if(N<=444) cout <<444;
  else  if(N<=555) cout <<555;
  else  if(N<=666) cout <<666;
  else  if(N<=777) cout <<777;
  else  if(N<=888) cout <<888;
  else cout <<999;
}

Measured memory_bytes: 256
import numpy as np

x1, y1, x2, y2 = map(int, input().split())

r = np.array([[0, -1], [1, 0]])
p1 = np.array([[x1, y1]])
p2 = np.array([[x2, y2]])
vec = p2 - p1
p4 = r.dot(vec.T).flatten() + p1
p3 = p4 + vec

x3, y3 = p3.flatten()
x4, y4 = p4.flatten()

print(x3, y3, x4, y4)


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

int main() {
	string S;
	cin >> S;
	bool flag = true;
	for(int i = 0; i < S.length(); i++) {
		if(i%2 == 0 && S.at(i) == 'L') { flag = false; break; }
		if(i%2 == 1 && S.at(i) == 'R') { flag = false; break; }
	}
	if (flag) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	return 0;
}

Measured memory_bytes: 256
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

import scala.collection.mutable

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val k = in.readLine().toInt

    val queue = mutable.Queue.empty[Long]
    for (i <- 1 to 9) {
      queue += i
    }

    for (_ <- 0 until (k - 1)) {
      val v = queue.dequeue()
      val lv = v % 10
      if (lv != 0) {
        queue += v * 10 + lv - 1
      }
      queue += v * 10 + lv
      if (lv != 9) {
        queue += v * 10 + lv + 1
      }
    }

    out.println(queue.dequeue())

    out.flush()
  }
}


Measured memory_bytes: 50404
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n,m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

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


int main()
{
	while (1) {
		cin >> n;
		if (n == 0) {
			return 0;
		} else {
			if (n == 1) {
				cout << 1 << ' ' << 1 << endl;
			} else {
				ll x[205] = { 0 }, y[205] = { 0 };
				REP(i, n - 1)
				{
					ll a, b;
					cin >> a >> b;
					x[i + 1] = x[a] + dx[b];
					y[i + 1] = y[a] + dy[b];
				}
				ll xma = 0, xmi = 0, yma = 0, ymi = 0;
				REP(i, n - 1)
				{
					xma = max(xma, x[i + 1]);
					xmi = min(xmi, x[i + 1]);
					yma = max(yma, y[i + 1]);
					ymi = min(ymi, y[i + 1]);
				}
				cout << xma - xmi + 1 << ' ' << yma - ymi + 1 << endl;
			}
		}
	}
}

Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

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

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

class UnionFind {
public:
    vector<int> par;
    UnionFind(int n) {
        par.resize(n);
        REP(i, 0, n) {
            par[i] = i;
        }
    }
    int Find(int n) {
        return (n == par[n] ? n : par[n] = Find(par[n]));
    }
    bool Union(int a, int b) {
        a = Find(a);
        b = Find(b);
        if (a == b) return false;
        par[a] = b;
        return true;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> p(N);
    REP(i, 0, N) {
        cin >> p[i];
    }
    UnionFind uf(N);
    REP(i, 0, M) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        uf.Union(x, y);
    }

    int ans = 0;
    REP(i, 0, N) {
        ans += (uf.Find(i) == uf.Find(p[i] - 1));
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  int N,M,Z=0;
  cin>>N>>M;
  
  vector<vector<int>> p(N+1,vector<int>(M+1));
  for(int i=1;i<=M;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      int x;
      cin>>x;
      p.at(x).at(i)=1;
    }
  }
  vector<int> q(M);
  for(int i=0;i<M;i++){
    cin>>q.at(i);
  }
  for(int i=0;i<(1<<N);i++){
    int w=i,c=1,d=2;
    vector<int> z(M,0);
    while(w>0){
      if(w%d!=0){
        for(int k=1;k<=M;k++){
          if(p.at(c).at(k)==1){
            z.at(k-1)=z.at(k-1)+1;
          }
        }
        w-=d/2;
      }
      c++;
      d*=2;
    }
        
    int l=1;
    for(int j=0;j<M;j++){
      if(q.at(j)!=z.at(j)%2){
        l--;
        break;
      }
    }
    if(l==1){
      Z++;
    }
  }
  cout<<Z<<endl;
          
}

Measured memory_bytes: 256
let init n = Array.make n (-1)

let rec find x p =
  if p.(x) < 0 then x else begin
    let x' = find p.(x) p in p.(x) <- x'; x'
  end

let unite x y p =
  let x', y' = find x p, find y p in
  if x' = y' then () else
  if p.(x') < p.(y') then (p.(y') <- x)
  else begin
    if p.(x') = p.(y') then p.(y') <- p.(y') - 1;
    p.(x') <- y'
  end

let same x y p = find x p = find y p

let () =
  Scanf.scanf "%d" @@ fun n ->
  let cs = Array.init n (fun _ -> Scanf.scanf " %d %d" (fun x y -> x, y)) in
  let xs, ys =
    Array.mapi (fun i (x,_) -> (x,i)) cs, Array.mapi (fun i (_,y) -> (y,i)) cs in

  Array.sort compare xs; Array.sort compare ys;

  let edges = Array.concat [
    Array.init (n-1) (fun i ->
      let (x0,i), (x1,j) = xs.(i+1), xs.(i) in (x0-x1, i, j));
    Array.init (n-1) (fun i ->
      let (y0,i), (y1,j) = ys.(i+1), ys.(i) in (y0-y1, i, j));
  ] in
  Array.sort compare edges;

  let uf = Array.make n (-1) in
  Array.fold_left (fun sw (d, i, j) ->
    if same i j uf then sw
    else (unite i j uf; sw+d)) 0 edges
  |> Printf.printf "%d\n"


Measured memory_bytes: 25472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in(), Ma = in(),Mb = in();
    vector<vector<vector<int>>> dp(420, vector<vector<int>>(420, vector<int>(N+1, mod)));
    dp[0][0][0] = 0;
    REP(i,N){
        int a = in(),b = in(),c = in();
        REP(k,400){
            REP(l,400){
                dp[k+a][l+b][i+1] = min(dp[k][l][i]+c,dp[k+a][l+b][i]);
            }
        }
        REP(k,400){
            REP(l,400){
                chmin(dp[k][l][i+1],dp[k][l][i]);
            }
        }
    }
    int answer = mod;
    REPS(i,min(400/Mb,400/Ma)+1){
        chmin(answer,dp[Ma*i][Mb*i][N]);
    }
    if(answer == mod){
        cout << -1 << "\n";
    }else{
    cout << answer << "\n";
    }
}

Measured memory_bytes: 34816
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n, d; cin >> n >> d;
    vector<vi> x(n, vi(d));
    rep(i, n) rep(j, d) cin >> x[i][j];

    int res = 0;
    rep(i, n){
        rep(j, i+1, n){
            double z = 0.0;
            rep(k, d) z += pow(1.0 * (x[i][k] - x[j][k]), 2.);
            double zz = sqrt(z);
            if(abs(zz - (int)zz) < 1e-8){
                res++;
            }
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int k, x;
	cin >> k >> x;

	int temp = k;
	int pos = x;
	for (int i = x - k + 1; i < x; i++)
	{
		cout << i << " ";
	}


	for (int i = x; i < x + k; i++)
	{
		cout << i << " ";
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd>> Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-3;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define CHECK cout<<"arrived"<<endl

ll C2(ll x){
    return x*(x-1)/2;
}
int main(){
    string S; cin>>S;
    vec d(26,0);
    ll N=S.size();
    rep(i,N) d[S[i]-'a']++;
    ll ans=C2(N);
    rep(i,26) ans-=C2(d[i]);
    ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 3756
N, M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
AB = sorted(AB, key = lambda x: x[0])
money = 0
for a, b in AB:
  if(M <= 0):
    break
  if(b <= M):
    money += a*b
  else:
    money += M*a
  M -= b
print(money)

Measured memory_bytes: 29788
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    string name;
    LL N;
    cin >> N;
    while (0 < N) {
        int d = N % 26;
        if (d == 0) {
            d = 26;
        }
        name = (char)('a' + d - 1) + name;
        N = (N-d) / 26;
    }
    cout << name << endl;

    return 0;
}


Measured memory_bytes: 3652
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())|	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import collections
import math

#### START
N,K = map(int,input().split())
AA = []
for _ in range(N):
  a,b = map(int,input().split())
  AA.append([a, b])

AA = sorted(AA)
s = 0
for a, b in AA:
  s += b
  if K<=s:
    print(a)
    break

Measured memory_bytes: 21192
#include <iostream>
using namespace std;
int main(void){
    long q, h, s, d, n;
    
    cin >> q >> h >> s >> d >>n;
    if(2*q < h) h = 2*q;
    if(2*h < s) s = 2*h;
    if(2*s < d) d = 2*s;
    
    cout << (n/2)*d + (n%2)*s << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define x first
#define y second
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl '\n'


int main()
{
	map<ll,int> mp;
	ll x;
	cin>>x;
	for(ll i=-3981;i<=3981;i++){
		ll val=i*i*i*i*i;
		mp[val]=i;
	}
	for(ll i=-3981;i<=3981;i++){
		ll val=i*i*i*i*i;
		ll xx=x+val;
		if(mp.find(xx)!=mp.end()){
			cout<<mp[xx]<<' '<<i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 4128
import { readFileSync } from "fs";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const range = (n: number | bigint) => [...Array(Number(n))].map((_, i) => i);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const tuple = <T extends unknown[]>(...ts: T) => ts;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [cin, nCin, biCin] = (() => {
  const inputs = readFileSync("/dev/stdin", "utf-8").split(/[\n|\s]+/);
  let count = 0;
  const cin = () => inputs[count++];
  return tuple(
    cin,
    () => Number(cin()),
    () => BigInt(cin())
  );
})();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const max = <T extends number | bigint>(...ts: T[]) =>
  ts.reduce((acc, t) => (acc >= t ? acc : t));
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const min = <T extends number | bigint>(...ts: T[]) =>
  ts.reduce((acc, t) => (acc <= t ? acc : t));


type Color = "R" | "W";

// 1. R...R
// 2. W...W
// 3. R...RW...W
const getAnswer = (N: number, cs: Color[]): number => {
  const rNum = cs.filter((c) => c === "R").length;

  return min(
    rNum,
    N - rNum,
    cs.slice(0, rNum).filter((c) => c === "W").length,
  );
};

{
  const N = nCin();
  const cs = cin()
    .split("")
    .map((c) => c as Color);
  const ans = getAnswer(N, cs);
  console.log(ans);
}


Measured memory_bytes: 41316
from collections import defaultdict
def main(n, m):
    d = defaultdict(int)
    for _ in range(n):
        M = list(map(int, input().split()))
        for num, i in enumerate(M):
            if num == 0: continue
            d[i] += 1
    ans = 10**20
    for key, value in d.items():
        if value > m:
            ans = key
            m = value
        elif value == m:
            ans = min(ans,key)
    if ans == 10 ** 20:
        ans = 0
    print(ans)

while 1:
    n, m = map(int, input().split())
    if n == m == 0:
        break
    main(n,m)


Measured memory_bytes: 6004
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            if (n == 1) { WriteLine(1); return; }
            var dic =new SortedDictionary<int, int>();
            for (int i = 0; i < 999999; i++)
            {
                dic.Add(i, 0);
            }

            for (int i = 0; i < n; i++)
            {
               dic[s[i]]++;
            }
            var ls = dic.ToList();
            long ans = 0;

            for (int i = 0; i < dic.Count-2; i++)
            {
                ans = Max(ans, ls[i].Value + ls[i + 1].Value + ls[i + 2].Value);
            }
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 76816
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
ll gcd (ll a, ll b){
    if (b==0) return a;
    return gcd(b, a%b);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,X;
    cin>> N>>X;
    cout << 3*(N-gcd(N,X))<<"\n";
}

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

using namespace std;

int main()
{
    double ans = 0;
    int n;
    int a[100010];

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    for (int i = 0; i < n; i++) {
        ans += (double)1 / a[i];
    }

    printf("%.14lf\n", 1/ans);
    
}


Measured memory_bytes: 256
use std::collections::VecDeque;
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let h: usize = sc.read();
    let w: usize = sc.read();
    let mut a: Vec<Vec<char>> = (0..h).map(|_| sc.chars()).collect();
    let mut stack = VecDeque::new();
    for (y, line) in a.iter().enumerate() {
        for (x, c) in line.iter().enumerate() {
            //black
            if *c == '#' {
                stack.push_back((y, x, 1));
            }
        }
    }
    let mut result = 0;
    while let Some((y, x, cnt)) = stack.pop_front() {
        result = cnt;
        //eprintln!("{} {}", y, x);
        for k in 0..4 {
            if let Some((ny, nx)) = utils::try_adj(y, x, k, h, w) {
                if a[ny][nx] == '.' {
                    a[ny][nx] = '#';
                    stack.push_back((ny, nx, cnt + 1));
                }
            }
        }
    }
    println!("{}", result - 1);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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


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

  lint X;
  cin >> X;


  for (lint A = -1000; A <= 1000; A++) {
    for (lint B = -1000; B <= 1000; B++) {
      lint cur = A * A * A * A * A - B * B * B * B * B;
      if (cur == X) {
        cout << A << " " << B << "\n";
        return 0;
      }
    }
  }

}


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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            if (N <= 111)
            {
                Console.Write("111");
            }
            else if (N <= 222)
            {
                Console.Write("222");

            }
            else if (N <= 333)
            {
                Console.Write("333");

            }
            else if (N <= 444)
            {
                Console.Write("444");

            }
            else if (N <= 555)
            {
                Console.Write("555");

            }
            else if (N <= 666)
            {
                Console.Write("666");

            }
            else if (N <= 777)
            {
                Console.Write("777");

            }
            else if (N <= 888)
            {
                Console.Write("888");

            }
            else if (N <= 999)
            {
                Console.Write("999");

            }
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

using namespace std;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30));
const long long linf = (1LL<<60);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<int, int> mp;
    for(int i=0; i<n; i++)
    {
        int rate;
        cin >> rate;
        if(rate<400) mp[0]++;
        else if(rate<800) mp[1]++;
        else if(rate<1200) mp[2]++;
        else if(rate<1600) mp[3]++;
        else if(rate<2000) mp[4]++;
        else if(rate<2400) mp[5]++;
        else if(rate<2800) mp[6]++;
        else if(rate<3200) mp[7]++;
        else mp[8]++;
    }
    int ans = 0;
    for(int i=0; i<8; i++) if(mp[i] > 0) ans++;
    cout << max(1,ans) << ' ';
    ans = ans+mp[8];
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

struct Matrix{
    Int val[50][50];
    Matrix(){
        for(int i = 0;i < 50;i++){
            for(int j = 0;j < 50;j++){
                val[i][j] = 0;
            }
        }
    }
};

Matrix I;

Matrix operator*(Matrix a, Matrix b){
    Matrix c;
    for(int i = 0;i < 50;i++){
        for(int j = 0;j < 50;j++){
            for(int k = 0;k < 50;k++){
                c.val[i][j] += a.val[i][k] * b.val[k][j] %MOD;
                c.val[i][j] %= MOD;
            }
        }
    }
    return c;
}

Int n, k;

Matrix matrix_power(Matrix a, Int b){
    if(b == 0)return I;
    Matrix res = matrix_power(a, b/2);
    res = res * res;
    if(b % 2 == 1)res = res * a;
    return res;
}

int main(){
    for(int i = 0;i < 50;i++)I.val[i][i] = 1;

    Matrix A;
    cin >> n >> k;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            cin >> A.val[i][j];
        }
    }

    Matrix A_k = matrix_power(A, k);
    Int ans = 0;
    for(int i =0;i < n;i++){
        for(int j = 0;j < n;j++){
            ans += A_k.val[i][j];
            ans %= MOD;
        }
    }

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


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

int main() {
    int n, temp, cnt, ans = INT_MAX;
    cin >> n;
    temp = n;
    rep(i, n + 1) {
        cnt = 0;
        temp = i;
        while(temp) {
            cnt += temp % 6;
            temp /= 6;
        }
        temp = n - i;
        while(temp) {
            cnt += temp % 9;
            temp /= 9;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int n,a[1000001];
int main(){
	scanf("%d",&n);
	bool cando=0;
	for(int i=1;i<=n;i++)scanf("%1d",a+i),--a[i],cando|=(a[i]==1);
	for(int i=1;i<=n;i++)if(a[i]==2)a[i]=!cando;
	int ans=0;
//	for(int i=1;i<=n;i++)printf("%d ",a[i]);putchar('\n');
	for(int i=1;i<=n;i++)if(((n-i)&(i-1))==0)ans^=a[i];
	printf("%d\n",ans?(cando?1:2):0);
}

Measured memory_bytes: 4096
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int[] v = io.r<int>(' ');
        io.w((v[0] * v[1]).ToString() + " " + (2 * (v[0] + v[1])).ToString());
        io.wflush();
    }
}

namespace LIB
{
    public class io
    {
        private const int WMAX = 1000;
        private static StringBuilder S = new StringBuilder();
        public static T r<T>() { return util.parse<T>(r()); }
        public static T[] r<T>(char s = ' ') { return r().Split(s).Select(util.parse<T>).ToArray(); }
        public static T[] r<T>(int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = r<T>(); } return r; }
        public static T[][] r<T>(int l, char s = ' ') { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = r<T>(s); } return r; }
        private static string r() { return Console.ReadLine(); }
        public static void w(object v, bool lf = true) { S.Append(util.parse<string>(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { wflush(); } }
        public static void wflush() { Console.Write(S.ToString()); S.Length = 0; }
    }
    public class util
    {
        public static T parse<T>(object value) { return (T)(Convert.ChangeType(value, typeof(T))); }
    }
    public class memo<Key, Result>
    {
        private Dictionary<Key, Result> R;
        public memo() { R = new Dictionary<Key, Result>(); }
        public Result exec(Key k, Func<Key, Result> f) { Result r; if (R.ContainsKey(k)) { r = R[k]; } else { r = f(k); R.Add(k, r); } return r; }
    }
}

Measured memory_bytes: 10188
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007


int main() {

  string S;
  cin >> S;

  bool c = false,f = false;
  for(int i = 0;i < S.size();i++) {
    if(S.at(i) == 'C') c = true;
    if(c && S.at(i) == 'F') f = true;
  }

  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;

}



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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(abs(a-c) <= d || abs(a-b) <= d && abs(b-c) <= d) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include "iostream"
#include "cstdio"
#include "cstring"
#include "algorithm"
#include "queue"
#include "stack"
#include "cmath"
#include "utility"
#include "map"
#include "set"
#include "vector"
#include "list"
#include "string"
#include "cstdlib"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define st first
#define nd second
#define exp 1e-8
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int MAXN = 20;
char s[MAXN];
int ans;
int main(int argc, char const *argv[])
{
	scanf("%s", s);
	if(s[0] != 'C') ans++;
	if(s[1] != 'O') ans++;
	if(s[2] != 'D') ans++;
	if(s[3] != 'E') ans++;
	if(s[4] != 'F') ans++;
	if(s[5] != 'E') ans++;
	if(s[6] != 'S') ans++;
	if(s[7] != 'T') ans++;
	if(s[8] != 'I') ans++;
	if(s[9] != 'V') ans++;
	if(s[10] != 'A') ans++;
	if(s[11] != 'L') ans++;
	if(s[12] != '2') ans++;
	if(s[13] != '0') ans++;
	if(s[14] != '1') ans++;
	if(s[15] != '6') ans++;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
//AtCoder ABC104 A - Rated for Me
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
int main() {
    ll r; cin>>r;
    string ans;
    if (r<1200){
        ans="ABC";
    } else if(r<2800){
        ans="ARC";
    } else {
        ans="AGC";
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
const int MAX_N = int(1e5) + 10;
const int INF = int(1e9);

int N,K;
int h[MAX_N];
int dp[MAX_N];

int main()
{
  cin >> N >> K;
  REP(i,0,N) cin >> h[i];

  dp[0] = 0;

  REP(i,1,N) {
    dp[i] = INF;
    REP(k,1,K+1) {
      int j = i - k;
      if (j >= 0) {
        dp[i] = min(dp[i], dp[j] + abs(h[i]-h[j]));
      }
    }
  }

  // 添字ずれ
  cout << dp[N-1] << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define mn(a,b) (a < b ? a : b)
#define mx(a,b) (a > b ? a : b)
#define f first
#define s second
#define mp make_pair
#define all(v) (v).begin(),(v).end()

using namespace std;

vector < int > adya[51];
vector < pair < int , int > > ari;

bool visited[51];
int n, m;

int BFS(int l){
    int con = 1;
    visited[1] = true;
    queue < int > cola;
    cola.push(1);
    while(!cola.empty()){
        int v = cola.front();
        cola.pop();
        for(auto to: adya[v]){
            if((to == ari[l].f && v == ari[l].s) || (to == ari[l].s && v == ari[l].f))
                continue;
            if(!visited[to]){
                visited[to] = true;
                cola.push(to);
                con++;
            }
        }
    }
    fill(visited + 1, visited + n + 1, 0);
    return con;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;

    for(int i = 0; i < m; i++){
        int n1, n2;
        cin>>n1>>n2;
        adya[n1].push_back(n2);
        adya[n2].push_back(n1);
        ari.push_back(mp(n1, n2));
    }
    int cont = 0;
    for(int i = 0; i < m; i++){
        if(BFS(i) < n)
            cont++;
    }
    cout<<cont;
    return 0;
}


Measured memory_bytes: 256
N, M ,K = map(int, input().split())
MOD = 10**9 + 7

def comb(n, r, mod=10**9+7):
  if n==0 and r==0:
    return 1
  else:
    a = b = 1
    A, B = n, r
    for i in range(r):
      a = a*A % mod
      b = b*B % mod
      A -= 1
      B -= 1
    return a * pow(b, mod-2, mod) % mod

ans = comb(N*M-2, K-2) * ((M*(N-1)*(N+1) + N*(M-1)*(M+1))*N*M//6)%MOD % MOD
print(ans)

Measured memory_bytes: 3064
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]

d = {}

for s, c in sc:
    if s in d:
        if d[s] != c:
            print(-1)
            exit()
        else:
            continue
    if (N > 1) & (s == 1) & (c == 0):
        print(-1)
        exit()
    d[s] = c

ans = 0

for i in range(1, N+1):
    if i in d:
        ans += d[i] * 10 ** (N - i)
    else:
        if (i == 1) & (N > 1):
            ans += 10 ** (N - 1)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    long long n, sum = 0;
    cin >> n;
    vector<long long>a(n),sf(n),sb(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        sum += a[i];
        sf[i] = sum;
    }
    sum = 0;
    for(int i=n-1; i>=0; i--){
        sum += a[i];
        sb[i] = sum;
    }
    long long ans = sf[n-1];
    for(int i=0; i<n-1; i++){
        int j = i+1;
        ans = min(abs(sf[i]-sb[j]),ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7912
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N, M;
    cin >> N >> M;
    string S;
    cin >> S;

    ll sum = 0;
    ll ans = 0;
    rep(i,len(S)){
        if(S[i] == '0') sum = 0;
        else sum++;
        if(sum >= M){
            print(-1);
            return 0;
        } 
    }

    reverse(ALL(S));
    vector<ll> pos(len(S));

    rep1(i, min(M,N)) if (S[i] != '1') pos[0] = i;

    for (ll i = 1; i <= N; ++i){
        if(S[min(i + M, N)] == '0') pos[i] = min(i + M,N);
        else pos[i] = pos[i-1];
    }

    vector<ll> dice;
    ll now = 0;
    while(now < N){
        dice.pb(pos[now] - now);
        now = pos[now];
    }

    rrep(i, len(dice)) cout << dice[i] << " ";
    cout << '\n';

    return 0;
}

Measured memory_bytes: 2248
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
// #define INF __INT32_MAX__
#define INF 1e9
#define LINF __LONG_LONG_MAX__

typedef pair<int, int> P;

int main() {
    int H, W; cin >> H >> W;
    int SX, SY, GX, GY; cin >> SX >> SY >> GX >> GY; 
    SX--; SY--; GX--; GY--;
    vector<vector<char>> S(H, vc(W)); rep(i, H) rep(j, W) cin >> S[i][j];

    vector<vector<int>> d(H, vi(W, INF));
    d[SX][SY] = 0;
    deque<P> dq;
    dq.emplace_back(P{SX, SY});

    vector<vi> mp = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

    while (!dq.empty()) {
        P p = dq.front(); dq.pop_front();
        int cx = p.first, cy = p.second;

        rep(i, 4) {
            int nx = cx + mp[i][0];
            int ny = cy + mp[i][1];

            if (!(nx >= 0 && nx < H && ny >= 0 && ny < W)) continue;
            if (S[nx][ny] == '#') continue;

            if (d[nx][ny] > d[cx][cy]) {
                d[nx][ny] = d[cx][cy];
                dq.emplace_front(P{nx, ny});
            }
        }

        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                int nx = cx + i;
                int ny = cy + j;

                if (!(nx >= 0 && nx < H && ny >= 0 && ny < W)) continue;
                if (S[nx][ny] == '#') continue;

                if (d[nx][ny] > (d[cx][cy] + 1)) {
                    d[nx][ny] = d[cx][cy] + 1;
                    dq.emplace_back(P{nx, ny});
                }
            }
        }
    }

    if (d[GX][GY] == INF) {
        cout << -1 << endl;
    } else {
        cout << d[GX][GY] << endl;
    }
}


Measured memory_bytes: 8560