akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);

  ll m = max(A, max(B, C));

  ll diff = 3 * m - (A + B + C);
  if (diff % 2 == 0) {
    put(diff / 2);
    return 0;
  }

  put(diff / 2 + 2);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 256
a, b, h, m = gets.chomp.split(' ').map(&:to_f)
time_angle = (h * 60 + m) * 0.5
minute_angle = m * 6.0
angle = [(time_angle - minute_angle).abs, 360 - (time_angle - minute_angle).abs].min
puts Math.sqrt((a ** 2) + (b ** 2) - (2 * a * b * Math.cos(angle * Math::PI / 180)))

Measured memory_bytes: 14704
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){

int n;
while(1){

scanf("%d",&n);if(n==0)break;
int s=0;int t=0;
for(int i=1;i*i<=n;i++)
{t=n/i;

	if(n%i==0){s+=i+t;
	if(n==t||t==i)s-=t;
	
	}
//cout<<t<<endl;
}
if(n==1)s=0;
//cout<<s<<endl;
if(s>n)printf("abundant number\n");
if(s==n)printf("perfect number\n");
if(s<n)printf("deficient number\n");
}
return 0;
}

Measured memory_bytes: 1168
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		if (n > n/100*111 ) {
			System.out.println((n / 100 + 1) * 111);
		} else {
			System.out.println(n / 100 * 111);
		}

	}
}

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

int main()
{
	//freopen("in","r",stdin);

	int a,b,c,k;
	cin>>a>>b>>c>>k;

int ans=0;
	if(a<=k && k!=0)
	  {ans=a;  k-=a; }
    else if (a>k && k!=0)
	{
		ans=k;k=0;
	}

	if(b<=k && k!=0)
	{
		k-=b;
	}
   else if(b>k && k!=0)
	{
		k=0;
	}

	if(k!=0)
	{
		ans-=k;
	}
	cout<<ans;

	return 0;
}

Measured memory_bytes: 3596
using System;
 
namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            string[] data;
            while((data = Console.ReadLine().Split())[0] != "0" || data[1] != "0") {
                int hit = 0, blow = 0;
                for(int i=0; i < data[0].Length; ++i) {
                    if(data[0][i] == data[1][i]) {
                        ++hit;
                    }
                    else if(data[0].IndexOf(data[1][i]) != -1) {
                        ++blow;
                    }
                }
                Console.WriteLine("{0} {1}", hit, blow);
            }
        }
    }
}

Measured memory_bytes: 5820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long int MOD = 1000000007;
const long long  INF = 1LL << 60;

int main(void){
    int AC = 0, WA = 0, TLE = 0, RE = 0;
    int N; cin >> N;
    for (int i = 0; i < N; i++){
        string s; cin >> s;
        if (s == "AC") AC++;
        if (s == "WA") WA++;
        if (s == "TLE") TLE++;
        if (s == "RE") RE++;
    }
    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;
    
}


Measured memory_bytes: 3592
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var n     = int.Parse(spl[0]);
        var k     = int.Parse(spl[1]);

        spl   = input.ReadLine().Split(' ');
        var r     = int.Parse(spl[0]);
        var s     = int.Parse(spl[1]);
        var p     = int.Parse(spl[2]);

        var t = input.ReadLine();

        var po = new Dictionary<char, int>() {
            { (char)0, 0 },
            { 'r', r },
            { 's', s },
            { 'p', p },
        };
        var vic = new Dictionary<char, char>() {
            { 'r', 'p' },
            { 's', 'r' },
            { 'p', 's' },
        };

        var list = new List<char>();
        var count = 0;

        for(int i=0; i<n; i++) {
            var c = t[i];
            var my = vic[c];
            var pre = i >= k ? list[i - k] : (char)0;

            if(pre == my) {
                if(po[pre] < po[my]) {
                    count -= po[pre];
                    count += po[my];
                } else {
                    my = (char)0;
                }
            }

            count += po[my];
            list.Add(my);
        }

        return count;
    }
}


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

//これだとtle
ll ryuka(ll n){
  if(n==0) return 2;
  else if(n==1) return 1;
  else return ryuka(n-1)+ryuka(n-2);
}

//メモカ再帰で解け

