akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
constexpr int loose = 0;
constexpr int tight = 1;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll dp[101010];

ll dfs(Graph& g,Array& used, int v){
	if(used[v]) return dp[v];
	used[v]=true;
	dp[v]=0;
	for(auto e:g[v]){
		chmax(dp[v],dfs(g,used,e.to)+1);
	}
	return dp[v];
}

void solve(){
	ll n,m;
	cin>>n>>m;
	Graph g(n);
	REP(i,m){
		ll x,y;
		cin>>x>>y;
		x--;y--;
		add_edge(g,x,y,1,false,0);
	}

	Array used(n,false);
	ll ans=0;
	REP(i,n) if(!used[i]) chmax(ans,dfs(g,used,i));
	cout<<ans<<en;
}

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

    solve();
    return 0;
}

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

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

    int n,t=1,cnt=0;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++)
        cin>>a[i];
    for(int i=0; i<n ; i++)
    {
        if(a[i]==t)
            cnt++,t++;
    }
    if(cnt==0)
        cout<<"-1"<<'\n';
    else
    cout<<n-cnt;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int ro[7],cl[7],h,w,k,ans=0 ;
string s[7] ;
void fun(int p)
{
    if(p>max(h,w))
    {
        string ss[7] ;
        //cout<<"here "<<endl ;
        for(int i = 1 ; i <= h ; i++) ss[i]=s[i] ;
        for(int i = 1 ; i <= h ; i++)
        {
            if(ro[i])
            {
                for(int j = 1 ; j <= w ; j++) ss[i][j]='.' ;
            }
        }
        for(int j = 1 ; j <= w ; j++)
        {
            if(cl[j])
            {
                for(int i = 1 ; i <= h ; i++) ss[i][j]='.' ;
            }
        }
        int ct=0 ;
        for(int i = 1 ; i <= h ; i++)
            for(int j = 1 ; j <= w ; j++)
            if(ss[i][j]=='#') ct++ ;
        //for(int i = 1 ; i <= h ; i++) cout<<ro[i]<<" " ; cout<<endl ;
        //for(int i = 1 ; i <= w ; i++) cout<<cl[i]<<" " ; cout<<"here end"<<endl ;
        if(ct==k)// ans++ ;
        {
            /*for(int i = 1 ; i <= h ; i++) cout<<ro[i]<<" " ; cout<<endl ;
            for(int i = 1 ; i <= w ; i++) cout<<cl[i]<<" " ; cout<<"here end"<<endl ;
            for(int i = 1 ; i <= h ; i++){
               //for(int j = 1 ; j <= w ; j++)
              //cout<<ss[i][j] ;
              cout<<ss[i]<<endl ;
             //  cout<<endl ;
            }*/
           // cout<<ct<<" "<<k<<endl ; cout<<endl ;
            ans++ ;
        }
        return ;
    }
    if(p<=h && p<=w)
    {
        ro[p]=1 ; cl[p]=1 ;
        fun(p+1) ;
        ro[p]=0 ; cl[p]=0 ;
    }
    if(p<=h)
    {
        ro[p]=1 ;
        fun(p+1) ;
        ro[p]=0 ;
    }
    if(p<=w)
    {
        cl[p]=1 ;
        fun(p+1) ;
        cl[p]=0 ;
    }
    fun(p+1) ;
}
int main()
{
    cin>>h>>w>>k ;
    for(int i = 1 ; i <= h ; i++) {cin>>s[i] ; s[i]='*'+s[i] ;}
    fun(1) ;
    cout<<ans<<endl ;
}


Measured memory_bytes: 3584
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const ll INF=1000000007LL;
typedef pair<int,int> P;
bool tin(int a,int b,int c){
	if(a==b||b==c||a==c)return false;
	return true;
}
int main() {
	int n,a[301][301];
	cin>>n;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			cin>>a[i][j];
		}
	}
	bool b=false;
	bool c=false;
	ll ans=0;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			c=false;
			for(int k=1;k<=n;++k){
				if(tin(i,j,k)){
					if(a[i][j]>a[i][k]+a[j][k]){
						b=true;
						break;
					}
					if(a[i][j]==a[i][k]+a[j][k])c=true;;

				}
			}
			if(!c)ans+=a[i][j];
			if(b)break;
		}
		if(b)break;
	}
	if(b)cout<<-1<<endl;
	else cout<<ans/2<<endl;
	return 0;
}


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

