akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
const int maxn=1e5+10;
using namespace std;
inline ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
inline ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
inline void umax(ll &p,ll q){if(p<q)p=q;}
inline void umin(ll &p,ll q){if(p>q)p=q;}
inline ll read()
{
    ll x=0;int f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m,k,t;
ll a[maxn],b[maxn];
int main()
{
    int i,j;
    scanf("%d",&n);
    rep(i,1,n)a[i]=read(),b[i]=read();
    ll ret=0;
    for(i=n;i>=1;i--)
    {
        ret+=(a[i]+ret)%b[i]==0?0:((a[i]+ret)/b[i]+1)*b[i]-(a[i]+ret);
    }
    printf("%lld\n",ret);
    return 0;
}


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

using namespace std;

#define MAX 1010
#define MAX_P 12
typedef vector<char> Vec;
typedef vector<Vec> Mat;

int dp[MAX][1<<MAX_P];

int get_dir(char ch)
{
    if (ch == 'L') return 0;
    if (ch == 'U') return 1;
    if (ch == 'R') return 2;
    return 3;
}

int main()
{
    int HPi, HPm;
    while (cin >> HPi >> HPm, HPi) {
        int H, W;
        cin >> H >> W;
        Mat a(H, Vec(W));
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cin >> a[i][j];
            }
        }
        int T, d, dmg[26] = {}, S;
        char ch;
        cin >> T;        
        for (int i = 0; i < T; i++) {
            cin >> ch >> d;
            dmg[ch-'A'] = d;
        }
        cin >> S;
        
        char dir;
        int dist, x = 0, y = 0;
        vector<int> vec;
        const int dx[] = {-1, 0, 1, 0};
        const int dy[] = {0, -1, 0, 1};
        
        for (int i = 0; i < S; i++) {
            cin >> dir >> dist;
            int d = get_dir(dir);
            for (int j = 0; j < dist; j++) {
                x += dx[d]; y += dy[d];
                vec.push_back(dmg[a[y][x]-'A']);
            }
        }

        int P;
        cin >> P;
        vector<int> p(P);
        for (int i = 0; i < P; i++) {
            cin >> p[i];
        }
        
        memset(dp, -1, sizeof(dp));
        dp[0][0] = HPi;
        
        int N = vec.size();
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < (1<<P); j++) {
                if (dp[i][j] <= 0) continue;
                if (dp[i][j] - vec[i] > 0) {
                    dp[i+1][j] = max(dp[i+1][j], dp[i][j] - vec[i]);
                }
                for (int k = 0; k < P; k++) {
                    if (j >> k & 1) continue;
                    dp[i][j|(1<<k)] = max(dp[i][j|(1<<k)], min(dp[i][j] + p[k], HPm));
                }
            }
        }
        bool reachable = 0;
        for (int i = 0; i < (1<<P); i++) {
            if (dp[N][i] > 0) {
                reachable = 1;
                break;
            }
        }
        cout << (reachable ? "YES" : "NO") << endl;
    }
    return 0;
}