int main(){
  ll n;
  cin >> n;
  ll ryu[100]={0};
  ryu[0]=2;
  ryu[1]=1;
  rep(i,n+1){
    if(i>1)ryu[i]=ryu[i-1]+ryu[i-2];
  }
  cout << ryu[n] <<endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = [0 for i in range(n)]
cnt = 0
for i in range(k):
    d = int(input())
    s = list(map(int, input().split()))
    for j in range(d):
        a[s[j]-1] += 1
for i in range(n):
    if a[i] == 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 67664
import sys
from collections import deque
readline = sys.stdin.readline


H, W = map(int, readline().split())
grid = '#' * (W + 2) + ''.join('#' + readline().strip() +
                               '#' for _ in range(H)) + '#' * (W + 2)
INF = 400


def shortest(grid, start, cost=0):
    dist = [INF] * (H + 2) * (W + 2)
    move = (-1, 1, W + 2, -W - 2)
    st = deque([start])
    dist[start] = 0
    while(st):
        sx = st.popleft()
        c = dist[sx]
        for a in move:
            x = sx + a
            if grid[x] == '#':
                continue
            dx = dist[sx] + 1
            if dist[x] <= dx:
                continue
            dist[x] = dx
            st.append(x)
    return max(x for x in dist if x < INF)


m = 0
for i in range(W + 3, (H + 1) * (W + 2) - 1):
    if grid[i] == '#':
        continue
    tm = shortest(grid, i)
    if m < tm:
        m = tm
print(m)


Measured memory_bytes: 3316
import scala.io.StdIn._
object Main{
  def main(args: Array[String]): Unit = {
     val in = readLine
     val l = in.split("\\s+").toList.map(_.toInt)
     if(l.filter(i => i<1&&i>100).isEmpty){
       val out = l.max - l.min
       println(out.toString)
     }
  }
}


Measured memory_bytes: 25300
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <math.h>
#include <string>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mk make_pair
#define fr first
#define sc second

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxn = 100100;

ll a, b, c, k;
ll _a, _b, _c;

void solve(){
	scanf("%lld %lld %lld %lld", &a, &b, &c, &k);
	if(k % 2){
		_a = b + c;
		_b = a + c;
		_c = a + b;
		a = _a;
		b = _b;
		c = _c;
	}
	printf("%lld", a - b);
}

int main(){
	int t = 1;
	while(t --){
		solve();
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
using namespace std;
typedef long long ll;

const ll mod = 1000000007;

ll dp[55][2];

int main(){
  string a,b,c;
  while(cin >> a,a!="0"){
    cin >> b >> c;
    int n = a.size();
    
    memset(dp,0,sizeof(dp));
    dp[n][0] = 1;
    rrep(i,n){
      rep(j,10){
	if(i==0 && j==0)continue;
	if(a[i]!='?' && a[i]-'0'!=j)continue;
	rep(k,10){
	  if(i==0 && k==0)continue;
	  if(b[i]!='?' && b[i]-'0'!=k)continue;
	  
	  rep(carry,2){
	    int nxtv = (j+k+carry)%10, nxtc = (j+k+carry)/10;
	    if(i==0 && nxtv==0)continue;
	    if(c[i]!='?' && c[i]-'0'!=nxtv)continue;
	    
	    (dp[i][nxtc] += dp[i+1][carry]) %= mod;
	  }
	}
      }
    }
    cout << dp[0][0] << endl;
  }
}

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

#define int long long

// ?????????????????????
int V, E;
struct edge {
    int to;
    int cost;
    edge(int to, int cost)
        : to(to), cost(cost) { }
};

vector<edge> G[100001];
int d[100001];

void dijkstra(int s) {
    using p = pair<int, int>;
    priority_queue<p, vector<p>, greater<p>> que;
    fill(d, d+V, 1e+9);
    d[s] = 0;
    que.push(p(0, s));
    while(!que.empty()) {
        p pi = que.top(); que.pop();
        int v = pi.second;
        if(d[v] < pi.first) continue;
        for(int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(p(d[e.to], e.to));
            }
        }
    }
}

signed main() {
    int r;
    cin >> V >> E >> r;
    for(int i=0; i<E; ++i) {
        int s, t, d;
        cin >> s >> t >> d;
        G[s].push_back(edge(t, d));
    }
    dijkstra(r);
    for(int i=0; i<V; ++i) {
        if(d[i]==1e+9) cout << "INF" << endl;
        else cout << d[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 19360
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = int(input())

if N == 1:
    print("0")
    exit()

temp = factorization(N)

ans = 0

def counter(num):
    count = 0
    time = 1
    while num > 0:
        num = num - time
        count += 1
        time += 1
        
    if num == 0:
        return count
    if num < 0:
        return count - 1

for i in range(len(temp)):
    ans += counter(temp[i][1])
    
print(ans)

Measured memory_bytes: 9508
import java.util.*;

public class Main{
  static int H, W;
  static char[][] field;
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    H = Integer.parseInt(S[0]);
    W = Integer.parseInt(S[1]);
    field = new char[H][W];
    for(int i = 0; i < H; i++){
      String s = sc.nextLine();
      for(int j = 0; j < W; j++){
        field[i][j] = s.charAt(j);
      }
    }
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        boolean c1, c2, c3, c4;
        c1 = c2 = c3 = c4 = false;
        if(field[i][j] == '#'){
          c1 = func(i+1,j);
          c2 = func(i-1,j);
          c3 = func(i,j+1);
          c4 = func(i,j-1);
          if(!c1 && !c2 && !c3 && !c4){
          System.out.println("No");
          return;
          }
        }
      }
    }
    System.out.println("Yes");
  }
  public static boolean func(int h, int w){
    if(h >= H || w >= W || w < 0 || h < 0){
      return false;
    }
    if(field[h][w] == '#'){
      return true;
    }else{
      return false;
    }
  }
}

Measured memory_bytes: 21844
n=int(input())
task=[]
for i in range(n):
    a,b=map(int,input().split())
    task.append((a,b))
task.sort(key=lambda x:x[1])

nowtime=0
for time,limit in task:
    nowtime+=time
    if nowtime>limit:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 31860
def prime_factorize(N):
    a = 1
    i = 2
    while i * i <= N:
        cnt = 1
        while N % i == 0:
            cnt += 1
            N //= i
        a *= cnt
        i += 1
    if N > 1:
        a *= 2
    return a


def resolve():
    import math as m
    N = int(input())
    n = m.factorial(N)
    a = prime_factorize(n)
    print(a % (10**9 + 7))


resolve()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define fi first
#define se second
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define pb push_back
#define len(x) (int)(x).size()
typedef long long ll;
typedef long double ld;

using namespace std;

vector<int>Z(string s){
    vector < int > z(len(s));
    int l = 0 , r = 0;
    for(int i = 1; i < len(s); ++i){
        if(s[i] != s[0])continue;
        if(i <= r)
            z[i] = min(z[i-l], r-i+1);
        while(i + z[i] < len(s) && s[z[i]] == s[i + z[i]])
            ++z[i];
        if(i + z[i]-1 > r)
            r = i + z[i] - 1 , l = i;
    }
    z[0] = len(s);
    return z;
}




signed main(){
    string w;cin >> w;
    int n = len(w);
    bool onelet = 1;
    for(int i = 1; i < len(w); ++i)
        if(w[i] != w[0])onelet = 0;
    if(onelet)return cout << len(w) << '\n' << 1 , 0;
    /// check that ans is 1
    vector < int > z , revz;
    z = Z(w);
    reverse(all(w)) , revz = Z(w);
    bool two = 0;
    for(int len = 1; len < n; ++len)
        if(n % len == 0 && z[len] + len == n)
            two = 1;
    if(!two)return cout << 1 << '\n' << 1 , 0;
    /// now we want smth like prefi and suf i + 1 , check that they are good
    int ans = 0;
    for(int pref = 0 ; pref < n - 1; ++pref){
        int lenp = pref + 1;
        int d = 2;

        bool ok = 1;
        while(d * d <= lenp){
            if(lenp % d == 0){
                if(d + z[d] >= lenp){
                    ok = 0;break;
                }
                if(lenp/d + z[lenp/d] >= lenp){
                    ok = 0;break;
                }
            }
            ++d;
        }
        if(lenp != 1){
            if(z[1] + 1 >= lenp)
                ok = 0;
        }
        if(!ok)continue;
        /// now we want to check suffix
        int lensuf = n - 1 - pref;
        d = 2;
        while(d * d <= lensuf){
            if(lensuf % d == 0){
                if(d + revz[d] >= lensuf){
                    ok = 0;break;
                }
                if(lensuf/d + revz[lensuf/d] >= lensuf){
                    ok = 0;break;
                }
            }
            ++d;
        }
        if(lensuf != 1){
            if(revz[1] + 1 >= lensuf)
                ok = 0;
        }
        if(!ok)continue;
        ans++;
    }
    cout << 2 << '\n' << ans;
    return 0;
}


Measured memory_bytes: 5148
#pragma GCC target("avx2")
#pragma GCC optimize("O3")

# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
   SpeedForce;
	cin >> n >> s;
	n = unique(every(s)) - s.begin();
	cout << n;
   return Accepted;
}

// B...a

Measured memory_bytes: 18944
H, W = map(int, input().split())

s = ['.' * (W + 2)]
for i in range(H):
    s.append('.' + input() + '.')
s.append('.' * (W + 2))

x = [0, -1, 0, 1]
y = [-1, 0, 1, 0]

for i in range(1, H + 1):
    for j in range(1, W + 1):
        check = False
        if s[i][j] == '#':
            for xx, yy in zip(x, y):
                if s[i + xx][j + yy] == '#':
                    check = True
            if not check:
                print("No")
                exit()

print("Yes")


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
//#define ll __int128
//#define int ll
//#define int ll
//#define char ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef MAX_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(4) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

void smain() {

    string s;
    cin >> s;
    stack<char> st;
    for (auto c : s) {
        if (c == 'S') {
            st.push(c);
        } else {
            if (st.size() && st.top() == 'S') {
                st.pop();
            } else {
                st.push(c);
            }
        }
    }
    cout << st.size();
}

Measured memory_bytes: 720
for i in range(int(input())):
	ax, ay, bx, by, cx, cy, dx, dy = map(float, input().split())
	if ax==bx or cx==dx:
		print("YES" if ax==bx and cx==dx and ay!=by and cy!=dy else "NO")
	else:
		print("YES" if abs((ay-by)/(ax-bx)-(cy-dy)/(cx-dx))<1e-10 else "NO")


Measured memory_bytes: 5608
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <tuple>
#include <vector>

int main(int argc, char* argv[]) {
  int64_t N;
  std::cin >> N;
  std::vector<int64_t> a(N + 1, 0);
  std::vector<int64_t> b(N + 1, 0);
  std::vector<int64_t> c(N + 1, 0);
  for (int64_t i = 1; i <= N; ++i) {
    std::cin >> a[i] >> b[i] >> c[i];
  }

  std::vector<int64_t> dp_a(N + 1, 0);
  std::vector<int64_t> dp_b(N + 1, 0);
  std::vector<int64_t> dp_c(N + 1, 0);
  for (size_t i = 1; i <= N; ++i) {
    const auto j{i - 1};
    dp_a[i] = std::max({dp_b[j], dp_c[j]}) + a[i];
    dp_b[i] = std::max({dp_c[j], dp_a[j]}) + b[i];
    dp_c[i] = std::max({dp_a[j], dp_b[j]}) + c[i];
  }
  std::cout << std::max({dp_a[N], dp_b[N], dp_c[N]}) << std::endl;
  return 0;
}


Measured memory_bytes: 4992
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    B = sorted(A)
    max_A = B[-1]
    submax_A = B[-2]
    for i in range(N):
        if A[i] == max_A:
            print(submax_A)
        else:
            print(max_A)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14104
// n個の行列が与えられたとき、スカラー乗算の回数が最小になるように
// 行列の計算順序を決定する連鎖行列積問題(Matrix Chain Multiplication)

#include <iostream>
#include <algorithm>
using namespace std;

static const int N = 100;
static const int INF = (1 << 21);

int main() {
	int p[N + 1]; // 行列M_iの行数と列数を記録する(M_i = P_i-1 * P_iになる)
	int m[N + 1][N + 1]; // 行列演算の最小回数(コスト)の表

	int n; cin >> n; // 行列の個数

	// n個の行列の行と列を記録する( (2*3) * (3*4) => {2, 3, 4} )
	for (int i = 1; i <= n; i++) {
		cin >> p[i - 1] >> p[i];
	}

	for (int i = 1; i <= n; i++) m[i][i] = 0; // mの対角成分を0に設定
	
	// 行列の掛け算の最小コストの探索
	for (int l = 2; l <= n; l++) {
		for (int i = 1; i <= n - l + 1; i++) {
			int j = i + l - 1;
			m[i][j] = INF; // INF
			for (int k = i; k <= j - 1; k++) {
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
			}
		}
	}

	cout << m[1][n] << endl;

	return 0;
}


Measured memory_bytes: 3124
n, k = map(int,input().split())
a = sorted(list(map(int,input().split())))
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7
N = 10**5
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
ans = 0
for i in range(n-k+1):
  ans += (a[n-1-i]-a[i])*cmb(n-1-i,k-1,mod)
  ans %=  mod
print(ans)

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

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

using namespace std;

int main()
{
    int k;
    cin >> k;
    string s;
    cin.ignore();
    getline(cin, s);
    int len = s.length();
    if(len<=k) cout << s << endl;
    else if(len>k)
    {
        rep(i,k)
        {
            cout << s[i];
        }

        cout << "..." << endl;
    }

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll h,w;
    cin>>h>>w;
    if(h==1||w==1){
    	cout <<1<<endl;
    	return 0;
    }
    cout << (h*w+1)/2 <<endl;
    return 0;
}


Measured memory_bytes: 256
nums = list(map(int, input().split(" ")))
W = nums[0]
H = nums[1]
x = nums[2]
y = nums[3]
r = nums[4]

if r*2 <= H and r*2 <= W and x >= r and (W-r) >= x and y >= r and (H-r) >= y:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 5596
sx,sy,tx,ty = map(int, input().split())
ans = ""
ans += "U"*(ty-sy)
ans += "R"*(tx-sx)
ans += "D"*(ty-sy)
ans += "L"*(tx-sx)
ans += ("L"+"U"*(ty-sy+1)+"R"*(tx-sx+1)+"D")
ans += ("R"+"D"*(ty-sy+1)+"L"*(tx-sx+1)+"U")
print(ans)

Measured memory_bytes: 9084
n , d = map(int, input().split())
x = []
y = []
for i  in range(n):
        a = list(map(int, (input().split())))
        x.append(a[0])
        y.append(a[1])

ans = 0
for i in  range(n):
        if (x[i] ** 2 + y[i] ** 2) ** (0.5)  <= d:
                ans += 1

print(ans)

Measured memory_bytes: 24932
#include<iostream>

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

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

    int begin_a_index = 0;
    int end_z_index = 0;

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

    // 最初の A のインデックスを見つける
    rep(i, size) {
        if (s[i] == 'A') {
            begin_a_index = i;
            break;
        }
    }
    
    // 最後の Z のインデックスを見つける
    rep(i, size) {
        if (s[i] == 'Z') {
            end_z_index = i;
        }
    }

    cout << end_z_index - begin_a_index + 1 << endl;
    return 0;
}


Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n, k;

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

    cin >> n >> k;
    cout << k + 100 * max(0LL, 10 - n) << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long
