akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Scanner;


public class Main {
public static void main (String[] args){


	Scanner sc =new Scanner(System.in);
	ArrayList<String> list=new ArrayList<String>();


	while(sc.hasNextLine()) {
		list.add(sc.nextLine());
	}
	
	int AC=0;
	int WA=0;
	int TLE=0;
	int RE=0;
	
	int num= Integer.parseInt(list.get(0))+1;
	
	for(int i=1; i<num;i++) {
		if(list.get(i).equals("AC")) {
			AC++;
		}
		if(list.get(i).equals("WA")) {
			WA++;
		}
		if(list.get(i).equals("TLE")) {
			TLE++;
		}
		if(list.get(i).equals("RE")) {
			RE++;
		}
	}
	
	System.out.println("AC x "+AC);
	System.out.println("WA x "+WA);
	System.out.println("TLE x "+TLE);
	System.out.println("RE x "+RE);

}}




Measured memory_bytes: 67008
MOD = 10**9 + 7


def main():
    S = input()
    N = len(S)
    dp = [[0]*2 for _ in range(N+1)]
    dp[0][0] = 1
    for i in range(N):
        # smaller: 1 -> 1
        dp[i+1][1] += dp[i][1]*3

        # smaller: 0 -> 0
        if S[i] == "1":
            dp[i+1][0] += dp[i][0]*2
        else:
            dp[i+1][0] += dp[i][0]

        # smaller: 0 -> 1
        if S[i] == "1":
            dp[i+1][1] += dp[i][0]

        dp[i+1][0] %= MOD
        dp[i+1][1] %= MOD

    print((dp[N][0]+dp[N][1]) % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 54236
// ABC168A - 

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	int N;
	cin >> N;

	if (N%10 == 3) {
		cout << "bon" << endl;
	} else if ((N%10 == 0)||(N%10 == 1)||(N%10 == 6)||(N%10 == 8)) {
		cout << "pon" << endl;
	} else {
		cout << "hon" << endl;
	}

	return 0;
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadInts();
            var A = Math.Abs(input[0] - input[1]);
            var B = Math.Abs(input[0] - input[2]);
            if (A < B)
            {
                WriteLine("A");
            }
            else
            {
                WriteLine("B");
            }
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#if 0

#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int n1,n2;
int main() {
  string word;
  stack<int> S;
  while (cin >> word) {
    if (word == "+") {
      n2 = S.top(); S.pop();
      n1 = S.top(); S.pop();
      S.push(n1+n2);
    }
    else if (word == "-") {
      n2 = S.top(); S.pop();
      n1 = S.top(); S.pop();
      S.push(n1-n2);
    }
    else if (word == "*") {
      n2 = S.top(); S.pop();
      n1 = S.top(); S.pop();
      S.push(n1*n2);
    }
    else {
      S.push(stoi(word));
    }
  }
  cout << S.top() << endl;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vecll = vector<long long>;
#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)

int main()
{
    long long x;
    cin >> x;

    cout << bitset<32>(x) << endl;
    cout << bitset<32>(~x) << endl;
    cout << bitset<32>(x << 1) << endl;
    cout << bitset<32>(x >> 1) << endl;
    return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, flag=0;
  cin >> a;
  for(int i=1; i<10; i++){
  	if (a%i==0){
      if (a/i<10){
        flag=1;
      }
    }
  }
  if (flag==1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(x) x.begin(), x.end()
#define MOD 1000000007
#define vi vector < int >
#define pii pair < int, int >
#define INF (int)1e9
#define pb push_back
#define ld long double
#define fastIO ios::sync_with_stdio(0); cin.tie(0);

int main()
{
    fastIO
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    
    long double c = 0;
    long double PI = 3.141592653589793238462;
    long double theta = PI * 2 * ((ld)h/ 12.0 + ((ld)m / 60.0) / 12.0 - (ld)m / 60.0);
    c = pow(a, 2) + pow(b, 2) - (ld)2.0 * a * b * cos(theta);
    c = sqrt(c);
    
    cout << fixed << setprecision(20) << c;

    return 0;
}

Measured memory_bytes: 4176
#include <cstdio>
#include <vector>
#include <set>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>

struct edge
{
  int to;
  int cost;
};

int n, m;
std::vector<edge> edges[100];
std::set<std::pair<int, int>> path;

void dijkstra(int s)
{
  int prev[100];
  std::fill(prev, prev + n, -1);
  int dist[100];
  std::fill(dist, dist + n, 1e9);
  dist[s] = 0;
  using pair = std::pair<int, int>;
  std::priority_queue<pair, std::vector<pair>, std::greater<pair>> q;
  q.emplace(pair{0, s});
  while (!q.empty())
  {
    auto p = q.top(); q.pop();
    int v = p.second;
    if (dist[v] < p.first) continue;
    for (auto e : edges[v])
    {
      if (dist[e.to] > dist[v] + e.cost)
      {
        dist[e.to] = dist[v] + e.cost;
        q.emplace(pair{dist[e.to], e.to});
        prev[e.to] = v;
      }
    }
  }
  for (int i = s + 1; i < n; ++i)
  {
    for (int t = i; t != -1; t = prev[t])
    {
      if (prev[t] == -1) break;
      path.insert(pair{std::min(t, prev[t]), std::max(t, prev[t])});
    }
  }
}

int main()
{
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i)
  {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    --a, --b;
    edges[a].emplace_back(edge{b, c});
    edges[b].emplace_back(edge{a, c});
  }
  for (int i = 0; i < n; ++i)
  {
    dijkstra(i);
  }
  printf("%d\n", m - path.size());
  return 0;
}


Measured memory_bytes: 256
//2018.11.17

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

int main() {
    int n;
    cin >> n;
    vector<unsigned long long> a;
    unsigned long long tmp;
    for(int i=0;i<n;i++){
        cin >> tmp;
        a.push_back(tmp);
    }

    sort(a.begin(),a.end(),greater<unsigned long long>());

    unsigned long long len1 = 0;
    unsigned long long len2 = 0;

    for(int i=1;i<n;i++){
        if(a[i-1]==a[i]) {
            if (len1 == 0) {
                len1 = a[i];
                i++;
            }
            else { len2 = a[i]; }
        }
        if (len1 != 0 && len2 != 0){ break; }
    }

    unsigned long long ans = len1 * len2;
    cout << ans << endl;
}


Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();

			
		for(int i=1;i<=n;i++)
		{
			int year = stdIn.nextInt();
			int month = stdIn.nextInt();
			int day = stdIn.nextInt();
			int count = 0;
			
			if(year%3==0)
			{
				count += 21-day;
				if(month!=10)
				{
					count += (10-month)*20;
				}
				
			}
			else
			{
				if(month%2==0)
				{
					count += 20-day;
				}
				else
				{
					count += 21-day;
				}
				
				for(int j=month+1;j<=10;j++)
				{
					if(j%2==0)
					{
						count += 19;
					}
					else
					{
						count += 20;
					}
				}
			}
			
			for(int j=year+1;j<1000;j++)
			{
				if(j%3==0)
				{
					count+=200;
				}
				else
				{
					count+=195;
				}
			}
				
			System.out.println(count);
				
		}
		
	}

}

Measured memory_bytes: 20688
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pq;
int main(){
  long long K,N;
  cin >> N >> K;
  pq sushi[N];
  for(long long i=0; i<N; i++){
    cin >> sushi[i].second >> sushi[i].first;
  }
  
  long long f[N+10] = {0};
  sort(sushi, sushi+N);
  reverse(sushi, sushi+N);
  
  long long ans = 0;
  long long tmp = 0;
  long long count[N+10] = {0};
  long long kind = 0;
  stack<pq> st;
  for(long long i=0; i<K; i++){
    if(count[sushi[i].second] == 0) kind++;
    count[sushi[i].second]++;
    tmp += sushi[i].first;
    st.push(sushi[i]);
  }
  f[kind] = tmp + kind * kind;
  
  pq top;
  for(long long i=K; i<N; i++){
    if(count[sushi[i].second] > 0) continue;
    while(!st.empty()){
      top = st.top();
      st.pop();
      if(count[top.second] > 1) break;
    }
    if(st.empty()) break;
    tmp = tmp - top.first + sushi[i].first;
    f[kind+1] = tmp + (long long)(kind+1) * (kind+1);
    kind++;
    count[top.second]--;
    count[sushi[i].second]++;
  }
  
  for(long long i=1; i<=kind; i++){
    ans = max(ans, f[i]);
  }
  
  cout << ans << endl;
  return 0;
}
    
    
    
    
      
  

Measured memory_bytes: 3328
function Main(input) {
	const lines = input.split(' ')
	const number = lines[0] * lines[1]
    if ( ( number % 2 ) == 0 ) {
      console.log("Even")
    } else {
      console.log("Odd")
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0)

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }

    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
    int n = ri();
	int a[n];
	INPUT(a);
	SORTT(a);

	s64 sum = 0;
	UPTO(i,1,n-1) sum += a[i];

	cout << (sum > a[0] ? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 256
N,P = map(int ,input().split())
A = list(map(int ,input().split()))
odd = 0#奇数
even = 0#偶数
for i in A:
    if i % 2 == 0:
        even += 1
    else:
        odd += 1
com = [[0] * 55 for i in range(55)]
com[0][0] = 1
for i in range(1,55):
    com[i][0] = 1
    for j in range(1,55):
        com[i][j] = com[i-1][j-1] + com[i-1][j]
eval = 0
for i in range(even + 1):
    eval += com[even][i]
oval = 0

if P == 0:
    for i in range(odd+1):
        if i % 2 == 0:
            oval += com[odd][i]
else:
    for i in range(odd + 1):
        if i % 2 == 1:
            oval += com[odd][i]
print(eval * oval)


Measured memory_bytes: 38640
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Online Judge: Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define ff first
#define ss second
#define endl '\n'
#define INF 1e9 + 1
#define _INF INT32_MIN
#define pq priority_queue
#define MM multimap
#define PB push_back
#define EMPP emplace_back
#define vii vector<int>
#define vll vector<LL>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sf1(v) scanf("%I64d",&v);
#define sf2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sf3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
float Euclidean(LL x1, LL x2, LL y1, LL y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
LL gcd(LL a,LL b) {
	return !b ? a : gcd(b, a % b);
}
LL LCM(LL a, LL b) {
	return (a*b) / gcd(a, b);
}
void PrimeFactor(LL n)
{
	while (n % 2 == 0) {
		//printf("%d ", 2);
//		aa.insert(2);
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n%i == 0) {
			//printf("%d ", i);
			//aa.insert(i);
			n /= i;
		}
	}
	if (n > 2){
		//printf("%d ", n);
	//	aa.insert(n);
	};
}
bool is_square(LL x) {
	LL l = 0, r = x;
	while (l <= r) {
		LL mid = l + (r - l) / 2;
		if (mid*mid == x)return true;
		if (mid*mid > x)r = mid - 1;
		else l = mid + 1;
	}
	return false;
}
LL power(LL x, LL y)
{
	LL temp;
	if (y == 0)return 1;
	temp = power(x, y / 2);
	if (y % 2 == 0)
		return temp*temp;
	else return x*temp*temp;
}
bool is_Prime(int x) {
	if (x == 2)return 1;
	else if (x % 2 == 0 || x < 2)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}
bool solv(int n,int a,int b)
{
	if (a > 9 || b > 9)return 0;
	if (a*b == n)
		return 1;
	return solv(n, a + 1, b) ||solv(n, a, b + 1);
}
int main()
{
	El3zba;
	/***  بسم الله الرحمن الرحيم   ***/
	int n;
	cin >> n;
	if (solv(n,1,1))
		return cout << "Yes\n", 0;
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
using LR = pair<int, int>;

int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  int l, r;
  vector<LR> lrs;
  for(int i = 0; i < Q; ++i) {
    cin >> l >> r;
    lrs.push_back(LR(l - 1, r - 1)); // 添字に変換
  }

  vector<int> acs(S.size(), 0);
  int acc = 0;
  for(int i = 1; i < S.size(); ++i) {
    if(S[i - 1] == 'A' && S[i] == 'C') {
      acc++;
    }
    acs[i] = acc;
  }
  /*
  for(auto ac : acs) {
    cout << ac << endl;
  }
  */
  for(auto lr : lrs) {
    // cout << lr.second << " - " << lr.first << endl;
    cout << acs[lr.second] - acs[lr.first] << endl;
  }
  return 0;
}

Measured memory_bytes: 2292
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<stdio.h>
#include<cstdio>

int v[1500001];
char s[1500001],t[500002];
void Zalgorithm(int N){
  int j=0;
  for(int i=1;i<N;++i){
    if(i+v[i-j]<j+v[j]){
      v[i]=v[i-j];
    }else{
      int k=j+v[j]-i;
      k*=k>0;
      while(i+k<N&&s[k]==s[i+k])++k;
      v[i]=k;
      j=i;
    }
  }
}
int i,j,K,que[500001],bf,ans,size;
int main(){
  int N,ng=500001,mid;
  std::fgets(t,1000000,stdin);
  std::fgets(s,1000000,stdin);
  while(ng-K>1){
    mid=(ng+K)>>1;
    (s[mid]?K:ng)=mid;
  }
  while(t[i]!='\n'){
    s[K+i]=t[i];++i;
  }
  N=i;
  i+=K;
  int M=N+(K<<1);
  while(i<M){
    s[i++]=t[j++];
    j*=j<N;
  }
  Zalgorithm(M);
  for(i=0;i<N;++i){
    if(v[i+K]<K)que[size++]=(i+K)%N;
  }
  for(i=0;i<N;++i){
    if(i==size){
      puts("-1");
      return 0;
    }
    if(v[que[i]+=K]>=K){
      que[size++]=que[i]%N;
      if(bf<=i){
        bf=size-1;
        ++ans;
      }
    }
  }
  printf("%d\n",ans);
}

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

using namespace std;

int root(int par[], int x) {
    if (par[x] == x) return x;
    
    par[x] = root(par, par[x]);
    return par[x];
}

bool isSameRoot(int par[], int x, int y) {
    return root(par, x) == root(par, y);
}

void unite(int par[], int size[], int x, int y) {
    x = root(par, x);
    y = root(par, y);
    if (x == y) return;

    par[x] = y;
    size[y] = size[x] + size[y];
    size[x] = size[y];
}

int main() {
    long N, M;
    cin >> N >> M;
    int A[M], B[M];
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
    }

    int par[N+1]; // 根を保存
    int size[N+1];
    for (int i = 1; i <= N; i++) {
        par[i] = i;
        size[i] = 1;
    }

    long ans[M];
    ans[M-1] = N*(N-1) / 2; // nC2
    for (int i = M-1; i >= 0; i--) {
        if (isSameRoot(par, A[i], B[i])) {
            ans[i-1] = ans[i];
        } else {
            ans[i-1] = ans[i] - size[root(par, A[i])] * size[root(par, B[i])];
            unite(par, size, A[i], B[i]);
        }
    }

    for (int i = 0; i < M; i++) {
        cout << ans[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3712
import numpy as np
N = int(input())
nList = [int(input()) for _ in range(N)]
maxN = max(nList)
lenMaxN = np.argmax(nList)
ansList = [maxN for _ in range(N)]
if nList.count(maxN) >= 2:
    for i in range(N):
        print(ansList[i])

else:
    second = sorted(set(nList))[-2]
    ansList[lenMaxN] = second
    for i in range(N):
        print(ansList[i])


Measured memory_bytes: 28988
// E - Coprime
#include <bits/stdc++.h>
using namespace std;
#define MAX_A 1'000'001
int N;
vector<int> A, C(MAX_A, 0);

// 素数と個数を求める
vector<pair<int,int>> factorize(int n){
  vector<pair<int,int>> res;
  for(int i=2; i*i<=n; ++i){
    if (n%i) continue;
    res.emplace_back(i,0);
    while(n%i == 0){
      n /= i;
      res.back().second++;
    }
  }
  if(n != 1) res.emplace_back(n,1);
  return res;
}

string solve(){
	int max_c = 0;
	for(int a:A)
		for(auto p:factorize(a)) max_c = max(max_c, ++C[p.first]);
	if(max_c <= 1) return "pairwise";
	else if(max_c <= N-1) return "setwise";
	return "not";
}

int main(){
	cin>>N;
	A.resize(N); for(int i=0; i<N; ++i) cin>>A[i];
	cout<< solve() <<" coprime\n";
}


Measured memory_bytes: 11124
import sys
sys.setrecursionlimit(10**7)
n = int(input())
graph = {i:[] for i in range(n+1)}
for j in range(n-1):
    x, y = [int(i) for i in sys.stdin.readline().split()]
    x -= 1
    y -= 1
    graph[x].append(y)
    graph[y].append(x)

memo_ls = [[None for j in range(2)] for i in range(n+1)]
# i番目の人がj色の時の通り数 0 : 白
cur = 0
def dfs(cur, col, last):
    if memo_ls[cur][col] is not None:
        return memo_ls[cur][col]
    next_col_num = 1 if col == 1 else 2
    _sum = 1
    cnt = 0
    for _next in graph[cur]:
        if _next == last:
            continue
        cnt += 1
        res = 0
        for next_col in range(next_col_num):
            res += dfs(_next, next_col, cur)
        _sum *= max(1, res)
    if cnt == 0:
        memo_ls[cur][col] = 1
        return 1
    res = _sum % (10 ** 9 + 7)
    memo_ls[cur][col] = res
    return res
res = dfs(0,0,-1) + dfs(0,1,-1)
print(res % (10**9+7))

Measured memory_bytes: 127200
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}	
	}
	return true;
}
int main()
{
   ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);
ll n;
cin>>n;
vector<ll>vi;
for(ll i=0;i<=130;i++)
{
	vi.pb(pow(i,5));
}
vector<ll>vii;
for(ll i=0;i>=-130;i--)
{
	vii.pb(pow(i,5));
}
for(int i=0;i<vi.size();i++)
{
	for(int j=0;j<vi.size();j++)
	{
		if(vi[i]-vi[j]==n)
		{
			cout<<i<<" "<<j<<endl;
			return 0;
		}
		if(vi[j]-vi[i]==n)
		{
			cout<<j<<" "<<i<<endl;
			return 0;
		}
	}
}
for(int i=0;i<vii.size();i++)
{
	for(int j=0;j<vii.size();j++)
	{
		if(vii[i]-vii[j]==n)
		{
			cout<<i<<" "<<j<<endl;
			return 0;
		}
		if(vii[j]-vii[i]==n)
		{
			cout<<j<<" "<<i<<endl;
			return 0;
		}
	}
}
for(int i=0;i<vi.size();i++)
{
	for(int j=0;j<vii.size();j++)
	{
		if(vi[i]-vii[j]==n)
		{
			cout<<i<<" "<<-(j)<<endl;
			return 0;
		}
		if(vi[j]-vii[i]==n)
		{
			cout<<j<<" "<<i<<endl;
			return 0;
		}
	}
}
}



Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;			
	   
