akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

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

   double a, b;
   a = r * r * M_PI;
   b = 2 * r * M_PI;

   printf("%.6f %.6f\n", a, b);

   return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

LL gcd(LL x,LL y) { return (!x||!y)?x+y:gcd(y,x%y); }
LL lcm(LL x,LL y) { return x/gcd(x,y)*y; }

LL solve(LL n, LL c, LL d)
{
  return n-(n/c)-(n/d)+n/lcm(c,d);
}
int main(void)
{
  LL a,b,c,d;
  cin >> a >> b >> c >> d;
  --a;
  cout << solve(b,c,d) - solve(a,c,d) << endl;
  return 0;
}


Measured memory_bytes: 256
def sieve(n):
    num = [True] * n
    num[0] = num[1] = False
    for i in range(2,int(n**0.5)+1):
        if num[i]:
            for j in range(i**2, n, i):
                num[j] = False
    return [i for i in range(2, n) if num[i]]
 
prime = sieve(110000)
 
while True:
    n = int(input())
    if n == 0: break
    print(sum(prime[:n]))

Measured memory_bytes: 8560
#include <iostream>
#include <vector>
using namespace std;
vector< vector<int> > edg;
vector<int> clr, a, b;
int k = 0;
void f(int x, int y){
    int c = 0;
    for(int i=0;i<edg[x].size();i++){
        int z = edg[x][i];
        if(clr[z] != 0)continue;
        c++;
        if(c == y) c++;
        clr[z] = c;
        k = max(k, c);
        int v = a[z];
        if(v == x) v = b[z];
        f(v, c);
    }
}
int main(void){
    int n;
    cin >> n;
    edg.assign(n, vector<int>());
    clr.assign(n, 0);
    a.assign(n, 0);
    b.assign(n, 0);
    
    for(int i=0;i<n-1;i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        edg[a[i]].push_back(i);
        edg[b[i]].push_back(i);
    }
    f(0, 0);
    cout << k << endl;
    for(int i=0;i<n-1;i++){
        cout << clr[i] << endl;
    }
}


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

int main() {
    long long N,min=1e6,o=1e9+1;
    int a=1;
    cin >> N;

    priority_queue<int> que;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        que.push(A.at(i));
    }
    
    // 処理順に出力する
     while (!que.empty()) {
        if(o==que.top()){
            a=0;
            break;
        }
        o = que.top();
        que.pop();
    }
    
    if(a==1) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 2936
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int x = in.nextInt();
            int min = Integer.MAX_VALUE;
            for (int i = 0; i < n; i++) {
                int cn = in.nextInt();
                x -= cn;
                if (cn < min)
                    min = cn;
            }
            out.println(n + x / min);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



Measured memory_bytes: 21460
S = input()
ans = 0
for i in range(len(S)):
    if i%2 == 0:
        if S[i] == "R" or S[i] == "U" or S[i] == "D":
            ans+= 1
    else:
        if S[i] == "L" or S[i] == "U" or S[i] == "D":
            ans+=1
if ans == len(S):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
 int n,x=0,a=0,i;
 scanf("%d",&n);
 char s[n+1];
 scanf("%s",s);
 for(i=0;i<n;i++){
  if(s[i]=='I') a++;
  else a--;
  if(x<a) x=a;
 }
 printf("%d",x);
 return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll A, B, K; cin >> A >> B >> K;
  if(A>=K) {
    cout << A-K << " " << B <<endl;
  } else if(A+B <= K) {
    cout << "0 0" <<endl;
  } else {
    cout << "0 " << A+B-K << endl;
  }
}

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

const int INF = 1 << 30;

typedef struct
{
  int l, r;
} Range;

