akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

int main()
{
    int x, y;

    while(1)
    {
        std::cin >> x >> y;

        if (x == 0 && y == 0) break;

        if (x > y) std::swap(x, y);

        std::cout << x << " " << y << std::endl;
    }
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;



int main()
{
  int x, y, z ;
  cin >> x >> y >> z ;
  int ans = 0 ;
  
  int n = 0 ;
  while(ans<=x){
    n++ ;
    ans = y*n+z*(n+1) ;
  }
  
  cout << n-1 <<endl ;

  return 0 ;
}




Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	char s[11];
	int i, max = 0, count = 0;

	scanf("%s", s);

	i = 0;
	while(1) {
		switch(s[i]) {
			case 'A':
			case 'C':
			case 'G':
			case 'T':
				++count;
				break;
			default:
				max = (count < max) ? max : count;
				count = 0;
				break;
		}
		if(s[i] == '\0')	break;
		else	++i;
	}

	printf("%d\n", max);

	return 0;
}

Measured memory_bytes: 128
import kotlin.math.*
import java.util.*

const val MOD = 1_000_000_007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main(args: Array<String>) {
  val n = readLine()!!.last() - '0'
  val pon = intArrayOf(0, 1, 6, 8)
  val ans = when (n) {
    3 -> "bon"
    in pon -> "pon"
    else -> "hon"
  }
  println(ans)
}


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

#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

template<typename T1,typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 & a, T2 b) { if (a < b) a = b; }

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;
const long long kMod = 1000000007;

const long kMAX = 1000000000;

using namespace std;
using ll = long long;

inline int readInt() {
  char c = getchar();
  while(!isdigit(c) && c != '-') c = getchar();
  int sigma = 1;
  if (c == '-') {
    sigma = -1;
    c = getchar();
  }
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * sigma;
}

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

  ll ans = 0, cn = 1;

  int n, m;
  vector<ll> a, b;

  string s, t;
  cin >> n >> m;
  while (cn < m) { cn += (n - 1); ans++; }
  cout << ans  << endl;
}


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

int main(){
int n,x,t;
int a;
cin>>n>>x>>t;
if(n%x==0){
   cout<<(n/x)*t<<endl;
}
else{
a=(n/x)+1;
cout<<a*t<<endl;
}


return 0;

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
const int MOD = 1000000007;
template<class T> void add(T &a, T b) { a = (a + b) % MOD; }

int main() {
    string L; cin >> L;
    int N = L.size();
    vector<vector<int64_t>> dp(N + 1, vector<int64_t>(2));
    dp[0][0] = 1;
    rep(i, 0, N) {
        if(L[i] == '0') {
            add(dp[i + 1][0], dp[i][0]);
            add(dp[i + 1][1], dp[i][1] * 3);
        } else {
            add(dp[i + 1][0], dp[i][0] * 2);
            add(dp[i + 1][1], dp[i][0]);
            add(dp[i + 1][1], dp[i][1] * 3);
        }
    }
    cout << (dp[N][0] + dp[N][1]) % MOD << endl;
    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>

int main()
{
    int n, m, cnt = 0, max = 0;
    std::string s[110], t[110];

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

    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            if(s[i] == s[j]){
                cnt++;
            }
        }
        for(int j = 0;j < m;j++){
            if(s[i] == t[j]){
                cnt--;
            }
        }
        max = std::max(cnt, max);
        cnt = 0;
    }

    std::cout << max;
    return 0;
}

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

typedef long long ll;

#define REP(i,m,n) for(int i=(int)m; i < (int) n; ++i)
#define rep(i,n) REP(i,0,n)
#define all(a) (a).begin(), (a).end()


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

    int x; cin >> x;
    int ans = 1;
    for(int i = 2; i*i <= x; i++) {
        int tmp = i*i;
        while(true) {
            if(tmp > x) break;
            tmp *= i;
        }
        ans = max(ans, tmp/i);
    }

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

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<vector<int>> G(N+1,vector<int>(0));
  vector<int> P(N+1,-1);
  vector<int> in(N+1,0);
  for(int i=0;i<N+M-1;i++){
    int a,b;
    cin >> a >> b;
    G[a].push_back(b);
    in[b]++;
  }
  
  int r;
  for(int i=1;i<=N;i++){
    if(in[i]==0) r = i;
  }
  P[r] = 0;
  queue<int> Q;
  Q.push(r);
  vector<bool> state(N+1,false);
  state[r] = true;
  while(!Q.empty()){
    int u = Q.front();
    Q.pop();
    for(int i=0;i<G[u].size();i++){
      int v = G[u][i];
      in[v]--;
      P[v] = u;
      if(in[v]==0 && state[v]==false){
        Q.push(v);
        state[v] = true;
      }
    }
  }
  
  for(int i=1;i<=N;i++) cout << P[i] << endl;
  return 0;
}


