akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
const int MAXN = 2005, mod = 1e9 + 7;
inline int addmod(int a, int b) { return (a + b) % mod; }
inline int mulmod(long long a, int b) { return (a * b) % mod; }
inline int powmod(int a, int x) {
    long long cur = a, res = 1;
    while(x) {
        if(x & 1) res = (res * cur) % mod;
        cur = (cur * cur) % mod;
        x >>= 1;
    }
    return (int)res;
}
int n, k, f[MAXN][MAXN], fac[MAXN * MAXN], rev_fac[MAXN * MAXN];
inline int commod(int n, int m) {
    return mulmod(fac[n], mulmod(rev_fac[m], rev_fac[n - m]));
}
int main() {
    fac[0] = 1;
    rev_fac[0] = powmod(fac[0], mod - 2);
    for(int i = 1; i < MAXN * MAXN; i++) fac[i] = mulmod(fac[i - 1], i), rev_fac[i] = powmod(fac[i], mod - 2);
    scanf("%d%d", &n, &k);
    int ans;
    if(k == 1) {
        ans = 1;
    }
    else {
        for(int i = 0; i <= n; i++) {
            for(int j = i; j <= n; j++) {
                if(i == 0 && j == 0) f[i][j] = 1;
                if(i - 1 >= 0) f[i][j] = f[i - 1][j];
                if(j > i)
                    f[i][j] = addmod(f[i][j], mulmod(f[i][j - 1], commod(i + j * (k - 1) - 1, k - 2)));
            }
        }
        ans = mulmod(fac[n], f[n][n]);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 47360
N = int(input())
s = []
for i in range(N):
  s.append(input())

M = int(input())
t = []
for i in range(M):
  t.append(input())

ans = 0
for i in set(s):
  if s.count(i) - t.count(i) > ans:
    ans = s.count(i) - t.count(i)

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string s;
    string t;
    cin >>s;
    cin >>t;
    if (t.substr(0,s.size())==s){
        cout <<"Yes";
    }
    else {
        cout <<"No";
    }
}


Measured memory_bytes: 3624
using System;
using System.Linq;

namespace _029_EnglishSentence
{
	class Program
	{
		static void Main ( string[] args )
		{
			string[] inputStr = Console.ReadLine ().Split (' ');

			Array.Sort (inputStr);

			int[] countArray = new int[inputStr.Length];
			countArray[0] = 1;

			for (int lp = 1; lp < inputStr.Length; lp++)
			{
				if (inputStr[lp] == inputStr[lp - 1])
					countArray[lp] = countArray[lp - 1] + 1;
				else
					countArray[lp] = 1;
			}

			int maxCount = countArray.Max ();
			int index = Array.IndexOf (countArray, maxCount);
			string maxCountStr = inputStr[index];


			string maxLengthStr = inputStr[0];

			for (int lp = 1; lp < inputStr.Length; lp++)
			{
				if (maxLengthStr.Length < inputStr[lp].Length)
				{
					maxLengthStr = inputStr[lp];
				}
			}

			Console.WriteLine (maxCountStr + " " + maxLengthStr);
		}
	}
}

Measured memory_bytes: 10200
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    vector<ll> b(100007, 0);
    for(ll i=0;i<n;++i){
        cin>>a[i];
        a[i]++;
        b[a[i]-1]++;
        b[a[i]]++;
        b[a[i]+1]++;
    }

    ll ans = 0;
    for(ll i=0;i<b.size();++i){
        ans = max(ans, b[i]);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	string s;
	cin >> s;
	
	if( s.substr(0, 4) == "YAKI" ) cout << "Yes";
	else cout << "No";
	
	cout << endl;
	
	return 0;
}


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

namespace C044
{
    class C108
    {

        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int K = int.Parse(s[1]);

            int num = N / K;
            long counter = (long)num * num * num;

            if(K % 2 == 0)
            {
                int num2 = (N + K / 2) / K;
                counter += (long)num2 * num2 * num2;
            }
            Console.WriteLine(counter);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define el '\n'
typedef long long ll;
int N;
ll sum;
int main() {
	cin >> N;
	for(int i = 1;i<=N;i++){
		if(i%3==0||i%5==0)continue;
		sum+=i;
	}
	cout << sum << el;
	return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
using namespace std;

typedef long long ll;
int a[100010];
int main() {
  int N; cin >> N;
  for ( int i = 0; i < N; i++ ) cin >> a[i];
  ll tmp = -2;
  ll cnt = 0;
  sort(a,a+N);
  a[N] = -1;
  ll ans = 0;
  for ( int i = 0; i < N; i++ ) {
    if ( tmp != a[i] ) {
      tmp = a[i];
      cnt = 0;
    }
    if ( a[i] == tmp ) cnt++;

    if ( a[i+1] == -1 ) {
      if ( cnt > tmp ) ans += cnt - tmp;
      else if ( cnt < tmp ) ans += cnt;
      break;
    } else if ( tmp != a[i+1] ) {
      if ( cnt > tmp ) ans += cnt - tmp;
      else if ( cnt < tmp ) ans += cnt;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
<?php
  list($n, $m) = explode(" ", trim(fgets(STDIN)));

  $lites = [];
  for($i=0; $i<$m; $i++){
    $lites[] = explode(" ", trim(fgets(STDIN)));
  }

  $p = explode(" ", trim(fgets(STDIN)));

  $patterns = f ($n, "");

  $ans = 0;
  for($i=0; $i<count($patterns); $i++){
    $pattern = $patterns[$i];
    $isOk = 1;
    
    for($j=0; $j<$m; $j++){
      $lite = $lites[$j];
      $on = 0;
      for($k=1; $k<count($lite); $k++){
//        echo "--".$pattern[$lite[$k]-1]." ".($lite[$k]).PHP_EOL;
        $on += $pattern[$lite[$k]-1];
      }
//      echo $on.PHP_EOL;
      if($on %  2 != $p[$j]){
        $isOk = 0;
        break;
      }
    }
//    echo $pattern." ".$isOk.PHP_EOL;
    if($isOk){
      $ans++;
    }
  }
  echo $ans;
  function f ($n, $str){
    if(strlen($str) >= $n){
      return [$str];
    }
    else {
      $new_str = [];
      $new_str = array_merge($new_str, f($n, $str."0"));
      $new_str = array_merge($new_str, f($n, $str."1"));
      return $new_str;
    }
  }


Measured memory_bytes: 4604
N, M = map(int, input().split())
H = list(map(int, input().split()))
routes = dict()
for i in range(M):
    A, B = map(int, input().split())
    if routes.get(A) is None:
        routes[A] = set([B])
    else:
        routes[A].add(B)
    if routes.get(B) is None:
        routes[B] = set([A])
    else:
        routes[B].add(A)

#print(routes)
answer = 0
for i in range(1, N + 1):
    if routes.get(i) is None:
        answer += 1
    else:
        tmp = 0
        for j in routes.get(i):
            tmp = max(tmp, H[j - 1])
        if H[i - 1] > tmp:
            answer += 1
print(answer)

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

struct Iterator {
  int i;
  int& operator*() { return i; }
  Iterator& operator++() { ++i; return *this; }
  bool operator!=(const Iterator& v) { return i != v.i; }
};

struct Range {
    int start;
    int step;
    int length;
    Iterator begin() { return {start};}
    Iterator end()   { return {start + step * length};}
};

int sum(vector<int> A, int N){
    int res = 0;
    rep(i,N) res += A[i];
    return res;
}

int sum(Range A){
    return (2 * A.start + (A.length - 1) * A.step) * A.length / 2;
}

int main(){
    int N,L,min_apple;
    cin >> N >> L;
    if ((L + N) <= 0) min_apple = L + N - 1;
    else if (L >= 0) min_apple = L;
    else min_apple = 0;
    cout << (sum(Range{L,1,N}) - min_apple) << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
p = list(map(int, input().split()))

count = 0
for i in range(N-1):
  if p[i] == i+1:
    p[i], p[i+1] = p[i+1], p[i]
    count += 1
if p[N-1] == N:
  p[N-2], p[N-1] = p[N-1], p[N-2]
  count += 1
  
print(count)

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

    int N;
    cin>>N;
    vector<int> P(N);
    rep(i, N){
        cin >> P.at(i);
    }
    int cnt = 0, Min = P.at(0);

    for (int i = 0; i < N;i++){
        if(P.at(i)==min(Min,P.at(i))){
            Min = P.at(i);
            cnt++;
        }
    }
    cout << cnt << endl;
}


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

int main() {
  string o,e;
  cin>>o>>e;
  rep(i,e.size()){
    cout<<o[i];
    cout<<e[i];
  }
  if(o.size()!=e.size()){
    cout<<o.back();
  }
}

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

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

using namespace std;

typedef pair<string,int> si;
typedef pair<int,int> ii;

struct Edge{
  int to,cap,cost,rev;
  Edge(int to=0,int cap=0,int cost=0,int rev=0):to(to),cap(cap),cost(cost),rev(rev){}
};

const int MAX_V = 1100, IINF = INT_MAX;
int V;
vector<Edge> G[MAX_V];
int h[MAX_V],dist[MAX_V],prevv[MAX_V],preve[MAX_V];

inline void add_edge(int from,int to,int cap,int cost){
  G[from].push_back(Edge(to,cap,cost,G[to].size()));
  G[to].push_back(Edge(from,0,-cost,G[from].size()-1));
}

int min_cost_flow(int s,int t,int f){
  int res = 0;
  fill(h,h+V,0);
  while(f>0){
    priority_queue<ii,vector<ii>,greater<ii> > Q;
    fill(dist,dist+V,IINF);
    dist[s] = 0;
    Q.push(ii(0,s));
    while(!Q.empty()){
      ii p = Q.top(); Q.pop();
      int v = p.second;
      if( dist[v] < p.first ) continue;
      for(int i=0;i<G[v].size();i++){
        Edge &e = G[v][i];
        if( e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to] ) { 
          dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
          prevv[e.to] = v;
          preve[e.to] = i;
          Q.push(ii(dist[e.to],e.to));
        }
      }
    }
    if( dist[t] == IINF ) return -1;
    rep(v,V) h[v] += dist[v];
    int d = f;
    for(int v=t;v!=s;v=prevv[v]) d = min(d,G[prevv[v]][preve[v]].cap);
    f -= d;
    res += d * h[t];
    for(int v=t;v!=s;v=prevv[v]){
      Edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return res;
}


int LevenshteinDistance(string a,string b){
  int alen = a.size(), blen = b.size();
  int dp[alen+1][blen+1];
  rep(i,alen+1) dp[i][0] = i;
  rep(i,blen+1) dp[0][i] = i;

  rep(i,alen) rep(j,blen){
    int cost = ( a[i] != b[j] );
    dp[i+1][j+1] = min(dp[i][j+1]+1,
                       min(dp[i+1][j]+1,dp[i][j]+cost));
  }

  return dp[alen][blen];
}

int main(){

  int N,M;
  cin >> N >> M;
  cin.ignore();
  vector<si> text_buf;
  vector<string> word_buf(M);
  map<string,int> counter;
  rep(i,N){
    string tmp;
    getline(cin,tmp);
    stringstream ss(tmp);
    while(!(ss>>tmp).fail()) counter[tmp]++;
  }

  for( pair<string,int> i : counter ) text_buf.push_back(i);
  rep(i,M) cin >> word_buf[i];

  V = (int)word_buf.size() + (int)text_buf.size();
  int source = V, sink = source + 1;
  V += 2;
  rep(i,V) G[i].clear();

  rep(i,text_buf.size())add_edge(source,i,1,0);
  int DIFF = text_buf.size();
  rep(i,word_buf.size())add_edge(DIFF+i,sink,1,0);
  rep(i,text_buf.size()){
    int f = i;
    rep(j,word_buf.size()){
      int t = j + DIFF;
      int cost = LevenshteinDistance(word_buf[j],text_buf[i].first) * text_buf[i].second;
      add_edge(f,t,1,cost);
    }
  }

  cout << min_cost_flow(source,sink,(int)text_buf.size()) << endl;

  return 0;
}

Measured memory_bytes: 7960
using System;
using System.Linq;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = IOUtils.ReadInt();
            var res = r * 2 * Math.PI;
            Console.WriteLine(res);
        }
    }

    static class IOUtils
    {
        public static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        public static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        public static ulong ReadUlong()
        {
            return ulong.Parse(Console.ReadLine());
        }
        public static int[] ReadInts()
        {
            return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        }
        public static long[] ReadLongs()
        {
            return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
        }

        public static void WriteNums(params int[] nums)
        {
            Console.WriteLine(string.Join(" ", nums));
        }
    }
}


Measured memory_bytes: 18596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int k;
    string s;cin>>k>>s;
    if(sz(s)<=k)
    {
        cout<<s<<endl;
    }
    else
        cout<<s.substr(0,k)+"..."<<endl;
    return 0;
}

Measured memory_bytes: 3624
N = gets.strip.to_i
a = gets.strip.split('')

def chmax(a, b) a > b ? a : b end


def f(x, y)
  x.uniq.select { |n| y.include?(n) }.size
end

res = 0
(N - 1).times do |i|
  res = chmax(f(a[0..i], a[(i + 1)..-1]), res)
end

puts res


Measured memory_bytes: 3836
open System

[<EntryPoint>]
let main argv =
    let inputs = stdin.ReadLine().Split(' ') |> Array.map int
    let appleCount = inputs.[0]
    let applePieceCount = inputs.[1]

    let answer = (appleCount * 3 + applePieceCount) / 2

    printfn "%d" answer

    0 // return an integer exit code


Measured memory_bytes: 11984
import Control.Applicative
import Data.List

main = do _ <- getLine
          xs <- map ((map read).words) . lines <$> getContents
          putStr . toOut $ solve xs initialState

toOut :: [[[Int]]] -> String
toOut ys = concatMap unlines . intersperse ["####################"] . map (map (concatMap (" " ++))) $ map (map (map show)) ys

solve :: [[Int]] -> [[[Int]]] -> [[[Int]]]
solve [] st = st
solve (x:xs) st = solve xs (changeSt x st)

changeSt :: [Int] -> [[[Int]]] -> [[[Int]]]
changeSt (b:f:r:v:_) st = makeSt b f st . changeLine r v $ specificLine b f st

specificLine :: Int -> Int -> [[[Int]]] -> [Int]
specificLine b f st = (st !! (b-1)) !! (f-1)

changeLine :: Int -> Int -> [Int] -> [Int]
changeLine r v line = bf ++ (n + v) : af
                      where bf = take (r-1) line
                            af = drop r line
                            n = line !! (r-1)

makeSt :: Int -> Int -> [[[Int]]] -> [Int] -> [[[Int]]]
makeSt b f st line = bfB ++ block : afB
                     where bfB = take (b-1) st
                           afB = drop b st
                           block = bf ++ line : af
                                   where bf = take (f-1) (st !! (b-1))
                                         af = drop f (st !! (b-1))

initialState :: [[[Int]]]
initialState = replicate 4 . replicate 3 $ replicate 10 0

Measured memory_bytes: 4324
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Integer> b = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			b.add(sc.nextInt());
		}
		ArrayList<Integer> ans = new ArrayList<>();
		for (int i = n - 1; i >= 0; i--) {
			if (b.size() > i && b.get(i) == i + 1) {
				b.remove(i);
				ans.add(i + 1);
				i = b.size();
			}
		}
		if (ans.size() != n) {
			System.out.println(-1);
		} else {
			for (int i = n - 1; i >= 0; i--) {
				System.out.println(ans.get(i));
			}
		}
	}
}

Measured memory_bytes: 22740
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
const int N = 1e5 + 5;
const int mod = 1e9 + 7; 
using namespace std;

int n, x[N], fac[N], inv[N], ans; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int fpow(int x, int y)
{
	int res = 1;
	for( ; y; y >>= 1, x = 1ll * x * x % mod)
		if(y & 1) res = 1ll * res * x % mod;
	return res; 
}

int main()
{
	n = read <int> ();
	for(int i = 1; i <= n; i++) x[i] = read <int> (); 
	for(int i = (fac[0] = 1); i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % mod; 
	for(int i = 1; i <= n; i++) inv[i] = (inv[i - 1] + fpow(i, mod - 2)) % mod; 
	for(int i = 1; i <= n - 1; i++) ans = (1ll * inv[i] * (x[i + 1] - x[i]) + ans) % mod; 
	ans = 1ll * ans * fac[n - 1] % mod, printf("%d\n", ans); 
	return 0; 
}


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

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REP1(i,n) for(int i = 1; i <= (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define MP(a,b) make_pair((a), (b))
#define ROUNDUP(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second
#define DEBUG(a) cout << #a << ": " << a << "\n"
// #define DEBUG(a) {}

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 4 * 1e18 + 1;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

template<typename T>
T debug(T x) {
	DEBUG(x);
	return x;
}

int cnt[26];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	cin >> s;

	if(s.size() == 26){
		priority_queue<char> que;
		vector<char> cs;
		cs.push_back(s[25]);
		RREP(i, s.size() - 1){
			if(upper_bound(ALL(cs), s[i]) != cs.end()){
				REP(j, i) cout << s[j];
				cout << *upper_bound(ALL(cs), s[i]) << "\n";
				return 0;
			}
			cs.push_back(s[i]);
		}
		cout << "-1\n";
	}
	else{
		REP(i, s.size()){
			cnt[s[i] - 'a']++;
		}

		queue<char> que;
		REP(i, 26){
			if(cnt[i] == 0){
				cout << s << char(i + 'a') << "\n";
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = nextInt()
    val S = next().map{ it == 'W' }.toMutableList()
    val L = 2 * N
    for (n in 1..L) {
        if ((L-n) % 2 == 1) S[n-1] = !S[n-1]
    }
//System.err.println(S.map{if (it) 'W' else 'B'}.joinToString(separator = ""))
    var l = 0
    var ans = 1L
    val MOD = 1000000007L
    S.forEach {
        if (it) l++ else {
            ans *= l
            ans %= MOD
            l--
        }
    }
    for (n in 2..N) {
        ans *= n
        ans %= MOD
    }
    println(if (l == 0) ans else 0)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())


Measured memory_bytes: 40956
#include<iostream>
using namespace std;
int main(){
	int i,j,n,N;
	char a,b;
	cin>>a>>b;
	if(a=='H'){
	    if(b=='H'){
	    	cout<<"H";
		}else{
			cout<<"D";
		}
	}else{
		if(b=='H'){
			cout<<"D";
		}else{
			cout<<"H";
		}
	}
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    var tmp = readLine()!!.split(" ").map { it.toInt() }
    val n = tmp[0]
    val k = tmp[1]
    val q = tmp[2]
    var point = arrayListOf<Int>()
    for (i in 0 until n){
        point.add(k-q)
    }
    var a = arrayListOf<Int>()
    for (i in 0 until q){
        point[readLine()!!.toInt()-1]++
    }

    for (i in 0 until n){
        println(if (point[i] > 0) "Yes" else "No")
    }
}


Measured memory_bytes: 48448
import time
st_time=time.time()

from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
ts=time.time()
sys.setrecursionlimit(10**6)
#input=sys.stdin.readline
show_flg=False
show_flg=True

class Comb:
    def __init__(self,n,mo=10**9+7):
        self.fac=[0]*(n+1)
        self.inv=[1]*(n+1)
        self.fac[0]=1
        self.fact(n)
        for i in range(2,n+1):
            self.inv[n]*=i
            self.inv[n]%=mo
        self.inv[n]=pow(self.inv[n],mo-2,mo)
        for i in range(1,n):
            self.inv[n-i]=self.inv[n-i+1]*(n-i+1)%mo
        return
    
    def fact(self,n):
        if self.fac[n]!=0:
            return self.fac[n]
        self.fac[n]=n*self.fact(n-1)%mo
        return self.fac[n]

    def invf(self,n):
        return self.inv[n]

    def comb(self,x,y):
        if y<0 or y>x:
            return 0
        return self.fac[x]*self.inv[x-y]*self.inv[y]%mo
    
n=int(input())
a=[int(i) for i in input().split()]

cm=Comb(n+1)
c=Counter(a)
db=c.most_common()[0][0]
fst=a.index(db)
lst=a.index(db,fst+1)
x=n+1-(lst-fst+1)

for i in range(1,n+2):
    ans=cm.comb(n+1,i)-cm.comb(x,i-1)
    print(ans%mo)


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


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

class BGoldenCoins {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll x;
        in >> x;
        ll ans=0L;
        ans+=(x/500)*1000;
        ans+=((x%500)/5)*5;
        out << ans << endl;
	}
};


int main() {
	BGoldenCoins solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 100005

ll n;

int main()
{
    _FastIO;
    cin >> n;
    ll ans = (n * (n - 1)) / 2;
    cout << ans << endl;
    return 0;
}


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

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

		Scanner stdIn = new Scanner(System.in);
		String str = stdIn.nextLine();

		String[] strArray = str.split("");
		int ans = 0;

		for(int i = 0;i < strArray.length;i++){
			if(strArray[i].equals("x")){
				ans++;
			}
		}

		String ansStr = "YES";
		if(ans >=8){
			ansStr = "NO";
		}
		System.out.println(ansStr);
		
  
	}
}

Measured memory_bytes: 21972
a = int(input())
b = int(input())
c = int(input())
d = int(input())
n =[a,b,c]
ans = 0
for i in range(n[0]+1):
    for j in range(n[1]+1):
        for k in range(n[2]+1):
            if (i)*500 + (j)*100 + (k)*50 == d:
                ans += 1
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        int a = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '+') {
                a++;
            } else {
                a--;
            }
        }

        System.out.println(a);
    }
}


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

