akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
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; }
ll MOD = 1000000007;
double PI = acos(-1);

void solve()
{	
	vector<double> ans;
	while (true)	
	{
		int n; cin >> n;
		if(!n)break;
		vector<double> a(n);
		double ave = 0;
		rep(i, n)
		{
			cin >> a[i];
			ave += a[i];
		}
		ave /= n;
		double var = 0;
		rep(i, n)var += (a[i]-ave)*(a[i]-ave);
		var /= n;
		ans.push_back(pow(var,0.5));
	}
	rep(i, sz(ans))cout << ans[i] << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}



Measured memory_bytes: 3504
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}

// 割り算の切り上げ処理
template<typename T>
T round_up(T a, T b) {
  return (a + b - 1) / b;
}

// 約数列挙
template<typename T>
vector<T> calc_divisor(T n) {
   vector<T> res;
   for (T i = 1LL; i*i <= n; ++i) {
       if (n % i == 0) {
           res.push_back(i);
           T j = n / i;
           if (j != i) res.push_back(j);
       }
   }
   sort(res.begin(), res.end());
   return res;
}

// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;

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




int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int a, b;
    cin >> a >> b;
    rep(i, 1e9+1){
        if(abs(a - i) == abs(b - i)){
            print(i);
            return 0;
        }
    }
    print("IMPOSSIBLE");

}


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

    class Program
    {
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split(' ').Select(s=> int.Parse(s)).ToArray();
            var N = NK[0];
            var K = NK[1];

            var inputs = new List<int>();
            for(var i = 0;i<N;i++)
            {
                inputs.Add(int.Parse(Console.ReadLine()));
            }
            inputs.Sort();
            var min = int.MaxValue;
            for(int i =0;i<=N-K;i++)
            {
                var tmp = inputs[i + K - 1] - inputs[i];
                if (tmp < min) min = tmp;
            }
            Console.WriteLine(min);
        }
    }

Measured memory_bytes: 17452
#include<iostream>
using namespace std;
int main()
{
  int n,k,x,y;
  cin>>n;
  cin>>k;
  cin>>x;
  cin>>y;
  int z;
  z=n-k;
  if(n>k){
  cout<<(k*x)+(z*y);
  }
  else{
    cout<<n*x;
  }
}

Measured memory_bytes: 3576
s = input()
n = len(s)
a = [0] * (n + 1)
for i in range(n):
    if s[i] == '<':
        a[i + 1] = max(a[i + 1], a[i] + 1)
for i in range(n - 1, -1, -1):
    if s[i] == '>':
        a[i] = max(a[i], a[i + 1] + 1)
print(sum(a))

Measured memory_bytes: 46448
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		List<Long> num = new ArrayList<>();
		long count = sc.nextLong();

		for(int i = 0; i < count; i++){
			num.add(sc.nextLong());
		}

		long sum = 0;
		long max = num.get(0);
		long min = num.get(0);
		for(int i = 0; i < num.size(); i++){
			max = Math.max(max, num.get(i));
			min = Math.min(min, num.get(i));
			sum += num.get(i);
		}

		System.out.println(min + " " + max + " " + sum);
	}

}


Measured memory_bytes: 42604
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;

// int MOD = 998244353;
int MOD = 1000000007;


signed main(){
    
    ll n;
    cin >> n;

    vector<pair<ll,char>> p;
    rep(i,n){
        int a;
        cin >> a;
        p.pb(MP(a,'a'));
    }
    rep(i,n){
        int a;
        cin >> a;
        p.pb(MP(a,'b'));
    }
    SORT(p);
    // rep(i,2*n)cerr << p[i].fi << " " << p[i].se << endl;

    int a=0,b=0;
    ll ans = 1;
    rep(i,2*n){
        if(p[i].se == 'a'){
            if(b == 0)a++;
            else{
                ans *= b;
                ans %= MOD;
                b--;
            }
        }else{
            if(a == 0)b++;
            else{
                ans *= a;
                ans %= MOD;
                a--;
            }
        }
    }
    cout << ans << endl;

    
    
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf16-exhibition-final-open.contest.atcoder.jp/tasks/cf16_exhibition_final_a
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc125.contest.atcoder.jp/tasks/abc125_a


Measured memory_bytes: 6384
#include <stdio.h>
#include <stdlib.h>

int cmp(const void* a, const void* b)
{
	return *(int*)b - *(int*)a;
}

int main()
{
	int i, imax, bow[100001] = { 0 };
	int tmp = 0;
	long long hen = 0, takasa = 0;

	scanf("%d", &imax);

	for (i = 0; i < imax; i++) {
		scanf("%d", &bow[i]);
	}

	qsort((void*)bow, imax, sizeof(bow[0]), cmp);

	for (i = 0; i < imax; i++) {
		if (tmp == bow[i]) {
			if (hen == 0) {
				hen = bow[i];
				tmp = 0;
			} else {
				takasa = bow[i];
				break;
			}
		} else {
			tmp = bow[i];
		}
	}


	printf("%lld", hen * takasa);
	return 0;
}

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

namespace ConsoleApp2
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] Wsa = Read(Console.ReadLine());

            int sum = Wsa.Sum();

            int sum1 = 0;
            int delta = sum;

            for (int i = 0; i < Wsa.Length; i++)
            {
                sum1 += Wsa[i];
                int test = Math.Abs(sum - sum1);
                if (delta > Math.Abs(test - sum1)) delta = Math.Abs(test - sum1);
            }

            Console.WriteLine(delta);
            

        }


        private static string ReplaceOneChar(string S ,int index,string newS)
        {
            string s1 = S.Substring(0, index-1);
            string s2 = S.Substring(index);
            return s1 + newS + s2;
        }

        private static int[] Read(string input)
        {
            string[] inputs = input.Split(' ');
            int num = inputs.Length;
            int[] ints = new int[num];
            for (int i = 0; i < num; i++)
            {
                ints[i] = int.Parse(inputs[i]);
            }
            
            return ints;
        }


    }
}



