akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<string>
#include<map>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<time.h>
#include<random>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
	map<string, int>mp;
	int n;
	cin >> n;
	rep(i, n) {
		string s;
		cin >> s;
		mp[s] += 1;
	}
	int ma = 0;
	for (auto itr = mp.begin(); itr != mp.end(); itr++) {
		ma = max(ma, itr->second);
	}
	for (auto itr = mp.begin(); itr != mp.end(); itr++) {
		if (itr->second == ma) {
			cout << itr->first << endl;
		}
	}
	return 0;
}


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

main(){
  int N,M;
  cin>>N>>M;
  int n=0;
  vector<vector<char>> data(N,vector<char>(M));
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin>>data.at(i).at(j);
    }
  }
  vector<int> v(N);
  vector<int> l(M);
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      if(data.at(i).at(j)=='#'){
        n=1;
        break;  
      }
    }
    if(n==1){
      n=0;
      continue;
    }
    v.at(i)=1;
  }
  for(int i=0;i<M;i++){
    for(int j=0;j<N;j++){
      if(data.at(j).at(i)=='#'){
        n=1;
        break;
      }
    }
    if(n==1){
      n=0;
      continue;
    }
    l.at(i)=1;
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      if(v.at(i)==0 && l.at(j)==0){
        cout<<data.at(i).at(j);
      }
    }
    if(v.at(i)==0){
      cout<<endl;
    }
    
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main() {
    string s,ans;
    cin >> s;
    ans = "ABC";

    if(s == "ABC")  ans = "ARC";

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

Measured memory_bytes: 3656
import numpy as np

K,N = map(int, input().split())
An = list(map(int, input().split()))
arr = np.array(An)
arr = np.diff(arr)
ans = list(arr)
ans.append(K-An[-1]+An[0])
# print(ans)
ans.remove(max(ans))
print(sum(ans))

Measured memory_bytes: 34164
def main():
    H, W = map(int, input().split())
    A = []
    for _ in range(H):
        a = input()
        A.append(a)
    bl = []
    wl = set()
    for i in range(H):
        for j in range(W):
            if A[i][j] == '#':
                bl.append((i, j))
            else:
                wl.add((i, j))
    r = 0
    while wl:
        bln = []
        for i in bl:
            if (i[0] + 1, i[1]) in wl:
                wl.remove((i[0] + 1, i[1]))
                bln.append((i[0] + 1, i[1]))
            if (i[0] - 1, i[1]) in wl:
                wl.remove((i[0] - 1, i[1]))
                bln.append((i[0] - 1, i[1]))
            if (i[0], i[1] + 1) in wl:
                wl.remove((i[0], i[1] + 1))
                bln.append((i[0], i[1] + 1))
            if (i[0], i[1] - 1) in wl:
                wl.remove((i[0], i[1] - 1))
                bln.append((i[0], i[1] - 1))
        bl = bln
        r += 1
    return r
print(main())


Measured memory_bytes: 137220
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int modpow(ll a, ll n, ll p){
  if(n==0) return 1;
  if(n==1) return a%p;
  if(n%2 == 1) return (a*modpow(a,n-1,p))%p;
  ll t = modpow(a,n/2, p);
  return (t*t)%p;
 }

ll modnCa(ll n, ll a, ll p){
  ll upper = 1;
  ll lower = 1;
  for(ll i = 1; i <= a; i++){
    upper *= n-i+1;
    upper %= p;
    lower *= i;
    lower %= p;
  }
  ll inv_lower = modpow(lower, p-2, p);
  return (upper * inv_lower)%p;
}


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

  ll m = s/3;

  ll ans = 0;
  for(int i = 1; i<= m; i++){
    ans += modnCa(s-3*i+i-1, i-1, 1000000007);
    ans %= 1000000007;
  }
  cout << ans << endl;
}


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

