akhauriyash/Code-Regression huggingface dataset:
open System
open System.Collections.Generic

module InputUtility =
    let InputTokens = new Queue<string>()

    let EnsureInput () =
        if InputTokens.Count = 0 then
            let input = Console.ReadLine ()
            let s = input.Split ([|' '|], StringSplitOptions.RemoveEmptyEntries)
            if s.Length > 0 then
                for x in s do InputTokens.Enqueue(x)
                true
            else false
        else true

    let rec ReadNext () =
        if EnsureInput () then InputTokens.Dequeue ()
        else ReadNext ()

    let ReadNextInt () = ReadNext () |> int

    let Read2Int () = ReadNextInt (), ReadNextInt ()

    let ReadListOf f n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop ((ReadNext () |> f) :: acc) (c-1)
        loop [] n

    let MultipleCaseWithId f =
        let caseNum = ReadNextInt ()
        let rec loop index =
            if index = caseNum then ()
            else
                f index
                loop (index + 1)
        loop 0

    let MultipleCase f = MultipleCaseWithId (fun _ -> f ())

    let ReadList n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop (ReadNext () :: acc) (c-1)
        loop [] n

open InputUtility

module ARC075 =
    type 'a BinaryIndexedTree (arr: 'a array) =
        let n = arr.Length

        member b.Set x f =
            let rec loopUp c =
                if c < n then
                    arr.[c] <- f arr.[c]
                    loopUp (c + (c &&& -c))
            loopUp x

        member b.Fold x f r =
            let rec loopDown c e =
                if c > 0 then
                    let ne = f e arr.[c]
                    loopDown (c - (c &&& -c)) ne
                else e
            loopDown x r
    let private ``Meaningful Mean`` () =
        let n, k = Read2Int ()
        let ba =
            let a = Array.zeroCreate (n + 2)
            new BinaryIndexedTree<_> (a)
        let inc x = ba.Set (x + 1) ((+) 1L)
        let read x = ba.Fold (x + 1) (+) 0L
        ReadListOf int64 n
        |> Seq.scan (+) 0L
        |> Seq.mapi (fun i v -> v - int64 i * int64 k, i)
        |> Seq.sort
        |> Seq.sumBy (fun (s, i) ->
            let c = read i
            inc i
            c)
        |> printfn "%d"

    let Entry = ``Meaningful Mean``

ARC075.Entry ()

Measured memory_bytes: 46124
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(){
  int A,B,H,M; //時針Acm 分針Bcm H時M分
  double Arad; //12時からの時針の角度
  double Brad; //12時からの分針の角度
  double ABrad; //時針と分針の間の角度
  double C; //求める長さ
  
  scanf("%d %d %d %d",&A,&B,&H,&M);
  
  Arad = 360 * (double)H / 12 + 30 * (double)M / 60;
  Brad = 360 * (double)M / 60;

  ABrad = fabs(Arad - Brad);
  
  if(ABrad > 180)
    ABrad = 360 - ABrad;//角度が180°より小さくなるように調整

  C = sqrt(A * A + B * B - 2 * A * B * cos(ABrad * M_PI / 180));
  
  printf("%.10lf",C);
  
  return 0;
}

Measured memory_bytes: 2600
n,m,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
x.sort()
y.sort()
l=[]
for i in range(X+1,Y):
  if x[-1]<i and y[0]>=i:
    l.append(i)

if l!=[]:
  print('No War')
else:
  print('War')

Measured memory_bytes: 38384
#include <iostream>
 
using namespace std;
 
int main()
{
int n, m, t[100], p[100], x[100], i, tmp, j, s;
 
cin >> n;
for(i=0;i<n;i++){
cin >> t[i];
}
cin >> m;
for(i=0;i<m;i++){
cin >> p[i] >> x[i];
}
 
for(i=0;i<m;i++){
s=0;
for(j=0;j<n;j++){
if(j+1==p[i]){
s+=x[i];
}
else{
s+=t[j];
}
}
cout << s << endl;
}
 
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define ll long long
using namespace std;
int main()
{
	int n,k,sum_max=-99999999,i,j,a,b,c;
	int f[1000];
	cin>>n>>k;
	for(i=0;i<n;i++)
	{
		cin>>f[i];
	}
	for(a=0;a<=k;a++)
	{
		for(b=0;b<=k;b++)
		{
			for(c=0;c<=k;c++)
			{
				if(a+b+c<=k && a+b>=c && a+b<=n)
				{
					priority_queue<int>q;
					for(i=0;i<a;i++)
					{
						q.push(f[i]);
					}
					for(i=0;i<b;i++)
					{
						q.push(f[n-i-1]);
					}
					int sum=0;
					for(i=0;i<a+b-c;i++)
					{
						sum+=q.top();
						q.pop();
					}
					sum_max=max(sum_max,sum);
				}
			}
		}
	}
	cout<<sum_max<<endl;
	return 0;
} 

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

class Program
{
    static void Main()
    {
        Scanner cin = new Scanner();
        int N = cin.Int();
        int M = cin.Int();
        int[] a = new int[M];
        int[] b = new int[M];

        for (int i = 0; i < M; i++)
        {
            a[i] = cin.Int();
            b[i] = cin.Int();
        }

        var s = new bool[200002];
        var t = new bool[200002];
        for(int i = 0; i < M; i++)
        {
            if (a[i] == 1) s[b[i]] = true;
            if (b[i] == N) t[a[i]] = true;
        }

        for(int i = 1; i <= N; i++)
        {
            if (s[i] && t[i])
            {
                Console.WriteLine("POSSIBLE");
                return;
            }
        }
        Console.WriteLine("IMPOSSIBLE");
        Console.ReadLine();
    }

}

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 Int()
    {
        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] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        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] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        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] = Double() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 16948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main(){
    bool ok = 1;
    string x; cin >> x;
    rep(i,x.size()){
        if(i%2 == 0 && x[i] == 'L') ok = 0;
        if(i%2 == 1 && x[i] == 'R') ok = 0;
    }
    puts(ok?"Yes":"No");
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-8)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
//*
// シンプルな構文解析用
typedef string::const_iterator State;
class ParseError {};
//*/
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;


