akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  ll w0;
  ll n, W;
  cin >> n >> W;
  vector<vector<ll>> v(4);
  REP(i, n)
  {
    int w;
    ll V;
    cin >> w >> V;
    if (i == 0)
    {
      w0 = w;
    }
    v[w - w0].push_back(V);
  }

  REP(i, 4)
  {
    sort(v[i].begin(), v[i].end(), greater<ll>());
  }

  ll cum[4][101] = {};
  REP(i, 4)
  {
    cum[i][0] = 0;
    FOR(j, 1, v[i].size() + 1)
    {
      cum[i][j] = cum[i][j - 1] + v[i][j - 1];
    }
  }

  ll ans = 0;
  REP(i, v[0].size() + 1)
  {
    REP(j, v[1].size() + 1)
    {
      REP(k, v[2].size() + 1)
      {
        REP(l, v[3].size() + 1)
        {
          if (i * w0 + j * (w0 + 1) + k * (w0 + 2) + l * (w0 + 3) > W)
            continue;
          ans = max(ans, cum[0][i] + cum[1][j] + cum[2][k] + cum[3][l]);
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split();
            string S = line[0];
            string T = line[1];

            Console.WriteLine($"{T}{S}");
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  cout << (H - h) * (W - w) << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end(), greater<int>());
  int n_Alice = 0;
  int n_Bob = 0;
  for(int i=0; i<n; i++){
    if(i%2 == 0){
      n_Alice += a.at(i);
    }else{
      n_Bob += a.at(i);
    }
  }
  
  int res;
  res = n_Alice - n_Bob;
  cout << res << endl;
  
  return 0;
}


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

int main(){
	int N; cin>>N;
	vector<int> A(N);
	for(int i=0; i<N; ++i) cin>>A[i];
	sort(A.begin(), A.end());
	int n = A[N-1], r = 0;
	int mindiff = INT_MAX;
	for(int i=N-2; i>=0; --i){
		int diff = abs((n+2-1)/2 - A[i]);// |⌈n/2⌉ - ai|
		if(mindiff > diff){ mindiff = diff; r = A[i]; }
		// if(mindiff >= diff){ mindiff = diff; r = A[i]; }

		// int diff = abs((n+2-1)/2 - A[i]);// |⌈n/2⌉ - ai|
		// if(mindiff > diff){ mindiff = diff; r = A[i]; }
		// if(mindiff >= diff){ mindiff = diff; r = A[i]; }

		// int diff = abs(n/2 - A[i]); // |⌊n/2⌋ - ai|
		// if(mindiff > diff){ mindiff = diff; r = A[i]; }
		// if(mindiff >= diff){ mindiff = diff; r = A[i]; } // NG!
	}
	cout<< n <<" "<< r <<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int a;
int b;
int c;

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

Measured memory_bytes: 256
def main():
    R, G, B, N = map(int, input().split())
    ans = 0
    for r in range(N//R+1):
        for g in range(N//G+1):
            tmp = N - R*r - G*g
            if tmp % B == 0 and 0 <= tmp:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
    int N;
    cin >> N;
    int i = 1;
    while ((i * (i + 1)) / 2 < N)
    {
        i++;
    }

    int sub = (i * (i + 1) / 2) - N;
    for (int j = 1; j <= i; j++)
    {
        if(j != sub) cout << j << " ";
    }
    cout << endl;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

template <ll mod>
class modint
{
public:
    constexpr modint(ll value = 0) : _value(value >= 0 ? value % mod : (value % mod) + mod) {}

    constexpr modint operator+() const { return *this; }
    constexpr modint operator-() const { return modint(-_value); }

    constexpr modint &operator+=(const modint &rhs) {
        if ((_value += rhs._value) >= mod) _value -= mod;
        return *this;
    }
    constexpr modint &operator-=(const modint &rhs) {
        if ((_value += mod - rhs._value) >= mod) _value -= mod;
        return *this;
    }
    constexpr modint &operator*=(const modint &rhs) {
        (_value *= rhs._value) %= mod;
        return *this;
    }
    constexpr modint &operator/=(const modint &rhs) {
        *this *= rhs.inv();
        return *this;
    }
    constexpr modint operator+(const modint &rhs) const { return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const { return modint(*this) /= rhs; }

    constexpr modint operator++() { *this += 1; return *this; }
    constexpr modint operator--() { *this -= 1; return *this; }
    constexpr modint operator++(int) { modint tmp = *this; ++*this; return tmp; }
    constexpr modint operator--(int) { modint tmp = *this; --*this; return tmp; }

    constexpr bool operator==(const modint &rhs) const { return _value == rhs._value; }
    constexpr bool operator!=(const modint &rhs) const { return _value != rhs._value; }

    constexpr modint inv() const {
        ll a = _value, b = mod, u = 1LL, v = 0LL;
        while (b > 0) {
            ll tmp = a / b;
            a -= tmp * b; swap(a, b);
            u -= tmp * v; swap(u, v);
        }
        return modint(u);
    }

    constexpr modint pow(ll n) const {
        modint e = *this, res = 1;
        while (n) {
            if (n & 1) res *= e;
            e *= e, n >>= 1;
        }
        return res;
    }

    friend ostream &operator<<(ostream &os, const modint &m) {
        os << m._value;
        return os;
    }

    friend istream &operator>>(istream &is, modint &m) {
        ll in;
        is >> in;
        m = modint(in);
        return is;
    }

private:
    ll _value;
};
using mint = modint<1000000007>;

vector<int> g[100000];
mint dp[100000][2];
bool visited[100000];

void dfs(int i)
{
    visited[i] = true;
    dp[i][0] = dp[i][1] = 1;
    for (auto &j: g[i]) {
        if (visited[j]) continue;
        dfs(j);
        dp[i][0] *= dp[j][0] + dp[j][1];
        dp[i][1] *= dp[j][0];
    }
}

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

    int n; cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int x, y; cin >> x >> y; x--, y--;
        g[x].emplace_back(y), g[y].emplace_back(x);
    }

    dfs(0);
    cout << dp[0][0] + dp[0][1] << endl;
    return 0;
}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000
#define infll 1000000000000000000ll
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mpr make_pair
#define fi first
#define se second
#define pq priority_queue<int>
#define pqll priority_queue<ll>
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define ad(x,y) (x=(x+(y))%mod)
#define N 200009
using namespace std;

int n,m,b[N]; char ch[N],a[N],t1[N],t2[N];
int calc(int x){
	int i;
	for (i=1; i<=m; i++){
		if (ch[x]==a[i]) x+=b[i];
		if (x<1 || x>n) return x;
	}
	return x;
}
int main(){
	scanf("%d%d%s",&n,&m,ch+1);
	int i;
	for (i=1; i<=m; i++){
		scanf("%s%s",t1,t2);
		a[i]=t1[0]; b[i]=(t2[0]=='L'?-1:1);
	}
	int ans=n;
	if (calc(1)==0){
		int l=1,r=n,mid;
		while (l<r){
			mid=l+r+1>>1;
			if (calc(mid)==0) l=mid; else r=mid-1;
		}
		ans-=l;
	}
	if (calc(n)==n+1){
		int l=1,r=n,mid;
		while (l<r){
			mid=l+r>>1;
			if (calc(mid)==n+1) r=mid; else l=mid+1;
		}
		ans-=n-l+1;
	}
	printf("%d\n",ans);
	return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define size_of(a) (int)(a).size()

class Alphabet {
public:
	static const int N = 4;
	
	inline int toInt(char c) {
		if (c == 'A') return 0;
		if (c == 'C') return 1;
		if (c == 'G') return 2;
		if (c == 'T') return 3;
		return -1;
	}
};

class Trie {
private:
	struct Node {
		vector< int > link;
		bool end;
		Node(int n) : link(n, -1),  end(false) {}
	};
	
	Alphabet& alph;
	vector< Node > node;
	string buf;
	
public:
	Trie(Alphabet& alph_) : alph(alph_) {
		node.push_back(Node(alph.N));
	}
	
	void insert(string& str) {
		buf = str;
		insert(0, 0);
	}
	
	void insert(int i, int vi) {
		if (i == size_of(buf)) {
			node[vi].end = true;
			return;
		}
		
		int ci = alph.toInt(buf[i]);
		
		if (node[vi].link[ci] != -1) {
			insert(i + 1, node[vi].link[ci]);
		} else {
			node.push_back(Node(alph.N));
			node[vi].link[ci] = size_of(node) - 1;
			insert(i + 1, node[vi].link[ci]);
		}
	}
	
	bool find(string& str) {
		buf = str;
		return find(0, 0);
	}
	
	bool find(int i, int vi) {
		if (i == size_of(buf)) return node[vi].end;
		
		int ci = alph.toInt(buf[i]);
		
		if (node[vi].link[ci] == -1) return false;
		return find(i + 1, node[vi].link[ci]);
	}
};

int main() {
	Alphabet alph;
	Trie trie(alph);
	
	int n;
	cin >> n;
	
	for_(i,0,n) {
		string op, str;
		cin >> op >> str;
		
		if (op == "insert") {
			trie.insert(str);
		} else {
			if (trie.find(str)) cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
}

Measured memory_bytes: 35052
n = int(input())
a = list(map(int, input().split()))
A = sorted(set(a))
if len(A) == 1 and A[0] == 0:
    print('Yes')
else:
    if n % 3 == 0:
        if len(A) == 2 and A[0] == 0 and a.count(A[0]) * 2 == a.count(A[1]):
            print('Yes')
        elif len(A) == 3 and bin(A[0]^A[1]) == bin(A[2]) and a.count(A[0]) == a.count(A[1]) == a.count(A[2]):
            print('Yes')
        else:
            print('No')
    else:
        print('No')


Measured memory_bytes: 14116
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>

using namespace std;

void solve(int N, vector<int> V, vector<int> C);

void solve(int N, vector<int> V, vector<int> C) {
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int x = V[i] - C[i];
    if (V[i] - C[i] > 0) {
      ans += x;
    }
  }
  cout << ans << endl;
}

int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  vector<int> C(N);
  for (int i = 0; i < N; i++) {
    cin >> V[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> C[i];
  }
  solve(N, V, C);
  return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
//#define int long long

using namespace std;


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int s, w;
    cin >> s >> w;
    if (w >= s) cout << "unsafe";
    else cout << "safe";
    return 0;
}


Measured memory_bytes: 3652
s=list(input())
s=s[::-1]
for i in range(len(s)):
    s[i]=int(s[i])
data=[0]
x=0
for i in range(len(s)):
    x=pow(10,i,2019)*s[i]+x
    x=x%2019
    data.append(x)
from collections import Counter
data=dict(Counter(data))
ans=0
for key in data.values():
    ans+=(key)*(key-1)//2
print(ans)


Measured memory_bytes: 18236
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

ll gcd(ll a, ll b) {
  return b ? gcd(b, a%b) : a;
}

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  ll N;
  cin >> N;
  vll A(N);
  rep(i, N) {
    cin >> A[i];
  }
  
  //左右からの最大公約数を記録する
  vll R(N);
  vll L(N);
  R[N-1] = A[N-1];
  L[0] = A[0];
  for(int i=1; i<N; i++) {
    L[i] = gcd(L[i-1], A[i]);
    R[N-i-1] = gcd(R[N-i], A[N-i-1]);
  }
  
  //各、消してみる
  ll maxv = 0;
  rep(i, N) {
    if(i==0) {
      chmax(maxv, R[i+1]);
    } else if(i == N - 1) {
      chmax(maxv, L[N-2]);
    } else {
      chmax(maxv, gcd(L[i-1], R[i+1]));
    }
  }
  fin(maxv);
}

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

typedef long long ll;
const int MAX_N = 55;    // Change as necessary

ll A[MAX_N][MAX_N*MAX_N];

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  ll n; cin >> n;
  ll AA; cin >> AA;
  
  A[0][0] = 1;
  ll sum = 0;
  for(int i=1;i<=n;i++){
    int x; cin >> x;
    sum += x;
    for(int j=i-1;j>=0;j--)
      for(int k=0;k<=sum;k++)
        if(A[j][k])
          A[j+1][k+x] += A[j][k];
  }
  
  ll ans = 0;
  for(int i=1;i<=n;i++)
    ans += A[i][i*AA];
  cout << ans << endl;
  
  return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> C(N, 1);
    vector<bool> D(N, false);
    D[0] = true;

    for(int i=0; i<M; ++i) {
        int x,y;
        cin >> x >> y;
        --x; --y;
        if(D[x]) D[y] = true;
        if(C[x] == 1) D[x] = false;
        --C[x]; ++C[y];
    }

    int res = 0;
    for(int i=0; i<N; ++i) {
        if(D[i]) ++res;
    }
    cout << res << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include <math.h>
using namespace std;

int main()
{
    int r;
    cin >> r;
    cout << r*r << endl;
    return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vi a,b;

int main(){
	cin>>n;
	a=b=vi(n);
	for(int i=0;i<n;i++) cin>>a[i]>>b[i];
	double res=0;
	for(int i=0;i<n;i++) for(int j=i+1;j<n;j++){
		double x=abs(a[i]-a[j]),y=abs(b[i]-b[j]);
		res+=sqrt(x*x+y*y)*2/n;
	}
	cout<<syosu(8)<<res<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define  int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;
#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
#define sz(x) (int)(x.size())
#define ff first
#define ss second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
const int N=100005;

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int d[n];
    for(int i=0;i<n;i++)
        cin>>d[i];
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            ans=ans+d[i]*d[j];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

int main() {
   long long a;
   cin>>a;
   bool flag=false;
   rep(i,10){
      rep(j,10){
         if(i*j==a){
            flag=true;
         }
      }
   }
   if(flag){
      cout<<"Yes"<<endl;
   }
   else{
      cout<<"No"<<endl;
   }
}


Measured memory_bytes: 256
// #include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power(((((a)%mod)*((a)%mod))%mod),b/2)%mod;
    else return (((a)%mod)*(power(((((a)%mod)*((a)%mod))%mod),b/2)%mod))%mod;
}
inline ll inverse(ll a,ll md) {
  a %= md;
  if (a < 0) a += md;
  ll b = md, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}
  
  
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solution
const int ce=1e9+7;
ll fast_mod(ll input)
{
    return input < ce ? input : input%ce;
}
#define pi 3.14159
int32_t main()
{
    IOS
 
	int n,k;
	cin>>n>>k;
	int sum=0;
	for(int i=1;i<=k;i++)
	{
		int x;
		cin>>x;
		sum+=x;
	}
	if(sum>n)
	{
		cout<<-1;
	}
	else
	{
		cout<<n-sum<<endl;
	}
}       

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

#include <bits/stdc++.h>
#define rep(i,a,n) for(ll i = a;i < n;i++)
typedef long long ll;
using namespace std;

int main(){
    string s;
    cin >> s;
    ll memo = 0;
    rep(i,0,s.size()){
        if(memo == 0 && s[i] == 'C') memo = 1;
        else if(memo == 1 && s[i] == 'F') memo = 2;
    }

    if(memo == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include <cstdio>
#include<cstring>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
int main()
{
	double N, K;
	scanf( "%lf %lf", &N,&K);
	double P;
	double j;
	double sum;
	sum = 0;
	for (int i = 1;i < N+1;i++) {
		j = 1;
		while (1) {

			
			if (i*j >= K) { break; }
			j = j * 2;
		}
		
		P = 1 /j/N;
		sum = sum +P ;
		j = 1;
	}
	printf("%.16f", sum);
	return 0;
}

Measured memory_bytes: 764
N, M = map(int, input().split())
ab = [[int(_) for _ in input().split()] for _ in range(M)]
ab = sorted(ab, key=lambda x:x[1])
ans = 0
last = 0

for i in ab:
    if i[0] < last:
        continue
    else:
        last = i[1]
        ans += 1

print(ans)

Measured memory_bytes: 23704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int main()
{
	int n,a,sum=0;
	vi v;
	set<int>S;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		v.pb(a);
	}
	for(int i=0;i<n;i++)	
	{
		if(i==v[v[i]-1]-1&&S.find(i)==S.end()&&S.find(v[i]-1)==S.end())
		{
			sum++;
			S.insert(i);
			S.insert(v[i]-1);
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 5368
//It doesn't matter how slow you go, Unless you don't stop.
#include<iostream>
#include<algorithm>
#include<bitset>
 
#include<cmath>
#include<cstring>
#include<climits>
 
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
 
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;
typedef map<LL,LL> mp64;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 long long dp[2][1100000];
     int w[110];
     int v[110];
void solve()
{    
     int a,b;cin>>a>>b;
     for(int i=0;i<a;i++)
     {
         cin>>w[i];
         cin>>v[i];
     }
     for(int i=1;i<1100000;i++)
     {
         dp[0][i] = 10000000000;
     }
     for(int i=1;i<=a;i++)
     {
         int t = i%2;
         for(int j=0;j<1100000;j++)
         {
             dp[t][j] = 100000000000;
         }
         for(int j=0;j<1100000;j++)
         {
             dp[t][j] = min(dp[t][j],dp[!t][j]);
             if(j-v[i-1]>=0)
             dp[t][j] = min(dp[t][j],dp[!t][j-v[i-1]]+w[i-1]);
         }
     }
    //  for(int i=0;i<2;i++)
    //  {
    //      for(int j=0;j<30;j++)
    //      {
    //          cout<<dp[i][j]<<" ";
    //      }
    //      cout<<endl;
    //  }
    //  cout<<endl;
     int res = 0;
     for(int i=0;i<1100000;i++)
     {
         if(dp[a%2][i]<=b)
         {
             res = i;
         }
     }
     cout<<res<<endl;

}
 
int main()
{
    DANGER;
    ofstream out("output.txt");
 
    auto start = chrono::high_resolution_clock::now();
    
    LL t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        solve();
    }
    
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

Measured memory_bytes: 17408
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

void run() {
	int a,b,c; scanf("%d%d%d",&a,&b,&c);
	int mx=max(a,max(b,c));
	int sum=(mx-a)+(mx-b)+(mx-c);
	if(sum%2==1) sum+=3;
	printf("%d\n",sum/2);
}

int main() {
	run();
	return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T 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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  ll N, K, Q;
  cin >> N >> K >> Q;
  
  vector<ll> Nans(N);
  for(int i = 0; i < N; i++){
    Nans[i] = 0;
  }

  ll tmp;
  for(int i = 0; i < Q; i++){
    cin >> tmp;
    tmp--;
    Nans[tmp]++;
  }

  vector<bool> ans(N);
  for(int i = 0; i < N; i++){
    ans[i] = false;
  }

  for(int i = 0; i < N; i++){
    if(Q - Nans[i] < K){
      ans[i] = true;
    }
  }

  for(int i = 0; i < N; i++){
    if(ans[i]){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(i,x) for(int i=last[x];i;i=e[i].next)
using namespace std;
inline ll read(){
    ll f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//******head by yjjr******
const int maxn=2e5+6;
struct edge{int to,next;}e[maxn<<1];
int now1=-1,now2=-1,tot=0,num=0,n,m,d[maxn],last[maxn],cnt=0;
void insert(int u,int v){e[++cnt]=(edge){v,last[u]};last[u]=cnt;}
void dfs(int x,int fr){
    reg(i,x){
        if(e[i].to==fr)continue;
        if(d[e[i].to]==2)dfs(e[i].to,x);
        else if(e[i].to==now1)tot+=2;
        else if(e[i].to==now2)tot+=1;
    }
}
int main(){
    n=read(),m=read();
    rep(i,1,m){
        int u=read(),v=read();
        d[u]++,d[v]++;
        insert(u,v);insert(v,u);
    }
    rep(i,1,n)if(d[i]&1){puts("No");return 0;}
    rep(i,1,n)if(d[i]>4){puts("Yes");return 0;}
    rep(i,1,n)if(d[i]==4)num++;
    if(num==0){puts("No");return 0;}
    else if(num>2){puts("Yes");return 0;}
    else if(num==1){puts("No");return 0;}
    else{
        rep(i,1,n)
            if(d[i]==4){
                if(now1==-1)now1=i;else now2=i;
            }
            dfs(now1,-1);
            if(tot>5){puts("Yes");return 0;}
            else{puts("No");return 0;}
    }
    return 0;
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char s[200001][11];
int a[200000];
int cmpstr(const void* a, const void* b) {
    return strcmp((char*)a, (char*)b);
}
int main() {
    int n, max = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%s", s[i]);
    }
    qsort(s, n, 11, cmpstr);
    for (int i = 0; i < n; i++) {
        if (strcmp(s[i], s[i + 1]) == 0) {
            a[i]++;
            a[i + 1] = a[i] + 1;
        }
    }
    for (int i = 0; i < n; i++) {
        if (a[i] > max) max = a[i];
    }
    for (int i = 0; i <= n; i++) {
        if (a[i] == max) printf("%s\n", s[i]);
    }
    return 0;
}

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

using namespace std;

int main(void) {
    int n, m;
    cin >> n >> m;
    vector<int> d(n + 1, -1);
    bool can = true;
    for (int i = 0; i < m; ++i) {
        int s, c;
        cin >> s >> c;
        if (d[s] != -1 && d[s] != c) {
            can = false;
            break;
        }
        d[s] = c;
    }

    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (n > 1 && i == 1 && d[i] == -1) {
            ans += pow(10, n - i);
        } else if (d[i] != -1) {
            ans += d[i] * pow(10, n - i);
        }
    }

    int t = ans;
    int digits = 0;
    while (t) {
        t /= 10;
        digits++;
    }
    if (ans == 0) digits = 1;

    if (digits < n) can = false;

    cout << (can ? ans : -1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;
int f[2001][2001], w[2001], b[2001];
int cw[2001][2001], cb[2001][2001];

int main(){
  memset(f, 0, sizeof(f));
  memset(cw, 0, sizeof(cw));
  memset(cb, 0, sizeof(cb));
  
  int N;cin>>N;
  for (int i=1;i<=2*N;++i){
    char c;cin>>c;
    int a_;cin>>a_;
    if(c=='W') w[a_]=i;
    else b[a_]=i;
  }


  for (int i=1;i<=N;++i){
    for (int j=1;j<i;++j){
      cw[i][0]+=(w[i]<w[j]);
    }
    //j以下の番号で、w[i]よりも右にあるb[k]の数をたす
    for (int j=1;j<=N;++j){
      cw[i][j]=cw[i][j-1]+(b[j]>w[i]);
    }
  }

  for (int i=1;i<=N;++i){
    for (int j=1;j<i;++j){
      cb[0][i]+=(b[j]>b[i]);
    }
    for (int j=1;j<=N;++j){
      cb[j][i]=cb[j-1][i]+(w[j]>b[i]);
    }
  }

  for (int i=1;i<=N;++i){
    f[i][0]=f[i-1][0]+cw[i][0];
  }
  for (int j=1;j<=N;++j){
    f[0][j]=f[0][j-1]+cb[0][j];
  }
  for (int i=1;i<=N;++i){
    for (int j=1;j<=N;++j){
      f[i][j]=min(f[i-1][j]+cw[i][j], f[i][j-1]+cb[i][j]);
    }
  }

  cout << f[N][N] << endl;
  return 0;
}

Measured memory_bytes: 47232
import java.util.*;
import java.io.PrintWriter;
public class Main{
	static ArrayList<Integer>[] map;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		map=new ArrayList[n];
		for(int i=0; i<n; i++){
			map[i]=new ArrayList<>();
		}
		for(int i=1; i<n; i++){
			map[sc.nextInt()-1].add(i);
		}
		System.out.println(dfs(0));
	}
	static int dfs(int i){
		if(map[i].size()==0){
			return 0;
		}
		ArrayList<Integer> tmp=new ArrayList<>();
		for(int j:map[i]){
			tmp.add(dfs(j));
		}
		Collections.sort(tmp);
		int re=0;
		for(int t=0; t<tmp.size(); t++){
			re=Math.max(tmp.get(t)+1,re+1);
		}
		return re;
	}
}


Measured memory_bytes: 93080
#include <iostream>
    #include <vector>
    #include <fstream>
    #include <algorithm>
    #include <map>
    #include <set>
    #include <unordered_map>
    #include <unordered_set>
    #include <iomanip>
    #include <math.h>

    using namespace std;
     
    #define pb push_back
    #define f first
    #define s second
    #define endl '\n'
    #define EPS 1e-9
    #define PI acos(-1)
     
    using ll = unsigned long long;
    using pll = pair<ll,ll>;
    using ii = pair<int,int>;
    using vi = vector<int>;
    using vii = vector<ii>;
    using vll = vector<ll>;
    using ui = unsigned int;


    int main() {
        ofstream out("output.txt");
        ios_base::sync_with_stdio(false);
        

        ll a,b;
        cin>>a>>b;
        ll x = (a)/(__gcd(a,b))*b;
        cout<<x<<endl;

        return 0;
    }   


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

#define ll long long int
#define T int t; scanf("%d",&t); while(t--)
#define N 1000005
#define pb push_back
#define sc(n) int n;scanf("%d",&n)

int main()
{
    char a;
    scanf("%c",&a);
    printf("%c",a+1);
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC075_D___Axis_Parallel_Rectangle
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            var N = NK[0];
            var K = NK[1];

            var points = new Point[N];
            for (int i = 0; i < N; i++)
            {
                var xy = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
                points[i] = new Point(xy[0], xy[1]);
            }

            points = points.OrderBy(p => p.x).ToArray();
            var projectionX = points.Select(p => p.x).OrderBy(x => x).ToArray();
            var projectionY = points.Select(p => p.y).OrderBy(y => y).ToArray();
            var minArea = long.MaxValue;

            for (int L = 0; L < N; L++)
            {
                for (int B = 0; B < N; B++)
                {
                    for (int R = L + 1; R < N; R++)
                    {
                        for (int T = B + 1; T < N; T++)
                        {
                            var containPoints = 0;
                            foreach (Point p in points)
                            {
                                if (p.x > projectionX[R]) break;
                                if (p.x >= projectionX[L] && p.x <= projectionX[R] && p.y >= projectionY[B] && p.y <= projectionY[T])
                                {
                                    containPoints += 1;
                                }
                            }
                            if (containPoints >= K) minArea = Math.Min(minArea, (projectionX[R] - projectionX[L]) * (projectionY[T] - projectionY[B]));
                        }
                    }
                }
            }
            Console.WriteLine(minArea);
        }
    }

    struct Point
    {
        public long x;
        public long y;

        public Point(long _x, long _y)
        {
            x = _x;
            y = _y;
        }

    }
}


Measured memory_bytes: 13524
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return 1;}return 0;}

int n,m;

int main(){
    cin >> n >> m;
    vector<int> a(m);
    vector<int> b(m);
    vector<ll> c(m);
    REP(i,m){
        cin >> a[i] >> b[i] >> c[i];
        --a[i];
        --b[i];
        c[i]*=-1;
    }
    //Bellman-Ford法
    vector<ll> dist(n,1e15);
    int src = 0;
    dist[src]=0;
    REP(i,n*2){
        bool flag = false;
        REP(j,m){
            if(chmin(dist[b[j]],dist[a[j]]+c[j])){
                if(b[j]==n-1)flag = true;
            }
        }
        if(i==2*n-1&&flag){
            put("inf");
            return 0;
        }
    }
    put(-dist.back());
    return 0;
}


Measured memory_bytes: 256
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

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

#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define dloop(i,n) for(int i=n-1;i>=0;i--)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

const int mxn = 1e5+10;
int a[mxn];

int32_t main(){
	NINJA;

	int n; cin >> n;
	int cnt =0 ;
	for1(i,n) {
		int x; cin >> x;
		cnt += ((x%2==1 && i%2==1) ? 1 : 0);
	}

	cout << cnt << endl;
	
	return 0;
}

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

using namespace std;
typedef long long int ll;

const ll p = 31;
const ll N = 1e9 +1;


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

  ll n;
  cin>>n;
  ll b[n],a[n];
  ll c[n-1];
  ll sb = 0;
  for(int i =0;i<n;i++){
  	cin>>a[i];
  }
  for(int i =0;i<n;i++){
  	cin>>b[i];
  	sb+=b[i];
  }
  for(int i = 0;i<n-1;i++){
  	cin>>c[i];
  }
  for(int i =0;i<n-1;i++){
  	if(a[i]+1==a[i+1]){
  		sb+=c[a[i]-1];
  	}
  }
  cout<<sb<<'\n';

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
#define N 200127
#define mod 1000000007
inline int M(int x){return (x>=mod)?(x-mod):x;}
inline int M1(int x){return (x<0)?(x+mod):x;}
int n,a[N],d[N],c[N],vis[N],ans,f[N],len[N],s[N];
//c:color,vis:oncircle
int main(){
	scanf("%d",&n);int i,j,x,y,p,st,la,lal;ans=1;
	for(i=1;i<=n;i++)scanf("%d",&a[i]),++d[a[i]];
	for(i=1;i<=n;i++)
	if(!c[i])
	{
		x=i;while(!c[x]){c[x]=i;x=a[x];}
		if(c[x]!=i)continue;while(!vis[x]){vis[x]=1;x=a[x];}
	}
	for(i=1;i<=n;i++)
	if((vis[i]&&(d[i]>2))||((!vis[i])&&(d[i]>1)))
	{puts("0");return 0;}
	for(i=1;i<=n;i++)
	if(!d[i]){p=0;x=i;while(!vis[x]){++p;x=a[x];}len[x]=p;}
	for(i=1;i<=n;i++)//基环树 
	if(vis[i])
	{
		x=i;p=st=la=lal=0;
		while(vis[x])
		{
			++p;vis[x]=0;
			if(len[x])
			{
				if(!st){st=la=p;lal=len[x];}
				else{ans=1ll*ans*((len[x]<(p-la))+(len[x]<=(p-la)))%mod;la=p;}
			}x=a[x];
		}
		if(st)ans=1ll*ans*((lal<(p+st-la))+(lal<=(p+st-la)))%mod;//是基环树 
		else ++s[p];
	}
	for(i=1;i<=n;i++)//正常环 
	if(s[i])
	{
		f[0]=1;const int up=s[i];
		if((i>1)&&(i&1))
		{
			for(j=1;j<=up;j++)
			f[j]=M(f[j-1]+f[j-1]),f[j]=M(f[j]+((j>1)?(1ll*f[j-2]*(j-1)%mod*i%mod):0));//就像PKUSC中的sg一样 
		}
		else
		{
			for(j=1;j<=up;j++)
			f[j]=f[j-1],f[j]=M(f[j]+((j>1)?(1ll*f[j-2]*(j-1)%mod*i%mod):0));//有i种方式 
		}ans=1ll*ans*f[up]%mod;
	}printf("%d",ans);return 0;
}

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

int main()
{
    int n;
    cin >> n;
    rep(i, n)
    {
        int a;
        cin >> a;
        if (a % 2 == 0 && a % 3 != 0 && a % 5 != 0)
        {
            cout<<"DENIED"<<endl;
            return 0;
        }
    }
    cout<<"APPROVED"<<endl;
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << #x << " " << x << endl
inline void filehandling()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
}
#define int long long
#define MOD 1000000007
int power(int x,int y)
{
  int res = 1LL ;
  while(y > 0)
  {
    if(y & 1)
    {
      res = ((res % MOD) * (x % MOD)) % MOD;
    }
      
      y >>= 1 ;
      x = ( (x % MOD) * (x % MOD) ) % MOD;
  }

  return res % MOD;
} 
void Solve_Case()
{
  int n;
  cin >> n;
   string s;
   cin >> s;
   
   if(n & 1)
   {
    cout << "No\n";
    return ;
   }
   else 
   {
    for(int i=0;i<n/2;i++)
    {
      if(s[i] != s[n/2+i])
      {
        cout << "No\n";
        return;
      }
    }
   }
  cout << "Yes\n";
}
signed main()
{
  // filehandling();
   int TestCases = 1;
  // cin >> TestCases;
   while(TestCases--)
   {
      Solve_Case();
   }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#ifndef ONLINE_JUDGE
#include"custom_header.h"
#else
#define openfile 
#endif
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define ll long long
#define ld long double
#define fo(i,v,e) for(v=i;v<e;v++)
#define rfo(i,v,e) for(v=i;v>e;v--)
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define vl vector<ll>
#define sz(x) (ll)x.size()
#define vvl vector<vl>
#define vpl vector<pll>
const ll mod = 1000000007;
void solve()
{
    ll n,x,t;cin>>n>>x>>t;
    ll temp = n/x+(n%x!=0);
    cout<<temp*t<<endl;
}
int main()
{
    //openfile;fastio;
    ll T = 1; 
    // cin>>T;
    while(T--)
    {solve();}
}

Measured memory_bytes: 3616
main :: IO ()
main = do
    [n, a, b] <- map read . words <$> getLine :: IO [Int]
    print $ solve 1 n a b
    
solve :: Int -> Int -> Int -> Int -> Int
solve c n a b = if n >= c then (cal c a b) + (solve (c + 1) n a b) else 0

digitSum :: Int -> Int
digitSum 0 = 0
digitSum x = (mod x 10) + (digitSum (div x 10))  

cal :: Int -> Int -> Int -> Int
cal c a b
    | res >= a && res <= b = c
    | otherwise = 0
  where 
    res = digitSum c
    

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

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, k; cin >> n >> k;
	ll a[100][n+1];
	rep(j, 1, n){
		cin >> a[0][j];
	}
	
	rep(i, 1, 60){
		rep(j, 1, n){
			a[i][j] = a[i-1][a[i-1][j]];
		}
	}
	
	ll ans = 1;
	rep(i, 0, 60){
		if(k & (1LL << i)){
			ans = a[i][ans];
			//cout << i << " " << ans << endl;
		}
	}
	
	print(ans)
	return 0;
}

Measured memory_bytes: 98936
#include<bits/stdc++.h>
using namespace std;
const int maxn=200100;
char s[maxn];int n,f[maxn][2];
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	for(int i=1;i<=n;i++) f[i][0]=f[i][1]=-n;
	f[1][0]=1;f[2][1]=1;
	for(int i=1;i<=n;i++)
	{
		if(i+2<=n)
		{
			f[i+2][1]=max(f[i+2][1],f[i][0]+1);
			if(s[i-1]!=s[i+1]||s[i]!=s[i+2])
				f[i+2][1]=max(f[i+2][1],f[i][1]+1);
		}
		if(i+1<=n)
		{
			f[i+1][0]=max(f[i+1][0],f[i][1]+1);
			if(s[i]!=s[i+1])
				f[i+1][0]=max(f[i+1][0],f[i][0]+1);
		}
	}
	cout<<max(f[n][0],f[n][1])<<endl;
}

Measured memory_bytes: 5532
def resolve():
	N, K = map(int, input().split())
	a = []*K
	for i in range(K*2): # 開始、終端、ステップ
		if i%2 == 0:
			_ = input()
		else:
			a.extend(list(map(int, input().split())))
	print(N - len(set(a)))

resolve()

Measured memory_bytes: 9184
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;
use std::collections::BTreeSet;
fn main() {
    let mut set = BTreeSet::new();
    let n: usize;
    input!(n);
    for _ in 0..n {
        let a: usize;
        input!(a);
        if set.contains(&a) {
            set.remove(&a);
        } else {
            set.insert(a);
        }
    }
    p(set.len());
}

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

int main(){
    int S;
    int a,b,c;
    cin >> S;
    a = (S/60)/60;
    b = (S/60)%60;
    c = S - (a*3600 + b*60);
    cout << a << ":" << b << ":" << c << endl;

}




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


int main() {
    ll n;
    cin >> n;
    vector<pair<ll, int>> fs;
    for (ll i = 2; i*i <= n; i++) {
        int x = 0;
        while (n%i == 0) {
            n /= i;
            x++;
        }
        
        fs.emplace_back(i, x);
    }
    if (n != 1) fs.emplace_back(n, 1);

    int ans = 0;
    for (auto p : fs) {
        int x = p.second;
        int b = 1;
        while (b <= x) {
            x -= b;
            b++;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19756
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    if ((a != b && b != c && c != a) || (a == b && b == c))
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
        int a, b, c, i;
        int cnt = 0;

        scanf("%d%d%d", &a, &b, &c);
        for (i = a; i <= b; i++) {
                if ((c % i) == 0) {
                        cnt++;
                }
        }
        printf("%d\n", cnt);
        return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    double a,b;
    cin>>a>>b;
    for(int i=0;i<=10000;i++){
        int q=i*0.08;
        int p=i*0.1;
        if(q==a&&p==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr ll INF = 1LL << 60;

string s;
ll q, a, f;
char c;
ll N, A, B;

int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> A >> B;
  cout << N / (A + B) * A + min(N % (A + B), A);
  return 0;
}



Measured memory_bytes: 256