akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	VI A(N), S(N), L(N + 1);
	L[0] = 0;
	REP(i, N) {
		cin >> A[i];
		S[i] = A[i];
	}
	SORT(S);
	int right = N - 1, left = 0;
	while (right!=left) {
		int j = (right + left + 1) / 2;
		int num = S[j];
		REP(i, N) {
			if (A[i] >= num) {
				L[i + 1] = 1;
			}
			else {
				L[i + 1] = -1;
			}
		}
		eFOR(i, 1, N)L[i] += L[i - 1];

		int cnt, t = 0;
		VI bit(2 * N + 2, 0);
		REP(i, N + 1) {
			int first = L[i] + N + 1;
			for (int x = first; x <= 2 * N + 1; x += x & -x)bit[x]++;
			
			int sum = 0;
			for (int x = first; x >= 1; x -= x & -x)sum += bit[x];
			t += i + 1 - sum;
		}
		cnt = N * (N + 1) / 2 - t;
		if (cnt >= (N*(N + 1) / 2 + 1) / 2) {
			left = j;
		}
		else {
			right = j - 1;
		}
	}
	cout << S[left] << endl;
	return 0;
}



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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1
#define j0 gray_cat_j0

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

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

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 16;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int v[2][MAXN];

int cnt[MAXN];

void solve(){
	int n, k;
	scanf("%d%d", &n, &k);
	REP(i, 0, n) {
		scanf("%d", &v[1][i]);
	}
	REP(j, 0, k) {
		int fl = 0;
		if (j > 10) {
			REP(i, 0, n) {
				if (v[0][i] != v[1][i]) {
					fl = 1;
					break;
				}
			}
			if (!fl) {
				break;
			}
		}
		REP(i, 0, n) {
			v[0][i] = v[1][i];
			v[1][i] = 0;
			cnt[i] = 0;
		}
		cnt[n] = 0;
		
		REP(i, 0, n) {
			int l = max(0, i - v[0][i]);
			int r = min(n - 1, i + v[0][i]);
			cnt[l]++;
			cnt[r + 1]--;
		}
		REP(i, 0, n) {
			if (i) {
				cnt[i] += cnt[i - 1];
			}
			v[1][i] = cnt[i];
		}
	}
	REP(i, 0, n) {
		printf("%d ", v[1][i]);
	}
	putchar('\n');
}

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 6080
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    if (args.length > 0 && args(0) == "TEST") {
      println(test())
    } else {
      val input = io.Source.stdin.getLines().mkString("\n")
      println(solve(input).trim())
    }
  }

  def solve(input: String): String = {
    val s: Scanner = new Scanner(input)
    val a,b,c = s.nextInt
    if (c == 0) "YES"
    else {
      def modByB(n: Int): Stream[Int] = ((a * n) % b) #:: modByB(n + 1)
      if (modByB(1).take(b-1).contains(c)) "YES"
      else "NO"
    }
  }

  val tests = List(
    """7 5 1""" -> """YES""",
    """2 2 1""" -> """NO""",
    """1 100 97""" -> """YES""",
    """40 98 58""" -> """YES""",
    """77 42 36""" -> """NO"""
  )

  def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }
    .zipWithIndex.map {
    case ((input, outputExpect), i) =>
      val output = solve(input).trim()
      val tnum = i + 1
      s"test$tnum:" + (
        if (output == outputExpect) "Passed"
        else s"Failed\nexpect:\n$outputExpect\noutput:\n$output")
  }
    .mkString("\n")
}

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

using namespace std;

typedef long double lld;
typedef pair<int,int> P;


int xy[51][2];
double dis(int a, int b){
    return pow(lld(xy[a][0]-xy[b][0])*lld(xy[a][0]-xy[b][0])+lld(xy[a][1]-xy[b][1])*lld(xy[a][1]-xy[b][1]), 0.5);
}

int main(){
    int n;
    cin >> n;
    
    for(int i = 0; i < n; i++) cin >> xy[i][0] >> xy[i][1];

    if(n == 2){
        cout << fixed << setprecision(15) <<  pow(dis(0,1)*dis(0,1),0.5)/2 << endl;
        return 0;
    }
    lld ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            for(int k = j+1; k < n; k++){
                lld r = 0;
                lld A = (dis(j,i)*dis(j,i)+dis(i,k)*dis(i,k)-dis(j,k)*dis(j,k))/(2*dis(i,j)*dis(i,k));
                if(A <= 0){
                    r = dis(j,k)/2;
                }else{
                    A = pow(1-A*A, 0.5);
                    r = dis(j,k)/(2*A);
                    if(dis(i,j)*dis(i,j)+dis(j,k)*dis(j,k) < dis(i,k)*dis(i,k)) r = dis(i,k)/2;
                    if(dis(i,k)*dis(i,k)+dis(j,k)*dis(j,k) < dis(i,j)*dis(i,j)) r = dis(i,j)/2;
                }
                ans = max(ans, r);
            } 
        }
    }
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}

