akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int a, b;
    cin >> a >> b;
    cout << (max(a, b) <= 8 ? "Yay!" : ":(") << "\n";
    
    return 0;
}

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


using namespace std;


int a,b,c;



int main()
{
	cin >> a >> b >> c;
	if ( a+b == c || a+c == b || b+c == a)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}


	//system("pause");

}

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

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

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

int main()
{
	int a, b;
	while( scanf("%d%d", &a, &b) != EOF )
	{
		if( a < b )swap(a, b);
		printf("%d\n", gcd(a, b));
	}
	return (0);
}

Measured memory_bytes: 1188
from math import factorial
n,m = map(int,input().split())
if abs(n-m) >= 2:
  print(0)
elif abs(n-m) == 1:
  print(((factorial(n))*(factorial(m)))%(10**9+7))
else:
  print((2*(factorial(n))**2) %(10**9+7))

Measured memory_bytes: 54640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  invar(string, S);
  if(S == "SUN") { fin(7); return 0; }
  if(S == "MON") { fin(6); return 0; }
  if(S == "TUE") { fin(5); return 0; }
  if(S == "WED") { fin(4); return 0; }
  if(S == "THU") { fin(3); return 0; }
  if(S == "FRI") { fin(2); return 0; }
  if(S == "SAT") { fin(1); return 0; }
  
  
}

Measured memory_bytes: 256
n = int(input())
s = input()


def get_common_chars(first_set, latter_set):
    common_chars = set([])
    for chara in first_set:
        if chara in latter_set:
            common_chars.add(chara)
    return common_chars


max_charlen = 0
for i in range(n - 1):
    first_set = set(s[:i + 1])
    latter_set = set(s[i + 1:])
    common_charlen = len(get_common_chars(first_set, latter_set))
    if max_charlen < common_charlen:
        max_charlen = common_charlen
print(max_charlen)

Measured memory_bytes: 3064
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
n, k = inp
x = inp.map{|u|u}
s = x[0]
min = 1e90
e = x[k-1]
(0..(n-k)).each do |i|
  if(x[i] < 0)
    b = -1*(x[i] - x[i+k-1]) + [x[i].abs,x[i+k-1].abs].min
    min = [b,min].min
  else
    p [min,x[i+k-1]].min
    exit
  end
end
p min

Measured memory_bytes: 12820
#define MYDEBUG
#include <bits/stdc++.h>

#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
#define EPS = 1e-14;
using std::vector;
using std::cout;
using std::cin;
using std::endl;
using std::max;
using std::min;
using std::swap;
using std::string;
using std::fill;
using std::pair;
using std::sort;
using std::reverse;
using std::pair;
using std::greater;
using std::priority_queue;
using std::ostream;

template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i] << endl;
	}
	return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last) {
			out << ",";
		}
	}
	out << "]";
	return out;
}

class stack {
private:
	static const int MAX_N = 1000;
	int top, S[MAX_N];
public:
	stack() {
		initialize();
	}
	void initialize() {
		top = 0;
	}
	bool isEmpty() {
		return top == 0;
	}
	bool isFull() {
		return top >= MAX_N - 1;
	}
	void push(int x) {
		if (isFull()) {
			//error
			printf("stack size limit exceeded: top=%d\n", top);
			return;
		}
		top++;
		S[top] = x;
	}
	int pop() {
		if (isEmpty()) {
			printf("stack is empty: top=%d\n", top);
			return -1;
		}
		top--;
		return S[top + 1];
	}
};
string opr;
void solve() {
	int a, b;
	stack st;
	while (cin >> opr) {
		if (opr == "+") {
			a = st.pop();
			b = st.pop();
			st.push(a + b);
		} else if (opr == "-") {
			a = st.pop();
			b = st.pop();
			st.push(b - a);
		} else if (opr == "*") {
			a = st.pop();
			b = st.pop();
			st.push(a * b);
		} else {
			st.push(std::atoi(opr.c_str()));
		}
	}
	printf("%d\n", st.pop());
}

int main() {
	solve();
}

Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
double w,h,x,y;

