akhauriyash/Code-Regression huggingface dataset:
import collections
from copy import deepcopy

n,a,b,c=map(int,input().split())
arr=[int(input()) for _ in range(n)]
l=collections.deque()
l.append([[],[],[]])
cnt=0

while 1:
  if cnt==n:
    break
  base=l.popleft()
  if len(base[0])==0 and len(base[1])==0 and len(base[2])==0:
    l.append([[arr[cnt]],[],[]])
    l.append([[],[arr[cnt]],[]])
    l.append([[],[],[arr[cnt]]])
    l.append([[],[],[]])
    cnt+=1
  else:
    tmp1=deepcopy(base)
    tmp1[0].append(arr[cnt])
    l.append(tmp1)
    tmp2=deepcopy(base)
    tmp2[1].append(arr[cnt])
    l.append(tmp2)
    tmp3=deepcopy(base)
    tmp3[2].append(arr[cnt])
    l.append(tmp3)
    tmp4=deepcopy(base)
    l.append(tmp4)

mincost=10**9
for bl in l:
  if len(bl[0])==0 or len(bl[1])==0 or len(bl[2])==0:
    continue
  else:
    tmpcost=abs(sum(bl[0])-a)+abs(sum(bl[1])-b)+abs(sum(bl[2])-c)+10*(len(bl[0])-1+len(bl[1])-1+len(bl[2])-1)
    if mincost>tmpcost:
      mincost=tmpcost
print(mincost)


Measured memory_bytes: 32244
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define int long long
#define For(i,x,y) for(int i = x; i <= y; ++i)
#define FOR For
#define rev_For(i,x,y) for(int i = x; i >= y; --i)
#define REV_FOR rev_For
#define ll long long
#define Size(v) ((int)v.size())
#define _section "\n--------------------\n"
#define fi first
#define se second
#define pb push_back
using namespace std;
// using namespace __gnu_pbds;


const int nax = 2e5 + 5;
int n, a[nax];
vector<int> dp[nax];
const int INF = 1e18;

int calc(int i, int j) {
	if (i <= 0) return 0;
	if (i > n / 2) return 0;

	if (2 * (i - 1) - 1 > j - 2) {
		return -INF;
	}

	if (dp[i][j - (2 * (i - 1))] != -1) return dp[i][j - (2 * (i - 1))];

	int ret = -INF;
	for (int k = 2 * (i - 1) - 1; k <= j - 2; ++k) {
		ret = max(ret, calc(i - 1, k));
	}

	dp[i][j - (2 * (i - 1))] = ret + a[j];

	return dp[i][j - (2 * (i - 1))];
}

void input() {
	cin >> n;
	FOR (i, 1, n) cin >> a[i];
	FOR (i, 1, nax - 1) {
		dp[i].assign(4, -1);
	}
}

void solve() {
	int ans = -INF;
	for (int i = 1; i <= n; ++i) {
		ans = max(ans, calc(n / 2, i));
	}

	cout << ans;
}

signed main() {
#ifdef _DEBUG
	// freopen("INPUT.inp", "r", stdin);
	//freopen("OUTPUT.out", "w", stdout);
	clock_t start, end;
	start = clock();
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
//------------------------------------------------------------------------------------
//----------------------------------MAIN PROGRAM--------------------------------------
	int t = 1;
	while (t--) {
		input();
		solve();
	}
//--------------------------------------END-------------------------------------------
//------------------------------------------------------------------------------------
#ifdef _DEBUG
	end = clock();
	cerr << "\n----------\nTime Elapsed: " << fixed << double(end - start) / double(CLOCKS_PER_SEC) << setprecision(6) << '\n';
#endif
	return 0;
}

Measured memory_bytes: 27084
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second 

