akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		Map<Integer, Integer> count = new HashMap<>();
		for (int i = 0; i < N; i++) {
			int tmp = sc.nextInt();
			count.put(tmp, count.getOrDefault(tmp, 0) + 1);
		}
		boolean can = true;
		if (count.size() == 1 && count.keySet().iterator().next() == 0) {
		
		} else {
			if (N % 3 != 0) can = false;
			int hav = N / 3;
			int xor = 0;
			for (Map.Entry<Integer, Integer> e : count.entrySet()) {
				int cc = e.getValue();
				if (cc % hav != 0) can = false;
				
				while (cc > 0) {
					xor ^= e.getKey();
					cc -= hav;
				}
			}
			if (xor != 0) can = false;
		}
		out.println(can ? "Yes" : "No");
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 42392
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

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

int R, C;
bool field[11][10010];

int solve(int bits){
  rep(i, R){
    if(bits >> i & 1){
      rep(j, C){
	field[i][j] = !field[i][j];
      }
    }
  }
  
  int ret = 0;
  rep(j, C){
    int osenbei = 0;
    rep(i, R){
      if(field[i][j]) osenbei++;
    }
    ret += max(osenbei, R-osenbei);
  }
  
  rep(i, R){
    if(bits >> i & 1){
      rep(j, C){
	field[i][j] = !field[i][j];
      }
    }
  }
  return ret;
}

int main(){
  while(cin >> R >> C, R|C){
    rep(i, R) rep(j, C) cin >> field[i][j];
    
    int ans = 0;
    rep(i, (1<<R)){
      ans = max(ans, solve(i));      
    }
    cout << ans << endl;
  }  
  return 0;
}





  

Measured memory_bytes: 1260
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    replace(s.begin(), s.end(), ',', ' ');
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll sor = 3;
  rep(i,n){
    cin >> a[i];
  }
  ll ans = 1;
  vector<ll> num(sor,0);
  rep(i,n){
    tmp1 = 0;
    rep(j,sor){
      if(a[i] == num[j]){
        tmp1++;
      }
    }
    rep(j,sor){
      if(a[i] == num[j]){
        num[j]++;
        break;
      }
    }
    ans = ans * tmp1 % mod;
    //cout << ans;
  }
  cout << ans << endl;
}


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

int main(){
    int A, B;
    cin >> A >> B;
    if (B == 1){
        cout << 0 << endl;
    }
    else{
        int count = A;
        int ans = 1;
        while (count < B){
            count += A - 1;
            ans++;
        }
        cout << ans << endl;
    }
}

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)
#define REP(i, n, m) for (long long i = (long long)(n); i < (long long)(m); i++)

namespace solver {
  using namespace std;
  typedef long long ll;

  string S;

  void init() {
    cin >> S;
  }

