akhauriyash/Code-Regression huggingface dataset:
import sys
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M, X] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    input_raw = read_func().strip().split()
    A = set([])
    for i in range(M):
        A.add(int(input_raw[i]))
    to_zero_cost = 0
    for i in range(X , -1, -1):
        if i in A:
            to_zero_cost += 1
    to_N_cost = 0
    for i in range(X , N + 1):
        if i in A:
            to_N_cost += 1
    print min(to_N_cost, to_zero_cost)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2696
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <cstring>

#define loop(i, num)  for (int i = 0; i < num; i++)

using namespace std;

int n, a, b;

int main() {
    
    cin >> n >> a >> b;
    
//    if (a > (tb - ta - 1) && a > b) {
//
//        cout << "Alice" << endl;
//
//    } else if (b > (tb - ta - 1) && b > a) {
//
//        cout << "Borys" << endl;
//
//    } else if (a > (tb - ta - 1) && a == b) {
//
//        cout << "Borys" << endl;
//
//    } else {
//
//        if ((tb - ta - 1) % 2) {
//
//            cout << "Alice" << endl;;
//
//        } else {
//
//            cout << "Borys" << endl;
//
//        }
//
//    }

    cout << ((b - a) % 2 == 0 ? "Alice" : "Borys") << endl;;
    
}

//             _
// 1 2 3 4 5 6 7 8
//         ^


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

int main() {
  
    int a;
   
 
   cin >> a;
  
   int b = a*800;
   
  int c = a/15;
  
    int e = c*200;
    int d = b - e;
  
   cout << d << endl;
 
  
  return 0;
}

Measured memory_bytes: 256
"""
https://atcoder.jp/contests/abc144/tasks/abc144_a
"""
import numpy as np


def calc(A: int, B: int) -> int:
    if 1 <= A <= 9 and 1 <= B <= 9:
        return A * B
    return -1


def load_input_as_int_array() -> np.ndarray:
    return np.array([int(v) for v in input().split(" ")])


def main() -> None:
    A, B = load_input_as_int_array()
    result = calc(A, B)
    print(result)


main()


Measured memory_bytes: 21652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
  int x, y;
  cin >> x >> y;
  if((x+y) % 3 != 0){
    cout << 0 << endl;
    return 0;
  }
  int m = (2*y-x)/3, n = (2*x-y)/3;
  if(m < 0 || n < 0){
    cout << 0 << endl;
    return 0;
  }
  ll bunsi = 1;
  ll bunbo = 1;
  rep(i, m){
    bunsi *= m+n-i;
    bunsi %= mod;
  }
  rep(i, m){
    bunbo *= m-i;
    bunbo %= mod;
  }
  ll res = bunsi * modinv(bunbo, mod) % mod;
  cout << res << endl;
  return 0;
}
  

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

f = False
for i in range(N+1):
  if f:
    break
  for j in range(N+1-i):
    if f:
      break
    k = N - i - j
    p = 10000 * i + 5000 * j + 1000 * k
    if p == Y:
      print("{0} {1} {2}".format(i, j, k))
      f = True
if not f:
  print('-1 -1 -1')


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#define int long long
using namespace std;

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

signed main() {

    int n,a,b;
    int num;
    int ans = 0;
    int sur;
    cin >> n >> a >>b;
    num = n/(a+b);
    sur = n%(a+b);
    
    ans += num*a;
    if(sur > a) ans += a;
    else ans+= sur;
    
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#define MAX 100000

int A[MAX],n;

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

}

int main(){
 int i,q;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&A[i]);
	
	q=partition(0,n-1);
	
	for(i=0;i<n;i++){
		if(i)printf(" ");
		if(i==q)printf("[");
		printf("%d",A[i]);
		if(i==q)printf("]");
	}
	printf("\n");

return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
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;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------

//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n, q;
  cin >> n >> q;
  vector<bpqll> st(n);

  REP(i,q){
    ll com;
    cin >> com;
    if(com == 0){
      ll t, x;
      cin >> t >> x;
      st[t].push(x);
    }
    else if(com == 1){
      ll t;
      cin >> t;
      if(!st[t].empty()) cout << st[t].top() <<endl;
    }
    else{
      ll t;
      cin >> t;
      if(!st[t].empty()) st[t].pop();
    }
  }
    
  return 0;
}




