akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

namespace Math{
      vector<int> fact;
      int M;

      int exp(int a, int b){
            if(b == 0)return 1;
            if(b % 2)return a * exp(a, b - 1) % M;
            int t = exp(a, b / 2);
            return t * t % M;
      }

      int comb(int n, int r){
            int ret = 1;
            for(int i = 0; i < r; i++) ret = ret * (n - i) % modulo;
            return ret * exp(fact[r], M - 2) % modulo;
      }
      bool isprime(int x){
            for(int i = 2; i * i <= x; i++){
                  if(x % i == 0)return false;
            }
            return true;
      }
      vector<int> divisors(int x){
            vector<int> ret;
            for(int i = 1; i * i <= x; i++){
                  if(x % i == 0){
                        ret.pb(i);
                        if(i * i != x)ret.pb(x / i);
                  }
            }
            return ret;
      }
      vector<int> prime_fac(int x){
            vector<int> ret;
            for(int i = 1; i * i <= x; i++){
                  if(x % i == 0){
                        ret.pb(i);
                        while(x % i == 0) x /= i;
                  }
            }
            if(x > 1) ret.pb(x);
            return ret;
      }
      void Math_init(int m = modulo){
            fact = vector<int>(2000006, 1);
            M = m;
            for(int i = 1; i < fact.size(); i++) fact[i] = fact[i - 1] * i % M;
      }
};
using namespace Math;



int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);Math_init();
      int n, a, b;
      cin >> n >> a >> b;
      cout << (exp(2, n) - comb(n, a) - comb(n, b) - 1 + 10ll * modulo) % modulo;
}


Measured memory_bytes: 15872
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		double a = saori.Hayamin();
		double b = saori.Hayamin();
		double x = saori.Hayamin();
		if(x > a * a * b / 2) {
			System.out.println(Math.toDegrees(Math.atan(2 * (a * a * b - x) / (a * a * a))));
		} else {
			System.out.println(Math.toDegrees(Math.atan(a * b * b / 2 / x)));
		}
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 28;
int rnd(int v){
	if (v < 0) return 0;
	if (v > 255) return 255;
	return v;
}
int diff(int a, int b){
	return (a - b) * (a - b);
}

int n, m;
int c[16];
int x[20000];
int dp[20001][256];

int main()
{
	while (scanf("%d %d", &n, &m), n){
		fill((int*)dp, (int*)dp + sizeof(dp) / sizeof(int), INF);
		
		for (int i = 0; i < m; i++){
			scanf("%d", &c[i]);
		}
		for (int i = 0; i < n; i++){
			scanf("%d", &x[i]);
		}
		
		dp[0][128] = 0;
		for (int i = 0; i < n; i++){
			for (int j = 0; j < 256; j++){
				for (int k = 0; k < m; k++){
					int to = rnd(j + c[k]);
					dp[i + 1][to] = min(dp[i + 1][to], dp[i][j] + diff(to, x[i]));
				}
			}
		}
		
		int mini = INF;
		for (int i = 0; i < 256; i++){
			mini = min(mini, dp[n][i]);
		}
		
		printf("%d\n", mini);
	}
}

Measured memory_bytes: 21264
n,a,b,c,d = map(int,input().split())
S = [1] + [1 if s == "." else 0 for s in input()]
flag = True
count = 0
for s,i in zip(S[1:],range(1,n+1)):
    if not(s):
        count += 1
    else:
        count = 0
    if count == 2 and a < i and i < c:
        flag = False
        break
    elif count == 2 and b < i and i < d:
        flag = False
        break
count = 0
if  c > d:
    flag = False
    for s in S[b-1:d+2]:
        if s:
            count += 1
        else:
            count = 0
        if count == 3:
            flag = True
            break
if flag :
    print("Yes")
else:
    print("No")

Measured memory_bytes: 6388
#include <bits/stdc++.h>
     
    int main(int argc, char* argv[])
    {
      std::string s;
      int K;
      std::vector< std::string > vs;
     
      std::cin >> s >> K;
     
      int length = 1;
      for (int length = 1; length <= K; length++) {
        for (int spos = 0; spos < s.size(); spos++) {
          std::string tmp = s.substr(spos, length);
          vs.push_back(tmp);
        }
      }
     
      std::sort(vs.begin(), vs.end());
      std::unique(vs.begin(), vs.end());
      std::cout << vs[K-1] << std::endl;
     
      return 0;
    }