int main() {
  int N, K; cin >> N >> K;
  int A[N+1];
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
  }
  int ans = 0;
  int save_i;
  for (int i = K; i < N; i += K-1) {
    ans++;
    save_i = i;
  }
  if (save_i < N) {
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
open Printf open Scanf
module MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v end
module MyInt64 = struct
	let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let labs p = if p < 0L then -1L*p else p let (~|) p = Int64.to_int p let (~~|) p = Int64.of_int p let input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let print_i64_endline n = n |> Int64.to_string |> print_endline let (mod) m n = m - (m/n) * n let (%) = (mod) let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n) let lcm m n = (m*n) / gcd m n let rep from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod ~~| !i with | `Break -> f := false | _ -> i := !i +$ 1; done let repb from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod (~~| !i) with | `Break -> f := false | _ -> i := !i +$ 1 done; !f let repm from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod (~~| !i) !m with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; !m let repmb from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod (~~| !i) !m with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; (!m,!f) let string_of_list ?(separator=" ") f ls = let rec f0 a s = match a with | [] -> s | [h] -> s ^ (f h) ^ separator | h::t -> f0 t (s ^ (f h) ^ separator) in f0 ls "" let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) [] let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
	let (@@@) = (@) let (@) a i = a.(~|i) let (<@) a (i,v) = a.(~|i) <- v
	let ceildiv m n = (m+n-1L) / n
end open MyInt64

let () =
	let a,b,c,x,y = get_5_i64 0 in
	(
		if a+b <= 2L*c then a*x+b*y
		else if x >= y then (
			if a >= 2L*c then 2L*c*x
			else 2L*c*y + a*(x-y)
		) else (
			if b >= 2L*c then 2L*c*y
			else 2L*c*x + b*(y-x)
		)
	)
	|> printf "%Ld\n"

Measured memory_bytes: 2432
#include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<bits/stdc++.h>
using namespace std;

int main()
{
	string s;
	cin>>s;
	int l=s.size();
	for(register int i=0;i<l;i++)
    {
        if(s[i]=='C')
        {
            for(register int j=i+1;j<l;j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 256
/*  .　　∧_∧
   　（ ´・ω・)
   　//＼￣￣旦＼
   ／/ ※ ＼＿＿＿＼
   ＼＼ 　※ 　※ 　※ ヽ
   　 ＼ヽ-＿_＿--＿__ヽ*/

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define vvsort(v) sort(v.begin(),v.end(),greater<int>());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
typedef priority_queue<int> pq;
typedef priority_queue<int,vector<int>,greater<int> > rpq;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
const double PI=acos(-1.0);
//-------------------------------------------------------------------------------------------------------------------------------------------//
int dp[100][100];
int a[1000],b[1000],c[1000];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			dp[i][j]=inf;
		}
	}
	for(int i=0;i<m;i++){
		cin>>a[i]>>b[i]>>c[i];
		a[i]--;b[i]--;
		dp[a[i]][b[i]]=dp[b[i]][a[i]]=c[i];
	}
	for(int k=0;k<n;k++){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
			}
		}
	}
	int ans=0;
	for(int i=0;i<m;i++){
		if(dp[a[i]][b[i]]!=c[i]){
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())
alfa = {1:'a',2:'b',3:'c',4:'d',5:'e',6:'f',7:'g',8:'h',9:'i',10:'j'}
end = [i+1 for i in range(N)]
s = [1 for i in range(N)]
def checks(s):
    if s[0] != 1:
        return False
    else:
        x = 1
        count = 1
        ch = 0
        for i in range(N):
            if s[i] == count:
                count += 1
            elif s[i] > count:
                ch = 1
                break
        if ch == 1:
            return False
        else:
            return True
            
def get_next(s):
    for i in range(1,N):
        y = list(s)
        y[-1*i] += 1
        #print(y)
        for j in range(1,i):
            y[-1*j] = 1
            #print(y)
        if checks(y):
            return(y)
            break
    return(s)
while s != end:
    #3print(end,s)
    ans = []
    for i in s:
        ans.append(alfa[i])
    print(''.join(ans))
    s = get_next(s)
ans = []
for i in s:
    ans.append(alfa[i])
print(''.join(ans))

Measured memory_bytes: 4436
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1e9 + 7;
vector<vector<int>>a;
int n;
ll dp[25][1<<22];
ll  rec(int curr,int mask) {
    if(curr == n) return 1;
    if(dp[curr][mask]!=-1) return dp[curr][mask];
    ll ans = 0;
    for(int i = 0;i<n;i++) {
        if(a[curr][i]== 1 && !(((1<<i)& mask)==(1<<i))) {
            ans = (ans + rec(curr+1,mask|(1<<i)))%mod;
        }
    }
    return dp[curr][mask] = ans;
}
int main() {
    cin>>n;
    memset(dp,-1,sizeof(dp));
    a.resize(n,vector<int>(n));
    for(int i =0;i<n;i++) {
        for(int j = 0;j<n;j++) {
            cin>>a[i][j];
        }
    }
    cout<<rec(0,0)<<"\n";
}

Measured memory_bytes: 822668
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
#include <map>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<string> W(N);
	for (int i = 0; i < N; i++)
	{
		cin >> W[i];
	}

	bool flag = true;
	for (int i = 1; i < N; i++)
	{
		if (!(W[i][0] == W[i - 1][W[i - 1].length() - 1])) {

			flag = false;
			break;
		}
		for (int j = 0; j < i; j++)
		{
			if (W[i] == W[j]) {
				flag = false;
			}

		}
	}
	
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}



