akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

double x[25],y[25],r[25];
int c[25],ng[25];
int n;
int dp[1<<24];
int dfs(int i){
    int ret=0;
    if(dp[i]!=-1) return dp[i];
    int cur=0;
    int ti=i;
    while(ti){
        if(ti%2==1){
            bool flag=true,flag2=true;
            rep(j,cur)if((i>>j&1)&&(ng[cur]>>j)&1){
                flag=false;break;
            }
            if(flag){
                FOR(j,cur+1,n)if(!((ng[cur]>>j)&1)&&c[cur]==c[j]&&(i>>j&1)){
                    bool f=false;
                    rep(k,j)if((i>>k&1)&&(ng[j]>>k&1)){
                        f=true;break;
                    }
                    if(!f) flag2=false,ret=max(ret,dfs(i^(1<<cur)^(1<<j))+2);
                }
            }
            //if(flag&&!flag2) break;
        }
        ++cur;
        ti>>=1;
    }
    return dp[i]=ret;
}
int main(){
    while(cin>>n,n){
        int cnt=0;
        memset(ng,0,sizeof(ng));
        memset(dp,-1,sizeof(dp));
        rep(i,n) cin>>x[i]>>y[i]>>r[i]>>c[i];
        FOR(i,1,n)rep(j,i){
            if(sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))<r[i]+r[j]){
                ng[i]|=(1<<j);
            }
        }
        cout<<dfs((1<<n)-1)<<endl;
    }
    return 0;
}


Measured memory_bytes: 68684
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
using namespace std;

int main(){
  int N;
  cin>>N;
  vector <int> p(N);
  vector <int> q(N);
  for(int i=0;i<N;i++) {cin>>p[i]; q[i] = i+1;}

  ll cnt = 0;

  for(int i=0;i<N;i++){
    if(p[i] == q[i]) continue;
    cnt++;
  }

  if(cnt == 0 or cnt == 2) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef long double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define cerr if(true)cerr
void print(){cout<<endl;}
template<typename T,typename... Args>
void print(T a, Args... args) {cout<<a<<" ";print(args...);}
lli llipowerp(lli x, lli y, lli p=LLONG_MAX)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
inline void printvec(vector<T> inp){
    for(auto it:inp) cout<<it<<" ";
    cout << endl;
}
//---------------------------------------------------------------------------------
vector<lli> w, v;

lli n, W;
lli dp[(lli)1e5 + 5][101];
lli fill(lli vr, lli i)
{
    if (vr <= 0)
        return 0LL;
    if (i == 0)
        return (lli)1e9+1;
    if(dp[vr][i]!=-1) return dp[vr][i];
    


    dp[vr][i]=min(fill(vr-v[i],i-1)+w[i],fill(vr,i-1));
    return dp[vr][i];


}
int main()
{

    cin >> n >> W;
    w.resize(n + 1);
    v.resize(n + 1);
    fori(n)
    {
        cin >> w[i + 1] >> v[i + 1];
    }
    memset(dp, -1, sizeof(dp));
    lli ans = 0;
    for(lli i=1;i<=(lli)1e5;i++){
        for(lli j=1;j<=n;j++){
            if(fill(i,j)<=W){
               // cout<<i<<" "<<j<<" "<<fill(i,j)<<endl;
                ans=max(ans,i);
            }
        }
    }
    
    
    cout<<ans<<endl;
    
}

Measured memory_bytes: 79104
from collections import deque
n,m=map(int,input().split())
p=list(map(int,input().split()))
ab=[[] for _ in range(n+1)]
ab_dict={}
count=0
for i in range(1,n+1):
    ab_dict[p[i-1]]=i
    if p[i-1]==i:
        count+=1
for i in range(m):
    a,b=map(int,input().split())
    ab[a].append(b)
    ab[b].append(a)
visited=[1]+[0]*(n)
su=[]
for i in range(1,n+1):
    if visited[n]==0:
        temp=set()
        temp.add(i)
        stack=deque()
        stack.append(i)
        visited[i]+=1
        while stack:
            x=stack.pop()
            for j in ab[x]:
                if visited[j]==0:
                    visited[j]+=1
                    stack.append(j)
                    temp.add(j)
        su.append(temp)

for k in su:
    for l in k:
        if ab_dict[l] in k and ab_dict[l]!=l:
            count+=1
print(count)

Measured memory_bytes: 126360
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    ll N,A,B;cin>>N>>A>>B;
    vector<ll> h(N);
    REP(i, N) cin >> h[i];
    ll l=0,r=1e9;
    while(l+1<r){
        ll m=(l+r)/2;
        ll cnt=0;
        REP(i,N) if(B*m<h[i]) cnt+=(h[i]-B*m-1)/(A-B)+1;
        if(cnt<=m) r=m;
        else l=m;
    }
    cout<<r<<endl;
}


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