#define INF INT_MAX
#define mod 1000000007
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
	int k;cin>>k;
	string s;cin>>s;
	if(s.length()<=k)cout<<s;
	else
	{
		for(int i=0;i<k;i++)cout<<s[i];
		cout<<"...";
	}
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;
#define F first
#define S second
int n;
int p[250005];
P a[505];
int main(void){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i].F);
        a[i].S=i+1;
    }
    sort(a,a+n);
    int q=1;
    for(int i=0;i<n;i++){
        int v=a[i].S,o=a[i].F;
        p[o]=v;
        for(int j=0;j<v-1;j++){
            while(p[q]>0)q++;
            if(q>o){
                printf("No\n");
                return 0;
            }
            p[q]=v;
        }
    }
    q=1;
    for(int i=0;i<n;i++){
        int v=a[i].S,o=a[i].F,s=n-v;
        for(int j=0;j<s;j++){
            while(p[q]>0)q++;
            if(q<o){
                printf("No\n");
                return 0;
            }
            p[q]=v;
        }
    }
    printf("Yes\n");
    for(int i=1;i<=n*n;i++){
        printf("%d",p[i]);
        if(i!=n*n)printf(" ");
    }
    printf("\n");
}

Measured memory_bytes: 2176
#define CRT_SECURE_NO_WARNINGS

