akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>


#define REP(i,N) for(auto i = 0; i <N; i++)
using namespace std;
typedef long long ll;


int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}


int look_site(int i, int j, int H, int W){
    
    if (i < 0) return 0;
    if (j <0) return 0;
    if (i>=H)return 0;
    if (j >= W) return 0;
    
    return 1;
    
}


int main() {
    
    int N = in();
    
    string S;
    
    cin >> S;
    
    int totalE = 0;
    
    for(auto s:S){
        
        if (s == 'E'){
            totalE ++;
        }
        
    }
    
    vector<int> Ws;
    vector<int> Es;
    
    Ws.push_back(0);
    Es.push_back(totalE - (S[0] == 'E')  );
    
    for(auto i = ++S.begin(); i!= S.end();i++){
        auto it = i;
        Ws.push_back(Ws.back() + (*(--it) == 'W'));   ///Wの個数の累積和
    }
    
    for(auto i = ++S.begin(); i!= S.end();i++){
        auto it = i;
        Es.push_back(Es.back() - (*it == 'E'));
    }
    
    
    int ans = INT_MAX;
    
    
    for(auto i = 0; i<N; i++){
        
        if (ans > Ws[i] + Es[i])  ans = Ws[i] + Es[i];
        
    }
    
    cout << ans << endl;
    
    
    return 0;
}










Measured memory_bytes: 4728
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int X = sc.nextInt();
   
   int ans =0;
   if(X>=2000) ans =1;
   else
   {
   for(int a=0;a<=20;a++)
   {
     for(int b=0;b<=20-a;b++)
     {
       for(int c=0;c<=20-a-b;c++)
       {
         for(int d=0;d<=20-a-b-c;d++)
         {
           for(int e=0;e<=20-a-b-c-d;e++)
           {
             for(int f=0;f<=20-a-b-c-d-e;f++)
             {
                if(100*a+101*b+102*c+103*d+104*e+105*f==X)
                {
                  ans =1;
                  break;
                }
             } 
           }
         }
       }
     }
   }
   }
   System.out.println(ans);
 }
}