int main(){
    cin>>w>>h>>x>>y;
     double ans=w*h/2.0;
    if (w/2==x&&h/2==y) {
        printf("%lf",ans);cout<<' '<<1<<endl;
    }else{
        printf("%lf",ans);cout<<' '<<0<<endl;
    }
}

Measured memory_bytes: 256
from itertools import permutations as per
from math import sqrt, factorial

n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]
p = [i for i in range(n)]
ans = 0
for pp in per(p, n):
    r = 0
    for j in range(n-1):
        r += sqrt((A[pp[j]][0] - A[pp[j+1]][0])**2 + (A[pp[j]][1] - A[pp[j+1]][1])**2)
    ans += r
print(ans/factorial(n))

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main() {
	var a, b, c int

	fmt.Scan(&a, &b, &c)

	if a+b >= c {
		fmt.Println(b + c)
	}
	if a+b < c {
		fmt.Println(a + 2*b + 1)
	}
}


Measured memory_bytes: 512
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		int[][] adjMatrix = new int[totalVertex][totalVertex];
		int vertex = 0;
		for(LinkedList<Integer> neighbors : adjList) {
			for(Integer n : neighbors) {
				adjMatrix[vertex][n] = 1;
			}
			vertex++;
		}
		for(int i = 0; i< totalVertex; i++) {
			for(int j = 0; j < totalVertex; j++) {
				System.out.print(adjMatrix[i][j]);
				if(j != totalVertex -1) {
					System.out.print(" ");
				}
				else {
					System.out.println();
				}
			}
		}
		
	}
}

//change class name GraphRepresentation to Main() for submission to AIZU
public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}



Measured memory_bytes: 34268
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

int n, k;
struct edge{
    int to, cost;
    edge(int to, int cost):to(to), cost(cost){}
};
vector<vector<edge> > G; 
int d[101];
const int INF = 1e9;

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P> > q;
    fill(d, d + n, INF);//INF
    d[s] = 0;
    q.push(P(0, s));

    while(!q.empty()){
        P p = q.top(); q.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        rep(i, 0, G[v].size()){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                q.push(make_pair(d[e.to], e.to));
            }
        }
    }
}


signed main(){
    while(1){
        cin >> n >> k;
        if(n == 0 && k == 0) break;
        G.clear();
        G.resize(n, vector<edge>());
        fill(d, d + n, 1e9);        
        rep(i, 0 ,k){
            int g;
            cin >> g;
            if(!g){
                int a, b;
                cin >> a >> b;
                a--; b--;
                dijkstra(a);
                cout << (d[b] >= 1e8 ? -1 : d[b]) << endl;
            }else{
                int c, d, e;
                cin >> c >> d >> e;
                c--; d--;
                G[c]. push_back(edge(d, e));
                G[d]. push_back(edge(c, e));
            }
        }
    }
}

Measured memory_bytes: 1260
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <map>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
int n, s;

int solve(int remain, int k, int depth)
{
	if(depth == n)
		return remain == 0;

	int ans = 0;
	reep(i, k, min(10, remain+1)){
		ans += solve(remain-i, i+1, depth+1);
	}
	return ans;
}

int main()
{
	while(scanf("%d %d", &n, &s), n||s){
		printf("%d\n", solve(s, 0, 0));
	}

	return 0;
}

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

using ll = long long;
const int mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    set<int> S;
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        S.insert(A);
    }
    if (S.size() == N)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <string>
#include <bits/stdc++.h>
typedef std::pair<int,std::string> is;

using namespace std;
 
int main() {
    int n; cin >> n;
    int mx = -1;
    string str;
    map<string, int>mp;
    priority_queue<is,vector<pair<int,string>>, greater<is>> pq;
    for(int i = 0; i <n; i++){
        cin >> str;
        mp[str]++;
        mx = max(mx, mp[str]);
    }
    map<string,int>::iterator it;
    for(it = mp.begin(); it != mp.end(); ++it){
        if(mx>0 && it->second != mx) continue;
        is p(it->second, it->first);
        pq.push(p);
    }
    while(!pq.empty()){
        cout << pq.top().second << endl;
        pq.pop();
    }
   return 0;
}


Measured memory_bytes: 28656
/// input macro
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
///
/// # Example
///
#[macro_export]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[macro_export]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

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

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

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

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

