akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

#define REP(i,n) for(int i=0; i< int(n); (i)++)
int all(int *,int );
int odd(int *);
int main()
{
    int n, sum_all=1, sum_odd=1, a[101]={0};
    cin >> n;
    REP(i,n)
    {
        cin >> a[i];
    }
    
    REP(i,n)
    {
        sum_odd *= odd(&a[i]);
    }
    
    REP(i,n)
    {
        /*if(a[i]==1 || a[i]==100)
        {
            sum_all *= 2;
        }
        else
        {*/
            sum_all *= 3;
        /*}*/
    }
    
    cout << sum_all - sum_odd << endl;
    return 0;
}
int odd(int *a)
{
    if(*a%2==0 /*|| *a==1*/)
    {
        return 2;
    }
    else
    {
        return 1;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void fun(long long x) {
  
  
  for (long long i = 0; i < 100; i++) {
    for (long long j = 0; j < 100; j++) {
      if (i * i * i * i * i + j * j * j * j * j == x) {
        cout << i << " " << -j << endl;
        return;
      }
    }
  }
  
  for (long long i = 0; i < 1001; i++) {
    for (long long j = 0; j < i; j++) {
      if (i * i * i * i * i - j * j * j * j * j == x) {
          cout << i << " " << j << endl;
        return;
      }
    }
  }
}
  



int main() {
  long long x;
  cin >> x;
  fun(x);
}
  

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

int n, k, c;
string s;
int main() {
	cin >> n >> k >> s;
	for(int i=1; i<n; i++) if(s[i]==s[i-1]) c++;
	cout << min(n-1, 2*k+c);
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}



int main2() {
  ll W, H, x, y;
  cin >> W >> H >> x >> y;
  bool center = (x * 2 == W) && (y * 2 == H);
  cout << (W * H / 2.0) << " " << (center ? 1 : 0) << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 256
n = int(input())
d = list(map(int,input().split()))
sort_d = sorted(d)
#print(sort_d)
tmp = n//2
#print(sort_d[tmp],sort_d[tmp-1])
if sort_d[tmp-1]==sort_d[tmp]:
    print(0)
else:
    print(sort_d[tmp]-sort_d[tmp-1])

Measured memory_bytes: 20588
N, K = list(map(int, input().split(' ')))
# Memo:
#     sum of k numbers from 0 ~ N
#     -> min: k(k-1)/2
#        max: min + k(N-k+1)
#     -> num of sum patterns: k(N-k+1)+1
#     sum up values above from k=K to k=N+1
val = (N * (N+1) * (N+2) - K * (K - 1) * (3 * N - 2 * K + 4)) // 6 + N + 2 - K
print(val % (10**9 + 7))

Measured memory_bytes: 9036
n=int(input())
ans=n
tmp=0
for i in range(n+1):
    t=i
    while t>0:
        tmp+=t%9
        t//=9
    t=n-i
    while t>0:
        tmp+=t%6
        t//=6
    if ans>tmp:
        ans=tmp
    tmp=0
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

	ll H, W, N;
	cin >> H >> W >> N;

	if(N == 0) {
		cout << (H - 2) * (W - 2) << endl;
		rep(j, 0, 9) cout << 0 << endl;
		return 0;
	}
	map<P, ll> m;
	rep(i, 0, N) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		rep(k, 0, 3) rep(l, 0, 3) {
			if(0 <= a - k and a - k < H - 2 and 0 <= b - l and b - l < W - 2) {
				m[make_pair(a - k, b - l)]++;
			}
		}
	}

	ll tmp = 0;
	ll res[9];
	memset(res, 0, sizeof(res));
	for(map<P, ll>::iterator itr = m.begin(); itr != m.end(); itr++) {
		res[itr->second - 1]++;
	}

	rep(i, 0, 9) tmp += res[i];
	cout << (H - 2) * (W - 2) - tmp << endl;
	rep(i, 0, 9) cout << res[i] << endl;
	
}


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


public class A
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int A = GetInt();
		int B = GetInt();
		Console.WriteLine(Math.Max(0, A - 2 * B));
	}
}


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() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int n;
  cin>>n;
  long long int m=n;
  int dip=0,lo;
  while(m){
    lo=m%10;
    dip+=lo;
    m/=10;
  }
  if(n%dip==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
/* HARDWORK IS THE KEY TO SUCCESS.
       RATING IS TEMPORARY , KNOWLEDGE IS PERMANENT.!!!*/
    #include <bits/stdc++.h>
    #define pragma
    using namespace std;
    #define ll long long
    #define ld long double
    #define T ll t = 1; cin>>t; while(t--)
    #define vin ll n; cin>>n; vector<ll>x(n); for(ll i=0; i<n; i++) cin>>x[i]
    #define vout for(ll i=0; i<n; i++) cout<<x[i]<<" "
    #define ain ll n,k,i; cin>>n; ll a[n]; for( i=0; i<n; i++) cin>>a[i]
    #define aout for(ll i=0; i<n; i++) cout<<a[i]<<" "
    #define matin ll m,n; cin >> n >> m; ll a[n + 1][m + 1] ; for(ll i=1;i<=n;i++) for(ll j=1;j<=m;j++) cin>>a[i][j];
    #define matout for(ll i=0;i<m;i++){for(ll j=0;j<n;j++) cout<<a[i][j]<<" "; cout<<"\n";}
    #define sin set<ll>s; ll n; cin>>n; ll tmp; for(ll i=0;i<n;i++){cin>>tmp; s.I(tmp);}
    #define sout for(auto it=s.begin();it!=s.end();++it) cout<<*it<<" "
    #define F first
    #define S second
    #define I insert
    #define pb push_back
    #define ppb pop_back
    #define AISORT sort(a,a+n)
    #define ADSORT sort(a,a+n,greater<ll>())
    #define VISORT sort(x.begin(),x.end())
    #define VDSORT sort(x.begin(),x.end(),greater<ll>())

    const ll maxs = 1e5+3;
    const ll maxs1 = 1e3+4;
    const ll mod = 1e9 + 7;

    //MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

    //POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

    //MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}

//     ll n;
//     ll a[maxs];
//     ll tree[maxs];
    bool vis[maxs];
    vector<ll>graph[maxs];
    //ALWAYS CLEAR THEM WHEN TESTCASES ARE GIVEN
    //ALWAYS RETURN WHEN ST == ED CONDITION IN SEGMENT TREES


    int main()
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        ld s;
        cin >> s;
        ld l = (s) / (ld)(3);
        s -= l;
        ld b = s / (ld)(2);
        ld h = s - b;
        ld ans = (l) * (b) * (h);
        cout << fixed << setprecision(12) << ans;
        
    }


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n; cin >> n;
    map<string,ll> mp;
    rep(i,n){
        string s; cin >> s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    ll ans = 0;
    for (auto a:mp){
        ans += (ll) (a.second*(a.second-1)/2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 11136
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
const int inf = 1000000000; //10^9
using ll = long long;
using P = pair<int, int>;
//加算代入演算子は+=！！！！！
int n, k, num, ans;
vector<bool> flag(10, false);
bool check(int n)
{
    while (n > 0)
    {
        if (flag.at(n % 10) == true)
        {
            return false;
        }
        else
        {
            n /= 10;
        }
    }
    return true;
}
int main()
{
    cin >> n >> k;
    rep(i, k)
    {
        cin >> num;
        flag.at(num) = true;
    }
    for (int i = n; i < 100000; i++) {
        if (check(i) == true)
        {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
        import java.util.ArrayList;
        import java.util.Collections;
        import java.util.List;
        import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
        int int1 = Integer.parseInt(scan.next());
//        String str1 = scan.next();
//        String str2 = scan.next();
//        String str3 = scan.next();
        int ans_int = 0;
        ans_int = int1/3;

        PrintWriter out = new PrintWriter(System.out);
        out.println(ans_int);
        out.flush();
        scan.close();
    }
}


Measured memory_bytes: 21712
#include <bits/stdc++.h>
using namespace std;
#define endl '\n';

int main()
{
    int n, ac = 0, wa = 0, tle = 0, re = 0;
    cin >> n;
    string casos[n];
    for(int i = 0; i < n; i++){
        cin >> casos[i];
        if(casos[i] == "AC")
            ac++;
        if(casos[i] == "WA")
            wa++;
        if(casos[i] == "TLE")
            tle++;
        if(casos[i] == "RE")
            re++;
    }
    cout << "AC x " << ac <<endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}

Measured memory_bytes: 6736
N, K = list(map(int,input().split()))
MOD = 10**9 + 7

#取る個数が違った場合、その和は絶対同じ数にならない。
#n個とるとしたら最低値(lowest)は下(0)からn-1まで、最大値(highest)は上(N-0)からN-(n-1)までの和
#最小値から最大値は連続的にすべての値をとる。
#ただし、n=K~Nであるのでここはfor文

ans = 0
for n in range(K,N+2):
  lowest = n*(n-1) // 2
  highest = n*N - n*(n-1) // 2
  
  ans += highest - lowest + 1
  ans %= MOD
  
print(ans)

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

using namespace std;

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

  int n = 0;
  cin >> n;

  vector<int> a(n);
  for (int i=0; i<n; i++)
    cin >> a[i];

  set<int> s;
  for (int i=0; i<n; i++)
    s.insert(a[i]);

  if (s.size() == a.size())
    cout << "YES" << "\n";
  else
    cout << "NO" << "\n";

  return 0;
}



Measured memory_bytes: 10368
n=int(input())
s=input()
tmp,ans=0,0
for i in range(n+1):
    s0=[]
    for j in range(n):
        if j<i:
            t=True
            for x in s0:
                if x==s[j]:t=False
            if t:s0.append(s[j])
        else:
            for k in range(len(s0)):
                if s0[k]==s[j]:
                    tmp+=1
                    s0[k]=-1
    #print(i,tmp)
    tmp,ans=0,max(ans,tmp)
print(ans)

Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
long long all(int level) {
    if(level==0) return 1;
    return 2 * all(level-1) + 3;
}

long long pate(int level, long long X) {
    if(level==0) return 1;
    
    long long l = all(level-1);
    
    if(X==1) return 0;
    if(X<=l+1) return pate(level-1, X-1);
    if(X==l+2) return pate(level-1, l) + 1;
    if(X<=2*l+2) return pate(level-1, l) + 1 + pate(level-1, X-l-2);
    return 2*pate(level-1, l) + 1;
    
}

int main() {
    int N; long long X;
    cin >> N >> X;
    cout << pate(N, X) << endl;
}


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

using namespace std;

typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long double ld;

const int inf = 1e9;
const ll inf64 = 1e18;

int main() {

#ifdef debug
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    ll s;

    cin >> s;

    ll sq = sqrt(s);
    while (sq * sq < s) sq++;

    cout << "0 0\n";
    cout << sq << " " << sq * sq - s << "\n";
    cout << "1 " << sq << "\n";

    return 0;
}

Measured memory_bytes: 764
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

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

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
int main() {
    int N; cin >> N;
    ll ans=0LL;
    vector<ll> A(N,0);

    for(int i=0; i<N; i++){
        cin >> A[i];
    }

    A.push_back(0);

    for(int i=0; i<N; i++){
        ans+=A[i]/2;
        A[i]=A[i]%2;

        if(A[i+1]){
            ans+=A[i];
            A[i+1]-=A[i];
        }
    }

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    long long N;
    cin >> N;

    long long  a = N / 3;
    long long  b = N / 5;
    long long  c = N / 15;

    long long  sum = N * (N+1) / 2 - 3 * a * (a+1) / 2 - 5 * b * (b+1) / 2 + 15 * c * (c+1) / 2;

    cout << sum << endl;

   
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200005,M=1e9+7;
int n,f1[N][19],f2[N][19];
struct Ask1{
	int x,y;
}A[N];
struct Ask2{
	int l,r;
}B[N];
int cmp(Ask1 x,Ask1 y){
	return x.y<y.y;
}
int cmp2(Ask2 x,Ask2 y){
	return x.l<y.l;
}
void init(){
	for (int i=1;i<=n;i++)f1[i][0]=f2[i][0]=A[i].x;
	for (int j=1;j<=18;j++)
		for (int i=1;i<=n;i++)
			f1[i][j]=min(f1[i][j-1],f1[min(i+(1<<(j-1)),n)][j-1]),
			f2[i][j]=max(f2[i][j-1],f2[min(i+(1<<(j-1)),n)][j-1]);
}
int find1(int l,int r){
	int k=(int)log2(r-l+1);
	return min(f1[l][k],f1[r-(1<<k)+1][k]);
}
int find2(int l,int r){
	int k=(int)log2(r-l+1);
	return max(f2[l][k],f2[r-(1<<k)+1][k]);
}
struct Tree{
	int l,r,num,flag1,flag2;
}T[N*4];
void build(int x,int l,int r){
	T[x].l=l;T[x].r=r;T[x].flag1=1;
	if (l==r){
		T[x].num=l==0;
		return;
	}
	int mid=(l+r)/2;
	build(x*2,l,mid);
	build(x*2+1,mid+1,r);
	T[x].num=(T[x*2].num+T[x*2+1].num)%M;
}
void down(int x){
	T[x*2].num=(ll)T[x*2].num*T[x].flag1%M;
	T[x*2+1].num=(ll)T[x*2+1].num*T[x].flag1%M;
	T[x*2].flag1=(ll)T[x*2].flag1*T[x].flag1%M;
	T[x*2+1].flag1=(ll)T[x*2+1].flag1*T[x].flag1%M;
	T[x*2].flag2=(ll)T[x*2].flag2*T[x].flag1%M;
	T[x*2+1].flag2=(ll)T[x*2+1].flag2*T[x].flag1%M;
	(T[x*2].num+=(ll)T[x].flag2*(T[x*2].r-T[x*2].l+1)%M)%=M;
	(T[x*2+1].num+=(ll)T[x].flag2*(T[x*2+1].r-T[x*2+1].l+1)%M)%=M;
	(T[x*2].flag2+=T[x].flag2)%=M;
	(T[x*2+1].flag2+=T[x].flag2)%=M;
	T[x].flag2=0;T[x].flag1=1;
}
void insert1(int x,int l,int r,int z){
	if (T[x].l>r||l>T[x].r)return;
	if (T[x].l>=l&&T[x].r<=r){
		(T[x].num+=(ll)z*(T[x].r-T[x].l+1)%M)%=M;
		(T[x].flag2+=z)%=M;
		return;
	}
	down(x);
	insert1(x*2,l,r,z);
	insert1(x*2+1,l,r,z);
	T[x].num=(T[x*2].num+T[x*2+1].num)%M;
}
void insert2(int x,int l,int r){
	if (T[x].l>r||l>T[x].r)return;
	if (T[x].l>=l&&T[x].r<=r){
		(T[x].num*=2)%=M;
		(T[x].flag2*=2)%=M;
		(T[x].flag1*=2)%=M;
		return;
	}
	down(x);
	insert2(x*2,l,r);
	insert2(x*2+1,l,r);
	T[x].num=(T[x*2].num+T[x*2+1].num)%M;
}
int find(int x,int l,int r){
	if (T[x].l>r||l>T[x].r)return 0;
	if (T[x].l>=l&&T[x].r<=r)return T[x].num;
	down(x);
	return (find(x*2,l,r)+find(x*2+1,l,r))%M;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)scanf("%d%d",&A[i].x,&A[i].y);
	sort(A+1,A+n+1,cmp);
	init();
	for (int i=1;i<=n;i++){
		int l=1,r=i;
		while (l<r){
			int mid=(l+r)/2;
			if (find2(l,mid)>A[i].x)r=mid;
			else l=mid+1;
		}
		B[i].l=l;
		l=i,r=n;
		while (l<r){
			int mid=(l+r)/2;
			if (find1(mid+1,r)<A[i].x)l=mid+1;
			else r=mid;
		}
		B[i].r=l;
	}
	sort(B+1,B+n+1,cmp2);
	build(1,0,n);
	for (int i=1;i<=n;i++){
		insert2(1,B[i].r+1,n);
		insert1(1,B[i].r,B[i].r,find(1,B[i].l-1,B[i].r));
	}
	printf("%d\n",find(1,n,n));
}


Measured memory_bytes: 46720
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

char maze[101][101];
int dp[101][101];
const int INF = 1 << 30;
int main(){
  int h,w;
  cin >> h >> w;
  rep(i,h) rep(j,w) cin >> maze[i][j];
  rep(i,h) rep(j,w) dp[i][j]=INF;
  int ans=0;
  if (maze[0][0]=='#') dp[0][0]=1;
  else dp[0][0]=0;
  rep(i,h) rep(j,w){
    if (maze[i][j]=='.'){
      if (maze[i+1][j]=='#') dp[i+1][j]=min(dp[i][j]+1,dp[i+1][j]);
      else dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
      if (maze[i][j+1]=='#') dp[i][j+1]=min(dp[i][j+1],dp[i][j]+1);
      else dp[i][j+1]=min(dp[i][j+1],dp[i][j]);
    }
    else {
      if (maze[i+1][j]=='#') dp[i+1][j]=min(dp[i][j],dp[i+1][j]);
      else dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
      if (maze[i][j+1]=='#') dp[i][j+1]=min(dp[i][j+1],dp[i][j]);
      else dp[i][j+1]=min(dp[i][j],dp[i][j+1]);
    }
  }
  //rep(i,h) {
  //rep(j,w) { 
  //  if (dp[i][j] == INF ) cout << "F";
  //  else cout << dp[i][j];
  //  }
  //printf("\n");
  //}
  cout << dp[h-1][w-1] << endl;

  return 0; 
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for(int i = a; i <= b; i++){
        int c = i/10000;
        int d = (i%10000)/1000;
        int e = (i%1000)/100;
        int f = (i%100)/10;
        int g = i%10;
        if(c == g && d == f){
            ans++;
            //cout << i << endl;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  vi A(N),B(N);
  rep(i,0,N) cin>>A[i];
  rep(i,0,N) cin>>B[i];
  vi C(N),D(N);
  C[0]=A[0];
  D[0]=A[0];
  rep(i,1,N){
    if(A[i-1]<A[i]){
      C[i]=A[i];
      D[i]=A[i];
    }
    else{
      D[i]=A[i];
      C[i]=1;
    }
  }
  vi E(N),F(N);
  E[N-1]=B[N-1];
  F[N-1]=B[N-1];
  REP(i,2,N){
    int j=N-i;
    if(B[j]>B[j+1]){
      E[j]=B[j];
      F[j]=B[j];
    }
    else{
      F[j]=B[j];
      E[j]=1;
    }
  }
  int ans=1;
  rep(i,0,N){
    if(D[i]<E[i]||F[i]<C[i]){
      ans=0;
      break;
    }
    ans*=min(D[i],F[i])-max(C[i],E[i])+1;
    ans%=MOD;
  }
  cout<<ans<<endl;
  }



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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  map<int, int> nums;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A[i] = a;
    if (!nums.count(a)) {
      nums[a] = 1;
    }
    else {
      nums[a]++;
    }
  }
  ll pairs = 0;
  for (auto p : nums) {
    ll v = p.second;
    pairs += v*(v-1)/2;
  }
  for (int i = 0; i < N; i++) {
    cout << pairs - (nums[A[i]] - 1) << endl;
  }
}

  

Measured memory_bytes: 8448
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
int n,ans,a,b; 
int main(){
	ans=0;
	cin>>n;
	a=n;
	while(a){
		ans+=a%10;a/=10;
	}
	if(ans==1)ans=10;
	cout<<ans;
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LiangJiaJun main
#define INF 1999122700
using namespace std;
int n,k;
int v[10004];
multiset<int>tr;
multiset<int>::iterator it;
int calc(int l,int r){
    tr.clear();
    int now=0;
    for(int i=1;i<=l;i++){
        tr.insert(v[i]);
        now+=v[i];
    }
    for(int i=n;i>=n-r+1;i--){
        tr.insert(v[i]);
        now+=v[i];
    }
    int res=k-l-r;
    while(res>0&&tr.size()>0&&(*tr.begin())<0){
        it=tr.begin();
        now-=(*it);
        tr.erase(it);
        res--;
    }
    return now;
}
int LiangJiaJun(){
    int ans=0;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)scanf("%d",&v[i]);
    for(int i=0;i<=min(k,n);i++){
        for(int j=0;i+j<=min(k,n);j++){
            ans=max(ans,calc(i,j));
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
ss = list(map(int, input().split()))

ans = 0
for C in range(1, N):
    score = 0
    for k in range(1, (N-1)//C+1):
        if (N-1)%C == 0 and k*C >= N-1-k*C: break
        if N-1-k*C <= C: break
        score += ss[k*C] + ss[N-1-k*C]
        ans = max(ans, score)

print(ans)


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

int main()
{
  int N, M;
  cin>>N>>M;
  vector<int> v;
  for(int i=0; i<N; i++)  v.push_back(i);

  vector<vector<bool>> graph(N, vector<bool>(N, false));
  for(int i=0; i<M; i++){
    int a, b;
    cin>>a>>b;
    graph[a-1][b-1]=true;  graph[b-1][a-1]=true;
  }

  int cnt = 0;
  do{
    bool check = true;
    for(int i=0; i<N; i++){
      if(v[0]!=0)  check = false;
      if(i<N-1){
        if(!graph[v[i]][v[i+1]])  check = false;
      }
    }
    if(check)  cnt++;
  }while(next_permutation(v.begin(), v.end()));

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


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
bool col[502][502];

inline int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}

int main()
{
	int n=read(), m=read();
	for (int i=1; i<=n; i++)
	{
		for (int j=1; j<=m; j++)
			{char ch=getchar(); col[i][j]=(ch=='#');}
		getchar();
	}
	for (int i=1; i<=n; i++)
	{
		for (int j=1; j<=m; j++)
			if ((j!=1)&&(col[i][j] || j==m || (i&1))) printf("#"); 
				else printf(".");
		puts("");
	}
	puts("");
	for (int i=1; i<=n; i++)
	{
		for (int j=1; j<=m; j++)
			if ((j!=m)&&(col[i][j] || j==1 || !(i&1))) printf("#"); 
				else printf(".");
		puts("");
	}
	return 0;//zzr AK IOI
}


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

int main(){
    int t, n;
    while(1){
        cin >> t;
        if(!t) break;
        cin >> n;
        for(int i = 0;i < n;i++){
            int s, f;
            cin >> s >> f;
            t -= f - s;
        }
        if(t <= 0) cout << "OK" << endl;
        else cout << t << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main() {
  int n;
  cin>>n;
  
  vector<int> A(n);
  rep(i,n) cin>>A[i];
  sort(ALL(A));
  
  cout<<A[n-1]-A[0]<<endl;

  return 0;
}

Measured memory_bytes: 3632
def main():
    n,x = map(int,input().split())
    l = list(map(int,input().split()))
    loc = 0
    res = 1
    for i in range(len(l)):
        if loc + l[i] <= x:
            res += 1
            loc += l[i]
        else:
            break
    print(res)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import java.io._

object Main extends App {

  val out = new PrintWriter(System.out,true)
  val buf = StringBuilder.newBuilder
  var sb = StringBuilder.newBuilder
  var isContinue = true

  while(isContinue) {
    val cards = io.StdIn.readLine()
    if(cards != "-") {

      sb.append(cards)
      val cnt = io.StdIn.readInt()
      for(_ <- 1 to cnt) {
        val h = io.StdIn.readInt()
        buf.append(sb.substring(h)).append(sb.substring(0,h))
        sb.clear()
        sb.append(buf)
        buf.clear()
      }

      out.println(sb)
      sb.clear()
    }
    else isContinue = false
  }
  out.flush()
}



Measured memory_bytes: 43672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  ll A,B,C,X,Y; cin >> A >> B >> C >> X >> Y;
  
  ll ans = 0;
  if (A + B <= 2*C) ans = A * X + B * Y;
  else if (X >= Y) {
    if (A >= 2*C) ans = 2 * C * X;
    else ans = 2 * C * Y + A * (X-Y);
  } else {
    if (B >= 2*C) ans = 2 * C * Y;
    else ans = 2 * C * X + B * (Y-X);
  }
  
  cout << ans << endl;
  
}

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

using namespace std;

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

	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	vector<int> dp(n, INT_MAX);
	dp[0] = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j <= i + 2 && j < n; j++) {
			dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
		}
	}
	cout << dp[n - 1] << '\n';

	return 0;
}



Measured memory_bytes: 1024
import sys

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    N = int(read_func().strip().split()[0])
    input_raw = read_func().strip().split()
    
    A = [0]
    for i in range(N):
        A.append(int(input_raw[i]))
    A.append(0)

    D = {}
    cost_sum = 0
    for i in range(N + 1):
        cost = abs(A[i] - A[i + 1])
        D[(i, i+1)] = cost
        cost_sum += cost

    for i in range(1, N+1):
        print cost_sum - D[(i, i+1)] - D[(i-1, i)] + abs(A[i - 1] - A[i + 1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 35576
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main {
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int a = fs.nextInt(), b = fs.nextInt(), c = fs.nextInt();
        String ans = "NO";
        if (b - a == c - b) ans = "YES";
        System.out.println(ans);
    }
}

Measured memory_bytes: 22612
n, mw = map(int, input().split())
w = []
v = []

for i in range(n):
    ww, vv = map(int, input().split())
    w.append(ww)
    v.append(vv)

dp = [[0] * (mw + 1) for i in range(n + 1)]

for i in range(n):
    for j in range(mw + 1):
        if j < w[i]:
            dp[i + 1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])

print(dp[n][mw])


Measured memory_bytes: 120428
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int x;
    cin >> x;

    set<int> s = {x};
    for(int i=2; ; ++i){
        if(x % 2 == 0)
            x /= 2;
        else
            x = 3 * x + 1;
        if(s.find(x) != s.end()){
            cout << i << endl;
            return 0;
        }
        s.insert(x);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define F first
#define S second
signed main(){
  ll N,K,ans=-1000000000000000,i,j,k,S,x;cin>>N>>K;ll C[N],P[N],X[N+1];
  REP(i,N)cin>>P[i];REP(i,N)cin>>C[i];
  REP(j,N){
    S=j;vector<bool>W(N,0);W.at(S)=1;X[0]=0;
    REP(i,N){S=P[S];S--;X[i+1]=X[i]+C[S];if(W.at(S)){x=i+1;break;}W.at(S)=1;}
    if(X[x]>0){
      REP(i,K%x+1)ans=max(ans,K/x*X[x]+X[i]);
      FOR(i,K%x+1,x)ans=max(ans,(K/x-1)*X[x]+X[i]);
    }
    else REP(i,x)ans=max(ans,X[i+1]);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>
using namespace std;

struct position{
    double x, y;
};

struct path{
    int now;
    double distance_all;
    
    bool operator >(const path& another) const{
        return distance_all > another.distance_all;
    }
};

double point_distance(position first, position second){
    return sqrt((first.x - second.x) * (first.x - second.x) + (first.y - second.y) * (first.y - second.y));
}

int main(){
    position start, goal;
    cin >> start.x >> start.y >> goal.x >> goal.y;
    int N;
    cin >> N;
    pair<position, double> barrier[N + 2];
    for(int i = 0; i < N; i++){
        cin >> barrier[i].first.x >> barrier[i].first.y >> barrier[i].second;
    }
    barrier[N] = {start, 0};
    barrier[N + 1] = {goal, 0};
    priority_queue<path, vector<path>, greater<path>> pathes;
    double distances[N + 2];
    pathes.push({N, 0.0});
    fill(distances, distances + N + 2, 1e18);
    distances[N] = 0.0;
    while(!pathes.empty()){
        path looking = pathes.top();
        pathes.pop();
        if(looking.distance_all > distances[looking.now] + 1e-6){
            continue;
        }
        for(int i = 0; i < N + 2; i++){
            if(looking.distance_all + max(0.0, point_distance(barrier[looking.now].first, barrier[i].first) - barrier[looking.now].second - barrier[i].second) + 1e-6 < distances[i]){
                distances[i] = looking.distance_all + max(0.0, point_distance(barrier[looking.now].first, barrier[i].first) - barrier[looking.now].second - barrier[i].second);
                pathes.push({i, distances[i]});
            }
        }
    }
    cout << fixed << setprecision(10) << distances[N + 1] << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);

    rep(i,n) cin >> a.at(i);

    set<int> b;
    rep(i,n) b.insert(a.at(i));
    string ans;

    if (a.size() == b.size()) ans = "YES";
    else ans = "NO";

    cout << ans << endl;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
double dp[305][305][305], p[305][305][305];
int main(){
	cout << fixed << setprecision(10);
	ll n; cin >> n;
	vector<ll> am(4);
	for(ll i = 0; i < n; i++){
		ll a; cin >> a;
		am[a]++;
	}
	p[am[1]][am[2]][am[3]] = 1;
	for(ll c = n; c >= 0; c--) for(ll b = n; b >= 0; b--) for(ll a = n; a >= 0; a--){
		if(a == 0 && b == 0 && c == 0) continue;
		if(a + b + c > n) continue;
		dp[a][b][c] += n / double(a + b + c) * p[a][b][c];

		if(a != 0){
			p[a-1][b][c] += p[a][b][c] * a/double(a + b + c);
			dp[a-1][b][c] += dp[a][b][c] * a/double(a + b + c);
		}
		if(b != 0){
			p[a+1][b-1][c] += p[a][b][c] * b/double(a + b + c);
			dp[a+1][b-1][c] += dp[a][b][c] * b/double(a + b + c);
		}
		if(c != 0){
			p[a][b+1][c-1] += p[a][b][c] * c/double(a + b + c);
			dp[a][b+1][c-1] += dp[a][b][c] * c/double(a + b + c);
		}
	}
	cout << dp[0][0][0] << endl;
}

Measured memory_bytes: 438528
from itertools import accumulate

q, *lr = map(int, open(0).read().split())

p = [True] * 100010
p[0] = False
p[1] = False
i = 2
while i <= 100005:
    if p[i]:
        j = i * 2
        while j <= 100005:
            p[j] = False
            j += i
    i += 1

s = [0] * 100010
for i in range(3, 100005, 2):
    if p[i] and p[(i + 2) // 2]:
        s[i] += 1
s = tuple(accumulate(s))

for l, r in zip(*[iter(lr)] * 2):
    print(s[r] - s[l - 1])


Measured memory_bytes: 31704
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  ll n;
  cin >> n;
  vector <ll> a(n);
  
  REP(i,n){
      cin >> a[i];
      a[i] -= i+1;
      
  }
  sort(a.begin(),a.end());
  ll f = -1e10,t = 1e10;
  ll b = -1e9;
  ll c = b+1;
  ll sum1, sum2;
  while(1){
      ll x = (f+t)/2;
      ll y = x+1;
      sum1 = 0;
      sum2 = 0;
      REP(i,n){
          sum1 += abs(a[i]-x);
          sum2 += abs(a[i]-y);
      }
      if(sum1 < sum2){
          t = y;
      }
      else if(sum1 > sum2){
          f = x;
      }
      else{
          ll ss = 0;
          REP(i,n){
              ss += abs(a[i]-x);
          }
          cout << ss << endl;
          return 0;
      }
      //cout << f << " " << t << endl;
      if(abs(f - t) <= 5){
          break;
      }
  }
  
  ll sum = 1e18;
  for(ll i = f-15; i <= t+15;i++){
      ll ssum1 = 0;
      REP(j,n){
          ssum1 += abs(a[j]-i);
      }
      sum = min(sum,ssum1);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {		
		try (Scanner sc = new Scanner(System.in)){
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			if (a <= 8 && b <= 8) {
				System.out.println("Yay!");
			} else {
				System.out.println(":(");
			}		
		}
	}
}


Measured memory_bytes: 21204
import java.util.Scanner;

public class Main {
	public static void main (String [] args) {
		Scanner scan = new Scanner (System.in);
		double p1_x, p1_y, p2_x, p2_y, dis;
		
		p1_x = scan.nextDouble();
		p1_y = scan.nextDouble();
		p2_x = scan.nextDouble();
		p2_y = scan.nextDouble();
		
		dis = Math.pow((p2_x - p1_x), 2) + Math.pow((p2_y - p1_y), 2);
		dis = Math.sqrt(dis);
		
		System.out.println(dis);
		
		scan.close();
	}
}



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

int main() {
  int r, c;
  cin >> r >> c;
  int table[r+1][c+1] = {};
  for(int i = 0; i < r; i++){
      for(int j = 0; j < c; j++) {
          cin >> table[i][j];
      }
  }
  
  for(int i = 0; i < r; i++){
      for(int j = 0; j < c; j++) {
          table[i][c] = table[i][c] + table[i][j];
      }
  }
  
  for(int i = 0; i < c+1; i++){
      for(int j = 0; j < r; j++){
          table[r][i] = table[r][i] + table[j][i];
      }
  }
  
  for(int i = 0; i < r+1; i++) {
      for(int j = 0; j < c+1; j++){
          cout << table[i][j];
          if(j == c) {
              cout << endl;
          } else {
              cout << " ";
          }
      }
  }
  
  
}


Measured memory_bytes: 3108
int main(void)
{
  int A[100], N, i;
  
  scanf("%d", &N);
  for (i = 0; i < N; i++)
  {
    scanf("%d", &A[i]);
    if (A[i] % 2 == 0)
    {
      if (A[i] % 3 != 0 && A[i] % 5 != 0)
      {
        printf("DENIED\n");
        return 0;
      }
    }
  }
  printf("APPROVED\n");
  
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){

	int X;

	scanf("%d",&X);

	int i,j,k;

	int ans=1;

	for(i=2;i<=32;i++){
		for(j=2;j<=10;j++){
			int b_p=1;
			for(k=1;k<=j;k++){
			b_p*=i;
			}
			if(b_p<=1000 && b_p<=X && ans<b_p){
			ans=b_p;
			}
		}
	}

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

return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <utility>

const int X = 100000;

int main() {
  int n, m, x;
  int ans = 0;
  int c[X + 1] = {};
  int rc[X] = {};
  int pc[X] = {};
  std::cin >> n >> m;
  for (int ni = 0; ni < n; ++ni) {
    std::cin >> x;
    ++c[x];
    ++rc[x % m];
    if (c[x] % 2 == 0) ++pc[x % m];
  }
  for (int r = 0; r < m; ++r) {
    if (r == (m - r) % m) {
      ans += rc[r] / 2;
    } else if (r < m - r) {
      int p = std::min(rc[r], rc[m - r]);
      ans +=  p
            + std::min((rc[r] - p) / 2, pc[r])
            + std::min((rc[m - r] - p) / 2, pc[m - r]);
    }
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 2040
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;

public class Main {

	final static int SIZE = 8;
	final static int MARGIN = 3;
	final static char BOMB = '1';
	final static char BOMBED = '0';
	static Deque<int[]> bombs;
	static char[][] map;

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null) {

			int n = Integer.parseInt(line);

			br.readLine();
			for (int i = 0; i < n; ++i) {
				bombs = new ArrayDeque<int[]>();
				map = new char[SIZE + MARGIN * 2][SIZE + MARGIN * 2];

				for (int j = MARGIN; j < SIZE + MARGIN; ++j) {
					line = br.readLine();
					for (int k = MARGIN; k < SIZE + MARGIN; ++k) {
						map[j][k] = line.charAt(k - MARGIN);
					}
				}

				int x = Integer.parseInt(br.readLine());
				int y = Integer.parseInt(br.readLine());

				bombs.offer(new int[] { y + MARGIN - 1, x + MARGIN - 1 });
				map[y + MARGIN - 1][x + MARGIN - 1] = BOMBED;
				while (!bombs.isEmpty()) {
					bomb();
				}
				System.out.print(print(i + 1, map));
				br.readLine();
			}
		}
	}

	static void bomb() {

		final int[] V = { 1, -1, 0, 0 };
		final int[] H = { 0, 0, 1, -1 };

		int[] yx = bombs.poll();
		int y = yx[0];
		int x = yx[1];

		// map[y][x] = BOMBED;

		for (int i = 0; i < 4; ++i) {
			for (int j = 1; j <= 3; ++j) {
				int yv = y + V[i] * j;
				int xh = x + H[i] * j;
				if (map[yv][xh] == BOMB) {
					bombs.offer(new int[] { yv, xh });
					map[yv][xh] = BOMBED;
				}
			}
		}
	}

	static String print(int n, char[][] map) {

		StringBuilder sb = new StringBuilder();
		sb.append("Data " + n + ":\n");
		for (int i = MARGIN; i < SIZE + MARGIN; ++i) {
			sb.append(Arrays.copyOfRange(map[i], MARGIN, SIZE + MARGIN));
			sb.append("\n");
		}

		return sb.toString();
	}

}

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

using namespace std;

const int N = 1005, MOD = 1e9 + 7;
int h, w, dp[N][N];
string s[N];

inline int add(int a, int b){
	a += b;
	if(a >= MOD)a -= MOD;
	return a;
}

inline int sub(int a, int b){
	a -= b;
	if(a < 0)a += MOD;
	return a;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	cin>>h>>w;
	for(int i=1;i<=h;++i){
		cin>>s[i]; s[i] = '#' + s[i];
	}

	dp[1][1] = 1;
	for(int i=1;i<=h;++i)
		for(int j=1;j<=w;++j)if(i != 1 || j != 1){
			if(s[i][j] == '#')continue;
			dp[i][j] = add(dp[i][j - 1], dp[i -1][j]);
		}
	cout<<dp[h][w]<<"\n";
	return 0;
}

Measured memory_bytes: 5248
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	int N;
	long long x, a[100000], an = 0;
	scanf("%d%lld", &N, &x);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &a[i]);
	}
	int co = 0;
	for (int i = 0; i < N - 1; i++) {
		if (a[i] + a[i + 1] > x) {
			an += a[i + 1] + a[i] - x;
			co= a[i + 1] + a[i] - x;
			if (a[i + 1] > co) {
				a[i + 1] -= co;
			}
			else {
				a[i + 1] = 0;
			}
		}
	}
	printf("%lld", an);
	return 0;
}


Measured memory_bytes: 896
N, M, R = gets.split.map(&:to_i)
r = gets.split.map(&:to_i).map { |x| x - 1 }

# ワーシャルフロイド
MAX = 1<<30
dist = Array.new(N){Array.new(N, MAX)}
M.times do
  a, b, c = gets.split.map(&:to_i)
  dist[a-1][b-1] = dist[b-1][a-1] = c
end

N.times do |k|
  N.times do |i|
    N.times do |j|
      dist[i][j] = dist[i][k]+dist[k][j] if dist[i][j] > dist[i][k]+dist[k][j]
    end
  end
end

ans = r.permutation.map do |perm|
  perm.each_cons(2).inject(0){|sum, (x,y)| sum+dist[x][y]}
end.min
puts ans

Measured memory_bytes: 3064
// SeeAlso: 

#include <bits/stdc++.h>

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

using namespace std;

int n, x;

int l[MAX];

int main() {


    cin >> n >> x;
    rep(i, n) {
        cin >> l[i];
    }

    int ans = 0;
    int d = 0;
    rep(i, n) {
        ans++;
        d += l[i];

        if (d > x) {
            cout << ans << endl;
            return 0;
            break;
        }
    }

    ans++;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
MOD = 998244353
N = int(input())
D = list(map(int, input().split()))
N_cnt = [0] * N
for i in range(N):
    N_cnt[D[i]] += 1

if D[0] != 0 or N_cnt[0] != 1:
    print(0)
else:
    res = 1
    for i in range(1, N):
        res *= N_cnt[i - 1]**N_cnt[i]
        res %= MOD
    print(res)

Measured memory_bytes: 54452
#include <bits/stdc++.h>
#define int long long 
using namespace std;
const int inf = 1e15;
int32_t main(){
    int n;cin>>n;
    vector<int> arrmv(n,0);
    cin>>arrmv[0];
    int minele=arrmv[0];
    int ans=0;
    for(int i=1;i<n;i++){
        int t;cin>>t;
        if(t<minele)ans++;
        minele=min(minele,t);
    }
    cout<<++ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  ll a, b;
  cin >> a >> b;
  ll n = (a > 1) ? (a-1)/4 : 0;
  ll m = b/4;
  ll s = 0, t = 0;
  for(ll i = 4*n; i <= a-1; i++) s ^= i;
  for(ll i = 4*m; i <= b; i++) t ^= i;
  ll ans = s^t;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define NIL -1
 
typedef struct node{
  int p;
  int r;
  int l;
}Node;
 
Node T[25];
 
void Pre(int u){

  if(u == NIL)return;
  printf(" %d",u);
  Pre(T[u].l);
  Pre(T[u].r);
}
 
void In(int u){

  if(u == NIL)return;
  
  In(T[u].l);
  printf(" %d",u);
  In(T[u].r);
}
 
void Post(int u){
  if(u == NIL)return;
  Post(T[u].l);
  Post(T[u].r);
  printf(" %d",u);
}
 
 
 
int main(){
  int n,i;
  int v,l,r;
  int root;
 
  scanf("%d",&n);
 
 
  for(i=0;i<n;i++){
    T[i].p = NIL;
  }
 
  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL)T[l].p = v;
    if(r != NIL)T[r].p = v;
  }
 
  for (i=0;i<n;i++) {
    if (T[i].p == NIL) root = i;
  }
 
  printf("Preorder\n");
  Pre(root);
  printf("\nInorder\n");
  In(root);
  printf("\nPostorder\n");
  Post(root);
  
  printf("\n");
  return 0;
}



Measured memory_bytes: 2096
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
typedef long long ll;


ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
  int n;
  cin >> n;

  map<string, ll> s;
  vector<string> ans;
  rep(i, n){
      string str;
      cin >> str;
      s[str]++;
  }
  
  ll count = 1;
  for(auto var : s)
  {
    count = max(count, var.second);
  }
  for(auto var : s)
  {
    if (var.second != count)
    {
      /* code */
      continue;
    }
    cout << var.first << endl;
  }
  // rep(i, s.size()) {


  //   //   cout << cur_max << " " << bef_max << endl;
  // }
}

Measured memory_bytes: 25216
#include<stdio.h>
int main(void){
  char a[6];
  scanf("%s",a);
  if(a[0]=='S'){
  	printf("Cloudy");
  }
  else if(a[0]=='C'){
    printf("Rainy");
  }
  else{
    printf("Sunny");
  }
  return 0;
}

Measured memory_bytes: 128