akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <tuple>

using namespace std;

using lint = long long;
using ldouble = long double;

const int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};

bool solve() {
    int H, W;
    cin >> W >> H;
    if (W == 0) return false;

    vector<string> L(H), R(H);
    for (int x = 0; x < H; ++x) {
        cin >> L[x] >> R[x];
        reverse(R[x].begin(), R[x].end());
    }

    int lsx, lsy, rsx, rsy;
    for (int x = 0; x < H; ++x) {
        for (int y = 0; y < W; ++y) {
            if (L[x][y] == 'L') lsx = x, lsy = y;
            if (R[x][y] == 'R') rsx = x, rsy = y;
        }
    }

    vector<vector<vector<vector<bool>>>> visited(H);
    for (auto& v1 : visited) {
        v1.resize(W);
        for (auto& v2 : v1) {
            v2.resize(H);
            for (auto& v3 : v2) {
                v3.assign(W, false);
            }
        }
    }

    queue<tuple<int, int, int, int>> que;
    que.emplace(lsx, lsy, rsx, rsy);
    visited[lsx][lsy][rsx][rsy] = true;

    bool judge = false;
    while (!que.empty()) {
        int lx, ly, rx, ry;
        tie(lx, ly, rx, ry) = que.front();
        que.pop();

        bool l = (L[lx][ly] == '%');
        bool r = (R[rx][ry] == '%');
        if (l && r) {
            judge = true;
            break;
        }
        if (l || r) continue;

        for (int i = 0; i < 4; ++i) {
            int lnx = lx + dx[i];
            int lny = ly + dy[i];
            if (lnx < 0 || H <= lnx || lny < 0 || W <= lny ||
                L[lnx][lny] == '#') lnx = lx, lny = ly;

            int rnx = rx + dx[i];
            int rny = ry + dy[i];
            if (rnx < 0 || H <= rnx || rny < 0 || W <= rny ||
                R[rnx][rny] == '#') rnx = rx, rny = ry;

            if (visited[lnx][lny][rnx][rny]) continue;
            visited[lnx][lny][rnx][rny] = true;
            que.emplace(lnx, lny, rnx, rny);
        }
    }

    cout << (judge ? "Yes" : "No") << endl;
    return true;
}

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



Measured memory_bytes: 12132
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>


using namespace std;