Measured memory_bytes: 13268
#include <stdio.h>

int main(){
	int i, n, c;
	c = 0;
	scanf("%d",&n);
	int a[n];
	for(i=0;i<n;i++) scanf("%d",&a[i]);
	for(i=0;i<n;i++){
		if(a[i]%2==0){
			if((a[i]%3!=0)&&(a[i]%5!=0)){
				c = 1;
			}
		}
	}
	if(c==1) printf("DENIED\n");
	else printf("APPROVED\n");
}


Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 1000000007
#define MAXN 200005
#define MAXH 4
#define MAXM 100
#define INF 1LL << 30
#define ll long long
#define ull unsigned long long
#define RNG mt19937
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
const int N = 18;
int dp[1 << N][N],c[1 << N];

int main(){
	fast_io();
	int ans = 0;
	int n;cin >> n;
	int x;cin >> x;
	cu(i,0,1 << n)c[i] = x;

	cu(i,1,1 << n){
		cin >> x;	
		c[i] = x;
		cu(j,0,n)dp[i][j] = x;

		cu(j,0,n){
			if((i >> j) & 1){
				cu(k,0,n){
					if(j != k && ((i >> k) & 1)){
						gmax(dp[i][j], dp[i ^ (1 << k)][j]); 
					}
				}
				gmax(c[i], c[i ^ (1 << j)]);
			}
		}

		cu(j,0,n){
			if((i >> j) & 1){
				gmax(ans, dp[i][j] + c[i ^ (1 << j)]);
			}
		}

		cout << ans << '\n';
	}
}


Measured memory_bytes: 22528
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<cstring>
#include<deque>
#define itn int
#define coder goodboy
using namespace std;
typedef long long LL;typedef unsigned long long ULL;
bool flag;int a,b,c;
int Main(){
	scanf("%d%d%d",&a,&b,&c);
	for (int i=1;i<=20010916;i++){
		int temp=a*i;
		if ((temp%b)==(c%b)) flag=1;
	}
	if (flag) puts("YES");
	else puts("NO");
	return 0;
}
int main(){;}
int goodboy=Main();


Measured memory_bytes: 256
package main

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

const MAX = 25
const NIL = -1

var N [MAX]Node
var sc = bufio.NewScanner(os.Stdin)

type Node struct {
	parent int
	left   int
	right  int
}

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}
func findRoot(id int) int {
	for N[id].parent != NIL {
		id = N[id].parent
	}
	return id
}

func preOrder(id int, w io.Writer) {
	if id == NIL {
		return
	}
	fmt.Fprint(w, " ", id)
	preOrder(N[id].left, w)
	preOrder(N[id].right, w)
}

func inOrder(id int, w io.Writer) {
	if id == NIL {
		return
	}
	inOrder(N[id].left, w)
	fmt.Fprint(w, " ", id)
	inOrder(N[id].right, w)
}

func postOrder(id int, w io.Writer) {
	if id == NIL {
		return
	}
	postOrder(N[id].left, w)
	postOrder(N[id].right, w)
	fmt.Fprint(w, " ", id)
}

func main() {
	n := scanInt()
	for i := 0; i < n; i++ {
		N[i].parent = NIL
		N[i].left = NIL
		N[i].right = NIL
	}

	for i := 0; i < n; i++ {
		id := scanInt()
		left := scanInt()
		right := scanInt()
		N[id].left = left
		N[id].right = right

		if left != NIL {
			N[left].parent = id
		}
		if right != NIL {
			N[right].parent = id
		}
	}

	root := findRoot(3)

	w := bufio.NewWriter(os.Stdout)
	fmt.Fprintln(w, "Preorder")
	preOrder(root, w)
	fmt.Fprintln(w)

	fmt.Fprintln(w, "Inorder")
	inOrder(root, w)
	fmt.Fprintln(w)

	fmt.Fprintln(w, "Postorder")
	postOrder(root, w)
	fmt.Fprintln(w)

	w.Flush()
}



