akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

#define TRACE(x) std::cout << #x << " = " << x << "\n"
#define _ << " _ " <<

using namespace std;

const int MAXN = 6020;
const int MAXB = 3030;
const int MAXC = 6060;

int f[MAXN][MAXB + MAXC];

int mod;

int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }

int mul(int a, int b) { return (a * 1LL * b) % mod; }

int main() {
  std::ios_base::sync_with_stdio(false);

  int N;
  cin >> N >> mod;
  N *= 3;

  f[0][0 + MAXB] = 1;
  for (int n = 0; n < N; ++n) {
    for (int d = 0; d < MAXB + MAXC; ++d) {
      if (f[n][d] == 0) continue;

      f[n + 3][d] = add(f[n + 3][d], mul(f[n][d], (N - n - 1) * (N - n - 2)));
      if (d > 0) {
        f[n + 2][d - 1] = add(f[n + 2][d - 1], mul(f[n][d], (N - n - 1)));
      }
      if (d + 1 < MAXB + MAXC) {
        f[n + 1][d + 1] = add(f[n + 1][d + 1], f[n][d]);
      }
    }
  }

  int ret = 0;
  for (int d = MAXB; d < MAXB + MAXC; ++d) {
    ret = add(ret, f[N][d]);
  }
  cout << ret << "\n";
  return 0;
}


Measured memory_bytes: 211584
#include <stdio.h>