Measured memory_bytes: 5260
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	H := sc.nextInt()
	A := make([]int, H+1)
	for i := 1; i <= H; i++ {
		A[i] = sc.nextInt()
	}
	for i := 1; i <= H; i++ {
		fmt.Fprint(wtr, "node ", i, ": ")
		fmt.Fprint(wtr, "key = ", A[i], ", ")
		if i/2 > 0 {
			fmt.Fprint(wtr, "parent key = ", A[i/2], ", ")
		}
		if 2*i <= H {
			fmt.Fprint(wtr, "left key = ", A[2*i], ", ")
		}
		if 2*i+1 <= H {
			fmt.Fprint(wtr, "right key = ", A[2*i+1], ", ")
		}
		fmt.Fprintln(wtr)
	}

	wtr.Flush()
}



Measured memory_bytes: 1124
#include<bits/stdc++.h>
using namespace std;
int jumpcost[100100];
int a[100100];
int main(){
int n;cin>>n;
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i++) jumpcost[i]=2e9;
jumpcost[0]=0;
for(int i=0;i<n;i++)
{
    for(int j=1;j<=2;j++) {if(i+j<=n-1){jumpcost [i+j]=min(jumpcost[i+j],abs(a[i]-a[i+j])+jumpcost[i]);}}
}
cout<< jumpcost[n-1];
return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String args[]) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine().trim());
        long a[] = new long[n+1];
        Arrays.fill(a, 1);
        a[0]=0;
        for(int i=2;i<=n;i++){
            for(int j=i;j<=n;j+=i){
                a[j]++;
            }
        }
        for(int i=1;i<=n;i++){
            a[i] *= i;
            a[i] += a[i-1];
        }
        out.println(a[n]);
        out.flush();
    }
}