  void solve() {
    if(S=="ARC") cout << "ABC" << endl;
    else cout << "ARC" << endl;
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 3568
#include <iostream>

using namespace std;

int main(){

	int n;
	int w,h;

	int data[110][110];

	while(1){
	for(int i=0;i<110;i++){
		for(int j=0;j<110;j++){
			data[i][j]=0;
		}
	}
	cin>>n;
	if(n==0)break;
	cin>>w>>h;

	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		data[y][x]=1;
	}

	int s,t;
	cin>>s>>t;
	int max=0;
	for(int i=0;i<t+h;i++){
		for(int j=0;j<w+s;j++){
			int cnt=0;
			for(int y=i;y<i+t;y++){
				for(int x=j;x<j+s;x++){
					if(data[y][x]==1){
						cnt++;
					}
				}
			}
			if(max<=cnt){
				max=cnt;
			}
		}
	}
	cout<<max<<endl;

	}

	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll int64_t 
#define f(i,s,e) for(i=s;i<e;++i)
#define endl << "\n"
#define sp << " "
#define INF INFINITY
#define mset(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI acos(-1) 
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define eb(a) emplace_back(a)
#define print(x) for(auto it:x) cout<<it<<' '; cout<<"\n";

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;

void dfs(vector < set <ll> >&adj,ll node,vector <bool>&visited,ll &count)
{
	count++ ;
	visited[node] = true ;
	for(auto it : adj[node])
		if(!visited[it])
			dfs(adj,it,visited,count) ;
}

int main()
{
	FAST_IO ;
	ll i,j,k,n,m;
	cin >> n >> m;
	vector < set <ll> > adj(n) ;
	ll ans = 1;
	f(i,0,m)
	{
		ll x,y;
		cin >> x >> y;
		x-- ; y-- ;
		adj[x].insert(y) ;
		adj[y].insert(x) ;
	}
	vector <bool> visited(n,false) ;
	for(i=0;i<n;++i)
	{
		if(!visited[i])
		{
			j = 0;
			dfs(adj,i,visited,j) ;
			ans = max(ans,j) ;
		}
	}
	cout << ans endl ;
	return 0;
}

/*
If u haven't come up with an approach yet ,skip this one
  Try this when feeling stuck -
  1. Int overflow, array bounds
  2. Special cases (n=1?)
  3. Prove your approach to yourself(mathematical induction,counter-intuitive or stronger test cases)
  4. Calm down and don't look at standings and stop thinking about rating and think about the question
  5. Just do it! 
*/ 

//Benq's advice - 
/* 
	And following advices are must for me -
	* do something instead of nothing and stay organized
	* WRITE STUFF DOWN 
*/

//#define _GLIBCXX_DEBUG 
// It will convert WA verdict to runtime error if that error is caused due to out of bound excess , declare it at the top
//#pragma GCC optimize "trapv" 
// It will convert WA to runtime error if WA was caused due to int overflow error,declare it anywhere

Measured memory_bytes: 43808
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define inp() for(int i=0;i<n;i++)cin>>a[i];
using namespace std;
int a[114514][3],dp[114514][3];
signed main(){
   int n;
   cin>>n;
   rep(i,n){cin>>a[i][0]>>a[i][1]>>a[i][2];}
   dp[0][0]=a[0][0];
   dp[0][1]=a[0][1];
   dp[0][2]=a[0][2];
   for(int i=1;i<n;i++){
	   rep(j,3){
		    dp[i][j]=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+a[i][j];
	   }
   }
   int sum=max(dp[n-1][0],dp[n-1][1]);
   int ans=max(sum,dp[n-1][2]);
   cout<<ans<<endl;
}




Measured memory_bytes: 5248
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

void solve(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; ++i) cin >> a[i] >> b[i];

    int cnt = 0;
    for(int i = 0; i < n; ++i){
        if(a[i]==b[i]){
            ++cnt;
        }
        else{
            cnt = 0;
        }

        if(cnt>=3){
            cout << "Yes\n";
            return;
        }
    }

    cout << "No\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<map>
#define int long long
const int mx = 1e5+5;
using namespace std;
main()
{
	//freopen("input.txt","rt",stdin);
	int r,d,x;
	cin>>r>>d>>x;
	int p = x;
	for(int i=1;i<11;i++)
	{
		 p = r*p -d;
		 cout<<p<<endl;
	}
}

Measured memory_bytes: 256
#include"iostream"
#include"algorithm"
#include"cstdio"
#include"cstring"
#include"string"
#include"vector"
#include"queue"
#include"map"
#include"set"
#include"stack"
#include"cmath"
using namespace std;
#define INF 2147483647
#define maxn 10000
long long int G[maxn][maxn];
long long int dist[maxn][maxn];
int m,n;
void Floyd()
{
    for(int k=0; k<n; k++)
    {
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<n; j++)
            {
				if(G[i][k] != INF && G[k][j] != INF)
                G[i][j] = min(G[i][k]+G[k][j],G[i][j]);
            }
        }
    }
}
void Init()
{
    for(int i=0; i<n; i++)
    {
        G[i][i]=0;
        for(int j=0; j<i; j++)
		{
			G[i][j]=INF;
			G[j][i]=INF;
		}
    }
}
int main()
{
	scanf("%d%d",&n,&m);
        Init();
        for(int i=0; i<m; i++)
        {
            int a, b;
			long long c;
            cin >> a >> b >> c;
            G[a][b] = min(G[a][b],c);
        }
		Floyd();
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
			{
				if(G[i][j]<0&&i==j)
				{
					printf("NEGATIVE CYCLE\n");
					return 0;
				}
			}
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				{
					if(j!=n-1)
					{
						if(G[i][j]==INF)
						cout<<"INF"<<" ";
						else cout<<G[i][j]<<" ";
					}
					else 
					{
						if(G[i][j]==INF)
						cout<<"INF"<<endl;
						else cout<<G[i][j]<<endl;
					}
				}
    return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll a,b;cin>>a>>b;
  if(a+b<10)cout<<a+b<<endl;
  else cout<<"error"<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i<N; i++)
