akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(ll i = 0; i < (ll)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(ll i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
//const ll MOD = 998244353ll;
const dou pi=3.141592653589793*2;
int ketawa(ll n){  //各桁の和を計算する
    ll dum=0ll;
    while(n!=0){
        dum+=n-(n/10)*10;
        n/=10;
    }
    return dum;
}
int main(){
    int n,a,b;
    std::cin >> n>>a>>b;
    int ans=0;
    rrep(i,1,n+1){
        if(ketawa(i)>=a&&ketawa(i)<=b)ans+=i;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main() {
	ios::sync_with_stdio(false);
	cin >> a >> b;
	b += " ";
	for(int i = 0; i < a.size(); i++)
		cout << a[i] << b[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
A,B,C,D = gets.split.map(&:to_i)

divB = B - (B/C) - (B/D) + (B/C.lcm(D))
divA = A-1 - ((A-1)/C) - ((A-1)/D) + ((A-1)/C.lcm(D))

puts divB-divA

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
// greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x%y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;




int main() {
	ll H, N, attack = 0;
	cin >> H >> N;

	

	for (int i = 0; i < N; i++)
	{
		ll temp;
		cin >> temp;
		attack += temp;
	}

	


	

	if(H - attack <= 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	

}


Measured memory_bytes: 256
s = input()
result = [0] * len(s)
s = s + 'R'
r_count = 0
l_count = 0
r_flag = True
index = 0

for i in range(len(s)):
    if s[i] == 'R':
        if r_flag is False:
            if (r_count + l_count) % 2 == 0:
                result[index] = (r_count + l_count) // 2
                result[index-1] = (r_count + l_count) // 2
            else:
                if r_count % 2 == 1:
                    result[index] = (r_count + l_count) // 2
                    result[index-1] = 1 + (r_count + l_count) // 2
                else:
                    result[index] = 1 + (r_count + l_count) // 2
                    result[index-1] = (r_count + l_count) // 2
            r_count = 0
            l_count = 0
            index = 0
            r_flag = True
        r_count += 1
    elif s[i] == 'L':
        l_count += 1
        if r_flag is True:
            index = i
            r_flag = False

for n in result:
    print(str(n) + ' ', end='')


Measured memory_bytes: 4984
//https://atcoder.jp/contests/dp/tasks/dp_f

#include <bits/stdc++.h>
#include <limits.h>
#include <algorithm>  


#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;


using namespace std;

typedef long long int ll;

const int precision = 16;
const int modulo =  1000000007; // 10^9 + 7
using ll = long long;
const double EPS = 1e-9;
const ll INF = 1e18L + 5;

string solveLCS() 
{
	string s, t;  cin >> s >> t;

	swap(s, t);

	vector<vector<int>> dp(s.size() + 1, vector<int> (t.size() + 1, 0));

	for(auto i = 0; i <= (int)s.size(); ++i) {
		dp[i][0] = i;
	}

	for(auto i = 0; i <= (int)t.size(); ++i) {
		dp[0][i] = i;
	}


	for(auto r = 1; r <= (int)s.size(); ++r) {
		for(auto c = 1; c <= (int)t.size(); ++c) {
			if(s[r - 1] == t[c - 1]) {
				dp[r][c] = dp[r - 1][c - 1];
			} else {
				dp[r][c] = min(dp[r - 1][c], dp[r][c - 1]) + 1;
			}
		}
	}


	// for(auto r : dp) {
	// 	for(auto c : r) {
	// 		cout << c << " ";
	// 	}
	// 	cout <<endl;
	// }


	int r = s.size(), c = t.size();

	string ret = "";
	while(r > 0 and c > 0) {
		if(s[r - 1] == t[c - 1]){
			ret += s[r - 1];
			r--;
			c--;
		} else {
			if(dp[r - 1][c] < dp[r][c - 1]) {
				r = r - 1;
			} else {
				c = c - 1;
			}
		}
	}

	reverse(ret.begin(), ret.end());
	return ret;
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(precision);
	cout.setf(ios_base::fixed);

	auto ret = solveLCS();
	cout << ret;
	return 0;
}




Measured memory_bytes: 35584
<?php

fscanf(STDIN, "%d", $n);
$S = [];
for ($i = 0; $i < $n; ++$i) {
    fscanf(STDIN, "%s", $tmp);

    $tmp_chars = str_split($tmp);
    sort($tmp_chars);
    $str = implode('', $tmp_chars);

    if (isset($S[$str])) {
        ++$S[$str];
    } else {
        $S[$str] = 1;
    }
}


$sum = 0;
foreach ($S as $cnt) {
    $sum += (int) ($cnt * ($cnt - 1) / 2);
}

echo $sum;


Measured memory_bytes: 13048
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	int n, k, i = 0, j = 0, ans = 0;
	string s;
	cin >> n >> k >> s;
	vector<pair<int, bool> > v(n);
	while (j < n) {
		while (j < n && s[j] == '1')
			++j;
		ans = max(ans, j - i);
		while (j < n && s[j] == '0')
			++j;
		--k;
		if (k < 0) {
			while (i < n && s[i] == '1')
				++i;
			while (i < n && s[i] == '0')
				++i;
		}
		ans = max(ans, j - i);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
int main(void)
{
	int a,b,c,d,i, p,m;
	int	sum=0;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);
	if (b >= a)
	{
		for (i = 1; i <= a; i++)
		{
			sum += c;
		}
	}
	else if (b < a)
	{
		for (p = 1; p <= b; p++)
		{
			sum += c;
		}
		for (m = a; m > b; m--)
		{
			sum += d;
		}
	}
	printf("%d", sum);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        s = s.toLowerCase();
        char a = s.charAt(2);
        char b = s.charAt(3);
        char c = s.charAt(4);
        char d = s.charAt(5);
        if(s.length()==6){
            if(a==b && c==d){
                System.out.println("Yes");
            }
            else
                System.out.println("No");
        }
        else
            System.out.println("No");
            
    }}

Measured memory_bytes: 35644
#include <bits/stdc++.h>
#define pb push_back
#define long long long
#define pll pair < long , long >
#define vll vector < pll >
#define ml map < long , long >
#define mll map < pll , long >
#define x first
#define y second
#define vl vector < long >
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
{
    io
    long n,a[100005]={0},x,i,ans=0;
    cin>>n;
    for(i=0;i<n;++i)
    {
        cin>>x;
        a[x]++;
    }
    for(i=0;i<=100000;++i)
    ans=max(ans,a[i]+a[i+1]+((i>0)?a[i-1]:0));
    cout<<ans;
    return 0;
}


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

int main() {
    int n, m = 0;
    cin >> n;
    vector<int> a(n), b(n, 0), ans;
    rep(i, n) cin >> a.at(i);
    for(int i = n - 1; i >= 0; i--) {
        int t = 1, cnt = 0;
        while((i + 1) * t <= n) if(b.at((i + 1) * (t++) - 1)) cnt++;
        if(cnt % 2 != a.at(i)) {
            b.at(i) = 1;
            ans.push_back(i + 1);
            m++;
        }
    }
    cout << m << endl;
    if(m > 0) {
        rep(i, m) cout << ans.at(i) << " ";
        cout << endl;
    }
}

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

int main()
{
	int n;
	cin>>n;
	int a[n];
	
	for(int i=0; i<=n; i++)  cin>>a[i];
	
	int f,count=0;
	
	do{
		f=0;
		for(int i=0; i<n; i++){
			if(a[i]%2==0){
				a[i]=a[i]/2;
			}
			else
			{
				f=1;
				break;
			}
		}
		
		if(f==0) count++;
	}while(f==0);
	
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない



int main() {
	
	int n;
	int x[100], y[100], h[100];
	ll cx, cy, H;
	int p = 0;

	cin >> n;

	rep(i, 0, n) {
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] > 0)p = i;
	}

	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			H = h[p] + abs(x[p] - i) + abs(y[p] - j);
			rep(l, 0, n) {
				ll sh = 0;
				if (h[l] > 0) {
					sh = h[l] + abs(x[l] - i) + abs(y[l] - j);
					if (sh != H)break;
				}
				else {
					if (H - abs(x[l] - i) - abs(y[l] - j) > 0)break;
				}

				if (l == n - 1) {
					cout << i <<' '<< j <<' '<< H << endl;
					return 0;
				}
				
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
    int N;
    cin >> N;
    map<ll, ll>nums;
    ll sum = 0;
    rep(i, 0, N){
        ll tmp;
        cin >> tmp;
        nums[tmp]++;
        sum+=tmp;
    }
    int Q;
    cin >> Q;
    rep(i, 0, Q){
        int B,C;
        cin >> B >> C;
        sum -= B*nums[B];
        sum -= C*nums[C];
        ll cnt = nums[B];
        nums[B]=0;
        nums[C]+=cnt;
        sum+=C*nums[C];
        cout << sum << endl;
    }
    
    return 0;
}

Measured memory_bytes: 9508
N=int(input())
S1=input()
S2=input()
mod=1000000007

cnt=0
stat=0
ans=1
if S1[cnt]==S2[cnt]:
  cnt+=1
  ans*=3
else:
  cnt+=2
  stat=1
  ans*=6

while cnt!=N:
  if stat:
    if S1[cnt]==S2[cnt]:
      stat=0
      cnt+=1
    else:
      ans*=3
      ans%=mod
      cnt+=2
  else:
    if S1[cnt]==S2[cnt]:
      cnt+=1
      ans*=2
      ans%=mod
    else:
      cnt+=2
      ans*=2
      ans%=mod
      stat=1
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a<b){
        if(b<c){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }else{
        printf("No\n");
    }
}


Measured memory_bytes: 2576
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<Character> list = new ArrayList<Character>();
		String str = scan.nextLine();
		int n = 0;
		for (n = 0; n < str.length(); n++) {
			list.add(str.charAt(n));
		}
		System.out.print(list.get(0));
		System.out.print(list.size()-2);
		System.out.println(list.get(n-1));
		scan.close();
	}

}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define all(c) c.begin(),c.end()
#define sz(c) ((int)c.size())
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;

signed main() {
    int N;
    cin >> N;
    vvi C(N, vi(N));
    rep(i, 0, N) {
        rep(j, 0, N) {
            cin >> C[i][j];
        }
    }
    int ans = 0;
    rep(i, 0, N) {
        rep(j, i + 1, N) {
            ans += min(C[i][j], C[j][i]);
        }
    }
    cout << ans << endl;
}



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

int main(){
  int N,K;
  cin >> N >> K;
  set<int> s;
  vector<int64_t> v(N,1e9);
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    if(s.count(a)){
      v.at(a-1)++;
    }else{
      s.insert(a);
      v.at(a-1)=1;
    }
  }
  if(s.size()<=K){
    cout << 0 << endl;
  }else{
    sort(v.begin(),v.end());
    int64_t ans=0;
    for(int i=0;i<s.size()-K;i++){
      ans+=v.at(i);
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int row,col,k;
	cin>>row>>col>>k;
	char c;
	int arr[row+1][col+1];
	int cnt=0,total=0,fin=0;
	for(int i=0;i<row;i++)
	{
	    for(int j=0;j<col;j++)
	    {
	        cin>>c;
	        if(c=='#')
	        {
	            arr[i][j]=1;
	            fin++;   
	        }
	        else
	        {
	            arr[i][j]=0;
	        }
	        
	    }
	}
	
	
	
	
	
	for(int row1=0;row1<(1<<row);row1++)
	{
	    for(int col1=0;col1<(1<<col);col1++)
	    {
	        total=0;
	        for(int i=0;i<row;i++)
	        {
	            for(int j=0;j<col;j++)
	            {
	               
	               if ((((row1>>i)&(1))==1 || ((col1>>j)&(1))==1) and arr[i][j]==1)total = total + 1;
 
	               
	               
	                
	            }
	        }
	        if(fin-total==k)
	        {
	            cnt++;
	        }
	    }
	}
	
	
	cout<<cnt<<endl;
	
	
	
}

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

#define pb push_back

using namespace std;

typedef long long ll;

const int maxn=1e3+10;

int main()
{
    ios_base::sync_with_stdio(false);
    char ch;
    cin>>ch;
    if(ch=='a' || ch=='i' || ch=='e' || ch=='o' || ch=='u')
        cout<<"vowel";
    else
        cout<<"consonant";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
#define Max 100000
int n,k;
typedef long long llong;
llong  T[Max];
int check (llong  P)
{
    int i=0;
    for(int j=0;j<k;j++)
    {
        llong sum=0;
        while(sum+T[i]<=P)
        {
             sum+=T[i];
            i++;
            if(i==n)
                return n;
        }
    }
    return i;
}
int solve()
{
    llong left=0;
    llong right=100000*10000;
    llong mid;
    while(right-left>1)
    {
        mid=(left+right)/2;
        int v=check(mid);
        if(v>=n)
        {
            right=mid;
        }
        else left=mid;
    }
    return right;
}
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
       cin>>T[i];
    }
   llong ans=solve();
   cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if(s.length() == 2) cout << s << endl;
  else{
    for(int i = 2; i >= 0; i--) cout << s[i];
    cout << endl;
  }  
  return 0;
}

Measured memory_bytes: 256
//🔴

#include<bits/stdc++.h>
using namespace std;
const long long INF = 1001000000;
//01ナップサック問題その２
//アリ本
//制約
// 1 <= n <= 100
// 1 <= w_i <= 1e7
// 1 <= v_i <= 100
// 1 <= W <= 1e9

#define int long long

signed main(){

    long long n, W; cin >> n >> W;
    vector<long long> v(n);
    vector<long long> w(n);
    for(int i = 0; i < n; i++){
        cin >> w[i] >> v[i];
    }

    //dp[i][j] := 価値がjとなるような重さの最小値
    long long dp[110][100010];
    memset(dp, INF, sizeof(dp));

    dp[0][0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 100010; j++){
            //take
            dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);

            //no
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        }
    }

    int ans = 0;
    for(int i = 0; i <= 100010; i++){
        if(dp[n][i] <= W) ans = max(ans, i);
    }

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

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

int main() {

    int n;
    map<string, int> dictionary;
    int maxCount = 0;

    cin >> n;

    for(int i = 0; i < n; ++i) {
        string s;
        cin >> s;

        if(dictionary.find(s) == dictionary.end())
            dictionary.emplace(s, 0);
        else {
            dictionary[s]++;

            if(maxCount < dictionary[s])
                maxCount = dictionary[s];

        }

    }

    vector<string> answer;

    for(auto itr = dictionary.cbegin(); itr != dictionary.end(); itr++)
        if(itr->second == maxCount)
            answer.push_back(itr->first);

    sort(answer.begin(), answer.end());

    // cout << endl;

    for(int i = 0; i < answer.size(); ++i)
        cout << answer[i] << endl;


    return 0;

}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)
#define All(x) (x).begin(),(x).end()
#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))
#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

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

    string s;

    cin >> s;

    int ans = 0;

    for (auto ch : s) if (ch == '2') ans++;

    Out(ans);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a,b,c,i;
	b=0;
	for(i=0;i<3;i++){
		scanf("%d",&a);
		if(i==0){
			b=a;
		}else if(i>0){
			if(b>a){
				b=a;
			}
	}
	}
	for(i=0;i<2;i++){
		scanf("%d",&a);
		if(i==0){
			c=a;
		}else if(i>0){
			if(c>a){
				c=a;
			}
	}
	}
	printf("%d\n",b+c-50);
	return 0;
}

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