int main(void) {
	string s;
	cin >> s;
	vi num(26, 0);
	for (auto c : s) {
		num[c - 'a']++;
	}
	ll ans = 0;
	rep(i, s.size()) {
		num[s[i] - 'a']--;
		ans += s.size() - i - 1 - num[s[i] - 'a'];
	}
	cout << ans + 1 << endl;

	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    int count[n + 1];
    fill(count, count + n + 1, 1);
    bool possible[n + 1];
    fill(possible, possible + n + 1, false);
    possible[1] = true;
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        count[x]--;
        count[y]++;
        if (possible[x]) {
            possible[y] = true;
        }
        if (count[x] == 0) {
            possible[x] = false;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (possible[i])
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
long long a[200010],b[200010];
const long long maxn=1e9+7;
int main()
{
	long long n,k;
	cin>>n>>k;
	for(long long i=1;i<=n;i++)
	{
		a[i]=a[i-1];
		a[i]+=i-1;
	}
	for(long long i=n;i>=1;i--)
	{
		b[i]=i;
		b[i]+=b[i+1];
	}
	reverse(b,b+n+1);
	for(int i=n;i>=1;i--)
		b[i]=b[i-1];
	a[0]=0;
	b[0]=n;
	unsigned long long ans=0;
	for(int i=k;i<=n;i++)
	{
		ans+=b[i]-a[i]+1;
	//	cout<<a[i]<<" "<<b[i]<<endl;
		ans=ans%maxn;
	}
	cout<<ans+1;
	return 0;
}

Measured memory_bytes: 6744
#include<stdio.h>
#include<stdlib.h>
int main(void){
	
	int *a,n,i,j,t,b;
	scanf("%d",&n);
	a=(int*)malloc(sizeof(int)*n);
	for(i=0;i<n;i++){
	scanf("%d ",&a[i]);}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(a[i]>a[j]){
			t=a[i];
			a[i]=a[j];
			a[j]=t;
			}
		}
	}
	b=a[0]-a[n-1];
	printf("%d",b);
return 0;
}


Measured memory_bytes: 128
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n:i64,
        a: i64,
        b: i64,
    }
    let ans = if n==1 {
        if a==b {
            1
        }else{
            0
        }
    }else if a > b {
        0
    }else{
        (n-2)*(b-a)+1
    };
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
//#include"Bignum/bignum.h"
//#define big bignum
#define lowbit(x) (x & -x)
#define debug(x) (cout << "#x = " << (x) << endl)
#define Set(x, i) memset (x, i, sizeof(x))
#define R register
#define For(i, j, k) for(R int i = (j); i <= (int) (k); ++i)
#define Rep(i, j, k) for(R int i = (j); i >= (int) (k); --i)
#define Cross(i, j, k) for(R int i = (j); i; i = (k))
using namespace std;
typedef long long ll;
const ll N = 100011;
const ll INF = 5e16;

namespace IO {

