akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
int n, k;
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>s>>k;
    s=s.c_str();
    char kc=s[k-1];
    for(int i=0;i<n;i++){
        if(s[i]!=kc){
            s[i]='*';
        }
    }
    for(int i=0;i<n;i++){
        cout <<s[i];
    }
    cout<<"\n";
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,card[4][13]={},rank,i,j;
  char gara,space;
 
  scanf("%d",&n);
  for(i=0;i<4;i++){
    for(j=0;j<13;j++){card[i][j]=0;}
  }
 
  for(n;n>0;n--){
    scanf("%c",&space);
    scanf("%c %d",&gara,&rank);
    if(gara=='S')i=0;
    else if(gara=='H')i=1;
    else if(gara=='C')i=2;
    else if(gara=='D')i=3;
    j=rank-1;
    card[i][j]=1;
  }
 
  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      if(card[i][j]==0){
    if(i==0)gara='S';
    else if(i==1)gara='H';
    else if(i==2)gara='C';
    else if(i==3)gara='D';
    rank=j+1;
    printf("%c %d\n",gara,rank);
      }
    }
  }
  return 0;
}

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

int main() {
  int l; cin >> l;
  string s = ".abcdefghij";
  vector<vector<vector<string>>> ss(11, vector<vector<string>>(11, vector<string>(0, "")));
  ss.at(1).at(1).push_back("a");
  for(int i = 1; i < l+1; i++){
    for(int j = 1; j < i+1; j++){
//      if(ss.at(i-1).at(j-1).empty() && ss.at(i-1).at(j).empty()) continue;
      if(!ss.at(i-1).at(j-1).empty()){
        for(string sss : ss.at(i-1).at(j-1)){
          ss.at(i).at(j).push_back(sss + s.at(j));
        }
      }
      if(!ss.at(i-1).at(j).empty()){
        for(string sss : ss.at(i-1).at(j)){
          for(int k = 1; k < j+1; k++){
            ss.at(i).at(j).push_back(sss + s.at(k));
          }
        }
      }
    }
  }
  vector<string> out;
  for(int i = 1; i < l+1; i++){
    for(string sss : ss.at(l).at(i)){
      out.push_back(sss);
    }
  }
  sort(out.begin(), out.end());
  for(string sss : out){
    cout << sss << endl;
  }
/*  for(string sss : ss.at(1).at(1)){
    cout << sss << " ";
  }
  cout << ss.at(2).at(1).at(0) << ss.at(2).at(2).at(0); */
}


Measured memory_bytes: 10740
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B, C);

// ===

fn main() {
    let (a, b, c): (i32, i32, i32) = read();
    let k: usize = read();

    let max = max(a, max(b, c));
    let mut sum = max<<k;
    sum += a + b + c - max;
    println!("{}", sum);
}


Measured memory_bytes: 4352
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.StringTokenizer; 
  
class Main 
{ 
    public static void main(String[] args) throws IOException 
    { 
  
        BufferedReader br = new BufferedReader( 
                              new InputStreamReader(System.in)); 
  
        StringTokenizer st = new StringTokenizer(br.readLine()); 
        int a = Integer.parseInt(st.nextToken()); 
        int b = Integer.parseInt(st.nextToken()); 
        int c = Integer.parseInt(st.nextToken()); 
        if (a+b+c>=22) System.out.println("bust");
        else System.out.println("win"); 
    } 
} 

Measured memory_bytes: 21204
import java.util.*;

public class Main {
	void solve() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int x = scan.nextInt();
		int[] c = new int[n];
		int[][] a = new int[n][m];
		for(int i = 0; i < n; i++) {
			c[i] = scan.nextInt();
			for(int j = 0; j < m; j++) {
				a[i][j] = scan.nextInt();
			}
		}
		ArrayList<Integer> money = new ArrayList<>();
		for(int i = 0; i < 1 << n; i++) {
			int[] sum = new int[m];
			boolean b = true;
			int cost = 0;
			for(int j = 0; j < n; j++) {
				if((1 & i >> j) == 1) {
					for(int k = 0; k < m; k++) {
						sum[k] += a[j][k];
					}
					cost += c[j];
				}
			}
			for(int j = 0; j < m; j++) {
				if(sum[j] < x) {
					b = false;
					break;
				}
			}
			if(b) {
				money.add(cost);
			}
		}
		if(money.isEmpty()) {
			System.out.println(-1);
			return;
		}
		Collections.sort(money);
		System.out.println(money.get(0));
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}


Measured memory_bytes: 38096
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let n: usize = read_as_vec()[0];
    let a = read_as_vec::<u128>();
    let mm = 1_000_000_007;
    let mut asum = 0;
    for elem in &a {
        asum += *elem;
    }

    let mut ans = 0;

    for i in 0..n - 1 {
        asum -= a[i];
        ans = (ans + asum * a[i]) % mm;
    }

    println!("{}", ans);
}


Measured memory_bytes: 7404
lines = readlines.join.split.map(&:to_i)
num = lines.shift
kind = lines.shift
hash = lines.group_by(&:itself)
ary = []
ary = hash.values