int main() {
	int a, b, sockets, ans;

	scanf("%d%d", &a, &b);
	sockets = 1;
	ans = 0;
	while (sockets < b) {
		sockets += a - 1;
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
vector<int> adj[100005];
int dp[100005];
bool vis[100005];
int dfs(int src)
{
    if (dp[src] != -1)
        return dp[src];
    vis[src] = true;
    int ans = 0;
    for (int i = 0; i < adj[src].size(); i++)
    {
        if (!vis[adj[src][i]])
            ans = max(ans, 1 + dfs(adj[src][i]));
        else
            ans = max(ans, dp[adj[src][i]] + 1);
    }
    return dp[src] = ans;
}
int main()
{
    int n, m;
    cin >> n >> m;
    memset(dp,-1,sizeof dp);
    while (m--)
    {
        int u, v;
        cin >> u >> v;

        adj[u].push_back(v);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
        ans = max(ans, dfs(i));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12124
open System

let rec gcd x y =
    if y = 0L then x
    else gcd y (x % y)
let readInts () = stdin.ReadLine().Split(' ') |> Array.map int64
let uncurry f (a,b) = f a b
let any = Array.fold (||) false
let all = Array.fold (&&) true

let lcm x y = x * y / gcd x y
let rec div x =
    if x >= 1L && x % 2L = 0L then 1L + div (x/2L)
    else 0L

let args = readInts()
let n, m = int args.[0], args.[1]
let a = readInts() |> Array.map (fun i -> i/2L)
let b = Array.map div a

if all (Array.map (fun i -> i=b.[0]) b)
    then
        let c = Array.fold lcm 1L a
        printfn "%d" ((m/c+1L)/2L)
    else
        printfn "0"

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

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

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

int H,W;
int acc[44][44];
int py,px;

// y  [a,b)
// x  [c,d)
int sum(int a,int b,int c,int d){
	return acc[b][d]-acc[a][d]-acc[b][c]+acc[a][c];
}


const int INF=1001001001;
int dp[44][44][44][44];

signed main(){
	cin>>H>>W;
	rep(i,H){
		string s;cin>>s;
		rep(j,W){
			if(s[j]=='P'){
				py=i;
				px=j;
			}
			if(s[j]=='#')acc[i+1][j+1]++;
			acc[i+1][j+1]+=acc[i][j+1]+acc[i+1][j]-acc[i][j];
		}
	}

	for(int i=py;i>=0;i--){
		for(int ii=py+1;ii<=H;ii++){
			for(int j=px;j>=0;j--){
				for(int jj=px+1;jj<=W;jj++){
					int &val=dp[i][ii][j][jj];
					val=INF;

					chmin(val,sum(i,py+1,j,px+1));
					chmin(val,sum(i,py+1,px,jj));
					chmin(val,sum(py,ii,j,px+1));
					chmin(val,sum(py,ii,px,jj));

					for(int k=i+1;k<ii;k++){
						for(int l=j+1;l<jj;l++){
							if(py<k&&px<l){
								chmin(val,dp[i][k][j][l]+sum(i,k,l,jj)+sum(k,ii,j,l));
							}
							if(py<k&&px>=l){
								chmin(val,dp[i][k][l][jj]+sum(i,k,j,l)+sum(k,ii,l,jj));
							}
							if(py>=k&&px<l){
								chmin(val,dp[k][ii][j][l]+sum(i,k,j,l)+sum(k,ii,l,jj));
							}
							if(py>=k&&px>=l){
								chmin(val,dp[k][ii][l][jj]+sum(i,k,l,jj)+sum(k,ii,j,l));
							}
						}
					}
				}
			}
		}
	}

	cout<<dp[0][H][0][W]<<endl;
	return 0;
}

Measured memory_bytes: 23040
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        s=input()
        if s[0] == 'A' and s[2:-1].count('C') == 1:
            for i in s[2:-1]:
                if i != 'C' and i.isupper():
                    return 'WA'
            if s[1].isupper() or s[-1].isupper():
                return 'WA'
            return 'AC'
        else:
            return 'WA'
    print(main())
resolve()

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
  int n;
  
  scanf("%d",&n);
  
  n = n % 10;
  
  if(n == 3){
    printf("bon\n");
  }else if( (n == 0) || (n == 1) || (n == 6) || (n == 8) ){
    printf("pon\n");
  }else{
    printf("hon\n");
  }
  
  return 0;
}

Measured memory_bytes: 1636
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF=1ll<<60;
int n,x; ll f[3];
char Getchar(){
    static char now[1<<20],*S,*T;
    if (T==S){
        T=(S=now)+fread(now,1,1<<20,stdin);
        if (T==S) return EOF;
    }
    return *S++;
}
int read(){
    int x=0,f=1;
    char ch=Getchar();
    while (ch<'0'||ch>'9'){
        if (ch=='-') f=-1;
        ch=Getchar();
    }
    while (ch<='9'&&ch>='0') x=x*10+ch-'0',ch=Getchar();
    return x*f;
}
int main(){
	n=read();
	f[0]=0; f[1]=-INF; f[2]=-INF;
	for (int i=1;i<=n;i++){
		x=read();
		f[0]+=x; f[1]-=x; f[2]+=x;
		if (x<0) f[2]=max(f[1],f[2]),f[1]=max(f[0],f[1]);
		f[0]=max(f[0],f[1]); f[1]=max(f[1],f[2]);
	}
	printf("%lld\n",f[0]);
	return 0;
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> dct;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define pi 3.14159265

bool compare(pll a, pll b){
    return (a.first*b.second) < (a.second*b.first);
}

const int mod = 1e9 + 7;
const ll inf = ll(1e18);

ll modexp(ll x,ll n){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%mod,n/2);
    return (x*modexp((x*x)%mod,n/2))%mod;
}

int main(){
    fastio;
    int n;
    cin>>n;
    vl a(n,0);
    f(i,0,n)cin>>a[i];
    ll ans = 0;
    f(i,0,61){
        ll sb = 0, usb = 0;
        ll temp = 0;
        f(j,0,n){
            if (a[j] % 2)sb++;
            else usb++;
            a[j] /= 2;
        }
        temp = (sb * usb)%mod;
        temp = (temp* modexp(2,i))%mod;
        ans =  (ans+temp)%mod;
    }
    cout<<ans<<endl;
}

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

struct edge {
	long long To;
	long long Cost;
};

typedef pair<long long, long long> P;
typedef pair<P, long long> PL;

int main() {
	long long N, M, L, INF = 1000000000000000;
	static vector<edge> V[300];
	cin >> N >> M >> L;
	for (int i = 0; i < M; i++) {
		long long A, B, C;
		cin >> A >> B >> C;
		if (L < C) continue;
		A--, B--;
		V[A].push_back({ B, C });
		V[B].push_back({ A, C });
	}
	static P Dist[300][300] = {};
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			Dist[i][j] = { INF, INF };
		}
	}
	for (int i = 0; i < N; i++) {
		priority_queue<PL, vector<PL>, greater<PL> > PQ;
		PQ.push({ {0, 0}, i });
		Dist[i][i] = { 0, 0 };
		while (!PQ.empty()) {
			PL p = PQ.top();
			PQ.pop();
			long long v = p.second;
			if (Dist[i][v] < p.first) continue;
			for (edge E : V[v]) {
				long long X = Dist[i][v].first, Y = Dist[i][v].second + E.Cost;
				if (Y > L) {
					X++;
					Y = E.Cost;
				}
				P NEXT = { X, Y };
				if (Dist[i][E.To] > NEXT) {
					Dist[i][E.To] = NEXT;
					PQ.push({ NEXT, E.To });
				}
			}
		}
	}
	long long Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		long long S, T;
		cin >> S >> T;
		S--, T--;
		P ANS = Dist[S][T];
		if (ANS == P{ INF, INF }) {
			cout << -1 << endl;
		}
		else cout << ANS.first << endl;
	}
}


Measured memory_bytes: 5652
#include <iostream>

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;
	}
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(v) (int)v.size() 
#define all(v) v.begin(), v.end()
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)


/****************************** CODE IS HERE ***********************************/

const int N = 1e5 + 4;
vector <int> g[N];
bitset <N> used;
vector <int> v;
vector <int> path(N, 0);

void topsort(int u) {
    used[u] = true;
    for (int nebr: g[u]) {
        if (!used[nebr])
            topsort(nebr);
    }
    v.push_back(u);
}


