akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N;
  cin >> N;
  vl A(N + 1, 0);
  rep2(i, 1, N + 1) cin >> A[i];

  map<ll, ll> cnt;
  cnt[1 + A[1]]++;
  ll ans = 0;

  rep2(i, 2, N + 1){
    ans += cnt[i - A[i]];
    cnt[i + A[i]]++;
  }

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


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

using ll = long long;

constexpr ll INF = 1'010'000'000'000'000'017LL;
constexpr ll MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for(ll i = (start); i < end; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }

template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
using pint = pair<int, int>;
using pll = pair<ll, ll>; using vp = V<pll>;

ll mod(ll val, ll m){ ll res = val % m; if(res < 0) res += m; return res;}
ll modinv(ll a, ll m) { ll b = m, u = 1, v = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u;}
ll modpow(ll a, ll n, ll mod) { ll res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }


//---------------------------------------------------------------

void Main()
{
    ll N;
    cin >> N;
    V<string> S(N+1, "~");
    REP(i, N){
        cin >> S[i];
    }

    sort(ALL(S));

    V<string> ans;
    ll max_cnt, num, cnt;
    max_cnt = 0;
    num = 0;
    cnt = 0;
    REP(i, N){
        cnt++;
        if(S[i] != S[i+1]){
            if(cnt > max_cnt){
                max_cnt = cnt;
                num = 1;
                ans.clear();
                ans.push_back(S[i]);
            }else if(cnt == max_cnt){
                num += 1;
                ans.push_back(S[i]);
            }
            cnt = 0;
        }
    }

    cout << endl;
    REP(i, num){
        cout << ans[i] << endl;
    }
}

