akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
import java.lang.*;

class Main {
	static final String YES = "Yes";
	static final String NO = "No";

	public static void main(String[] args) {
		final FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		while (n > 0) {
			if (n % 10 == 7) {
				System.out.println(YES);
				return;
			}
			n /= 10;
		}
		System.out.println(NO);
	}

	static class FastScanner {
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		public FastScanner(InputStream source) {
			in = source;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte()) return buffer[ptr++];
			else return -1;
		}

		private static boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (true) {
    c -= b;
    if (c <= 0) {
      cout << "Yes" << endl;
      break;
    }
    a -= d;
    if (a <= 0) {
      cout << "No" << endl;
      break;
    }
  }
}


Measured memory_bytes: 3648
n,k=map(int,input().split())
a=list(map(lambda x:(int(x)-1)%k,input().split()))
a_=0
cs_a=[0]
for ai in a:
  a_+=ai
  a_%=k
  cs_a.append(a_)
ans=0
from collections import defaultdict
d=defaultdict(int)
for i in range(n+1):
  ans+=d[cs_a[i]]
  d[cs_a[i]]+=1
  if i>=k-1:
    d[cs_a[i-k+1]]-=1
print(ans)


Measured memory_bytes: 40808
function Main(input){
	var args = input.split(/\n|\s/g);
	var N = parseInt(args[0],10);
var result = 'No';
for(let i=0;i<=N;i+=4){
  if((N-i)%7===0){result='Yes';break;}
}
  console.log(result);
}
Main(require('fs').readFileSync('/dev/stdin','utf8')); 

Measured memory_bytes: 7372
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc158/tasks/abc158_c>
 問題文============================================================
 C - Tax Increase
 =================================================================
 解説=============================================================
 
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int A,B; cin >> A >> B;
    
    for(int X = 0; X <= 2000; X++){
        int cA = X*8/100;
        int cB = X*10/100;
        
        if(cA == A && cB == B) return X;
    }
    res = -1;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
#define MOD1 1000000007
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){
    return *(ll *)a>*(ll *)b?1:*(ll *)a<*(ll *)b?-1:0;}

int main(void){
    ll x,y,ans=0;
    scanf("%lld%lld",&x,&y);
    if( x*y>0){
        if(x<=y) ans=y-x;
        else ans=x-y+2;
    }
    if(x*y<0){
        ans=max2(ABS(y),ABS(x)) - min2(ABS(y),ABS(x)) +1;
    }
    if(x*y==0){
        ans=(x<=y)?y-x:x-y+1;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,n)cin>>a[i];

	
	vector<int> b(n);
	vector<int> ans;
	for(int i=n-1;i>=0;--i)
	{
		int sum=0;
		for(int j=i;j<n;j+=i+1)
		{
			sum+=b[j];
		}
		//cout<<b[5]<<endl;
		//cout<<sum<<":"<<a[i]<<endl;
		if(sum%2!=a[i])
		{
			b[i]++;
			ans.push_back(i+1);
		}	
	}
	//rep(i,n)cout<<b[i];
	cout<<ans.size()<<endl;
	rep(i,ans.size())
	cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

int main() {
    FAST_IO();
    int N; cin >> N;
    vector<vector<int>> id(N + 1, vector<int> (N + 1));
    int vertex_num = 0;
    repp(i, 1, N) repp(j, i + 1, N) {
        // match (i-j)-th vertex number : id[i][j] = id[j][i]
        id[i][j] = id[j][i] = ++vertex_num;
    }
    vector<int> indegree(vertex_num + 1, 0);
    vector<int> A(N - 1);
    vector<vector<int>> adj(vertex_num + 1);
    repp(i, 1, N) {
        rep(j, N - 1) cin >> A[j];
        rep(j, N - 2) {
            adj[id[i][A[j]]].push_back(id[i][A[j + 1]]);
            indegree[id[i][A[j + 1]]]++;
        }
    }
    int day = 0, match = 0;
    // topology_sort
    vector<int> tbr;
    repp(i, 1, vertex_num) {
        if(indegree[i] == 0) {
            tbr.push_back(i);
        }
    }
    while(sz(tbr) != 0) {
        ++day;
        match += sz(tbr);
        vector<int> nextTbr;
        for(auto &here : tbr) {
            for(auto &next : adj[here]) {
                if(--indegree[next] == 0) nextTbr.push_back(next);
            }
        }
        tbr = nextTbr;
    }
    if(match == vertex_num) {
        cout << day << "\n";
    } else {
        cout << "-1\n";
    }
}

Measured memory_bytes: 33536
import itertools

n = int(input())
ans_d = {i: 0 for i in range(1,10001)}

p = itertools.product(range(1, 100), range(1, 100), range(1, 100))

for x, y, z in p:
    cnt = (x ** 2) + (y ** 2) + (z ** 2) + (x * y) + (y * z) + (x * z)
    if cnt <= 10000:
        ans_d[cnt] += 1

for i, j in ans_d.items():
    print(j)
    if i == n:
        break

Measured memory_bytes: 9912
/**
 * author:    Ziel
 * created:   15.04.2020 21:45:28
**/

// ~zaletaet~

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back

using namespace std;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const double EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int h, w;
char a[25][25];

inline bool in_range(int x, int y) {
	return x >= 0 && x < h && y >= 0 && y < w;
}

inline int bfs(int i, int j) {
	queue<ii> q;
	q.push(make_pair(i, j));
	int d[25][25];
	bool was[25][25];
	for (int ii = 0; ii < 24; ii++) for (int jj = 0; jj < 24; jj++) d[ii][jj] = -1, was[ii][jj] = false;
	d[i][j] = 0;
	was[i][j] = true;
	
	while (sz(q)) {
		int x = q.front().fi;
		int y = q.front().se;
		
		for (int k = 0; k < 4; k++) {
			if (in_range(x + dx[k], y + dy[k]) && !was[x + dx[k]][y + dy[k]] && a[x + dx[k]][y + dy[k]] == '.') {
				q.push({x + dx[k], y + dy[k]});
				was[x + dx[k]][y + dy[k]] = true;
				d[x + dx[k]][y + dy[k]] = d[x][y] + 1;
			}
		}
		
		q.pop();
	}
	
	int res = -1;
	for (int ii = 0; ii < 24; ii++) for (int jj = 0; jj < 24; jj++) res = max(res, d[ii][jj]);
	
	return res;
}

main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	cin >> h >> w;
	
	for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) cin >> a[i][j];
	
	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') continue;
			int res = bfs(i, j);
			ans = max(ans, res);
		}
	}
	
	cout << ans;
	return 0;
}



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

