akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(void){

    int A, B;
    cin >> A >> B;
    for (int i = 0 ; i < 20; i++){
        if((i*A+1)-i >= B){
             cout << i << endl;
             return 0;
        }
    }


    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <iterator>
#include <random>
#include <cassert>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位


int dp[1000000];

int dpVal(int i) {
    if (i < 0) return LL_HALFMAX;
    else return dp[i];
}
int h[1000000];

signed main() {
    int N;
    cin >> N;
    dp[0] = 0;

    for (int i = 0; i < N; i++) cin >> h[i];
    for (int i = 1; i < N; i++) dp[i] = min(dpVal(i - 1) + abs(h[i] - h[i - 1]), dpVal(i - 2) + abs(h[i] - h[i - 2]));

    cout << dp[N - 1] << "\n";

	return 0;
}

Measured memory_bytes: 5120
N=int(input())
S=input()

E=[0]*N
W=[0]*N

if S[0]=='E':
    E[0]=1
else:
    W[0]=1

i=1
while i<N:
    if S[i]=='E':
        E[i]=E[i-1]+1
        W[i]=W[i-1]
    else:
        W[i]=W[i-1]+1
        E[i]=E[i-1]
    i+=1

E=[0]+E
W=[0]+W

ans=N
j=1
while j<=N:
    count=W[j-1]+(E[N]-E[j])
    ans=min(ans,count)
    j+=1

print(ans)

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

#define int long long
#define REP(i, n) for (int i=0; i<(n); ++i)
#define IREP(i, n) for (int i=1; i<=(n); ++i)

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> t) {
    return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> t) {
    return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ", " + to_string(get<3>(t)) + ")";
}

template <typename A>
string to_string(vector<A> v) {
    bool first = true;
    string result = "[";
    for (A i : v) {
        if (!first) result += ", ";
        first = false;
        result += to_string(i); 
    }
    return result + "]";
}

template <typename A>
string to_string(A x[], signed n) {
    string result = "{";
    for (signed i=0; i<n; ++i) {
        if (i!=0) result += ", ";
        result += to_string(x[i]); 
    }
    return result + "}";
}

const int BIGN = 200000;
int n;
map<pair<int,int>, int> edgeID;
vector<int> edges[BIGN];
int out[BIGN];
int maxcnt = -1;

void dfs(int x, int prev, int skip) {
    int cnt = 1;
    for (int y : edges[x]) {
        if (y != prev) {
            if (cnt == skip) ++cnt;
            out[edgeID[{min(x,y),max(x,y)}]] = cnt;
            maxcnt = max(maxcnt, cnt);
            dfs(y, x, cnt);
            ++cnt;
        }
    }
}


signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    cin >> n;
    REP(i, n-1) {
        int a,b; cin >> a >> b;
        if (b<a) swap(a,b);
        edgeID[{a, b}] = i;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    dfs(1, 0, 0);
    cout << maxcnt << '\n';
    REP(i, n-1) cout << out[i] << '\n';
}

Measured memory_bytes: 19200
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <bitset>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = (a); i < (n); i++)
#define MP make_pair
#define all(s) (s).begin(), (s).end()
#define rev(s) (s).rbegin(), (s).rend()
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

struct bits{
	bitset<32> b;

	bits(){ rep(i, 32) b[i] = 0; }

	bits(string s){
	}

	double to_f(){
		double res = 0;
		rep(i, 7) if(b[i]) res += pow(2.0, i-7);
		FOR(i, 7, 31) if(b[i]) res += 1<<(i-7);
		if(b[31]) res *= -1;

		return res;
	}
};