use std::io::Write;

macro_rules! eprintln(
    ($($arg:tt)*) => { {
        let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

/// Vecのすべてが偶数ならtrue
fn is_all_even(v: &Vec<i32>) -> bool {
    v.iter().all(|x| *x % 2 == 0 )
}

fn main() {
    input! {
        n: usize,
        a: [i32; n],
    }

    let mut a = a;

    let mut cnt = 0;
    loop {
        eprintln!("{:?}", a);
        if !is_all_even(&a) { break }

        a = a.iter().map(|x| x / 2).collect::<Vec<i32>>();
        cnt += 1;
    }

    println!("{}", cnt);
}



Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    unordered_map<string, int> D;
    for (int i = 0; i < n;i++){
        string s;
        cin>>s;
        sort(All(s));
        D[s]++;
    }
    int res = 0;
    for(auto it:D){
        res += it.second * (it.second - 1) / 2;
    }
    cout << res << endl;
}

Measured memory_bytes: 10660
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    // https://atcoder.jp/contests/abc135/tasks/abc135_c
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
//        int t = in.nextInt();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) throws IOException {
            int n = in.nextInt();
            long[] towns = new long[n+1];
            long[] heroes = new long[n];
            for (int i = 0; i < n+1; i++) {
                towns[i] = in.nextLong();
            }
            for (int i = 0; i < n; i++) {
                heroes[i] = in.nextLong();
            }
            long count = 0;
            for (int i = n-1; i >= 0; i--) {
                if (towns[i+1] < heroes[i]){
                    count += towns[i+1];
                    heroes[i] -= towns[i+1];
                    count += Math.min(towns[i], heroes[i]);
                    towns[i] -= Math.min(towns[i], heroes[i]);
                }else{
                    count+= heroes[i];
                    towns[i+1] -= heroes[i];
                }
            }
            out.println(count);
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

        public char nextChar() {
            return next().charAt(0);
        }

        public String nextLine() throws IOException {
            return reader.readLine().trim();
        }
    }
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		int x = fs.nextInt();
		int n = fs.nextInt();
		
		if(n == 0) {
			System.out.println(x);
			return;
		}
		
		int[] pArr = fs.nextIntArr(n);
		Arrays.sort(pArr);
		
		int minDiff = 1_000_000;
		int candidate = -1;
		
		for(int i = 0; i < 1000; i++) {
			if(exist(pArr, i)) {
				continue;
			}
			if(Math.abs(i-x) < minDiff) {
				minDiff = Math.abs(i-x);
				candidate = i;
			}
		}
		
		System.out.println(candidate);
	}
	
	boolean exist(int[] intArr, int value) {
		for(int arrContent : intArr) {
			if(arrContent == value) {
				return true;
			}
		}
		
		return false;
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int, int> pii;

double dist(pii p, pii q){
    return sqrt((p.fi - q.fi) * (p.fi - q.fi) + (p.se - q.se) * (p.se - q.se));
}

int main(){
    fcin;
    int n;
    cin >> n;
    vector<pii> v;
    vector<int> ord(n);
    for(int i = 0; i < n; i++){
        int x, y;
        cin >> x >> y;
        v.eb(x, y);
        ord[i] = i;
    }

    double d = 0.0;
    int k = 1;
    for(int i = 1; i <= n; i++) k *= i;
    do{
        for(int i = 1; i < n; i++){
            d += dist(v[ord[i]], v[ord[i-1]]);
        }
    } while(next_permutation(all(ord)));

    cout << fixed << setprecision(10) << d / double(k) << endl;
    return 0;
}



Measured memory_bytes: 256
N ,M = map(int, input().split())

ans = "IMPOSSIBLE"
list1 = [0] * N
listN = [0] * N

for _ in range(M):
    a, b = map(int, input().split())
    if a == 1:
        list1[b] = 1
    elif b == N :
        listN[a] = 1

for i in range(N):
    if list1[i] == 1 and listN[i] == 1:
        ans = "POSSIBLE"
        break

print(ans)

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

using namespace std;
	
	
class Hoge{
			int ir,iD,ix2000,ix;
			int* pi;
			int itest;
		public:
			Hoge(int hoge):itest(10){
			
			cin>>ir>>iD>>ix2000;
			
			}
			 void showresult() ;
									
virtual ~Hoge(){	
					delete[] pi;
					//cout<<"pi is erased."<<endl;
				}
};

void Hoge::showresult() {
						//cout<<ix2000<<endl;
						ix=ix2000;
						for(int icount=0;icount<10;icount++){
						
						ix=ir*ix-iD;
						cout<<ix<<endl;
						
						}
						cout<<endl;

};



int main()
{
	const int ix=5;
	
	Hoge* ph;
	ph=new Hoge(10);
	ph->showresult();
	delete ph;
}

Measured memory_bytes: 256
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n, m, h, w;
    cin >> n >> m >> h >> w;
    if (n % h == 0 && m % w == 0) {
        cout << "No\n";
        return 0;
    }

    cout << "Yes\n";
    forn(i, n) {
        forn(j, m) {
            int x;
            if ((i + 1) % h == 0 && (j + 1) % w == 0) x = -(h * w - 1) * 4000 - 1;
            else x = 4000;
            cout << x << " \n"[j + 1 == m];
        }
    }

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

const int INF = 1001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, x, y;
    cin >> n >> x >> y;
    vi k(n);
    for (int i = 1; i <= n; ++i) {
        for (int j = i+1; j <= n; ++j) {
            int d = min({j-i, abs(i-x) + abs(j-y) + 1, abs(i-y) + abs(j-x) + 1});
            k[d]++;
        }
    }
    for (int i = 1; i <= n-1; ++i) cout << k[i] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();
            int[] X = new int[M];
            int[] Y = new int[M];
            int[] Z = new int[M];
            for (int i = 0; i < M; i++) {
                X[i] = in.nextInt() - 1;
                Y[i] = in.nextInt() - 1;
                Z[i] = in.nextInt() & 1;
            }

            UnionFind uf = new UnionFind();
            uf.init(N);
            for (int i = 0; i < M; i++) {
                uf.unite(X[i], Y[i]);
            }
            int count2 = 0;
            boolean[] used = new boolean[N];
            for (int i = 0; i < N; i++) {
                if (used[uf.find(i)]) {
                    continue;
                }
                used[uf.find(i)] = true;
                count2++;
            }

            System.out.println(count2);

        }
    }
}