int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int n, m; cin >> n >> m;
    for (int i = 0, x, y; i < m; ++i) {
        cin >> x >> y;
        g[x].push_back(y);
    }
    for (int i = 1; i <= n; ++i){
        if (!used[i])
            topsort(i);
    }
    reverse(all(v));
    for (int i = n-1; i >= 0; --i) {
        int u = v[i];
        for (int v: g[u])
            path[u] = max(path[u], path[v]+1);
    }

    int ans = *max_element(all(path));
    cout << ans;



    return 0;
}


Measured memory_bytes: 8828
#include<stdio.h>
#include<stdbool.h>
int gcd(int a, int b){return b?gcd(b,a%b):a;}
int N, A, B[1<<20], t = 0;
bool p[1<<20] = {[2 ... 1<<20-1] true}, flg = true;
int main(){
	scanf("%d", &N);
	for(int i=0; i<N; i++){
		scanf("%d", &A);
		t = gcd(A, t);
		B[A]++;
	}
	for(int i=2; i<(1<<20); i++){
		if(p[i]){
			int cnt = B[i];
			for(int j=2*i; j<(1<<20); j+=i){
				p[j] = false;
				cnt += B[j];
			}
			if(cnt > 1)flg = false;
		}
	}
	if(flg){
		puts("pairwise coprime");
	}else if(t == 1){
		puts("setwise coprime");
	}else {
		puts("not coprime");
	}
	return 0;
}

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

int main()
{
  	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 	int n; 
  	cin >> n;
  	vector<int> a(n), b(n);
  	for(int i = 0; i < n; i++)
      	cin >> a[i];
  	for(int i = 0; i < n; i++)
      	cin >> b[n-i-1];
  	
  	int same = -1;
  	for(int i = 0; i < n; i++)
      	if(a[i] == b[i]) {
         	same = a[i];
          	break;
        }
  	
  	int left = 0;
  	for(int i = 0; i < n; i++)
    	if(a[i] == same && b[i] == same) {
         	left = i;
          	break;
        }
  
  	int right = -1;
  	for(int i = n-1; i >= 0; i--)
      	if(a[i] == same && b[i] == same) {
         	right = i;
          	break;
        }
  	
  	for(int i = 0; i < n; i++)
    	if(a[i] != same && b[i] != same && left <= right) {
          	swap(b[i], b[left]);
          	left++;
        }
  
  	if(left <= right) {
     	cout << "No"; 
    } else {
     	cout << "Yes\n";
      	for(int i = 0; i < n; i++) cout << b[i] << " ";
    }
}

Measured memory_bytes: 4796
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}
use input::*;

use std::collections::HashMap;

fn get_group(n: usize) -> usize {
    if n < 400 {
        return 0;
    }
    if n < 800 {
        return 1;
    }
    if n < 1200 {
        return 2;
    }
    if n < 1600 {
        return 3;
    }
    if n < 2000 {
        return 4;
    }
    if n < 2400 {
        return 5;
    }
    if n < 2800 {
        return 6;
    }
    if n < 3200 {
        return 7;
    }
    return 8;
}

fn main() {
    let n: usize;
    input!(n);
    let v = input_vector::<usize>();

    let mut h: HashMap<usize, usize> = HashMap::new();
    h.insert(8, 0);
    for z in v {
        let g = get_group(z);
        let p = h.entry(g).or_insert(0);
        *p += 1;
    }
    let mut ans = 0;
    for (i, _) in &h {
        if *i != 8 {
            ans += 1;
        }
    }
    if ans == 0 {
        println!("{} {}", 1, h[&8]);
    } else {
        println!("{} {}", ans, ans + h[&8]);
    }
}


Measured memory_bytes: 4352
n = int(input())
taro = []
hanako = []

for i in range(n):
    t, h = input().split()
    taro.append(t)
    hanako.append(h)

taros_point = 0
hanakos_point = 0

for i in range(n):
    if taro[i] > hanako[i]:
        taros_point += 3
    elif taro[i] == hanako[i]:
        taros_point += 1
        hanakos_point += 1
    else:
        hanakos_point += 3

print(taros_point, hanakos_point)
    