Measured memory_bytes: 19196
/* ***********************************************
Author        :axp
Created Time  :2016/9/11 20:12:41
TASK		  :C.cpp
LANG          :C++
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

typedef long long ll;
const int inf = 1<<30;
const int md = 1e9+7;
ll n;
ll x;
ll ans;
int ar[20];

ll f(int x)
{
	if(x==0)return 1;
	return 1<<x-1;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    cin>>x;
	while(x)
	{
		ar[++n]=x%10;
		x/=10;
	}
	for(int i=1;i<=n/2;i++)swap(ar[i],ar[n+1-i]);
	ll v;
	for(int i=1;i<=n;i++)
	{
		v=0;
		for(int j=i;j<=n;j++)
		{
			v=v*10+ar[j];
			ans+=v*f(i-1)*f(n-j);
		}
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;

#define _GLIBCXX_DEBUG
#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end())

void Add(ll &a, ll b){a=(a+b)%mod;}
void Pro(ll &a, ll b){a=(a*b)%mod;}

int main(){
    ll N,M; cin>>N>>M;
    dsu d(N);
    rep(i,M){
        ll x,y; cin>>x>>y; x--; y--;
        d.merge(x,y);
    }
    cout<<d.groups().size()-1<<endl;
}

Measured memory_bytes: 8968
def main():
    n = int(input())
    ans = 0

    fac = 2
    e = 1
    while True:
        div = pow(fac, e)
        if n % div == 0:
            n //= div
            ans += 1
            e += 1
        else:
            while n % fac == 0:
                n //= fac
            if fac == 2:
                fac += 1
            else:
                fac += 2
            if fac * fac > n:
                break
            e = 1
    if n != 1:
        ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){
  string N;
  cin >> N;
  
  int A = 0;
  
  for(int i = 0; i < 3; i++){
    if(N.at(i) == '1'){
      A++;
    }
  }
  
  cout << A << endl;
  
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if a*500+b*100+c*50 == X:
                count += 1
print(count)


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

int main(){
  ll n;cin>> n;ll b=n+1;
  for(ll i=2;i*i<=n;i++){
    if(n%i==0){
      b=min(i+n/i,b);
    }
  }
  cout << b-2<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
  string input;
  string output;
  cin >> input;
  for(int i=0;i<input.length();i++)
  {
  	output += input[i];
    if(input[i] == 'B')
    {
      if(output.length() == 1)
      {
        output.pop_back();
        continue;
      }
      output.pop_back();
      output.pop_back();
    }
  }
  
  cout << output;
  return 0;
}


Measured memory_bytes: 256
open System.Collections.Generic

type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextI32()|]

    member public this.IArrayI32(n: int) =
        [|for i in 0 .. n - 1 -> this.NextI32(), i|]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextI64()|]

    member public this.IArrayI64(n: int) =
        [|for i in 0 .. n - 1 -> this.NextI64(), i|]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextF32()|]

    member public this.IArrayF32(n: int) =
        [|for i in 0 .. n - 1 -> this.NextF32(), i|]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextF64()|]

    member public this.IArrayF64(n: int) =
        [|for i in 0 .. n - 1 -> this.NextF64(), i|]

    member public __.Tuple2Array n (f : int -> 'a list) =
        [|for _ in 0 .. n - 1 -> f 2 |> fun x -> x.[0], x.[1]|]
    
    member public __.Tuple3Array n (f : int -> 'a list) =
        [|for _ in 0 .. n - 1 -> f 3 |> fun x -> x.[0], x.[1], x.[2]|]

    member public __.CountDic n (f : unit -> 'a) =
        let seqs = seq {for _ in 0 .. n - 1 -> f()}
        let dic = new Dictionary<'a, int64>();
        for i in seqs do
            if dic.ContainsKey(i)
            then dic.[i] <- dic.[i] + 1L
            else dic.Add(i, 1L)
        dic

end

[<EntryPoint>]
let main _ =
#if DEBUG
    printfn "debuged"
#endif

    let scanner = Scanner()
    let abc = scanner.ArrayI32(3)
    let mx = Array.max abc
    let mn = Array.min abc
    let mxl = abc |> Array.where(fun x -> x = mx) |> Array.length
    let mnl = abc |> Array.where(fun x -> x = mn) |> Array.length
    if mxl = 2 || mnl = 2 then "Yes" else "No"
    |> printfn "%s"

    0


Measured memory_bytes: 12124
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define fo(x,a,b) for(register int x=a;x<=b;x++)
#define dfo(x,a,b) for(register int x=a;x>b;x--)
using namespace std;
int n,a[1000000];
bool ans[1000000];
int main ()
{	
	fo(i,2,999999)
	{
		ans[i]=true;
		fo(j,2,sqrt(i))
		{
			if (i%j==0) {ans[i]=false;break;}
		}
		
	}
	do
	{
		scanf("%d",&n);
		if (getchar()!='\n') break;
		int te=0;
		if (a[n]==0)
		{
			fo(i,2,n)
			{
				if (ans[i]) te++;
			}
			a[n]=te;
		}
		printf("%d\n",a[n]);
	} while (true);
	
	return 0;
}




Measured memory_bytes: 4136
N, K = map(int, input().split(" "))
A = list(map(int, input().split(" ")))

# for a in A:
#     print(bin(a)[2:].rjust(6, "0"))

# Xは桁ごとに最適があるがK以下という制限があると、
# 最適が変わる可能性がある
x = 0
for i in range(39, -1, -1):
    b = sum((a>>i)%2 for a in A)*2 < N
    # print(b, b<<i)
    if x+(b<<i) <= K:
        x += (b<<i)
    else:
        continue

# for i in range(39, -1, -1):
#     if x <= K:
#         break
#     x = x&((1<<i)-1)

print(sum(x^a for a in A))

Measured memory_bytes: 14596
### main

n, k = gets.strip.split(' ').map{|s| s.to_i}

xhash = {}
yhash = {}
zhash = {}
cbs = []

n.times do
  x0, y0, z0, x1, y1, z1 = gets.strip.split(' ').map{|s| s.to_i}
  cbs << [x0, y0, z0, x1, y1, z1]
  xhash[x0] = xhash[x1] = yhash[y0] = yhash[y1] = zhash[z0] = zhash[z1] = 0
end

xs = xhash.keys.sort
ys = yhash.keys.sort
zs = zhash.keys.sort
nxs = xs.length - 1
nys = ys.length - 1
nzs = zs.length - 1
#p [xs, ys, zs]

xs.each_with_index{|x, i| xhash[x] = i}
ys.each_with_index{|y, i| yhash[y] = i}
zs.each_with_index{|z, i| zhash[z] = i}
#p [xhash, yhash, zhash]

ovls = nxs.times.map{nys.times.map{nzs.times.map{0}}}

for cb in cbs
  x0, y0, z0, x1, y1, z1 = cb
  for xi in (xhash[x0]...xhash[x1])
    for yi in (yhash[y0]...yhash[y1])
      for zi in (zhash[z0]...zhash[z1])
        ovls[xi][yi][zi] += 1
      end
    end
  end
end

vsum = 0

for xi in (0...nxs)
  dx = xs[xi + 1] - xs[xi]
  for yi in (0...nys)
    dy = ys[yi + 1] - ys[yi]
    for zi in (0...nzs)
      dz = zs[zi + 1] - zs[zi]
      if ovls[xi][yi][zi] >= k
        vsum += dx * dy * dz
      end
    end
  end
end

puts vsum

Measured memory_bytes: 16728
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Ord

main :: IO ()
main = readLn >>= readContents >>= putStrLn . solve 

solve :: [[Int]] -> String
solve = check . sortBy cmpf
    where
        cmpf lhs rhs = comparing last rhs lhs `mappend` comparing head rhs lhs
        check (x : xs) = inner (last x) $ x : xs

        inner t xxs@([a, b] : xs)
            | t < 0 = "No"
            | b < t = inner b xxs
            | t - a < 0 = "No"
            | otherwise = inner (t - a) xs
        inner _ _ = "Yes"

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

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

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

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector <ll> vll;
typedef vector <int> vii;
typedef vector <pll> vpll;
typedef vector <pii> vpii;
const int N = 1e5 + 5;
const int inf = 1e9 + 7;

int a[N];

void solve() {
	int n, k, ans = 0;
	cin >> n >> k;
	for (int i = 1;i <= n; i ++)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= k; i ++)
		ans += a[i];
	cout << ans << endl;
}

int main() {
	int tests = 1;
//	cin >> tests;
	while (tests --)
		solve();
	return 0;
}









Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(a) for(int k=head[a];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=3e5+5,M=5e3+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
int r[N],x,K;
int main(){//judge();
	read(x,K);
	rep(i,1,K)read(r[i]);
	int sgn=-1,pt=1,aa=0,bb=x,lover=0;
	int Q=read();rep(cas,1,Q){
		int t,a;read(t,a);
		while(t>=r[pt]&&pt<=K){
			int dt=sgn*(r[pt]-r[pt-1]);lover+=dt;
			aa+=dt;gmin(aa,x);gmax(aa,0);
			bb+=dt;gmin(bb,x);gmax(bb,0);
			pt++;sgn=-sgn;
		}
		int res=lover+a;
		gmin(res,bb);gmax(res,aa);
		res+=sgn*(t-r[pt-1]);
		gmin(res,x);gmax(res,0);
		cout<<res<<endl;
	}
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    ll n,m,x; cin>>n>>m>>x;
    vector<ll> a(m);
    ll left=0,right=0;
    rep(i,m) cin>>a[i];
    rep(i,m){
        if(a[i]<x) left++;
        else right++;
    }
    ll res=(left<right) ? left : right;
    cout<< res <<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int AmodK = A % K;
        if (((B - A) >= (K - AmodK)) || (AmodK == 0)) {
            System.out.println("OK");
        } else {
            System.out.println("NG");
        }
    }
}

Measured memory_bytes: 35852
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a / gcd(a, b) * b; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

inline ll mod(ll a){
    return (a + MOD)%MOD;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    ll n,type = 1,ans = 1;
    //type == 0   | type == 1
    //  o         |  o o
    //  o         |  x x

    bool flag = true;//一番左のブロックか?
    cin>>n;
    string s[2];
    rep(i,2)cin>>s[i];
    rep(i,n){
        if(flag){
            flag = false;
            if(s[0][0] == s[1][0]){
                type = 0;
                ans *= 3;
            }
            else{
                ans *= 6;
                i++;
            }

        }
        else if(s[0][i] == s[1][i]){
            //type == 0
            if(type == 0){
                ans *= 2;
                ans = mod(ans);
            }
            else{
                type = 0;
            }
        }
        else{
            //type == 1
            i++;
            if(type == 0){
                type = 1;
                ans *= 2;
                ans = mod(ans);
            }
            else{
                ans *= 3;
                ans = mod(ans);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cctype>
#include <iostream>
#include <string>

using namespace std;

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

    string result("WA");
    if (s[0] == 'A') {
        int c_idx = -1;
        for (int i = 2; i < s.length() - 1; ++i) {  // find 'C'
            if (s[i] == 'C') {
                c_idx = i;
                break;
            }
        }

        if (c_idx != -1) {  // check all chars are lowercase except 'A' and 'C'
            bool flag = true;
            for (int i = 1; i < s.length(); ++i) {
                if (i != c_idx && islower(s[i]) == 0) {
                    flag = false;
                    break;
                }
            }
            if (flag)
                result = "AC";
        }
    }
    cout << result << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;
typedef vector<double> vd;


const int mod = 100000007;
const int inf = 100000005;
const int N = 200005, M = N;
int i,j,n,m;

ll cnt , idx;
vi temp;



void solve() {
   ll n,k,q;
   cin>>n>>k>>q;
   vl vec(n+1,k-q);
   ll x;

   fo(i,0,q) cin>>x , vec[x]++;

   fo(i,1,n+1) {
    if(vec[i] > 0) cout<<"Yes\n";
    else cout<<"No\n";
   }

}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}




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

using namespace std;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll         long long int
#define co         cout
#define ci         cin
#define sf1(n)     scanf("%lld",&n)
#define sf2(n,m)   scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p);
#define pf1(n)     printf("%lld\n",n);
#define en         cout<<endl;
#define pb         push_back
#define fi         first
#define se         second
#define coy        cout<< "YES"<<endl;
#define con        cout<< "NO"<<endl;
#define f(a,b)     for(ll i=a;i<b;i++)
#define pi         pair<ll,ll>
#define br         break;
#define i64        long long

int main()
{
    ll t,n,c,res;
    ci>>n;
    vector<ll>a(n);
    c=0;
    f(0,n)
    {
        ci>>a[i];
        if(a[i]==0) c=1;
    }
    if(c)
    {
        co<<0LL<<endl;
        return 0;
    }
    res=1;
    f(0,n)
    {
        if(a[i]<=1000000000000000000/res) res*=a[i];
        else
        {
            co<<-1LL<<endl;
            return 0;
        }
    }
    co<<res;
    return 0;
}



Measured memory_bytes: 4000
import Data.Ratio
main = do
  n <- readLn
  putStrLn $ unwords $ map show $ head [
    [h,m,w] |
      h <- [3500,3499..(n`div`4)`max`1],
      let x = 4%n - 1%h,
      m <- [3500,3499..(numerator x`div`denominator x)`max`h],
      let y = x - 1%m,
      numerator y == 1,
      let w = denominator y]


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

int main(void){
    int sx,sy,tx,ty; cin >> sx >> sy >> tx >> ty;
    string u(ty-sy,'U'),r(tx-sx,'R'),d(ty-sy,'D'),l(tx-sx,'L');
    string s = u+r+d+l+'L'+u+'U'+r+"RDR"+d+'D'+l+"LU";
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
function main(input) {
    var num = input.split(" ");
    var result = parseInt(num[0]) * parseInt(num[1]);
    if(result % 2 == 0){
        console.log("Even")
    }else{
        console.log("Odd");
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 9420
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  int N;
  cin >> N;

  long long a[N + 1];
  for (int i = 0; i < N + 1; ++i)
    cin >> a[i];

  long long b[N];
  for (int i = 0; i < N; ++i)
    cin >> b[i];

  long long ret = 0;
  for (int i = 0; i < N; ++i) {
    // defeat his town
    if (a[i] > b[i]) {
      a[i] -= b[i];
      ret += b[i];
      b[i] = 0;
    } else {
      ret += a[i];
      b[i] -= a[i];
      a[i] = 0;
    }

    // defeat next town
    if (a[i + 1] > b[i]) {
      a[i + 1] -= b[i];
      ret += b[i];
      b[i] = 0;
    } else {
      ret += a[i + 1];
      b[i] -= a[i + 1];
      a[i + 1] = 0;
    }
  }

  cout << ret << endl;

}

Measured memory_bytes: 1792
#include <stdio.h>

int main() {
  int a, b, x=-1;
  scanf("%d %d", &a, &b);
  for(int i=b*10; i<(b+1)*10; ++i) {
    if ((int)(i*0.08) == a) {
      x = i;
      break;
    }
  }
  printf("%d", x);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void){
    int num;
    int k;
    char str[50];
    int i;
    
    scanf("%d%d",&num,&k);
    scanf("%s", str);

    for(i=0; i<num; i++){
        printf("%c", k-1==i?str[i]-('A'-'a'):str[i]);        
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cstring>

using namespace std;
typedef pair<int, int> pii;

int dp[2][101][1001];

int main(){
        while(true){
                int LIMIT, N, M, X;
                cin >> LIMIT >> N >> M >> X;
                if(LIMIT == 0 && N == 0 && M == 0 && X == 0){ break; }
                memset(dp, -1, sizeof(dp));
                vector<pii> secret(N);
                for(int i = 0; i < N; ++i){
                        string name;
                        cin >> name >> secret[i].first >> secret[i].second;
                        if(secret[i].first <= LIMIT){
                                dp[0][0][secret[i].first] =
                                        max(dp[0][0][secret[i].first], secret[i].second);
                        }
                }
                for(int i = 0; i < N; ++i){
                        for(int j = 0; j < i; ++j){
                                pii s1 = secret[i], s2 = secret[j];
                                int e = s1.first + s2.first;
                                if(e <= LIMIT){
                                        dp[0][0][e] = max(dp[0][0][e], s1.second + s2.second);
                                }
                        }
                }
                vector<pii> normal(M);
                for(int i = 0; i < M; ++i){
                        string name;
                        cin >> name >> normal[i].first >> normal[i].second;
                }
                for(int i = 0; i < M; ++i){
                        int cur = i & 1, next = 1 - cur;
                        pii g = normal[i];
                        for(int j = 0; j <= i; ++j){
                                for(int k = 0; k <= LIMIT; ++k){
                                        if(dp[cur][j][k] < 0){ continue; }
                                        dp[next][j][k] = max(dp[next][j][k], dp[cur][j][k]);
                                        int e = k + g.first;
                                        if(e <= LIMIT){
                                                dp[next][j + 1][e] =
                                                        max(dp[next][j + 1][e], dp[cur][j][k] + g.second);
                                        }
                                }
                        }
                        for(int j = 0; j <= i; ++j){
                                for(int k = 0; k <= LIMIT; ++k){ dp[cur][j][k] = -1; }
                        }
                }
                int answer = 0;
                for(int i = X; i <= M; ++i){
                        for(int j = 0; j <= LIMIT; ++j){
                                answer = max(answer, dp[M & 1][i][j]);
                        }
                }
                cout << answer << endl;
        }
        return 0;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

ll h, w;

int main() {
    cin >> h >> w;

    if (h == 1) {
        cout << 1 << '\n';
        return 0;
    }
    if (w == 1) {
        cout << 1 << '\n';
        return 0;
    }

    ll x = (w+1)/2;

    if (h%2 == 0) {
        cout << w*(h/2) << '\n';
    } else {
        cout << w*(h/2) + x << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int k = Integer.parseInt(sc.nextLine());
		String x = sc.nextLine();
		
		Pattern p = Pattern.compile("ABC");
		Matcher m = p.matcher(x);
		int count = 0;
		while(m.find()) {
			count++;
		}
		System.out.println(count);
	}		
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


int a;

void solve()
{
    cin >> a;
    nout(a + a*a + a*a*a);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3608
/**Bismillahir Rahmanir Raheem
    Author:Refat(BSMRSTU)**/
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 2e5 + 5;
const int M = 1e9 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}
ll ar[N];
int main() {
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);
    int test=1,n,k;ll sum=0;
    ///scanf("%d",&test);
    for(int cs=1; cs<=test; cs++) {
       scanf("%d %d",&n,&k);
       for(int i=1;i<=n;i++){
        scanf("%lld",&ar[i]);
       }
       sort(ar+1,ar+n+1);
       reverse(ar+1,ar+n+1);
       for(int i=k+1;i<=n;i++){
          sum+=ar[i];
       }
       printf("%lld\n",sum);
    }
    return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  vector<int>c(n-1);
  for(int i=0; i<n; i++) cin >> a[i];
  for(int i=0; i<n; i++) cin >> b[i];
  for(int i=0; i<n-1; i++) cin >> c[i];
  int ans=0;
  for(int i=0; i<n; i++) ans += b[i];
  for(int i=0; i<n-1; i++){
    if(a[i]+1 == a[i+1]) ans += c[a[i]-1];
  }
  cout << ans << endl;
}

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



