akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <map>
#include <iterator>
#include <queue>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for (int i=(a-1);i>=(b);--i)
#define rrep(i,n) rrepd(i,n,0)
typedef long long ll;
typedef pair<int, int> P;


int main(int argc, const char * argv[]) {

  int a, b;
  cin >> a >> b;
  if (a <= b*2){
    cout << 0 << endl;
    return 0;
  }
  cout << a-(b*2) << endl;

  return 0;
  
}


Measured memory_bytes: 888
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

t = gets.chomp.split("")
t << "x"
(t.size - 1).downto(0) do |i|
  if(t[i] == "?")
    t[i] = "D"
  end
end
puts t[0..(t.size-2)].join

Measured memory_bytes: 33520
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef complex<double> Point;
typedef long long ll;
const ll INF = 114514810000;
const int MOD = 1000000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int v, e;
ll d[105][105];

int main()
{
	cin >> v >> e;
	REP(i, v)REP(j, v) d[i][j] = (i == j ? 0 : INF);
	REP(i, e)
	{
		int a, b, c;
		cin >> a >> b >> c;
		d[a][b] = c;
	}
	REP(k, v)REP(i, v)REP(j, v) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	bool f = true;
	REP(i, v) if (d[i][i] < 0) f = false;
	if (f)
	{
		REP(i, v)
		{
			REP(j, v)
			{
				cout << (d[i][j] > INF/2 ? "INF" : to_string(d[i][j])) << (j==v-1?"\n":" ");
			}
		}
	}
	else puts("NEGATIVE CYCLE");
	return 0;
}

Measured memory_bytes: 1288
#!/usr/bin/env python3
import sys
from collections import defaultdict
sys.setrecursionlimit(10**8)
INF = float("inf")

MOD = 1000000007  # type: int


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.E = defaultdict(list)

    def add_edge(self, f, t, w=1):
        self.E[f].append((t, w))
        self.E[t].append((f, w))


def solve(N: int, x: "List[int]", y: "List[int]"):

    g = Graph(N)
    for xx, yy in zip(x, y):
        g.add_edge(xx-1, yy-1)

    white = [-1]*N
    black = [-1]*N

    def rec(node, pre):
        if white[node] > 0:
            return white[node], black[node]

        # nodeを黒と塗る場合
        bbb = 1
        www = 1
        for t, _ in g.E[node]:
            if t != pre:
                w, b = rec(t, node)
                bbb *= w
                bbb %= MOD
                www *= (w+b) % MOD
                www %= MOD
        black[node] = bbb % MOD
        white[node] = www % MOD
        return white[node], black[node]

    w, b = rec(0, -1)
    print((w+b) % MOD)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N - 1)  # type: "List[int]"
    y = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, x, y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 148480
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
#define ll long long
const ll mod=1e9+7;
const int maxn=1e6+5;
char ss[maxn];
ll f[2*maxn],inv[2*maxn];
ll quick_pow(ll a,int times)
{
    ll res=1;
    while(times)
    {
        if(times&1) res=(res*a)%mod;
        a=(a*a)%mod; times>>=1;
    }
    return res;
}
ll binom(int a,int b)
{
    return f[a]*inv[b]%mod*inv[a-b]%mod;
}
int main()
{
    int k;
    scanf("%d",&k);
    scanf("%s",ss);
    int s=(int)strlen(ss);
    int len=k+s;
    f[0]=1;
    for(int i=1;i<=len;i++)
        f[i]=(f[i-1]*i)%mod;
    inv[len]=quick_pow(f[len],(int)mod-2);
    for(int i=len-1;i>=0;i--)
        inv[i]=inv[i+1]*(i+1)%mod;
    ll ans=0;
    for(int i=s;i<=len;i++)
    {
        ll cur=1;
        int front=i-s,back=len-i;
        cur=cur*quick_pow(25,front)%mod*quick_pow(26,back)%mod;
        cur=cur*binom(i-1,s-1)%mod;
        ans=(ans+cur)%mod;
    }
    printf("%lld\n",ans);
    return 0;
}
/*
5
oof
 
37564
whydidyoudesertme
 */


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

int N;

