akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

void FACT(int n, map<int, int> &M) {
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            int d = 0;
            while (n % i == 0) d++, n /= i;
            M[i] += d;
        }
    }
    if (n != 1) M[n]++;
}

int main() {

    int N;
    cin >> N;

    map<int, int> M;
    for (int i = 1; i <= N; i++) FACT(i, M);

    vector<int> p;
    for (auto x : M) p.push_back(x.second);

    int ans = 0;

    //4 4 2
    for (int i = 0; i < p.size(); i++) {
        if (p[i] >= 4) {
            for (int j = i + 1; j < p.size(); j++) {
                if (p[j] >= 4) {
                    for (int k = 0; k < p.size(); k++) {
                        if (p[k] >= 2 && i != k && j != k) ans++;
                    }
                }
            }
        }
    }

    //14 4
    for (int i = 0; i < p.size(); i++) {
        if (p[i] >= 14) {
            for (int j = 0; j < p.size(); j++) {
                if (i != j && p[j] >= 4) ans++;
            }
        }
    }

    //24 2
    for (int i = 0; i < p.size(); i++) {
        if (p[i] >= 24) {
            for (int j = 0; j < p.size(); j++) {
                if (i != j && p[j] >= 2) ans++;
            }
        }
    }

    //74
    for (int i = 0; i < p.size(); i++) if (p[i] >= 74) ans++;

    cout << ans << endl;

    return 0;
}

















































Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 #define rep(i,N) for(int i=0;i<int(N);++i)
 using ll = long long;
 const int MOD = 1e9 + 7;
 const int INF = 111000000;
 
 struct UnionFind {
     vector<int> r;
  
     UnionFind(int N) {
         r = vector<int>(N, -1);
     }
  
     int root(int x) {
         if (r[x] < 0) return x;
         return r[x] = root(r[x]);
     }
  
     bool unite(int x, int y) {
         x = root(x);
         y = root(y);
         if (x == y) return false;
         if (r[x] > r[y]) swap(x, y);
         r[x] += r[y];
         r[y] = x;
         return true;
     }
  
     int size(int x) {
         return -r[root(x)];
     }
 };


 int main(){
     ll n,m;
     cin >> n >> m;
     vector<ll> a(m);
     vector<ll> b(m);
     rep(i,m){
         cin >> a[i] >> b[i];
     }
     UnionFind UF(n);
     for(int i=0;i<m;i++){
         int A,B;
         A = a[i];
         A-=1;
         B = b[i];
         B-=1;
         UF.unite(A,B);
     }
     int ans = 0;
     for(int i=0;i<n;i++){
         if(UF.r[i]<0)
            ans++;
     }
     cout << ans-1 << endl;
     return 0;
 }

Measured memory_bytes: 5020
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n;
	cin >> n;
	vector<int> v(n+2);
	v[0] = 0;
	v[n+2-1] = 0;
	rep(i,n) {
		cin >> v[i+1];
	}

	ll sum = 0;
	rep(i,n+1) {
		sum += abs(v[i] - v[i+1]);
	}

	for (int i = 0; i < n; i++) {
		cout << sum + abs(v[i]-v[i+2]) - abs(v[i]-v[i+1]) - abs(v[i+1]-v[i+2]) << endl;
	}
}

Measured memory_bytes: 3760
//bit全探索
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

ll dp[110000][15];//かみi桁　あまり　通り数

int main(){cout<<fixed<<setprecision(10);
		   string s;
           cin>>s;
           int n=s.size();
           dp[0][0]=1;
           rep(i,1,n+1){
             rep(j,0,13){
              if(s[i-1]!='?'){
                //10x+s=j
                rep(k,0,13){
                  
                if((k*10+(s[i-1]-'0'))%13==j)
                dp[i][j]+=dp[i-1][k];
                }
              }
              else{
                //dp[i][j]=Σdp[i-1][k] 
                rep(k,0,10){
                  rep(l,0,13){
                    if((l*10+k)%13==j)
                  dp[i][j]+=dp[i-1][l]; 
                  }
                }
              }
               dp[i][j]%=inf;
             }
           }
           cout<<dp[n][5]<<endl;
}

Measured memory_bytes: 15420
H, W = map(int, input().split())
maze = ['#'*(W+2)]
for _ in range(H):
  maze.append('#'+input()+'#')
maze.append('#'*(W+2))

cost = [[-1]*(W+2) for _ in range(H+2)]
cost[1][1] = 0

que = [(1,1)]
while que:
  i,j = que.pop(0)
  if (i,j) == (H,W):
    break
  for k,l in ((i-1,j), (i+1,j), (i,j-1), (i,j+1)):
    #print(maze[k][l], cost[k][l])
    if maze[k][l] == '.' and cost[k][l] == -1:
      cost[k][l] = cost[i][j] + 1
      que.append((k,l))