int main()
{
  int n;
  while (~scanf("%d", &n)) {
    if (n == 0)
      break;

    vector<vector<Range> > s(2);
    for (int i = 1; i <= n; ++i) {
      int c;
      scanf("%d", &c);
      if (i%2 == 0) {
	if (!s[c].empty() && s[c].back().r+1 == i) {
	  s[c].back().r = i;
	} else {
	  if (s[c].empty())
	    s[c].push_back(s[c^1].back());
	  s[c^1].pop_back();
	  s[c].back().r = i;
	}
      } else {
	if (s[c].empty() || s[c].back().r+1 != i)
	  s[c].push_back((Range){i, i});
	else
	  s[c].back().r = i;
      }
    }

    int ans = 0;
    for (unsigned int i = 0; i < s[0].size(); ++i)
      ans += s[0][i].r - s[0][i].l + 1;
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+5;
int num[N]={0};
int main()
{
    int n,x,ok=0,cnt=0;
    scanf("%d",&n);
    for(int j=1;j<=n;j++)
    {
        scanf("%d",&x);
        for(int i=2;i<=x/i;i++)
            {
                 if(x%i==0)num[i]++;
                 while(x%i==0)
                 {
                     x/=i;
                 }
            }
             if(x>1)
                num[x]++;
    }
    for(int i=1;i<=N;i++)
    {
        if(num[i]>1)ok=1;
        cnt=max(cnt,num[i]);
    }
    if(ok==0)printf("pairwise coprime\n");
    else if(cnt<n) printf("setwise coprime\n");
    else
                printf("not coprime\n");
    return 0;
}


Measured memory_bytes: 7544
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int X;
      cin >> X;
      int ure=0;
      int ure500, ure100, ure50, ure10, ure5, ure1;

      if(X>=500)  {
        ure500=X/500;
        ure=1000*ure500;
        X=X-(500*ure500);
      }
    
      if(X>=5){
        ure5=X/5;
        ure=ure+(5*ure5);
      }

   cout << ure <<endl;



    return 0;
    }

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

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

    int cnt = 0;
    irep(i, n) {
        int j;
        cin >> j;
        if(j != (i+1)) { cnt++; }
    }

    if(cnt > 2) { 
        cout << "NO";
    } else {
        cout << "YES";
    }
    return 0;
}   
/** atcoder **/


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int l = sc.nextInt();
    int[] taste = new int[n];
    int sum = 0;
    int abs_min = 512;
    int abs_min_index = 512;

    for(int i=0; i<n; ++i) {
      taste[i] = l + (i+1) - 1;
      sum += taste[i];
      if( Math.abs(taste[i]) < abs_min ) {
        abs_min = Math.abs(taste[i]);
        abs_min_index = i;
      }
    }

    sum -= taste[abs_min_index];
    System.out.println(sum);
  }
}

Measured memory_bytes: 21844
#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() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll num = N/(A+B);
  ll d = N%(A+B);
  ll ans = A*num + min(d, A);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case, unused_variables)]

use std::io::{Read, stdin};

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    let mut buf = String::new();
    stdin.read_to_string(&mut buf).unwrap();
    let mut buf = buf.split_whitespace();

    let W: i32 = buf.next().unwrap().parse().unwrap();
    let H: i32 = buf.next().unwrap().parse().unwrap();
    let x: i32 = buf.next().unwrap().parse().unwrap();
    let y: i32 = buf.next().unwrap().parse().unwrap();
    let r: i32 = buf.next().unwrap().parse().unwrap();

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


Measured memory_bytes: 5020
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	ll ret=0;
	REP(i,n) {
		ll x;
		cin>>x;
		ret+=2*min(x,abs(x-k));
	}
	cout<<ret<<endl;
}


Measured memory_bytes: 256
#include <iostream>

int main(){

    int ans=0;

    int n;
    std::cin>>n;

    int V[20]={0};
    int C[20]={0};

    for(int i=0;i<n;i++){
        std::cin>>V[i];
    }
    for(int i=0;i<n;i++){
        std::cin>>C[i];
    }
    
    for(int i=0;i<n;i++){
        if(V[i]-C[i]>0){
            ans+=V[i]-C[i];
        }
    }

    std::cout << ans<< std::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);
        long n = Long.parseLong(sc.next());
        if(n < 1200) System.out.println("ABC");
        else if(n < 2800) System.out.println("ARC");
        else System.out.println("AGC");
        
    }
    
}