#include <stdio.h>

int main(void)
{
	int a;
	int b;

	scanf("%d", &a); scanf("%d", &b);

	if (a == b) {
		printf("a == b\n");
	}

	if (a > b) {
		printf("a > b\n");
	}

	if (a < b) {
		printf("a < b\n");
	}
	return 0;
}


Measured memory_bytes: 2140
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n, m; int a, b, c[50] = {};
  scanf("%d %d", &n, &m);
  for(int i = 0; i < m; i++){
    scanf("%d %d", &a, &b);
    c[a - 1]++; c[b - 1]++;
  }
  for(int i = 0; i < n; i++) printf("%d\n", c[i]);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define L long
#define t first
#define u second
#define M push_back(make_pair(c(
using namespace std;L R,C,N,a[9<<14],b,i;vector<pair<L,L>> p;bool s(L x,L y){return !(x^0&&x^R&&y^0&&y^C);}L c(L x,L y){return L(atan2(x-R/2,y-C/2)*(1<<30));}main(){cin>>R>>C>>N;for(;i<N;++i){cin>>*a>>a[1]>>a[2]>>a[3];if(s(*a,a[1])&&s(a[2],a[3])){p.M*a,a[1]),i));p.M a[2],a[3]),i));}}sort(p.begin(), p.end());fill(a,a+114514,0);stack<L> s;for(auto P : p){if(s.empty()||s.top()^P.u)s.push(P.u);else s.pop();}puts(s.empty()?"YES":"NO");}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t n;
  cin >> n;
  int64_t a;
  int64_t sum = 0;
  map<int64_t, int64_t> map;
  map[0]=1;
  for(int64_t i=0;i<n;i++){
    cin >> a;
    sum += a;
    map[sum] += 1;
  }
  int64_t count = 0;
  for(auto val: map){
    count += val.second*(val.second-1)/2;
  }
  cout << count << endl;;
  return 0;
}