sorted_ary = ary.sort{|a,b| a.count <=> b.count }


kind.times do 
    sorted_ary.pop
end

p sorted_ary.flatten.count

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

#include <cstdio>
#include <cstdlib>
#include <cmath>

#include <iostream>

#include <string>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

const ll mod = 1000000007;

class mint{
public:
  ll x;
  mint(ll x=0) : x(x%mod){}
  mint& operator+=(const mint rhs){
    x += rhs.x;
    while(x >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint rhs){
    x -= rhs.x;
    while(x < 0) x += mod;
    return *this;
  }
  mint & operator*=(const mint rhs){
    (x *= rhs.x) %= mod;
    return *this;
  }
  mint operator+(const mint rhs) const {
    mint res(*this);
    return res += rhs;
  }
  mint operator-(const mint rhs) const {
    mint res(*this);
    return res -= rhs;
  }
  mint operator*(const mint rhs) const {
    mint res(*this);
    return res *= rhs;
  }
  bool operator>(const ll rhs) const {
    return x > rhs;
  }
  bool operator<(const ll rhs) const {
    return x < rhs;
  }
  bool operator>=(const ll rhs) const {
    return x >= rhs;
  }
  bool operator<=(const ll rhs) const {
    return x <= rhs;
  }
  bool operator==(const ll rhs) const {
    return x == rhs;
  }
  bool operator!=(const ll rhs) const {
    return x != rhs;
  }
  friend ostream& operator<<(ostream& os,const mint rhs){
    os << rhs.x;
    return os;
  }
};

#define rep(index,num) for(int index=0;index<num;++index)

int main(){
  int A,B,C,K;
  std::cin >> A >> B >> C >> K;
  int ret = 0;
  if(K >= A + B + C) std::cout << A-C << std::endl;
  else if(K >= A+B) std::cout << A - (K-(A+B)) << std::endl;
  else if(K >= A) std::cout << A << std::endl;
  else std::cout << K << std::endl;
  return 0;
}


Measured memory_bytes: 3644
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		ArrayList<Integer> list = new ArrayList<Integer>();

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

			list.add(input());

		}

		int W = list.get(0);
		int H = list.get(1);
		int x = list.get(2);
		int y = list.get(3);
		int r = list.get(4);

		if ((x + r <= W) && (0 <= x - r) && (y + r <= H) && (0 <= y - r)) {

			System.out.println("Yes");

		} else {

			System.out.println("No");

		}


		close();

	}

	public static int input() {

		return scanner.nextInt();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

Measured memory_bytes: 26356
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




int main() {
    string s;
    int k;
    cin >> s >> k;
    set<string> st;
    REP(i, s.size()){
        string t;
        for(int j = i; j < min(i + 5, (int)s.size()); j++){
            t += s[j];
            st.insert(t);
        }
    }
    
    string ans;
    int i = 1;
    for(auto x : st){
        if(i == k){
            cout << x << endl;
            return 0;
        }
        i++;
    }
}

Measured memory_bytes: 1664
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}




signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
 
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }

    ll dp[n+1][2]={};

    for(int i=0;i<=n;i++){
        dp[i][0] = -1e18;
        dp[i][1] = -1e18;
    }
    dp[0][0] = 0;
    for(int i=0;i<n-1;i++){
        dp[i+1][0] = max(dp[i][0]+a[i], dp[i][1] - a[i]);
        dp[i+1][1] = max(dp[i][1]+a[i], dp[i][0] - a[i]); 
    }
    dp[n][0] = max(dp[n-1][1]-a[n-1],dp[n-1][0]+a[n-1]);
    cout << dp[n][0] << endl;
}

Measured memory_bytes: 2560
#include <stdio.h>