Measured memory_bytes: 35788
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug { 
    ($($a: expr),*) => { 
        println!(concat!($(stringify!($a)," = {:?}, "),*), $($a),*);
    } 
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

fn solve() {
    let (n, q) = get!(usize, usize);
    let s = get!(String);
    let mut vec = vec![0; n+1];
    let mut aflag = false;
    for (i, c) in s.chars().enumerate() {
        vec[i+1] = if c == 'C' && aflag {
            vec[i] + 1
        } else {
            vec[i]
        };
        aflag = c == 'A';
    }
    for i in 0..q {
        let (l, r) = get!(usize, usize);
        println!("{}", vec[r]-vec[l]);
    }
}


Measured memory_bytes: 9084
from collections import deque
n,m = map(int,input().split())
ad_ls = [[] for i in range(n+1)]
ls = [0] * (n+1)
done_ls = [0] * (n+1)
for i in range(m):
    a,b = map(int,input().split())
    ad_ls[a].append(b)
    ad_ls[b].append(a)
q = deque()
for node in ad_ls[1]:
    q.append([1,node])
done_ls[1] = 1
while q:
    start, goal = q.popleft()
    if done_ls[goal] != 1:
        ls[goal] = start
        done_ls[goal] = 1
        for node in ad_ls[goal]:
            q.append([goal, node])

res = 1
for node in range(2,n+1):
    if ls[node] == 0:
        res = 0
if res:
    print('Yes')
    for node in range(2,n+1):
        print(ls[node])
else:
    print('No')

Measured memory_bytes: 57808
# https://atcoder.jp/contests/abc143/tasks/abc143_b
n=int(input())
item_list=list(map(int,input().split()))
c=int((n*(n-1))/2)
Answer=0
for i  in range(c):
    for k in range(i+1,n,1):
        Answer+=item_list[i]*item_list[k]

    
print(Answer)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int n;
string s[50];
int calc(int a, int b, bool m) {int res = m;for (int i = b; i < n; i++) {if (s[i].size() <= a)break;if ('0' <= s[i][a] && s[i][a] <= '9') {if (m)res *= s[i][a] - '0';else res += s[i][a] - '0';}if (s[i][a] == '*') {if (m)res *= calc(a + 1, i + 1, 1);else res += calc(a + 1, i + 1, 1);}if (s[i][a] == '+') {if (m)res *= calc(a + 1, i + 1, 0);else res += calc(a + 1, i + 1, 0);}}return res;}
int main() {
while (scanf("%d", &n), n) {rep(i, n)cin >> s[i];printf("%d\n", calc(0, 0, 0));}}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int N;
    cin >> N;
    vector<llint> num(5, 0);
    REP(i, N){
        string s;
        cin >> s;
        switch(s[0]){
        case 'M':
            num[0]++;
            break;
        case 'A':
            num[1]++;
            break;
        case 'R':
            num[2]++;
            break;
        case 'C':
            num[3]++;
            break;
        case 'H':
            num[4]++;
            break;
        }
    }
    llint ans = 0;
    REP(i, 3)FOR(j, i+1, 5)FOR(k, j+1, 5){
        ans += num[i]*num[j]*num[k];
    }

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

Measured memory_bytes: 256
// Math = ♥️

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define ordered_set                            \
    tree<ll, null_type, less<ll>, rb_tree_tag, \
         tree_order_statistics_node_update>

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

    ll n;
    cin >> n;

    vi arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }

    ll dp[n][n];
    for (int i = 0; i < n; i++) {
        dp[i][i] = 0;
    }

    for (int gap = 1; gap < n; gap++) {
        for (int i = 0; i + gap < n; i++) {
            ll sum = 0;
            for (int j = i; j <= i + gap; j++) {
                sum += arr[j];
            }

            ll ans = LLONG_MAX;
            for (int j = i; j < i + gap; j++) {
                ans = min(ans, dp[i][j] + dp[j + 1][i + gap] + sum);
            }

            dp[i][i + gap] = ans;
        }
    }

    cout << dp[0][n - 1] << "\n";
}


Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int max = Integer.MIN_VALUE;
        int[] anss = new int[]{
                a + b,
                a - b,
                a * b
        };

        for (int ans : anss) {
            max = Math.max(max, ans);
        }

        System.out.println(max);
    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    ll n; cin>>n;
    vector<ll> a(n+1);
    rep(i,n+1) cin>>a[i]; // a: num of leaf
    if(n==0){
        if(a[0]==1) cout<<1<<endl;
        else cout << -1 << endl;
        return 0;
    }
    vector<ll> branch(n+1, 1); // branch: remain
    branch[0] -= a[0];
    branch[1] = branch[0];
    ll res=n+1;
    ll j=0;
    rep(i, n+1){
        if(a[i]==0) continue;
        ll cnt = a[i];
        if(i == n) cnt--;
        while(j<i){
            if(cnt >= branch[j]){
                cnt -= branch[j];
                branch[j+1] += branch[j];
                //branch[i] += branch[j];
                res += branch[j] * (i - j);
                branch[j] = 0;
                j++;
                branch[j] -= a[j];
                if(j+1 <= n) branch[j+1] = branch[j];
                if(cnt == 0) break;
            }else{
                branch[j+1] += cnt;
                //branch[i] += cnt;
                branch[j] -= cnt;
                res += cnt * (i - j);
                cnt = 0;
                break;
            }
        }
        //branch[i] -= a[i];
        if(cnt > 0){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4844
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>

using namespace std;
int ans = 0;
void _dfs(unsigned long& n,unsigned long now, int x3, int x5, int x7){
	if(now <= n){
		ans += x3 > 0 and x5 > 0 and x7 > 0;
		_dfs(n, now*10+3, x3+1, x5,x7);
		_dfs(n, now*10+5, x3, x5+1, x7);
		_dfs(n, now*10+7, x3, x5, x7+1);
	}
}

int main(){
	unsigned long n;
	scanf("%d", &n);
	_dfs(n, 0, 0, 0, 0);
	printf("%d",ans);
	return 0;
	

	
	
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  int n;
  std::cin >> n;
  long long result = 0;
  long long current_sum = 0;
  for (int i = 0; i < n; ++i) {
    int current;
    std::cin >> current;
    current_sum += current;
    if (current == 0) {
      result += current_sum / 2;
      current_sum = 0;
    }
  }
  result += current_sum / 2;
  std::cout << result << std::endl;
  return 0;
}


Measured memory_bytes: 256
import Data.List(transpose)
import Control.Monad(forM_)

main = do
  ns <- lines <$> getContents
  forM_ (solve (tail ns)) putStrLn

solve :: [String] -> [String]
solve ls = remove $ transpose $ remove $ transpose ls

remove :: [String] -> [String]
remove ls = filter (any (=='#')) ls

Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;

int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  cout << fixed << setprecision(15);
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int ans;
  if (k <= a + b) ans = min(k, a);
  else ans = a - (k - a - b);
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 3612
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

typedef struct{
    int a;
    long b;
}data;

//昇順
int asc(const void* a, const void* b){
    data p=*(data*)a;
    data q=*(data*)b;
    if((p.a-q.a)>0) return 1;
    else if((p.a-q.a)<0) return -1;
    else return 0;
}

int main(void){
    int N;
    long K;
    scanf("%d%ld",&N,&K);

    //A[0]~A[N-1]に格納する
    data* A;
    NEW(A,N);
    for(int i=0;i<N;i++){
        scanf("%d %ld",&A[i].a, &A[i].b);
    }
    qsort(A,N,sizeof(data),asc);

    long sum=0;
    for(int i=0;i<N;i++){
        sum+=A[i].b;
        if(sum>=K){
            printf("%d\n",A[i].a);
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3324
#include<iostream>
#include<string>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	string S;
	cin >> N >> S;
	int ans = 0;
	for (int i = 0; i < N - 2; i++){
		if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let h: usize = scan(tokens);
    let a: usize = scan(tokens);
    println!("{}", (h + a - 1) / a);
}


Measured memory_bytes: 4352
program main
  implicit none
  
  integer :: n, a(100) = 0,i,j,c=0,chk
  read(*,*)n
  do i = 1, n
    read(*,*)a(i)
    chk = 0
    do j = 1, i-1
      if (a(j) == a(i)) then
        chk = 1
      end if
    end do
    if (chk == 0) then
      c = c + 1
    end if
  end do
  write(*,'(i0)')c
end program main
    

Measured memory_bytes: 256
# coding: utf-8
N=int(input())
K=int(input())

lN=len(str(N))

dp=[[[0 for i in range(K+1)] for j in range(2)] for k in range(lN+1)]

dp[0][0][0]=1

for i in range(lN):
    num=int(str(N)[i])
    for j in range(K+1):
        if num==0:
            dp[i+1][0][j] = dp[i][0][j]
        else:
            if j==0:
                dp[i+1][0][j] = 0
            else:
                dp[i+1][0][j] = dp[i][0][j-1]
        
        if j==0:
            dp[i+1][1][j] = 1
        else:
            if num==0:
                dp[i+1][1][j] = dp[i][1][j-1]*9 + dp[i][1][j]*1
            else:
                dp[i+1][1][j] = dp[i][1][j-1]*9 + dp[i][1][j]*1 + dp[i][0][j-1]*(num-1) + dp[i][0][j]*1

print(dp[lN][1][K] + dp[lN][0][K])


Measured memory_bytes: 3064
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        String s = scanner.next();
        System.out.println(s.contains("N") == s.contains("S") && s.contains("W") == s.contains("E") ? "Yes" : "No");
    }
}

Measured memory_bytes: 22740
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.nextLong();
            var b = cin.nextDouble();
            var db = Convert.ToDecimal(b);
            var ans = a * db;
            ans = Decimal.Floor(ans);
            Console.WriteLine(ans);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

string inttos(int num)
{
    return to_string(num);
}

int stoint(string sss)
{
    return stoi(sss);
}

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));	
	int T;
	T=1;
	while(T--)
	{
		int k,n;
		cin >> k >> n;
		int c=0;
		rep(i,1,n)
		{
			int x;
			cin >> x;
			c += x;
		}
		if(c>k)
			cout << "-1" << endl;
		else
			cout << k-c << endl;
	}
}