Measured memory_bytes: 1124
'use strict'
function main(inp) {
  inp = inp.trim().split('\n');
  const N = inp.shift();
  let ans = inp[0];
  let txt;
  if(ans.length > N){
    console.log(ans.substr(0,N) + "...");
  }else {
    console.log(ans);
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29628
#include<bits/stdc++.h>
#define ll long long
#define fastio  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD=1000000007;
#define PI acos(-1)
using namespace std;
int main(){
	int n ;
	cin >> n ;
	int a[n];
	for(int i =0 ; i < n ; i++){
		cin >> a[i];
	}
	ll sum =0;
	for(int i = 1 ; i < n ; i++){
		   if( a[i] < a[i-1]){
		     sum +=(a[i-1]-a[i]);
		     a[i] = a[i-1];
		 }
	}
	cout << sum << endl;
}


Measured memory_bytes: 4372
#include<bits/stdc++.h>
using namespace std;
#define ll               long long
#define dl               double
#define ull              unsigned long long
#define ft               first
#define sd               second
#define pi               acos(-1)
#define ct(tc)           scanf("%lld",&tc)
#define scnm(n,m)        scanf("%lld %lld",&n,&m);
#define max3(a,b,c)      max(a,max(b,c))
#define max4(a,b,c,d)    max(a,max(b,max(c,d)))
#define min3(a,b,c)      min(a,min(b,c))
#define min4(a,b,c,d)    min(a,min(b,min(c,d)))
#define pb               push_back
#define srt              sort(v.begin(),v.end())
#define rsrt             reverse(v.begin(),v.end())
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n,m;
    scnm(n,m);
    if((n*500)>=m)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }

    return 0;

}


Measured memory_bytes: 256
// AOJ 0283: Study Session
// 2018.1.29 bal4u

#include <stdio.h>
#include <stdlib.h>

#define MAX(a,b) ((a)>=(b)?(a):(b))

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int N;
int s[1000002], t[1000002];
int leader[102], lsz;
int group[102],  gsz;

int bsch(int x)
{
	int m, l = 0, r = N;

    while (l < r) {
        m = l+((r-l)>> 1);
        if (t[m] < x) l = m + 1; else r = m;
    }
	return l;
}

int check(int v)
{
	int i, r = 0;
	if (lsz) r = bsch(group[0]+1) - bsch(group[0]-v);
    for (i = 1; i < lsz; i++) {
		r += bsch(group[i]+1) - bsch(MAX(group[i-1]+1, group[i]-v));
	}
	return r;
}

int cmp(int *a, int *b) { return *a - *b; }

int main()
{
	int Q, i, a, lo, hi, m, f, max;
	char buf[20], *p;
	
	N = in(), Q = in();
    for (i = 0; i < N; i++) s[i] = t[i] = in();
	qsort(t, N, sizeof(int), cmp);
	max = t[N-1]+1;

	lsz = 0, f = 1;
    while (Q--) {
		fgets(p=buf, 20, stdin);
		while (*p > ' ') p++;
		a = atoi(p+1);
		if (*buf == 'A') leader[lsz++] = a-1, f = 1;
		else if (*buf == 'R') {
			f = 1, a--;
            for (i = 0; leader[i] != a; i++);
			while (i < lsz) leader[i] = leader[i+1], i++;
			lsz--;
        } else if (*buf == 'C') {
			if (f) {
				gsz = 0;
				for (i = 0; i < lsz; i++) group[gsz++] = s[leader[i]];
				qsort(group, gsz, sizeof(int), cmp);
			}

			f = 0;
			lo = -1, hi = max;
            while (hi - lo > 1) {
                m = lo + ((hi-lo)>>1);
                if (check(m) >= N-a) hi = m; else lo = m;
            }
            if (hi == max) printf("NA\n");
            else printf("%d\n", hi);
        }
    }
    return 0;
}


Measured memory_bytes: 13128
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
// greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x%y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;



struct result {
	int p;
	string s;
};

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

	vector<result> vec(m);
	for (int i = 0; i < m; i++)
	{
		int px;
		string sx;
		cin >> px >> sx;
		result r = { px,sx };
		vec[i] = r;
	}




	int acAns = 0;
	int waAns = 0;
	vector<int> waCount(n + 1, 0);
	vector<bool> hasDoneAc(n + 1, false);
	for (int i = 0; i < m; i++)
	{
		int p = vec[i].p;
		string s = vec[i].s;
		if (s == "AC") hasDoneAc[p] = true;
		
		if (!hasDoneAc[p]) {
			waCount[p]++;
		}
	}

	//ac trueの数
	for (int i = 0; i < n + 1; i++)
	{
		if (hasDoneAc[i]) {
			acAns++;
			waAns += waCount[i];
		}

	}

	cout << acAns << " " << waAns << endl;

}


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

int main() {
  int A, B;
  cin >> A >> B;
  int coin = 0;

  for (int i = 0; i < 2; ++i) {
    if (A <= B) {
    coin += B;
    --B;
    }
    else {
    coin += A;
    --A;
    }
  }
  cout << coin << endl;
}