int main(){
	int n;
	cin >> n;
	while(n--){
		int bits = 0;
		string s;
		cin >> s;
		rep(i, 8){
			bits <<= 4;
			int b;
			if(s[i] >= '0' && s[i] <= '9') b = s[i] - '0';
			else b = s[i] - 'a' + 10;
			bits += b;
		}

		double b = 0;
		int a = 0;
		rep(i, 7) if(bits&(1<<i)) b += pow(2.0, i-7);
		FOR(i, 7, 31) if(bits&(1<<i)) a += 1<<(i-7);

		string str;
		while(abs(b-(int)b) > pow(2.0, -8)){
			b *= 10;
			str += '0'+(int)b%10;
		}
		if(str.empty()) str = '0';

		if(bits&(1<<31)) cout << '-';
		cout << a << '.' << str << endl;
	}


	return 0;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

int32_t main(){
    boost;

    //code

    set<int> s;
    int temp;
    for(int i = 0 ; i < 3 ; ++i){
    	cin >> temp;
    	s.insert(temp);
    }

    cout << s.size();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
int main()
{ 
    cool;
    unsigned ll int a[1005];
    a[0]=0;
	for(int i=1;i<1000;i++){
		a[i]=pow(i,5);
	}
	ll int n,x,y,f=0;
	cin>>n;
	for(int i=0;i<=1000;i++){
		for(int j=0;j<=1000;j++){
			if((a[i]+a[j])==n){
				x=i;
				y=j;
				f=1;
				break;
			}
			else if((a[j]-a[i])==n){
				x=i;
				y=j;
				f=2;
				break;
			}
		}
		if(f==1||f==2)
		break;
	}
	if(f==1){
		y*=-1;
		cout<<x<<" "<<y;
	}
	else if(f==2){
		cout<<y<<" "<<x;
	} 
    return 0;
}


Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define EFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i, n) FOR(i,0,n)
#define INF 1e9
const int MOD = 1000000007;
typedef pair<ll,ll> P;

int main(void){
    string s;
    cin >> s;
    if(s[s.length()-1] == 's'){
        cout << s << "es" << endl; 
    }else{
        cout << s << "s" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
/*
ID: amagica1
TASK: ariprog
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
#define INF INT_MAX
#define NINF -INF
#define mp make_pair
#define endl '\n'
#define boost() cin.tie(0); cin.sync_with_stdio(0)
#define For(i, a, b) for(int i=a; i<b; i++)
#define FOR(i, a, b) for(int i=a; i<=b; i++)
#define Rev(i, a, b) for(int i=a; i>b; i--)
#define REV(i, a, b) for(int i=a; i>=b; i--)
#define debug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;
typedef long double ld;
typedef int64_t l;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
const ll MOD = 1e9 + 7;
const int MAXN = 200005;
ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
mt19937 rng;
int BIT[MAXN], N;
void upd(int x) {
    for(int i=x; i<MAXN; i+=i&-i)
        BIT[i]++;
}
int qry(int x) {
    int ret=0;
    for(int i=x; i>0; i-=i&-i)
        ret += BIT[i];
    return ret;
}
int main() {
    //-----------FILE------------//
    //freopen("airprog.in", "r", stdin);
    //freopen("airprog.out", "w", stdout);
    //----------------------------//
    cin >> N; int cnt=0;
    for(int i=1, x; i<=N; i++) {
        cin >> x; int ret = qry(x);
        if(ret == 0) cnt++;
        upd(x);
    }
    cout << cnt << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;


using VT = vector<int>;
using VVT = vector<VT>;
// Forma esglaonada reduida. Les columnes amb
// el primer no-zero de cada fila son (0..1..0).
int gauss(VVT mat) {
  int r = mat.size(), c = mat[0].size();
  int i,j;
  for (i = 0, j = 0; i < r and j < c; ++j) {
    int nz = i;
    for (int k = i + 1; k < r; ++k) {
      if (abs(mat[nz][j]) < abs(mat[k][j])) nz = k;
    }
    if (abs(mat[nz][j]) < 1) continue;
    swap(mat[i], mat[nz]);
    for (int k = 0; k < r; ++k) if (k != i and abs(mat[k][j])) {
      for (int w = j; w < c; ++w)
        mat[k][w] ^= mat[i][w]; // idem
    }
    ++i;
  }
  return i;
}

const int C = 62;

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

  int t;
  cin >> t;
  for (int cas = 1; cas <= t; ++cas) {
    int n;
    cin >> n;
    vi A(n);
    for (int i = 0; i < n; ++i) cin >> A[i];
    string s;
    cin >> s;
    bool pot = true;
    VVT mat;
    for (int i = n-1; i >= 0; --i) {
      auto mat2 = mat;
      VT rt(C);
      for (int j = 0; j < C; ++j) {
        if (A[i]&(1ll<<j)) rt[j] = 1;
        else rt[j] = 0;
      }
      mat2.push_back(rt);
      if (s[i] == '0') {
        int d = mat.size();
        int d2 = gauss(mat2);
        if (d2 > d) mat = mat2;
        //cerr << 0 << ' ' << d << ' ' << d2 << endl;
      }
      else {
        int d = mat.size();
        int d2 = gauss(mat2);
        //cerr << 1 << ' '  << d << ' ' << d2 << endl;
        if (d2 > d) {
          pot = false;
          break;
        }
      }
    }
    if (pot) cout << 0 << '\n';
    else cout << 1 << '\n';
  }
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++) 
#define fs first
#define sc second
#define _GLIBCXX_DEBUG

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

template <class S>
void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){
		cout << v[i] << ' ';
	}
	cout << endl;
}
template <class S>
void print(vector<vector<S>> &v) {
  	for (ll i = 0; i < (ll)v.size(); i++) {
    	for (ll j = 0; j < (ll)v[i].size(); j++) {
      		cerr << v[i][j] << ' ';
    	}
    	cerr << endl;
  	}
}

int main(){
	int n;
	cin >> n;
	vector<vector<pair<int,bool>>> st(n);
	rep(i,n){
		int a; cin >> a;
		Rep(a){
		int x,y;
		cin >> x >> y;
		st[i].push_back(make_pair(x-1,y));
		}
	}
	int ans = 0;
	int c=0;
	rep(bits, (1 << n)){
		c=0;
		rep(i,n){
			if(bits >> i & 1){
				c++;
				for(auto p: st[i]){
					int h=p.fs;
					bool u=p.sc;
					if((bits >> h & 1) != u) goto wrong;
				}
			}
		}
		ans = max(c, ans);
		wrong:;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import math

base = 998244353

n, a, b, k =  map(int, input().split())

fac = [1] * (n + 1)
rev = [1] * (n + 1)
for i in range(1, n + 1):
    fac[i] = fac[i - 1] * i % base
    rev[i] = pow(fac[i], base -2, base)



def comb(n,r):
    hoge = (fac[n] * rev[r] * rev[n - r] ) % base
    return hoge





count = 0

an = 0 

for an in range(n+1):
    if k - an * a < 0 or (k - an * a) % b != 0:
        continue
    bn = (k -an * a) // b
    if not 0 <= bn <= n:
        continue

    count += comb(n, an) * comb(n, bn) % base
    count %= base



print(count)







    



Measured memory_bytes: 26716
N=map(int,input().split())
A=tuple(map(int,input().split()))
l=[0]*(10**5+1)
for i in A:
    l[i]+=1
a=0
t=0
for i in l:
    if i!=0:
        a+=1
        if i%2==0:
            t+=1
if t%2==1:
    a-=1
print(a)

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

#define ll long long
#define ld long double
#define ii pair<int ,int >
#define S second
#define F first
#define PI 3.1415926535897932384626
#define SPEED std::ios_base::sync_with_stdio(false);

int main(){
    SPEED
    ll n,k,x,y;
    cin>>n>>k>>x>>y;
    if(k>=n){
        cout<<n*x;
        return 0;
    }
    cout<<(x*k)+(max(0LL,(n-k))*y);

}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String P =sc.next();
    String M[] ={"SAT","FRI","THU","WED","TUE","MON","SUN"};
    for(int i=0;i<7;i++){
      if(P.equals(M[i])){System.out.println(i+1);}
    }
  }
}

Measured memory_bytes: 21844
#include<stdio.h>

int main(){
  int a[20000],i=0,j=0,b;
  while(i>=0){
    scanf("%d",&a[i]);
    if(a[i]==0){
      b=i-1;
      i=-2;
    }
    if(a[i]!=0)i++;
  }
  for(j=0;j<b+1;j++){
    printf("Case %d: %d\n",j+1,a[j]);
  }
  return 0;
}

Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long N, M, i, j, dp[3001][3001];
	string a, b, w = "";
	cin >> a >> b;
	N = a.size();
	M = b.size();
	for(i = 0; i < N; i++)
	{
		for(j = 0; j < M; j++)
			dp[i][j] = 0;
	}
	if(a[N - 1] == b[M - 1])
	{
		dp[N - 1][M - 1] = 1;
	}
	for(i = N - 2; i >= 0; i--)
	{
		if(a[i] == b[M - 1] || dp[i + 1][M - 1] == 1)
		{
		    dp[i][M - 1] = 1;
		}
	}
	for(i = M - 2; i >= 0; i--)
	{
		if(b[i] == a[N - 1] || dp[N - 1][i + 1] == 1)
		dp[N - 1][i] = 1;
	}
	for(i = N - 2; i >= 0; i--)
	{
		for(j = M - 2; j >= 0; j--)
		{
			if(a[i] == b[j])
				dp[i][j] = 1 + dp[i + 1][j + 1];
			else
			{
				dp[i][j] = max(dp[i + 1][j], dp[i][j + 1]);
			}
		}
	}
	long long x = 0, y = 0;
    while(x < N && y < M)
    {
        if(a[x] == b[y])
        {
            w += a[x];
            x++;
            y++;
        }
        else if(dp[x + 1][y] > dp[x][y + 1])
        x++;
        else
        y++;
    }
	cout << w;
	return 0;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	map<int, int> MAP;

	rep1(i, N) {
		int kari = i;
		rep1(ii, N) {
			if (ii != 1 && kari % ii == 0) {
				while (kari % ii == 0) {
					MAP[ii]++;
					kari /= ii;
				}
			}
		}
	}

	ll kotae = 1;
	ll mod = 1e9 + 7;
	for (auto itr : MAP) {
		kotae = kotae * (itr.second + 1) % mod;
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=205;

int n,a[N]; 

int main(){
	scanf("%d",&n);
	rep(i,1,n<<1) scanf("%d",a+i);
	sort(a+1,a+n+n+1);
	ll sum=0;
	for(int i=1;i<(n<<1);i+=2) sum+=a[i];
	printf("%lld\n",sum);
	return 0;
}


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

int main() {
    long long int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k <= a) {
        cout<<k; 
    } else if(k<=(a+b)){
        cout<<a;
    } else {
        cout<<a-((k-(a+b)));
    }
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor_ct.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/strong_components.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/bellman_ford_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
using namespace std;
using namespace boost::math;

int main() {
	string s, t;

	cin >> s >> t;
    multiset<pair<char, int>> spawned;
  
    REP(i, s.length())
      spawned.emplace(s[i], i);
  
    long long marker = -1;
    long long cross = 0;
  
    REP(i, t.length()) {
      auto it = spawned.lower_bound(make_pair(t[i], marker + 1));
      
      if (it == spawned.end() || it->first != t[i]) {
        cross++;
        it = spawned.lower_bound(make_pair(t[i], 0));
        if (it->first != t[i]) {
          cout << -1 << endl;
          return 0;
        }
        marker = it->second;
      }
      else {
        marker = it->second;
      }
    }
    

	cout << cross * s.length() + marker + 1 << endl;

	return 0;
}


Measured memory_bytes: 5120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str = sc.next();
		int num = sc.nextInt();

		int a;
		int b;
		String replace;
		String input;

		for (int j = 0; j < num; j++) {
			input = sc.next();
			a = sc.nextInt();
			b = sc.nextInt();

			if (input.equals("print")) {
				System.out.println(str.substring(a, b+1));
			} else if (input.equals("reverse")) {
				char[] c1 = str.substring(a, b+1).toCharArray();
				String temp="";
				for (int i = 0; i < c1.length; i++) {
				    temp += c1[c1.length - 1 - i];
				}
				replace = temp;
				str = str.replace(str.substring(a, b+1), replace);
			} else {
				replace = sc.next();
				str = str.substring(0,a)+replace+str.substring(b+1);
			}
		}
	}

}


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

using namespace std;
typedef pair<int,int> P;
int r,c,n;
bool used[100001];

int main() {
  cin >> r >> c >> n;
  vector<P> r1,r2,r3,r4;
  for(int i = 0; i < n; i++) {
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    if((x1 > 0 && y1 > 0 && x1 < r && y1 < c) || (x2 > 0 && y2 > 0 && x2 < r && y2 < c)) continue;
    if(x1 == 0 && y1 < c) r1.push_back(P(y1,i));
    if(x2 == 0 && y2 < c) r1.push_back(P(y2,i));
    if(x1 < r && y1 == c) r2.push_back(P(x1,i));
    if(x2 < r && y2 == c) r2.push_back(P(x2,i));
    if(x1 == r && y1 > 0) r3.push_back(P(y1,i));
    if(x2 == r && y2 > 0) r3.push_back(P(y2,i));
    if(x1 > 0 && y1 == 0) r4.push_back(P(x1,i));
    if(x2 > 0 && y2 == 0) r4.push_back(P(x2,i));
					  
  }
  

  sort(r1.begin(),r1.end());
  sort(r2.begin(),r2.end());
  sort(r3.begin(),r3.end(),greater<P> ());
  sort(r4.begin(),r4.end(),greater<P> ());

  /* for(int i = 0; i < r1.size(); i++) cout <<"r1 = "<<r1[i].second<<endl;
  for(int i = 0; i < r2.size(); i++) cout <<"r2 = "<<r2[i].second<<endl;
  for(int i = 0; i < r3.size(); i++) cout <<"r3 = "<<r3[i].second<<endl;
  for(int i = 0; i < r4.size(); i++) cout <<"r4 = "<<r4[i].second<<endl;
  */

 
  stack<int> s;
  bool ok = true;
  for(int i = 0; i < r1.size(); i++) {
    if(!used[r1[i].second]) {
      s.push(r1[i].second);
      used[r1[i].second] = true;
    }
    else {
      int t = s.top();
      if(t != r1[i].second) ok = false;
      else s.pop();
    }
  }
  
  for(int i = 0; i < r2.size(); i++) {
    if(!used[r2[i].second]) {
      s.push(r2[i].second);
      used[r2[i].second] = true;
    }
    else  {
      int t = s.top();
      if(t != r2[i].second) ok = false;
      else s.pop();
    }
  }
  
  for(int i = 0; i < r3.size(); i++) {
    if(!used[r3[i].second]) {
      s.push(r3[i].second);
      used[r3[i].second] = true;
    }
    else  {
      int t = s.top();
      if(t != r3[i].second) ok = false;
      else s.pop();
    }
  }
  
  for(int i = 0; i < r4.size(); i++) {
    if(!used[r4[i].second]) {
      s.push(r4[i].second);
      used[r4[i].second] = true;
    }
    else  {
      int t = s.top();
      if(t != r4[i].second) ok = false;
      else s.pop();
    }
  }

  if(ok) cout << "YES" << endl;
  else cout << "NO" << endl;

  
}
        


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

int main() {
    // 入力
    int n,k;
    cin>>n>>k;

    string S;
    cin >> S;

    int ans=0,lr=0,rl=0;
	  for (int i = 1; i < n;i++){
      if(S[i]=='L' && S[i-1]=='L'){
        ans++;
      }
      else if(S[i]=='R' && S[i-1]=='R'){
        ans++;
      }
    }
    cout << min(n-1,ans+2*k) << endl;



}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

bool compare(pair<int, string> former, pair<int, string> latter){
    if(former.first == latter.first){
        return former.second < latter.second;
    }else{
        return former.first > latter.first;
    }
}

int main(void){
    int N;
    string Sbuf;
    vector<string> S;
    vector<pair<int, string>> Ssorted;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> Sbuf;
        S.push_back(Sbuf);
    }
    sort(S.begin(), S.end());
    Ssorted.push_back(pair<int, string>(1, S[0]));
    int counter=0;
    for(int i=1; i<N; i++){
        if(Ssorted[counter].second == S[i]){
            Ssorted[counter].first++;
        }else{
            Ssorted.push_back(pair<int, string>(1,S[i]));
            counter++;
        }
    }
    sort(Ssorted.begin(), Ssorted.end(), compare);
    int threshold = Ssorted[0].first;
    for(int i=0; i<=counter; i++){
        if(Ssorted[i].first == threshold){
            cout << Ssorted[i].second << endl;
        }else break;
    }
    return 0;
}

Measured memory_bytes: 18544
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(sc.hasNext()){
			int m = sc.nextInt();
			for(int i=0;i<m;i++){
				StringBuffer s = new StringBuffer(sc.next());
				StringBuffer t, u, v;
				ArrayList<String> list = new ArrayList<String>();
				list.add(s.toString());
				for(int j=1;j<s.length();j++){
					t = new StringBuffer(s.substring(0,j));
					u = new StringBuffer(s.substring(j,s.length()));
					v = new StringBuffer();
					
					v.delete(0, s.length());
					v.append(t);
					v.append(u.reverse());
					if(list.indexOf(v.toString())==-1){
						list.add(v.toString());
					}
					
					v.delete(0, s.length());
					v.append(t.reverse());
					v.append(u);
					if(list.indexOf(v.toString())==-1){
						list.add(v.toString());
					}
					
					v.delete(0, s.length());
					v.append(t);
					v.append(u.reverse());
					if(list.indexOf(v.toString())==-1){
						list.add(v.toString());
					}
					
					v.delete(0, s.length());
					v.append(u);
					v.append(t.reverse());
					if(list.indexOf(v.toString())==-1){
						list.add(v.toString());
					}
					
					v.delete(0, s.length());
					v.append(u.reverse());
					v.append(t);
					if(list.indexOf(v.toString())==-1){
						list.add(v.toString());
					}
					
					v.delete(0, s.length());
					v.append(u);
					v.append(t.reverse());
					if(list.indexOf(v.toString())==-1){
						list.add(v.toString());
					}
					
					v.delete(0, s.length());
					v.append(u.reverse());
					v.append(t);
					if(list.indexOf(v.toString())==-1){
						list.add(v.toString());
					}
				}	
				System.out.println(list.size());
			}
			
		}
	
	}	
}

