akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int n,a;
vector<int> x(60);
ll dp[60][60][3000];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>a;
    rep(i,n) cin>>x[i];
    rep(i,60) dp[i][0][0]=1;
    rep(i,n)FOR(j,1,i+2)rep(k,3000){
      //if(j==1 && k==0) dp[i][j][k]=1;
      if(k>=x[i]) dp[i+1][j][k]=dp[i][j-1][k-x[i]]+dp[i][j][k];
      else dp[i+1][j][k]=dp[i][j][k];
    }
    //cout<<dp[n][1][8]<<endl;
    ll ans=0;
    /*
    rep(i,n)FOR(j,1,i+2)rep(k,33){
      cout<<i+1<<' '<<j<<' '<<k<<' '<<dp[i+1][j][k]<<endl;
    }
    */
    FOR(j,1,n+1)rep(k,3000){
      if(j*a==k){
        ans+=dp[n][j][k];
        //cout<<j<<' '<<k<<' '<<dp[n][j][k]<<endl;
      }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 82176
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = int.Parse(Console.ReadLine());
            int ret = 0;
            for (int i = 0; i < r; i++)
            {
                ret += i + 1;
            }
            Console.WriteLine(ret);
        }
    }
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    while(cin >> n && n)
    {
        int a[n], b[n], asum = 0, bsum = 0;
        for(int i=0;i<n;i++) cin >> a[i] >> b[i];
        for(int i=0;i<n;i++)
        {
            if(a[i] > b[i]) asum += a[i] + b[i];
            else if(a[i] == b[i]) {asum += a[i];bsum += b[i];}
            else bsum += a[i] + b[i];
        }
        cout << asum << " " << bsum << "\n";
    }
    
    return 0 ;
}



Measured memory_bytes: 3156
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}
signed main(){
	string s;cin>>s;
	int flag=1,SF=0,VF=0;
	const int MAX_Z=16000;
	//flag=1:横を向いている
	vi R,U;
	rep(i,s.size()){
		if(s[i]=='F'){//前に進むとき横の移動量が増える
			if(flag==1) SF++;
			if(flag==0) VF++;
		}
		else{//回転するとき右または上に行き続けた場合を配列に入れる
			flag=1-flag;
			if(s[i+1]=='F'){
				if(flag==1)R.push_back(SF),SF=0;
				if(flag==0)U.push_back(VF),VF=0;
			}
		}
	}
	R.push_back(SF);U.push_back(VF);
	int x,y;
	cin>>x>>y;
	bool ok=false;
	auto f=[MAX_Z](vi a,int z,bool flag){
		int n=a.size();
		vvi dp(a.size()+1,vi(MAX_Z+1,0));
		dp[0][MAX_Z/2]=1;
		rep(i,n){
			
			rep(j,MAX_Z+1){
				if(j-a[i]>=0) dp[i+1][j]=dp[i][j-a[i]];
				if(i==0){
					if(flag&&j+a[i]<=16000) dp[i+1][j]=max(dp[i+1][j],dp[i][j+a[i]]);
				}
				else{ 
					if(j+a[i]<=16000)dp[i+1][j]=max(dp[i][j+a[i]],dp[i+1][j]);		    	
				}
			}
			//cout<<a[i]<<" "<<dp[i+1][8004]<<endl;
		}
		if(dp[n][z+MAX_Z/2]==1) return true;
		return false;
	};
	Yn(f(R,x,false)&&f(U,y,true));
}

Measured memory_bytes: 334216
#include<bits/stdc++.h>
#define mk make_pair
using namespace std;
char s[10005];
int x,y,n,f[2][20005];
vector<int>v[2];
int main()
{
	scanf("%s",s+1);
	scanf("%d%d",&x,&y);
	n=strlen(s+1);
	s[n+1]='T';
	int nw=0,tmp=0,flag=0;
	for(int i=1;i<=n+1;i++)
	{
		if(s[i]=='F')tmp++;
		else
		{
			if(!flag)
			{
				x-=tmp;flag=1;
			}
			else
			{
				v[nw].push_back(tmp);
			}
			nw^=1;tmp=0;
		}
	}
	nw=0;int pr=1;
	f[0][8005]=1;
	for(int i=0;i<v[0].size();i++)
	{
		memset(f[pr],0,sizeof(f[pr]));
		nw^=1;pr^=1;
		for(int j=0;j<=17000;j++)
		{
			if(f[pr][j]==0)continue;
			f[nw][j+v[0][i]]=1;
			f[nw][j-v[0][i]]=1;
		}
	}
	if(x<(-8000)||f[nw][8005+x]==0)return puts("No"),0;
	
	
	memset(f,0,sizeof(f));
	nw=0;pr=1;
	f[0][8005]=1;
	for(int i=0;i<v[1].size();i++)
	{
		memset(f[pr],0,sizeof(f[pr]));
		nw^=1;pr^=1;
		for(int j=0;j<=17000;j++)
		{
			if(f[pr][j]==0)continue;
			f[nw][j+v[1][i]]=1;
			f[nw][j-v[1][i]]=1;
		}
	}
	if(f[nw][8005+y]==0)return puts("No"),0;
	
	puts("Yes");
	return 0;
} 