def solve(X: int):
    for i in range(-120, 120):
        for j in range(-120, 120):
            if i ** 5 - j ** 5 == X:
                print(i, j)
                return
    


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 63748
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll ans, n, k;

ll gv(ll x)
{
	if(x<=k) return 0;
	ll i, ret=0; if(k==0) ret--;
	for(i=0 ; i*x<=n ; i++) ret+=max(min(n-i*x,x-1)-k+1,0LL);
	return ret;
}

int main(void)
{
	cin>>n>>k; ll i, j;
	for(i=1 ; i<=n ; i++) ans+=gv(i);
	cout<<ans; return 0;
}

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

using namespace std;

#define DEBUG 0
#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define VIN(VECTOR,n)

int main(){

	lli n,m;
	cin>>n>>m;
	map<lli,set<lli>> data;
	map<lli,map<lli,lli>> ans;
	vector<lli> p;
	vector<lli> y;
	REP(i,m){
		lli tmpP,tmpY;
		cin>>tmpP>>tmpY;
		p.push_back(tmpP);
		y.push_back(tmpY);
		data[tmpP].insert(tmpY);
	}

	for(lli i=1;i<=n;i++){
		lli cnt = 1;
		set <lli> *s = &(data[i]);
		for(auto itr = s->begin() ; itr != s->end();itr++){
			ans[i][*itr] = cnt;
			cnt++;
		}
	}

	REP(i,m){
		printf("%06d%06d\n",p[i],ans[p[i]][y[i]]);
	}

	return 0;
}