class UnionFind {
    private int[] par;
    private int[] rank;
    private int[] size;

    public void init(int n) {
        par = new int[n];
        rank = new int[n];
        size = new int[n];
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
            size[i] = 1;
        }
    }

    public int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            par[x] = find(par[x]);
            return par[x];
        }
    }

    public int size(int x) {
        return size[find(x)];
    }

    public void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            return;
        }
        if (rank[x] < rank[y]) {
            par[x] = y;
            size[x] += size[y];
            size[y] = size[x];
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
            size[y] += size[x];
            size[x] = size[y];
        }
    }

    public boolean same(int x, int y) {
        return find(x) == find(y);
    }
}


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

using namespace std;

typedef long long ll;

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

	ll h, w;
	cin >> h >> w;

	if(h == 1){
		cout << 1 << endl;
		return 0;
	}

	if(w == 1){
		cout << 1 << endl;
		return 0;
	}

	if(w % 2 == 0){
		cout << w / 2 * h << endl;
	}else{
		if(h % 2 == 0){
			cout << w * h / 2 << endl;
		}else{
			cout << w * (h / 2) + w / 2 + 1 << endl;
		}
	}

}


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

long long n, x, k, p;
pair<long long, long long> a[52];
vector<pair<long long, long long> > v[52];

void bg(long long dg) {
    for(int i = 0; i < v[dg].size(); ++i) {
        if(v[dg][i].second == 2) {
            if(k >= v[dg][i].first) {
                k -= v[dg][i].first;
                p += a[dg - 1].first;
            } else {
                bg(dg - 1);
            }
        } else {
            if(k) {
                --k;
                if(v[dg][i].second == 0) {
                    ++p;
                }
            } else {
                cout << p << endl;
                exit(0);
            }
        }
    }
}