Measured memory_bytes: 1660
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;

	for (int i = 0; i < (int) s.size(); ++i) {
		if (i + 1 == k) {
			char ch = s[i] - 'A' + 'a';
			cout << ch;
		}
		else {
			cout << s[i];
		}
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int A = scan.nextInt();
        int B = scan.nextInt();

        if(N*A > B){

            System.out.println(B);

        }else{

            System.out.println(N*A);
        }

    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define debug(x)   cerr<<#x<<": "<<x<<endl;
#define all(x)     (x).begin() , (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl       '\n'
#define MAX        1000000
typedef long long int ll;
using namespace std;


const ll mod = 1e9+7;
const double eps = 1e-9;




void solve(){
    ll a,b,n;
    cin>>a>>b>>n;
    ll t = min(b-1,n);
    cout<<(ll)(a*t/b) - a*(t/b);
}





int main(){
    fastio
    int test=1;
    while(test--)
        solve();
    return 0;
}


Measured memory_bytes: 3616
from fractions import gcd
class segtree():
    def segfunc(x,y):
        return min(x,y)
    #####単位元######
    ide_ele = -1
    n=1
    init_val=[0]*n
    #num:n以上の最小の2のべき乗
    num =2**(n-1).bit_length()
    seg=[ide_ele]*2*num
    
    def __init__(self,INIT_VAL,SEGFUNC,IDE_ELE):
        self.ide_ele=IDE_ELE
        self.init_val=[i for i in INIT_VAL]
        self.segfunc=SEGFUNC
        self.n=len(self.init_val)
        self.num =2**(self.n-1).bit_length()
        self.seg=[self.ide_ele]*2*self.num
 
        #set_val
        for i in range(self.n):
            self.seg[i+self.num-1]=self.init_val[i]    
        #built
        for i in range(self.num-2,-1,-1) :
            self.seg[i]=self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 
        
    def update(self,k,x):
        k += self.num-1
        self.seg[k] = x
        while k+1:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1],self.seg[k*2+2])
        
    def query(self,p,q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res=self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res,self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res,self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res,self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q])
        return res
N=int(input())
A=[int(i) for i in input().split()]
B=segtree(A,gcd,0)
C=[gcd(B.query(0,i),B.query(i+1,N+1)) for i in range(N+1)]
print(max(C))


Measured memory_bytes: 98912
import math
#角度の差を求める
A, B, H, M = list(map(int, input().split()))
l = (2*math.pi)/(12*60*60)
s = (2*math.pi)/(60*60)

t = H * 60 * 60 + M * 60
tt = M * 60

lr = l * t
sr = s * tt

x1 = A * math.cos(lr)
y1 = A * math.sin(lr)

x2 = B * math.cos(sr)
y2 = B * math.sin(sr)

print(math.sqrt((x1-x2)**2 + (y1-y2)**2))

Measured memory_bytes: 9524
import sys

input_list = map(int, raw_input().split())

x = input_list[0]
y = input_list[1]

if x < y:
	tmp = x
	x = y
	y = tmp
elif x == y:
	print(x)
	sys.exit(0)


r = 0
while y != 0:
	r = x % y
	x = y
	y = r

print(x)
	



Measured memory_bytes: 4648
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> P;