Measured memory_bytes: 112620
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<set>
#include<sstream>
using namespace std;
typedef long long ll;
const ll maxn=1e6+10;
const ll inf=0x3f3f3f3f3f3f3f3f;
void io(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
char s[maxn];
ll n,ans=0;
void dfs(ll num)
{
	if(num==n)
	{
		for(int i=0;i<n;i++)	
			cout<<s[i];
		cout<<endl;
		return ;
	}
	for(int i=0;i<=ans;i++)
	{
		s[num]='a'+i;
		ll tmp=ans;
		if(i==ans) ans++;
		dfs(num+1);
		ans=tmp;
	} 
} 
int main()
{
	io();
	cin>>n;
	dfs(0);
	return 0;
}

Measured memory_bytes: 1536
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#define MAX_N 100001
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
int main()
{
  int a,b;
  cin >> a >> b;
  if(a + b== 15)
    cout << "+" << endl;
  else if(a * b == 15)
    cout << "*" << endl;
  else
    cout << "x" << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

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

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



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>
#include <boost/dynamic_bitset.hpp>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
  // INFILE();
	int n;
	cin >> n;
	
	if (n < 1200) {
		cout << "ABC\n";
	} else {
		cout << "ARC\n";
	}
  return 0;
}

template <class T> static void scan(vector<T> &v) {
  map<type_index, const char *const> m = {{typeid(int), "%d"},
                                          {typeid(ll), "%lld"},
                                          {typeid(double), "%lf"},
                                          {typeid(char), "%c"}};

  auto tFormat = m[typeid(T)];

  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
	if (isWord) {
		for (auto &n : v) {
			cin >> n;
		}
		return;
	}

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
	string s;
	getline(cin, s);

	if (s.size() == 0) {
		getline(cin, s);
	}

	for_each(begin(s), end(s), [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
	return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}());
const ll mod=1000000007;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int n;

int main() {
	scanf("%d",&n);
	printf("%d\n",(n+999)/1000*1000-n);
}

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define I_1000000007 (1000000007)
#define I_998244353   (998244353)
#define I_INF             (1<<28)
#define L_INF           (1LL<<60)
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"
template<class T> inline bool chmin(T& a, const T& b) {
  if (a > b) { a = b; return true; } else return false;
}
template<class T> inline bool chmax(T& a, const T& b) {
  if (a < b) { a = b; return true; } else return false;
}

namespace solver {
  using namespace std;
  using ll = long long;

  ll N;

  void init() {
    cin >> N;
  }

  vector<ll> factors(ll n) {
    vector<ll> res;
    int lim = (int)min(n, (ll)sqrt(n)+2);
    REP(i, 1, lim) {
      if(i > n/i) break;
      else if(n%i==0) {
        res.push_back(i);
        if(i != n/i) res.push_back(n/i);
      }
    }
    sort(res.begin(), res.end());
    return res;
  }

  void solve() {
    if(N<=2) {
      cout << 1 << "\n";
      return;
    }
    vector<ll> f1 = factors(N-1);
    vector<ll> f2 = factors(N);
    ll ans = 0;
    ans += f1.size() - 1;
    for(const auto& a : f2) {
      if(a == 1) continue;
      ll n = N;
      while(n % a == 0) n /= a;
      if(n > a && (n % a == 1)) ans++;
      else if(n == 1) ans++;
    }
    cout << ans << "\n";
  }
}

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

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

n,a,b,c = map(int,input().split())
ans = []
abc = [a,b,c]

d = {'AB\n':(0,1),'AC\n':(0,2),'BC\n':(1,2)}

if(a+b+c==0):
    print('No')
    exit()

if(a+b+c >= 3)|(a+b+c==1):
    for _ in range(n):
        s = input()
        x,y = d[s]
        if(abc[x]==0)&(abc[y]==0):
            print('No')
            exit()
        if(abc[x] < abc[y]):
            x,y = y,x
        abc[x] -= 1
        abc[y] += 1
        ans.append(y)

elif(a+b+c==2):
    ss = [input() for _ in range(n)]
    if(max(abc)==2):
        #(2,0,0)
        case = True
    else:
        case = False

    for i in range(n):
        s = ss[i]
        x,y = d[s]
        if(case)|(i==n-1):
            if(abc[x]==0)&(abc[y]==0):
                print('No')
                exit()
            if(abc[x] < abc[y]):
                x,y = y,x
            abc[x] -= 1
            abc[y] += 1
            case = False
        else:
            if(abc[x]!=abc[y]):
                if(abc[x] < abc[y]):
                    x,y = y,x
                abc[x] -= 1
                abc[y] += 1
                case = False
            else:
                sn = ss[i+1]
                if(x in d[sn]):
                    x,y = y,x
                abc[x] -= 1
                abc[y] += 1
                case = True
        ans.append(y)

print('Yes')
for i in ans:
    print(chr(i+ord('A')))

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

int N,a[10];
string s;

int main(){
    cin >> s;
    N=s.length();

    int i;
    for (i=0; i<N; i++){
        if (s[i]=='N') a[1]=1;
        if (s[i]=='S') a[2]=1;
        if (s[i]=='W') a[3]=1;
        if (s[i]=='E') a[4]=1;
    }

    if (((a[1]^a[2])==0) && ((a[3]^a[4])==0)) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
int n;
ll ans, b;
ll a[200005];
ll f(ll x) { return x > 0 ? x : -x; }
int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> a[i], a[i] -= i;
	sort(a + 1, a + n + 1);
	b = a[(n + 1) / 2];
	for (int i = 1; i <= n; i++)ans += f(a[i] - b);
	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
#define mp make_pair
#define pb push_back
#define ii pair<int, int>

int a[100001];

int main()
{
    int n;
    cin>>n;
    for(int i = 0; i< n;i ++){
        int x;
        cin>>x;
        if(x == 0)a[0] ++;else{
            a[x - 1]++;
            a[x + 1]++;
            a[x] ++;
        }
    }
    int maxx = 0;
    for(int i = 0;i < 100001;i ++){
        maxx = max(maxx, a[i]);
    }
    cout<<maxx;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>

#define endl '\n'
#define ll long long

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll x, curr = 100, cnt = 0;;
	cin >> x;

	while (curr < x)
	{
		curr += curr / 100;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

    ll a;
    cin >> a;
    double b;
    cin >> b;
    ll intB = b * 100 + 0.5;
    a *= intB;
    a /= 100;
    printf("%lld\n", a);
    return 0;
}


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

using namespace std;

int main() {
    int N;  //4 <= N <= 30000
    cin >> N;

    string S;
    cin >> S;

    int count = 0;
    for (int i = 0; i < 1000; i++) {
        vector<int> secretNumber = {i / 100, (i / 10) % 10, i % 10};
        int offset = 0;
        for (int j = 0; j < N; j++) {
            if (secretNumber.at(offset) == S.at(j) - '0') {
                offset++;
                if (offset == 3) break;
            }
        }
        if (offset == 3) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define maxn 100001
using namespace std;
const int md=1e9+7;

int n,a[maxn],cnt[26];
int ans;
char x[maxn];
int main(){
	scanf("%d%s",&n,x+1);
	for (int i=1;i<=n;++i)
	a[i]=x[i]-'a';
	for (int i=1;i<=n;++i){
		cnt[a[i]]++;
		ll res=1;
		for (int j=0;j<26;++j)
		if (j!=a[i])
		res=1ll*res*(cnt[j]+1)%md;
		(ans+=res)%=md;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cmath>

#define REP(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;
int cnt = 0, n;
int A[500000];

long long int merge(int f, int l);

int main() {
	cin >> n;
	REP(i, n) cin >> A[i];
	cout << merge(0, n - 1) << endl;
	return 0;
}

long long int merge(int f, int l) {
	if (f == l)return 0;
	long long int mid = (f + l) / 2,T1,T2,T=0;
	T1=merge(f, mid);T2=merge(mid + 1, l);
	int lptr = f, rptr = mid + 1;
	int  i = 0;
	vector<int> B;
	while (lptr != mid + 1 || rptr != l+1) {
		if (lptr != mid + 1 && rptr != l + 1) {
			if (A[lptr] > A[rptr]) {
				B.push_back(A[rptr]);
				rptr++; T += mid + 1 - lptr;
			}
			else {
				B.push_back(A[lptr]);
				lptr++;
			}
		}
		else if (lptr == mid + 1) {
			B.push_back(A[rptr]);
			rptr++;
		}
		else {
			B.push_back(A[lptr]);
			lptr++;
		}
	}
	for (int i = f;i <= l;i++) A[i] = B[i-f];
	return T1+T+T2;
}

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

int main(){
    string s;
    cin >> s;
    size_t n = s.length();

    string ans = "Yes";

    for (int i = 0; i < n; ++i){
        if (i%2==0){
                if(s[i]=='L') ans="No";
        }else if (i%2==1){
                if(s[i]=='R') ans="No";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n, m; cin>>n>>m;
    int p[11];
    vector<int> s[11];
    for(int i=0; i<m; i++){
        int k; cin>>k;
        for(int j=0; j<k; j++){
            int s0; cin>>s0;
            s[i].push_back(s0-1);
        }
    }
    for(int i=0; i<m; i++){
        cin>>p[i];
    }
    int ans=0;
    for(int i=0; i<(1<<n); i++){
        int cnt0=0;
        for(int j=0; j<m; j++){
            int cnt=0;
            for(auto x:s[j]){
                if(i&(1<<x)) cnt++;
            }
            if((cnt%2)==p[j]) cnt0++;
        }
        if(cnt0==m) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

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

vector<vector<int>> bfs(int xx, int yy, vector<vector<char>> maze) {
    queue<pair<int, int>> que;
    vector<vector<int>> dist(H, vector<int>(W, -1));
    dist[yy][xx] = 0;
    que.push(MP(xx, yy));
    while(!que.empty()) {
        pii p = que.front();
        que.pop();
        int x = p.first;
        int y = p.second;
        for(int i = 0; i < 4; i++) {
            if(x + dx[i] >= 0 && x + dx[i] < W && y + dy[i] >= 0 &&
               y + dy[i] < H) {
                int nx = x + dx[i];
                int ny = y + dy[i];
                if(maze[ny][nx] == '#')
                    continue;
                if(dist[ny][nx] != -1)
                    continue;
                dist[ny][nx] = dist[y][x] + 1;
                que.push(MP(nx, ny));
            }
        }
    }
    return dist;
}
int main() {
    cin >> H >> W;
    vector<vector<char>> maze(H, vector<char>(W));
    rep(i, H) rep(j, W) { cin >> maze[i][j]; }
    int res = -1;
    for(int sx = 0; sx < W; sx++) {
        for(int sy = 0; sy < H; sy++) {
            if(maze[sy][sx] == '#')
                continue;
            auto dist = bfs(sx, sy, maze);
            for(int gx = 0; gx < W; gx++) {
                for(int gy = 0; gy < H; gy++) {
                    res = max(dist[gy][gx], res);
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n,x=i2()
a=intl()
a.sort()
b=0
for i in range(n):
	x-=a[i]
	if i<n-1:
		if x>=0:
			b+=1
		elif x<0:
			break
	elif i==n-1:
		if x==0:
			b+=1
print(b)

Measured memory_bytes: 3064
N, M = map(int, input().split())
disputes = [list(map(int, input().split())) for x in range(M)]
disputes.sort(key=lambda x: x[1])
disconnects = []
for dispute in disputes:
    for disconnect in disconnects:
        if dispute[0] <= disconnect and disconnect < dispute[1]:
            break
    else:
        disconnects.append(dispute[1] - 1)
print(len(disconnects))

Measured memory_bytes: 29564
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define ll long long int
#define lim 100010
#define INF 1e9
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define ABS(x) ((x)>0?(x):-(x))

typedef struct{
	ll dX,dY;
}P;

int main(void){
	int n;
	scanf("%d",&n);
	ll x[n],y[n];
	P diff[2500];
	for(int i=0;i<n;i++){
		scanf("%lld%lld",&x[i],&y[i]);
	}
	int c=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i==j)continue;
			diff[c].dX = x[i]-x[j];
			diff[c++].dY = y[i]-y[j];
		}
	}
	int cMAX =c;
	c=0;
	int ans=0;
	while(c<cMAX){
		int num=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(j==i)continue;
				if(x[i]-x[j]==diff[c].dX && y[i]-y[j]==diff[c].dY)num++;
			}
		}
		c++;
		ans = MAX(ans,num);
	}
	if(ans==n)printf("1");
	else printf("%d",n-ans);
	
	return 0;
}

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

int main() {
    int N,K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i=0; i<N; i++) cin>>h.at(i);

    int counter = 0;
    for (int i=0; i<N; i++) {
        if (h.at(i)>=K) counter++;
    }

    cout << counter << endl;
}

Measured memory_bytes: 640
// ARC082
// E - ConvexScore

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 200;
const int MOD = 998244353;

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

int N;
int x[MAX_N], y[MAX_N];
int p2[MAX_N + 1], lc[MAX_N + 1];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }

    p2[0] = 1;
    for (int i = 1; i <= N; i++) {
        p2[i] = (2 * p2[i - 1]) % MOD;
    }

    memset(lc, 0, sizeof(lc));
    for (int i = 0; i < N; i++) {
        map<pii, int> slope;
        for (int j = 0; j < N; j++) {
            if (i == j) {
                continue;
            }
            int dx = x[i] - x[j];
            int dy = y[i] - y[j];
            if (dx < 0) {
                dx *= -1;
                dy *= -1;
            }
            if (dx == 0) {
                dy = 1;
            } else if (dy == 0) {
                dx = 1;
            } else {
                int d = gcd(dx, abs(dy));
                dx /= d;
                dy /= d;
            }
            slope[pii(dx, dy)]++;
        }
        for (auto &p : slope) {
            lc[p.second + 1]++;
        }
    }

    int ans = (p2[N] + MOD - (1 + N + N * (N - 1) / 2)) % MOD;
    for (int i = 3; i <= N; i++) {
        int sel =
            1LL * (MOD - p2[i] + (1 + i + i * (i - 1) / 2)) * (lc[i] / i) % MOD;
        (ans += sel) %= MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
	int N; cin >> N;
	vector<int> a(N);
	rep(i,N) cin >> a[i],a[i]--;
	int ans = 0;
	rep(i,N){
		if(a[a[i]] == i) ans++;
	}
	cout << ans/2 << endl;
}



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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(long long i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const double pi = acos(-1.0);
const ll mod = pow(10,9) + 7;
const ll INF = pow(2,31) - 1;

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll h;
    cin >> h;
    ll n = log2(h)+1;
    ll ans = pow(2,n) - 1;
    cout << ans << endl;
    
    return 0;
}

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

int check(string str) 
{ 
  
    int n = str.length(); 
    int digitSum = 0; 
    for (int i=0; i<n; i++) 
        digitSum += (str[i]-'0'); 
  
    return (digitSum % 9 == 0); 
} 

int main() 
{ 
    string str; 
  cin>>str;
    check(str)?  cout << "Yes" : cout << "No"; 
    return 0; 
} 

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
inline void read(int &x){
    char c=getchar();
    int p=1;
    x=0;
    while(!isdigit(c)){
        if(c=='-')p=-1;
        c=getchar();
    }
    while(isdigit(c)){
        x=(x<<1)+(x<<3)+(c^'0');
        c=getchar();
    }
    x*=p;
}
int a[5];
int main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    read(a[1]);read(a[2]);read(a[3]);
    sort(a+1,a+1+3);
    int ans=a[3]-a[2]+(a[3]-(a[1]+a[3]-a[2]))/2;
    if((a[3]-(a[1]+a[3]-a[2]))&1)ans+=2;
    cout<<ans<<endl;
    return 0;
}


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

const int N=1e5+5;
ll r,c,n;

bool isImportant(int x,int y){
	bool flagx=(x==0)||(x==r);
	bool flagy=(y==0)||(y==c);
	return flagx||flagy;
}

ll w(int x,int y){
	if(x==0) return y;
	if(y==c) return c+x;
	if(x==r) return 2*c+r-y;
	return 2*c+2*r-x;
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>r>>c>>n;
	vector<P> p;
	for(int i=0;i<n;++i){
		int xa,ya,xb,yb;
		cin>>xa>>ya>>xb>>yb;
		if(isImportant(xa,ya)&&(isImportant(xb,yb))){
			ll x=w(xa,ya);
			ll y=w(xb,yb);
			if(x>y) swap(x,y);
			p.emplace_back(x,y);
		}
	}
	sort(p.begin(),p.end());
	stack<ll> s;
	for(P i:p){
		while(!s.empty()&&s.top()<i.first) s.pop();
		if(s.empty()) s.push(i.second);
		else{
			if(s.top()<i.second){
				cout<<"NO\n";
				return 0;
			}
			s.push(i.second);
		}
	}
	cout<<"YES\n";
}




Measured memory_bytes: 5288
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

struct data{
    int num;
    int pos;
};

int main(){
    lli n,sum=0,a,ans;
    data data;
    lli i,j,k;
    vector<lli> point;
    point.push_back(0);
    cin>>n;
    rep(i,1,n+1){
        cin>>a;
        point.push_back(a);
        sum+=abs(point[i-1]-a);
    }
    sum+=abs(point[n]);
    point.push_back(0);
    rep(i,1,n+1){
        ans=sum-(abs(point[i]-point[i-1])+abs(point[i]-point[i+1]));
        ans+=abs(point[i-1]-point[i+1]);
        cout<<ans<<endl;
    }
}


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

int main()
{
    int n, k;
    int i, ans = 1;
    
    cin >> n >> k;
    
    for(i = 0; i < n; i++) {
        if((2 * ans) > ans + k) {
            ans = ans + k;
        } else {
            ans = ans * 2;
        }
    }
    
    cout << ans << "\n";
    
    return 0;
}

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


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  freopen("out", "w", stdout);
#endif

  int n;
  cin >> n;
  unordered_map<string, int> M;
  vector<string> V = {"AC", "WA", "TLE", "RE"};
  for (auto& i : V) M[i] = 0;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    M[s]++;
  }
  for (auto& i : V) {
    cout << i << " x " << M[i] << "\n";
  }
  return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main()
{
        int a;
        int b;
        int d[200];
        int i = 0;
        int j = 0;
        int sum = 0;
        int c = 1;
        while (scanf("%d %d\n", &a, &b) != EOF)
        {   
                c = 1;
                sum = a + b;
                while (sum < 0 || sum > 9)
                {   
                        sum = sum / 10; 
                        c++;
                }   
                d[i] = c;
                i++;
        }   
        for(j = 0; j < i; j++)
        {   
                printf("%d\n", d[j]);
        }   
        return (0);
}


Measured memory_bytes: 1988
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPI(itr, v) for(auto itr = (v).begin(); itr != (v).end(); ++itr)

using namespace std;

typedef struct{
  int to,cost;
} edge;


bool is_line(vector<vector<edge>> G){

  int N = G.size();
  vector<bool> is_visit(N, false);
  vector<int> x(N, 0);

  REP(i, N){
    if(is_visit[i]){
      continue;
    }
    
    queue<int> que;
    que.push(i);
    while(!que.empty()){
      int j = que.front();
      que.pop();
      REPI(itr, G[j]){
	int k = itr->to;
	int x_new = x[j] + itr->cost;
	if(is_visit[k]){
	  if(x[k] != x_new){
	    return false;
	  }
	}else{
	  que.push(k);
	  is_visit[k] = true;
	  x[k] = x_new;
	}
      }
    }
  }

  return true;
}

int main(void){

  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;

  vector<vector<edge>> G(N);
  REP(i, M){
    int L, R, D;
    cin >> L >> R >> D;
    edge e1, e2;
    e1.to = R-1, e1.cost = D;
    e2.to = L-1, e2.cost = -1 * D;
    G[L-1].push_back(e1);
    G[R-1].push_back(e2);
  }

  cout << (is_line(G) ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 15616
package main

import (
	"fmt"
)

func main() {
	var n int
	var value float64
	fmt.Scan(&n)

	sum := 0.0
	for i := 0; i < n; i++ {
		fmt.Scan(&value)

		sum += 1 / value
	}
	fmt.Println(1 / sum)
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
 
int buf[100000] = {};

int main(void) {
  int n, q;
  std::cin >> n >> q;
  std::string s;
  std::cin >> s;
  bool found = false;
  int count = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'A') {
        found = true;
    } else if (s[i] == 'C') {
      if (found) {
        count++;
      }
      found = false;
    } else {
      found = false;
    }
    buf[i] = count;
  }

  for (int i = 0; i < q; ++i) {
    int l, r;
    std::cin >> l >> r;
   	std::cout << buf[r - 1] - buf[l - 1] << std::endl;
  } 
  return 0;
}

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

#define int long long
#define ld long double
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define vt vector
#define pb push_back
#define u_s unordered_set
#define u_m unordered_map
#define p_q priority_queue

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
// if using oset remove define int long long
//#define oset tree<int32_t, null_type, less<int32_t>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
//void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define deb(x...) cout << "[" << #x << "] = ["; _print(x)
int __pow(int x, int y) {int res = 1;while(y>0){if(y&1) res*=x; y>>=1; x*=x;}return res;}
int gcd(int a, int b) {if(b==0) return a; return gcd(b, a % b);}

const int N = 2e5+2, inf = 1e18;

int test, query, n, m;

void test_case()
{
    cin>>n>>m;
    int ans = 0;
    for(int i = 0; i<n; i++)
    {
        int x, y;
        cin>>x>>y;
        if(sqrt(x*x+y*y)<=m) ans++;
    }
    cout<<ans<<endl;
}
int32_t main()
{
//#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
//#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    test = 1;
    //cin>>test;
    while(test--)
        test_case();
#ifndef ONLINE_JUDGE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
    return 0;
}


Measured memory_bytes: 3700
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int H = sc.nextInt();
		int W = sc.nextInt();
		int A[] = new int[N];
		int B[] = new int[N];
		int cnt = 0;
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
			if(A[i] >= H && B[i] >= W) cnt++;
		}
		
		System.out.println(cnt);
	}
}


Measured memory_bytes: 26596
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
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; }
 
ll MOD = 1000000007;
ll INF =1<<30;
ll dp[110][100100];
 
vector<int> fac(1010,0);
void factri(int n){
     if(n==1){
          fac[1]++;
          return;
     }
     for(int i = 2;i*i<=n;++i){
          if(n%i==0){
               while(n%i==0){
                    n/=i;
                    fac[i]++;
               }
          }
     }
     if(n!=1)fac[n]++;
}
int main(){
    int n;
    cin >> n;
    for(int i = 2;i<=n;++i){
         factri(i);
    }
    ll ans =1;
    rep(i,1001){
         if(fac[i]>=1) {
              ans*=fac[i]+1;
              ans%=MOD;
         }
    }
    cout << ans <<endl;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <cmath>

int main() {
    int a, b, C;
    double S, L, h, c;
    double x;
    double PI = acos(-1);
    scanf("%d %d %d", &a, &b, &C);
    x = C * PI / 180;
    h = b * sin(x);
    S = a * h / 2;
    c = sqrt(a*a + b*b - 2*a*b*cos(x));
    L = a + b + c;
    printf("%f\n%f\n%f\n", S, L, h);
    return 0;
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
#define int long long

int nbVertices, nbEdges;
int longestPath[100001];

vector<int> graph[100001];

int dfs(int node){
    if (longestPath[node]) return longestPath[node];

    int longueurMax = 0;

    for (auto voisin : graph[node]){
        longueurMax = max(longueurMax, dfs(voisin));
    }

    longueurMax ++;
    longestPath[node] = longueurMax;
    return longueurMax;
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> nbVertices >> nbEdges;

    for (int i = 0; i < nbEdges; i++){
        int a, b; cin >> a >> b;
        graph[a-1].push_back(b-1);
    }

    int maximum = 0;
    for (int i = 0; i < nbVertices; i++){
        maximum = max(maximum, dfs(i));
    }

    cout << maximum - 1;
}

Measured memory_bytes: 8576
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int X; cin >> X;
    int m=1;
    for(int i=2;i<X;i++){
        int a=i*i;
        while(a<=X){
            if(a>m) m=a;
            a*=i;
        }
        //cerr << i << "\t" << a/i << endl;
    }
    cout << m << endl;
    return 0;
}


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

int main(){
  int n;
  cin>> n;
  vector<int> p(n);
  for (int i=0; i<n; i++) cin>> p.at(i);
  
  int ans=0;
  int left=p.at(0);
  int center=p.at(1);
  int right;
  for (int i=2; i<n; i++){
    right=p.at(i);
    if ((left<center && center<right)||(left>center && center>right)) ans++;
    left=center; center=right;
  }
  cout<< ans <<endl;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;
const ll MOD=1e9+7;

int main() {
    int n;
    cin>>n;
    ll dp[n+1][4][4][4];
    //1A 2C 3G 0T
    memset(dp,0,sizeof(dp));
    dp[0][0][0][0]=1;
    for (int i=1;i<n+1;i++){
        rep(m,4){
            rep(j,4){
                rep(k,4){
                    rep(l,4){
                        if (j==1 && k==3 && l==2){
                            continue;
                        }
                        else if (j==1 && k==2 && l==3){
                            continue;
                        }
                        else if (j==3 && k==1 && l==2){
                            continue;
                        }
                        else if (m==1 && k==3 && l==2){
                            continue;
                        }
                        else if (m==1 && j==3 && l==2){
                            continue;
                        }
                        else{
                            dp[i][j][k][l]+=dp[i-1][m][j][k];
                            dp[i][j][k][l]%=MOD;
                        }
                    }
                }
            }
        }
    }
    ll ans=0;
    rep(i,4){
        rep(j,4){
            rep(k,4){
                ans+=dp[n][i][j][k];
                ans%=MOD;
            }
        }
    }
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 256
fun main(arr:Array<String>) {
    var abc = readLine()!!.split(" ").map { it.toInt() }.sorted().toMutableList()
    var ans = 0
    while (abc[2] - abc[0] >= 2) {
        abc[0] += 2
        abc.sort()
        ans += 1
    }
    if(abc[0] == abc[2]) {
        println(ans)
        return
    }
    if(abc[0] == abc[1]) {
        ans++
    } else {
        ans+=2
    }
    println(ans)
}


Measured memory_bytes: 37740
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int m, n;
long long a[51001];
long long b[550], w[550];

long long INF = 1LL<<61;
long long dp[550][51001];

int main() {
    while (cin >> m >> n) {
        memset(a, 0, sizeof(a));
        for (int i = 0; i < m; ++i) cin >> a[i+1];
        sort(a+1, a+m+1, greater<int>());
        for (int i = 0; i < 51000; ++i) {
            a[i+1] += a[i];
            //cout << i << " : " << a[i] << endl;
        }
        for (int i = 0; i < n; ++i) cin >> b[i] >> w[i];
        
        for (int i = 0; i < 550; ++i) for (int j = 0; j < 51001; ++j) dp[i][j] = INF;
        dp[0][0] = 0;
        for (int i = 0; i <= n; ++i) {
            for (int j = 0; j <= m+20000; ++j) {
                //if (dp[i][j] < INF) cout << i << ", " << j << " : " << dp[i][j] << endl;
                chmin(dp[i+1][j], dp[i][j]);
                if (j + b[i] < 51001) chmin(dp[i+1][j+b[i]], dp[i][j] + w[i]);
            }
        }
        
        long long res = 0;
        for (int i = 0; i <= m+20000; ++i) {
            chmax(res, a[i] - dp[n][i]);
        }
        
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 220740