akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;

    vs64 minus(n, 0);
    rep (i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        if (a > b) swap(a, b);
        minus[b] += a + 1;
    }

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

    s64 ans = 0;
    rep (i, n)
    {
        ans += dp[i];
    }

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



Measured memory_bytes: 6340
n, m = map(int, input().split())
A = [tuple(map(int, input().split())) for i in range(n)]
C = [tuple(map(int, input().split())) for j in range(m)]
for i in range(n):
  res = 1 
  ans = abs(A[i][0] - C[0][0]) + abs(A[i][1] - C[0][1])
  for j in range(m):
    tmp = abs(A[i][0] - C[j][0]) + abs(A[i][1] - C[j][1])
    if tmp < ans:
      ans = tmp
      res = j+1
  print(res)


Measured memory_bytes: 3064
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <unordered_map>
//#include <string>
typedef long long LL;
//typedef long double LD;
using namespace std;

#define MOD 1000000007

LL mod_pow(LL x, LL n){
    LL ans = 1;
    while(n>0){
        if((n&1)==1){
            ans = ans * x % MOD;
        }
        x = x * x % MOD;
        n >>= 1;
    }
    return ans;
}

int main() {
    LL n;
    LL n_tmp;
    LL a;
    LL b;
    LL ans=1;

    cin >> n >> a >> b;
    ans=mod_pow(2,n);
    ans--;
    LL tmp_n=1;
    LL tmp_d=1;
    LL tmp_nd;
    for(int i=1; i<=a; i++){
        tmp_n=(tmp_n*(n+1-i))%MOD;
        tmp_d=(tmp_d*i)%MOD;
        tmp_nd=tmp_n*mod_pow(tmp_d,MOD-2);
    }
    ans=(ans-tmp_nd)%MOD;
    while(ans<0){
        ans+=MOD;
    }
    //cout << ans << " " << tmp_ans << endl;

    tmp_n=1;
    tmp_d=1;
    for(int i=1; i<=b; i++){
        tmp_n=(tmp_n*(n+1-i))%MOD;
        tmp_d=(tmp_d*i)%MOD;
        tmp_nd=tmp_n*mod_pow(tmp_d,MOD-2);
    }
    ans=(ans-tmp_nd)%MOD;
    //cout << ans << " " << tmp_ans << endl;
    while(ans<0){
        ans+=MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=input()
w=[0]
b=[0]

for i in range(len(s)):
    if s[i]=='#':
        w.append(w[-1]+1)
    else:
        w.append(w[-1])
    if s[-i-1]=='.':
        b.append(b[-1]+1)
    else:
        b.append(b[-1])
#print(w)
#print(b)
total=[]
for i in range(len(s)+1):
    total.append(w[i]+b[-i-1])
#print(total)
print(min(total))

Measured memory_bytes: 20932
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int cnt = 0, n;
    char s[102];
    scanf("%s", s);
    n = strlen(s);
    n /= 2;
    int l = strlen(s)-1;
    for (int i = 0; i<n; i++) {
        if (s[i] != s[l-i]) cnt++;
    }
    printf("%d\n", cnt);
    return 0;

}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int N;
char S[102];
int main(){
  int i;
  N = rd(S);
  for(i=0;i<(N);i++){
    if(i%2==0 && S[i]=='L'){
      wt_L("No");
      wt_L('\n');
      return 0;
    }
    if(i%2==1 && S[i]=='R'){
      wt_L("No");
      wt_L('\n');
      return 0;
    }
  }
  wt_L("Yes");
  wt_L('\n');
  return 0;
}
// cLay varsion 20190914-1

// --- original code ---
// int N;
// char S[102];
// {
//   rd(S@N);
//   rep(i,N){
//     if(i%2==0 && S[i]=='L') wt("No"), return 0;
//     if(i%2==1 && S[i]=='R') wt("No"), return 0;
//   }
//   wt("Yes");
// }


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int n=0,m=0;
    int data[51]={};
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int a=0,b=0;
        cin >> a >> b;
        data[a-1]++;
        data[b-1]++;
    }
    for(int i=0;i<n;i++){
        cout << data[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n,s)		for(i=s;i<n;i++)
#define repr(i,n,s)		for(i=s;i>=n;i--)
#define remax(x,y)		x = max(x,(y))
#define remin(x,y)		x = min(x,(y))
#define all(c)			(c).begin(),(c).end()
#define allr(c)         (c).rbegin(),(c).rend()
#define loop(c,i)       for(typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define loopr(c,i)      for(typeof(c.end()) i = c.end(); i != c.begin(); )
#define ittr(v) typeof(v)::iterator
#define pb	push_back
#define mp 	make_pair
#define vi 	vector<int>
#define vl 	vector<long>
#define vpii 	vector< pair<int,int> >
#define vpil 	vector< pair<int,long> >
#define vpll 	vector< pair<long,long> >
#define pii 	pair<int,int>
#define piii	pair< pair<int,int>,int >
#define pll 	pair<long,long>
#define plll 	pair< pair<long,long>,long >
#define umii 	unordered_map<int,int>

using namespace std;

int main()
{
	int k,i;
	cin>>k;
	long a[k],g=2,l=2;
	rep(i,k,0)
		cin>>a[i];
	repr(i,0,k-1)
	{
			l = l + (a[i] - l%a[i])%a[i];
			g = g - g%a[i] + a[i] - 1;
			if(l>g)
				break;
	}
	if(l>g)
		cout<<-1;
	else
		cout<<l<<" "<<g;
}



Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>

int main(void) {
	using namespace std;
	int S;
	int a;
	int h, m, s;

	cin >> S;

	h = (int)(S / 3600);
	a = S % 3600;
	m = (int)(a / 60);
	s = a % 60;

	cout << h << ':' << m << ':' << s << endl;

	return 0;
}

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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#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 REPA(i,a) for(ll i=0;i<(ll)(a.size());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--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  string s, t;
  cin >> s >> t;
  ll count = 0;
  REP(i, 3) {
    if (s[i] == t[i]) {
      count++;
    }
  }
  COUT(count);
}

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