Measured memory_bytes: 256
#define CPP17
#include <limits>
#include <initializer_list>
#include <utility>
#include <bitset>
#include <tuple>
#include <type_traits>
#include <functional>
#include <string>
#include <array>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <algorithm>
#include <complex>
#include <random>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <regex>
#include <cassert>
#include <cstddef>
#ifdef CPP17
#include <variant>
#endif

// Yay!!
#define endl codeforces

// macros for iterator
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)

// alias
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;

// variadic min/max
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }

// variadic chmin/chmax
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

// multi demension array
template <typename T, std::size_t Head, std::size_t... Tail> struct multi_dim_array { using type = std::array<typename multi_dim_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dim_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t... Args> using mdarray = typename multi_dim_array<T, Args...>::type;

#ifdef CPP17
// fill container
template <typename T, typename F, typename... Args> 
void fill_seq(T &t, F f, Args... args) { if constexpr (std::is_invocable<F, Args...>::value) { t = f(args...); } else { for (ssize_t i = 0; i < t.size(); i++) fill_seq(t[i], f, args..., i); } }
#endif

// make multi dimension vector
template <typename T> vec<T> make_v(ssize_t sz) { return vec<T>(sz); }
template <typename T, typename... Tail> auto make_v(ssize_t hs, Tail&&... ts) { auto v = std::move(make_v<T>(std::forward<Tail>(ts)...)); return vec<decltype(v)>(hs, v); }

// init
namespace init__ { 
struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; 
}


int main() {
    ll a;
    std::string b;
    std::cin >> a >> b;
    auto tmp = b.substr(0, b.size() - 3);
    ll bb = std::stoll(b);
    bb *= 10;
    bb += b[b.size() - 2] - '0';
    bb *= 10;
    bb += b[b.size() - 1] - '0';
    ll ans = a * bb;
    std::cout << ans / 100 << "\n";
    return 0;
}


Measured memory_bytes: 3656
N = int(input())
W = [input() for _ in range(N)]
ary = [W[0]]

for i in range(N-1):
    if W[i][-1] != W[i+1][0] or W[i+1] in ary:
        print('No')
        exit()
    ary.append(W[i])
print('Yes')


Measured memory_bytes: 38384
import java.util.*;
import java.util.stream.*;

/**
 * LIS(Longest increasing subsequence) を用いた解法
 */
public class Main {
	Scanner sc;
	int N;
	int[] a;
	int[] lenTable; // 広義単調減少列の各長さでの右端最大値 table
	int len; // lenTable の -1 でない数
	
//=============
// constructor
//
	public Main() {
		sc = new Scanner(System.in);
	}
	
//==================
// instance methods
//
	private void input() {
		N = sc.nextInt();
		a = new int[N];
		IntStream.range(0, N).forEach(i -> a[i]=sc.nextInt());
		lenTable = new int[N+1]; // [0] は使わない
		Arrays.fill(lenTable, -1);
		len = 0;
	}
	
	private void output() {
			out(len);
	}
	
	private void out(Object o) {
		System.out.println(o);
		System.out.flush();
	}
	
	/**
	 * 計算本体
	 */
	private void calc() {
		for (int i = 0; i < N; i++) {
			int v = a[i];
			// v を用いて lenTable を更新する
			updateLenTable(v);
		}
	}

	/**
	 * 数列の右に newValue を追加した場合、lenTable を更新する。
	 * 
	 * @param newValue 数列の右に追加する数
	 */
	private void updateLenTable(int newValue) {
		// newValue より真に小さい最初の index を探す
		// newValue-0.5 の入る位置を探す
		int left = 1;
		int right = len+1; // 必ず -1 のところにする
		while (left <= right) {
			int mid = (left + right) / 2;
			int mval = lenTable[mid];
			
			if (mval > newValue-0.5) {
				left = mid + 1;
			} else if (mval < newValue-0.5) {
				right = mid - 1;
			} else {
				// ここにはこない
			}
		}
		if (lenTable[left] == -1) len++;
		lenTable[left] = newValue;
	}
	
//======
// main
//
	public static void main(String[] args) throws Exception {
		Main m = new Main();
		m.input();
		m.calc();
		m.output();
	}
}


Measured memory_bytes: 51424
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll Mod = 1e9 + 7;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    int n , a , b;
    cin >> n >> a >> b;
    int ans = 1000000;
    for(int i = 0 ;i < n ;i++)
        ans = min(ans , a*i + b);
    ans = min(ans , n*a);
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)