if cost[H][W] == -1:
  print(-1)
else:
  n = -2 # .の数数
  for i in range(1,H+1):
    for j in range(1,W+1):
      if maze[i][j] == '.':
        n += 1
  print(n - cost[H][W] + 1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

const int mx=200010;
const ll mod=1e9+7;
/*
i番目とj番目のブロックどちらかを先に置くかを決められないか考える。
既に置かれている重さの合計をWとして、 
iの次にj : W+wi<=sj⇔W<=sj−wi
jの次にi : W+wj<=si⇔W<=si−wj
右辺を見比べて、
sj−wi>=si−wj⇔si+wi<=sj+wj
のとき、iの次にjをおいた方がが必ず得をする。
これは推移律を満たすのでs+wでソートしてdpすればよい。
*/

vector<vector<ll>> dp(1010, vector<ll>(20010));

int main(){
  int n;
  cin >> n;
  vector<int> a(n),b(n),c(n);
  rep(i,n){ cin>>a[i]>>b[i]>>c[i]; }
  vector<int> ord(n);
  rep(i,n){ ord[i]=i; } 
  sort(ord.begin(),ord.end(),[&](int x,int y){ return a[x]+b[x]<a[y]+b[y]; });  
  
  rep(i,n){
    int idx=ord[i];
    rep(j,b[idx]+1){ dp[i+1][j+a[idx]]=dp[i][j]+c[idx]; }
    rep(j,20001){ dp[i+1][j]=max(dp[i+1][j],dp[i][j]); }
  }
  ll ans=0;
  rep(i,20001){ ans = max(ans, dp[n][i]); }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 162048
#include "bits/stdc++.h"
using namespace std;

int main() {
	vector<int> a(10002);
	int i=0;
	while(true){
		cin>>a[i];
		if(a[i]==0){return 0;	}
		cout<<"Case "<<i+1<<": "<<a[i]<<endl;
        i=1+i;
	}
}

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

string str;

int main( void ) {
    
    cin >> str;
    
    bool ok = true;
    for( char ch : str ) {
        if( ch == 'N' && find( str.begin(), str.end(), 'S' ) == str.end() )
            ok = false;
        if( ch == 'S' && find( str.begin(), str.end(), 'N' ) == str.end() )
            ok = false;
        if( ch == 'W' && find( str.begin(), str.end(), 'E' ) == str.end() )
            ok = false;
        if( ch == 'E' && find( str.begin(), str.end(), 'W' ) == str.end() )
            ok = false;
    }
    
    cout << ( ( ok == true ) ? "Yes\n" : "No\n" ) << endl;
    return 0;
}

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

//#include <debug.h>
using namespace std;

const int MAX = 2 * 100010;

vector<vector<int> > g(MAX);
vector<int> used(MAX);

int dfs(int s){
	used[s] = true;
	int x = 1;
	for(int v : g[s]){
		if(!used[v]){
			x += dfs(v);
		}
	}
	return x;
}

int main(){
	int n,m;
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int u,v; cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}	
	vector<int> cm;
	for(int i = 1; i <= n; i++ ){
		if(!used[i]){
			cm.push_back(dfs(i));
		}
	}
	sort(cm.begin(),cm.end());
	int res = 0;
	res+=cm[0];
	for(int i = 1; i < cm.size(); i++){
		res+= cm[i] - cm[i-1];
	}
	cout << res << "\n";
	return 0;
}


Measured memory_bytes: 21152
import java.math.BigDecimal;
import java.util.Scanner;


public class Main {
	public static void main(String[] args){
		Scanner sn = new Scanner(System.in);
		while(true){
			int n = sn.nextInt();
			if(n == 0) return;
			long fiveCnt = 0;
			long lim= 25;
			int add = 1;
			for(int i = 5; i <= n; i+=5){
				if(i == lim){
					lim*=5;
					add++;
				}
				fiveCnt += count(i, 5, add);
			}
			long twoCnt = 0;
			
			if(fiveCnt != 0){
				add = 1;
				lim = 4;
				for(int i = 2; i <= n; i+=2){
					if(i == lim){
						lim *= 2;
						add++;
					}
					twoCnt += count(i, 2, add);
				}
			}
			//System.out.println(f( new BigDecimal(n) ));
			System.out.println(Math.min(fiveCnt, twoCnt));
		}

	}
	
	 //iテ」ツ?ォnテ」ツ?古・ツ青ォテ」ツ?セテ」ツつ古」ツ?ヲテ」ツ??」ツつ凝・ツ?凝ヲツ閉ー
	static int count(int i,  int n, int lim){
		int c = 0;
		int x = (int)Math.pow(n, lim);
		
		while(lim >= 1 && i%x != 0){
			lim--;
			x/=n;
		}
		return lim;
	}
	
	static BigDecimal f(BigDecimal n){
		return n.equals(BigDecimal.ZERO)? new BigDecimal(1): n.multiply(f(n.subtract(new BigDecimal(1))));
	}
}

Measured memory_bytes: 20064
import java.util.*;

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();
        int x = sc.nextInt();
        int count = 0;
        for (int i = 0; i <= a; i++) {
            for (int j = 0; j <= b; j++) {
                for (int k = 0; k <= c; k++) {
                    if (x == 500 * i + 100 * j + 50 * k)
                        count++;
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { 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 = 1LL<<60;

int main(){
    vector<int> a(3);
    for(auto &i:a) cin >> i;
    sort(a.begin(),a.end());
    if(a[0]==a[1]&&a[1]==a[2]){
        cout << "No" << endl;
        return 0;
    }
    if(a[0]==a[1]&&a[0]!=a[2]){
        cout << "Yes" << endl;
        return 0;
    }
    if(a[1]==a[2]&&a[0]!=a[2]){
        cout << "Yes" << endl;
        return 0;
    }
    if(a[0]==a[1]&&a[2]!=a[0]){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    }

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string.h>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
#include<algorithm>
using namespace std;
#define ll long long
// void read(__int128 &x)
// {
//     x = 0;
//     char ch;
//     int flag = 1;
//     while ((ch = getchar()))
//     {
//         if (ch == '-') flag = -1;
//         if (ch >= '0' && ch <= '9') break;
//     }
//     x = ch - '0';
//     while ((ch = getchar()) >= '0' && ch <= '9')
//     {
//         x = x * 10 + ch - '0';
//     }
//     x *= flag;
// }

// void out(__int128 x)
// {
//     if (x < 0)
//     {
//         x = -x;
//         putchar('-');
//     }
//     if (x >= 10) out(x / 10);
//     putchar(x % 10 + '0');
// }


// ll b[300005];
// int n, k;
// ll a[300005];

// int res;
// bool check(int cnt)
// {

//     for(int i = 0; i < cnt; i++)
//     {
//         a[i] = b[i];
//     }

//     int pos = cnt;
//     for(int i = cnt; i < cnt * k; i++)
//     {
//         while(b[pos] < (2 * a[i - cnt] ) && pos < n)
//         {
//             pos++;
//         }
//         if(pos >= n)
//             return 0;
//         a[i] = b[pos];
//         pos++;
//     }
//     return 1;
// }



int a, b, c, n;
const int M = 1e5 + 100;
string s[M];
char ans[M];
bool flag = 1;
void dfs(int i, int a, int b, int c)
{
    if (i == n)
    {
        // cout << "Yes\n";
        printf("Yes\n");
        for (int i = 0; i < n; i++)
            //cout << ans[i] << "\n";
            printf("%c\n", ans[i] );
        exit(0);
    }
    if (s[i] == "AB")
    {
        if (a) ans[i] = 'B', dfs(i + 1, a - 1, b + 1, c);
        if (b) ans[i] = 'A', dfs(i + 1, a + 1, b - 1, c);
    }
    if (s[i] == "BC")
    {
        if (b) ans[i] = 'C', dfs(i + 1, a, b - 1, c + 1);
        if (c) ans[i] = 'B', dfs(i + 1, a, b + 1, c - 1);
    }
    if (s[i] == "AC")
    {
        if (a) ans[i] = 'C', dfs(i + 1, a - 1, b, c + 1);
        if (c) ans[i] = 'A', dfs(i + 1, a + 1, b, c - 1);
    }
}

int main()
{


    cin >> n >> a >> b >> c;
    for (int i = 0; i < n; i++)
        cin >> s[i];
    dfs(0, a, b, c);
  //  if(flag)
        cout << "No";
}


Measured memory_bytes: 16232
struct Read<R: std::io::BufRead> {
    stdin: R,
    v: Vec<String>,
    i: usize,
}
impl<R:std::io::BufRead> Read<R> {
    pub fn new(stdin: R) -> Self {
        Read{
            stdin: stdin,
            v: Vec::new(),
            i: 0,
        }
    }
    pub fn read_line(&mut self) {
        self.i = 0; self.v.clear();
        let mut buf = String::new();
        self.stdin.read_line(&mut buf).unwrap();
        let buf = buf.trim().to_owned();
        let mut ws = buf.split_whitespace();
        loop {
            let x = ws.next();
            if x.is_none() {break;}
            let x = x.unwrap().to_owned();
            self.v.push(x);
        }
    }
    #[allow(dead_code)]
    pub fn read_t<T: std::str::FromStr>(&mut self) -> T {
        if self.i == self.v.len() {self.read_line();}
        let elem = &self.v[self.i];
        self.i += 1;
        elem.parse().unwrap_or_else(|_| panic!())
    }
    
    #[allow(dead_code)]
    pub fn read_i32(&mut self) -> i32 {
        if self.i == self.v.len() {self.read_line();}
        let elem = self.v[self.i].parse().unwrap();
        self.i += 1;
        elem
    }
    #[allow(dead_code)]
    pub fn read_usize(&mut self) -> usize {
        if self.i == self.v.len() {self.read_line();}
        let elem = self.v[self.i].parse().unwrap();
        self.i += 1;
        elem
    }
    #[allow(dead_code)]
    pub fn read_u64(&mut self) -> u64 {
        if self.i == self.v.len() {self.read_line();}
        let elem = self.v[self.i].parse().unwrap();
        self.i += 1;
        elem
    }
    #[allow(dead_code)]
    pub fn read_string(&mut self) -> String {
        if self.i == self.v.len() {self.read_line();}
        let elem = &self.v[self.i];
        self.i += 1;
        elem.to_owned()
    }
}
fn main() {
    use std::io;
    let stdin = io::stdin();
    let stdin = io::BufReader::new(stdin.lock());
    let read = Read::new(stdin);
    solve(read);
}

fn solve<R: std::io::BufRead>(mut r: Read<R>) {
    let a = r.read_i32();
    let b = r.read_i32();
    let c = r.read_i32();
    let d = r.read_i32();

    let mut x = a;
    let mut y = c;
    
    loop {
        y-=b;
        if y <= 0 {
            println!("Yes");
            return;
        }
        x-=d;
        if x <= 0{
            println!("No");
            return;
        }
    }
}


Measured memory_bytes: 2132
while True:
  n = int(input())
  if n == 0: break
  c = input().split()
  cnt = [0]*26
  for i in range(n):
    num = ord(c[i])-ord('A')
    cnt[num] += 1
    end = False
    for j in range(26):
      win = True
      for k in range(26):
        if k == j: continue
        mx = cnt[k]+(n-1-i)
        if mx >= cnt[j]:
          win = False
      if win:
        print(chr(j+ord('A')),i+1)
        end = True
        break
    if end:
      break      
  else:
    print('TIE')



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

int main(){
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(r <= x && x <= w - r && r <= y && y <= h - r)cout << "Yes" << endl;
    else cout<< "No" << endl;
    return 0;
}


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

bool isPalindrome(const string &S) {
    int l = 0;
    int r = S.size() - 1;
    while(l < r) {
        if(S[l] != S[r]) return false;
        l++, r--;
    }
    return true;
}

int main() {
    string S; cin >> S;
    bool ok = true;
    if(!isPalindrome(S)) ok = false;
    string T = S.substr(0, S.size() / 2);
    string U = S.substr((S.size() + 3) / 2 - 1);
    if(!isPalindrome(T)) ok = false;
    if(!isPalindrome(U)) ok = false;
    cout << (ok ? "Yes" : "No") << '\n';
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

struct Rect {
	int x, y, w, h;
	Rect(int x1, int y1, int x2, int y2) {
		if (x1 > x2) swap(x1, x2);
		if (y1 > y2) swap(y1, y2);
		x = x1, y = y1, w = x2-x1, h = y2-y1;
	}
};

vector<int> read(vector<bool>& used, vector<Rect>& r, vector<bool>& target) {
	int N = used.size();
	vector<int> res;
	while (1) {
		int n = 0; REP(i, N) n += !used[i] && target[i];
		if (n == 0) return res;
//		cout << n << endl;
		int tid = -1;
		{
//			cout << target << endl;
			vector< pair<P,int> > v;
			REP(i, N) {
				if (!used[i] && target[i]) {
					v.pb( pair<P,int>(P(r[i].x, r[i].y), i) );
				}
			}
			tid = min_element(ALL(v))->second;
//			debug(tid);
			used[tid] = true;
			target[tid] = false;
			res.pb(tid);
		}
		int xto = inf;
		REP(i, N) {
//			if (r[i].x+r[i].w <= r[tid].x && r[i].y < r[tid].y+r[tid].h && r[tid].y+r[tid].h < r[i].y+r[i].h) {
			if (r[i].x >= r[tid].x+r[tid].w && r[i].y < r[tid].y+r[tid].h && r[tid].y+r[tid].h < r[i].y+r[i].h) {
				xto = min(xto, r[i].x);
			}
		}
//		debug(xto);
		vector<bool> a(N, false);
		REP(i, N) {
			if (used[i]) continue;
//			if (r[tid].x <= r[i].x && r[i].x+r[i].w <= r[tid].x+r[tid].w && r[i].y+r[i].h <= r[tid].y) {
			if (r[tid].x <= r[i].x && r[i].x+r[i].w <= xto && r[i].y+r[i].h <= r[tid].y+r[tid].h) {
				a[i] = true;
			}
		}
		vector<int> v = read(used, r, a);
		REP(i, v.size()) res.pb(v[i]);
	}
	return res;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	bool isFirst = true;
	int N;
	while (cin >> N, N) {
		if (!isFirst) cout << endl;
		isFirst = false;

		vector<Rect> r;
		REP(i, N) {
			int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
			r.pb( Rect(x1, y1, x2, y2) );
		}
		REP(i, N) {
//			cout << r[i].x << " " << r[i].y << " " << r[i].w << " " << r[i].h << endl;
		}
		vector<bool> used(N, false);
		vector<bool> target(N, true);
		vector<int> ans = read(used, r, target);
		vector<int> ar(N);
		REP(i, N) {
			ar[ans[i]] = i+1;
		}
		REP(i, N) cout << ar[i] << endl;
	}
}

Measured memory_bytes: 3012
#include "bits/stdc++.h"
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)
typedef long long ll;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    Rep(i, N) cin >> A[i];
    cout << (N + K - 3) / (K - 1) << endl;
    return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int a, b, k;
  cin >> a >> b >> k;
  rep(i, k){
    if(a + i <= b){
      cout << a + i << '\n';
    }
  }
  for(int i = k - 1;i >= 0;i --){
    if(a + k <= b - i && a <= b - i){
       cout << b - i << '\n';
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
using CompLib.Util;
using System;

public class Program
{
    int N, X;
    int[] A;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        X = sc.NextInt();
        A = sc.IntArray();
        long ans = 0;
        for (int i = 1; i < N; i++)
        {
            // 食べる数
            int t = Math.Max(0, A[i - 1] + A[i] - X);
            ans += t;
            A[i] = Math.Max(0, A[i] - t);
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;
    class Scanner
    {
        private int _index;
        private string[] _line;
        const char separator = ' ';

        public Scanner()
        {
            _index = 0;
            _line = new string[0];
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(separator);
                _index = 0;
            }
            return _line[_index++];
        }
        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(separator);
            _index = _line.Length;
            return _line;
        }
        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
    }
}

Measured memory_bytes: 28252
#include <bits/stdc++.h>
#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;
    cin >> n;
    ll ans = 0;
    for (double i=1.0; i<=double(n); i++) {
        double d = i*1.08 - double(n);
        if (0 <= d && d < 1) ans = ll(i);
    }
    if (ans == 0) cout << ":(" << endl;
    else cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
s = list(str(input()))
t = list(str(input()))

X = [[] for _ in range(26)]
for i, c in enumerate(s):
    j = ord(c)-ord('a')
    X[j].append(i)

n = len(s)
q = 0
r = -1
import bisect
for c in t:
    j = ord(c)-ord('a')
    if len(X[j]) == 0:
        print(-1)
        exit()
    idx = bisect.bisect_right(X[j], r)
    #print(X[j], idx)
    if idx == len(X[j]):
        q += 1
        r = X[j][0]
    else:
        r = X[j][idx]
    #print(q, r)
ans = q*n + r+1
print(ans)


Measured memory_bytes: 87988
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define mod 1e9+7

void lcs_top_down(string x,string y,int n,int m)
     {int td[n+1][m+1];
	 for(int i=0; i<=n; i++){
		 for(int j=0; j<=m ;j++){
			 if(i==0 || j==0)
			   td[i][j]=0;
			else {
				if(x[i-1]==y[j-1])
				 td[i][j]=1+td[i-1][j-1];
				 else
				 td[i][j]=max(td[i-1][j],td[i][j-1]);
			}
			// cout<<td[i][j]<<" ";
		 }
		// cout<<endl;
	 }
	 
	 int i=n,j=m;
       string s="";
         while(i>0&& j>0){
            if(x[i-1]==y[j-1]){
			    s+=x[i-1];
			    i--; j--;
			}
			else{
			        if(td[i-1][j] > td[i][j-1]){
					  i--;
					}
					else
					  j--;
			      		        
			}
		 }
		 reverse(s.begin(),s.end());
		 cout<<s<<endl;
		 // return td[n][m];
	   
}

int main(){
      ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);
     
    
     int n,m;
        //cin>>n>>m;
        string x,y;
          cin>>x>>y;
          n=x.length(); m=y.length();
          
      lcs_top_down(x,y,n,m);
      
    /*   for(int i=0; i<=n; i++){
		 for(int j=0; j<=m ;j++){
		  cout<<dp[i][j]<<" "; 
	      } cout<<endl;
      }*/
        
 
      
    }


Measured memory_bytes: 35456
N,K = map(int,input().split())

A = list(map(int,input().split()))

sumA = sum(A)

now = 1
yaku = []

while True:

    if now ** 2 > sumA:
        break

    if sumA % now == 0:
        yaku.append(now)
        yaku.append(sumA // now)

    now += 1

yaku.sort()

nowK = 0
nowX = 0
flag = True
ans = 0
for i in yaku:

    nowK = 0
    nowX = 0
    flag = True
    nlis = []
    for a in A:

        nowK += a % i
        nlis.append(a%i)

    nlis.sort()
    nlis.reverse()

    for j in range(nowK // i):

        nowX += i - nlis[j]

    if nowX > K:
        flag = False
        


            
    if flag:
        ans = max(ans,i)

print (ans)


Measured memory_bytes: 41808
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,a,b;
    cin>>x>>a>>b;
    if(b-a>x)cout<<"dangerous"<<endl;
    else if(a>=b)cout<<"delicious"<<endl;
    else cout<<"safe"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int main() {
    int count = 0;
    string s; cin >> s;
    rep(i,4){
        if (s[i] == '-'){
            count--;
        }else{
            count++;
        }
    }
    print(count);
}

Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "array"
#include "string"
#include "algorithm"

using namespace std;
#define rep(p,q) for(int i = p;i < q;i++)


int main(void) {
	string str;
	cin >> str;
	int price = 700;
	rep(0, 3) {
		if (str[i] == 'o') {
			price += 100;
		}
	}
	cout << price << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

bool solve(string& s);

int main() {
  string s;
  cin >> s;

  string ans = solve(s) ? "Yes" : "No";
  cout << ans << endl;
}

bool solve(string& s) {
  bool is_easy = true;
  rep(i, s.length()) {
    if (s[i] == 'U' || s[i] == 'D') {
      continue;
    }
    if (i % 2 == 0) {
      is_easy = s[i] == 'R';
    } else {
      is_easy = s[i] == 'L';
    }
    if (!is_easy) {
      break;
    }
  }

  return is_easy;
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	int a[200005];
	for (int i = 1; i < n+1 ; i++) {
		cin >> a[i];
		a[i] = a[i] - i;
	}
	long long int r=0;
	sort(a+1, a + n+1);
	int t = (n + 1) / 2;
	int b = a[t];
	long long int q = 0;
	for (int i = 1; i < n + 1; i++) {
		if (a[i] - b > 0)q = q + a[i] - b; else q = q - a[i]  +b;
	}
	cout << q;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define M 1000000007
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define mp make_pair
#define bs binary_search
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;
/**
  * @author :: Rishabh
  */
ll dp[1001][100001] = {0};
ll w[110], v[110];
 
int main()
{
	ibs;
	cti;
    ll N, W; cin >> N >> W;
    rep(i, N) cin >> w[i] >> v[i];
 
    rep(i, N)
    {
        rep(j, W + 1)
        {
            if (j - w[i] >= 0) dp[i+1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j]);
            else dp[i + 1][j] = dp[i][j];
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 79360
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979

int main()
{
	int odd = 0, even = 0;
	string s;
	cin >> s;

	//奇数番目に1が来る場合
	rep(i, s.length())
	{
		if (i % 2 != 0 && s[i] == '0') odd++;
		else if (i % 2 == 0 && s[i] == '1') odd++;
	}

	//偶数番目に1が来る場合
	rep(i, s.length())
	{
		if (i % 2 == 0 && s[i] == '0') even++;
		else if (i % 2 != 0 && s[i] == '1') even++;
	}

	cout << min(odd, even) << endl;
	return 0;
}

Measured memory_bytes: 3768
import sys
sys.setrecursionlimit(10 ** 6)
import sys
def input():
    return sys.stdin.readline()[:-1]

n,q = map(int,input().split())
tree = [[] for _ in range(n)]
point = [0] * n

for _ in range(n-1):
    a,b = map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
    
for _ in range(q):
    a,b = map(int,input().split())
    a -= 1
    point[a] += b
    
def dfs(now, prev = -1):
    for next in tree[now]:
        if next == prev:
            continue
        point[next] += point[now]
        
        dfs(next, now)
        
dfs(0)
print(*point)

Measured memory_bytes: 268464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn for(int i=0;i<n;i++)
#define pb push_back
#define pob pop.back()
int main()
{
 
  int n;
  cin>>n;
  int arr[n];
  forn cin>>arr[i];
  sort(arr,arr+n);
  cout<<arr[n/2]-arr[n/2-1];
  return 0;
  
  
  
    
}

Measured memory_bytes: 640
#include <iostream>

int main(int argc, char const* argv[])
{
    int a, b, c, k;
    std::cin >> a >> b >> c >> k;
    int max = std::max(std::max(a, b), c);
    int result = a + b + c - max + (max << k);

    std::cout << result << std::endl;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;

  long long X;
  cin >> X;
  long long a = 100;
  int count = 0;
  for(int i = 0; i < 1000000; i++){
    if(a >= X){
      cout << count <<endl;
      return 0;
    } else{
      a *= 1.01;
      count++;
    }
  }
}

Measured memory_bytes: 3688
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>

using namespace std;
typedef long long ll;


ll ans,mx,mn=1e8,sum;
int main(){
	int a,b;
	cin>>a>>b;
	for(int i=1; i<3; i++){
		if((i*a*b)%2!=0) {
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
}


Measured memory_bytes: 256
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi


def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)


def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y


for _ in range(int(input()) if not True else 1):
    #n = int(input())
    x, k, d = map(int, input().split())
    #a, b = map(int, input().split())
    #c, d = map(int, input().split())
    if x > 0:
        req = x // d
        if k <= req:
            print(abs(x - k*d))
        else:
            k -= req
            cur = x % d
            print(abs(cur) if k % 2 == 0 else abs(cur - d))
    else:
        req = (-x) // d
        if k <= req:
            print(abs(x + k*d))
        else:
            k -= req
            cur = - (-x%d)
            print(abs(cur) if k % 2 == 0 else abs(cur + d))


Measured memory_bytes: 63188
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll res[1025][100010],dp[12][100010],v[270000] = {},w[270000] = {};
void dfs(int s,int h,int l){
    if(s>=1024) return;
    int i;
    for(i=0;i<=l;i++){
        dp[h][i] = -1;
    }
    for(i=0;i<=l;i++){
        dp[h][i] = max(dp[h][i],dp[h - 1][i]);
        if(i + w[s]<=l) dp[h][i + w[s]] = max(dp[h][i + w[s]],dp[h - 1][i] + v[s]); 
    }
    res[s][0] = dp[h][0];
    for(i=1;i<=l;i++){
        res[s][i] = max(res[s][i - 1],dp[h][i]);
    }
    dfs(2*s,h + 1,l); dfs(2*s + 1,h + 1,l);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int i,j,k,n,q;
    cin >> n;
    for(i=1;i<=n;i++){
        cin >> v[i] >> w[i];
    }
    dp[0][0] = 0;
    dfs(1,1,100002);
    cin >> q;
    for(i=0;i<q;i++){
        int ver,l; cin >> ver >> l;
        if(ver<1024){
            cout << res[ver][l] << endl;
        }else{
            vector<int> vect;
            vect.clear();
            while(ver>=1024){
                vect.push_back(ver);
                ver /= 2;
            }
            int sz = vect.size();
            ll ans = 0;
            for(j=0;j<(1<<sz);j++){
                ll val = 0,hev = 0;
                for(k=0;k<sz;k++){
                    if(j & (1<<k)){
                        val += v[vect[k]]; hev += w[vect[k]];
                    }
                }
                if(hev>l) continue;
                ans = max(ans,res[ver][l - hev] + val);
            }
            cout << ans << endl;
        }
    }
}

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


int main() {
    int num,n,m,l;
    long long sum = 0;
    long long A[100][100];
    long long B[100][100];
    long long C[100][100];
    cin >> n >> m >> l;
    
    for (int i=0; i<n; ++i) {
        for (int j=0; j<m; ++j) {
            cin >> num;
            A[i][j] = num;
        }
    }
    for (int i=0; i<m; ++i) {
        for (int j=0; j<l; ++j) {
            cin >> num;
            B[i][j] = num;
        }
    }
    
    for (int i=0; i<n; ++i) {
        for (int j=0; j<l; ++j) {
            for (int k=0; k<m; ++k) {
                sum += A[i][k]*B[k][j];
            }
            C[i][j] = sum;
            sum = 0;
        }
    }
    
    for (int i=0; i<n; ++i) {
        for (int j=0; j<l; ++j) {
            cout << C[i][j];
            if (j != l-1) cout << ' ';
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3332
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a,b;
  cin >> a >> b;

  cout << (a<=b ? a : a-1) << endl;
  return 0;
}


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

string keywords[4] = {"dream", "dreamer", "erase", "eraser"};

bool startWith(const string& str, const string& query) {
  if(query.size() <= str.size()) {
    return equal(begin(query), end(query), begin(str));
  }
  return false;
}

int main() {
  string target;
  cin >> target;
  reverse(target.begin(), target.end());
  for(int i = 0; i < 4; ++i) {
    reverse(keywords[i].begin(), keywords[i].end());
  }

  bool next = true;
  while(next) {
    next = false;
    for(int i = 0; i < 4; ++i) {
      if(startWith(target, keywords[i])) {
        target = target.substr(keywords[i].size());
        if(target.size() == 0) {
          cout << "YES" << endl;
          return 0;
        }
        next = true;
        break;
      }
    }

    if(!next) {
      cout << "NO" << endl;
      return 0;
    }
  }

  return 0;
}


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

vector< int > alterSequence( vector< int >& seq ){
	int size = seq.size();
	vector< int > ret( size, 0 );
	for( int i = 0; i < size; ++i ){
		if( ret[ i ] != 0 ){
			continue;
		}
		int target = seq[ i ];
		int count = 0;
		for( int j = i; j < size; ++j ){
			if( seq[ j ] == target ){
				++count;
			}
		}
		for( int j = i; j < size; ++j ){
			if( seq[ j ] == target ){
				ret[ j ] = count;
			}
		}
	}
	return ret;
}

int main()
{
	int n;

	while( cin >> n && n ){
		vector< int > seq;
		for( int i = 0; i < n; ++i ){
			int d;
			cin >> d;
			seq.push_back( d );
		}
		int alt_count = 0;
		vector< int > alt;
		bool first = true;
		while( alt != seq ){
			if( first ){
				first = false;
			}else{
				seq = alt;
				++alt_count;
			}
			alt = alterSequence( seq );
		}
		cout << alt_count << endl;
		first = true;
		for( int i = 0; i < (int)seq.size(); ++i ){
			if( first ){
				first = false;
			}else{
				cout << " ";
			}
			cout << seq[ i ];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>

using namespace std;

int main(void){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        int x = i;
        if(x%3 == 0){
            cout << " " << i;
        }
        else {
            while(x){
                if(x%10 == 3){
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
}



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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,a,b,p,ans[3];
main() {
    cin >> n >> a >> b;
    rep(i,n) {
        cin >> p;
        if (p<=a) ans[0]++;
        else if (p>b) ans[2]++;
        else ans[1]++;
    }
    ct(min(min(ans[0],ans[1]),ans[2]))
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
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;}
constexpr long long INF = 1e9;

int dp[111][2][5];

signed main(){
	string s;int K;
	cin >> s >> K;
	dp[0][1][0] = 1;
	REP(i,s.size()){
		REP(j,2){
			int lim = j ? s[i] - '0' : 9;
			REP(k,lim+1){
				REP(l,K+1){
					dp[i+1][j&&(k==lim)][l+(k>0)]+=dp[i][j][l];
				}
			}
		}
	}
	int ans = 0;
	REP(i,2)ans+=dp[s.size()][i][K];
	out(ans);
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        while(sc.hasNextInt()){
            list.add(sc.nextInt());
        }
        System.out.println(getKinds(list));
    }

    public static  int getKinds(List<Integer> list){
        Set<Integer> set = new HashSet<>();
        for(int i = 0; i < list.size(); i++){
            set.add(list.get(i));
        }
        return  set.size();
    }
}

Measured memory_bytes: 9680
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

N = int(input())
list = [list(map(int,input().split())) for i in range(N)]

## Logic

t = 0
x = 0
y = 0

for i in range(0,N):
    mt = abs(list[i][0] - t)
    mx = abs(list[i][1] - x)
    my = abs(list[i][2] - y)
    if (mx + my == mt) or ( (mx+my<mt) & ((mt - mx - my)%2 == 0)):
        t = list[i][0]
        x = list[i][1]
        y = list[i][2]
    else:
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 85972
#include <iostream>
#include <string>

int main()
{
	std::string S;
	std::cin >> S;

	unsigned long long x = 0;
	for ( int i = 0; i < S.size(); i++ )
	{
		x *= 10;
		x += S[i] - '0';
	}

	unsigned int diff = 1e9;
	for ( ; x > 0; x /= 10 )
	{
		int y = x % 1000;
		int z = std::abs( 753 - y );

		if ( z < diff )
		{
			diff = z;
		}
	}

	std::cout << diff << std::endl;

	return ( 0 );
}


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


int main(void) {
  ll n;
  cin >> n;
  vector<ll> v(5);
  rep(i, v.size()) {
    cin >> v[i];
  }

  ll minMove = v[0];
  for (int i = 1; i < v.size(); ++i) minMove = min(minMove, v[i]);
  ll ans = ((n + minMove - 1) / minMove) + 4;  

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

Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<tuple>
#include<ctime>
#include<functional>
#include<cmath>
#include<cassert>
#include<string.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p; 
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
    ll A,V,B,W,T;
    cin>>A>>V>>B>>W>>T;
    if(abs(A-B)<=(V-W)*T) p("YES");
    else p("NO");
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int mod(int a)
{
  if(a>0)
  return a;
  return -a;
}
int main() {
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
	cin>>a[i];
	int dp[n+1];
	dp[1]=0;
	dp[2]=mod(a[2]-a[1]);
	for(int i=3;i<=n;i++)
	{
		dp[i]=min(dp[i-2]+mod(a[i]-a[i-2]),dp[i-1]+mod(a[i]-a[i-1]));
	}
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 1024
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>();
    for (i, ch) in s.chars().enumerate() {
        if i % 2 == 0 {
            print!("{}", ch);
        }
    }
    println!("");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352