/*

3 2
*/


Measured memory_bytes: 3616
def half_enumeration(a, *, func):
    """正しい英訳は不明"""
    n = len(a)
    h = n // 2

    def enum(h, *, second_half: bool = False) -> set:
        p = set()
        if second_half:
            b = a[h:]
        else:
            b = a[:h]

        for x in b:
            q = set()
            for e in p:
                q.add(func(e, x))
            p.add(x)
            p.update(q)
        return p

    return enum(h), enum(h, second_half=True)


def main():
    INF = 40 * 100 + 1

    N, Ma, Mb = map(int, input().split())

    def update(e, x):
        return e[0] + x[0], e[1] + x[1]

    xcs = []
    for _ in range(N):
        ai, bi, ci = map(int, input().split())
        x = Ma * bi - Mb * ai  # Σai:Σbi=Ma:Mb<->Ma*Σbi-Mb*Σai=0
        xcs.append((x, ci))

    p1, p2 = half_enumeration(xcs, func=update)

    t1 = [INF] * (INF * 2 + 1)
    t2 = [INF] * (INF * 2 + 1)
    for x, c in p1:
        t1[x] = min(t1[x], c)
    for x, c in p2:
        t2[x] = min(t2[x], c)

    ans = min(t1[0], t2[0])
    for x in range(-INF, INF + 1):
        ans = min(ans, t1[x] + t2[-x])

    print(-1 if ans == INF else ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 115896
#include<bits/stdc++.h>
    using namespace std;
     
    typedef long long ll;
    typedef pair<int,int> pii;
     
    long long MOD = 1000000000 + 7;
     
    int main(){
      cout << setprecision(10);
      int N,M;
      cin >> N >> M;
      vector<vector<int>> v(N);
     
      map<pii,ll> m;
     
      vector<pii> e; // 枝情報
     
      int tmp1,tmp2;
      for(int i = 0; i < M; i++){
     
        ll d;
        cin >> tmp1 >> tmp2 >> d;
        tmp1--;
        tmp2--;
        v.at(tmp1).push_back(tmp2);
        v.at(tmp2).push_back(tmp1);
     
        m[make_pair(tmp1,tmp2)] = d;
        m[make_pair(tmp2,tmp1)] = -d;
        e.push_back(make_pair(tmp1,tmp2));
        e.push_back(make_pair(tmp2,tmp1));
      }
     
      queue<int> q;
     
      ll INF = 1000000000000000000;
      vector<ll> dist(N, INF);
      vector<bool> check(N, false);
     
     
     
      bool flg = true;
      for(int i = 0; i <= N ; i++){
     
        while(!q.empty()){
          int now = q.front();
          check[now] = true;
          q.pop();
     
          for(auto next: v.at(now)){
            if(dist[next] == INF){
              dist[next] = dist[now] + m[make_pair(now,next)];
              q.push(next);
            } else{
              if(dist[next] == dist[now] + m[make_pair(now,next)]){
                // ok
                if(!check[next]){
                }
              } else { 
                flg = false;
                break;
              }
            }
          }
          if(!flg) break;
        }
     
        if(i < N && check[i] == false){
          q.push(i);
          dist[i] = 0;
        }
     
      }
      cout << (flg ? "Yes" : "No") << endl;
     
     
     
     
    }

Measured memory_bytes: 35948
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI (acos(-1))
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using Complex = std::complex<double>;
using namespace std;


int N, M;
bool ab[30][30];


bool judge(VI& v){
	if(v[0] != 0) return false;
	rep(i, 0, SIZE(v)-1)
		if(!ab[v[i]][v[i+1]]) return false;
	return true;
}


int solve(){
	int ans = 0;
	VI v(N, 0);
	iota(ALL(v), 0);
	do {
		if(judge(v)) ans++;
	} while(next_permutation(ALL(v)));
	return ans;
}


signed main(){
	cin >> N >> M;
	rep(i, 0, M){
		int a, b;
		cin >> a >> b;
		a--, b--;
		ab[a][b] = true;
		ab[b][a] = true;
	}

	cout << solve() << endl;

	return 0;
}

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

int main() {
  ll S,h,m,s;
  cin >> S;
  h = S/3600;
  m = (S - h*3600)/60;
  s = S%60;
  cout << h << ":" << m << ":" << s << endl;
  return 0;
}



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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

ll pow2(ll a, ll x){
    if(x == 0) return 1;
    else return pow2(a, x-1)*a;
}
int main()
{
    cout << fixed << setprecision(15);
    ll N, K;
    cin >> N >> K;

    vector<ll> A(N);
    REP(i, N){
        cin >> A[i];
    }

    vector<vector<int>> data(N, vector<int>(40));
    data.assign(N, vector<int>(40, 0));

    REP(i, N){
        ll bina = A[i];
        for (int j = 0; bina>0 ; j++){
            data[i][j] = bina%2;
            bina = bina/2;
        }
    }
    
    vector<ll> C(40,0);
    REP(i, N){
        REP(j, 40){
            // cout << data[i][j];
            if(data[i][j] == 1){
                C[j]++;
            }
        }
        // cout << endl;
    }

    // vector<int> KX(40);
    // ll bina = K;
    // int kx_counter = 0;
    // for (int i = 0; bina>0 ; i++){
    //     KX[i] = bina%2;
    //     bina = bina/2;
    //     kx_counter = i;
    // }

    ll ans = 0;
    for(int i=40; i>=0; i--){
        if(C[i] <= N/2){
            ll temp;
            temp = ans + pow2(2, i);
            // cout << i << ":" << temp << endl;
            if(temp > K){
                ans = ans;
            }
            else{
                ans = temp;
            }
        }
    }
    // cout << ans << endl;

    ll ans2 = 0;
    REP(i, N){
        ans2 += ans^A[i];
    }
    cout << ans2 << endl;
    return 0;
}

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

int main() {
  long a, b, k;
  cin >> a >> b >> k;
  
  long da = min(a, k);
  a -= da;
  k -= da;
  
  long db = min(b, k);
  b -= db;
  k -= db;
  
  cout << a << ' ' << b << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
    
    int N, K;
    scanf("%d %d", &N, &K);
    int SCORE[N];
    for(int i=0;i<N;i++){
        scanf("%d", &SCORE[i]);
    }
    for(int i=K;i<N;i++){
        if(SCORE[i-K]<SCORE[i]){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }
    return 0;
}

Measured memory_bytes: 2392
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n,t,a;
	cin>>n>>t>>a;
	vector<pair<double,int>> h;
	rep(i,n){
	    int p;
	    cin>>p;
	    h.emplace_back(abs(t-p*0.006-a),i+1);
	}
    sort(all(h));
    cout<<h.front().sc<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int cnt[202020],a[202020];
int n;
long long h;
bool jud(int mid)
{
	int now=100000,nsum=1;
	long long sum=0;
	memset(cnt,0,sizeof(cnt));
	cnt[now]++;
	for(int i=1;i<=n;i++)
	{
		if(a[i]<=mid)
		{
			nsum-=cnt[now];
			now--;
			cnt[now]++;
			nsum++;
		}
		else
		{
			now++;
			cnt[now]++;
			nsum+=cnt[now];
		}
		sum+=nsum-1;
	}
	return sum>=h;
}
int main()
{
	int l=1,r=1000000000,mid;
	scanf("%d",&n);
	h=((long long)(n+1)*n/2+1)/2;
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	while(l<r)
	{
		mid=(l+r)/2;
		if(jud(mid))
			l=mid+1;
		else
			r=mid;
	}
	printf("%d",l);
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int a[100001];
	int n,i,j,ans=0;
	cin>>n;
	for(i=0;i<=n-1;i++)
		cin>>a[i];
	sort(a,a+n);
	i=0;
	while(i<=n-1)
	{
	if(a[i]==a[i+1])i+=2;
		else {ans++;i++;}
	}
	cout<<ans;
	return 0;
}

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

int main(){
  string n;
  cin >> n;
  if(n[0] == '7' || n[1] == '7' || n[2] == '7') cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		ArrayList<Integer> alist = new ArrayList<Integer>();
		long answer = 0;

		for( String str:br.readLine().split(" ") ){
			alist.add(Integer.parseInt(str));
		}
		Collections.sort(alist, Comparator.reverseOrder());

		for(int i=0;i<n;i++){
			int num = (2*i)+1;
			answer += alist.get(num);
		}

		System.out.println(answer);
	}
}

Measured memory_bytes: 73664
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>

#define ll long long int
#define MOD 1000000007
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair

using namespace std;

int main(){
    double W,H,x,y;
    cin>> W >> H >> x >>y;
    double t_x=W/2,t_y=H/2;
    double ans=(W*H)/2;
    if(t_x==x&&t_y==y){
        cout << (double)ans << " " << 1 << endl;
    }
    else{
        cout << (double)ans << " " << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for (int i = 0; i < n; i++){
    if (s.substr(i, 3) == "ABC")
      ans++;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        n: usize,
        cs: Chars
    }

    let mut r = n;
    let mut count = 0;

    for l in 0..n {
        if cs[l] == 'W' {
            while l+1 < r {
                r -= 1;
                if cs[r] == 'R' {
                    count += 1;
                    break;
                }
            }
        } 
    }

    println!("{}",count)
}


Measured memory_bytes: 3004
#include<bits/stdc++.h>
using namespace std;
int a;
char c[10005];
int main()
{
	scanf("%d",&a);
	scanf("%s",c);
	a%=26;
	for(int i=0;i<strlen(c);i++)
	{
		if((int)c[i]+a>=91)
		{
			c[i]-=(26-a);
		}
		else c[i]+=a;
	}
	printf("%s",c);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef vector<ll> vl;
#define rep(i,n)for(i=0;i<n;i++)
void cm(ll &a,ll b){if(a>b)a=b;}
int main(void){ll n,s,k,v,i,j,b;cin>>n;vl x(n),y(n),p(n),a(n+1,1LL<<60);vector<vl>X(n),Y(n);rep(i,n)cin>>x[i]>>y[i]>>p[i];rep(i,n){X[i]=vl(1<<n,abs(x[i])),Y[i]=vl(1<<n,abs(y[i]));rep(b,1<<n)rep(j,n)if(b&1<<j)cm(X[i][b],abs(x[i]-x[j])),cm(Y[i][b],abs(y[i]-y[j]));}rep(b,1<<n){s=b;do{k=__builtin_popcountl(b),v=0;rep(i,n)v+=p[i]*min(X[i][s],Y[i][b&~s]);cm(a[k],v),s=(s-1)&b;}while(s!=b);}rep(i,n+1)cout<<a[i]<<" ";return 0;}

Measured memory_bytes: 11176
#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 H, W;
std::vector<std::pair<std::pair<int, int>, std::pair<int, int>>>ans;

int main()
{
	in >> H >> W;
	std::vector<std::vector<int>>a(H, std::vector<int>(W));
	rep(i, H) rep(j, W) in >> a[i][j];
	bool searchFlag = false;
	int px, py;
	rep(i, H)
	{
		if (i % 2 == 0)
		{
			rep(j, W)
			{
				if (searchFlag)
				{
					ans.push_back(std::make_pair(std::make_pair(px + 1, py + 1), std::make_pair(i + 1, j + 1)));
					if (a[i][j] % 2 == 1) searchFlag = false;
					else
					{
						px = i; py = j;
					}
				}
				else if (a[i][j] % 2 == 1)
				{
					searchFlag = true;
					px = i; py = j;
				}
			}
		}
		else
		{
			for (int j = W - 1; j >= 0; --j)
			{
				if (searchFlag)
				{
					ans.push_back(std::make_pair(std::make_pair(px + 1, py + 1), std::make_pair(i + 1, j + 1)));
					if (a[i][j] % 2 == 1) searchFlag = false;
					else
					{
						px = i; py = j;
					}
				}
				else if (a[i][j] % 2 == 1)
				{
					searchFlag = true;
					px = i; py = j;
				}
			}
		}
	}
	out << ans.size() << std::endl;
	for (auto i : ans) out << i.first.first << " " << i.first.second << " " << i.second.first << " " << i.second.second << std::endl;
	return 0;
}


Measured memory_bytes: 5232
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define endl "\n"
#define fo for(int i=0;i<n;i++)
#define clear cin.clear();cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define loopSolve int t; cin>>t; while(t--){solve();}
//INT_MAX         2,147,483,647                       <10^10
//U_INT_MAX       4,294,967,295                       <10^10
//LONG_LONG_MAX   9,223,372,036,854,775,807           <10^18
//U_LONG_LONG_MAX 18,446,744,073,709,551,615          <10^18
//ll power(int a, int b){
//    return (ll)(pow(a,b)+0.5);
//}

vector<int> gV(int n){
    vector<int> v(n);
    int input;
    fo { cin>>v[i];  }
    return v;
}

int* gA(int n){
    int* arr = new int[n];
    fo cin>>arr[i];
    return arr;
}


void solve(){
    int x,y;
    cin>>x>>y;
    int a=(4*x - y)/2, b=(y-2*x)/2;
    //2cout<<a<<" "<<b<<" "<<endl;
    if( a>=0 && b>=0 && (a+b == x) && (2*a + 4*b ==y))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}


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

    solve();
    //loopSolve;

	return 0;
}


Measured memory_bytes: 3632
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

int N, M;
int A[100000], B[100000], S[100000];
vector<pair<int, ll>> e[100000];

int vis[100000];
ll x[100000];

bool dfs1(int n, int p, int d) {
	vis[n] = d;
	if (d == 0 && x[n] <= 0) return false;
	bool ret = true;
	rep(i, e[n].size()) {
		if (vis[e[n][i].first] == d) {
			if (d == 0 && x[n] + x[e[n][i].first] < e[n][i].second) {
				return false;
			}
			if (d == 1 && x[n] + x[e[n][i].first] > e[n][i].second) {
				return false;
			}
			continue;
		}
		if (vis[e[n][i].first] == (d ^ 1)) {
			if (x[n] + x[e[n][i].first] != e[n][i].second) {
				cout << 0 << endl;
				exit(0);
			}
			continue;
		}
		x[e[n][i].first] = e[n][i].second - x[n];
		ret &= dfs1(e[n][i].first, n, d ^ 1);
	}
	return ret;
}

bool dfs2(int n, int p, int d) {
	vis[n] = d;
	if (d == 1 && x[n] <= 0) return true;
	bool ret = false;
	rep(i, e[n].size()) {
		if (vis[e[n][i].first] == d) {
			if (d == 0 && x[n] + x[e[n][i].first] > e[n][i].second) {
				return true;
			}
			if (d == 1 && x[n] + x[e[n][i].first] < e[n][i].second) {
				return true;
			}
			continue;
		}
		if (vis[e[n][i].first] == (d ^ 1)) {
			if (x[n] + x[e[n][i].first] != e[n][i].second) {
				cout << 0 << endl;
				exit(0);
			}
			continue;
		}
		x[e[n][i].first] = e[n][i].second - x[n];
		ret |= dfs2(e[n][i].first, n, d ^ 1);
	}
	return ret;
}

signed main() {
	cin >> N >> M;
	rep(i, M) {
		cin >> A[i] >> B[i] >> S[i];
		A[i]--; B[i]--;
		e[A[i]].pb({ B[i],S[i] });
		e[B[i]].pb({ A[i],S[i] });
	}

	ll ng1 = 0;
	ll ok1 = 1e15L;
	while (ok1 - ng1 > 1) {
		ll m = (ok1 + ng1) / 2;
		memset(vis, -1, sizeof(vis));
		x[0] = m;
		if (dfs1(0, -1, 0)) ok1 = m;
		else ng1 = m;
	}

	ll ng2 = 0;
	ll ok2 = 1e15L;
	while (ok2 - ng2 > 1) {
		ll m = (ok2 + ng2) / 2;
		memset(vis, -1, sizeof(vis));
		x[0] = m;
		if (dfs2(0, -1, 0)) ok2 = m;
		else ng2 = m;
	}

	//cout << ok1 << " " << ok2 << endl;
	cout << max(0LL, ok2 - ok1) << endl;
}


Measured memory_bytes: 21152
#include<stdio.h>
#include<string.h>
int main(){
  char s1[51],s2[51];
  int n1,n2;
  scanf("%s",s1);
  scanf("%s",s2);
  n1=strlen(s1);
  n2=strlen(s2);
  for(int i=0;i<n1;i++){
    printf("%c",s1[i]);
    if(i<n2)
      printf("%c",s2[i]);
  }
  printf("\n");
}

Measured memory_bytes: 128
// ~/Remember,remember the 6th of March

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-8;
const ll MOD = 1000000007;
const int N = 100000 + 7;

int main()
{
    int n,k,cnt=0;
    cin>>n>>k;
    while(n)
        n/=k,cnt++;
    cout<<cnt<<endl;
    return 0;
}





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

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

#define FOR(k,a,b) for(int k=(a); k<=(b); ++k)
#define IFOR(k,a,b) for(int k=(a); k>=(b); --k)
#define REP(k,a) for(int k=0; k<(a);++k)
#define IREP(k,a) for(int k=a-1; k>=(0);--k)
#define SZ(a) int((a).size())
#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define x first
#define y second
#define INF 1000000001
#define INFLONG 1000000000000000000
#define MOD 1000000007
#define MAX 100
#define ITERS 100
#define MAXM 200000
#define MAXN 1000000
#define PI 3.1415926535897932384626
#define ERR -987654321
#define MEM(a,b) memset(a,b,sizeof(a));
#define read1(a) scanf("%d",&a)
#define read2(a,b) scanf("%d%d",&a,&b)
#define read3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define readl1(a) scanf("%lld",&a)
#define readl2(a,b) scanf("%lld%lld",&a,&b)
#define readl3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)

int deg[MAXN], color[MAXN], isValid[MAXN], visited[MAXN];
vi v[MAXN], g[MAXN];

int weight[MAXN], node, wt;

void dfs(int p, int len, int flag) {
    visited[p] = flag;
    if(len + weight[p] >= wt) {
        wt = len;
        node = p;
    }
    for(auto i: g[p]) {
        if(visited[i] == flag) continue;
        dfs(i, len+weight[p], flag);
    }
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    int rn = uniform_int_distribution<int>(0, MAXN)(rng);

    int n;
    char c;
    cin>>n;
    REP(i,n-1) {
        int x,y;
        cin>>x>>y;
        x--, y--;
        v[x].PB(y); v[y].PB(x);
        deg[x]++; deg[y]++;
    }
    int count = 0;
    REP(i,n) {
        cin>>c;
        if(c == 'W') color[i] = 0, count++;
        else color[i] = 1;
    }
    
    if(count == 0) {
        cout<<"0"; return 0;
    } else if(count == 1) {
        cout<<"1"; return 0;
    }

    queue<int> q;
    REP(i,n) if(deg[i] == 1 && color[i] == 1) q.push(i);
    MEM(isValid, 1);
    while(!q.empty()) {
        int p = q.front();
        isValid[p] = 0;
        q.pop();
        for(auto i: v[p]) {
            if(deg[i] <= 1 || !isValid[i]) continue;
            deg[i] -= 1;
            if(deg[i] == 1 && color[i] == 1) q.push(i);
        }
    }

    int edges = 0, bv = 0, st = -1;
    REP(i,n) {
        if(!isValid[i]) continue;
        st = i;
        for(auto j: v[i]) if(isValid[j]) g[i].PB(j);
        edges += g[i].size();
        if((color[i] == 1 && g[i].size()%2 == 1) || (color[i] == 0 && g[i].size()%2 == 0)) weight[i] = 2, bv += 1;
        else weight[i] = 0;
    }

    wt = -1;
    dfs(st,0,1);
    wt = -1, st = node;
    dfs(st,0,2);

    int res = edges + bv - wt;
    cout<<res;

    return 0;
}

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

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

    int n, a, b;
    string s;
    cin >> n >> a >> b >> s;

    int passou = 0;
    int ov = 0;
    for(int i = 0; i < n; ++i) {
        if (s[i] == 'c') {
            cout << "No\n";
            continue;
        }
        if (s[i] == 'a') {
            if (a + b > passou) {
                cout << "Yes\n";
                passou++;
            } else {
                cout << "No\n";
            }
        } else {
            ov++;
            if (a + b > passou and ov <= b) {
                passou++;
                cout << "Yes\n";
            } else cout << "No\n";
        }
    }

    return 0;
}


Measured memory_bytes: 848
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		StringBuilder buf = new StringBuilder();
		
		String strA = String.valueOf(a);
		String strB = String.valueOf(b);
		
		if (a > b) {
			for (int i=0; i<a; i++) {
				buf.append(strB);
			}
			System.out.println(buf);
		} else {
			for (int i=0; i<b; i++) {
				buf.append(strA);
			}
			System.out.println(buf);
		}
	}
}