Measured memory_bytes: 384
INF=10**30
H,N=map(int,input().split())
A,B=[],[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a);B.append(b)
dp=[INF]*(H+10)
dp[0]=0
for i in range(N):
    for j in range(H+1):
        if(j<A[i]):
            dp[j]=min(dp[j],dp[0]+B[i])
        else:
            dp[j]=min(dp[j],dp[j-A[i]]+B[i])
print(dp[H])

Measured memory_bytes: 46556
using System;
using CompLib.Util;

public class Program
{
    private int N;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        int[] tmp = new int[N + 1];
        for (int i = 0; i <= N; i++)
        {
            tmp[i] = i;
        }

        long[] div = new long[N + 1];
        for (int i = 1; i <= N; i++)
        {
            div[i] = 1;
        }


        for (int i = 2; i * i <= N; i++)
        {
            if (tmp[i] != 1)
            {
                for (int j = i; j <= N; j += i)
                {
                    int cnt = 0;
                    while (tmp[j] % i == 0)
                    {
                        cnt++;
                        tmp[j] /= i;
                    }

                    div[j] *= (cnt + 1);
                }
            }
        }

        for (int i = 1; i <= N; i++)
        {
            if (tmp[i] != 1) div[i] *= 2;
        }

        long ans = 0;
        for (int i = 1; i <= N; i++)
        {
            ans += i * div[i];
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 144928
#define cross(a1, b1, a2, b2) ((a1)*(b2)-(a2)*(b1))
int main(){
	double a[20],b[20],s,t,x;
	int n=0,c=1,i;
	for(;~scanf("%lf,%lf",a+n,b+n);n++);
	for(i=s=t=0;i<n-1;i++){
		if((x=cross(a[i],b[i],a[i+1],b[i+1]))>0)s+=fabs(x)/2.0;
		else t+=fabs(x)/2;
	}
	if((x=cross(a[i],b[i],a[0],b[0]))>0)s+=fabs(x)/2;
	else t+=fabs(x)/2;
	printf("%.6f\n",fabs(s-t));
exit(0);}

Measured memory_bytes: 656
#include <iostream>

using namespace std;

int main(){
  int H,W;

  cin >> H >> W;

  char s[H+2][W+2];

  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      cin >> s[i][j];
    }
  }

  for(int i=0;i<H+2;i++){
    s[i][0] = '.';
    s[i][W+1] = '.';
  }
  for(int i=0;i<W+2;i++){
    s[0][i] = '.';
    s[H+1][i] = '.';
  }

  bool answer = true;

  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      if(s[i][j]=='#'){
        if(s[i-1][j] == '#' || s[i][j-1] == '#' || s[i+1][j] == '#' || s[i][j+1] == '#'){
          answer = true;
        }else{
          answer = false;
        }
      }
      if(!answer){
        i=H+1;
        j=W+1;
      }
    }
  }

  if(answer){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


  return 0;
}

Measured memory_bytes: 256
object Main extends App {
	val pw = new java.io.PrintWriter(System.out)

	@scala.annotation.tailrec
	def loop(start: Int, end: Int)(f: Int => Unit): Unit =
		if (start <= end) {
			f(start)
			loop(start + 1, end)(f)
		}

	val n, m, k = Scanner.nextInt

	val friend, blocked = Array.fill(n+1)(0)
	val uf = UnionFind(1 to n)

	Seq.fill(m)((Scanner.nextInt, Scanner.nextInt)) foreach { case (a, b) =>
		uf.unite(a, b)
		friend(a) = friend(a) + 1
		friend(b) = friend(b) + 1
	}

	Seq.fill(k)((Scanner.nextInt, Scanner.nextInt)) foreach { case (c, d) =>
		if (uf.same(c,d)) {
			blocked(c) = blocked(c) + 1
			blocked(d) = blocked(d) + 1
		}
	}

	loop(1, n) { i =>
		pw.print( (uf.size(i) - 1 - friend(i) - blocked(i)).toString + " " )
	}
	pw.flush()
}