using namespace std;

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

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

  int Y;
  cin >> Y;
  int M=-1, G=-1, S=-1;

  int total=0;

  for(int i = 0; i < N+1; i++){
    for(int j = 0; j < N-i+1; j++){
      total = i * 10000 + j * 5000 + (N-i-j) * 1000;
      if(total == Y){
        M = i; G = j; S = N-i-j;
      }
    }
  }

  cout << M << " " << G << " " << S << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
	int a,b=1,d;
	bool c=0;
	cin>>a;
	vector<int> v;
	v.push_back(a);
	while(true){
		b++;
		if(a%2==0){
			a=a/2;
		}
		else{
			a=a*3+1;
		}
		if(find(v.begin(),v.end(),a)!=v.end()){
			break;
		}
		v.push_back(a);
	}
	cout<<b<<endl;
	return 0;
}

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

using namespace std;

const int maxx = 1e5 + 20;

int n, k, mxh[maxx], a[maxx], ans = 0;
bool vis[maxx];
vector<int> adj[maxx];

void dfs(int root)
{
	vis[root] = true;
	for(int x:adj[root])
	{
		if (vis[x]) continue; 
		dfs(x);
		if (mxh[x] == k - 1 && root) ans++;
		else	mxh[root] = max(mxh[root], mxh[x] + 1);
	}
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> a[i];
	if (k == 1) 
	{
		for(int i = 0; i < n; i++) if (a[i] != 1) ans++;
		return cout << ans << endl, 0;
	}
	if (a[0] != 1) a[0] = 1, ans++;
	for(int i = 1; i < n; i++)
	{
		adj[i].push_back(a[i] - 1);
		adj[a[i] - 1].push_back(i);
	}
	dfs(0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
int c[9];
int main(){
  for(int i=0;i<9;i++)cin>>c[i];
  puts(c[1]-c[0]==c[4]-c[3]&&c[1]-c[0]==c[7]-c[6]&&c[2]-c[1]==c[5]-c[4]&&c[2]-c[1]==c[8]-c[7]?"Yes":"No");
}

Measured memory_bytes: 256
def get_node(num):
    now_num = 1
    count = 1
    while 1:
        if now_num > num:
            count -= 1
            break
        count += 1
        now_num *= 2
    return count

def get_ans_data(node_num):
    ans_data = []
    for i in range(1, node_num):
        data = [i, i + 1, 2**(i - 1)]
        data2 = [i, i + 1, 0]
        ans_data.append(data)
        ans_data.append(data2)
    return ans_data

def main():
    num = int(input())

    node_num = get_node(num)
    ans_data = get_ans_data(node_num)

    now_path = 2 ** (node_num - 1)
    now_num = node_num - 1


    for i in range(now_num, 0, -1):
        now_data = 2 ** (i - 1)
        if num - now_data >= now_path:
            ans_data.append((i, node_num, num - now_data))
            num -= now_data

    print(node_num, len(ans_data))
    for data in ans_data:
        print(' '.join(list(map(str, data))))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, sum=0;
  cin >> N;
  
  for (int i=0; i<N; i++){
    int l,r;
    cin >> l >> r;
    sum += r-l+1;
    if (i<N-1){
    continue;
    }
    else{
    cout << sum << endl;
    }    
  } 
}

Measured memory_bytes: 256
N = int(input())

answer = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}
for i in range(N):
    s = input()
    answer[s] = answer.get(s, 0) + 1