Measured memory_bytes: 512
var
x,a,b,e,min,i,j:longint;
begin
readln(x);
readln(a);
readln(b);
min:=maxlongint;
for j:=1 to x div b do
 if (1*a+j*b)<=x then if x-(1*a+j*b)<min then min:=x-(1*a+j*b);
write(min);
end.

Measured memory_bytes: 128
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

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

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

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

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

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

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

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

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

use std::collections::VecDeque;

fn bfs(adj: &Vec<Vec<usize>>, dist: &mut Vec<i64>, start: usize) {
  dist[start] = 0;
  let mut q = VecDeque::new();
  q.push_back(start);
  while let Some(v) = q.pop_front() {
    let d = dist[v];
    for &next in &adj[v] {
      if dist[next] < d {
        continue;
      }
      dist[next] = d + 1;
      q.push_back(next);
    }
  }
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    u: usize1,
    v: usize1,
    es: [(usize1, usize1); n-1],
  }
  let mut adj = vec![vec![]; n];
  for &(a, b) in &es {
    adj[a].push(b);
    adj[b].push(a);
  }
  let mut adist = vec![1i64 << 60; n];
  bfs(&adj, &mut adist, v);
  let mut tdist = vec![1i64 << 60; n];
  bfs(&adj, &mut tdist, u);
  let mut max_ad = 0;
  for i in 0 .. n {
    if tdist[i] <= adist[i] {
      max_ad = cmp::max(max_ad, adist[i]);
    }
  }

  puts!("{}\n", max_ad - 1);
}


Measured memory_bytes: 16636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int n = Integer.parseInt(strArr[0]);
		int m = Integer.parseInt(strArr[1]);

		int a = n;
		int b = m;
		if (n < m) {
			a = m;
			b = n;
		}
		if (a - b > 1) {
			System.out.println(0);
			return;
		}
		long ans = 1;
		if (a == b)
			ans = 2;
		final long MOD = 1000000007;
		for (long i = 1; i <= a; i++)
			ans = (ans * i) % MOD;
		for (long i = 1; i <= b; i++)
			ans = (ans * i) % MOD;
		System.out.println(ans);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {
	}
}


Measured memory_bytes: 22740
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  int a,b; cin >>a >>b;
  printf("%d",6-a-b);
}

/// confirm df==0 ///


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		ArrayDeque<Integer> deque = new ArrayDeque<>();

		int loop = in.nextInt();
		for(int i = 0; i < loop; i++) {
			int odr = Integer.parseInt(in.next()), wild = Integer.parseInt(in.next());

			switch(odr) {
				case 0:
					if(wild == 0 ) deque.addFirst(Integer.parseInt(in.next()));
					else deque.addLast(Integer.parseInt(in.next()));
					break;

				case 1:
					Iterator<Integer> itr = deque.iterator();
					for(int j = 0; j < wild; j++)itr.next();
					out.println(itr.next());
					break;

				case 2:
					if(wild == 0)deque.removeFirst();
					else deque.removeLast();
					break;
			}
		}
		out.flush();
		in.close();
	}

}



Measured memory_bytes: 186472
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n,m,p;
vector<pair<int,int> >g[2555];
int dist[2555];
signed main(){
	cin>>n>>m>>p;
	for(int i=1;i<=m;i++){
		int a,b,c;cin>>a>>b>>c;c-=p;
		g[a].push_back(make_pair(b,-c));
//		g[b].push_back(make_pair(a,-c));
	}
	memset(dist,inf,sizeof dist);
	dist[1]=0;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			for(auto p:g[j]){
				int to=p.first,cos=p.second;
				if(dist[to]>dist[j]+cos){
					dist[to]=dist[j]+cos;
				}
			}
		}
	}
	for(int i=1;i<=m;i++)
	for(int j=1;j<=n;j++){
		for(auto p:g[j]){
			int to=p.first,cos=p.second;
			if(dist[to]>dist[j]+cos){
				dist[to]=dist[j]+cos;
				if(to==n){
					puts("-1");return 0;
				}
			}
		}
	}
	cout<<max(0ll,-dist[n])<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;