case class UnionFind[T](seq: Seq[T]) {
	import scala.collection.mutable.Map
	private[this] val par: Map[T, T] = Map[T,T](seq.map(elem => elem -> elem): _*)
	private[this] val sz: Map[T, Int] = Map[T, Int](seq.map(elem => elem -> 1): _*)

	@scala.annotation.tailrec
	private[this] def find(t: T, acc: Seq[T] = Nil): T = {
		val p = par(t)
		if (p == t) {acc foreach { par(_) = t }; t} else find(p, p +: acc)
	}

	def unite(a: T, b: T): Unit = {
		val pa = find(a)
		val pb = find(b)

		if (pa == pb) return

		if (sz(pa) <= sz(pb)) {
			par(pa) = pb
			sz(pb)  = sz(pa) + sz(pb)
		} else {
			par(pb) = pa
			sz(pa)  = sz(pa) + sz(pb)
		}
	}

	def same(a: T, b: T) = find(a) == find(b)

	def size(a: T) = sz(find(a))
}

object Scanner {
	private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0

	@inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
	@inline private def hasNextByte(): Boolean = if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else true
	@inline private def hasNext(): Boolean = {
		while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
		hasNextByte()
	}
	@inline private def readByte(): Byte = if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else -1

	def next(): String = {
		if(!hasNext()) ???
		val sb = new StringBuilder; var b = readByte()
		while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
		sb.toString
	}

	def nextInt(): Int = {
		val n = nextLong()
		if (n < Int.MinValue || Int.MaxValue < n) ???
		n.toInt
	}

	def nextLong(): Long = {
		if(!hasNext()) ???
		var minus = false; var b = readByte()
		if (b == '-') { minus = true; b = readByte() }

		@scala.annotation.tailrec
		def go (b: Byte, n: Long = 0): Long = if ('0' <= b && b <= '9') go(readByte(), n * 10 + b - '0') else if (minus) -n else n

		go(b)
	}

	def nextDouble(): Double = next().toDouble
}

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

int main() {
	int N;
	int K;
	char str[50];
	scanf("%d", &N);
	scanf("%d ", &K);
	for (int i = 0; i < N; i++) {
		scanf("%c",&str[i]);
	}
	str[K-1] = tolower(str[K-1]);

	for (int i = 0; i < N; i++) {
		printf("%c", str[i]);
	}
	return 0;
}


Measured memory_bytes: 256
/*
 * Pawan Harendra Mishra
 */

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

#define X first
#define Y second
typedef long long ll;
typedef pair<ll,ll> pll;

int main(int argc, char const *argv[])
{
    //ios::sync_with_stdio(false);
    //cin.tie(NULL);

    string s, t;
    cin >> s >> t;
    ll count = 0;
    for (ll i=0; i<3; i++) if (s[i] == t[i]) count++;
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  string s;
  cin>>s;
  int ans=0;
  rep(i,6){
    if(s[i]=='1')ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main() {
    int pow[1000001]={}, i, j, n, a[1000001], s=0, t=0, k=0, b[1000000],com[1000001]={}, comb[1000001]={};
    for(i=1;i<=1000000;i++)
    {
        if(i%2)
        {}
        else
            pow[i]=1+pow[i/2];
    }
    scanf("%d", &n);
    for(i=0;i<=n-2;i++)
    {
        if(i==0)
            comb[i]=0;
        else
        {
            comb[i]=comb[i-1]+pow[n-i-1]-pow[i];
        }
        if(comb[i])
            com[i]=0;
        else
            com[i]=1;
    }
    for(i=1;i<=n;i++)
        scanf("%1d", &a[i]);
    for(i=1;i<=n-1;i++)
        {
            if(a[i+1]>a[i])
                b[i]=a[i+1]-a[i];
            else
                b[i]=a[i]-a[i+1];
                
            s+=(b[i]%2);
        }
    if(s==0)
    {
        for(i=1;i<=n-1;i++)
        {
            b[i]/=2;
        }
        for(i=1;i<n;i++)
        {
            k+=b[i]*com[i-1];
            k%=2;
        }
    }
    else
    {
        for(i=1;i<=n-1;i++)
        {
        t+=b[i]*com[i-1];
        t%=2;
        }
    }
    

    if(t)
        printf("1");
    else if(s)
        printf("0");
    else if(k)
        printf("2");
    else
        printf("0");
    
    return 0;
}

Measured memory_bytes: 19840
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		HashSet<String>map = new HashSet<String>();

		for (int i=0; i<n; i++){
			map.add(sc.next());
		}
		System.out.println(map.size());
	}
}