Measured memory_bytes: 5620
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int n;
    cin>>n;
    int a[n];
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    int tmp=0;
    int ans=sum;
    for(int i=0;i<n;i++){
        tmp+=a[i];
        ans=min(ans,abs(tmp-(sum-tmp)));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3600
from collections import defaultdict


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


n, k, l = map(int, input().split())
uf1 = UnionFind(n)
uf2 = UnionFind(n)
for _ in range(k):
    a, b = map(int, input().split())
    uf1.unite(a - 1, b - 1)
for _ in range(l):
    a, b = map(int, input().split())
    uf2.unite(a - 1, b - 1)
d = defaultdict(int)
for i in range(n):
    d[(uf1.find(i), uf2.find(i))] += 1
ans = [0] * n
for i in range(n):
    ans[i] = d[(uf1.find(i), uf2.find(i))]
print(*ans)


Measured memory_bytes: 56312
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int P=1e9+7;
const int M=1e5+5;
int head[M],to[M<<1],val[M<<1],nxt[M<<1],col[M<<1],tot;
void Add(int x,int y,int c,int d){
	to[++tot]=y;
	nxt[tot]=head[x];
	col[tot]=c,val[tot]=d;
	head[x]=tot;
}
int n,m;
int rt[M];
struct node{int cnt,sum;};
struct Seg{
	#define N M*40
	int Lson[N],Rson[N],cnt[N],sum[N],tot;
	void insert(int &rt,int od,int L,int R,int k,int x){
		rt=++tot;
		sum[rt]=sum[od],cnt[rt]=cnt[od];
		Lson[rt]=Lson[od],Rson[rt]=Rson[od];
		if(L==R){cnt[rt]++,sum[rt]+=x;return;}
		int mid=(L+R)>>1;
		if(k<=mid)insert(Lson[rt],Lson[od],L,mid,k,x);
		else insert(Rson[rt],Rson[od],mid+1,R,k,x);
	}
	node query(int rt,int L,int R,int k){
		if(!rt)return (node){0,0};
		if(L==R)return (node){cnt[rt],sum[rt]};
		int mid=(L+R)>>1;
		if(k<=mid)return query(Lson[rt],L,mid,k);
		else return query(Rson[rt],mid+1,R,k);
	}
}tree;

int top[M],son[M],fa[M],sz[M],dep[M],dis[M];

void dfs(int x,int f){
	sz[x]=1,son[x]=0;
	fa[x]=f,dep[x]=dep[f]+1;
	for(int i=head[x];i;i=nxt[i]){
		int y=to[i];
		if(y==f)continue;
		dis[y]=dis[x]+val[i];
		tree.insert(rt[y],rt[x],1,n,col[i],val[i]);
		dfs(y,x);
		sz[x]+=sz[y];
		if(sz[y]>sz[son[x]])son[x]=y;
	}
}
void dfs_top(int x,int f,int tp){
	top[x]=tp;
	if(son[x])dfs_top(son[x],x,tp);
	for(int i=head[x];i;i=nxt[i]){
		int y=to[i];
		if(y==f||y==son[x])continue;
		dfs_top(y,x,y);
	}
}
int LCA(int a,int b) {
	while(top[a]!=top[b]) {
		if(dep[top[a]]>dep[top[b]])swap(a,b);
		b=fa[top[b]];
	}
	return dep[a]<dep[b]?a:b;
}
void solve(){
	for(int i=1,x,d,u,v;i<=m;i++){
		scanf("%d%d%d%d",&x,&d,&u,&v);
		int lca=LCA(u,v);
		int sum=dis[u]+dis[v]-2*dis[lca];
		node t1=tree.query(rt[u],1,n,x);
		node t2=tree.query(rt[v],1,n,x);
		node t3=tree.query(rt[lca],1,n,x);
		sum-=(t1.sum+t2.sum-t3.sum*2);
		sum+=(t1.cnt+t2.cnt-t3.cnt*2)*d;
		printf("%d\n",sum);
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,x,y,c,d;i<n;i++){
		scanf("%d%d%d%d",&x,&y,&c,&d);
		Add(x,y,c,d),Add(y,x,c,d);
	}
	dfs(1,0),dfs_top(1,0,1);
	solve();
	return 0;
}

Measured memory_bytes: 47616
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2) % MOD; 
	p = (p * p) % MOD; 
  
	return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
	

	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	READV(N);
	READV(K);
	READAR(A,N);
	READAR(F,N);
	sort(A,A+N);
	sort(F,F+N,greater<ll>());
	ll lb=0,ub=1e12;
	while (lb<ub)
	{
		ll mid=(lb+ub)/2;
		ll w=0;
		FORI(i,0,N)
		{
			ll x=max(A[i]*F[i]-mid,0LL);
			if(x%F[i]==0)
			{
				w+=x/F[i];
			}
			else
			{
				w+=((x/F[i])+1);
			}
		}
		if(w<=K)
		{
			ub=mid;
		}
		else
		{
			lb=mid+1;
		}
	}
	cout<<lb<<endl;
	
	

	return 0;
}

Measured memory_bytes: 3968
#include <iostream>

#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

using ll = long long;
using ii = pair<ll, ll>;

int main()
{
    ios::sync_with_stdio(false);

    string s;
    size_t K;

    cin >> s >> K;

    auto N = s.size();

    vector<string> subs;

    for (size_t a = 0; a < N; ++a)
        for (size_t b = a; b < N; ++b)
        {
            auto sub = s.substr(a, b - a + 1);

            bool found = false;

            for (const auto& x : subs)
                if (x == sub)
                {
                    found = true;
                    break;
                }

            if (found)
                continue;

            if (subs.size() < K)
            {
                subs.push_back(sub);
                sort(subs.begin(), subs.end());

            } else
            {
                if (sub >= subs.back())
                    continue;

                subs[K - 1] = sub;
                sort(subs.begin(), subs.end());
            }
        }

    cout << subs[K - 1] << endl;

    return 0;
}



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