using namespace std;

class MYCP {
public:
	//数値を標準出力
	static void Print_Int(long long number) {
		std::cout << number << std::endl;
	}

	static void Print_Ints(vector<long long> numbers) {
		std::cout << numbers[0];
		for (int i = 1;i < numbers.size();i++) {
			std::cout << " " << numbers[i];
		}

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

	static vector<string> MyReadLineSplit(int n) {
		vector<string> str(n);
		for (int i = 0;i < n;i++) {
			std::cin >> str[i];
		}

		return str;
	}

	static vector<long long> ReadInts(long long number) {
		vector<long long> a(number);
		for (int i = 0;i < number;i++) {
			std::cin >> a[i];
		}

		return a;
	}

	//渡された自然数が素数ならtureを返す
	static bool PrimeCheck_Int(long number) {
		if (number < 2)return false;

		for (int i = 2;i*i <= number;i++) {
			if (number%i == 0)return false;
		}

		return true;
	}
};


int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long n;
	cin >> n;
	vector<long long> a = MYCP::ReadInts(n);

	for (int i = 0; i < n; i++) {
		a[i] = a[i] - i - 1;
	}

	sort(a.begin(), a.end());
	long long number = n / 2;
	long long b = a[number];
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		sum += abs(b - a[i]);
	}

	cout << sum;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