void A() {
	for (int i = 0; i < 5; i++) {
		int x; cin >> x;
		if (x != i + 1) {
			cout << i + 1 << endl;
			return;
		}
	}
}

void B() {
	int X, Y; cin >> X >> Y;
	if (Y % 2 != 0) {
		pNo; return;
	}

	if (Y >= 2 * X && (Y - 2 * X) % 2 == 0) {
		pYes; return;
	}
	else {
		pNo; return;
	}
}

void C() {
	int X, N; cin >> X >> N;
	set<int> s;
	for (int i = 0; i < N; i++) {
		int p; cin >> p;
		s.insert(p);
	}

	int high = X + 1;
	int low = X - 1;

	while (true) {
		if (s.find(X) == s.end()) {
			cout << X << endl;
			return;
		}

		if (s.find(low) == s.end()) {
			cout << low << endl;
			return;
		}

		if (s.find(high) == s.end()) {
			cout << high << endl;
			return;
		}

		high++; low--;
	}
}
int main() {
	C();
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define pb push_back

using namespace std;

const int up = 9e5 + 5;
int tree[up << 2];

void update(int node, int l, int r, int pos, int val) {
    if(l == r) {
        tree[node] = max(tree[node], val);
    }else {
        int mid = (l + r) >> 1;
        if(pos <= mid) {
            update(node << 1, l, mid, pos, val);
        }else {
            update((node << 1) | 1, mid + 1, r, pos, val);
        }
        tree[node] = max(tree[node << 1], tree[(node << 1) | 1]);
    }
}

int ask(int node, int l, int r, int ql, int qr) {
    if(l > qr || ql > r) {
        return 0;
    }
    if(ql <= l && r <= qr) {
        return tree[node];
    }
    int mid = (l + r) >> 1;
    int q1 = ask(node << 1, l, mid, ql, qr);
    int q2 = ask((node << 1) | 1, mid + 1, r, ql, qr);
    return max(q1, q2);
}
int main()
{
    ios_base::sync_with_stdio(false);
    int n, k, a, cur, best = 0;
    cin >> n >> k;
    for(int i = 0; i < n; ++i) {
        cin >> a;
        a += (k + 1);
        cur = ask(1, 1, up - 1, a - k, a + k) + 1;
        best = max(cur, best);
        update(1, 1, up - 1, a, cur);
    }

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

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

public class Solution
{
    public static void Main()
    {
        var N = long.Parse(Console.ReadLine());
        var digits = 1;
        for (long i = 26; true; i *= 26)
        {
            if (N <= i)
            {
                break;
            }
            N -= i;
            digits++;
        }
        N--;

        var name = new List<int>();
        for (int d = 0; d < digits; d++)
        {
            name.Add((int)(N % 26));
            N /= 26;
        }
        name.Reverse();
        var answer = string.Join("", name.Select(i => (char)(i + 'a')));
        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 28372
n = int(input())
temp = input()
h = temp.split()
for i,item in enumerate(h):
    h[i] = int(item)
dp = [0]
for i,height in enumerate(h):
    if i >=2:
        step1 = dp[i - 1] + abs(height - h[i-1])
        step2 = dp[i-2] + abs(height - h[i-2])
        dp.append(step1 if step1 <= step2 else step2)
    elif i == 1:
        dp.append(abs(height - h[i-1]))

print(dp.pop())



Measured memory_bytes: 12060
const main = stdin => {
  const [A, B, C, K] = stdin.trim().split(' ').reduce((acc, value) => {
    acc.push(parseInt(value))
    return acc
  }, [])

  if (A >= K) {
    console.log(K)
  } else if (B >= K - A) {
    console.log(A)
  } else {
    console.log(A - (K - A - B))
  }
}


// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 29944
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
vector <int> v[10];
int fix[10],ans,n,m;
void dfs (int x,int r){
      if (r == n) ans++;
      fix[x] = 1;
      for (int i = 0; i < v[x].size(); i++){
            int to = v[x][i];
            if (!fix[to]) dfs(to,r + 1);
      }
      fix[x] = 0;
      return;
} 
int main (){
  cin >> n >> m;
  
    for (int i = 1; i <= m; i++){
          int a,b;
          cin >> a >> b;
          v[a].pb(b);
          v[b].pb(a);
    }
    dfs(1,1);
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


#include <bits/stdc++.h>
using namespace std;
signed main(){
    int N; cin>>N;
    int ans = 1;
    FOR(i,1,N+1){
        ans *= i;
        ans %= mod;
    }
    Out(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1005;
int a[maxn]; 
int main(void)
{
	int n,m; scanf("%d%d",&n,&m);
	int sum=0;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) sum+=a[i];
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(4*m*a[i]>=sum) cnt++;
	}
	if(cnt>=m) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;

  vll h(n + 1);
  rep(i, n) {
    cin >> h[i];
  }

  ll ans = 0;

  rep(l, n) {
    while (h[l] > 0) {
      ll r = l + 1;
      for (r = l + 1; r < n; r++) {
        if (h[r] <= 0) {
          break;
        }
      }

      for (ll i = l; i < r; i++) {
        h[i]--;
      }
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 85
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

bitset <25605> dp[85][85],s;
const int N=12800;
int n,m,a[85][85],b[85][85];

int main()
{
	n=read(); m=read();
	rep(i,1,n) rep(j,1,m) a[i][j]=read();
	rep(i,1,n) rep(j,1,m) b[i][j]=read();
	dp[1][1][a[1][1]-b[1][1]+N]=1; dp[1][1][b[1][1]-a[1][1]+N]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(a[i][j]-b[i][j]>=0)
			{
				a[i][j]-=b[i][j];
				if(i!=1) dp[i][j]|=(dp[i-1][j]<<a[i][j]),dp[i][j]|=(dp[i-1][j]>>a[i][j]);
				if(j!=1) dp[i][j]|=(dp[i][j-1]<<a[i][j]),dp[i][j]|=(dp[i][j-1]>>a[i][j]);
			}
			else
			{
				a[i][j]-=b[i][j]; a[i][j]=-a[i][j];
				if(i!=1) dp[i][j]|=(dp[i-1][j]<<a[i][j]),dp[i][j]|=(dp[i-1][j]>>a[i][j]);
				if(j!=1) dp[i][j]|=(dp[i][j-1]<<a[i][j]),dp[i][j]|=(dp[i][j-1]>>a[i][j]);
			}
		}
	}
	int ans=inf;
	for(int i=0;i<=25601;i++) if(dp[n][m][i]) ans=min(ans,abs(i-N));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 22400
N, M = gets.split.map(&:to_i)
switches = M.times.map{gets.split.map{|c| c.to_i - 1}[1..-1]}
p = gets.split.map(&:to_i)

ans = 0
(1 << N).times do |i|
  flag = true
  switches.each_with_index do |s, idx|
    on = 0
    s.each do |v|
      on += 1 if (i >> v) & 1 == 1
    end
    flag &= on % 2 == p[idx]
  end
  ans += 1 if flag
end
puts ans

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

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

int main() {
    int n,sum=0;
    ll a;
    cin >> n;
    rep(i, n) {
        cin >> a;
        auto s = prime_factor(a);
        sum += s[2];
    }
    cout << sum << endl;
    return 0;
}

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

int main() {
  int K, S;
  cin >> K >> S;

  int count = 0;

  for (int X = 0; X <= K; X++) {
    for (int Y = 0; Y <= K; Y++) {
      int Z = S - X - Y;
      if (Z >= 0 && Z <= K) {
        count++;
      }
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void){
    double a,b,c,d,e,f,A,x,y,X,Y,Z;

    while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=EOF){


    Y=a*e-b*d,Z=f*a-c*d;
    y=Z/Y;

    x=(c-b*y)/a;

   printf("%.3lf %.3lf\n",x,y);
    }
   //printf("\na%lf\nb%lf\nc%lf\nd%lf\ne%lf\nf%lf\n%lf\n%lf",a,b,c,d,e,f,Y,Z);

    return 0;
}

Measured memory_bytes: 1080
#include <bits/stdc++.h>
using namespace std;
int ss[100005];
void ini()
{
    for(int i=0;i<100005;i++)
    {
        ss[i]=i;
    }
}
int main() {
    //ini();
    string s;
    cin>>s;
    int arr[26]={0};
    for(int i=0;i<s.length();i++)arr[s[i]-'A']++;
    int c=0;
    for(int i=0;i<26;i++)
    {
        if(arr[i]&&arr[i]%2==0)c++;
        
    }
    if(c==2)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

// 1 点更新区間取得
// 条件は要素がモノイドであること（あるいは半群？）
// 有名どころは 和, 積, min, max gcd lcm
// プラスアルファで行列 ?

template <typename T>
struct SegmentTree{
    using F = function<T(T, T)>;
    int n;
    F f;
    T ti;
    vector<T> dat;
    SegmentTree(){};
    SegmentTree(F f, T ti, const vector<int> &v):f(f),ti(ti){
        int sz = v.size();
        n = 1;
        while(n < sz) n <<= 1;
        dat.assign(2 * n - 1, ti);
        for(int i = 0; i < sz; i++) dat[n - 1 + i] = v[i];
        for(int i = n - 2; i >= 0; i--) dat[i] = f(dat[2 * i + 1], dat[2 * i + 2]);
    }

    // x 番目(0 - indexed) の要素を val に更新
    void update(int x, T val){
        x += (n - 1);
        dat[x] = val;
        while(x > 0){
            x = (x - 1) / 2;
            dat[x] = f(dat[2 * x + 1], dat[2 * x + 2]);
        }
    }

    // 区間[a, b)を取得する
    T get(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return ti;
        if(a <= l && r <= b) return dat[k];
        T vl = get(a, b, k * 2 + 1, l, (l + r) / 2);
        T vr = get(a, b, k * 2 + 2, (l + r) / 2, r);
        return f(vl, vr);
    }
    
    T get(int  a, int b){
        return get(a, b, 0, 0, n);
    }
};


signed main(){

    int n, q; cin >> n >> q;
    int ti = 0;
    vector<int> v(n, ti);
    // 関数, 単位元, 元の配列の順に宣言
    SegmentTree<int> rmq([](int a, int b){return a + b;}, ti, v);
    
    for(int i = 0; i < q; i++){
        int c, x, y; cin >> c >> x >> y;
        if(c) cout << rmq.get(x - 1, y) << endl;
        else rmq.update(x - 1, y + rmq.get(x - 1, x));
    }

    return 0;
}




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

int main() {
	int h, w, i, j;
	while (1) {
		cin >> h >> w;
		if (h == 0 && w == 0) {
			break;
		}
		else {
			for (i = 0; i < h; i++) {
				for (j = 0; j < w; j++) {
					cout << "#";
				}cout << endl;
			}
			cout << endl;
		}
	}
	return 0;
}


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

int main() {
  int n,a[1000000];
  long long ans=0;
  cin >> n;

  for (long long i = 0; i < 3 * n; i++) {
	cin >> a[i];
  }

  sort(a, a + 3 * n);

  for (long long i = n; i < 3 * n; i++) {
	if (n % 2 == 0 && i % 2 == 0) {
	  ans += a[i];
	}
	else if (n % 2 == 1 && i % 2 == 1) {
	  ans += a[i];
	}
  }
  cout << ans << endl;

}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	string s;
	ll x, y;
	ll ans = 0;

	cin >> s;

	REP(i, s.size()) {
		if (s[i] == 'A') {
			x = i;
			break;
		}
	}

	RREP(i, s.size()) {
		if (s[i] == 'Z') {
			y = i;
			break;
		}
	}

	ans = y - x + 1;

	cout << ans << endl;
}

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

// マクロ
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x));
#define cou(x) cout << x << endl;
#define y() cout << "Yes" << endl;
#define n() cout << "No" << endl;
#define x2(x) x * x

// 型エイリアス
using lint = long long;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;

int main() {

	string s;
	cin >> s;
	rep(i, s.size()) {
		cout << "x";
	}
	cout << endl;
}

Measured memory_bytes: 256
import sys
import math
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template

def make_devisor(n: int):
    x = n
    ret = []
    for i in range(2, int(math.sqrt(n)) + 1):
        cnt = 0
        while x % i == 0:
            cnt += 1
            x //= i
        if cnt != 0:
            ret.append(cnt)
    if x != 1:
        ret.append(1)
    return ret

def main():
    n = ii()
    a = make_devisor(n)
    # print(a)
    ans = 0
    for x in a:
        t = -1
        while (t + 2) * (t + 1) // 2 <= x:
            t += 1
        ans += t
    print(ans)
    return

if __name__ == "__main__":
    main()


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

int main() {
	int n;
	string s;
	cin >> n >> s;
	int res = 0;
	for(int i = 0; i <= n - 3; i++) {
		if (s.substr(i, 3) == "ABC")
			res++;
	}
	cout << res;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

class Dice{
  private:
    int d_1,d_2,d_3,d_4,d_5,d_6;
  public:
    void setDice(int a,int b,int c,int d,int e,int f){
      d_1 = a;
      d_2 = b;
      d_3 = c;
      d_4 = d;
      d_5 = e;
      d_6 = f;
    }
    void roll_w(){
      int tmp = d_1;
      d_1 = d_3;
      d_3 = d_6;
      d_6 = d_4;
      d_4 = tmp;
    }
    void roll_e(){
      int tmp = d_1;
      d_1 = d_4;
      d_4 = d_6;
      d_6 = d_3;
      d_3 = tmp;
    }
    void roll_n(){
      int tmp = d_1;
      d_1 = d_2;
      d_2 = d_6;
      d_6 = d_5;
      d_5 = tmp;
    }
    void roll_s(){
      int tmp = d_5;
      d_5 = d_6;
      d_6 = d_2;
      d_2 = d_1;
      d_1 = tmp;
    }

    void spin(){
      int tmp = d_2;
      d_2 = d_3;
      d_3 = d_5;
      d_5 = d_4;
      d_4 = tmp;
    }

    int findRight(int top,int front){
      for(int i=0;i < 6;i++){
        for(int j=0;j < 4;j++){
          if((*this).d_1 == top && (*this).d_2 == front) return (*this).d_3;
          (*this).spin();
        }
        if(i % 2 == 0)
        (*this).roll_n();
        else
        (*this).roll_w();
      }
      return -1;
    }

    bool cmpDice(Dice d2){
      for(int i=0;i < 6;i++){
        for(int j=0;j < 4;j++){
          if((*this).d_1 == d2.d_1 && (*this).d_2 == d2.d_2 && (*this).d_3 == d2.d_3
          && (*this).d_4 == d2.d_4 && (*this).d_5 == d2.d_5 && (*this).d_6 == d2.d_6){
            return true;
          }
          d2.spin();
        }
        if(i % 2 == 0) d2.roll_n();
        else d2.roll_w();
      }
      return false;
    }

    int getDice(){
      return d_1;
    }

};

int main(){
  int a1,b1,c1,d1,e1,f1;
  int a2,b2,c2,d2,e2,f2;
  Dice D1,D2;
  cin >> a1 >> b1 >> c1 >> d1 >> e1 >> f1;
  cin >> a2 >> b2 >> c2 >> d2 >> e2 >> f2;
  D1.setDice(a1,b1,c1,d1,e1,f1);
  D2.setDice(a2,b2,c2,d2,e2,f2);
  if(D1.cmpDice(D2)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a),q(b),r(c);
    rep(i,a) cin >> p[i];
    rep(i,b) cin >> q[i];
    rep(i,c) cin >> r[i];

    sort(p.rbegin(),p.rend());
    sort(q.rbegin(),q.rend());
    sort(r.rbegin(),r.rend());

    vector<int> s(x+y);

    rep(i,x){
        s[i] = p[i];
    }
    rep1(i,x,x+y){
        s[i] = q[i-x];
    }
    sort(s.begin(),s.end());

    int itr = 0;
    auto z = s.size();
    ll cost = 0;
    rep(i,z){
        if(itr<c && s[i]<r[itr]){
            cost += r[itr];
            itr++;
        }else{
            cost += s[i];
        }
    }
    
    cout << cost << endl;

}

Measured memory_bytes: 2176
n = int(input())

AB = []
for _ in range(n):
    ab = tuple(map(int, input().split()))
    AB.append(ab)

AB_A = sorted(AB, key=lambda x: x[0])
AB_B = sorted(AB, key=lambda x: x[1])

if n%2==1:
    sa, sb = AB_A[n//2]
    la, lb = AB_B[n//2]
    print(lb - sa + 1)
else:
    sal, sbl = AB_A[n//2-1]
    sar, sbr = AB_A[n//2]

    lal, lbl = AB_B[n//2-1]
    lar, lbr = AB_B[n//2]
    print((lbl + lbr) - (sal + sar) +1)


Measured memory_bytes: 42132
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
N = int(input())
S =[int(input()) for i  in range(N)]
ans = "No"

D = [A[0],B[0],C[0]]
E = [A[1],B[1],C[1]]
F = [A[2],B[2],C[2]]
G = [A[0],B[1],C[2]]
H = [A[2],B[1],C[0]]

if len(set(S)&set(A)) >= 3:
  ans ="Yes"
if len(set(S)&set(B)) >= 3:
  ans ="Yes"
if len(set(S)&set(C)) >= 3:
  ans ="Yes"
if len(set(S)&set(D)) >= 3:
  ans ="Yes"
if len(set(S)&set(E)) >= 3:
  ans ="Yes"
if len(set(S)&set(F)) >= 3:
  ans ="Yes"
if len(set(S)&set(G)) >= 3:
  ans ="Yes"
if len(set(S)&set(H)) >= 3:
  ans ="Yes"

print(ans)

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

int main(){
  string s;
  cin>>s;
  int n = s.size(), ans = 0;

  int cnt = 0;
  for(int i=0; i<n; i++){
    if(s[i]=='A' || s[i]=='T' || s[i]=='G' || s[i]=='C') {
      cnt++;
      ans = max(ans, cnt);
    }
    else cnt = 0;
  }
  cout<<ans<<endl;
}


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

#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 < 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 remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#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;
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

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


void solve(){
   int a,b;cin >> a>> b;
   cout << (double)a/b;
}

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;
  WL(t)solve();
  return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline

def main():
    N = int(input())
    a1,b1,c1 = 0,0,0
    for _ in range(N):
        a,b,c = map(int, input().split())
        a0,b0,c0 = a1,b1,c1
        a1 = a + (b0 if b0 > c0 else c0)
        b1 = b + (a0 if a0 > c0 else c0)
        c1 = c + (a0 if a0 > b0 else b0)

    print(max(a1,b1,c1))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import bisect
n = int(input())
a = sorted(list(map(int,input().split())))
b = sorted(list(map(int,input().split())))
c = sorted(list(map(int,input().split())))
counta = 0
countc = 0
count = 0
for i in range(n):
    countc = n  - bisect.bisect_right(c,b[i])
    counta = bisect.bisect_left(a,b[i])
    count += countc*counta
print(count)

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 1001001001001001000;

ll modpow(ll A, ll N) {
    ll RET = 1;
    // 例えば3=101(2)なので、下位bitから順に1ならa倍する
    while (N) {
        if (N & 1) RET = RET * A % mod;
        A = A * A % mod;
        N >>= 1;
    }
    return RET;
}

ll comb(ll N, ll R) {
    if (N < 0 || R < 0 || N < R) return 0;
    // numerator/denominator
    ll NUME = 1, DENO = 1;
    R = min(R, N-R);
    for (int i = 1; i <= R; i++) {
        NUME = NUME * N % mod;
        DENO = DENO * i % mod;
        N--;
    }
    return NUME * modpow(DENO, mod-2) % mod;
}

int main() {
    int x,y; cin >> x >> y;
    bool ans = 1;
    if ((x+y)%3 != 0) ans = 0;
    if (2*x-y<0 || 2*y-x<0) ans = 0;
    if (!ans) {
        printf("0\n");
        return 0;
    }
    ll a = (2*x-y)/3, b = (2*y-x)/3;
    ll anss = comb(a+b,a);
    cout << anss << endl;
    return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<cctype>
using namespace std;

int main() {
	int a, b;
	char s;
	cin >> a >> s >> b;
	if (s == '+')
		cout << a + b << endl;
	else
		cout << a - b << endl;
}


Measured memory_bytes: 256
n = int(input())
mons = list(map(int, input().split()))
kill = list(map(int, input().split()))

cnt = 0
for i in range(n-1, -1,-1):
    if mons[i+1] < kill[i]:
        cnt += mons[i+1]
        kill[i] -= mons[i+1]
        mons[i+1] = 0
    else:
        cnt += kill[i]        
        mons[i+1] -= kill[i]
        kill[i] = 0
    if mons[i] < kill[i]:
        cnt += mons[i]
        kill[i] -= mons[i]
        mons[i] = 0
    else:
        cnt += kill[i]
        mons[i] -= kill[i]
        kill[i] = 0
        
print(cnt)

Measured memory_bytes: 24224
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cctype>
#include<vector>
#include<queue>
#include<map>
using namespace std;

int main() {
	int a, b1 = 0, b2 = 0, b3 = 0;

	for (int i = 0; i < 10; i++) {
		cin >> a;
		if (a > b1) {
			b3 = b2;
			b2 = b1;
			b1 = a;
		}
		else if (a > b2) {
			b3 = b2;
			b2 = a;
		}
		else if (a > b3) {
			b3 = a;
		}
	}

	cout << b1 << endl << b2 << endl << b3 << endl;

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main()
{	string s; cin>>s;
	cout<<(s.substr(0,4)=="YAKI"?"Yes":"No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    int x;
    cin >> x;

    cout << ((x >= 1200) ? "ARC" : "ABC") << endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ls x<<1
#define rs x<<1|1
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-6;
const ull hashp=1e7+19;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=1e3+100;
int a[maxn],b[maxn];
int v[maxn],dp[maxn][(1<<12)+10];
void solve()
{
	int n,m;
	scdd(n,m);
	rep1(i,m){
		scdd(a[i],b[i]);
		rep1(j,b[i]){
			int x;scd(x);
			v[i]|=(1<<(x-1));
		}
	}
	mst(dp,inf);
	dp[0][0]=0;
	int lim=1<<n;
	rep1(i,m){
		rep(sta,lim){
			dp[i][sta]=min(dp[i][sta],dp[i-1][sta]);
			int nxt=sta|v[i];
			dp[i][nxt]=min(dp[i][nxt],dp[i-1][sta]+a[i]);
		}
	}
	int ans=dp[m][lim-1];
	if(ans==inf)ans=-1;
	ac;
}
int main(){
    //IOS;
    solve();
    return 0;
}


Measured memory_bytes: 17920
mod = 1000000007
eps = 10**-9


def main():
    import sys
    from collections import deque
    input = sys.stdin.readline

    N, M = map(int, input().split())
    adj = [[] for _ in range(N+1)]
    for _ in range(M):
        a, b = map(int, input().split())
        adj[a].append(b)
        adj[b].append(a)

    que = deque()
    que.append(1)
    seen = [-1] * (N+1)
    seen[1] = 0
    par = [0] * (N+1)
    child = [[] for _ in range(N+1)]
    seq = []
    while que:
        v = que.popleft()
        seq.append(v)
        for u in adj[v]:
            if seen[u] == -1:
                seen[u] = seen[v] + 1
                par[u] = v
                child[v].append(u)
                que.append(u)
    seq.reverse()

    print("Yes")
    for v in range(2, N+1):
        print(par[v])


if __name__ == '__main__':
    main()


Measured memory_bytes: 101436
n=int(input())
S=list(map(int, input().split()))
Sum=sum(S)
#print(Sum)
wa=0
count=0
for i in range(n):
    if wa<Sum/2:
        wa=wa+S[i]
        count=count+1
x=int(abs(Sum-2*wa))
wa=wa-S[count-1]
        #print(wa,Sum-wa)
y=int(abs(Sum-2*wa))
print(min(x,y))

Measured memory_bytes: 26220
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, m;
    string s;
    cin >> n >> m >> s;
    vector<int> d, ans;
    for (int i = 0; i <= n; ++i) if ('1' - s.at(i)) d.push_back(i);
    int pos = n, npos;
    while (pos > 0) {
        npos = *lower_bound(d.begin(), d.end(), pos - m);
        if (pos == npos) {
            cout << "-1\n";
            return 0;
        } else ans.push_back(pos - npos), pos = npos;
    }
    for (int i = int(ans.size()) - 1; i >= 0; --i) cout << ans.at(i) << (i ? ' ' : '\n');
    return 0;
}


Measured memory_bytes: 1480
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int a,b;
  while(cin >> a >> b){
    if(a > b) swap(a, b);

    if(a == 1 and b == 2) cout << 3 << endl;
    if(a == 1 and b == 3) cout << 2 << endl;
    if(a == 2 and b == 3) cout << 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import itertools
import math

def main():
    N = int(input())
    X = []
    Y = []
    for _ in range(N):
        x, y = map(int, input().split())
        X.append(x)
        Y.append(y)

    l = range(N)
    cnt = 0
    total = 0
    for v in itertools.permutations(l):
        sum = 0
        for i in range(N-1):
            idx1 = v[i]
            idx2 = v[i+1]
            sum += math.sqrt( (X[idx1]-X[idx2]) ** 2 + (Y[idx1]-Y[idx2]) ** 2)
        total += sum
        cnt += 1

    print(total/cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

const ll MOD = 1000000007;
ll dp[2005];


int main() {
    int n;
    cin >> n;
    dp[3] = dp[4] = dp[5] = 1;

    vector<ll> sums(n + 1, 1);
    sums[0] = sums[1] = sums[2] = 0;
    for (ll i = 4; i <= n; ++i) {
        for (ll j = 3; j <= i - 3; ++j) {
            sums[i] = (sums[i] + sums[j]) % MOD;
        }
    }

    cout << sums[n];
    return 0;
}


Measured memory_bytes: 3632