Measured memory_bytes: 23124
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
	for(int i=0;i<7;i++)
	{
		int a,b;
		cin >> a >> b;
		cout << a-b << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
n = int(input())
arr = list(map(int,input().split(" ")))
flag=True
for i in range(len(arr)):
    if(arr[i]%2==0):
        if(arr[i]%3==0 or arr[i]%5==0):
            continue
        else:
            flag=False
            break
if(flag):
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <functional>
typedef long long ll;
using namespace std;
typedef pair<int,int> P;

int d[100][100];
P mp[100][100];
bool used[2000];
int main()
{
	int n,m;
	int ans=0;
	cin>>n>>m;
	fill(d[0],d[100],1e8-1);
	fill(mp[0],mp[100],P(1e8-1,1e8-1));
	fill(used,used+2000,false);
	for(int i=0;i<n;i++)
		d[i][i]=0;
	fill(used,used+2000,false);
	for(int i=0;i<m;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		a--;
		b--;
		d[a][b]=c;
		d[b][a]=c;
		mp[a][b]=P(c,i);
		mp[b][a]=P(c,i);
	}

	//ワーシャルフロイド
	for(int k=0;k<n;k++)
	{
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(d[i][j]>d[i][k]+d[k][j])
				{
					d[i][j]=d[i][k]+d[k][j];
				}
			}
		}
	}
	//ワーシャルフロイドここまで
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			//cerr<<i<<" "<<j<<endl;
			//ij間の最短経路を調べる
			if(mp[i][j].first!=1e8-1 && mp[i][j].first>d[i][j])
				used[mp[i][j].second]=true;
		}
	}
	for(int i=0;i<m;i++)
	{
		if(used[i])
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    sort(h.begin(), h.end());
    int ans = INT_MAX;
    for (int i = 0; i+k-1 < n; i++) {
        ans = min(ans, h[i+k-1]-h[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
<?php
while (1) {
	$input = explode(' ', fgets(STDIN));
	$a = $input[0];
	$b = $input[2];
	$op = $input[1];

	if($op == '+')
		print($a+$b."\n");
	elseif($op == '-')
		print($a-$b."\n");
	elseif($op == '*')
		print($a*$b."\n");
	elseif($op == '/')
		print(floor($a/$b)."\n");
	else
		break;
}

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

int main() {
  int n;
  cin >> n;
  
  vector<double> vec(n);
  for (int i = 0; i < n; i++){
    cin >> vec.at(i);
  }
  
  double mother;
  
  for (int i = 0; i < n; i++){
    mother += 1/vec.at(i);
  }
  cout << 1 / mother << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <map>
#include <fstream>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define INF 1e9 
typedef long long ll;
typedef long double ld;
int main(){
    ll n;cin>>n;
    vector<ll> times(n);
    ll sum=0;
    REP(i,n){
        cin>>times[i];
        sum+=times[i];
    }
    ll m;cin>>m;
    REP(i,m){
        ll p, t;
        cin>>p>>t;
        p--;
        cout<<sum-times[p]+t<<endl;
    }
    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;

// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>

vector <ll> v;

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

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

	ll n,i,m,j,k,x,y,a=0,b,t,c;
	string s;
	
	cin >> n >> m;
	for(i=0;i<n;i++)
	{
		cin >> x;
		a+=x;
		v.pb(x);
	}
	sort(v.begin(),v.end(),greater<ll>());
	for(i=0;i<m;i++)
		if(v[i]*4*m<a)
			break;
	if(i==m)
		cout << "Yes";
	else
		cout << "No";
	
	return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

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

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
ll sz(string &s){ return (ll)s.size(); }
ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b; }


int main(){
    ll x;
    cin >> x;
    ll ans = 1;
    rep(i,2,x){
        for(ll j = 2;;j++){
            if(pow(i,j) > x) break;
            ans = max(ans,(ll)pow(i,j));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3984
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	vi w(10),k(10);
	rep(i,10)
		cin>>w[i];
	rep(i,10)
		cin>>k[i];
	sort(allof(w),greater<int>());
	sort(allof(k),greater<int>());
	cout<<accumulate(allof(w)-7,0)<<" "<<accumulate(allof(k)-7,0)<<endl;
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

int main(){
  int N,Y;
  cin >> N >> Y;
  int A = 0,B= 0,C = 0;
  int ans = -1;
  int k;
  for(int i = 0;i <= N;i++){
    if(ans == 1){break;}
    for(int j = 0;j <= N-i;j++){
      k = N - i -j;
      if(k >=0){
      if(10000*i + 5000*j + 1000*k == Y){
        A = i;
        B = j;
        C = k;
        ans = 1;
        break;
      }
      }
    }
    
  }
  if(ans == -1){
	A = -1;
    B = -1; 
    C = -1;
  }
  cout << A << " " << B << " " << C << endl;
}
  



Measured memory_bytes: 3560
import math
mod = 10**9 + 7

def fact(n):
    ans=1
    for i in range(1,n+1):
        ans = (ans * i)%mod
    return (ans)

N,M = [int(i) for i in input().split()]
if abs(N-M)>=2 :
    print(0)
elif N == M:
    print((2*fact(N)*fact(M))%mod)
else:
    print((fact(N)*fact(M))%mod)


Measured memory_bytes: 3060
#include<stdio.h>

int main() {
    //変数の宣言
    int a, b, c;
    int i, count=0; //処理用
    
    //入力
    scanf("%d %d %d\n", &a, &b, &c);
    
    //条件確認
    if (a<1 || b<1 || c<1 || a>b) {
        printf("not");
    }
    
    for (i=a; i<=b; i++) { //a~b
        if (c%i == 0) {
            count ++;
        }
    }
    
    //出力
    printf("%d\n", count);
    
    return 0;
}



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

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

  sort(A, A + N);
  
  long long ans = 0;
  int median = A[N / 2];
  for (int i = 0; i < N; i++) {
    ans += abs(A[i] - median);
  }

  cout << ans << endl;
}

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

#define endl "\n"
#define PB push_back
#define F first 
#define S second
#define int long long 
#define Runner_up ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

signed main()
{	
	Runner_up 
	int t=1; //cin>>t;
	while(t--){
		int n, k; cin>>n>>k;
		map <int, int> mp;  
		for(int i=0; i<k; i++){
			int d; cin>>d;
			for(int j=0; j<d; j++){
				int a; cin>>a;
				mp[a]++;
			}
		}
		int ans=0;
		for(int i=1; i<=n; i++){
			if(!mp[i]) ans++;		
		}
		cout<<ans;
	}
	return 0;	
}

Measured memory_bytes: 3620
N = int(input())
A = [int(s) for s in input().split()]
B = [int(s) for s in input().split()]
C = [int(s) for s in input().split()]

prev = -9999
total = 0
for i, a in enumerate(A):
  total += B[i]
  if prev + 1 == a:
    total += C[prev - 1]
  prev = a

print(total)

Measured memory_bytes: 38256
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long i64;
const int P=1e9+7;
const int N=1e6+6;

int inv[N],iinv[N];

int pwr(int x,int a){
	int s=1;
	while(a){
		if(a&1)s=(i64)s*x%P;
		x=(i64)x*x%P;
		a>>=1;
	}
	return s;
}

int C(int n,int m){
	return (i64)inv[n]*iinv[m]%P*iinv[n-m]%P;
}

int main()
{
	int n,a,b,c,i,x,ans=0;
	cin>>n>>a>>b>>c;
	inv[0]=1;
	for(i=1;i<=2*n;i++)
		inv[i]=(i64)inv[i-1]*i%P;
	iinv[2*n]=pwr(inv[2*n],P-2);
	for(i=2*n;i;i--)
		iinv[i-1]=(i64)iinv[i]*i%P;
	x=pwr(100,P-2);
	a=(i64)a*x%P;
	b=(i64)b*x%P;
	c=(a+b)%P;
	x=pwr(c,P-2);
	a=(i64)a*x%P;
	b=(i64)b*x%P;
	for(i=0;i<n;i++){
		ans+=(i64)x*(n+i)%P*C(n-1+i,i)%P*pwr(a,i)%P*pwr(b,n)%P;
		ans%=P;
		ans+=(i64)x*(n+i)%P*C(n-1+i,i)%P*pwr(a,n)%P*pwr(b,i)%P;
		ans%=P;
	}
	//ans=(i64)ans*pwr(2,P-2)%P;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define MOD 1000000007
#define ar array
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);

int32_t main() {
	fast_io;

	// int t; cin >> t;
	// while (t--) {
		
	// }
	int n;
	cin >> n;
	vector<int> dp(3);
	for (int i = 0; i < 3; i++) {
		cin >> dp[i];
	}
	for (int day = 1; day < n; day++) {
		vector<int> happiness(3);
		for (int i = 0; i < 3; i++) {
			cin >> happiness[i];
		}
		vector<int> new_dp(3);
		new_dp[0] = happiness[0] + max(dp[1], dp[2]);
		new_dp[1] = happiness[1] + max(dp[2], dp[0]);
		new_dp[2] = happiness[2] + max(dp[0], dp[1]);
		dp = new_dp;
	}
	cout << max(dp[0], max(dp[1], dp[2])) << endl;

	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sll set<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
using namespace std;
 
void solve(){
	ll n;
	cin>>n;
 
	string ans="";
 
	while(n>0){
		int c=(n%26-1+26)%26;
		if(n%26==0)
			n-=26;
		if(c<0)
			c=0;
		ans+='a'+c;
		//cout<<n<<endl;
		n/=26;
	}
	reverse(ans.begin(), ans.end());
	cout<<ans<<endl;
}
 
int main(){
    IOS;
    int q=1;
    //cin>>q;
    while(q--){
        solve();
    }
}

Measured memory_bytes: 3660
#include <iostream>
#include<algorithm>
using namespace std;
int main(){
    char s[200010];
    cin>>s;

    long long ans = 0;
    int astrem = 0;

    for(int i=0; s[i]!='\0'; i++){
        if(s[i]=='A'){
            astrem++;
        }else if(s[i]=='B'){
            i++;
            if(s[i]=='\0'){
                break;
            }else if(s[i]=='C'){
                ans += astrem;
            }else if(s[i]=='A'){
                 astrem = 1;
            }else{//B
                astrem = 0;
            }
        }else{//C
            astrem = 0;
        }
    }

    cout<<ans<<endl;
}

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

int i,n,ans;
int a[100007];
map<int,int> mem;

int main() {
	scanf("%d",&n);
	for (i=0 ; i<n ; i++) {
		scanf("%d",&a[i]);
		mem[a[i]]++;
	}
	
	for (i=0 ; i<n ; i++) {
		if (mem[a[i]] > 0) {
			if (mem[a[i]] < a[i]) ans += mem[a[i]]; else ans += mem[a[i]] - a[i];
		}
		mem[a[i]] = 0;
	}
	
	printf("%d\n",ans);
}


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

using namespace std;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> adj(n);
  for (int i = 0; i < n - 1; ++i) {
    int from, to;
    cin >> from >> to;
    --from;
    --to;
    adj[from].push_back(to);
    adj[to].push_back(from);
  }
  vector<int> dist(n, -1);
  function<void(int)> dfs = [&](int x) {
    for (auto y : adj[x]) {
      if (dist[y] == -1) {
        dist[y] = dist[x] + 1;
        dfs(y);
      }
    }
  };
  dist[0] = 0;
  dfs(0);
  int root = max_element(dist.begin(), dist.end()) - dist.begin();
  dist.assign(n, -1);
  dist[root] = 0;
  dfs(root);
  int diameter = *max_element(dist.begin(), dist.end());
  cout << (diameter % 3 == 1 ? "Second" : "First") << "\n";
  return 0;
}


Measured memory_bytes: 24448
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
static const int giga = pow(10,9);

int main(void){
  string str;
  cin >> str;
  
  int strsize = str.size();
  int ans = giga;
  for(int i = 0; i < strsize-2; i++){
    int temp;
    temp = abs((str[i] - '0')*100 + (str[i+1] - '0')*10 + (str[i+2] - '0') - 753);
    if(temp < ans){
      ans = temp;
    }
  }

  cout << ans << endl;

  return 0;
}

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

main() {
  int m;
  cin >> m;
  for(int t = 0; t < m; t++) {
    int fund;
    int year;
    int n;
    cin >> fund;
    cin >> year;
    cin >> n;

    int maxi;
    for(int i = 0; i < n; i++) {
      int isFukuri, yTesu;
      double yRiritsu;
      cin >> isFukuri >> yRiritsu >> yTesu;
      int tmp = fund;
      int rishiSum = 0;
      for(int j = 0; j < year; j++) {
	int rishi = int(tmp * yRiritsu);
	rishiSum += rishi;
	if(isFukuri) tmp = tmp + rishi - yTesu;
	else         tmp = tmp - yTesu;
      }
      if(!isFukuri) tmp += rishiSum;
      if(i == 0 || tmp > maxi) maxi = tmp;
    }
    cout << maxi << endl;
  }
}

Measured memory_bytes: 0
use proconio::{fastout, input, marker::Chars};

#[fastout]
fn main() {
    input! {
        n: usize,
        c: Chars,
    }

    let mut ans = 0;

    let mut l = 0;
    let mut r = n - 1;
    while r as i64 - l as i64 > 0 {
        if c[l] == 'R' {
            l += 1;
        } else if c[r] == 'W' {
            r -= 1;
        } else if c[l] == 'W' && c[r] == 'R' {
            ans += 1;
            l += 1;
            r -= 1;
        }
    }

    println!("{}", ans)
}


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

const int N = 310;

typedef long long LL;

int dp[N][N], C[N][N], sum[N][N];

int main() {
    int n, k, mod; scanf("%d%d%d", &n, &k, &mod), n++;
    for (int i = 0; i <= n; i++) {
        C[i][0] = 1;
        for (int j = 1; j <= i; j++) C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
    }
    for (int i = 0; i <= k; i++) sum[1][i] = k - i + 1, dp[1][i] = 1;
    for (int i = 2; i <= n; i++) {
        for (int j = 0; j <= k; j++) {
            for (int t = 1; t < i; t++) 
                dp[i][j] = (dp[i][j] + (LL)dp[i - t][j] * C[i - 2][t - 1] % mod * sum[t][j + 1]) % mod;
        }
        for (int j = k; j >= 1; j--) sum[i][j] = (sum[i][j + 1] + dp[i][j]) % mod;
    }
    printf("%d\n", dp[n][0]);
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,M;
    cin >> N >>M;
    int R1=99999999;
    int L1=0;
for(int i=0;i<M;i++){
    int L;
    cin >>L;
    int R;
    cin >>R;
    if(R<L){
        int a;
        a=L;
       L=R;
       L=a;
    }
    L1=max(L1,L);
    R1=min(R1,R);
}
int count=0;
for(int i=1;i<=N;i++){
    if(i<=R1&&L1<=i){
     count ++;
    }
}
cout << count <<endl;
}

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

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

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

using namespace std;

////////////////////////////////////////////////////////////////////////////////////////////////////
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define wt(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define wt(x...)
#endif
/////////////////////////////////////////////////////////////////////////////////////////////////


#define LL long long
const int MAXN = 212345;
const int INF  = 0x3f3f3f3f;

int dig (int x) { return 1 + log10(x);}


int main () {

	ios_base::sync_with_stdio(false);  cin.tie(NULL); 

	int n;
	cin >> n;

	int cnt = 0;
	for (int i = 1; i <= n; ++i) {
		if (dig(i) & 1) ++cnt;
	}

	cout << cnt << '\n';





	return 0;
}

Measured memory_bytes: 640
# coding: utf-8


def solve(*args: str) -> str:
    x = int(args[0])

    ret = None
    for b in range(120):
        for a in range(b, 120):
            a5, b5 = pow(a, 5), pow(b, 5)
            if a5-b5 == x:
                ret = (a, b)
            elif a5+b5 == x:
                ret = (a, -b)

    return ' '.join(map(str, ret))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


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


int main() {
	int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;

    // (sx,sy)→(tx,ty)
    for(int y=0; y<ty-sy; y++){
        cout << "U";
    }
    for(int x=0; x<tx-sx; x++){
        cout << "R";
    }

    // (tx,ty)→(sx,sy)
    for(int y=0; y<ty-sy; y++){
        cout << "D";
    }
    for(int x=0; x<tx-sx; x++){
        cout << "L";
    }

    // (sx,sy)→(tx,ty)
    cout << "L";
    for(int y=0; y<=ty-sy; y++){
        cout << "U";
    }
    for(int x=0; x<=tx-sx; x++){
        cout << "R";
    }
    cout << "D";

    // (tx,ty)→(sx,sy)
    cout << "R";
    for(int y=0; y<=ty-sy; y++){
        cout << "D";
    }
    for(int x=0; x<=tx-sx; x++){
        cout << "L";
    }
    cout << "U";

    cout << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
const ll mod=998244353;
ll n,m,k,ans,a[200001],b[200001],c[200001];
ll gg(ll x,ll y){
	return c[y]*b[x]%mod*b[y-x]%mod;
}
ll jj(ll x,ll y){
	ll z=1;
	while(y){
		if(y&1)
		z=z*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return z;
}
int main(){
	a[1]=c[1]=b[1]=a[0]=c[0]=b[0]=1;
	for(ll i=2;i<200001;i++){
		c[i]=c[i-1]*i%mod;
		a[i]=(mod-mod/i)*a[mod%i]%mod;
		b[i]=b[i-1]*a[i]%mod;
	}
	n=read(),m=read(),k=read();
	if(m==1){
		if(k==n-1)printf("1");
		else printf("0");
		return 0;
	}
	for(ll i=0;i<=k;i++)
		ans=(ans+jj(m-1,n-i-1)*gg(i,n-1)%mod)%mod;
	ans=ans*m%mod;
	printf("%lld",ans);
	return 0;
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, auto init = 0) {
    return std::accumulate(all(vec), T(init));
}
// -------------------------------------------------------------------

using P = pair<int, int>;

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

    int n, k;
    cin >> n >> k;
    int ks = k;
    vector<int> a(n);
    rep (i, n)
        cin >> a[i];

    int ans = 0;

    int total = 0;
    Forr(i, 50, 0) {
        int max_kurai = -1;
        rep (j, 50) {
            if ((k >> j) % 2) max_kurai = j;
        }

        int zero = 0;
        int one = 0;

        rep (j, n) {
            if ((a[j] >> i) % 2)
                one++;
            else
                zero++;
        }

        if (max_kurai < i) {
            ans += (1LL << i) * one;
        } else {
            ans += (1LL << i) * max(one, zero);
            if (zero > 0 and zero > one) {
                total += (1LL << i);
                k -= (1LL << i);
            }
        }
    }

    if (total > ks) {
        k = ks;
        ans = 0;
        int max_kurai = -1;
        rep (j, 50) {
            if ((k >> j) % 2) max_kurai = j;
        }
        k -= (1LL << max_kurai);

        int total = 0;
        Forr(i, 50, 0) {
            int max_kurai = -1;
            rep (j, 50) {
                if ((k >> j) % 2) max_kurai = j;
            }

            int zero = 0;
            int one = 0;

            rep (j, n) {
                if ((a[j] >> i) % 2)
                    one++;
                else
                    zero++;
            }

            if (max_kurai < i) {
                ans += (1LL << i) * one;
                total += (1LL << i);
            } else {
                ans += (1LL << i) * max(one, zero);
                if (zero > one) total += (1LL << i);
                k -= (1LL << i);
            }
        }
    }

    print(ans);

    return 0;
}


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

int main() {
  string S;
  cin>>S;
  bool result = true;
  for (int i = 0; i < S.size(); i++){

    if(i%2 == 0){
      //奇数('R','U','D')
      if(S.at(i) == 'R' ||S.at(i) == 'U' ||S.at(i) == 'D' ){

      }else{
        result = false;
        break;
      }
    }else{
      //偶数('L','U','D')
      if(S.at(i) == 'L' ||S.at(i) == 'U' ||S.at(i) == 'D' ){

      }else{
        result = false;
      }  
    }
  }

  //出力
  if(result==true){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
  
return 0;

}

Measured memory_bytes: 256
b, w = [int(i) for i in input().split()]
p = 10 ** 9 + 7

def fact(n, p=10**9 + 7):
    f = [1]
    for i in range(1, n+1):
        f.append(f[-1]*i%p)
    return f

def invfact(n, f, p=10**9 + 7):
    inv = [pow(f[n], p-2, p)]
    for i in range(n, 0, -1):
        inv.append(inv[-1]*i%p)
    return inv[::-1]

def get_inv(n, p=10**9 + 7):
    inv = [0, 1]
    for i in range(2, n+1):
        inv.append(-(p//i * inv[p%i]) % p)
    return inv

f = fact(b + w + 1)
invf = invfact(b + w + 1, f)

def comb(a, b):
    if a < b:
        return 0
    return f[a] * invf[b] * invf[a-b] % p

P = [[0] * 2 for i in range(b + w + 1)]
B = 0
W = 1
inv_2 = invf[2]

for i in range(1, b + w + 1):
    P[i][B] = P[i - 1][B] + comb(i - 1, b - 1) * inv_2  #i番目になくなってる確率
    P[i][W] = P[i - 1][W] + comb(i - 1, w - 1) * inv_2
    inv_2 = inv_2 * invf[2] % p 
    print((1 - P[i - 1][B] + P[i - 1][W]) * invf[2] % p)


Measured memory_bytes: 49480
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
// const int MOD = 998244353;
const int MOD = 1000000007;


/*----------------------------------------------------------------*/
signed main(){
	
	int n,d;
	cin >> n >> d;
	int cnt = 0;
	rep(i,n){
		int x,y;
		cin >> x >> y;
		if(x*x + y*y <= d*d)cnt++;
	}
	cout << cnt << endl;

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2017-qualb.contest.atcoder.jp/tasks/code_festival_2017_qualb_b
// rm -r -f test;oj dl https://atcoder.jp/contests/abc174/tasks/abc174_b

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;


int main()
{
	int32_t N, M;
	cin >> N >> M;

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

	int32_t p = 1000000007;
	vector<int32_t> cnt(N + 1);
	cnt[0] = 1;
	for (int32_t i = 0; i < N; i++) {
		if (broken[i])
			continue;
		if (i + 1 <= N) {
			cnt[i + 1] += cnt[i];
			cnt[i + 1] %= p;
		}
		if (i + 2 <= N) {
			cnt[i + 2] += cnt[i];
			cnt[i + 2] %= p;
		}
	}

	cout << cnt[N] << endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <map>

using namespace std;
int n,x;
map <int, int> m;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        if(m[x])
        {
            cout<<"NO";
            return 0;
        }
        m[x]=1;
    }
    cout<<"YES";
    return 0;
}


Measured memory_bytes: 9600
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>

using namespace std;

int main()
{
    int a;
    while(~scanf("%d",&a))
    {
        if(a<=3)
            printf("%d\n",a);
        else
        {
            int f=0,maxn;
            for(int i=a; i>=1; i--)
            {
                for(int j=2; j<=sqrt(i+1); j++)
                {
                    int b=i;
                    while(b)
                    {
                        if(b%j==0)
                            b=b/j;
                        else
                        {
                            f=0;
                            break;
                        }
                        if(b==1)
                        {
                            f=1;
                            maxn=i;
                            break;
                        }
                    }
                    if(f==1)
                        break;
                }
                if(f==1)
                    break;
            }
            printf("%d\n",maxn);
        }

    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string str;
    while(cin>>str){
        int _min=str.size(),n=str.size();
        for(int i=1;i<n;i++){
            if(str[i]!=str[i-1]){
                _min=min(_min,max(i,n-i));
            }
        }
        cout<<_min<<endl;
    }
    return 0;
}


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


int main() {
  
  int N;
  cin>>N;
  
  int sw=0;
  
  vector<int> d(N);
for (int i = 0; i < N; i++) {
  cin >> d.at(i);
}
  
  sort(d.begin(), d.end());
  
  sw=d.at(N/2)-d.at(N/2-1);
  
  cout<<sw<<endl;
     
}


 
  
  
  

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int N=sc.nextInt();
		long[] A=new long[N];
		long[] B=new long[N];
		long sum=0;
		for(int i=0; i<N; i++) {
			A[i]=sc.nextLong();
		}
		for(int i=0; i<N; i++) {
			B[i]=sc.nextLong();
		}
		for(int i=0; i<N; i++) {
			sum+=(B[i]-A[i]);
		}
		long kai1=0;
		long kai2=0;
		for(int i=0; i<N; i++) {
			if(A[i]==B[i]) {
				continue;
			}
			else if(A[i]>B[i]) {
				kai1+=(A[i]-B[i]);
			}
			else if(A[i]<B[i]) {
				kai2+=(B[i]-A[i]+1)/2;
			}
		}
		if(sum>=kai1 && sum>=kai2) {
			pl("Yes");
		}
		else {
			pl("No");
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

Measured memory_bytes: 25940
#include<stdio.h>

int main(void){
	int n,i,a,max,min;
	long sum;
	scanf("%d %d",&n,&min);
	max = min;
	sum = min;

	for(i = 1;i < n;i++){
		scanf("%d",&a);
		if(min > a){
			min = a;
		}
		if(max < a){
			max = a;
		}
		sum += a;
	}

	printf("%d %d %ld\n",min,max,sum);

	return 0;
}
	

Measured memory_bytes: 600
#include <iostream>

using namespace std;

int main(void){
  int a,b;
  while(cin>>a){
    int digit=0;
    cin>>b;
    int sum=a+b;

    while(sum!=0){
      ++digit;
      sum/=10;
    }

    cout<<digit<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define MAXN 3100
using namespace std;
const int M = 1e9+7;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

int dp[MAXN][MAXN];
int soma[MAXN];
char sign[MAXN];

signed main(){
	int n;
	cin>>n;
	
	for(int i=0;i<MAXN;i++)
		for(int j=0;j<MAXN;j++)
			dp[i][j]=0;
	dp[0][1]=1;
	
	soma[0]=0;   	
	
	for(int i=1;i<n;i++)cin>>sign[i];
	 
	for(int i=1;i<n;i++){
		soma[0]=0;
		for(int k=1;k<=i+1;k++){
			soma[k]=mod(soma[k-1]+dp[i-1][k],M);
		}
		
		for(int j=1;j<=i+1;j++){
			if(sign[i]=='<'){
				dp[i][j]=mod(soma[j-1],M);
			}else{
					dp[i][j]=mod(soma[i+1]-soma[j-1],M);
			}
		}
		
	}

	int res=0;
	for(int j=1;j<=n;j++){
		res=mod(dp[n-1][j]+res,M);
	}
	cout<<res<<endl;
	
}


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

int n, k, dp[100010], arr[100000];

int main(void){
	cin>>n>>k;
	for(int i=0;i<100010;i++)dp[i]=0;
	for(int i=0;i<n;i++)cin>>arr[i];
	for(int i=0;i<=k;i++){
		bool current=dp[i];
		for(int j=0;j<n;j++){
			if(i+arr[j]>k)break;
			else if(dp[i+arr[j]]==0)dp[i+arr[j]]=!dp[i];
		}

	}
	if(dp[k]==1)cout<<"First";
	else cout<<"Second";
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> H(N);
  for(int i = 0; i < N; i++) cin >> H.at(i);
  
  int count = 1;
  for(int i = 1; i < N; i++){
    for(int j = 0; j < i; j++){
      if(H.at(j) > H.at(i)) break;
      if(j == i - 1) count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =2e5+10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
typedef long long ll;
int n;
ll a[MAXN];
int main()
{
	ll ans=0,max1=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	max1=a[1];
	for(int i=2;i<=n;i++)
	{
		if(a[i]<max1)
		{
			ans+=(max1-a[i]);
		}
		else
		{
			max1=a[i];
		}
	}
	printf("%lld\n",ans);
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(std::vector<long long> x){
    rep(i,0,x.size()) {
        if (x[i] == 0) {
            cout << i+1 << endl;
            return;
        }
    }
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    std::vector<long long> x(5);
    for(int i = 0 ; i < 5 ; i++){
        scanf("%lld",&x[i]);
    }
    solve(std::move(x));
    return 0;
}


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

int N;
const int MAX_N = 1000 + 100;
int l[MAX_N], r[MAX_N];

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

    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += r[i] - l[i] + 1;
    }

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


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

int main(){
  int N;
  cin >> N;
  int *a = (int*)malloc(sizeof(int) * N);

  int c=0,d=0;
  for(int i=0;i<N;i++){
    cin >> a[i];
    if(a[i]%2==0)
      ++d;
    if(a[i]%2==0 && ((a[i]%3==0)||(a[i]%5==0)))
      ++c;
  }
  if(c==d)
    cout << "APPROVED"<<endl;
  else
    cout << "DENIED"<<endl;
}


Measured memory_bytes: 256
import sys
import math

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

a, b, n = nm()

if n >= b:
    print(math.floor(a*(b-1)/b))
else:
    print(math.floor(a*n/b))

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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    cout<<a[n/2]-a[n/2-1]<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll n, m, p[100000], y[100000];
vector<P> a[100000];
string res[100000];

int main(int argc, char **argv) {
	cin >> n >> m;
	REP(i, m) {
		cin >> p[i] >> y[i];
		--p[i];
		a[p[i]].push_back(P{y[i], i});
	}
	char t[13];
	REP(i, n) {
		sort(ALL(a[i]));
		REP(j, a[i].size()) {
			sprintf(t, "%06d%06d", i+1, j+1);
			res[a[i][j].S] = string(t);
		}
	}
	REP(i, m) cout << res[i] << endl;
	return 0;
}


Measured memory_bytes: 13664
gets; nums = gets.strip.split(' ').map(&:to_i)
res = 0
gcds_asc  = [0] + nums.map{|i| res = res.gcd i}
res = 0
gcds_desc = [0] + nums.reverse_each.map{|i| res = res.gcd i}
gcds_desc.pop
gcds_desc.reverse!
puts nums.size.times.map { |i|
  gcds_asc[i].gcd(gcds_desc[i])
}.max


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int MAX=7368791;
bool flag[MAX];

int M,N;
void solve(){
    memset(flag,0,sizeof(flag));
    int cur=M;
    rep(i,N){
        while(cur<MAX&&flag[cur])cur++;
        for(int j=cur;j<MAX;j+=cur)flag[j]=true;
    }
    while(cur<MAX&&flag[cur])cur++;
    cout<<cur<<endl;
}

signed main(){
    while(cin>>M>>N,M||N)solve();
    return 0;
}

Measured memory_bytes: 10180
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int K, S; cin >> K >> S;
  
  int ans = 0;
  repi(X,0,K) {
    repi(Y,0,K) {
      if (0<=S-X-Y && S-X-Y<=K) ans++;
    }
  }
  
  cout << ans << endl;
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

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

  int q;
  cin >> q;
  VI a(q), b(q);
  REP(i, q) {
    cin >> a[i] >> b[i];
    if(a[i] > b[i]) swap(a[i], b[i]);
  }

  REP(i, q) {
    // [lb, ub)
    int lb = 0, ub = b[i]-a[i]+1;
    auto check = [&](int mid) -> bool {
      for(int j=mid/2-2; j<=mid/2+2; ++j) {
        if(j<0 || b[i]-a[i]<j) continue;
        if((a[i]+j)*(a[i]+mid-j) >= a[i]*b[i]) return false;
      }
      return true;
    };
    while(ub-lb > 1) {
      int mid = (lb+ub)/2;
      if(check(mid)) {
        lb = mid;
      } else {
        ub = mid;
      }
    }
    cout << a[i]*2-2 + lb << endl;
  }

  return 0;
}

Measured memory_bytes: 256
// AOJ 2162: Galaxy Wide Web Service
// 2017.12.13 bal4u@uu

#include <stdio.h>
#include <string.h>

#define MAX1 55440

int a[MAX1+1];
int q[25][25];
char f[25], chk[25];
char buf[205], *bp;

int getint(void)
{
	int n = 0;
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	bp++;
	return n;
}

int gcd(int a, int b)
{
	int r;
	while (b != 0) r = a % b, a = b, b = r;
	return a;
}

int lcm(int a, int b)
{
	return a/gcd(a, b)*b;
}

int main()
{
	int n, i, j, jj, k, d, t, p, ans1, ans;

	chk[13] = chk[17] = chk[19] = chk[23] = 1;

	while (fgets(bp=buf, 10, stdin) && *bp != '0') {
		n = getint();

		memset(q, 0, sizeof(q));
		memset(f, 1, sizeof(f));

		for (i = 0; i < n; i++) {
			fgets(bp=buf, 205, stdin);
			d = getint(), t = getint(); f[d] = 0;
			jj = d-t; 			
			j = d; while (j--) {
				if (jj == d) jj = 0;
				q[d][jj++] += getint();
			}
		}

		p = 1;
		for (d = 1; d <= 24; d++) {
			if (f[d]) continue;
			if (!chk[d]) p = lcm(p, d);
		}

		memset(a, 0, sizeof(int)*p);

		ans = 0;
		for (d = 1; d <= 24; d++) {
			if (f[d]) continue;
			if (chk[d]) {
				k = 0;
				for (i = 0; i < d; i++) {
					if (q[d][i] > k) k = q[d][i];
				}
				ans += k;
			} else {
				for (i = 0; i < d; i++) {
					k = q[d][i];
					for (j = i; j < p; j += d) a[j] += k;
				}
			}
		}

		ans1 = 0; for (i = 0; i < p; i++) if (a[i] > ans1) ans1 = a[i];
		printf("%d\n", ans+ans1);
	}
	return 0;
}

Measured memory_bytes: 1880
#include<iostream>
#include<string.h>
using namespace std;

int main()
{

  int N;
  cin >> N;
  int A[N];
  for(int i=0;i<N;i++)
    cin >> A[i];
  
  int awase=A[0];
  long long sum=0;
  
  for(int i=1;i<N;i++)
  {
    if(awase < A[i])
      awase = A[i]; 
    
    sum += awase - A[i];
  }
  
  cout << sum << endl;  
  
  return 0 ;
}
  

Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(), (a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;
typedef long long ll;

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c(m);
    vector<ll> d(m);
    rep(i, n) cin >> a[i] >> b[i];
    rep(i, m) cin >> c[i] >> d[i];

    rep(i, n)
    {
        ll ans = -1;
        ll mnh = 1002003004005006;

        rep(j, m)
        {
            if (mnh > abs(a[i] - c[j]) + abs(b[i] - d[j]))
            {
                mnh = min(mnh, abs(a[i] - c[j]) + abs(b[i] - d[j]));
                ans = j + 1;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
int main(){
   int A,B,C;
   cin>>A>>B>>C;
   if((C-A)*(C-B)<0){
       cout << "Yes" << endl;
   }else{
       cout << "No" << endl;
   }
}
       
       
       
       
       
       
       
       
       
       
       
       
       
       
  



Measured memory_bytes: 3568
using System;

namespace ABC97_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var M = 1;
            for (int i = 1; i < N; i++)
            {
                for (int j = 2; j <= 10; j++)
                {
                    if (M <= Math.Pow(i, j) && Math.Pow(i, j) <= N) M = (int)Math.Pow(i,j);
                }
            }
            Console.WriteLine(M);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main(){
    string s;
    cin>>s;
    int n=s.length(),cnt=0;
    int r=n/2;
    for (int i=0;i<r;i++)
        if (s[i]!=s[n-1-i])
            cnt++;
    cout<<cnt<<endl;
}

Measured memory_bytes: 256