int main() {
    cin >> n >> x;
    k = x;
    v[0].push_back({1, 0});
    a[0].first = 1;
    for(int i = 1; i <= n; ++i) {
        v[i].push_back({1, 1});
        v[i].push_back({a[i - 1].first + a[i - 1].second, 2});
        v[i].push_back({1, 0});
        v[i].push_back({a[i - 1].first + a[i - 1].second, 2});
        v[i].push_back({1, 1});
        a[i].first = 2 * a[i - 1].first + 1;
        a[i].second = 2 * a[i - 1].second + 2;
    }
    bg(n);
    cout << p << endl;
}

Measured memory_bytes: 256
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#include <cstdio>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef std::vector<int> VI;
typedef std::pair<int,int> P;
int read()
{
    int x=0,flag=1; char c=getchar();
    while((c>'9' || c<'0') && c!='-') c=getchar();
    if(c=='-') flag=0,c=getchar();
    while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return flag?x:-x;
}

const int maxn=2e5+5;
int far[maxn],t[maxn];

int findd(int x){return x==far[x]?x:far[x]=findd(far[x]);}
void unite(int x,int y){far[findd(x)]=findd(y);}

int main()
{
    int n=read(),m=read();
    REP(i,1,n) far[i]=i;
    while(m--)
    {
        int a=read(),b=read();
        unite(a,b);
    }
    REP(i,1,n) t[findd(i)]++;
    cout<<*max_element(t+1,t+n+1);

    return 0;
}


Measured memory_bytes: 10660
s = input()
k = int(input())
num,ans = 0,[]
while num!=len(s):
	if s[num]=="a": ans.append("a")
	elif 123-ord(s[num])<=k:
		k -= 123-ord(s[num])
		ans.append("a")
	else: ans.append(s[num])
	num += 1
ans[-1] = chr(ord(ans[-1])+k%26)
print("".join(ans))

Measured memory_bytes: 4340
import java.util.Scanner;

public class Main {
    private static final int[] dr = new int[] { -1, -1, -1, 0, 0, 0, 1, 1, 1, };
    private static final int[] dc = new int[] { -1, 0, 1, -1, 0, 1, -1, 0, 1, };

    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            String firstLine = in.nextLine();

            int H = Integer.parseInt(firstLine.split(" ")[0]);
            int W = Integer.parseInt(firstLine.split(" ")[1]);

            String[] S = new String[H];
            for (int i = 0; i < S.length; i++) {
                S[i] = in.nextLine();
            }

            int[][] counts = new int[H][W];
            for (int r = 0; r < H; r++) {
                for (int c = 0; c < W; c++) {
                    if (S[r].charAt(c) == '#') {
                        continue;
                    }

                    int count = 0;

                    for (int d = 0; d < dr.length; d++) {
                        int nr = r + dr[d];
                        int nc = c + dc[d];
                        if (nr < 0 || nr >= H) {
                            continue;
                        }
                        if (nc < 0 || nc >= W) {
                            continue;
                        }

                        if (S[nr].charAt(nc) == '#') {
                            count++;
                        }
                    }

                    counts[r][c] = count;

                }
            }

            StringBuilder sb = new StringBuilder();
            for (int r = 0; r < H; r++) {
                for (int c = 0; c < W; c++) {
                    sb.append(S[r].charAt(c) == '#' ? "#" : counts[r][c]);
                }
                sb.append("\n");
            }

            System.out.println(sb.toString());
        }
    }
}


Measured memory_bytes: 21716
N=int(input())
A=list(map(int,input().split()))
X=[[0,0]]
Y=[[0,0]]
for i in A:
    if i<0:
        k=1-X[-1][1]
    else:
        k=X[-1][1]
    X.append([X[-1][0]+abs(i),k])
for i in A[::-1]:
    if i<0:
        k=1-Y[-1][1]
    else:
        k=Y[-1][1]
    Y.append([Y[-1][0]+abs(i),k])
Y.reverse()

ans=-10**20
for i in range(N):
    t=(-1)**(X[i][1]+Y[i+1][1])
    a=X[i][0]+Y[i+1][0]+t*A[i]
    ans=max(a,ans)
print(ans)


Measured memory_bytes: 84384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(ll i=0;i<n;++i)
#define FOR(i,j,n) for(ll i=j;i<n;++i)