Measured memory_bytes: 7040
#include <stdio.h>
#include <string.h>

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>

using namespace std;

int calc( decltype(vector<int>().begin()) begin_iter, decltype(vector<int>().end()) end_iter )
{
    auto arg_min_iter = min_element(begin_iter, end_iter);
  	int all_try_count = *arg_min_iter;
  
  	for (auto iter = begin_iter; iter != end_iter; ++iter)
    {
        *iter -= all_try_count;
    }
    
    int left_try_count;
    if ( distance(begin_iter, arg_min_iter) >= 2 ) 
    {
        left_try_count = calc(begin_iter, arg_min_iter);
    }
    else if ( distance(begin_iter, arg_min_iter) == 1 ) 
    {
        left_try_count = *begin_iter;
    }
    else if ( distance(begin_iter, arg_min_iter) == 0 ) 
    {
        left_try_count = 0;
    }

    int right_try_count;
    if ( distance(arg_min_iter, end_iter) >= 3 ) 
    {
        right_try_count = calc(arg_min_iter + 1, end_iter);
    }
    else if ( distance(arg_min_iter, end_iter) == 2 ) 
    {
        right_try_count = *(end_iter - 1);
    }
    else if ( distance(arg_min_iter, end_iter) == 1 ) 
    {
        right_try_count = 0;
    }

    return all_try_count + left_try_count + right_try_count;
}


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

    vector<int> h(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> h[i];
    }
    
    cout << calc(h.begin(), h.end());

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main{
    public  static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
        	while(sc.hasNext()) {
        		long[][] dp=new long[5][4001];
        		int n = sc.nextInt();
        		dp[0][0]=1;
        		for(int i=0; i<4; i++) {
        			int max=i*1000;
        			for(int j=0; j<=max; j++) {
        				for(int k=0; k<=1000; k++) {
        					dp[i+1][j+k]+=dp[i][j];
        				}
        			}
        		}
        		System.out.println(dp[4][n]);
        	}
        }
    }
}


Measured memory_bytes: 35828
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
#define first fi
#define second se
using namespace std;
int sdkys(int a,int b){
    if(b==0) return a;
    return sdkys(b,a%b);
}
int sskbs(int a,int b){
    return a*b/sdkys(a,b);
}
int sosu(int a){
    if(a==2){
        return 1;
    }
    for(int i=2;i<sqrt(a)+1;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}
vector<int> v;
int n,m,cnt=0,ans=0,aa[220000],ab[220000];
pair<int,int> pp[220000];
string s,ss[220000],sa;
char ch[110][110];
queue<int> que;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>aa[i];
        cnt+=aa[i];
    }
    if(cnt%10==0){
        sort(aa,aa+n);
        rep(i,n){
            if(aa[i]%10!=0){
                cout<<cnt-aa[i]<<endl;
                return 0;
            }
        }
        cout<<0<<endl;
    }else{
        cout<<cnt<<endl;
        return 0;
    }
}

Measured memory_bytes: 10500
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

int main(){

    ll ans = 1;
    ll N;
    cin >> N;
    for(ll i = 1; i <= N; i++){
        ans = ans * i % MOD;
    }
    cout << ans << endl;


    return 0;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }


int x;
bool dp[100005];
void solve() {
    cin >> x;

    dp[0] = true;
    rep(i, 6) rep(j, 100002) {
        auto val = 100 + i;
        dp[j] |= dp[j];
        if (j + val < 100002) dp[j + val] |= dp[j];
    }

    if (dp[x]) cout << 1 << endn;
    else cout << 0 << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 384
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
mod = 998244353
N, M, K = map(int, input().split())
if (M == 1) and (K == (N-1)):
	print(1)
	sys.exit()
def cumprod(x, MOD = mod):
	L = len(x)
	Lsq = int(L**.5 + 1)
	x = np.resize(x, Lsq ** 2).reshape(Lsq, Lsq)
	for n in range(1, Lsq):
		x[:,n] *= x[:,n-1]
		x[:,n] %= MOD
	for n in range(1,Lsq):
		x[n] *= x[n-1, -1]
		x[n] %= MOD
	return x.flatten()[:L]

def make_fact(U, MOD = mod):
	x = np.arange(U, dtype = np.int64)
	x[0] = 1
	fact = cumprod(x, MOD)
	x = np.arange(U, 0, -1, dtype = np.int64)
	x[0] = pow(int(fact[-1]), MOD - 2, MOD)
	fact_inv = cumprod(x, MOD)[::-1]
	return fact, fact_inv

fact, fact_inv = make_fact(N+10)


ans = 0
D = M * ((M-1) ** (N-1))
D %= mod
for i in range(K+1):
	if i == 0:
		ans += D
	else:
		d = fact[N-1]
		d *= fact_inv[i]
		d %= mod
		d *= fact_inv[N-1-i]
		d %= mod

		tmp = d * D
		tmp %= mod
		ans += tmp

	ans %= mod		
	D *= pow(M-1, mod-2, mod)
	D %= mod

ans %= mod

print(ans)

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

S = [list(input().replace(".", "0")) for _ in range(H)]  # .を0に置換しておく。文字列にしか置換できないので注意

def fill_cells_around_mine(i,j): # 地雷の座標(i,j)を与え、その周りのセルの値を+1する
    for y in range(max(0,i-1),min(H,i+2)):
        for x in range(max(0, j-1), min(W,j+2)):
            if S[y][x] != "#":
                S[y][x] = str(int(S[y][x])+1)

for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            fill_cells_around_mine(i, j)

for idx in range(len(S)):
    print("".join(S[idx]))

Measured memory_bytes: 3064
#include <iostream>
#include<set>
#include<iterator>
#include <algorithm>
using namespace std;

int main() {
   
    
   int N;
  cin >> N;
  int ans = 0;
  for (int C = 1; C <= N; C += 2) {
    int div = 0;
    for (int X = 1; X <= C; ++X) {
      if (C % X == 0) {
        div++;
      }
    }
    if (div == 8) {
      ans++;
    }
  }
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#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 ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a,b,n;
    string s,s1;
    cin >> a >> b;
    if (a+b%2==0) cout << (a+b)/2 << endl;
    else cout << (a+b+1)/2 << endl;
    return 0;
} 

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

#define PAT1 1
#define PAT2 2
#define PAT3 3
#define PAT4 4

long long N;
string S1, S2;


int getlen(int pat){
	if(pat == PAT1){
		return 1;
	}
	if(pat == PAT2){
		return 2;
	}
	if(pat == PAT3){
		return 1;
	}
	if(pat == PAT4){
		return 2;
	}
}

int getmul(int pat){
	if(pat == PAT1){
		return 2;
	}
	if(pat == PAT2){
		return 2;
	}
	if(pat == PAT3){
		return 1;
	}
	if(pat == PAT4){
		return 3;
	}
}

int getpat(int pos){
	if(S1[pos] == S2[pos]){
		if(S1[pos+1] == S2[pos+1]){
			return PAT1;
		}else{
			return PAT2;
		}
	}else{
		if(S1[pos+1] == S2[pos+1]){
			return PAT3;
		}else{
			return PAT4;
		}
	}
}

int main(){
	cin >> N >> S1 >> S2;
	long long cur;
	long long pos;

	if(S1[0] == S2[0]){
		cur = 3;
		pos = 0;
	}else{
		cur = 6;
		pos = 1;
	}

	while(pos < N - 1){
		int pat = getpat(pos);
		cur *= getmul(pat);
		cur %= 1000000007;
		pos += getlen(pat);
	}
	cout << cur << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int length(int n){
	int count = 0;
	while(n != 0){
		n = n / 10;
		count++;
	}
	return count;
}

int main(){
	int a,b;
	
	while(scanf("%d %d", &a, &b) != EOF){
	a = length(a + b);
	
	printf("%d\n", a);
	}
	return 0;
}

Measured memory_bytes: 600
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# import numpy as np
# from itertools import permutations
# from itertools import combinations
# from itertools import combinations_with_replacement
import queue
# import heapq

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    N, M = map(int, input().split())
    queries = (map(int, input().split()) for _ in range(M))

    tree = [set() for _ in range(N+1)]

    for a, b in queries:
        tree[a].add(b)
        tree[b].add(a)

    nn = 10 ** 9
    signs = [nn for _ in range(N+1)]
    visited = {0}

    que = queue.Queue()

    que.put((0, 1))  # parent, current

    while not que.empty():

        parent, current = que.get()

        if current in visited:
            continue

        visited.add(current)
        signs[current] = parent

        for t in tree[current]:
            if t in visited:
                continue
            else:
                que.put((current, t))

    return signs[2:]


def main():
    ans = solve()
    if 10**9 in ans:
        print('No')
    else:
        print('Yes')
        for a in ans:
            print(a)


if __name__ == "__main__":
    main()


Measured memory_bytes: 74136
#include<iostream>
#include <numeric>
// #include<string>
#include<vector>
#include <algorithm>
#include <cmath>
// #include <functional>

using namespace std;

int main()
{
    // Input
    int n, m;
    cin >> n >> m;

    vector<unsigned long long> A;
    for (int i = 0; i < n; i++) {
        unsigned long long in;
        cin >> in;

        A.push_back(in);
    }

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

    if (A[m-1] * (4 * m) < accumulate(A.begin(), A.end(), 0LL)) {
        cout << "No";
    } else {
        cout << "Yes";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for (int i = (a); i < (b); i++)
#define N 2345

int n;
long long a[N], x, ans = 1e18;
multiset<long long> v;
int main() {
	scanf("%d %lld", &n, &x);
	fo(i,0,n) scanf("%lld", a+i);
	fo(i,0,n) {
		long long res = i*x;
		v.clear();
		fo(j,0,i+1) v.insert(a[j]);
		fo(j,0,n) {
			res += *v.begin();
			v.erase(v.find(a[j]));
			v.insert(a[(j + i + 1)%n]);
		}

		ans = min(ans, res);
	}
	printf("%lld\n", ans);


	return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    
    vector<vector<int>> A(n, vector<int>(m));
    vector<int> b(m), ans(n);
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> A[i][j];
        }
    }
    
    for(int i = 0; i < m; i++){
        cin >> b[i];
    }
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            ans[i] += A[i][j] * b[j];
        }
    }
    
    for(auto val : ans){
        cout << val << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3152
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int n;
  cin >> n;
  int a[2][n + 1];
  memset(a, 0, sizeof(a));
  rep(i, 2) {
    FOR(j, 1, n + 1) {
      cin >> a[i][j];
    }
  }

  rep(i, 2) {
    rep(j, n) {
      a[i][j + 1] += a[i][j];
    }
  }

  int ans = 0;
  FOR(j, 1, n + 1) {
    ans = max(ans, a[0][j] + a[1][n] - a[1][j - 1]);
  }
  cout << ans << endl;



  
  return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  
  vector<vector<int> > A(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> A.at(i).at(j);
    }
  }
  
  vector<vector<int> > B(m, vector<int>(1));
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < 1; j++) {
      cin >> B.at(i).at(j);
    }
  }
  
  int C;
  
  for (int i = 0; i < n; i++) {
    C = 0;
    for (int j = 0; j < m; j++) {
      C += A.at(i).at(j) * B.at(j).at(0);
      if (j == m - 1){
        cout << C << endl;
      }
    }
  }
}
  


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