Measured memory_bytes: 32744
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

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

    bool n = 0, s = 0, e = 0, w = 0;

    for(auto& c : S) {
        if(c == 'N') n |= 1;
        if(c == 'S') s |= 1;
        if(c == 'E') e |= 1;
        if(c == 'W') w |= 1;
    }

    if(n == s && e == w) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#if ONLINE_JUDGE
#define DEBUG false
#else
#define DEBUG true
#endif
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rep1(i, n) REP(i, 1, n)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)
#define rrep(i, n) rREP(i, 0, n)
#define forlist(i, vec) for(auto &&i : vec)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define truecheck assert
#define dump(x) cerr << #x << ": " << (x) << endl
using namespace std;
typedef long long LL;
typedef long long int64;
typedef std::vector<int> VI;
typedef std::vector<VI> VVI;
typedef std::vector<LL> VL;
typedef std::vector<VL> VVL;
typedef std::vector<std::string> VS;
typedef std::pair<int, int> PII;
typedef std::pair<LL, LL> PLL;
typedef std::queue<int> QI;
typedef std::priority_queue<int> PQI;
template<class T,class U>inline bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>inline bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>inline void vcinpb(T &v, U n){rep(i, n){typename T::value_type a;cin >> a;v.pb(a);}}

const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;
// M_PI 3.1415...

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cill(k);
    cill(a);
    cill(b);
    string ans = "NG";
    REP(i, a, b+1){
        if (i % k == 0){
            ans = "OK";
            break;
        }
    }
    co(ans);
    return 0;
}