Measured memory_bytes: 16072
#include<bits/stdc++.h>
#define LL long long
#define N 100005
#define INF (1LL<<60)
using namespace std;
const int mo=1e9+7;
int n,f[N],g[N],a[N],b[N]; LL A,B,S[N];
int find(int x,int *P){ return P[x] ? P[x]=find(P[x],P) : x;}
int main()
{
	int i,p,q;
	cin>>n>>A>>B;
	for(i=1;i<=n;i++){
		scanf("%lld",&S[i]);
		if(S[i]-S[i-1]>=A) a[i]=find(i-1,a);
		if(S[i]-S[i-1]>=B) b[i]=find(i-1,b);
	  }
	f[1]=g[1]=1,S[p=q=0]=-INF;
	for(i=2;i<=n;i++){
		while(p+1<=i&&S[p+1]+A<=S[i]) p++;
		if(p==i-1) f[i]=f[i-1];
		if(p>=find(i-1,b)-1)
			f[i]=(f[i]+g[min(p+1,i-1)])%mo;
		while(q+1<=i&&S[q+1]+B<=S[i]) q++;
		if(q==i-1) g[i]=g[i-1];
		if(q>=find(i-1,a)-1)
			g[i]=(g[i]+f[min(q+1,i-1)])%mo;
	  }
	printf("%d",(f[n]+g[n])%mo);
	return 0;
}