Measured memory_bytes: 44256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
//import std.regex;
import std.container;

void main()
{
	auto n = readln.chomp.to!int;
	int cnt;

	while (cnt < n) {
		int outCnt, score;
		int base;

		while (outCnt < 3) {
			auto str = readln.chomp;
			if (str == "OUT") { 
				outCnt++;
			} else if (str == "HOMERUN") {
				score += base + 1;
				base = 0;
			} else {
				if (base == 3) score++;
				else base++;
			}
		}
		score.writeln;
		cnt++;
	}
}

Measured memory_bytes: 1052
#include <iostream>
#include <cmath>
#include <list>
#include <algorithm>

#define INF (1<<30)
#define re(i, n) for(int i=0;i<(n);i++)
#define rep(i, s, n) for(int i=(s);i<(n);i++)
using namespace std;
typedef long long ll;

int main(void) {
    int n, W;
    cin >> n >> W;
    int v[n], w[n];
    re(i, n)cin >> w[i] >> v[i];
    ll d[n + 1][W + 1];
    re(i, n + 1) re(j, W + 1) d[i][j] = 0;
    rep(i, 1, n + 1) {
        rep(j, 1, W + 1) {
            if (j - w[i - 1] >= 0) d[i][j] = max(d[i - 1][j], max(d[i - 1][j - w[i - 1]] + v[i - 1], d[i][j]));
            else d[i][j] = max(d[i - 1][j], d[i][j]);
        }
    }
    cout << d[n][W] << endl;


    return 0;
}