int main() {
	ll n, k, q;
	cin >> n >> k >> q;
	int seikaisuu[100001] = {};
	FOR(i, 1, q) {
		int a;
		cin >> a;
		seikaisuu[a]++;
	}
	int jouken = q - k;
	FOR(i, 1, n) {
		if (seikaisuu[i] > jouken) {
			ps(Yes)
		}
		else {
			ps(No)
		}
	}
	return(0);
}

Measured memory_bytes: 1024
a1 = map(int, input().split())
a2 = map(int, input().split())
a3 = map(int, input().split())
bingo = []
bingo += a1
bingo += a2
bingo += a3
n = int(input())
b = [0] * n
ans = [0] * 9
for i in range(n):
    b[i] = int(input())
for i in range(n):
    for j in range(9):
        if b[i] == bingo[j]:
            ans[j] = 1

if ans[0] == 1 and ans[1] == 1 and ans[2] == 1:
    print('Yes')
    exit()

if ans[3] == 1 and ans[4] == 1 and ans[5] == 1:
    print('Yes')
    exit()

if ans[6] == 1 and ans[7] == 1 and ans[8] == 1:
    print('Yes')
    exit()

if ans[0] == 1 and ans[3] == 1 and ans[6] == 1:
    print('Yes')
    exit()

if ans[1] == 1 and ans[4] == 1 and ans[7] == 1:
    print('Yes')
    exit()

if ans[2] == 1 and ans[5] == 1 and ans[8] == 1:
    print('Yes')
    exit()

if ans[0] == 1 and ans[4] == 1 and ans[8] == 1:
    print('Yes')
    exit()

if ans[2] == 1 and ans[4] == 1 and ans[6] == 1:
    print('Yes')
    exit()

print('No')

Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        if (a.substring(a.length() - 1, a.length()).equals(b.substring(0, 1))) {
            if (b.substring(b.length() - 1, b.length()).equals(c.substring(0, 1))) {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }
}


Measured memory_bytes: 23252
#include<iostream>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  int m=0,n=0;
  for(int i=0;i<b;i++)
  {
    m=10*m+a;
  }
  for(int i=0;i<a;i++)
  {
    n=10*n+b;
  }
  if(m>n)
    cout<<m;
  else
    cout<<n;
  return 0;
}

Measured memory_bytes: 256
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

N, A, B, C =  map(int, sys.stdin.readline().split())
l = [int(sys.stdin.readline()) for i in range(N)]
INF = 10 ** 9

def dfs(idx, a, b, c):
    if idx >= N:
        return abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a, b, c) > 0 else INF
    n_t = dfs(idx + 1, a, b, c)
    a_t = dfs(idx + 1, a + l[idx], b, c) + 10
    b_t = dfs(idx + 1, a, b + l[idx], c) + 10
    c_t = dfs(idx + 1, a, b, c + l[idx]) + 10
    return min(n_t, a_t, b_t, c_t)

print(dfs(0,0,0,0))

Measured memory_bytes: 69848
class UnionFind:
    def __init__(self, n):
        self._n = n
        self._table = [-1]*n

    def _root(self, x):
        stack = []
        while self._table[x] >= 0:
            stack.append(x)
            x = self._table[x]
        for y in stack:
            self._table[y] = x
        return x
    
    def unite(self, x, y):
        x, y = self._root(x), self._root(y)
        if x == y:
            return
        if x > y:
            x, y = y, x
        self._table[x] += self._table[y]
        self._table[y] = x
    
    def same(self, x, y):
        return self._root(x) == self._root(y)

    def count_members(self, x):
        return -self._table[self._root(x)]
    
    def count_groups(self):
        return len({self._root(i) for i in range(self._n)})
    
    def __str__(self):
        return str([self._root(i) for i in range(self._n)])
    
    def __repr__(self):           
        return repr([self._root(i) for i in range(self._n)])

n, m, *AB = map(int, open(0).read().split())
ans = 0
for i in range(m):
    uf = UnionFind(n)
    for j, (a, b) in enumerate(zip(AB[::2], AB[1::2])):
        if i == j:
            continue
        uf.unite(a-1, b-1)
    ans += uf.count_groups() != 1
print(ans)

Measured memory_bytes: 9212
#include <iostream>
#include <cstring>

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

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

#define MAXN 100004

int N;
int A[MAXN];
int freq[MAXN];

const int MOD = 1e9 + 7;