int main( void ) {
    vector<int> num( 3 );
    for( int i = 0; i < 3; i++ ) {
        cin >> num.at( i );
    }
    sort( num.begin(), num.end() );
    for( int i = 0; i < 3; i++ ) {
        if( i == 2 )
            cout << num.at( i ) << endl;
        else
            cout << num.at( i ) << " ";
    }
}



Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S;
    char s;
    int ans = 0;
    cin >> S;
    for(int i=0;i<S.size();i++){
        s = S[i];
        if (s=='+'){
            ans++;
        }else{
            ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int r=0,c=0,h=0,w=0,num=0,wsum=0,hsom=0,sum=0;
	int a[101][101] = {0};
	
	scanf("%d %d",&r,&c);
	
		for(h=1;h<=r;h++){
			for(w=1;w<=c;w++){
			scanf("%d",&num);
			a[h][w]=num;
			}
		}
		
		for(h=1;h<=r;h++){
			for(w=1;w<=c;w++){
			printf("%d",a[h][w]);
					if(w<=c){printf(" ");}
			}
				for(w=1;w<=c;w++){
				wsum+=a[h][w];
				}
				printf("%d",wsum);
				wsum=0;
				printf("\n");
		}
		
	for(w=1;w<=c;w++){
		for(h=1;h<=r;h++){
		hsom+=a[h][w];
		sum+=a[h][w];
		}
		printf("%d",hsom);
		if(w<c){printf(" ");}
		hsom=0;
	}
	printf(" %d\n",sum);
	
return 0;
}

Measured memory_bytes: 652
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n;
		n=sc.nextInt();
		sc.nextLine();
		String str;
		while(n--!=0){
			str=sc.nextLine();
			str=str.replace("Hoshino","Hoshina");
			System.out.println(str);
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;

int main(){
  int n,k,h[100500];cin>>n>>k;
  rep(i,n)cin>>h[i];
  int cost[100500]={};
  for(int i=1;i<100500;i++)cost[i]=1e9;
  for(int i=0;i<n;i++){
    for(int j=1;j<=k;j++){
      cost[i+j]=min(cost[i+j],cost[i]+abs(h[i]-h[i+j]));
    }
  }
  cout<<cost[n-1];
}

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

int main() {
  int N, P ,Q;
  cin >> N;
  P = N - N % 10;
  Q = N % 1000;
  if (P % 111 == 0 || Q % 111 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
const int MOD = 1000000007;
int a[200001],b[200001];
int fac[8001],ni[8001],f[4001][4001],ans;
int n,x,y,p;
void read(int &k) {
    char c=getchar();
    while (c<48||c>57) c=getchar();
    k=0;
    while (c>=48&&c<=57) {
        k=k*10+c-48;
        c=getchar();
    }
}
int C(int n,int m) {
    return 1ll*fac[n]*ni[m]%MOD*ni[n-m]%MOD;
}
int fun(int a,int k) {
    int s=1;
    while (k) {
        if (k&1) s=1ll*s*a%MOD;
        a=1ll*a*a%MOD;
        k>>=1;
    }
    return s;
}

int main() {
    fac[0]=1;
    for (int i=1; i<=8000; ++i) fac[i]=(long long)fac[i-1]*i%MOD;

    ni[8000]=fun(fac[8000],MOD-2);
    for (int i=7999; i>0; --i) ni[i]=(long long)ni[i+1]*(i+1)%MOD;

    read(n);
    for (int i=1; i<=n; ++i) {
        read(a[i]);
        read(b[i]);
        if (a[i]>x) x=a[i];
        if (b[i]>y) y=b[i];
        f[2000-a[i]][2000-b[i]]++;
    }

    for (int i=2000-x; i<=2000+x; ++i)
        for (int j=2000-y; j<=2000+y; ++j) {
            if (i>0) {
                p=f[i][j]+f[i-1][j];
                f[i][j]= p>=MOD ? p-MOD : p;
            }
            if (j>0) {
                p=f[i][j]+f[i][j-1];
                f[i][j]= p>=MOD ? p-MOD : p;
            }
        }

    for (int i=1; i<=n; ++i) {
        p=ans+f[2000+a[i]][2000+b[i]];
        ans = p>=MOD ? p-MOD : p;
        p=ans+MOD - C(a[i]+b[i]+a[i]+b[i],a[i]+a[i]);
        ans = p>=MOD ? p-MOD : p;
    }
    ans=1ll*ans*ni[2]%MOD;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 64256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

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


Measured memory_bytes: 256
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
ab=sorted(ab)
ans=0
d=0
for i in range(n):
  s=min(m-d,ab[i][1])
  ans+=ab[i][0]*s
  d+=s
  if d==m:
    break
print(ans)

Measured memory_bytes: 28648
import java.util.Scanner;


public class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int m = sc.nextInt();
			int n = sc.nextInt();
			boolean[][] e = new boolean[m+1][m+1];
			int[] deg = new int[m+1];
			for(int i=0; i<n; i++) {
				int x = sc.nextInt();
				int y = sc.nextInt();
				e[y][x] = true;
				deg[y]++;
			}
			for(int i=0;i<m;i++){
				for(int j=1;j<=m;j++) {
					if(deg[j]==0){
						if(i!=m-1 && j==2)continue;
						System.out.println(j);
						deg[j] = -1;
						for(int k=1;k<=m;k++)if(e[k][j]) {
							deg[k]--;
						}
					}
				}
			}
		}
	}
}


Measured memory_bytes: 26280
<?php

fscanf(STDIN, '%d', $n);
for ($count = 0; $count < $n; $count++) {
    fscanf(STDIN, '%f %f %f %f %f %f', $x1, $y1, $x2, $y2, $x3, $y3);
    $a = sqrt(($x1 - $x2) * ($x1 - $x2) + ($y1 - $y2) * ($y1 - $y2));
    $b = sqrt(($x3 - $x2) * ($x3 - $x2) + ($y3 - $y2) * ($y3 - $y2));
    $c = sqrt(($x1 - $x3) * ($x1 - $x3) + ($y1 - $y3) * ($y1 - $y3));
    $R = $a * $b * $c / sqrt(($a + $b + $c) * (- $a + $b + $c) * ($a - $b + $c) * ($a + $b - $c));
    $s = array();
    $s[] = $x2 - $x1;
    $s[] = $y2 - $y1;
    $s[] = ($x2 * $x2 - $x1 * $x1 + $y2 * $y2 - $y1 * $y1) / 2;
    $t = array();
    $t[] = $x3 - $x1;
    $t[] = $y3 - $y1;
    $t[] = ($x3 * $x3 - $x1 * $x1 + $y3 * $y3 - $y1 * $y1) / 2;

    if ($s[0] === 0.0) {
        $tmp = $s;
        $s = $t;
        $t = $tmp;
    }
    $div = $s[0];
    for ($i = 0; $i < 3; $i++) {
        $s[$i] /= $div;
    }
    $times = $t[0];
    for ($i = 0; $i < 3; $i++) {
        $t[$i] -= $s[$i] * $times;
    }
    $div = $t[1];
    for ($i = 0; $i < 3; $i++) {
        $t[$i] /= $div;
    }
    $times = $s[1];
    for ($i = 0; $i < 3; $i++) {
        $s[$i] -= $t[$i] * $times;
    }
    echo sprintf('%.3f %.3f %.3f', round($s[2], 3), round($t[2], 3), round($R, 3));
    echo PHP_EOL;
}

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

int main(){
  
  string S, l, r, c, Ans;
  cin >> S;
  long long Q, i, t, f;
  int rlch = 1;
  cin >> Q;
  
  for (i = 0; i < Q; i++){
    
    cin >> t;
    
    if (t == 1){
      rlch *= -1;
    }else{
      
      cin >> f >> c;
      
      if(rlch == 1 && f == 1 || rlch == -1 && f == 2){
        
        l += c;
      }else{
        
        r += c;
      }
      
    }
  }
  
  
  reverse(l.begin(), l.end());
  
  if (rlch == -1){
    Ans = l + S + r;
    reverse(Ans.begin(), Ans.end());
  }else{
    Ans = l + S + r;
  }
  
  cout << Ans << endl;
  return 0;
}

Measured memory_bytes: 1348
import java.io.IOException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int count = 0;

		for(int i=a;i<=b;i++) {
			if(c%i==0) {
				count++;
			}
		}

		System.out.println(count);

		sc.close();
	}
}