int main()
{
	cin >> N;
	int ans[] = { 111, 222, 333, 444, 555, 666, 777, 888, 999 };
	for (auto a : ans) {
		if (N <= a) {
			cout << a << endl;
			return 0;
		}
	}
	return 0;
}

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

using namespace std;
#define PB push_back
#define LL long long
#define int LL
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define st first
#define nd second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define VI vector<int>
#define PII pair<int,int>
#define LD long double

template<class C> void mini(C& a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C& a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream &os, vector<T> V){
  os<<"[";for(auto vv:V)os<<vv<<",";return os<<"]";
} 

template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}


#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif


int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  int A,B,C;
  cin>>A>>B>>C;
  int k;
  cin>>k;
  int sum;
  if(!(k & 1)){
     sum = -B + A;
  } else{
    sum = -(A - B); 
  }
  if(abs(sum) > 1e18){
    cout<<"Unfair\n";
  } else{
    cout<<sum<<"\n";
  }

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
#define max(x,y) ((x)>(y)?(x):(y))
int main ()
{
	long long j,ans=0,n,k;
	cin>>n>>k;
	if(k==0)
	{
		cout<<(n*n);
		return 0;
	}
	for(j=k+1;j<=n;j++)
	{
		ans+=(j-k);
		ans+=(n-j)/j*(j-k);
		ans+=max(((n-j)%j-k+1),0);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string.h>
#include <deque>
#define REP(i,j,n) for(int i=j;i<n;i++)
#define SORT(x) sort(x.begin(),x.end())

using namespace std;

int main() {
	int n, m, l;
	cin >> n >> m >> l;
	vector<vector<int>> v1(n, vector<int>(m));
	vector<vector<int>> v2(m, vector<int>(l));
	vector<vector<long>> ans(n, vector<long>(l));

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

	for (int i = 0; i < m; i++) {
		for (int j = 0; j <l ; j++)cin >> v2[i][j];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			long sum = 0;
			for (int k = 0; k < m; k++) {
				sum += v1[i][k] * v2[k][j];
			}
			ans[i][j] = sum;
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			if (j != l - 1) cout << ans[i][j] << " ";
			else cout << ans[i][j] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3156
//C
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int x,n;cin>>x>>n;
    map<int,int> mp;
    rep(i,n){
        int p;cin>>p;
        mp[x-p]++;
    }
    int tmp=0;
    while(true){
        if(mp[tmp]==0){
            cout<<x-tmp<<endl;
            return 0;
        }
        if(mp[-tmp]==0){
            cout<<x+tmp<<endl;
            return 0;
        }
        tmp++;
    }
}

Measured memory_bytes: 3600
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
           
             String Key = sc.next();
        		Key = Key.toUpperCase();
        int sum =0;
        while( true ){
            String T = sc.next();
            if( T.equals( "END_OF_TEXT" ) )
                break;
				T = T.toUpperCase();
            	if(Key.equals(T))
                    sum++;
        }
        System.out.println(sum);
        sc.close();
    }
}


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

int main()
{
  int n;
  string s;
  cin >> n;
  cin >> s;
  
  int x = 0;
  int max = 0;
  for(int i = 0; i < n; ++i)
  {
    if(s[i] == 'I')
    {
      x++;
      if(x > max) max = x;
    }
    else
    {
      x--;
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int n; cin >> n;
	int a[n][2];
	for(int i = 0; i < n; i ++) cin >> a[i][0] >> a[i][1];
	for(int i = 0; i + 2 < n; i ++) {
		int cnt = 0;
		for(int j = i; j < i + 3; j ++) cnt += a[j][0] == a[j][1];
		if(cnt == 3) return cout << "Yes", 0;
	}	
	cout << "No";
	
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mk make_pair
#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef pair <int, int> pii;

vector <ll> dp;
ll ans = 0;
ll mod = 1e9 + 7;
int solve(int v){
	//cout << v << endl;
	if(dp[v] > 1)
		return dp[v];

	for(int i = 3; v - i >= 0; i++)
		dp[v] = (dp[v] + solve(v - i)) % mod;

	return dp[v];
}

int main(){
	int n;
	cin >> n;
	if(n < 3)
		return cout << 0 << endl, 0;
		
	dp.resize(n+1, 1);
	dp[0] = 0, dp[1] = 0, dp[2] = 0, dp[3] = 1;

	cout << solve(n) % mod << endl;
	return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,A,B;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>A>>B;
	if(A+B>N+1) return _P("-1\n");
	if(1LL*A*B<N) return _P("-1\n");
	
	vector<int> T;
	int S=N-A;
	int cur=N;
	FOR(i,A) {
		int num=min(B-1,S)+1;
		S-=num-1;
		FOR(j,num) T.push_back(cur-num+1+j);
		cur-=num;
	}
	reverse(ALL(T));
	FORR(v,T) cout<<v<<" ";
	cout<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  i64 H, W;
  cin >> H >> W;
  if (H == 1 || W == 1) {
    cout << 1 << endl;
    return;
  }
  if (H % 2 == 0) {
    cout << (H / 2) * W << endl;
  } else if (W % 2 == 0) {
    cout << (W / 2) * H << endl;
  } else {
    cout << (H * W + 1) / 2 << endl;
  }
}


Measured memory_bytes: 384
import java.util.Scanner;
 class Main {
    public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    for(int i=1;;i++){
    	int t=sc.nextInt();
    	if(t==0)break;
    	System.out.println("Case "+i+": "+t);
    }   }}

Measured memory_bytes: 33036
import std.stdio;
import std.string, std.conv, std.array, std.algorithm;
import std.uni, std.math, std.container;
import core.bitop, std.datetime;

void main(){
    auto N = readln.chomp.to!int;
    auto A = readln.split.to!(int[]);
    auto ans = int.max;

    foreach(x; -100 .. 101){
        ans = min(ans, calc_dif2(x, A));
    }

    ans.writeln;
}

int calc_dif2(int x, int[] A){
    int ret;
    foreach(a;A){
        ret += (a - x)^^2;
    }
    return ret;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
d = []
A = []
for _ in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))

# print(A)

snuke = [False] * N
for i in range(K):
    for j in range(d[i]):
        snuke[A[i][j] - 1] = True
# print(snuke)
print(snuke.count(False))

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

int main(){
  long long N,ans;
  cin>>N;
  ans=0;
  vector<long long>a(N+1),b(N);
  for(int i=0;i<N+1;i++){
    cin>>a[i];
  }
    for(int i=0;i<N;i++){
    cin>>b[i];
  }
    for(int i=0;i<N;i++){
      if(a[i]<=b[i]){
        ans+=a[i];
        b[i]-=a[i];
        if(a[i+1]<=b[i]){
          ans+=a[i+1];
          a[i+1]=0;
          continue;
        }
        else{
          a[i+1]-=b[i];
          ans+=b[i];
          continue;
        }
      }
      else{
        ans+=b[i];
        continue;
      }
        
  }
    cout<<ans<<endl;
  }

Measured memory_bytes: 1792
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int answer = 0;

            while (true)
            {
                string input = Console.ReadLine();
                string[] array = input.Split(' ');

                int a = int.Parse(array[0]);
                string op = array[1];//??????????????£??\
                int b = int.Parse(array[2]);

                if (op == "?")//??£??\?????????????????§????????£????????????
                    break;

                switch (op)//????????????????????????????¨????
                {
                    case "+": answer = a + b;
                        Console.WriteLine(answer);
                        break;
                    case "-": answer = a - b;
                        Console.WriteLine(answer);
                        break;
                    case "*": answer = a * b;
                        Console.WriteLine(answer);
                        break;
                    case "/": answer = a / b;
                        Console.WriteLine(answer);
                        break;
                }
            }
        }
    }
}

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

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

	vector<int>sumw(n + 1), sume(n + 1);
	sumw[0] = 0;
	sume[0] = 0;
	for (int i = 0;i < n;i++) {
		sumw[i + 1] = (s[i] == 'W') ? sumw[i] + 1 : sumw[i];
		sume[i + 1] = (s[i] == 'E') ? sume[i] + 1 : sume[i];
	}
	int ans = 1e9;
	for (int i = 0;i < n;i++) {
		ans = min(ans, sumw[i] + sume[n] - sume[i + 1]);
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3076
def frac(n):
	r = 1
	for i in range(1,n+1):
		r*=i
	return(r)

def ans(n,k,i):
	if(n-k < i-1):return(0)
	r1 = frac(k-1) // frac(k-i) // frac(i-1)
	r2 = frac(n-k+1) // frac(n-k-i+1) // frac(i)
	
	return(r1*r2)

n,k = map(int,input().split())

for i in range(1,k+1):
	print(int(ans(n,k,i))%1000000007)


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

void dfs(vector<array<int8_t, 8000>>& dp, const vector<int>& a, int i, int z) {
    if (dp[i][z]) return; else dp[i][z] = 1;
    if (--i >= 0) {
        dfs(dp, a, i, abs(z - a[i]));
        dfs(dp, a, i, z + a[i]);
    }
}

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

    string s;
    cin >> s;

    s.push_back('T');
    int n = s.size();

    int x, y;
    cin >> x >> y;

    vector<int> a[2];
    int c = 0, d = 0, f = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'F') {
            c++;
        } else {
            if (f == 0) {
                x -= c;
                f = 1;
            } else {
                a[d].push_back(c);
            }
            c = 0;
            d ^= 1;
        }
    }

    int b = 0;
    for (int d = 0; d < 2; d++) {
        int m = a[d].size();
        vector<array<int8_t, 8000>> dp(m + 1);
        dfs(dp, a[d], m, 0);

        if (dp[0][abs(d == 0 ? x : y)]) b++;
    }

    cout << (b == 2 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 31616
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
count = 0
k=0
t=0

while t<len(A):
    if A[t] == k+1:
            k += 1
            t += 1
    else:
            count += 1
            t += 1
if count == N:
    print(-1)
else:
    print(count)


Measured memory_bytes: 25912
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(x) for(auto it=(x).begin();it!=(x).end();it++) 
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
 
using namespace std;

int main(){
    int n,x;
    cin>>n>>x;
    int mi=INF;
    rep(i,0,n){
        int xx; cin>>xx;
        mi=min(xx,mi);
        x-=xx;
    }
    
    cout<<n+x/mi<<endl;
    
    
    
    return 0;
}

Measured memory_bytes: 256
import heapq
import sys

N = int(input())
d = [[] for i in range(N)]
for i in range(N - 1):
	a, b, c = map(int, input().split())
	d[a - 1].append([b - 1, c])
	d[b - 1].append([a - 1, c])
Q, K = map(int, input().split())
e = [[0, K - 1]]
f = [False] * N
g = [sys.maxsize] * N
g[K - 1] = 0
while len(e):
	h = heapq.heappop(e)
	f[h[1]] = True
	for i in d[h[1]]:
		if not f[i[0]]:
			if g[h[1]] + i[1] < g[i[0]]:
				g[i[0]] = g[h[1]] + i[1]
				heapq.heappush(e, [g[i[0]], i[0]])
for i in range(Q):
	x, y = map(int, input().split())
	print(g[x - 1] + g[y - 1])

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

int main() {
  int N, scoreA, scoreB, ans;
  
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  scoreA = 0;
  scoreB = 0;
  ans = 0;
  for (int i = 0; i < N - 1; i += 2) {
    scoreA += a.at(i);
    scoreB += a.at(i + 1);
  }
  
  if (N % 2 == 1) {
    scoreA += a.at(N - 1);
  }
  
  ans = scoreA - scoreB;
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 110 ;
typedef long long ll ;
ll a[20][N] ;
int main()
{
  for(int i = 1; i <= 9 ;i ++)
    a[1][++ a[1][0]] = i ;
  int cnt = 9 ;
  for(int i = 2 ; i <= 15 ;i ++)
   {
     for(int j = 1 ;j <= a[i - 1][0] ;j ++)
      {
        ll t = a[i - 1][j] ;
        t %= 10 ;
        if(t - 1 >= 0) a[i][++ a[i][0]] = a[i - 1][j] * 10 + t - 1 , cnt ++ ;
        a[i][++ a[i][0]] = a[i - 1][j] * 10 + t , cnt ++ ;
        if(t + 1 <= 9) a[i][++ a[i][0]] = a[i - 1][j] * 10 + t + 1 , cnt ++ ;
        if(cnt > 1e5)
         break ;
      }
    if(cnt > 1e5) break ;
   }
   int k ;
   cin >> k ;
   cnt = 0 ;
   for(int i = 1; i <= 10 ;i ++)
    {
      for(int j = 1 ;j <= a[i][0] ;j ++)
       {
         cnt ++ ;
         if(cnt == k)
          {
            cout << a[i][j] << endl ;
            return 0 ;
          }
       }
    }
  return 0 ;
}


Measured memory_bytes: 6400
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

// rep(i, 100) { cout << i << endl; } => 0 1 2 ... 99
#define rep(i, n) for(int i = 0, i##_len = (n); i < (int)n; i++)

// std::sort(all(v));
#define all(x) (x).begin(), (x).end()

// long long int
using ll = long long;

// utility to cast return value of size function to int
#define SZ(x) ((int)(x).size())

// VS defines "_DEBUG" macro when debug configuration.
#if _DEBUG
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define dump(x)
#define debug(x)
#endif

// update max
template<class T>bool chmax(T & prov, const T & cur)
{
	if (cur > prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

// update min
template<class T>bool chmin(T & prov, const T & cur)
{
	if (cur < prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

int main()
{
	int N;
	cin >> N;
	vector<ll> A(N);
	rep(i, N)
	{
		cin >> A[i];
	}

	struct Memo
	{
		int val;
		int count;
	};

	vector<Memo> memo_l(N);
	vector<Memo> memo_r(N);
	rep(i, N)
	{
		memo_l[i].val = i - A[i];
		memo_l[i].count = 1;
		memo_r[i].val = i + A[i];
		memo_r[i].count = 1;
	}

	sort(all(memo_l), [](auto& l, auto& r) { return l.val < r.val; });
	sort(all(memo_r), [](auto& l, auto& r) { return l.val < r.val; });

	vector<Memo> new_memo_l;
	new_memo_l.push_back(memo_l[0]);
	for (int i = 1; i < N; i++)
	{
		if (memo_l[i].val == new_memo_l.back().val)
		{
			new_memo_l.back().count++;
		}
		else
		{
			new_memo_l.push_back(memo_l[i]);
		}
	}
	vector<Memo> new_memo_r;
	new_memo_r.push_back(memo_r[0]);
	for (int i = 1; i < N; i++)
	{
		if (memo_r[i].val == new_memo_r.back().val)
		{
			new_memo_r.back().count++;
		}
		else
		{
			new_memo_r.push_back(memo_r[i]);
		}
	}

	ll ans = 0;
	for(int r = 0, l = 0; l < new_memo_l.size() && r < new_memo_r.size();)
	{
		if (new_memo_l[l].val == new_memo_r[r].val)
		{
			ans += (ll)new_memo_l[l].count * (ll)new_memo_r[r].count;
			l++;
			r++;
		}
		else if (new_memo_l[l].val > new_memo_r[r].val)
		{
			r++;
		}
		else
		{
			l++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 12388
import java.util.*;

class Main{

    public static void main(String[] args){

	Scanner sc = new Scanner(System.in);

	int N = sc.nextInt();

	int[] B = new int[N-1];

	for(int i=0; i<N-1; i++){

	B[i] = sc.nextInt();	

  }

	int[] A = new int[N];

	for(int i=0; i<N-2; i++){

	if(B[i]==B[i+1]){	

	A[i+1] = B[i];

  }	

	else if(B[i]<B[i+1]){

	A[i+1] = B[i];

  }  

	else if(B[i]>B[i+1]){

	A[i+1] = B[i+1];

  }

 }

	A[0] = B[0];

	A[N-1] = B[N-2];

	int ans = 0;

	for(int i=0; i<N; i++){

	ans += A[i];

   }

	System.out.println(ans);

 }
}

Measured memory_bytes: 23252
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($exp_input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                let start = std::time::Instant::now();
                let input = solve($exp_input);
                let end = start.elapsed();
                assert_eq!(input, $output, "{}.{:03}", end.as_secs(), end.subsec_millis());
                assert!(end.as_secs() <= 2, "expected_sec: {}sec, actual_sec: {}sec", 2, end.as_secs());
                assert!(end.as_secs() <= 1, "expected_sec: {}sec, actual_sec: {}sec", 1, end.as_secs());
                assert!(end.subsec_millis() <= 10, "expected_ms: {}ms, actual_ms: {}ms", 10, end.subsec_millis());
                assert!(end.subsec_millis() <= 2, "expected_ms: {}ms, actual_ms: {}ms", 2, end.subsec_millis());
            )*
        }
    };
}

test! {
r#"4 3"# => r#"3333"#,
r#"7 7"# => r#"7777777"#,
}

fn solve(src: &str) -> String {
    let mut src_iter = src.split_whitespace();
    input! {
        source = src_iter,
        a: usize,
        b: usize,
    }

    let a_b = (0..b).into_iter().map(|_| a.to_string()).collect::<String>();
    let b_a = (0..a).into_iter().map(|_| b.to_string()).collect::<String>();

    if a_b > b_a {
        b_a
    } else {
        a_b
    }
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  if((A > B && C > B && A > C)||(B > A && C > A && B > C)){
    cout << "Yes" << endl;
  }
      else {  
        cout << "No" << endl;
      }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

template<typename T>
map<T, int> prime_factor(T n) {
    map<T, int> res;
    for (long long i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

int calc(int e) {
    repr(i, 1, e + 2) {
        if (e < i * (i + 1) / 2)
            return i - 1;
    }
    return -1;
}

int main() {
    ll n;
    cin >> n;
    auto ps = prime_factor(n);
    int ans = 0;
    for (auto [_, cnt]: ps) {
        ans += calc(cnt);
        //cout << cnt << " " << calc(cnt) << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

int main()
{
    vector<ll> x(2), y(2);
    cin >> x[0] >> x[1] >> y[0] >> y[1];
    if (x[0] < 0 && x[1] > 0)
    {
        x.push_back(0);
    }
    if (y[0] < 0 && y[1] > 0)
    {
        y.push_back(0);
    }
    ll maxi = -LINF;
    for (ll xx : x)
    {
        for (ll yy : y)
        {
            maxi = max(maxi, xx * yy);
        }
    }
    cout << maxi << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h1,a1,h2,a2;
	cin>>h1>>a1>>h2>>a2;
	bool flag=1;
	while(h1>0&&h2>0)
	{
		if(flag) h2-=a1;
		else h1-=a2;
		flag=!flag;
	}
	if(h1<=0) cout<<"No\n";
	else cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 3652
import bisect
import collections
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 62


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


def llmi(n):
    return [lmi() for _ in range(n)]


N, K = lmi()

_sum = [0]
for i in range(1, N + 1):
    _sum.append(_sum[-1] + i)
# 10**100 + k    k = 0,1,..,N
ans = 0
for k in range(K, N + 2):
    # k vals
    max_val = _sum[-1] - _sum[max(0,N  - k)]
    min_val = _sum[k - 1]
    # print(k, max_val, min_val)
    ans += max_val - min_val + 1
print(ans%ACMOD)


Measured memory_bytes: 81824
import std.conv, std.functional, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const K = readLong();
      const A = readLong();
      const B = readLong();
      
      long ans = 1 + K;
      if (A <= B && A - 1 <= K) {
        long tmp = A;
        tmp += (B - A) * ((K - (A - 1)) / 2);
        if ((K - (A - 1)) % 2 != 0) {
          tmp += 1;
        }
        chmax(ans, tmp);
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}

Measured memory_bytes: 256
#include <iostream>
int main()
{
    std::string s;
    std::cin >> s;
    int j = 0;
    for (std::size_t i = 1; i < s.length(); i++)
    {
        if (s[i] == s[i - 1])
            j = j + 1;
    }
    if (j > 0)
        std::cout << "Bad";
    else
        std::cout << "Good";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver2.2.0
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){Vout(a[lY]);}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MOD 1000000007  //  10^9 + 7
using namespace std;
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void uniq(Vi &v){sort(ALL(v)); v.erase(unique(ALL(v)),v.end());}  //  uniqのやつ
 
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
 
signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n;
  cin >> n;
  Vi a(n),b(n),c(n);
  Vin(a);
  Vin(b);
  Vin(c);
  
  Vi ansa(n),ansc(n);
  
  sort(ALL(a));
  sort(ALL(b));
  sort(ALL(c));
  
  int now,ct=0;
  
  rep(i,0,n){
    rep(j,ct,n){
      if(a[j]<b[i]){ct++;continue;}
      else{ansa[i]=ct;break;}
    }
    if(ct==n&&a[n-1]<b[i]) ansa[i]=ct;
  }
//  Vout(ansa);
  
  reverse(ALL(b));
  reverse(ALL(c));
  ct=0;
  
  rep(i,0,n){
    rep(j,ct,n){
      if(c[j]>b[i]){ct++;continue;}
      else{ansc[i]=ct;break;}
    }
    if(ct==n&&c[n-1]>b[i]) ansc[i]=ct;
  }
//  Vout(ansc);
  reverse(ALL(ansc));
  
  int ans = 0;
  
  rep(i,0,n){
    ans += ansa[i]*ansc[i];
  }
  
  cout << ans << endl;
  return 0;
}

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

int main() {
	int n;
	int s[13] = {0};
	int h[13] = {0};
	int c[13] = {0};
	int d[13] = {0};

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		char suit;
		int rank;
		cin >> suit;
		cin >> rank;
		switch (suit) {
		case 'S':
			s[rank-1] = 1;
			break;
		case 'H':
			h[rank-1] = 1;
			break;
		case 'C':
			c[rank-1] = 1;
			break;
		case 'D':
			d[rank-1] = 1;
			break;
		}
	}

	for (int i = 0; i < 13; i++)
	{
		if (!s[i])
		{
			cout << 'S' << ' '<<i+1<<endl;
		}
	}

	for (int i = 0; i < 13; i++)
	{
		if (!h[i])
		{
			cout << 'H' << ' ' << i + 1 << endl;
		}
	}

	for (int i = 0; i < 13; i++)
	{
		if (!c[i])
		{
			cout << 'C' << ' ' << i + 1 << endl;
		}
	}

	for (int i = 0; i < 13; i++)
	{
		if (!d[i])
		{
			cout << 'D' << ' ' << i + 1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3052
from collections import deque
n = int(input())
a = [int(i) for i in input().split()]
b = deque()
f = True
for i in range(n):
    if f: b.append(a[i])
    else: b.appendleft(a[i])
    f = not f
if i % 2 == 0: b.reverse()
print(*b)


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

using namespace std;

int main()
{
    int n,number,q;
    q=0;
    number = 0;
    string s;
    cin>>n>>s;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        if(s.at(i)=='I')
        {
            number++;
            arr[q]=number;
            q++;
        }else if(s.at(i)=='D')
        {
            number--;
            arr[q]=number;
            q++;
        }
    }
    int temp;
    for(int a=0;a<n;a++)
    {
        for(int b=0;b<a;b++)
        {
            if(arr[a]>=arr[b])
            {
                temp = arr[a];
                arr[a] = arr[b];
                arr[b] = temp;
            }
        }
    }
    if(arr[0]>0)
    {
        cout<<arr[0];
    }else
    {
        cout<<"0";
    }
    return 0;
}


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

string s, t;
int ans = INT_MAX;

void solve() {
    cin >> s >> t;
    int n = s.length();
    int k = t.length();
    for (int i=0; i+k<=n; i++) {
        int subans = 0;
        for (int j=0; j<k; j++) subans += (s[i+j] != t[j]);
        ans = min(ans, subans);
    }
    cout << ans << '\n';
}

int main() {
    // int t; cin >> t;
    // while(t--)
        solve();
}

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <queue>
#include <iomanip>
#include <iterator>

#define MOD 1000000007
#define INF 1000000001

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}


int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    vector<int> D(N);
    for (int i = 0; i < N; ++i) {
        cin >> D[i];
    }
    sort(D.begin(), D.end());
    // print(D);

    vector<int> hours = {0};
    for (int i = 0; i < N; ++i) {
        int d = (i % 2 == 0) ? D[i] : 24 - D[i];
        hours.push_back(d);
    }

    sort(hours.begin(), hours.end());
    // print(hours);

    int ans = 24;
    for (int i = 0; i < N+1; ++i) {
        int d = abs(hours[(i+1)%(N+1)] - hours[i]);
        ans = min(ans, min(d, 24 - d));
        // print(i, (i+1)%N, min(d, 24 - d), ans);
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<int> v(n);
    REP(i,n) cin>>v[i];
    int ans = 0;
    FOR(i,1,n-1){
        if(v[i-1]<v[i] && v[i]<v[i+1]) ans++;
        else if(v[i-1]>v[i] && v[i]>v[i+1]) ans++;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
s = []
for _ in range(h):
  s.append(input().strip())

visited = [[False for _ in range(w)] for _ in range(h)]

ans = 0
for i in range(h):
  for j in range(w):
    if visited[i][j]:
      continue
    bc = 0
    wc = 0
    visited[i][j] = True
    node = [(i, j)]
    while node:
      ci, cj = node[0]
      node = node[1:]
      if s[ci][cj] == '#':
        bc += 1
      else:
        wc += 1
      if ci - 1 >= 0 and s[ci][cj] != s[ci-1][cj]:
        if not visited[ci-1][cj]:
          visited[ci-1][cj] = True
          node.append((ci-1, cj))
      if ci + 1 <= h-1 and s[ci][cj] != s[ci+1][cj]:
        if not visited[ci+1][cj]:
          visited[ci+1][cj] = True
          node.append((ci+1, cj))
      if cj - 1 >= 0 and s[ci][cj] != s[ci][cj-1]:
        if not visited[ci][cj-1]:
          visited[ci][cj-1] = True
          node.append((ci, cj-1))
      if cj + 1 <= w-1 and s[ci][cj] != s[ci][cj+1]:
        if not visited[ci][cj+1]:
          visited[ci][cj+1] = True
          node.append((ci, cj+1))
    ans += bc * wc

print(ans)


Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define pii pair<ll,ll>
#define pi pair<int ,int> 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i,a,n) for(int i=a;i>=n;i--)
#define F first
#define S second
int main()
{    
    
   string s;
   cin>>s;
   ll n=s.length();
   string ans="";
   REP(i,0,n)
   {
       ans+='x';
   }
   cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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; }

int main() {
  int n,k;
  cin>>n>>k;
  vi p(n);
  REP(i, n) cin>>p[i];
  sort(all(p));
  int ans = 0;
  REP(i, k) ans += p[i];
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3624
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())

A = [0 for _ in range(M)]
B = [0 for _ in range(M)]
for i in range(M):
    A[i] , B[i] = map(int, input().split())
    A[i] -= 1
    B[i] -= 1






uf = UnionFind(N)
for i in range(M):
    uf.union(A[i], B[i])
print(uf.group_count()-1)

Measured memory_bytes: 18356
#include <stdio.h>
#include <complex>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef complex<double> P;

double cross(const P& a, const P& b) { return imag(conj(a)*b); }

bool same(const P& a, const P& b, const P& c, const P& p) {
    return cross(b-a, c-a) * cross(b-a, p-a) >= 0;
}

bool in(const P& a, const P& b, const P& c, const P& p) {
    return same(a, b, c, p) && same(b, c, a, p) && same(c, a, b, p);
}

int main() {
    double x1, y1, x2, y2, x3, y3, xp, yp;
    while (scanf("%lf%lf", &x1, &y1) != EOF) {
        scanf("%lf%lf", &x2, &y2);
        scanf("%lf%lf", &x3, &y3);
        scanf("%lf%lf", &xp, &yp);
        const bool ans = in(P(x1, y1), P(x2, y2), P(x3, y3), P(xp, yp));
        puts(ans ? "YES" : "NO");
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  string s;
  cin >> s;
  int n = s.size();
  string ans = s[0] + to_string(n-2) + s[n-1];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[int(x) for x in input().split()]

dic1={}
dic2={}
for i in range(n):
  if i+1+a[i] not in dic1:
    dic1[i+1+a[i]]=1
  else:
    dic1[i+1+a[i]]+=1

for i in range(n):
  if i+1-a[i] not in dic2:
    dic2[i+1-a[i]]=1
  else:
    dic2[i+1-a[i]]+=1

ans=0

for i in dic1:
  if i not in dic2:
    continue

  ans+=dic1[i]*dic2[i]
print(ans)

Measured memory_bytes: 145072