Measured memory_bytes: 79104
while (ary = gets.split.map(&:to_i)) != [0, 0]
  answer     = []
  key_ary    = []
  result_ary = []

  ary[1].times do |num|
    key_ary << (num + 1).to_s
    result_ary << 0
  end

  ary[0].times do
    tmp_ary = gets.split.map(&:to_i)
    result_ary = result_ary.zip(tmp_ary).map! {|a, b| a + b}
  end

  tmp_hash = Hash[*key_ary.zip(result_ary).flatten]
  tmp_hash = tmp_hash.sort_by {|key, value| -value}
  tmp_hash.each {|key, value| answer << key}
  puts answer.join(" ")
end

Measured memory_bytes: 8980
import math
x,y = map(int, input().split())
 
pre_ans = math.log2(y/x)
ans = math.ceil(pre_ans)
 
if pre_ans == ans:
  ans += 1

if (2**(ans-1))*x <= y and y < (2**ans)*x:
  print(ans)
elif (2**(ans))*x <= y and y < (2**(ans+1))*x:
  print(ans+1)
elif (2**(ans-2))*x<=y and y < (2**(ans-1))*x:
  print(ans-1)
else:
  print("error")

Measured memory_bytes: 3064
#include <iostream>  
#include <algorithm>  
using namespace std;  
long long n,m,ans;  
struct P  
{  
    long long x,y;  
}pnt1[256],pnt2[256];  
  
