akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        // 整数の入力
        long S=sc.nextLong();
        if(S==1000000000000000000L){
            System.out.println("0 0 1000000000 0 0 1000000000");
            return;

        }
        if(S<=1000000000){
            System.out.println("0 0 1 0 0 "+String.valueOf(S));
        }else{
            int x1=0;
            int y1=0;
            int x2=1;
            int y2=1000000000;

            long a=S/1000000000L;
            long b=S%1000000000L;

            int x3=(int)a+1;
            int y3=(int)(1000000000-b);

            System.out.println(x1+" "+y1+" "+x2+" "+y2+" "+x3+" "+y3);




        }


    }
}


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

int minCost(int a[], int n, int k)
{
	int dp[n + 5];

	dp[1] = 0;

	for (int i = 2; i <= n; i++)
	{
		dp[i] = INT_MAX;
		for (int j = i - 1; j >= 1 && (i - j) <= k; j--)
		{
			dp[i] = min(dp[i], abs(a[i] - a[j]) + dp[j]);
		}
	}
	return dp[n];
}

int main()
{
	int n, k;

	cin >> n >> k;

	int a[n + 5];

	for (int i = 1; i <= n; i++)
		cin >> a[i];
	cout << minCost(a, n, k);
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
    int main(void){
        int N;
            cin >> N;
        vector<int> A(N);
            for(int i = 0; i < N; i++){
                cin >> A.at(i);
            }
        int max = A.at(0);
        int min = A.at(0);
            for(int j = 0; j < N; j++){
                if(A.at(j) < min){
                    min = A.at(j);
                }
                if(A.at(j) > max){
                    max = A.at(j);
                }
            }
                cout << max - min << endl;
        
    return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

// dp[i][j]:=iまで見て確定null/a/ab/abc
long long dp[200010][4];
int main(){
    string s; cin>>s;
    int n=s.size();
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        if(s[i-1]=='?'){
            dp[i][0]=dp[i-1][0]*3;
            dp[i][1]=dp[i-1][1]*3+dp[i-1][0];
            dp[i][2]=dp[i-1][2]*3+dp[i-1][1];
            dp[i][3]=dp[i-1][3]*3+dp[i-1][2];
        }else{
            dp[i][0]=dp[i-1][0];
            dp[i][1]=(s[i-1]=='A'?dp[i-1][1]+dp[i-1][0]:dp[i-1][1]);
            dp[i][2]=(s[i-1]=='B'?dp[i-1][2]+dp[i-1][1]:dp[i-1][2]);
            dp[i][3]=(s[i-1]=='C'?dp[i-1][3]+dp[i-1][2]:dp[i-1][3]);
        }
        rep(j,4) dp[i][j]%=MOD;
    }
    cout<<dp[n][3]<<endl;
    return 0;
}


Measured memory_bytes: 4608
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
const int MAX = 1000000;
int selectionSort(int A[], int N){ //N個の要素を含む0-オリジンの配列0
    int minj, sw = 0;
    for(int i = 0; i < N - 1; i++){
        minj = i;
        for(int j = i; j < N; j++){
            if(A[j] < A[minj]) minj = j;
            }
            swap(A[i], A[minj]);
            if(i != minj) sw++;
    }
    return sw;
}

int main(){
    int A[100], N, sw;

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

    sw = selectionSort(A, N);

    for(int i = 0; i < N; i++){
        if(i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;

	return 0;
}


Measured memory_bytes: 3136
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1;i<=n;i++){
        if(i%3==0&&i%5==0) continue;
        else if(i%3==0) continue;
        else if(i%5==0) continue;
        else ans+=i;
    }
    cout<<ans<<endl;
}

//ペナルティ出しても焦らない　ACできると信じろ！！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え(=でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
*/

Measured memory_bytes: 3640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
constexpr long long LINF = 1000100010001000100LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() { 
    int n, c; cin >> n >> c;
    vector<int> S(n), T(n), C(n);
    vector<vector<int>> counter(c, vector<int>(200010));
    rep(i, n){
        cin >> S[i] >> T[i] >> C[i]; C[i]--;
        int a = (S[i]-0.5)*2, b = T[i]*2;
        counter[C[i]][a]++;
        counter[C[i]][b]--;
    }

    rep(i, 200000){
        rep(j, c){
            if(counter[j][i]==1 && counter[j][i+1]==-1){
                counter[j][i] = counter[j][i+1] = 0;
            }
        }
    }

    int mx = 0, cnt = 0;
    rep(i, 200000){
        rep(j, c){
            cnt += counter[j][i];
            chmax(mx, cnt);
        }
    }
    cout << mx << ln;
}

Measured memory_bytes: 25728
import java.lang.Math.sqrt

fun main(args:Array<String>?): Unit {
    val prime = primes(10_000_000)
    val yotsugo = (3 until prime.size).filter{i -> prime[i] - 8 == prime[i - 3] && prime[i - 2] - 2 == prime[i - 1] - 6 && prime[i - 3] == prime[i - 1] - 6}.map{prime[it]}.toIntArray()
    while(true){
        val n = readLine()!!.trim().toInt()
        if (n == 0) return
        println(yotsugo[upperBound(yotsugo, n) - 1])
    }
}
fun upperBound(array: IntArray, target: Int): Int {
    var left = 0
    var right = array.size
    while(left < right){
        val mid = (left + right) / 2
        if (array[mid] <= target){
            left = mid + 1
        }else {
            right = mid
        }
    }
    return right
}

fun primes(upper: Int): IntArray {
    val isPrime = BooleanArray(upper + 1){true}
    for (p in 2 .. sqrt(upper.toDouble()).toInt()) if (isPrime[p]) {
        for (i in p * p .. upper step p) {
            isPrime[i] = false
        }
    }
    return (2 .. upper).filter(isPrime::get).toIntArray()
}


Measured memory_bytes: 121648
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename x>
using ordered_set = tree<x,null_type,less<x>,rb_tree_tag,tree_order_statistics_node_update>;
#define sorta(a,n) sort(a,a+n)
#define sortad(a,n) sort(a,a+n,greater<__typeof(a[0])>())
#define all(x) (x).begin(),(x).end()
#define ms0(x) memset((x),0,sizeof((x)))
#define ms1(x) memset((x),-1,sizeof((x)))
typedef pair<long long,long long> pi;
#define inarr(arr,n) for(long long i=0;i<n;i++)cin>>arr[i];
#define prinarr(arr) {for(long long x:arr)cout<<x<<" ";} cout<<"\n";
#define cout1(a) cout<<a<<"\n";
#define cout2(a,b) cout<<a<<" "<<b<<"\n";
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define setpre(n) cout<<fixed<<setprecision(8)<<n<<"\n";
#define filldp(arr,n,m,k) for(long long i=0;i<n;i++){for(long long j=0;j<m;j++) arr[i][j]=k;}

#define mod 1000000007
#define mod1 998244353


vector<vector<long long>> adj;
vector<long long> dis;
vector<long long> parent;
vector<bool> visited;

void newgr(long long n){
    n+=10;
    adj=vector<vector<long long>>(n);
    dis=vector<long long>(n,0);
    //parent=vector<long long>(n,-1);
    visited=vector<bool>(n,false);
}

void dfs(long long s){
    visited[s]=true;
    for(auto u:adj[s]){
        if(!visited[u]){
            //parent[u]=s;
            dis[u]=dis[s]+1;
            dfs(u);
        }
    }
}

void bfs(long long s){
    queue<long long> q;
    q.push(s);
    visited[s]=true;
    dis[s]=0;
    while(!q.empty()){
        auto u=q.front();
        q.pop();
        for(auto x:adj[u]){
            if(!visited[x]){
                //parent[x]=u;
                visited[x]=true;
                dis[x]=dis[u]+1;
                q.push(x);
            }
        }
    }
}

long long power(long long x,long long y){  
    long long ans=1;
    x%=mod;
    while(y>0){
        if(y&1) ans=(ans*x)%mod;
        y>>=1;
        x=(x*x)%mod;
    }
    return ans;
}

long long modinv(long long b){ 
    return power(b,mod-2);
}


int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    long long n;
    cin>>n;
    long long arr[n];
    inarr(arr,n);
    long long ans=0,a=arr[0];
    for(long long i=1;i<n;i++){
        if(arr[i]<a){
            ans+=a-arr[i];
        }
        else{
            a=arr[i];
        }
    }
    cout1(ans);
    return 0;
}

