akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define foreach(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define all(c) begin(c),end(c)
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

vvi gettable(const vi& a,const vector<tuple<int,int,int>>& rs)
{
	int n=a.size();
	vector<vector<unordered_set<int>>> dp(n,vector<unordered_set<int>>(n));
	rep(i,n) dp[i][(i+1)%n].insert(a[i]);
	//per(i,n) repi(j,i+2,n+1) repi(k,i+1,j)
	//	for(auto r:rs){
	//		int x1,x2,y; tie(x1,x2,y)=r;
	//		if(dp[i][k%n].count(x1) && dp[k][j%n].count(x2))
	//			dp[i][j%n].insert(y);
	//	}
	repi(len,2,n+1) rep(i,n) repi(j,1,len)
		for(auto r:rs){
			int x1,x2,y; tie(x1,x2,y)=r;
			if(dp[i][(i+j)%n].count(x1) && dp[(i+j)%n][(i+len)%n].count(x2))
				dp[i][(i+len)%n].insert(y);
		}
	vvi res(n,vi(n));
	rep(i,n) rep(j,n)
		for(int x:dp[i][j]) if(x>=0)
			res[i][j]|=1<<x;
	return res;
}


int calc(const vi& a,const vi& b,const vvi& ta,const vvi& tb)
{
	int n=a.size(),m=b.size();
	
	vvi dp(n+1,vi(m+1,-1e8));
	dp[n][m]=0;
	peri(j,1,n+1) peri(l,1,m+1) rep(i,j) rep(k,l)
		if(ta[i][j%n]&tb[k][l%m])
			dp[i][k]=max(dp[i][k],dp[j][l]+1);
	return dp[0][0];
}

void rotate(vi& a,vvi& ta)
{
	rotate(begin(a),begin(a)+1,end(a));
	rotate(begin(ta),begin(ta)+1,end(ta));
	rep(i,ta.size())
	rotate(begin(ta[i]),begin(ta[i])+1,end(ta[i]));
}

int main()
{
	for(int n,m,r;cin>>n>>m>>r,n|m|r;){
		vi a(n),b(m);
		rep(i,n) cin>>a[i],a[i]--;
		rep(i,m) cin>>b[i],b[i]--;
		
		vector<tuple<int,int,int>> rs;
		for(int i=0,c=0;i<r;i++){
			int k; cin>>k;
			vi xs(k+1);
			rep(j,k+1){
				cin>>xs[j];
				xs[j]--;
			}
			int p=xs[0];
			repi(j,1,k-1){
				rs.emplace_back(p,xs[j],--c);
				p=c;
			}
			rs.emplace_back(p,xs[k-1],xs[k]);
		}
		
		vvi ta=gettable(a,rs),tb=gettable(b,rs);
		
		int res=-1;
		rep(i,n){
			rep(j,m){
				res=max(res,calc(a,b,ta,tb));
				rotate(b,tb);
			}
			rotate(a,ta);
		}
		
		cout<<res<<endl;
	}
}

Measured memory_bytes: 1380
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int n, m; cin >> n >> m;
	vector<vector<int>> g;
	g.resize(n);
	for (int i = 0; i < m; ++i) {
		int a, b; cin >> a >> b;
		--a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	queue<int> q;
	vector<int> pre(n, -1);
	vector<int> dist(n, INF);
	q.push(0);
	dist[0] = 0;
	while(!q.empty()) {
		int p = q.front(); q.pop();
		for (int u: g[p]) {
			if(dist[u] != INF) continue;
			dist[u] = dist[p] + 1;
			pre[u] = p;
			q.push(u);
		}
	}
	int ans = 0;
	cout << "Yes" << endl;
	for (int i = 0; i < n; ++i) {
		if (i == 0) continue;
		ans = pre[i];
		ans++;
		cout << ans << endl;
	}
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 10648
W, H, x, y, r = input().split()
W = int(W)
H = int(H)
x = int(x)
y = int(y)
r = int(r)
if x - r >= 0\
and y - r >= 0\
and x + r <= W\
and y + r <= H:
    print("Yes")
else:
    print("No")

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

using namespace std;

int main()
{
  int n;
  cin >> n;

  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin >> p.at(i);
  }
  int count=0;
  for(int i=1;i<n-1;i++){
    if(p.at(i-1)<p.at(i)&&p.at(i)<p.at(i+1)){
      count++;
    }
    else if(p.at(i-1)>p.at(i)&&p.at(i)>p.at(i+1)){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    int r;cin>>r;
    if(r<1200)cout<<"ABC"<<endl;
    else if(r<2800)cout<<"ARC"<<endl;
    else cout<<"AGC"<<endl;
}

Measured memory_bytes: 256
s=input()
q=int(input())
hanten=0
s_1 = ""
s_2 = ""

for i in range(q):
    s1=input()
    if len(s1)==1:
        hanten+=1
    else:
        a,f,c=s1.split()
        f=int(f)
        if (f+hanten)%2==0:
            s_2 += c
        else:
            s_1 = c + s_1     

if hanten%2==0:
    print(s_1 + s + s_2)
else:
    s_3 = s_1 + s + s_2
    print(s_3[::-1])


Measured memory_bytes: 4600
#include<bits/stdc++.h>
using namespace std;
int x;
int main()
{
	scanf("%d",&x);
	int flag=0;
	while(1)
	{
		flag=0;
		for(int i=2;i<x;i++)
		{
			if(x%i==0)
			{
				flag=1;
				break;
			}
		}
		if(flag==0)
		{
			printf("%d",x);
			return 0;
		}
		x++;
	}
	
	return 0; 
} 

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

using namespace std;
const int MAX=3000;
int slen,tlen,dp[MAX+2][MAX+2];
string s,t;
vector<char> v;

int solve(int sp,int tp){
if(sp==slen ||tp==tlen) return 0;
if(dp[sp][tp]!=-1) return dp[sp][tp];
int ans = INT_MIN;
ans=max(ans,solve(sp,tp+1));
ans=max(ans,solve(sp+1,tp));
if(s[sp]==t[tp]) ans=max(ans,solve(sp+1,tp+1)+1);
return dp[sp][tp]=ans;
}

int main()
{
    cin>>s>>t;
    slen=s.length();
    tlen=t.length();
    memset(dp,-1,sizeof dp);
    solve(0,0);
    int x=0,y=0;
    while(x!=slen&&y!=tlen){
        int ans=INT_MIN,hold=0;
        if(solve(x,y+1)>=ans){
            hold = 1;
            ans=solve(x,y+1);
        }
        if(solve(x+1,y)>=ans){
            hold = 2;
            ans=solve(x+1,y);
        }
        if(s[x]==t[y] && solve(x+1,y+1)>=ans){
            hold = 3;
        }
        if(hold==1) y++;
        if(hold==2) x++;
        if(hold==3){
            v.push_back(s[x]);
            x++;
            y++;
        }
    }
    for(int i=0;i<v.size();i++) cout<<v[i];
    return 0;
}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    int A[N]; rep(i, N) cin >> A[i];
    int ulim = 1000000;
    sort(A, A+N);
    vector<bool> nodiv(ulim+1, true);
    rep(i, N){
        if(nodiv[A[i]]) for(int j = (A[i] << 1); j <= ulim; j+=A[i]) nodiv[j] = false;
        if(i < N-1 && A[i] == A[i+1]) nodiv[A[i]] = false;
    }
    int ans = 0;
    rep(i, N) if(nodiv[A[i]]) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4540
#include <iostream>
#include<stdio.h>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<math.h>
#include<cmath>
using namespace std;
set<int>lp[30];
int main()
{
    int n,i,j,k,l;
    string s;
    cin>>n>>s;
    for(i=0;i<n;i++)
    {
        lp[s[i]-'a'].insert(i);
    }
    cin>>k;
    char pi;
    for(i=0;i<k;i++)
    {
        cin>>j;
        if(j==1)
        {
            cin>>l>>pi;
            l--;
            lp[s[l]-'a'].erase(l);
            lp[pi-'a'].insert(l);
            s[l]=pi;
        }
        else
        {
            int sum=0,p,q;
            cin>>p>>q;
            p--,q--;
            
            for(int pp=0;pp<26;pp++)
            {
                set<int>::iterator po;
                po=lp[pp].lower_bound(p);
                if(po==lp[pp].end())
                    continue;
                    if(*po<=q)
                    sum++;
            }
            printf("%d\n",sum);
        }
    }
    return 0;
}



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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, k, n) for (int i = k; i < n; ++i)
#define fore(i,a) for (auto &i : a)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

signed main (int argc, char *argv[]) {
    int n;
    cin >> n;
    vector<int> V(n), C(n);
    rep(i, n) cin >> V[i];
    rep(i, n) cin >> C[i];

    int ans = 0;
    rep(i, n) {
        if (V[i] - C[i] > 0) ans += V[i] - C[i];
    }

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

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#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--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;

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

int main(){
    //input
    ll N; cin>>N;
    vector<int> L(N+1,0);
    rep1(i,N) cin>>L[i];
    sort(all(L));
    L.pb(1000000);
    ll ans=0;

    rep1(i1,N-2){
        FOR(i2,i1+1,N){
            int tmp=L[i1]+L[i2];
            
            // 二分探索
            int l=i2+1,r=N+1;
            while(r-l>=1){
                int i=(l+r)/2;
                if(L[i]<tmp) l=i+1;
                else r=i;
            }
            ans+=max((ll)0,r-i2-1);
        }
    }

    cout<<ans<<endl;
}

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

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}


	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		Map<Long,Long>cnt = new HashMap<>();
		List<Long> a = new ArrayList<>();
		for(int i=0; i<n; i++) {
			long v=sc.nextLong();
			cnt.put(v, cnt.containsKey(v) ? cnt.get(v)+1 : 1);
			a.add(v);
		}
		Collections.sort(a);
		a = a.stream().distinct().collect(Collectors.toList());
		ArrayList<Long> ans = new ArrayList<>();
		for(int i=a.size()-1; i>=0; i--) {
			long v=a.get(i);
			if(cnt.get(v) >= 4) {
				ans.add(v);
				ans.add(v);
			}else if(cnt.get(v)>=2) {
				ans.add(v);
			}
			if(ans.size()>=2) break;
		}
		if(ans.size()<1){
			System.out.println(0);
		}else {
			System.out.println(ans.get(0)*ans.get(1));
		}
		sc.close();
	}





}