Measured memory_bytes: 3660
import java.util.*;

public class Main {
	static int M2;
	public static void nextPrime(int M) {
	    while(!isPrime(M++));
	    M2 = M-1;
	}
	public static boolean isPrime(int n) {
	    for(int i = 2; i < n/2; i++) {
	        if(n % i == 0) return false;
	    }
	    return true;
	}
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		nextPrime(scn.nextInt());
		System.out.println(M2);
		scn.close();
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string str;cin >> str;
    if(str.size()>=4){
    if(str.at(0)=='Y'&&str.at(1)=='A'&&str.at(2)=='K'&&str.at(3)=='I'){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string s, t;
	cin>>s;
	cin>>t;
 
	int n=s.size();
	int res=0;
	for(int i=0;i<n;i++) {
		if(s[i]!=t[i])
			res++;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
 
 
 
string str;
string tmp;
 
// bool check() {
// 	int k = str.find('K');
// 	int i = str.find('I');
// 	int h = str.find('H');
// 	int b = str.find('B');
// 	int r = str.find('R');
// 	bool a1 = ((k == 1 && str[k - 1] == 'A') || k == 0);
// 	bool a2 = (k == i - 1 && i == h - 1);
// 	bool a3 = ((h == b - 2 && str[h + 1] == 'A' && str[b - 1] == 'A') || (h == b - 1));
// 	bool a4 = ((b == r - 2 && str[b + 1] == 'A' && str[r - 1] == 'A') || (b == r - 1));
// 	bool a5 = ((r == str.length() - 1) || (r == str.length() - 2 && str[str.length() - 1] == 'A'));
// 	return a1 & a2 & a3 & a4 & a5;
// }
 
bool check() {
	string t = "AKIHABARA";
	int p = 0;
	for (int i = 0; i < t.length(); i++) {
		if (str[p] == t[i]) {
			p++;
		}
		if (p == str.length())return true;
	}
	return false;
}
 
void solve() {
	cin >> str;
	for (int i = 0; i < str.length(); i++) {
		if (str[i] != 'A') {
			tmp += str[i];
		}
	}
	if (tmp != "KIHBR") {
		puts("NO");
		return;
	}
	if (check())puts("YES");
	else puts("NO");
}
 
 
 
 
// void solve() {
// 	while (cin >> str) {
// 		int a[3] = {0};
// 		for (int i = 0; i < str.length(); i++) {
// 			a[str[i] - 'a']++;
// 		}
// 		sort(a, a + 3);
// 		if (a[0] == a[2] || (a[2] == a[1] && a[0] == a[1] - 1) || (a[0] == a[1] && a[2] == a[1] + 1)) {
// 			puts("YES");
// 		} else {
// 			puts("NO");
// 		}
// 	}
// }
 
int main() {
	solve();
}

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

typedef long long ll;
typedef pair<ll, int> P;
typedef pair<pair<int, int>, int> PP;

const ll INF = 1e15;
const int MAX = 510000;
const ll MOD = 1000000007;

int N;
ll K;
ll A[200010];
ll F[200010];
bool isOK(ll ma) {
  ll cnt = 0;
  for (int i = 0; i < N; i++) {
    if(A[i] * F[i] <= ma) continue;
    cnt += A[i] - max(0LL , ma / F[i]);
  }
  return cnt <= K;
}
int main(void) {
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> F[i];
  sort(A, A + N);sort(F, F + N);reverse(F, F + N);
  ll left = -1, right = INF;
  while (right - left > 1) {
    ll md = (right + left) / 2;
    if (isOK(md)) right = md;
    else left = md;
  }
  cout << right << endl;
}


Measured memory_bytes: 3328
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#define db double
#define LL long long
#define inf 0x3f3f3f3f
using namespace std;
int gi()
{
    int res=0,s=1; char ch;
    for(ch=getchar();(ch<'0'||ch>'9')&&ch!='-';ch=getchar());
    if(ch=='-') s=-1,ch=getchar();
    for(;ch>='0'&&ch<='9';ch=getchar()) res=res*10+ch-48;
    return res*s;
}
int n;
char mat[605][605];
bool ok[605][605][305];
int main()
{
    n=gi();
    for(int i=1;i<=n;++i)
	scanf("%s",mat[i]+1);
    for(int i=n+1;i<=n+n;++i) 
	for(int j=1;j<=n;++j)
	    mat[i][j]=mat[i-n][j];
    for(int i=1;i<=n;++i)
	for(int j=n+1;j<=n+n;++j)
	    mat[i][j]=mat[i][j-n];
    for(int i=n+1;i<=n+n;++i)
	for(int j=n+1;j<=n+n;++j)
	    mat[i][j]=mat[i-n][j-n];
    for(int i=1;i<=2*n;++i) {
	for(int j=1;j<=2*n;++j) {
	    for(int k=1;k<=n;++k) 
		ok[i][j][k]=false;
	    for(int k=1;k<=n && i+k-1<=2*n && j+k-1<=2*n && mat[i+k-1][j]==mat[i][j+k-1];++k)
		ok[i][j][k]=true;
	}
    }
    int ans=0;
    for(int i=1;i<=n;++i) {
	for(int j=1;j<=n;++j) {
	    int flag=1;
	    for(int k=1;k<=n && flag;++k)
		if(!ok[i+k-1][j+k-1][n-k+1]) flag=0;
	    ans+=flag;
	}
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 108928
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define LL long long
#define LD long double
#define VI vector<int>
#define VPII vector<PII>
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define pb pop_back
#define FOR(a,s,d) for (int a = (s); a <= (int)(d); ++a)
#define FORD(a,s,d) for (int a = (s); a >= (int)(d); --a)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(x) x.begin(), x.end()
#define siz(x) ((int)x.size())
#define Sim template <class s
Sim, class d> ostream & operator<<(ostream &os, pair<s,d> x){return os << "<" << x.f << ", " <<
  x.s << "> ";}
Sim> auto operator<<(ostream &os, s x) -> typename enable_if<!is_same<s,string>::value,
  decltype(x.begin(), os)>::type
{ int o = 0; os << "{"; for (auto c : x) {if(o++) os << ", "; os << c;}return os << "} ";}
void dor() {cerr << endl;}
Sim, class ...t> void dor(s x, t...y) {cerr << x << " "; dor(y...);}
#ifdef DEB
#define debug(c...) dor(__FUNCTION__, ":", __LINE__, ": ", c)
#else
#define debug(...)
#endif
const int M = 30000;

set<int> secik;
vector<int> a3, a2, a6, r;
int n;

void push(vector<int>& x, int il)
{
  n -= il;
  while (il > 0)
  {
    r.PB(x[siz(x) - 1]);
    x.pb();
    il--;
  }
}

int main()
{
  //ios_base::sync_with_stdio(0);
  //cin.tie(0);
  scanf("%d", &n);
  if (n == 3)
  {
    printf("2 5 63\n");
    return 0;
  }
  for (int i = 2; i <= M; i++)
  {
    if (i % 2 == 1)
    {
      if (i % 3 == 0)
      {
        a3.PB(i);
      }
    }
    else
    {
      if (i % 3 == 0)
      {
        a6.PB(i);
      }
      else
      {
        a2.PB(i);
      }
    }
  }
  reverse(ALL(a2));
  reverse(ALL(a3));
  reverse(ALL(a6));
  
  //debug(siz(a2), siz(a3), siz(a6));
  push(a3, 2);
  push(a2, 2);
  while (n > 0)
  {
    if (n > 1 && !a3.empty())
    {
      push(a3, 2);
      continue;
    }
    if (n > 1 && !a2.empty())
    {
      push(a2, 2);
      continue;
    }
    push(a6, 1);
  }
  
  for (auto x : r)
  {
    printf("%d ", x);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))
q=int(input())
m=list(map(int,input().split()))
l=[]
for i in range(2**n):
    sub=0
    for j in range(n):
        if (i>>j)&1==1:
            sub+=a[j]
    l.append(sub)
for i in m:
    if i in l:
        print("yes")
    else:
        print("no")


Measured memory_bytes: 43084
MAX=55555

from collections import defaultdict
f = defaultdict(int)

ans=[]
N=int(input())

p=2
while p<=MAX:
    m=2*p
    while m<=MAX:
        f[m]=1
        m+=p
    p+=1
    while f[p]!=0:
        p+=1
        if p>MAX:
            break
    if p%5==1:
        ans.append(p)
        if len(ans)==N:
            break
print(' '.join([str(a) for a in ans]))





Measured memory_bytes: 43756
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  long long int x, a, b;
  cin>>x>>a>>b;
  if(a-b>=0){
    cout<<"delicious"<<endl;
  }else if(a-b+x>=0){
    cout<<"safe"<<endl;
  }else{
    cout<<"dangerous"<<endl;
  }
}

Measured memory_bytes: 256
// I make this just for fun because i'm done
// Aimi Haraguni >> Konomi Suzuki >> Yui >>  Ikimono Gakari >> Garnidelia >> Kalafina >> Eir Aoi.   .. dude? 
// problems that involves any kind of persistent data structures are the best of the best, are not them?
 
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
 
#define pb push_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define all(v) (v).begin(), (v).end()
#define fill(x, v) memset(x, v, sizeof(x))
#define FER(i,a,b) for(int i=int(a); i< int(b); ++i)
#define IFR(i,a,b) for(int i=int(a); i>=int(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
 
// #define N 21000000
// #define M 19
// #define mod3 9
 
#define mod1  998244353
#define mod 48
#define mod2 1000000009
#define mody 998244353
#define bas 987625403
#define sqr(x) (x)*(x)  
#define INF 3000000000000000000
#define N1 1000
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii > tri;
typedef vector<ll> vi;
typedef vector<vi> vv;
typedef vector<ii> vii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> S_t;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}
 
inline ll add(ll a, ll b) { return a+b < mod? a+b : a+b-mod;}
inline ll rem(ll a, ll b) { return a >= b? a - b: a- b + mod;}
inline ll mul(ll a, ll b) { return (long long) a*b%mod;}
inline void Mul(ll &a, ll b) { a = (long long) a*b%mod;}
inline ll bp(ll a, ll p){
    ll ret;
    for(ret = 1; p; p>>=1, Mul(a, a)) (p & 1) && (Mul(ret, a), 1);
    return ret;
}
 
 
static inline void read(ll &result) {
    bool minus = false;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' and ch <= '9') break;
        ch = getchar();
    }
    (ch == '-')? minus = true: result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' or ch > '9') break;
        result = (result<<3)+ (result<<1) + (ch - '0');
    }
    if(minus) result=-result;
}


int main(){
	ll d, t, s; read(d), read(t), read(s);
	(t * s >= d)? cout<<"Yes\n": cout<<"No\n";
	return 0;
}

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

pair<long, long> ext(long x, long y) {
    long r0 = x;
    long r1 = y;
    long a0 = 1;
    long a1 = 0;
    long b0 = 0;
    long b1 = 1;
    while (r1 > 0) {
        long q1 = r0 / r1;
        long r2 = r0 % r1;
        long a2 = a0 - q1 * a1;
        long b2 = b0 - q1 * b1;
        r0 = r1;
        r1 = r2;
        a0 = a1;
        a1 = a2;
        b0 = b1;
        b1 = b2;
    }
    return make_pair(a0, b0);
}

int main() {
    int a, b;
    cin >> a >> b;
    auto c = ext(a, b);
    cout << c.first << " " << c.second << endl;
}

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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+(key%(M-1)); }

int find(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0)return 1;
    else if(strlen(H[h])==0)return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0;;i++){
     h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0)return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}
 



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