Measured memory_bytes: 2688
#include<stdio.h>

int main(){
  int a,b;

  char op;

  while(1)
    {
      scanf("%d %c %d",&a,&op,&b);
      if(op == '?')break;

      if(op == '+')
	{
	  printf("%d\n",a+b);
	}
      if(op == '-')
	{
	  printf("%d\n",a-b);
	}
      if(op == '*')
	{
	  printf("%d\n",a*b);
	}
      if(op == '/')
	{
	  printf("%d\n",a/b);
	}
    }
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-9;
const ll MOD=1e9+7;
int main(){
    int n;cin>>n;
    vector<ll> a(n),b(n);
    vector<ll> v;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        v.push_back(a[i]);
        v.push_back(b[i]);
    }
    sort(all(v));
    v.erase(unique(all(v)),v.end());
    map<ll,ll> mp;
    for(int i=0;i<v.size();i++){
        mp[v[i]]=i;
    }
    vector<ll> sum(v.size()+10);
    for(int i=0;i<n;i++){
        sum[mp[a[i]]]++;
        sum[mp[b[i]]+1]--;
    }
    ll ans=0;
    for(int i=1;i<=v.size();i++){
        sum[i]+=sum[i-1];
    }
    for(int i=0;i<=v.size();i++){
        ans=max(ans,sum[i]);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 19980
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int X; 
	cin >> X;
    int a=0;
    for(int i=1;i<121;i++){
    	if(X % i == 0 && 360 % i == 0)
          	a = i;
    }
    	cout << 360/a << endl;
}

Measured memory_bytes: 3592
#include <iostream>

int main(){
    char input;
    std::cin>>input;
    switch(input){
        case 'A':
        std::cout<<'T';
        break;
        case 'T':
        std::cout<<'A';
        break;
        case 'C':
        std::cout<<'G';
        break;
        case 'G':
        std::cout<<'C';
        break;
    }
    return 0;
}

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

int main(void) {
    int n, m, a, b;
    int count = 0;
    std::vector<long> h;
    std::vector<bool> be_road;


    std::cin >> n >> m;
    h.resize(n);
    for(int i = 0; i < n; i++) {
        std::cin >> h[i];
    }

    be_road.resize(n);

    for(int i = 0; i < m; i++) {
        std::cin >> a >> b;
        --a;
        --b;
        if(h[a] <= h[b]) {
            be_road[a] = true;
        }
        if(h[a] >= h[b]){
            be_road[b] = true;
        }
    }

    for(int i = 0; i < n; i++) {
        if(!be_road[i]) {
            count++;
        }
    }

    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 4040
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m=0,l=0,r;
    cin>>n>>s;
    for(char c:s)
    {
        (c=='I')? l++:l--;
        m=max(m,l);
    }
    cout<<m<<"\n";
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] in = br.readLine().split(" ");
        int n = Integer.parseInt(in[0]);
        int x = Integer.parseInt(in[1]);

        int[] l = new int[n];
        in = br.readLine().split(" ");
        for(int i = 0; i < n; i++) {
            l[i] = Integer.parseInt(in[i]);
        }

        int sum = 0;
        int ans = 1;
        for(int i = 0; i < n; i++) {
            sum += l[i];
            if(sum <= x) ans++;
            else break;
        }
        System.out.println(ans);
    }
}

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