//---------------------------------------------------------------
int main()
{
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 15988
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
int main()
{
  int k;
  cin>>k;
  string s;
  cin>>s;
  if(s.size()<=k)
  {
    cout<<s<<endl;
  }
  else
  {
    for(int i=0;i<k;i++)
    {
      cout<<s[i];
    }
    cout<<"..."<<endl;
  }
}

Measured memory_bytes: 3624
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	x=II()

	li=set([1])

	for i in range(2,35):
		for j in range(2,11):
			if i**j<=1001:
				li.add(i**j)
			else:
				break

	li=list(li)
	li.sort(reverse=True)

	#print(li)

	for i in li:
		if i<=x:
			print(i)
			exit()










if __name__ == "__main__":
	main()


Measured memory_bytes: 9144
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

ll sum(ll n, ll a) {
    ll ret = n / a;
    ret = (1+ret)*ret/2*a;
    return ret;
}

int main(void)
{
    int N;
    cin >> N;
    cout << sum(N, 1)-sum(N, 3)-sum(N, 5)+sum(N, 15) << endl;
    return 0;
}


Measured memory_bytes: 3636
from math import factorial


def cmb(n,r):
    return factorial(n)//(factorial(n-r)*factorial(r))


n,p=map(int,input().split())
A=list(map(int,input().split()))
A=[A[i]%2 for i in range(n)]

cnt=A.count(0)
ans=0
for i in range(p,n-cnt+1,2):
    ans +=cmb(n-cnt,i)
print(ans*(2**cnt))

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

constexpr int mod = 1e9 + 7;
constexpr int32_t inf = 1001001001;
constexpr int64_t infll = 1001001001001001001ll;
constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int a = in(), b = in();
  cout << (max(a, b) < 9 ? "Yay!" : ":(") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 9223372036854775807

signed main()
{
    int n;
    double m;
    cin >> n >> m;
    double a[n];
    double sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    double ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] >= sum / (4 * m))
        {
            ans++;
        }
    }

    if (ans >= m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

int main(void) {
	int r, g, b, n, sum = 0;
	cin >> r >> g >> b >> n;
	for (int i = 0; r*i <= n; i++) {
		for (int j = 0; r*i + g * j <= n; j++) {
			int k = n - r * i - g * j;
			if (k%b == 0)sum++;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int N=3030,P=1e9+7,iv2=(P+1)>>1;
int n,Q,x,y,ans,a[N],f[N][N],g[N][N];
int qpw(int x,int y){int z=1;for(;y;y>>=1,x=1ll*x*x%P)if(y&1) z=1ll*z*x%P;return z;}
int main(){
	scanf("%d%d",&n,&Q);
	FOR(i,1,n) scanf("%d",&a[i]);
	FOR(i,1,n)FOR(j,i+1,n) f[i][j]=a[i]>a[j],g[i][j]=a[i]==a[j];
	FOR(p,1,Q){
		scanf("%d%d",&x,&y);
		if(x>y) swap(x,y);
		f[x][y]=1ll*(1-g[x][y]+P)%P*iv2%P;
		FOR(i,1,x-1){
			f[i][x]=f[i][y]=1ll*(f[i][x]+f[i][y])%P*iv2%P;
			g[i][x]=g[i][y]=1ll*(g[i][x]+g[i][y])%P*iv2%P;
		}
		FOR(i,x+1,y-1){
			int u=f[x][i],v=f[i][y],a=g[x][i],b=g[i][y];
			f[x][i]=1ll*(u+((1-v+P)%P-b+P)%P)%P*iv2%P;
			f[i][y]=1ll*(v+((1-u+P)%P-a+P)%P)%P*iv2%P;
			g[x][i]=g[i][y]=1ll*(a+b)%P*iv2%P;
		}
		FOR(i,y+1,n){
			f[x][i]=f[y][i]=1ll*(f[x][i]+f[y][i])%P*iv2%P;
			g[x][i]=g[y][i]=1ll*(g[x][i]+g[y][i])%P*iv2%P;
		}
		//FOR(i,1,n)FOR(j,1,n) cout<<f[i][j]<<char(j==n?'\n':' ');
	}
	FOR(i,1,n)FOR(j,i+1,n) (ans+=f[i][j])%=P;
	ans=1ll*ans*qpw(2,Q)%P;
	cout<<ans<<'\n';
}

Measured memory_bytes: 71936
#include<stdio.h>
#include<string.h>
#define INFTY (1<<30)
#define MAX 10000000

int p(int i){return i/2;}
int l(int i){return 2*i;}
int r(int i){return 2*i+1;}

void maxHeapify(int *,int );
void swap(int *,int *);
void insert(int *,int );
void heapIncreaseKey(int *,int ,int );
int  extract(int *);

int n;

int main(){
  int key;
  char ob[10];
  int A[MAX];
 
  while(1){
    strcpy(ob,"");
    scanf("%s",ob);
    if(strcmp(ob,"insert")==0){
      scanf("%d",&key);
      insert(A,key);
    }else if(strcmp(ob,"extract")==0){
      printf("%d\n",extract(A));
    }else if(strcmp(ob,"end")==0) break;
  }

  return 0;
}


void maxHeapify(int *A,int i){
  int lft,rgh,max;
  lft=l(i);
  rgh=r(i);

  if(lft <= n && A[lft]>A[i]) max=lft;
  else max=i;
  if(rgh <=n && A[rgh]>A[max]) max=rgh;

  if(max!=i){
    swap(&A[max],&A[i]);
    maxHeapify(A,max);
  }
}

void swap(int *a,int *b){
  int buf;
  buf=*a;
  *a=*b;
  *b=buf;
}

void heapIncreaseKey(int *A,int i,int key){
  if(key<A[i]) return ;
  A[i]=key;
  while(i>1 && A[p(i)]<A[i]){
    swap(&A[p(i)],&A[i]);
    i=p(i);
  }
}

void insert(int *A,int key){
  n++;
  A[n]=-INFTY;
  heapIncreaseKey(A,n,key);
}

int extract(int *A){
  int max;
  if(n<1) return -INFTY;
  max=A[1];
  A[1]=A[n--];
  maxHeapify(A,1);
  return max;
}



Measured memory_bytes: 5604
import sys
from heapq import heappop, heappush
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')

class BIT:
    def __init__(self, size):
        self.size = size
        self.tree = [0] * (size + 1)

    def add(self, index):
        while index <= self.size:
            self.tree[index] += 1
            index += index & (-index)

    def sum(self, index):
        s = 0
        while index:
            s += self.tree[index]
            index -= index & (-index)
        return s

    def search(self, val):
        i = 0
        s = 0
        step = 1 << (self.size.bit_length() - 1)  # 一番上の長さ

        while step:
            if i + step <= self.size and s + self.tree[i + step] < val:
                i += step
                s += self.tree[i]
            step //= 2
        return i + 1

def sol():
    N = int(input())
    P = [None] + list(map(int, input().split()))

    pToI = {p : i for i, p in enumerate(P[1:], 1)}
    tree = BIT(N)

    ans = 0
    for p in range(1, N + 1)[:: -1]:
        i = pToI[p]
        left = tree.sum(i)  # 左にある個数
        tree.add(i)
        right = (N - p) - left  # 右にある個数(処理済みの内，左にないものの個数)

        # L1 < L2 < p < R1 < R2
        L1 = tree.search(left - 1) if left >= 2 else 0
        L2 = tree.search(left) if left >= 1 else 0
        R1 = tree.search(left + 2) if right >= 1 else N + 1
        R2 = tree.search(left + 3) if right >= 2 else N + 1

        cnt = 0
        if L2 != 0:
            cnt += (L2 - L1) * (R1 - i)
        if R1 != 0:
            cnt += (R2 - R1) * (i - L2)

        ans += cnt * p

    print(ans)

sol()

Measured memory_bytes: 67924
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int dx[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
int dy[] = { -1, -1, 0, 1, 1, 1, 0, -1 };
const ll MOD = 1000000007;
const ll INF = 1000000;
const int MAX = 10000000;

int n;

int main() {
    cin >> n;
    cout << n / 3 << endl;
}

Measured memory_bytes: 768
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;

signed main() {
	ll h, w; cin >> h >> w;
	vector<string> v(h);
	rep(i, h) cin >> v[i];
	ll i = 0;
	ll t = 0;
	while (i < h) {
		cout << v[i] << endl;
		if (t == 0) t++;
		else {
			t = 0;
			i++;
		}
	}
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int x, y, b=0;
  scanf("%d %d", &x, &y);
  
  for(int i=0; i<=x; i++){
    int sum = i*2+(x-i)*4;
    if(sum==y){
      b = 1;
    }
  }
  if(b==1){
    printf("Yes");
  }
  else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 1736
#![allow(unused_imports)]

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::fmt::{Debug, Display};
use std::io::{self, Read};
use std::str::{self, FromStr};


fn solve(ab: Vec<(u64, u64)>) -> u64 {
    let a = ab.iter().map(|&p| p.0).max().unwrap();
    let b = ab.iter()
        .filter_map(|&p| if p.0 == a { Some(p.1) } else { None })
        .next()
        .unwrap();
    a + b
}


fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    let n = sc.next();
    println!("{}", solve(sc.pairs(n)));
}


struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(256),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: Debug,
    {
        self.buf.clear();
        for c in self.bytes
            .by_ref()
            .map(|c| c.unwrap())
            .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
            .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
        {
            self.buf.push(c);
        }
        str::from_utf8(&self.buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<A: FromStr, B: FromStr>(&mut self, n: usize) -> Vec<(A, B)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<A: FromStr, B: FromStr, C: FromStr>(&mut self, n: usize) -> Vec<(A, B, C)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
        <C as FromStr>::Err: Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.vec(m)).collect()
    }
}


#[allow(dead_code)]
fn print_yesno(x: bool, yes: &'static str, no: &'static str) {
    println!("{}", if x { yes } else { no });
}


#[allow(dead_code)]
fn print_foreach<T: Display, I: IntoIterator<Item = T>>(xs: I) {
    for x in xs.into_iter() {
        println!("{}", x);
    }
}


#[allow(dead_code)]
fn print_or<T: Display>(x: Option<T>, or: &'static str) {
    if let Some(x) = x {
        println!("{}", x);
    } else {
        println!("{}", or);
    }
}


Measured memory_bytes: 6396
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int n,m;
int main()
{

    cin>>n>>m;
    for(int i=m/n;i>=1;i--)
    {
        if(m%i==0)
        {
            int t=m/i;
            if(t>=n)
            {
                cout<<i<<endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];

int main(){
    int K,X,N,ans = 1;
    cin >> K >> X;
    int a = max(X - K + 1, -1000000);
    int b = min(X + K - 1, 1000000);
    for(int i = a; i < b+1; i++){
        cout << i;
        if(i == b) cout << " " << endl;
        else cout << " ";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int Max_N = 101;
int A[Max_N], N;
void Cout_Sort(){
	for(int i=0; i<N; i++){
		cout << A[i];
		if(i != (N - 1)) cout << " ";
	}
	cout << endl;
} 
void Insertion_Sort(){
    int i;
	for(int P=1; P<N; P++){
	 int temp = A[P];  /*待插入的数*/
	 for( i = P; i>0 && A[i-1]>temp;i--)
	 A[i] = A[i-1];
     A[i] = temp; /*找到插入位置*/
     Cout_Sort();
	}
}
int main()
{   
    cin >> N;
    for(int i=0; i<N; i++)
      cin >> A[i];
	Cout_Sort();
    Insertion_Sort(); 
    return 0;
}


Measured memory_bytes: 3120
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int ans = Reader.ReadLine().Count(a => a == 'o') * 100 + 700;
        Console.WriteLine(ans);



    }





    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"








";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 13268
def main():
    n, w_lim = map(int, input().split())
    group = {}
    min_w = 0
    for i in range(n):
        w, v = map(int, input().split())
        if i == 0:
            group = {x: [] for x in range(w, w + 4)}
            min_w = w
        group[w].append(v)
    length = [len(group[i]) + 1 for i in range(min_w, min_w + 4)]
    for i in range(min_w, min_w + 4):
        group[i].sort(reverse=True)
        for j in range(1, length[i - min_w] - 1):
            group[i][j] += group[i][j - 1]
        group[i] = [0] + group[i]
    answer = 0
    for i in range(length[0]):
        for j in range(length[1]):
            for k in range(length[2]):
                for l in range(length[3]):
                    if w_lim < min_w * i + (min_w + 1) * j + (min_w + 2) * k + (min_w + 3) * l:
                        break
                    answer = max(answer, group[min_w][i] + group[min_w + 1][j] + group[min_w + 2][k] + group[min_w + 3][l])
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 40304
#include<iostream>

using namespace std;

int main(){
  int N,A; cin >> N >> A;
  A /= 1000; bool flag = false;
  for(int X = 0; X <= N; X++){
    for(int Y = 0; Y <= N - X; Y++){
      if(9*X + 4*Y + N == A){ flag = true; 
                             cout <<X<<' '<< Y << ' ' << N - X - Y << endl; return 0;}
    }}
  
  cout <<"-1 -1 -1"<< endl; return 0;}


Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        long[] h = new long[N+K+1];
        long[] ans = new long[N+K+1];
        for(int i=0;i<N;i++){
            h[i] = Long.parseLong(sc.next());
            ans[i]=-1;
        }
        for(int i=0;i<N;i++){
            for(int j=i+1;j<=K+i;j++){
                if(ans[j] >= 0)
                    ans[j] = Math.min(ans[j], ans[i] + Math.abs(h[i]-h[j]));
                else 
                    ans[j] = (ans[i]>=0?ans[i]:0) + Math.abs(h[i]-h[j]);
            }
        }
        System.out.println(ans[N-1]);
    }
}

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

int main() {
  int N;
  cin >> N;
  for (int n = 1; n <= N; n++) {
    int cnt = 0;
    for (int x = 1; x * x < n; x++) {
      for (int y = 1; x * x + y * y < n; y++) {
        for (int z = 1; x * z + y * z + z * z <= n - x * x - y * y - x * y; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == n) cnt++;
        }
      }
    }
    cout << cnt << "\n";
  }
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> p;


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, ll> p;
 
#define MOD 1000000007

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

    int N, K;
    cin >> N >> K;

    vector<int> A(N);

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

    for(int i = 0; i < min(K, 41); i++) {
        vector<int> B(N);
        for(int j = 0; j < N; j++) {
            int l = max(0, j - A[j]);
            int r = j + A[j] + 1;
            B[l]++;
            if(r < N) B[r]--;
        }
        A[0] = B[0];
        for(int j = 1; j < N; j++) {
            B[j] += B[j - 1];
            A[j] = B[j];
        }
    }

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

Measured memory_bytes: 5008
def solve(string):
    s, k = string.split()
    k = int(k)
    chars = sorted(set(s))
    exists = []

    def dfs(base):
        exists.append(base)
        if len(exists) >= k:
            return
        for c in chars:
            if base + c in s:
                dfs(base + c)

    for c in chars[:3]:
        dfs(c)

    return exists[k - 1]


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <set>
#include <string>

using namespace std;

int main(){
  int m;
  string str;
  cin >> m;

  while(m--){
    set <string> train;
    cin >> str ;

    for(unsigned int i=1;i < str.size();i++){
      string str1[2],str2[2];
      str1[0] = str.substr(0,i);
      str1[1] = "";

      for(int j=str1[0].size()-1;j >= 0;j--){
        str1[1] += str1[0][j];
      }

      str2[0] = str.substr(i);
      str2[1] = "";

      for(int j=str2[0].size()-1;j >= 0;j--){
        str2[1] += str2[0][j];
      }


      for(int j=0;j<2;j++){
        for(int k=0;k<2;k++){
          if(train.empty()) train.insert(str1[j] + str2[k]);
          if(train.find(str1[j] + str2[k]) == train.end()) train.insert(str1[j] + str2[k]);
          if(train.find(str2[j] + str1[k]) == train.end()) train.insert(str2[j] + str1[k]);
        }
      }

    }
    cout << train.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 1000
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>n;
    cin>>s;
    for(int i=0;i<s.length();i++){
        s[i]=(s[i]+n-'A')%26+'A';
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;
  multiset<int> set;
  rep(i,n){
    int a;
    cin>>a;
    set.insert(a);
  }

  int ans=0;
  int s=1LL<<31;
  
  while(s>1){
    multiset<int> mul;
    mul=set;
    for(int x:set){
      auto it=mul.find(s-x);
      if(it!=mul.end()){
        mul.erase(it);
        if(mul.find(x)==mul.end()){
          mul.insert(*it);
        }else{
          ans++;
          mul.erase(mul.find(x));
        }
      }
    }
    set=mul;
    s>>=1;
  }
    
  cout<<ans<<endl;


}

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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI

int main() {
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    if ( n <= m ) {
        ans = 1;
    }

    cout << ( ans ? "unsafe" : "safe" ) << endl;
    return 0;
}


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

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

    cout << acos(-1)*r*2.0 << endl;
    return 0;
}

Measured memory_bytes: 3768
let n = stdin.ReadLine() |> int

let a =
  [| for _ in 0 .. n - 1 -> stdin.ReadLine() |> (fun x -> int x - 1) |]

let ans =
  [1 .. n]
  |> List.scan (fun acc _ -> a.[acc]) 0
  |> List.tryFindIndex (fun i -> i = 1)
  |> (fun x ->
        match x with
        | Some i -> i
        | None -> -1 )

ans |> stdout.WriteLine

Measured memory_bytes: 29784
#include <bits/stdc++.h>
using namespace std;
void alert(vector<int> vec){
  int64_t N = vec.size();
  for(int64_t i=0; i<N-1; i++){
    cout << vec.at(i) << " ";
  }
  cout << vec.at(N-1) << endl;
}

int main(){
  int S, W;
  cin >> S >> W;
  if(S<=W) cout << "unsafe" << endl;
  else cout << "safe" << endl;
}

Measured memory_bytes: 3640
word = input()
q = int(input())

for _ in range(q):
    s = input().split(" ")
    command = s[0]
    a = int(s[1])
    b = int(s[2])
    if command == "print":
        print(word[a:b+1])
    elif command == "reverse":
        word = word[:a] + word[a:b+1][::-1] + word[b+1:]
    elif command == "replace":
        word = word[:a] + s[3] + word[b+1:]

Measured memory_bytes: 7652
a, b = input().split(" ")

a_str = ""
b_str = ""

for i in range(int(b)):
    a_str = a_str + a
for i in range(int(a)):
    b_str = b_str + b

if a_str < b_str:
    print(a_str)
else:
    print(b_str)

Measured memory_bytes: 8904
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

MOD = 10**9+7

fac = [1, 1]     # 元テーブル
f_inv = [1, 1]   # 逆元テーブル
inv = [0, 1]     # 逆元テーブル計算用テーブル
def prepare(n, mod):
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)


def cmb(n, r, mod):
    if n < 0 or r < 0:
        return 0
    if r > n:
        return 0

    return fac[n] * pow(fac[r],MOD-2,MOD) * pow(fac[n-r],MOD-2,MOD) % mod


def prime_factorization(n):
    d = []
    i, e = 2, 0  # factor, exponent
    while i * i <= n:
        while n % i == 0:
            n //= i
            e += 1
        if e > 0:
            d.append((i, e))
        i += 1
        e = 0
    if n > 1:
        d.append((n, 1))
    return d


def main():
    N,M = map(int, readline().split())

    prepare(N+100, MOD)
    d = prime_factorization(M)

    ans = 1
    for i, e in d:
        ans *= cmb(N-1+e, e, MOD)
        ans %= MOD

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 7084
package main

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

func main() {
	sc = initScanner(os.Stdin)
	n := scanInt(sc)
	h := scanIntSlice(sc, n)
	fmt.Println(resolve(n, h))
}

func resolve(n int, h []int) int {
	count, max := 0, 0
	prev := h[0]
	for i:=1; i<n; i++  {
		if prev >= h[i] {
			count++
		} else {
			if max < count {
				max = count
			}
			count = 0
		}
		prev = h[i]
	}
	if max < count {
		max = count
	}

	return max
}

// --------------- BASE DEFINITIONS ---------------

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}

func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanStringSlice(sc *bufio.Scanner, n int) []string {
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		ss[i] = sc.Text()
	}

	return ss
}


Measured memory_bytes: 4296
#include <iostream>

typedef long long ll;

#define FOR(i,a,b) for(ll i = (a);i < (b);++i)
#define REP(i,n) FOR(i,0,n)

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

int main(void){

  int x,y,z;
  cin >> x >> y >> z;

  int width = z+y;

  int ideal = x / width;
  
  if(ideal * width > x - z){
    ideal--;
  }

  cout << ideal << endl;

    
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main() {
    srand((unsigned)time(NULL));
    int n; char a[11][11]; int b, c[11], d = -1;
    for (int i = 0; i < 11; i++) { c[i] = 0; }
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
            if (a[i][j] != 'x') c[i]++;
        }
        if (c[i] == n) d = i + 1;
    }
    for (int i = 0; i < 1000; i++) {
        if (d >= 0) cout << d << endl;
        else cout << rand() % n + 1 << endl;
        cin >> b;
    }
    return 0;
}

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

#define ff first
#define ss second
//#define int long long
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp make_pair
#define endl "\n"      // Comment in INTERACTIVE(there just use endl which flushes output , no need of fflush(sdtout)).
//  for counting setbits -> __builtin_popcountll(x)
// for counting zerobits -> __builtin_ctzll(x)
#define fastio() ios_base::sync_with_stdio(false);        cin.tie(NULL); //(unties i/o buffer).
            // DON'T USE SCANF/PRINTF WITH IT (c/c++ -> seperates buffer).

const int mod = 1000000007;
const int inf = 1000000009;
 const int N = (1e5) + 2;
 int arr[N][4];
 int dp[N][4];
 int memo[N][3];


 int profit(int i,int next ,int n){
// memoized BUT DIFFICULT to do from recursion AS IN STATE VAR next -> DEPEND ON next STATE
    // Better if DEPENDENT ON OWN , THEN MORE CLEAR.
    if(i <= 0)
        return 0;
    if(memo[i][next] != -1)
        return memo[i][next];

    int c1 = (next +1)%3;
    int c2 = (next  +2)%3;
    return memo[i][next] = max(profit(i-1,c1,n) + arr[i][c1+ 1] , profit(i-1,c2,n ) + arr[i][c2 + 1]);
 }

int32_t main(){
    fastio();

    // #ifndef ONLINE_JUDGE
    //  freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    // #endif

     memset(memo, - 1, sizeof(memo));

     // ***** AC_chahiye EK BAR MEIN

     // BEGIN CODE HERE
    int n ;
    cin>>n;
    for(int i = 1;i <= n; ++i){
        cin>>arr[i][1]>>arr[i][2]>>arr[i][3];
    }
    dp[0][0] = dp[0][1] = dp[0][2] = dp[0][3] = 0;
    for(int i = 1;i <= n; ++i){
        for(int j = 1;j <= 3 ; ++j){
            int mx = 0;
            for(int k = 1;k <= 3; ++k){
                if(j != k)
                    mx = max(mx,dp[i - 1][k]);
            }
            dp[i][j] = mx + arr[i][j];
        }
    }
    // cout<<max({dp[n][1],dp[n][2],dp[n][3]})<<endl;

    cout<<max({profit(n,0,n) , profit(n,1,n) , profit(n,2,n) })<<endl;
    //getch();
}


Measured memory_bytes: 12416
import java.util.Scanner;

class Main {
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);

      int W = sc.nextInt();
      int H = sc.nextInt();
      int x = sc.nextInt();
      int y = sc.nextInt();
      int r = sc.nextInt();

      if((x + r <= W) && (y + r <= H) && (x - r >= 0) && (y - r >= 0)){
         System.out.println("Yes");
      } else {
         System.out.println("No");
      }
   }
}

Measured memory_bytes: 17316
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=105;

int n,m,p,q;
char g[N][N];
short sc[N][N],sr[N][N],f[N][N][N][N];

inline short wr(int i,int l,int r){ return l<r?sr[i][r]-sr[i][l]:0; }
inline short wc(int j,int l,int r){ return l<r?sc[r][j]-sc[l][j]:0; }

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin);
	freopen("my.out","w",stdout);