int main()
{
	int n;
	cin >> n;
	int tmp, min, max;
	cin >> tmp;
	min = max = tmp;
	for(int i = 1; i < n; i++)
	{
		cin >> tmp;
		if( tmp > max )
			max = tmp;
		if( tmp < min )
			min = tmp;
	}
	cout << abs(max-min);
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll m, ll n){
	ll tmp;
	while(m % n != 0){
		tmp = n;
		n = m % n;
		m = tmp;
	}

	return n;
}

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

	int n;
	ll x;
	cin >> n >> x;

	ll y[n+1];
	ll mn = 1e11;
	rep(i, n){
		cin >> y[i];
		mn = min(mn, y[i]);
	}
	y[n] = x;
	mn = min(mn, y[n]);

	rep(i, n+1) y[i] -= mn;

	ll ans = (y[0] == 0 ? y[1] : y[0]);

	rep(i, n){
		if(y[i+1] == 0) continue;
		ans = gcd(ans, y[i+1]);
	}

	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n;
    cin>>n;
    int x[n],t[n];
    map<int,int>mp;
    for(int i=0;i<n;i++){
        cin>>x[i];
        t[i]=x[i];
    }
    int a,b;
    sort(t,t+n);
    for(int i=0;i<n;i++)mp[t[i]]=i;
    a=t[n/2-1];
    b=t[n/2];
    for(int i=0;i<n;i++){
        if(mp[x[i]]<n/2){
            cout<<b<<endl;
        }else{
            cout<<a<<endl;
        }
    }
 return 0;   
}

Measured memory_bytes: 12928
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <fstream>
#include <queue>
#include <cmath>
#include <algorithm>

using namespace std;

const int MAXN = 107;
const int INF = 1e9 + 7;

int dp[MAXN][MAXN][MAXN];

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

    for (int i = 0; i < MAXN; ++i) {
        for (int j = 0; j < MAXN; ++j) {
            for (int k = 0; k < MAXN; ++k) {
                dp[i][j][k] = INF;
            }
        }
    }

    int a, b, c;
    cin >> a >> b >> c;

    dp[a][b][c] = 0;
    for (int i = 0; i < MAXN; ++i) {
        for (int j = 0; j < MAXN; ++j) {
            for (int k = 0; k < MAXN; ++k) {
                if (i && j) dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - 1][k] + 1);
                if (i && k) dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j][k - 1] + 1);
                if (j && k) dp[i][j][k] = min(dp[i][j][k], dp[i][j - 1][k - 1] + 1);
                if (i >= 2) dp[i][j][k] = min(dp[i][j][k], dp[i - 2][j][k] + 1);
                if (j >= 2) dp[i][j][k] = min(dp[i][j][k], dp[i][j - 2][k] + 1);
                if (k >= 2) dp[i][j][k] = min(dp[i][j][k], dp[i][j][k - 2] + 1);
            }
        }
    }

    int ans = INF;
    for (int i = 0; i < MAXN; ++i) {
        ans = min(ans, dp[i][i][i]);
    }

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


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

using ll = long long;

const ll MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    map<int, int> mp;
    mp[0] = 0;
    rep(i, N) {
        cin >> a[i];
        mp[a[i]]++;
    }
    vector<int> k(0);
    for (auto i = mp.begin(); i != mp.end(); i++) {
        k.push_back(i->first);
    }
    sort(k.begin(), k.end());
    //rep(i, k.size()) cout << k[i] << mp[k[i]] << endl;
    int j = 0;
    ll d = N;
    rep(i, N) {
        ll c = 0;
        while (a[i] > k[j]) {
            c += d * (k[j + 1] - k[j]);
            j++;
            d -= mp[k[j]];
        }
        cout << c << endl;
    }
}

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

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

    int x, a, b;
    cin >> x >> a >> b;

    if (a - b >= 0) {
        cout << "delicious" << endl;
    } else if (x + a - b >= 0) {
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }
}


Measured memory_bytes: 256
N = int(input())
s = []
t = []
for i in range(N) :
  tmp = input().split()
  s.append(tmp[0])
  t.append(int(tmp[1]))
X = input()

num = s.index(X) + 1

if N > num :
  print(sum(t[num:]))
else :
  print(0)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main(void){
    double a;
    cin >> a;
    
    double b = sqrt(a*a - (int)a/1*(int)a/1);
    
    double x = 0;
    if (b < 1) x = (int)a/1 + 1;
    
    double z = a/sqrt(2) * 2;
    
    double ans;
    b < 1 ? ans = max(x,z) : ans = z;
    printf("%.12lf\n",ans);
}

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

using std::vector;

using Node = size_t;
using AdjacencyList = vector<vector<Node>>;

AdjacencyList ReadInput(std::istream& in_stream = std::cin);
bool Solve(const AdjacencyList& adjacency_list);
void WriteAns(const bool ans, std::ostream& out_stream = std::cout);

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  auto input = ReadInput();
  auto result = Solve(input);
  WriteAns(result);
  
  return 0;
}

bool Solve(const AdjacencyList& adjacency_list) {
    size_t nodes = adjacency_list.size();
    
    for (auto neigbour : adjacency_list[0]) {
        for (auto son : adjacency_list[neigbour]) {
            if (son == nodes - 1) {
                return true;
            }
        }
    }

    return false;
}