int main(){
  int n, k, q;  scanf("%d%d%d", &n, &k, &q);
  int score[100003] = {0};
  for(int i=0; i<q; i++){
    int tmp;  scanf("%d", &tmp);
    score[tmp]++;
  }
  for(int i=1; i<=n; i++)
    if(k - q + score[i] > 0)
      printf("Yes\n");
    else
      printf("No\n");

  return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
	Scanner w = new Scanner ( System.in) ;
	int h = w.nextInt(); 
	int a = w.nextInt();
	
	int i = 0 ; 
	
	while (h>0) { 
		h-=a;
		i++;
	}
	System.out.println(i);
	}
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	long long int a, b;
	vector<long long int> ff(100010, 0);
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		ff[a]++;
		ff[b + 1]--;
	}
	long long int ans = 0;
	for (int i = 1; i < 100010; i++) {
		ff[i] += ff[i - 1];
		if (ff[i] >= i - 1) {
			ans = i-1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3620
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M = map(int,readline().split())
A = [True] * (N+10)
MOD = 10 ** 9 + 7
for _ in range(M):
  x = int(readline())
  A[x] = False


DP = [0] * (N+10)
DP[0] = 1

for i in range(N):
  if not A[i]:
    continue
  
  if A[i+1]:
    DP[i+1] += DP[i]
    DP[i+1] %= MOD
  if A[i+2]:
    DP[i+2] += DP[i]
    DP[i+2] %= MOD
       
print(DP[N]%MOD)
      
  




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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------
int q = 20 ;
string ask(int num){
    string res ;
    cout << num <<endl ;
    cin >> res ;
    q-- ;
    return res ;
}
//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();
    int n ;
    cin >> n ;
    int a = 0 ;
    int b = n-1 ;

    string sa = ask(a) ;
    if(sa=="Vacant"){
        cout << a <<endl;
        return 0 ;
    }

    string sb = ask(b) ;
    if(sb=="Vacant"){
        cout << b <<endl;
        return 0 ;
    }

    while(q>0){
        int m = (a+b)/2 ;
        string sm = ask(m) ;
        if(sm=="Vacant"){
            cout << m <<endl;
            return 0 ;
        }
        if((m-a)%2==0 && sm==sa){
            a = m ;
            sa = sm ;
            
        }
        else if((m-a)%2==0 && sm!=sa){
            b = m ;
            sb = sm ;
        }
        else if((m-a)%2==1 && sm==sa){
            b = m ;
            sb = sm ;
        }
        else{
            a = m ;
            sa = sm ;
        }
    }


    





    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



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

using namespace std;
using ll = long long;

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

    vector<pair<int, int>> aps(A + B + C);

    for(int i = 0; i < A; i++) {
        int x;
        cin >> x;
        aps.push_back(make_pair(x, 0));
    }

    for (int i = 0; i < B; i++)
    {
        int x;
        cin >> x;
        aps.push_back(make_pair(x, 1));
    }

    for (int i = 0; i < C; i++)
    {
        int x;
        cin >> x;
        aps.push_back(make_pair(x, 2));
    }

    int cnt_r = 0, cnt_g = 0, cnt_w = 0;
    ll res = 0;

    sort(aps.begin(), aps.end(), greater<pair<int, int>>());
    for(int i = 0;cnt_r + cnt_g + cnt_w < X + Y; i++) {
        int c = aps[i].second;
        if(c == 0 && cnt_r >= X) continue;
        if(c == 1 && cnt_g >= Y) continue;
        switch(c) {
            case 0:
            cnt_r++;
            break;
            case 1:
            cnt_g++;
            break;
            case 2:
            cnt_w++;
            break;
        }
        res += aps[i].first;
    }

    cout << res << endl;
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N;
  string S;
  cin>>N>>S;
  int ans=0;
  for(int i=0;i<10;i++)
    for(int j=0;j<10;j++)
      for(int k=0;k<10;k++){
        int a=0;
        for(char &c:S){
          if(c=='0'+i && a==0)
            a=1;
          else if(c=='0'+j && a==1)
            a=2;
          else if(c=='0'+k && a==2){
            a=3;
            break;
          }
        }
        if(a==3)
          ans++;
      }
  cout<<ans<<endl;
}

Measured memory_bytes: 3672
N, M = [int(i) for i in input().split(" ")]
H = [int(i) for i in input().split(" ")]

node = [[] for _ in range(N)]

for i in range(M):
    a,b = [int(i) for i in input().split(" ")]
    node[a-1].append(b-1)
    node[b-1].append(a-1)

ans = 0
for n,i in enumerate(node):
    i_high = H[n]
    for j in i:
        if H[j] >= i_high:
            break
    else:
        ans += 1

print(ans)

Measured memory_bytes: 29424
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=3.14159265359;

int DPx[4005][16005];
int DPy[4005][16005];

int main() {
    string S;
    cin>>S;
    int x, y;
    cin>>x>>y;
    vector<int> xarr, yarr;
    bool axisx = true;
    int tmp = 0;
    for(int i=0;i<S.size();++i){
        if(S[i]=='F'){
            tmp++;
        }
        else{
            if(axisx) {
                xarr.push_back(tmp);
                axisx = false;
            }
            else {
                yarr.push_back(tmp);
                axisx = true;
            }
            tmp = 0;
        }
    }
    if(tmp>0){
        if(axisx) xarr.push_back(tmp);
        else yarr.push_back(tmp);
    }
    x -= xarr[0];
    DPx[0][8000] = 1;
    DPy[0][8000] = 1;
    for(int i=1;i<xarr.size();++i){
        for(int j=0;j<16000;++j){
            if(DPx[i-1][j]>0){
                DPx[i][j+xarr[i]] = 1;
                DPx[i][j-xarr[i]] = 1;
            }
        }
    }
    for(int i=0;i<yarr.size();++i){
        for(int j=0;j<16000;++j){
            if(DPy[i][j]>0){
                DPy[i+1][j+yarr[i]] = 1;
                DPy[i+1][j-yarr[i]] = 1;
            }
        }
    }
    if((DPx[xarr.size()-1][x+8000]) & (DPy[yarr.size()][y+8000])){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}



Measured memory_bytes: 498048
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    ll h, w, n; cin >> h >> w >> n;
    vll a(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    vll col(0);
    rep(i, 0, n){
        rep(j, 0, a[i]){
            col.emplace_back(i+1);
        }
    }
    vvll ans(h, vll(w));
    ll c = 0, f = 0; bool t = true;
    while(f < w){
        if(f%2 == 0){
            rep(i, 0, h){
                ans[i][f] = col[c];
                c++;
            }
        }else{
            rrep(i, h-1, -1){
                ans[i][f] = col[c];
                c++;
            }
        }
        f++;
    }
    rep(i, 0, h){
        rep(j, 0, w){
            prt(ans[i][j]); prt(" ");
        }
        prt(endl);
    }
}

Measured memory_bytes: 560
t=input()
s=[0]*len(t)

for i in range(len(t)):
  
    if t[i]=='?':
        if i==0:
            if len(t)>=2:
                if t[i+1]=='D':
                    s[i]='P'
                else:
                    s[i]='D'
            else:s[i]='D'
      
      
        elif i==len(t)-1:
            s[i]='D'
        
    
        else:
            if s[i-1]=='P':s[i]='D'
            elif t[i+1]=='P':s[i]='D'
            else:s[i]='P'

    elif t[i]=='D' or t[i]=='P':s[i]=t[i]
    else:continue
#print(s)
print(''.join(s))

Measured memory_bytes: 87180
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

void swap(int *a, int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}
//swap(&a, &b)

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}//ちいさい順
//qsort(a,n,sizeof(int),cmp);
//char s[n][11]

int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);