#endif
	read(n),read(m);	
	rep(i,1,n){
		scanf("%s",g[i]+1);
		rep(j,1,m){
			if(g[i][j]=='E')p=i,q=j;
			else sc[i][j]=sr[i][j]=g[i][j]=='o';
		}
	}
	rep(i,1,n)rep(j,1,m)sr[i][j]+=sr[i][j-1];
	rep(i,1,n)rep(j,1,m)sc[i][j]+=sc[i-1][j];
	rep(u,0,p-1)rep(d,0,n-p)rep(l,0,q-1)rep(r,0,m-q){	
		Pr("f[%d][%d][%d][%d]=%d\n",u,d,l,r,f[u][d][l][r]);
		if(u+1<=p-1){
			int i=p-(u+1),w=i>=d+1?wr(i,max(r,q-l-1),min(m-l,q+r)):0;
			cmax(f[u+1][d][l][r],w+f[u][d][l][r]);
			Pr("tru,w=%d\n",w); 
		}
		if(d+1<=n-p){
			int i=p+(d+1),w=i<=n-u?wr(i,max(r,q-l-1),min(m-l,q+r)):0;
			cmax(f[u][d+1][l][r],w+f[u][d][l][r]);
			Pr("trd,w=%d\n",w); 
		}
		if(l+1<=q-1){
			int j=q-(l+1),w=j>=r+1?wc(j,max(d,p-u-1),min(n-u,p+d)):0;
			cmax(f[u][d][l+1][r],w+f[u][d][l][r]);
			Pr("trl,w=%d\n",w); 
		}
		if(r+1<=m-q){
			int j=q+(r+1),w=j<=m-l?wc(j,max(d,p-u-1),min(n-u,p+d)):0;
			Pr("(%d,%d]\n",max(d,p-u-1),min(n-d,p+u)); 
			cmax(f[u][d][l][r+1],w+f[u][d][l][r]);
			Pr("trr,w=%d\n",w); 
		}
	}
	printf("%d\n",f[p-1][n-p][q-1][m-q]);
	return 0;
}