typedef long long ll;
typedef unsigned long long ull;

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

  vector<ll> a(n);
  for (ll i = 0; i < n; ++i) {
    cin >> a[i];
  }

  ll v = 1;
  ll c = 0;
  for (ll i = 0; i < n; ++i) {
    if (a[i] == v) {
      v++;
      c++;
    }
  }

  if (c == 0) {
    cout << -1 << endl;
    return 0;
  }
  cout << a.size() - c << endl;

  return 0;
}

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

using namespace std;

const int N = 1234567;

vector <int> g[N];

int dfs(int v, int pr) {
  int x = 0;
  for (int u : g[v]) {
    if (u == pr) {
      continue;
    }
    x ^= dfs(u, v);
  }
  return x + 1;
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    x--; y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  printf("%s\n", dfs(0, -1) == 1 ? "Bob" : "Alice");
  return 0;
}


Measured memory_bytes: 36992
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}
vector<int>v(maxn),adj[maxn];

void solve(){
    // int n;
    // cin >> n;
    // FOR(i,1,n+1)cin >> v[i];
    // FOR(i,1,n){
    //     int u,v;
    //     cin >> u >> v;
    //     adj[u].pb(v);
    //     adj[v].pb(u);
    // }
    int x;
    cin >> x;
    FOR(i,0,1001){
        int a = i*i*i*i*i;
        FOR(j,0,i+1){
            int b = j*j*j*j*j;
            if(a+b == x){cout << i << " " << -j << "\n";return ;}
            if(a-b == x){cout << i << " " << j << "\n";return ;}
        }
    }
}

