akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		sc.close();
		
		if(A == B)
			System.out.println(C);
		else if(B == C)
			System.out.println(A);
		else
			System.out.println(B);
	}
}


Measured memory_bytes: 23508
n, m = map(int, input().split())
h = list(map(int, input().split()))
li=[0]*n
for i in range(m):
  c=list(map(int, input().split()))
  if h[c[0]-1]==h[c[1]-1]:
    li[c[0]-1]=1
    li[c[1]-1]=1    
  if h[c[0]-1]<h[c[1]-1]:
    li[c[0]-1]=1
  if h[c[0]-1]>h[c[1]-1]:
    li[c[1]-1]=1
sss=li.count(0)
print(sss)
  

Measured memory_bytes: 20128
#include<bits/stdc++.h>
using namespace std;
long long int MOD=1000000007;
long long int fun(long long int a,long long int n)
{ long long int res=1;
 while(n)  
 { if(n%2==1)
 { res=(res*a) % MOD;
  n--; }
  a=(a*a) % MOD;
  n/=2;
 }
 return res;
}
int main()
{long long int N;
 cin>>N;
 long long int X=fun(10,N)-fun(9,N)-fun(9,N)+fun(8,N);
 X=X % MOD;
 X=(X+MOD) % MOD;
 cout<<X;
}

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