int main (void)
{
	int a,b,c,n,i;

scanf("%d",&a);
  
  if(a%1000==0){
  printf("0\n");
    return 0;
  }
  
  b=a%1000;
	
    printf("%d",1000-b);
return 0;
}


Measured memory_bytes: 1736
import math
A,B=map(int,input().split())

a1 = math.ceil( A /0.08 )
a2 = math.ceil( (A+1) /0.08 )-1

b1 = math.ceil( B /0.1 )
b2 = math.ceil( (B+1) /0.1 )-1

ans = max(a1,b1)
if ans >= a1 and ans <= a2 and ans >= b1 and ans <= b2:
  print(ans)
else:
  print(-1)

Measured memory_bytes: 38484
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <random>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(int i=0; i<(n); i++)
#define LLREP(i,n) for(LL i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define SORT(x) sort(ALL(x))
#define REVE(x) reverse(ALL(x))
#define MP make_pair
#define PB push_back
#define INF INT_MAX

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef queue<int> QI;
typedef long long LL;

int main() {
	int h, w, cnt = 0;
	cin >> h >> w;
	REP(i, h)REP(j, w) {
		char c; cin >> c;
		if (c == '#')cnt++;
	}
	printf(cnt == h + w - 1 ? "P" : "Imp");
	puts("ossible");
}

Measured memory_bytes: 256
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 aCap = a - b;
        int ans = c - aCap;
        if (ans < 0) {
          ans = 0;
        }
    
		// 出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 23636
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
  cin.tie(0); 
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> B(N);
  B[0] = 0;
  for (int i = 1; i < N; i++) {
    cin >> B[i];
  }
  vector<int> A(N);
  for (int i = 1; i < N-1; i++) {
    if (B[i] <= B[i + 1]) {
      A[i] = B[i];
    } else {
      A[i] = B[i + 1];
    }
  }
  A[0] = B[1];
  A[N - 1] = B[N - 1];
  //cout << A(N) << endl;
  int sum = 0;
  for (int i = 0; i < N;i++){
    //cout << A[i] << " ";
    sum += A[i];
  }
  cout << sum << endl;
}


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

ll n,w;
__int128 res,ans;
ll d[N],sum[N],a[N];

int main()
{
	scanf("%lld%lld",&n,&w);
	for (int i=1;i<=n;i++) scanf("%lld",&d[i]),sum[i]=sum[i-1]+d[i];
	a[1]=a[2]=5;
	for (int i=3;i<=n;i++) a[i]=a[i-1]+2;
	for (int i=1;i<=n;i++)
	{
		res=0;
		int now=n,j=1;
		while (now>0)
		{
			res+=(sum[now]-sum[max(now-i,0)])*a[j];
			now-=i; j++;
		}
		if (i==1) ans=i*w+res; else
		ans=min(ans,i*w+res);
	}
	printf("%lld\n",ans+n*w);
	return 0;
}

Measured memory_bytes: 4992
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#define RG register
#define IL inline
#define pi acos(-1.0)
#define ll long long 
using namespace std;

struct edge{
	int first,nxt,to,w1,w2;
};
edge a[40005];
int dis[10005];
int dis2[10005];
int n,m,num,ans=0;
int D[10005];
int pan[10005];

void add(int l,int r,int w1,int w2){
	a[++num].to=r;
	a[num].nxt=a[l].first;
	a[l].first=num;
	a[num].w1=w1,a[num].w2=w2;
}

void spfa(){
  queue <int> s;
	s.push(1);
	for(int i=1;i<=n;i++) dis[i]=999999999;
	memset(pan,true,sizeof(pan));
	pan[1]=false;
	dis[1]=0;
	while(!s.empty()){
		int u=s.front();
		s.pop();
		pan[u]=true;
		for(int i=a[u].first;i;i=a[i].nxt){
			int v=a[i].to;
			if(dis[v]>dis[u]+a[i].w1){
				dis[v]=dis[u]+a[i].w1;
				if(pan[v]){
					pan[v]=false;
					s.push(v);
				}
			}
		}
	}
}