Measured memory_bytes: 22612
S = input()
T = "ACGT"
ans = 0

i = 0
while i < len(S):
    if S[i] in T:
        temp = 1
        for j in range(i+1, len(S)):
            if S[j] in T:
                temp += 1
            else:
                break
        ans = max(ans, temp)
        i += 1
    else:
        i += 1

print(ans)


Measured memory_bytes: 8996
using System;
public class Program
{
    public static void Main(string[] args)
    {
        var S = Console.ReadLine();
        var T = Console.ReadLine();
        var result = 0;
        for (int i = 0; i < S.Length; i++)
        {
            if (S[i] == T[i])
            {
                result++;
            }
        }
        Console.WriteLine(result);
    }
}

Measured memory_bytes: 13140
N, Y = map(int, input().split())


def main():
    # 大きな額面の札から優先して使用
    # 最小枚になる
    x = Y // 10000
    y = (Y - 10000 * x) // 5000
    z = (Y - 10000 * x - 5000 * y) // 1000

    while True:
        t = x + y + z

        # 一万 → 一千
        if t + 9 <= N and 0 < x:
            x -= 1
            z += 10
            continue

        # 五千 → 一千
        if t + 4 <= N and 0 < y:
            y -= 1
            z += 5
            continue

        # 一万 → 五千
        if t + 1 <= N and 0 < x:
            x -= 1
            y += 2
            continue

        break

    print(x, y, z) if x + y + z == N else print(-1, -1, -1)

    return