int main(){
    string S; cin >> S;
    int ans = 0;
    int cnt = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if (S.at(i) == 'A' ||S.at(i) == 'C' ||S.at(i) == 'G' ||S.at(i) == 'T')
        {
            cnt++;
            ans = max(cnt,ans);
        }else
        {
            cnt = 0; 
        }
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
public class diverta2019C {
    public static void Main() {
        int N, lastA = 0, firstB = 0, ans = 0;
        string str;
        bool preA = false, same = true, fB = false, lA = false;
        N = int.Parse(System.Console.ReadLine());
        for (int i = 0; i < N; i++) {
            fB = false;
            lA = false;
            preA = false;
            str = System.Console.ReadLine();
            for (int j = 0; j < str.Length; j++) {
                if (str[j] == 'B' && preA) ans++;
                if (str[j] == 'A') preA = true;
                else preA = false;
                if (j == 0 && str[j] == 'B') {
                    firstB++;
                    fB = true;
                }
                if (j == str.Length - 1 && str[j] == 'A') {
                    lastA++;
                    lA = true;
                }
            }
            if ((fB && !lA) || (!fB && lA)) same = false;
        }
        if (firstB == 0 && lastA == 0) same = false;
        ans += Math.Min(firstB, lastA);
        if (same && ans > 0) ans -= 1;
        System.Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    int n,c,ans=0;cin>>n>>c;

    vector<int> sum(100010,0);
    vector<vector<P>> v(31,vector<P>(0));

    for(int i=0;i < n;i++)
    {
        int s,t,c;cin>>s>>t>>c;
        v[c].pb({s,t});
    }

    for(int i=0;i < 31;i++)
    {
        sort(v[i].begin(),v[i].end());

        for(int j=0;j< siz(v[i]);j++)
        {
            sum[v[i][j].fi]++;
            sum[v[i][j].se+1]--;

            if(-1<j-1 && v[i][j].fi == v[i][j-1].se) {
                sum[v[i][j].fi]--;
                sum[v[i][j-1].se+1]++;
            }
        }
    }

    

    for(int i=1;i < 100010;i++)
    {
        sum[i]+=sum[i-1];
        ans=max(ans,sum[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1920
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	void A() {
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		System.out.println(Math.max(0,(H-h)*(W-w)));
	}
	void B() {
		int N = sc.nextInt();
		int M = sc.nextInt();
		int C = sc.nextInt();
		int ans = 0;
		int []  B = new int[M];
		int [] A = new int[M];
		for(int i = 0; i < M; i++) B[i] = sc.nextInt();
		for(int i = 0; i < N; i++) {
			int tmp = C;
			for(int j = 0; j < M; j++) {
				A[j] = sc.nextInt();
				tmp += A[j] * B[j];
			}
			if(tmp>0) ans++;
		}
		System.out.println(ans);
	}
	void C() {
		
	}
	void D() {
		
	}
	void doIt() {
		B();
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().doIt();
	}

}


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecb2(var, n, m)    vector<vector<bool>> var(n, vector<bool>(m, false))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------
vector<int> make_divisors(ll x){
  vector<int> v;
  for(ll i=1; i*i<=x; i++){
    if(x%i==0){
      v.push_back(i);
      if(i!=x/i) v.push_back(x/i);
    }
  }
  sort(v.begin(), v.end());
  return v;
}

int main(void) {
  int n, m;
  cin >> n >> m;

  vec v = make_divisors(m);
  rep(i,v.size()){
    if(m/v[v.size()-1-i]>=n){
      prt(v[v.size()-1-i]);
      return 0;
    }
  }
}


Measured memory_bytes: 3636
import sys
import copy
import  math
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

x, y = na()
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
print('Yes' if (x in a and y in a) or (x in b and y in b) else 'No')

Measured memory_bytes: 3444
#include <iostream>
#define NMAX 1002
using namespace std;
int main(){
	int N,X[NMAX],TMIN;
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> X[i];
	}
	for (int i = 0; i < 101; ++i)
	{
		int T = 0;
		for (int j = 0; j < N; ++j)
		{
			T += (max(X[j],i)-min(X[j],i))*(max(X[j],i)-min(X[j],i));
		}
		if(i == 0){
			TMIN = T;
		}else{
			TMIN = min(TMIN,T);
		}
	}
	cout << TMIN << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  vector<vector<int>> A(3, vector<int>(3));
  rep(i, 3) {
    rep(j, 3) {
      cin >> A[i][j];
    }
  }
  int N;
  cin >> N;
  vector<int> b(N);
  rep(i, N) {
    cin >> b[i];
  }

  rep(n, N) {
    rep(i, 3) {
      rep(j, 3) {
        if (A[i][j] == b[n])
          A[i][j] = 0;
      }
    }
  }

  int exist = false;
  rep(i, 3) {
    int sum = 0;
    rep(j, 3) {
      sum += A[i][j];
    }
    if (sum == 0)
      exist = true;
  }

  rep(j, 3) {
    int sum = 0;
    rep(i, 3) {
      sum += A[i][j];
    }
    if (sum == 0)
      exist = true;
  }

  int sum = 0;
  rep(i, 3) {
    sum += A[i][i];
  }
  if (sum == 0)
    exist = true;

  sum = 0;
  rep(i, 3) {
    sum += A[i][2 - i];
  }
  if (sum == 0)
    exist = true;

  if (exist)
    cout << "Yes\n";
  else
    cout << "No\n";
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c;
  d=100*a+10*b+c;
  if(d%4==0)cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

int a, b, c, d, e, f, g, h;

int main(){
    scanf("%d %d %d %d\n%d %d %d %d", &a, &b, &c, &d, &e, &f, &g, &h);
    if(a + b + c + d <= e + f + g + h){
        printf("%d\n", e + f + g + h);
    }else{
        printf("%d\n", a + b + c + d);
    }
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;


int main() {
    int N;
    cin >> N;
    map<int, int> A;
    for(int i = 0; i < N; i++){
        int AA;
        cin >> AA;
        A[AA]++;
    }
    bool flag = true;
    if(N % 2 == 0){
        for(int i = 0; i < N; i++){
            if(i % 2 == 0){
                if(A[i] != 0) flag = false;
            }else{
                if(A[i] != 2) flag = false;
            }
        }
    }else{
        for(int i = 0; i < N; i++){
            if(i == 0){
                if(A[i] != 1) flag = false;
            }else if(i % 2 == 0){
                if(A[i] != 2) flag = false;
            }else{
                if(A[i] != 0) flag = false;
            }
        }
    }
    if(flag){
        ull sum = 1;
        for(int i = 0; i < N / 2; i++){
            sum *= 2;
            sum %= 1000000007;
        }
        cout << sum << endl;
    }else{
        puts("0");
    }
}

Measured memory_bytes: 4992
dic = {"i":1,"x":10,"c":100,"m":1000}
for r in range(input()):
	a,b = raw_input().split()
	s = 0
	for i in range(len(a)-1,-1,-1):
		if a[i] in "ixcm":
			try: s += int(a[i-1])*dic[a[i]]
			except: s += dic[a[i]]
	for i in range(len(b)-1,-1,-1):
		if b[i] in "ixcm":
			try: s += int(b[i-1])*dic[b[i]]
			except: s+= dic[b[i]]
	s = str(s)
	ans = ""
	for i in range(len(s)):
		if int(s[-i-1]) > 0:
			ans += "ixcm"[i] + s[-i-1]
	print ans[::-1].replace("1","")

Measured memory_bytes: 4288
from itertools import combinations
import numpy as np
N,M,X = map(int,input().split())
setto = list(range(N))
ans = 10**18
sankosyo = [list(map(int,input().split())) for i in range(N)]
subsets = []
for i in range(N+1):
    for c in combinations(setto,i):
        subsets.append(c)
for subset in subsets:
    cost = 0
    rikaido = np.array([0]*M)
    if subset == set():
        continue
    for i in subset:
        cost += sankosyo[i][0]
        for idx,A in enumerate(sankosyo[i][1:]):
            rikaido[idx] += A
    if np.count_nonzero(rikaido < X) == 0:
        ans = min(ans,cost)
if ans == 10**18:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 27628
def primes(a):
    if a==2 or a%2 != 0:
        return True
    return False

P=[0]*100000

for i in range(2,100000):
    if P[i]==0 and primes(i):
        for j in range(i+i,100000,i):
            P[j] = 1

C=[0]*100000

for i in range(3,100000,2):
    if P[i]==0 and P[int((i+1)/2)]==0:
        C[i]+=1
for i in range(3,100000):
    C[i]+=C[i-1]

N= int(input())

L=[]
R=[]
for i in range(N):
    l,r=map(int, input().split())
    L.append(l)
    R.append(r)

for i in range(N):
    print(C[R[i]]-C[L[i]-1])


Measured memory_bytes: 15568
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main() 
{
 
  ios::sync_with_stdio(0); 
  cin.tie(0); cout.tie(0);
 
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int a1 = a * c;
  int a2 = b * d;
  int ans = max(a1, a2);
  if(a <= 0 && b >= 0 || c <= 0 && d >= 0)
     ans = max(0LL, ans);

  ans = max(ans, d * a);
  ans = max(ans, b * c);

  cout << ans;

  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

long long SmallestWindowII(const vector<long long> &v,const long long K){
  long long n = v.size(),l=0,r=0,ans = 1000000000000000007;
  set<long long> s;
  long long counter[K+1] = {0};
  while(l < n){
    if(s.size() == K){
      ans = min(ans,r-l);
      if(1 <= v[l] && v[l] <= K){
        counter[v[l]]--;
        if(counter[v[l]] == 0)s.erase(v[l]);
      }
      l++;
    }
    else{
      if(r == n)return ans;
      if(1 <= v[r] && v[r] <= K){
        counter[v[r]]++;
        if(counter[v[r]] == 1)s.insert(v[r]);
      }
      r++;
    }
  }
  return ans;
}

signed main(){
  ll N,K;
  cin >> N >> K;
  vector<ll> a(N);
  FOR(i,0,N)cin >> a[i];
  cout << (SmallestWindowII(a,K) == LINF ? 0 : SmallestWindowII(a,K)) << endl;
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  ll N;
  cin >> N;

  cout << setprecision(30) << (N - 1) * N / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+5;
int main()
{
    string a;
    cin>>a;
    if(a[2]==a[3]&&a[4]==a[5])printf("Yes\n");
    else printf("No\n");
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  int n;
  cin >> n;
  char c[10];
  string s[100000];
  REP(i, n)
  {
    string ss;
    cin >> ss;
    REP(j, ss.length())
    {
      c[j] = ss[j];
    }
    sort(c, c + ss.length());
    s[i] = string(c, ss.length());
  }

  sort(s, s + n);

  ll ans = 0;
  ll count = 1;
  FOR(i, 1, n)
  {
    if (s[i] == s[i - 1])
    {
      count++;
    }
    if (s[i] != s[i - 1] && count != 1)
    {
      ans += count * (count - 1) / 2;
      count = 1;
    }
  }
  if (count != 1)
  {
    ans += count * (count - 1) / 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 5760
#include <cstdio>
#include <algorithm>
using namespace std;
int arr[101];

int main()  {
    int N, res = 0, idx;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) scanf("%d", &arr[i]);
    sort(arr, arr+N);
    for (int i = N; i > 0; i--) {
        idx = int(lower_bound(arr, arr+N, i) - arr);
        if (N -idx >= i) res = max(res, i);
    }
    printf("%d\n", res);

    return 0;
}



Measured memory_bytes: 2780
num = int(input())
num_list = input().split(' ')
num_list.reverse()
num_list[0] = int(num_list[0])
for i in range(num):
    if i + 1 == num:
        print('Yes')
        break
    num_list[i+1] = int(num_list[i+1])
    if num_list[i] >= num_list[i+1]:
        continue
    else:
        if num_list[i] + 1 == num_list[i+1]:
            num_list[i+1] = num_list[i+1] -1
        else:
            print('No')
            break

Measured memory_bytes: 11152
using Yorukatsu036.Questions;
using Yorukatsu036.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu036.Questions
{
    /// <summary>
    /// ABC072 B
    /// </summary>
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var s = inputStream.ReadLine();

            var builder = new StringBuilder();

            for (int i = 0; i < s.Length; i += 2)
            {
                builder.Append(s[i]);
            }

            yield return builder.ToString();
        }
    }
}


namespace Yorukatsu036
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu036.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu036.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 11616
N = int(input())
A = list(map(int, input().split()))
total = sum(A)
mid = total // 2
sum_left, sum_left2 = 0, 0
seperation_i = 0
for i, l in enumerate(A[:-1]):
  sum_left += l
  if sum_left >= mid:
      seperation_i = i
      sum_left2 = sum_left - l
      break
sum_right, sum_right2 = sum(A[seperation_i + 1:]), sum(A[seperation_i:])
print(min(abs(sum_right - sum_left), abs(sum_right2 - sum_left2)))

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

int main() {
  int N; //要素の数
  cin >> N; //要素数の宣言
  int ac = 0;
  int wa = 0;
  int tl = 0;
  int re = 0;
  
  string arr[N]; //配列の宣言
  
  for (int i = 0; i < N; i ++){
  	cin >> arr[i];
  }

  for (int i = 0; i < N; i ++){
  	if (arr[i] == "AC"){
    	ac = ac + 1;
    }else if (arr[i] == "WA"){
    	wa =  wa + 1;
    }else if (arr[i] == "RE"){
    	re = re + 1;
    }
  }
  
  tl = N - ac - wa - re;
  
  string ac1 = "AC x " + to_string(ac);
  cout << ac1 << endl;
  
  string wa1 = "WA x " + to_string(wa);
  cout << wa1 << endl;
  
  string tl1 = "TLE x " + to_string(tl);
  cout << tl1 << endl;
  
  string re1 = "RE x " + to_string(re);
  cout << re1 << endl;
}


Measured memory_bytes: 6804
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main()
	{
		int N = GetInt();
		int[] a = new int[N];
		for(int i = 0; i < N; i++)
			a[i] = GetInt();

		for(int i = 0; i < N; i++)
		{
			if(a[i] % 2 == 1)
			{
				Console.WriteLine("first");
				return;
			}
		}
		Console.WriteLine("second");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 17204
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,(n))
typedef long long ll;
using namespace std;

int main() {
    string S;
    cin >> S;
    puts(S == "ARC" ? "ABC" : "ARC");
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int a[200005], n;
long long k;
vector<int> cycle;
int first[200005];

int main() {
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> a[i];

    cycle.push_back(1);
    first[1] = 0;
    int curr = a[1];
    while(!first[curr]) {
        cycle.push_back(curr);
        first[curr] = cycle.size()-1;
        curr = a[curr];
    }
    if(k < cycle.size()) cout << cycle[k];
    else {
        k -= first[curr];
        long long sz = 1LL*(cycle.size()-first[curr]);
        long long mod = k%sz;
        cout << cycle[mod+first[curr]];
    }
}


Measured memory_bytes: 5780
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n, a[100]={0};//100個
    cin >> n;
    if(n<=100){
    for(int i=0; i < n; i++){
        cin >> a[i];
    }
     for(int i = n-1; i >= 0; i--){
         if(i == n-1){
        cout << a[i];
     }
     else{
         cout << " " << a[i];
     }
     }
    cout << endl;
}
}


Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<ll> A(n), B;
    for (int i = 0; i < n; i++) cin >> A[i];
    sort(A.begin(), A.end());
    for (int i = 0; i < n - 1; i++) {
        if (A[i] == A[i + 1]) { 
            B.push_back(A[i]);
            i++; 
        }
    }
    int m = B.size();
    ll ans = 0;
    if (m >= 2) ans = B[m - 1] * B[m - 2];
    cout << ans << endl;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;
    if (n==1) {
        cout << 1 << endl;
        return 0;
    }

    vector<ll> x(n), y(n);
    rep(i, 0, n) {
        cin >> x[i] >> y[i];
    }

    ll ans = INF;
    rep(i, 0, n) rep(j, 0, n) {
        if (i == j) continue;
        ll p = x[i] - x[j], q = y[i] - y[j];
        ll tmp = 0;
        rep(k, 0, n) rep(l, 0, n) {
            if (k == l) continue;
            if (x[k] - x[l] == p && y[k] - y[l] == q) tmp++;
        }
        chmin(ans, n - tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define inf             1e18
#define no_of_test(x)        int x; cin>>x; while(x--)
const int mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//	no_of_test(x)
	{
      string s;
	  cin>>s;
	  int k=s.length();
	   string z(k,'x');
	   cout<<z<<'\n';
	}
	return 0;
}

Measured memory_bytes: 3588
#include<stdio.h>

int main()
{
    int a=0,max=0,min=100,i;
    for(i=0;i<3;i++)
    {
        scanf("%d",&a);
        if(a>=max)max=a;
        if(a<=min)min=a;
    }
    printf("%d",(max-min));
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int n,k,x,y;
	scanf("%d%d%d%d",&n,&k,&x,&y);
	if(n<=k){
		printf("%d\n",x*n);
	}else{
		printf("%d\n",x*k+y*(n-k));
	}
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    for (auto c : s){
        if (c == 'o'){
            cnt++;
        }
    }
    cout << (cnt + (15 - s.size()) >= 8 ? "YES" : "NO") << endl;
}

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

using namespace std;

const int N = 1000010;

int n;
int tot = -1, head[N];
struct Edge {
    Edge(int p = 0, int next = 0) : p(p), next(next) {}
    int p, next;
} edge[N << 1];
inline void Add(int u, int v) {
    edge[++tot] = Edge(v, head[u]);
    head[u] = tot;
    return;
}
int a[N];
int f[N];

bool DFS(int u) {
    if (~f[u]) return f[u];
    f[u] = 0;
    for (int i = head[u]; ~i; i = edge[i].next) {
        int v = edge[i].p;
        if (a[u] > a[v]) f[u] |= !DFS(v);
    }
    return f[u];
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    memset(head, -1, sizeof(head));
    for (int i = 1; i < n; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        Add(u, v);
        Add(v, u);
    }
    memset(f, -1, sizeof(f));
    for (int i = 1; i <= n; ++i)
        if (!~f[i]) DFS(i);
    for (int i = 1; i <= n; ++i)
        if (f[i] > 0) printf("%d ", i);
    putchar('\n');
    return 0;
}

Measured memory_bytes: 25600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll n;
    string s;
    cin >> n >> s;

    ll count = 0;
    ll v = 0;
    rep(i, 0, n){
        if(s[i] == '('){
            count++;
        }else{
            count--;
        }

        if(count < 0){
            v = max(v, abs(count));
        }
    }

    rep(i, 0, v){
        s = '(' + s;
    }

    count = 0;
    rep(i, 0, n + v){
        if(s[i] == '('){
            count++;
        }else{
            count--;
        }
    }

    rep(i, 0, count){
        s = s + ')';
    }
    cout << s << endl;
}


Measured memory_bytes: 256
class diceClass:
	def __init__(self, valuelist):
		self.valuelist = valuelist
		self.t = valuelist[0]
		self.b = valuelist[5]
		self.n = valuelist[4]
		self.s = valuelist[1]
		self.e = valuelist[2]
		self.w = valuelist[3]

	def throw(self, direction):
		# N,S,W,E
		if direction == 'N':
			self.t, self.s, self.b, self.n = self.s, self.b, self.n, self.t
		elif direction == 'S':
			self.t, self.s, self.b, self.n = self.n, self.t, self.s, self.b
		elif direction == 'W':
			self.t, self.e, self.b, self.w = self.e, self.b, self.w, self.t
		elif direction == 'E':
			self.t, self.e, self.b, self.w = self.w, self.t, self.e, self.b


arrinput1 = list(map(int, input().split()))
arrinput2 = list(map(int, input().split()))
dirinput = 'WWWWSWWWWSWWWWSWWWWWSWWWWSSWWWW'
dicresult1 = []
dicresult2 = []

dice = diceClass(arrinput1)
dice2 = diceClass(arrinput2)

for s in dirinput:
	dice.throw(s)
	dice2.throw(s)
	if dicresult1.count([[dice.t, dice.s], dice.e]) == 0:
		dicresult1.append([[dice.t, dice.s], dice.e])
	if dicresult2.count([[dice2.t, dice2.s], dice2.e]) == 0:
		dicresult2.append([[dice2.t, dice2.s], dice2.e])

#print(dicresult1)
#print(dicresult2)

for i in dicresult1:
	if dicresult2.count(i) != 1:
		print('No')
		exit(0)

print('Yes')


Measured memory_bytes: 5616
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>

using namespace std;
int main(){
    int  h[100010]={0},d[100010]={0},n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    d[1]=0;
    d[2]=abs(h[2]-h[1]);
    for(int i=3;i<=n;i++){
        d[i]=min(d[i-2]+abs(h[i]-h[i-2]), d[i-1]+abs(h[i]-h[i-1]));
    }
    cout<<d[n]<<endl;
        
}


Measured memory_bytes: 4384
import sys
from math import floor

if __name__ == "__main__":
	A, B = map(int,input().split())

	a = int(A / 0.08)
	b = int(B / 0.1)

	if a < b:
		c = a
	else:
		c = b

	for money in range(c, 1009+1):
		m_a = floor(money * 0.08)
		m_b = floor(money * 0.10)
		if m_a == A and m_b == B:
			print(money)
			sys.exit()
	print(-1)

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

using namespace std;

#define MAX 310
#define INF 1e9

int N,a[MAX],s[MAX];
int memo[MAX][MAX];

int getSize(int v){
    int cnt = 0;
    while(v > 0){
        v /= 10; cnt++;
    }
    return cnt;
}

int calc(int X,int Y){
    int res = 0,c = 0;
    int size = max(getSize(X),getSize(Y));
    for(int i = 0 ; i < size ; i++){
        int x = X%10,y = Y%10;
        c = (x + y + c) / 10;
        res += x*y+c;
        X /= 10; Y /= 10;
    }
    return res;
}

int solve(int L,int R){
    if(L+1 == R) return 0;
    int &res = memo[L][R];
    if(res != INF) return res;
    for(int i = L+1 ; i < R ; i++){
        int cost = calc(s[i]-s[L],s[R]-s[i]);
        res = min(res,solve(L,i)+solve(i,R)+cost);
    }
    return res;
}

int main(){
    int N;
    cin >> N;
    for(int i = 0 ; i < N ; i++){
        cin >> a[i];
        s[i+1] = a[i] + s[i];
    }
    fill(memo[0],memo[0]+MAX*MAX,INF);
    cout << solve(0,N) << endl;
    return 0;
}

Measured memory_bytes: 1560
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
#endif

#ifdef _DEBUG
void init_global_C() {}
#else

#endif


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

    string S, T; cin >> S >> T;    
    int SL = S.size();
    int TL = T.size();

    string rs = S;
    replace(rs.begin(), rs.end(), '?', '.');

    vi idxs;
    for (int i = 0; i <= SL - TL; i++) {
        regex re(rs.substr(i,TL));

        if (regex_match(T, re)){
            idxs.push_back(i);
        }
    }

    int idx = idxs.size() > 0 ? idxs.back() : -1;
    string ans = "";
    if (idx < 0) ans = "UNRESTORABLE";
    else {
        int i = 0;
        while(i < SL) {
            if (i == idx) {
                ans += T;
                i += TL;
            } else {
                if (S[i] == '?') ans += 'a';
                else ans += S[i];
                i++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  string s; cin >> s;
  string v[] = {"AKIHABARA",
                "KIHABARA",
                "AKIHBARA",
                "AKIHABRA",
                "AKIHABAR",
                "KIHBARA",
                "KIHABRA",
                "KIHABAR",
                "AKIHBRA",
                "AKIHBAR",
                "AKIHABR",
                "KIHBRA",
                "KIHBAR",
                "KIHABR",
                "AKIHBR",
                "KIHBR"
               };
  bool f = false;
  for(int i = 0; i < 16; ++i)f |= s == v[i];
  cout << (f ? "YES" : "NO") << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); --i)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    ll X; cin >> X;

    ll P = 100, ans = 0;
    while(P < X) {
        P += P/100;
        ans++;
    }

    cout << ans;
}


Measured memory_bytes: 3652
class UnionFind:
  def __init__(self, n):
    self.par = [i for i in range(n+1)]
    self.rank = [0] * (n+1)
 
    # 検索
  def find(self, x):
    if self.par[x] == x:
      return x
    else:
      self.par[x] = self.find(self.par[x])
      return self.par[x]
 
  # 併合
  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if self.rank[x] < self.rank[y]:
      self.par[x] = y
    else:
      self.par[y] = x
      if self.rank[x] == self.rank[y]:
        self.rank[x] += 1
 
  # 同じ集合に属するか判定
  def same_check(self, x, y):
    return self.find(x) == self.find(y)
n,m = map(int,input().split())
u = UnionFind(n)
for _ in range(m):
  ai,bi = map(int,input().split())
  u.union(ai,bi)
s = [0 for _ in range(n+1)]
for i in range(1,n+1):
  s[u.find(i)] = 1
print(sum(s)-1)

Measured memory_bytes: 80608
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]

ans = "No"
for i in range(3):
    L1.append(I())
N, = I()
for _ in range(N):
    t, = I()
    for i in range(3):
        for j in range(3):
            if L1[i][j] == t:
                L1[i][j] = 0
                break
for i in range(3):
    if sum(L1[i]) == 0:
        ans = "Yes"
for j in range(3):
    s = 0
    for i in range(3):
        s += L1[i][j]
    if s == 0:
        ans = "Yes"
if L1[0][0] + L1[1][1] + L1[2][2] == 0 or L1[2][0] + L1[1][1] + L1[0][2] == 0:
    ans = "Yes"
print(ans)




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

int main(){
  int array[10],n,ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>array[i];
  }
  sort(array,array+n);
  array[n-1]/=2;
  for(int i=0;i<n;i++){
    ans+=array[i];
  }
  cout<<ans<<endl;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int main() {
    int N;
    cin >> N;
    
    vector<int> x(N), y(N), ID(N + 1);
    for_(i,0,N) {
        cin >> x[i] >> y[i];
        ID[y[i]] = i;
    }

    vector<int> order(N);
    iota(ALL(order), 0);
    sort(ALL(order), [&](int i, int j) { return x[i] < x[j]; });

    vector<bool> vis(N + 1, false);
    set<int> val;
    for_(i,0,N) val.insert(y[i]);

    dsu uf(N);
    for_(i,0,N) {
        int j = order[i];
        if (vis[y[j]]) {
            val.erase(y[j]);
            continue;
        }

        auto it = val.upper_bound(y[j]);
        while (it != val.end()) {
            uf.merge(j, ID[*it]);
            vis[*it] = true;
            ++it;
        }

        val.erase(y[j]);
    }

    for_(i,0,N) cout << uf.size(i) << endl;
}

Measured memory_bytes: 16436
from heapq import heappush, heappop
from collections import deque
import re
import math
import functools

def sRaw():
    return input().rstrip("\r")

def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29


def make1d_arr(n, val=INF):
    return [val for i in range(n)]


def make2d_arr(h, w, val=INF):
    return [[val for i in range(w)]for i in range(h)]


def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)


def BFord(n,es):
    v_cost = [INF]*n
    v_cost[0] = 0
    for v in range(n*2):
        for e in es:
            frm = e[0]
            to = e[1]
            if v_cost[to] > v_cost[frm]+e[2]:
                v_cost[to] = v_cost[frm]+e[2]
                if v >= n:
                    v_cost[to] = -INF
        if v == n-1:
            prev = v_cost[:]
    v_cost = [-INF if prev[idx]!=v_cost[idx] else v_cost[idx] for idx in range(n)]
    return v_cost
    
def ZAlgo(s):
    l = len(s)
    A = [0]*l
    i =1
    j =0
    A[0]=l
    while i<l:
        while i+j<l and s[j] == s[i+j]:
            j+=1
        if j==0:
            i+=1
            continue
        A[i]=j
        k=1
        while (i+k<l) and (k+A[k]<j):
            A[i+k] =A[k]
            k+=1
        i+=k
        j-=k
    return A


DIV = 998244353

def main():
    MD = isRaw()
    MD2 =isRaw()
    return 0 if MD[0] == MD2[0] else 1

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 38256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from fractions import gcd

n, *a = map(int, read().split())
b = a[::-1]
cumsum_m = [0] * (n - 1)
cumsum_p = [0] * (n - 1)
cumsum_m[0] = b[0]
cumsum_p[0] = a[0]
for i in range(1, n - 1):
    cumsum_p[i] = gcd(cumsum_p[i - 1], a[i])
    cumsum_m[i] = gcd(cumsum_m[i - 1], b[i])
ans = max(cumsum_m.pop(), cumsum_p.pop())
for p, m in zip(cumsum_p, cumsum_m[::-1]):
    v = gcd(p, m)
    if ans < v:
        ans = v
print(ans)


Measured memory_bytes: 14564
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<long double,string> P;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<P> p(n);
    rep(i,n) cin >> p[i].first >> p[i].second;
    long double sum=0;
    rep(i,n){
        if(p[i].second == "JPY"){
            sum+=p[i].first;
        }
        else{
            sum+=p[i].first * 380000.0;
        }
    }
    cout << sum << endl;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  vector<char> S(10);
  rep(i, 10) cin >> S[i];
  int y {};
  rep(i, 4) {
    y *= 10;
    y += (S[i] - '0');
  }
  if (y < 2019) {
    cout << "Heisei\n";
    return 0;
  } else if (y == 2019) {
    int m {};
    srep(j, 5, 7) {
      m *= 10;
      m += (S[j] - '0');
    }
    if (m < 4) {
      cout << "Heisei\n";
      return 0;
    } else if (m == 4) {
      int d {};
      srep(k, 8, 10) {
        d *= 10;
        d += (S[k] - '0');
      }
      if (d <= 30) {
        cout << "Heisei\n";
        return 0;
      }
    }
  }
  cout << "TBD\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int A,B,C;
	while(scanf("%d%d%d",&A,&B,&C)!=EOF)
	{
		if(A==5&&B==5&&C==7)
		   printf("YES\n");
		else if(A==7&&B==5&&C==5)
		  printf("YES\n");
		else if(A==5&&B==7&&C==5)
		  printf("YES\n");
		else 
		  printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 256
i=0
while True:
    N=int(input())
    if N==0:
        break
    else:
        a = list(map(float,input().split()))
        m=sum(a)/N
        #print(m)
        for i in range(N):
            a[i]=(float)(a[i]-m)**2
            #print(a[i])
            i+=1
        
        A=(sum(a)/N)**(1/2)
        print(A)
        


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

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

    ll A;
    if(N * 2 >= M) A = M / 2;
    else {
        A = N;
        M -= N * 2;
        A += M / 4;
    }
    PR(A);

    return 0;
}

/*



*/

Measured memory_bytes: 3604
#include <vector>
#include <iostream>
#include <climits>

using namespace std;

const int kSize = 200000;

int cnt = 0;

void BubbleSort(int A[], int n) {
    for (int i = 0; i < n - 1; ++i) {
        for (int j = n - 1; j >= i + 1; --j) {
            if (A[j] < A[j - 1]) {
                swap(A[j], A[j - 1]);
                cnt++;
            }
        }
    }
}

void SelectionSort(int A[], int n) {
    for (int i = 0; i < n; ++i) {
        int min_index = i;
        for (int j = i; j < n; ++j) {
            {
                if (A[j] < A[min_index]) {
                    min_index = j;
                }
            }
        }

        if (i != min_index) {
            cnt++;
        }
        swap(A[min_index], A[i]);
    }
}

int main() {
    int A[kSize];
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }

    //BubbleSort(A, n);
    SelectionSort(A, n);
    for (int i = 0; i < n; ++i) {
        if (i > 0) {
            cout << " ";
        }
        cout << A[i];
    }

    cout << endl;
    cout << cnt << endl;
}


Measured memory_bytes: 3104
from heapq import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n,m=MI()
    to=[[] for _ in range(n)]
    for _ in range(m):
        u,v=MI1()
        to[u].append(v)
        to[v].append(u)
    hp=[]
    ans=[-1]*n
    heappush(hp,(0,0,0))
    while hp:
        d,u,pu=heappop(hp)
        if ans[u]!=-1:continue
        ans[u]=pu
        for v in to[u]:
            if ans[v]!=-1:continue
            heappush(hp,(d+1,v,u))
    print("Yes")
    for a in ans[1:]:
        print(a+1)

main()

Measured memory_bytes: 39884
#include<stdio.h>
main(){
  int a;
  int b;
  int count=0;
  while(1){
    scanf("%d",&a);
    if(a==0)break;
    b=1000-a;
    while(b!=0){
      if(b>=500){
	b=b-500;
	count=count+1;
      }
      else if(b>=100){
	b=b-100;
	count=count+1;
      }
      else if(b>=50){
	b=b-50;
	count=count+1;
      }
      else if(b>=10){
	b=b-10;
	count=count+1;
      }
      else if(b>=5){
	b=b-5;
	count=count+1;
      }
      else if(b>=1){
	b=b-1;
	count=count+1;
      }
    }
    printf("%d\n",count);
    a=0;
    b=0;
    count=0;
  }
  return 0;
}

Measured memory_bytes: 600
n = int(input())
l = []
i = 1
while i<=n:
    a = input()
    l.append(a)
    i+=1
print("AC x "+ str(l.count("AC")))
print("WA x "+ str(l.count("WA")))
print("TLE x "+ str(l.count("TLE")))
print("RE x "+ str(l.count("RE")))

Measured memory_bytes: 16204