signed main()   
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){
        solve();
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...


Measured memory_bytes: 9504
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N, A;
    string b;
    cin >> N;
    
    for ( int i = 0; i < N; ++i)
    {
        cin >> A;
        if ( A % 2 == 0 )
        {
            if(A%3 != 0 && A%5 !=0)
            {
                b = "DENIED";
                break;
            }
        }
    }
    
    if(b == "DENIED")
    {
        cout << b << endl;
    }
    else
    {
        cout << "APPROVED" << endl;
    }
}


Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    ll x;   cin >> x;
    bool flag = false;
    for (ll a = 0; a*a*a*a*a <= x; a++) {
        ll k = a*a*a*a*a;
        for (ll b = 0; b*b*b*b*b <= x-k; b++) {
            if (b*b*b*b*b == x-k) {
                cout << a << " " << -b << endl;
                flag = true;
            }
            if (flag)
                break;
        }
        if (flag)
            break;
    }
    if (flag)
        return 0;

    for (ll a = 0; a <= 1000; a++) {
        for (ll b = 0; b <= 1000; b++) {
            ll k = a*a*a*a*a, l = b*b*b*b*b;
            if (k - l == x) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}

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

int main(){
    int n, m, a;
    cin >> n >>m;
    int numbers_1[n][m];
    int numbers_2[m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a;
            numbers_1[i][j] = a;
        }
    }
    for(int i=0;i<m;i++){
        cin >> a;
        numbers_2[i]=a;
    }
    for(int i=0;i<n;i++){
        int volume=0;
        for(int j=0;j<m;j++){
            volume += numbers_1[i][j]*numbers_2[j];
        }
        cout << volume << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

string s, ans = "AKIHABARA";
char check[] = {'H', 'B', 'R'};
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> s;
    rep(i, 0, s.size()) {
        if (s[0] != 'A') s.insert(s.begin(), 'A');
        rep(j, 0, 3) {
            if (s[i] == check[j] && s[i+1] != 'A') s.insert(s.begin() + i + 1, 'A');
        }
    }
    if (ans == s) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>



struct node {
  int key;
  struct node *right;
  struct node *left;
  struct node *parent;
};

struct node *root;
struct node *NIL;

void insert(int );

void inorder(struct node *);

void preorder(struct node *);

  
int main(){

  int n,i,x;
  char *com;
  char *cominsert = "insert";
  char *comprint = "print";

  com = (char*)malloc(10*sizeof(char));  
  
  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%s", com);
  
    if(strncmp(com,cominsert,6)==0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strncmp(com,comprint,5)==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}


void insert(int k){

  struct node *y = NIL;
  struct node *x = root;
  struct node *z;

  z = (struct node *)malloc(sizeof(struct node));

  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x-> key){
      x = x->left;
    }
    else {
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }
  else{
    if(z->key < y->key) {
      y->left = z;
    }
    else {
      y -> right = z;
    }
  }
}


void inorder(struct node *u){
  if(u == NIL) {
    return;
  }
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(struct node *u){
  if(u == NIL) {
    return;
  }
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}



Measured memory_bytes: 25172
def main():
    def solve(mid,g):
        for t,d in zip(x,y):
            if s[mid]==t:
                mid-=(d<'R')or-1
                if mid==g:
                    return 1
        return 0
    n,q,s,*z=open(0).read().split()
    x,y=z[::2],z[1::2]
    n,q=int(n),int(q)
    s=' %s '%s
    ok=0
    ng=n+1
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if solve(mid,0):
            ok=mid
        else:
            ng=mid
    a=ok
    ok=n+1
    ng=0
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if solve(mid,n+1):
            ok=mid
        else:
            ng=mid
    print(max(0,ok-a-1))
if __name__=='__main__':
    main()

Measured memory_bytes: 11628
#include<cstdio>
#include<queue>
using namespace std;
const int MAXN = 200000;
const int MAXM = 2000000;
struct edge{
    int to;
    edge *nxt;
}edges[MAXM + 5], *adj[4*MAXN + 5], *ecnt = &edges[0];
char s[MAXN + 5];
void addedge(int u, int v) {
    edge *p = (++ecnt);
    p->to = v, p->nxt = adj[u], adj[u] = p;
}
int indeg[4*MAXN + 5];
int main() {
    int N, M;
    scanf("%d%d", &N, &M);
    scanf("%s", s+1);
    for(int i=1;i<=M;i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        if( a == b ) {
            addedge(a+N, a+2*N);
            addedge(a+3*N, a);
        }
        else {
            if( s[a] == s[b] ) {
                addedge(a+N, b);
                addedge(b+N, a);
                addedge(a+3*N, b);
                addedge(b+N, a+2*N);
                addedge(b+3*N, a);
                addedge(a+N, b+2*N);
                addedge(a+3*N, b+2*N);
                addedge(b+3*N, a+2*N);
            }
            else {
                addedge(a, b+N);
                addedge(b, a+N);
                addedge(a+2*N, b+N);
                addedge(b, a+3*N);
                addedge(b+2*N, a+N);
                addedge(a+2*N, b+N);
                addedge(a+2*N, b+3*N);
                addedge(b+2*N, a+3*N);
            }
        }
    }
    for(int i=1;i<=4*N;i++) {
        for(edge *p=adj[i];p!=NULL;p=p->nxt)
            indeg[p->to]++;
    }
    queue<int>que;
    for(int i=1;i<=4*N;i++)
        if( !indeg[i] ) que.push(i);
    int cnt = 0;
    while( !que.empty() ) {
        cnt++;
        int f = que.front(); que.pop();
        for(edge *p=adj[f];p!=NULL;p=p->nxt) {
            indeg[p->to]--;
            if( !indeg[p->to] ) que.push(p->to);
        }
    }
    if( cnt == 4*N ) puts("No");
    else puts("Yes");
}

Measured memory_bytes: 36224