long long cmp1(P a,P b)  
{  
    return a.x<b.x;  
}  
  
long long cmp2(P a,P b)  
{  
    return a.y<b.y;  
}  
long long vis[256];  
  
void judge(long long lx,long long rx)  
{  
    long long y[256],u=0,d=0;  
    for(long long i=0;i<n;++i)  
        if(pnt2[i].x>=lx&&pnt2[i].x<=rx){  
            y[u++]=pnt2[i].y;  
            if(u-d==m){  
                ans=min(ans,(y[u-1]-y[d])*(rx-lx));  
                ++d;  
            }     
        }  
}  
  
int main()  
{  
    cin>>n>>m;  
    for(long long i=0;i<n;++i){  
        cin>>pnt1[i].x>>pnt1[i].y;  
        pnt2[i]=pnt1[i];
    }  
    sort(pnt1,pnt1+n,cmp1);  
    sort(pnt2,pnt2+n,cmp2);  
    ans=1e63;          
    long long l,r;  
    for(long long i=0;i<n;++i)  
        for(long long j=i;j<n;++j)  
            judge(pnt1[i].x,pnt1[j].x);  
    cout<<ans<<endl;
    return 0;     
}   

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pp;
double PI=acos(-1);
int const N = 1e6 + 10,M=5e6+10, oo = 1e9;
const int mod = oo+7;
const ll  OO = 3e18;