main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using VI = vector<int>;
using VB = vector<bool>;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  double total = 0;
  rep(i, n)
  {
    total += a[i];
  }

  double cod = total / 4 / m;
  vector <int> ans;
  rep(i, n) {
    if (a[i] >= cod){
      ans.push_back(a[i]);
    }
  }
  if (ans.size() >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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


 int main()
{
	int num , count = 0 , k = 0;


while(1){

cin >> num;
if( num == 0 ) break;
	for (int i = num; i > 0; i-- )
	{

		if ( i % 5 == 0 )
		{
			//k = i;
			//cout << i << 999999 << endl;

			while(1){
				if( k == 0 ) k = i;

				k = k / 5;
				count++;
				//cout << k << " " << count << endl; 
				if( k % 5 != 0 ){
					k = 0;
					//count = 0;
					break;
				} 
					
			}
			//cout << k << endl;
			//if( k % 5 != 0 ){
				//k = i / 5;
				//count++;

				//cout << k << endl;
				//continue;
				
				
			
		}
	}
	cout << count << endl;
	count = 0;
	}
	

	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
    #include<string.h>
     
     
    int main(){
      char s[11];
      scanf("%s",&s);
      int i,n;
      int ans = 0,res = 0;
      
      n = strlen(s);
      
      for(i=0;i<n;i++){
      switch(s[i]=='A' || s[i]=='C' || s[i]=='G' ||s[i]=='T'){
        case 0:res = 0;break;
        case 1:res = res + 1;break;
      }
        if(ans < res)
          ans = res;
      }
      
      printf("%d",ans);
      return 0;
    }

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.TreeMap;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();)
			solver.readBody(in.readLine());
		solver.solve();
	}
}