int n;
vector <int> a(101010);
ll ansp = 0;
ll ansm = 0;

int main()
{
  cin >> n;
  rep(i,n) cin >> a[i];

  ll sum = 0;
  rep(i, n){
    sum += a[i];
    if(i%2 == 1){
      while(sum <= 0){
        sum++;
        ansm++;
      }
    }
    else{
      while(sum >= 0){
        sum--;
        ansm++;
      }
    }
  }

  sum = 0;
  rep(i, n){
    sum += a[i];
    if(i%2 == 0){
      while(sum <= 0){
        sum++;
        ansp++;
      }
    }
    else{
      while(sum >= 0){
        sum--;
        ansp++;
      }
    }
  }

  cout << min(ansm, ansp) << endl;
}


Measured memory_bytes: 640
import numpy as np
n = int(input())
s = list()
for i in range(n):
    s.append(int(input()))
    
a = np.array(s)
goukei = a.sum()

if goukei % 10 == 0:
    if (a % 10 == 0).all():
        print(0)
    else:
        print(goukei - a[a % 10 > 0].min())
else:
    print(goukei)

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

using pp=pair<int,int>;

int main() {
  string S;
  cin >> S;
  string ans="AC";
  if (S[0]!='A') {ans="WA";}
  int c=0, ci;
  for (int i=2; i<S.size()-1; i++) {
    if (S[i]=='C') {
      c++;
      ci=i;
    }
  }
  if (c!=1) {ans="WA";}
  for (int i=0; i<S.size(); i++) {
    if (i==0 || i==ci) {continue;}
    if (S[i]-'Z'<=0) {
      ans="WA";
      break;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

const int NS = (int)1e5+4, MOD = (int)1e9+7;
int N; char s[NS];
int cnt[30];

int main(){
    int ans = 1;
    scanf("%d %s", &N, &s);
    for(int i=0;i<N;++i) ++cnt[s[i]-'a'];
    for(int i=0;i<26;++i) ans = (long long)ans*(cnt[i]+1)%MOD;
    printf("%d\n", ans-1);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {
	int a, b, c, ans;
	cin >> a >> b >> c;
	if (a == b) {
		ans = c;
	}
	else if (b == c) {
		ans = a;
	}
	else {
		ans = b;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define mod 1000000007
#define N 300010
using namespace std;
int main()
{
    int a, b, c, d;
    long long n;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    scanf("%lld", &n);
    n = n * 4;
    if(a * 2 < b) b = a * 2;
    if(a * 4 < c) c = a * 4;
    if(b * 2 < c) c = b * 2;
    if(a * 8 < d) d = a * 8;
    if(b * 4 < d) d = b * 4;
    if(c * 2 < d) d = c * 2;
    long long ans = 0;
    ans = ans + n / 8 * d;
    n %= 8;
    ans = ans + n / 4 * c;
    n %= 4;
    ans = ans + n / 2 * b;
    n %= 2;
    ans = ans + n / 1 * a;
    n %= 1;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <cmath>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define ins insert
#define iter ::iterator
#define upb upper_bound
#define lwb lower_bound

#define sz(v) v.size()
#define aloc(i, a, n) i *a = new i[n]

#define for0(i,a) for(ll i = 0; i < a; i++)
#define fori(i,a,b) for(ll i = a; i < b; ++i)
#define rfor0(i,a) for(ll i = a; i >= 0; --i)
#define rfor(i,a,b) for(ll i = a; i >= b; --i)


//##############################################################################

int main(){
  ll a, b;
  cin >> a >> b;
  fori(i, -a + 1, a) cout << b + i << ' ';
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	ll a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	
	bool yes = false;
	if( v <= w ) {
		cout << "NO" << endl;
		return 0;
	}
	
	if( abs(a - b) <= t * abs(v - w) ) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3636
{-# LANGUAGE OverloadedStrings #-}
import Prelude hiding (null, elem)
import Control.Monad
import Data.Char
import Data.List hiding (insert, null, elem)
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as MV
import qualified Data.Vector.Unboxed as UV

main :: IO ()
main = do
  [n, m] <- getIntList
  jobs <- MV.replicate m []
  replicateM_ n $ do
    [day, reward] <- getIntList
    if day <= m
      then MV.modify jobs (reward:) (day-1)
      else return ()
  print . solve =<< (V.freeze jobs)

solve :: V.Vector [Int] -> Int
solve jobs = go [0..m-1] empty
  where
    m = V.length jobs
    go [] _ = 0
    go (d:days) qs = p + go days qs''
      where
        rewards = jobs V.! d
        qs' = merge qs $ fromList rewards
        (p, qs'') = if null qs' then (0, qs') else deleteFindMax qs'

-- Leftist Heap
data Heap a =
  Empty |
  Heap {
    rank :: Int,
    elem :: a,
    left :: Heap a,
    right ::Heap a}

empty :: Heap a
empty = Empty

null :: Heap a -> Bool
null Empty = True
null (Heap _ _ _ _) = False 

singleton :: a -> Heap a
singleton x = Heap 1 x Empty Empty

merge :: Ord a => Heap a -> Heap a -> Heap a
merge h     Empty = h
merge Empty h     = h
merge h1 h2
  | elem h1 > elem h2 = makeHeap (elem h1) (left h1) (merge (right h1) h2)
  | otherwise = makeHeap (elem h2) (left h2) (merge (right h2) h1)

makeHeap :: a -> Heap a -> Heap a -> Heap a
makeHeap x a b =
  if ra >= rb then Heap (rb + 1) x a b else Heap (ra + 1) x b a
  where 
    rb = if null b then 0 else rank b
    ra = if null a then 0 else rank a

insert :: Ord a => a -> Heap a -> Heap a
insert x h = merge (singleton x) h

deleteFindMax :: Ord a => Heap a -> (a, Heap a)
deleteFindMax Empty = error "Empty Heap"
deleteFindMax (Heap _ x a b) = (x, merge a b)

fromList :: Ord a => [a] -> Heap a
fromList = foldl (flip insert) Empty

toList :: Ord a => Heap a -> [a]
toList h
  | null h = []
  | otherwise = let (x, h') = deleteFindMax h
                in x : toList h'
-- IO
readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

getInt :: IO Int
getInt = readInt <$> BS.getLine

getIntList :: IO [Int]
getIntList = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

getIntVec :: Int -> IO (UV.Vector Int)
getIntVec n = UV.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

Measured memory_bytes: 24444
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <bitset>
#include <tuple>
#include <queue>
#include <stack>
#define inf 100100100
using namespace std;
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i <(int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i,k,n) for (int i = (int)(n)-1; i >= k; i--)
#define pb push_back
#define INF (1<<31)
#include<iostream>
#include<string>
using namespace std;
ll dp[200010] = {};
int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int a = 0;
    int c = 0;
    rep(i,n){
        if(s[i]=='.') c+=1;
    }
    int ans = 100100100;
    rep(i,n){

        if(s[i]=='#'){
            ans = min(ans,c+a);
            a+=1;
        }else{
            ans = min(ans,c+a);
            c-=1;
        }
    }
    ans = min(ans,c+a);
    cout << ans << endl;
    return 0;
}


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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define BIT(bit,a,n) for (int bit = a;bit < (1<<n);bit++) // {0, 1, ..., n-1} の部分集合の全探索 // n番目のフラグが立っている状態は (1<<n)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20

typedef long long ll;
using namespace std;

int a,b,c;
int x;
int cnt = 0;
int main() {
    scanf("%d%d%d",&a,&b,&c);
    scanf("%d",&x);
    rep(i,0,a+1){
        int ai = 500*i;
        rep(j,0,b+1){
            int bj = 100*j;
            rep(k,0,c+1){
                int ck = 50*k;
                if(ai+bj+ck == x) cnt++;
            }
        }
    }
    pout(cnt);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {

    int x, t;
    cin >> x >> t;
    if(x > t){
        cout << x - t << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, T) = readInputLine().split(" ").map { it.toInt() }
    val aList = readInputLine().split(" ").map { it.toInt() }
    val aListSorted = aList.mapIndexed { index, num -> Pair(index, num) }.sortedByDescending { it.second }.toMutableList()

    var maxDiff = 0
    var diffCnt = 0
    
    for ((i, num) in aList.withIndex()) {
        while (!aListSorted.isEmpty()) {
            val (maxIndex, maxNum) = aListSorted.first()
            if (maxIndex < i || maxNum < num) {
                aListSorted.removeAt(0)
            } else {
                break
            }
        }
        if (aListSorted.isEmpty()) {
            break
        }
        
        val diff = aListSorted.first().second - num
        if (diff > maxDiff) {
            maxDiff = diff
            diffCnt = 1
        } else if (diff == maxDiff) {
            diffCnt++
        }
    }
    
    println(diffCnt)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 80700
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll =long long;
using namespace std;
using graph=vector<vector<int>>;
using field=vector<string>;
using p =pair<int,int>;
const ll mod=1000000007;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> x(n);
    for(ll i=0;i<n;++i)cin>>x[i];
    ll ans=10e9;
    rep(i,n-k+1){
        ll tmp1=abs(x[i+k-1]-x[i]);
        ll tmp2=min(tmp1+abs(x[i+k-1]),tmp1+abs(x[i]));
        ans=min(tmp2,ans);
    }
    cout<<ans<<endl;

}
    

Measured memory_bytes: 3988
(stdin => {
  // Define Function
  const more = (a, b) => (a === b) ? `a == b`
    : (a > b)
      ? `a > b`
      : `a < b`

  // Declare Variable
  const inputs = stdin.toString().trim().split('\n')
  const Z = inputs[0].split(' ')
  const A = parseInt(Z[0], 10)
  const B = parseInt(Z[1], 10)

  console.log(more(A, B))
})(require('fs').readFileSync('/dev/stdin', 'utf8'))



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()%
#define int long long

int divisor_func(int num){
    int divisors = 1;
    for(int i=2; i*i <= num; i++){
        int p = 0;
        while(num%i==0){ num /= i; p++; }
        divisors *= (p+1);
    }
    if(num != 1) divisors *= 2;
    return divisors;
}

bool is_good_distance(vector<int> &a, vector<int> &b){
    int ans = 0;
    rep(i,a.size()){
        ans += (a[i]-b[i]) * (a[i]-b[i]);
    }
    return divisor_func(ans) % 2 == 1;
}

signed main(){
    int n, d;
    cin >> n >> d;
    vector<vector<int>> X(n,vector<int>(d));
    rep(i,n)rep(j,d) cin >> X[i][j];
    
    int ans = 0;
    reps(i,0,n-2)reps(j,i+1,n-1){
        if(is_good_distance(X[i], X[j])) ans++;
    }
    
    cout << ans << endl;
}

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

int main(){
	int k, x;
	cin >> k >> x;

	rep(i, k*2-1){
		if(i != k*2-2) cout << x-k+1+i << " ";
		else cout << x-k+1+i << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	
	string s; cin>>s;
	ll arr[26];
	memset(arr,0,sizeof(arr));
	for(int i = 0; i < s.size(); i++){
		arr[s[i]-'a']++;
	}
	bool flag = false;
	for(int i = 0; i < 26; i++){
		if(arr[i]&1) flag = true;
	}
	if(flag) cout<<"No"<<"\n";
	else cout<<"Yes"<<"\n";
}

Measured memory_bytes: 256
import collections

def main():
    s = str(input())

    if len(s) % 2 == 0:
        for i in range(len(s)//2):
            if s[0+2*i:2+2*i] != 'hi':
                print('No')
                break
    
        else:
            print('Yes')
    else:
        print('No')



if __name__ == '__main__':
    main()



Measured memory_bytes: 3316
#include<iostream>
#include<complex>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ck(a) (-100+EPS<a&&a<100-EPS)
#define pb push_back
using namespace std;

const double EPS = 1e-10;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
struct L : public vector<P> {
  L(const P &a, const P &b) {
    pb(a); pb(b);
  }
};
struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  return m[0] + B / A * (m[1] - m[0]);
}

int main(){
	int n;
	while(cin>>n,n){
		vector<L> lines; lines.reserve(n);
		int ans=1;
		rep(i,n){
			int x1,y1,x2,y2,d=0,c=0,f;
			cin>>x1>>y1>>x2>>y2;
			L newline(P(x1,y1),P(x2,y2)); vector<P> cps;
			rep(j,lines.size()){
				P cp=crosspoint(lines[j],newline);
				if(ck(real(cp))&&ck(imag(cp))){
					c++; f=0;
					rep(k,cps.size())
					if(abs(real(cps[k]-cp))<EPS&&abs(imag(cps[k]-cp))<EPS)d++,f=1;
					if(!f)cps.pb(cp);
				}
			}
			lines.pb(newline); ans+=1+c-d;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 936
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lli n, m, k;
	cin >> n >> m >> k;
	vector<lli> v1, v2;
	for1(i, 0, n)
	{
		lli a;
		cin >> a;
		v1.pb(a);
	}
	for1(i, 0, m)
	{
		lli a;
		cin >> a;
		v2.pb(a);
	}

	for1(i, 1, n)
	{
		// v2[i] += v2[i - 1];

		v1[i] += v1[i - 1];
	}
	for1(i, 1, m)
	{
		v2[i] += v2[i - 1];
	}
	lli x = 0;
	for1(i, 0, n)
	{
		lli a = i + 1;
		lli y = k - v1[i];
		if (y < 0)
		{
			break;
		}
		if (y > 0)
		{
			lli u = upper_bound(v2.begin(), v2.end(), y) - v2.begin();
			u -= 1;
			if (u >= 0)
			{
				a += (u + 1);
			}
		}
		x = max(x, a);
		// cout << x << endl;
	}
	lli u = upper_bound(v2.begin(), v2.end(), k) - v2.begin();
	if (u > 0)
	{
		x = max(x, u);
	}
	cout << x << endl;
}

Measured memory_bytes: 7952
import queue
k = int(input())
q = queue.Queue()

for i in range(1,10):
    q.put(i)

for i in range(k):
    x = q.get()
    if not x%10 == 0:
        q.put(10*x+(x%10)-1)
    q.put(10*x+(x%10))
    if not x%10 == 9:
        q.put(10*x+(x%10)+1)

print(x)


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


int n;
vector<int>G[101000], G2[101000], ans, vec;

void dfs(int x,int fff){
    vec.push_back(G[x].size()-1);
    for (auto y:G2[x])
        if (y!=fff)
            dfs(y,x);
}
vector<int> fuck(int s){
    vec.clear();
    vec.push_back(1);
    dfs(s,0);
    vec.push_back(1);
    vector<int>res(n,0);
    int las=0;
    for (auto o:vec){
        int p=las;
        res[las+o-1]=p++;
        for (int i=0;i<o-1;++i)
            res[las+i]=p++;
        las=p;
    }
    return res;
}

int main(){
    cin>>n;
    for (int i=1;i<n;++i){
        int u, v; cin>>u>>v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    if (n==2){
        puts("1 2");
        return 0;
    }
    for (int i=1;i<=n;++i)
        for (auto j:G[i])
            if (G[i].size()>1&&G[j].size()>1)
                G2[j].push_back(i);
    for (int i=1;i<=n;++i)
        if (G2[i].size()>2){
            puts("-1");
            return 0;
        }
    ans.push_back(n+1);
    for (int i=1;i<=n;++i)
        if (G2[i].size()==1)
            ans=min(ans,fuck(i));
    if (ans[0]==n+1)
        for (int i=1;i<=n;++i)
            if (G[i].size()>1)
                ans=min(ans,fuck(i));
    for (auto o:ans)
        printf("%d ",o+1);
    puts("");
}

Measured memory_bytes: 19188
#include <iostream>
#include <map>
#include <set>
using namespace std;

int main(void){
  string KEYS[3]={"ABC","DEF","GHI"};
  map<char,set<char> > K;
  for(int i=0;i<3;++i){
    for(int j=0;j<3;++j){
      if(j-1>=0) K[KEYS[i][j]].insert(KEYS[i][j-1]);
      if(j+1<3) K[KEYS[i][j]].insert(KEYS[i][j+1]);
      if(i-1>=0) K[KEYS[i][j]].insert(KEYS[i-1][j]);
      if(i+1<3) K[KEYS[i][j]].insert(KEYS[i+1][j]);
    }
  }
  for(int i=0;i<1000;++i){
    string s;cin>>s;
    char before = s[0];
    bool f=false;
    for(int j=1;j<s.size();++j){
      if(K[s[j-1]].find(s[j])==K[s[j-1]].end()){
        f=true;break;
      }
    }
    if(!f) cout<<s<<endl;
  }
}

Measured memory_bytes: 1192
#include <stdio.h>

int solve(int i, int m);

int n;
int A[25];
int main (void) {
    int q, m;
    scanf("%d", &n);
    int i;
    for (i = 0 ; i < n ; i ++) {
        scanf("%d", &A[i]);
    }

    scanf("%d", &q);
    for (i = 0 ; i < q ; i ++) {
        scanf("%d", &m);
        if (solve (0, m)) printf("yes\n");
        else printf("no\n");
    }

    return 0;
}

int solve (int i, int m) {
    int res;
    if(m == 0) return 1;
    if (i >= n) return 0;

    res = solve (i + 1, m) || solve (i + 1, m - A[i]);
    return res;
}

Measured memory_bytes: 580
// Never let them see you bleed...

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;

const int maxn = 15e4 + 10, mod = 1e9 + 7;
const ll inf = 1e18 + 10;

vector<pii> v[maxn];
set<pll> st[maxn];
ll LIM;

void add(set<pll> &st, pll p){
    if(st.count(p))
	return;
    auto it = st.upper_bound(p);
    if(it != st.begin() && (prev(it)->S) <= p.S)
	return;
    it = st.insert(p).F;
    while(next(it) != st.end() && p.S <= (next(it)->S))
	st.erase(next(it));
}
bool dfs(int u){
    st[u].clear();
    for(pii y : v[u]){
	if(!dfs(y.F))
	    return 0;
    }
    if(sz(v[u]) == 0){
	st[u].insert({0,0});
	return 1;
    }
    if(sz(st[v[u][0].F]) > sz(st[v[u][1].F]))
	swap(v[u][0], v[u][1]);
    pii A = v[u][0], B = v[u][1];
    for(pll p : st[A.F]){
	auto it = st[B.F].upper_bound({LIM - p.S - A.S - B.S, inf});
	if(it != st[B.F].begin()){
	    --it;
	    add(st[u], {p.F + A.S, it->S + B.S});
	    add(st[u], {it->S + B.S, p.F + A.S});
	}
    }
    if(st[u].empty())
	return 0;
    return 1;
}

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

    int n;
    cin >> n;
    for(int i = 2; i <= n; i++){
	int p, c;
	cin >> p >> c;
	v[p].PB({i, c});
    }
    ll l = -1, r = 1ll * maxn * maxn;
    while(r-l > 1){
	ll mid = (l+r) >> 1;
	LIM = mid;
	if(dfs(1))
	    r = mid;
	else
	    l = mid;	
    }
    return cout << r << endl, 0;
}


Measured memory_bytes: 82432
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>x;
    rep(i,n)cin>>a[i];
    rep(i,n-1){
        sum=a[i]+a[i+1];
        if(sum<=x)continue;
        ll want=sum-x;
        ans+=want;
        if(a[i+1]>=want){
            a[i+1]-=want;
        }
        else{
            want-=a[i+1];
            a[i+1]=0;
        }
    }
    Cout(ans);
    return 0;
}

Measured memory_bytes: 1024
/*
        |___Arshit Mangukiya___|
        |___DA-IICT____|
        |___201801173____|
*/
        //__WRITE  YOUR  CODE  HERE___//
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;            
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppl;
typedef vector<pll> vpl;
#define ff first
#define ss second
#define pi acos(-1)
#define mr_ad_0501 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define all(a)      a.begin(),a.end()
#define f(i,a,n) for(ll i=a;i<n;i++)
#define MOD 1000000007
#define MAX 200007
#define LM LLONG_MAX
#define sz size()
#define p(x)        cout<< x << " ";
#define pe(x)       cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
const int N=1e5+5;
        /*  bool fun(pair<int,int>a , pair<int,int>b)
            {
                if(a.ff == b.ff)    return a.ss < b.ss;
                else            return a.ff < b.ff;
            }*/
 /*void bfs(ll x)
 {
    queue<ll> q;
    q.push(x);
    while(!q.empty())
    {
        ll k=q.front();
        q.pop();
        for(auto X:v[k])
        {
            if(!vis[X])
            {
                l[X]=l[k]+1;
                vis[X]=1;
                q.push(X);
            }
        }
    }
 }*/

void solve()
{
	ll n;
	cin>>n;
	ll a=0,w=0,t=0,r=0;
	while(n--)
	{
		string s;
		cin>>s;
		if(s=="AC")a++;
		if(s=="WA")w++;
		if(s=="TLE")t++;
		if(s=="RE")r++;
		
	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<w<<endl;
	cout<<"TLE x "<<t<<endl;
	cout<<"RE x "<<r;
}
    
int32_t main(){
    mr_ad_0501;
    ll t=1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    
}

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

/** defines and macros */
#define ll long long
#define ull unsigned long long
#define loop(n) for(int i = 0; i < n; i++)
#define loop1(n) for(int i = 1; i <= n; i++)
#define all(v) ((v).begin()), ((v).end())
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vvi vector<vi>
#define vvpii vector<vii>
#define PB push_back

#define fw(fileName) freopen(fileName, "w", stdout)
#define fr(fileName) freopen(fileName, "r", stdin)
#define fc(stream) fclose(stream);

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

/*To compile and run

	g++ -o main main.cpp && ./main

*/

/*
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣀⣤⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣷⣶⣤⣀⡀⠄⠄⠄⠄⠄⣰⣷⡀⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⣀⣀⣀⠄⠄⠄⠄⠄⣠⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣄⠄⠄⢠⣿⣿⣷⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠤⠒⠛⠛⠛⠛⠻⠷⣦⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⣿⣿⣿⠟⠁⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⢀⣤⣤⣶⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣡⡤⠐⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⢀⣶⣿⣿⠿⢛⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠁⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⢠⣿⠟⠉⢀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠘⠁⠄⢀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠻⣿⣿⣿⣿⣿⣿⣿⡛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⣾⣿⡿⣽⡿⢹⣿⣿⣟⣿⢻⠇⢀⢹⣿⢿⣿⣿⣿⣿⣿⣦⣙⢿⣿⢷⣈⠻⢿⣟⢿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⢿⡿⠁⡿⠁⢸⣿⣿⢹⡇⢸⠄⠈⠄⠻⣏⠻⣿⡿⣿⣿⣿⣌⠛⢿⡌⠙⢧⣀⠙⢳⡹⢻⣿⣿⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠘⡇⠄⡇⢠⣼⣿⣿⠈⡇⠘⠤⠤⠤⠤⢜⣢⣘⡻⢮⡛⢿⣿⣷⣬⡤⠤⠤⠤⠥⠤⠥⢬⣿⣧⡄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠁⠄⠄⠘⢿⡏⠛⠄⠄⠄⠄⠄⠄⠄⠄⠄⠙⣿⣿⣿⡿⠋⠉⠛⠉⠄⠄⠄⠄⠄⠄⠄⢹⡿⠃⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠘⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⡟⠁⠈⢳⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢸⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠱⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⡜⠁⠄⠄⠈⢇⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠑⠦⢄⣀⣀⣀⣀⣀⠴⠊⠄⠄⠄⠄⠄⠄⠑⠤⢀⣀⣀⣀⡀⠠⠔⠋⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣶⣦⣄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣤⣶⣆⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢸⣿⣿⣿⣿⣶⣄⣀⣀⣀⣀⣤⣾⣿⣿⣿⣿⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢸⣿⣿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣿⣿⣿⣿⣿⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠘⣿⣿⣿⣿⠟⠁⠄⠄⠄⠄⠙⢿⣿⣿⣿⡟⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠘⠟⠋⠁⠄⠄⠄⠄⠄⠄⠄⠄⠉⠛⠿⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
*/

const double pi = 3.14159265358979323846;

int main() {
	faster_IO_stream

	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	if(a > 0 && c > 0) cout << b * d << "\n";
	else if(b <= 0 && d <= 0) cout << a * c << "\n";
	else cout << max(max(a * c, a * d), max(b * c, b * d)) << "\n";

//	if((a >= 0 || b >= 0) && (c >= 0 ||  d >= 0)) cout << max(abs(a), abs(b)) * max(abs(c), abs(d)) << "\n";
//	else cout << max(a, b) * max(c, d) << "\n";

	return 0;
}


Measured memory_bytes: 3648