int main(void){
    ll N, M;
    cin >> N >> M;
    ll A, sum = 0;
    REP(i,M){
        cin >> A;
        sum += A;
    }

    if(sum>N){
        cout << -1 << endl;
    }
    else{
        cout << (N-sum) << endl;
    }

}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

void ch(string s, int &a, int &b){
  if(s == "AB"){
    a = 0;
    b = 1;
  }
  if(s == "BC"){
    a = 1;
    b = 2;
  }
  if(s == "AC"){
    a = 0;
    b = 2;
  }
}

int main(){
  int n;
  cin >> n;
  vector<int> v(3);
  rep(snip_i, 3) cin >> v.at(snip_i);
  vector<string> s(n);
  rep(snip_i, n) cin >> s.at(snip_i);
  s.push_back("AB");

  string ans;
  rep(i, n){
    int x, y;
    ch(s.at(i), x, y);
    int &a = v.at(x), &b = v.at(y);
    if(a == 0 && b == 0){
      cout << "No" << endl;
      return 0;
    }
    if(a == 0 || b == 0){
      if(a != 0){
        a--;
        b++;
        ans.push_back('A'+y);
      }else{
        a++;
        b--;
        ans.push_back('A'+x);
      }
    }else{
      int nx, ny;
      ch(s.at(i+1), nx, ny);
      if(nx == x || ny == x){
        a++;
        b--;
        ans.push_back('A'+x);
      }else{
        a--;
        b++;
        ans.push_back('A'+y);
      }
    }
  }

  cout << "Yes" << endl;
  for(char c : ans){
    cout << c << endl;
  }
  return 0;
}

Measured memory_bytes: 9604
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.20f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