print('AC x ' + str(answer['AC']))
print('WA x ' + str(answer['WA']))
print('TLE x ' + str(answer['TLE']))
print('RE x ' + str(answer['RE']))

Measured memory_bytes: 9200
N = int(input())

sumsum = 0
for i in range(N):
    
    val = i+1
    if val % 3 == 0 & val % 5 == 0:
        
        pass
        #print('FizzBuzz')
    
    elif val % 3 == 0:
        
        pass
        #print('Fizz')
    
    elif val % 5 == 0:
        
        pass
        #print('Buzz')
        
    else:
        
        sumsum += val
        
print(sumsum)

Measured memory_bytes: 9172
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;
const double pi = acos(-1.0);
#define LL long long

int main()
{

    double a,b,x;
    while(~scanf("%lf%lf%lf",&a,&b,&x))
    {

        double z = x/a;
        if(z<=(a*b/2))

        {
            z = z*2/b;
            double k  = sqrt( z*z + b*b);

            printf("%.10lf\n",90-asin(z/k)*180/pi);
        }
        else
        {

            z = z*2/a-b;

            printf("%.10lf\n",atan((b-z)/a)*180/pi);
        }
    }
}


Measured memory_bytes: 256
def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j][1] <= x[1]:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1

def quickSort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quickSort(A, p, q-1)
        quickSort(A, q+1, r)

n = int(input())
A = []
for i in range(n):
    x, y = input().split()
    A.append([x, int(y)])
    
B = A[:]

quickSort(A, 0, n - 1)

for i in range(n - 1):
    if A[i][1] == A[i + 1][1]:
        if B.index(A[i]) > B.index(A[i + 1]):
            print("Not stable")
            break
else:
    print("Stable")
  
for i in A:
    print(*i)         


Measured memory_bytes: 18844
#include <cstdio>
#include <vector>
#include <numeric>
#include <cmath>

using namespace std;

int main() {
    int n;
    double sum, avg, disp, std_dev;
    vector<int> scores;
    
    scanf("%d", &n);
    
    while(n != 0) {
        disp = 0;
        scores.resize(n);
        
        for(int i = 0;i < n;i++) {
            scanf("%d", &scores[i]);
        }
        
        sum = accumulate(scores.begin(), scores.end(), 0);
        avg = sum / n;
        
        for(int i = 0;i < n;i++) {
            disp += pow(scores[i] - avg, 2);
        }
        
        disp /= n;
        std_dev = sqrt(disp);
        
        printf("%lf\n", std_dev);
        
        scores.clear();
        scanf("%d", &n);
    }
    
    return 0;
}


Measured memory_bytes: 2680
// Problem : F - Mirrored
// Contest : AtCoder Regular Contest 075
// URL : https://atcoder.jp/contests/arc075/tasks/arc075_d
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define cerr if(1)cerr
#define size(x) (int)x.size()
#define all(x) x.begin(), x.end()

const int N = 1e6 + 1, mod = 1e9 + 7, inf = 2e9;

int d;
ll pw = 1, ans = 0;