Measured memory_bytes: 73060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;


void ABC166C()
{
	int N, M;
	cin >> N >> M;
	vi H(N);
	for (auto& x : H)
		cin >> x;
	vector<set<int> > path(N);
	for (int i = 0; i < M; ++i)
	{
		int A, B;
		cin >> A >> B;
		--A; --B;
		path[A].insert(B);
		path[B].insert(A);
	}
	int ans = 0;
	for (int i = 0; i < N; ++i)
	{
		auto& neighber = path[i];
		bool highest = true;
		for (auto& x : neighber)
		{
			if (H[i] <= H[x])
			{
				highest = false;
				break;
			}
		}
		if (highest)
			++ans;
	}
	cout << ans << endl;
}


int main()
{
	ABC166C();
	return 0;
}


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

int main() {
  ll x;
  cin>>x;
  ll sho=x/11;
  if (x%11==0)cout<<sho*2<<endl;
  else if (x%11<=6)cout<<sho*2+1<<endl;
  else cout << (sho+1)*2<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	if (a == 1) {
		a += 13;
	}
	if (b == 1) {
		b += 13;
	}
	if (a < b) {
		cout << "Bob" << endl;
	}
	else if (a > b){
		cout << "Alice" << endl;
	}
	else {
		cout << "Draw" << endl;
	}
	return 0;
}



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