int main(){
    double a, b, x;
    cin >> a >> b >> x;
    double pi = M_PI;
    double a3 = pow(a, 3);
    double l = 0, r = pi;
    double v1 = (a*a*b) / 2;
    double tana;
    if(x > v1){
        tana = (2*a*a*b - 2*x) / a3;
    }else{
        tana = a*b*b/(2*x);
    }
    double bb = atan(tana);
    double ans = (bb/pi) * (double) 180;
    cout << setprecision(20) << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int d;
bool calc(vll& A, vll& B) {
    ll cur = 0;
    for (int i = 0; i < d; ++i) {
        cur += (A[i]-B[i])*(A[i]-B[i]);
    }
    long double r = sqrt(cur);
    return (r - floor(r)) == 0;
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n >> d;
    vector<vector<ll>> arr;
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        vll cur;
        for (int j = 0; j < d; ++j) {
            int v; cin >> v;
            cur.push_back(v);
        }

        for (int j = 0; j < arr.size(); ++j) {
            ans += calc(cur, arr[j]);
        }

        arr.push_back(cur);
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std; 
const int mod = 1e9+7;
vector<pair<int,int> > fa;
long long dp[101][100000];
int main(){
	//cout<<sqrt(1000000000)<<endl;
	long long n,k;
	cin>>n>>k;
	for(int i=1;i*i<=n;i++){
		fa.push_back({i,0});
		fa.push_back({n/i,0});
	}
	sort(fa.begin(),fa.end());
	fa.erase(unique(fa.begin(),fa.end()),fa.end());
	map<long long,long long> pos;
	int m=(int)fa.size();
	//cout<<m<<endl;
	for(int i=0;i<m-1;i++){
		long long l=n/(fa[i+1].first);
		long long r=n/(fa[i].first);
		fa[i].second=r-l;
	}
	fa.back().second=1;
	for(int i=0;i<m;i++) pos[fa[i].first]=i;
	dp[0][pos[n]]=1;
	for(int i=0;i<k;i++){
		for(int j=m-2;j>=0;j--) dp[i][j]=(dp[i][j]%mod+dp[i][j+1]%mod)%mod;
		for(int j=0;j<m;j++){
			int nj=pos[n/fa[j].first];
			dp[i+1][j]=(dp[i+1][j]%mod+(dp[i][nj]%mod*fa[j].second%mod)%mod)%mod;
		}
	}
	long long ans=0;
	for(int i=0;i<m;i++) ans=(ans%mod+dp[k][i]%mod)%mod;
	cout<<ans%mod<<endl;
	return 0;
} 

Measured memory_bytes: 82424
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*
願はくは花の下にて春死なんそのきさらぎの望月のころ（西行 1118-1190）
--This is old Japanese poem expressing the desire to die under tree on the full moon night.(written by Saigyo)
In my research, there is possibility that the tree may be seg-tree.
*/

/*Coding Space*/
class UF{
public:
  vi value;
  vi over; // When over < 0, 'over' keep number of node(using negative number). -1 means this tree is a node.
  int root(int index){
    int t = index;
    stack<int> stack_i;
    while(over[t] >= 0){
      stack_i.push(t);
      t = over[t];
    }
    while(!stack_i.empty()){
      int i = stack_i.top(); stack_i.pop();
      over[i] = t;
    }// reconnect
    return t;
  }
  void merge(int a,int b){
    if(this->root(a) == this->root(b)) return;
    over[root(a)] += over[root(b)]; // over have a number of nodes.
    over[root(b)] = root(a);
  }
  int NumNode(int a){
    return -over[root(a)];
  }
  UF(int Nodes){
    value.resize(Nodes);
    over.resize(Nodes);
    rep(i,Nodes)
      over[i] = -1;
  }
};
UF uf(100001);
int main(){
  int n,m; cin >> n >> m;
  vi p(n+1); rep(i,n) cin >> p[i+1];
  rep(i,m){
    int x,y; cin >> x >> y;
    uf.merge(x,y);
  }
  int ans = 0;
  rep(i,n){
    if(uf.root(i+1) == uf.root(p[i+1]))
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
def main():
    N = int(input())
    X = list(map(int,input().split()))
    ans = 10**9
    for i in range(1,101):
        tmp = sum([(X[j]-i)**2 for j in range(N)])
        ans = min(ans,tmp)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 39408
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
    int n;
    while (scanf("%d",&n)!=EOF) {
        if (n%10==3)
            printf("bon\n");
        else if (n%10==0||n%10==1||n%10==6||n%10==8)
            printf("pon\n");
        else
            printf("hon\n");
    }
    return 0;
}


Measured memory_bytes: 3132
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int N, K;
  cin >> N >> K;
  int ans[N];

  rep(i, N) { ans[i] = 0; }
  rep(i, K) {
    int d;
    cin >> d;
    rep(i, d) {
      int A;
      cin >> A;
      if (ans[A - 1] == 0) ans[A - 1] = 1;
    }
  }

  int sum_ = 0;
  rep(i, N) { sum_ += ans[i]; }
  cout << N - sum_ << endl;

  return 0;
}


Measured memory_bytes: 3636
N, A, B = map(int, input().split())
MAX = max(A, B) + 1
MOD = 1000000007
nCk = [0] * MAX
nCk[0] = 0
nCk[1] = N


def mod_pow(a, n, m):
    res = 1
    while n != 0:
        if n & 1:
            res = (res * a) % m
        n = n >> 1
        a = (a * a) % m
    return res


def mod_inv(a, m):
    b = m
    u = 1
    v = 0
    while b:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    u %= m
    if u < 0:
        u += m
    return u


for i in range(2, MAX):
    nCk[i] = (nCk[i-1] * ((N-i+1) * mod_inv(i, MOD))) % MOD

count = (mod_pow(2, N, MOD) - 1 - nCk[A] - nCk[B]) % MOD
print(int(count))


Measured memory_bytes: 10940
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
  ll N, Q, b, c;
  cin >> N;
  int anums[100005] = {};
  int as[100005] = {};
  ll sum = 0;
  for (ll i = 0; i < N; i++) {
    cin >> as[i];
    anums[as[i]]++;
    sum += as[i];
  }
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    cin >> b >> c;
    sum += anums[b] * (c - b);
    anums[c] += anums[b];
    anums[b] = 0;
    cout << sum << '\n';
  }
}