int n,k,aa[N];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>k;
    if(k==n){
        cout<<1<<endl;
        return 0;
    }
    int at=0;
    for(int i=0;i<n;i++){
        cin>>aa[i];
        if(aa[i]==1)at=i;
    }
    int i=at,an=0;
    while(i<n-1){
        i+=k;
        i--;
        an++;
    }
    i=min(at,at-(i-n));
    while(i>0){
        i-=k;
        i++;
        an++;
    }
    int an2=0;
    i=at;
    while(i>0){
        i-=k;
        i++;
        an2++;
    }
    i=max(at,at-i);
    while(i<n-1){
        i+=k;
        i--;
        an2++;
    }
    cout<<min(an,an2)<<endl;
    return 0;
}




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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, M; scanf("%d %d", &N, &M);
  vector<ll> A(N), B(N), C(M), D(M);
  for (int i = 0; i < N; ++i) {
    scanf("%lld %lld", &A[i], &B[i]);
  }
  for (int i = 0; i < M; ++i) {
    scanf("%lld %lld", &C[i], &D[i]);
  }
  for (int i = 0; i < N; ++i) {
    int cp = -1;
    ll dist = LLINF;
    for (int j = 0; j < M; ++j) {
      if (abs(C[j] - A[i]) + abs(D[j] - B[i]) < dist) {
        dist = abs(C[j] - A[i]) + abs(D[j] - B[i]);
        cp = j + 1;
      }
    }
    printf("%d\n", cp);
  }
  return 0;
}


Measured memory_bytes: 384
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

ans=0
n=int(input())

for d in make_divisors(n):
    if d==1:
        continue
    m=d-1
    if n//m==n%m:
        ans+=m
print(ans)




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

using namespace std;

int main(void)
{
    double w,h,x,y;
    cin >>w >>h >>x >>y;

    double area = w * h / (double)2;

    if(abs(w/2 - x) <= 0.0000001 && abs(h/2- y) < 0.0000001){
        printf("%.10lf 1\n", area);
    }else{
        printf("%.10lf 0\n", area);
    }

    return 0;
}

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

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    
    if(a==b){
        cout<<"Draw"<<endl;
    }else if(a==1 && b!=1){
        cout<<"Alice"<<endl;
    }else if(a!=1 && b==1){
        cout<<"Bob"<<endl;
    }else if(a>b){
        cout<<"Alice"<<endl;
    }else{
        cout<<"Bob"<<endl;
    }
    
    return 0;
}

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



struct dice{
    int top, bottom, west, east, north, south;
    
    // no need naming these... just for clarity
    void roll_east(){
        int t = top;
        top = west;
        west = bottom;
        bottom = east;
        east = t;       
    };
    void roll_west(){
        int t = top;
        top = east;
        east = bottom;
        bottom = west;
        west = t;
    };
    void roll_north(){
        int t = top;
        top = south;
        south = bottom;
        bottom = north;
        north = t;
    };
    void roll_south(){
        int t = top;
        top = north;
        north = bottom;
        bottom = south;
        south = t;
    };
    void show_dice(){
        std::cout << " " << north << std::endl;
        std::cout << west << bottom << east << top << std::endl;
        std::cout << " " << south << std::endl;
        std::cout << std::endl;
    };
};

int main(){
    dice d;
    std::cin >> d.top >> d.south >> d.east >> d.west >> d.north >> d.bottom;
    //d.show_dice();
    char m;
    while(std::cin >> m){
        switch(m){
            case 'W':
                d.roll_west();
                break;
            case 'E':
                d.roll_east();
                break;
            case 'N':
                d.roll_north();
                break;
            case 'S':
                d.roll_south();
                break;   
        }
        //d.show_dice();
        
    }
    std::cout << d.top << std::endl;
    return 0;
}

Measured memory_bytes: 3100
#include<cstdio>
#include<algorithm>
using namespace std;

typedef long long ll;
const int N=222;

char a[N][N];

int n,m,dp[2][N][N][N];
int s[N][N];

int sum(int a,int b,int c,int d)
{
	if(a>b||c>d)return 0;
	return s[b][d]-s[a-1][d]-s[b][c-1]+s[a-1][c-1];
}

void init()
{
	for(int i=1; i<=n; i++)
	{
		scanf("%s",a[i]+1);
		for(int j=1; j<=m; j++)
			s[i][j]=(a[i][j]=='#');
	}
	for(int i=1; i<=n; i++)
		for(int j=2; j<=m; j++)
			s[i][j]+=s[i][j-1];
	for(int i=2; i<=n; i++)
		for(int j=1; j<=m; j++)
			s[i][j]+=s[i-1][j];
	for(int l=1; l<=m; l++)
		for(int r=l; r<=m; r++)
			for(int i=1,j=0; i<=n; i++)
			{
				for(j=max(i-1,j); j<n; ++j)
				{
					int ss=sum(i,j+1,l,r);
					if(ss>0 && ss<(r-l+1)*(j-i+2))
						break;
				}
				dp[0][i][l][r]=j;
			}
}