#define RVROOP(i, N) for(int i=N; i>=0; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){

  int H,N; cin>>H>>N;
  vector<int> A(N), B(N);
  int max_A=0;
  for(int i=0; i<N; i++){
    cin>>A[i]>>B[i];
    max_A=max(max_A, A[i]);
  }

  vector<int> dp(H+max_A, INF);
  dp[0]=0;

  for(int i=1; i<H+max_A; i++){
    for(int j=0; j<=N; j++){
      if(i>=A[j]){
        dp[i]=min(dp[i], dp[i-A[j]]+B[j]);
      }
    }
  }
  int ans=INF;
  for(int i=H; i<H+max_A; i++){
     if(dp[i]!=0){
       ans=min(ans, dp[i]);
     }    
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define min(a,b) ((a)<(b)?(a):(b))
int main(void){
    long long i,n,ans=0,minus=0,min=10e9,a;
    scanf("%lld",&n);
    for(i=0;i<n;i++){
        scanf("%lld",&a);
        if(a<0) minus++;
        ans+=abs(a);
        min=min(min,abs(a));
    }
    if(minus%2) ans-=2*min;
    printf("%lld",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll


int t, n, m, k, a[300010], q, l, r;
int f[10010];

int32_t main(){
INIT



for(int x=1; x<=100; x++){
    for(int y=1; y<=100; y++){
        for(int z=1; z<=100; z++){
            if(   (((x+z+y)*(x+z+y)-x*y-x*z-y*z)>10000) || (((x+z+y)*(x+z+y)-x*y-x*z-y*z)<1)   ){
                continue;
            }
            else{
                f[ ((x+z+y)*(x+z+y)-x*y-x*z-y*z)   ]++;
            }
        }
    }
}





cin>>n;
for(int i=1; i<=n; i++){
    cout<<f[i]<<"\n";
}



return 0;
}



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

using namespace std;

long long f(int n) {
    if (n < 2) {
        return 1;
    }
    return n*f(n-2);
}


int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    long long n;
    cin >> n;
    long long ans = 0;
    if (n % 2 == 0) {
        n /= 2;
        long long dv = 5;
        while (n >= dv) {
            ans += n/dv;
            dv *= 5;
        }
    }
    cout << ans << endl;
    //cout << "124999999999999995" << endl;
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int N;
std::vector<LL>c, t, x, d;
LL Q;
std::vector<LL>res(1123);

int main()
{
	in >> N;
	c.resize(N);
	rep(i, N) in >> c[i];
	in >> Q;
	c.resize(Q), t.resize(Q), x.resize(Q), d.resize(Q);
	rep(i, Q) in >> t[i] >> x[i] >> d[i];
	rep(i, Q)
	{
		if (t[i] == 2 && res[x[i]] < d[i])
		{
			out << x[i] << std::endl;
			return 0;
		}
		if (t[i] == 1 && res[x[i]] + d[i] > c[x[i] - 1])
		{
			out << x[i] << std::endl;
			return 0;
		}
		if (t[i] == 2)
		{
			res[x[i]] -= d[i];
		}
		if (t[i] == 1)
		{
			res[x[i]] += d[i];
		}
	}
	out << 0 << std::endl;
	return 0;
}


Measured memory_bytes: 6048
#include <bits/stdc++.h>
#define INF 1001001001
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> x(n), y(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}
	vector<int> fx(n), fy(n);
	for (int i = 0; i < n; i++) {
		fx[i] = x[i] - y[i];
		fy[i] = x[i] + y[i];
	}
	int minFx = INF, maxFx = -INF;
	for (int i = 0; i < n; i++) {
		minFx = min(minFx, fx[i]);
		maxFx = max(maxFx, fx[i]);
	}
	int minFy = INF, maxFy = -INF;
	for (int i = 0; i < n; i++) {
		minFy = min(minFy, fy[i]);
		maxFy = max(maxFy, fy[i]);
	}
	cout << max(maxFx - minFx, maxFy - minFy) << endl;
	return 0;
}

Measured memory_bytes: 6416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int b[3];
    for (int i = 0; i < 3; i++) {
        cin >> b[i];
    }
    if ((b[0] == 1 && b[1] == 1) || b[2] == 1) {
        cout <<"Open\n";
    } else {
        cout << "Close\n";
    }
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <cassert>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

int getnum(char x){
    if (x == 'R') return 2;
    if (x == 'G') return 3;
    if (x == 'B') return 5;
}

int main(){
    int n; cin >> n;
    string s; cin >> s;
    vector<int> rs, gs, bs;
    ll ans = 0;
    rep(i, n){
        if (s[i] == 'R') rs.push_back(i);
        else if (s[i] == 'G') gs.push_back(i);
        else bs.push_back(i);
    }
    ll num = 0;
    rep(i, n){
        int wid = 3 + 2 * i;
        rep(j, n){
            if (j + wid - 1 >= n) break;
            int judge = 0;
            judge += getnum(s[j]);
            judge += getnum(s[j + (wid - 1) / 2]);
            judge += getnum(s[j + wid - 1]);
            if (judge == 10) num++;
        }
    }
    ans = rs.size() * gs.size() * bs.size() - num;
    cout << ans << endl;
}


Measured memory_bytes: 3196
A = []
for i in range(3):
  A += list(map(int,input().split()))

called = [False] * 9

bingo = ((0,1,2),(3,4,5),(6,7,8),(0,3,6),(1,4,7),(2,5,8),(0,4,8),(2,4,6))

N = int(input())
for i in range(N):
  target = int(input())
  if target in A:
    called[A.index(target)] = True
  
for a,b,c in bingo:
  if called[a] and called[b] and called[c]:
    print("Yes")
    break
else:
  print("No")


Measured memory_bytes: 9112
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;

const int NIL = -1;

int main(void)
{
	int H, key;
	vector<int> heap;
	heap.push_back(NIL);
	cin >> H;
	for (int i = 0; i < H; i++) {
		cin >> key;
		heap.push_back(key);
	}
	for (int i = 1; i <= H; i++) {
		cout << "node " << i << ": key = " << heap[i] << ", ";
		if (i / 2 > 0)
			cout << "parent key = " << heap[i / 2] << ", ";
		if (2 * i <= H)
			cout << "left key = " << heap[2 * i] << ", ";
		if (2 * i + 1 <= H)
			cout << "right key = " << heap[2 * i + 1] << ", ";
		cout << endl;
	}
	return 0;
}




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

#define ll long long int

using namespace std;

int main() {
    ll a, b, k;
    cin >> a >> b >> k;

    ll last = 0;
    set<ll> S;
    for (ll i = 0; i < k && a + i <= b; ++i) {
        S.insert(a+i);
    }
    for (ll i = 0; i < k && b - i >= a; ++i) {
        S.insert(b-i);
    }
    for (auto s : S) {
        cout << s << endl;
    }
}


Measured memory_bytes: 3640
//Author:- Yatin Patel
//Mail:- yatinpatel.gt@gmail.com

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define FILEIN ifstream fin;fin.open("input.txt");
#define FILEOUT ofstream fout;fout.open("output.txt");

using namespace std;
using namespace __gnu_pbds;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << "  ";
    err(++it, args...);
}

#define FAST ios::sync_with_stdio(false);ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second

#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<ll,vector<ll>,greater<ll> >
#define maxQueue priority_queue<ll,vector<ll>,less<ll> > 

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=a;i>b;i--)
#define FILL(a,b) memset((a),(b),sizeof((a)))