Measured memory_bytes: 256
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		Map<Integer, Integer> m = new TreeMap<>();
		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			int c = 0;
			if (m.containsKey(a))
				c = m.get(a);
			m.put(a, c + 1);
		}
		int ans = 0;
		for (Integer i:m.keySet()) {
			int c = m.get(i);
			if (c < i)
				ans += c;
			else
				ans += c - i;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 48660
total = int(input())
text = input()

res = 0

if total >= 3:
    for x in range(0, total - 1):
        if text[x] == "A":
            if x + 3 <= total:
                if text[x + 1] == "B" and text[x + 2] == "C":
                    res += 1

print(res)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

class UnionFind {
public:
    vector<int> parent;  //親ノード
    vector<int> Siz;  //集合の大きさ

    // コンストラクタ
    UnionFind(int n): parent(n), Siz(n, 1) {
        rep(i, n) {
            parent[i] = i;
        }
    }

    // n要素で初期化
    void init(int n) {
        parent.resize(n);
        Siz.assign(n, 1);
        rep(i, n) {
            parent[i] = i;
        }
    }

    // xの属する集合の根を求める
    int root(int x) {
        if(parent[x] == x) {
            return x;
        }
        else {
            return parent[x] = root(parent[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(int x, int y) {

        x = root(x);
        y = root(y);
        if(x == y) {
            return;
        }

        if(Siz[x] < Siz[y]) {
            swap(x, y);
        }

        Siz[x] += Siz[y];
        parent[y] = x;
    }

    // xとyが同じ集合に属するかどうか
    bool same(int x, int y) {
        return root(x) == root(y);
    }

    // xの属する集合の要素数を求める
    int size(int x) {
        return Siz[root(x)];
    }
};

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

    vector<int> a(m), b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;  b[i]--;
    }

    UnionFind Uni(n);

    int ans = 0;
    rep(i, m) {

        Uni.init(n);

        rep(j, m) {
            if(j == i) {
                continue;
            }
            Uni.unite(a[j], b[j]);
        }

        if(Uni.size(0) != n) {
            ans++;
        }

    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, a[100010] = {0}, b, ans = 0;
int main() {
    cin >> n;
    for(int i = 0; i < n + 1; i++) scanf("%d", a + i);
    for(int i = 0; i < n; i++) {
        scanf("%d", &b);
        ans += min(a[i], b);
        b -= min(a[i], b);
        if(b > 0) ans += min(a[i+1], b), a[i+1] -= min(a[i+1], b);
    }
    cout << ans << endl;
}


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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
#define en "\n"
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define sortv(vv) sort(vv.begin(), vv.end())
#define all(v) v.begin(), v.end()
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>


using namespace std;
const ll maxn=4e3+100,inf=1e18,LOG=23,mod=1e9+7;
int block = 300, timer = 0;
const ld EPS = 1e-7;

#define bt(i) (1 << (i))
#define int ll

int n, ans, pref[maxn][570];
char a[maxn];

main()
{
	cin >> n;
	forn(1, i, n)
	{
		cin >> a[i];
		pref[i]['R'] = pref[i - 1]['R'];
		pref[i]['B'] = pref[i - 1]['B'];
		pref[i]['G'] = pref[i - 1]['G'];
		pref[i][a[i]]++;
	}
	forn(1, i, n)
	{
		forn(1, j, i - 1)
		{
			if(a[i] == a[j]) continue;
			ans += pref[j - 1]['R'] + pref[j - 1]['G'] + pref[j - 1]['B'] - pref[j - 1][a[i]] - pref[j - 1][a[j]];
			if(2*j - i > 0 && a[2*j - i] != a[i] && a[2*j - i] != a[j])
			{
				ans--;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 19952
/* 
 * Project: AtCoder Beginners Contest 144 B - 81
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/08/08
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstdint>
#include <cmath>
using namespace std;

int32_t n;

void solve() {

    int max_term = sqrt(n);
    for (int32_t i=1;i<max_term+1;i++) {
        if (n%i==0 && n/i<10) {
            printf("Yes\n");
            return;
        }
    }
    printf("No\n");

}

int main() {

    scanf("%d", &n);

    solve();

}

Measured memory_bytes: 3168
#include<iostream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cstdlib>

using namespace std;
int main(){


  int x[7];
  for(int i=1;i<7;i++){
    cin >> x[i];
  }
  string str;
  cin >> str;

  for(int i=0;i<str.size();i++){
    char c = str[i];
    int tmp = 0;
    if(c == 'N'){
      tmp = x[1];
      x[1] = x[2];
      x[2] = x[6];
      x[6] = x[5];
      x[5] = tmp;
    }else if(c== 'S'){
      tmp = x[1];
      x[1] = x[5];
      x[5] = x[6];
      x[6] = x[2];
      x[2] = tmp;
    }else if(c=='E'){
      tmp = x[1];
      x[1] = x[4];
      x[4] = x[6];
      x[6] = x[3];
      x[3] = tmp;
    }else if(c == 'W'){
      tmp = x[1];
      x[1] = x[3];
      x[3] = x[6];
      x[6] = x[4];
      x[4] = tmp;
    }
  }
  cout << x[1] << endl;



}





Measured memory_bytes: 3200
#include <stdio.h>
int main(void)
{
	int a,b,r,d;
	double f;
	
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	printf("%d %d %lf",d,r,f);
	
	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main() {
    double x1, y1, x2, y2, d;

    cin >> x1 >> y1 >> x2 >> y2;

    d = (x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2);

    // cout << sqrt(d) << endl;

    printf( "%.10lf\n", sqrt(d) );

    return 0;
}

Measured memory_bytes: 3176
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
	int tmp;
	string s;
	cin >> s;
	string fo, la;
	fo = s.substr(0, s.size()/2);
	la = s.substr((s.size()+1)/2 , s.size()/2);
    bool tf = true;
	if(fo != la) tf = false;
	int n = fo.size();
	REP(i, n/2) if(fo[i] != fo[n-1-i]) tf = false;
	//cout << ans << endl;
	if (tf) cout << "Yes" << endl;
	else cout << "No" << endl;
	
}

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

int main(){
	int W,H,x,y;
	cin >> W >> H >> x >> y;
	double ans=(double)W*(double)H;
  	ans=ans/2;
	int pos;
	if(W%2==0&&H%2==0&&x==W/2&&y==H/2){
		pos=1;
	}else{
		pos=0;
	}
	cout << ans << " " << pos << endl;
}

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;

void solve() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << (N - A) % B << endl;
    return;
}

int main() {
    solve();
}


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

int main(){
    int N;
    cin >> N;
    int X[N],Y[N];
    rep(i,N) cin >> X[i] >> Y[i];
    map<pair<int,int>,long long> m;
    rep(i,N){
        rep(j,N){
            if(i == j) continue;
            m[make_pair(X[i]-X[j],Y[i]-Y[j])]++;
        }
    }
    long long res = 0;
    for(auto it = m.begin();it != m.end();it++){
        res = max(res,it->second);
    }
    cout << N - res << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int a,b;
	int counter = 0;
	while (1) {
		cin >> b;
		counter = 0;
		if (b == 0) {
			break;
		}
		a = 1000 - b;
		if (a / 500 > 0) {
			counter += (a / 500);
			a = a % 500;
		}
		if (a / 100 > 0) {
			counter += (a / 100);
			a = a % 100;
		}
		if (a / 50 > 0) {
			counter += (a / 50);
			a = a % 50;
		}
		if (a / 10 > 0) {
			counter += (a / 10);
			a = a % 10;
		}
		if (a / 5 > 0) {
			counter += (a / 5);
			a = a % 5;
		}
		if (a / 1 > 0) {
			counter += (a / 1);
			a = a % 1;
		}
		cout << counter << endl;
	}
	return 0;
}

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

int used[23][23];
int answer;
int h,w;
string s[23];

void dfs(int y,int x){
  answer++;
  used[y][x] = 1;
  
  if( y-1 >= 0 && used[y-1][x]==0 && s[y-1][x]!='#') dfs( y-1,x );
  
  if( y+1 <  h && used[y+1][x]==0 && s[y+1][x]!='#') dfs( y+1,x );
  
  if( x-1 >= 0 && used[y][x-1]==0 && s[y][x-1]!='#') dfs( y,x-1 );
  
  if( x+1 <  w && used[y][x+1]==0 && s[y][x+1]!='#') dfs( y,x+1 );
}

int main(){
  
  while( cin>>w>>h,w){
    
    int y,x;

    answer = 0;
    
    memset( used,0,sizeof(used) );
    for(int i=0;i<h;i++) cin>>s[i];
    
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(s[i][j]=='@'){
	  y = i;
	  x = j;
	}
      }
    }    
    dfs(y,x);
    cout<< answer <<endl;
  }
}



Measured memory_bytes: 3176
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <ctime>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n; cin >> n;
	vl a(n),b(n);
	rep(i,n) cin >> a[i] >> b[i];
	sort(all(a)); sort(all(b));
	if(n & 1){
		cout << b[n/2] - a[n/2] + 1 << endl;
	}else{
		ll f = (b[n/2-1] + b[n/2]) % 2;
		ll g = (a[n/2-1] + a[n/2]) % 2;
		if(f == g){
			ll ans = ((b[n/2] + b[n/2-1]) / 2 - (a[n/2] + a[n/2-1]) / 2) * 2;
			cout << ans+1 << endl;
		}else{
			ll ans = ((b[n/2] + b[n/2-1]) / 2 - (a[n/2] + a[n/2-1]) / 2) * 2 + 1;
			if(b[n/2] % 2 == b[n/2-1] % 2) ans--;
			else ans++;
			cout << ans << endl;
		}
	}
}

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

using namespace std;

int main() {
	int n; cin >> n;
	vector<vector<int> > A(n,vector<int>(n));
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j)
			cin >> A[i][j];
    for(int k=0;k<n;++k) {
		for(int i=0;i<n;++i) {
			for(int j=0;j<n;++j) {
				if(A[i][j]>A[i][k]+A[k][j]) {
					cout << -1 << endl;
					return 0;
				}
			}
		}
	}
	long long ans=0;
	for(int i=0;i<n;++i) {
		for(int j=i+1;j<n;++j) {
			bool flag=true;
			for(int k=0;k<n;++k) {
				if(i==k||j==k) continue;
				if(A[i][j]==A[i][k]+A[k][j]) flag=false;
			}
			if(flag) ans+=A[i][j];
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxV = 90010;
const int maxN = 1e5+10;
const int MOD = 1e9+7;
const ll INF = 1000000000000000010LL;
const ll inf = 1e9+10;
 
 

int main() {
	vector<string> a(3);
	a[0] = "Sunny";
	a[1] = "Cloudy";
	a[2] = "Rainy";
	string x;
	cin>>x;
	unordered_map<string,int> mp;
	for(int i=0;i<3;i++)
	{
		mp[a[i]] = i;
	}
	string y = a[(mp[x]+1)%3];
	cout<<y<<endl;
	return 0;
}

Measured memory_bytes: 256
while True:
    m, f, r = map(int,input().split())
    if m == -1 and  f == -1 and r == -1:
                break
    if m == -1 or f == -1:
      print("F") 
    elif m + f >= 80:
      print("A")
    elif 65 <= m + f < 80:
      print("B")
    elif 50 <= m + f < 65:
      print("C")
    elif r >= 50:
      print("C")
    elif 30 <= m + f < 50:
      print("D")
    elif r >= 50:
      print("C")
    else :
      print("F")


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

int main(){
  string S;
  cin >> S;
  
  int first_back, first_front;
  int half = S.size() / 2;
  int change_num = 0;

  if(S.size() % 2 == 0){
    first_back  = half;
    first_front = half - 1;
  }else{
    first_back  = half + 1;
    first_front = half - 1;
  }
   
  for(int i = 0; i < half; i++){
    if(S[first_back + i] != S[first_front - i]){
      change_num++; 
    }
  }
  
  cout << change_num << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

    // 初項を正にする場合
    ll ans1 = 0, sum1 = a[0];
    if (sum1 <= 0) {
        ans1 += 1 - sum1;
        sum1 = 1;
    }
    for (int i = 1; i < n; i++) {
        ll sum_c = sum1;
        sum1 += a[i];
        if (sum_c < 0 && sum1 <= 0) {
            ans1 += 1 - sum1;
            sum1 = 1;
        } else if (sum_c > 0 && sum1 >= 0) {
            ans1 += sum1 + 1;
            sum1 = -1;
        }
    }

    // 初項を負にする場合
    ll ans2 = 0, sum2 = a[0];
    if (sum2 >= 0) {
        ans2 += sum2 + 1;
        sum2 = -1;
    }
    for (int i = 1; i < n; i++) {
        ll sum_c = sum2;
        sum2 += a[i];
        if (sum_c < 0 && sum2 <= 0) {
            ans2 += 1 - sum2;
            sum2 = 1;
        } else if (sum_c > 0 && sum2 >= 0) {
            ans2 += sum2 + 1;
            sum2 = -1;
        }
    }

    cout << min(ans1, ans2) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
const int MAX_N = 2010;
const int INF = 1e9;
int d[MAX_N][MAX_N];
vector<int> G[MAX_N];
int n, k, s;

int calc(int x1, int y1, int z1, int x2, int y2, int z2){
    int x = min(x1, x2) + s - max(x1, x2);
    int y = min(y1, y2) + s - max(y1, y2);
    int z = min(z1, z2) + s - max(z1, z2);
    if(x <= 0 || y <= 0 || z <= 0) return 0;
    int res = 2 * (x * y + y * z + z * x);
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(1){
        cin >> n >> k >> s;
        if(n + k + s == 0) break;
        vector<int> x(n), y(n), z(n);
        rep(i, 0, n){
            cin >> x[i] >> y[i] >> z[i];
        }
        if(n == 1 || k == 1){
            cout << 6 * s * s << endl;
            continue;
        }
        rep(i, 0, n) rep(j, 0, n) d[i][j] = 0;  
        rep(i, 0, n) G[i].clear();
        rep(i, 0, n){
            rep(j, i + 1, n){
                d[i][j] = calc(x[i], y[i], z[i], x[j], y[j], z[j]);
                d[j][i] = d[i][j];
                if(d[i][j] > 0){
                    G[i].push_back(j);
                    G[j].push_back(i);
                }
            }
        }
        int ans = INF;
        rep(i, 0, n){
            rep(j, 0, G[i].size()){
                int tmp = 0;
                int now = G[i][j], nxt, pre = i;
                rep(l, 0, k - 1){
                    if(now == i){
                        tmp = INF; break;
                    }
                    tmp += d[pre][now];
                    if(G[now].size() == 1){
                        if(l == k - 2){
                            now = pre = -1;
                        }else{
                            tmp = INF;
                        }
                        break;
                    }else{
                        rep(p, 0, G[now].size()){
                            if(G[now][p] != pre) nxt = G[now][p];
                        }
                        pre = now;
                        now = nxt;
                    }
                }
                if(tmp != INF){
                    if(now == i) tmp += d[pre][now];
                    tmp = 6 * s * s * k - tmp;
                    ans = min(ans, tmp);
                }
            }
        }
        if(ans == INF) cout << -1 << endl;
        else cout << ans << endl;
    }
}


Measured memory_bytes: 11028
#include<bits/stdc++.h>
using namespace std;
long long n,m,k,ans[10];
int dx[9]={1,1,1,0,-1,-1,-1,0,0};
int dy[9]={-1,0,1,1,1,0,-1,-1,0};
map<long long,long long> mp;
map<long long,long long>::iterator it;
void make(long long x,long long y){
	long long a,b;
	for(int i=0;i<9;i++){
		a=x+dx[i];
		b=y+dy[i];
		if(a<=1||a>=n||b<=1||b>=m){
			continue;
		}
		mp[(b-1)*(n-2)+a]++;
	}
}
int main(){
	cin>>n>>m>>k;
	long long x,y;
	for(int i=0;i<k;i++){
		scanf("%lld %lld",&x,&y);
		make(x,y);
	}
	ans[0]=(n-2)*(m-2);
	for(it=mp.begin();it!=mp.end();it++){
//		cout<<(it->first)<<" "<<(it->second)<<endl;
		ans[it->second]++;
		ans[0]--;
	}
	for(int i=0;i<10;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

struct SuffixArray{
    int N;
    vector<int> sa,rank;
    vector<int> ary;//int
    string str;//string

    SuffixArray(){}

    void build(vector<int> &S){
        int k;//重要

        N=S.size();
        sa.resize(N+1,0);
        rank.resize(N+1,0);
        for(int i=0;i<=N;i++){
            sa[i]=i;
            rank[i]=(i<N ? S[i] : -1);
        }

        auto cmp = [&](int i,int j){
            if(rank[i]!=rank[j]) return rank[i]<rank[j];
            int ri=(i+k<=N ? rank[i+k] : -1);
            int rj=(j+k<=N ? rank[j+k] : -1);
            return ri<rj;
        };

        vector<int> tmp(N+1,0);
        for(k=1;k<=N;k*=2){
            sort(sa.begin(),sa.end(),cmp);

            tmp[sa[0]]=0;
            for(int i=1;i<=N;i++){
                tmp[sa[i]]=tmp[sa[i-1]]+(cmp(sa[i-1],sa[i]) ? 1 : 0);
            }
            rank=tmp;
        }

        //空文字を削除
        sa.erase(sa.begin());
        rank.pop_back();
        for(int i=0;i<rank.size();++i) --rank[i];
    }

    void initialize(vector<int> &A){
        ary=A;
        build(A);
    }

    void initialize(string &S){
        str=S;
        vector<int> A;
        for(int i=0;i<S.size();++i) A.push_back(S[i]);
        ary=A;
        build(A);
    }

    vector<int> lcp_array(vector<int> S,vector<int> sa){
        int N=S.size();
        vector<int> trans(N,0);
        for(int i=0;i<N;++i) trans[sa[i]]=i;

        vector<int> lcp(N-1,0);
        int prelen=0;
        for(int i=0;i<N;++i){
            prelen=max(0,prelen-1);
            int now=trans[i];
            if(now==N-1){
                prelen=0;
                continue;
            }

            int len=prelen;
            int tar=sa[now+1];
            while(i+len<N&&tar+len<N){
                if(S[i+len]!=S[tar+len]) break;
                ++len;
            }
            lcp[now]=len;
            prelen=len;
        }
        return lcp;
    }

    int operator[](int i)const{
        return sa[i];
    }
};

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

  string S;
  cin>>S;
  ll N=S.size();

  SuffixArray SA;
  SA.initialize(S);
  vector<int> sa=SA.sa;

  ll ans=N*(N+1)/2;
  vector<int> lcp=SA.lcp_array(SA.ary,sa);
  for(auto x:lcp){
      ans-=x;
  }
  cout<<ans<<"\n";

  return 0;
}


Measured memory_bytes: 19576
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <climits>
using namespace std;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % int(powl(10,9) + 7);
    }

    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;

    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

int main(){
    int a,b;
    cin >> a >> b;
    if(a == b)
        cout << "Draw" << endl;
    else if(b == 1 || (a != 1 && a < b))
        cout << "Bob" << endl;
    else
        cout << "Alice" << endl;
    return 0;
}

Measured memory_bytes: 256
n, y = map(int, input().split())
t = 0
for i in range(n+1):
    if t == 1:
        break
    for j in range(n+1):
        if (i+j) <= n:

            if i * 1000 + j * 5000 + (n - i - j) * 10000 == y:
                print((n - i - j), j, i)
                t = 1
                break


if t == 0:
    print(-1, -1, -1)

Measured memory_bytes: 40940
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.nextInt();
            var b = cin.nextInt();
            var c = cin.nextInt();
            var bk = new int[20];
            bk[a]++;
            bk[b]++;
            bk[c]++;
            Console.WriteLine((bk[5]==2&&bk[7]==1)?"YES":"NO");
        }
    }

    class Scanner
    {
        string[] s;
        int i;

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

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

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

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

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

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

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

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

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


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

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

map<ll,ll>l2;

int main()
{
    ll n,a=0,b=0,c=0,x=0,y,z;
    cin>>n;
    ll l1[n+1];
    for(int i=1;i<=n;i++){
        cin>>l1[i];
        l2[l1[i]]++;
    }
    for(int i=0;i<100000;i++){
        if(i==0)x=max(x,l2[i]+l2[i+1]);
        else x=max(x,l2[i]+l2[i-1]+l2[i+1]);
    }
    if(x)cout<<x;
    else cout<<1;

    return 0;
}


Measured memory_bytes: 7296
S = input()
for i in range(len(S)):
  if i%2==0:
    if S[i] in ['R', 'U', 'D']:
      continue
    else:
      print('No')
      break
  else:
    if S[i] in ['L', 'U', 'D']:
      continue
    else:
      print('No')
      break
else:
  print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n,m;
    cin>>n>>m;
    ll sum=0;
    rep(0,i,m){
        ll a;
        cin>>a;
        sum+=a;
    }
    ll ans=n-sum;
    if(ans<0)cout<<-1<<endl;
    else cout<<ans;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 10000000007
#define ff first
#define ss second
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 1e5 + 5;
int a[N],b[N],hs[N];
int main()
{
    IOS
    int n,m;
    cin>>n>>m;
    vector<pair<int,int> > vp;
    for(int i=1;i<=n;i++) {
        cin>>a[i]>>b[i];
        vp.pb(mp(b[i],a[i]));
    }
    sort(vp.begin(),vp.end());
    reverse(vp.begin(),vp.end());
    lli ans = 0;
    int ind = 0;
    set<int> st;
    for(int i=1;i<=m;i++) {
        st.insert(i);
    }
    for(int i=0;i<vp.size();i++) {
        int x = vp[i].second;
        if(st.count(x)) {
            ans+= vp[i].first;
            st.erase(x);
        }
        else {
            set<int>::iterator it = st.upper_bound(x);
            if(it != st.end()) {
                st.erase(it);
                ans+=vp[i].first;
            }
        }
    }
    cout<<ans;
    return 0;
}




Measured memory_bytes: 6516
import sys
import math
sys.setrecursionlimit(10 ** 7)

# 桁DP
# 非再帰

S = input()
K = int(input())
N = len(S)

# dp[n桁目まで決まってる][Non-Zeroの個数][Nと一致? 0:一致している 1:一致していない]
dp = [[[0] * 2 for _ in range(4)] for _ in range(N + 1)]

# n=0 桁目の値は、0として、それはKの値には関係なく、Nと一致している
dp[0][0][0] = 1

# i,j,kのうち、小さい方から埋めていく
for i in range(N):
    for j in range(4):
        for k in range(2):
            # 今決めようとしているの桁の値
            d = int(S[i])

            # 次の桁の値のループ(0-9)
            for nextd in range(10):
                # 次の桁を決めたあとのj,k
                nextj = j
                nextk = k

                # 次の桁がNon-Zero
                if nextd != 0:
                    nextj += 1
                # K個を超えたらいらない
                if nextj > K:
                    continue

                # 前の桁までNと一致していた場合
                # 使える数に制限あり
                if k == 0:
                    if d < nextd:
                        continue
                    elif nextd < d:
                        nextk = 1

                        # 前までの個数と同じ分の場合の数
                dp[i + 1][nextj][nextk] += dp[i][j][k]


ans = dp[N][K][0] + dp[N][K][1]
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

void chg(int *, int *);

int main(void) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    chg(&a, &b), chg(&b, &c), chg(&a, &b);
    printf("%d %d %d\n", a, b, c);
    return 0;
}

void chg(int *x, int *y) {
    *x > *y && (*x ^= *y, *y ^= *x, *x ^= *y);
}

Measured memory_bytes: 596
#include <cstdio>
#include <cstring>
#define MAXN 2010
#define LL long long
#define P 1000000007

int n,m,N;
LL fac[MAXN*MAXN],invfac[MAXN*MAXN];
LL f[MAXN][MAXN];

LL getPow(LL x,LL y){
	LL res=1;
	while(y){
		if(y&1) res=res*x%P;
		x=x*x%P;
		y>>=1;
	}
	return res;
}

LL getC(LL x,LL y){
	if(x<y) return 0;
	return fac[x]*invfac[y]%P*invfac[x-y]%P;
}

LL calc_g(LL x,LL y){ return getC(x+y-1,y); }

void init(){
	fac[0]=1;
	for(int i=1;i<=N;i++)
		fac[i]=fac[i-1]*i%P;
	invfac[N]=getPow(fac[N],P-2);
	for(int i=N-1;i>=0;i--)
		invfac[i]=invfac[i+1]*(i+1)%P;
}

int main(){
#ifdef DEBUG
	freopen("F.in","r",stdin);
#endif
	scanf("%d%d",&n,&m);
	if(m==1){
		puts("1");
		return 0;
	}
	N=n*m;
	init();
	f[1][0]=f[1][1]=1;
	for(int i=2;i<=n;i++){
		for(int j=0;j<i;j++)
			f[i][j+1]=f[i-1][j]*calc_g(m*(i-1)-j+1,m-2)%P;
		for(int j=i-1;j;j--)
			f[i][j]=(f[i][j]+f[i][j+1])%P;
		f[i][0]=f[i][1];
	}
	LL ans=f[n][0]*fac[n]%P;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 93056