Measured memory_bytes: 3652
import string
N=int(input())
A=string.ascii_letters
ans=["a"]*N
Ans=[1]*N

def search(n):
    if n!=N-1:
        for i in range(max(Ans)+1):
            Ans[n]=i+1
            ans[n]=A[i]
            search(n+1)
            Ans[n+1:]=[1]*(N-n-1)
    else:
        for i in range(max(Ans)+1):
            Ans[n]=i+1
            ans[n]=A[i]
            print("".join(ans))

if N==1:
    print("a")
else:
    search(1)

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

void trace(int A[], int N) {
	int i;
	for (i = 0; i < N; i++) {
		if (i > 0) {
			printf(" ");
		}
		printf("%d", A[i]);
	}
	printf("\n");
}

void insertionSort(int A[], int N) {
	int i, j, v;
	for (i = 1; i < N; i++) {
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trace(A, N);
	}
}

int main() {
	int N, i, j;
	int A[100];
	cin >> N;
	for (i = 0; i < N; i++) {
		int t;
		cin >> t;
		A[i] = t;
	}
	trace(A, N);
	insertionSort(A, N);
	return 0;
}



Measured memory_bytes: 3208
N = int(input())
H = list(map(int,input().split()))
import sys
import functools
#indexi番目にいるときの最小コスト
sys.setrecursionlimit(pow(10,6))