#define MOD 1000000007
#define INF LONG_MAX
#define MINF LONG_MIN

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

ll power(ll x, unsigned ll y){
    if (y == 0)
        return 1;
    else if (y%2 == 0)
        return power(x, y/2)*power(x, y/2);
    else
        return x*power(x, y/2)*power(x, y/2);
}

//#define fin cin
//#define fout cout

int main(){

    FAST;
    ll n;
    cin>>n;
    ll c1 = 0;
    ll c2 = 0;
    ll c3 = 0;
    ll ans = 0;
    for(ll i=0;i<n;i++){
        string tmp;
        cin>>tmp;
        for(ll j = 1;j<tmp.length();j++){
            if(tmp[j]=='B' && tmp[j-1]=='A'){
                ans++;
            }
        }
        if(tmp[0]=='B' && tmp[tmp.length()-1]=='A'){
            c3++;
        }
        else if(tmp[0]=='B'){
            c1++;
        }
        else if(tmp[tmp.length()-1]=='A'){
            c2++;
        }
    }
    if(c3>=2)
       ans += (c3-1);
    
    if(c1>=1 && c3!=0){
        ans++;
        c1--;
    }
    if(c2>=1 && c3!=0){
        ans++;
        c2--;
    }

    ans += min(c1,c2);
    cout<<ans;

    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)n - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

template<int Modulus> 
struct ModInt {
    long long x;
    ModInt(long long x = 0) :x((x%Modulus + Modulus)%Modulus) {}
    constexpr ModInt &operator+=(const ModInt a) {if ((x += a.x) >= Modulus) x -= Modulus; return *this;}
    constexpr ModInt &operator-=(const ModInt a) {if ((x += Modulus - a.x) >= Modulus) x -= Modulus; return *this;}
    constexpr ModInt &operator*=(const ModInt a) {(x *= a.x) %= Modulus; return *this;}
    constexpr ModInt &operator/=(const ModInt a) {return *this *= a.inverse();}

    constexpr ModInt operator+(const ModInt a) const {return ModInt(*this) += a.x;}
    constexpr ModInt operator-(const ModInt a) const {return ModInt(*this) -= a.x;}
    constexpr ModInt operator*(const ModInt a) const {return ModInt(*this) *= a.x;}
    constexpr ModInt operator/(const ModInt a) const {return ModInt(*this) /= a.x;}
    
    friend constexpr ostream& operator<<(ostream& os,const ModInt<Modulus>& a) {return os << a.x;}
    friend constexpr istream& operator>>(istream& is,ModInt<Modulus>& a) {return is >> a.x;}
    
    ModInt inverse() const {// x ^ (-1) 
        long long a = x,b = Modulus,p = 1,q = 0;
        while (b) {long long d = a/b; a -= d*b; swap(a,b); p -= d*q; swap(p,q);}
        return ModInt(p);
    }
    ModInt pow(long long N) {// x ^ N 
        ModInt a = 1;
        while (N) {
            if (N&1) a *= *this;
            *this *= *this;
            N >>= 1;
        }
        return a;
    }
};

using mint = ModInt<1000000007>;

//nexS[i][j] = i番目以降でj番目のアルファベットが一番初めに現れるindex
vector<vector<int>> next_calc(const string &S) {
    int N = S.size();
    vector<vector<int>> ret(N + 1,vector<int>(26,N));
    for (int i = N - 1;i >= 0;--i) {
        for (int j = 0; j < 26;++j) {
            ret[i][j] = ret[i + 1][j];
        }
        ret[i][S[i] - 'a'] = i;
    }
    return ret;
}

int main() {
    string S; cin >> S;
    string T = S;
    reverse(T.begin(),T.end());
    int N = S.size();
    vector<vector<mint>> dp(N + 1,vector<mint>(N + 1,0));
    vector<vector<int>> nexS = next_calc(S);
    vector<vector<int>> nexT = next_calc(T);

    dp[0][0] = 1;
    rep(i,N) {
        rep(j,N) {
            rep(k,26) {
                if (nexS[i][k] + 1 > N || nexT[j][k] + 1 > N || nexS[i][k] + nexT[j][k] + 2 > N) continue;
                dp[nexS[i][k] + 1][nexT[j][k] + 1] += dp[i][j];
            }
        }
    }

    mint ans = 0;
    rep(i,N + 1) {
        rep(j,N + 1) {
            if (i + j > N) break;
            mint ret = 1;
            rep(k,26) {
                if (nexS[i][k] + j < N) ret += 1;
            }
            ans += ret * dp[i][j];
        }
    }
    ans -= 1;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 34852
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=100010;
int a[N],f[N],g[N],p[N],q[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') ch=='-'?o=-1:0,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return o*x;
}
int main() {
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) a[i]=gi();
    for(int i=0;i<N;i++) p[i]=q[i]=i;
    for(int i=1;i<=n;i+=2) ++f[a[i]];
    for(int i=2;i<=n;i+=2) ++g[a[i]];
    sort(p,p+N,[](const int &x,const int &y) {return f[x]>f[y];});
    sort(q,q+N,[](const int &x,const int &y) {return g[x]>g[y];});
    if(p[0]==q[0]) cout<<n-max(f[p[0]]+g[q[1]],f[p[1]]+g[q[0]]);
    else cout<<n-f[p[0]]-g[q[0]];
    return 0;
}