ll solve(ll d, ll p, bool leading) {
	if (!p) return !d;
	ll ans = 0;
	int c = (d % 10 + 10) % 10;
	ans += (10 - c - leading) * solve((d - c * p) / 10, p / 100, 0);
	ans += (c - leading) * solve((d + (10 - c) * p) / 10, p / 100, 0);
	return ans;
}

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> d;
	if (d % 9) {
		return cout << 0, 0;
	}
	d /= 9;
	for (int i = 2; i <= 18; i++) {
		pw *= 10;
		ll res = solve(d, pw / 9, 1);
		if (i & 1) {
			res *= 10;
		}
		ans += res;
	}
	cout << ans;
}


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

const static ll MOD = (1e+9)+7;

ll get_keta(ll a){
    return (ll)log10(a)+1;
}

int main(){
    ll n;cin>>n;
    ll root_n = pow(n,1.0/2);
    ll max_num = 1;
    rep1(i,root_n){
        if(n % i == 0)max_num=i;
    }
    cout<<max(get_keta(max_num),get_keta(n/max_num))<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int x , a , b;
        Scanner sc = new Scanner(System.in);
        x = sc.nextInt();
        a = sc.nextInt();
        b = sc.nextInt();
        simpleDist(x, a, b);

    }

    private static void simpleDist(int x, int a, int b) {
        int max = 1000, min =1;
        if ((x <= max && a<=max && b<=max) && (x >= min && a >=min && b>=min)  ){
            String res= Math.abs(x-a) < Math.abs(x-b) ? "A" : "B";
            System.out.println(res);
        }
    }
}

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

int main() {
	int buildings[4][3][10] = {{{0}}};
	int n, b, f, r, v;

	cin >> n;

	for (int i = 0; i < n; i++){
		cin >> b >> f >> r >> v;
		buildings[b - 1][f - 1][r - 1] += v;
	}
	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 3; j++){
			for (int k = 0; k < 10; k++){
				cout << " " << buildings[i][j][k];
			}
			cout << endl;
		}
		if (i < 3) cout << "####################" << endl;
	}

	return 0;
}


Measured memory_bytes: 3092
using System;

