akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>

typedef  long long ll;
#define mop 1000000007
using namespace std;

ll dp[10001];

int main() {
    

    for(ll i=1;i<=10000;i++){
        dp[i] = mop;
    }
    ll h,n;
    cin >> h >> n;
    vector <pair<ll,ll>> v;
    for(ll i=0;i<n;i++){
        ll a,b;
        cin >> a >> b;
        pair<ll, ll> p = make_pair(a,b);
        v.push_back(p);
        ll tmp = 0;
        while(tmp <= h){
            if(tmp+a <= h) {
                dp[tmp + a] = min(dp[tmp + a], dp[tmp] + b);
            }else{
                dp[h] = min(dp[h], dp[tmp] + b);
            }
            tmp += 1;
        }

    }
//    queue <pair<ll, ll> > q;
//    for(ll i=0;i<n;i++){
//        q.push(v[i]);
//
//        dp[v[i].first] = min(dp[v[i].first], v[i].second);
//    }
//
//    while(!q.empty()){
//        pair <ll, ll> u;
//        u = q.front();
//        q.pop();
////        cout << u.first << " " << u.second << " to ";
//        if(u.first >= h){
//            u.first = h;
//            dp[u.first] = min(dp[u.first], u.second);
//            continue;
//        }
//        if(dp[u.first] < u.second){
//            continue;
//        }
//        for(ll i=0;i<n;i++){
//            pair <ll, ll> tmp;
//            tmp = u;
//            tmp.first += v[i].first;
//            tmp.second += v[i].second;
//            if(tmp.first >= h){
//                tmp.first = h;
//            }
////            cout << tmp.first << " " << tmp.second << endl;
//            if(dp[tmp.first] <= tmp.second){
//                continue;
//            }
//            dp[tmp.first] = min(dp[tmp.first], tmp.second);
//            if(tmp.first != h){
//                q.push(tmp);
//            }
//        }
//    }
    cout << dp[h] << endl;



}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int a =s.nextInt(),b=s.nextInt(),c=s.nextInt(),d=s.nextInt();
        System.out.println(Math.max(a*b,c*d));
    }

}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main(void)
{
  ll a, b, c, d; cin >> a >> b >> c >> d;
  ll k1, k2;
  k1 = (a + d - 1) / d;
  k2 = (c + b - 1) / b;
  cout << ((k2 <= k1) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = long long ;
using P = pair<ll,ll>;
// ll INF = 1000000007;
ll INF = 100100100100100;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    cin >> n;
    vi a(n), csum(n);
    rep(i,n) cin >> a.at(i);
    csum.at(0) = a.at(0);
    for(ll i=1; i<n; i++) csum.at(i) = csum.at(i-1) + a.at(i);
    ll allSum = csum.at(n-1);
    ll res = INF;
    for(ll i=0; i<n-1; i++){
        ll a = csum.at(i);
        ll b = allSum - csum.at(i);
        res = min(res, abs(a-b));
    }
    cout << res << endl;
}

Measured memory_bytes: 3456
import sys, os 
sys.setrecursionlimit(10**8)
#resource.setrlimit(resource.RLIMIT_STACK, (2**29,-1))

read = lambda : sys.stdin.readline().rstrip('\n')
tint = lambda x: [int(x) for x in x.split()]
inf = float('inf')

def main():
    n = tint(read())[0]
    stones = tint(read())
    dp = [inf]*n
    dp[0] = 0
    for i in range(n-1):
        if i+1 < n:
            dp[i+1] = min(dp[i+1], dp[i]+abs(stones[i]-stones[i+1]))
        if i+2 < n:
            dp[i+2] = min(dp[i+2], dp[i]+abs(stones[i]-stones[i+2]))
    print(dp[-1])


if __name__ == '__main__':    
    main()


Measured memory_bytes: 20956
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T = lint>
struct Edge {
	int to;
	T cost;
	Edge() {}
	Edge(int to, T cost) : to(to), cost(cost) {}
	bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

template<class T>
vector<T> Dijkstra(vector<vector<Edge<T>>> &edges, int st) {

	int V = (int)edges.size();
	const T inf = numeric_limits<T>::max() / 2;
	vector<T> cost(V, inf);
	cost[st] = 0;

	priority_queue<Edge<T>, vector<Edge<T>>, greater<Edge<T>>> p_que;
	p_que.emplace(st, cost[st]);

	while (!p_que.empty()) {

		Edge<T> now(p_que.top().to, p_que.top().cost);
		p_que.pop();

		if (cost[now.to] < now.cost) continue;
		for (const Edge<T> &e : edges[now.to]) {
			T tmp_cost = now.cost + e.cost;
			if (cost[e.to] > tmp_cost) {
				cost[e.to] = tmp_cost;
				p_que.emplace(e.to, cost[e.to]);
			}
		}
	}

	return cost; // min cost to vertex idx from st
}

template<class T>
inline bool chmin(T &a, T b) { return a > b && (a = b, true); }

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	while (true) {

		int c, n, m, s, d;
		cin >> c >> n >> m >> s >> d;
		if (c == 0) break;
		s--, d--;

		vector<vector<Edge<int>>> edges(n*(c + 1));
		for (int i = 0; i < m; i++) {
			int u, v, len;
			cin >> u >> v >> len;
			u--, v--;
			for (int j = 0; j <= c; j++) {
				edges[u * (c + 1) + j].emplace_back(v * (c + 1) + j, len);
				edges[v * (c + 1) + j].emplace_back(u * (c + 1) + j, len);
				if (j != c) {
					edges[u * (c + 1) + j].emplace_back(v * (c + 1) + (j + 1), len / 2);
					edges[v * (c + 1) + j].emplace_back(u * (c + 1) + (j + 1), len / 2);
				}
			}
		}

		auto cost = Dijkstra(edges, s * (c + 1));

		int ans = INF;
		for (int i = 0; i <= c; i++) chmin(ans, cost[d*(c + 1) + i]);

		cout << ans << "\n";
	}

	return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef pair<int, int> P;

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;}

P f(int x){
    int a = x % 10;//末尾
    int b = 0;
    while(x){
        b = x; //先頭
        x /= 10;
    }
    return P(a, b); 
}

int main(){
    int n; cin >> n;
    map<P, int> freq;
    ll ans = 0;
    for(int i = 1; i <= n; i++){            
        P p = f(i);
        freq[p]++; //先頭と末尾の同じ数をカウント
    }
    for(int i = 1; i <= n; i++){
        P p = f(i);
        P q(p.second, p.first);
        ans += freq[q]; //条件を満たせる個数を足す
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES


long long int dp[3002][3002];
pair<int ,int > ans[3002][3002];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   //	freopen("input.txt","r",stdin);
   //	freopen("output.txt","w",stdout);
	string a,b;
	cin>>a>>b;
	for(int i=1;i<=a.size();i++)
	{
		for(int j=1;j<=b.size();j++)
		{
			if(dp[i-1][j]>=dp[i][j])
			{
				dp[i][j] = dp[i-1][j];
				ans[i][j] = make_pair(i-1,j);
			}
			if(dp[i][j-1]>=dp[i][j])
			{
				dp[i][j] = dp[i][j-1];
				ans[i][j] = make_pair(i,j-1);
			}
			if(dp[i-1][j-1]+1>=dp[i][j] && a[i-1] == b[j-1])
			{
				dp[i][j] = dp[i-1][j-1]+1;
				ans[i][j] = make_pair(i-1,j-1);
			}
		}
	}
	string finale = "";
	pair<int,int> p = make_pair(a.size(),b.size());
	while(p.first > 0 && p.second > 0)
	{
		pair<int,int> temp = ans[p.first][p.second];
		if(dp[temp.first][temp.second] != dp[p.first][p.second])
		{
			finale+=a[temp.first];
		}
		p.first = temp.first;
		p.second = temp.second;
	}
	reverse(finale.begin(),finale.end());
	cout<<finale;
	return 0 ;
}

Measured memory_bytes: 141056
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <assert.h>

#define maxn 100001

using namespace std;

vector<int> g[maxn];
int height[maxn];
int cuts = 0;

int dfs( int s, int k ) {
	int height = 0;
	
	for( int nxt : g[s] ) {
		int subtree_height = dfs(nxt, k);
		if( subtree_height == k-1 ) {
			if( s > 1 ) cuts++;
		} else {
			height = max(height, subtree_height + 1); 
		}
	}
	
	return height;
}

int main( void ) {
	int n, k;
	scanf("%i %i", &n, &k);
		
	for( int i = 1; i <= n; i++ ) {
		int j;
		scanf("%i", &j);
		
		if( i == 1 ) {
			if( j != 1 ) {
				cuts = 1;
			}
		} else {
			g[j].push_back(i);
		}
	}
	
	dfs(1, k);
	
	printf("%i\n", cuts);
	
	return 0;
}

Measured memory_bytes: 12032
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

// constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
// constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s;
    cin >> s;
    if (s[s.size()-1] == 's') s += "es";
    else s += "s";
    cout << s << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const int INF=1e7;

int main(){
    string s;
    cin >> s;
    int N=-1,W=-1,S=-1,E=-1;
    for(int i=0;i<s.length();i++){
        if(s[i]=='W') W=1;
        if(s[i]=='S') S=1;
        if(s[i]=='N') N=1;
        if(s[i]=='E') E=1;
    }
    if(N*S>0&&W*E>0) puts("Yes");
    else puts("No");
    return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	a, b, c := nextInt(), nextInt(), nextInt()

	rem := 0
	in := b + c
	if a < in {
		rem = in - a
	}
	fmt.Println(rem)
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException, Exception{
		BufferedReader st = new BufferedReader(new InputStreamReader(System.in));
		int n = getInt(st);
		int[] data = getIntArry(st);
		int cnt = 0;
		int max = 0;
		for (int i=0;i<n-1;i++) {
			if (data[i] >= data[i+1]) {
				cnt++;
				if(max < cnt) {
					max = cnt;
				}
			} else {
				cnt = 0;
			}
		}
		anser(max);
	}

	private static int getInt(BufferedReader st) throws Exception, IOException {
		int num = Integer.parseInt(st.readLine());
		return num;
	}

	private static int[] getIntArry(BufferedReader st) throws Exception, IOException {
		String line = st.readLine();
		String[] strData = line.split(" ");
		int[] intData = new int[strData.length];
		for (int i = 0; i < strData.length; i++) {
			intData[i] = Integer.parseInt(strData[i]);
		}
		return intData;
	}

	private static void anser(int num) {
		System.out.println(num);
	}
}

Measured memory_bytes: 44508
import scala.io.Source.stdin

object Main {
  val v = new Array[Int](101)
  def main(args:Array[String]) =  {
    var i = 0
    stdin.getLines.foreach { a => v(a.toInt) += 1 }
    v.foreach { e =>
      if(e == v.max) println(i)
      i += 1
    }
  }
}

Measured memory_bytes: 43912
//#define _USE_MATH_DEFINES
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }
inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));