int solve() {
   REP(i, N) {
      ++freq[A[i]];
      if (freq[A[i]] > 2)
         return 0;
   }
   llong res = 1;
   if (N & 1) {
      if (freq[0] != 1)
         return 0;
      FOR(j, 1, N) {
         if (freq[j] == 1)
            return 0;
         if (freq[j] == 0)
            continue;
         res = (res * 2) % MOD;
      }
   }
   else {
      if (freq[0] != 0)
         return 0;
      FOR(j, 1, N) {
         if (freq[j] == 1)
            return 0;
         if (freq[j] == 0)
            continue;
         res = (res * 2) % MOD;
      }
   }
   return res;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(NULL);

   cin >> N;
   REP(i, N)
      cin >> A[i];

   int res = solve();
   cout << res << endl;

   return 0;
}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    lint a,b,c;cin>>a>>b>>c;
    lint ans;
    if(a%2==0||b%2==0||c%2==0)ans=0;
    else{
        if(a>b&&a>c)ans=b*c;
        else if(b>c)ans=a*c;
        else ans=a*b;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
using namespace std;
vector<ll> v;
vector<string> vs;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
vector<tuple<ll, ll, ll>> vt;
map<ll, ll> mp;

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	vs.resize(3);
	REP(i, 3) cin >> vs[i];
	REP(i, 3) cout << static_cast<char>(vs[i][0] - 32);
	cout << endl;
}

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