int main()
{
	scanf("%d%d",&n,&m);
	init();
	if(dp[0][1][1][m]>=n)return puts("0"),0;
	for(int c=1;;++c)
	{
		auto *f=dp[~c&1],*g=dp[c&1];
		for(int i=1; i<=n; i++)
			for(int l=1; l<=m; l++)
				for(int r=l; r<=m; r++)
				{
					g[i][l][r]=max(f[i][l][r],f[f[i][l][r]+1][l][r]);
					if(g[i][l][r]>=n)
						continue;
//					for(int k=l; k<r; ++k)
//						g[i][l][r]=max(g[i][l][r],min(f[i][l][k],f[i][k+1][r]));
					int x=l,y=r-1;
					while(x<=y){
						int mid=(x+y)>>1,a=f[i][l][mid],b=f[i][mid+1][r];
						g[i][l][r]=max(g[i][l][r],min(a,b));
						if(a>b)x=mid+1;else y=mid-1;
					}
				}
		if(g[1][1][m]>=n)return printf("%d",c),0;
	}
	return 0;
}


Measured memory_bytes: 73472
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define INF (int)1e9+5
#define nax (int)1e5+2
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hello\n"
#define f first
#define s second
using namespace std;

ll mod = 1000000007;

/*ll power(ll x,ll y)  
{  
    ll temp;  
    if(y == 0)  
        return 1;  
    temp = power(x, y / 2);  
    if (y % 2 == 0)  
        return temp * temp;  
    else
    {  
        if(y > 0)  
            return x * temp * temp;  
        else
            return (temp * temp) / x;  
    }  
}*/

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or 
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
}
  