class Solver {
	int N;
	int cnt;
	TreeMap<Long, Integer> Member;

	public void init() {
		N = 0;
		cnt = 0;
		Member = new TreeMap<Long, Integer>(new Comparator<Long>() {
			public int compare(Long m, Long n) {
				return ((Long) m).compareTo(n) * -1;
			}
		});
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public boolean hasNext() {
		return cnt < 1;
	}

	public void readBody(String str) {
		String[] strArr = str.split(" ");
		for (int i = 0; i < 3 * N; i++) {
			long a = Long.parseLong(strArr[i]);
			if (Member.containsKey(a))
				Member.put(a, Member.get(a) + 1);
			else
				Member.put(a, 1);
		}
		cnt++;
	}

	public void solve() {
		long total = 0;
		boolean even = false;
		int grp = 0;
		for (long a : Member.keySet()) {
			for (int i = 0; i < Member.get(a) && grp < N; i++) {
				// System.out.println(a);
				if (even) {
					total += a;
					grp++;
				}
				even = !even;
			}
			if (grp >= N)
				break;
		}
		System.out.println(total);
	}
}


Measured memory_bytes: 96200
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll =  long long ;
using P = pair<int,int> ;
const int INF = 1e9;
const int MOD = 1000000007;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int now = 0;
    int t = 1;
    vector<ll> mp(2019,0);
    ll ans = 0;
    mp[0] = 1;
    for(int i=n-1;i>=0;i--){
        int d = s[i] - '0';
        now = (now + t * d) % 2019;
        ans += mp[now];
        mp[now] ++;
        t = (t * 10)% 2019;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3752
# 最大公約数
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


# 最小公倍数
def lcm(a, b):
    return a * b // gcd(a, b)


N = int(input())
T = [int(input()) for _ in range(N)]
if N == 1:
    print(T[0])
    exit()

base = lcm(T[0], T[1])
for i in range(2, N):
    base = lcm(base, T[i])
print(base)


Measured memory_bytes: 3064
h,w=map(int,input().split())
g=[input() for _ in range(h)]
from collections import *
def bfs(x,y):
  d=[[-1]*w for _ in range(h)]
  d[x][y]=0
  q=deque([(x,y)])
  while q:
    tx,ty=q.popleft()
    for dx,dy in [(1,0),(0,1),(-1,0),(0,-1)]:
      nx,ny=tx+dx,ty+dy
      if 0<=nx<h and 0<=ny<w and g[nx][ny]=='.' and d[nx][ny]<0:
        d[nx][ny]=d[tx][ty]+1
        q.append((nx,ny))
  return d
d=bfs(0,0)[-1][-1]
print((h*w-sum(s.count('#') for s in g)-d)*(d>0)-1)

Measured memory_bytes: 9424
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::f64::consts::PI;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}

#[allow(unused_macros)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn a() {
    let (a, b) = read!(usize, usize);
    if a <= 9 && b <= 9 {
        println!("{}", a * b);
    } else {
        println!("-1");
    }
}