Measured memory_bytes: 205184
import math
import collections
import fractions
import itertools
import functools
import operator

def ncr(n, r):
    if n < r: return 0
    r = min(r, n-r)
    if r == 0:
        return 1
    numer = functools.reduce(operator.mul, range(n, n-r, -1), 1)
    denom = functools.reduce(operator.mul, range(1, r+1), 1)
    return numer // denom

def solve():
    n, k = map(int, input().split())
    for i in range(1,k+1):
        ans = (ncr(k-1, i-1) * ncr(n-k+1, i)) % (10**9+7)
        print(int(ans))
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 10552
#include <iostream>

using namespace std;

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

	int A,B,C;
	cin >> A >> B >> C;

	if (((A == 5) && (B == 7) && (C == 5)) ||
		((A == 7) && (B == 5) && (C == 5)) ||
		((A == 5) && (B == 5) && (C == 7))) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 892
class UnionFind(n: Int) {
    private val par = IntArray(n) { -1 }
    fun find(x: Int): Int {
        if (par[x] < 0) return x
        par[x] = find(par[x])
        return par[x]
    }
    fun unite(x: Int, y: Int) {
        val (rx, ry) = run {
            val rx = find(x)
            val ry = find(y)
            if (rx > ry) ry to rx else rx to ry
        }
        if (rx == ry) return
        par[rx] += par[ry]
        par[ry] = rx
    }
    fun same(x: Int, y: Int): Boolean {
        return find(x) == find(y)
    }
    fun size(x: Int): Int {
        return -par[find(x)]
    }
}