@functools.lru_cache(None)
def func(i):
    if i==0:
        return 0
    if i==1:
        return abs(H[0]-H[1])
    return min(func(i-1)+abs(H[i]-H[i-1]),func(i-2)+abs(H[i-2]-H[i]))

print(func(N-1))


Measured memory_bytes: 265472
#include <bits/stdc++.h>
#define N 100001
using namespace std;
long long sum[N],a[N],b[N],vt[N],n,i,u,v,kq[N];
long long bs(long long L,long long R)
{
    long long l=1,r=n,vl,vr;
    while(l<r)
    {
        int mid=(l+r)>>1;
        if(b[mid]>=L) r=mid; else l=mid+1;
    }
    vl=l;
    l=1; r=n;
    while(l<r)
    {
        int mid=(l+r+1)>>1;
        if(b[mid]<=R) l=mid; else r=mid-1;
    }
    vr=l;
    return sum[vr]-sum[vl-1]-L*(vr-vl+1)+(R-L)*(n-vr);
}
int main()
{
   // freopen("ntu.inp","r",stdin);
   // freopen("ntu.out","w",stdout);
    cin>>n;
    for(i=1;i<=n;i++) { cin>>a[i]; b[i]=a[i]; }
    sort(b+1,b+n+1);
    for(i=1;i<=n;i++) sum[i]=sum[i-1]+b[i];
    vt[0]=0;
    for(i=1;i<=n;i++)
        if(a[i]>a[vt[i-1]]) vt[i]=i; else vt[i]=vt[i-1];
    u=vt[n];
    while(u>0)
    {
        v=vt[u-1];
        kq[u]=bs(a[v],a[u]);
        u=v;
    }
    for(i=1;i<=n;i++) cout<<kq[i]<<'\n';
}