void bfs(){
	queue <int> s;
	s.push(1);
	memset(pan,0,sizeof(pan));
	memset(dis2,0,sizeof(dis2));
	long long ans=0;
	pan[1]=false;
	while(!s.empty()){
		int u=s.front();
		s.pop();
		for(int i=a[u].first;i;i=a[i].nxt){
			int v=a[i].to;
			if(dis2[u]+a[i].w1==dis[v]){
				if(!pan[v]){
					ans+=a[i].w2;
					pan[v]=a[i].w2;
					dis2[v]=dis2[u]+a[i].w1;
					s.push(v);
				} else{
					if(a[i].w2<pan[v]){
						ans=ans-pan[v]+a[i].w2;
						pan[v]=a[i].w2;
					}
				}
			}
		}
	}
	printf("%lld\n",ans);
}

int main(){
  while(1){
	  scanf("%d%d",&n,&m);
		if(n==0&&m==0) break;
		memset(a,0,sizeof(a));
		num=0;
		for(int i=1;i<=m;i++){
			 int l,r,w1,w2;
			 scanf("%d%d%d%d",&l,&r,&w1,&w2);
			 add(l,r,w1,w2);
			 add(r,l,w1,w2);
		}
		spfa();
		bfs();
	}
	return 0;
}

Measured memory_bytes: 4176
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
for i in range(1,n):
    a[i] += a[i-1]
for i in range(1,m):
    b[i] += b[i-1]
a = [0]+a
b = [0]+b

ans = 0
ALL = 0
j = m

for i in range(n+1):
    if a[i] > k:
        continue
    else:
        while k-a[i] < b[j] :
            j -=1
    ans = max(ans,i+j)
print(ans)

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

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

int main()
{
    int N;
    cin >> N;
    rep(i, 1, 10)
    {
        if(N % i == 0 && (N / i) < 10)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
ans =1 
flag = true
(1..n).each do |i|
    if a[i-1] == 0
        puts 0
        flag = false
        break
    end
end

if flag
(1..n).each do |i|
     ans *= a[i-1]
    if ans > 1000000000000000000
       puts -1
       flag = false
       break
    end
end
end

if flag
    puts ans
end


Measured memory_bytes: 21580
import sys
from collections import deque

sys.setrecursionlimit(1000000)
n = int(input())
graph = [[] for _ in range(n)]

global visited 
visited = [0 for _ in range(n)]
global Q, S, T

S = [0] #訪れた順
T = []
visited[0] = 1 #開始位置はすでに訪れたことにする

def input_graph(n):
  for i in range(n):
    vs = list(map(int, input().split()))
    graph[i] = vs
    """for j in range(n):
      if vs[j] != -1:
        tree[i].append([j, vs[j]])"""

def prim():
  global S
  cost = 0
  while len(S) < n:
    max_e = 3000
    ad_v = 0
    ad_list = []
    for s in S:
      for j in range(n):
        if graph[s][j] != -1 and j not in S:
          ad_list.append(graph[s][j])
          #print("s: ",s, " j: ",j, graph[s][j])
          if max_e > graph[s][j]:
            max_e = graph[s][j]
            ad_v = j
    S.append(ad_v)
    cost += max_e
  print(cost)
  

if __name__ == "__main__":
  input_graph(n)
  prim()
  


Measured memory_bytes: 6308
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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


def check(dic):
    lst=[0]*m
    for i in range(n):
        for j in range(m):
            if dic[a[i][j]]==1:
                lst[a[i][j]-1]+=1
                break
    maxl=max(lst)
    # print(dic,maxl,lst)
    if maxl==0:
        return n
    for i in range(m):
        if lst[i]==maxl:
            dic[i+1]=0
            break

    return min(maxl,check(dic))


dic={}
for i in range(m):
    dic[i+1]=1
# print(dic)
print(check(dic))

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

using namespace std;
static const int MAX = 200000;

int main(){
	int R[MAX], n;
	
	cin >> n;
	for ( int i = 0; i < n; i++ ) cin >> R[i];
	
	int maxv = -2000000000;
	int minv = R[0];
	
	for ( int i = 1; i < n; i++ ){
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]); 
	}
	
	cout << maxv << endl;
	
	return 0;
}

Measured memory_bytes: 3864
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		String S = next();
		int N = S.length();
		char[] C = S.toCharArray();
		long[][] dp = new long[100010][15];
		dp[0][0]=1L;

		for(int i=0;i<N;i++) {
			for(int j=0;j<13;j++) {
				for(int k=0;k<=9;k++) {
					if(k==C[i]-'0'||C[i]=='?') {
						dp[i+1][(j*10+k)%13]=(dp[i+1][(j*10+k)%13]+dp[i][j])%Mod;
					}
				}
			}
		}
		out.println(dp[N][5]);
	}

	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;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}
}