using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
	int A, B;
	cin >> A >> B;

	int ans = -1;
	for (int i = 1; i <= 1000; ++i) {
		double a = i * 0.08;
		double b = i * 0.1;

		if ((int)a == A && (int)b == B) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3612
N = int(input())
ans = ''

for i in range(1, 99):
    if N <= 26 ** i:
        N -= 1
        
        for j in range(i):
            ans += chr(ord('a') + N % 26)
            N //= 26
            
        break
        
    else:
        N -= 26 ** i

print(ans[::-1])

Measured memory_bytes: 8904
#include<iostream>
#include<map>
using namespace std;
int main(){
  map<char,char>vocal;
  char consonant[10]={'w','a','k','s','t','n','h','m','y','r'};
  vocal['T']='a';
  vocal['L']='i';
  vocal['U']='u';
  vocal['R']='e';
  vocal['D']='o';
  string s;
  cin>>s;
  for(int i=0;i<s.size();i+=2){
    if(s[i]=='0'){
      if(s[i+1]=='T'){
        cout<<"wa";
      }else if(s[i+1]=='D'){
        cout<<"wo";
      }else{
        cout<<"nn";
      }
    }else if(s[i]=='8'){
      if(s[i+1]=='T'){
        cout<<"ya";
      }else if(s[i+1]=='U'){
        cout<<"yu";
      }else{
        cout<<"yo";
      }
    }else{
      if(s[i]!='1'){
        cout<<consonant[s[i]-'0'];
      }
      cout<<vocal[s[i+1]];
    }
  }
  cout<<endl;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //   cin >> t;
    while (t--)
    {
        char ch;
        cin >> ch;
        if (ch >= 'a' && ch <= 'z')
            cout << "a";

        if (ch >= 'A' && ch <= 'Z')
            cout << "A";
    }
}

Measured memory_bytes: 3636
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int ac = 0;
		int wa = 0;
		int tle = 0;
		int re = 0;
		for(int i = 0; i < n; i++){
		    String s = sc.next();
		    if(s.equals("AC")) ac++;
		    if(s.equals("WA")) wa++;
		    if(s.equals("TLE")) tle++;
		    if(s.equals("RE")) re++;
		}
		
		// 計算
		int result = 0;
		System.out.println("AC x " + ac);
		System.out.println("WA x " + wa);
		System.out.println("TLE x " + tle);
		System.out.println("RE x " + re);
		
		
		// 出力
		//System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}



Measured memory_bytes: 38732
#include <iostream>
#include <cmath>

using namespace std;

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

    int N;
    cin >> N;

    bool flag = false;
    for (int h = 1; h <= 3500; ++h) {
        for (int n = 1; n <= 3500; ++n) {
            double w = 1.0 * N * h * n / (4 * h * n - N * n - N * h);
            if (abs(w - (int) w) < 1e-9 && w > 0) {
                cout << h << " " << n << " " << (int) w << endl;
                flag = true;
            }
            if (flag)
                break;
        }
        if (flag)
            break;
    }
}


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

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

    for(char c = 'a'; c <= 'z'; c++){
        int cnt = 0;
        for(int i = 0; i < s.size(); i++){
            if(s[i] == c) cnt++;
        }
        if(cnt > 1){
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    return 0; 
}

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

#define ll long long int
#define endl "\n"
#define mod 1000000007
#define maxN 100005


int main()
{

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	{
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
#endif
	ll n;
	cin >> n;
	n = n % 10;
	if (n == 2 ||  n == 4 || n == 5 || n == 7 || n == 9) {
		cout << "hon" << endl;
	} else if (n == 0 || n == 1 || n == 6 || n == 8) {
		cout << "pon" << endl;
	} else if (n == 3) {
		cout << "bon" << endl;
	}

	return 0;
}

Measured memory_bytes: 3616
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N, H, W;

signed main(){
    cin >> N >> H >> W;
    cout << max(0, N-H+1)*max(0, N-W+1) << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <queue>
using namespace  std;

const int nIMPOS = -1;
struct StDist
{
  int m_nDist;
  int m_nFromMeTo;

  StDist(int nDist) : m_nDist(nDist), m_nFromMeTo(0)
  { }
};

void fnInput(vector<vector<int>>& rvvnAdjcy, vector<StDist>& rvoDist)
{
  int nxSiz;
  cin >> nxSiz;

  rvvnAdjcy.resize(nxSiz + 1, vector<int>(nxSiz + 1, 0));
  for (int i = 0; i < nxSiz; ++i)
  {
    int nx, nySiz;
    cin >> nx >> nySiz;
    for (int j = 0; j < nySiz; ++j)
    {
      int ny;
      cin >> ny;
      rvvnAdjcy[nx][ny] = 1;
    }
  }
  StDist oDist(nIMPOS);
  rvoDist.resize(nxSiz + 1, oDist);
}

void fnBreadthFirstSearch(const vector<vector<int>>& cnrvvnAdjcy, 
                          queue<int>& rqnBFSrch, vector<StDist>& rvoDist)
{
  while (rqnBFSrch.size())
  {
    int nx = rqnBFSrch.front(); rqnBFSrch.pop();
    if (rvoDist[nx].m_nDist == nIMPOS)  continue;
    if (rvoDist[nx].m_nFromMeTo)        continue; 

    rvoDist[nx].m_nFromMeTo = 1;
    for (int ny = 1; ny < cnrvvnAdjcy[nx].size(); ++ny)
      if (cnrvvnAdjcy[nx][ny] == 1)
      {
        int nDist = rvoDist[nx].m_nDist + 1;
        if (rvoDist[ny].m_nDist == nIMPOS)
          rvoDist[ny].m_nDist = nDist;
        else
          rvoDist[ny].m_nDist = min(rvoDist[ny].m_nDist, nDist);

        rqnBFSrch.push(ny);
      }
  }
}

void fnResult(const vector<StDist>& cnrvoDist)
{
  for (int i = 1; i < cnrvoDist.size(); ++i)
    cout << i <<  " " << cnrvoDist[i].m_nDist << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<vector<int>> vvnAdjcy;
  queue<int>  qnBFSrch;
  vector<StDist> voDist;

  fnInput(vvnAdjcy, voDist);

  voDist[1].m_nDist = 0;
  qnBFSrch.push(1);
  fnBreadthFirstSearch(vvnAdjcy, qnBFSrch, voDist);
  fnResult(voDist);

  return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <assert.h>

int main() {

  int K, X;
  std::cin >> K >> X;
  assert(K>=1 and K<=100);
  assert(X>=0 and X<=100);

  for (int i=X-K+1; i<X+K; i++)  std::cout << i << " ";
  std::cout << std::endl;
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)

int main()
{
  int n, k;
  cin >> n >> k;
  if(n%k==0)cout << 0 << endl;
  else cout << 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>

typedef long long int lli;

int main(void) {
    lli k;
    scanf("%lld", &k);

    lli n=50;
    lli a[50] = {};
    for(int i=0; i<50; i++)
        a[i] = 49;
    for(int i=0; i<50; i++)
        a[i] += (k/50)*n;
    for(int i=0; i<(k%50); i++)
        a[i] += n + 1;
    for(int i=0; i<50; i++)
        a[i] -= k - (k/50);

    printf("50\n");
    for(int i=0; i<50; i++)
        printf("%lld%c", a[i], i==49 ? '\n' : ' ');
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main{
	public static void main (String[] args) throws java.lang.Exception{
		Scanner scan = new Scanner(System.in);

		String s = scan.next();
		int n = Integer.parseInt(s);
		n = n * n * n;
		System.out.println(n);
	}
}

Measured memory_bytes: 17120
ss = gets.chomp.split('')
x, y = gets.split.map(&:to_i)

#ss = ['F', 'T'] * 4000
#x, y = 2000, 2000

first = 0
while ss[0] == 'F' do
    first += 1
    ss.shift
end

verts = []
vi = 0
horis = []
hi = 0
hori_now = true

while ss.length > 0 do
    s = ss.shift
    if s == 'F'
        if hori_now
            horis[hi] ||= 0
            horis[hi] += 1
        else
            verts[vi] ||= 0
            verts[vi] += 1
        end
    else
        if hori_now
            hori_now = false
            hi += 1 if horis[hi]
        else
            hori_now = true
            vi += 1 if verts[vi]
        end
    end
end

def check(arr, target)
    n = arr.length

    if n == 0
        return target == 0
    end

    sum = arr.inject(:+)
    if target > sum
        return false
    end
    if (target + sum) % 2 == 1
        return false
    end
    target = (target + sum) / 2
    dp = Array.new(n + 1){Array.new(target + 1, false)}
    dp[0][0] = true
    dp[0][arr[0]] = true

    (1...n).each do |i|
        (0..target).each do |j|
            dp[i][j] = dp[i - 1][j]
            dp[i][j] ||= dp[i - 1][j - arr[i]] if j - arr[i] >= 0
        end
    end
    return dp[n - 1][target]
end

if check(verts, y) && check(horis, x - first)
    print 'Yes'
else
    print 'No'
end

Measured memory_bytes: 57852
/*
 * atcoder/nomura2020/b.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * PD?D??P
 *
 * Dにすると必ず+1ポイント
 * Pにするとその後がDだった場合+2ポイント
 *
 * 右から見ていって、右が無ければD
 * 右がDならP, PならD
 *
 * D?
 */
int N;
string T, S = "";
void solve() {
  cin >> T;
  N = T.size();

  char prev = ' ';
  for (int i=0; i<N; i++) {
    char t = T[i];
    char next = i==N-1 ? ' ' : T[i+1];
    if (t != '?') { S+= t; prev = t; continue; }
    if (prev == 'P') {
      S += 'D';
      prev = 'D';
      continue;
    }

    if (next == ' ' or next == 'P') {
      S += 'D';
      prev = 'D';
      continue;
    }

    S += 'P';
    prev = 'P';
  }

  cout << S << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 3876
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main
{
	static HashMap<String, Long>[] DP;
	static String Chars = "ACGT";
	
	static boolean isValid(String Last)
	{
		for (int i = 0; i < Last.length(); i++)
		{
			String temp = Last;
			if (i >= 1)
			{
				temp = "";
				for (int j = 0; j < i - 1; j++)
				{
					temp += Last.charAt(j);
				}
				temp += Last.charAt(i) + "" + Last.charAt(i - 1);
				for (int j = i + 1; j < Last.length(); j++)
				{
					temp += Last.charAt(j);
				}
			}
			if (temp.contains("AGC"))
			{
				return false;
			}
		}
		return true;
	}
	
	static long DFS(int N, String Last)
	{
		if (DP[N].containsKey(Last))
		{
			return DP[N].get(Last);
		}
		if (N == 0) return 1;
		DP[N].put(Last, 0l);
		for (int i = 0; i < Chars.length(); i++)
		{
			if (isValid(Last + Chars.charAt(i)))
			{
				long prev = DP[N].get(Last);
				DP[N].put(Last, (prev + DFS(N - 1, Last.substring(1) + Chars.charAt(i))) % ((int)1e9 + 7));
			}
		}
		return DP[N].get(Last);
	}
	
	public static void main(String[] Arguments) throws IOException 
	{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(BR.readLine()); DP = new HashMap[N + 1];
		for (int i = 0; i <= N; i++)
		{
			DP[i] = new HashMap<>();
		}
		System.out.println(DFS(N, "TTT"));
	}
}


Measured memory_bytes: 55332
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int w,a,b;
	cin>>w>>a>>b;
	if(w==3&&a==1&&b==3){
		cout<<0<<endl;
		return 0;
	}
	if(a<b){
		cout<<b-a-w<<endl;
	}
	else if(a>b){
		cout<<a-b-w<<endl;
	}
	else{
		cout<<0<<endl;
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;

enum VAL{ODD, EVEN};
struct Pos{
    int x;
    int y;
    int order;
};
bool asc_x(const Pos& l, const Pos& r) {
    return l.x < r.x;
}
bool asc_y(const Pos& l, const Pos& r) {
    return l.y < r.y;
}

struct Node{
    int x;
    int y;
    int order;
    Node* left;
    Node* right;
};

class Tree{
    Node* root;
    Node* makeTree(vector<Pos>& A, int l, int r, VAL V){
        if (l > r) return nullptr;
        if (V == ODD) {
            sort(A.begin() + l, A.begin() + r + 1, asc_y);
            V = EVEN;
        } else {
            sort(A.begin() + l, A.begin() + r + 1, asc_x);
            V = ODD;
        }
        int mid = (l + r) / 2;
        Node* p = new Node;
        p->x     = A[mid].x;
        p->y     = A[mid].y;
        p->order = A[mid].order;
        p->left  = makeTree(A,       l, mid - 1, V);
        p->right = makeTree(A, mid + 1,       r, V);
        return p;
    }
    void find_(Node* n, int sx, int tx, int sy, int ty, VAL V, vector<int>& ans){
        if (n == nullptr) return;
        int n_, s, t;
        if (V == ODD) {
            n_ = n->y;
            s  = sy;
            t  = ty;
            V = EVEN;
        } else {
            n_ = n->x;
            s  = sx;
            t  = tx;
            V = ODD;
        }
        if (n_ >= s) find_(n->left, sx, tx, sy, ty, V, ans);
        if (n->x >= sx && n->x <= tx && n->y >= sy && n->y <= ty) {
            ans.push_back(n->order);
        }
        if (n_ <= t) find_(n->right, sx, tx, sy, ty, V, ans);
    }
public:
    Tree(vector<Pos>& A){
        root = makeTree(A, 0, A.size() - 1, ODD);
    }
    void find(int sx, int tx, int sy, int ty){
        vector<int> ans;
        find_(root, sx, tx, sy, ty, ODD, ans);
        sort(ans.begin(), ans.end());
        for (int i = 0, s = ans.size(); i < s; i++) {
            printf("%d\n", ans[i]);
        }
        printf("\n");
    }
};

int main(){
    int n;
    scanf("%d", &n);
    vector<Pos> A(n);
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &(A[i].x), &(A[i].y));
        A[i].order = i;
    }
    Tree T(A);
    int q;
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        int sx, tx, sy, ty;
        scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
        T.find(sx, tx, sy, ty);
    }
    return 0;
}



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

int main() {
  vector<vector<int>> a(3, vector<int>(3));
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++)
      scanf("%d", &a[i][j]);
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int b;
    scanf("%d", &b);
    
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 3; k++)
        if (a[j][k] == b)
          a[j][k] = 0;
  }

  bool succ = false;
  for (int i = 0; i < 3; i++) {
    bool f = true;
    for (int j = 0; j < 3; j++)
      if (a[i][j] > 0)
        f = false;
    if (f) succ = true;
  }
  for (int i = 0; i < 3; i++) {
    bool f = true;
    for (int j = 0; j < 3; j++)
      if (a[j][i] > 0)
        f = false;
    if (f) succ = true;
  }
  if (!a[0][0] && !a[1][1] && !a[2][2]) succ = true;
  if (!a[0][2] && !a[1][1] && !a[2][0]) succ = true;

  if (succ)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}

Measured memory_bytes: 256
/***  بسم الله الرحمن ا لرحيم   ***/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#define endl                         '\n'
#define Ceil(x,y)             ((x+y-1)/y)
#define sz(s)               (int)s.size()
#define RT(x)           return cout<<x,0;
#define mem(x,y)    memset(x,y,sizeof(x))
#define all(v) ((v).begin()), ((v).end())
#define watch(x) cout<<#x<<" = { "<<x<<" }\n"
#define test int t;cin>>t;while(t--)
const int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
const double PI = acos(-1), EPS = 1e-7;
const int OO = 0x3f3f3f3f, N = 2e5 + 5, mod = 1e9 + 7;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll x, ll y) { return (!y) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return ((x / gcd(x, y)) * y); }
void file() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif  !ONLINEJUDGE
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int n,cost;
vector<int>we,val;
ll memo[105][100005];
ll dp(int i, int v) {
	if (i == n) {
		if(!v)return 0;
		return OO;
	}
	ll& ret = memo[i][v];
	if (~ret)return ret;
	ret = min(dp(i + 1, v - val[i]) + we[i], dp(i + 1, v));
	return ret;
}
void solve() {
	cin >> n>>cost;
	we = vector<int>(n);
	val = vector<int>(n);
	for (int i = 0; i < n; i++)cin >> we[i] >> val[i];
	mem(memo, -1);
	for (int i = 100000; i >= 0; i--) {
		if (dp(0, i) <= cost) { cout << i; break; }
	}
}
int main() {
	file();
//	test {
		solve();
		
//	}
	return 0;
}

Measured memory_bytes: 85668
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(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 erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
inline int newline() { putchar('\n'); return 0; }

int main() {
    ll n, k;
    cin(n);
    cin(k);

    double expected[n];
    rep2(i, n) {
        ll temp;
        cin(temp);

        double e = (1.0 + temp) / 2.0;

        if (i == 0) expected[i] = e;
        else expected[i] = expected[i - 1] + e;
    };

    double max = 0;
    rep3(i, k - 1, n) {
        if (i == k - 1) {
            max = expected[i];
        } else {
            if (expected[i] - expected[i - k] > max) {
                max = expected[i] - expected[i - k];
            }
        }
    }

    printf("%.12lf\n", max);
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int n;
    long long ans = 0;
    cin >> n;
    vector<int> a(n),b(n),c(n);
    for(int i = 0;i < n;i++){
        cin >> a[i] >> b[i];
        c[i] = (a[i]+b[i]);
        ans -= b[i];
    }
    sort(c.begin(),c.end(),greater<int>());
    for(int i = 0;i < n;i+=2){
        ans += c[i];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main()
{
    LL n,m,c;cin>>n>>m>>c;
    VL b(m);
    REP(i,m){
        cin>>b[i];
    }
    VVL a(n);
    REP(i,n){
        a[i].resize(m);
        REP(j,m){
            cin>>a[i][j];
        }
    } 

    LL result = 0;
    REP(i,n){
        LL t = c;
        REP(j,m){
            t += a[i][j] * b[j];
        }
        if(t > 0){
            result++;
        }

    }
    cout<<result<<endl;

    
	return;
}

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

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

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int NumOfDisits(long n)
        {
            int count = 0;
            while (n > 0)
            {
                ++count;
                n /= 10;
            }
            return count;
        }
        static int Solve(long N)
        {
            int min = int.MaxValue;
            for (long a = 1; a * a <= N; ++a)
            {
                if (N % a == 0)
                {
                    long b = N / a;
                    min = Math.Min(Math.Max(NumOfDisits(a), NumOfDisits(b)), min);
                }
            }
            return min;
        }
        static void Main(string[] args)
        {
            long N = ReadLong();
            Console.WriteLine(Solve(N));
        }
    }
}


Measured memory_bytes: 13140
// Created by arvybhatt

#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define p_b push_back
#define m_p make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;

int main()
{
    fast;
  	int n;cin>>n;
  	ll s=0;
  	for(int i=1; i<=n; i++)
  	{
  		if(i%3!=0 && i%5!=0)
  		{
  			s+=i;
  		}
  	}
  	cout<<s;

}


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

int main() {

    int r;
    cin >> r;

    cout << 3 * r * r << endl;

    return 0;
}

Measured memory_bytes: 256