#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)


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

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);      
    #endif
    fastio;

    ll t; t=1;
    while(t--){
        ll n; cin>>n;
        ll a[n-1];
        rep(i,n-1){
            cin>>a[i];
        }
        ll ans[n]={0};
        rep(i,n-1){
            ans[a[i]-1]++;
        }
        rep(i,n){
            cout<<ans[i]<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 6780
N = int(input())
dict = {}
max_count = 0
max_count_words = []

for _ in range(N):
  s = str(input())

  if(s in dict):
    dict[s] += 1
  else:
    dict[s] = 1

for key, value in dict.items():
  if(value > max_count):
    max_count = value
    max_count_words = [key]
  elif(value == max_count):
    max_count_words.append(key)

list.sort(max_count_words)
print("\n".join(map(str, max_count_words)))

Measured memory_bytes: 34140
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <string>
#include <tuple>
using namespace std;

int main(void){
  int n;
  cin >> n;
  
  vector<int> dp(45);
  
  dp[0] = 1;
  dp[1] = 1;
  
  for(int i=2;i<=n;i++){
    dp[i] = dp[i-1] + dp[i-2];
  }

  cout << dp[n] << endl;
}



Measured memory_bytes: 3132
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();
    if a * b % 2 != 0 {
        println!("Odd");
    } else {
        println!("Even");
    }
}


Measured memory_bytes: 4352
/*
// A - Traveling Budget
#include <iostream>
using namespace std;

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  cout<<min(A,B)+min(C,D)<<endl;
  return 0;
}
 */
// B - Chocolate
#include <iostream>
using namespace std;

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int N,D,X;
  cin>>N>>D>>X;
  int A[N];
  for (int i=0; i<N; i++) {
    cin>>A[i];
  }
  int ans=X;
  for (int i=0; i<N; i++) {
    int k=0;
    while (k*A[i]+1<=D) {
      ans++;
      k++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<climits>
#define ll long long int
using namespace std;

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	vector<int> a;
	vector<int> b;
	vector<int> c(2 * n + 1, 0);
	int x;
	for (int i = 1; i <= n; i++)
	{
		cin >> x;
		if (x <= n)
		{
			a.push_back(x + i);
			c[x + i]++;
			b.push_back(i - x);
		}
	}
	ll count = 0;
	for (auto e : b)
	{
		if (e <= 2 * n && e > 0)
			count += c[e];
	}
	cout << count;


	return 0;

}

Measured memory_bytes: 6660
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int a[] = {380, 550, 850, 0.8*380*5, 0.85*550*4, 0.88*850*3};
  int w[] = {200, 300, 500, 200*5, 300*4, 500*3};

  int dp[7][5001] = {1<<30};
  REP(i,7)
    REP(j,5001) {
    dp[i][j] = 9999;
    if (j==0) dp[i][j]=0;
  }
    
  REP(i,6) {
    for (int j=0; j<=5000; j+=100) {
      if (j<w[i])
        dp[i+1][j] = dp[i][j];
      else
        dp[i+1][j] = min(dp[i][j], dp[i+1][j-w[i]] + a[i]);
//      printf("%5d", dp[i+1][j]);
    }
    //  cout << endl;
    
  }
  
  int n;
  while (cin >> n, n) {
    cout << dp[6][n] << endl;
  }
  
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
using namespace std;
//??????????????¢????????£?????????????????????
int main(){
	int nn[5001] = { 0 }, temp, n, max = -110000;
	while (cin >> n && (n != 0)){
		for (int i = 0; i < n; i++){
			cin >> nn[i];
		}
		temp = nn[0];
		for (int i = 1; i < n; i++){
			temp += nn[i];
			if (temp < nn[i]) temp = nn[i];
			if (max < temp) max = temp;
		}if (max < nn[0]) cout << nn[0] << endl;
		else cout << max << endl;
		max = -110000;
	}
	return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define inf 1001001001001000
#define mod 1000000007
using namespace std;


ll mpow(ll a,ll b){
    if(b == 0) return 1;
    if(b == 1) return a%mod;
    if(b%2 == 0) return mpow((a*a)%mod,b/2)%mod;
    else return (a%mod)*mpow((a*a)%mod,(b-1)/2)%mod;
}


ll comb(ll a,ll b){
    if(a<b) return 0;
    if(a == b) return 1;
    ll ue = 1,sita = 1;
    rep(i,b){
        sita *= (i+1);
        ue *= a--;
    }
    return ue/sita;
}

//necessary mpow
#define N 1000000
ll fact[N+1],ifact[N+1];
void init_comb(){
    fact[0] = 1;
    ifact[0] = 1;
    rep1(i,N+1){
        fact[i] = (fact[i-1]*i)%mod;
    }
    ifact[N] = mpow(fact[N],mod-2);
    for(ll i=1000000;i>0;--i) ifact[i-1] = (ifact[i]*i)%mod;
}
ll mcomb(ll a,ll b){
    if(a<b) return 0;
    if(a==b) return 1;
    return (((fact[a]*ifact[b])%mod)*ifact[a-b])%mod;
}

int main(void){
    // Your code here!
    ll n,k;
    cin>>n>>k;
    k = min(k,n-1);
    ll ans = 0;
    init_comb();
    rep(i,k+1){
        ans = (ans+(mcomb(n,i)*mcomb(n-1,i))%mod)%mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 15872
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; string s; cin >> n >> s;
	stack<char> ans;
	fore(e, s) {
		if(ans.empty() or ans.top() != e) ans.push(e);
	}
	println(ans.size());
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    static int longestCommonSubsequence(char[] X, char[] Y) {
        int m = X.length;
        int n = Y.length;
        int[][] c = new int[m + 1][n + 1];
        for (int i = 0; i < m; i++) {
            c[i][0] = 0;
        }
        for (int i = 0; i < n; i++) {
            c[0][i] = 0;
        }

        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= n; j++) {
                if (X[i - 1] == Y[j - 1])
                    c[i][j] = c[i - 1][j - 1] + 1;
                else if (c[i - 1][j] >= c[i][j - 1])
                    c[i][j] = c[i - 1][j];
                else
                    c[i][j] = c[i][j - 1];
            }
        }
        return c[m][n];
    }

    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
             PrintWriter out = new PrintWriter(System.out)) {
            int n = Integer.parseInt(in.readLine());
            for (int i = 0; i < n; i++) {
                char[] X = in.readLine().toCharArray();
                char[] Y = in.readLine().toCharArray();
                out.println(longestCommonSubsequence(X, Y));
            }
            out.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}



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

int main(){
    int n,h;cin>>h>>n;
    for(int i=0;i<n;i++){
        int a;cin>>a;
        h-=a;
    }
    if(h>0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class Program
{

    public void Proc()
    {
        int inputCount = int.Parse(Reader.ReadLine());
        int[] pos = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).Distinct().OrderBy(a => a).ToArray();
        int ans = 0;
		ans = pos.Last() - pos.First();
        Console.WriteLine(ans);
    
    }

    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"


8
3 1 4 1 5 9 2 6

";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}


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

int main(){
    int k;
    cin >> k;
    int n = k;
    for(int i = 1; i <= n; i++){
        if(360 * i % k == 0){
            cout << 360 * i / k << endl;
            break;
        }
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const double PI = acos(-1);
const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    double w,h,x,y;
    cin >> w >> h >> x >> y;
    double mw = w / 2;
    double mh = h / 2;
    if(mw == x && mh == y){
        cout << w * h / 2 << " " << 1 << endl;
    } else {
        cout << w * h / 2 << " " << 0 << endl;
    }




}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

template<typename W>
struct N003 {
   typedef std::vector<long> LI;
   typedef std::vector<W>    LW;
   long n, e;
   LI ss, ds;
   LW ws;
   std::vector<LI> iss;
   N003(long n_, const LI& ss_, const LI& ds_, const LW& ws_)
      : n(n_), e(ss_.size()), ss(ss_), ds(ds_), ws(ws_) {
      iss.resize(n+1);
      for(long i = 0; i < e; ++i) {
         iss[ss[i]].push_back(i);
      }
   }
};

template<typename W>
struct N004 {
   std::vector<long> xs;
   N004(const N003<W>& g, long s, W inf) : xs(g.n+1, inf) {
      std::priority_queue<std::pair<W, long>> q;
      q.push(std::make_pair(0, s));
      while( not q.empty() ) {
         W d2; long i;
         std::tie(d2, i) = q.top(); q.pop();
         W d = -d2;
         if( d < xs[i] ) {
            xs[i] = d;
            for(long k : g.iss[i]) {
               W nd = d + g.ws[k];
               if( nd < xs[g.ds[k]] ) {
                  q.push(std::make_pair(-nd, g.ds[k]));
               }
            }
         }
      }
   }
};

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      typedef std::vector<long> LI;
      long v, e, r;
      scan(v, e, r);
      LI ss(e+1), ds(e+1);
      LI ws(e+1);
      for(long i = 0; i < e; ++i) {
         scan(ss[i], ds[i], ws[i]);
      }
      N003<long> g(v, ss, ds, ws);
      N004<long> dijkstra(g, r, (1LL << 60));
      for(long i = 0; i < v; ++i) {
         long res = dijkstra.xs[i];
         if( res == (1LL << 60) ) {
            puts("INF");
         }
         else {
            printf("%ld\n", res);
         }
      }
   }
};

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
}

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

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


Measured memory_bytes: 3096
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

const int N=1000005;
const int mod=924844033;

struct E{
	int to,next;
}mem[N];
int n,num,x,y,l,il;
int head[N],b[N],a[N],f[N],sz[N],g[N],fac[N],inv[N];

void add(int x,int y){
	num++;
	mem[num].to=y; mem[num].next=head[x];
	head[x]=num;
}

int quickpow(int x,int y){
	int s=1;
	for (;y;y>>=1,x=1ll*x*x%mod)
		if (y&1) s=1ll*s*x%mod;
	return s;
}

void init(){
	int i;
	fac[0]=inv[0]=1;
	for (i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[n]=quickpow(fac[n],mod-2);
	for (i=n-1;i;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
}

void dfs(int k,int pre){
	int j,u;
	sz[k]=1;
	for (j=head[k];j;j=mem[j].next){
		u=mem[j].to;
		if (u==pre) continue;
		dfs(u,k);
		sz[k]+=sz[u]; g[sz[u]]--;
	}
	g[n-sz[k]]--;
}

void ntt(int z[],int p){
	int w,wd,x,y,i,j,k,s;
	for (i=0;i<l;i++){
		s=0;
		for (j=1,k=l>>1;j<l;j<<=1,k>>=1) if (i&j) s+=k;
		if (s>i) swap(z[s],z[i]);
	}
	for (i=1;i<l;i<<=1){
		wd=quickpow(5,(mod-1)/(i<<1));
		if (p==-1) wd=quickpow(wd,mod-2);
		for (j=0;j<l;j+=(i<<1)){
			w=1;
			for (k=0;k<i;k++){
				x=z[j+k]; y=1ll*z[j+k+i]*w%mod;
				z[j+k]=(x+y)%mod;
				z[j+k+i]=(x-y+mod)%mod;
				w=1ll*w*wd%mod;
			}
		}
	}
}

int main(){
	int i;
	scanf("%d",&n);
	for (i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	init();
	dfs(1,0);
	for (l=1;l<n+n+2;l<<=1);
	g[n]=n;
	for (i=0;i<=n;i++) a[i]=1ll*(g[n-i]+mod)*fac[n-i]%mod;
	for (i=0;i<=n;i++) b[i]=inv[i];
	ntt(a,1);
	ntt(b,1);
	for (i=0;i<l;i++) f[i]=1ll*a[i]*b[i]%mod;
	ntt(f,-1);
	il=quickpow(l,mod-2);
	for (i=0;i<l;i++) f[i]=(1ll*f[i]*il%mod+mod)%mod;
	for (i=1;i<=n;i++) printf("%d\n",1ll*inv[i]*f[n-i]%mod);
	return 0;
}

Measured memory_bytes: 41600
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.rbegin(),a.rend())
#define lb(a,b) lower_bound(a.begin(),a.end(),b)
#define ub(a,b) upper_bound(a.begin(),a.end(),b)
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double
#define sqrt sqrtl
#define cbrt cbrtl
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<float,int> fi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<fi> vfi;
typedef vector<vi> vvi;
typedef vector<vf> vvf;
typedef vector<vii> vvii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef priority_queue<fi> pqfi;
typedef priority_queue <int, vector<int>, greater<int> > rpqi; 
typedef priority_queue <ii, vector<ii>, greater<ii> > rpqii; 
typedef priority_queue <fi, vector<fi>, greater<fi> > rpqfi; 



int32_t main()
{
	IOS
	int n;cin>>n;
	vector<int>A(n+1);
	vector<bool>B(n+1);
	map<int,int>M;
	int diff=0;
	for(int i=1;i<=n;i++)
	{
		cin>>A[i];M[A[i]]=i;
		if(A[i]!=i)diff++;
	}
	if(diff==0 || diff== 2)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;

}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
 
 
int main(){
  string S;
  cin >> S;
  ll ans = 700;
  rep(i,S.size())
    if(S.at(i) =='o'){
      ans = ans + 100;
    }
      cout << ans <<endl;
  }
  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n;
    int a[103];
    int ans = 0;

    Scd(n);
    Rep(i,n){
        Scd(a[i]);
        ans += a[i];
    }
    sort(a,a+n);

    if( ans % 10 == 0 )
        Rep(i,n+1){
            if( n == i ) {
                ans = 0;
                break;
            }
            if( a[i] % 10 ){
                ans -= a[i];
                break;
            }
        }

    printf ("%d\n", ans);


    return 0;
}



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

long long const MOD = 1e9+7;

long long mod_pow(long long m, long long n, long long MOD) {
    long long res = 1;
    if (n > 0) {
        res *= mod_pow(m, n / 2, MOD);
        if (n % 2 == 0) (res *= res) %= MOD;
        else (((res *= res) %= MOD) *= m) %= MOD;
    }
    return res;
}

int main() {
    long long m, n;
    cin >> m >> n;

    cout << mod_pow(m, n, MOD) << endl;
    return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int dt[2010][2010];


int max(int a,int b){
	return (a>b)?a:b;
}

int min(int a,int b){
	return (a<b)?a:b;
}

int main(){
	int n,k;
	cin>>n>>k;
	long long x[n],y[n];
	char c;
	rep(i,n){
		cin>>x[i]>>y[i]>>c;
		if(c=='W')x[i]+=k;
		x[i]%=2*k;y[i]%=2*k;
	}
	int ans=0;
	rep(i,2*k+1)fill(dt[i],dt[i]+2*k+10,0);
	rep(i,n){
		dt[max(0,y[i]-k+1)][max(0,x[i]-k+1)]++;
		dt[max(0,y[i]-k+1)][x[i]+1]--;
		dt[y[i]+1][max(0,x[i]-k+1)]--;
		dt[y[i]+1][x[i]+1]++;
		if(y[i]-k+1<0 || x[i]-k+1<0){
			int resx=k-1-x[i],resy=k-1-y[i];
			if(resx>0 && resy>0){
				dt[2*k-resy][2*k-resx]++;
				dt[2*k-resy][2*k]--;
				dt[2*k][2*k-resx]--;
				dt[2*k][2*k]++;
			}
			if(resx>0){
				dt[max(0,y[i]-k+1)][2*k-resx]++;
				dt[max(0,y[i]-k+1)][2*k]--;
				dt[y[i]+1][2*k-resx]--;
				dt[2*k][2*k]++;
			}
			if(resy>0){
				dt[2*k-resy][max(0,x[i]-k+1)]++;
				dt[2*k][max(0,x[i]-k+1)]--;
				dt[2*k-resy][x[i]+1]--;
				dt[2*k][2*k]++;
			}
		}
		dt[y[i]+1][x[i]+1]++;
		dt[min(2*k,y[i]+1+k)][x[i]+1]--;
		dt[y[i]+1][min(2*k,x[i]+1+k)]--;
		dt[min(2*k,y[i]+1+k)][min(2*k,x[i]+1+k)]++;
		if(y[i]+1+k>2*k || x[i]+1+k>2*k){
			int resx=x[i]+k+1-2*k,resy=y[i]+k+1-2*k;
			if(resx>0&&resy>0){
				dt[0][0]++;
				dt[0][resx]--;
				dt[resy][0]--;
				dt[resy][resx]++;
			}
			if(resx>0){
				dt[y[i]+1][0]++;
				dt[y[i]+1][resx]--;
				dt[min(2*k,y[i]+1+k)][0]--;
				dt[min(2*k,y[i]+1+k)][resx]++;
			}
			if(resy>0){
				dt[0][x[i]+1]++;
				dt[resy][x[i]+1]--;
				dt[0][min(2*k,x[i]+1+k)]--;
				dt[resy][min(2*k,x[i]+1+k)]++;
			}
		}
	}
	rep(i,2*k){
		rep(j,2*k){
			dt[i][j+1]+=dt[i][j];
		}
	}
	rep(i,2*k){
		rep(j,2*k){
			dt[i+1][j]+=dt[i][j];
		}
	}
	rep(i,2*k){
		rep(j,2*k){
			ans=max(ans,dt[i][j]);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 17536
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <queue>
#include <vector>
#include <set>


using namespace std;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

template<class T> inline bool chmin(T& a, T b) {
  //aの方が大きければbに値を更新、そうでなければ何もしない
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
bool compare_a_big(pair<int,int> l,pair<int,int> r){
  //firstが大きい方からソート、firstが同じならbが小さい方から
  if(l.first != r.first){
    return l.first>r.first;
  }
  else{
    return l.second < r.second;
  }
}
bool compare_a_b_big(pair<int,int> l,pair<int,int> r){
  //firstが大きい方からソート、firstが同じならbが大きい方から
  if(l.first != r.first){
    return l.first>r.first;
  }
  else{
    return l.second > r.second;
  }
}
bool compare_b_small(pair<int,int> l,pair<int,int> r){
  //secondが小さい方からソート、firstが同じならfirstが小さい方から
  if(l.second != r.second){
    return l.second<r.second;
  }
  else{
    return l.first < r.first;
  }
}
const int INF = 1e9;
const int M = 1000000007;


typedef long long int ll;
vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算、a,b<=300000でないと使えない
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

typedef long long int ll;


int main(){

  int n;
  cin >> n;
  int a[n];
  int i;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  for(i=0;i<n-1;i++){
    if(a[i] == a[i+1]){
      printf("NO\n");
      break;
    }
    if(i==n-2){
      printf("YES\n");
    }
  }


}


Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (int)n; i++)
using namespace std;

void reverse(string &s) {
	int l = 0, r = s.length() - 1;
	while (l < r) {
		swap(s[l], s[r]);
		l++;
		r--;
	}
}

int n, m;
string w[50000], wr[50000];
string s;

int solve0(string s) {
	int id = lower_bound(w, w + n, s) - w;
	return id < n && w[id] == s;
}

int solve1(string s) {
	if (s.length() == 1) return n;
	string t, u; int i;
	rep(i, s.length() - 1) t += s[i];
	u = t; u[u.length() - 1] = t[t.length() - 1] + 1;
	
	int l = lower_bound(w, w + n, t) - w;
	int r = lower_bound(w, w + n, u) - w;
	return r - l;
}

int solve2(string s) {
	reverse(s);
	string t, u; int i;
	rep(i, s.length() - 1) t += s[i];
	u = t; u[u.length() - 1] = t[t.length() - 1] + 1;
	
	int l = lower_bound(wr, wr + n, t) - wr;
	int r = lower_bound(wr, wr + n, u) - wr;
	return r - l;
}

int main() {
	int i, j;
	
	cin >> n >> m;
	rep(i, n) { cin >> w[i]; string tmp = w[i]; reverse(tmp); wr[i] = tmp; }
	sort(w, w + n);
	sort(wr, wr + n);
	rep(i, m) {
		cin >> s;
		rep(j, s.length()) if (s[j] == '?') break;
		int pos = j;
		int ans = 0;
		if (pos < s.length()) {
			rep(j, 26) {
				s[pos] = j + 'a';
				if (s[s.length() - 1] == '*') ans += solve1(s);
				else if (s[0] == '*') ans += solve2(s);
				else ans += solve0(s);
			}
		}
		else {
			if (s[s.length() - 1] == '*') ans += solve1(s);
			else if (s[0] == '*') ans += solve2(s);
			else ans += solve0(s);
		}
		cout << ans << endl;
	}
	return 0;
}


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

long long int knapsacke(vector<long long int>val,vector<long long int>wt,long long int W,long long int n)
{
long long 	int i, w; 
   long long int K[n+1][W+1]; 
  
   for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
  
   return K[n][W]; 
}

int main()
{
	long long int w,n;
	
	cin>>n>>w;
	
	vector<long long int>v(n),u(v);
	
	for(long long int i=0;i<n;i++)
	{
		cin>>v[i]>>u[i];
	}
	
	cout<<knapsacke(u,v,w,n);
}

Measured memory_bytes: 79104
N = gets.to_i
Se = []
So = []
(N + 1).times{|i| So << []; Se << []}
(N - 1).times{|i|
  u, v, w = gets.chomp.split(" ").map(&:to_i);
  w.even? ? (Se[u] << v; Se[v] << u) : (So[u] << v; So[v] << u)
}

vtx = Array.new(N + 1){ -1 } 
vtx[1] = 1
q = [1]
while q.size > 0
  v = q.shift
  Se[v].select{|i| -1 == vtx[i] }.each{|j| vtx[j] =   vtx[v]; q.push(j)}
  So[v].select{|i| -1 == vtx[i] }.each{|j| vtx[j] = 1-vtx[v]; q.push(j)}
end

(1..N).each{|i|
  puts vtx[i]
}

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

int main() {
	string s;
	long long K;
	cin >> s >> K;
	
	long long l=s.size();
	
	for(long long i=0; i<l; i++){
		long long moji=s[i];
		if(moji+K>=123 && moji>97){
			s[i]=97;
			K = K - (123-moji);
		}
	}
	s[l-1]+=(K%26);
	if(s[l-1]>122){s[l-1] = s[l-1]-26;}
	
	cout << s <<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

int main() {
  int n;
  cin >> n;
  vector<int> s(1 << n);
  rep(i, 1 << n) cin >> s[i];

  sort(s.begin(), s.end());
  multiset<int> t;
  rep(i, (1 << n) - 1) t.insert(s[i]);
  vector<int> res;
  res.push_back(s[(1 << n) - 1]);
  rep(i, n) {
    vector<int> nxt = res;
    rep(j, res.size()) {
      auto it = t.lower_bound(res[j]);
      if (it == t.begin()) {
        cout << "No" << endl;
        return 0;
      }
      it--;
      nxt.push_back(*it);
      t.erase(it);
    }
    sort(nxt.begin(), nxt.end(), greater<int>());
    swap(res, nxt);
  }
  cout << "Yes" << endl;
  
  


  
  return 0;
}

Measured memory_bytes: 13568
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define LL long long
#define RG register
#define R RG int
using namespace std;
const LL N=2009,M=N*N,YL=1e9+7;
int f[N][N],fac[M],inv[M];
inline int fm(RG LL b){
    RG LL a=1;
    for(R k=YL-2;k;k>>=1,b=b*b%YL)
        if(k&1)a=a*b%YL;
    return a;
}
inline int C(R n,R m){
    if(n<0||m<0||n<m)return 0;
    return(LL)fac[n]*inv[m]%YL*inv[n-m]%YL;
}
int main(){
    R n,k,nk;
    scanf("%d%d",&n,&k);nk=n*k;
    if(k==1)return puts("1"),0;
    for(R i=fac[0]=1;i<=nk;++i)
        fac[i]=fac[i-1]*(LL)i%YL;
    inv[nk]=fm(fac[nk]);
    for(R i=nk;i;--i)
        inv[i-1]=inv[i]*(LL)i%YL;
    f[0][0]=1;
    for(R i=1;i<=n;++i)
        for(R j=f[i][0]=1;j<=i;++j)
            f[i][j]=(f[i-1][j]+(LL)f[i][j-1]*(n-j+1)%YL*C(n-i+(n-j+1)*(k-1)-1,k-2))%YL;
    printf("%d\n",f[n][n]);
    return 0;
}

Measured memory_bytes: 47488
/***
 *      __  __            _    _       _
 *     |  \/  |          | |  | |     | |
 *     | \  / |_ __      | |  | |_ __ | | ___ __   _____      ___ __
 *     | |\/| | '__|     | |  | | '_ \| |/ / '_ \ / _ \ \ /\ / / '_ \
 *     | |  | | |     _  | |__| | | | |   <| | | | (_) \ V  V /| | | |
 *     |_|  |_|_|    (_)  \____/|_| |_|_|\_\_| |_|\___/ \_/\_/ |_| |_|
 *
 *
***/
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
/*---------------for_stuff-------------------*/
#define f(i,a,b) for (int i=a;i<=b;i++)
#define f_(i,a,b) for (int i=a;i>=b;i--)
/*---------------pair_stuff------------------*/
#define MP make_pair
#define ii pair<int,int>
#define Iii pair<int,ii>
#define ill pair<int,ll>
#define lli pair<ll,int>
#define iiI pair<ii,int>
#define llll pair<ll,ll>
#define fi first
#define se second
/*--------------vector_stuff-----------------*/
#define pb push_back
#define ppb pop_back
/*--------------const_stuff-----------------*/
const ll mod=1000000007;
/*--------------map_stuff--------------------*/
// why do you think I should write something in this part? :v

int a,b,c;
int main() {
//	freopen("","r",stdin);
//	freopen("","w",stdout);
	cin>>a>>b>>c;
	cout<<max(c-(a-b),0);
	return 0;
}

Measured memory_bytes: 256
n=int(input())
p=[int(x) for x in input().split()]
cnt=0
for i in range(n):
  if i+1==p[i]:
    if i!=n-1:
      p[i],p[i+1]=p[i+1],p[i]
    else:
      p[i],p[i-1]=p[i-1],p[i]
    cnt+=1
print(cnt)
  

Measured memory_bytes: 13880
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long n = Long.parseLong(sc.next());

		// nが1だったら答えは0で確定
		if (n == 1) {
			System.out.println(0);
			return;
		}

		// nを素因数分解
		HashMap<Long, Long> map = primeFactorize(n);

		// 素因数分解の結果表示
		for (long key : map.keySet()) {
			// System.out.println(key + "^" + map.get(key));
		}

		// 結果を求めて出力
		int result = 0;
		for (long key : map.keySet()) {
			long z = map.get(key);
			for (int j = 1; j < 10000; j++) {
				if (j <= z) {
					z -= j;
					result++;
				} else {
					break;
				}
			}
		}

		System.out.println(result);

	}

	// nを素因数分解して、結果用mapに素因数と指数のペアを入れて返す関数。
	public static HashMap<Long, Long> primeFactorize(long n) {

		long input = n;
		HashMap<Long, Long> map = new HashMap<Long, Long>();

		// nが0以下だったらnullを返す
		if (n <= 0) {
			return null;
		}

		// nが1だったら素因数分解結果は1^1
		if (n == 1) {
			map.put(1L, 1L);
			return map;
		}

		// 素因数分解していく。計算量はO(√n)
		for (long i = 2; i * i <= input; i++) {
			long j = 0;
			while (true) {
				if (n % i == 0) {
					j++;
					map.put(i, j);
					n /= i;
				} else {
					break;
				}
			}
		}

		// 最後に残った数も忘れずに入れる
		if (n != 1) {
			map.put(n, 1L);
		}

		return map;
	}
}

Measured memory_bytes: 36640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
int main() {
    int N;
    cin>>N;
    int odd=N/2;
    double ans=1.0-1.0*odd/N;

    printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    if (s.equals("ABC")) {
      System.out.println("ARC");
    } else {
      System.out.println("ABC");
    }
    sc.close();
  }
}

Measured memory_bytes: 35640
// C++ implementation of the approach 
#include <bits/stdc++.h> 
using namespace std; 

// Function that returns true if n 
// is prime else returns false 
bool isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) return false; 
	if (n <= 3) return true; 
	
	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n%2 == 0 || n%3 == 0) return false; 
	
	for (int i=5; i*i<=n; i=i+6) 
		if (n%i == 0 || n%(i+2) == 0) 
		return false; 
	
	return true; 
} 

// Function to return the smallest 
// prime number greater than N 
int nextPrime(int N) 
{ 

	// Base case 
	if (N <= 1) 
		return 2; 

	int prime = N-1; 
	bool found = false; 

	// Loop continuously until isPrime returns 
	// true for a number greater than n 
	while (!found) { 
		prime++; 

		if (isPrime(prime)) 
			found = true; 
	} 

	return prime; 
} 

// Driver code 
int main() 
{ 
	int N;
	cin>>N;

	cout << nextPrime(N); 

	return 0; 
} 


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

int main(){
	int a, b;
	cin >> a >> b;
	if ((int64_t)a * b < 0)puts("Zero");
	else {
		if ((a < 0 && b < 0)&&(b-a)%2==0) {
			puts("Negative");
		}
		else {
			puts("Positive");
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
	fastio
	LL n, i, ans=0;
	cin>>n;
	LL a[n];
	for(i=0; i<n-1; i++)
		cin>>a[i];
	if(n==2){
		cout<<2*a[0]<<endl;
		return 0;
	}
	ans+=a[0];
	for(i=0; i<n-2; i++){
		if(a[i+1]>a[i])
			ans+=a[i];
		else
			ans+=a[i+1];
	}
	ans+=a[n-2];
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

long long m, ps[100005];
int n, a[100005];

long long solve(int mn) {
	int p = n - 1;
	long long cnt = 0;
	
	for (int i = 0; i < n; i++) {
		while (p >= 0 && a[i] + a[p] < mn) p--;
		cnt += p + 1;
	}
	return cnt;
}

long long calc(int mn) {
	int p = n - 1;
	long long cnt = 0;
	long long res = 0;
	
	for (int i = 0; i < n; i++) {
		while (p >= 0 && a[i] + a[p] <= mn) p--;
		if (p >= 0) {
			res += ps[p] + 1LL * (p + 1) * a[i];
		}
		cnt += p + 1;
	}
	res += 1LL * (m - cnt) * mn;
	return res;
}

int main() {
	scanf("%d%lld", &n, &m);
	
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	
	sort(a, a + n, greater<int>());
	for (int i = 0; i < n; i++) {
		ps[i] = a[i];
		if (i - 1 >= 0) ps[i] += ps[i - 1];
	}
	
	int lb = 0;
	int ub = 2e5 + 1;
	
	while (ub - lb > 1) {
		int mid = (lb + ub) / 2;
		if (solve(mid) >= m) lb = mid;
		else ub = mid;
	}
	
	printf("%lld\n", calc(lb));
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    int N;
    cin >> N;
    string S;
    cin >> S;

    int x = 0;
    int mx = 0;

    for (int i = 0; i < N; i++) {
        x += (S[i] == 'I') ? 1 : -1;
        mx = max(mx, x);
    }

    cout << mx << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
using namespace std;

signed main(){
    char a;
    cin>>a;
    a++;
    cout<<a<<endl;
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <numeric>
#include <complex>
using namespace std;

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

int main() {
    int N, K;
    cin >> N >> K;
    long long sum = K;
    for (int i = 1; i < N; i++) {
        sum *= K-1;
    }
    cout << sum << endl;
}

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

using namespace std;

int main()
{
    char c;
    scanf("%c", &c);
    if(c == 'A')
        printf("T\n");
    else if(c == 'T')
        printf("A\n");
    else if(c == 'G')
        printf("C\n");
    else if(c == 'C')
        printf("G\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007, INF = 1111111111;
const double EPS = 1e-9;


int main() {

	cin.tie(0);

	int N, K;
	cin >> N >> K;

	if ((N + 1) / 2 >= K) cout << "YES" << "\n";
	else cout << "NO" << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

typedef long long int ll;



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

    ll sol = 0;
    ll pa, pb, pab;
    ll x, y;
    ll mn, mx, d, mp;
    cin >> pa >> pb >> pab >> x >> y;
    if(2*pab >= pa+pb) {
        sol = x*pa+y*pb;
        cout << sol << endl;
    }
    else {
        mn = min(pa, pb);
        mx = max(pa, pb);
        sol += 2*pab*min(x, y);
        d = max(x,y)-min(x,y);
        if(max(x,y) == x) {
            mp = pa;
        }
        else {
            mp = pb;
        }
        sol += d*min(2*pab, mp);
        cout << sol << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cctype>
using namespace std;

namespace zyt
{
	template<typename T>
	inline bool read(T &x)
	{
		char c;
		bool f = false;
		x = 0;
		do
			c = getchar();
		while (c != EOF && c != '-' && !isdigit(c));
		if (c == EOF)
			return false;
		if (c == '-')
			f = true, c = getchar();
		do
			x = x * 10 + c - '0', c = getchar();
		while (isdigit(c));
		if (f)
			x = -x;
		return true;
	}
	template<typename T>
	inline void write(T x)
	{
		static char buf[20];
		char *pos = buf;
		if (x < 0)
			putchar('-'), x = -x;
		do
			*pos++ = x % 10 + '0';
		while (x /= 10);
		while (pos > buf)
			putchar(*--pos);
	}
	const int N = 1e5 + 10;
	int n, a[N], b[N], fa[N], ida[N], idb[N];
	int f(const int x)
	{
		return x == fa[x] ? x : fa[x] = f(fa[x]);
	}
	bool cmpa(const int i, const int j)
	{
		return a[i] < a[j];
	}
	bool cmpb(const int i, const int j)
	{
		return b[i] < b[j];
	}
	int work()
	{
		read(n);
		for (int i = 1; i <= n; i++)
			read(a[i]), ida[i] = i;
		for (int i = 1; i <= n; i++)
			read(b[i]), idb[i] = i;
		sort(ida + 1, ida + n + 1, cmpa);
		sort(idb + 1, idb + n + 1, cmpb);
		for (int i = 1; i <= n; i++)
		{
			fa[i] = i;
			if (a[ida[i]] > b[idb[i]])
			{
				puts("No");
				return 0;
			}
		}
		for (int i = 1; i <= n; i++)
			if (i && a[ida[i]] <= b[idb[i - 1]])
			{
				puts("Yes");
				return 0;
			}
		int cnt = 0;
		for (int i = 1; i <= n; i++)
		{
			int x = f(ida[i]), y = f(idb[i]);
			if (x == y)
				++cnt;
			else
				fa[x] = y;
		}
		if (cnt > 1)
			puts("Yes");
		else
			puts("No");
		return 0;
	}
}
int main()
{
	return zyt::work();
}

Measured memory_bytes: 3712
N = int(input())
ab = [list(map(int,input().split()))+[False] for _ in range(N)]
cd = [list(map(int,input().split()))+[False] for _ in range(N)]
ab.sort(key=lambda x: x[0],reverse=True)
ab.sort(key=lambda x: x[1],reverse=True)
cd.sort(key=lambda x: x[1])
cd.sort(key=lambda x: x[0])

ans = 0
for i in range(N):
    a = ab[i][0]
    b = ab[i][1]
    for j in range(N):
        if cd[j][2] == True:
            continue 
        c = cd[j][0]
        d = cd[j][1]
        if a<c and b<d:
            ans += 1
            cd[j][2] = True
            break
print(ans)

Measured memory_bytes: 3064
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}


fn main(){
    let helix = read_as_string();
    
    let mut ans = 0;
    for i in 0..helix.len()+1{
        for j in 1..helix.len()-i+1{
            if helix.chars().skip(i).take(j).
               all(|c| c == 'A' || c == 'C' ||c == 'G' || c == 'T'){
                ans = cmp::max(j, ans);
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n;
ll s;
int main() {
    cin>>n;
    for(int i=1;i<=n;i++) s+=gi();
    puts((s&1)?"NO":"YES");
    return 0;
}


Measured memory_bytes: 256