Measured memory_bytes: 4992
n = int(input())
c = input()
if c.count('R') == n:
    print(0)
elif c.count('W') == n:
    print(0)
else:
    MIN = min(n-c.count('R'),n-c.count('W'))
    for i in range(n):
        if c[i] == 'W':
            red = c[i:].count('R')
            MIIN = red-c[i:i+red].count('R')
            print(min(MIIN,MIN))
            break

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

int main() {
  int N;
  cin >> N;
 vector<int> x(N);
 vector<int> y(N);
 vector<ll> h(N);
  for(int i = 0;i<N;i++){
    cin >> x[i];
    cin >> y[i];
    cin >> h[i];
  }
  int c = 0;
  for(int i = 0;i<N;i++){
    if(h[i] != 0){
      c = i;
      break;
    }
  }
 vector<int> ansCx;
 vector<int> ansCy;
 vector<ll> ansH;
  for(int Cx = 0;Cx <=100;Cx++){
    for(int Cy = 0;Cy <= 100;Cy++){
      ll H = h[c] + abs(x[c]-Cx) + abs(y[c]-Cy);
      ansCx.push_back(Cx);
      ansCy.push_back(Cy);
      ansH.push_back(H);
    }
  }
  vector<bool> ans(ansCx.size(),true);
  for(int i = 0;i<ansCx.size();i++){
    for(int j = 0;j<N;j++){
      if(h[j] >0){
        if(ansH[i]-abs(x[j]-ansCx[i]) -abs(y[j]-ansCy[i]) != h[j]){
          ans[i] = false;
        }
      }
       if(h[j] ==0){
         if(ansH[i]>abs(x[j]-ansCx[i]) +abs(y[j]-ansCy[i])){
           ans[i] = false;
         }
       }
      }
    }
  int d = 0;
     for(int i = 0;i<ans.size();i++){
       if(ans[i] == true){
         d = i;
         break;
       }
     }
  cout << ansCx[d] << " " << ansCy[d] << " " << ansH[d] << endl;
}


Measured memory_bytes: 512
package main

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

func main() {
	l := readf()
	fmt.Println(l / 3.0 * l / 3.0 * l / 3.0)
}

// IO---------------------------------------------------

func readi() (n int) {
	fmt.Scan(&n)
	return
}

func readf() (n float64) {
	fmt.Scan(&n)
	return
}

func reads() (n string) {
	fmt.Scan(&n)
	return
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func readSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func readFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

func yesorno(b bool) {
	if b {
		fmt.Println("yes")
		return
	}
	fmt.Println("no")
}

// calc---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func ave(a []int) (ave int) {
	for i := 0; i < len(a); i++ {
		ave += a[i]
	}
	ave /= len(a)
	return
}