Measured memory_bytes: 67276
#include <iostream>
#include <cstring>
using namespace std;
int main(){
  int len, ct=0;
  char str[16];
  cin >> str;
  len=strlen(str);
  for(int i=0; i<len; i++){
    if(str[i]=='o')
      ct++;
  }
  if(7-len+ct>=0)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    cout << N*N*N <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;



int main(void) {
  string n;
  cin >> n ;
  bool ok = false;
  rep(i,n.size())if(n[i]=='7')ok = true;
  if(ok)cout << "Yes" << endl;
  else cout << "No" << endl;
}






Measured memory_bytes: 3588
N, H = map(int, input().split())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

max_a = max(A)
B.sort(key=lambda b:-b) # descending                                                                                                                          

ans = 0
for b in B:
    if b < max_a:
        break
    H -= b
    ans += 1
    if H <= 0:
        print(ans)
        exit()
ans += (H-1) // max_a + 1 # ceil                                                                                                                              
print(ans)

Measured memory_bytes: 21392
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
const int INF=1e9;

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



int main(){
    int n, q;
    string s;
    cin>>n>>q>>s;
    vector<int> l(q), r(q), sum(n+1, 0);
    for(int i=0; i<q; i++){
        cin>>l[i]>>r[i];
    }
    for(int i=1; i<n; i++){
        sum[i+1]=sum[i];
        if(s[i-1]=='A'&&s[i]=='C'){
            sum[i+1]++;
        }
    }
    for(int i=0; i<q; i++){
        cout<<sum[r[i]]-sum[l[i]]<<endl;
    }
    
}


Measured memory_bytes: 2304
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const ll INF=1000000000;
int n;
ll w;
ll w1[101],v[101];
ll v2[4][101]={};
ll s[4]={};
ll mi=INF;
ll reg(int n1,int w2){
	if(n1==4)return 0;
	ll res=0,t=0;
	res=max(res,reg(n1+1,w2));
	for(int i=s[n1]-1;i>=0;--i){
		t+=v2[n1][i];
		if(w2+(mi+n1)*(s[n1]-i)>w)break;
		res=max(res,reg(n1+1,w2+(mi+n1)*(s[n1]-i))+t);
	}
	return res;
}
int main() {
	cin>>n>>w;
	for(int i=0;i<n;++i){
		cin>>w1[i]>>v[i];
		mi=min(mi,w1[i]);
	}
	for(int i=0;i<n;++i){
		ll a=w1[i]-mi;
		v2[a][s[a]]=v[i];
		s[a]++;
	}
	for(int i=0;i<4;++i)sort(v2[i],v2[i]+s[i]);

	cout<<reg(0,0)<<endl;
	return 0;
}


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

using namespace std;

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

    int zero = 0;
    int one = 0;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == '0')
            ++zero;
        else
            ++one;
    }
    cout << min(zero, one) * 2 << '\n';
}


Measured memory_bytes: 512
from itertools import permutations
n,m=map(int,input().split())
s=[set(map(int,input().split())) for _ in range(m)]

ans=0
x=[i for i in range(2,n+1)]
cand=permutations(x)
for i in cand:
  crnt=1
  for nxt in i:
    if set([crnt,nxt]) in s:
      crnt=nxt
    else:
      break
  else:
    ans+=1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl

int main() {
    int x;
    cin >> x;
    if (x == 3 || x == 5 || x == 7) ct("YES");
    else ct("NO");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int N,M; cin >> N >> M ;
    vector<int> s(M);
    vector<int> c(M,0);
    bool res = true;
    map<int,int> mp;
    rep(i,M) {
        cin >> s[i] >> c[i];
        if (mp[s[i]] !=0 ){
            if (mp[s[i]] != c[i]){
                res = false;
                break;
            }
        }
        mp[s[i]] = c[i];
        if (N>1 && s[i] ==1 && c[i] == 0){
            res = false;
            break;
        }
    }
    if (!res) cout << -1 << endl;
    else {if (N==1){
        int d = 0;
        rep(i,M){
            d = c[i];
        }
        cout << d ;
    }
        else if(N==2){
            vector<int> d = {1,0};
            rep(i,M){
                d[s[i]-1] = c[i];
            }
            rep(i,2){
            cout << d[i];
            }
        }
        else {
            vector<int> d ={1,0,0};
            rep(i,M){
                d[s[i]-1] = c[i];
            }
            rep(i,3){
            cout << d[i] ;
            }
        }
    }
}


Measured memory_bytes: 256
n, l = map(int, input().split())
taste = list(range(l, n + l))
ans = 0

if taste.count(0) == 1:
  ans = sum(taste)
elif max(taste) < 0:
  taste.remove(max(taste))
  ans = sum(taste)