fun main(args: Array<String>) {
    val (n, m, k) = readLine()!!.split(' ').map { it.toInt() }
    val uf = UnionFind(n + 1)
    val fs = IntArray(n + 1)
    val bs = IntArray(n + 1)

    repeat(m) {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        fs[a]++
        fs[b]++
        uf.unite(a, b)
    }

    repeat(k) {
        val (c, d) = readLine()!!.split(' ').map { it.toInt() }
        if (uf.same(c, d)) {
            bs[c]++
            bs[d]++
        }
    }

    val ans = (1..n)
            .map { uf.size(it) -1 - fs[it] - bs[it] }
            .joinToString(" ")

    println(ans)
}


Measured memory_bytes: 77380
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
const double ONE=1.0;
const double EO=1e-10;
const double T=45.0/atan(1.0);
double a,b,x;
int Check(double p){
	double len=a/tan(p);
	double v=a*a*(b-len)+a*a*len/2;
	return v>=x;
}
int main(){
	scanf("%lf%lf%lf",&a,&b,&x);
	double l=0,r=3.1415926535+EO;
	if(a*a*b/2>=x){
		double t=ONE*2*x/(a*b);
		printf("%.10f\n",90-atan(t/b)*T);
		return 0;
	}
	while(l+EO<r){
		double mid=(l+r)/2;
		if(Check(mid))r=mid;
		else l=mid;
	}
	printf("%.10f\n",90-r*T);
}