int main() {
			fast
			// #ifndef ONLINE_JUDGE
			// freopen("input.txt","r",stdin);
			// freopen("output.txt","w",stdout);
			// #endif

			ll t;
			t=1;
			while(t--)
			{
				ll n;
				cin>>n;
				map<string,ll>id;
				id["AC"]=0;
				id["WA"]=0;
				id["TLE"]=0;
				id["RE"]=0;
				while(n--)
				{
					string x;
					cin>>x;
					id[x]+=1;
				}

				cout<<"AC x "<<id["AC"]<<endl;
				cout<<"WA x "<<id["WA"]<<endl;
				cout<<"TLE x "<<id["TLE"]<<endl;
				cout<<"RE x "<<id["RE"]<<endl;
			}
			return 0;
		 }	




Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

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

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,cnt=0,ans=0;
    map<ll,ll> mp;
    cin >> n;
    vll a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    rep(i,n){
        cnt++;
        if(a[i]!=a[i+1] || i==n-1){
            if(cnt<a[i]) ans+=cnt;
            else ans+=cnt-a[i];
            cnt=0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 310, LOG=20;

int n, m, k, L, u, v, x, y, t, a, b;
int G1[MAXN][MAXN];
int G2[MAXN][MAXN];

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	memset(G1, 63, sizeof(G1));
	memset(G2, 63, sizeof(G2));
	for (int i=0; i<MAXN; i++) G1[i][i]=G2[i][i]=0;
	cin>>n>>m>>L;
	while (m--){
		cin>>u>>v>>x;
		G1[u][v]=G1[v][u]=x;
	}
	for (int k=1; k<=n; k++) for (int i=1; i<=n; i++) for (int j=1; j<=n; j++) G1[i][j]=min(G1[i][j], G1[i][k]+G1[k][j]);
	for (int i=1; i<=n; i++) for (int j=1; j<=n; j++) if (i!=j && G1[i][j]<=L) G2[i][j]=1;
	for (int k=1; k<=n; k++) for (int i=1; i<=n; i++) for (int j=1; j<=n; j++) G2[i][j]=min(G2[i][j], G2[i][k]+G2[k][j]);
	for (int i=1; i<=n; i++) for (int j=1; j<=n; j++) if (G2[i][j]>=inf) G2[i][j]=0;
	cin>>m;
	while (m--){
		cin>>u>>v;
		cout<<G2[u][v]-1<<'\n';
	}
	
	
	return 0;
}


Measured memory_bytes: 1280
import sys
sys.setrecursionlimit(1000000)
n=int(input())
g=[[] for _ in range(n)]
for _ in range(n-1):
    a,b,c=map(int,input().split())
    g[a-1].append((b-1,c))
    g[b-1].append((a-1,c))
q,k=map(int,input().split())
d=[-1]*n
def f(k,c):
    d[k]=c
    for i,v in g[k]:
        if d[i]==-1:
            f(i,c+v)
f(k-1,0)
for _ in range(q):
    x,y=map(int,input().split())
    print(d[x-1]+d[y-1])

Measured memory_bytes: 131632
n=int(input())
s=input()
count=0
for i in range(10):
    for j in range(10):
        for k in range(10):
            num=str(i)+str(j)+str(k)
            a=s.find(num[0])
            if (a==-1):
                continue
            b=s[a+1::].find(num[1])
            if (b==-1):
                continue
            c=s[a+b+2::].find(num[2])
            if (c==-1):
                continue
            count+=1
            #print(num,a,b,c)
        ##
    ##
##
print(count)

Measured memory_bytes: 3064
n=int(input())
lab=[]
for i in range(n):
  ab=list(map(int,input().split()))
  lab.append(ab)
  
lab.sort(key=lambda x:(x[1],x[0]))

sum1=0
for i in lab:
  sum1+=i[0]
  if sum1>i[1]:
    print('No')
    exit()
    
print('Yes')
  

Measured memory_bytes: 59592
import java.util.*

fun main(args: Array<String>) {
    val (n, m) = readLine()?.split(" ")?.map(String::toInt) ?: return
    val a = readLine()?.split(" ")?.map(String::toLong) ?: return
    val queue = PriorityQueue<Long>(n, Comparator { o1, o2 -> (o2 - o1).toInt() })
    queue.addAll(a)
    repeat(0.until(m).count()) {
        val f = queue.poll() / 2
        queue.offer(f)
    }

    println(queue.sum().toString())
}



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

//B

int main() {
	// your code goes here
	int n,i,w[105],ans=100000,s=0,s1=0,s2=0;
	cin >> n;
	for(i=1;i<=n;i++) {
		cin >> w[i];
		s+=w[i];
	}
	s2=s; ans=min(ans,s2);
	for(i=1;i<=n;i++){
		s1+=w[i];
		s2-=w[i];
		ans=min(ans,abs(s1-s2));
	}
	cout << ans << endl;
	return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

bool dpx[8000][16001];
bool dpy[8000][16001];
int main()
{
	string S;
	int x, y;
	cin >> S >> x >> y;

	vec(A);
	fx(S.size()) {
		int y = x;
		while (x<S.size()&&S[x]=='F') {
			x++;
		}
		pb(A,x-y)
	}
	dpx[0][A[0]+8000] = true;
	dpy[0][8000] = true;
	int dx = 0, dy = 0;
	for (int i = 2; i < A.size(); i += 2) {
		fz(16001) {
			if (dpx[i/2-1][z]) {
				dpx[i / 2][z - A[i]] = true;
				dpx[i / 2][z + A[i]] = true;
				dx = i / 2;
			}
		}
	}

	for (int i = 1; i < A.size(); i += 2) {
		fz(16001) {
			if (dpy[i / 2][z]) {
				dpy[i / 2 + 1][z - A[i]] = true;
				dpy[i / 2 + 1][z + A[i]] = true;
				dy = i / 2 + 1;
			}
		}
	}
	
	if (dpx[dx][x+8000]&&dpy[dy][y+8000]) {
		cey;
	}
	else {
		cen;
	}

    return 0;
}



Measured memory_bytes: 125824
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i
menu = [a,b,c,d,e]
naga = []

for i in menu
naga.push(i%10)
end

sum = 0
while true
 indx = naga.index(naga.min)
  if naga[indx] == 0
  naga.delete_at(indx)
  sum += menu.delete_at(indx)
 else
  break
 end
 if naga.length == 0
 break
end
end

if naga.length > 1
while naga.length>1 do
  indx = naga.index(naga.max)
  sum += (((menu.delete_at(indx)-1)/10)+1)*10
  naga.delete_at(indx)
end

sum += menu[0]
end
puts sum

Measured memory_bytes: 1788
#include<iostream>
#include<stdio.h>
#include<string>
#include <math.h>
using namespace std;
# define maxn 200000

int main(){
  int a,b;
  cin>>a>>b;
  if(a>=13){
    cout<<b;
  }else if(a >=6){
    cout<<b/2;
  }else{
    cout <<0;
  }
  // long long a,b,x,cnt(0);
  // cin>>a>>b>>x;
  // cout<<(b/x)-(a/x);
  // int n,a[maxn],b[maxn],cnt(0),sum(0);
  // cin>>n;
  // for(int i(0);i<n;i++){
  //   cin>>a[i]>>b[i];
  // }
  // for(int i(0);i<n;i++){
  //   if(a[i]==b[i]){
  //     cout << -1<<endl;
  //   }else{
  //     cout << abs(a[i] - b[i])<<endl;
  //   }
  // }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true){
			int a = sc.nextInt();
			int b = sc.nextInt();
			if( a == 0 && b == 0 ) break;
			if( a > b){a^=b;b^=a;a^=b;}
			System.out.println(a+" "+b);
		}
	}
}