else:
  taste.remove(min(taste))
  ans = sum(taste)
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<queue>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<functional>
#include<set>
using namespace std;
#define int long long
int a[5];
signed main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (s[0] == 'M')a[0]++;
		else if (s[0] == 'A')a[1]++;
		else if (s[0] == 'R')a[2]++;
		else if (s[0] == 'C')a[3]++;
		else if (s[0] == 'H')a[4]++;
	}
	cout << a[0] * a[1] * a[2] + a[0] * a[1] * a[3] + a[0] * a[1] * a[4]
		+ a[0] * a[2] * a[3] + a[0] * a[2] * a[4] + a[0] * a[3] * a[4] +
		a[1] * a[2] * a[3] + a[1] * a[2] * a[4] + a[1] * a[3] * a[4] + a[2] * a[3] * a[4] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
int main(void) {
    string s;
    cin >> s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;
    return 0;
}

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

constexpr int MAX_N = 1e5+7;
int h[MAX_N];
int dp[MAX_N];

int main() {
  int N;
  cin >> N;
  for (int i{}; i < N; ++i) {
    cin >> h[i];
  }

  dp[0] = 0;
  dp[1] = abs(h[1]-h[0]);
  for (int i{2}; i < N; ++i) {
    dp[i] = min(dp[i-2] + abs(h[i]-h[i-2]), dp[i-1] + abs(h[i]-h[i-1]));
  }

  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	ll n; cin >> n;
	FOR(a, 1, 3501)
	{
		FOR(b, 1, 3501)
		{
			ll x = a * b * n;
			ll y = 4 * a * b - b * n - a * n;
			if (y == 0) continue;
			if (x % y == 0 && x / y > 0)
			{
				cout << a << " " << b << " " << x / y << endl;
				return 0;
			}
		}
	}
	assert(false);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
// const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 1e6+1;
const int MOD = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

long long modpow(long long res,long long a, long long n, long long mod) {
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//sieve(MAX);でベクトルIsPrimeに「MAXまでの数値の素数の真偽」を格納する。
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}
// ここから開始
int main(){
  ll a,b;
  cin>>a>>b;
  
  ll ans = 0;
  ll start;
  ll end;
  if(a%2==0) {
    start = a;
  }
  else{
    start = a+1;
    ans = ans^a;
  }
  if(b%2==0) {
    end = b-1;
    ans = ans^b;
  }
  else {
    end = b;
  }
  ll x = (end-start+1)/2;
  if(x%2!=0) ans = ans^1;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    map<string, int> mp;
    rep(i,n) {
        string s; cin>>s;
        mp[s]++;
    }

    cout << "AC x " << mp["AC"] << '\n';
    cout << "WA x " << mp["WA"] << '\n';
    cout << "TLE x " << mp["TLE"] << '\n';
    cout << "RE x " << mp["RE"] << '\n';

    return 0;
}

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

int main(){

    int y,m,d;
    char c1,c2;
    cin >> y >> c1 >> m >> c2 >> d;

    if(m<4)cout << "Heisei" << endl;
    else if(m==4 and d<=30)cout << "Heisei" << endl;
    else cout << "TBD" << endl;

    return 0;

}


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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define SORT(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> P;

int main(){
	int n,k;
	cin>>n>>k;
	if(n%k==0){
		cout <<0 <<endl;
	  }
	  else{
		  cout<<1<<endl;
		}
  }



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

int main(void)
{
    int i;
    int x, y;

    for (;;) {
        if (scanf("%d %d", &x, &y) == EOF) {
            break;
        }
        x += y;
        for (i = 1; ; i++) {
            x /= 10;
            if (x == 0) {
                break;
            }
        }
        printf("%d\n", i);
    }

    return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define rep1(i,s,e) for(int i=s;i<e;i++)
#define rep2(i,s,e,c) for(int i=s;i>=e;i--)
#define pfi(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define pfn() printf("\n")
#define pfs() printf(" ")
#define sfi(x) scanf("%d",&x)
#define sfi1(x,y) scanf("%d%d",&x,&y)
#define sff(x) scanf("%lf",&x)
#define sfl(x) scanf("%lld",&x)
#define memset1(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
const int MAX = 1e4 + 50;
const int mod = 996873654;
double arr[100];
int main(){
	int n;
	sfi(n);
	for(int i=0;i<n;i++){
		scanf("%lf",&arr[i]);
	}
	sort(arr,arr+n);
	double sum=arr[0];
	for(int i=1;i<n;i++){
		sum = 1.0*(sum+arr[i])/2;
	}
	printf("%.8lf",sum);
	return 0;
}

Measured memory_bytes: 256
S = list(input())

hantei = True
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "R" or S[i] == "U" or S[i] == "D":
             continue
        else:
            hantei = False
            break
    else:
        if S[i] == "L" or S[i] == "U" or S[i] == "D":
             continue
        else:
            hantei = False
            break
if hantei:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
// E - Virus Tree 2
#include <bits/stdc++.h>

using namespace std;

#define	MOD	1000000007

long long mpow(long long x, long long n)
{
	long long r = 1;
	for ( ; n > 0; x = x * x % MOD, n >>= 1)
		if (n & 1) r = r * x % MOD;
	return r;
}

bool failed = false;
long long n, k;
vector<vector<int> > g;
vector<long long> o;
vector<long long> f(100000 + 1, 1);

long long dfs(int u, int parent)
{
	long long c = k - 1 - (parent < 0 ? 0 : 1), r = o[u] - (parent < 0 ? 0 : 1);
	if (r > c) return 0;
	long long sum = f[c] * mpow(f[r], MOD - 2) % MOD * mpow(f[c - r], MOD - 2) % MOD * f[r] % MOD;
	for (int i = 0; i < g[u].size(); i++) {
		int v = g[u][i];
		if (v == parent) continue;
		sum = sum * dfs(v, u) % MOD;
	}
	return sum;
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);

	for (long long i = 2; i < f.size(); i++) f[i] = f[i - 1] * i % MOD;

	cin >> n >> k;
	g.resize(n);
	o.resize(n);
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		g[u].push_back(v);
		g[v].push_back(u);
		o[u]++; o[v]++;
	}

	cout << (dfs(0, -1) * k % MOD) << "\n";

	return 0;
}


Measured memory_bytes: 13184
#include<bits/stdc++.h>
#define ll long long
#define INF 1e11
using namespace std;
unordered_map<ll,ll> s;
set<ll> p;
ll n,A,B,C,D;
int t;
ll tr(ll x,ll y){
	if (INF/(x-y)>=D)return D*(x-y);
	return INF;
}
void get(ll x,ll y){
	if (s[x]==0){s[x]=y;p.insert(x);}else s[x]=min(s[x],y);
}
int main(){
	cin>>t;
	while (t--){
		s.clear();p.clear();
		cin>>n>>A>>B>>C>>D;p.insert(n);
		if (n==1){cout<<D<<endl;continue;}
		s[0]=min((A+D)*70,min((B+D)*48,(C+D+D)*30));
		while (!p.empty()){
			auto g=p.end();g--;
			ll x=(*g);p.erase(g);
			ll y=s[x];if (y>s[0])continue;
			get(x/2,y+min(A+D*(x-(x/2)*2),tr(x,x/2)));
			if (x%2!=0)get(x/2+1,y+min(A+D,tr(x,x/2+1)));
			if (x%3<=1)get(x/3,y+min(B+D*(x-(x/3)*3),tr(x,x/3)));
			else get(x/3+1,y+min(B+D*((x/3+1)*3-x),tr(x,x/3+1)));
			if (x%5<3)get(x/5,y+min(C+D*(x-(x/5)*5),tr(x,x/5)));
			else get(x/5+1,y+min(C+D*((x/5+1)*5-x),tr(x,x/5+1)));
		}
		cout<<s[0]<<endl;
	}
	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for (int i=1; i<=n; i+=2) {
        int dn = 0;
        for (int j=1; j<=i; j++) {
            if (i%j==0) ++dn;
        }
        if (dn==8) ++ans;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int   H,W,i,j;
  
    while(1){
        scanf("%d",&H);
        scanf("%d",&W);
        if(H == 0 && W == 0){
            break;
        }
        for(i = 0;i<H;i++){
           for(j = 0;j<W;j++){
               if(i==0||i==H-1||j==0||j==W-1){
                   printf("#");
               }else{
                   printf(".");
               }
           }
           printf("\n");
        }
        printf("\n");
    }
  return 0;
}


Measured memory_bytes: 2132
#include<cstdio>
#include<iostream>
#include<list>
#include<cstring>
#include<stack>
#include<string>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;

const int maxn = 100100;
int arr[maxn], n, k;
int check(long long num)
{
	int i = 1, tot=0;
	long long curWeight = 0;
	while (i <= n)
	{
		curWeight = 0;
		while (curWeight <= num&&i<=n)
		{
			if (arr[i] > num)
				return 0;
			curWeight += arr[i];
			i++;
		}
		if (curWeight > num)
			i--;
		tot++;
		
			
	}
	if (tot <= k)
		return 1;
	else

		return 0;
}
void sol()
{
	long long l = 1, r = 100000000000;
	long long m;

	long long  ret;
	while (l <= r) {
		m = (l + r) >> 1;
		if (check(m)) {
			ret = m;
			r = m - 1;
		}
		else
			l = m + 1;
		
	}
	cout << ret << endl;
}
int main()
{
	while (scanf("%d%d", &n, &k) == 2)
	{
		for (int i = 1; i <= n; i++)
			scanf("%d", &arr[i]);
		sol();
	}
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int 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 fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    int cnt = 0;
    REP(i, 1, n) {
        int p;
        cin >> p;
        if (p != i) cnt++;
    }
    if (cnt <= 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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


Measured memory_bytes: 3644
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
#define all(v) v.begin(), v.end()
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<int,int>;
using Mat = vector<vector<int>>;
const ll inf = 1e18;
const int N = 2e5+10;


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

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

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


li = []
li2 = []
count1 = 0
count2 = 0
kaijyou = 1
for i in range(1, N):
    kaijyou *= i
kaijyoucpy = kaijyou
for i in range(1, N+1):
    li.append(i)
    li2.append(i)
for i in range(N-1):

    count1 += (li.index(P[i])) * kaijyou
    li.remove(P[i])
    kaijyou  = kaijyou // (N - 1- i)

kaijyou = kaijyoucpy
for i in range(N-1):
    count2 += (li2.index(Q[i]))  * kaijyou
    li2.remove(Q[i])
    kaijyou = kaijyou // (N - 1 - i)

print(abs(count1 - count2))

Measured memory_bytes: 38384
def factorize(n):
    fct = []
    b,e = 2,0
    while b*b <= n:
        while n % b==0:
            n = n // b
            e += 1
        if e > 0:
            fct.append((b,e))
        b,e = b+1,0
    if n > 1:
        fct.append((n,1))
    return fct

n = int(input())

def d(n):
    l = factorize(n)
    r = 1
    for i,j in l:
        r *= int(j)+1
    return r
ans = 0

import math
ans = d(math.factorial(n))%1000000007

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;


int main() {
	int N, K; cin >> N >> K;
	vector<ll> a(N + 1), acc(N + 1);
	for (int i = 1; i <= N; i++) cin >> a[i];
	for (int i = 1; i <= N; i++) acc[i] += acc[i - 1] + a[i];
	vector<string> b;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j <= N; j++) {
			ll w = acc[j] - acc[i];
			string s;
			for (int j = 0; j < 63; j++) {
				s += (w&1) ? "1" : "0";
				w /= 2;
			}
			//reverse(s.begin(), s.end());
			b.push_back(s);
		}
	}
	ll ans = 0;
	bool ng[1000005] = {};
	for (int t = 62; t >= 0; t--) {
		int cnt = 0;
		for (int i = 0; i < (int)b.size(); i++) {
			if (ng[i]) continue;
			if (b[i][t] == '0') continue;
			cnt++;
		}
		if (cnt >= K) {
			ans += 1LL << (ll)t;
			for (int i = 0; i < (int)b.size(); i++) {
				ng[i] |= b[i][t] == '0';
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 60012
#include<stdio.h>
#include<algorithm>
using namespace std;
int g[500][500];
int dp[17][1<<16];
int dat[500];
int val[20];
int main(){
	int a,b,c,d,e;
	while(scanf("%d%d%d%d%d",&a,&b,&c,&d,&e),a){
		d--;
		for(int i=0;i<a;i++){
			for(int j=0;j<a;j++)g[i][j]=999999999;
			g[i][i]=0;
			dat[i]=-1;
		}
		for(int i=0;i<b;i++){
			int p,q,r;
			scanf("%d%d%d",&p,&q,&r);
			p--;q--;
			g[p][q]=g[q][p]=r;
		}
		for(int k=0;k<a;k++){
			for(int i=0;i<a;i++){
				for(int j=0;j<a;j++)g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
			}
		}
		for(int i=0;i<c+1;i++){
			for(int j=0;j<(1<<c);j++)dp[i][j]=999999999;
		}
		dp[c][0]=0;
		for(int i=0;i<c;i++){
			int p,q;
			scanf("%d%d",&p,&q);
			p--;
			val[i]=p;
			dat[p]=q;
		}
		val[c]=d;
		for(int i=0;i<(1<<c);i++){
			for(int j=0;j<c+1;j++){
		//		printf("%d ",dp[j][i]);
				for(int k=0;k<c+1;k++){
					if(k==c)dp[k][i]=min(dp[k][i],dp[j][i]+g[val[j]][val[k]]);
					if(k<c&&!(i&(1<<k)))dp[k][i+(1<<k)]=min(dp[k][i+(1<<k)],dp[j][i]+g[val[j]][val[k]]+dat[val[k]]);
				}
			}
		//	printf("\n");
		}
		int ret=0;
		for(int i=(1<<c)-1;i>=0;i--){
			for(int j=0;j<c+1;j++)
				if(dp[j][i]+g[val[c]][val[j]]<=e){	
					ret=max(ret,__builtin_popcount(i));
				}
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 5968
N, M = map(int, input().split())
drinks = [list(map(int, input().split())) for _ in range(N)]

drinks.sort()
count = 0
cost = 0
for idx, drink in enumerate(drinks):
    count += drink[1]
    cost += drink[0]*drink[1]
    if count >= M:
        break

cost -= drinks[idx][0] * (count - M)
print(cost)

Measured memory_bytes: 27880
n,k = input().split()
n = int(n)
k = int(k)
l = [0] * n

for i in range(k):
    tmp = int(input())
    tmp2 = list(map(int,input().split()))
    for j in range(tmp):
        l[tmp2[j]-1] = 1

print(l.count(0))


Measured memory_bytes: 67820
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	private static FastScanner sc = new FastScanner();
	private static char[] op = {'N', 'W', 'W', 'W', 'N', 'N'};

	public static void main(String[] args) {

		int[] num = new int[6];
		for(int i=0; i<num.length; i++) {
			num[i] = sc.nextInt();
		}

		Dice dice1 = new Dice(num);

		for(int i=0; i<num.length; i++) {
			num[i] = sc.nextInt();
		}

		Dice dice2 = new Dice(num);

		for(int i=0; i<op.length; i++) {
			for(int j=1; j<=4; j++) {

				boolean flag = true;
				for(int k=0; k<num.length; k++) {
					if(dice1.getNum(k) != dice2.getNum(k)) {
						flag = false;
						break;
					}
				}

				if(flag) {
					System.out.println("Yes");
					return;
				}

				dice2.spin();
			}

			dice2.lotate(op[i]);
		}

		System.out.println("No");

	}

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

	static class Dice {

		//0:?????¢???1:S??´??¢???2:E??´??¢???3:W??´??¢???4:N??´??¢???5:?????¢
		int[] num = new int[6];

		Dice(int[] num) {
			for(int i=0; i<num.length; i++){
				this.num[i] = num[i];
			}
		}

		int getNum(int idx){
			return num[idx];
		}

		void lotate(char direction) {
			int temp;
			switch(direction) {
			case 'N':
				temp = num[0];
				num[0] = num[1];
				num[1] = num[5];
				num[5] = num[4];
				num[4] = temp;
				break;

			case 'S':
				temp = num[0];
				num[0] = num[4];
				num[4] = num[5];
				num[5] = num[1];
				num[1] = temp;
				break;

			case 'W':
				temp = num[0];
				num[0] = num[2];
				num[2] = num[5];
				num[5] = num[3];
				num[3] = temp;
				break;

			case 'E':
				temp = num[0];
				num[0] = num[3];
				num[3] = num[5];
				num[5] = num[2];
				num[2] = temp;
				break;
			}
		}

		//????¨????????????????
		void spin() {
			int temp = num[1];
			num[1] = num[2];
			num[2] = num[4];
			num[4] = num[3];
			num[3] = temp;
		}

	}

}

Measured memory_bytes: 24480
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define vv vector< vector< int > >
#define ll long long
#define ALL(a) (a).begin(), (a).end()
const long long mod = 1000000000 + 7;
const long long INF = 9e18;
const double PI = 3.14159265358979323846;

ll gcd(ll a, ll b){if (b == 0) return a;return gcd(b, a % b);}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

int stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}

int main(){
    string S, ans="AC";
    cin >> S;
    if(S[0] != 'A') ans = "WA";
    else {
        S[0] = 'a';
        string sub;
        sub = S.substr(2, S.length()-3);
        if(stringcount(sub, 'C') != 1) ans = "WA";
        else {
            S[S.find('C')] = 'c';
            for(char c : S) {
                if(!islower(c)) {
                    ans = "WA";
                    break;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3580
# import numpy as np

# import sys
# sys.setrecursionlimit(200000)

K, A, B = list(map(int, input().split(" ")))

if B - A < 2:
    print(K + 1)
elif K < A - 1:
    print(K + 1)
else:
    free = K - (A - 1)
    if free % 2 == 0:
        print(A + (B - A) * (free // 2))
    else:
        print(A + (B - A) * (free // 2) + 1)



Measured memory_bytes: 3060
#include<stdio.h>
int main(){
  int a,b,i;
  scanf("%d%d",&a,&b);
  if(a>b)
    for(i=0;i<a;i++)
      printf("%d",b);
  else
    for(i=0;i<b;i++)
      printf("%d",a);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	while(n!=0)
	{
		int s;
		s=n%10;
		if(s==7)
		{
			cout<<"Yes";
			return 0;
		}
		else
		n/=10;
	}
	cout<<"No";
}

Measured memory_bytes: 3600