#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
#define EPS = 1e-14;
using std::vector;
using std::cout;
using std::cin;
using std::endl;
using std::max;
using std::min;
using std::swap;
using std::string;
using std::fill;
using std::pair;
using std::sort;
using std::reverse;
using std::pair;
using std::greater;
using std::priority_queue;
using std::ostream;

template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i] << endl;
	}
	return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last) {
			out << ",";
		}
	}
	out << "]";
	return out;
}

struct edge {
	int from, to, cost;
	edge() {
		*this = edge(-1, -1, -1);
	}
	edge(int from_, int to_, int cost_) {
		from = from_;
		to = to_;
		cost = cost_;
	}
	bool operator<(const edge& e) const {
		return cost < e.cost;
	}
};

void solve() {
	int a, b;
	cin >> a >> b;
	if (a + b <= 9) {
		cout << a + b << endl;
	} else {
		cout << "error" << endl;
	}
}

int main() {
	solve();
}


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

int N,A = 0,B = 0;
vector<int> a(200,0);

int main(){
				cin >> N;
				for(int i = 0; i < N; i++) cin >> a[i];
				for(int i = 0; i < N; i++){
								A += *max_element(a.begin(), a.end());
								a.erase(max_element(a.begin(), a.end()));
								B += *max_element(a.begin(), a.end());
								a.erase(max_element(a.begin(), a.end()));
				}
				cout << A - B << endl;
				return 0;
				}


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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	int a[n];
	for(int i = 0;i < n; ++i){cin >> a[i];--a[i];}
	int ans = 0;
	for(int i = 0;i < n; ++i){
		ans += a[a[i]] == i;	
	}
	ans/=2;
	cout << ans << '\n';
}


Measured memory_bytes: 640
class Dice1():
    def move(self,direction,n):
        if direction == "S":
            top = n[0]
            n[0] = n[4]
            n[4] = n[5]
            n[5] = n[1]
            n[1] = top
        elif direction == "N":
            top = n[0]
            n[0] = n[1]
            n[1] = n[5]
            n[5] = n[4]
            n[4] = top
        elif direction == "E":
            top = n[0]
            n[0] = n[3]
            n[3] = n[5]
            n[5] = n[2]
            n[2] = top
        elif direction == "W":
            top = n[0]
            n[0] = n[2]
            n[2] = n[5]
            n[5] = n[3]
            n[3] = top
        return n
n = [int(i) for i in input().split()]
di = list(input())
dc = Dice1()
for i in di:
    n = dc.move(i,n)
print(n[0])


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
using namespace std;