Measured memory_bytes: 56776
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
#define N 2010
#define mod 1000000007
int NOEL(ll ans){
    ans%=mod;
    if(ans<0)ans+=mod;
    cout<<ans<<endl;
    return 0;
}
class UnionFind{
    public:
    ll p[N];
    void init(){
	for(int i=0;i<N;i++)p[i]=i;
    }
    ll par(ll x){
	ll y=x,z;
	while(x!=p[x])x=p[x];
	while(y!=x)z=p[y],p[y]=x,y=z;
	return x;
    }
    bool same(ll a,ll b){return par(a)==par(b);}
    void unite(ll a,ll b){p[par(a)]=par(b);}
};UnionFind uf;
vector<P> g[N];
ll dfs(ll x,ll from,ll goal){
    if(x==goal)return 0;
    for(auto y:g[x]){
	if(y.first==from)continue;
	ll res=dfs(y.first,x,goal);
	if(~res)return max(res,y.second);
    }
    return -1;
}
ll n,m,k;
PP e[N];
int main(){
  cin>>n>>m>>k;
  for(int i=0;i<m;i++){
      cin>>e[i].second.first>>e[i].second.second>>e[i].first;
  }sort(e,e+m);
  uf.init();
  for(int i=0;i<m;i++){
     ll cost=e[i].first,a=e[i].second.first,b=e[i].second.second;
     if(uf.same(a,b))continue;
     uf.unite(a,b);
     g[a].push_back(make_pair(b,cost));
     g[b].push_back(make_pair(a,cost));
     k-=cost;
  }
  ll eq=0,up=0;
  for(int i=0;i<m;i++){
      ll cost=e[i].first,a=e[i].second.first,b=e[i].second.second;
      bool th=0; for(auto x:g[a])if(x.first==b)th=1; if(th)continue;
      ll val=cost-dfs(a,-1,b);
      if(val==k)eq++;
      if(val>k)up++;
  }//cout<<k<<" "<<eq<<" "<<up<<endl;
  ll po[N]; po[0]=1; for(int i=1;i<N;i++)po[i]=po[i-1]*2%mod;
  if(k<0)return NOEL(0);
  if(k==0){
      ll df=po[m-(n-1)]*(po[n-1]-2)%mod;
      ll sa=2*(po[eq]-1)*po[up]%mod;
      return NOEL(df+sa);
  }
  if(k>0){
      ll rs=2*(po[eq]-1)*po[up]%mod;
      return NOEL(rs);
  }
  return 0;
}


Measured memory_bytes: 512
// Created by arvybhatt

#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define p_b push_back
#define m_p make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;

int main()
{
    fast;
	int n;cin>>n;
	int a[n];
	for(int i=0; i<n; i++)
	cin>>a[i];
	map<int,int> mp;
	for(int i=1;i<=n; i++)
	{
		mp[i-a[i-1]]++;
	}    
	ll count=0;
	for(int i=1; i<=n; i++)
	{
		ll x=i+a[i-1];
		count+=mp[x];
	}
	cout<<count;	
    return 0;
}


Measured memory_bytes: 21264
def solve():
    N, Z, W = map(int, input().split())
    a = list(map(int, input().split()))
    
    if N == 1:
        print(abs(a[0] - W))
        exit()
    
    print(max(abs(a[-1] - W), abs(a[-2] - a[-1])))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3188
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

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

int Dist(int x, int y, int n, int m) {
	return min(min(x, y), min(n - x - 1, m - y - 1));
}

int main () {
    ios_base::sync_with_stdio(0);
	//freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);

	int n, m, k;
	cin >> n >> m >> k;

	int x0 = 0, y0 = 0;

	vector<vector<bool>> a(n, vector<bool>(m));
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		for (int j = 0; j < m; ++j) {
			if (s[j] == 'S') {
				x0 = i;
				y0 = j;
				a[i][j] = true;
			} else {
				a[i][j] = (s[j] == '.');
			}
		}
	}

	vector<vector<int>> d(n, vector<int>(m, inf));

	vector<pair<int, int>> och;
	int first = 0;
	och.pb(mp(x0, y0));
	d[x0][y0] = 0;

	while (sz(och) > first) {
		int x = och[first].fs;
		int y = och[first].sc;
		++first;
		for (int i = 0; i < 4; ++i) {
			int x1 = x + dx[i];
			int y1 = y + dy[i];
			if (Dist(x1, y1, n, m) >= 0 && a[x1][y1]) {
				if (d[x1][y1] > d[x][y] + 1) {
					d[x1][y1] = d[x][y] + 1;
					och.pb(mp(x1, y1));
				}
			}
		}
	}


	int res = inf;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			if (d[i][j] <= k) {
				res = min(res, 1 + (Dist(i, j, n, m) + k - 1) / k);
		   	}
		}
	}

	cout << res << endl;
                
	return 0;
}


Measured memory_bytes: 12780
#include<iostream>
using namespace std;
int n;
int a[100006],b;
long long ans=0;
int main(){
	cin>>n;
	for(int i=1;i<=n+1;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++){
		cin>>b;
		if(b>=a[i]+a[i+1]){
			ans+=(a[i]+a[i+1]);
			a[i+1]=0;
		}
		else{
			ans+=b;
			if(b>a[i]){
				b-=a[i];
				a[i+1]-=b;
			}
		}
	}
	cout<<ans;
	return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec A(N);
    REP(i,0,N) {
        cin >> A[i];
        --A[i];
    }

    ll cnt = 0;
    REP(i,0,N) {
        if(i == A[A[i]]) ++cnt;
    }
    PR(cnt/2);

    return 0;
}

