akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
bool book[100100];
vector<int> ft[100100];
queue<int> bfs;
int step[100100];
void dfs(int x){
	int i;
	book[x]=1;
	for(i=0;i<ft[x].size();i++)
	{
		if(!book[ft[x][i]])
		{
			dfs(ft[x][i]);
		}
	}
}
int main(){
	int n,m,s,t,i,j,k,u,v,w,x;
	cin>>n>>m;
	for(i=0;i<m;i++)
	{
		cin>>u>>v;
		ft[u].push_back(v);
	}
	cin>>s>>t;
	memset(step,127,sizeof(step));
	dfs(s);
	if(!book[t])
	{
		cout<<-1<<endl;
		return 0;
	}
	bfs.push(s);
	step[s]=0;
	while(bfs.size())
	{
		u=bfs.front();
		bfs.pop();
		for(i=0;i<ft[u].size();i++)
		{
			v=ft[u][i];
			for(j=0;j<ft[v].size();j++)
			{
				w=ft[v][j];
				for(k=0;k<ft[w].size();k++)
				{
					x=ft[w][k];
					if(step[x]>=1e9)
					{
						if(x==t)
						{
							cout<<step[u]+1<<endl;
							return 0;
						}
						step[x]=step[u]+1;
						bfs.push(x);
					}
				}
			}
		}
	}
	cout<<-1<<endl;
	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

int main(void){
	string s;
	cin >> s;
	int ans=0;

	const int n=s.size();
	rep(i,n-1) if(s[i]!=s[i+1]) ans++;
	cout << ans << endl;
	
	return 0;
}

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

int calc(int p[], ll c[], int D, ll G) {
    int minCount = INT_MAX;
    for (int bit = 0; bit < (1 << D); ++bit) {
        int maxIdx = 0;
        ll total = 0;
        int count = 0;
        for (int i = 0; i < D; i++) {
            if (bit & (1 << i)) {
                total += (i + 1) * 100 * p[i] + c[i];
                count += p[i];
            } else {
                maxIdx = i;
            }
        }
        int plus = 0;
        int maxN = p[maxIdx];
        while (total < G && plus < maxN - 1) {
            plus++;
            total += (maxIdx + 1) * 100;
        }
        count += plus;

        if (G <= total && count < minCount) minCount = count;
    }
    return minCount;
}

void solve() {
    int D;
    ll G;
    cin >> D >> G;

    int p[D];
    ll c[D];
    for (int i = 0; i < D; ++i) {
        cin >> p[i] >> c[i];
    }

    cout << calc(p, c, D, G) << endl;
}

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


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

pair<int, int> d[300 * 300 + 1];
int sum[300 * 300 + 1];

int abs(int x) {
	return x > 0 ? x : -x;
}

int main() {
	int N, M, D;
	cin >> N >> M >> D;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			int x;
			cin >> x;
			d[x].first = i;
			d[x].second = j;
		}
	}
	
	for(int i = 1; i <= D; i++) {
		int x = d[i].second;
		int y = d[i].first;
		for (int j = i + D; j <= N * M; j += D) {
			sum[j] += abs(x - d[j].second) + abs(y - d[j].first) + sum[j - D];
			x = d[j].second;
			y = d[j].first;
		}
	}
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int L, R;
		cin >> L >> R;
		cout << sum[R] - sum[L] << endl;
	}
}

Measured memory_bytes: 2176
#include <iostream>

int main(){
  int A, B;
  std::cin>>A>>B;

  if(A>=13) std::cout<<B<<std::endl;
  if(A<=12 && A>=6) std::cout<<B/2<<std::endl;
  if(A<=5) std::cout<<0<<std::endl;

  return 0;
}


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

int main(){
  int N,K,Q;
  cin >> N;
  vector <int> A(100000);
  cin >> K >> Q;
  rep(i,N) A.at(i) =  K - Q;
  vector <int> B(100000);
  rep(i,Q){
    cin >> B.at(i);
    B.at(i)--;
    A.at(B.at(i))++;
  }
  rep(i,N){
   if(A.at(i) > 0)
      cout << "Yes" << endl;
   else if(A.at(i) < 0 || A.at(i) == 0)
      cout << "No" << endl;
  }
  return 0;
}


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

long long sum[51] = {1};

long long burger(long long level, long long *remain){
    if(*remain <= 0){
        return 0;
    }
    
    if(level == 0){
        if(*remain > 0){
            (*remain)--;
            return 1;
        }else{
            return 0;
        }
    }
    
    long long ans = 0;
    if(*remain >= sum[level]){
        ans = sum[level] / 2 + 1;
        *remain -= sum[level];
        return ans;
    }else{
        (*remain)--;
        ans += burger(level - 1, remain);
    }
    
    if(*remain <= 0){
        return ans;
    }
    
    ans++;
    (*remain)--;
    
    if(*remain <= 0){
        return ans;
    }
    
    ans += burger(level - 1, remain);
    
    return ans;
}