Measured memory_bytes: 26340
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
    long long x;
    cin >> x;
    long long total=0;
    long long ans=0;
    for(long long i=0;i<10000000;i++){
        total+=i;
         if(total>=x){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ITP1_2_C
{
	class Program
	{
		static void Main(string[] args)
		{
			List<int> vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();

			vals.Sort();

			Console.WriteLine($"{vals[0]} {vals[1]} {vals[2]}");
		}
	}
}



Measured memory_bytes: 18376
I = list(map(int,input().split()))
A = I[0]
B = I[1]
C = I[2]
K = I[3]

R = K-(A+B)
if R <= 0 :
    R = 0
elif R >= C :
    R = C

S = A - R
if A > K :
    S = K

print(S)  

Measured memory_bytes: 9196
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

char s[4];
int a[3];

int main(void){

	scanf("%s",s);

	for(int i=0;i<3;i++){
		a[s[i]-'a']++;
	}

	if(a[0]&&a[1]&&a[2]){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int tmp;

        //1番目の数と2 番目の数を比べて逆順ならば交換する
        if (a > b) {
            tmp = a;
            a = b;
            b = tmp;
        }

        //2番目の数と3番目の数を比べて逆順ならば交換する
        if (b > c) {
            tmp = b;
            b = c;
            c = tmp;
        }

        //1番目の数と2番目の数を比べて逆順ならば交換する
        if (a > b) {
            tmp = a;
            a = b;
            b = tmp;
        }

        System.out.println(a + " " + b + " " + c);
    }
}


Measured memory_bytes: 26200
#include<iostream>
#include<vector>
#include<set>
using namespace std;

#define MAX 100000

vector<int> G[MAX];
int N;
bool visited[MAX];
int prenum[MAX], parent[MAX], lowest[MAX], timer;

void dfs(int current, int prev) {
	prenum[current] = lowest[current] = timer;
	timer++;

	visited[current] = true;

	int next;

	for (int i = 0; i < G[current].size(); i++) {
		next = G[current][i];
		if (!visited[next]) {
			parent[next] = current;

			dfs(next, current);

			lowest[current] = min(lowest[current], lowest[next]);
		}
		else if (next != prev) {
			lowest[current] = min(lowest[current], prenum[next]);
		}
	}
}

void art_points() {
	for (int i = 0; i < N; i++)visited[i] = false;
	timer = 1;
	dfs(0,- 1);

	set<int> ap;
	int np = 0;
	for (int i = 1; i < N; i++) {
		int p = parent[i];
		if (p == 0)np++;
		else if (prenum[p] <= lowest[i])ap.insert(p);
	}
	if (np > 1)ap.insert(0);
	for (set<int>::iterator it = ap.begin(); it != ap.end(); it++)
		cout << *it << endl;
}

int main() {
	int m;
	cin >> N >> m;

	for (int i = 0; i < m; i++) {
		int s, t;
		cin >> s >> t;
		G[s].push_back(t);
		G[t].push_back(s);
	}
	art_points();

	return 0;
}


Measured memory_bytes: 6860
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int q;
  cin>>q;
  while(q--){
    string s;
    cin>>s;
    string t=s;
    t.erase(unique(t.begin(),t.end()),t.end());
    if(s.size()!=t.size()){
      cout<<"No"<<endl;
      continue;
    }
    if((int)s.size()<3){
      cout<<"Yes"<<endl;
      continue;
    }
    bool f=0;
    for(int k=0;k<2;k++){
      bool ff=1;
      char l=s[k],r=s[!k];
      if(l=='R'||r=='L'){
	  ff=0;
      }
      for(int i=2;i<(int)s.size();i++){
	if((i+k)%2) r=s[i];
	else l=s[i];
	if(l=='R'||r=='L'){
	  ff=0;
	  break;
	}
      }
      f|=ff;
    }
    if(f) cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3284
#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;

int main(){
  int K,X;
  cin>>K>>X;

  for(int i=1;i<K;i++) cout<<X-K+i<<" ";
  cout<<X;
  for(int i=1;i<K;i++) cout<<" "<<X+i;
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,p;
    string s;
    cin>>n;
    vector<tuple<string,ll,ll>> v(n);
    for(ll i=0;i<n;i++){
        cin>>s>>p;
        v[i]=make_tuple(s,-p,i);
    }
    sort(all(v));
    for(ll i=0;i<n;i++) cout<<get<2>(v[i])+1<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        
        // 標準入力の取得
        int N = Integer.parseInt(scan.next());

        List<String> W = new ArrayList<String>(N);
        for (int i = 0; i < N; i++) {
            W.add(scan.next());
        }

        // 重複チェック
        Set<String> Wst = new HashSet<String>(W);
        if(!(Wst.size() == W.size())){
            System.out.println("No");
            return ;
        }
        
        // しりとりできてるかチェック
        for (int i = 0; i < N-1; i++) {
            if(W.get(i).charAt(W.get(i).length() - 1) != W.get(i+1).charAt(0)){
                System.out.println("No");
                return ; 
            }
        }
        System.out.println("Yes");
        return ; 
    }
}


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


struct UnionFind {
    vector<int> par;
    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }
    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
  int N,M;
  cin>>N>>M;
  
  vector<pair<int,int>> ab(M);
  for(int i=0;i<M;++i){
    cin>>ab.at(i).first>>ab.at(i).second;
  }

  int count=0;
  for(int i=0;i<M;++i){
    UnionFind UF(N);
    set<int> connect;
    for(int j=0;j<M;++j){
      if(j!=i){
        UF.unite(ab.at(j).first-1,ab.at(j).second-1);
      }
    }
    for(int k=0;k<N;++k){
      connect.insert(UF.root(k));
    }
    
    if(connect.size()>1){
      ++count;
    }
  }

  cout<<count<<endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func main() {
	var N, X int
	fmt.Scan(&N, &X)
	x := make([]int, N+1)
	x[0] = X
	for i := 0; i < N; i++ {
		fmt.Scan(&x[i+1])
	}
	sort.Ints(x)

	d := make([]int, N)
	for i := 0; i < N; i++ {
		d[i] = x[i+1] - x[i]
	}

	ans := 0
	for i := 0; i < len(d); i++ {
		ans = gcd(ans, d[i])
	}
	fmt.Println(ans)
}


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

int main(){
    map<string, int> dict;
    int n;
    cin >> n;
    string cmd, word;
    for(int i = 0; i < n; i++){
        cin >> cmd >> word;
        if(cmd == "insert")
            dict[word.c_str()] = 1;
        else if(cmd == "find"){
            if(dict[word.c_str()] == 1)
                cout << "yes" << endl;
            else
                cout << "no" << endl;
        }
    }
}

Measured memory_bytes: 47324
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    A = [LI() for i in range(N)]

    dq = []
    heapify(dq)
    
    for i in range(N):
        for j in range(N):
            heappush(dq, (A[i][j], i, j))
    
    # dist matrix
    dist = [[float('inf') if i != j else 0 for i in range(N)] for j in range(N)]
    
    res = 0
    
    while dq:
        d, x, y = heappop(dq)
        equal = True
        for i in range(N):
            tempD = dist[x][i]+dist[i][y]
            if d > tempD:
                print(-1)
                exit()
            elif d == tempD:
                equal = False
    
        dist[x][y] = d
        dist[y][x] = d
    
        if equal:
            res+=d

    print(res)

if __name__ == "__main__":
    main()

Measured memory_bytes: 82868
// #include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <emmintrin.h>

using std::scanf;
using std::printf;
using std::max;

typedef long long ll;

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

int n,m;
const int MAX_N = 5000;
const int MAX_M = 200;
unsigned int a[MAX_N] __attribute__((aligned(16)));
unsigned int b[MAX_N * MAX_M] __attribute__((aligned(16)));
unsigned int mx[MAX_M] __attribute__((aligned(16)));

static inline __m128i __attribute__((always_inline))
po_mm_max_epi32(__m128i a, __m128i b){
  __asm__("pmaxsd %1, %0" : "+x" (a) : "xm" (b));
  return a;
}
// max of two array
// a[i] = max(a[i], b[i])
void vec_chmax(int n, unsigned int *a, unsigned int *b){
  for(int i=0;i<n;i+=4){
    __m128i xx = _mm_load_si128((__m128i*)(a+i));
    __m128i yy = _mm_load_si128((__m128i*)(b+i));
    xx = po_mm_max_epi32(xx,yy);
    _mm_store_si128((__m128i*)(mx+i), xx);
  }
}

unsigned long long tmp[2] __attribute__((aligned(16)));
// sum of array
// Σa[i]
ll vec_sumll(int n, unsigned int *a){
  __m128i x = _mm_setzero_si128();
  __m128i y = _mm_setzero_si128();
  const __m128i zero = _mm_setzero_si128();

  for(int i=0;i<n;i+=4){
    __m128i xx = _mm_load_si128((__m128i*)(a+i));
    __m128i yy = _mm_unpackhi_epi32(xx,zero);
            xx = _mm_unpacklo_epi32(xx,zero);
    x = _mm_add_epi64(x,xx);
    y = _mm_add_epi64(y,yy);
  }
  x = _mm_add_epi64(x,y);
  _mm_store_si128((__m128i*)tmp, x);
  return tmp[0] + tmp[1];
}

int main(){
  scanf("%d%d",&n,&m);
  REP(i,n-1)scanf("%u",a+i);
  REP(i,n)REP(j,m)scanf("%u",&b[MAX_M*i+j]);

  ll ans = 0;
  REP(l,n){
    ll lensum = 0;
    REP(j,m)mx[j]=0;
    vec_chmax(m, mx, b+MAX_M*l);
    ans = max(ans, vec_sumll(m, mx)-lensum);

    FOR(r,l+1,n){
      lensum += a[r-1];
      vec_chmax(m, mx, b+MAX_M*r);
      ans = max(ans, vec_sumll(m, mx)-lensum);
    }
  }
  printf("%lld\n",ans);
  return 0;
}

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

int main() {
    int n, x;
    cin >> n >> x;
    int m[n];
    for (int i=0; i<n; i++) cin >> m[i];
    for (int i=0; i<n; i++) x -= m[i];
    int min = std::numeric_limits<int>::max();
    for (int i=0; i<n; i++) {
        if (min > m[i]) min = m[i];
    }
    int count = n;
    count += x / min;

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll a;
    ld b;
    cin>>a>>b;
    ld c=a*b;
    ll ans=c*1;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3744
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int main() {
	ll N; cin >> N;
	for (int i = 1; i <= 3500; ++i) {
		for (int j = 1; j <= 3500; ++j) {
			ll s = N * i*j;
			ll t = 4 * i*j - i * N - j * N;
			if (t <= 0)continue;
			if (s%t==0&&s/t>0) {
				cout << i << " " << j << " " << s/t << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256