AdjacencyList ReadInput(std::istream& in_stream) {
    size_t nodes, edges;
    in_stream >> nodes >> edges;

    AdjacencyList adjacency_list(nodes);
    for (size_t i = 0; i < edges; ++i) {
        Node a, b;
        in_stream >> a >> b;
        --a, --b;

        adjacency_list[a].push_back(b);
        adjacency_list[b].push_back(a);
    }

    return adjacency_list;
}

void WriteAns(const bool ans, std::ostream& out_stream) {
    if (ans) {
        out_stream << "POSSIBLE";
    } else {
        out_stream << "IMPOSSIBLE";
    }
}

Measured memory_bytes: 12776
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int n = kb.nextInt();
		int k = kb.nextInt();
		int count = 0;
		ArrayList<Integer> a = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			int p = kb.nextInt();
			a.add(p);
		}
		Collections.sort(a);
		for (int i = 0; i < k; i++) {
			count += a.get(i);
		}

		System.out.println(count);

		kb.close();
	}

}


Measured memory_bytes: 30344
n = int(input())
l = list(map(int,input().split()))
flag=True
if len(l)==1:
  print("Yes")
else:
  for i in range(n-1):
    if l[i+1]-l[i]>=1:
      l[i+1] = l[i+1]-1
    elif l[i+1]<l[i]:
        flag=False
        break
    else:
      pass
  if flag:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 14396
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>pii;
typedef vector<pii>Vll;
typedef vector<pair<int,pair<int,int> > >Vlll;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) cin>>n
#define pl(n) cout<<n<<" "
const int N=1e5+2;
const int inf= (int)(1e19+10LL);
    
void solve(){
	string str;
	sl(str);
	if(str=="ABC")cout<<"ARC"<<endl;
	else{
		cout<<"ABC"<<endl;
		return;
	}
}

signed main(){
  int test=1;
// sl(test);
 while(test--){
 	solve();
 }
 
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}
const int N = 2e5 + 50;
ll mod = 998244353;
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937_64 mt(seed);
int fac[N],invf[N];
inline int add(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }
inline int sub(int x, int y) { return x - y >= 0 ? x - y : x - y + mod; }
inline int power(int x, int y, int res = 1) {
    for (; y; y >>= 1, x = 1ll * x * x % mod) {
        if (y & 1) { res = 1ll * res * x % mod; }
    } return res;
}
void initcombi(int n) {
    for (int i = fac[0] = 1; i <= n; i++) { fac[i] = 1ll * fac[i - 1] * i % mod; }
    invf[n] = power(fac[n], mod - 2);
    for (int i = n; i; i--) { invf[i - 1] = 1ll * invf[i] * i % mod; }
}
 
inline int NCR(int n, int m) {
    if (n < m) { return 0; }
    return 1ll * fac[n] * invf[m] % mod * invf[n - m] % mod;
}
int ans[N];
int main() {
    io();
    int n, x, y;
    cin >> n >> x >> y;


    for(int i = 1; i <= n; i++) {
        for(int j = i + 1; j <= n; j++) {
            ans[min({j - i, abs(x - i) + abs(y - j) + 1, abs(y - i) + abs(x - j) + 1})]++;
        }
    }

    for(int i = 1; i < n; i++)  cout << ans[i] << "\n";


}
    

Measured memory_bytes: 256
import java.util.Map;
import java.util.Scanner;

public class Main {

    /**
     * 本処理を実行します。
     */
    public static void execute() {
        Scanner sc = new Scanner(System.in);

        int n = nextInt(sc);
        String nc = String.valueOf(n);

        int num = 0;

        for (int i = 0; i < nc.length(); i++) {
            num += Integer.valueOf(nc.substring(i, i + 1));
        }

        if (n % num == 0) {
            out("Yes");
        } else {
            out("No");
        }
    }

    /**
     * 次の標準入力をintで受け取ります。
     * @return 標準入力値(int)
     */
    public static int nextInt(Scanner sc) {
        return sc.nextInt();
    }

    /**
     * 次の標準入力をStringで受け取ります。
     * @return 標準入力値(String)
     */
    public static String nextString(Scanner sc) {
        return sc.next();
    }

    /**
     * 次の標準入力を指定回数分intで受け取ります。
     * @param n 取得回数
     * @return 取得した標準入力値の配列(int)
     */
    public static int[] nextInts(Scanner sc, int n) {
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = nextInt(sc);
        }

        return arr;
    }

    /**
     * 標準出力にオブジェクトを出力します。
     * @param o 出力対象
     */
    public static void out(Object o) {
        System.out.println(o);
    }

    public static void main(String[] args) {
        execute();
    }

    public static void putCountMap(Map<Integer, Integer> map, int value) {
        if (map.containsKey(value)) {
            map.put(value, map.get(value) + 1);
        } else {
            map.put(value, 1);
        }
    }
}



Measured memory_bytes: 21844
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