Measured memory_bytes: 2176
import heapq

N, M = map(int, input().split())
A = list(map(lambda x:int(x)*(-1), input().split()))

heapq.heapify(A)

for i in range(M):
    x = heapq.heappop(A) * -1
    x //= 2
    heapq.heappush(A, x*(-1))

print(sum(A)*(-1))

Measured memory_bytes: 72216
#include <iostream>

using namespace std;

int main()
{
    int a,n,b,c;
    cin>>n>>a;
    if(a*1>n)
        {
            cout<<"Yes";
        }
    else
        {
            if(n%500==0)
        {
            cout<<"Yes";
        }
        else if(n%500!=0&&a==0)
        {
            cout<<"No";
        }
        else if(n%500!=0)
        {
            b=n%500;
            if(b*1<=a*1)
            {
                cout<<"Yes";
            }
            else if(b*1!=a*1)
            {
                cout<<"No";
            }
        }
    }

}

Measured memory_bytes: 3592
(n,k) = gets.split.map {|x| x.to_i}
ds = gets.split.map {|x| x.to_i}

def check(n, ds)
  while (n > 0)
    a = n % 10
    if ds.include?(a)
      return false
    end
    n /= 10
  end
  return true
end

while (1)

  if check(n,ds)
    break
  else
    n += 1
  end
end
p n


Measured memory_bytes: 1788
#include <cstdint>
#include <iostream>

using namespace std;

int main()
{
    int64_t n, walk, teleport;
    cin >> n >> walk >> teleport;

    int64_t res = 0;
    int64_t prev = 0;

    for (auto i = 0; i < n; i += 1) {
        int64_t curr;
        cin >> curr;

        if (i > 0) {
            res += min(teleport, walk * (curr - prev));
        }
        prev = curr;
    }

    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 384
#include<iostream>

signed main(){
    // @begin func main
    // @Memory_limit 1000 MB
    // @Time_limit 2 sec
    // @ask_olphe Problem A
    // @out_olphe_ans
    // @end func main
}












__attribute__((constructor))
void solver() {
    int a,b; std::cin >> a >> b;
    std::cout << a*b - a - b + 1 << std::endl;
}





Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define rep(i,n) for(int i=0; i <(n); i++)
int main(){
  char s[20];
  scanf("%s",s);
  printf("%c",s[0]);
  printf("%c",s[1]);
  printf("%c\n",s[2]);
  return 0;
}

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

#define int long long

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, m;
    cin >> n >> m;
    cout << (m*(m-1))/2 + (n*(n-1))/2 << endl;
}

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

using namespace std;
using ll=long long;