int main()
{
  int n, m;
  string s;
  cin >> n >> m >> s;
  vector<int> ans;
  int ix = n;
  while (ix > 0) {
    int i;
    for (i = m; i > 0; i--) {
      if (ix - i < 0) continue;
      if (s[ix - i] == '0') {
        ix -= i;
        ans.push_back(i);
        break;
      }
    }
    if (i == 0) break;
  }
  if (ix == 0) {
    reverse(begin(ans), end(ans));
    string sp;
    for (auto&& e : ans) {
      cout << sp << e;
      sp = " ";
    }
    cout << endl;
  } else {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 1144
N, _, C = [int(i) for i in input().split()]
B =  [int(i) for i in input().split()]
A = []
for i in range(N):
  A.append([int(i) for i in input().split()])
  
cnt = 0
for a in A:
  s = C
  for i in range(len(B)):
    s += a[i] * B[i]
  if s > 0:
    cnt += 1
    
print(cnt)

Measured memory_bytes: 9156
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  string s;
  cin >> s;
  int cnt = 0;
  for(int i=0;i<s.size()-1;i++){
    if(s[i]!=s[i+1]) cnt++;
  }
  cout<< cnt <<endl;
}


Measured memory_bytes: 512
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(void) {
  int n,m;
  cin>>n>>m;
  int i;
  int path[10][10]={};
  for (int i = 0; i < m; i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    path[a][b]++;
    path[b][a]++;
  }

  vector<int> v;
  for (int i = 0; i < n; i++){
    v.push_back(i);
  }
 
  int ans=0;
  do{
    if(v[0]!=0)break;
    for (i = 0; i < n-1; i++){
      if(path[v[i]][v[i+1]]==0)break;
    }
    if(i==n-1)ans++;
  }while(next_permutation(all(v)));
 
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;cin>>S;
  int N=S.size();
  vector<int> a;
  for(int i=0;i<N;i++)if(S.at(i)=='R' && S.at(i+1)=='L')a.push_back(i);
  
  int M=a.size(),k=0;
  vector<int> ans(N);
  for(int i=0;i<N;i++){
    if(S.at(i)=='R'){
      if((a.at(k)-i)%2==1)ans.at(a.at(k)+1)++;
      else ans.at(a.at(k))++;
    }
    if(S.at(i)=='L'){
      if((i-a.at(k))%2==0)ans.at(a.at(k))++;
      else ans.at(a.at(k)+1)++;
    }
    if(i<N-1 && S.at(i)=='L' && S.at(i+1)=='R')k++;
  }
  for(int i=0;i<N;i++)cout<<ans.at(i)<<" ";
  cout<<endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll r, d, x;
  in3(r, d, x);
  rep(i, 10){
    x = r * x - d;
    out(x);
    memi;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  vector<string> vec(a);
  bool flag = true;
  vector<int> cnt(a);
  cnt = {0};
  for (int i = 0; i < a; i++) cin >> vec[i];
  for (int i = 0; i < a - 1; i++) {
    char c, d;
    c = vec.at(i)[vec[i].size() - 1];
    d = vec.at(i + 1)[0];
    if (c != d) flag = false;
  }
  for (int i = 0; i < a; i++) {
    for (int j = 0; j < a; j++) {
      if (vec[i] == vec[j]) cnt[i]++;
    }
  }
  for (int i = 0; i < a; i++) {
    if (cnt[i] > 1) flag = false;
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

const long long INF = 1LL << 60;
const ll MOD = pow(10, 9) + 7;

int main() {
  ll ans=1, N;
  cin >> N;

  rep(i, N){
    ans = ans * (i+1)%MOD;
  }
  print(ans%MOD);

}


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

bool isLeapYear(int y) {
  if(!(y % 4)) {
    if(!(y % 100)) {
      if(!(y % 400)) return true;
      return false;
    }
    return true;
  }
  else return false;
}

int a[50], b[50];

int main() {
  int n = 0;
  bool flag;
  while(cin >> a[n] >> b[n]) {
    if(a[n] == 0 && b[n] == 0) break;
    n++;
  }

  for(int j = 0; j < n; ++j) {
    flag = 0;
    for(int i = a[j]; i <= b[j]; ++i) {
      if(isLeapYear(i)) {
        flag = 1;
        cout << i << endl;
      }
    }
    if(!flag) cout << "NA" << endl;
    if(j < n - 1) cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
 
typedef uint64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;
 
 
int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	string s1,s2;
	cin >>s1 >>s2;
	
	ll ans=1;
	int p=0;
	
	if(s1[0] = s2[0]){ ans =3; p=1;}
	else {ans = 6; p=2;}
	
	rep2(i,p,n){
		if(s1[i-1] == s2[i-1]){
			if( s1[i]==s2[i]){ (ans *=2)%=mod;} 
				else{ (ans *=2)%=mod; i++;}
		}else{
			if( s1[i] == s2[i]){ ans +=0;} 
			else{(ans *=3)%=mod; i++;}
		}
	}
	
	cout << ans <<"\n";
	return 0;
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 23.03.2019 14:33:37       
**/
#include <bits/stdc++.h>

using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(2 * n);
  for (int i = 0; i < 2 * n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int low = 0, high = m;
  while (low < high) {
    int mid = (low + high) >> 1;
    vector<int> bal(2 * n + 1);
    auto Mark = [&](int from, int to, int i) {
      int x = (int) (lower_bound(a.begin(), a.end(), from) - a.begin());
      int y = (int) (upper_bound(a.begin(), a.end(), to) - a.begin()) - 1;
      if (x <= y) {
        x = (x + i) % (2 * n);
        y = (y + i) % (2 * n);
        bal[x]++;
        bal[y + 1]--;
        if (x > y) {
          bal[0]++;
        }
      }
    };
    for (int i = 0; i < 2 * n; i++) {
      Mark(-a[i], mid - a[i], i);
      Mark(m - a[i], m + mid - a[i], i);
    }
    debug(mid, bal);
    int sum = 0;
    int ok = 0;
    for (int i = 0; i < 2 * n; i++) {
      sum += bal[i];
      if (i % 2 == 1 && sum == 2 * n) {
        ok = 1;
        break;
      }
    }
    if (ok) {
      high = mid;
    } else {
      low = mid + 1;
    }
  }
  cout << low << '\n';
  return 0;
}


Measured memory_bytes: 1804
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, K, Vl, Vr;
ll a[1001], ans;
vector<ll>v;
int main() {
	cin >> N >> K;
	for (int i = 1; i != N + 1; ++i) {
		cin >> a[i];
		a[i] += a[i - 1];
	}
	for (int i = 0; i != N; ++i) {
		for (int j = i + 1; j != N + 1; ++j) {
			v.push_back(a[j] - a[i]);
		}
	}
	Vl = 0;
	for (ll i = 40; i != 0; --i) {
		for (int j = Vl; j != v.size(); ++j) {
			v[j] %= ((ll)1 << (ll)i);
//			cout << v[j] << sp;
		}
//		cout << endl;
		sort(v.begin() + Vl, v.end());
		int t = v.end() - lower_bound(v.begin() + Vl, v.end(), ((ll)1 << (ll)(i - 1)));
//		cout << t << endl;
		if (t >= K) {
//			cout << nyan <<i<< sp << ans << sp<< ((ll)1 << (ll)(i - 1)) <<endl;
			ans += ((ll)1 << (ll)(i - 1));
			Vl = v.size() - t;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6512
#!/usr/bin/env python

def main():
    a, b, c, d = map(int, input().split())
    while a > 0 or c > 0:
        c -= b
        a -= d

        if c <= 0:
            print("Yes")
            break
        elif a <= 0:
            print("No")
            break

if __name__ == '__main__':
    main()


Measured memory_bytes: 9172
#include<bits/stdc++.h>
#define fr(i,a,n) for(ll i=a;i<n;i++)
#define YES cout<<"YES"<<endl
#define all(v) v.begin(),v.end()
#define NO cout<<"NO"<<endl
#define pb(x) emplace_back(x)
#define fastio std::ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define vi vector<ll>
#define mi map<ll,ll>
#define pi pair<ll,ll>
#define what(x) cout<<#x<<" ="<<x<<endl;
using namespace std;
using ll =long long;


int main()
{
   ll n;
   cin>>n;
   ll mod=1e9+7;
   if(n<2)cout<<0<<endl;
   else
   {
       ll ans=1;
       ll one=1;
       ll two=1;
       fr(i,0,n)
       {
           ans=(ans%mod * (10)%mod)%mod;
           one=(one%mod * (9)%mod)%mod;
           two=(two%mod * (8)%mod)%mod;

       }

       //one=(one*2)%mod;
       ans=(ans-one)%mod;
       ans=(ans-one)%mod;
       ans=(ans+two)%mod;

    if(ans<0)ans+=mod;



       cout<<ans<<endl;

   }


}




























Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
int N, memo[105][6][6][6];

int func(int idx, int before, int bbfore, int bbbfore)
{
    if(idx == N)
    {
        return 1;
    }
    int &ret = memo[idx][before][bbfore][bbbfore];
    if(ret != -1)
    {
        return ret;
    }
    ret = 0;
    for(int i = 1; i <= 4; i++)
    {
        if(i == 2 && ((before == 1 && bbfore == 3) || (before == 3 && bbfore == 1)))
        {
            continue;
        }
        if(i == 3 && before == 2 && bbfore == 1)
        {
            continue;
        }
        if(i == 2 && ((before == 3 && bbbfore == 1) || (bbfore == 3 && bbbfore == 1)))
        {
            continue;
        }
        ret = (ret + func(idx + 1, i, before, bbfore)) % 1000000007;
    }
    return ret;
}

int main()
{
    scanf("%d", &N);
    memset(memo, -1, sizeof memo);
    printf("%d\n", func(0, 0, 0, 0));
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>

using namespace std;

int main() {
	int a,b;
	char op;
	
	cin >> a >> op >> b;
	while (op != '?') {
		
		switch (op) {
			case '+':
				cout << a + b << endl;
				break;
			case '-':
				cout << a - b << endl;
				break;
			case '*':
				cout << a * b << endl;
				break;
			case '/':
				cout << a / b << endl;
				break;
			default:
				break;
		}
		cin >> a >> op >> b;
	}
}



Measured memory_bytes: 3100
#include <cstdio>
 
long long int d = 0;

long long int a, b, c;

 
void solve() {
  if (a + b >= c) {
    d = b + c;
  } else {
    d = a + 2 * b + 1;
  }
}
 
int main() {
  scanf("%lld", &a);
  scanf("%lld", &b);
  scanf("%lld", &c);
  solve();
  printf("%lld\n", d);
 
  return 0;
}


Measured memory_bytes: 128
import sys
input=sys.stdin.readline
def main():
  n,m,q=map(int,input().split())
  x=[[0]*(n+1) for i in range(n+1)]
  c=[[0]*(n+1) for i in range(n+1)]
  for i in range(m):
    l,r=map(int,input().split())
    x[l][r]+=1
  for i in range(1,n+1):
    for j in range(1,n+1):
      c[i][j]=c[i][j-1]+x[i][j]
  for i in range(q):
    p,q=map(int,input().split())
    s=0
    for j in range(p,q+1):
      s+=c[j][q]-c[j][p-1]
    print(s)
if __name__=='__main__':
  main()

Measured memory_bytes: 55772
#include <string>
#include <iostream>
#include <math.h>

using namespace std;

string str;
int charsF[11];
char charsC[11];
int cnt;

void replaceAll(string &str, const string &a, const string &b) {
  int i;
  i = str.find(a);
  while (i != -1) {
    str.replace(i, a.size(), b);
    i = str.find(a);
  }
}

bool input() {
  int i;

  cin >> str;
  if (str.at(0) == '#') return false;

  fill(charsF, charsF + 11, -1);
  fill(charsC, charsC + 11, '\0');
  cnt = 0;
  for  (i = 0;  i < (int)str.size(); ++i ) {
    if ('a' <=  str.at(i) && 'k' >= str.at(i) && charsF[str.at(i) - 'a'] == -1) {
      charsF[str.at(i) - 'a'] = cnt;
      charsC[cnt] = str.at(i);
      cnt++;
    }
  }

  return true;
}

int main() {
  int i, j, k;
  string b;
  while (input()) {
    int d = (int)pow((double)2, cnt);
    //printf("%d %d\n", d, cnt);
    for (i = 0; i < d; ++i ) {
      b = string(str);
      for (j = 0;  j < cnt; j++) {
      //printf("%s %d\n", b.c_str(), 1 << j);
        if (i & 1 << j) {
          for (k = 0; (int)k < b.size(); k++) {
            if (b[k] == charsC[j]) b[k] = 'T';
          }
        } else {
          for (k = 0; (int)k < b.size(); k++) {
            if (b[k] == charsC[j]) b[k] = 'F';
          }
        }
      //printf("%s\n", b.c_str());
      }

      while (b.size() != 3) {
        replaceAll(b, "(T+T)", "T");
        replaceAll(b, "(T+F)", "T");
        replaceAll(b, "(F+T)", "T");
        replaceAll(b, "(F+F)", "F");
        replaceAll(b, "(T*T)", "T");
        replaceAll(b, "(T*F)", "F");
        replaceAll(b, "(F*T)", "F");
        replaceAll(b, "(F*F)", "F");
        replaceAll(b, "(T->T)", "T");
        replaceAll(b, "(T->F)", "F");
        replaceAll(b, "(F->T)", "T");
        replaceAll(b, "(F->F)", "T");
        replaceAll(b, "-T", "F");
        replaceAll(b, "-F", "T");
      }
      if ( b.c_str()[0] != b.c_str()[2] ) {
        break;
      }

    }

    if (i == d) printf("YES\n");
    else printf("NO\n");

  }

  return 0;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, m, n) for (int i = m; i < n; i++)
#define repr(i, m, n) for (int i = m; i >= n; i--)
#define db(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD   998244353
#define PI (acos(-1))
#define EPS 1e(-9);
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//--GLOBAL---------------------------------
ll dsum(ll n) {
    ll ret = 0;
    while (n > 0) {
        ret += 1;
        n /= 10;
    }
    return ret;
}
//--MAIN-----------------------------------
void Main() {
    string S; cin>>S;
    int ans=0;
    if(S=="SUN") ans=7;
    if(S=="MON") ans=6;
    if(S=="TUE") ans=5;
    if(S=="WED") ans=4;
    if(S=="THU") ans=3;
    if(S=="FRI") ans=2;
    if(S=="SAT") ans=1;
    cout<< ans<<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	int n;
	while(cin>>n){
	int c;
	if(n==0){
		break;
	}
	int ma=0,mi=2000,ans=0;
	for(int i=0;i<n;i++){
		cin>>c;
		ans+=c;
		ma=max(ma,c);
		mi=min(mi,c);
	}
	cout<<(ans-mi-ma)/(n-2)<<endl;
	}
	return 0;
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if((a+b) == c || (b+c) == a || (c+a) == b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int a,b,c,d,tombol[110];

void solve()
{
	cin>>a>>b>>c>>d;
	for (int i=a;i<=b;i++)
	 tombol[i]++;
	for (int i=c;i<=d;i++)
	 tombol[i]++;
	int sum=0;
	for (int i=0;i<=100;i++)
	 if (tombol[i]==2)
	  sum++;
	if (sum==0)
	 sum++;
	cout<<sum-1<<"\n";
	return;
}

int main()
{
	solve();
}

Measured memory_bytes: 256
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N,K = MI()
A = LI()

s = sum(A)

divisor = []  # s の約数

for i in range(1,int(s**.5)+1):
    if s % i == 0:
        divisor.append(i)
        if i != s//i:
            divisor.append((s//i))

divisor.sort(reverse=True)

from itertools import accumulate

for d in divisor:
    B = [a % d for a in A if a % d != 0]
    B.sort()
    C = [0] + list(accumulate(B))
    D = [0] + list(accumulate([d-b for b in B]))
    r = 10**10  # 操作の回数
    for i in range(len(C)):
        r = min(r,max(C[i],D[-1]-D[i]))
    if r <= K:
        print(d)
        break


Measured memory_bytes: 75280
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;

  int a,b,c,d;

  cin >> a >> b >> c >> d;
  while (a > 0 && c > 0){

    c -= b;
    if(c<=0){
      break;
    }
    
    a -= d;
    if(a<=0){
      break;
    }
  }

  //cout << a << " " << c << endl;
  if(a>0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    string x;
    cin >> x;
    int n = x.size();
    int ans = n;
    deque<char> deq;
    rep(i, n){
        if (x[i] == 'S'){
            deq.push_back('S');
        }
        else if (!deq.empty() && x[i] == 'T' && deq.back() == 'S') deq.pop_back();
        else if (x[i] == 'T') deq.push_back('T');
    }
    cout << deq.size() << endl;
    return 0;
}

Measured memory_bytes: 644
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int main(){
    string s;
    cin >> s;
    
    string kougo1 = "", kougo2 = "";
    int cnt1 = 0, cnt2 = 0;
    for(int i = 0; s[i] != '\0'; ++i){
        if(i % 2 == 0){
            kougo1 += '0';
            kougo2 += '1';
        }else{
            kougo1 += '1';
            kougo2 += '0';
        }

        cnt1 += (s[i] != kougo1[i]);
        cnt2 += (s[i] != kougo2[i]);
    }
    //cout << kougo1 << endl;
    //cout << kougo2 << endl;
    //cout << cnt1 << endl;
    //cout << cnt2 << endl;
    
    int ans = min(cnt1, cnt2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  int X;
  cin>>X;
  int answer=0;
  int num=2000;
  while(num>X){
    num-=200;
    answer++;
  }
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
typedef long long ll;
#define MOD 1000000007

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

const ll INF = 1LL << 60;

int main(){
int a,b,c;
cin >> a >> b >> c;
if(a==b && b==c){
  cout << "Yes" << endl;
}else{
  cout << "No" << endl;
}
}


Measured memory_bytes: 256
// D - Friend Suggestions
// DFS version
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rep(i,n) for(int i=0;i<(n);++i)

#define MAX 100000
vvi F(MAX);//friend
vi gid(MAX,-1), cnt(MAX);

int dfs(int root, int p){
	if(gid[p]>=0) return root;
	gid[p] = root;
	cnt[root]++;
	for(auto c:F[p]) dfs(root, c);
	return root;
}

int main(){
	int N,M,K; cin>>N>>M>>K;
	vi C(N);
	int s,t;
	rep(i,M){
		cin>>s>>t; s--; t--;
		F[s].push_back(t);
		F[t].push_back(s);
		C[s]++; C[t]++;
	}
	rep(i,N) dfs(i, i);
	rep(i,K){
		cin>>s>>t; s--; t--;
		if(gid[s] == gid[t]) C[s]++, C[t]++;
	}
	rep(i,N) cout<< cnt[gid[i]]-C[i]-1 <<" ";
}

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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    string S; cin >> S;
    int lenS = S.length();
    int ans = 1;
    int aim_idx = 0;
    int aim_len = 1;
    for(int i = 1; i < lenS;){
        if(aim_len == 2){
            aim_idx = i;
            aim_len = 1;
            i++;
        }
        else if(i == lenS-1 && aim_len == 1 && S[aim_idx] == S[i]){
            ans--;
            i++;
        }
        else{
            if(S[aim_idx] == S[i]){
                aim_idx = i;
                aim_len = 2;
                i += 2;
            }
            else{
                aim_idx = i;
                i++;
            }
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}

void solve(){}

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

bool comp(pair<ll,ll> i,pair<ll,ll> j)
{
	if(i.first+i.second==j.first+j.second)
	return i.second<j.second;
	return i.first+i.second<j.first+j.second;
}

main()
{
	int n;
	cin>>n;
	
	vector<pair<ll,ll>> v(n);
	
	for(int i=0;i<n;i++)
	cin>>v[i].first>>v[i].second;
	
	sort(v.begin(),v.end(),comp);
	
	vector<vector<ll>> dp(n+1,vector<ll> (n+1,1e14));
	dp[0][0]=0;
	
	int ans=0;
	
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=i;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(dp[i-1][j-1]<=v[i-1].first)
			{
				dp[i][j]=min(dp[i][j],dp[i-1][j-1]+v[i-1].second);
				ans=max(ans,j);
			}
			
			//if(dp[i][j]!=1e14)
			//ans=max(ans,j);
		}
	}
	
	//for(int i=1;i<=n;i++)
	//cout<<v[i-1].first<<" "<<v[i-1].second<<" "<<dp[i].hi<<endl;
	
	cout<<ans;
}

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

int main(){
    string N;
    cin >> N;
    int len = N.length();
    int sum = 0;
    for (int i = 0; i < len; i++) {
        //cout << (int) N[i] << endl;
        sum += ((int)N[i] - 48);
    }
    //cout << sum << endl;
    if (sum%9 == 0) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3692
#include <stdio.h>

int N, M;
int k[16];
int s[16][16];
int p[16];

int main(void) {
	int i, j;
	int search, count = 0;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < M; i++) {
		if (scanf("%d", &k[i]) != 1) return 1;
		for (j = 0; j < k[i]; j++) {
			if (scanf("%d", &s[i][j]) != 1) return 1;
			s[i][j]--;
		}
	}
	for (i = 0; i < M; i++) {
		if (scanf("%d", &p[i]) != 1) return 1;
	}

	for (search = 0; search < (1 << N); search++) {
		int ok = 1;
		for (i = 0; i < M; i++) {
			int kazu = 0;
			for (j = 0; j < k[i]; j++) {
				if ((search >> s[i][j]) & 1) kazu++;
			}
			if (kazu % 2 != p[i]) {
				ok = 0;
				break;
			}
		}
		if (ok) count++;
	}
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 128
def main():
    N = int(input())
    ga, sa, ba = map(int, input().split())
    gb, sb, bb = map(int, input().split())

    # A : ドングリと金属に変える
    # B : 全部ドングリに変える
    # B : ドングリと金属に変える（無駄な操作でロスがないので、いったんドングリ化してよい）
    # A : ドングリに変える

    dp1 = list(range(N + 1))  # dp1[巣から持ってきたドングリ数] = 取引所 B で持てる最大ドングリ数
    dp1[0] = 0
    for i in range(N + 1):
        if i >= ga:
            dp1[i] = max(dp1[i], dp1[i - ga] + gb)
        if i >= sa:
            dp1[i] = max(dp1[i], dp1[i - sa] + sb)
        if i >= ba:
            dp1[i] = max(dp1[i], dp1[i - ba] + bb)

    N = dp1[N]
    dp2 = list(range(N + 1))  # dp2[取引所 B から持ってきたドングリ数] = 巣に持ち帰れる最大ドングリ数
    for i in range(N + 1):
        if i >= gb:
            dp2[i] = max(dp2[i], dp2[i - gb] + ga)
        if i >= sb:
            dp2[i] = max(dp2[i], dp2[i - sb] + sa)
        if i >= bb:
            dp2[i] = max(dp2[i], dp2[i - bb] + ba)
    print(dp2[N])


if __name__ == '__main__':
    main()


Measured memory_bytes: 228636
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
static class Program
{
	static int[] ReadInts(this TextReader reader) => reader.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
	static long[] ReadLongs(this TextReader reader) => reader.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
	static IEnumerable<int[]> ReadInts(this TextReader reader, int count)
	{
		for (long i = 0; i < count; ++i)
			yield return reader.ReadInts();
	}

	static IEnumerable<long[]> ReadLongs(this TextReader reader, long count)
	{
		for (long i = 0; i < count; ++i)
			yield return reader.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
	}
	
	public static void Main(string[] args)
	{
		var input = Console.In.ReadLongs();
		var n = input[0]; var k = input[1];
		var n2 = n;
		do {
			n = n2 % k;
			n2 = Math.Abs(n - k);
		} while(n2 < n);
		Console.WriteLine(n);
	}
}

Measured memory_bytes: 13396
x=str(input())
s1=x.count("K")
s2=x.count("U")
s3=x.count("P")
s4=x.count("C")
b=min(s1,s2,s3,s4)
if s1==0 or s2==0 or s3==0 or s4==0:
    b==0
print(b)



Measured memory_bytes: 5556
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;
const int Maxn = 1010;
struct Era
{
	char name[20];
	int n;
	int year;
}era[Maxn];
int n, m;

void solve(int year)
{
	int ret = -1;
	for (int i = 0; i < n; ++i)
	{
		if (era[i].year < year) continue;
		if (era[i].year - era[i].n < year)
		{
			if (ret == -1) ret = i;
			else ret = -2;
		
		}
	}
	if (ret < 0) 
		puts("Unknown");
	else 	printf("%s %d\n", era[ret].name, era[ret].n + year - era[ret].year);
			
	
}
int main()
{
	while (scanf("%d%d", &n, &m) != EOF)
	{
		if (n == 0) break;
		for (int i = 0; i < n; ++i)
			scanf("%s%d%d", era[i].name, &era[i].n, &era[i].year);
		for (int i = 0; i < m; ++i)
		{
			int y;
			scanf("%d", &y);
			solve(y);
		}
		
	}
	return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <unordered_map>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ll long long int

using namespace std;

string s = "01";
int main()
{
  cin >> s;
  if (atoi(s.substr(0, 4).c_str()) < 2019)
  {
    cout << "Heisei" << endl;
    return 0;
  }
  if (atoi(s.substr(0, 4).c_str()) > 2019)
  {
    cout << "TBD" << endl;
    return 0;
  }

  if (atoi(s.substr(5, 2).c_str()) < 4)
  {
    cout << "Heisei" << endl;
    return 0;
  }
  if (atoi(s.substr(5, 2).c_str()) > 4)
  {
    cout << "TBD" << endl;
    return 0;
  }

  if (atoi(s.substr(8, 2).c_str()) <= 30)
  {
    cout << "Heisei" << endl;
    return 0;
  }
  cout << "Heisei" << endl;
  return 0;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
  string x,y;
  cin >> x >> y;
  ll ans = 0;
  for(int i = 0; i < x.size(); i++){
    if(x[i] != y[i]) ans++;
  }
  cout << ans;
}


Measured memory_bytes: 3812
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());

            for (int i = 1; i < 10; i++)
            {
                for (int j = 1; j < 10; j++)
                {
                    if (i * j == n)
                    {
                        Console.WriteLine("Yes");

                        return;
                    }
                }
            }

            Console.WriteLine("No");
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

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

int main(){
    LL N;
    cin >> N;
    vector<LL>  a(N), b(N);
    for(int i = 0;i < N;i++){
        cin >> a[i];
        b[i] = a[i];
    }
    LL ans1 = 0;
    for(int i = 0;i < N-1;i++){
        if(b[i] < 0){
            b[i] *= -1;
            b[i+1] *= -1;
        }
        ans1 += b[i];
    }
    ans1 += b[N-1];
    LL ans2 = 0;
    for(int i = 0;i < N;i++)    ans2 += abs(a[i]);
    LL m = 1e10;
    for(int i = 0;i < N;i++)    m = min(m, abs(a[i]));
    ans2 -= m*2;
    cout << max(ans1, ans2) << endl;
}

Measured memory_bytes: 1792
R=0
N=int(input())
L=list(map(int,input().split()))
maxa=max(L)
mina=min(L)
minb=10**10
for i in range(mina,maxa+1):
  for j in range(N):
    R+=(L[j]-i)**2
  minb=min(minb,R)
  R=0
print(minb)

Measured memory_bytes: 3064
INF = 10**9
from heapq import heappop,heappush
H,W = (int(i) for i in input().split())
Ch,Cw = (int(i)-1 for i in input().split())
Dh,Dw = (int(i)-1 for i in input().split())
S = [input() for i in range(H)]

dist = [[INF]*W for _ in range(H)]
dist[Ch][Cw]= 0
que = [(0,Ch*W+Cw)]
while(que):
    u_dist,u = heappop(que)
    uh,uw = u//W,u%W
    if dist[uh][uw] < u_dist:
        continue
    for dh in range(-2,3):
        for dw in range(-2,3):
            nh = uh + dh
            nw = uw + dw
            if nh<0 or H <= nh or nw < 0 or W <= nw:
                continue
            if S[nh][nw]=="#":
                continue
            cost = 0 if abs(dh)+abs(dw)<=1 else 1
            if dist[nh][nw] > dist[uh][uw] + cost:
                dist[nh][nw] = dist[uh][uw] + cost
                heappush(que,(dist[nh][nw],nh*W+nw))
if dist[Dh][Dw] == INF:
    print(-1)
else:
    print(dist[Dh][Dw])

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;

struct point{
    ll x, y;
};

/*FUNCs=================================================*/



/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    char s1,s2, s3,a1,a2,a3;
    cin >> s1>> s2>>s3>> a1>>a2>>a3;
    int cnt;
    if(s1 == a1) cnt++;
    if(s2 == a2) cnt++;
    if(s3 == a3) cnt++;
    cout <<cnt <<endl;
}

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

int main(){
    int r=0;
    int w=0;
    int n;
    cin >> n;
    string s;
    cin >> s;
    for(int i=0; i<n; i++){
        if(s.at(i)=='R') r++;
        else w++;
    }
    int ans=0;
    for(int i=0; i<r; i++){
        if(s.at(i)=='W') ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3728
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/30 14:36:20 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

#define MOD 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

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

// TOP
void	Main()
{
	int	h, w;
	cin >> h >> w;
	vector<vector<int>>	VVI(h, vector<int>(w));
	vector<string>	VS(h);
	for (auto& s : VS)
		cin >> s;
	rep(i, w)
	{
		if (VS.at(0).at(i) == '#')
			break;
		VVI.at(0).at(i) = 1;
	}
	rep(i, h)
	{
		if (VS.at(i).at(0) == '#')
			break;
		VVI.at(i).at(0) = 1;
	}
	rep2(i, 1, h)
	{
		rep2(j, 1, w)
		{
			if (VS.at(i).at(j) == '#')
				continue;
			VVI.at(i).at(j) = (VVI.at(i - 1).at(j) + VVI.at(i).at(j - 1)) % MOD;
		}
	}
	cout << VVI.back().back() << endl;
}
// END

int		main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 5248
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	bool can_win = count(s.begin(), s.end(), 'x') < 8;
	cout << (can_win ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		int C=sc.nextInt();
		int[] B=new int[M];
		for(int i=0; i<M; i++) {
			B[i]=sc.nextInt();
		}
		int ans=0;
		for(int i=0; i<N; i++) {
			int[] tmp=new int[M];
			int sum=0;
			for(int j=0; j<M; j++) {
				tmp[j]=sc.nextInt();
				sum+=tmp[j]*B[j];
			}
			sum+=C;
			if(sum>0) {
				ans++;
			}
		}
		pl(ans);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define INT long long
#define oo (int)(1e9)+1
using namespace std;

int n, z, w, p[2020], dt[2020][2020][2];

int dp(int a, int b, int k)
{
    if( a == n+1 or b == n+1 ) return abs(p[a]-p[b]);
    if( ~dt[a][b][k] ) return dt[a][b][k];
    int c = max( a, b );
    int &ret = dt[a][b][k];
    if( k == 0 ) ret = max( dp(c+1, b, 1-k), dp(c+1, b, k) );
    else ret = min( dp(a, c+1, 1-k), dp(a, c+1, k) );
    return ret;
}

int main()
{
    cin>>n>>z>>w;
    memset(dt, -1, sizeof(dt));
    p[0] = z, p[1] = w;
    for(int i = 2 ; i < n+2 ; i++ ) cin>>p[i];
    cout<<dp(0, 1, 0)<<endl;
}


Measured memory_bytes: 32384
#include <iostream>
#include <vector>
#include <unordered_map>
#include <deque>
#include <list>
#include <set>
#include <random>
#include <deque>

using namespace std;
using ll = long long;
const int BIG = 100000007;


int main() {
    ll n,d;
    cin >> n >> d;
    ll c = 0;
    for(ll i = 0;i < n;++i){
        ll x,y;
        cin >> x >> y;
        if(d * d>= (x * x + y * y))++c;
    }
    cout << c << endl;
}




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

#define ll long long
#define ii pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007
#define loo 10000000000000007

#define prime 1000000007

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int a, b, c; cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 3608
def solve(n, x, A):
    A.sort()
    count = 0
    for i in range(n):
        if i < n - 1 and A[i] <= x or i == n - 1 and A[i] == x:
            x -= A[i]
            count += 1
        else:
            break
    return count

_n, _x = list(map(int, input().split()))
_A = list(map(int, input().split()))
print(solve(_n, _x, _A))


Measured memory_bytes: 2940
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,M;
vector<ll> E[100005];
ll V[100005];
queue<ll> que;
ll ans[100005];
ll INF = 10000000000009;

int main(){
    cin >> N>>M;
    for(int i=0;i<M;i++){
        int n,m;
        cin >> n >> m;
        E[n-1].push_back(m-1);
        E[m-1].push_back(n-1);
    }
    for(int i=0;i<N;i++){
        V[i] = INF;
    }
    V[0] = 0;
    que.push(0);
    while(!que.empty()){
        ll now;
        now = que.front();
        que.pop();
        ll nowans = V[now];
        for(int i = 0;i<E[now].size();i++){
            if(V[E[now][i]]>nowans+1){
                V[E[now][i]] = nowans +1;
                ans[E[now][i]] = now+1;
                que.push(E[now][i]);
            }
        }
    }
    for(int i=0;i<N;i++){
        if(V[i] == INF){
            cout << "No"<<endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(int i=1;i<N;i++){
        cout << ans[i] << endl;
    }
    
}




Measured memory_bytes: 13732
n = int(input())
arr = [int(i) for i in input().split()]

count = 0
flag = True

for i in range(n-1):
    if arr[i] == arr[i+1]:
        pass
    elif arr[i] == arr[i+1] + 1:
        if flag:
            flag = False
        else:
            count = 1
    elif arr[i] > arr[i+1] + 1:
        count = 1
    else:
        arr[i] < arr[i+1]
        flag = True
        
if count == 1:
    print("No")
else:
    print("Yes")

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

use std::collections::BinaryHeap;

fn main() {
    input! {
        n: usize,
        m: usize,
        mut works: [(usize, usize); n],
    }
    works.sort_by_key(|&a| a.0);

    let mut ans = 0;
    let mut index = 0;
    let mut heap = BinaryHeap::new();

    for i in 1..m + 1 {
        while index < n && works[index].0 <= i {
            heap.push(works[index].1);
            index += 1;
        }

        ans += heap.pop().unwrap_or(0);
    }

    println!("{}", ans);
}


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

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

  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
  // ここにプログラムを追記
}

Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    ans = 0

    for i in range(N):
        if A[i] >= K:
            ans += 1

    print(ans)

    # for i in range(N):
    #     A = list(map(int, input().split()))


if __name__ == '__main__':
    main()


Measured memory_bytes: 51440