int main()
{
  int a,b; cin >> a >> b;
  
  if(a*b % 2 == 1) cout << "Odd" << endl;
  else cout << "Even" << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <iostream>
#include <bitset>
using namespace std;
#define N 1005
int dis[N][N],ans,n,m;char a[N][N];
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
void bfs()
{
	memset(dis,-1,sizeof(dis));
	queue<pair<int ,int > >q;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(a[i][j]=='#')dis[i][j]=0,q.push(make_pair(i,j));
	while(!q.empty())
	{
		int x=q.front().first,y=q.front().second;q.pop();ans=max(ans,dis[x][y]);
		for(int i=0;i<4;i++)
		{
			int tx=x+dx[i],ty=y+dy[i];
			if(tx<=n&&tx>0&&ty<=m&&ty>0&&dis[tx][ty]==-1)
				dis[tx][ty]=dis[x][y]+1,q.push(make_pair(tx,ty));
		}
	}
	printf("%d\n",ans);
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%s",a[i]+1);bfs();
}

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

using namespace std;
using ll = long long;
using ld = long double;

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

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif

  int x, y;
  cin >> x >> y;

  bool ok = true;
  ok &= (y % 2 == 0);
  ok &= (y >= 2 * x);
  ok &= (4 * x >= y);
  cout << (ok ? "Yes" : "No");
  cout << '\n';

  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  

/////////////

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	string s;
	cin>>s;
	if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2])
	{
		cout<<"Yes";
		return 0;
	}
	if(s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1])
	{
		cout<<"Yes";
		return 0;
	}
	if(s[0]==s[3]&&s[2]==s[1]&&s[0]!=s[2])
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
}

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

 int main(){
   int N;cin>>N;
   vector<int> a(N);
   for(int i=1;i<N;i++){
       int s;cin>>s;s--;
        a[s]++;
   }
   for(int i=0;i<N;i++){
       cout<<a[i]<<endl;
   }
 }

 
    

Measured memory_bytes: 4048
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int A,B;
    cin >> A >> B;

    cout << ( (A*B)%2 == 0 ? "No" : "Yes" ) << endl;


    return 0;
}

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

using namespace std;

const int inf = 1<<25;

int n;
int a[100010];
int dp[100010][2][2];

int chmin(int& a, int b) { return a = min(a, b); }

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) cin >> a[i];
  for(int i = 0; i < 100010; ++i) {
    for(int j = 0; j < 2; ++j) {
      for(int k = 0; k < 2; ++k) dp[i][j][k] = inf;
    }
  }
  dp[0][0][0] = 0;
  dp[0][1][0] = 0;
  for(int i = 0; i < n-1; ++i) {
    if(a[i+1] > a[i]) chmin(dp[i+1][0][0], dp[i][1][0]);
    if(i && a[i+1] > a[i-1]) chmin(dp[i+1][0][0], dp[i][1][1]);
    for(int j = 0; j < 2; ++j) {
      if(i && a[i+1] < a[i] && a[i+1] < a[i-1]) chmin(dp[i+1][0][1], dp[i-1][0][j]+1);
    }
    if(a[i+1] < a[i]) chmin(dp[i+1][1][0], dp[i][0][0]);
    if(i && a[i+1] < a[i-1]) chmin(dp[i+1][1][0], dp[i][0][1]);
    for(int j = 0; j < 2; ++j) {
      if(i && a[i+1] > a[i] && a[i+1] > a[i-1]) chmin(dp[i+1][1][1], dp[i-1][1][j]+1);
    }
  }
  int ans = inf;
  for(int i = 0; i < 2; ++i) {
    for(int j = 0; j < 2; ++j) chmin(ans, dp[n-1][i][j]);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 5016
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int A,B,K;
  cin>>A>>B>>K;
  
  int check=0;
  
  
  for(int i=min(A,B);i>0;i--){
    if(A%i==0&&B%i==0){
      check++;
    }
    if(check==K){
      cout<<i<<endl;
      break;
    }
  }
}

Measured memory_bytes: 3608
n,c = map(int, input().split())
x = []
x_r = []
v = []
for i in range(n):
    xi,vi = map(int, input().split())
    x.append(xi)
    x_r.append(c - xi)
    v.append(vi)
x_r.reverse()
x.insert(0, 0)
x_r.insert(0, 0)

score = [0]
score_r = [0]
tmp = 0
for i, vi in enumerate(v):
    tmp += vi
    score.append(tmp - x[i+1])
tmp = 0
for i, vi in enumerate(v[::-1]):
    tmp += vi
    score_r.append(tmp - x_r[i+1])

maxscore = []
maxscore_r = []
tmp = 0
for i, si in enumerate(score):
    tmp = max(tmp, si)
    maxscore.append(tmp)
tmp = 0
for i, si in enumerate(score_r):
    tmp = max(tmp, si)
    maxscore_r.append(tmp)

ans = 0
for i, si in enumerate(score):
    ans = max(si + maxscore_r[n-i] - x[i], ans)
for i, si in enumerate(score_r):
    ans = max(si + maxscore[n-i] - x_r[i], ans)