namespace Atcoder
{
    class ABC124_A
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);

            if(a > b )
            {
                Console.Write(a + (a -1));
            }
            else if(a == b)
            {
                Console.Write(2 * a);
            }
            else
            {
                Console.Write(b + (b -1));
            }
        }
    }
}


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

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

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T> void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U> void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int main()
{
   int H, W; cin >> H >> W;
   auto A = make_v<int>(H, W);
   for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
         cin >> A[i][j];
      }
   }

   int mi = IINF;
   for (int a = 0; a < H; ++a) {
      for (int b = 0; b < W; ++b) {

         int total = 0;
         for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
               total += A[i][j] * min(abs(i-a),abs(j-b));
            }
         }

         chmin(mi, total);

      }
   }

   cout << mi << endl;

   return 0;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    cout << "ABC" << N << endl;
}

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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  int n;
  cin >> n;
  int t = n % 10;
  if (t == 2 || t == 4 || t == 5 || t == 7 || t == 9) {
    cout << "hon\n";
  } else if (t == 0 || t == 1 || t == 6 || t == 8) {
    cout << "pon\n";
  } else {
    cout << "bon\n";
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 3648
num,time = map(int, input().split())
times = [int(n) for n in input().split()]
stop = time
total = 0
for i in range(1,num):
    if times[i]<=stop:
        total += times[i]-times[i-1]
    else:
        total += stop-times[i-1]
    stop = times[i]+time
total += time
print(total)


Measured memory_bytes: 25200
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int main(){
  long h,w,d;
  cin >> h >> w >> d;
  long a;
  long row[h*w+1];
  long col[h*w+1];
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> a;
      row[a]=i;
      col[a]=j;
    }
  }
  long accum[h*w];
  for(long i = 1; i <= h*w; i++){
    if(i<=d){
      accum[i] = 0;
    }else{
      accum[i] = accum[i-d] + abs(row[i]-row[i-d]) + abs(col[i]-col[i-d]);
    }
  }
  long q;
  cin >> q;
  for(long i = 0; i < q; i++){
    long l,r;
    cin >> l >> r;
    cout << accum[r]-accum[l] << endl;
  }
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(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 fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

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

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

int main() {
	int n, K, in1, in2;
	vl x, y,xx,yy;
	cin >> n >> K;
	rep(i, n) {
		cin >> in1 >> in2;
		x.push_back(in1);
		y.push_back(in2);
		xx.push_back(in1);
		yy.push_back(in2);
	}
	sort(all(xx));
	sort(all(yy));
	ll ans = (1ll)*(xx[n-1] - xx[0])*(yy[n-1] - yy[0]);
	rep(i, n) {
		range(j, i + 1, n) {
			rep(k, n) {
				range(l, k + 1, n) {
					int count = 0;
					rep(m, n) {
						if (xx[i] <= x[m] && x[m] <= xx[j] && yy[k] <= y[m] && y[m] <= yy[l]) {
							count++;
						}
					}
					if (count >= K) {
						ll area = (1ll)*(xx[j] - xx[i])*(yy[l] - yy[k]);
						ans = min(ans, area);
					}
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, num = 1;
  cin >> N >> K;
  
  for(int i = 0; i < N; i++){
    int num_2, num_k;
    num_2 = num * 2;
    num_k = num + K;
    if(num_2 < num_k){
      num = num_2;
    }else{
      num = num_k;
    }
  }
  cout << num << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M=109000;
const ll N=309;
const ll INF = 1e17;
ll n,m,l,q;
ll fuel[N][N];
ll dist[N][N];
ll s[M],t[M];
ll A[M], B[M], C[M];
void chmin(ll &a, ll b) {
    if(a>b) a=b;
}   
int main() {
    cin>>n>>m>>l;
    for(int i=1;i<=m;i++) cin>>A[i]>>B[i]>>C[i];
    cin>>q;
    for(int i=1;i<=q;i++) cin>>s[i]>>t[i];
    fill(fuel[0],fuel[0]+N*N,INF);
    fill(dist[0],dist[0]+N*N,INF);
    for(int i=1;i<=n;i++) {
        fuel[i][i]=0;
        dist[i][i]=0;
    }
    for(int i=1;i<=m;i++) {
        chmin(fuel[A[i]][B[i]],C[i]);
        chmin(fuel[B[i]][A[i]],C[i]);
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            for(int k=1;k<=n;k++)
                chmin(fuel[j][k],fuel[j][i]+fuel[i][k]);
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=n;j++) {
            if(i==j) continue;
            if(fuel[i][j]<=l) chmin(dist[i][j],1LL);
        }
    }
    for(int i=1;i<=n;i++) 
        for(int j=1;j<=n;j++) 
            for(int k=1;k<=n;k++) 
                chmin(dist[j][k],dist[j][i]+dist[i][k]);
    for(int i=1;i<=q;i++) {
        if(dist[t[i]][s[i]]<INF) cout<<dist[t[i]][s[i]]-1<<endl;
        else cout<<-1<<endl;
    }    
    return 0;
}

Measured memory_bytes: 4992
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	string s, t;
	cin >> s >> t;
	reverse(s.begin(), s.end());
	if (s == t) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    int f = max(a, max(b, max(c, max(d, e))));
    int g = min(a, min(b, min(c, min(d, e))));
    if (fabs(f - g) > k)
    {
        cout << ":(";
    }
    else
    {
        cout << "Yay!";
    }
}

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n; cin >> n;
    map<int, int> mp;
    rep(i, n) {
        int d; cin >> d;
        mp[d]++;
    }
    int m; cin >> m;
    vector<int> t(m);
    rep(i, m) cin >> t[i];

    int cnt = 0;
    rep(i, m) {
        if(mp[t[i]]) cnt++;
        mp[t[i]]--;
    }
    cout << (cnt >= m ? "YES" : "NO") << '\n';
    return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int n;
  string  s,t;
  cin>>n>>s>>t;

  rep(i,n){
    cout << s[i] << t[i];
  }

 cout << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#pragma warning (disable: 4996)

int N, A[1 << 17], B[1 << 17], dp[1 << 17], ret; vector<int>X[1 << 17], G[1 << 17];
bool used[1 << 17];

void dfs(int pos) {
	used[pos] = true;
	for (int i = 0; i < X[pos].size(); i++) {
		if (used[X[pos][i]] == true) continue;
		G[pos].push_back(X[pos][i]);
		dfs(X[pos][i]);
	}
}

vector<int> solve(int pos) {
	int used[30]; for (int i = 0; i < 30; i++) used[i] = 0;

	for (int i = 0; i < G[pos].size(); i++) {
		vector<int> E = solve(G[pos][i]);
		for (int j = 0; j < E.size(); j++) used[E[j]]++;
	}

	int c = -1, t = 0;
	for (int i = 0; i < 30; i++) { if (used[i] >= 2) t = i; }
	for (int i = t; i < 30; i++) {
		if (used[i] == false) { c = i; break; }
	}
	dp[pos] = c;
	vector<int>L; L.push_back(c);
	for (int i = c + 1; i < 30; i++) { if (used[i] == true) L.push_back(i); }
	return L;
}

int main() {
	//FILE *in = freopen("in1.txt", "r", stdin);
	cin >> N;
	for (int i = 1; i <= N - 1; i++) {
		cin >> A[i] >> B[i];
		X[A[i]].push_back(B[i]);
		X[B[i]].push_back(A[i]);
	}
	dfs(1);
	solve(1);

	int maxn = 0; for (int i = 1; i <= N; i++) maxn = max(maxn, dp[i]);
	cout << maxn << endl;
	return 0;
}

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

int main() {
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,ans=1e9,tw=0,tr=0;
    string s;
    cin>>n>>s;
    vector<int> w(n);
    vector<int> r(n);
    if(s[0]=='W') {tw++;w[0]++;} else {tr++;r[0]++;}
    for(int i=1;i<n;i++) {
        if(s[i]=='W') {
            tw++;w[i]++;
        }
        else {
            tr++;r[i]++;
        }
        w[i]+=w[i-1];
        r[i]+=r[i-1];
    }
    for(int i=0;i<n;i++) {
        int g = w[i],h=tr-r[i],j=min(g,h);
        ans=min(ans,g+h-j);
    }
    cout<<min(ans,min(tr,tw));
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H, W, M;
  cin >> H >> W >> M;
  vector<vector<int>> Y(H), X(W);
  for (int i = 0; i < M; i++) {
    int h, w;
    cin >> h >> w;
    h--, w--;
    Y[h].emplace_back(w);
    X[w].emplace_back(h);
  }
  int a = 0;
  for (int i = 0; i < H; i++) {
    a = max(a, (int)Y[i].size());
  }
  int c = 0;
  map<int, int> mp;
  for (int i = 0; i < H; i++) {
    if (a == (int)Y[i].size()) {
      for (const auto& e : Y[i]) {
        mp[e]++;
      }
      c++;
    }
  }
  int res = 0;
  for (int i = 0; i < W; i++) {
    int r = (int)X[i].size() + a;
    if (mp[i] == c) r--;
    res = max(res, r);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 50168
#define scanf_s scanf
//#define gets_s gets
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 81
#define _MAX 100
#define ABC 26
int main(void)
{
	int n;
	long long int ans = 1;
	scanf_s("%d", &n);
	for (int i = 1; i <= n; ++i) {
		ans *= i;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 1184
#include <iostream>
#include <cmath>
#include<vector>
#include <algorithm>


using namespace std;

typedef long long ll;
const int Max_N = 100000;
int K,X;


int main(){
  cin >> K >> X;
  int MAX_A=10000000;
  int MIN_A=-1000000;
  MAX_A = min(MAX_A,X+K-1);
  MIN_A = max(MIN_A,X-K+1);
  for(int k=MIN_A;k<MAX_A+1;k++){
    cout << k <<endl;
  }
}



Measured memory_bytes: 888
from collections import deque
S = deque(input())
S2 = deque([])
counter = 0
flag = True
while True:
    if len(S) == 0:
        break
    s = S.popleft()
    if len(S2) == 0:
            S2.append(s)
            flag = False
            continue
    
    elif s!=S2[-1]:
            S2.pop()
            flag = False
            counter +=2
    else:
        S2.append(s)
    if flag:
        break
print(counter)

Measured memory_bytes: 4212
#include<stdio.h>
#include<math.h>

int main(){
	float x[5]={0};
	float y[5]={0};
	float a[3]={0};
	int i,tate=0,yoko=0;
	
	while(scanf("%f%f%f%f%f%f%f%f",&x[1],&y[1],&x[2],&y[2],&x[3],&y[3],&x[4],&y[4])!=EOF)
	{
		if((x[2]-x[1])*(x[4]-x[3])+(y[2]-y[1])*(y[4]-y[3])==0)printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    long long n;
    cin >> n;
    n--;

    int len = 1;
    long long power = 26;
    while (power <= n) {
        n -= power;
        len++;
        power *= 26;
    }

    power /= 26;
    for (int i=0; i<len; i++) {
        cout << (char) ('a' + n / power);
        n %= power;
        power /= 26;
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 3644
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Magatro
{

    static void Main()
    {
        long[] s = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        Array.Sort(s);
        if (s.Count(a => a % 2 == 0) > 0)
        {
            Console.WriteLine(0);
            return;
        }
        Console.WriteLine(s[0] * s[1]);
       
    }

}


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

long long MOD = 1000000007;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    long long m, n;
    cin >> m >> n;
    cout << modpow(m, n, MOD) << endl;
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

bool solve(LL &th, VI &a, LL &n, LL &m, VLL &ru) {
    LL cnt = 0;
    RREP(i,0,n) {
        auto it = lower_bound(all(a), th - a[i]);
        cnt += max(0LL, (LL)(n - distance(a.begin(), it)));
    }
    return cnt >= m;
}

long long meguru_bin(VI &a, LL &n, LL &m, VLL &ru) {
    long long ok = -1;
    long long ng = 200001;

    while (abs(ok - ng) > 1) {
        long long mid = ng + (ok - ng) / 2;
        if (solve(mid,a,n,m,ru)) ok = mid;
        else ng = mid;
    }

    return ok;
}

void solve() {
    LL n,m;
    cin >> n >> m;
    VI a(n);
    REP(i,0,n) cin >> a[i];
    sort(all(a));
    VLL ru(n+1);
    REP(i,0,n) ru[i+1] = ru[i] + a[i];
    int th = meguru_bin(a,n,m,ru);
    LL cnt = 0;
    LL sum = 0;

    RREP(i,0,n) {
        auto it = lower_bound(all(a), th - a[i]);
        int d = distance(a.begin(), it);
        cnt += max(0LL, (n - d));
        sum += max(0LL, (ru[n] - ru[d]) + (n - d) * a[i]);
    }
    sum -= max(0LL, cnt - m) * th;
    cout << sum << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main(){
	int a,b,x;
	scanf("%d%d%d",&a,&b,&x);
	if (a+b<x)
		printf("NO\n");
	else if(a>x)
		printf("NO\n");
	else
		printf("YES\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,ans;
  cin >> s;
  for (int i=0;i<s.size();i++){
    if (s[i]=='0'){
      ans+='0';
    }
    else if (s[i]=='1'){
      ans+='1';
    }
    else if (s[i]=='B'&&ans.size()>0){
      ans.pop_back();
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	int water[31] = { };
	REP(i, 31){
		REP(j, 31){
			if(100 * (i * a + j * b) <= 3000) water[i*a + j*b] = 1;
		}
	}
	int sugar[3001] = { };
	REP(i, 3000){
		REP(j, 3000){
			if(i * c + j * d <= 3000) sugar[i*c + j*d] = 1;
		}
	}
	int ans1 = 0, ans2 = 0;
	double max = 0;
	FOR(i, 1, 31){
		REP(j, 3001){
			double d = j / (double)(100 * i + j); 
			if(water[i] == 1 && sugar[j] == 1 && (100 * i) + j <= f && j <= (e * i) && d >= max){
				ans1 = i * 100 + j;
				ans2 = j;
				max = (double)j / (double)(100 * i + j);
			}
		}
	}
	cout << ans1 << " " << ans2 << endl;
	return 0;
}


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

int main() {
  string S1,S2,S3;
  cin >> S1 >> S2 >> S3;
  if(S1[S1.size()-1]==S2[0] && S2[S2.size()-1]==S3[0]){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector<int> adj[100001];
int dp[100001];
int dfs(int node)
{
    if(dp[node]!=-1)
        return dp[node];
    dp[node]=0;
    for(int i=0;i<adj[node].size();++i)
    {
        dp[node]=max(dp[node],1+dfs(adj[node][i]));
    }
    return dp[node];
}
signed main()
{
    SPEED;
    int n,m,ans=0;
    cin>>n>>m;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<m;++i)
    {
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
    }
    for(int i=1;i<=n;++i)
    {
        ans=max(ans,dfs(i));
    }
    cout<<ans;
}


Measured memory_bytes: 11924
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		String x = "";
		for(int i=0;i<s.length();i++){
			x = x + "x";
		}
		System.out.println(x);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL
string arr[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI","SAT"};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  int n;cin >> n;
  string s;cin >> s;
  for(int i=0;i<s.length();i++){
    s[i] = 'A' + (s[i]-'A'+n)%26;
  }
  cout << s << endl;
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int INF = 10000010;
int main(){

    int h,w;
    cin>>h>>w;
    int graph[15][15];

    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cin>>graph[i][j];
        }
    }
    int wall[1009][1009];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin>>wall[i][j];
        }
    }

    for(int k = 0 ; k < 10; k++){
            for(int i = 0; i < 10; i++){
                for(int j =0; j < 10; j++){
                    if(graph[i][j] > graph[i][k] + graph[k][j]){
                        graph[i][j] = graph[i][k] + graph[k][j];
                    }
                }
            }
       }
       long long ans = 0;
       for(int i = 0;i < h;i++){
           for(int j =0; j < w; j++){
               if(wall[i][j] != -1){
                   ans += graph[wall[i][j]][1];
               }
           }
       }
       cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3072
let input = require("fs").readFileSync("/dev/stdin", "utf8");
let cin = input.split(/ |\n/), cid = 0;
function next() { return +cin[cid++]; }
//input from catoonさん

function buffer(){
    // if (console._LOG_BUFFER) return;
// console._LOG_BUFFER = true;

var util = require('util');

var cache = {};

// make sure to flush at exit
process.on('exit', flush);

// export the flush and patch functions
module.exports = patch;
module.exports.flush = flush;

// save the original functions, and make a buffer for each
['warn', 'log', 'error', 'info'].forEach(function(name) {
  cache[name] = {
    func: console[name].bind(console),
    size: 0,
    buf: []
  };
});

// patch when required
patch();

/**
 * Patch the console.* commands with the given
 * limit (default 8k)
 */
function patch(limit?, pre?) {
  limit = limit || 8192; // 8kb

  // overwrite the console.* functions to buffer
  Object.keys(cache).forEach(function(name) {
    console[name] = function() {
      // format the input
      var s = util.format.apply(this, arguments);
      if (typeof pre === 'string') s = pre + s;
      else if (typeof pre === 'function') s = pre() + s;

      // calculate the new length
      var len = Buffer.byteLength(s);
      cache[name].size += len;

      // push the data, and flush if > limit
      cache[name].buf.push(s);
      if (cache[name].size > limit) flush();
    };
  });
}

/**
 * Flush all the caches by calling the original function forEach
 */
function flush() {
  // flush all caches
  Object.keys(cache).forEach(function(name) {
    // dump the buffer if present
    if (cache[name].size)
      cache[name].func(cache[name].buf.join('\n'));

    // clear the buffer
    cache[name].buf.length = 0;
    cache[name].size = 0;
  });
}
}
buffer();

class UnionFind {
    p: number[];
    sizes: number[];
    tmpsize: number;
    constructor(n: number) {
        this.p = []
        this.sizes = [];
        for (let i = 0; i < n; i++) {
            this.p.push(i);
            this.sizes.push(1);
        }
        this.tmpsize = n;
    }
    find(x: number) {
        if (this.p[x] === x) {
            return x;
        } else {
            let tmp = this.find(this.p[x]);
            return tmp;
        }
    }
    unite(x: number, y: number) {
        let findx = this.find(x);
        let findy = this.find(y);
        if (findx === findy) return;

        let [large, small] = this.sizes[findx] >= this.sizes[findy] ? [findx, findy] : [findy, findx];

        this.p[small] = large;
        this.sizes[large] += this.sizes[small];
        this.tmpsize--;

    }
    is_same(x: number, y: number) {
        return this.find(x) === this.find(y);
    }
}
function main() {
    let n = next();
    let q = next();
    let uf = new UnionFind(n);
    while (q--) {
        let condition = next();
        let tmp = next();
        let tmp1 = next();
        if (condition === 0) {
            uf.unite(tmp, tmp1);
        }
        else {
            if (uf.is_same(tmp, tmp1)) {
                console.log(1);
            }
            else {
                console.log(0);
            }

        }
    }
    return;
}
main();


Measured memory_bytes: 90164
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;



int main(){
  string s;
  cin >> s;
  if((s[0] == s[1]) && (s[2] == s[3]) && (s[0] == s[2])) cout << "No";
  else if((s[0] == s[1]) && (s[2] == s[3])) cout << "Yes";
  else if((s[0] == s[2]) && (s[1] == s[3])) cout << "Yes";
  else if((s[0] == s[3]) && (s[1] == s[2])) cout << "Yes";
  else cout << "No";
  return 0;
}

Measured memory_bytes: 384