Measured memory_bytes: 12000
//https://atcoder.jp/contests/abc165/tasks/abc165_a
//2020-05-02
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    int k,a,b;
    cin >>  k >> a >> b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

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

using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class T> ostream& operator<<(ostream &os, set<T> S){os << "{ "; for(auto s:S) os<<s<<" "; return os<<"}";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {os << "{ "; for(auto m:M) os<<"("<<m.first<<":"<<m.second<<") "; return os<<"}";}
#ifdef np
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>void __f(const char *name, Arg1 &&arg1) { cout<<name<<" : "<<arg1<<endl;}
template<typename Arg1, typename ... Args>void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma=strchr(names+1,','); cout.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif


int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
	
	ll a, b; cin>>a>>b;
    cout<<lcm(a,b)<<endl;
    

#ifdef np
    cerr <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
 return 0; 
 }


Measured memory_bytes: 256
n, m = map(int, input().split())
a = []
b = []
c = []
for i in range(n):
    a.append(list(map(int, input().split())))
for i in range(m):
    b.append(int(input()))
for i in range(n):
    elm = 0
    for k in range(m):
        elm += a[i][k] * b[k]
    c.append(elm)
for i in c:
    print(i)


Measured memory_bytes: 5980
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	cin >> N >> M;
	vector< int > A(N), B(M);
	rep(i, N) cin >> A[i];
	rep(j, M) cin >> B[j];
	vector< int > AI(1000010, 0);
	vector< int > BI(1000010, 0);
	rep(i, N) AI[A[i]]++;
	rep(j, M) BI[B[j]]++;
	rep(i, AI.size()) {
		if (AI[i] > 1) {
			cout << 0 << endl;
			return 0;
		}
	}
	rep(j, BI.size()) {
		if (BI[j] > 1) {
			cout << 0 << endl;
			return 0;
		}
	}
	vector< int > acAI(1000010, 0);
	vector< int > acBI(1000010, 0);
	for (int i = 1; i < acAI.size(); i++)
		acAI[i] = acAI[i - 1] + AI[i];
	for (int j = 1; j < acBI.size(); j++)
		acBI[j] = acBI[j - 1] + BI[j];
	int ans = 1;
	for (int k = N * M; k > 0; k--) {
		if (AI[k] && BI[k])
			continue;
		else if (AI[k]) {
			ans *= (M - acBI[k - 1]);
		} else if (BI[k]) {
			ans *= (N - acAI[k - 1]);
		} else {
			ans *= ((N - acAI[k - 1]) * (M - acBI[k - 1]) - N * M + k);
		}
		ans %= MOD;
		//cout << ans << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 31616
n = int(input())
X = list(map(int,input().split(' ')))
X2 = X.copy()
X2.sort()
Xminor = X2[int(n/2)]
Xmajor = X2[int(n/2)-1]
for x in X:
    if x < Xminor:
        print(Xminor)
    else:
        print(Xmajor)

Measured memory_bytes: 25472
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;
 
typedef long long ll;
typedef pair < int , int > ii;
 
int a,b;
 
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    
    cin >> a >> b;
    if(a % b == 0)
        cout << a / b;
    else 
        cout << a / b + 1;

    return 0;
} 