/*



*/

Measured memory_bytes: 4048
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=1e5+5;
ll n,k,a[N];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n>>k;
    for(ll i=1;i<=n;i++)cin>>a[i];

    for(ll i=1;i<n;i++){
        if(a[i]+a[i+1]>=k){
            cout<<"Possible\n";
            for(ll j=1;j<i;j++)cout<<j<<"\n";
            for(ll j=n-1;j>=i;j--)cout<<j<<"\n";
            return 0;
        }
    }
    cout<<"Impossible\n";
}



Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main(void){
	double w,h,x,y;
	cin>>w>>h>>x>>y;
	cout<<fixed;
	cout<<w*h/2.0<<" ";
	if(x+x==h&&y+y==w||x+x==w&&y+y==h)	cout<<1<<endl;
	else				cout<<0<<endl;
	return 0;
}
	
	
	
	

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD (ll)(1e9+7)

int N, M;
ll S[1<<18];
multiset<ll> st1, st2;
int main(){
	cin >> N;
	M = (1<<N);
	for(int i=0; i<M; i++){
		cin >> S[i];
		st1.insert(-S[i]);
	}

	auto itr = st1.begin();
	st2.insert(*itr);
	st1.erase(itr);

	//cout << st1.size() << endl;
	for(int i=0; i<N; i++){
		vector<int> tmp;
		for(auto j=st2.begin(); j!=st2.end(); j++){
			auto itr = st1.upper_bound(*j);
			if(itr == st1.end()){
				cout << "No" << endl;
				return 0;
			}
			tmp.pb(*itr);
			st1.erase(itr);
			//cout << st1.size() << endl;
		}
		for(int j=0; j<tmp.size(); j++){
			st2.insert(tmp[j]);
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 15352
var lines = [];
var MOD = Math.pow(10, 9) + 7;

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0].split(" ")[0])
    var M = Number(lines[0].split(" ")[1])

    lines.shift();

    var ab = lines.map(value => value.split(" ").map(value => Number(value)));

    // ex
    //       <----->
    //          <----->
    //    <-------------->
    // <-------------------->
    //                   <----->    
    // 1  2  3  4  5  6  7  8  9

    ab.sort((a, b) => a[1] - b[1])
    var broken = 0, ans = 0;

    for (var value of ab) {
        var start = value[0], end = value[1];
        if (broken <= start) { broken = end; ans++; }
    }
    console.log(ans)
});

Measured memory_bytes: 52752
G=[nil,nil,nil,%w(a.. a.. .bb),%w(aabc ddbc efgg efhh),%w(abbcc ad..e fd..e f.ggh iijjh),%w(aabc.. ddbc.. ..eefg ..hhfg ij..kk ij..ll),%w(aabbcc. ..de..f ..de..f gh....i gh....i jj..kkl ..mmnnl)]
N=gets.to_i
A=N.times.map{?. * N}
def w x,j
  G[x].each do|g|
    s=?.*N
    s[j,x]=g
    puts s
  end
end
if N==2
  p -1
elsif N==3
  w 3,0
else
  m=N%4+4
  w m,0
  (N/4-1).times do|j|
    w 4,m+j*4
  end
end

Measured memory_bytes: 4860
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
	int a[5];
	rep(i,5)cin>>a[i];
	ll k;
	cin>>k;
	if(a[4]-a[0]>k)puts(":(");
	else puts("Yay!");
}


Measured memory_bytes: 256
a=input()
if a=="SUN":
	print(7)
elif a=="MON":
	print(6)
elif a=="TUE":
	print(5)
elif a=="WED":
	print(4)
elif a=="THU":
	print(3)
elif a=="FRI":
	print(2)
elif a=="SAT":
	print(1)


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

int main(){
  string a, b, c, ans;
  cin >> a >> b >> c;
  
  cout << a[0] << b[0] << c[0] << endl;
}

Measured memory_bytes: 256
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

  int n,m;
  cin >> n >> m;
  int a[n+1];
  for(int i=1;i<=n;i++){
    cin >> a[i];
    a[i]/=2;
  }  
  int lc = a[1];
  if(lc>m ){
    cout << 0 << endl;
    return 0;
  }
  for(int i=2;i<=n;i++){
    // cout << lc << endl;
    lc = (a[i]*lc)/__gcd(a[i],lc);
    if(lc>m ){
      cout << 0 << endl;
      return 0;
    }
  }
  for(int i=1;i<=n;i++){
    if((lc/a[i])%2==0){
      cout << 0 << endl;
      return 0;
    }
  }
  int ans = (m/lc);
  // cout << ans << " " << lc << endl;
  ans = ans - (ans/2);
  cout << ans << endl;