Measured memory_bytes: 384
(declaim (optimize (speed 3) (debug 0) (safety 0)))

;;cyclone-loop
(defun cyclone-reader (stream char)
  (declare (ignore char))
  `(loop ,@(read stream t nil t) do ,(read stream t nil t)))
(set-macro-character #\CYCLONE #'cyclone-reader)
;;

(defun main ()
  (let ((a (* (read) 100))
        (b (* (read) 100))
        (c (read))
        (d (read))
        (e (read))
        (f (read)))
    (declare (fixnum a) 
             (fixnum b)
             (fixnum c)
             (fixnum d)
             (fixnum e)
             (fixnum f))
    🌀 (for an to (truncate f a)
               :with max rational  = -1
               :with amax fixnum = -1
               :with smax fixnum = 0
               :finally (format t "~A ~A~%" amax smax)) 
    🌀 (for bn to (truncate (- f (* an a)) b))
    🌀 (for cn to (truncate (- f (+ (* an a) (* bn b))) c))
    🌀 (for dn to (truncate (- f (+ (* an a) (* bn b) (* cn c))) d)
               :for s fixnum = (+ (* cn c) (* dn d))
               :for w fixnum = (+ (* an a) (* bn b))
               :for all fixnum = (+ w s))
    (when (and (not (zerop all))
               (> (/ s all) max)
               (<= all f)
               (<= (* s 100) (* e w)))
      (setf max (/ s all))
      (setf amax all)
      (setf smax s))))
(compile 'main)
(main)

Measured memory_bytes: 55656
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    string ans = "";
    int n;
    vector<int> val(3);
    cin>>n>>val[0]>>val[1]>>val[2];
    char arr[n+1][2];
    for(int i = 0; i < n; i++)
        cin>>arr[i][0]>>arr[i][1];
    for(int i = 0; i < n; i++){
        int x = arr[i][0]-'A', y = arr[i][1]-'A';
        if(!val[x] && !val[y]){
            cout<<"No";
            return ;
        }

        if(val[x] > val[y]){
            ans += 'A'+y;
            --val[x];
            ++val[y];
        }
        else if(val[x] < val[y] || i == n-1){
            ans += 'A'+x;
            ++val[x];
            --val[y];
        }
        else{
            int x2 = arr[i+1][0]-'A', y2 = arr[i+1][1]-'A';
            if(x== x2 || x == y2){
            ans += 'A'+x;
            ++val[x];
            --val[y];
            }
            else{
            ans += ('A'+y);
            ++val[y];
            --val[x];}
        }
    }
        cout<<"Yes\n";
        for(char ch : ans)
            cout<<ch<<"\n";
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3968
#include <iostream>
#include <string>
#include <cmath>
#include <stdio.h>

using namespace std;

int main(void)
{
    int n;
    long k;

    int a[200000 + 1];

    cin >> n;
    cin >> k;

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    // for (int i = 1; i <= n; i++) {
    //     cout << a[i] << endl;
    // }

    int current_pos = 1;
    int tele_count = 0;

    bool visited[200000 + 1];

    for (int i = 0; i <= n; i++) {
        visited[i] = false;
    }

    int loop_first;

    while (true) {
        current_pos = a[current_pos];
        tele_count++;
        // cout << "current_pos: ";
        // cout << current_pos << endl;
        if (visited[current_pos] == true) {
            loop_first = current_pos;
            break;
        }
        else {
            visited[current_pos] = true;
        }
    }

    // cout << tele_count << endl;

    int pre = 0;
    current_pos = 1;

    int count = 0;
    while (true) {
        current_pos = a[current_pos];
        pre++;
        // cout << "current_pos: ";
        // cout << current_pos << endl;
        if (current_pos == loop_first) {
            break;
        }
    }

    int loop_count = tele_count - pre;

    // cout << "loop_count: ";
    // cout << pre;

    int ans_pos = 1;

    if (k <= pre) {
        for (int i = 0; i < k; i++) {
            ans_pos = a[ans_pos];
        }
    } else {
        for (int i = 0; i < pre; i++) {
            ans_pos = a[ans_pos];
        }
        for (int i = 0; i < (k - pre) % (loop_count); i++) {
            ans_pos = a[ans_pos];
        }
    }

    // cout << "ans: ";
    cout << ans_pos;

    // int ans = memo[k % loop_count];
    // for (int i = 1; i <= loop_count; i++) {
    //     cout << memo[i] << endl;
    // }
    // cout << ans;
    return 0;
}


Measured memory_bytes: 4616
#include <iostream>
#include <string>
#include <algorithm>
#include<vector>

using namespace std;

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

Measured memory_bytes: 3628
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

int d[100][100];             //スタートからの距離を保存
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


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


   int cnt = 0;
   rep(i, h){
       if(i % 2 == 0){
           rep(j, w){
               mem[i][j] = cnt + 1;
               a[cnt]--;
               if(a[cnt] == 0)cnt++;
           }
       }

       else {
           for(int j = w - 1; j >= 0; j--){
               mem[i][j] = cnt + 1;
               a[cnt]--;
               if(a[cnt] == 0)cnt++;
           }
       }
   }
   rep(i, h){
       rep(j, w)cout << mem[i][j] << " ";
       cout << endl;
   }
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {
	unordered_map<ll,ll> mp;
	for(int i=1;i<=100;i++) {
		for(int j=1;j<=100;j++) {
			for(int k=1;k<=100;k++) {
				ll temp = (i+j+k) * (i+j+k);
				temp -= (i*j + j*k + k*i);
				mp[temp]++;
			}
		}
	}
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) {
		cout<<mp[i]<<"\n";
	}
}

Measured memory_bytes: 5064
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

int h, w, now = 0;
int xd[] = {1, 0, -1, 0};
int yd[] = {0, 1, 0, -1};
char d[] = {'R', 'D', 'L', 'U'};
int moved[2] = {0};
// mp[y][x]
bool mp[505][505] = {0};
string ans;
// fi = y,se = x
list<pair<int, int>> ls;

void solve();

int main() {
  cin >> h >> w;
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j) {
      char c;
      cin >> c;
      mp[i][j] = (c == '#');
    }
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j)
      if(mp[i][j]) ls.push_back(make_pair(i, j));
  solve();
  pair<int, int> a = *(ls.begin());
  cout << "! " << a.fi << " " << a.se << endl;
  return 0;
}

void solve() {
  int nx, ny;
  pair<int, int> np;
  bool init = 1;
  while(ls.size() > 1) {
    bool isyes;
    cout << "? " << d[now] << endl;
    cin >> ans;
    isyes = (ans == "YES");
    nx = moved[0] + xd[now];
    ny = moved[1] + yd[now];
    for(auto i = ls.begin(); i != ls.end(); ++i) {
      np = *i;
      int x = np.se + nx, y = np.fi + ny;
      if(x >= 0 && x < w && y >= 0 && y < h &&
         mp[y][x] != isyes) {
        i = ls.erase(i);
        --i;
      }
    }
    if(isyes) {
      moved[0] += xd[now];
      moved[1] += yd[now];
      if(!init) now = (3 + now) % 4;
    }
    else {
      if(init) init = 0;
      now = (now + 1) % 4;
    }
  }
}


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

int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  long long n;
  cin >> n;
  long long x = sqrt(n);
  for (long long i = x; i >= 1; i--) {
    if (n % i == 0) {
      cout << i + n / i - 2 << endl;
      return 0;
    }
  }
}

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

int main(){
  int N;
  cin >> N;
  
  string str;
  
  cin >> str;
  
  int n = N;
  
  rep(i, N - 1){
    if(str.at(i) == str.at(i + 1)) n--;
  }
  
  cout << n << endl;
}

Measured memory_bytes: 512