Measured memory_bytes: 5160
# if required XOR, re-solve later.
# just copy and paste from https://atcoder.jp/contests/abc147/submissions/14707076
for i in range(pow(10,6)):
    pass
# added due to avoid duplicated search list wtih the same solver.
n = int(input())
a = list(map(int,input().split()))
d = 0
m = 10**9+7
for i in range(60):
    b = 1<<i
    l = len([1for j in a if j&b])
    d += l*(n-l)*b%m
    d %= m
print(d)

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

using namespace std;

typedef long long LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = N; i >= 0; i--)

template<typename Container>
bool include(const Container& c, const typename Container::value_type& v) {
  return ( c.end() != std::find(c.begin(),c.end(),v) );
}

template<class T>
vector<T> unique_vec(const vector<T> &v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  return v;
}

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  rep(i, K) {
    if (B >= C) {
      C = C * 2;
    }
    else if (A >= B) {
      B = B * 2;
    }

    if (A < B && B < C) {
      // cout << A << " "  << B << " " << C << endl;
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3588
import Control.Monad

intermediate :: Int -> String
intermediate w
    | w == 1    = "#"
    | w == 2    = "##"
    | otherwise = "#" ++ replicate (w - 2) '.' ++ "#"

solve :: [Int] -> IO ()
solve [h, w] = do
    putStrLn $ replicate w '#'
    when (2 <= h) $ do
        replicateM_ (h - 2) (putStrLn $ intermediate w)
        putStrLn $ replicate w '#'
    putStrLn ""

main :: IO ()
main = getContents >>= mapM_ solve . takeWhile (\[h, w] -> h /= 0 || w /= 0) . map (map read . words) . lines

Measured memory_bytes: 4036
n, m = map(int, input().split())
mod = 10 ** 9 + 7

fact = [-1] * (max(n, m) + 1)
for i in range(max(n, m) + 1):
  if i < 3:
    fact[i] = i
  else:
    fact[i] = i * fact[i - 1] % mod

if abs(n - m) == 0:
  print(fact[n] * fact[m] * 2 % mod)
elif abs(n - m) == 1:
  print(fact[n] * fact[m] % mod)
else:
  print(0)

Measured memory_bytes: 6900
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m, s;
  cin >> n >> m;
  vector<int> a(m);
  for (int i=0; i<m; i++) {
    cin >> a[i]; 
  }  
  
  s = accumulate(a.begin(), a.end(), 0);
  if (s <= n) cout << (n - s) << endl;
  else cout << -1 << endl;
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> s(N);
    for(int i = 0; i<N; i++){
        cin >> s.at(i);
    }
    int now_index = 1, ans = 0;
    while(1){
        if(ans > N-1){
            cout << -1 << endl;
            break;
        } else if (now_index == 2){
            cout << ans << endl;
            break;
        }
        else ans++;
        now_index = s.at(now_index-1);
    }
}

Measured memory_bytes: 768
#include <vector>
#include <set>
#include <map>
#include <string>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <ctime>
using namespace std;

const int len = 20;
long long x, y;
long long p[len];
long long c[len];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie();
    cin >> x >> y;
    for(int i = 0;i < x;i++){
        cin >> p[i] >> c[i];
    }
    int ans = 1 << 30;
    for(int i = 0;i < 1 << x;i++){
        int now = 0;
        long long s = 0;
        vector < int > f;
        for(int j = 0;j < x;j++){
            if((i & (1 << j)) != 0){
                now += p[j];
                s += 100 * (j + 1) * p[j];
                s += c[j];
            } else {
                for(int k = 0;k < p[j];k++)
                    f.push_back(100 * (j + 1));
            }
        }

        sort(f.begin(), f.end());
        reverse(f.begin(), f.end());

        int pos = 0;
        while(s < y && pos < f.size()){
            now++;
            s += f[pos++];
        }

        if(s >= y)
            ans = min(ans, now);
    }

    cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b, c, d;
    int i, N, X, Y;
    
    scanf("%d", &N);
    for(i=0; i<N; i++)
    {
        scanf("%d %d %d", &a, &b, &c);
        if(a>b && a>c)
        {
            d = a;
            a = c;
            c = d;
        }
        
        else if(a<b && b>c)
        {
            d = b;
            b = c;
            c = d;
        }
        X = a*a+b*b;
        Y = c*c;
        if(X == Y)
        {
            printf("YES\n");
        }
        
        else
        {
            printf("NO\n");
        }
    }

    return 0;

}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  long long h;
  cin >> h;
  int n = 0;
  long long k = 1;
  while(k <= h) {
    k *= 2;
    n += 1;
  }
  long long saigo = 1;
  rep(i,n) saigo *= 2;
  cout << saigo - 1 << endl;
}