vector< vector<int> > warshallFloyd(vector< vector<int> > dist) {
  int n = dist.size();
  for(int k=0;k<n;k++) {
    for(int i=0;i<n;i++) {
      for(int j=0;j<n;j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }

  return dist;
}

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

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

  auto dist = warshallFloyd(a);
  for(int i=0;i<n;i++) {
    for(int j=0;j<n;j++) {
      if(a[i][j] != dist[i][j]) {
        cout << -1 << endl;
        return 0;
      }
    }
  }

  long long ans = 0;
  for(int i=0;i<n;i++) {
    for(int j=0;j<i;j++) {
      int needed = 1;
      for(int k=0;k<n;k++) {
        if(a[i][k] + a[k][j] == a[i][j] && i != k and j != k) {
          needed = 0;
          break;
        }
      }
      ans += needed * a[i][j];
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include"bits/stdc++.h"
using namespace std;

int main() {
	int n,ans;
	cin >> n;
	ans = n;
	vector<char>s(n);
	for (int i = 0; i < n; i++)cin >> s.at(i);
	for (int i = 0; i < n-1; i++) {
		if (s.at(i) == s.at(i + 1))ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>

int main()
{
    int n;
    scanf("%d", &n);

    int a[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    for (int i = n - 1; i >= 0; i--)
    {
        if (i != 0)
        {
            printf("%d ", a[i]);
        }
        else
        {
            printf("%d", a[i]);
        }
    }
    printf("\n");
}


Measured memory_bytes: 2604
s = [i for i in range(1001)]
s[0] = 0
s[1] = 0
i = 2
while i < len(s):
    j = i * 2
    while s[i] != 0:
        if j >= len(s):
            break
        s[j] = 0
        j += i
    i += 1

N = int(input())
cnt = [0 for i in range(1001)]
for i in range(1, N + 1):
    j = 1
    while i != 1:
        while s[j] == 0:
            j += 1
        while i % j == 0:
            cnt[j] += 1
            i /= j
        j += 1
ans = 1
for i in s:
    if i != 0:
        ans *= cnt[i] + 1
print(ans % (10 ** 9 + 7))


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

int main() {
  ll mod = 998244353;
  int N, S; cin >> N >> S;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  vector< vector<ll> > dp1(S+1, vector<ll>(3, 0));
  vector< vector<ll> > dp2(S+1, vector<ll>(3, 0));
  dp1[0][0] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= S; j++) {
      if (A[i] <= j) {
        dp2[j][0] = dp1[j][0];
        dp2[j][1] = (dp1[j][1]+dp1[j-A[i]][1]+dp1[j-A[i]][0]*(i+1)%mod)%mod;
        dp2[j][2] = (dp1[j][2]+dp1[j-A[i]][1]*(N-i)%mod+dp1[j-A[i]][0]*(i+1)%mod*(N-i)%mod)%mod;
      } else {
        for (int k = 0; k < 3; k++) dp2[j][k] = dp1[j][k];
      }
    }
    dp1 = dp2;
  }
  cout << dp1[S][2] << endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    int n, d;
    cin >> n >> d;
    int count = 0;
    d = d * d;
    int x, y;
    rep(i, n) {
        cin >> x >> y;
        x = x * x;
        y = y * y;
        if (d >= x + y)
            count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
template<class T> istream& operator>>(istream &is,vector<T> &st){
  for(size_t i=0;i<st.size();++i) is >> st[i];
  return is;
}
template<class T> istream& operator>>(istream &is,vector<vector<T>> &st){
  for(size_t i=0;i<st.size();++i) is >> st[i];
  return is;
}
template<class T> ostream& operator<<(ostream &os, const vector<T> &st){
  for(size_t i=0;i<st.size();++i){
    if(i==st.size()-1) os << st[i];
    else os << st[i] << " ";
  }
  return os;
}
template<class T> ostream& operator<<(ostream &os, const vector<vector<T>> &st){
  for(size_t i=0;i<st.size();++i){
    os << st[i];
    if(i!=st.size()-1) os << endl;
  }
  return os;
}
string max(string l, string r){
  if(l.size()!=r.size()) return l.size()<r.size()?r:l;
  REP(i,l.size()){
    if(l[i]<r[i]) return r;
    if(l[i]>r[i]) return l;
  }
  return l;
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vi num = {2,5,5,4,5,6,3,7,6};
  int n,m;
  cin >> n >> m;
  vi a(m);
  cin >> a;
  vb can(9,false);
  REP(i,m) can[a[i]-1] = true;
  V<string> dp(n+10,"");
  REP(i,n){
    if(i!=0&&dp[i]=="") continue;
    REP(j,9)if(can[j]){
      dp[i+num[j]] = max(dp[i+num[j]],dp[i]+char(j+1+'0'));
    }
  }
  cout << dp[n] << endl;
}



Measured memory_bytes: 43648
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
  int a, b, C;
  cin >> a >> b >> C;

  double PI = acos(-1);
  double rad = C * PI / 180;
  
  double S = a * b * sin(rad) / 2;
  double c = sqrt(a * a + b * b - 2 * a * b * cos(rad));
  double L = a + b + c;
  double h = b * sin(rad);

  printf("%lf\n%lf\n%lf\n", S, L, h);
  
  return 0;
}


Measured memory_bytes: 3508
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int table_s[27];
int table_t[27];
int main(){
  string s,t;cin>>s>>t;

  rep(i,s.size()){
    table_s[s[i]-97]++;
  }
  rep(i,t.size()){
    table_t[t[i]-97]++;
  }
  
  bool flg=true;
  rep(i,26){
    if(table_s[i]!=table_t[i]){
      flg=false;
      FOR(j,i,26){
        if(table_s[j]==table_t[i]){
          swap(table_s[i],table_s[j]);
          flg=true;
        }
      }
      if(!flg){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }

  cout<<"Yes"<<endl;

  return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;

const ll INF = 1LL << 60;
const int MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, b, e) for (int i = (b); i <= (e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

int main() {
    string s;
    cin >> s;
    int ans = 0;
    int m = 0;
    REP(i, s.size()) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            m++;
        } else {
            ans = max(ans, m);
            m = 0;
        }
    }
    ans = max(ans, m);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define sort(vec) sort((vec).begin(),(vec).end());
#define rever(vec) reverse((vec).begin(),(vec).end());
#define cout(n) cout<<(n)<<endl;
using namespace std;

int main() {
  string s;
  cin>>s;
  ll e=s.size()-1;
  ll ans=0;
  for(ll i=0;i<e;i++) {
    if(s.at(i)!=s.at(i+1)) {
      ans++;
    }
  }
  cout(ans);
}

Measured memory_bytes: 512
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,m = inpl()
res = [[0] * n for i in range(n)]
for i in range(m):
    a,b = inpl()
    res[a-1][b-1] += 1
    res[b-1][a-1] += 1
for i in range(n):
    print(sum(res[i]))


Measured memory_bytes: 38512
using AtCoderBeginnerContest129.Questions;
using AtCoderBeginnerContest129.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest129.Questions
{
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var weights = inputStream.ReadIntArray();

            var sum = weights.Sum();
            var partialSum = 0;
            var min = int.MaxValue;

            foreach (var weight in weights)
            {
                partialSum += weight;
                min = Math.Min(Math.Abs(sum - 2 * partialSum), min);
            }

            yield return min;
        }
    }
}


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

#region Base Classes

namespace AtCoderBeginnerContest129.Questions
{

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

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

            return Solve(reader);
        }

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

}

#endregion

#region Extensions

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

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

#endregion


Measured memory_bytes: 13396
import sys

stdin = sys.stdin

mod = 1000000007
inf = 1 << 60

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

s = ns()
x, y = int(s[:2]), int(s[2:])

if x >= 1 and x <= 12:
	if y >= 1 and y <= 12:
		print("AMBIGUOUS")
	else:
		print("MMYY")
else:
	if y >= 1 and y <= 12:
		print("YYMM")
	else:
		print("NA")

Measured memory_bytes: 3064
/*
    Mbak Rose Dong
*/
#include<bits/stdc++.h>
using namespace std;
int arr[200200];
int kiri[200200];
int kanan[200200];
int main()
{
    int n,i,j,k,x,y,ans,curr,temp,m,inc=1;
    cin >> n;
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&arr[i]);
    }
    sort(arr+1,arr+n+1);
    kiri[0] = 0;
    for(i=1;i<=n;i++)
    {
        kiri[i] = __gcd(kiri[i-1],arr[i]);
    }
    kanan[n+1] = 0;
    for(i=n;i>0;i--)
    {
        kanan[i] = __gcd(kanan[i+1], arr[i]);
    }
    int rose = 0;
    for(i=1;i<=n;i++)
    {
        rose = max(rose, __gcd(kiri[i-1], kanan[i+1]));
    }
    printf("%d\n",rose);
    return 0;
}


Measured memory_bytes: 1408
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int n = 0;
            foreach(char c in S)
            {
                n++;
                if(n % 2 == 0)
                {
                    if(c == 'L' | c == 'U' | c =='D')
                    {
                        continue;
                    }
                    else
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
                else
                {
                    if(c=='R' | c == 'U' | c == 'D')
                    {
                        continue;
                    }
                    else
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
            }
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 13140
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    R = int(input())
    G = int(input())
    
    print(2*G - R)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, c, k := nextInt(), nextInt(), nextInt()

	tArray := make([]int, n)
	for i := range tArray {
		tArray[i] = nextInt()
	}
	sort.Sort(sort.IntSlice(tArray))

	ans := 0
	passenger := 0
	tLeave := 0
	for _, t := range tArray {
		if t <= tLeave && passenger < c {
			passenger++
			continue
		}
		tLeave = t + k
		ans++
		passenger = 1
	}

	fmt.Println(ans)
}


Measured memory_bytes: 2944
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define reprs(i, s, e) for(int i=e-1; i>=s; i--)

ll n, x;
ll nlayer[51], npatty[51];

ll dfs(ll n, ll x){
    if(n == 0) return 1;

    ll center = (nlayer[n] + 1)/2;

    if(x == 1) return 0;
    else if(x < center) return dfs(n-1, x-1);
    else if(x == center) return npatty[n-1] + 1;
    else return dfs(n-1, x-center) + npatty[n-1] + 1; 
}


int main(){

    cin >> n >> x;

    nlayer[0] = 1;
    npatty[0] = 1;
    reps(i, 1, n+1){
        nlayer[i] = 2*nlayer[i-1] + 3;
        npatty[i] = 2*npatty[i-1] + 1;
        // cout << nlayer[i] << " " << npatty[i] << endl;
    }


    cout << dfs(n, x);

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{
    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());

        var left = new List<int>();
        var right = new List<int>();

        for (int i = 0; i < N; i++)
        {
            var ab = Console.ReadLine().Split(' ').Select(j => int.Parse(j)).ToArray();
            left.Add(ab[0]);
            right.Add(ab[1]);
        }

        left.Sort();
        right.Sort();

        if (N % 2 == 1)
            Console.WriteLine(right[N / 2] - left[N / 2] + 1);
        else
            Console.WriteLine((right[N / 2 - 1] + right[N / 2]) - (left[N / 2 - 1] + left[N / 2]) + 1);
    }
}

Measured memory_bytes: 44764
import collections
n=int(input())
d={'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8, 'i': 9, 'j': 10, 'k': 11, 'l': 12, 'm': 13, 'n': 14, 'o': 15, 'p': 16, 'q': 17, 'r': 18, 's': 19, 't': 20, 'u': 21, 'v': 22, 'w': 23, 'x': 24, 'y': 25, 'z': 26, 1: 'a', 2: 'b', 3: 'c', 4: 'd', 5: 'e', 6: 'f', 7: 'g', 8: 'h', 9: 'i', 10: 'j', 11: 'k', 12: 'l', 13: 'm', 14: 'n', 15: 'o', 16: 'p', 17: 'q', 18: 'r', 19: 's', 20: 't', 21: 'u', 22: 'v', 23: 'w', 24: 'x', 25: 'y', 26: 'z'}
lc=[["aaa",1],["aab",2],["aba",2],["abb",2],["abc",3]]

ld=[]
for j in range(len(lc)):
    for i in range(1,lc[j][1]+2):
        k=lc[j][0]+d[i]
        c = collections.Counter(k)
        ld.append([k,len(c)])
ld=sorted(ld)

le=[]
for j in range(len(ld)):
    for i in range(1,ld[j][1]+2):
        k=ld[j][0]+d[i]
        c = collections.Counter(k)
        le.append([k,len(c)])
le=sorted(le)

lf=[]
for j in range(len(le)):
    for i in range(1,le[j][1]+2):
        k=le[j][0]+d[i]
        c = collections.Counter(k)
        lf.append([k,len(c)])
lf=sorted(lf)

lg=[]
for j in range(len(lf)):
    for i in range(1,lf[j][1]+2):
        k=lf[j][0]+d[i]
        c = collections.Counter(k)
        lg.append([k,len(c)])
lg=sorted(lg)

lh=[]
for j in range(len(lg)):
    for i in range(1,lg[j][1]+2):
        k=lg[j][0]+d[i]
        c = collections.Counter(k)
        lh.append([k,len(c)])
lh=sorted(lh)

li=[]
for j in range(len(lh)):
    for i in range(1,lh[j][1]+2):
        k=lh[j][0]+d[i]
        c = collections.Counter(k)
        li.append([k,len(c)])
li=sorted(li)

lj=[]
for j in range(len(li)):
    for i in range(1,li[j][1]+2):
        k=li[j][0]+d[i]
        c = collections.Counter(k)
        lj.append([k,len(c)])
lj=sorted(lj)

if n==1:
    print("a")
elif n==2:
    l=["aa","ab"]
    print(*l)

elif n==3:
    for i in lc:
        print(i[0])
elif n==4:
    for i in ld:
        print(i[0])
elif n==5:
    for i in le:
        print(i[0])
elif n==6:
    for i in lf:
        print(i[0])
elif n==7:
    for i in lg:
        print(i[0])
elif n==8:
    for i in lh:
        print(i[0])
elif n==9:
    for i in li:
        print(i[0])
elif n==10:
    for i in lj:
        print(i[0])


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n;
    cin >> n;
    int a[n + 1];
    FOR(i, 1, n) cin >> a[i];
    bool ok = 1;
    FOR(i, 1, n)
        if(a[i] % 2 == 0)
        {
            if(a[i] % 3 != 0 && a[i] % 5 != 0)
            {
                ok = 0;
                break;
            }
        }
    if(ok)
    {
        cout << "APPROVED";
    }
    else cout << "DENIED";
    return 0;
}


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

using namespace std;

bool isPrime(int n) {
    if (n == 1) {
        return false;
    }
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int count = 0;
    for (int i = 0; i < n; i++) {
        int num;
        cin >> num;
        if (isPrime(num)) {
            count++;
        }
    }
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 3172
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void solve() {
	int n; cin >> n;
	int k; cin >> k;
	rep(i, k) {
		int x, y; cin >> x >> y;
		int mid = (1 + n) / 2;
		if (x > mid) {
			x = n + 1 - x;
		}
		if (y > mid) {
			y = n + 1 - y;
		}
		int ma = min(x, y);
		int ans = ma % 3; if (ans == 0)ans += 3;
		cout << ans << endl;
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}



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

using namespace std;

int main(void) {
  string S, ans = ""; cin >> S;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'B') {
      if (!ans.empty()) {
        ans.pop_back();
      }
    } else {
      ans.push_back(S[i]);
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <vector>
#define X real()
#define Y imag()
#define EPS 1e-10
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
typedef pair<P,double> C;

double dot(P a, P b){
  return a.X*b.X + a.Y*b.Y;
}

double cross(P a, P b){
  return a.X*b.Y - a.Y*b.X;
}

vector<P> sort_comp(vector<P> a){
  int l = a.size();
  vector< pair<double, double> > t(l);
  for(int i = 0; i < l; ++i){
    t[i].first = a[i].X;
    t[i].second = a[i].Y;
  }
  sort(t.begin(),t.end());
  for(int i = 0; i < l; ++i){
    a[i] = P(t[i].first,t[i].second);
  }
  return a;
}

P n_vector(P a){
  double l = abs(a);
  return P(-a.Y,a.X)/l;
}

vector<P> cpcc(C a, C b){
  double d = abs(a.first-b.first), ra = a.second, rb = b.second;
  double t = (ra*ra-rb*rb+d*d)/2/d, h = sqrt(ra*ra-t*t);
  P m = t/abs(b.first-a.first)*(b.first-a.first)+a.first;
  vector<P> cp(2,m);
  P n = n_vector(a.first-b.first);
  cp[0] -= h*n;
  cp[1] += h*n;
  return sort_comp(cp);
}

vector<P> tangent_to_C(P p, C c){
  C c2 = C((p+c.first)/2.0,abs(p-c.first)/2.0);
  return cpcc(c,c2);
}

int main(){
  double x, y, r;
  vector<C> Cs(2);
  cin >> x >> y;
  P p = P(x,y);
  cin >> x >> y >> r;
  C c = C(P(x,y),r);
  vector<P> cp = tangent_to_C(p,c);
  printf("%.10lf %.10lf\n%.10lf %.10lf\n",cp[0].X,cp[0].Y,cp[1].X,cp[1].Y);
  return 0;
}

Measured memory_bytes: 3276
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
typedef pair<int, int> P;
vector<int> G[200000];
P dfs(int v, int p) {
	P ret(0, v);
	for (int to : G[v]) {
		if (to == p) continue;
		P tmp = dfs(to, v);
		ret = max(ret, P(tmp.first + 1, tmp.second));
	}
	return ret;
}
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int s = dfs(0, -1).second;
	int d = dfs(s, -1).first;
	if (d % 3 == 1) cout << "Second" << endl;
	else cout << "First" << endl;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H;
  cin >> H;
  vector<int> A(H);
  for (int i = 0; i < H; i++){
    cin >> A[i];
  }
  for (int i = 0; i < H; i++){
    cout << "node " << i + 1 << ": ";
    cout << "key = " << A[i] << ", ";
    if (i > 0){
      cout << "parent key = " << A[(i - 1) / 2] << ", ";
    }
    if ((i * 2 + 1) < H){
      cout << "left key = " << A[i * 2 + 1] << ", ";
    }
    if ((i * 2 + 2) < H){
      cout << "right key = " << A[i * 2 + 2] << ", ";
    }
    cout << endl;
  }
}


Measured memory_bytes: 3112