	inline char gc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return (p1 == p2) && (p2 = (p1 = buf) +
			fread(buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
	}

	#define dd ch = getchar()
	inline ll read() {
		R ll x = 0; R int f = 0; R char dd;
		for (; !isdigit(ch); dd) f ^= (ch == '-');
		for (; isdigit(ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write ( ll x ) {
		if (x < 0) x = -x, putchar('-');
		if (x > 9) write(x / 10); putchar(x % 10 | 48);
	}

	inline void wrn ( ll x ) { write(x), putchar(' '); }

	inline void wln ( ll x ) { write(x), putchar('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn(x), wln(y); }

}

using IO::wln;
using IO::read;

namespace Cesare {
	
	ll m, d, Ans;
	
	int main() {
		m = read(), d = read();
		For ( i, 1, m ) For ( j, 1, d ) 
			if (j >= 10) {
				ll d1 = j % 10, d2 = j / 10;
				if (d1 < 2 || d2 < 2) continue;
				if (d1 * d2 == i) ++Ans;
			}
		return wln(Ans), 0;
	}
	
}

int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);

	return Cesare :: main();
}

/*

*/






Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<cstdio>
#include<math.h>
#include<bitset>
#include<algorithm>
#include<iomanip>
#include<list>
#include<set>
#include<utility>
using namespace std;

//repetition
//------------------------------------------

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
//#define INF (1 << 30)
#define pii pair<int, int>

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

static const int INF = 1000000010;
string s[510];
int d[3][3];

int main() {
  rep(i,3){
    rep(j,3){
      cin >> d[i][j];
    }
  }
  int num = d[0][0] - d[0][1];
  int num2 = d[1][0] - d[1][1];
  int num3 = d[2][0] - d[2][1];
  int num5 = d[0][1] - d[0][2];
  int num6 = d[1][1] - d[1][2];
  int num7 = d[2][1] - d[2][2];
  int dum = d[0][0] - d[1][0];
  int dum2 = d[0][1] - d[1][1];
  int dum3 = d[0][2] - d[1][2];
  int dum5 = d[1][0] - d[2][0];
  int dum6 = d[1][1] - d[2][1];
  int dum7 = d[1][2] - d[2][2];
  if(num==num2&&num2==num3&&num5==num6&&num6==num7){
    if(dum==dum2&&dum2==dum3&&dum5==dum6&&dum6==dum7){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int T=0;
	int X=0;
	
	double a=0;
	double b=0;
	
	scanf("%d %d",&T,&X);
	
	a=(double)T;
	b=(double)X;
	printf("%lf",a/b);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int x; cin>>x;
    cout<<10-x/200<<endl;
}

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

using namespace std;

class UnionFind {
public:
	explicit UnionFind(int N) : root(N, -1) {}
	int getRoot(int v){ return root[v] == -1 ? v : root[v] = getRoot(root[v]); }
	void merge(int a, int b){
		int p = getRoot(a), q = getRoot(b);
		if(p != q) root[q] = p;
	}
private:
	vector<int> root;
};

int main(){
	int N;
	while(cin >> N){
		vector<pair<int, int>> dictX, dictY;
		UnionFind uf(N);
		for(int i=0;i<N;i++){
			int x, y; cin >> x >> y;
			dictX.emplace_back(x, i);
			dictY.emplace_back(y, i);
		}
		sort(dictX.begin(), dictX.end());
		sort(dictY.begin(), dictY.end());
		vector<pair<int, pair<int,int>>> vp;
		auto pushCosts = [&](const vector<pair<int, int>>& dict){
			for(int i=0;i+1<dict.size();i++){
				auto& a = dict[i];
				auto& b = dict[i+1];
				vp.push_back(make_pair(b.first - a.first, make_pair(a.second, b.second)));				
			}
		};
		pushCosts(dictX);
		pushCosts(dictY);
		sort(vp.begin(), vp.end());
		long long res = 0;
		for(auto& p : vp){
			int a = uf.getRoot(p.second.first);
			int b = uf.getRoot(p.second.second);
			if(a != b){
				res += p.first;
				uf.merge(a, b);
			}
		}
		cout << res << endl;
	}
}


Measured memory_bytes: 7528
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#define SF scanf
#define PF printf
using namespace std;
long long power(long long x,long long num,long long mod){
    long long res=1;
    while(num){
        if(num&1){res=res*x;res%=mod;}
        x*=x;
        x%=mod;
        num>>=1;
    }
    return res;
}
long long phi(long long n){
    long long res=n,t=n;
    for(long long i=2;i*i<=t;i++)
        if(t%i==0){
            res-=res/i;
            while(t%i==0)
                t/=i;
        }
    if(t>1)
        res-=res/t;
    return res;
}
long long gcd(long long x,long long y){
    if(y==0)
        return x;
    return gcd(y,x%y);
}
long long exgcd(long long a,long long b,long long &x,long long &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    long long g;
    g=exgcd(b,a%b,y,x);
    y-=a/b*x;
    return g;
}
long long solve(long long a,long long mod){
    if(mod==1)
        return 1;
    long long x,y;
    long long pm=phi(mod);
    long long d=gcd(mod,pm);
    long long t=solve(a,d);
    long long at=power(a,t,mod);
    exgcd(mod/d,pm/d,x,y);
    x=x*(((t-at)%pm+pm)%pm)/d;
    x=((x%(pm/d))+pm/d)%(pm/d)+pm/d;
    return x*mod+at;
}
long long a,mod;
int main(){
    int q;
    SF("%d",&q);
    while(q--){
        SF("%lld%lld",&a,&mod);
        PF("%lld\n",solve(a,mod));
    }
}


Measured memory_bytes: 128
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let k: i64 = scan(tokens);
    let x: i64 = scan(tokens);
    for i in x - k + 1..x + k - 1 {
        print!("{} ", i)
    }
    println!("{}", x + k - 1);
}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    int a1 = a + b;
    int a2 = a + c;
    int a3 = b + c;
    int res = min(a1, min(a2, a3));
    cout << res << endl;


    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; i++){
        cin >> s.at(i);
        sort(s.at(i).begin(), s.at(i).end());
    }
    
    sort(s.begin(), s.end());
    
    int count = 1;
    long long pattern = 0;
    
    for(int i = 0; i < n - 1; i++){
        if(s.at(i) == s.at(i + 1)){
            count++;
        }else{
            pattern += count * (long long)(count - 1) / 2;
            count = 1;
        }
    }
    
    if(count != 1){
        pattern += count * (long long)(count - 1) / 2;
    }
    cout << pattern << endl;
} 


Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map>       // pair
using namespace std;
#define rep(start, end) for (int i = (start); i < (end); ++i)
typedef long long ll;

int main()
{
    ll n;
    cin >> n;
    vector<pair<int, int>> pairs(n);

    rep(0, n)
    {
        int a, b;
        cin >> a >> b;
        pairs[i] = make_pair(b, a);
    }

    // firstが小さい順、secondが小さい順にソート
    sort(pairs.begin(), pairs.end());

    ll sum = 0;
    bool ok = true;
    rep(0, n)
    {
        sum += pairs[i].second;
        if (sum > pairs[i].first)
        {
            ok = false;
            break;
        }
    }
    //puts(""); // => (0,0) (1,1) (1,9) (4,2) (4,8) (5,5) (6,4) (6,6) (9,3) (9,7)
    cout << (ok ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector> 
using namespace std;
 
long long f_gcd (long long n1, long long n2){
	long long a = n1, b = n2;
	if(n2 < n1){
		a = n2;
		b = n1;
	}
	long long r = a % b;
	while(r != 0){
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

int main(){
	long long a,b,c,d,gcd,lcm,cnt=0;
	cin >> a >> b >> c >> d;

	gcd = f_gcd(c,d);
	lcm = c / gcd * d;

	cnt = ((b / c) - ((a-1) / c)) + ((b / d) - ((a-1) / d)) - ((b / lcm) - ((a-1) / lcm));


	cout << b+1 - a - cnt << endl;

}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque

N = int(input())

chars = "abcdefghij"

queue = deque()
queue.append(('a', 1))

ans = []

while queue:
    s, num = queue.popleft()
    if len(s) == N:
        print(s)
    else:
        for i in range(num+1):
            ss = s + chars[i]
            if i == num:
                queue.append((ss, num+1))
            else:
                queue.append((ss, num)) 

Measured memory_bytes: 64856
/*input
4 10
1 2 3 4
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

const int N = 2001;
int a[N];
int pref[N][N];

void solve(){
  	int n,x;
  	cin >> n >> x;
  	RE(i,n){
  		cin >> a[i];
  	}
  	RE(i,n){
  		pref[i][0] = a[i];
  		for(int j = 1;j < n;j++){
  			int br = i-j;
  			if(br <= 0)br += n;
  			pref[i][j] = min(pref[i][j-1],a[br]);
  		}
  	}
  	int ans = INF;
  	for(int j = 0;j < n;j++){
  		int suma = 0;
  		for(int i= 1;i <= n;i++)suma += pref[i][j];
  		ans = min(ans,suma+x*j);
  	}
  	cout << ans << endl;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

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

int main() {
    long long Q, H, S, D, N; cin >> Q >> H >> S >> D >> N;
    long long one = min({Q * 4, H * 2, S}), two = min(one * 2, D);
    long long ans = 0;
    if (N % 2) ans += one;
    ans += N / 2 * two;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int dfs(vector<vector<int>> &c, int v = 0){
	int deg = c[v].size();
	vector<int> x;
	for (int w : c[v]){
		x.push_back(dfs(c, w));
	}
	sort(x.begin(), x.end());
	reverse(x.begin(), x.end());
	int ans = 0;
	for (int i = 0; i < deg; i++){
		ans = max(ans, x[i] + i);
	}
	ans++;
	return ans;
}
int main(){
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 1; i < N; i++){
		cin >> a[i];
		a[i]--;
	}
	vector<vector<int>> c(N);
	for (int i = 1; i < N; i++){
		c[a[i]].push_back(i);
	}
	cout << dfs(c) - 1 << endl;
}

Measured memory_bytes: 18488
#include<iostream>
using namespace std;
long long whh[100]={0};
int m;
int main(){
	cin>>m;
	whh[0]=2;whh[1]=1;
	for(int i=2;i<=m;i++){
		whh[i]=whh[i-1]+whh[i-2];
	}
	cout<<whh[m]<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let x: i64 = read();

    let mut a = vec![1i64];
    let mut p = vec![1i64];

    for i in 0..n {
        let a_i = a[i] as i64 * 2 + 3;
        let p_i = p[i] as i64 * 2 + 1;
        a.push(a_i);
        p.push(p_i);
    }

    println!("{}", dfs(n, x, &a, &p));
}

fn dfs(n: usize, x: i64, a: &[i64], p: &[i64]) -> i64 {
    if n == 0 {
        if x <= 0 {
            0
        } else {
            1
        }
    } else if x <= 1 + a[n - 1] {
        dfs(n - 1, x - 1, a, p)
    } else {
        p[n - 1] + 1 + dfs(n - 1, x - 2 - a[n - 1], a, p)
    }
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	set_range_search
# CreatedDate:  2020-07-25 12:57:11 +0900
# LastModified: 2020-07-25 13:36:16 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    q = int(input())
    ans = set()
    for _ in range(q):
        s = list(map(int, input().split()))
        if s[0] == 0:
            ans.add(s[1])
            print(len(ans))
        elif s[0] == 1:
            if s[1] in ans:
                print(1)
            else:
                print(0)
        elif s[0] == 2:
            if s[1] in ans:
                ans.remove(s[1])
        else:
            if len(ans) > s[2] - s[1]:
                for i in range(s[1], s[2]+1):
                    if i in ans:
                        print(i)
            else:
                ans = sorted(ans)
                for a in ans:
                    if s[1] <= a and a <= s[2]:
                        print(a)
                ans = set(ans)


if __name__ == "__main__":
    main()



Measured memory_bytes: 23368
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <cstdlib>
#include <bitset>

using namespace std;
int mat[3][3] = { 0 };
struct Myst
{
	int a[3] = { 0,0,0 };
	int b[3] = { 0,0,0 };
	bool af[3] = { false, false, false };
	bool bf[3] = { false, false, false };
}st;

int func(int i, int j, Myst sst) {

	if (j >= 3) {
		i++;
		j = 0;
		if (i >= 3) {
			cout << "Yes" << endl;
			

			exit(0);
		}
	}

	if (sst.af[i] == true && sst.bf[j] == true) {
		if (sst.a[i] + sst.b[j] == mat[i][j]) {
			func(i, j + 1, sst);
		}
		else {
			return 0;
		}
	}

	if (sst.af[i] == true) {
		sst.b[j] = mat[i][j] - sst.a[i];
		sst.bf[j] = true;
		func(i, j + 1, sst);
	}else
	if (sst.bf[j] == true) {
		sst.a[i] = mat[i][j] - sst.b[j];
		sst.af[i] = true;
		func(i, j + 1, sst);
	}
	else {

		for (int k = 0; k <= mat[i][j]; k++) {
			sst.a[i] = k;
			sst.b[j] = mat[i][j] - k;
			sst.af[i] = true;
			sst.bf[j] = true;
			func(i, j + 1, sst);
		}

	}
}

int main() {
	int i, j, k;
	Myst sst;

	for (i = 0; i < 3; i++) {
		for (j = 0; j < 3; j++) {
			cin >> mat[i][j];
		}
	}


	func(0, 0, sst);



	cout << "No" << endl;







	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr long long INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    long long N,K;cin >> N >> K;
    ll ans = 0;
    REPP(i,1,N+1){
        ans += max(0LL,i - K)*(N/i) + max(0LL,N%i - K + 1);
    }
    if(K == 0) ans = N*N;
    cout << ans << endl;
}

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

int main() {
    ll n,m;
    cin>>n>>m;
    vector<ll> path[n+1];
    ll ans[n+1]={0};
    for (int i = 0; i < m; ++i) {
        ll a,b;
        cin>>a>>b;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    queue<ll> now;
    now.push(1);
    while(!now.empty()){
        ll basho=now.front();
        now.pop();
        for (int i = 0; i < path[basho].size(); ++i) {
            ll saki=path[basho][i];
            if(ans[saki]==0){
                ans[saki]=basho;
                now.push(saki);
            }
        }
    }
    cout<<"Yes"<<endl;
    for (int j = 1; j < n; ++j) {
        cout<<ans[j+1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 12936
#include<bits/stdc++.h>
#define LL long long int
using namespace std;
int i,j,k,n,m,f=0,lis[200000]={0},suu,x;
int bin1[200000],bin2[200000];
int main(void)
{
	cin>>n>>m;
	for(i=0;i<m;i++) 
		cin>>bin1[i]>>bin2[i];
	for(i=0;i<m;i++) {
		if(n==bin2[i]) lis[bin1[i]]=1;
	}
	for(i=0;i<m;i++) {
		if(lis[bin2[i]]==1&&bin1[i]==1) cout<<"POSSIBLE"<<endl,f=1;
	}
	if(f==0) cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 2560
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
int64_t X;
int64_t x[200000];

int64_t func(int64_t stream)
{
	int64_t res = 0;
	int64_t k = 1;
	for (int32_t i = N-1; i >= 0; i-= stream)
	{
		++k;
		for (int32_t j = i; j > std::max<int32_t>(-1, i- stream); j--)
		{
			int64_t add = k * k - (k - 1)*(k - 1);
			if (k == 2) { add = 4; res += x[j]; }
			res += add* x[j];
		}
	}

	return res + stream * X + X * N;
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N >> X;

	for (int32_t i = 0; i < N; i++)
	{
		in >> x[i];
	}

	using BS_INT = int64_t;
	BS_INT ok_range = 1, ng_range = N + 1;
	while (std::abs(ok_range - ng_range) > 2) {
		BS_INT mid1 = ok_range - (ok_range - ng_range) / 3;
		BS_INT mid2 = ok_range - (ok_range - ng_range)*2 / 3;

		//ここに書く

		int64_t score1 = func(mid1), score2= func(mid2);


		if (score1 < score2) {
			ng_range = mid2;
		}
		else {
			ok_range = mid1;
		}
	}
	int64_t score1 = func(ok_range), score2 = func(ok_range+1);

	out << std::min(score1, score2) << endl;

	return 0;
}
#endif


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

int partition(int A[], int p, int r){
  int x = A[r];
  int i = p - 1;
  for(int j = p;j<r;j++){
    if(A[j] <= x){
      i++;
      swap(A[i], A[j]);
    }
  }
  swap(A[i+1], A[r]);
  return i+1;
}

int main(){
  int n, A[100010];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  int st = partition(A, 0, n-1);
  for(int i=0;i<n;i++){
    if(i) cout<<" ";
    if(i == st) cout<<"[";
    cout<<A[i];
    if(i == st) cout<<"]";
  }
  cout<<endl;
  return 0;
}
  
      



Measured memory_bytes: 3460
#include<iostream>
#include<string>
#include<cstdint>
using namespace std;
int main(){
	int64_t a, b, k, x, y;
	cin >> a >> b >> k;
	if (a <= k){
		x = 0;
		if (b + a - k <= 0){
			y = 0;
		}
		else{
			y = a + b - k;
		}
	}
	else{
		x = a - k;
		y = b;
	}
	cout << x << " " << y << endl;
	system("pause");
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n, d;
    cin >> n >> d;
    cout << (n + (2*d+1) -1)/(2*d+1) << endl;
    return 0;
}

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

int main()
{
    int x,y,z;
    while(~scanf("%d%d%d",&x,&y,&z))
    {
       if(z>=x&&z<=x+y)
       {
           printf("YES\n");
       }
       else
       {
           printf("NO\n");
       }
    }
    return 0;
}


Measured memory_bytes: 128
import Debug.Trace

main = do
  [x,y] <- map read . words <$> getLine :: IO [Int]
  print $ solve x y

solve x y =
  ans
  where
    calc x' y' acc
      | x'>y' = acc
      | otherwise =
        traceShow x' $
        calc (x'*2) y' (acc+1)
    ans = calc x y 0
    
    


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

using namespace std;
using u64 = std::uint_fast64_t;

class RollingHash {
 private:
  using u64 = std::uint_fast64_t;

  const u64 mod = ((u64)1 << 61) - 1;
  std::vector<u64> hashes, pows;

  inline u64 add(u64 a, u64 b) const {
    a += b;
    if (a >= mod) a -= mod;
    return a;
  }

  inline u64 sub(u64 a, u64 b) const {
    if (a < b) a += mod;
    a -= b;
    return a;
  }

  inline u64 mul(u64 a, u64 b) const {
    u64 ah = a >> 31, al = a & (((u64)1 << 31) - 1), bh = b >> 31,
        bl = b & (((u64)1 << 31) - 1), m = ah * bl + al * bh,
        v = (ah * bh << 1) + (m >> 30) + ((m & (((u64)1 << 30) - 1)) << 31) +
            al * bl;
    v = (v & (((u64)1 << 61) - 1)) + (v >> 61);
    return v;
  }

 public:
  template <typename T>
  RollingHash(const T &S, u64 base = 10007)
      : hashes(S.size() + 1, 0), pows(S.size() + 1, 0) {
    pows[0] = 1;
    for (size_t i = 0; i < S.size(); i++) {
      pows[i + 1] = mul(pows[i], base);
      hashes[i + 1] = add(mul(hashes[i], base), S[i]);
    }
  }

  // S[r, l)
  u64 slice(int l, int r) const {
    return sub(hashes[r], mul(hashes[l], pows[r - l]));
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  string S;
  cin >> S;
  RollingHash rh(S);

  auto f = [&](int d) -> bool {
    map<u64, int> mp;
    for (int i = 0; i + d < N + 1; i++) {
      u64 x = rh.slice(i, i + d);
      if (mp.count(x)) {
        if (i - mp[x] >= d) return true;
      } else {
        mp[x] = i;
      }
    }
    return false;
  };

  int lo = 0, hi = N + 1;
  while (lo < hi) {
    int mi = (lo + hi + 1) >> 1;

    if (f(mi)) {
      lo = mi;
    } else {
      hi = mi - 1;
    }
  }

  cout << lo << '\n';
  return 0;
}


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

int main() {
  int A, B, C;
  cin >> A;
  cin >> B;
  C=0;
     for (int i = 0;i < 10000; i++) {
     if ((C-1)*(A-1)+A >= B ){
       break;}
       C++;
  }
  cout << C << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/


signed main() {
	int h, w; cin >> h >> w;
	int cnt = 0;
	rep(i, h)rep(j, w) {
		char c; cin >> c;
		if (c == '#')cnt++;
	}
	cout << (cnt == h + w - 1 ? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#define lowbit(a) ((a)&(-(a)))
using namespace std;

void file(bool opt)
{
	if (opt&&fopen("in.txt", "r"))
	{
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
}

int main()
{
	int a, p;
	cin >> a >> p;
	cout << (a * 3 + p) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = [i+1 for i in range(N)]

S = 0
for x in range(1, N+1):
    if x % 15 == 0:
        a[x-1] = "FizzBazz"
    elif x % 3 == 0:
        a[x-1] = "Fizz"
    elif x % 5 == 0:
        a[x-1] = "Bazz"
    else:
        a[x-1] = x
        S += x
print(S)

Measured memory_bytes: 48484
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String x = br.readLine();
		String[] cut = x.split(" ");
		int a = Integer.parseInt(cut[0]);
		int b = Integer.parseInt(cut[1]);
		System.out.println((a - 1) * (b - 1));
	}
}

Measured memory_bytes: 21332
import math

def factorial(n):
    ans = 1
    for i in range(2, n+1):
        ans *= i
    return ans

N = int(input())
XY = []
for _ in range(N):
    XY.append(list(map(int, input().split())))

sum_dist = 0
cnt = 0
for i in range(N):
    for j in range(i+1, N):
        sum_dist += math.sqrt((XY[i][0]-XY[j][0])**2 + (XY[i][1]-XY[j][1])**2)
        cnt += 1

print(sum_dist * (N-1) / cnt)



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


int A[5][5];

int main(){
	vector<int> v;
	for(int i=1;i<=3;i++){
		for(int j=1;j<=3;j++){
			cin >> A[i][j];
		}
	}
	
	v.push_back(A[1][1]+A[2][2]+A[3][3]);
	v.push_back(A[1][1]+A[2][3]+A[3][2]);
	
	v.push_back(A[1][2]+A[2][1]+A[3][3]);
	v.push_back(A[1][2]+A[2][3]+A[3][1]);
	
	v.push_back(A[1][3]+A[2][1]+A[3][2]);
	v.push_back(A[1][3]+A[2][2]+A[3][1]);
	
	
	for(int i=1;i<v.size();i++){
		if(v[i]!=v[i-1]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int maxn=200003;

map<ll,ll> primefactor(ll n){
  map<ll,ll> res;
  for( ll i=2LL ;i*i<=n;i++){
    while(n%i==0){
      ++res[i];
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}


vector<int> g[10];
int n,m;
int dfs(int s,int bit){
  if(bit==(1<<n)-1)return 1;
  int res=0;
  for(int i=0;i<g[s].size();i++){
    if(!(bit>>g[s][i]&1)  ){
      res+=dfs(g[s][i],bit | (1<<g[s][i]));
    }
  }
  return res;
}
int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  cout<<dfs(0,1)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <vector>       // ヘッダファイルインクルード
using namespace std;
int main()
{
    // 整数の入力
    int num;
    cin >> num;
    
    vector<int> val(num);
    vector<int> cost(num);

    for (int i = 0; i < num; i++) 
    {
        cin >> val[i];
    }
    
    for (int i = 0; i < num; i++) 
    {
        cin >> cost[i];
    }
    
    int ans = 0;
    
    for (int i = 0; i < num; i++) 
    {
        if ((val[i] - cost[i]) > 0)
        {
            ans += val[i] - cost[i];
        }
    }
    
    
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#coding:utf-8

s = input()
s_arr = list(s)

n = 0
l = len(s_arr)

ans = 0
b_count = 0
for i in range(l, 0, -1):
    if i == l:
        if s_arr[i-1] == 'B':
            b_count += 1
    else:
        if s_arr[i-1]=='B':
            ans += l - i - b_count
            b_count += 1


print(ans)

Measured memory_bytes: 4840
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std ;

int main(){
	
	double n , r , m[3] ;
	
	while( cin >> m[0] >> m[1] >> m[2] , m[0] ){
		
		sort( m , m+3 ) ;
		m[2] = sqrt( m[0]*m[0] + m[1]*m[1] ) ;
		
		cin >> n ;
		
		for( int i=0 ; i<n ; i++ ){
			cin >> r ;
			if( r*2 > m[2] ) cout << "OK" ;
			else cout << "NA" ;
			cout << endl ;
		}
	}
	
return 0 ;
}

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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

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

   int ans=0;
   if(n>0) ans+=n*(n-1)/2;
   if(m>0) ans+=m*(m-1)/2;

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


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

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

struct edge{
    ll to, cost;
};


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

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

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

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

int main(){
    while(true){
        ll n, x;
        cin>>n>>x;
        if(n == 0 and x == 0){
            break;
        }

        ll ans = 0;
        for(ll i=1;i<=n;++i){
            for(ll j=i+1;j<=n;++j){
                for(ll k=j+1;k<=n;++k){
                    if(i + j + k == x){
                        ans++;
                    }
                }
            }
        }
        cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 3076
#import sys

#input = sys.stdin.readline

#import heapq
#import math
#import fractions

#def sosuhante(n):
#    for k in range(2, int(math.sqrt(n))+1):
#        if n% k ==0:
#            return False
#    return True

def main():
#    h,w,a,b = map(int, input().split())
    s = input()
    k= int(input())
    a= []
    b= []
    n=len(s)
    for i in range(n):
        a.append(s[i])
        b.append(s[i])

    a[0]="a"
    if n > 1:
        for i in range(1,n):
            if b[i]==b[i-1]:
                a[i]="a" if a[i-1]=="a" else "b"
            else:
                a[i]="b" if a[i-1]=="a" else "a"
#    print(a)
    temp=1
    henka=0
    if n > 1:
        for i in range(1,n):
            if a[i]==a[i-1]:
                temp+=1
                if i==n-1:
                    henka+=temp//2
                    temp=1
            else:
                henka+=temp//2
                temp=1
    temp=1
    hasi=0
    mae=1
    usiro=1
    if k > 1 and n > 1 and b[0]==b[n-1]:
        for i in range(1,n):
            if a[i]==a[i-1]:
                temp+=1
                if i==n-1:
                    mae=temp
            else:
                mae=temp
                break
        temp=1
        for i in range(n-2,-1,-1):
            if a[i]==a[i+1]:
                temp+=1
                if i==0:
                    usiro=temp
            else:
                usiro=temp
                break
        if (mae+usiro)//2 > mae//2 + usiro//2:
            hasi=1
#    print(henka,"henka")
    count=0
    if k > 1 and n>1:
        count=henka*k + hasi*(k-1)
    if k == 1 and n>1:
        count=henka
    if n==1 and k==1:
        count=0
    if n==1 and k>1:
        count=k//2
    if mae==usiro and mae==n:
        count=(n*k)//2


    print(count)





if __name__ == "__main__":
    main()

Measured memory_bytes: 3192
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include<bits/stdc++.h>
using namespace std;
	typedef long long ll;
	const int maxn=100050;
	ll a,b,c,n;
	string s[maxn]; 
	bool ans;
	string ot;
	void dfs(int i){
		if(ans)
			return ;
		if(!(a>=0&&b>=0&&c>=0))
			return ;
		if(i==n+1){
			ans=1;
			return ;
		}
		if(s[i]=="AB"){
			a--;b++;
			ot+='B';
			dfs(i+1);
			if(ans)
				return ;
			ot.erase(ot.end()-1);
			a++,b--;
			
			a++,b--;
			ot+='A';
			dfs(i+1);
			if(ans)
				return ;
			a--,b++;
			ot.erase(ot.end()-1);
			
		}
		else if(s[i]=="AC"){
			a--;c++;
			ot+='C';
			dfs(i+1);
			if(ans)
				return ;
			ot.erase(ot.end()-1);
			a++,c--;
			
			a++,c--;
			ot+='A';
			dfs(i+1);
			if(ans)
				return ;
			a--;c++;
			ot.erase(ot.end()-1);
		}
		else{
			b--;c++;
			ot+='C';
			dfs(i+1);
			if(ans)
				return ;
			ot.erase(ot.end()-1);
			b++,c--;
			
			
			b++,c--;
			ot+='B';
			dfs(i+1);
			if(ans)
				return ;
			b--;c++;
			ot.erase(ot.end()-1);
		}
		return ;
	}
	int main(){
		cin>>n>>a>>b>>c;
		for(int i=1;i<=n;i++)
			cin>>s[i];
		dfs(1);
		if(ans){
			cout<<"Yes"<<endl;
			for(char ch:ot)
				cout<<ch<<endl;
		}
			
		else
			cout<<"No"<<endl;
		return 0;
	}//芜湖，起飞飞飞飞飞飞~~~~

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

int main() {
	int n;
	cin >> n;
	for(int i = 1; i <= 9; ++i)
		for(int j = 1; j <= 9; ++j)
			if(i * j == n)
				return cout << "Yes", 0;
	cout << "No";
}


Measured memory_bytes: 3584
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
#define LL long long



int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << a + b + c - max(a, max(b, c)) << endl;

	return 0;
}

Measured memory_bytes: 256