Measured memory_bytes: 256
import numpy as np
import math

# K = int(input())
# N, K = map(int, input().split())
# A = list(map(int, input().split()))
# S = input() # String
# DP = np.zeros((N, Y), dtype=int)

N = list(map(int, input()))

for i in range(3):
    if N[i] == 1:
        N[i] = 9
    elif N[i] == 9:
        N[i] = 1

print(N[0],N[1],N[2], sep='')


Measured memory_bytes: 22300
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N,L;
	cin >> N >> L;
	V<int> a(N);
	rep(i,N) a[i] = L+i;
	int s = 0, o = a[0];
	rep(i,N){
		s += a[i];
		if(abs(o) > abs(a[i])) o = a[i];
	}
	cout << s - o << endl;
}


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

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

    ll a[N];
    ll sum = 0;

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

    ll ave1,ave2;
    ll ans1 = 0;
    ll ans2 = 0;
    if(sum % N == 0)
    {
        ave1 = sum / N;
        for(ll i = 0; i < N; i++)
        {
            ans1 += pow(a[i]-ave1,2);
        }
    }
    else
    {
        ave1 = sum / N;
        ave2 = sum / N + 1;
        for(ll i = 0; i < N; i++)
        {
            ans1 += pow(a[i]-ave1,2);
        }
        for(ll i = 0; i < N; i++)
        {
            ans2 += pow(a[i]-ave2,2);
        }
        ans1 = min(ans1,ans2); 
    }

    cout << ans1 << endl;
    return 0;
    

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    long long A, B, K;
    cin >> A >> B >> K;
    long long a1;
    long long b1;
    if (A >= K)
    {
        a1 = A - K;
        b1 = B;
    }
    else
    {
        a1 = 0;
        b1 = max(0ll,B - (K - A));
    }

    cout << a1 << " " << b1 << endl;

    return 0;
}