int const mod = 1e9+7;

inline int safe_mul(const int x, const int y) {
    return x * 1LL * y % mod;
}

inline void safe_add(int& x, const int y) {
    x += y;
    if (x >= mod)
        x -= mod;
}

int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("floor4.out", "w", stdout);
//    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    const int m = 13;
    vector<int> dp(m, 0);
    dp[0] = 1;

    string s;
    cin >> s;

    for (char c : s) {
        vector<int> ndp(m, 0);
        if (c == '?') {
            for (int p = 0; p < m; ++p)
            for (int v = 0; v <= 9; ++v) {
                int ne = (p * 10 + v) % m;
                safe_add(ndp[ne], dp[p]);
            }
        } else {
            int v = c - '0';
            for (int p = 0; p < m; ++p) {
                int ne = (p * 10 + v) % m;
                safe_add(ndp[ne], dp[p]);
            }
        }
        dp.swap(ndp);
    }
    cout << dp[5] << endl;
}



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

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 32768);
    static PrintWriter out = new PrintWriter(System.out);
    static StringTokenizer t;

    static String sn() {
        while (t == null || !t.hasMoreTokens()) {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return t.nextToken();
    }

    static int ni() {
        return Integer.parseInt(sn());
    }

    static long nlo() {
        return Long.parseLong(sn());
    }

    public static void main(String args[]) {
        int t = 1;//ni();
        while (t-- > 0) {
            solve();
        }
        out.close();
    }

    static long mod = 998244353;

    static long pro(long a, long b) {
        return (a % mod * b % mod) % mod;
    }

    static long add(long a, long b) {
        return (a + b) % mod;
    }

    static long maxn = 200005;

    static void solve() {
        int a=ni();
        int b=ni();
        if(a<=5)
            out.println(0);
        else if(a<=12)
            out.println(b/2);
        else
            out.println(b);
    }
}