public class Main {
    public static void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int[][] field = new int[h + 2][w + 2];
        int[] arr = new int[h * w];
        for (int i = 0; i < h * w; i++) {
            int x = sc.nextInt();
            arr[x - 1] = i;
        }
        int count = 0;
        for (int i = 0; i < h * w; i++) {
            int hh = arr[i] / w + 1;
            int ww = arr[i] % w + 1;
            int[] besides = new int[]{field[hh - 1][ww], field[hh][ww - 1], field[hh + 1][ww], field[hh][ww + 1]};
            Arrays.sort(besides);
            if (besides[0] == -1) {
                field[hh][ww] = -1;
                count++;
            } else {
                int x = besides[0];
                for (int j = 1; j < 4; j++) {
                    if (x == 0) {
                        x = besides[j];
                    } else {
                        if (x != besides[j]) {
                            field[hh][ww] = -1;
                            count++;
                            break;
                        }
                    }
                }
                if (field[hh][ww] == -1) {
                    continue;
                }
                if (x == 0) {
                    field[hh][ww] = i + 1;
                } else {
                    field[hh][ww] = x;
                }
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 304816
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (typeof((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(typeof(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}
string tostr(char s[], int a, int n) {string res = "";for(int i=a;i<a+n;++i){if(s[i]!=0)res+=s[i];}return res;}



int main() {
    //freopen( "/Users/macuser/Documents/Programming/Contest/input.in", "r", stdin );
    
    char str[200];
    while (true) {
        memset(str, 0, sizeof(str));
        gets(str);
        
        if (str[0] == '.' && str[1] == 0) break;
        
        string kakko = "";
        for (int i = 0; i < 200; ++i) {
            if (str[i] == '(' || str[i] == ')' || str[i] == '[' || str[i] == ']') kakko += str[i];
        }
        
        stack<char> st;
        
        for (int i = 0; i < 110; ++i) st.push('0');
        for (int i = 0; i < kakko.size(); ++i) {
            char top = st.top();
            if ((kakko[i] == ')' && top == '(') || (kakko[i] == ']' && top == '[')) {
                st.pop();
            }
            else st.push(kakko[i]);
        }
        
        if (st.top() == '0') cout << "yes" << endl;
        else cout << "no" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1176
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int N = Integer.valueOf(sc.next());

    int[] x = new int[N];
    int[] y = new int[N];
    
    for (int i = 0; i < N; i++) {
      x[i] = Integer.valueOf(sc.next());
      y[i] = Integer.valueOf(sc.next());
    }

    double[][] costs = new double[N][N];
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        costs[i][j] = dist(x[i], y[i], x[j], y[j]);
      }
    }

    List<List<Integer>> list = new ArrayList<>();
    perm(IntStream.rangeClosed(1, N).boxed().collect(Collectors.toList()), new ArrayList<>(), list);

    List<Double> ans = new ArrayList<>();
    for (int i = 0; i < list.size(); i++) {
      double d = 0;
      for (int j = 0; j < list.get(i).size() - 1; j++) {
        d += costs[list.get(i).get(j)-1][list.get(i).get(j+1)-1];
      }
      ans.add(d);
    }

    System.out.println(ans.stream().mapToDouble(Double::valueOf).average().getAsDouble());
  }

  private static void perm(List<Integer> candidate, List<Integer> perm, List<List<Integer>> perms) {
    if (candidate.size() == 0) {
      perms.add(perm);
    }
    for (int i = 0; i < candidate.size(); i++) {
      List<Integer> c = new ArrayList<>(candidate);
      List<Integer> p = new ArrayList<>(perm);
      p.add(c.get(i));
      c.remove(i);
      perm(c, p, perms);
    }
  }

  private static double dist(int x1, int y1, int x2, int y2) {
    return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
  }
}

Measured memory_bytes: 49240
#include <iostream>
#include <vector>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;

//// D
int main(){
    int n, m; cin >> n >> m;
    vector<vector<int>> jobs(m);
    rep(i, n){
        int a, b; cin >> a >> b;
        if(a > m) continue;
        jobs[m-a].push_back(b);
    }
    priority_queue<int> q;
    ll ans=0;
    for(int i=m-1; i>=0; i--){
        for(int b : jobs[i]){
            q.push(b);
        }
        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }
    cout << ans;
}

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

int		main(void)
{
	int		abc[3];
	int		count;

	count = 0;
	cin>>abc[0];cin>>abc[1];cin>>abc[2];
	for (int i = 0; i < 2; i++)
	{
		for (int j = i + 1; j <= 2; j++)
		{
			if (abc[i] != abc[j])
				count++;
		}
	}
	if (count == 0)
		count++;
	cout<<count<<endl;
	return (0);
}


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

using namespace std;
typedef long long ll;

int main(void)
{
  int N;
  cin >>N;

  int num = 1;
  bool find = false;
  int count = 0;

  for(int i=0;i<N;i++){
    int block;
    cin >> block;
    if(block==num){
      num++;
      find = true;
    }
    else{
      count++;
    }

  }

  if(!find){
    count = -1;
  }

  cout<<count<<endl;

  return 0;
}

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

int main() {
  int N,D;
  int ans;

  cin >> N >> D;

  ans = N%(D*2+1) == 0 ? N/(D*2+1) : N/(D*2+1)+1;

  cout << ans  << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int a[3];
  
  cin >> a[0] >> a[1] >> a[2];
  
  sort(a,a+3);
  
  if ((a[0]==a[1] || a[1]==a[2]) && a[0]!=a[2]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int task_C (const unsigned int* len_sequence, unsigned int val_sequence[])
{
	// variables for this function
	unsigned int maxval_1st;
	unsigned int maxval_2nd;
	unsigned int maxval_answer;

	// support variables for this function
	size_t itr;

	// STEP.01
	// initialize the variables to store the maximum values of given sequence
	maxval_1st = 0U;
	maxval_2nd = 0U;

	// STEP.02
	// search the maximum values of given sequence
	for (itr = 0; itr < *len_sequence; itr++)
	{
		if (maxval_1st < val_sequence[itr])
		{ 
			maxval_2nd = maxval_1st;
			maxval_1st = val_sequence[itr];
		}
		else if (maxval_2nd < val_sequence[itr])
		{
			maxval_2nd = val_sequence[itr];
		}
		else
		{
			continue;
		}
	}

	// STEP.03
	// output the answer of this task
	for (itr = 0; itr < *len_sequence; itr++)
	{
		if ( val_sequence[itr] != maxval_1st ) { maxval_answer = maxval_1st; }
		else                                   { maxval_answer = maxval_2nd; }
		
		printf("%d\n", maxval_answer);
	}

	// STEP.END
	return EXIT_SUCCESS;
}

#define len_sequence_max 200000U

int main (void)
{
	// variables for main process
	unsigned int N;
	unsigned int A[len_sequence_max];

	// support variables for main process
	int rtvl;

	// STEP.01
	// read out the given data
	// (the length of the given sequence)
	rtvl = scanf("%d", &N);

	// STEP.02
	// read out the given data
	// (the values of the given sequence)
	for (size_t itr = 0; itr < N; itr++) { rtvl = scanf("%d", &A[itr]); }

	// STEP.03
	// calculate & output the answer of the task
	rtvl = task_C(&N, A);

	// STEP.END
	return EXIT_SUCCESS;
}

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

bool vis[30];

int main() {
  string s;
  cin>>s;
  if(s.length() < 26) {
    for(int i = 0; i < s.length(); i++) vis[s[i] - 'a'] = 1;
    
    for(int i = 0; i < 26; i++) if(vis[i] == 0) {
      char tmp = i + 'a';
      cout<<s<<tmp<<endl;
      break;
    }
  } else {
    int A[30];
    for(int i = 0; i < 26; i++) A[i] = s[i];
    next_permutation(A, A + 26);
    if(s == "zyxwvutsrqponmlkjihgfedcba") cout<<-1<<endl;
    else {
      for(int i = 0; i < 26; i++) {
        char tmp = A[i];
        cout<<tmp;
        if(tmp != s[i]) break;
      }
      cout<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
int main(void){
    int n,m;
    scanf("%d%d",&n,&m);
    unsigned long long p[m],y[m];
    unsigned long long x[m];
    for(int i=0;i<m;i++){
        scanf("%lu%lu",&p[i],&y[i]);
        x[i]=(p[i]<<47)+(y[i]<<17)+i;
    }
    std::sort(x,x+m);
    int c=1;
    y[(x[0]<<47)>>47]=c;
    for(int i=1;i<m;i++){
        if(x[i]>>47==x[i-1]>>47)c++;
        else c=1;
        y[(x[i]<<47)>>47]=c;
    }
    for(int i=0;i<m;i++){
        printf("%06lu%06lu\n",p[i],y[i]);
    }
}

Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define N 1000006

using namespace std;

int n;
char s[N];
int a[N];

int main(){
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; ++i) a[i] = (s[n - i + 1] - '0') * 9;
	for(int i = 1; i <= n; ++i)
		a[i + 1] += a[i] / 10, a[i] %= 10;
	if(a[n + 1]) ++n;
	int sum = 0;
	for(int i = 1; i <= n; ++i) sum += a[i];
	for(int i = 1; i <= n * 100; ++i){
		++a[1];++sum;
		int pos = 1;
		while(a[pos] >= 10)
			a[pos + 1] += a[pos] / 10, a[pos++] %= 10, sum -= 9;
		if(pos > n) n = pos;
		if(sum <= i){
			cout << (i + 8) / 9 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 4608
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#include <cmath>
#include <map>
#include <utility>
#include <numeric>
#include <set>
#include <map>

#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 _USE_MATH_DEFINES

using namespace std;
using ll = long long;
using P = pair<int,int>;

const ll INF = 999999999;
const ll atcoder = 1e9 + 7;
const int dx[4] = { 1 , 0 , -1 ,0 };
const int dy[4] = { 0 , 1 , 0 , -1 };

int main() {

	set<int>s;

	int n;

	cin >> n;

	for (int i = 0; i < n; i++) {
		ll a;
		cin >> a;
		if (s.find(a) == s.end())
			s.insert(a);
		else s.erase(a);
	}

	cout << s.size() << endl;

	return 0;

}

Measured memory_bytes: 4864
#include <cstdio>
#include <cstdint>
#include <set>

std::set<intmax_t> divisor(intmax_t n) {
  std::set<intmax_t> res;
  for (intmax_t i = 1; i*i <= n; ++i)
    if (n % i == 0) {
      res.insert(i);
      res.insert(n / i);
    }
  return res;
}

bool f(intmax_t n, intmax_t k) {
  if (!(2 <= k && k <= n)) return false;
  while (n >= k) {
    if (n % k == 0) {
      n /= k;
    } else {
      n %= k;
    }
  }
  return n == 1;
}

int main() {
  intmax_t n;
  scanf("%jd", &n);

  std::set<intmax_t> res;
  for (auto k: divisor(n-1)) if (f(n, k)) res.insert(k);
  for (auto k: divisor(n)) if (f(n, k)) res.insert(k);

  // std::set<intmax_t> res_expected;
  // for (intmax_t k = 2; k <= n; ++k)
  //   if (f(n, k)) res_expected.insert(k);

  // fprintf(stderr, "expected:\n");
  // for (auto k: res_expected) fprintf(stderr, "? %jd\n", k);
  // puts((res == res_expected)? "\x1b[1;92m": "\x1b[1;91m");

  // fprintf(stderr, "got:\n");
  // for (auto k: res) fprintf(stderr, "? %jd\n", k);
  // fprintf(stderr, "\x1b[m");

  printf("%zu\n", res.size());
  // for (auto k: res) fprintf(stderr, "? %jd\n", k);
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
const int maxn=1000+10;

char t[maxn],p[maxn];
void solve()
{
    int tl=strlen(t);
    int pl=strlen(p);
    bool bMatch;
    if(tl<pl) return;
    for(int i=0;i<=tl-pl;i++)
    {
        bMatch=true;
        for(int j=0;j<pl;j++)
        {
            if(t[i+j]!=p[j])
            {
                bMatch=false;
                break;
            }
        }
        if(bMatch) printf("%d\n",i);
    }

}

int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%s%s",t,p);
    solve();

    return 0;

}

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

typedef long long int ll;
typedef long double ld;

#define Pb push_back
#define Mp make_pair

#define ff first
#define ss second

#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))

#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN

#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define db1(x) cout<<#x<<" : "<<x<<endl;
#define db2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define db3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;

const int VMAX = 1e5+5;
const int N = 105;
ll dp[VMAX][N];
ll w[N],v[N];
ll n,W;

ll sol(ll V,ll idx)
{
  if(V<=0)
  {
    return 0;
  }
  if(idx == n)
  {
    return 1000000001;
  }
  ll &ans = dp[V][idx];
  if(ans != -1)
  {
    return ans;
  }
  ans = min(w[idx] + sol(V-v[idx],idx+1),sol(V,idx+1));
  return ans;
}

void solve()
{
  cin >> n >> W;
  for(ll i=0;i<n;i++)
  {
    cin >> w[i] >> v[i];
  }
  memset(dp,-1,sizeof(dp));
  for(ll i = VMAX-5;i>=0;i--)
  {
    if(sol(i,0) <= W)
    {
      cout << i;
      return;
    }
  }
  return;
}

signed main()
{
  IOS;
  //freopen("input.txt", "rt", stdin);
  //freopen("output.txt", "wt", stdout);
  int t=1;
  //cin >> t;
  while(t--)
  {
    solve();
  }
  return 0;
}
/*==============================================================================================================================================================*/


Measured memory_bytes: 82304
let content = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', buf => {
  content += buf;
});

process.stdin.on('end', () => {
  let [, nums] = content
    .trim()
    .split('\n')
    .map(line => line.split(' ').map(n => +n));
  selectionSort(nums);
});

const selectionSort = nums => {
  let cnt = 0;
  for (let i = 0; i < nums.length; i++) {
    let minIdx = i;
    for (let j = i; j < nums.length; j++) {
      if (nums[minIdx] > nums[j]) {
        minIdx = j;
      }
    }
    
    if (nums[minIdx] !== nums[i]) {
      let tmp = nums[minIdx];
      nums[minIdx] = nums[i];
      nums[i] = tmp;
      cnt++;
    }
  }

  console.log(nums.join(' '));
  console.log(cnt);
};


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

const int MAX_V = 501;
const int INF = 1e+9;

int n, m;
int d[MAX_V][MAX_V];

void init(){
	for(int i=0 ; i < MAX_V ; i++ ){
		for(int j=0 ; j < MAX_V ; j++ ){
			d[i][j] = (i == j)? 0 : INF ;
		}
	}
}

void add_edge(int u, int v, int cost){
	d[u][v] = d[v][u] = cost;
}

int main(){
	while( cin >> n >> m , n || m ){
		string s, p, g;
		int id = 0;
		map<string,int> h;
		init();
		
		cin >> s >> p >> g;
		for(int i=0 ; i < m ; i++ ){
			string a, b;
			int d, t;
			cin >> a >> b >> d >> t;
			
			int cost = d / 40 + t;
			if( h.count(a) == 0 ){
				h[a] = id;
				id++;
			}
			if( h.count(b) == 0 ){
				h[b] = id;
				id++;
			}
			add_edge( h[a] , h[b] , cost );
		}
		for(int k=0 ; k < n ; k++ ){
			for(int i=0 ; i < n ; i++ ){
				for(int j=0 ; j < n ; j++ ){
					d[i][j] = min( d[i][j] , d[i][k] + d[k][j] );
				}
			}
		}
		cout << d[ h[s] ][ h[p] ] + d[ h[p] ][ h[g] ] << endl;
	}
}

Measured memory_bytes: 1940
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n;
main()
{
  cin>>n;
vector<int>a(n);
  for(int i=0;i<n;i++)
  {
cin>>a[i];a[i]-=i;
  }
  sort(a.begin(),a.end());
  long ans=0;
  for(int i=0;i<n;i++)ans+=abs(a[i]-a[n/2]);
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
//package com.company;

import java.io.*;
import java.util.*;

public class Main {
    static long TIME_START, TIME_END;
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//        Scanner sc = new Scanner(new FileInputStream("Test.in"));
        PrintWriter pw = new PrintWriter(System.out);
//        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.out"));
//        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.in"));

        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
//        System.out.println("Memory increased:" + (usedMemoryAfter-usedMemoryBefore) / 1000000 );
//        System.out.println("Time used: " + (TIME_END - TIME_START) + ".");

    }


    public static class Task {
        public int dist(int a, int b){
            return Math.abs(a - b);
        }
        //https://arc093.contest.atcoder.jp/tasks/arc093_a
        // 3978
        // Traveling Plan
        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            int n = sc.nextInt();
            int[] a = new int[n + 2];
            for (int i = 1; i <= n; i++) {
                a[i] = sc.nextInt();
            }
            int[] prefix = new int[n + 2];
            int[] suffix = new int[n + 2];
            for (int i = 1; i <= n; i++) {
                prefix[i] = prefix[i - 1] + dist(a[i-1], a[i]);
            }
            for (int i = n; i > 0; i--) {
                suffix[i] = suffix[i + 1] + dist(a[i+1], a[i]);
            }
            for (int i = 1; i <= n; i++) {
                pw.println(prefix[i-1] + dist(a[i-1], a[i+1]) + suffix[i+1]);
            }

        }




    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

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

        public Scanner(FileReader s) throws FileNotFoundException {br = new BufferedReader(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 { return Double.parseDouble(next()); }

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


Measured memory_bytes: 43792
while True:
    m, f, r = (int(x) for x in input().split())
    if (m, f, r) == (-1, -1, -1):
        break
    sum_score = m + f

    if m == -1 or f == -1:
        print("F")
    elif sum_score >= 80:
        print("A")
    elif 65 <= sum_score < 80:
        print("B")
    elif 50 <= sum_score < 65:
        print("C")
    elif 30 <= sum_score < 50:
        print("C") if r >= 50 else print("D")
    else:
        print("F")

Measured memory_bytes: 7716
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

int main(){

    ll N;
    cin >> N;
    string s, t;
    cin >> s >> t;
    rep(i, N){
        cout << s[i] << t[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256