int main()
{
    int n;cin >>n;
    int a[n][3];
    int dp[n][3];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            dp[i][j]=-1;
            cin >>a[i][j];
        }
    }
    for(int i=0;i<3;i++){
        dp[0][i]=a[0][i];
    }
    for(int i=1;i<n;i++){
       for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(k==j)continue;
                dp[i][k]=max(dp[i][k],dp[i-1][j]+a[i][k]);
            }
       }
    }
    int ans=0;
    for(int i=0;i<3;i++){
        ans=max(ans,dp[n-1][i]);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

struct data
{
	int weight;
	int start;
	int end;
};

void solve()
{
	int n;
	while (cin >> n, n)
	{
		vector<data> person(n);
		for (int i = 0; i < n; ++i)
		{
			cin >> person[i].weight >> person[i].start >> person[i].end;
		}
		bool isOK = true;
		for (int i = 0; i < n; ++i)
		{
			int sumStart = person[i].weight;
			int sumEnd = person[i].weight;
			for (int j = 0; j < n; ++j)
			{
				if (j == i)
				{
					continue;
				}
				if (person[j].start <= person[i].start && person[i].start <= person[j].end - 1)
				{
					sumStart += person[j].weight;
				}
				if (person[j].start <= person[i].end - 1 && person[i].end - 1 <= person[j].end - 1)
				{
					sumEnd += person[j].weight;
				}
			}
			if (sumStart > 150 || sumEnd > 150)
			{
				cout << "NG" << endl;
				isOK = false;
				break;
			}
		}
		if (isOK)
		{
			cout << "OK" << endl;
		}
	}
}

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

Measured memory_bytes: 1188
class Queue(object):

    def __init__(self):
        self.queue_list = []

    def enqueue(self, value):
        self.queue_list.append(value)

    def dequeue(self):
        try:
            # 先頭をとりだす
            value = self.queue_list.pop(0)
        except IndexError:
            value = None

        return value
N = int(input())

pair = []
tree = {}

for _ in range(N-1):
    a, b = list(map(int, input().split(" "))) 
    if a in tree.keys():
        tree[a].append(b)
    else:
        tree[a] = [b]
        
    if b in tree.keys():
        tree[b].append(a)
    else:
        tree[b] = [a]
    pair.append([a,b])
    
c = list(map(int, input().split(" ")))
c.sort(reverse=True)
c = c[:N+2]


queue = Queue()
tree_l = {}
for key in tree.keys():
    tree_l[key] = len(tree[key])

ans = {}
max_node = max((v, k) for k, v in tree_l.items())[1]
ans[max_node] = c[0]
used = [max_node]
cnt = 0

candi = {}
for i in tree[max_node]:
    candi[i] = tree_l[i]

for k, v in sorted(candi.items(), key=lambda x: -x[1]):
    queue.enqueue(k)
    used.append(k)

while True:
    node = queue.dequeue()
    cnt += 1
    ans[node] = c[cnt]
    
    if cnt == N-1:
        break
    
    candi = {}
    for i in tree[node]:
        candi[i] = tree_l[i]
    for k, v in sorted(candi.items(), key=lambda x: -x[1]):
        if k not in used:
            queue.enqueue(k)
            used.append(k)
total = 0
for a, b in pair:
    if ans[a] > ans[b]:
        total += ans[b]
    else:
        total += ans[a]
        
print(total)
for i in range(1, N, 1):
    print(ans[i], end=" ")

print(ans[N])

Measured memory_bytes: 8456
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - Red and Green Apples
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_N2 = MAX_N * 2;

/* typedef */

typedef long long ll;

/* global variables */

int ps[MAX_N], qs[MAX_N], rs[MAX_N];
int ss[MAX_N2];
ll sss[MAX_N2 + 1], rss[MAX_N + 1];

/* subroutines */

/* main */

int main() {
  int x, y, a, b, c;
  scanf("%d%d%d%d%d", &x, &y, &a, &b, &c);

  for (int i = 0; i < a; i++) scanf("%d", ps + i);
  for (int i = 0; i < b; i++) scanf("%d", qs + i);
  for (int i = 0; i < c; i++) scanf("%d", rs + i);

  sort(ps, ps + a);
  sort(qs, qs + b);
  sort(rs, rs + c);

  int n = 0, pk = a, qk = b;
  for (int i = 0; i < x; i++) ss[n++] = ps[--pk];
  for (int i = 0; i < y; i++) ss[n++] = qs[--qk];
  sort(ss, ss + n);

  for (int i = 0; i < n; i++) sss[i + 1] = sss[i] + ss[i];
  for (int i = 0; i < c; i++) rss[i + 1] = rss[i] + rs[i];

  ll maxsum = sss[n];
  int l = min(n, c);
  for (int i = 0; i <= l; i++) {
    ll sum = sss[n] - sss[i] + (rss[c] - rss[c - i]);
    if (maxsum < sum) maxsum = sum;
  }

  printf("%lld\n", maxsum);
  return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

// a^p % mod を求める
// 計算量はO(log(n))
// 2^9 -> 2 * 2^8
// 2^8 -> 2^4 * 2^4
// 2^4 -> 2^2
// 2^2 -> 2^1
ll modPow(ll a, ll p, ll mod) {
  if (p == 0) return 1;
  if (p % 2 == 0) {
    ll half = modPow(a, p/2, mod);
    return (half*half) % mod;
  } else {
    return a * modPow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n-a < a) return modCombination(n, n-a, mod);
  // cout << n << ' ' << a << endl;
  ll denominator = 1;
  ll numerator = 1;
  for (ll i = 0; i < a; i++) {
    numerator *= (n - i);
    denominator *= i + 1;
    numerator %= mod;
    denominator %= mod;
  }
  // cout << numerator << '/' << denominator << endl;
  // フェルマーの小定理
  // numerator/denominator = numerator * (denominator ^ (mod - 2)) (mod mod)
  return numerator * modPow(denominator, mod-2, mod) % mod;
}

const ll mod = 1000000007;

int main() {
  ll M, N;
  cin >> N >> M;

  ll remaining = M;
  ll ans = 1;
  // 素因数分解
  for (ll i = 2; i * i < M; i++) {
    if (remaining % i == 0) {
      // 指数を求める
      ll p = 0;
      while (remaining % i == 0) {
        p += 1;
        remaining /= i;
      }
      // 重複組合せ
      ans *= modCombination(N + p - 1, N - 1, mod);
      ans %= mod;
    }
  }
  if (remaining != 1) {
    ans *= modCombination(N + 1 - 1, N - 1, mod);
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll mod(ll x)
{
    if(x<0)
    return -x;
    else
    return x;
}
int main() 
{
ll n,k;
cin>>n>>k;
ll h[n];
for(ll i=0;i<n;i++)
{
    cin>>h[i];
}
ll ans[n]={0};
ans[1]=mod(h[1]-h[0]);
ll abd=ans[1];
for(ll i=2;i<n;i++)
{abd=ans[i-1]+mod(h[i]-h[i-1]);
  for(ll j=1;j<=k;j++)
{  if(i-j>=0)
    abd=min(ans[i-j]+mod(h[i]-h[i-j]),abd);
    else
    break;
}
ans[i]=abd;
}
cout<<ans[n-1];
}


Measured memory_bytes: 1792
s = input()
sy = int(s[0:4])
sm = int(s[5:7])
sd = int(s[8:10])
if sy > 2019:
    print("TBD")
elif sy < 2019:
    print("Heisei")
else:
    if sm > 4:
        print("TBD")
    elif sm <= 4:
        print("Heisei")


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<math.h>
using namespace std;

void a()
{
    string s,t;
    cin >> s >> t;
    if (t.substr(0,t.length()-1)==s)
    cout << "Yes";
    else cout << "No"; 

    return;
}
void b()
{
    int a,b,c,k;
    cin >>a >> b >> c >> k;
    if(a>k)cout <<k;
    else{
        if(a+b>=k)cout <<a;
        else cout << 2*a+b-k;
    }
    return;
}
void c()
{
    int n,m,x;
    cin >> n >> m >> x;
    vector<int>c;
    vector<vector<int>>a(n);
    for(int i=0;i<n;i++)
    {
        int t_c;
        cin >> t_c;
        c.push_back(t_c);
        for(int j=0;j<m;j++)
        {
            int t_a;
            cin >> t_a;
            a[i].push_back(t_a);
        }
    }
    long long int cost = INT64_MAX;
    int flag = 0;
    for (int bit = 0;bit<(int)pow(2,n);bit++)
    {
        int p[m]={0};
        int t_cost=0;
        for(int i = 0;i<n;i++)
        {
            if((int)(bit & (1 << i))!=0)
            {
                t_cost+=c[i];
                for(int j=0;j<m;j++)
                {
                    p[j]+=a[i][j];
                }
            }

        }
        int judge=0;
        for(int i=0;i<m;i++)
        {
            if(p[i]<x)judge=1;
        }
        if(judge==0&&cost>t_cost){
            cost=t_cost;
            flag=1;}
    }
    if(flag==1)cout << cost;
    else cout<< -1;
    return;
}
void d()
{
    return;
}
void e()
{
    return;
}
void f()
{
    return;
}
int main(void){
    //a();
    //b();
    c();
    //d();
    //e();
    //f();

    return 0;
}

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

int main(){
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<int>ac(n, 0);
  for(int i=1; i<n; i++){
    ac[i]=ac[i-1];
    if(s[i-1]=='A' && s[i]=='C')ac[i]++;
  }
  for(int i=0; i<q; i++){
    int l, r;
    cin >> l >> r;
    cout << ac[r-1]-ac[l-1] << endl;
  }
  return 0;
}

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

int N, M, C;
int B[30], A[30][30];

void abc121b() {
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ll sum = 0;
    for (int j = 0; j < M; j++) {
      sum += A[i][j] * B[j];
    }
    if (sum + C > 0) {
      ans++;
    }
  }
  cout << ans << '\n';
  return;
}

int main() {
  cin >> N >> M >> C;
  for (int i = 0; i < M; i++) {
    cin >> B[i];
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> A[i][j];
    }
  }
  abc121b();
  return 0;
}

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

class Counter<T> extends TreeMap<T,Long>{
    public Counter(){
        super();
    }
    public Long count(Object elm){
        return getOrDefault(elm,0L);
    }
    public void add(T elm, long amount){
        if(!this.containsKey(elm)) put(elm, amount);
        else replace(elm, get(elm)+amount);
    }
}
public class Main {
    static void answer(int ans){
        System.out.println(ans);
        System.exit(0);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();
        Counter<Integer> counter = new Counter<>();
        for(int n=0; n<N; n++){
            counter.add(sc.nextInt(), sc.nextLong());
        }
        while(K>0){
            int least = counter.firstKey();
            K -= counter.get(least);
            if(K<=0) answer(least);
            counter.remove(least);
        }
    }
}


Measured memory_bytes: 95772
N, M, X, Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

ans = 'War'
Z = [i for i in range(X+1, Y+1)]
z = [i for i in range(max(x)+1, min(y)+1)]

for i in Z:
    if i in z:
        ans = 'No War'
        break

print(ans)


Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
ll n,m,k,ans;
string s,t;
const ll powll = 1LL<<1;

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

  if(a[0] == a[1] && a[1] != a[2]) cout << "Yes\n";
  else if(a[1] == a[2] && a[2] != a[0]) cout << "Yes\n";
  else if(a[0] == a[2] && a[2] != a[1]) cout << "Yes\n";
  else cout << "No\n";
}

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

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

  int A, B, C;
  cin >> A >> B >> C;
  string result;
  if(A == 7) {
    if(B == 5 && C == 5) {
      result = "YES";
    } else {
      result = "NO";
    }
  } else {
    if((B == 5 && C == 7) || (B == 7 && C == 5)) {
      result = "YES";
    } else {
      result = "NO";
    }
  }
  cout << result;
}

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