Measured memory_bytes: 3624
n,k = map(int,input().split())
a = list(map(int,input().split()))
inside = 0
for i in range(n):
  for j in range(i+1,n):
    if a[i] > a[j]:
      inside += 1
inside *= k
mod = 10**9+7
a.sort()
b = [0]
for i in range(1,n):
  if a[i-1] == a[i]:
    b.append(b[-1])
  else:
    b.append(i)
outside = sum(b)
kk = k * (k-1) // 2
kk %= mod
outside *= kk
outside %= mod
ans = (inside + outside) % mod
print(ans)

Measured memory_bytes: 3188
package main

import (
	"fmt"
)

func main() {
	var a,b,sum int
	var tako []int
	c := 1
	fmt.Scanf("%d", &a)

	for i:=0; i<a; i++{
		fmt.Scanf("%d", &b)
		tako = append(tako, b)
	}
	for j:=0; j<len(tako); j++{
		for k:=c; k<len(tako); k++{
			sum += tako[j] * tako[k]
		}
		c++
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
N = int(input())
S = input()
lw = [0] * N
re = [0] * N
for i in range(1, N):
  lw[i] = lw[i-1] + (S[i-1] == "W")
  re[-i-1] = re[-i] + (S[-i] == "E")
ans = 10**6
for i in range(N):
  ans = min(ans, lw[i] + re[i])
print(ans)

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

typedef long long ll;

int main() {
  int W,H,N; cin >> W >> H >> N;
  int x[101],y[101],a[101];
  for ( int i = 1; i <= N; i++ ) {
    cin >> x[i] >> y[i] >> a[i];
  }
  char board[101][101];
  for ( int i = 1; i <= H; i++ ) {
    for ( int j = 1; j <= W; j++ ) {
      board[i][j] = 'W';
    }
  }

  for ( int k = 1; k <=N; k++ ) {
    if ( a[k] == 1 ) {
      for ( int i = 1; i <= H; i++ ) {
	for ( int j = 1; j <= x[k]; j++ ) {
	  board[i][j] = 'B';
	}
      }
    }  else if ( a[k] == 2 ) {
      for ( int i = 1; i <= H; i++ ) {
	for ( int j = x[k]+1; j <= W; j++ ) {
	  board[i][j] = 'B';
	}
      }
    }  else if ( a[k] == 3 ) {
      for ( int i = H-y[k]+1; i <= H ; i++ ) {
	for ( int j = 1; j <= W; j++ ) {
	  board[i][j] = 'B';
	}
      }
    }  else if ( a[k] == 4 ) {
      for ( int i = 1; i <= H-y[k]; i++ ) {
	for ( int j = 1; j <= W; j++ ) {
	  board[i][j] = 'B';
	}
      }
    }
  }
  int cnt = 0;
  for ( int i = 1; i <= H; i++ ) {
    for ( int j = 1; j <= W; j++ ) {
      if( board[i][j] == 'W' ) cnt++;
      //     cout << board[i][j];
    }
    //    cout << endl;
  }
  cout << cnt << endl;
  return 0;
}


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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define LOCAL
#define MP make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define PF push_front 
#define PB push_back
#define PP push
#define lb lower_bound 
#define ub upper_bound
#define lowbit(x) x&(-x)
#define testbit(x,i) x&(1<<i)

inline void checkmin(int &x,int y){x=min(x,y);}
inline void checkmax(int &x,int y){x=max(x,y);}

const int maxn = 1e5+10;

int n, a, b, c, cnt[3][maxn];
string str[maxn];
vector<char> ans;

int main() 
{
	#ifndef LOCAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>n>>a>>b>>c;
    for(int i = 0; i < n; i++) {
    	cin>>str[i];
	} 
	for(int i = n - 1; i >= 0; i--) {
		if(str[i] == "AB") {
			cnt[0][i] = cnt[0][i + 1] + 1;
			cnt[1][i] = cnt[1][i + 1] + 1;
		}else if(str[i] == "AC") {
			cnt[0][i] = cnt[0][i + 1] + 1;
			cnt[2][i] = cnt[2][i + 1] + 1;
		}else {
			cnt[1][i] = cnt[1][i + 1] + 1;
			cnt[2][i] = cnt[2][i + 1] + 1;
		}
	}
    for(int i = 0; i < n; i++) {
    	string s = str[i];
    	if(s == "AB") {
    		if(a == 0 && b == 0) {
    			cout<<"No"<<endl;
    			return 0;
			}else {
				if((a < b) || (a == b && cnt[0][i] > cnt[1][i])) {
					++a, --b;
					ans.push_back('A');
				}else {
					--a, ++b;
					ans.push_back('B');
				}
			}
		}else if(s == "AC") {
    		if(a == 0 && c == 0) {
    			cout<<"No"<<endl;
    			return 0;
			}else {
				if((a < c) || (a == c && cnt[0][i] > cnt[2][i])) {
					++a, --c;
					ans.push_back('A');
				}else {
					--a, ++c;
					ans.push_back('C');
				}
			}
		}else {
    		if(b == 0 && c == 0) {
    			cout<<"No"<<endl;
    			return 0;
			}else {
				if((b < c) || (b == c && cnt[1][i] > cnt[2][i])) {
					++b, --c;
					ans.push_back('B');
				}else {
					--b, ++c;
					ans.push_back('C');
				}
			}
		}
	}
	cout<<"Yes"<<endl;
	for(int i = 0; i < ans.size(); i++) {
		cout<<ans[i]<<endl;
	}
    /* end code */
	return 0;
}

Measured memory_bytes: 8084
import math
a,b,x=map(int,input().split())
left=a*a*b-x
if left<=x:
	degree=math.degrees(math.atan(2*left/(a*a*a)))
else:
	degree=90-math.degrees(math.atan(2*x/(a*b*b)))
print('{:.8f}'.format(degree))

Measured memory_bytes: 3060
ans :: Double -> Int
ans v =
  let y = v * v / 9.8 / 9.8 * 4.9
  in
    ceiling $ (y + 5) / 5
  
main = do
  c <- getContents
  let i = map read $ lines c :: [Double]
      o = map ans i
  mapM_ print o

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll k,n;

int main(){
  cin >> n >> k;
  cout << n-k+1 << endl;

}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

}

signed main() {
	ll n, a, b;

	cin >> n;

	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else {
		cin >> a >> b;

		cout << a + b << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define MAX                 10000007
#define MIN                 -10000007



              
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
      
    int t;
    t=1;
     //  cin>>t;
    while(t--){
            int n,k,sum=0,a[1002];
            cin>>n>>k;
            REP(i,0,n-1){cin>>a[i];}
            sort(a,a+n);
            REP(i,0,k-1){sum+=a[i];}
            cout<<sum;  
       


             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


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

int main(){
    int n, k;
    int j = 0;
    cin >> n >> k;
    int i = 1;
    while(j == 0){
        if(n < pow(k, i)){
            cout << i << endl;
            j++;
        }
        i++;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

vector<ll> sosuu;

int main(){
    ll x;cin>>x;
    bool b;
    sosuu.pb(2);
    rep(i,3,200000){
        b=false;
        rep(j,0,sosuu.size()-1){
            if(i%sosuu[j]==0){
                b=true;
                break;
            }
        }
        if(b){
            continue;
        }
        sosuu.pb(i);
    }
    ll ans=0;
    rep(i,0,sosuu.size()-1){
        if(sosuu[i]>=x){
            ans=sosuu[i];
            break;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 640
#include <stdio.h>

#define N 8

int Q[N][N];
int dpos[2*N-1];
int dneg[2*N-1];
int t[N];
int y[N];

void board(void){

  int i;
  int j;

  for(i=0; i<N; i++){
    for(j=0; j<N; j++){

      if(Q[i][j]==1){
	if(t[i]!=j) return;
      }

    }
  }

  for(i=0; i<N; i++){
    for(j=0; j<N; j++){

      if(t[i]==j){
	printf("Q");
      }

      else{
	printf(".");
      }

    }
    printf("\n");
  }
}


void putQ(int i){
  int j;

  if(i== N){
    board();
    return;
  }

  for(j=0; j<N; j++){
    if(y[j]==1 || dpos[i+j]==1 || dneg[i-j+N-1]==1)
      continue;

    t[i] = j;
    y[j] = dpos[i+j] = dneg[i-j+N-1] = 1;
    putQ(i+1);
    y[j] = dpos[i+j] = dneg[i-j+N-1] = 0;
  }

}


int main(){

  int i;
  int n;
  int qt;
  int qy;

  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf("%d%d",&qt,&qy);
    Q[qt][qy] = 1;
  }

  putQ(0);

  return 0;
}




Measured memory_bytes: 2096
N = int(input())
H = [int(hoge) for hoge in input().split()]
R = [H[i] >= H[i+1] for i in range(N-1)]
ans = 0
cur = 0
for r in R:
    if r:
        cur += 1
        ans = max(cur,ans)
    else:
        cur = 0
print(ans)

Measured memory_bytes: 64228
#include <bits/stdc++.h>
#define ll long long
#define fastio std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll inf = 1e18L +5;
using namespace std;

void max_self(ll &a, ll b){
    a = max(a,b);
}

void min_self(ll &a, ll b){
    a = min(a,b);
}

int main() {
	fastio;
	int n, W;
	cin>>n>>W;
	vector<int> w(n),v(n);      // w - weight    v- value
	for(int i=0;i<n;i++)
	    cin>>w[i]>>v[i];
	int sum_value =0 ; 
	for(int x: v)
	    sum_value+=x;
	vector<ll> dp(sum_value+1, inf);  
	dp[0]=0;
	// dp[i] - the minimum total weight of items with 
	//total value exactly 'i'
    for(int item = 0 ; item < n ; item++)
        for(int value_already =sum_value - v[item]; value_already >=0; value_already--)
            min_self(dp[value_already+v[item]], dp[value_already ]+ w[item]);
    ll ans{0};
    for(int i=0; i<=sum_value;i++)
        if(dp[i]<=W)
            max_self(ans,(ll)i);
    cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

template<typename T>
vector<T> cumulative_sum(vector<T> &v) {
    vector<T> sum(v.size() + 1);
    for(int i = 0; i < (int)v.size(); ++i){
        sum[i+1] = sum[i] + v[i];
    }
    return sum;
}
/*使うとき
vector<int> a(N);
auto cum = cumlative_sum(a)
とするとvector<int> cumが生成される

i番目までの仕切りの和
cum[i]: [0,i)の和（半開区間）

要素i~jの和が欲しい時
j+1 ~ i番目の仕切りまで数えればよい
int sum = cum[j+1]-cum[i]
*/
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;cin>>N;
    vector<ll> A(N);
    rep(i,N)cin>>A[i];
    auto cumsum = cumulative_sum(A);
    map<ll,ll> map;
    rep(i,(int)cumsum.size()){
        map[cumsum[i]]++;
    }
    ll ans = 0;
    for(auto p: map){
        ans += p.second*(p.second-1)/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 15872
N = int(input())
H = list(map(int, input().split()))
h = 0
for i in range(N-1):
    # print(h,H[i]-1,H[i],H[i+1])
    if h <= H[i]-1 <= H[i+1] or h <= H[i] <= H[i+1]:
        h = max(H[i]-1,h)
    else:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 14396
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
	char S[100002];
	scanf("%s", S);
	for (int i = 0; i < strlen(S); i++) {
		if (i % 2 == 0) {
			printf("%c", S[i]);
		}
	}
	printf("\n");





#ifdef DEBUGF
	getch();
#endif
	return 0;
	}

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

int main(){
  int a,b;cin >> a >> b;
  if(a == b)cout << "a == b" << endl;
  else if(a > b)cout << "a > b" << endl;
  else cout << "a < b" << endl;
  return 0;
}


Measured memory_bytes: 3108
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int A, B;
int d[11][11];
bool flag[11][11];
vector<pair<pair<int, int>, int>> out;
map<pair<int, int>, int>tmp;

#define PAPAPAPAPAPA 1

int main(void)
{
	cin >> A >> B;
	for (int i = 0; i < A; ++i) {
		for (int j = 0; j < B; ++j) {
			cin >> d[i][j];
		}
	}
	for (int xk = 0; xk <= 100; ++xk) {
		for (int yk = 0; yk <= 100; ++yk) {
			int small = INT_MIN;
			for (int i = 0; i < A; ++i) {
				for (int j = 0; j < B; ++j) {
					//if (flag[i][j])continue;
					int val = (i + 1) * xk + (j + 1) * yk;
					small = max(small, d[i][j] - val);
				}
			}
			if (small < 0)continue;
			for (int i = 0; i < A; ++i) {
				for (int j = 0; j < B; ++j) {
					int val = (i + 1) * xk + (j + 1) * yk;
					if (small == d[i][j] - val) {
						if (!flag[i][j]) {
							flag[i][j] = true;
							int from = 0 + xk;
							int to = 201 - yk;
							if (tmp.count({ from,to })) {
								tmp[{from, to}] = min(tmp[{from, to}], small);//バグの可能性あり
							}
							else {
								tmp[{from, to}] = small;
							}
							assert(small <= 100);
						}
					}
				}
			}
		}
	}
	for (int i = 0; i < A; ++i) {
		for (int j = 0; j < B; ++j) {
			if (!flag[i][j]) {
				cout << "Impossible\n";
				return 0;
			}
		}
	}
	cout << "Possible\n";
	for (auto tm : tmp) {
		out.push_back(tm);
	}
	out.push_back({ { 202,0 },0 });
	out.push_back({ { 202,101 },0 });
	out.push_back({ { 100,203 },0 });
	out.push_back({ { 201,203 },0 });
	for (int i = 0; i < 100; ++i) {
		out.push_back({ { i,i + 1 },-1 });
		out.push_back({ { i + 101,i + 102 },-2 });
	}
	cout << 204 << " " << (int)out.size() << endl;
	for (auto elm : out) {
		cout << elm.first.first + 1 << " " << elm.first.second + 1 << " ";
#if PAPAPAPAPAPA
		if (elm.second == -1) {
			cout << "X\n";
		}
		else if (elm.second == -2) {
			cout << "Y\n";
		}
		else {
#endif
			cout << elm.second << endl;
#if PAPAPAPAPAPA
		}
#endif
	}
	cout << "203 204\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <array>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;

struct Problem {

	void Solve() {
		int x, y; cin >> x >> y;
		int L = 0, T = 1, R = 1, B = 0;
		int C = 0;
		int D = 0;
		while (true) {

			if (L <= x && x < R)
				if (B <= y && y < T) {
					cout << C + 1 << endl;
					break;
				}

			if (D == 0) { R += (T - B); }
			if (D == 1) { T += (R - L); }
			if (D == 2) { L -= (T - B); }
			if (D == 3) { B -= (R - L); }

			D = (D + 1) % 4;
			C = (C + 1) % 3;
		}
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}



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

int main(){
  ll n,k,array[100000]={},a[100000],b[100000];
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
    array[a[i]-1]+=b[i];
  }
  for(int i=0;i<100000;i++){
    if(array[i]>=k){
      cout<<i+1<<endl;
      return 0;
    }
    k-=array[i];
  }
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using ll=long long;

int h, w, cnt;
string s[50];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
bool ans = 1;

int main(){
  cin >> h >> w;
  rep(i,h) cin >> s[i];
  rep(i,h)rep(j,w){
    if(s[i][j] == '.') continue;
    cnt = 1;
    rep(dir,4) {
      if(i + dx[dir] >= 0 && i + dx[dir] < h && j + dy[dir] >=0 && j + dy[dir] < w){
        if(s[i + dx[dir]][j + dy[dir]] == '#') cnt++;
      }
    }
    if(cnt<2) ans = 0;
  }
  cout << ((ans) ?"Yes" :"No") << endl;
}

Measured memory_bytes: 256
from functools import reduce
import bisect

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10

    # mod用
    p=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]    

    N = int(input().rstrip())
    A = list(map(int, input().split()))
    # A = list(int(_) for _ in input().split())
    # A = list(input().split())
    A.sort()
    flag = False
    if A[0] == 0 and N%2 == 1:
        flag = True
        for i in range(N):
            if A[i] != (i + 1) // 2 * 2:
                flag = False
                break
    if A[0] == 1 and N%2 == 0:
        flag = True
        for i in range(N):
            if A[i] != i // 2 * 2 + 1:
                flag = False
                break
    if flag:
        print(2**(N//2) % p)
    else:
        print(0)
        
if __name__ == '__main__':
    main()


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

int main(){

    string s; cin >> s;
    int a = -1;
    int z = 0;
    for(int i = 0; i < s.size(); i++){
        if(a == -1 && s[i] == 'A') a = i;
        if(s[i] == 'Z') z = i;
    }

    cout << z - a + 1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

int main()
{
    int num;
    std::cin >> num; 
    int edge[3];

    for(int i = 0; i < num; i++) {

        std::cin >> edge[0] >> edge[1] >> edge[2];

        // "edge" to "edge+3" ha "array edge" no memory jyou no
        // adress no hajimari to owari wo simesu. 
        // Yoku miru to kou natteru ==> [hajimari, owari)
        std::sort(edge, edge + 3);

        if(edge[2] * edge[2] == edge[0] * edge[0] + edge[1] * edge[1]) {
            std::cout << "YES" << std::endl;
        } else {
            std::cout << "NO" << std::endl;
        }

    }
}

Measured memory_bytes: 3136
macro_rules! get_one {
    ($t:ty) => {{
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse::<$t>().unwrap()
    }};

    ($t:ty; $n:expr) => {
        (0..$n).map(|_| get_one!($t)).collect::<Vec<_>>()
    };
}

fn main() {
    let n = get_one!(usize);
    let mut v_num_f: Vec<usize> = vec![0; 100];
    let mut v_num_g: Vec<usize> = vec![0; 100];

    for i in 1..n+1 {
        let (ht, th) = f(i);
        v_num_f[ht] += 1;
        v_num_g[th] += 1;
    }

    let sum: usize = v_num_f.into_iter().zip(v_num_g.into_iter())
        .map(|(a, b)| a * b)
        .sum();

    println!("{}", sum)

}

/// 両端だけを取る．
fn f(num: usize) -> (usize, usize) {
    let strnum = num.to_string();
    let head = strnum.chars().nth(0).unwrap();
    let tail = strnum.chars().rev().nth(0).unwrap();
    let ht = vec![head, tail].into_iter().collect::<String>().parse::<usize>().unwrap();
    let th = vec![tail, head].into_iter().collect::<String>().parse::<usize>().unwrap();
    (ht, th)
}


Measured memory_bytes: 4352
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007
var mod1 int = 1000000007

type con struct {
	a int
	b int
}

func conunt(d int, a []int) int {
	ans := 0
	for i := 0; i < len(a); i++ {
		if a[i] == d {
			ans++
		}
	}
	return ans
}

func modPlus(a int, b int) int {
	return a%mod1 + b%mod1
}

func modTime(a int, b int) int {
	return a % mod1 * b % mod1
}

func modMinus(a int, b int) int {
	tm := (a - b) % mod1
	if tm < 0 {
		tm += mod1
	}
	return tm
}

func modDiv(a int, b int) int {
	return a % mod1 * modInv(b) % mod1
}

func modInv(a int) int {
	b := mod1
	u := 1
	v := 0
	for {
		if b == 0 {
			break
		}
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= mod1
	if u < 0 {
		u += mod1
	}
	return u
}

var inf = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	//予備
	n := iScan()
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
		b[i] = iScan()
	}
	sort.Slice(a, func(i int, j int) bool {
		return a[i] <= a[j]
	})
	sort.Slice(b, func(i int, j int) bool {
		return b[i] <= b[j]
	})
	if n%2 == 1 {
		fmt.Println(b[(n-1)/2] - a[(n-1)/2] + 1)
	} else {
		M := (b[(n+1)/2] + b[(n-1)/2])
		m := (a[(n+1)/2] + a[(n-1)/2])
		//fmt.Println(M, m)
		fmt.Println((M - m + 1))
	}
}


Measured memory_bytes: 8372
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>

constexpr int str_length = 300;
char S[str_length + 10];

constexpr int mod = 998244353;
int DP[str_length + 1][str_length + 1];
int EP[str_length + 1][str_length + 1];

int main(void){
    int K; std::cin >> S >> K;
    const int n = strlen(S);
    std::vector<int> A(0); A.reserve(n);
    int sum = 0;
    for(int i = 0; i < n; ){
        int cnt = 0; while(i + cnt < n and S[i + cnt] == '1') ++cnt;
        A.push_back(cnt); i += cnt + 1; sum += cnt;
    }

    std::reverse(A.begin(), A.end());
    const int m = A.size();
    DP[0][0] = 1;
    for(int i = 0; i < m; ++i){
        std::memset(EP, 0, sizeof(EP));
        for(int chokin = 0; chokin <= sum; ++chokin){
            for(int k = 0; k <= sum; ++k) if(DP[chokin][k]){
                for(int move = (-k < -chokin) ? -chokin : -k; move <= A[i]; ++move){
                    const int nxt_k = ((0 < move) ? move : 0) + k;
                    if(nxt_k > K) continue;
                    (EP[chokin + move][nxt_k] += DP[chokin][k]) %= mod;
                }
            }
        }
        std::swap(DP, EP);
    }
    int res = 0;
    for(int i = 0; i <= sum; ++i){ res += DP[0][i]; if(res >= mod) res -= mod; }
    std::cout << res << '\n';
    return 0;
}

Measured memory_bytes: 3908
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    int n = s.length();
    string tmp = "";
    bool f = false;
    rep(i, n) {
        if (f) {
            f = false;
            continue;
        }
        if (s[i] == 'B' & s[i+1] == 'C') {
            tmp += 'D'; 
            f = true;
        }
        else {
            tmp += s[i];
        }
    }
    s = tmp;
    
    n = s.length();
    int count = 0;
    int start = n-1;
    ll ans = 0;
    rrep(i, n) {
        if (s[i] == 'B' | s[i] == 'C') {
            count = 0;
            start = i-1;
            continue;
        }
        if (s[i] == 'A') {
            ans += start - i - count;
            count++;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
#define ll long long
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << n*n*n << endl;
	return 0;
}


Measured memory_bytes: 3140