int main(void){
    long long n, x;
    cin >> n >> x;
    
    for(long long i = 1; i <= 50; i++){
        sum[i] = sum[i - 1] * 2 + 3;
    }
    
    cout << burger(n, &x) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 200010;
const int MAXK = 110;
const int MAXQ = 200010;

int n, a[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    FOR(i,1,n) {
        if (a[i] > a[i-1]) a[i]--;
        else if (a[i] < a[i-1]) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max({a * c, b * d, a * d, b * c}) << '\n';
  return 0;
}


Measured memory_bytes: 3688
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;

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



int main()
{
    int c[3][3];
    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            cin >> c[i][j];
        }
    }
    for(int i = 0; i < 2; i++)
    {
        for(int j = 0; j < 2; j++)
        {
            if(c[j][i] - c[j + 1][i] != c[j][i + 1] - c[j + 1][i + 1])
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    // // a1 - a2系は終わった
    for(int i = 0; i < 2; i++)
    {
        for(int j = 0; j < 2; j++)
        {
            if(c[j][i] - c[j][i+1] != c[j + 1][i] - c[j + 1][i + 1])
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

ll f[100100];

ll pow_mod(ll a, ll b, ll m){
    ll ret = 1;
    while (b > 0) {
        if (b & 1) {
            ret = ret * a % m;
        }
        a = a * a % m;
        b >>= 1;
    }
    return ret;
}

ll inv_mod(ll a, ll m){
    return pow_mod(a, m - 2, m);
}

ll comb(ll a, ll b){
    if(a < b) return 0;
    ll tmp = f[a] * inv_mod(f[b], mod) % mod;
    ll ret = tmp * inv_mod(f[a - b], mod) % mod;
//    cout << "comb " << a << "," << b << ":" << ret << endl;
    return ret;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    f[0] = 1;
    rep(i, 1, 100100){
        f[i] = f[i - 1] * i % mod;
    }
    
    ll N;
    cin >> N;
    vector<int> A(N + 1);
    vector<int> B(100100, 0);
    rep(i, N + 1) {
        cin >> A[i];
        B[A[i]]++;
    }
    
    int l = -1, r = -1;
    rep(i, 100100){
        if(B[i] > 1){
            rep(j, N + 1){
                if(A[j] == i){
                    if(l == -1) l = j;
                    else r = j;
                }
            }
        }
    }
    int x = l, z = N - r;
    
    rep(i, N + 1){
        ll a = comb(N + 1, i + 1);
        ll b = comb(x + z, i);
//        ll c = comb(x, i) + comb(z, i) % mod;
//        b = (b + c) % mod;
        output((a - b + mod) % mod);
    }
    
//    cout << l << "," <<  r << endl;
    return 0;
}

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

int main() {
    double x1, x2, y1, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        cout << fixed << setprecision(4); 
        cout << sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) << endl;
    return 0;
}    


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    string a, b, c;
    cin >> a >> b >> c;

    char x = a[0];
    while(1) {
        if (x == 'a') {
            if (a.size() == 0) {
                cout << "A" << endl;
                return 0;
            }
            x = a[0];
            a.erase(a.begin());
        } else if (x == 'b') {
            if (b.size() == 0) {
                cout << "B" << endl;
                return 0;
            }
            x = b[0];
            b.erase(b.begin());
        } else {
            if (c.size() == 0) {
                cout << "C" << endl;
                return 0;
            }
            x = c[0];
            c.erase(c.begin());
        }
    }

    return 0;
}

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

using namespace std;

int main(){
	while(true){
		int n, m, k;
		cin >> n >> k >> m;
		if(n == 0 && m == 0 && k == 0){ break; }
		vector<int> removed(n);
		--m;
		int remains = n;
		while(remains > 1){
			removed[m] = 1;
			int l = k % --remains;
			if(l == 0){ l = remains; }
			while(l--){
				if(++m >= n){ m = 0; }
				while(removed[m]){
					if(++m >= n){ m = 0; }
				}
			}
		}
		cout << (m + 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include<iostream>
using namespace std;
int main(){

	cout<<"1x1=1"<<endl;
	cout<<"1x2=2"<<endl;
	cout<<"1x3=3"<<endl;
    cout<<"1x4=4"<<endl;
	cout<<"1x5=5"<<endl;
	cout<<"1x6=6"<<endl;
	cout<<"1x7=7"<<endl;
	cout<<"1x8=8"<<endl;
	cout<<"1x9=9"<<endl;
	cout<<"2x1=2"<<endl;
	cout<<"2x2=4"<<endl;
	cout<<"2x3=6"<<endl;
	cout<<"2x4=8"<<endl;
	cout<<"2x5=10"<<endl;
	cout<<"2x6=12"<<endl;
	cout<<"2x7=14"<<endl;
	cout<<"2x8=16"<<endl;
	cout<<"2x9=18"<<endl;
	cout<<"3x1=3"<<endl;
	cout<<"3x2=6"<<endl;
	cout<<"3x3=9"<<endl;
	cout<<"3x4=12"<<endl;
	cout<<"3x5=15"<<endl;
	cout<<"3x6=18"<<endl;
	cout<<"3x7=21"<<endl;
	cout<<"3x8=24"<<endl;
	cout<<"3x9=27"<<endl;
	cout<<"4x1=4"<<endl;
	cout<<"4x2=8"<<endl;
	cout<<"4x3=12"<<endl;
	cout<<"4x4=16"<<endl;
	cout<<"4x5=20"<<endl;
	cout<<"4x6=24"<<endl;
	cout<<"4x7=28"<<endl;
	cout<<"4x8=32"<<endl;
	cout<<"4x9=36"<<endl;
	cout<<"5x1=5"<<endl;
	cout<<"5x2=10"<<endl;
	cout<<"5x3=15"<<endl;
	cout<<"5x4=20"<<endl;
	cout<<"5x5=25"<<endl;
	cout<<"5x6=30"<<endl;
	cout<<"5x7=35"<<endl;
	cout<<"5x8=40"<<endl;
	cout<<"5x9=45"<<endl;
	cout<<"6x1=6"<<endl;
	cout<<"6x2=12"<<endl;
	cout<<"6x3=18"<<endl;
	cout<<"6x4=24"<<endl;
	cout<<"6x5=30"<<endl;
	cout<<"6x6=36"<<endl;
	cout<<"6x7=42"<<endl;
	cout<<"6x8=48"<<endl;
	cout<<"6x9=54"<<endl;
	cout<<"7x1=7"<<endl;
	cout<<"7x2=14"<<endl;
	cout<<"7x3=21"<<endl;
	cout<<"7x4=28"<<endl;
	cout<<"7x5=35"<<endl;
	cout<<"7x6=42"<<endl;
	cout<<"7x7=49"<<endl;
	cout<<"7x8=56"<<endl;
	cout<<"7x9=63"<<endl;
	cout<<"8x1=8"<<endl;
	cout<<"8x2=16"<<endl;
	cout<<"8x3=24"<<endl;
	cout<<"8x4=32"<<endl;
	cout<<"8x5=40"<<endl;
	cout<<"8x6=48"<<endl;
	cout<<"8x7=56"<<endl;
	cout<<"8x8=64"<<endl;
	cout<<"8x9=72"<<endl;
	cout<<"9x1=9"<<endl;
	cout<<"9x2=18"<<endl;
	cout<<"9x3=27"<<endl;
	cout<<"9x4=36"<<endl;
	cout<<"9x5=45"<<endl;
	cout<<"9x6=54"<<endl;
	cout<<"9x7=63"<<endl;
	cout<<"9x8=72"<<endl;
	cout<<"9x9=81"<<endl;
    
	return 0;

}

Measured memory_bytes: 1116
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#include<fstream>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	if(s=="zyxwvutsrqponmlkjihgfedcba") {
		cout<<-1<<endl;
		return 0;
	}
	vector<ll> c(26,0);
	REP(i,(ll)s.size()) {
		c[s[i]-'a']++;
	}
	if((ll)s.size()<26) {
		REP(i,26) if(c[i]==0) {
			s+=('a'+i);
			cout<<s<<endl;
			return 0;
		}
	} else {
		for(ll i=25; i>=1; i--) {
			c[s[i]-'a']--;
			for(ll j=(s[i-1]-'a')+1; j<26; j++) {
				if(c[j]==0) {
					string ret=s.substr(0,i-1);
					ret+='a'+j;
					cout<<ret<<endl;
					return 0;
				}
			}
		}
	}
}



Measured memory_bytes: 256
import Control.Monad
import Data.List (foldl', unfoldr)

type Queue a = ([a], Int, [a], Int)

empty' :: Queue a
empty' = ([], 0, [], 0)

isEmpty' :: Queue a -> Bool
isEmpty' (_, 0, _, _) = True
isEmpty' _ = False

head' :: Queue a -> a
head' (x : _, _, _, _) = x
head' _ = error "the queue is empty"

check :: Queue a -> Queue a
check q@(f, fl, t, tl)
  | fl < tl = (f ++ reverse t, fl + tl, [], 0)
  | otherwise = q

tail' :: Queue a -> Queue a
tail' (_ : f, fl, t, tl) = check (f, fl - 1, t, tl)
tail' _ = error "the queue is empty"

snoc' :: Queue a -> a -> Queue a
snoc' (f, fl, t, tl) x = check (f, fl, x : t, tl + 1)

main = do
  [n, q] <- fmap (map read . words) getLine
  let readPair :: IO (String, Int)
      readPair = do
        [a, b] <- fmap words getLine
        return $ (a, read b)
  qu <- fmap (foldl' snoc' empty') $ replicateM n readPair
  let f qu ti o
        | isEmpty' qu = o
        | l <= q = let ti' = ti + l
                   in f t ti' ((n, ti') : o)
        | otherwise = let qu' = snoc' t (n, l - q)
                          ti' = ti + q
                      in f qu' ti' o
        where
          (n, l) = head' qu
          t = tail' qu
      o = reverse $ f qu 0 []
  mapM_ (\(n, t) -> putStrLn $ n ++ " " ++ show t) o

Measured memory_bytes: 42952
def GCD(x,y):

    if(x >= y):
        z = y
        w = x%y
    else:
        z = x
        w = y%x

    if(not(w == 0)):
        return GCD(z,w)
    else:
        return z

A = [int(i) for i in input().split()]
print(GCD(A[0],A[1]))

"""実行結果

100 55
5



66 77
11

"""



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


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(20)<<fixed;

	int n;
	cin>>n;
	int x,y;
	int c=0;
	string s="No";
	for(int i=0;i<n;i++)
	{
		cin>>x>>y;
		
		if(x==y)
			c++;
		else
			c=0;
		if(c==3)
			s="Yes";
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include <string>
#include <algorithm>
#include <bitset>
#include <iostream>

using namespace std;

int n, q;
string a[200005], b[200005], c, d, st;

int main() {
  cin >> n >> q >> st;
  
  for (int i = 0; i < q; ++i) {
    cin >> a[i] >> b[i];
  }

  int l = -1, r = n;
  for (int i = q-1; i >= 0; --i) {
    c = a[i];
    d = b[i];

    if (d[0] == 'L') {
      if (st[l + 1] == c[0]) {
        ++ l;
      }

      if (r < n && st[r] == c[0]) {
        ++ r;
      }
    } else {
      if (st[r - 1] == c[0]) {
        -- r;
      }

      if (l >= 0 && st[l] == c[0]) {
        -- l;
      }
    }
  }
  
  cout << r - l - 1 << endl;
  return 0;
}



Measured memory_bytes: 22276
#include<stdio.h>
int main()
{
    int t,money,m;
    scanf("%d %d %d",&t,&money,&m);
    int n=t*money;
    if(n<m)
        printf("%d",n);
    else if(n==m)
        printf("%d",m);
    else
        printf("%d",m);
    return 0;
}


Measured memory_bytes: 128
h, w, n = map(int, input().split())
wall = [list(map(int, input().split())) for _ in range(n)]

wall.sort(key=lambda x: x[1])
wall.sort(key=lambda x: x[0])


# combination---

mod = 10**9 + 7
fac = [1, 1]
inv = [1, 1]
finv = [1, 1]
for i in range(2, h+w+1):
    fac.append(fac[i-1] * i % mod)
    inv.append(mod - inv[mod%i] * (mod//i) % mod)
    finv.append(finv[i-1] * inv[i] % mod)

def nck(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod



# dp[i]:= i-1番目までの壁を通らず、i番目の壁にたどり着く経路の数
dp = [0] * n

for i in range(n):
    res = 0    # i-1までの壁を一回以上通って、i回目の壁にたどり着く経路数
    for j in range(i):
        # 最初にぶつかる壁がjで、iの壁に到達する経路数を求めていく
        res += dp[j] * nck(wall[i][0] - wall[j][0] + wall[i][1] - wall[j][1], wall[i][0] - wall[j][0])
        res %= mod
        
    # dp[i] = (i番目の壁までの経路数) - (i-1までの壁を一回以上通って、i回目の壁にたどり着く経路数)
    dp[i] = nck(wall[i][0] - 1 + wall[i][1] - 1, wall[i][0] - 1) - res
    dp[i] %= mod

# 余事象 ((h, w)までに少なくとも1つの壁にぶつかる経路数を数える)
ans = 0
for i in range(n):
    # 最初にぶつかる壁がiで、(h, w)に到達する経路数
    ans += dp[i] * nck(h - wall[i][0] + w - wall[i][1], h - wall[i][0])
    ans %= mod

print((nck(h-1 + w-1, h-1) - ans) % mod)

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

const string YES = "Yes";
const string NO = "No";

auto solve(long long N, long long M, std::vector<std::string> A, std::vector<std::string> B){
    for(int i = 0; i < (N - M + 1); ++i) {
        for(int j = 0; j < (N - M + 1); ++j) {
            bool match = true;
            for(int k = 0; k < M; ++k ){
                for(int l = 0; l < M; ++l ){
                    match &= (A[i+k][j+l] == B[k][l]);
                }
            }

            if(match) {
                return YES;
            }
        }
    }
    return NO;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<std::string> A(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> A[i];
    }
    std::vector<std::string> B(M);
    for(int i = 0 ; i < M ; i++){
        std::cin >> B[i];
    }
    auto result = solve(N, M, std::move(A), std::move(B));
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> V;

#define _ cin.tie(0);ios::sync_with_stdio(false);
int sx,sy,tx,ty;
int main(){ _;
  cin>>sx>>sy>>tx>>ty;
  tx-=sx;
  ty-=sy;
  sx=sy=0;
  REP(i,tx) cout<<"R";
  REP(i,ty) cout<<"U";
  REP(i,tx) cout<<"L";
  REP(i,ty+1) cout<<"D";
  REP(i,tx+1) cout<<"R";
  REP(i,ty+1) cout<<"U";
  cout<<"LU";
  REP(i,tx+1) cout<<"L";
  REP(i,ty+1) cout<<"D";
  cout<<"R"<<endl;
  
  

  return 0;
}


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

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

int main(){
    int na,nb,nm;
    int a[100000];
    int b[100000];
    cin>>na>>nb>>nm;
    int amin=100000000,bmin=100000000;
    for(int i=0;i<na;i++){
        cin>>a[i];
        amin=min(amin,a[i]);
    }
    for(int i=0;i<nb;i++){
        cin>>b[i];
        bmin=min(bmin,b[i]);
    }
    amin+=bmin;
    
    int x,y,c;
    for(int i=0;i<nm;i++){
        cin>>x>>y>>c;
        amin=min(amin,a[x-1]+b[y-1]-c);
    }
    cout<<amin<<endl;
    return 0;
}

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

int main() {
  string S;cin>>S;
  vector<bool> A(26,false);
  bool isyes=true;
  int l=S.size();
  for(int i=0;i<l;i++){
    if(!A.at(S.at(i)-'a')) A.at(S.at(i)-'a')=true;
    else isyes=false;
  }
  cout<<(isyes?"yes":"no")<<endl;
}
    

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


int main()
{
	int n; cin >> n;
	int ans = 0, sum = 0;
	for (int i = 0; i < n; ++i)
	{
		int a; cin >> a;
		ans += sum * a;
		sum += a;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3624
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    a, b, c = (int(_) for _ in input().split())
    if c >= a and c <= b:
        print('Yes')
    else:
        print('No')
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const ll N=1e9,INF=~0u>>2;
ll n,ans,i,len,l,r,mid;
string rep;
int main(){
//	freopen("ex.in","r",stdin);
	cout<<"? 10000000000"<<endl;
	cin>>rep;
	if(rep=="Y"){
		ans=2;
		while(1){
			cout<<"? "<<ans<<endl;
			cin>>rep;
			if(rep=="Y"){
				cout<<"! "<<ans/2<<endl;
				return 0;
			}
			ans*=10;
		}
	}
	r=10;
	while(1){
		cout<<"? "<<r<<endl;
		cin>>rep;
		if(rep=="N") break;
		r*=10;
	}
	l=r/10;
	r--;l--;
	while(r-l>1){
		mid=(l+r)>>1;
		cout<<"? "<<mid<<"0"<<endl;
		cin>>rep;
		if(rep=="Y") r=mid;
		else l=mid;
	}
	cout<<"! "<<r<<endl;
	return 0;
}

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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

void solve(long long N, std::vector<long long> A) {
    map<long long, int> C;
    rep (i, N) C[A[i]]++;
    set<long long> S(A.begin(), A.end());
    vector<long long> B(S.begin(), S.end());

    N = B.size();
    if (N == 1) {
        cout << B[0] << endl;
    } else {
        long long ans = 0;
        rep(i, N) ans = __gcd(ans, B[i]);
        rep(i, N) {
            if (C[B[i]] != 1) continue;
            long long tmp = B[i == 0];
            rep(j, N) {
                if (i == j) continue;
                tmp = __gcd(tmp, B[j]);
                // if (tmp < ans) break;
            }
            ans = max(ans, tmp);
        }
        assert(ans);
        cout << ans << endl;
    }
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 3964
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[4801];
		int[] flag= {0,0,0,0,0,0,0,0,0};
		int cnt=0;
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
			if(3200<=a[i]) {
				flag[8]++;
				continue;
			}
			else if(2800<=a[i]) {
				flag[7]=1;
				continue;
			}
			else if(2400<=a[i]) {
				flag[6]=1;
				continue;
			}
			else if(2000<=a[i]) {
				flag[5]=1;
				continue;
			}
			else if(1600<=a[i]) {
				flag[4]=1;
				continue;
			}
			else if(1200<=a[i]) {
				flag[3]=1;
				continue;
			}
			else if(800<=a[i]) {
				flag[2]=1;
				continue;
			}
			else if(400<=a[i]) {
				flag[1]=1;
				continue;
				
			}
			else if(1<=a[i]) {
				flag[0]=1;
				continue;
			}
		}
		for(int i=0;i<8;i++) {
			if(flag[i]==1)	cnt++;
		}
		
		if(flag[8] == 0)	System.out.println(cnt+" "+cnt);	
		else if(cnt==0) {
			if(flag[8]+cnt <=8)	System.out.println(1 +" "+(cnt+flag[8]));
			else		System.out.println(1 + " " + 8);
		}
		else {
			System.out.println(cnt+" "+(cnt+flag[8]));
		}
		
	}

}

Measured memory_bytes: 22868
#include<stdio.h>
int main()
{
	int a;
	while(scanf("%d",&a)!=EOF)
	{
		char arr[a];
		scanf("%s",arr);
		int counta=0,countb=0;
		for(int i=0;i<a;i++)
		{
			if(arr[i]=='R') counta++;
			else            countb++;
		}
		if(counta>countb) printf("Yes");
		else              printf("No");
	}
	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	int ans=100'000;
	for(int i=0;i<n;++i){
		ans=ans*21/20;
		ans=(ans+999)/1000*1000;
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3136
use std::io::stdin;
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let mut iterator = buf.trim().split_whitespace();
    let n: i64 = iterator.next().unwrap().parse().unwrap();
    let k: i64 = iterator.next().unwrap().parse().unwrap();
    println!("{}", solve(n, k));
}

fn solve(n: i64, k:i64) -> i64{
    let quotient = n % k;
    min(quotient, k - quotient)
}

Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define int long long
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcount
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
        factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int n, k;
int arr[101];
int dp[100001][2];
bool fun(int st, bool turn){
    //cout << st << endl;
    if(dp[st][turn] != -1){
        return dp[st][turn];
    }
    bool rv = turn;
    for(int i=0;n>i;i++){
        if(st - arr[i] >= 0){
            bool temp = fun(st - arr[i], !turn);
            if(temp != turn){
                rv = !turn;
                break;
            }
        }
    }
    dp[st][turn] = rv;
    return rv;
}
signed main(){
    memset(dp, -1, sizeof(dp));
    cin >> n >> k;
    for(int i=0; n>i; i++){
        cin >> arr[i];
    }
    sort(arr, arr+n);
    if(!fun(k, true)){
        cout << "First\n";
    }else{
        cout << "Second\n";
    }
}










Measured memory_bytes: 9600
from collections import deque

d = [(1, 0), (-1, 0), (0, 1), (0, -1)]
d_ = [-2, -1, 0, 1, 2]

h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
s = [input() for i in range(h)]
INF = 10 ** 6

ch, cw = ch - 1, cw - 1
dh, dw = dh - 1, dw - 1
used = [[INF] * w for i in range(h)]

used[ch][cw] = 0
val = 0
q = deque([(ch, cw, val)])
while q:
    i, j, val = q.popleft()
    if val > used[i][j]:
        continue
    val = used[i][j]

    for di, dj in d:
        nx_i, nx_j = i + di, j + dj
        if not(0 <= nx_i < h and 0 <= nx_j < w):
            continue
        elif s[nx_i][nx_j] == "#":
            continue
        elif used[nx_i][nx_j] > val:
                used[nx_i][nx_j] = val
                q.appendleft((nx_i, nx_j, val))

    for di in d_:
        for dj in d_:
            nx_i, nx_j = i + di, j + dj
            if not(0 <= nx_i < h and 0 <= nx_j < w):
                continue
            elif s[nx_i][nx_j] == "#":
                continue
            elif used[nx_i][nx_j] > val + 1:
                used[nx_i][nx_j] = val + 1
                q.append((nx_i, nx_j, val + 1))

if used[dh][dw] == INF:
    print(-1)
else:
    print(used[dh][dw])


Measured memory_bytes: 97336
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

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

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
ll mod=1e9+7;
#define PI acos(-1)
struct edge{int from, to;};
int dp[100000]={};
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> p(m);
    vector<string> S(m);
    rep(i,m) cin>>p.at(i)>>S.at(i);

    int pena=0;
    int ok=0;
    for(int i=0;i<m;i++){
        int Q=p[i];
        if(S[i]=="WA"&&dp[Q]==0) pena++;
        else if(S[i]=="AC"&&dp[Q]==0) {
            ok++;
            dp[Q]=1;
        }
    }
    for(int i=0;i<m;i++){
        if(dp[p[i]]!=1){
            pena--;
        }
    }
    cout<<ok<<" "<<pena<<endl;

    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

void solve() {
    int n;
    cin >> n;

    vector<tuple<int, int, int>> klr(n);
    rep(i, n) {
        int k, l, r;
        cin >> k >> l >> r;
        klr[i] = make_tuple(k, l, r);
    }
    sort(klr.begin(), klr.end());
    vector<tuple<int, int, int>> left, right;
    ll sum = 0;
    rep(i, n) {
        int k, l, r;
        tie(k, l, r) = klr[i];
        sum += min(l, r);
        if (l >= r) {
            left.push_back(klr[i]);
        } else {
            if (n-k == 0) continue;
            right.push_back(make_tuple(n-k, r, l));
        }
    }
    reverse(right.begin(), right.end());
    rep(_, 2) {
        priority_queue<int, vector<int>, greater<int>> pq;
        int now = 0;
        for (int i = 1; i <= n; ++i) {
            while (now < left.size()) {
                int k, l, r;
                tie(k, l, r) = left[now];
                if (k == i) {
                    pq.push(l - r);
                    sum += l - r;
                    now++;
                } else break;
            }
            while (pq.size() > i) {
                sum -= pq.top();
                pq.pop();
            }
        }
        swap(left, right);
    }
    cout << sum << endl;
}

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

    int t;
    cin >> t;
    while (t--) solve();
}


Measured memory_bytes: 8908
#include<iostream>
using namespace std;
double p[100100];
int main(void){
    int n,tgt,i;
    cin>>n>>tgt;
    for(i=0;i<100100;i++){
        p[i]=0.0;
    }

    double p_temp;
    int score;
    for(i=1;i<=n;i++){
        if(i!=1 && p[i]!=0.0){
            continue;
        }
        p_temp=1/(double)n;
        score=i;
        while(1){
            if(score>=tgt){
                break;
            }
            score*=2;
            p_temp*=0.5;
        }
        for(int j=i;j<=n;j*=2){
            p[j]=p_temp;
            p_temp*=2;
            if(p_temp>1/(double)n){
                p_temp=1/(double)n;
            }
        }
    }
    double ans=0.0;
    for(i=1;i<=n;i++){
        ans+=p[i];
    }
    printf("%.13lf\n",ans);
    return 0;
}

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1 << 30;

int main() {
  int N, M;
  std::cin >> N >> M;

  std::vector<int> a(M);
  std::vector<int> cs(M, 0);
  rep(i, M) {
    int b;
    std::cin >> a[i] >> b;
    rep(j, b) {
      int tmp;
      std::cin >> tmp;
      cs[i] |= 1 << (tmp - 1);
    }
  }

  const int TARGET = (1 << N) - 1;
  std::vector<int> dp(TARGET + 1, INF);
  dp[0] = 0;

  for(int s = 0; s < TARGET; ++s) {
    for(int i = 0; i < M; ++i) {
      int new_s = s | cs[i];
      dp[new_s] = std::min(dp[new_s], dp[s] + a[i]);
    }
  }

  if(dp[TARGET] < INF) {
    std::cout << dp[TARGET] << '\n';
    return 0;
  }
  std::cout << -1 << '\n';
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
from decimal import Decimal
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = sorted(inpl())
print(a[n//2] - a[n//2-1])

Measured memory_bytes: 78080
#include<bits/stdc++.h>
using namespace std;
set<int> x;
int n;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        x.insert(a);
    }
    cout<<((x.size()%2)?x.size():x.size()-1)<<endl;
    return 0;
}

Measured memory_bytes: 4992
fun main(args : Array<String>) {
    val (N, M) = readLine()!!.split(" ").map { it.toInt() }
    val X = readLine()!!.split(" ").map { it.toLong() }.toLongArray()
    X.sort()
    if ( M == 1) {
        println(0)
        return
    }



    val diffs = LongArray(M -1)
    for (i in 0 until M - 1) {
        diffs[i] = X[i+1] - X[i]
    }
    diffs.sortDescending()

    var sum = diffs.sum()
    for (i in 0 until Math.min((N - 1), M - 1)) {
        sum -= diffs[i]
    }

    println(sum)
}

Measured memory_bytes: 54052
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;

int main() {
    string S, T;
    cin >> S >> T;

    if(T.substr(0,S.length()) == S) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3596
//A - Libra
#include <iostream>
using namespace std;

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;

  if((A+B) > (C+D)){
    cout<<"Left"<<endl;
  }
  else if((A+B) < (C+D)){
    cout<<"Right"<<endl;
  }
  else{
    cout<<"Balanced"<<endl;
  }

  return 0;
}


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

int main() {
int N,X;
cin>>N;
  string Ans="APPROVED";
rep(i,N){cin>>X;if(X%2==0){if((X%3)*(X%5)!=0){Ans="DENIED";break;}}}
  cout<<Ans<<endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> H(N);
  for(int i=0;i<N;i++)
    cin >> H[i];

  int ans = 0;
  int tmp = 0;
  for(int i=0;i<N-1;i++)
     {
      if( H[i]>=H[i+1] )
	tmp++;
      else
	tmp = 0;
      ans = max(tmp, ans);
    }
  cout << ans << endl;
}


Measured memory_bytes: 640
N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
sum_a_list = [a[0]]
for i in range(1,N):
    sum_a_list.append(sum_a_list[i-1]+a[i])
if sum(a) < x:
    print(N-1)
elif sum(a) == x:
    print(N)
else:
    for i in range(N):
        if sum_a_list[i] > x:
            print(i)
            break

Measured memory_bytes: 3064
def resolve():
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    A = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    result = 0
    while len(A) > 1:
        flag = False
        for i in range(1, len(A)):
            if A[0] == A[i]:
                continue
            elif A[0] < A[i]:
                j = i
                while A[j-1] <= A[j]:
                    j += 1
                    if j == len(A):
                        A = []
                        result += 1
                        flag = True
                        break
                else:
                    del A[:j]
                    result += 1
                    flag = True
            elif A[0] > A[i]:
                j = i
                while A[j-1] >= A[j]:
                    j += 1
                    if j == len(A):
                        A = []
                        result += 1
                        flag = True
                        break
                else:
                    del A[:j]
                    result += 1
                    flag = True
            if flag == True:
                break
    else:
        if len(A) == 1:
            result += 1
    print(result)

resolve()

Measured memory_bytes: 62704
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=2019;llfor;///////////////////////////////////////////////////////////
int main(){
 ll l,r;sc(l);sc(r);
 if((r-l+1>=2019)||(l<=2019&&2019<=r)||l==0){
  puts("0");return 0;
 }
 rep(i,l,r+1){
  rep(j,i+1,r+1){
    ll a=(i*j)%2019;
    ans=min(ans,a);
  }
 }
  
 pr(ans);
  
return 0;}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(int i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(int i=(a);i<(n);i++)cout<<(arr)[i]<<' ';

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}

int main(){
	fast;
	ll x;
	cin>>x;
	ll z = 0;
	forn(i, 1, x+1){
		z+=i;
		if(z>=x){
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3620
import java.util.Scanner;

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

    //input
    int numOfLamps = sc.nextInt();
    int numOfReps = sc.nextInt();
    int[] brightnessArray = new int[numOfLamps];
    for(int i = 0; i < brightnessArray.length; i++){
      brightnessArray[i] = sc.nextInt();
    }

    //output
    int realReps = numOfReps;
    //(int)(Math.log(numOfLamps)/Math.log(2))*5
    if( numOfReps > 41 ){
      realReps = 41;
    }

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

      int[] cumulativeSumArray = new int[numOfLamps];
      for(int j = 0; j < brightnessArray.length; j++){

        int leftNum = j-brightnessArray[j];
        if( j-brightnessArray[j] < 0 ){
          leftNum = 0;
        }
        int rightNum = j+brightnessArray[j];
        if( j+brightnessArray[j] > numOfLamps ){ //if beyond the end, right side set to end
          rightNum = numOfLamps;
        }

        //upon taking the cumulative sum, code below would add 1 to all in range
        cumulativeSumArray[leftNum]++;
        if( rightNum+1 < numOfLamps ){ //if not beyond the end
          cumulativeSumArray[rightNum+1]--;
        }

      }
      //take cumulative sum
      for(int m = 1; m < cumulativeSumArray.length; m++){
        cumulativeSumArray[m] += cumulativeSumArray[m-1];
      }

      //if there is no difference, break
      if( cumulativeSumArray.equals(brightnessArray) ){
        break;
      }else{ //if there is a difference, continue
        brightnessArray = cumulativeSumArray;
      }

    }
    //print out numbers
    for(int i = 0; i < brightnessArray.length; i++){
      System.out.print(brightnessArray[i]+" ");
    }

  }
}


Measured memory_bytes: 53860
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int score(int idx, int action, char arr[], const int r, const int s, const int p) {
    if (arr[idx] == 'r' && action == 2) {
        return p;
    }
    if (arr[idx] == 's' && action == 0) {
        return r;
    }
    if (arr[idx] == 'p' && action == 1) {
        return s;
    }
    return 0;
}

int dp(int t, int action, vector<vector<int>>& rcd, const int n, const int k, char arr[], const int r, const int s, const int p) {
    if (t >= n) {
        return 0;
    } else if (rcd[t][action] != -1) {
        return rcd[t][action];
    } else {
        int maxv = 0;
        for (int j = 0; j < 3; j++) {
            if (j == action) {
                continue;
            }
            maxv = max(maxv, dp(t + k, j, rcd, n, k, arr, r, s, p) + score(t, j, arr, r, s, p));
        }
        return rcd[t][action] = maxv;
    }
}

int main() {
    int n, k;
    scanf("%d %d", &n, &k);

    int r, s, p;
    scanf("%d %d %d", &r, &s, &p);

    char arr[100010];
    scanf("%s", arr);

    // 0 is R, 1 is S, 2 is P
    int res = 0;
    vector<vector<int>> rcd = vector<vector<int>>(n, vector<int>(3, -1));
    for (int i = 0; i < k; i++) {
        int maxv = 0;
        for (int j = 0; j < 3; j++) {
            maxv = max(maxv, dp(i + k, j, rcd, n, k, arr, r, s, p) + score(i, j, arr, r, s, p));
        }
        res += maxv;
    }
    printf("%d\n", res);
}

Measured memory_bytes: 16640
#include <stdio.h>
#include <string.h>
 
  int i,j,k,l,m;
  int n,e,s,w,un,up;
  int a[7];
int t;
 
void input() {
 for(i=0;i<6;i++){ 
    scanf("%d",&a[i+1]); 
  }
}
 
 void N() {
   t = a[1];
   a[1] = a[2];
   a[2] = a[6];
   a[6] = a[5];
   a[5] = t;
 }
 
 void S() {
   t = a[1];
   a[1] = a[5];
   a[5] = a[6];
   a[6] = a[2];
   a[2] = t;
}
 
 void E() {
   t = a[1];
   a[1] = a[4];
   a[4] = a[6];
   a[6] = a[3];
   a[3] = t;
 }
 
 void W() {
   t = a[1];
   a[1] = a[3];
   a[3] = a[6];
   a[6] = a[4];
   a[4] = t;
 }
 
int main() {
 
  input();
 char str[110];  
 scanf("%s",str);
 
 for(i=0;i<strlen(str);i++) {
 
   if(str[i] == 'N') {
     N();
   } else if(str[i] == 'S') {
     S();
   } else if(str[i] == 'W') {
     W();
   } else if(str[i] == 'E') {
     E();
   }
 }
 printf("%d\n",a[1]);
 
 return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main() {
    IO;
    char s;
    cin>>s;
    if(islower(s))
        cout<<"a"<<endl;
    else
        cout<<"A"<<endl;
    return 0;

}




Measured memory_bytes: 3664