Measured memory_bytes: 256
processnum,process_time = list(int(element) for element in input().split())

processes = []
process2time = {}
elapsed_time = 0

for _ in range(int(processnum)):
  process, remaining_time = input().split()
  processes.append(process)
  process2time[process] = int(remaining_time)

while processes:
  new_processes = []
  for process in processes:
    if process2time[process] > process_time:
      elapsed_time += process_time
      process2time[process] -= process_time
      new_processes.append(process)
    else:
      elapsed_time += process2time[process]
      print(process + ' ' + str(elapsed_time))

  processes = new_processes


Measured memory_bytes: 11968
#include <stdio.h>
#include <math.h>
 
int main(void) {
    int n;
    while (scanf("%d", &n) == 1 && n != 0) {
        double s[1024];
        int i;
        double average = 0, sd = 0;
        for (i = 0; i < n; i++) {
            if (scanf("%lf", &s[i]) != 1) return 1;
            average += s[i];
        }
        average /= n;
        for (i = 0; i < n; i++) {
            sd += (s[i] - average) * (s[i] - average);
        }
        printf("%.15f\n", sqrt(sd / n));
    }
    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = 998244353;
const long long INF_LL = 1e18+11; const int INF_int = 1e9+11;
#define ll long long
#define mp std::make_pair
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto x:a) cout << x << " ";cout << endl;
int main(){
    int a = 0;
    string s;
    cin >> s;
    rep(i,s.size()) a+=int(s[i]-'0');
    if(a%9==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3720
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll h,n;
cin>>h>>n;
vector<ll>v;
ll sum=0;
for(ll i=0;i<n;i++)
{
    ll a;
    cin>>a;
    v.pb(a);
    sum+=a;
}
if(h-sum<=0)
{
    cout<<"Yes"<<endl;
}else
{
    cout<<"No"<<endl;
}
return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
using namespace std;

typedef string::const_iterator State;

const size_t N = 3e6+100;
ll n,ans;
ll mem[N],nxt[N];
char s[N];
ll INF = 1e9+10;
ll number(int &i){
    ll res = 0;
    while(isdigit(s[i]))res=res*10+s[i++]-'0';
    return res;
}
ll expr(int &i);
ll factor(int &i,bool flag=true){
    if(s[i]=='('){
        if(!flag){
            ll res = mem[i];
            i = nxt[i];
            return res;
        }
        int st = i;
        i++;
        ll res = expr(i);
        mem[st] = res;
        nxt[st] = ++i;
        return res;
    }
    else return number(i);
}
ll expr(int &i){
    int l = i;
    ll res = factor(i);
    ll tmp = res;
    deque<ll> dq{res};
    ll cnt = 0;
    for(;;){
        while(tmp > n){
            cnt = 0;
            ll now = factor(l,0);
            if(s[l] == '+'){
                tmp -= now;
                dq.pop_front();
                l++;
            }
            else if (s[l] == '*'){
                tmp -=dq.front();
                dq.front() /= now;
                tmp += dq.front();
                l++;
            }
            else break;
        }
        if(tmp == n and l<i){
            int L = l;
            while(L<i-1){
                if(factor(L,0) == 1){
                    if(L<i and s[L]=='*'){
                        L++;cnt++;
                    }
                    else break;
                    l = L;
                }
                else break;
            }
            ans += cnt+1;
        }
        if(s[i] == '+'){
            i++;
            dq.push_back(factor(i));
            res+=dq.back();
            tmp+=dq.back();
        }
        else if(s[i] == '*'){
            i++;
            tmp -= dq.back();
            res -= dq.back();
            dq.back() *= factor(i);
            tmp += dq.back();
            res += dq.back();
        }
        else break;
    }
    if(res>INF)res = INF;
    return res;
}


    
    
#define pb push_back

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);cout<<fixed<<setprecision(15);
    while(1){
        cin >> n;
        if(!n)exit(0);
        string t;cin>>t;
        int sz = t.size();
        rep(i,sz)s[i]=t[i];
        ans = 0;
        int now = 0;
        expr(now);
        rep(i,sz)s[i]=' ';
        cout<<ans<<endl;
    }

}


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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    int odd = 0;
    for (int ai: a) if (ai & 1) odd++;
    cout << (odd % 2 == 0 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 640
#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ar array


void solve(){
    int n, x, t;
    cin >> n >> x >> t;
    int val = n/x;
    if(n%x != 0) val++;
    cout << t*val << "\n";     
}

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

    int TC = 1;
    while(TC--)
        solve();        
    
    return 0;
}



Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(a>=b&&a>=c){
		for(int i=0;i<k;i++){
	    	a=a*2;
		}
		cout<<a+b+c;	
	}
	else if(b>=a&&b>=c){
		for(int i=0;i<k;i++){
	    	b=b*2;
		}
		cout<<a+b+c;	
	}
	else if(c>=a&&c>=b){
		for(int i=0;i<k;i++){
	    	c=c*2;
		}
		cout<<a+b+c;	
	}
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<int,int>
const int N = 1e5+4 , M=N,inf=(int)1e9;
const ll mod=1e9+7;
int fastAbs(int n) { return (n ^ (n >> 31)) - (n >> 31); }
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
int ans = INT_MAX;
map< pair<int,int> , int > mp;
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
void solve(){
	int  n , k ;
	cin >> n >> k ;
	vector < int > a(n);
	for( int i = 0 ; i < n ;i++)	cin >> a[i] ;
	vector < vector < ll > > dp(n,vector < ll > (k+1,0));
	for( int i = 0 ; i <=a[0];i++){
		dp[0][i]=1;
	}
	vector < ll > prefix(k+1,0);
	prefix[0] = 1 ;
	for( int i = 1 ; i <= k ; i++){
		prefix[i] = add(dp[0][i],prefix[i-1]);
	}
	for( int i = 1 ; i < n ; i++){
		for( int j = 0 ; j <= a[i] ; j++){
			dp[i][j] = prefix[j];
		}
		for( int j = a[i]+1 ; j <= k ; j++){
				dp[i][j] = sub(prefix[j],prefix[j-a[i]-1]);
		}
		prefix[0]=dp[i][0];
		for( int j = 1 ; j <= k ; j++){
			prefix[j] = add(dp[i][j],prefix[j-1]);
		}
	}
	/*for( int i = 0 ; i < n ; i++){
			for( int j = 0 ; j <= k ; j++){
				cout << dp[i][j] << " ";
			}
			cout <<"\n";
	}*/
	cout << dp[n-1][k] ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}


