akhauriyash/Code-Regression huggingface dataset:
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    // 数値の配列を作る
    const numList0 = input[0].split(' ').map(x => parseInt(x, 10));
    const N = numList0[0];
    const L = numList0[1];

    // 初項と末項を求める
    const a = L;
    const l = L + N - 1;

    // 符号が変わっていたら0があるので取り除いても結果は変わらない
    if (a <= 0 && l >= 0) {
        const result1 = N * (a + l) / 2;
        console.log(result1);
    } else {
        // 符号が変わっていない場合は絶対値が小さい方を取り除く
      	if (Math.abs(a) > Math.abs(l)) {
          const l2 = l - 1;
          const result2 = (N - 1) * (a + l2) / 2;
          console.log(result2);
        } else {
        	const a2 = L + 1;
        	const result3 = (N - 1) * (a2 + l) / 2;
        	console.log(result3);
        }
    }
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <iostream>
#include <iomanip>
/*cout<<setprecision(5)<<ret<<endl;で、数字部分を計5桁表示かつゼロ埋め無*/
/*cout<<fixed<<setprecision(5)<<ret<<endlで、小数部のみ5桁表示かつゼロ埋め有*/
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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; }

/* [Shift+Command+b]（コンパイル）ー＞[Ctrl+Shift+^]（ターミナル起動）ー＞[./a.out] */