int main() {
	int n;
	cin >> n;
	ll a[n+1];
	rep (i, n+1) cin >> a[i];

	vector<ll> sum(n+2, 0);
	for (int i = n; i >= 0; i--) sum[i] = sum[i+1] + a[i];

	// a[0]=1のとき
	if (a[0]) {
		if (a[0] > 1) {
			cout << -1 << endl;
			return 0;
		}
		for (int i = 1; i <= n; i++) {
			if (a[i]) {
				cout << -1 << endl;
				return 0;
			}
		}
	}

	ll ans = 1;
	ll can = 1;
	bool ok = false;
	for (ll i = 1; i <= n; i++) {
		if (!ok) {
			can *= 2;
			if (a[i] > can) {cout << -1 << endl; return 0;}
			if (sum[i] <= can) ok = true;
			ans += min(can, sum[i]);
			can -= a[i];
		}
		else ans += sum[i];
	}

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


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

int main() {
    string S;
    cin >> S;
    int res = 0;
    int len = S.length();
    char c_comp[] = {'A', 'C', 'G', 'T'};
    rep(i, 0, len) rep(j, 1, len-i+1) {
        bool isACGTstr = true;
        for (char c : S.substr(i, j)) {
            bool isACGT = false;
            rep(k, 0, 4) {
                if (c == c_comp[k]) isACGT = true;
            }
            if (!isACGT) isACGTstr = false;
        }
        if (isACGTstr == true && j > res) res = j;
    }
    cout << res << endl;
}

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

int main(void){
        int n,m,i,min=1000001,max=-1000001;
        long long int sum=0;

        scanf("%d",&n);

        for(i=0; i<n; i++){
                scanf("%d",&m);
                if(m < min)
                        min = m;
                if(m > max)
                        max = m;
                sum += m;
        }

        printf("%d %d %lld\n",min, max, sum);

        return 0;
}

Measured memory_bytes: 600
using System;

namespace AtCorder2
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = ("1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51").Split(',');

            int a = int.Parse(Console.ReadLine());

            Console.WriteLine(Method(str, a -1));
        }

        static string Method(string[] str, int a)
        {
            return str[a].Replace(" ","");
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define deb(x) cout<<#x<<" : "<<x<<"\n";
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define deb_arr(a,n) {cout<<#a<<":";for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';}
#define deb_mat(dist,n,m) {cout<<#dist<<"\n";for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}}
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define all(a) (a).begin(),(a).end()
#define bs binary_search
#define sz size()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define clr fflush(stdout);
//#define clr cout.flush();
#define N 200001
#define fpr(i,a,b) for(int i=a;i<b;i++)
#define fdr(i,a,b) for(int i=a;i>b;i--)
#define repp(i,a,b,d) for(int i=a;i<b;i+=d)
#define repd(i,a,b,d) for(int i=a;i>b;i-=d)
#define LLMIN LLONG_MIN
#define LLMAX LLONG_MAX
#define AKASH_PATEL ios_base::sync_with_stdio(false);
#define SVNIT_SURAT cin.tie(NULL);cout.tie(NULL);
#define mset(x,a) memset(x,a,sizeof(x));
#define nl cout<<'\n';
#define print(c) cout<<c<<'\n';
#define setp(n) cout << fixed << setprecision(n)
#define take_arr(a,n) fpr(i,0,n) cin>>a[i];
#define print_arr(a,n) for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';
#define take_mat(mat,n,m) fpr(i,0,n) fpr(j,0,m) cin>>mat[i][j];
#define set_mat(mat,n,m,k) fpr(i,0,n) fpr(j,0,m) mat[i][j]=k;
#define print_mat(dist,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
template< class T > bool odd(T a) { return a&1; }
template< class T > bool even(T a) { return !(a&1); }
int main()
{
//#ifndef ONLINE_JUDGE
//    freopen("../ip.txt", "r", stdin);
//    freopen("../op.txt", "w", stdout);
//#endif
    AKASH_PATEL;
    SVNIT_SURAT;
    int t=1;
    //cin>>t;
    int gcd[201][201];
    fpr(i,1,201)
    {
        fpr(j,1,201)
        {
            gcd[i][j]=__gcd(i,j);
        }
    }
    while(t--)
    {
        int n;
        cin>>n;
        ll sum=0;
        fpr(i,1,n+1)
        {
            fpr(j,1,n+1)
            {
                fpr(k,1,n+1)
                {
                    int x=gcd[j][k];
                    sum+=gcd[i][x];
                }
            }
        }
        print(sum)
    }
    return 0;
}





Measured memory_bytes: 3804
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
using ll=long long;
#ifdef ONLINE_JUDGE
#define D(...)
#else
#define D(...)cerr<<__LINE__<<":"<<"["<<#__VA_ARGS__<<"]->",P(__VA_ARGS__)
#endif
void P(){cerr<<endl;} 
template<typename H,typename...T>void P(H h,T...t){cerr<<h<<" ";P(t...);}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n,sum=0,maxm=INT_MIN;cin>>n;
    for(int i=0,x;i<n;++i){
        cin>>x;
        maxm=max(maxm,x);
        sum+=x;
    }
    cout<<sum-(maxm)/2;


}

Measured memory_bytes: 3592
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
ll mod=998244353;
ll combi(ll N_, ll C_) {
    const int NUM_=400001;
    static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
    if (fact[0]==0) {
        inv[1]=fact[0]=factr[0]=1;
        for (int i=2;i<=NUM_;++i) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
        for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mod, factr[i]=factr[i-1]*inv[i]%mod;
    }
    if(C_<0 || C_>N_) return 0;
    return factr[C_]*fact[N_]%mod*factr[N_-C_]%mod;
}

int main(){
    int n;
    ll a,b,k;
    cin >> n >> a >> b >> k;
    ll ans = 0;
    rep(i,n+1){
        if(k-a*i<0 or(k-a*i)%b)continue;
        ans += combi(n,i)*combi(n,(k-a*i)/b);
        ans %= mod;
    }
    cout << ans << endl;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  cout << A*B-A-B+1 << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
xy_ls = []
count = 0
while count < n:
    xy_ls.append(list(map(int, input().split())))
    count = count + 1
count_diff = {}
for i in range(n):
    for j in range(n):
        x = xy_ls[i][0] - xy_ls[j][0]
        y = xy_ls[i][1] - xy_ls[j][1]
        xy = (x, y)
        if xy == (0,0):
            continue
        if count_diff.get(xy):
            count_diff[xy] += 1
        else:
            count_diff[xy] = 1
max_count = 0
for v in count_diff.values():
    if v > max_count:
        max_count = v
print(n-(int(max_count)))



Measured memory_bytes: 3444
#include <iostream>
#include<vector>
using namespace std;
const int MOD = 1000000007;

int N,M;
vector<bool> issafe;

int main(void){
    cin >> N >> M;
    issafe.assign(N+1,true);
    for(int i = 0;i < M ;i++){
        int a;
        cin >> a;
        issafe[a]=false;
    }
    
    vector<int> dp(N+1,0);
    
    dp[0]=1;
    if(issafe[1])dp[1]=1;
    
    for(int n = 2; n <= N ; ++n){
        if(issafe[n-1])dp[n]+=dp[n-1];
        if(issafe[n-2])dp[n]+=dp[n-2];
        dp[n]%=MOD;
    }
    
    cout << dp[N]<<endl;
    
}


Measured memory_bytes: 640
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

#define rep(i, n) for (long long i = 0; i < n; i++)

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

ll sheep_or_wolf(ll conf, ll at) {
    return (conf >> at) & 1LL;
}

bool is_consistent_at(string& s, string& conf, ll at) {
    bool must_same = (conf[at] == 'S' && s[at] == 'o') || (conf[at] == 'W' && s[at] == 'x');
    
    char next = conf[(at + 1) % s.size()];
    char prev = conf[(at + s.size() - 1) % s.size()];
    return (must_same && next == prev) || (!must_same && next != prev);
}

bool fill(string& s, string& conf) {
    for (ll i = 1; i < s.size() - 1; i++) {
        bool must_same = (conf[i] == 'S' && s[i] == 'o') || (conf[i] == 'W' && s[i] == 'x');
        if (must_same)
            conf[i + 1] = conf[i - 1];
        else
            conf[i + 1] = conf[i - 1] == 'W' ? 'S' : 'W';
    }

    return is_consistent_at(s, conf, 0) && is_consistent_at(s, conf, s.size() - 1);
}

void solve() {
    ini(N);
    ins(s);

    string conf(s.size(), 'U');
    
    for (auto cand: {"SS", "SW", "WS", "WW"}) {
       conf[0] = cand[0]; 
       conf[1] = cand[1]; 
       if (fill(s, conf)) {
           out(conf);
           return;
       }
    }

    out(-1);
}


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

#define N 200123
#define mod 1000000007

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    int ans = 0;
    string s, t;
    cin >> s >> t;
    for(int i = 0 ; i < 3 ; i++)
    	if(s[i] == t[i])
    		ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
struct dts{
    int t;
    int s;
    int d;
};

int main(void){
    int N,M,i,cnt;
    while(1){
        scanf("%d",&N);
        scanf("%d",&M);
        if(!N && !M){break;}
        int pcs[N];
        vector<dts> datas;
        for(i=0;i<N;i++){pcs[i]=0;}
        pcs[0]=1;
        cnt=0;
        for(i=0;i<M;i++){
            struct dts buf;
            scanf("%d",&buf.t);
            scanf("%d",&buf.s);
            scanf("%d",&buf.d);
            datas.push_back(buf);
        }
        sort(datas.begin(),datas.end(),[](const dts& x,const dts& y){return x.t < y.t;});
        for(i=0;i<M;i++){
            if(pcs[datas[i].s-1]){pcs[datas[i].d-1]=1;}
        }
        for(i=0;i<N;i++){if(pcs[i]){cnt++;}}
        printf("%d\n",cnt);
    }
    return 0;
}






Measured memory_bytes: 3048
S=input()
l=len(S)
ls=[i for i in range(1,l)]
    
import itertools as it
a=0
for i in range(l):
 for j in it.combinations(ls, i):
  t='';p=0
  for k in j:
    t+=S[p:k]+'+'
    p=k
  t+=S[p:]
  a+=eval(''.join(t))
print(a)

Measured memory_bytes: 8924
#!/usr/bin/env python3


def main() -> None:
    K = ri()
    A, B = rmi()
    for trial in range(A, B + 1):
        if trial % K == 0:
            w('OK')
            return
    w('NG')


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> tuple:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(*data, delim: str = ' ') -> None:
    print(delim.join(map(str, data)))


if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10**9)
    main()


Measured memory_bytes: 9152