Measured memory_bytes: 79488
#include<cctype>
#include<cstdio>

using namespace std;

int main(){
	for(char s[501];scanf("%s",s),s[0]!='#';){
		bool ok=false;
		for(int i=0,c=0,a[3];s[i];i++){
			if(isalpha(s[i])) a[c++]=(s[i-1]=='~'?-1:1)*s[i];
			if(c==3){
				if(a[0]+a[1] && a[1]+a[2] && a[2]+a[0]) ok=true;
				c=0;
			}
		}
		puts(ok?"yes":"no");
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<climits>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX 100005

ll dp[MAX];
vector<ll>graph[MAX];
ll n,m;

ll solve(int src){
    if(src>n) return 0;

    if(dp[src] != -1) return dp[src];

    ll ans=0;
    for(int i=0; i<graph[src].size(); i++){
        ans = max(ans, 1+solve(graph[src][i]));
    }
    dp[src]=ans;
    return dp[src];
}

int main(){
    cin>>n>>m;
    for(int i=1; i<=m; i++){
        ll x,y;
        cin>>x>>y;
        graph[x].push_back(y);
    }
    memset(dp, -1, sizeof(dp));
    ll ans=0;
    for(int i=1; i<=n; i++){
        ans = max(ans, solve(i));
    }    
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 8576
W,H,N=map(int,input().split())
x=[]
y=[]
a=[]
w=[i for i in range(W+1)]
h=[i for i in range(H+1)]
S=W*H

for _ in range(N):
    X, Y, A = map(int, input().split())
    x.append(X)
    y.append(Y)
    a.append(A)

for i in range(len(x)):
    if a[i]==1 and len(w)!=0:
        for j in range(x[i]):
            if j in w: w.remove(j)
    if a[i]==2 and len(w)!=0:
        for j in reversed(range(x[i]+1,w[-1]+1)):
            if j in w: w.remove(j)
    if a[i]==3 and len(h)!=0:
        for j in range(y[i]):
            if j in h: h.remove(j)
    if a[i]==4 and len(h)!=0:
        for j in reversed(range(y[i]+1,h[-1]+1)):
            if j in h: h.remove(j)
if len(w)==0 or len(h)==0:
    print(0)
else:
    S_f = (w[-1]-w[0]) * (h[-1]-h[0])
    print(S_f)


Measured memory_bytes: 3192
n = int(input())
lst = [int(i) for i in input().split()]
lst_sort = sorted(lst)
med = (lst_sort[n//2] + lst_sort[n//2-1])/2

for i in range(n):
    if lst[i] < med:
        print(lst_sort[n//2])
    else:
        print(lst_sort[n//2-1])

Measured memory_bytes: 25224
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	int n;
	cin >> n;
	ll sum = 0;
	vector<ll>a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	ll ans =3 * inf;
	ll sunuke = 0;
	for (int i = 0; i < n-1; i++) {
		sunuke += a[i];
		ll arai = sum - sunuke;
		ans = min(ans, abs(sunuke - arai));	
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1792
n = int(input())
s = input()
was = [0] * n
if s[0] == 'W':
  was[0] = 1
for i in range(1, n):
  if s[i] == 'W':
    was[i] = was[i - 1] + 1
  else:
    was[i] = was[i - 1]
result = (n - 1) - (was[n - 1] - was[0])
for i in range(1, n):
  result = min(result, was[i - 1] + ((n - (i + 1)) - (was[n - 1] - was[i])))
print(result)


Measured memory_bytes: 15260
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char ch[3],ch2[3];
    int cnt=0;
    scanf("%s %s",ch,ch2);
    for(int i=0;i<3;i++)
    {
        if(ch[i]==ch2[i])
            cnt++;
    }
    printf("%d",cnt);
    return 0;
}


Measured memory_bytes: 256