Measured memory_bytes: 4424
#include <iostream>

using namespace std;

int b[1000000010];

int main()
{
	int n, q, s, t;
	int ans = 0 ;

	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> s;
		b[s]++;
	}
	cin >> q;
	for (int i = 0; i < q; i++){
		cin >> t;
		if (b[t] >= 1) ans++;
	}
	cout << ans << endl;
	return (0);
}

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

int main() {
	int n;
	scanf("%d", &n);

	vector<int> v {0};
	fori(i, 0, n) {
		int x;
		scanf("%d", &x);
		v.push_back(x);
	}

	v.push_back(0);

	ll total = 0;
	fori(i, 1, v.size()) {
		total += abs(v[i] - v[i - 1]);
	}

	fori(i, 1, v.size() - 1) {
		ll cur = total - abs(v[i] - v[i - 1]) - abs(v[i + 1] - v[i]) + abs(v[i + 1] - v[i - 1]);
		printf("%lld\n", cur);
	}

	return 0;
}


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

int main(){

int n;
while(1){
vector<pair<int, int> > v;
cin >> n;
if(n == 0) break;
v.resize(n);
for(int i = 0; i < n; i++){
cin >> v[i].second >> v[i].first;
}
sort(v.begin(),v.end());

int ans = 0;
int judge = 0;
for(int i = 0; i < n; i++){
ans+= v[i].second;
if(ans > v[i].first){
judge = 1;
break;
}
}

if(judge == 0) cout << "Yes" << endl;
else cout << "No" << endl;
}


}

Measured memory_bytes: 1192
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
  char c[25] = {0};
  scanf("%s", c);
  for(int i = 24; i >= 0; i--)
  {
    if(c[i])
      cout << c[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 1144
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define chu(x) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/

const ll mod=1e9+7ll;
std::vector<int> son[maxn];
ll ans=1ll;
ll cnt[maxn];
ll n,m;
void dfs(int x,int pre)
{
    ans=(ans*(m-1ll-cnt[pre]))%mod;
    cnt[pre]++;
    if(pre!=0)
    {
        cnt[x]++;
    }
    for(auto t:son[x])
    {
        if(t!=pre)
        {
            dfs(t,x);
        }
    }
}
int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
    //freopen("D:\\common_text\code_stream\\out.txt","w",stdout);
    gbtb;
    cin>>n>>m;
    int u,v;
    cnt[0]=-1;
    repd(i,2,n)
    {
        cin>>u>>v;
        son[u].push_back(v);
        son[v].push_back(u);
    }
    dfs(1,0);
    cout<<ans<<endl;


    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}





Measured memory_bytes: 32768
from collections import defaultdict
n = int(input())
s = list(input())
c = defaultdict(int)

for i in s:
    if i=="R":
        c["R"]+=1
    elif i=="G":
        c["G"]+=1
    else:
        c["B"]+=1
ans = c["R"]*c["G"]*c["B"]
nans = 0
for i in range(n-2):
    j = 1
    while i+2*j<=n-1:
        
        if s[i] != s[i+j] and s[i] != s[i+j*2] and s[i+j] != s[i+j*2]:
            nans+=1
        j+=1
print(ans-nans)

Measured memory_bytes: 9420
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define vll vector<ll>
#define M 100011

ll a[111];
ll dp[M];


int main()
{

    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll t,i,j,m,x,y,n,z,p,k,T;string s1,s2,s3;x=1;
	cin>>n>>k;
	for(i=1;i<=n;++i)cin>>a[i],dp[a[i]]=1;
	for(i=1;i<=k;++i){
		if(dp[i]==1)continue;
		dp[i]=0;
		for(j=1;j<=n;++j){
			if(i-a[j]>0)if(dp[i-a[j]]==0){dp[i]=1;break;}
		}
	}
	if(dp[k])cout<<"First\n";
	else cout<<"Second\n";









	
	return 0;
}

Measured memory_bytes: 1024
x1, y1 ,x2 ,y2 = map(int, input().split())
lst = []

lst.append(y1-y2+x2)
lst.append(x2-x1+y2)
lst.append(x1+y1-y2)
lst.append(y1+x2-x1)

for i in range(4):
    print(lst[i], end=' ')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int x;
  cin >> x;
  if (x < 1200) {
  	cout << "ABC" << "\n";
  }else {
  	cout << "ARC" << "\n";
  }
}

Measured memory_bytes: 256
package main

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