print(ans)

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

#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define rd(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define wt(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int main() {
  rd(int, x);
  if (x >= 30) {
    wt("Yes");
  } else {
    wt("No");
  }
}


Measured memory_bytes: 3596
a,b,c=map(int,input().split())
x=(-a+b*c+2*c-1)//(2*c)
if(x>=b):x=b
if(x<=0):x=0
def f(x):
	return abs(a+(2*x-b)*c)
print(min([f(x),f(max(x-1,0))]))

Measured memory_bytes: 61964
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=3e5+5;
int W,H,ans,n,nx,ny;
struct point{int x,y;}a[MN],b[MN],p[MN];
#define mid (l+r>>1)
#define ls (t<<1)
#define rs (t<<1|1)
int tr[MN<<2],tag[MN<<2];
inline void pushdown(int t){
	if(!tag[t])return;
	tag[ls]+=tag[t];tag[rs]+=tag[t];
	tr[ls]+=tag[t];tr[rs]+=tag[t];
	tag[t]=0;
}
void update(int t,int l,int r,int a,int b,int v){
	if(a<=l&&r<=b){tr[t]+=v;tag[t]+=v;return;}
	pushdown(t);
	if(a<=mid)update(ls,l,mid,a,b,v);
	if(b>mid)update(rs,mid+1,r,a,b,v);
	tr[t]=max(tr[ls],tr[rs]);
}
inline void solve(){
	sort(p+1,p+1+n,[](const point& a,const point& b){
		return a.x==b.x?a.y<b.y:a.x<b.x;
	});
	memset(tr,0,sizeof(tr));
	memset(tag,0,sizeof(tag));
	reg ll l=0,r=0;
	for(reg int i=1;i<=n;i++){
		if(p[i].y<=H/2){
			reg int pre=i-1;
			while(l&&a[l].y<p[i].y){
				update(1,1,n,a[l].x,pre,a[l].y-p[i].y);
				pre=a[l].x-1;l--;
			}
			if(pre!=i-1)a[++l]={pre+1,p[i].y};
		}
		else{
			reg int pre=i-1;
			while(r&&b[r].y>p[i].y){
				update(1,1,n,b[r].x,pre,p[i].y-b[r].y);
				pre=b[r].x-1;r--;
			}
			if(pre!=i-1)b[++r]={pre+1,p[i].y};
		}
		a[++l]={i,0};b[++r]={i,H};
		update(1,1,n,i,i,H-p[i].x);
		ans=max(ans,tr[1]+p[i+1].x);
	}
	return;
}
int main(){
	scanf("%d%d%d",&W,&H,&n);
	for(reg int i=1;i<=n;i++)
		scanf("%d%d",&p[i].x,&p[i].y);
	p[++n]={0,0};p[++n]={W,H};solve();
	for(reg int i=1;i<=n;i++)swap(p[i].x,p[i].y);
	swap(W,H);solve();printf("%d\n",ans*2);
	return 0;
}