using namespace std;
inline void read(long long &x) {
    char ch;
    bool flag = false;
    for (ch = getchar(); !isdigit(ch); ch = getchar())if (ch == '-') flag = true;
    for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
    x = flag ? -x : x;
}
inline void write(long long x) {
    static const long long maxlen = 100;
    static char s[maxlen];
    if (x < 0) {   putchar('-'); x = -x;}
    if (!x) { putchar('0'); return; }
    long long len = 0; for (; x; x /= 10) s[len++] = x % 10 + '0';
    for (long long i = len - 1; i >= 0; --i) putchar(s[i]);
}

inline void read(int &x){
    char ch;
    bool flag = false;
    for (ch = getchar(); !isdigit(ch); ch = getchar())if (ch == '-') flag = true;
    for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
    x = flag ? -x : x;
}

const long long MAXN =1001000;

long long n;
long long a[ MAXN ];
long long f[ MAXN ];
long long g[ MAXN ];

priority_queue<long long,vector<long long>,greater<long long> > Q;

priority_queue<long long,vector<long long>,less<long long> > P;

int main(){
    read(n);
    for (long long i=1;i<=3*n;i++)
        read(a[i]);

    for (long long i=1;i<=n;i++)
    {
        Q.push(a[i]);
        f[n]+=a[i];
    }

    for (long long i=n+1;i<=n*2;i++)
        if ( a[i]>Q.top() )
            {
                f[i]=f[i-1]+a[i]-Q.top();
                Q.pop();
                Q.push(a[i]);
            }
        else
            f[i]=f[i-1];

    for (long long i=2*n+1;i<=3*n;i++)
    {
        P.push(a[i]);
        g[2*n+1]+=a[i];
    }

    for (long long i=2*n;i>=n+1;i--)
        if ( a[i]<P.top() )
            {
                g[i]=g[i+1]+a[i]-P.top();
                P.pop();
                P.push(a[i]);
            }
        else
            g[i]=g[i+1];
    long long ans=-1e15;
    for (long long i=n;i<=2*n;i++)
        ans=max(ans,f[i]-g[i+1]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 8820
#include <bits/stdc++.h>
#define ll long long
#define ii pair<int,int>
#define fr first
#define sc second
#define mp make_pair
#define All(v) v.begin(),v.end()
using namespace std;
int n;
int main()
{
 cin>>n;
 int a[n];
 ll sum = 0;
 for(int i=0;i<n;i++)
 {
     scanf("%d",&a[i]);
     sum+=a[i];
 }
 ll b = 0;
 ll minx = 1e18;
 for(int i=0;i< n-1;i++)
 {
     b+=a[i];
     sum-=a[i];
     minx = min(minx , abs(sum-b));
 }
 cout<<minx;
}


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

int main() {
    int n;
    cin >> n;
    int c[n][26];
    memset(c,0,sizeof c);
    vector<string> v(n);
    for(int i=0;i<n;++i){
    	string s;
    	cin >> s;
    	v[i]=s;
    }
    for(int i=0;i<n;++i){
    	for(int j=0;j<v[i].length();++j){
    		int t=v[i][j]-97;
    		c[i][t]++;
    	}
    }
    string s;
    for(char x='a';x<='z';++x){
    	int m=12345678;
    	for(int i=0;i<n;++i){
    	for(int j=0;j<v[i].length();++j){
    		if(c[i][x-97] < m)m=c[i][x-97];
    	}
    }
    string temp;
    for(int i=0;i<m;++i){
    	temp+=x;
    }
    s+=temp;
}
cout << s <<endl;

    return 0;

}


Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	A := sc.NextIntArray()
	D := A[2]*60 + A[3] - (A[0]*60 + A[1])
	D -= A[4]
	fmt.Println(D)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 1760
#include "iostream"
#include "cmath"
using namespace std;

bool prime(int a){
  if(a==1)return false;
  int i,limit = sqrt(a);
  for(i=2;i<=limit;++i){
    if(a%i==0)break;
  }
  if(i==limit+1)return true;
  else return false;
}


int main(){
  int a,d,n,count,i;
  while(true){
    count=0;
    cin >>a>>d>>n;
    if(!a&&!d&&!n)break;
    for(i=0;;++i){
      if(prime(a+d*i))++count;
      if(count==n)break;
    }
    cout << a+d*i <<endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

#define MAX_V 100005
struct edge {
	int to;
	int cost;
};
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + MAX_V, INF);
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;

		for (int i = 0; i < G[v].size(); ++i) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

void solve_abc_d() {
	ll n, m, x, k;
	cin >> n >> m;

	ll a, b;
	edge e;
	rep(i, m) {
		cin >> a >> b;
		e.cost = 1;
		e.to = b;
		G[a].push_back(e);
		e.to = a;
		G[b].push_back(e);
	}

	dijkstra(1);

	V ans(n + 1);
	rep2(i, 2, n + 1) {
		if (d[i] == INF) {
			cout << "No" << "\n";
			return;
		}
		else {
			rep(j, G[i].size()){
				if (d[G[i][j].to] == d[i] - 1) {
					ans[i] = G[i][j].to;
				}
			}
		}
	}

	cout << "Yes" << "\n";
	rep2(i, 2, n + 1) {
		cout << ans[i] << "\n";
	}
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed;
	//cout << setprecision(7);

	solve_abc_d();

	return 0;
}


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

using namespace std;
using ll = long long;

int main() {
	ll n, a, b;
	int ans = 11, f;
	cin >> n;

	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			a = i;
			b = n / i;
			int digit_a = 0, digit_b = 0;
			while (a != 0) {
				a /= 10;
				digit_a++;
			}
			while (b != 0) {
				b /= 10;
				digit_b++;
			}
			f = max(digit_a, digit_b);
			if (f < ans) ans = f;
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main(void){
    int  n ;
    cin >>  n ;
    int p[200000] ;

    for(int i = 0 ; i < 200000 ; i++){
         p[i] = 0 ;
    }
    p[0] = 1 ;
    
     for(int k=2 ; k<=100000; k++){
      for(int j=2 ; k*j<=200000 ; j++){
      if(p[k*j-1] == 0)
        p[k*j-1] = 1;
    }
  }
     for(int l=0 ; l<200000 ; l++){
    if(p[l] == 0&&l>=n-1){
     cout << l+1 << endl;
     break ;
    }
  }
   
   
    
    return 0;
}

Measured memory_bytes: 1024