func main() {
	N := nextInt()
	K := nextInt64()
	Q := nextInt()
	points := make([]int, N)
	for i := 0; i < Q; i++ {
		w := nextInt()
		points[w-1] += 1
	}
	for _, v := range points {
		if int64(v)+K > int64(Q) {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func Max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Min(s, v)
	}
	return s
}

func MaxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Max(s, v)
	}
	return s
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 3968
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

a, b, x = map(int, input().split())

total = a*a*b
flg = x > total/2

if flg:
    b_tmp = 2*(total-x)/a/a
    ans = math.degrees(math.atan(b_tmp/a))
else:
    a_tmp = 2*x/a/b
    ans = math.degrees(math.atan(b/a_tmp))

print(ans)




Measured memory_bytes: 5184
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String o=sc.next();
        String e=sc.next();
        for(int i=0;i<o.length();i++){
            System.out.print(o.charAt(i));
            if(i<e.length())System.out.print(e.charAt(i));
        }
        System.out.println();
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
int a[202020];
LL ball[202020];

int main(){
    
    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    rep(i, N){
        scanf("%d", &a[i]);
        // a[i] が 書かれているボールの数.
        ball[a[i]]++;
    }
    
    // 2. N個のボールで, 条件を満たす2個のボールの選び方は？
    LL total = 0;
    repx(i, 1, N + 1) total += ball[i] * (ball[i] - 1) / 2;
    
    // 3. k番目のボールを除いた場合, 条件を満たす2個のボールの選び方は？
    rep(k, N){
        LL b = ball[a[k]], ans = total;
        // ans = ans - b * (b - 1) / 2 + (b - 1) * (b - 2) / 2
        // => ans = ans - b + 1
        if(b) ++ans -= b;
        printf("%lld\n", ans);
    }
    return 0;
    
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int X = nextInt();
  if (X == 3 || X == 5 || X == 7)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
# frozen_string_literal: true

n = gets.to_i
s = n.times.map { gets.chomp }
h = Hash.new { 0 }
s.each do |e|
  h[e] += 1
end
a = h.sort_by { |e| -e[1] }

max = a[0][1]

b = []
a.each do |e|
  s = e[0]
  m = e[1]
  break if m < max

  b.push s
end

puts b.sort


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

int main(){
	int n;
	while (1) {
		cin >> n;
		if (n == 0) break;
		int num; int ans = 0;
		for (int i = 0; i < n / 4; i++) {
			cin >> num; ans += num;
		}
		cout << ans << endl;
	}
	return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[1005][1005];
struct Vertex
{
    ll count = 0;
    ll max = 0;
    vector<ll> node;
};

Vertex V[1100005];
bool U[1100005];

int main()
{
    ll N;
    cin >> N;
    REP(i, N)
    {
        REP(j, N - 1)
        {
            cin >> A[i][j];
            A[i][j]--;
        }
    }

    REP(i, N)
    {
        FOR(j, N - 1, 1)
        {
            ll n = std::min(i, A[i][j]) + std::max(i, A[i][j]) * N;
            ll p = std::min(i, A[i][j - 1]) + std::max(i, A[i][j - 1]) * N;
            V[p].node.push_back(n);
            V[n].count++;
        }
    }
    memset(U, 0, sizeof(U));
    queue<pll> q;
    REP(i, N)
    {
        ll index = std::min(i, A[i][0]) + std::max(i, A[i][0]) * N;
        if (V[index].count == 0)
        {
            q.push(pll(index, 1));
        }
    }

    ll max = 0;
    while (!q.empty())
    {
        pll t = q.front();
        q.pop();
        if (U[t.first])
            continue;
        U[t.first] = true;
        max = std::max(max, t.second);
        REP(i, V[t.first].node.size())
        {
            ll n = V[t.first].node[i];
            V[n].count--;
            V[n].max = std::max(V[n].max, t.second + 1);
            if (V[n].count <= 0)
                q.push(pll(n, V[n].max));
        }
    }

    REP(i, N)
    {
        REP(j, N - 1)
        {
            ll index = std::min(i, A[i][j]) + std::max(i, A[i][j]) * N;
            if (U[index])
                continue;
            cout << -1 << endl;
            return 0;
        }
    }

    cout << max << endl;
    return 0;
}

Measured memory_bytes: 67712
n=int(input())
l=list(map(int, input().split()))
for i in range(n):
    if i!=n:
        part_l=sorted(l[0:i+1])  
        l=part_l+l[i+1:n+1]
        print(*l)

    elif i==n:
        if l[i-1]>l[i]:
            l=+list(reversed(l[i-1:i]))
            print(*l)


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

using namespace std;

int main(){
    int x, n;
    cin >> x >> n;
    if (n == 0){
        cout << x << endl;
        return 0;
    }
    vector<int> P(n);
    copy_n(istream_iterator<int>(cin), n, P.begin());
    sort(P.begin(), P.end());

    vector<bool> A(102);
    for (const auto &p: P)
        A[p] = true;

    int ans = 1e9;
    for (int i = 0; i <= 101; i++){
        if (A[i])
            continue;
        if (abs(x - i) < abs(x - ans))
            ans = i;
    }

    cout << ans << endl;
}

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

using namespace std;

#define fr(i, n) for(ll i = 0; i < n; i++)
#define frr(i, n) for(ll i = 1; i <= n; i++)
#define frm(i, n) for(ll i = n-1; i >= 0; i--)

#define pb push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<double, double> ponto;
typedef vector<vector<ll>> matrix;

#define mem(v, k) memset(v, k, sizeof(v));

#define db cout << "Debug" << endl;

#define mp make_pair
#define pq priority_queue

#define mx(a, b) a = max(a, b);
#define mod(a, b) a = a%b;

#define MAXN 100010
#define MOD 1000000007
#define MAXL 30
#define ROOT 1
#define INF 987654321

ll fr[MAXN];

int main(){
	ios::sync_with_stdio(false);
	ll n, k;
	cin >> n >> k;
	fr(i, n){
		ll a, b;
		cin >> a >> b;
		fr[a]+=b;
	}

	ll ind = 0;
	
	while(k > 0){
		ind++;
		k-=fr[ind];
	}

	cout << ind << endl;
}


Measured memory_bytes: 1024
n = gets.to_i

def divisor_8 n
    count = 0
    (1..n).each do |num|
        if n % num == 0
            count += 1
        end
    end
    return count == 8
end

count = 0
(1..n).each do |num|
    next if num.even?
    count += 1 if divisor_8(num)
end

puts count

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000


int main(){
	
	int A,B,Q;
	cin>>A>>B>>Q;
	
	vector<long long> S,T;
	S.push_back(-Inf);
	T.push_back(-Inf);
	
	for(int i=0;i<A;i++){
		long long x;
		cin>>x;
		S.push_back(x);
	}
	for(int i=0;i<B;i++){
		long long y;
		cin>>y;
		T.push_back(y);
	}
	
	S.push_back(Inf);
	T.push_back(Inf);

	for(int i=0;i<Q;i++){
		long long x;
		cin>>x;
		
		auto it = lower_bound(S.begin(),S.end(),x);
		long long s1 = (*it);
		it--;
		long long s2 = (*it);
		
		it = lower_bound(T.begin(),T.end(),x);
		
		long long t1 = (*it);
		it--;
		long long t2 = (*it);
		
		long long ans = Inf;
		
		ans = min({abs(x-s1)+abs(s1-t1),abs(x-s1)+abs(s1-t2),abs(x-s2)+abs(s2-t1),abs(x-s2)+abs(s2-t2),
		abs(x-t1)+abs(t1-s1),abs(x-t1)+abs(t1-s2),abs(x-t2)+abs(t2-s1),abs(x-t2)+abs(t2-s2)});
		cout<<ans<<endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef long double ld;
const ld pi = 4*atan((ld)1);
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll nax = 0;

ll n, a[105];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n;
	for(ll i = 1; i <= n; i++){
		cin >> a[i];
	}
	ll ans = 0;
	for(ll i = 1; i <= n; i += 2){
		if(a[i] & 1){
			ans++;
		}
	}
	cout << ans << '\n';
}



Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int n,m,X,Y;
	cin >> n >> m >> X >> Y;
	int x[n+1], y[m+1];
	for (int i = 0;i < n;i++) {
		cin >> x[i];
	}
	for (int i = 0;i < m;i++) {
		cin >> y[i];
	}
	x[n] = X;
	y[m] = Y;
	sort(x, x + n + 1);
	sort(y, y + m + 1);
	if (x[n] < y[0]) {
		cout << "No War" << endl;
		return 0;
	}
	cout << "War" << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

var ans = [1e5]int{}
func main() {
  var s []byte
  fmt.Scan(&s)
  var n,p int
  var last byte = 'R'
  ans := make([]int, len(s))
  for i := range s {
    if last != s[i] {
      if s[i] == 'L' {
        ans[i-1] += (n+1)/2 
        ans[i] += n/2
        p = i
        n=0
      } else {
        ans[p-1] += n/2
        ans[p] += (n+1)/2
        n=0
      }
    } 
    n++
    last = s[i]
    
    if i == len(s)-1 && last == 'L' {
      ans[p-1] += n/2
      ans[p] += (n+1)/2
    }    
  }
  for i := 0; i < len(s); i++ {
    fmt.Printf("%d ", ans[i])
  }
}
  
  
  
  
  
  
  






Measured memory_bytes: 4296
#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())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int x,y;
  cin>>x>>y;
  vector<vector<bool>> dp1(8010,vector<bool>(20010,false));
  vector<vector<bool>> dp2(8010,vector<bool>(20010,false));
  dp1[0][10000]=true;
  dp2[0][10000]=true;
  int cnt=0;
  int now=0;
  int a=1,b;
  rep(i,len(s)){
    if(s[i]=='F'){
      now++;
      if(i==len(s)-1){
        cnt++;
        if(cnt==1){
          dp1[cnt][10000+now]=true;
          a=1;
        }else if(cnt%2==0){
          rep(j,20001){
            dp2[cnt/2][j]=dp2[cnt/2-1][max(0ll,j-now)]|dp2[cnt/2-1][min(20000ll,j+now)];
          }
          b=cnt/2;
        }else{
          rep(j,20001){
            dp1[cnt/2+1][j]=dp1[cnt/2][max(0ll,j-now)]|dp1[cnt/2][min(20000ll,j+now)];
          }
          a=cnt/2+1;
        }
      }
    }else if(s[i]=='T'){
      cnt++;
      if(cnt==1){
        dp1[cnt][10000+now]=true;
        a=1;
      }else if(cnt%2==0){
        rep(j,20001){
          dp2[cnt/2][j]=dp2[cnt/2-1][max(0ll,j-now)]|dp2[cnt/2-1][min(20000ll,j+now)];
        }
        b=cnt/2;
      }else{
        rep(j,20001){
          dp1[cnt/2+1][j]=dp1[cnt/2][max(0ll,j-now)]|dp1[cnt/2][min(20000ll,j+now)];
        }
        a=cnt/2+1;
      }
      //cout<<cnt<<' '<<now<<endl;
      now=0;
    }
    //cout<<i<<' '<<s[i]<<' '<<cnt<<endl;
  }
  //cout<<cnt<<' '<<a<<' '<<b<<endl;
  if(dp1[a][10000+x] && dp2[b][10000+y]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl; 
}

Measured memory_bytes: 40192
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

int main(){
  ll A,B,C;
  cin >> A >> B >> C;
  if( (B*10+C)%4==0 ){
    cYES;
  }
  else{
    cNO;
  }
}

Measured memory_bytes: 256
N = int(input())

a = []

for i in range(N+1):
	j = i
	a.append(j)

a.pop(0)

b = []
for i in a:
	i = str(i)
	b.append(i)

counter = 0


for i in b:
	if len(i)%2 !=0:
		counter+=1

print(counter)
	

Measured memory_bytes: 13336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    ll f[200005] = {1}, g[200005] = {}; g[200000] = 750007460;
    for (int i = 1; i <= 100001; i++) f[i] = f[i - 1] * i % mod;
    for (int i = 199999; i >= 0; i--) g[i] = g[i + 1] * (i + 1) % mod;
    int n, a[100005] = {}, b[100005] = {}, x = 0, y = 0;
    cin >> n;
    for (int i = 1; i <= n + 1; i++) {
        cin >> a[i];
        if (!b[a[i]]) b[a[i]] = i;
        else {
            x = b[a[i]];
            y = i;
            break;
        }
    }
    for (int i = 1; i <= n + 1; i++) {
        ll z = f[n + 1] * g[i] % mod * g[n + 1 - i] % mod;
        if (x + n - y - i + 1 < 0) cout << z << '\n';
        else {
            ll w = f[x + n - y] * g[i - 1] % mod * g[x + n - y - i + 1] % mod;
            z -= w;
            if (z < 0) z += mod;
            cout << z << '\n';
        }
    }
}


Measured memory_bytes: 5120
N, X = map(int, input().split())

a, p = [1], [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def f(N, X): 
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a[N-1]:
        return f(N-1, X-1)
    else:
        return p[N-1] + 1 + f(N-1, X-2-a[N-1])


print(f(N, X))

Measured memory_bytes: 3064
use std::io;
use std::io::BufRead;

fn main() {
    let stdin = io::stdin();
    for line in stdin.lock().lines() {
        let v: Vec<usize> = line.unwrap().split_whitespace()
            .map(|s| s.parse().unwrap())
            .collect();
        if v == [0, 0] {break;}
        let rect = ("#".repeat(v[1])+"\n").repeat(v[0]);
        println!("{}", rect);
    }
}


Measured memory_bytes: 5032
#include <stdio.h>
#include <string.h>
int main(void){
    char s[100000+5];
    int alph[30]={0};
    scanf("%s", s);
    for(int i=0; i<strlen(s); i++)alph[(int)s[i]-'a']=1;
    for(int i=0; i<26; i++){
        if(alph[i]==0){
            printf("%c\n", 'a'+i);
            return 0;
        }
    }
    printf("None\n");
    return 0;
}


Measured memory_bytes: 1776
#include<stdio.h>
#include<string.h>
int main(){

int a,b;
char s[10],t[10],c[10];

scanf("%s %s",&s,&t);
scanf("%d %d",&a,&b);
scanf("%s",&c);

if(s[0]==c[0]){
    a--;
}
else if(t[0]==c[0]){
    b--;
}

printf("%d %d",a,b);


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,b,c;
  	ci(a>>b>>c);
  bool d=true;
  FOR(i,1,b){
    if(a*i%b==c){
      co("YES")
        d=false;
        break;
    }
  }
  if(d) co("NO")
}


Measured memory_bytes: 256
import collections
N=int(input())
A=list(map(int,input().split()))
c = collections.Counter(A)
ans=0
n=len(set(A))
c_=c.most_common()
for i in range(n):
    a=int(c_[i][0])
    b=c_[i][1]
    if a <= b:
        ans+=b-a
    else:
        ans+=b
print(ans)

Measured memory_bytes: 75432
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define MAXN 100005
#define MP make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define SQ(a) (a)*(a)
#define nl "\n"
#define INF std::numeric_limits<int>::max()
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
ll mod=1000000009;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a,b;
	cin>>a>>b;
  	bool f = 0;
	for(int i = 1 ; i <= 100000 ; i++){
		if( ((i*8)/100 == a) && (i/10 == b)){
			cout<<i<<nl;
          	f =1;
			break;
		}
	}
  	if(!f){
    	cout<<"-1"<<nl;
    }
	return 0;
}






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

using namespace std;

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

const int N = 2e5 + 5;

int n;
int a[N];

class tree{ public:
	ii t[N << 1];
	void init() {
		for(int i = 1; i < (N << 1); i++)
			t[i] = {1e9, -1};
	}
	void add(int i, ii x) {
		t[i += N] = x;
		while(i > 1) {
			i >>= 1;
			t[i] = min(t[i + i], t[i + i + 1]);
		}
	}
	ii get(int l, int r) {
		ii res = {1e9, -1};
		for(l += N, r += N; l <= r; l = (l + 1) >> 1, r = (r - 1) >> 1) {
			if(l & 1) res = min(res, t[l]);
			if(~r & 1) res = min(res, t[r]);
		}
		return res;
	}
}odd, even;

int cnt = 1;
set < ii > s[N];
map < ii, ii > M;

void solve(int l, int r) {
	if(l > r)
		return;
	int i, j;
	if(l & 1) {
		i = odd.get(l, r).second;
		j = even.get(i + 1, r).second;
	}
	else {
		i = even.get(l, r).second;
		j = odd.get(i + 1, r).second;
	}
	solve(l, i - 1);
	solve(i + 1, j - 1);
	solve(j + 1, r);
	M[{l, r}] = {i, j};

}

ii get(int l, int r) {
	ii x = M[{l, r}];
	return {a[x.first], a[x.second]};
}

int main() {

	odd.init();
	even.init();

	scanf("%d", &n);

	for(int i = 1; i <= n; i++) {
		scanf("%d", a + i);
		if(i & 1)
			odd.add(i, {a[i], i});
		else
			even.add(i, {a[i], i});
	}

	solve(1, n);

	set < pair < ii, ii > > s;

	int i, j;
	tie(i, j) = M[{1, n}];

	s.insert({{a[i], a[j]}, {1, n}});

	while(s.size()) {
		auto x = *s.begin();
		s.erase(s.begin());
		printf("%d %d ", x.first.first, x.first.second);
		int l, r;
		tie(l, r) = x.second;
		tie(i, j) = M[{l, r}];
		if(l <= i - 1)
			s.insert({get(l, i - 1), {l, i - 1}});
		if(i + 1 <= j - 1)
			s.insert({get(i + 1, j - 1), {i + 1, j - 1}});
		if(j + 1 <= r)
			s.insert({get(j + 1, r), {j + 1, r}});
	}

	puts("");

    return 0;

}


Measured memory_bytes: 36608
S = input()

if S == "SSS":
    print(0)
elif S == "SSR":
    print(1)
elif S == "SRS":
    print(1)
elif S == "SRR":
    print(2)
elif S == "RSS":
    print(1)
elif S == "RSR":
    print(1)
elif S == "RRS":
    print(2)
elif S == "RRR":
    print(3)

Measured memory_bytes: 8980