// Returns n^(-1) mod p 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
ll nCrModPFermat(ll n, ll r, ll p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    ll fac[n+1]; 
    fac[0] = 1; 
    for (ll i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}
ll ncr(ll n ,ll r, ll p){
	//ll i = n-(n-r);
	ll val = 1;
	for(ll i =n-r+1;i<=n;i++ ){
		val = ((val%p) * (i%p))%p;
	}
	ll temp = 1;
	for(ll i = 1;i<=r;i++){
		
	}
	return (val/temp);
	
} 
long modPow(long a, long x, long p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

long modInverse(long a, long p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}
long modBinomial(long n, long k, long p) {
// calculates C(n,k) mod p (assuming p is prime).

    long numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    long denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}


int main(){
	fast;
	ll n;
	ll a,b;
	cin>>n;
	cin>>a>>b;
	ll ans = power(2,n,mod);
	deb(ans);
	ll val1 = modBinomial(n,a,mod);
	deb(val1);
	ll val2 = modBinomial(n,b,mod);
	ll val = (val1+val2+1)%mod;
	ans = (ans%mod - val%mod +mod)%mod;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
tree_num,choice_num = map(int,input().split())
tree_list = sorted([int(input()) for _ in range(tree_num)])
mi = 999999999999999999999999
for idx in range(tree_num-choice_num+1):
    cand = tree_list[idx+choice_num-1] - tree_list[idx]
    if cand < mi:
        mi = cand
print(mi)

Measured memory_bytes: 8280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll a, b;
  cin >> a >> b;
  cout << (a + b) % 24 << endl;
}

Measured memory_bytes: 3572
def ipt(N=0,switch=0):
    if N == 0:
        return list(map(int,input().split()))
    else:
        if switch==0:
            return [list(map(int,input().split())) for _ in range(N)]
        else:
            return [int(input()) for _ in range(N)]

N,K=ipt()
l=sorted(ipt(),reverse=True)
print(sum(l[:K]))

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{      
    char c[200];
    cin >> c;
    int num =0,y=1;
    while(true){
        if(c[num]=='L'){
            y=0;
            break;
        }else if(c[num]=='\0'){
            break;
        }
        num++;
        if(c[num]=='R'){
            y=0;
            break;
        }else if(c[num]=='\0'){
            break;
        }
        num++;
    }
    if(y==1){
        cout << "Yes";
    }else if(y==0){
        cout << "No";
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll a[205];
ll b[64];
void insertVector(ll mask) {
	for (int i = 63; i >= 0; i--) {
		if ((mask & (1ll << i)) == 0ll) continue;
		if (!b[i]) {
			b[i] = mask;
			return;
		}
		mask ^= b[i];
	}
}
bool checkVector(ll mask) {
	for (int i = 63; i >= 0; i--) {
		if ((mask & (1ll << i)) == 0ll) continue;
		if (b[i]) mask ^= b[i];
	}
	return (mask==0ll);
}
int main(){
    int t;
    scanf("%d",&t);
    while (t--){
        int n;
        scanf("%d",&n);
        for (int i = 0; i < n; i++) scanf("%lld",&a[i]);
        string s;
        cin >> s;
        int ans = 0;
        for (int i = 0; i < 64; i++) b[i] = 0;
        for (int i = n-1; i >= 0; i--){
            if (s[i] == '0'){
                insertVector(a[i]);
            }
            else{
                if (!checkVector(a[i])){
                    ans = 1; break;
                }
            }
        }
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 3760
#include<stdio.h>
#include<stdlib.h>
struct node{int n;struct node *np,*pp;};
struct node *fp=NULL,*ep,*n,*nfp,*nep;
int N,t,a;
char cmd[15];

void del(struct node*dp)
{
	struct node *nnp=dp->np;
	struct node *npp=dp->pp;
	npp->np=nnp;
	nnp->pp=npp;
	free(dp);
}

int main()
{
	scanf("%d\n",&N);
	for(;N--;)
	{
		scanf("%s",cmd);
		if(cmd[0]=='i')
		{
			scanf("%d\n",&t);
			struct node *tp=(struct node*)malloc(sizeof(struct node));
			tp->n=t;
			if(fp==NULL)
			{
				tp->np=tp->pp=tp;
				fp=tp;
				ep=tp;
				tp->np=fp;
			}
			else
			{
				tp->np=fp;
				fp->pp=ep->np=tp;
				tp->pp=ep;
				fp=tp;
			}
		}
		else
		{
			if(cmd[6]=='F')
			{
				nfp=fp;
				fp=fp->np;
				del(nfp);
			}
			else if(cmd[6]=='L')
			{
				nep=ep;
				ep=ep->pp;
				del(nep);
			}
			else
			{
				scanf("%d\n",&t);a=0;
				for(n=fp;n->n!=t&&(!a||n!=fp);)
					n=n->np,a++;
				if(n->n!=t)continue;
				if(n==fp)
					fp=fp->np;
				if(n==ep)
					ep=ep->pp;
				del(n);
			}
		}
	}
	for(n=fp,t=1;t||n!=fp;n=n->np)
		t=!printf("%d%c",n->n,n->np==fp?'\n':' ');
	return 0;
}

Measured memory_bytes: 31792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N;
	cin >> N;
	if (N == 1) {
		cout << 1 << endl;
		return 0;
	}
	vector<int>D(N);
	rep(i, N) {
		cin >> D[i];
	}
	sort(D);
	int cnt = 0;
	for (int i = 1; i < N; i++) {
		if (D[i - 1] == D[i]) {
			cnt++;
		}
	}
	cout << N - cnt << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)

void solve() {
	int N;
	cin >> N;
	
	string ans = "APPROVED";
	REP(i, N) {
		int x;
		cin >> x;
		if (x % 2 == 0) {
			if (x % 3 != 0 && x % 5 != 0) {
				ans = "DENIED";
			}
		}
	}

	cout << ans << endl;

}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	solve();

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int A, B, C; cin >> A >> B >> C;
  cout << min(C, B / A) << endl;
}


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

int main()
{
	int a,b,c,d,sum=0;
	string s;

	cin>>s;
    a=s.size();

    for(int i=0;i<a;i++)
    {
        if(s[i]!=s[a-1-i])
        {
            cout<<"No";
            return 0;
        }

    }
    cout<<"Yes";
	
	return 0;
}
	

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
  int i,j,c[1000001],n,m,ans;
  char s[1000001];

  while(scanf("%d",&n) && n){
    memset(c,0,sizeof(c));

    scanf("%d%s",&m,s);
    for(i=m-1;i>1;i--){
      if(s[i] == 'I' && s[i-1] == 'O' && s[i-2] == 'I'){
        c[i-2] = c[i] + 1;
      }
    }

    ans = 0;
    for(i=0;i<m;i++){
      if(c[i] >= n){
        ans++;
      }
    }
    printf("%d\n",ans);
  }

  return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class G
{
	public static void Main()
	{
		(new Solver()).Solve();
	}
}


public class Solver
{
	private int N;
	private int M;
	private List<int>[] adj;
	private int[] memo;

	public Solver()
	{
		N = GetInt();
		M = GetInt();
		adj = Enumerable.Range(0, N).Select(_ => new List<int>()).ToArray();
		for(int i = 0; i < M; i++)
		{
			int x = GetInt() - 1;
			int y = GetInt() - 1;
			adj[x].Add(y);
		}
		memo = Enumerable.Repeat(-1, N).ToArray();
	}

	public void Solve()
	{
		Console.WriteLine(Enumerable.Range(0, N).Select(x => rec(x)).Max());
	}

	private int rec(int v)
	{
		if(memo[v] != -1)
			return memo[v];

		int max = -1;
		foreach(int u in adj[v])
			max = Math.Max(max, rec(u));

		memo[v] = max + 1;
		return memo[v];
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 32524
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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 gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

//高速な素因数分解O(logN)
template<typename T>
vector<T> sieve(T n){//n以下の整数について最小の素因数を調べる
    vector<T>prime(n+1);
		for(int i=0;i<=n;++i)prime[i]=i;
    for(int i=2;i*i<=n;i++){
        if(prime[i]<i)continue;
				for(int j=i*i;j<=n;j+=i){
					if(prime[j]>=i)prime[j]=i;
				}
    }
    return prime;
}

template<typename T>
vector<pair<T,int>> osa_k(T n,const vector<T>& min_factor){//min_factorはsieveで求めた配列を使う
  vector<T> ret;
  while(n>1){
		ret.push_back(min_factor[n]);
		n/=min_factor[n];
	}
  vector<pair<T,int>>v;
	T value=0;
	int pos=0;
	while(pos<ret.size()){
		int cnt=0;
		value=ret[pos];
		while(pos<ret.size()&&ret[pos]==value){
			++cnt;
			++pos;
		}
		v.emplace_back(value,cnt);
	}
  return v;
}

void solve()
{
	ll n;
	cin>>n;
	ll ans=0;
	auto s=sieve(n);
	REP(i,1,n+1){
		ll cul=1;
		for(auto x:osa_k((ll)i,s)){
			cul*=x.second+1;
		}
		ans+=cul*i;
	}
	cout<<ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 81320