//////////////////
//  A
int main(void){
    string a;cin>>a;
    sort(a.begin(),a.end());
    if(a[0]==a[1] && a[2]==a[3] && a[0]!=a[2]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}
//////////////////
//  B
/*int main(void){

    return 0;
}*/
//////////////////
//  C
/*int main(void){

    return 0;
}*/
//////////////////
//  D
/*int main(void){

    return 0;
}*/
//////////////////
//  E
/*int main(void){

    return 0;
}*/
//////////////////
//  F
/*int main(void){

    return 0;
}*/


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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  if(N == 1) cout << "Hello World" << endl;
  else {
    int A,B;
    cin>>A>>B;
    cout << A+B << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);

int main(){
	int n;cin>>n;
    vector<pair<ll,int>>sum;
    vi a(n),b(n);
    rep(i,n){
        cin>>a[i]>>b[i];
        sum.push_back({a[i]+b[i],i});
    }
    sort(been(sum));
    ll aok =0,tkh=0;
    rep(i,n){
        if(i%2==0){
            tkh+=a[sum[n-1-i].second];
        }
        else{
            aok+=b[sum[n-1-i].second];
        }
    }
    cout<<tkh-aok<<endl;
}

Measured memory_bytes: 6136
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <cstring>
#include <string>
#include <bitset>
#include <stdlib.h>
#include <time.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef unsigned long long ull;
typedef set<int>::iterator SI;

#define st first
#define sd second
#define mkp make_pair
#define pb push_back
void wenjian(){freopen("concatenation.in","r",stdin);freopen("concatenation.out","w",stdout);}
void tempwj(){freopen("hash.in","r",stdin);freopen("hash.out","w",stdout);}
ll gcd(ll a,ll b){return b == 0 ? a : gcd(b,a % b);}
ll qpow(ll a,ll b,ll mod){a %= mod;ll ans = 1;while(b){if(b & 1)ans = ans * a % mod;a = a * a % mod;b >>= 1;}return ans;}
struct cmp{bool operator()(const pii & a, const pii & b){return a.second > b.second;}};
int lb(int x){return  x & -x;}

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 9901;
 
const int M = 10000007;
const int maxn = 2e5+5;
int a[maxn];
int b[maxn];
ll sum[maxn];
ll sumb[maxn];
int main()
{
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	for (int i = 1; i <= n; i ++ )
	{
		scanf("%d",&a[i]);
		sum[i] = sum[i - 1] + a[i];
	}
	for (int i = 1; i <= m; i ++ )
	{
		scanf("%d",&b[i]);
		sumb[i] = sumb[i - 1] + b[i];
	}
	int ans =0 ;
	for (int i = 0; i<= n; i ++ )
	{
		// printf("%d %lld\n",k,sum[i]);
		if(sum[i] > k)
			break;
		int s = k - sum[i];
		int y = lower_bound(sumb, sumb + 1 + m,s) - sumb;
		if(y > m)
			y = m;
		if(sumb[y] > s)
			y -- ;
		// printf("%d\n",y);
		ans = max(ans,i + y);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 7908
[N,M] = map(int, raw_input().split())
sl = []
for i in range(N):
    sl.append(map(int, raw_input().split()))
pl = []
for i in range(M):
    pl.append(map(int, raw_input().split()))
ans = []
for (x,y) in sl:
    dmin = 400000001
    imin = -1
    for (i, (px, py)) in enumerate(pl):
        d = abs(x - px) + abs(y - py)
        if(d < dmin):
            dmin = d
            imin = i
    ans.append(imin+1)
for i in ans:
    print i


Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
 
#define mem(dp,a)       memset(dp,a,sizeof dp)
#define ninja           ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb(x)           push_back(x)
#define mp(x,y)         make_pair(x,y)
#define all(c)          c.begin(), c.end()
#define ff              first
#define ss              second
#define nl              '\n'
#define inf             1e9+7
 
int main()
{
	ninja
	int t; //cin>>t;
	t=1;
	while(t--)
	{
		int n; cin>>n;
		vector<int> v(n);
		for(int i=0;i<n;i++)
			cin>>v[i];

		int res=inf,s1=0;
		for(int i=0;i<n;i++)
		{
			s1+=v[i];int s2=0;
			for(int j=i+1;j<n;j++){
				s2+=v[j];
			}
			res = min(res,abs(s1-s2));
		}
		cout<<res;
	}
}


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

vector<P>g[60];
vector<int>es;

bool dfs(int v, int tv, int p=-1){
  //aがbに到達した
  if(v==tv)return true;
  for(P u:g[v]){
    if(u.first==p)continue;
    //aからbまでの経路はtrue(esに経路が入る)
    if(dfs(u.first,tv,v)){
      es.push_back(u.second);
      return true;
    }
  }
  return false;
}

int main(){
  int n; cin>>n;
  rep(i,n-1){
    int a,b; cin>>a>>b;
    a--; b--;
    g[a].push_back(P(b,i));
    g[b].push_back(P(a,i));
  }
  int m; cin>>m;
  vector<ll>Eset(m);
  rep(i,m){
    int a,b; cin>>a>>b;
    a--; b--;
    es=vector<int>();
    dfs(a,b);
    //辺のidをlong longで管理(1ならその辺を含む)
    for(int bit:es){
      Eset[i]|=1LL<<bit;
    }
  }
  //包除原理
  ll ans=0;
  rep(i,1<<m){
    ll mask=0;
    //条件の辺を白で塗る
    rep(j,m){
      if(i>>j&1)mask|=Eset[j];
    }
    int white=__builtin_popcountll(mask);
    ll cnt=1LL<<(n-1-white);
    int pc=__builtin_popcount(i);
    if(pc%2==0)ans+=cnt;
    else ans-=cnt;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    print(max(0, a - 2 * b))
    return

#B
def B():
    n = II()
    d = LI()
    ans = 0
    for i in range(n):
        for k in range(i+1, n):
            ans += d[i] * d[k]
    print(ans)
    return

#C
def C():
    n = II()
    s = S()
    i = 0
    ans = 1
    for i in range(1, n):
        if s[i - 1] == s[i]:
            continue
        ans += 1
    print(ans)
    return

#D
def D():
    n = II()
    l = LI()
    l.sort()
    ans = 0
    for i in range(n - 1, 0, -1):
        for k in range(i - 1, -1, -1):
            ab = l[i] - l[k]
            c = max(0, k - bisect_right(l, ab))
            ans += c
    print(ans)
    return

#E
def E():
    n, m, l = LI()
    dist = [[inf] * n for i in range(n)]

    for _ in range(m):
        a, b, c = LI_()
        c += 1
        if c > l:
            continue
        dist[a][b] = c
        dist[b][a] = c

    supply = [[n] * n for i in range(n)]
    for k in range(n):
        distk = dist[k]
        for i in range(n):
            if i == k:
                continue
            disti = dist[i]
            distik = dist[i][k]
            for j in range(i + 1, n):
                if distik + distk[j] < disti[j]:
                    disti[j] = distik + distk[j]
                    dist[j][i] = disti[j]

    lis = [[] for i in range(n)]
    for i in range(n):
        for j in range(i + 1, n):
            if dist[i][j] <= l:
                supply[i][j] = 0
                supply[j][i] = 0
                lis[i].append(j)
                lis[j].append(i)

    for i in range(n):
        q = []
        for k in lis[i]:
            heappush(q, (0, k))
        supplyi = supply[i]

        while q:
            time, p = heappop(q)
            for k in lis[p]:
                if supplyi[k] > time + 1:
                    supplyi[k] = time + 1
                    heappush(q, (time + 1, k))

    q = II()
    for _ in range(q):
        s, t = LI_()
        if dist[s][t] == inf:
            print(-1)
            continue
        else:
            print(supply[s][t])
    return


#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 40048
package main

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

func main() {
	n, k := ScanInt64(), ScanInt64()
	m := make(map[int64]bool)

	for !m[n%k] {
		m[n%k] = true
	}

	r := n % k
	r1 := abs(k - (n % k))
	P(Mn(r, r1))
}

/*********************** I/O ***********************/

var in *bufio.Scanner
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }

func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }

func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
ll N, S, W, Q;
ll mod;
ll ten[200001];
ll inv[200001];
ll beki(ll a, ll b, ll mod = Q) {
    if(b == 0) return 1;
    ll ret = beki(a, b / 2, mod);
    ret = ret * ret % mod;
    if(b & 1) ret = ret * a % mod;
    return ret;
}
vector<ll> a;

void generator() {
    a.resize(N);
    ll g = S;
    for(int i = 0; i < N; i++) {
        a[i] = (g / 7) % 10;
        if(g % 2 == 0) g = g / 2;
        else g = (g / 2) ^ W;
    }
}

ll f(ll l, ll r) {
    if(l == r) return 0;
    if(r == l + 1) {
        //cerr << "one: " << l << " "<< (a[l] % Q == 0) << endl;
        return (a[l] % Q == 0) && (a[l] != 0);
    }
    ll ans = 0;
    ll mid = (l + r) / 2;
    map<ll, ll> mp;
    ll now = 0;
    ll Total = 0;
    for(int i = mid - 1; i >= l; i--) {
        now += beki(10, i - mid + 1) * a[i];
        now %= mod;
        //cerr << i << " " << now << endl;
        if(a[i] != 0) {
            mp[now]++;
            Total++;
            //cerr << i << " " << now << endl;
        }
    }
    now = 0;
    for(int i = mid; i < r; i++) {
        now *= 10;
        now += a[i];
        now %= mod;
        if(10 % Q != 0) {
            ll tmp = Q - now;
            tmp %= mod;
            //ll tmp2 = ten[i + 1 - mid];
            tmp *= inv[i+1-mid];
            tmp %= mod;
            //cerr << i << " " << now << " " << tmp << " " << mp[tmp] << endl;
            ans += mp[tmp];
        } else {
            if(now % Q == 0) {
                ans += Total;
            }
        }
    }
    //cerr << "sum: " << l << " " << mid << " " << r << " " << ans << endl;
    return ans + f(l, mid) + f(mid, r);
}

void solve() {
    generator();
    for(ll i = 1; i <= 2e5; i++) {
        ten[i] = ten[i-1] * 10 % mod;
        //inv[i] = beki(ten[i], mod - 2);
    }
    inv[200000] = beki(ten[200000], mod - 2);
    for(ll i = 2e5 - 1; i >= 0; i--) {
        inv[i] = inv[i+1] * 10 % mod;
    }
    /*
    for(int i = 0; i < N; i++) cerr << a[i] << " ";
    cerr << endl;
    */
    cout << f(0, N) << endl;
}

int main() {
    //cout.precision(10);
    ten[0] = 1;
    inv[0] = 1;
    while(cin >> N >> S >> W >> Q) {
        mod = Q;
        if(N == 0) break;
        solve();
    }
    return 0;
}


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

using namespace std;

long long N, anx, any, anv;
vector<long long> x, y, h, zx, zy;


bool check()
{
    for (int i = 0; i < (int) zx.size(); ++i) {
        if (anv > abs(zx[i] - anx) + abs(zy[i] - any)) return false;
    }
    return true;
}

void solve()
{
    for (int cx = 0; cx <= 100; ++cx) for (int cy = 0; cy <= 100; ++cy) {
        bool ok = true;
        long long v = abs(cx-x[0]) + abs(cy-y[0]) + h[0];
        if (v == 0) continue;
        for (int i = 1; i < (int) x.size() && ok; ++i) {
            long long w = abs(cx-x[i]) + abs(cy-y[i]) + h[i];
            if (v != w) ok = false;
        }
        if (ok) {
            anx = cx, any = cy, anv = v;
            if (check()) {
                cout << anx << ' ' << any << ' ' << anv << endl;
                return;
            }
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N;
    for(int i = 0 ; i < N ; i++){
        int X, Y, H;
        cin >> X >> Y >> H;
        if (H) {
            x.push_back(X);
            y.push_back(Y);
            h.push_back(H);
        } else {
            zx.push_back(X);
            zy.push_back(Y);
        }
    }
    solve();
    return 0;
}


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

int main(){
  int N;
  vector<int> a(10000); 
  cin >> N;
  
  int i;
  for(i = 0;i < N;i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
 
  int alice = 0;
  int j;
  for(j = 0;j < N;j += 2){
    alice += a.at(j);
  }
  
  int bob = 0;
  int k;
  for(k = 1;k < N;k += 2){
    bob += a.at(k);
  }
  
  int sa = alice - bob;
  cout << sa << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define nfs ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,a,b) for(i=a;i>=b;i--)
#define m_p make_pair
#define p_b push_back
#define MOD 1000000007
int main()
{
	nfs;
	int t;
	t=1;
//	cin >> t;

	while(t--)
	{
		ll N,B,A;
		cin >> N >> A >> B;
		ll i;
		ll e=0,m=0,h=0;
		F(i,0,N)
		{
			ll x;
			cin >> x;
			if(x> B)
			{
				h++;
			}
			else if(x<=A)
			{
				e++;
			}
			else
			{
				m++;
			}
		}
		cout << min(min(e,m),h)<<endl;
		
	}
	return 0;

}



Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input!{
        x: i32,
    }

    match x {
        0 => println!("{}", 1),
        1 => println!("{}", 0),
        _ => unreachable!(),
    }
}


Measured memory_bytes: 2080
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

//桁DP
//dp[i][j] -> あまりj のカウント数
//2桁のときの疑問は解消->足しても0
int main() {

    string S;
    cin >> S;

    ll dp[105000][13];

    REP(i,105000)
    {
        REP(j,13)
        {
            dp[i][j] = 0;
        }
    }

    ll mul = 1;

    //S.size()-1 z = 1;
    //S.size()-2 z = 2;
    dp[0][0] = 1;
    //各文字
    for(ll i = S.size() - 1; i >= 0; --i)
    {
        ll z = (S.size() - 1) - i;
        //?か
        if(S[i] == '?')
        {
            for(ll k = 0; k <= 9; ++k)
            {
                for(ll j = 0; j < 13; ++j)
                {
                    dp[z+1][(k * mul + j) % 13] += dp[z][j];
                    dp[z+1][(k * mul + j) % 13] %= MOD;
                }
            }
        }
        else
        {
            ll k = S[i] - '0';
            for(ll j = 0; j < 13; ++j)
            {
                //
                dp[z+1][(k * mul + j) % 13] += dp[z][j];
                dp[z+1][(k * mul + j) % 13] %= MOD;
            }  
        }
        mul *= 10;
        mul %= 13;
    }

    ll res = dp[S.size()][5];

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

Measured memory_bytes: 11136
#include<iostream>
using namespace std;
int main(){
    int n,x;
    int card[5][14];
    cin>>n;
    char a;
    
    for(int i=1;i<=4;i++){
        for(int j=1;j<=13;j++){
            card[i][j]=0;
        }
    }
    for(int i=1;i<=n;i++){
        cin>>a>>x;
        if(a=='S'){
            card[1][x]=1;
        }
        else if(a=='H'){
            card[2][x]=1;
        }
        else if(a=='C'){
            card[3][x]=1;
        }
        else if(a=='D'){
            card[4][x]=1;
        }
    }
    for(int i=1;i<=4;i++){
        for(int j=1;j<=13;j++){
            if(card[i][j]==0){
                if(i==1){
                    cout<<'S'<<" "<<j<<endl;
                }
                else if(i==2){
                    cout<<'H'<<" "<<j<<endl;
                }
                else if(i==3){
                    cout<<'C'<<" "<<j<<endl;
                }
                else if(i==4){
                    cout<<'D'<<" "<<j<<endl;
                }
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
   
using namespace std;
     
#define PB(x) push_back(x)
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x) make_pair(x);
    
#define debug(x) cerr << #x << '=' << x << endl;
#define debug2(x, y) cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(a) for (int x: a) cerr << x << ' '; cerr << endl;
#define debugm(a, n, m) for (int i = 0; i < n; i++, cout << endl)           \
						for (int j = 0; j < m; j++) cout << a[i][j] << ' ';

#define int long long
     
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN;
const int mmod = 1000000007;

int32_t main()
{
	int k, x;
	
	cin >> k >> x;
	
	int l = max(-1000000ll, x-k+1);
	int r = min(k+x-1, 1000000ll);
	
	for (int i = l; i <= r; i++)
		cout << i << ' ';
	cout << endl;
	
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined 


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<numeric>
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  int* x=new int[m];
  int* dx=new int[m];
  for(int i=0;i<m;i++){ cin>>x[i]; }
  if(n>=m){ cout<<"0"<<endl; return 0; }
  sort(x,x+m);
  adjacent_difference(x,x+m,dx);
  sort(dx+1,dx+m);
  int s=accumulate(dx+1,dx+1+m-n,0);
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 1024
# AOJ 2824: Coastline
# Python3 2018.7.11 bal4u

while True:
	T, D, L = map(int, input().split())
	if T == 0: break
	a = []
	for i in range(T):
		x = int(input())
		if x >= L: a.append(i)
	T, ans = T-1, 0
	for i in range(1, len(a)):
		x = D
		if T-a[i-1] < D: x = T-a[i-1]
		if a[i]-a[i-1] < x: ans += a[i]-a[i-1]
		else: ans += x
	if a: ans += T-a[-1] if a[-1]+D > T else D
	print(ans)



Measured memory_bytes: 9500
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100000;

int x[MAX_N];

int main()
{
	int n;
	ll a,b;
	ll res=0;
	cin >> n >> a >> b;
	rep(i,n){
		cin >> x[i];
	}
	rep(i,n-1){
		res += min(a*(x[i+1]-x[i]),b);
	}
	cout << res;
}

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

int main(){
  int n;
  cin>>n;
  using P = pair<int,int>;
  vector<P> v(n);
  rep(i,n) cin>>v[i].first>>v[i].second;

  long kotae = 0;

  rep(_,2){
    vector<bool> used(n,false);

    priority_queue<P> pqr,pql;
    rep(i,n){
      pqr.push({-v[i].second, i});
      pql.push({v[i].first, i});
    }

    int cur = 0;
    long ans = 0;
    while(!pqr.empty() && !pql.empty()){
      bool ok = true;
      while(true){
        if(pql.size()==0){ok=false;break;}
        auto p = pql.top(); pql.pop();
        if(used[p.second]) continue;
        if(p.first <= cur){ok=false; break;}
        ans += p.first - cur;
        cur = p.first;
        used[p.second] = true;
        break;
      }
      if(!ok) break;
  // dbg(cur, ans);
      while(true){
        if(pqr.size()==0){ok=false;break;}
        auto p = pqr.top(); pqr.pop();
        if(used[p.second]) continue;
        if(-p.first >= cur){ok=false; break;}
        ans += cur + p.first;
        cur = - p.first;
        used[p.second] = true;
        break;
      }
      if(!ok) break;
  // dbg(cur, ans);
    }
    ans += abs(cur);
    kotae = max(ans, kotae);

    rep(i,n){
      swap(v[i].first, v[i].second);
      v[i].first *= -1;
      v[i].second *= -1;
    }
  }

  cout << kotae << endl;

  return 0;
}


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

namespace ABC064A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, d;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            d = 100 * a + 10 * b + c;

            if (d % 4 == 0)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

            Console.ReadKey();
            
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>

#define N 100

int main(){
	int n, i, j, k, min, temp;
	int r[N+1], m[N][N];
	
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d %d", &r[i], &r[i+1]);
	}
	
	for (i = 0; i < n; i++){
		m[i][i] = 0;
	}
	
	for (i = 1; i < n; i++){
		for (j = 0; j < n - i; j++){
			for(k = j; k < j + i; k++){
				temp = m[j][k] + m[k+1][j+i] + r[j]*r[k+1]*r[j+i+1];
				if (k == j || min > temp) min = temp;
			}
			m[j][j+i] = min;
		}
	}
	
	printf("%d\n", m[0][n-1]);
	
	return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, M; cin >> N >> M;
    vec<lint> A_list(N);
    range(i, 0, N) cin >> A_list.at(i);
    lint sum_num_votes = 0;
    range(i, 0, N) sum_num_votes += A_list.at(i);
    lint num_selectable_items = 0;
    range(i, 0, N) num_selectable_items += (A_list.at(i) * 4 * M >= sum_num_votes ? 1 : 0);
    cout << (num_selectable_items >= M ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<stdio.h>
int main(void)
{
  char buf1[400001];
  gets(buf1);
  gets(buf1 + 200000);
  int ans = 0;
  int i = 200000;
  do if(buf1[i - 200000] != buf1[i]) ++ans; while(buf1[++i]);
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 1988
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    
    int d = a/b;
    int r = a%b;
    double f = (double)a / (double)b;
    
    printf("%d %d %.5f\n", d, r, f);
    
    return 0;
}


Measured memory_bytes: 3204
s = gets.chomp.chars
t = gets.chomp.chars
n = s.size
m = t.size

dp = Array.new(n+1){Array.new(m+1, 0)}
n.times do |i|
  dp_cur = dp[i]
  dp_next = dp[i+1]
  m.times do |j|
    if s[i] == t[j]
      dp_next[j+1] = dp_cur[j] + 1
    else
      a = dp_cur[j+1]
      b = dp_next[j]
      dp_next[j+1] = a > b ? a : b
    end
  end
end

i, j = n, m
ans = ''
while i > 0 && j > 0 do
  if dp[i][j] == dp[i-1][j]
    i -= 1
  elsif dp[i][j] == dp[i][j-1]
    j -= 1
  else
    ans << s[i-1]
    i -= 1
    j -= 1
  end
end

puts ans.reverse


Measured memory_bytes: 73112
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K, ans=0;
    cin >> N >> K;
    vl A(N);
    rep(i,N){
        cin >> A[i];
    }
    sort(A.begin(),A.end(),greater<ll>());
    rep(i,K){
        ans+=A[i];
    }
    cout << ans << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 3664
k, s = map(int, input().split())

if s==3*k:
    print(1)
else:
    ans=0
    for i in range(k+1):
        if i>s:
            break
        for j in range(k+1):
            if i+j+k>=s and s-i-j>=0:
                ans+=1
            elif i+j>s:
                break

    print(ans)

Measured memory_bytes: 41180
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

typedef pair<int,int> P;

int H,W;
char s[50][51];

int d[50][50];

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

int bfs(){
	queue<P> que;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			d[i][j] = 100000;
		}
	}
	que.push(P(0,0));
	d[0][0] = 1;

	while(que.size()){
		P p = que.front(); que.pop();
		if(p.first==H-1 && p.second==W-1)break;
		for(int i=0;i<4;i++){
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];
			if(0<=nx&&nx<H && 0<=ny&&ny<W && s[nx][ny]!='#' && d[nx][ny]>1000){
				que.push(P(nx,ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[H-1][W-1];
}


int main(){

	scanf("%d %d", &H, &W);
	for(int i=0;i<H;i++) scanf("%s", s[i]);

	int ans = H * W;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(s[i][j]=='#') ans--;
		}
	}

	int dis = bfs();
	//printf("%d\n", dis);
	if(dis > 100){
		printf("-1\n");
		return 0;
	}

	ans -= dis;

	printf("%d\n", ans);

	return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

int p[20010];
int a[20010],b[20010];

int main(void){
	int n;
	cin >> n;
	rep(i,n) cin >> p[i],p[i]--;

	const int offset=20000;
	rep(i,n) a[i]=offset*i;
	rep(i,n) b[i]=offset*(n-1-i);

	rep(i,n){
		int cur=i+2;
		a[p[i]]+=cur+1;
		b[p[i]]+=1;
	}
	
	rep(i,n) cout << (i?" ":"") << a[i];
	cout << endl;

	rep(i,n) cout << (i?" ":"") << b[i];
	cout << endl;

	return 0;
}

Measured memory_bytes: 896
fun main(arg: Array<String>) {
    val (N, K) = listOfInt()
    val P = listOfInt()
    val e = P.map {
        val s = it * (it + 1) / 2
        s.toDouble() / it.toDouble()
    }
    val S = DoubleArray(N + 1)
    for (n in 0 until N) {
        S[n + 1] = S[n] + e[n]
    }
    var ans = 0.0
    for (n in 0 .. N - K) {
        val w = S[n + K] - S[n]
        if (ans < w) ans = w
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfDouble() = listOfString().map(String::toDouble)


Measured memory_bytes: 60208
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace  std;


int main()
{
    int Q;
    cin >> Q;
    int N = pow(10,5);
    vector<int> a(N,0);
    vector<int> is_prime(N,1);
    is_prime[0] = 0;
    is_prime[1] = 0;



    for (int i = 2; i < N ;i++ ) {
        if(is_prime[i]== 1){
            for(int j = i * 2;j<=N;j+=i){
                is_prime[j] = 0;
            }
        }
    }

    for (int k = 0; k < N ; ++k) {
        if(k % 2 == 1){
            if(is_prime[k] == 1 && is_prime[(k+1)/2]){
                a[k] = 1;
            }
        }
    }

    vector<int> s(N+1,0);

    for(int i = 0;i<N+1;i++){
        s[i+1] = s[i] + a[i];
    }
/*
    for (int l = 0; l <N ; ++l) {
        cout <<l<<", "<< a[l]<<endl;
    }
*/

    for (int m = 0; m < Q; ++m) {
        int r,l;
        cin >> l;
        cin >> r;
        cout<<s[++r] - s[l]<<endl;
    }


}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
vector<int> enum_div(int n)//nの約数を列挙
{
	vector<int> ret;
	for(int i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    int ans = 1;
    vector<int> v = enum_div(m);
    for(auto& e: v) {
        if (m / e >= n) ans = max(ans, e);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
 
using namespace std;
using ll = long long;
 
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
 
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

class UFT{
private:
    vector<int> par;
    vector<int> siz;
    int find(int x){ return (par[x] == x) ? x : (par[x] = find(par[x])); };
public:
    UFT(int n) : par(vector<int>(n)), siz(vector<int>(n, 1)){ For(i, n) par[i] = i; };
    bool same(int x, int y){ return find(x) == find(y); };
    void unite(int x, int y){ if(!same(x = find(x), y = find(y))){ par[x] = y; siz[y] += siz[x]; } };
    int size(int x){ return siz[find(x)]; };
    void print() const{ Couts(par); };
};

int main(void){
    Cin(int, n, m);
    Cins2(int, m, e1, e2);
    int ans = 0;
    For(i, m){
        UFT uft(n);
        For(j, m) if(j != i) uft.unite(e1[j]-1, e2[j]-1);
        if(uft.size(0) < n) ans ++;
    }
    Cout(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = 1e9;

int main() {
    ll N, K;
    cin >> N >> K;
    ll temp = N / K;
    ll ans = abs(N - K * temp);
    ans = min(ans, abs(N - (K * (temp + 1))));
    cout << ans << endl;
}


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

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            if (!A.Contains(1))
            {
                Console.WriteLine("-1");
                return;
            }

            var temp = 1;
            for (int i = 0; i < N; i++)
            {
                if (A[i] == temp)
                {
                    temp++;
                }
            }
            Console.WriteLine(N - temp + 1);
        }
    }
}

Measured memory_bytes: 35804
#include <bits/stdc++.h>
using namespace std;
int main(){
    int arr[5],k;
    for(int i=0; i < 5; ++i) cin >> arr[i];
    cin>>k;
    sort(arr,arr+5);
    cout << (arr[4]-arr[0]>k?":(":"Yay!");
    return 0;
}


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

int main(){
  int W, a, b, ans;
  cin >> W >> a >> b;

  if(a > b){
    ans = a - (b + W);
  }else{
    ans = b - (a + W);
  }

  if(ans <= 0){
    cout << 0 << endl;
  }else{
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

vll prime_list(0);

void make_prime_list(int N){
    int plsz=0;
    for(int i=2;i<=N;i++){
        int sqi=(int)sqrt(i)+1;
        bool p=true;
        for(int j=0;j<plsz;j++){
            if(i%prime_list[j]==0){
                p=false;break;
            }
            if(sqi<prime_list[j])break;
        }
        if(p){
            prime_list.push_back(i);
            plsz++;
        }
    }
}

//Nは2以上 1を与えると空集合が返る
void pdec(ll N,vector<pllll> &rt){
    rt.clear();
    if(N<=1)return;
    vll pd;
    int idx=0;
    const int plsz=prime_list.size();
    while(idx<plsz){
        if(N%prime_list[idx]==0){
            N/=prime_list[idx];
            pd.push_back(prime_list[idx]);
            if(N==1)break;
        }else{
            idx++;
        }
    }
    if(N>1){
        pd.push_back(N);
    }
    assert(pd.size()>0);
    rt.push_back(make_pair(pd[0],1));
    int rtsz=1;
    int pdsz=pd.size();
    for(int i=1;i<pdsz;i++){
        if(pd[i]==rt[rtsz-1].first){
            rt[rtsz-1].second++;
        }else{
            rt.push_back(make_pair(pd[i],1));
            rtsz++;
        }
    }
}

void make_divlist(vll &rt,vector<pllll> &pp,ll ppsz,ll lv){
    ll rtsz=rt.size();
    if(rtsz==0){
        rt.push_back(1);
        if(ppsz==0)return;
        for(int i=1;i<=pp[lv].second;i++){
            ll v=rt[i-1]*pp[lv].first;
            rt.push_back(v);
        }
    }else{
        ll times=pp[lv].first;
        for(int i=1;i<=pp[lv].second;i++){
            for(int j=0;j<rtsz;j++){
                ll v=rt[j]*times;
                rt.push_back(v);
            }
            times*=pp[lv].first;
        }
    }
    if(lv+1<ppsz){
        make_divlist(rt,pp,ppsz,lv+1);
    }
}

int main(){
    ll N,M;
    cin>>N>>M;
    
    make_prime_list(1000000);
    vector<pllll> pp;
    vll divlist;
    pdec(M,pp);
    make_divlist(divlist,pp,pp.size(),0);
    sort(ALL(divlist));

    // for(int i=0;i<pp.size();i++){
    //     cout<<"["<<pp[i].first<<","<<pp[i].second<<"] ";
    // }
    // cout<<endl;
    // for(int i=0;i<divlist.size();i++){
    //     cout<<divlist[i]<<" ";
    // }
    // cout<<endl;

    int dlsz=divlist.size();
    for(int i=dlsz-1;i>=0;i--){
        if(divlist[i]*N<=M){
            cout<<divlist[i]<<endl;
            return 0;
        }
    }

}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  ll n, k;
  cin >> n >> k;
  cout << (n % k != 0) << endl;

  return 0;
}

Measured memory_bytes: 256
/*	
	Over ice, I'm freezing
	Beautiful eyes, deceiving
	We may die this evening
	Coughing, wheezing, bleeding...
*/	
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("Os")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define mp make_pair

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=1e2+10, maxm=2e3+10, lg=18, mod=1e9+7, inf=1e18;

ll n,m,A[maxn][maxn],B[maxn][maxn],C[maxn][maxn],tr[maxn][maxn];
bool us[maxn][maxn],dar[maxn],mk[maxn];
vector<ll> g[maxn];
ll mt[maxn];

bool dfs(ll v){
	if(mk[v]) return 0;
	mk[v]=1;
	for(auto u:g[v])if(mt[u]==-1 || dfs(mt[u])) return mt[u]=v,1;
	return 0;
}

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	cin>>n>>m;
	for(int r=0;r<n;r++)for(int c=0;c<m;c++) cin>>A[r][c], tr[r][(--A[r][c])/m]++;
	for(int c=0;c<m;c++){
		for(int i=0;i<n;i++) g[i].clear(), mt[i]=-1, dar[i]=0;
		for(int r=0;r<n;r++)for(int col=0;col<n;col++)if(tr[r][col]) g[col].pb(r);
		bool F=1;
		while(F){
			F=0;
			for(int col=0;col<n;col++)if(!dar[col]){
				memset(mk,0,sizeof(mk));
				F|=(dar[col]=dfs(col));
			}
		}
		for(int i=0;i<n;i++)for(int j=0;j<m;j++)if(!us[i][j] && mt[i]==A[i][j]/m){ us[i][j]=1; B[i][c]=A[i][j]; C[c][A[i][j]/m]=A[i][j]; tr[i][A[i][j]/m]--; break; }
	}
	for(int i=0;i<n;i++,cout<<endl)for(int j=0;j<m;cout<<1+B[i][j++]<<' ');
	for(int i=0;i<n;i++,cout<<endl)for(int j=0;j<m;cout<<1+C[j++][i]<<' ');
	
	return 0;
}




Measured memory_bytes: 4108
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    auto xs = readints;
    int[int] m;
    foreach (x; xs)
        m[x]++;

    foreach (k, v; m) {
        if (v == 1)
            writeln(k);
    }
}


Measured memory_bytes: 256