return 0;
}
///....


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n;
struct R{int x,c;};
int a[1050][1050],l[1050],dd[1050];
bool v[1050];
queue<R>q;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<n;j++)scanf("%d",&a[i][j]);
	for(int i=1;i<=n;i++)l[i]=1;
	for(int i=1;i<=n;i++)
	{
		if(v[i])continue;
		if(l[i]==n)continue;
		int x=a[i][l[i]];
		if(v[x])continue;
		if(a[x][l[x]]==i)q.push({i,1}),v[i]=v[x]=1;
	}
	int md=0,out=0,tot=n*(n-1)/2;
	while(!q.empty())
	{
		int x=q.front().x,c=q.front().c;
		q.pop();
		md=max(c,md);
		int nx=a[x][l[x]];
		out++;
		l[x]++;
		l[nx]++;
		if(l[x]<n)
		{
			int y=a[x][l[x]];
			if(a[y][l[y]]==x)q.push({x,c+1});
		}
		if(l[nx]<n)
		{
			int y=a[nx][l[nx]];
			if(a[y][l[y]]==nx)q.push({nx,c+1});
		}
	}
	if(out<tot)puts("-1");
	else
	{
		printf("%d\n",md);
	}
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    int k, a, b;
    cin >> k >> a >> b;
    bool ok = false;
    for (int i=0;i*k<=b;i++) {
        if(a <=i*k && i*k<= b) ok = true;
    }
    if(ok) cout << "OK";
    else cout << "NG";
}

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

using namespace std;

#define ll long long 
#define rep(n) for(ll i;i<n;i++)
int n;
int dp[100001];
int d(int n){
    if(dp[n]!=-1)return dp[n];
    int a9=1,a6=1;
    if(n==0) return 0;
    while(a9<=n){
        a9*=9;
    }
    while(a6<=n)a6*=6;
    dp[n]= min(d(n-a9/9),d(n-a6/6))+1;
    return dp[n];
}
int main(){
    cin>>n;
    rep(n+1)dp[i]=-1;
    d(n);
    cout<<d(n)<<endl;
    return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES

#include <iostream>
#include <math.h> 
#include <vector>
#include <algorithm>
#include <iomanip>      // std::setprecision
#include <map>
#include <unordered_map>
#include <string>
#include <set>
#include <unordered_set>

using namespace std;
namespace
{
	long long int encode(std::vector<bool> input, int start, int end)
	{
		long long int encoded = 0;
		for (int i = start; i < end; i++)
		{
			encoded |= input[i] << (i - start);
		}
		return encoded;
	}
}
int main()
{
	int N, M;
	std::cin >> N >> M;
	std::vector<std::vector<bool>> N_MAT(N);
	std::vector<std::vector<bool>> M_MAT(M);
	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < N; ++j)
		{
			char input;
			std::cin >> input;
			if (input == '.')
			{
				N_MAT[i].push_back(true);
			}
			else
			{
				N_MAT[i].push_back(false);
			}
		}
	}
	for (int i = 0; i < M; ++i)
	{
		for (int j = 0; j < M; ++j)
		{
			char input;
			std::cin >> input;
			if (input == '.')
			{
				M_MAT[i].push_back(true);
			}
			else
			{
				M_MAT[i].push_back(false);
			}
		}
	}
	std::vector<long long int> M_encoded;
	for (int i = 0; i < M; ++i)
	{
		M_encoded.push_back(encode(M_MAT[i], 0, M_MAT.size()));
	}
	for (int i = 0; i < (N - M+1); i++)
	{
		long long int row = encode(N_MAT[i], 0, M-1);
		for (int j = M-1; j < (N - M +1); j++)
		{
			row = (row >> 1) | (N_MAT[i][j] << (M-1));
			if (row == M_encoded[0])
			{
				bool correct = true;
				for (int k = 1; k < M; k++)
				{
					if (encode(N_MAT[i+k], j-M+1, j + M-1) != M_encoded[k])
					{
						correct = false;
						break;
					}
				}
				if (correct)
				{
					std::cout << "Yes\n";
					return 0;
				}
			}
		}
	}
	std::cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int N, M;
int cnt, a, b;
vector<vector<int> > path;
int p;
queue<int> q;
 
void bfs(){
  // チェック済みかどうかの配列
	vector<bool> check(N, true);
  vector<int> ans(N, -1);

  // 1番目のものを入れる
  check[0] = false;
	q.push(0);
  ans[0] = 0;
	
	while(q.size()){
		p=q.front(); //先頭の要素をqに入れる
		q.pop(); // 先頭の要素を取り出す
    
    for(int i: path[p]){
      if(check[i]) {
        q.push(i);
        check[i] = false;
        ans[i] = p+1;
      }
    }
	}
  // YesかNoを出力する用
  rep(i, N){
    if(ans[i] == -1){
      print("No");
      return ;
    }
  }
  print("Yes");
  for(int i = 1; i < N; i++){
    print(ans[i]);
  }
	return;
}

int32_t main()
{
	cin >> N >> M;
  path.resize(N);
  rep(i, M){
    cin >> a >> b;
    a--; b--;
    path[a].push_back(b);
    path[b].push_back(a);
  }
  bfs();

	return 0;
}

Measured memory_bytes: 9752