int main() {
	int n, d, x, a[101];
	int sum = 0;
	for (int i = 0;i < 101;i++)
		a[i] = 0;
	cin >> n;
	cin >> d >> x;
	for (int i = 0;i < n;i++)
		cin >> a[i];
	for (int i = 0;i < n;i++)
		if (d%a[i] == 0)
			sum += d / a[i];
		else
		sum += (d / a[i]) + 1;
	cout << sum + x;


	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int sum = a + b;
		int mul = a * b;
		int min = a - b;
		if(sum > mul){
			if(sum > min){
				System.out.println(sum);
			}else{
				System.out.println(min);
			}
		}else{
			if(mul > min){
				System.out.println(mul);
			}else{
				System.out.println(min);
			}
		}
	}
}

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

using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  

const long double PI = 3.14159265358;

int32_t main()
{
    fastio;
    cout << fixed << setprecision(10);
    long double a, b, x, ans;
    cin >> a >> b >> x;
    long double num = 2*(a*a*b - x), den = a*a*a;
    ans = num/den;
    ans = atan(ans);
    if(a*a*b/2.0 > x) ans = PI/2 - atan((2*x)/(a*b*b));
    ans = ans*(180.0/PI);
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
num_map = [0] * ((n + 2 - 1) // 2)
for i in range(n):
    num_map[a[i] // 2] += 1

res = 1
if n % 2 == 1:
    if num_map[0] != 1:
        print(0)
    else:
        for i in range(1, (n + 2 - 1) // 2):
            if num_map[i] != 2:
                print(0)
                break
            else:
                res = res * 2 % mod
        else:
            print(res)
else:
    for i in range((n + 2 - 1) // 2):
        if num_map[i] != 2:
            print(0)
            break
        else:
            res = res * 2 % mod
    else:
        print(res)


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

void swap(char *x, char *y){
  char t[3];
  strcpy(t, x);
  strcpy(x, y);
  strcpy(y, t);
}

int main(){
  int n, i, j, f, min;
  char in[37][3], bs[37][3];
  scanf("%d", &n);
  for(i = 0; i < n; ++i) scanf("%s", in[i]);

  for(i = 0; i < n; ++i) strcpy(bs[i], in[i]);

  for(i = 0; i < n; ++i)
    for(j = n - 1; j > i; --j)
      if(bs[j][1] < bs[j - 1][1])
	swap(bs[j], bs[j - 1]);

  for(i = 0; i < n; ++i) printf(i != 0 ? " %s" : "%s", bs[i]);
  printf("\nStable\n");

  for(i = 0; i < n; ++i){
    min = i;
    for(j = i + 1; j < n; ++j)
      if(in[j][1] < in[min][1])
	min = j;
    if(min != i)
      swap(in[min], in[i]);
  }
  f = 0;
  for(i = 0; i < n; ++i){
    printf(i != 0 ? " %s" : "%s", in[i]);
    if(in[i][0] != bs[i][0]) f = 1;
  }
  puts("");
  puts(f ? "Not stable" : "Stable");
  return 0;
}



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

int X[10][10];

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

    int n, d;
    cin >> n >> d;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            cin >> X[i][j];
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int hoge = 0;
            for (int k = 0; k < d; k++) {
                hoge += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            }
            int x = int(sqrt(hoge));
            if (x * x == hoge) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}


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

int main() {
    int n, m;
    map<string, int> c;

    // blue
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (c.count(s) == 0) {
            c[s] = 1;
        } else {
            c[s] += 1;
        }
    }

    // red
    cin >> m;
    for (int i = 0; i < m; i++) {
        string s;
        cin >> s;
        if (c.count(s) == 0) {
            c[s] = -1;
        } else {
            c[s] -= 1;
        }
    }

    // count
    // int ans = 0;
    // for (const auto& [k, v] : c) {
    //     ans = max(ans, v);
    // }

    int ans = 0;
    for (auto itr = c.begin(); itr != c.end(); ++itr) {
        ans = max(ans, itr->second);
    }

    ans = max(ans, 0);
    cout << ans << endl;
}

Measured memory_bytes: 256