Measured memory_bytes: 20820
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        k: usize,
        d: [i64; n],
    }
    let n_act = min(n, k);
    let mut ans = 0;
    for a in 0..n_act + 1 {
        for b in 0..n_act + 1 - a {
            let rm = k - a - b;
            let mut acc_vec: Vec<i64> = d.iter().take(a).chain(d.iter().skip(n-b)).cloned().collect();
            acc_vec.sort();
            let acc = acc_vec.iter().enumerate().filter(|&(i, x)| rm <= i || (rm > i && *x > 0)).map(|(_, x)| *x).sum();
            ans = max(ans, acc);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <cctype>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    string s;
    int n,k;
    cin >> n >> s >> k;
    rep(i,s.size()) if(s.at(i) != s.at(k-1)) s.at(i)='*';
    cout << s << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var sp = new Tuple<string, int,int>[N];
            for (int i = 0; i < N; i++)
            {
                var r = Console.ReadLine().Split();
                sp[i] = new Tuple<string, int,int>(r[0], int.Parse(r[1]),i+1);
            }

            Array.Sort(sp, (a, b) => a.Item1 != b.Item1 ? a.Item1.CompareTo(b.Item1) : -a.Item2.CompareTo(b.Item2));

            foreach (var item in sp)
            {
                Console.WriteLine(item.Item3);
            }
        }
    }
}