int main(){
    int n,k,dd;cin>>n>>k;
    vector<int> d(10,0);
    for(int i=0;i<k;i++){
        cin>>dd;
        d[dd]=1;
    }
    for(int i=n;i<100000;i++){
        int flag=1;
        int tmp=i;
        while(tmp!=0){
            if(d[tmp%10]==1){
                flag=0;break;
                }
            tmp/=10;
        }
        if(flag){
            cout<<i<<endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <cctype>

typedef long long int ll;
using namespace std;

//
string last_char(string str);

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

    cin >> a >> b >> c;
    if((last_char(a) == b.substr(0, 1)) && (last_char(b) == c.substr(0, 1))){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

string last_char(string str){
    const size_t len = str.length();
//    char x;
    return str.substr(len - 1, 1);

}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int b,d1,d2,n,a[1000][1000],t=0;
int main(){
	scanf("%d%d%d",&n,&d1,&d2);
	b=1;
	while (!(d1%4)) b*=2,d1/=4;
	if (d1%2==1) 
	{
		for (int i=0;i<n*2;++i)
			for (int j=0;j<n*2;++j)
				if ((i/b+j/b)%2) a[i][j]=1;
	} 
	if (d1%4==2) 
	{
		for (int i=0;i<n*2;++i)
			for (int j=0;j<n*2;++j)
				if ((i/b)%2) a[i][j]=1;
	} 
	b=1;
	while (!(d2%4)) b*=2,d2/=4;
	if (d2%2==1) 
	{
		for (int i=0;i<n*2;++i)
			for (int j=0;j<n*2;++j)
				if ((i/b+j/b)%2) a[i][j]=1;
	} 
	if (d2%4==2) 
	{
		for (int i=0;i<n*2;++i)
			for (int j=0;j<n*2;++j)
				if (i/b%2) a[i][j]=1;
	} 
	for (int i=0;i<n*2;++i)
		for (int j=0;j<n*2;++j)
			if (!a[i][j]) {
				++t;
				if (t>n*n) return 0;
				printf("%d %d\n",i,j);
			}
	return 0;
} 

Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
using namespace std;

int main(){
    long long n, k;
    cin >> n >> k;

    vector<long long> x(n);
    for(long long i = 0; i < n; i++){
        cin >> x[i];
    }

    long long minv = abs(x[0]) + abs(x[k-1]-x[0]);
    for(long long i = 0; i + k - 1 < n; i++){
        long long minv2 = min(abs(x[i])+abs(x[i+k-1]-x[i]), abs(x[i+k-1])+abs(x[i]-x[i+k-1]));
        minv = min(minv2, minv);
    }
    cout << minv << endl;
    return 0;
}

Measured memory_bytes: 3992
N = int(input())

A = []
for i in range(N):
    x,y,h = map(int, input().split())
    A.append([x,y,h])
H = max([h for x,y,h in A])
while True:
    for i in range(100+1):
        for j in range(100+1):
            for x,y,h in A:
                tx, ty = abs(x-i), abs(y-j)
                if max(H - tx - ty, 0) != h:
                    break
            else:
                print(i,j,H)
                exit()
    H += 1


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

int main(){
    int n;
    cin>>n;
    int a[n];
    const long long INF=1LL<<60;
    long long dp[n];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)dp[i]=INF;
    dp[0]=0;
    for(int i=1;i<n;i++){
        dp[i]=min(dp[i],dp[i-1]+abs(a[i]-a[i-1]));
        if(i>1)dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 4740
#include<bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include<string>
#include<vector>
#include<stdlib.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
int N;
bool check(int p[]){
    for(int i=0;i<N-1;i++){
        if(p[i]<=p[i+1]){
            continue;
        }else{
            return false;
        }
    }
    return true;
}
int main(void){
  int i,j,A,B;
  cin >> N;
  int p[N];
  rep(i,N){
      cin >> p[i];
  }
  if(check(p)==true)
  {
            cout << "YES";
            return 0;
    }
    for(i=0;i<N-1;i++){
        for(j=N;j>i;j--){
            swap(p[i],p[j]);
            if(check(p)==true){
                cout << "YES";
                return 0;
            }
            swap(p[i],p[j]);
        }
    }
    cout << "NO";
    return 0;
}


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


int main(){
  string A,ANS;
  ANS="";
  int c = 1;
  cin>>A;
  int N = A.size();
  for(int i = 0;i<N;i++){
    if(A.at(i)=='B'){
      if(ANS!="")ANS.pop_back();
    }else{
      ANS.push_back(A.at(i));
    }

  }
cout<<ANS<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll roundd(ll x,ll n){
  if(x>n){return x%n;}
  else if(x<0){return x%n+n;}
  else return x;
}

int main(){
  ll n;cin>>n;
  
  vvll g(n,vll(0));vll e(n-1);
  rep(i,0,n-1){
    ll a,b;cin>>a>>b;
    a--;b--;
    e[i]=b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  ll color=0;
  rep(i,0,n){
    color=max(color,SIZE(g[i]));
  }
  vll ans(n,-1);
  queue<ll> q;
  q.push(0);
  ans[0]=-1;
  while(!q.empty()){
    ll tmp=q.front();
    q.pop();
    ll cnt=1;
    rep(i,0,SIZE(g[tmp])){
      if(ans[g[tmp][i]]==-1&&g[tmp][i]!=0){
        ans[g[tmp][i]]=roundd(ans[tmp]+cnt,color);
        cnt++;
        q.push(g[tmp][i]);
      }
    }
  }
  cout<<color<<endl;
  rep(i,0,n-1){
    cout<<ans[e[i]]%color+1<<endl;
  }
  
}



Measured memory_bytes: 10688
<?php
// 5
// 6 7 9 10 31

$h = STDIN;
$n = fgets($h);
$a = explode(' ', trim(fgets($h)));

$ans = 'APPROVED';
foreach ($a as $item) {
    if ($item % 2 === 0) {
        if ($item % 5 === 0 || $item % 3 === 0) {
            continue;
        }

        $ans = 'DENIED';
        break;

    }
}


echo $ans;

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

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin>>n>>k;
	int ss[n];
	for(int i=0;i<k;i++)
	{
		cin>>ss[i];
	}
	int dp[k+1];
	int limit=ss[0];
	for(int i=0;i<ss[0];i++)
	{
		dp[i]=0;
	}
	for(int i=limit;i<=k;i++)
	{
		int flag=0;
		for(int j=0;j<n;j++)
		{
			if((i-ss[j])>=0 && dp[i-ss[j]]==0)
			{
				flag=1;
				break;
			}
		}
		if(flag==1)
			dp[i]=1;
		else
			dp[i]=0;
	}
	if(dp[k])
		cout<<"First"<<endl;
	else
		cout<<"Second"<<endl;
return 0;
}

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

#define F first
#define S second
#define int long long
#define pb push_back
#define endl '\n'

using namespace std;

int n , k , dp[100001] , a[100001] ;

int32_t main()
{
	ios_base :: sync_with_stdio(false) ;
	cin.tie(0); cout.tie(0) ;
	cin >> n >> k ;
	fill_n(dp , 100001 , INT_MAX) ;
	dp[1] = 0 ; 
	for(int i = 1 ; i <= n ; i++){
		cin >> a[i] ;
		for(int j = i - 1 ; j >= i - k and j >= 1 ; j--){
			dp[i] = min(dp[i] , dp[j] + abs(a[i] - a[j])) ; 
		}
	}
	cout << dp[n] << endl ; 
	return 0 ;
}



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

int main()
{
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k; cin >> k;
  cout << a[k-1] << endl;

  return 0;
}


Measured memory_bytes: 256
MOD = 1000000007

S = input()

a, ab, abc, all_s = 0, 0, 0, 1

for s in S:
    if s == "A":
        a = (a + all_s) % MOD
    elif s == "B":
        ab = (ab + a) % MOD
    elif s == "C":
        abc = (abc + ab) % MOD
    elif s == "?":
        abc = (abc * 3 + ab) % MOD
        ab = (ab * 3 + a) % MOD
        a = (a * 3 + all_s) % MOD
        all_s = (all_s * 3) % MOD

print(abc)

Measured memory_bytes: 3188
a, b, c = gets.chomp.split.map(&:to_i)
radian = c * Math::PI / 180.0
puts a * b * Math.sin(radian) * 0.5
puts a + b + Math.sqrt(a*a + b*b - 2*a*b*Math.cos(radian))
puts b * Math.sin(radian)

Measured memory_bytes: 8992
import math,itertools,fractions,heapq,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  ans=[0]*n

  ind=n
  for i in range(n):
    sm=0
    for j in range(2,n+1):
      if ind*j>n:
        break
      else:
        sm+=ans[ind*j-1]
    ans[ind-1]=(l[ind-1]+sm)%2
    ind-=1
    # print(ans,ind)

  # print(ans)

  _ans=[]
  for i,x in enumerate(ans):
    if x==1:
      _ans.append(i+1)

  ln=len(_ans)
  print(ln)
  if ln!=0:
    print(' '.join([str(x) for x in _ans]))

main()
# print(main())


Measured memory_bytes: 21964
#include "bits/stdc++.h"
#define rep(i,N) for (int (i) = 0; (i) < (N); (i)++)

int main() {

	std::cin.tie(nullptr); std::ios::sync_with_stdio(false);
	
	std::string s, t; std::cin >> s >> t;
	std::sort(s.begin(), s.end());
	std::sort(t.begin(), t.end(), std::greater<char>());

	bool flag1 = false;
	bool flag2 = false;

	if (s.size() < t.size()) {
		rep(i, s.size()) {
			if (s[i] != t[i])break;
			if (i == s.size() - 1)flag1 = true;
		}
	}
	rep(i, std::min(s.size(), t.size())) {
		if (s[i] < t[i])flag2 = true;
	}
	if (flag1 | flag2)std::cout << "Yes";
	else std::cout << "No";

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
int D;
scanf("%d",&D);

if(D==25)
{
  printf("Christmas");
}
else if(D==24)
{
  printf("Christmas Eve");
}
else if(D==23)
{
  printf("Christmas Eve Eve");
}
else if(D==22)
{
   printf("Christmas Eve Eve Eve");
}
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long c;
int n;
long long x[100100],v[100100];
long long a[100100],b[100100];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>c;
	for(int i=1;i<=n;i++)
		cin>>x[i]>>v[i];
	for(int i=1;i<=n;i++){
		a[i]=a[i-1]-(x[i]-x[i-1])+v[i];
	}
	x[n+1]=c;
	for(int i=n;i>=1;i--){
		b[i]=b[i+1]-(x[i+1]-x[i])+v[i];
	}
	for(int i=1;i<=n;i++)
		a[i]=max(a[i],a[i-1]);
	for(int i=n;i>=1;i--)
		b[i]=max(b[i],b[i+1]);
	long long res=0;
	for(int i=1;i<=n;i++){
		res=max(res,a[i]);
		res=max(res,b[i]);
		res=max(res,a[i]-x[i]+b[i+1]);
		res=max(res,b[i]-(c-x[i])+a[i-1]);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3456
#include<iostream>
using namespace std;
int main(){
    long long n,c=0LL,t=5LL;
    cin>>n;
    for(;t*2<=n;t*=5LL)c+=n/(t*2);
    cout<<(n>=10LL?n%2==0LL?c:0LL:0LL)<<endl;
    return 0;
}

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

int main () {
  int N;
  cin >> N;
  
  vector<string> freebie(N, "");
  for (int i = 0; i < N; i++) {
    cin >> freebie.at(i);
  }
  
  sort(freebie.begin(), freebie.end());
  
  int count = 1;
  for (int i = 0; i < N - 1; i++) {
    if (freebie.at(i) != freebie.at(i+1)) {
     count++;
    }
  }
  
  cout << count;
}

Measured memory_bytes: 9572
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define mem(x, y) memset(x, y, sizeof(x))
#define pii pair<int, int>
#define mkp make_pair
int n;
LL a, b, c, d;

int main()
{
    cin >> n >> a >> b >> c >> d;
    LL l = b + (n - 1) * c, r = b + (n - 1) * d;
    for(int i = 0; i < n; i++) {
        if(l <= a && a <= r) {
            cout << "YES" << endl;
            return 0;
        }
        l -= (c + d);
        r -= (c + d);
    }
    cout << "NO" << endl;
    return 0;
}



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

int main(){
  int n;
  cin >>n;
  vector<string> s(n);
  rep(i,n) cin >>s[i];
  sort(s.begin(), s.end());
  int cnt = 1;
  for(int i = 1; i<n; i++){
    if(s[i-1]!=s[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 9572
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

ll mochi[110], ans;
int main()
{
  ll n;
  scanf("%lld", &n);
  for (int i = 0; i < n; i++)
  {
    ll d;
    scanf("%lld", &d);
    mochi[d]++;
  }
  for (int i = 0; i < 110; i++)
  {
    ans += !!mochi[i];
  }
  printf("%lld\n", ans);
  return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
        for (auto &u : v) os << u << endl;
        return (os);
}

template<typename T>
istream& operator >>(istream &is, pair<vector<T>&, int> v) {
        while (v.second--) {
                T a;
                v.first.push_back(is >> a, a);
        }
        return (is);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
        for (auto &u : v) is >> u;
        return (is);
}

int main() {
    int R, C, N;
    vector<Pi> dat[4];  // saigo ni merge suru

    int cnt = 0;
    cin >> C >> R >> N;
    for (int i = 0; i < N; i++) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if ((x1 == 0 || x1 == C || y1 == 0 || y1 == R) && 
            (x2 == 0 || x2 == C || y2 == 0 || y2 == R)) {
            cnt++;
            //upper (syoujunn)
            if (x1 > 0 && y1 == R) dat[0].emplace_back(x1, i);
            if (x2 > 0 && y2 == R) dat[0].emplace_back(x2, i);
            //migi (koujunn)
            if (y1 < R && x1 == C) dat[1].emplace_back(y1, i);
            if (y2 < R && x2 == C) dat[1].emplace_back(y2, i);
            //lower (koujunn)
            if (x1 < C && y1 == 0) dat[2].emplace_back(x1, i);
            if (x2 < C && y2 == 0) dat[2].emplace_back(x2, i);
            //hidari (syoujunn)
            if (y1 > 0 && x1 == 0) dat[3].emplace_back(y1, i);
            if (y2 > 0 && x2 == 0) dat[3].emplace_back(y2, i);
        }
    }
    if (cnt == 0) {
        cout << "YES" << endl;
        return (0);
    }
    sort(begin(dat[0]), end(dat[0]));
    sort(rbegin(dat[1]), rend(dat[1]));
    sort(rbegin(dat[2]), rend(dat[2]));
    sort(begin(dat[3]), end(dat[3]));
    
    vint adat;

    for (int i = 0; i < 4; i++) {
        for (auto &x : dat[i]) {
            adat.push_back(x.second);
        }
    }

    stack<int> st;
    for (auto &x : adat) {
        if (st.empty() || st.top() != x) st.push(x);
        else st.pop();
    }

    if (st.empty()) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return (0);
}


Measured memory_bytes: 3668
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    ll x,y;
    cin>>x>>y;
    for(int i=1;i<n;i++){
        ll nx,ny;
        cin>>nx>>ny;
        ll ww=max((x-1)/nx+1,(y-1)/ny+1);
        x=ww*nx;
        y=ww*ny;
    }
    cout<<x+y<<endl;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
ks = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))
cnt = 0
for i in range(2**n):
  cnt_on = [0 for i in range(m)]
  for j in range(n):
    if (i >> j) & 1:
      for k in range(m):
        g = ks[k][1:]
        for a in g:
          if a == j+1:
            cnt_on[k] += 1
  for l in range(m):
    if cnt_on[l]%2 != p[l]:
      break
    if l == m-1:
      cnt += 1
print(cnt)

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

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

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

    ll cnt = x / 11 * 2;

    if (x % 11 == 0) {
        // 何もしない
    } else if (x % 11 >= 7) {
        cnt += 2;
    } else {
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int X, A, B;
	cin >> X >> A >> B;
	if (A >= B) {
		cout << "delicious" << endl;
	}
	else if (X + A >= B) {
		cout << "safe" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}

    return 0;
}


Measured memory_bytes: 256
while (h,w = gets.split(" ").map(&:to_i)) != [0,0]
  line = "#" * w
  puts "#{line}"
  for i in 2..h-1 do
      dot = "#" + "."*(w-2) + "#"
      puts "#{dot}"
  end
  puts "#{line}"
  puts "\n"
end


Measured memory_bytes: 7016
from math import isinf

N, Ma, Mb = map(int, input().split())
a,b,c = [],[],[]
for i in range(N):
    ai,bi,ci = map(int, input().split())
    a.append(ai)
    b.append(bi)
    c.append(ci)

W_MAX = 40*10
dp = [[float('inf')]*(W_MAX+1) for _ in range(W_MAX+1)]
dp[0][0] = 0

for i in range(N):
    for wa in reversed(range(W_MAX+1)):
        for wb in reversed(range(W_MAX+1)):
            if isinf(dp[wa][wb]): continue
            if wa+a[i]<=W_MAX and wb+b[i]<=W_MAX:
                dp[wa+a[i]][wb+b[i]] = min(dp[wa+a[i]][wb+b[i]],
                                           dp[wa][wb]+c[i])

ans = float('inf')
for wa in range(1, W_MAX+1):
    for wb in range(1, W_MAX+1):
        if wa*Mb == wb*Ma:
            ans = min(ans, dp[wa][wb])

if isinf(ans): ans = -1
print(ans)

Measured memory_bytes: 49116
#coding:utf-8
import numpy as np
from collections import Counter
ls_x = []
ls_y = []
diff = []
N = int(input())
for n in range(N):
    x,y = map(int,input().split())
    for i in range(len(ls_x)):
        diff.append(str((ls_x[i] - x))+"_"+str((ls_y[i] - y)))
        diff.append(str(-(ls_x[i] - x))+"_"+str(-(ls_y[i] - y)))
    ls_x.append(x)
    ls_y.append(y)
if N == 1:
    print (1)
    exit()
cnt = Counter(diff)
#print (cnt.most_common())
print (N-cnt.most_common(1)[0][1])


Measured memory_bytes: 21512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    string s, t; cin >> s >> t;
    ll n = (ll)sz(s);
    map<char, vector<int>> mp;
    rep(i, n) {
        mp[s[i]].push_back(i+1);
    }

    ll ans = 0;
    int loc = 0;
    bool ok = true;
    rep(i, sz(t)) {
        char c = t[i];
        if (mp[c].empty()) {ok = false; break;}
        auto it = lower_bound(all(mp[c]), loc+1);
        if (it==mp[c].end()) {
            ans += (n-loc);
            ans += mp[c][0];
            loc = mp[c][0];
        } else {
            ans += (*it-loc);
            loc = *it;
        }
        debug(c, loc, ans);
    }
    if (!ok) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 1216
import java.util.*;
import java.io.*;

public class Main {
    public static long solve(LinkedList<Integer> a){
    	int N = a.size();
    	long ans = 0;
    	int prev = a.remove((N-1)/2);
    	
    	boolean top = false;
    	while(! a.isEmpty()){
    		int cur = top ? a.removeFirst() : a.removeLast();
    		ans += Math.abs(cur-prev);
    		top = !top;
    		prev = cur;
    	}
    	return ans;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> A = new ArrayList<>(N);
        for(int n=0;n<N;n++) A.add(sc.nextInt());
        
        Collections.sort(A);
        LinkedList<Integer> a = new LinkedList<>(A);
        Collections.reverse(A);
        LinkedList<Integer> b = new LinkedList<>(A);
        
        System.out.println(Math.max(solve(a),solve(b)));
        
    }
}

Measured memory_bytes: 63964
#include<stdio.h>

int main(){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    int i,count=0;

    int box[4];
    box[0]=a;
    box[1]=b;
    box[2]=c;
    box[3]=d;
    
    if(a==b||b==c||c==d||d==a){
        printf("NO\n");
        return 0;
    }

    for(i=0;i<4;i++){
        if(box[i]==1){
            count++;
        }else if(box[i]==7){
            count++;
        }else if(box[i]==9){
            count++;
        }else if(box[i]==4){
            count++;
        }else{
            break;
        }
    }

    if(count==4){
        printf("YES\n");
    }else{
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;

struct circle
{
    double x;
    double y;
    double r;
};

double getDistance(circle a, circle b)
{
    return sqrt(pow(a.x - b.x ,2)
            +pow(a.y - b.y ,2));
}

int main()
{
    int n;
    circle a, b;
    double distance;
    cin >> n;
    for(int c = 0; c < n; c++)
    {
        cin >> a.x >> a.y >> a.r
            >> b.x >> b.y >> b.r;
        distance = getDistance(a, b);
        if(abs(a.r + b.r) < distance)
            cout << 0 << endl;
        else {
            if(a.r - b.r > distance)
                cout << 2 << endl;
            else if(b.r - a.r > distance)
                cout << -2 << endl;
            else cout << 1 << endl;
        }
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 1232
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <map>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};

namespace std{
    bool operator < (const P& a, const P& b){
        return !EQ(a.X,b.X) ? a.X<b.X : a.Y+EPS<b.Y;
    }
    bool operator == (const P& a, const P& b){
        return abs(a-b) < EPS;
    }
}

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
P rotate(const P &p, double rad){
    return p *P(cos(rad), sin(rad));
}

VP convex(VP v){
    VP ret;
    int n = v.size();
    sort(v.begin(), v.end());
    for(int i=0; i<n; i++){
        while((int)ret.size()>1 && cross(ret.back()-ret[ret.size()-2], v[i]-ret.back()) < EPS){
            ret.pop_back();
        }
        ret.push_back(v[i]);
    }
    int t = ret.size();
    for(int i=n-2; i>=0; i--){
        while((int)ret.size()>t && cross(ret.back()-ret[ret.size()-2], v[i]-ret.back()) < EPS){
            ret.pop_back();
        }
        ret.push_back(v[i]);
    }
    if((int)ret.size() > 1) ret.pop_back();
    return ret;
}

double solve(int k, VP v){
    int n = v.size();
    P diff = v[k];
    for(int i=0; i<n; i++){
        v[i] -= diff;
    }
    double rot = arg(v[(k+1)%n] -v[k]);
    for(int i=0; i<n; i++){
        v[i] = rotate(v[i], -rot);
    }
    double xmin=INF,xmax=-INF,ymin=INF,ymax=-INF;
    for(int i=0; i<n; i++){
        xmin = min(xmin, v[i].X);
        xmax = max(xmax, v[i].X);
        ymin = min(ymin, v[i].Y);
        ymax = max(ymax, v[i].Y);
    }
    return (xmax-xmin)*(ymax-ymin);
}

int main(){
    int n;
    cin >> n;
    VP dir{P(-1,0), P(0,-1), P(1,0), P(0,1)};
    VP v(n);
    v[0] = P(0, 0);
    for(int i=1; i<n; i++){
        int idx,d;
        cin >> idx >> d;
        v[i] = v[idx]+dir[d];
    }
    VP p(4*n);
    VP vdir{P(0,0), P(0,1), P(1,0), P(1,1)};
    for(int i=0; i<n; i++){
        for(int d=0; d<4; d++){
            p[4*i+d] = v[i]+vdir[d];
        }
    }
    p = convex(p);

    double ans = INF;
    for(int i=0; i<(int)p.size(); i++){
        ans = min(ans, solve(i, p));
    }
    cout << fixed << setprecision(10);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 16844
fun main(args: Array<String>) {
    val x = readLine()!!.toInt()
    val max = (1.5 * x).toInt()
    val list = Array<Boolean>(max + 1) { i -> true }
    for (i in (2..max).step(2)) {
        list[i] = false
    }

    for (i in (3..max).step(2)) {
        val v = list[i]
        if (v) {
            for (n in ((i + i)..max).step(i)) {
                list[n] = false
            }
        }
    }
    list[2] = true
    for (i in (x..max)) {
        if (list[i]) {
            println(i)
            return
        }
    }
}


Measured memory_bytes: 33896
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using ll = long long;
using namespace std;

#define MX 100001

int H, W;
int c[10][10];
int A[201][201];

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

    cin >> H >> W;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> c[i][j];
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A[i][j];
        }
    }

    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] >= 0) {
                ans += c[A[i][j]][1];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<string, ll>;

int main(int argc, char const *argv[]) {
    ll n, k, h[100100];
    ll dp[100100];
    cin >> n >> k;
    for(int i=0;i<n;i++){
        cin >> h[i];
        dp[i]=INF;
    }
    dp[0]=0;
    for(int i=1;i<n;i++){
        for(int m=1;m<=k&&(i-m)>=0;m++){
            chmin(dp[i],dp[i-m]+abs(h[i-m]-h[i]));
        }
    }
    cout << dp[n-1] << endl;

    return 0;
}

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

int read()
{
	int ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=0;
	if(ch=='-')flag=1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10+ch-'0';
	if(flag)ans=-ans;
	return ans;
}

long long rell()
{
	long long ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=0;
	if(ch=='-')flag=1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10ll+(long long)(ch-'0');
	if(flag)ans=-ans;
	return ans;
}

void writ(int n)
{
	char ch[25];
	int m=0;
	if(n<0)putchar('-'),n=-n;
	if(n==0)
	{
		putchar('0');
		return;
	}
	for(;n;n/=10)ch[m++]=n%10ll+'0';
	for(;m;)putchar(ch[--m]);
}

void wrll(long long n)
{
	char ch[25];
	int m=0;
	if(n<0)putchar('-'),n=-n;
	if(n==0)
	{
		putchar('0');
		return;
	}
	for(;n;n/=10ll)ch[m++]=n%10ll+'0';
	for(;m;)putchar(ch[--m]);
}
const int N=1<<9;
int a[N][N],f[N],s[N];

int main()
{
	int n=read(),m=read();
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			a[i][j]=read()-1;
		}
	}
	memset(f,0,sizeof(f));
	int ans=n;
	for(int z=m;z--;)
	{
		memset(s,0,4*m);
		for(int i=0;i<n;i++)
		{
			int j;
			for(j=0;f[a[i][j]];j++);
			//printf("i=%d j=%d\n",i,j);
			s[a[i][j]]++;
		}
		/*for(int i=0;i<m;i++)
		{
			printf("i=%d s[i]=%d\n",i,s[i]);
		}*/
		int ma=0;
		for(int i=1;i<m;i++)
		{
			if(s[i]>s[ma])ma=i;
		}
		//printf("z=%d ma=%d %d\n",z,ma,s[ma]);
		ans=min(ans,s[ma]);
		f[ma]=1;
	}
	writ(ans);
	puts("");
	return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#include <vector>
#include <iostream>

using namespace std;

int main() {
    string s, t;
    int i, count=0;

    cin >> s >> t;
    for (i=0;i<3;i++)
        if (s[i]==t[i])
            count++;
    cout << count << endl;
}



Measured memory_bytes: 256
def dfs(l,N,M):
    # 末端まで探索したか判定
    if judge_end(l,N):
        global score
        
        tmp_score = calc_score(ABCD,l)
        score = max(tmp_score, score)
        return
    else:
        # 現時点から選べる選択肢の列挙と探索
        nexts = listup_next(l[-1], M)
        for x in nexts:
            dfs(l+[x],N,M)


def judge_end(l,N):
    return len(l)==N


def calc_score(ABCD, l):
    s=0
    for a,b,c,d in ABCD:
      if l[b-1] - l[a-1] ==c:
        s+=d
    return s


def listup_next(m, M):
    return range(m,M+1)

N,M,Q = map(int, input().split())
ABCD = [list(map(int, input().split())) for i in range(Q)]
score=0
for i in range(1, M+1):
  dfs([i], N,M)
print(score)


Measured memory_bytes: 9232
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    ll n,ans=0;
    cin >> n;
    for(int i=1; i<=n; i++){
        if(i%3!=0 && i%5!=0)
            ans+=i;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
int n, wmax;
int w[125];
int v[125];
vi yo[4];
vl sm[4];

int main() {
	//入力受け取り
	cin >> n >> wmax;
	REP(i, n) cin >> w[i] >> v[i];

	//重さの基準を格納
	int base = w[0];

	//重さごとに分類して格納。
	REP(i, n) {
		yo[w[i] - base].push_back(v[i]);
	}

	//重さごとに、価値の降順でソート
	REP(i, 4)sort(ALL(yo[i]));
	REP(i, 4)reverse(ALL(yo[i]));

	//価値の累積和。
	//個数を指定すると、価値が高い順にとった時の結果が返ってくる

	REP(x, 4) {
		ll sum = 0;
		sm[x].push_back(0);
		REP(i, yo[x].size()) {
			sum += yo[x][i];
			sm[x].push_back(sum);
		}
	}
	//前処理終了
	
	//演算、グループごとにa個、ｂ個、c個とるとして個数で全探索
	//a,b,cが決まれば、dも決まるので価値を計算して結果の更新。

	ll ans = 0;
	REP(a, sm[0].size())REP(b, sm[1].size())REP(c, sm[2].size()) {
		ll wsum = (ll)a*base + (ll)b*(base + 1) + (ll)c*(base + 2);
		if (wsum > wmax)break;
		int rest = wmax - wsum;
		int d = min((int)yo[3].size(), rest / (base + 3));
		ll tmp = sm[0][a] + sm[1][b] + sm[2][c] + sm[3][d];
		CHMAX(ans, tmp);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    ll n, ans = 1LL;
    cin >> n;

    for(int i = 1; i <= n; i++) {
        ans *= i;
        ans %= mod;
    }

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

Measured memory_bytes: 256
N = int(input())
S = input()
num = S.count('E')
min_num = num
for i in range(N-1):
    if S[i]=='W':
        num += 1
    if S[i+1]=='E':
        num -= 1
    min_num = num if min_num > num else min_num
print(min_num if S[0]=='W' else min_num-1)

Measured memory_bytes: 3672
//http://qiita.com/Nabetani/items/f3cca410428f90333e28
//http://nabetani.sakura.ne.jp/hena/ord12rotdice/
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;

int make_hash(vector<int> &cube)
{
    int ret;
     
    ret = 0;
    for (int i = 0; i < 6; i++){
        ret = ret * 6 + cube[i];
    }
     
    return (ret);
}

// http://www.prefield.com/algorithm/misc/dice.html
enum FACE { TOP, LEFT, FRONT, BACK, RIGHT, BOTTOM };
class dice {
public:
  dice(vector<int>&v):id(v) {}
  void roll_x() { roll(TOP, BACK, BOTTOM, FRONT); }
  void roll_x2() { roll(TOP, FRONT, BOTTOM, BACK); }
  void roll_y() { roll(TOP, LEFT, BOTTOM, RIGHT); }
  void roll_y2() { roll(TOP, RIGHT, BOTTOM, LEFT); }
  void roll_z() { roll(FRONT, RIGHT, BACK, LEFT); }
  void roll_z2() { roll(FRONT, LEFT, BACK, RIGHT); }
  void all_rolls(set<int>&s){
    for (int k = 0; k < 6; (k&1?roll_y():roll_x()),++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        s.insert(make_hash(id));
  }
  vector<int> id;
private:
  void roll(FACE a, FACE b, FACE c, FACE d) {
    int tmp = id[a];
    id[a] = id[b]; id[b] = id[c];
    id[c] = id[d]; id[d] = tmp;
  }
};



int main(){
	map<char,int>m;
	m['R']=0,m['Y']=1,m['B']=2,m['M']=3,m['G']=4,m['C']=5;
	string str;
	int n,i,j,r,x;
	for(;cin>>n,n;){
		set<int>s;
		for(r=i=0;i<n;i++){
			vector<int>v;
			for(j=0;j<6;j++)cin>>str,v.push_back(m[str[0]]);
			x=make_hash(v);
			//cout<<"---"<<x<<endl;
			if(s.find(x)!=s.end())r++;
			else{
				dice d(v);
				d.all_rolls(s);
			}
//set<int>::iterator it=s.begin();
//for(;it!=s.end();it++,cout<<endl)cout<<(*it);
		}
		cout<<r<<endl;
	}
}

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

int n, m;
vector<int> graph[10005];
vector<int> rgraph[10005];
vector<int> tp;
vector<bool> visited;
int cmp[10005];
int in[10005];
int out[10005];

void dfs(int v) {
    visited[v] = true;
    for (int i = 0; i < graph[v].size(); i++) {
        if (!visited[graph[v][i]]) dfs(graph[v][i]);
    }
    tp.push_back(v);
}

void rdfs(int v, int k) {
    visited[v] = true;
    cmp[v] = k;

    for (int i = 0; i < rgraph[v].size(); i++) {
        if (!visited[rgraph[v][i]]) rdfs(rgraph[v][i], k);
    }
}

int scc(void) {
    visited.assign(n, false);

    for (int i = 0; i < n; i++) {
        if (!visited[i]) dfs(i);
    }

    int k = 0;
    visited.assign(n, false);
    for (int i = (int)tp.size() - 1; i >= 0; i--) {
        if (!visited[tp[i]]) {
            rdfs(tp[i], k);
            k++;
        }
    }

    return k;
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int s, t;

        cin >> s >> t;
        graph[s].push_back(t);
        rgraph[t].push_back(s);
    }

    int k = scc();

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < graph[i].size(); j++) {
            int from = i;
            int to = graph[i][j];

            if (cmp[to] != cmp[from]) {
                in[cmp[to]]++;
                out[cmp[from]]++;
            }
        }
    }

    int x, y;
    x = 0; y = 0;
    for (int i = 0; i < k; i++) {
        if (in[i] == 0) x++;
        if (out[i] == 0) y++;
    }

    if (k == 1) cout << 0 << endl;
    else cout << max(x, y) << endl;

    return 0;
}



Measured memory_bytes: 5720
require 'pp'

x = gets.to_i

if x >= 1800
    puts "1"
elsif x >= 1600
    puts "2"
elsif x >= 1400
    puts "3"
elsif x >= 1200
    puts "4"
elsif x >= 1000
    puts "5"
elsif x >= 800
    puts "6"
elsif x >= 600
    puts "7"
else
    puts "8"
end


Measured memory_bytes: 14624
#include <iostream>
#include <vector>
#include <algorithm>
#define INF 1000000007

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<int> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    
    vector<int> x(n + 1, -INF);
    for(int i = 0; i < n; i++) {
        int index = lower_bound(x.begin(), x.end(), v[i]) - x.begin() - 1;
        x[index] = v[i];
    }
    
    for(int i = n; i >= 0; i--) {
        if(x[i] == -INF) {
            cout << n - i << endl;
            return 0;
        }
    }
}


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

using namespace std;

typedef long long ll;

ll d(ll x){
    ll ans = 0;
    while(x){
        ++ans;
        x/=10;
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    ll dp[n+1];
    dp[0]=0;
    for(int i=1; i<=n; i++){
        cin >> dp[i];
        --dp[i];
        dp[i]+=dp[i-1];
        dp[i]%=k;
    }
    ll ans = 0;
    map<int, int> mp;mp[0]=1;
    for(int i=1; i<=n;i++){
        if(i>=k) mp[dp[i-k]]--;
        ans+= mp[dp[i]]++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 11264
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

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

const long double pi = 3.141592653589793;

#define debug(x) cerr << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

ll n, t, ans = 0;
ll A[1<<20];

int main() {
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
  cin>>n>>t;
  rep(i, n) cin>>A[i];
  rep(i, n) {
      if(i == n-1) {
          ans += t;
          continue;
      }
      if(A[i]+t <= A[i+1]) ans += t;
      else ans += A[i+1]-A[i];
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Rep(i,n,m) for (int i = (n); i< (m); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
using namespace std;



int main() {
    int n;
    string s ="No";
    cin>>n;
    
    if(n%10 == 7) s ="Yes";
    n = n/10;
    if(n%10 == 7) s ="Yes";
    n = n/10;
    if(n%10 == 7) s ="Yes";
    n = n/10;
    
    
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    int a = abs(A2 - A1) + abs(A2 - A3);
    int b = abs(A1 - A3) + abs(A1 - A2);
    int c = abs(A3 - A2) + abs(A3 - A1);
    cout << min(a, min(b,c)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int X, Y, Z, K;
ll A[1000], B[1000], C[1000];
priority_queue<ll>AB, ABC;

int main(){
	cin >> X >> Y >> Z >> K;
	for (int i = 0; i < X; ++i) {
		cin >> A[i];
	}
	for (int i = 0; i < Y; ++i) {
		cin >> B[i];
	}
	for (int i = 0; i < Z; ++i) {
		cin >> C[i];
	}
	for (int i = 0; i < X; ++i) {
		for (int j = 0; j < Y; ++j) {
			AB.push(A[i] + B[j]);
		}
	}
	for (int i = 0; i < K&&i < X*Y; ++i) {
		for (int j = 0; j < Z; ++j) {
			ABC.push(AB.top() + C[j]);
		}
		AB.pop();
	}
	for (int i = 0; i < K; ++i) {
		cout << ABC.top() << endl;
		ABC.pop();
	}
	return 0;
}

Measured memory_bytes: 42980
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;

#pragma endregion

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 




/*****************************************************************************/
int n;
vvvd dp;

double rec(int i, int j, int k) {
	if (dp[i][j][k] >= 0)return dp[i][j][k];
	if (i == 0 && j == 0 && k == 0)return 0.0;

	double res = 0.0;
	if (i > 0) {
		res += rec(i - 1, j, k)*i;
	}
	if (j > 0) {
		res += rec(i + 1, j - 1, k)*j;
	}
	if (k > 0) {
		res += rec(i, j + 1, k - 1)*k;
	}
	res += n;
	res *= 1.0 / (i + j + k);
	return dp[i][j][k] = res;
}

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


	cin >> n;

	dp.resize(n + 1, vvd(n + 1, vd(n + 1)));
	f(i, 0, n + 1) {
		f(j, 0, n + 1) {
			f(k, 0, n + 1) {
				dp[i][j][k] = -1;
			}
		}
	}
	int one = 0, two = 0, three = 0;
	f(i, 0, n) {
		int a;
		cin >> a;
		if (a == 1) {
			one++;
		}ei(a == 2) {
			two++;
		}
		else {
			three++;
		}
	}

	cout << fixed << setprecision(10) << rec(one, two, three);
	return 0;
}

Measured memory_bytes: 216960
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int ans = 0;
        for(int i = 0; i <= n/4; i++){
            if((n-i*4) % 7 == 0){
                ans++;
            }
        }
        pw.println(ans > 0 ? "Yes" : "No");
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 32896