Measured memory_bytes: 16640
#include <stdio.h>
#include <algorithm>
using namespace std;
int N, A, B, v[111], r[111], G[111][222];
int rec(int pos) {
	int ret = 0; v[pos] = 1;
	for (int i = 0; i < r[pos]; i++) {
		if (!v[G[pos][i]]) ret = max(ret, rec(G[pos][i]));
	}
	v[pos] = 0;
	return ret + 1;
}
int main() {
	while (scanf("%d", &N), N) {
		for (int i = 0; i < 100; i++) r[i] = 0;
		for (int i = 0; i < N; i++) {
			scanf("%d%d", &A, &B), A--, B--;
			G[A][r[A]++] = B, G[B][r[B]++] = A;
		}
		int ret = 0;
		for (int i = 0; i < 100; i++) ret = max(ret, rec(i));
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 2760
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N, K;
	
	cin >> N >> K;

	int a[N];

	int c[200010];
	memset(c, 0, sizeof(c));

	rep(i, N)
	{
		cin >> a[i];
		c[a[i]]++;
	}

	sort(c, c+200010, greater<int>());

	int count = 0;
	rep(i, K)
	{
		count += c[i];
	}

	cout << N - count << endl;
	
	return 0;
}


Measured memory_bytes: 1920
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

a,b = I()
for i in range(1,2000):
    if int(i*0.08)==a and int(i*0.1)==b:
        print(i)
        sys.exit()

print(-1)


Measured memory_bytes: 10520
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> graph[300000];
  for (int i = 0; i < M; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    graph[u].push_back(v + N);
    graph[u + N].push_back(v + N + N);
    graph[u + N + N].push_back(v);
  }
  int S, T;
  cin >> S >> T;
  S--;
  T--;
  // SからTへの最短経路を探る
  int ans = -1;
  vector<int> visited(300000, 0);
  queue<pair<int, int>> qu;
  qu.push(P(S, 0));
  visited[S] = 1;
  while (!qu.empty()) {
    auto now = qu.front();
    auto vertex = now.first;
    auto dist = now.second;
    qu.pop();

    for (const auto& v : graph[vertex]) {
      if (!visited[v]) {
        visited[v] = true;
        qu.push(P(v, dist + 1));
        if (v == T) {
          ans = (dist + 1) / 3;
        }
      }
    }
    if (ans != -1) {
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 17792
#include <iostream>

using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
int n, d, x, ans = 0;
int a[100]={0};
int main() {
    cin >> n >> d >> x;
    rep(i, n)
        cin >> a[i];
    rep(i, n){
        rep(j, d){
            //cout << (j+1)%a[i] <<endl;
            if(((j+1)%a[i]) == 1 || a[i]==1){
                ans++;
            }
        }
    }
    ans += x;
	cout<< ans <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll n; cin >> n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++) cin >> a[i];
    sort(ALL(a));
    ll ans = 1;
    ll start,cur;

    if(n%2 == 1){
        if(a[0] != 0) ans = 0;
        start = 1;
        cur = 2;
    }else{
        start = 0;
        cur = 1;
    }

    for(ll i=start;i<n;i+=2){
        if(a[i] != cur  or  a[i+1] != cur){
            ans = 0;
            break;
        }
        ans *= 2;
        ans %= mod;
        cur += 2;
    }

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



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

int main(){
	long long int A, B, C;
	cin >> A >> B >> C;
	long long ans = 0;
	if(A+B == C || A+B+1 == C){
		cout << C+B << endl;
		return 0;
	}
	if(A+B > C){
		cout << B + C << endl;
		return 0;
	}
	if(A+B < C){
		cout << A+2*B+1 << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
/***********************************************
#
#      Filename: c.cpp
#
#        Author: Comsyl - ylsong15@fudan.edu.cn
#   Description: ---
#        Create: 2017-05-20 20:07:37
***********************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll ans = 1LL << 60;

void cut1(int H, int W) {
    int c1 = H / 3, c2 = H / 3;
    int c3 = H - c1 - c2;
    if (!c1 || !c2 || !c3) return ;
    ll res = (max(c1, c3) - min(c1, c3)) * 1LL * W;
    ans = min(ans, res);

    c1 = H/3+1;
    c2 = H/3+1;
    c3 = H - c1 - c2;
    if (!c1 || !c2 || !c3) return ;
    res = (max(c1, c3) - min(c1, c3)) * 1LL * W;
    ans = min(ans, res);

}

void cut2(int H, int W) {
    for (int w = 1; w <= W-1; ++ w) {
        ll a1 = w * 1LL * H * 1LL;
        ll a2 = (H/2) * 1LL * (W - w) * 1LL;
        ll a3 = (H-H/2) * 1LL * (W - w) * 1LL;
        if (!a1 || !a2 || !a3) return ;
        ll min_v = min( min(a1, a2), a3);
        ll max_v = max( max(a1, a2), a3);
        ll res = max_v - min_v;
        ans = min(ans, res);
    }
}

int main()
{
    int H, W;
    cin >> H >> W;
    if (H % 3 == 0 || W % 3 == 0) {
        cout << 0 << endl;
        return 0;
    }
    if (H >= 3) cut1(H, W);
    if (W >= 3) cut1(W, H);
    cut2(H, W);
    cut2(W, H);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

int N, M, X;
vector<int> C;
vector<vector<int>> A;

int solverec(int b, int set, vector<int> &S, int total_cost) {
    int ans = numeric_limits<int>::max();
    for (int i = b; i < N; ++i) {
        if ((set >> i) & 1) continue;
        bool satisfy = true;
        for (int j = 0; j < M; ++j) {
            S[j] += A[i][j];
            if (S[j] < X) satisfy = false;
        }
        if (satisfy) {
            ans = min(ans, total_cost + C[i]);
        }
        ans = min(ans, solverec(i + 1, set | (1 << i), S, total_cost + C[i]));

        for (int j = 0; j < M; ++j) {
            S[j] -= A[i][j];
        }
        ans = min(ans, solverec(i + 1, set, S, total_cost));
    }
    return ans;
}

int solve() {
    vector<int> S(M, 0);
    int ans = solverec(0, 0, S, 0);
    if (ans == numeric_limits<int>::max()) {
        return -1;
    }
    return ans;
}

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

    cin >> N >> M >> X;
    C.assign(N, 0);
    A.assign(N, vector<int>(M, 0));
    for (int i = 0; i < N; ++i) {
        cin >> C[i];
        for (int j = 0; j < M; ++j) {
            cin >> A[i][j];
        }
    }
    cout << solve() << endl;

    return 0;
}

Measured memory_bytes: 3636
n,h=map(int,input().split())

b = []
t = []
for _ in range(n):
    c,d = map(int,input().split())
    b.append(c)
    t.append(d)


b_max = max(b)
t =sorted(t)

from bisect import bisect_right
from math import ceil
index = bisect_right(t,b_max)

ans=0
for i in range(n-1,index-1,-1):
    h-=t[i]
    ans+=1
    if h<=0:
        print(ans)
        exit(0)

cnt = ceil(h/b_max)

print(ans+cnt)




Measured memory_bytes: 17824
n = int(input())

sp = []
for i in range(n):
    _s, _p = input().split()
    sp.append((_s, int(_p), i+1))

sp.sort(reverse=True, key=lambda x:x[1])
sp.sort(key=lambda x:x[0])

for i in sp:
    print(i[2])

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

using namespace std;

int main(){
  int a, b, c;
  string s;
  int n,k;
  cin >> n >> s >> k;

  for(int i = 0; i < n ; i++){
    if(s[i] != s[k-1]) s[i] = '*';
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 2019;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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 mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};

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

  ll arr[200100];
  ll count[3000];

  // ll keta = 1;
  int keta = 0;
  reverse(s.begin(), s.end());
  rep(i, s.size())
  {
    struct mint m(10);
    struct mint tmp(s[i] - '0');
    int val = (tmp * m.pow(keta)).x;
    if (i == 0)
      arr[i] = val % 2019;
    else
      arr[i] = (arr[i - 1] + val) % 2019;
    count[arr[i]]++;
    keta++;
  }

  ll ans = 0;
  count[0]++;
  rep(i, 2019)
  {
    ans += (count[i] * (count[i] - 1)) / 2;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5312
#include<iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <limits>
#include <map>
#include <bitset>

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

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

vector< vector<int> > memo;

int gcd(int a, int b, int c) {
	int min_num = (a > b) ? b : a;
	if (min_num > c) min_num = c;
	while (min_num != 1) {
		if (a % min_num == 0 && b % min_num == 0 && c % min_num == 0) break;
		min_num--;
	}
	return min_num;
}

int gcd(int a, int b) {
	int m = (a < b) ? a : b;
	while (m != 1) {
		if (a % m == 0 && b % m == 0)break;
		m--;
	}
	return m;
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n-1) {
		int tmp;
		cin >> tmp;
		a[tmp - 1]++;
	}

	rep(i, n)cout << a[i] << endl;

	return 0;
}


Measured memory_bytes: 4052
object Main {
    def solve(used : Set[String], ws : List[String]) : Unit = {
        ws match {
            case Nil => println("Yes")
            case w::Nil => 
                if (used contains w) println("No") else println("Yes")
            case w1::w2::ws => {
                if (w1(w1.length - 1) == w2(0) && !(used contains w1))
                    solve(used + w1, w2::ws)
                else
                    println("No")
            }
        }
    }
    def main(args: Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        val n = sc.nextInt
        val ws = List.fill(n)(sc.next)
        solve(Set(), ws)
    }
}

Measured memory_bytes: 27328
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>

typedef unsigned long long ULONG;
typedef long long LONG;
using namespace std;

#define PI 3.1415926535897932384626433
#define _DBG_

#define BIG 10000000000 //10

#define LAST 10000000 //10^7





int main(void) {

	LONG N;
	cin >> N;
	vector<LONG > A(N);
	for (LONG n = 0; n < N; n++) {
		cin >> A[n];
	}
	sort(A.begin(), A.end());
	vector<LONG > A2(N);
	for (LONG n = 0; n < N; n++) {
		A2[n] = A[N - n - 1];
	}
	LONG sum = 0;
	sum += A2[0];
	for (LONG n = 1; n < N-1; n++) {
		sum += A2[(n + 1) / 2];
	}
	
	cout << sum << endl;




	return 0;
}



Measured memory_bytes: 6404
#include<iostream>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
  
  	int counter_5 = 0;
  	int counter_7 = 0;
      
  	if (a == 5)
    {
      counter_5++;
    }
    if (b == 5)
    {
      counter_5++;
    }
    if (c == 5)
    {
      counter_5++;
    }
  	if (a == 7)
    {
      counter_7++;
    }
    if (b == 7)
    {
      counter_7++;
    }
    if (c == 7)
    {
      counter_7++;
    }
  
  	if (counter_5 == 2 && counter_7 == 1)
    {
      cout << "YES" << endl;
    }
    else
    {
      cout << "NO" << endl;
    }
  
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  long long n;

  scanf("%lld",&n);
  long long m=n;
  int i=1;
  long long j=1;
  while(n>=10){
    n=n/10;
    i++;
    j=j*10;
  }
  if((m+1)%j==0){
    printf("%lld\n",n+9*(i-1));
  }
  else{
    printf("%lld\n",n-1+9*(i-1));
  }

  return 0;
}
  


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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m, x;
    cin>>n>>m>>x;
    
    int c[n];
    int a[n][m];
    f1(i,0,n)
    {
        cin>>c[i];
        f1(j,0,m)
        cin>>a[i][j];
    }

    int ans = mod;
    int num = 1ll<<n;
    
    for(int i = 0; i < num; i++)
    {
        // cout<<i<<endl;
        int cost = 0;
        int arr[m];
        memset(arr, 0, sizeof(arr));

        for(int j = 0; j < n; j++)
        {
            if( (i & (1ll<<j)) > 0)
            {
                // cout<<i<<gp<<j<<endl;
                cost+=c[j];
                f1(k,0,m)
                arr[k] += a[j][k];
            }
        }
        int flag = 1;
        f1(j,0,m)
        if(arr[j] < x) {
            // cout<<111<<gp<<j<<gp<<arr[j]<<endl;
            flag = 0;
        }
        
        if(flag)
        ans = min(ans, cost);
        // cout<<cost<<endl<<ans<<endl;

    }
    if(ans == mod)
    cout<<-1<<endl;
    else
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3656
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	i64 n, m;
	cin >> n >> m;
	i64 ans;
	if (m == 1)
	{
		ans = 0;
	}
	else if (n <= m / 2)
	{
		ans = n + (m - n * 2) / 4;
	}
	else
	{
		ans = m / 2;
	}
	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

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

template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

const int MAX = 210000;
const ll MOD = 998244353;
ll dp[5100][5100];
ll sum[5100];
ll fac[MAX], finv[MAX], inv[MAX];

ll comb_init(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  FOR(i, 2, MAX){
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}
ll comb(int n, int k){
  if(n < k) return 0;
  if(n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
ll modpow(ll a,ll n, ll mod){
  ll res = 1;
  while(n > 0){
    if(n&1) res = res*a%mod;
    a = a*a%mod;
    n >>= 1;
  }
  return res;
}
ll modinv(ll a, ll mod){
  ll b = mod, u = 1, v = 0;
  while(b){
    ll t = a/b;
    a -= t*b; swap(a, b);
    u -= t*v; swap(u, v);
  }
  u %= mod;
  if(u < 0) u += mod;
  return u;
}
int
main(void){  
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  string s;
  cin >> s;

  comb_init();
  int n = s.size();

  sum[0] = 0LL;
  REP(i, n){
    int num = 0;
    if(s[i] == '0') num += 2;
    else if(s[i] == '1') num += 1;
    sum[i+1] = sum[i] + num;
  }
  //なぜ 1?
  dp[0][0] = 1;
  REP(i, n){
    REP(r, i+1){
      if(dp[i][r] == 0) continue;
      //赤の総数が r+1個 以上ならば
      if(sum[i+1] >= r+1){
	dp[i+1][r+1] += dp[i][r];
	dp[i+1][r+1] %= MOD;
      }
      //青の総数が i+1-r個 以上ならば
      if((i+1)*2-sum[i+1] >= i+1-r){
	dp[i+1][r] += dp[i][r];
	dp[i+1][r] %= MOD;
      }
    }
  }
  ll res = 0LL;
  REP(r, n+1){
    res += dp[n][r] * comb(n, sum[n]-r)%MOD;
    res %= MOD;
  }
  cout << res << endl;
  return 0;
}


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

int main() {
  int N, M, key = 0, kk = 0;
  string U[256], T;
  cin >> N;
  rep(i, N) cin >> U[i];
  cin >> M;
  rep(i, M) {
    cin >> T;
    rep(i, N) {
      if (U[i] == T && key == 0) {
        cout << "Opened by " << T << endl;
        key = 1;
        kk = 1;
        break;
      } else if (U[i] == T && key == 1) {
        cout << "Closed by " << T << endl;
        key = 0;
        kk = 1;
        break;
      }
    }
    if (kk == 0) {
      cout << "Unknown " << T << endl;
    }
    kk = 0;
  }
  return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

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

	if (N % 10 == 9 || N / 10 == 9)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
def main():
    h,w=map(int,input().split())
    n=int(input())
    a=list(map(int,input().split()))

    ans=[[0]*w for i in range(h)]
    
    i,j,right=0,0,True
    for color in range(1,n+1):
        #print(ans)
        cnt=a[color-1]
        while cnt>0:
            if right:
                if i+cnt<w:
                    for k in range(i,i+cnt):
                        ans[j][k]=color
                    i+=cnt
                    cnt=0
                else:
                    for k in range(i,w):
                        ans[j][k]=color
                    cnt-=w-i
                    i=w-1
                    j+=1
                    right=False
            
            else:
                if i+1-cnt>0:
                    for k in range(i,i-cnt,-1):
                        ans[j][k]=color
                    i-=cnt
                    cnt=0
                else:
                    for k in range(i,-1,-1):
                        ans[j][k]=color
                    cnt-=i+1
                    i=0
                    j+=1
                    right=True
    for i in range(h):
        print(*ans[i])
if __name__=='__main__':
    main()

Measured memory_bytes: 3916