Measured memory_bytes: 27760
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	string Sp,T;
	vector<string> Skoho;
	scan(Sp);scan(T);
	rep(i,Sp.size()){
		string Skari=Sp;
		for(int j=i;j<Sp.size();j++){
			if(Sp[j]!='?'&&Sp[j]!=T[j-i]) break;
			else Skari[j]=T[j-i];
			if(j-i==T.size()-1){
				rep(k,Skari.size()){
					if(Skari[k]=='?') Skari[k]='a';
				}
				Skoho.push_back(Skari);
			}
		}
	}
	sort(Skoho.begin(),Skoho.end());
	if(Skoho.empty()) prin("UNRESTORABLE");
	else prin(Skoho[0]);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	char s[10];
	int a[10];
	while(cin>>s[0]){
	a[0]=s[0]-'0';
	for(int i=1;i<10;i++){
		cin>>s[i];
		a[i]=s[i]-'0';
	}
	for(int i=9;i>0;i--){
		for(int j=0;j<i;j++){
			a[j]=(a[j]+a[j+1])%10;
		}
	}
	cout<<a[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1136
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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; }

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int main(){
    ios::sync_with_stdio(false);
    ll x,y; cin >>x >> y;
    ll ans=0;
    while(x<=y){
        x*=2;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin >> s;
  int N = s.size();

  if(s == "AKIHABARA") cout << "YES" << endl;
  else if(s == "AKIHABAR") cout << "YES" << endl;
  else if(s == "AKIHABRA") cout << "YES" << endl;
  else if(s == "AKIHBARA") cout << "YES" << endl;
  else if(s == "KIHABARA") cout << "YES" << endl;
  else if(s == "AKIHABR") cout << "YES" << endl;
  else if(s == "AKIHBAR") cout << "YES" << endl;
  else if(s == "KIHABAR") cout << "YES" << endl;
  else if(s == "AKIHBRA") cout << "YES" << endl;
  else if(s == "KIHABRA") cout << "YES" << endl;
  else if(s == "KIHBARA") cout << "YES" << endl;
  else if(s == "AKIHBR") cout << "YES" << endl;
  else if(s == "KIHABR") cout << "YES" << endl;
  else if(s == "KIHBAR") cout << "YES" << endl;
  else if(s == "KIHBRA") cout << "YES" << endl;
  else if(s == "KIHBR") cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
D,L={},[]
for _ in range(N):
    a,b=map(int,input().split())
    L.append(a)
    if a in D:D[a]=D[a]+b
    else:D[a]=b
l=list(set(L))
l.sort()
for i in l:
    K-=D[i]
    if K<=0:
        print(i)
        exit()

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

int xo(int a){
	if(a%4 == 0)
      	return a;
  	if(a%4 == 1)
      	return 1;
 	if(a%4 ==2 )
      	return a+1;
 	if(a%4 == 3)
      	return 0;
}

int a,b;
main(){
	cin >> a >> b;
  	cout<<(xo(b)^xo(a-1));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9 + 7;
const int INT_MOD=1e9+7;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 0; i <= n; i++)
#define rrep(i,n) for(int i=n;i>0;i--)
#define RREP(i,n) for(int i=n;i>=0;i--)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
signed main(){
    int n;cin>>n;
    if(n%2==1) cout<<n/2<<endl;
    else cout<<n/2-1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void BubbleSort( int *A, int n ) 
{
	int i,j;
	int tmp;
	int cnt;
	
	cnt=0;
	for( i=0; i<n; i++ ) {
		for( j=n-1; i<j; j-- ) {
			if( A[j] < A[j-1] ) {
				tmp=A[j-1];
				A[j-1]=A[j];
				A[j]=tmp;
				cnt++;
			}
		}
	}
	for( i=0; i<n; i++ ) {
		printf( "%d", A[i] );
		if( n-1 != i ) {
			printf( " " );
		}
	}	
	printf( "\n" );	
	printf( "%d\n", cnt );
	
	return;
}

int main( void ) 
{
	int n;
	int A[101];
	int i;

	scanf( "%d", &n );
	for( i=0; i<n; i++ ) {
		scanf( "%d", &A[i] );
	}
	
	BubbleSort( A, n );
	
	return 0;
}

Measured memory_bytes: 604
#include<stdio.h>

int main(void){
    int N, Y;
    int x, y, z;
    scanf("%d %d",&N,&Y);

    for(x = 0;x <= N;x++){
        for(y = 0;y <= N - x;y++){
            z = N - x - y;
            int tot = 10000*x + 5000*y + 1000*z;
            // printf("x = %d, y = %d, z = %d\n",x,y,z);
            if(tot == Y){
                printf("%d %d %d", x, y, z);
                return 0;
            }
        }
    }
    printf("-1 -1 -1");
    return 0;   
}

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

using namespace std;

#define int long long

int n;
vector<int> a;

main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < n; i++){
        int t;
        cin >> t;
        a.push_back(t);
    }
    int mx = INT_MIN;
    for(int i = 0; i < n; i++) mx = max(mx, a[i]);
    if(mx < 0){
        cout << mx << endl;
        vector<int> op;
        int i;
        for(i = 0; a[i] != mx; i++) op.push_back(0);
        for(int j = n - 1; j > i; j--) op.push_back(j - i);
        cout << op.size() << endl;
        for(auto u: op) cout << u + 1 << '\n';
        exit(0);
    }
    int so = 0, se = 0;
    for(int i = 0; i < n; i++){
        if(i&1) se += max(0ll, a[i]);
        else so += max(0ll, a[i]);
    }
    vector<int> op;
    if(se > so){
        for(int i = 0; i < n; i++){
            if(!(i&1)) a[i] = -1;
        }
    }
    else{
        for(int i = 0; i < (int)a.size(); i++){
            if(i&1) a[i] = -1;
        }
    }
    reverse(a.begin(), a.end());
    while(a.back() < 0){
        op.push_back(0);
        a.pop_back();
    }
    reverse(a.begin(), a.end());
    while(a.back() < 0){
        op.push_back(a.size() - 1);
        a.pop_back();
    }
    vector<int> st;
    for(int i = 0; i < (int)a.size(); i++){
        st.push_back(a[i]);
        while(st.size() >= 3){
            int k = st.size();
            if(st[k - 3] >= 0 && st[k - 1] >= 0 || st[k - 3] < 0 && st[k - 1] < 0){
                int add = st[k - 3] + st[k - 1];
                op.push_back(k - 2);
                for(int j = 0; j < 3; j++) st.pop_back();
                st.push_back(add);
            }
            else break;
        }
    }
    while(st.back() < 0){
        op.push_back(st.size() - 1);
        st.pop_back();
    }
    cout << st.front() << endl;
    cout << op.size() << endl;
    for(auto u: op) cout << u + 1 << '\n';
}


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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

int main()
{
    canhazfast();

    int n;
    map<int, int> mp;
    vi v, f;
    bool ans;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        ++mp[a];
    }
    for (auto &p : mp) {
        v.pb(p.fir);
        f.pb(p.sec);
    }
    switch (mp.size()) {
    case 1:
        ans = v[0] == 0;
        break;
    case 2:
        ans = n%3 == 0 && v[0] == 0 && f[0] == n/3;
        break;
    case 3:
        ans = n%3 == 0 && (v[0]^v[1]^v[2]) == 0;
        sort(all(f));
        ans = ans && f[0] == f[1] && f[0] == f[2];
        break;
    default:
        ans = false;
    }
    cout << (ans ? "Yes\n" : "No\n");

    return 0;
}


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

int main(){
  int s;
  cin>>s;
  vector<long long> dp(s+1,0);
  long long max = pow(10,9)+7;
  
  dp[0] = 1;
  for(int i=3;i<=s;i++){
    dp[i] = (dp[i-1]+dp[i-3])%max;
  }
  cout<<dp[s]<<endl;
  return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#define int long long
using namespace std;
signed main() {
	int n, a, ans = 0, b = 0; cin >> n;
	for (int h = 1; h <= n; h++) {
		cin >> a;
		if (ans >= a) { b++; }
		ans = a;
	}
	cout << b + 1 << endl;
	cout << n << endl;
}


Measured memory_bytes: 3108
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    sevens = 0
    for i in range(1, K + 1):
        sevens = sevens * 10 + 7
        sevens %= K
        if sevens == 0:
            print(i)
            exit()
    print(-1)


Measured memory_bytes: 63236
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b;
	cin >> a >> b;
	if(a*b % 2 == 0) cout << "Even" << endl;
	else cout << "Odd" << endl;
	return 0;
}

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

using namespace std;

const int N = 2e5 + 5;;

int n, x, a[N];
long long sum[N];

int main() {
  scanf("%d %d", &n, &x);
  sum[0] = 0;
  for (int i = 0; i < n; ++i)
    scanf("%d", a+i), sum[i+1] = sum[i] + a[i];
  long long ans = -1;
  for (int c = 1; c <= n; ++c) {
    long long now = 1LL * c * x;
    int last = 0;
    // for (int i = 0; i < n; ++i) {
    //   int d = a[i] - last;
    //   int sisa = n-i;
    //   int down = sisa / c;
    //   int r = sisa - down * c;
    //   long long cost = (down > 0 ? 1LL * (down + 1) * (down + 1) * (c - r) : 0) + 1LL * (down + 2) * (down + 2) * r;
    //   if (down > 0)
    //     cost += c;
    //   else
    //     cost += r;
    //   now += 1LL * d * cost;
    //   last = a[i];
    // }
    for (int i = n, cur = 1; i > 0; i -= c, ++cur) {
      int from = max(i-c, 0);
      long long w = 1LL * (cur+1) * (cur+1);
      long long z = sum[i] - sum[from];
      z -= sum[max(i - c, 0)] - sum[max(from - c, 0)];
      now += w * z;
    }
    now += sum[n] - sum[n-c];
    if (ans < 0 || ans > now)
      ans = now;
  }
  ans += 1LL * x * n;
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
template<class T>inline bool chmax(T& a, T b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T& a, T b){if(a > b){a = b; return 1;}return 0;}
const ll INF = 1LL<<60;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    ll k, a, b; cin >> k >> a >>b;
    if(a>b) cout << k+1 << endl;
    else{
        if(a+2 >= b) cout << k+1 << endl;
        else{
            ll res = 0;
            if(k <= a){
                cout << k+1 << endl;
            }
            else{
                k -= a+1;
                res += b;
                if(k == 1){
                    res +=1;
                    cout << res << endl;
                }
                else{
                    if(k%2 == 0){
                        ll num = k/2;
                        res += num*b - num*a;
                        cout << res << endl;
                    }
                    else{
                        ll num = k/2;
                        res += num*b - num*a;
                        cout << res+1 << endl;
                    }
                }
            }
        }
    }

}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long int
#define db double
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define endl "\n"
#define mp make_pair
#define f first
#define s second
ll power(ll x, ll y, long long int mod = 1000000007){ ll ans = 1;x %= mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
ll modInverse(ll a, ll m){ll m0 = m;ll y = 0, x = 1;if (m == 1) return 0;while (a > 1){ ll q = a / m;ll t = m;m = a % m,a = t;t = y;y = x - q * y;x = t;}if(x < 0) x += m0;return x;}

int main() {
    fastio;
    int n, k;
    cin >> n >> k;
    
    int h[n], dp[n] = {0};
    
    for(int i = 0; i < n; i++) {
        cin >> h[i];
    }
    dp[1] = abs(h[0] - h[1]);
    
    for(int i = 2; i < n; i++) {
        int j = i - 1;
        dp[i] = INT_MAX;
        int times = k;
        while(times-- && j >= 0) {
            dp[i] = min(dp[i], abs(h[i] - h[j]) + dp[j]);
            // if(i == 3) {
            //     //cout << abs(h[i] - h[j]) << " " << dp[j] << endl;
            // }
            j--;
        }
        //cout << dp[i] << " " << h[i] << " ";
        //dp[i] = min((abs(h[i] - h[i-2]) + dp[i-2]), (abs(h[i] - h[i-1]) + dp[i-1]));
    }
    
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#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(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, std::string S) {
  ll cnt = 0;
  for (int i = 0; i <= 9; i++) {
    int ci = -1;
    rep(ii, N) {
      if (S.at(ii) == '0' + i) {
        ci = ii;
        break;
      }
    }
    if (ci == -1) continue;

    for (int j = 0; j <= 9; j++) {
      int cj = -1;
      FOR(ii, ci + 1, N) {
        if (S.at(ii) == '0' + j) {
          cj = ii;
          break;
        }
      }
      if (cj == -1) continue;

      for (int k = 0; k <= 9; k++) {
        int ck = -1;
        FOR(ii, cj + 1, N) {
          if (S.at(ii) == '0' + k) {
            ck = ii;
            break;
          }
        }
        if (ck == -1) {
          continue;
        } else {
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
}

int main() {
  cin.tie(0);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  string S;
  cin >> S;
  solve(N, S);
  return 0;
}


Measured memory_bytes: 384
/*
	Name: Hopscotch Addict 
	Author: Jerryjiang090210
	Date: 30/06/19 15:18
	Description: AoShi Xu's code <Hopscotch Addict>
*/
#include<bits/stdc++.h>
using namespace std;
const int maxn=(1e5+10);
int n,m,s,t,dis[maxn];
vector<int> graph[maxn];
bool vis[maxn];
void dfs(int x)
{
	//cout<<x<<endl; 
	vis[x]=true;
	for(int i=0;i<graph[x].size();i++)
	{
		int to=graph[x][i];
		if(vis[to])
		{
			continue;
		}
		dfs(to);	
	}
}
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		--x,--y;
		graph[x].push_back(y);
	}
	cin>>s>>t;
	--s,--t;
	/*puts("////////////////////////");
	for(int i=0;i<n;i++)
	{
		cout<<i<<": ";
		for(int j=0;j<graph[i].size();j++)
			cout<<graph[i][j]<<" ";
		cout<<endl;
	}*/
	//cout<<s<<" "<<t<<endl;
	dfs(s);
	if(!vis[t])
	{
		cout<<-1<<endl;
		return 0;
	}
	//puts("Over DFS!!!");
	queue<int> q;
	q.push(s);
	memset(dis,63,sizeof(dis));
	dis[s]=0;
	while(q.size())
	{
		int x=q.front();
		q.pop();
		for(int i=0;i<graph[x].size();i++)
		{
			int a=graph[x][i];
			for(int j=0;j<graph[a].size();j++)
			{
				int b=graph[a][j];
				for(int k=0;k<graph[b].size();k++)
				{
					int c=graph[b][k];
					if(dis[c]<(1e9))
						continue;
					if(c==t)
					{
						cout<<dis[x]+1<<endl;
						return 0;
					}
					dis[c]=dis[x]+1;
					q.push(c);
				}
			}
		}
	}
	cout<<-1<<endl;
	return 0;
}

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

#define long long long int

using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    int s = 0;
    int res = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (i == n - 1 || a[i + 1] > a[i]) {
            s = 0;
        } else {
            s++;
        }
        res = max(res, s);
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define ll long long
#define bg begin
namespace IO{
	
cs int RLEN=1<<20|1;
char ibuf[RLEN],*ib,*ob;
inline char gc(){
	(ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob)?EOF:*ib++;
}
#define gc getchar
inline int read(){
	char ch=gc();
	int res=0;bool f=1;
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
	return f?res:-res;
}
inline int readstring(char *s){
	int top=0;char ch=gc();
	while(isspace(ch))ch=gc();
	while(!isspace(ch)&&ch!=EOF)s[++top]=ch,ch=gc();
	return top;
}
inline char readchar(){
	char ch=gc();
	while(isspace(ch))ch=gc();
	return ch;
}

}
using IO::read;
using IO::readstring;
using IO::readchar;
template<typename tp>inline void chemx(tp &a,tp b){a=max(a,b);}
template<typename tp>inline void chemn(tp &a,tp b){a=min(a,b);}
cs int N=128,C=62;
inline bool comp(cs string &a,cs string &b){
	return a.size()<b.size();
}
inline char id(int x){
	if(x<26)return 'a'+x;
	if(x>51)return '0'+(x-52);
	return 'A'+(x-26);
}
inline int query(string x){
	cout<<"? "<<x<<endl;
	return read();
}
int n;
inline bool check(string x){
	return query(x)+x.size()==n;
}
int main(){
	vector<string>tp;
	for(int i=0;i<C;i++){
		string x(N,id(i));
		int vl=N-query(x);
		n+=vl;
		if(vl)tp.pb(string(vl,id(i)));
	}
	while(tp.size()>1){
		sort(tp.bg(),tp.end(),comp);
		string a=tp[0],b=tp[1],res;
		tp.erase(tp.bg(),tp.bg()+2);
		while(a.size()&&b.size()){
			if(check(res+a[0]+b)){
				res+=a[0],a.erase(a.bg());
			}
			else res+=b[0],b.erase(b.bg());
		}
		res+=a,res+=b;
		tp.pb(res);
	}cout<<"! "<<tp[0]<<endl;
}

Measured memory_bytes: 3760
N=input()
N=N[len(N)-1]
N=int(N)
if N==2 or N==4 or N==5 or N==7 or N==9:
    print("hon")
elif N==0 or N==1 or N==6 or N==8:
    print("pon")
else:
    print("bon")

Measured memory_bytes: 9180
N = int( input() )
d = [ [] for _ in range( N )]

for i in range( N - 1 ):
  v, u, w = map( int, input().split() )
  d[ v - 1 ].append(( u - 1, w ))
  d[ u - 1 ].append(( v - 1, w ))

s = [( 0, 0 )]
l = [ -1 ] * N
while s != []:
  a, w = s.pop()
  l[ a ] = w % 2
  for i, j in d[ a ]:
    if l[ i ] == -1:
      s.append( ( i , j + w ) )
for i in l:
  print( i )

Measured memory_bytes: 38828
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>

#define PI 3.141592

using namespace std;

int main (void){
    int N;
    vector <string> S;
    string s;
    set <string> val;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>s;
        S.push_back(s);
    }
    for(int k=0;k<N;k++){
        val.insert(S[k]);
    }
    cout<<val.size()<<endl;
    return 0;
}

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


int main(void) {
	string S, T; cin >> S >> T;
	T += T;
	int ans = T.find(S);
	
	if (ans == string::npos) {
		cout << "No" << endl;
	}
	else { cout << "Yes" << endl; }
	return 0;
}

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

using ll = long long;
using ld  = long double;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll)(n) ; i++ )
#define DREP(i,m,n) for(ll i=(ll)(m) ; i > (ll)(n) ; i-- )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //




// --------- library end - //


int main(){

  ll N = il();

  ll rs = 0;
  ll ws = 0;
  string cs;
  rep(i, N){
    char c = ic();
    if (c == 'R') rs++;
    else ws++;
    cs.p_b(c);
  }

  if (rs == 0 || ws == 0){
    cout << 0 << endl;
    return 0;
  }

  // 入れ替えを行う
  // 0 ~ rs-1 の範囲にある wの数が答え
  ll ans = 0;
  rep(i, rs){
    if (cs[i]=='W') ans++;
  }

  cout << ans << endl;


}

Measured memory_bytes: 3804