func eq(a []string, b []string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func mid(a []int) int {
	sort.Ints(a)
	return a[len(a)/2]
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <cstring>

int k,n;
int a[200001];

int main() {
	std::cin >> k >> n;
	for(int i = 1;i <= n;i++) std::scanf("%d",a + i);
	int max = k - a[n] + a[1];
	for(int i = 2;i <= n;i++) max = std::max(max,a[i] - a[i - 1]);
	std::printf("%d\n",k - max);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<queue>

#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

#define ARRAY_MAX 25

int h,w;
char mp[ARRAY_MAX][ARRAY_MAX];
int sx,sy;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
int ans = 1;

void dfs(int sy,int sx){

    mp[sy][sx] = '$';//今いるところを塗りつぶす
    
    for(int i = 0;i < 4;i++){
        int nx = sx + dx[i];
        int ny = sy + dy[i];
        if(nx >= 0 && nx < w && ny >= 0 && ny < h && mp[ny][nx] == '.'){
            //mpの範囲内で.があれば調べる
            ans++;
            dfs(ny,nx);
        }
    }
}

int main(){

    while(cin >> w >> h,w){

        REP(i,h){
            REP(j,w){
                cin >> mp[i][j];
                if(mp[i][j] == '@'){
                    sy = i;
                    sx = j;//スタート一を保存
                }
            }
        }
        dfs(sy,sx);
        cout << ans << endl;
        ans = 1;
    }



    return 0;
}


Measured memory_bytes: 2964
import numpy as np


def solve():
    num_so = np.array([0] * (len(a)+1))
    so = [[] for i in range(len(a)+1)]
    for i in reversed(range(len(a)+1)):
        num_so[i] = len(so[i])
        if i!=0:
            chief = a[i-1]-1
            so[chief].append(i)
            #so[chief].extend(so[i])
    #print(so[-1])
    for nu in num_so:
        print(nu)
    return




n = int(input())
a = [int(i) for i in input().split(" ")]
solve()

Measured memory_bytes: 65740
#include <iostream>
#include <limits>
#include <sstream>
#include <string>
#include <vector>

using NumNode = short;
using List = std::vector<NumNode>;
struct Node {
    NumNode idx;
    NumNode value;
    List list;
};
using Nodes = std::vector<Node>;
using Edge = bool;
using Row = std::vector<Edge>;
using Array = std::vector<Row>;

Nodes input_nodes(NumNode n_node);
List make_val2idx(Nodes nodes);
Array solve(Nodes nodes);
void print_graph_array(Array array);

int main() {
    NumNode n;
    std::cin >> n;
    Nodes nodes = input_nodes(n);
    const Array array = solve(nodes);
    print_graph_array(array);
}

Nodes input_nodes(NumNode n_node) {
    Nodes nodes{};
    for (NumNode i = 0; i < n_node; ++i) {
        NumNode u, k;
        std::cin >> u >> k;

        Node node{};
        node.idx = i;
        node.value = u;

        List list{};
        for (NumNode j = 0; j < k; ++j) {
            NumNode v;
            std::cin >> v;
            list.push_back(v);
        }
        node.list = list;
        nodes.push_back(node);
    }
    return nodes;
}

Array solve(Nodes nodes) {
    Array array{};
    List val2idx = make_val2idx(nodes);
    for (Node node : nodes) {
        Row row{};
        row.resize(nodes.size());
        for (NumNode node_dst : node.list) {
            const NumNode node_dst_idx = val2idx.at(node_dst);
            row.at(node_dst_idx) = true;
        }
        array.push_back(row);
    }
    return array;
}

List make_val2idx(Nodes nodes) {
    List val2idx{};
    NumNode value_max = std::numeric_limits<NumNode>::max();
    val2idx.resize(value_max);
    for (Node node : nodes) val2idx[node.value] = node.idx;
    return val2idx;
}

void print_graph_array(Array array) {
    for (Row row : array) {
        for (auto iter_edge = row.begin(); iter_edge != row.end();
             ++iter_edge) {
            std::cout << *iter_edge;
            if (iter_edge != end(row) - 1) std::cout << ' ';
        }
        std::cout << std::endl;
    }
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tokens = br.readLine().split(" ");
		System.out.println(Integer.parseInt(tokens[0]) > Integer.parseInt(tokens[1]) ? "safe" : "unsafe");
	}
}


Measured memory_bytes: 25328