ll calc(int N, int M, int Q, vint& A, vint& a, vint& b, vint& c, vint& d, int add_i) {
    ll score = 0;
    //rep(i, N) cout << A[i] << " ";
    //cout << endl;
    rep(i, Q) {
        if (A[a[i] - 1] - A[b[i] - 1] == c[i]) score += ll(d[i]);
    }
    vint newA = A;
    if (add_i < N) {
        REP(i, 1, M + 1) {

            newA[add_i] = i;
            if (add_i - 1 >= 0 && newA[add_i - 1] < newA[add_i]) continue;
            score = max(score, calc(N, M, Q, newA, a, b, c, d, add_i + 1));
        }
    }
    return score;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, M, Q;
    cin >> N >> M >> Q;
    vint a(Q), b(Q), c(Q), d(Q);
    rep(i, Q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    vint A(N, 1);
    ll ans = calc(N, M, Q, A, a, b, c, d, 0);

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

Measured memory_bytes: 3616
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
template <class... T> void printd(T&&...){ }
#endif

int main(){
    ll n, m;
    cin >> n >> m;
    if(2 * n >= m){
        cout << m / 2 << '\n';
    }else{
        cout << n + (m - 2 * n) / 4 << '\n';
    }
    return 0;
}


Measured memory_bytes: 888
package main

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

var sc *bufio.Scanner

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 0), 1000000001*3)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	ans := n
	for i := 1; i*i <= n; i++ {
		if n%i > 0 {
			continue
		}
		j := n / i
		if (i-1)+(j-1) < ans {
			ans = (i - 1) + (j - 1)
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<stdio.h>

int main(void) {
	
	int n, k, ans=0;
	int a[101][101], d[101], s[101];

	scanf("%d%d", &n, &k);

	for (int i = 1; i <= k; i++) {
		scanf("%d", &d[i]);
		for (int j = 1; j <= d[i]; j++) {
			scanf("%d", &a[i][j]);
		}
	}

	for (int i = 1; i <= n; i++) {
		s[i] = 0;
	}

	for (int i = 1; i <= k; i++) {
		for (int j = 1; j <= d[i]; j++) {
			s[a[i][j]]++;
		}
	}

	for (int i = 1; i <= n; i++) {
		if(s[i] == 0) ans++;
	}

	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 1764
#include <iostream>
#include <string>
#include <climits>
using namespace std;
const int INFY = INT_MAX;
int p[101], M[101][101];

void matrixCahinOrder(int length){
    int n = length - 1;
    for (int i = 1; i <= n; i++){
        M[i][i] = 0;
    }
    for (int l = 2; l <= n; l++){
        for (int i = 1; i <= n-l+1; i++){
            int j = i + l - 1;
            M[i][j] = INFY;
            for (int k = i; k <= j-1; k++){
                int q = M[i][k] + M[k+1][j] + p[i-1]*p[k]*p[j];
                M[i][j] = min(M[i][j], q);
            }
        }
    }
}
int main(int argc, char* argv[]) {
    int n, tmp;
    cin >> n;
    for (int i = 0; i < n; i++){
            cin >> p[i] >> tmp;
    }
    p[n] = tmp;

    /*
    for (int i = 0; i <= n; i++){
        cout << p[i] << endl;
    }
    */
    matrixCahinOrder(n+1);
    cout << M[1][n] << endl;
    return 0;
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const ll INF = (1LL << 31) - 1;
const double pi=acos(-1);

int main(){
  ll n,k,q ;
  cin >> n >> k >> q;
  vector<ll>vec(n,0);
  rep(i,q){
    ll a;
    cin >> a;
    a--;
    vec[a]++;
  }
  rep(i,n){
    if(k-(q-vec[i])>0)cout<<"Yes"<<endl;
    else cout << "No" << endl;
  }
  
}


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

using namespace std;

int main() {
    int n, a, b;
    cin >> n >> a >> b;

    while (true) {
        if (b - a > 1) {
            a++;
        } else {
            cout << "Borys" << endl;
            return 0;
        }

        if (b - a > 1) {
            b--;
        } else {
            cout << "Alice" << endl;
            return 0;
        }
    }
}

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

int main(){
  int n;
  cin >> n;
  P a[n];
  rep(i,n){
    int c;
    cin >> c;
    a[i] = P(c,i); 
  }
  sort(a,a+n);
  rep(i,n) cout << a[i].second + 1 << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 1536
# coding: utf-8

line = input()
while line != "0":
    gameCount = int(line)
    pointOfA = 0
    pointOfB = 0
    for count in range(gameCount):
        cardOfA, cardOfB = list(map(int, input().split(" ")))
        if cardOfA > cardOfB:
            pointOfA += cardOfA + cardOfB
        elif cardOfB > cardOfA:
            pointOfB += cardOfA + cardOfB
        else:
            pointOfA += cardOfA
            pointOfB += cardOfB
    print("{0} {1}".format(pointOfA, pointOfB))
    line = input()
    

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

int main() {

    int n, k, q;

    cin >> n >> k >> q;

    vector<int> point(n, 0);


    for(int i = 0; i < q; ++i) {
        int num;
        cin >> num;

        point[num - 1]++;

    }

    for(int i = 0; i < n; ++i) {

        if(k - q + point[i] > 0)
            cout << "Yes";
        else
            cout << "No";
        cout << endl;


    }

    return 0;

}

Measured memory_bytes: 1024
//<editor-fold desc="I/O Templates">
private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readLong() = readLn().toLong()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map(String::toInt)
private fun readLongs() = readStrings().map(String::toLong)
//</editor-fold>

fun main() {
    var (a, b, c) = readInts()
    val k = readInt()
    var times = 0
    while (a >= b) {
        b *= 2
        times++
    }
    while (b >= c) {
        c *= 2
        times++
    }
    println(if (times > k) "No" else "Yes")
}

Measured memory_bytes: 36408
#include<bits/stdc++.h>
//One implementation to rule them all?
#define db 				double
#define ll 				long long int
//#define ld				long long double
//#define int 			long long int
#define ull 			unsigned long long
#define fi 				first
#define se 				second
#define rep(i,a,n)      for(int i=a;i<n;i++)
#define repr(i,n,b)     for(int i=n;i>=b;i--)
#define endl 			'\n'
#define mem(a,b) 		memset(a, b, sizeof a)
#define mkp 			make_pair
#define pb 				push_back
#define max3(a,b,c) 	max(a,max(b,c))
#define min3(a,b,c) 	min(a,min(b,c))
#define w(t)            int t; cin>>t; while(t--)
#define all(a)			a.begin(), a.end()
#define sz(a)           int((a).size())
#define tr(container, it) \
for(auto it = container.begin(); it != container.end(); it++)
using namespace std;
typedef vector < int > vii;
typedef vector < ll > vll;
typedef vector < vii > vvi;
typedef pair < int,int > pii;
const db PI = 2*acos(0.0);
const int INF = 0x3f3f3f3f;
const ll LINF = (ll)2e18;
db eps       =			0.000001;
ll mod       =			(1e9+7);   //998244353
void print(vector <int> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";
    
    cout<<endl;
}
void printll(vector <ll> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";
    
    cout<<endl;
}

ll ncr(ll n, ll r)
{
    r=min(r,n-r);
    ll A[r],i,j,B[r];
    iota(A,A+r,n-r+1);  
    iota(B,B+r,1);     

    ll g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    ll ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}
const int SIZE=200001;
bool judgePermutation(int a[], int n){
    static int used[SIZE+1];
    for(int i = 1; i <= n; i++) used[i] = 0;
    for(int i = 0; i < n; i++) used[a[i]] = 1;
    for(int i = 1; i <= n; i++) {
        if(!used[i]) return 0;
    }
    return 1;
}
//DSU Implementation
void init(int idx[], int sz[],int n){
	rep(i,0,n) idx[i]=-1, sz[i]=1;
}
int root(int index, int idx[]){
	while(index!=idx[index]){
		index=idx[index];
	}
	return index;
}
bool qfind(int p, int q, int idx[]){
	return root(p,idx)==root(q,idx);
}
void qunion(int p, int q, int idx[], ll sz[]){
	int rootp=root(p,idx), rootq=root(q,idx);
	if(rootp==rootq) return;
	idx[rootq]=rootp;
	sz[rootp]+=sz[rootq];
}


int main(){	
//CONDITION && cout << "YES" || cout << "NO"; cout << '\n';
//////////////////////////////////////////////////////////////////////
//  ios_base::sync_with_stdio(false);
//  cin.tie(NULL);
//  cout.tie(NULL);
//  cerr.tie(NULL);
//For fast IO
///////////////////////////////////////////////////////////////////// 
//  std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//  std::cout.precision(10);
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	db a,b,h,m;
	cin>>a>>b>>h>>m;
	db x1,x2,y1,y2;
	db t1=(h/6)*PI+((m*PI)/360), t2=(m*PI)/30;
	//cout<<t1<<" "<<t2<<endl;
	x1=a*sin(t1), y1=a*cos(t1), x2=b*sin(t2), y2=b*cos(t2);
	db dist=(x1-x2)*(x1-x2);
	dist+=(y1-y2)*(y1-y2);
	dist=sqrt(dist);
	printf("%0.9lf\n",dist);
	return 0;
    }

Measured memory_bytes: 4104
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NM[0]; var M = NM[1];
            Console.WriteLine(N * (N - 1) / 2 + M * (M - 1) / 2);
        }
    }
}


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

sum=0
a=list(map(int,input().split()))
for num in range(M):
	sum=sum+a[num]
	
nokori=N-sum	
if nokori>=0:
	print(nokori)
	
else:
	print(-1)

Measured memory_bytes: 10188
s = gets.chomp.split("")
if s.size == 2
  if s.uniq.size == 1
    puts "1 2"
    exit
  end
else
  0.upto(s.size - 3) do |left|
    tmp_s = s[left, 3]
    if tmp_s.uniq.size < 3
      puts "#{left + 1} #{left + 3}"
      exit
    end
  end
end
puts "-1 -1"


Measured memory_bytes: 9468
#include <iomanip>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define vec vector<long long int>
#define fi first
#define se second
#define pb push_back
int main()
{
    int n;
    cin >> n;
    if (n == 0)
    {
        cout << 1;
    }
    else
    {
        cout << 0;
    }
}

Measured memory_bytes: 3668
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

X, Y = sys.stdin.readline().split()

if X < Y:
    print("<")
elif X > Y:
    print(">")
else:
    print("=")

Measured memory_bytes: 63980
#include <stdio.h>

int main(void) {
  int a = 0;
  int b = 0;
  
  int area = 0;
  int length = 0;

  scanf("%d", &a);
  scanf("%d", &b);

  area = a * b;
  length = 2 * (a + b);

  printf("%d %d\n", area, length);

  return 0;
}

Measured memory_bytes: 596
// AOJ 1167
#include<cstdio>
#include<algorithm>
#include<vector>
#define rep(i,a) for( int i = 0; i != (a); ++i )

const int INF = 1<<30;

std::vector<int> tet;
std::vector<int> dp( 1000001, INF ), dpOdd( 1000001, INF );

int main()
{
	for( int i = 1; i*(i+1)*(i+2)/6 <= 1000000; ++i )
		tet.push_back( i*(i+1)*(i+2)/6 );

	dp[0] = dpOdd[0] = 0;
	rep( i, 1000001 )
	{
		rep( j, tet.size() )
		{
			if( i-tet[j] >= 0 )
			{
				dp[i] = std::min( dp[i], dp[i-tet[j]]+1 );
			
				if( tet[j]&1 )
					dpOdd[i] = std::min( dpOdd[i], dpOdd[i-tet[j]]+1 );
			}
		}
	}

	int n;
	while( scanf( "%d", &n ), n )
		printf( "%d %d\n", dp[n], dpOdd[n] );

	return 0;
}

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

int a,b;
int k,x;


int main()
{
    cin>>k>>x;
    for(int i=k-1;i>=0;i--)
    {
    	cout<<x-i<<" ";
	}
	for(int i=1;i<=k-1;i++)
	{
		cout<<x+i<<" ";
	}
    
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
int n,k,q;
int calc(vector<int> const& a,int mn){
  vector<int> buf;
  vector<int> hoge;
  rep(i,n+1){
    if(a[i]<mn){
      sort(buf.begin(),buf.end());
      if(buf.size()>=k){
        rep(j,buf.size()-k+1){
          hoge.push_back(buf[j]);
        }
      }
      buf.resize(0);
    }
    else{
      buf.push_back(a[i]);
    }
  }
  int res=inf;
  sort(hoge.begin(),hoge.end());
  if(hoge.size()>=q){
    res=hoge[q-1]-hoge[0];
  }
  return res;
}
signed main(){
  cin>>n>>k>>q;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  int res=inf;
  vector<int> num(a);
  a.push_back(0);
  sort(num.begin(),num.end());
  rep(i,n){
    res=min(res,calc(a,num[i]));
  }
  //if(res==inf)res=-1;
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll ans(ll a){
    if(a<10) return 0;
    ll sum=0,k=0,kk=0;
    while(a>0) sum+=a%10,a/=10,k++;
    rep(i,ll(log10(sum))) kk+=sum/ll(pow(10,i+1))-1;
    return ans(sum)+kk+k-1;
}
int main(){
    ll m,D[200001],C[200001],sum=0,k=0,kk=0;
    cin>>m;
    rep(i,m) cin>>D[i]>>C[i],sum+=D[i]*C[i],k+=C[i];
    rep(i,ll(log10(sum))) kk+=sum/ll(pow(10,i+1))-1;
    cout<<ans(sum)+kk+k-1;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
int main() {
  int N; cin >> N;
  //AC, WA, TLE, RE 
  vi ans(4,0);
  rep(i,N){
    string rsl; cin >> rsl;
    if (rsl == "AC")  ans[0]++; 
    if (rsl == "WA")  ans[1]++; 
    if (rsl == "TLE")  ans[2]++; 
    if (rsl == "RE")  ans[3]++; 
  }
  cout << "AC x " << ans[0] << endl;
  cout << "WA x " << ans[1] << endl;
  cout << "TLE x " << ans[2] << endl;
  cout << "RE x " << ans[3] << endl;
}


Measured memory_bytes: 3620
n = gets.chomp.to_i
as = gets.chomp.split.map(&:to_i)

is = {}
as.each_with_index do |a, i|
    x = a + i
    is[x] = [] if is[x].nil?
    is[x] << i
end

cnt = 0
as.each_with_index do |a, j|
    x = j - a
    cnt = cnt + (is[x] || []).count
end

puts cnt


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

using namespace std;


int main() {
	int n = 1;
	cin >> n ;
	assert(n >= 2 && n <= 50);

	vector<int> d_list;
	int ret = 0;
	for (int i = 1; i <= n; i++) {
		int d_i = 0;
		cin >>  d_i;
		assert(d_i >= 0 && d_i <= 100); 
		for (int j = 0; j < d_list.size(); j++) {
			ret += d_list[j] * d_i;
 		}
		d_list.push_back(d_i);
	}
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int N = cin.nextint;
        eratos(N + 2);
        //WriteLine(prime.Count);
        int cnt = 0;
        foreach (var item in prime)
        {
            if (item <= N && is_prime[item + 2])
            {
                cnt += 2;
            }
        }
        WriteLine(cnt);
    }

    List<int> prime;
    bool[] is_prime;
    void eratos(int n)
    {
        prime = new List<int>();
        is_prime = new bool[n + 1];
        for (int i = 0; i <= n; i++) is_prime[i] = true;
        is_prime[0] = is_prime[1] = false;
        for (int i = 0; i <= n; i++)
        {
            if (is_prime[i])
            {
                prime.Add(i);
                for (int j = 2 * i; j <= n; j += i) is_prime[j] = false;
            }
        }
    }
    int[] P;
    void phi(int n)
    {
        P = new int[n + 1];
        for (int i = 0; i <= n; i++) P[i] = i;
        for (int i = 2; i <= n; i++)
        {
            if (is_prime[i])
            {
                P[i] -= P[i] / i;
                for (int j = 2 * i; j <= n; j += i) P[j] -= P[j] / i;
            }
        }
    }
}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}   


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

using i64 = long long int;

int main(){
    string s;
    int w;
    cin >> s >> w;
    for(int i=0;i<s.size();i+=w){
        cout << s[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<string>
#include<string.h>
#include<map>
#include<vector>
#include<set>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main()
{
	char s[200];
	cin>>s;
	cout<<s[0]<<strlen(s)-2<<s[strlen(s)-1];
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int sum(int x[], int n)
{
  int a, t_sum=0;
  for(a=1; a<n-1; a++)
    {
      t_sum+=x[a];
    }
  return t_sum;
}


int main(void)
{
  int count=0, check=0, i=0,k=0, avg[101]={0};

  while(1)
    {
      int  temp=0, score[101]={0};
      scanf("%d", &count);
      if(count==0)
	{

	  for(i=1;i<=k;i++)
	    {
	      printf("%d\n", avg[i]);
	    }
	  return 0;
	}
      else
	{
	  k++;
	  for(i=0; i<count; i++)
	    {
	      scanf("%d", &check);
	      score[i]=check;
	    }
int t, j, temp;

  for(t=0;t<count-1;t++)
    {
      for(j=count-1;j>t; j--)
	{
	  if(score[j-1]>score[j])
	    {
	    temp=score[j];
	  score[j]=score[j-1];
	  score[j-1]=temp;
	    }
	}
    }
	  temp=sum(score,count);

	  avg[k]=temp/(count-2);
	  
	}
    }

}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define ks ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fr first
#define sc second
#define pb push_back
#define pf push_front
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>pa;
template<class T>inline void read(T &res){
    char c;T flag=1;
    while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
    while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
void wenjian(){freopen("concatenation.in","r",stdin);freopen("concatenation.out","w",stdout);}
void tempwj(){freopen("hash.in","r",stdin);freopen("hash.out","w",stdout);}
ll gcd(ll a,ll b){return b == 0 ? a : gcd(b,a % b);}
ll qpow(ll a,ll b,ll mod){a %= mod;ll ans = 1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod;b >>= 1;}return ans;}
struct chongzai{int c; bool operator<(const chongzai &b )const{ return c>b.c; } }s;

const int maxn=4e5+177;
const ll mod=0x3f3f3f3f3f3f3f3f;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
int maxx=1;
int fa[maxn],siz[maxn];

int get(int now){
    return now==fa[now]?now:fa[now]=get(fa[now]);
}

void bcj(int x,int y){
    int xx=get(x);
    int yy=get(y);

    if(xx!=yy){
        fa[xx]=yy;
        siz[yy]+=siz[xx];
        maxx=max(maxx,siz[yy]);
    }

}


int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        fa[i]=i;
        siz[i]=1;
    }
    int a,b;
    for(int i=1;i<=m;i++){
        scanf("%d%d",&a,&b);
        bcj(a,b);
    }
    printf("%d\n",maxx);


}


Measured memory_bytes: 5308
n = int(raw_input())
ais = map(int, raw_input().split(' '))
cumul = [0,1]
"""
a    b
15 = 6 x 2 + 3
b    a%b

a    b       a%b
6  = 3 x 1 + 0
b    a%b

a   b
3   0

"""
def gcd(a,b):
	return gcd(b, a % b) if b else a
	#return a if a else gcd(b, a % b)
for a in ais:
	b,c = cumul
	#1c   ab
	#ac   ac

	cumul = [c + a*b, a*c]
	g = gcd(cumul[0], cumul[1])
	cumul = [cumul[0]/g, cumul[1]/g ]

print float(cumul[1])/cumul[0]

Measured memory_bytes: 32796
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum P = 10L^^9+7;

void main()
{
    auto N = readln.chomp.to!long;
    auto S = readln.chomp;
    long x, r = 1;
    foreach (c; S) {
        if (c == 'B') {
            if (x%2 == 0) {
                x += 1;
            } else {
                (r *= x) %= P;
                x -= 1;
            }
        } else {
            if (x%2 == 0) {
                (r *= x) %= P;
                x -= 1;
            } else {
                x += 1;
            }
        }
    }
    if (x != 0) {
        writeln(0);
        return;
    }

    foreach (long n; 1..N+1) (r *= n) %= P;
    writeln(r);
}

Measured memory_bytes: 2996
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	m := iScan()
	a := append([]int{-1}, iSScan(m)...)
	a = append(a, n+1)
	fib := make([]int, n+10)
	fib[0], fib[1] = 1, 1
	for i := 2; i < n+10; i++ {
		fib[i] = fib[i-1] + fib[i-2]
		fib[i] %= mod
	}
	ans := 1
	for i := 1; i < m+2; i++ {
		if a[i]-a[i-1] == 1 {
			ans = 0
			break
		} else {
			ans *= fib[a[i]-1-a[i-1]-1]
			ans %= mod
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4724
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,k,ans;
int main()
{
	cin>>a>>b>>c>>k;
	int x=min(a,k);
	ans+=x;
	k-=x;
	x=min(b,k);
	k-=x;
	x=min(c,k);
	ans-=x;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <queue>
#include <deque>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define LL long long
#define Pair pair<int,int>
#define LOWBIT(x) x & (-x)
using namespace std;

const int MOD=2e9;
const long long INF=1e16;
const int magic=348;

int n;
int a[200048];
LL dp1[200048][2],dp2[200048][2];
LL sum=0;
LL s1,s2;

inline LL myabs(LL x)
{
	return x>=0?x:-x;
}

int main ()
{
	int i,j;
	scanf("%d",&n);
	for (i=1;i<=n;i++) 
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	LL ans=INF;
	s1=0;s2=sum;
	for (i=1;i<=n-1;i++)
	{
		s1+=a[i];s2-=a[i];
		if (myabs(s1-s2)<ans) ans=myabs(s1-s2);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("03")
#pragma GCC optimize ("unroll-loops")
#define ll long long
#define ms(a) memset(a,0,sizeof(a))
#define endl '\n'
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define mpp(a,b,c) make_pair(a,make_pair(b,c))
#define fi first
#define se second
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define repp(a,b,c) for(int a=b;a>=c;a--)
ll wei[110],val[110];
ll memo[110][101000];
ll n,maxw;

ll dp(ll idx,ll value){
	if(value <= 0)return 0;
	else if(idx==n+1)return 1e15;
	else if(memo[idx][value]!=-1)return memo[idx][value];
	else{
		return memo[idx][value] = min(dp(idx+1,value),dp(idx+1,value-val[idx])+wei[idx]);
	}
}

int main(){
/////////////////////////////////////////////
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
/////////////////////////////////////////////
	memset(memo,-1,sizeof(memo));
	ms(wei);
	ms(val);
	cin >> n >> maxw;
	rep(i,1,n){
		cin >> wei[i] >> val[i];
	}
	ll res;
	rep(i,1,100001){
		res = dp(1,i);
		if(res > maxw){
			res = i-1;
			break;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 87040
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(...) recursive_debug(#__VA_ARGS__, __VA_ARGS__)

void recursive_debug(string) { cerr << endl; }

template<class H,class... T>
void recursive_debug(string s, H h, T... t) {
    int comma = s.find(',');
    cerr << s.substr(0,comma) << " = " << h << ", ";
    recursive_debug(s.substr(comma+1), t...);
}

template<class T,class U>
ostream& operator<<(ostream& ost, const pair<T,U> &p) {
    ost << "(" << p.first << ", " << p.second << ")";
    return ost;
}

template<class T>
ostream& operator<<(ostream &ost, const vector<T> &v) {
    ost << "[";
    for(T t : v) ost << t << ",";
    ost << "]";
    return ost;
}

int main(void){
    int D;
    cin >> D;
    int M = 26;
    vector<int> c(M);
    rep(m,M) cin >> c[m];
    vector<vector<int>> s(D, vector<int>(26));
    rep(d,D) {
        rep(m,M){
            cin >> s[d][m];
        }
    }
    rep(d,D) cout << rand()%M + 1 << endl;
    return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
 
typedef long long ll;
typedef pair<ll, int> ll_i;

int main() {
	ll a,b,r=0;
	cin >> a >> b;
	int t = b - a;
	rep(i,t) r+=i;
	r -= a;
	cout<<r<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;

LL n;
LL t=2;
LL ans;

inline LL qr()
{
	LL w=1,x=0;char a=0;
	while(a<'0'||a>'9'){if(a=='-')w=-1;a=getchar();}
	while(a>='0'&&a<='9'){x=(x<<3)+(x<<1)+(a^48);a=getchar();}
	return x*w;
}

int main()
{
	cin>>n;
	while(n>1)
	{
		n>>=1;
		ans+=t;
		t<<=1;
	}
	cout<<ans+1;
	return 0;
} 

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

const ll mod = 1000000007;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    string s;
    cin >> s;
    int sz = SZ(s);
    int l = 0, r = sz - 1;
    while (l < r) {
    	if (s[l] != s[r]) {
    		cout << "No\n";
    		return 0;
    	}
    	l++;
    	r--;
    }
    l = 0, r = (sz - 1) / 2 - 1;
    while (l < r) {
    	if (s[l] != s[r]) {
    		cout << "No\n";
    		return 0;
    	}
    	l++;
    	r--;
    }
    l = (sz + 3) / 2 - 1, r = sz - 1;
    while (l < r) {
    	if (s[l] != s[r]) {
    		cout << "No\n";
    		return 0;
    	}
    	l++;
    	r--;
    }
    cout << "Yes\n";


}

Measured memory_bytes: 256