fn b() {
    let n = read!(usize);
    for i in 1..10 {
        for j in 1..10 {
            if i * j == n {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}

fn c() {
    let n = read!(usize);
    if n == 2 {
        println!("1");
        return;
    }
    if n == 3 || n == 4 {
        println!("2");
        return;
    }
    let mut max_div = 1;
    for i in 1..((n as f64).sqrt() as usize + 1) {
        //        println!("{}", i);
        if n % i == 0 {
            max_div = i;
        }
    }
    let t = n / max_div;

    //    debugln!("{} {}", max_div, t);

    println!("{}", max_div + t - 2);
}

fn d() {
    let (a, b, x) = read!(usize, usize, usize);
    let a = a as f64;
    let b = b as f64;
    let x = x as f64;
    let theta = ((b * b * a) / (2.0 * x)).atan();

    if b * ((PI / 2.0) - theta).tan() <= a {
        println!("{}", theta * 180.0 / PI);
        return;
    }

    let theta = ((2.0 * a * a * b - 2.0 * x) / a.powi(3)).atan();
    println!("{}", theta * 180.0 / PI);
}

fn e() {
    unimplemented!();
}

fn f() {
    unimplemented!();
}

fn main() {
    a();
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main() {
	ll n, m, x, y;
	cin >> n >> m >> x >> y;
	ll a[110], b[110];
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < m; i++)cin >> b[i];
	sort(a, a + n); sort(b, b + m);
  for(int i=x+1;i<=y;i++){
    if(a[n-1]<i&&i<=b[0]){
      cout<<"No War"<<endl;
      return 0;
    }
  }
	cout << "War" << endl;
	return 0;
}

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

using namespace std;

int N,K;
int V[110];

int ans=0;
vector<int> v_minus;

int main(){

    cin>>N>>K;
    for(int i=0;i<N;++i)cin>>V[i];

    int R=min(N,K);

    for(int A=0;A<=R;++A){
        for(int B=0;B<=R;++B){
            if(A+B>R)continue;
            int v=0;
            for(int i=0;i<A;++i){
                v+=V[i];
                if(V[i]<0)v_minus.push_back(V[i]);
            }
            for(int i=0;i<B;++i){
                v+=V[N-i-1];
                if(V[N-i-1]<0)v_minus.push_back(V[N-i-1]);
            }
            sort(v_minus.begin(),v_minus.end());
            for(int i=0;i<min((int)v_minus.size(),K-(A+B));++i)v-=v_minus[i];
            ans=max(ans,v);
            v_minus.clear();
        }
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char n[10];
	cin>>n;
	for(int i=0;i<strlen(n);i++)
	{
		if(n[i]=='A'&&n[i+1]=='C')
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}

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

int main(){
  	int N,A;
  	cin>>N>>A;
	if(N%500==0){
    	cout<<"Yes"<<endl;
    }
	
	else if(N%500-A<=0){
    	cout<<"Yes"<<endl;
    }
	
	else{
    	cout<<"No"<<endl;
    }
}

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

int main() {
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	char c;
	int a=0,b=0;
	char aa=0,bb=0;
	for(int i=0;i<4;i++) {
		c=getchar();
		if(aa==0) {a++;aa=c;}
		else if(aa==c) a++;
		else if(bb==0) {b++;bb=c;}
		else if(bb==c) b++;
		else {cout<<"No"<<endl;return 0;}
	}
	if(a==2 && b==2) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
const int limit= 1000000;
char s[limit][12];
int main (){
  int n;
  long int result=0;
  long int m=0, a=0, r=0, c=0, h=0;
  scanf("%d\n", &n);
  for( int i=0; i<n; i++){
    scanf("%s", s[i]);
    switch(s[i][0]){
    case 'M': m++; break;
    case 'A': a++; break;
    case 'R': r++; break;
    case 'C': c++; break;
    case 'H': h++; break;
    default: break;
    }
  }
  result += m*a*r;
  result += m*a*c;
  result += m*a*h;
  result += m*r*c;
  result += m*r*h;
  result += m*c*h;

  result += a*r*c;
  result += a*r*h;
  result += a*c*h;

  result += c*r*h;

  printf("%ld\n", result);
  return 0;
}


Measured memory_bytes: 1280
n,m,c = list(map(int,input().split()))
b = list(map(int,input().split()))
cnt = 0
for i in range(n):
    a = list(map(int,input().split()))
    ok = 0
    for j in range(m):
        ok+=a[j]*b[j]
    if ok + c <=0:
        continue
    else:
        cnt+=1

print(cnt)

        


Measured memory_bytes: 38256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b, x := iScan(), iScan(), iScan()
	if a == 0 {
		fmt.Println(b/x + 1)
	} else {
		fmt.Println(b/x - (a-1)/x)
	}
}


Measured memory_bytes: 1772
#include<stdio.h>

int diffabs(int a,int b){
    if(a<b){
        return b-a;
    }else{
        return a-b;
    }
}

int main(void){
    int A[3]={};
    for(int i=0;i<3;i++){
        scanf("%d",&A[i]);
    }
    int small;
    small = diffabs(A[0],A[1])+diffabs(A[1],A[2]);
    if(diffabs(A[0],A[2])+diffabs(A[2],A[1])<small){
        small = diffabs(A[0],A[2])+diffabs(A[1],A[2]);
    }
    if(diffabs(A[0],A[1])+diffabs(A[0],A[2])<small){
        small = diffabs(A[0],A[1])+diffabs(A[0],A[2]);
    }

    printf("%d\n",small);
    return 0;
}

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


int main(){

  int a,b,c,d;
  cin>>a>>b>>c>>d;
  
 int x=(a+b+c+d) / 60;
 int y=(a+b+c+d) % 60;
 
 cout<<x<<endl;
 cout<<y<<endl;

  

  return 0;
}


Measured memory_bytes: 3076
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
int main() {
  int n, k; cin >> n >> k;
  vector< priority_queue<long long int> > pq(n+1);
  for(int i=0; i<n; i++) {
    long long int t, d; cin >> t >> d;
    pq[t-1].push(d);
  }

  priority_queue<long long int> a;
  priority_queue<long long int> b;
  for(int i=0; i<n; i++) {
    if(pq[i].empty()) continue;

    a.push(pq[i].top());
    pq[i].pop();
    while(!pq[i].empty()) {
      b.push(pq[i].top());
      pq[i].pop();
    }
  }

  vector<long long int> s = {0};
  vector<long long int> t = {0};
  while(!a.empty()) {
    s.push_back(s.back() + a.top());
    a.pop();
  }
  while(!b.empty()) {
    t.push_back(t.back() + b.top());
    b.pop();
  }

  long long int ans = 0;
  for(long long int i=1; i<=k; i++) {
    if (i >= s.size()) break;
    if (k-i >= t.size()) continue;
    ans = max(ans, s[i] + t[k-i] + i*i);
  }

  cout << ans << endl;


  return 0;
}



//EOF


Measured memory_bytes: 8820
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
#include<numeric>
using namespace std;

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

    vector<int> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];

    //sort(A.begin(), A.end());

    int sum = accumulate(A.begin(), A.end(), 0);
    //int cnt = A.end() - lower_bound(A.begin(), A.end(), (int)(sum / (4.0 * M) + 0.5));

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] >= (sum / (4.0*M)))
            cnt++;
    }

    if (cnt >= M)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256