akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;

using namespace std;

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

    int n;
    cin >> n;

    vector<pair<int, int>> left, right; // (min_h, h)
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;

        int h = 0, min_h = 0;
        for (char c : s) {
            if (c == '(') h++;
            else h--;

            min_h = min(min_h, h);
        }
        if (h >= 0) {
            left.emplace_back(min_h, h);
        } else {
            right.emplace_back(min_h - h, -h);
        }
    }
    sort(rbegin(left), rend(left));
    sort(rbegin(right), rend(right));

    int left_h = 0, right_h = 0;

    for (auto p : left) {
        if (left_h + p.first < 0) {
            cout << "No" << endl;
            return 0;
        }
        left_h += p.second;
    }
    for (auto p : right) {
        if (right_h + p.first < 0) {
            cout << "No" << endl;
            return 0;
        }
        right_h += p.second;
    }

    if (left_h == right_h) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 10800
use std::cmp::Ordering;
use std::io::{stdin, BufRead, BufReader};

struct Vector {
    x: f32,
    y: f32,
}

fn main() {
    let input = BufReader::new(stdin());
    for line in input.lines() {
        let values: Vec<f32> = line.unwrap()
            .split_whitespace()
            .filter_map(|x| x.parse::<f32>().ok())
            .collect();
        let (tri_vectors, target) = get_vectors(values);
        if is_inside(tri_vectors, target) {
            println!("YES");
        } else {
            println!("NO");
        }
    }
}

fn is_inside(tri_vectors: Vec<Vector>, target: Vector) -> bool {
    let idx_pair = [(1, 0), (2, 1), (0, 2)];
    let mut cross_product = vec![];
    for pair in &idx_pair {
        let v1 = sub_vector(&tri_vectors[pair.0], &tri_vectors[pair.1]);
        let v2 = sub_vector(&target, &tri_vectors[pair.0]);
        let c = v1.x * v2.y - v1.y * v2.x;
        cross_product.push(c);
    }
    let plus: Vec<&f32> = cross_product.iter().filter(|x| x > &&0.0).collect();
    let minus: Vec<&f32> = cross_product.iter().filter(|x| x < &&0.0).collect();
    return plus.len() == 3 || minus.len() == 3;
}

fn sub_vector(v1: &Vector, v2: &Vector) -> Vector {
    return Vector {
        x: v1.x - v2.x,
        y: v1.y - v2.y,
    };
}

fn get_vectors(points: Vec<f32>) -> (Vec<Vector>, Vector) {
    let mut vectors = Vec::with_capacity(3);
    let mut i = 0;
    while i < points.len() - 2 {
        vectors.push(Vector {
            x: points[i],
            y: points[i + 1],
        });
        i += 2;
    }
    vectors.sort_by(|a, b| match a.x.partial_cmp(&b.x).unwrap() {
        Ordering::Equal => a.y.partial_cmp(&b.y).unwrap(),
        other => other,
    });
    return (
        vectors,
        Vector {
            x: points[i],
            y: points[i + 1],
        },
    );
}



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

const int N = 8, Free = -1, NotFree = 1;
int row[N], col[N], dpos[2*N-1], dneg[2*N-1];
bool X[N][N];

void init(){
    for (int i = 0; i < N; i++) row[i] = col[i] = Free;
    for (int i = 0; i < 2*N - 1; i++) dpos[i] = dneg[i] = Free;
}
void PrintBoard(){
    for (int i = 0; i < N; i++){
        for (int j = 0; j < N; j++){
            if (X[i][j]){
                if (row[i] != j) return;
            }
        }
    }
    for (int i = 0; i < N; i++){
        for (int j = 0; j < N; j++){
            cout << ((row[i] == j) ? "Q" : ".");
        }
        cout << endl;
    }
}
void recursive(int i){
    if (i == N) {
        PrintBoard(); return;
    }
    for (int j = 0; j < N; j++)
    {
        if (NotFree == col[j] ||
            NotFree == dpos[i+j]||
            NotFree == dneg[i-j+N-1])continue;
        row[i] = j;col[j] = dpos[i+j] = dneg[i-j+N-1] = NotFree;
        recursive(i+1);
        row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=Free;
    }
}

int main(){
    init();
    for(int i=0;i<N;i++)
        for(int j=0;j<N;j++)X[i][j] = false;
    int k; cin >> k;
    for (int i = 0; i < k; i++)
    {
        int r, c; cin >> r >> c;
        X[r][c] = true;
    }
    recursive(0);
}


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

struct human{int num,sum;};

const int INFTY =2147483647;
struct human L[200000],R[200000];

void merge(struct human A[],int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    for(int i=0;i<n1;i++) L[i]=A[left+i];
    for(int i=0;i<n2;i++) R[i]=A[mid+i];
    L[n1].sum =R[n2].sum=INFTY;
    int i=0,j=0;
    for(int p=left;p<right;p++){
        if(L[i].sum<=R[j].sum) A[p]=L[i++];
        else A[p]=R[j++];
    }
}

void sort(struct human A[],int left,int right){
    if(left+1<right){
        int mid=(left + right)/2;
        sort(A,left,mid);
        sort(A,mid,right);
        merge(A,left,mid,right);
    }
}

//sort(A,0,n)で使用

int main(){
    struct human A[100005];
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        A[i].num=i+1;
        cin>>A[i].sum;
    }
    sort(A,0,n);
    for(int i=0;i<n;i++){
        if(i==0)cout<<A[i].num;
        else cout<<" "<<A[i].num;
    }
    cout<<endl;
    return 0;
}

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

def main():
    N = int(readline())
    
    ans = ''
    while N:
        N -= 1
        ans += chr((N % 26) + 97)
        N //= 26

    print(ans[::-1])

if __name__ == "__main__":
    main()


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    constexpr int mod = 1e9 + 7;
    int n, m;
    cin >> n >> m;
    vector<string> s(n);
    for (string& it : s)
        cin >> it;
    vector<vector<int>> dp(n, vector<int>(m));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (s[i][j] == '#')
                continue;
            if (i)
                dp[i][j] += dp[i - 1][j];
            if (j)
                dp[i][j] += dp[i][j - 1];
            if (dp[i][j] >= mod)
                dp[i][j] -= mod;
        }
    }
    cout << dp[n - 1][m - 1];
    return 0;
} 

Measured memory_bytes: 8228
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n, ans = 0; cin >> n;
	rep(i, 1, n)
	{
		int a; cin >> a;
		ans += a - 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int tmp = 0;
    for(int i=1; i<=K; i++) {
        tmp *= 10;
        tmp += 7;
        tmp %= K;
        if(tmp == 0) {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  int ssize = s.size();
  int x = 0;
  while(x <= ssize-1){
    cout << s.at(x);
    x += 2;
  }
  cout << endl;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    int dp[3010][3010];
    // dp[i][j] : sのi文字目，tのj文字目のLCSの長さ
    // 0文字目->空文字列
    REP(i, 3010) REP(j, 3010) dp[i][j] = 0;
    for (int i = 1; i <= s.size(); i++) {
        for (int j = 1; j <= t.size(); j++) {
            if(s[i - 1] == t[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            } else {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }

    string ans = "";
    int x = s.size();
    int y = t.size();
    while(x > 0 && y > 0) {
        if (dp[x][y] == dp[x - 1][y]) {
            x--;
        } else if (dp[x][y] == dp[x][y - 1]) {
            y--;
        } else {
            x--;
            y--;
            ans.push_back(s[x]);
        }
    }

    reverse(ALL(ans));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35712
n,k = map(int,input().split())
ans = []
for i in range(1,n+1):
    if i < k:
        tmp = k/i
        counter = 0
        for _ in range(1000000):
            tmp = tmp/2
            if tmp <=1:
                break
            else:
                counter +=1
        ans.append(1/n*(1/2)**(counter+1))
    else:
        ans.append(1/n)
print(sum(ans))

Measured memory_bytes: 6296
#include <stdio.h>
#include <string.h>
#define PRI(x) printf(x); puts("");
#define PRIF(x,v1,v2) printf(x,v1,v2); puts("");
#define FOR(x,n) for(int i=(x);i<(n);i++)
typedef struct {
    char status[3];
    int wac;
}hoge;

int main(void){
    // Your code here!
    int var,test,ibuf;
    char sbuf[3];
    scanf("%d %d",&var,&test);
    hoge arr[var+1];
    FOR(0,var+1){
        arr[i].wac=0;
    }
    int wac=0;
    int acc=0;
    FOR(0,test){
        scanf("%d %s",&ibuf,sbuf);
        if(strcmp("AC",arr[ibuf].status) != 0){
            if(strcmp("AC",sbuf)==0){
                ++acc;
                strcpy(arr[ibuf].status,"AC");
            }else{
                ++arr[ibuf].wac;
            }
        }
    }
    FOR(0,var+1){
        if(strcmp("AC",arr[i].status) == 0){
            wac += arr[i].wac;
        }
    }
    PRIF("%d %d",acc,wac);
}


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

vector<vector<int>> g(100010);
vector<int> check(100010, -1);
bool dfs(int key){
    bool flag=false;
    for(int i=0; i<g[key].size(); ++i){
        if(check[g[key][i]]<0){
            check[g[key][i]]=1-check[key];
            flag |= dfs(g[key][i]);
        }
        else flag |= check[key]==check[g[key][i]];
    }
    return flag;
}

int main() {
	int N, M; cin >> N >> M;
	for(int i=0; i<M; ++i){
	    int u, v;
	    cin >> u >> v;
	    g[u].push_back(v);
	    g[v].push_back(u);
	}
	long solo=0, matsu=0, other=0;
	for(int i=1; i<=N; ++i){
	    if(check[i]<0){
	        if(g[i].size()<1) ++solo;
	        else{
	            check[i]=0;
	            if(dfs(i)) ++other;
	            else ++matsu;
	        }
	    }
	}
	cout << solo*(2*N-solo)+matsu*matsu+(matsu+other)*(matsu+other) << endl;
	return 0;
}


Measured memory_bytes: 9984
#include<stdio.h>
int main(){
int e,n,m,a[1001],b[1001],i,c=0,max=0,d;
scanf("%d %d\n",&n,&m);
for(i=0;i<m;i++){
scanf("%d %d\n",&a[i],&b[i]);
if(a[i]>=b[i]){
c++;
}
}
if(c>=m-1){
printf("0\n");
}
else{
for(i=0;i<m;i++){
e=b[i]-a[i];
if(e>c){
c=e;
d=i;
}
}
for(i=0;i<m;i++){
if(i!=d && a[i]<b[i]){
max=max+b[i]-n;
}
}
}
printf("%d\n",max);
return 0;
}


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

int main(){
    int a,b,ret;
    cin >> a >> b;
    if(a > 12){
        ret = b;
    }else if(a > 5){
        ret = b / 2;
    }else{
        ret = 0;
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll M1, D1, M2, D2;
	cin >> M1 >> D1 >> M2 >> D2;
	if (M1 != M2) {
		cout << 1 << "\n";
	}
	else cout << 0 << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <map>
using namespace std;
const int  N=1e5+9;
map<int,int>p;
int  n,a[N];
int main()
{
    while(~scanf("%d",&n))
    {
p.clear();
int maxx=-1;
for(int i=1;i<=n;i++){
    scanf("%d",&a[i]);
    p[a[i]-1]++;
    maxx=max(maxx,p[a[i]-1]);
    p[a[i]]++;
    maxx=max(maxx,p[a[i]]);
    p[a[i]+1]++;
    maxx=max(maxx,p[a[i]+1]);

}
printf("%d\n",maxx);
    }
    return 0;
}


Measured memory_bytes: 5120
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

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

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

fn gcd(a: u64, b:u64) -> u64 {
    if b == 0 { a } else { gcd(b, a % b) }
}

fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}

fn main() {
    input!{
        n: usize,
        ts: [u64; n],
    }
    if n == 1 {
        println!("{}", ts[0]);
        return;
    }

    let mut ans = lcm(ts[0], ts[1]);
    for i in 2..n {
        ans = lcm(ans, ts[i]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using longlong=long long;

int main(){
    std::cin.tie(nullptr);std::cin.sync_with_stdio(false);
    int x0, y0, x1, y1;
    std::cin >> x0 >> y0 >> x1 >> y1;
    int dx=-(y1-y0),dy=x1-x0;
    std::cout << x1+dx
        << " " << y1+dy
        << " " << x0+dx
        << " " << y0+dy
        << std::endl;
}

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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  map<int, int> cnt;
  long long ans = 0;
  for(int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    ans += cnt[a - i];
    cnt[-a - i] += 1;
  }
  cout << ans << '\n';
}

Measured memory_bytes: 20492
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(o) {cerr<<#o<<" "<<o<<endl;}
#define DUMPC(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	int a[5] = { 18680908,19120730,19261225,19890108,INF };
	string b[5] = { "pre-meiji","meiji","taisho","showa","heisei" };
	for (int y, m, d; cin >> y >> m >> d;) {
		int c = y * 10000 + m * 100 + d;
		REP(i, 5) {
			if (a[i] > c) {
				if (i == 0)cout << b[0] << endl;
				else cout << b[i] << " " << (y - a[i - 1] / 10000) + 1 << " " << m << " " << d << endl;
				break;
			}
		}
	}
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N, A, B;
    ll count = 0;
    cin >> N >> A >> B;
    for(ll i = 1;i <= N;i++) {
        ll sum = 0;
        ll temp = i;
        while(temp) {
            sum += temp % 10;
            temp /= 10;
        }
        if(A <= sum && sum <= B) count += i;
    }
    cout << count << 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 a = sc.nextInt();
      int b = sc.nextInt();
      if((a * b) % 2 == 0) {
          System.out.println("Even");
      }else{
          System.out.println("Odd");
      }
    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;

int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char>> a(H,vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>a.at(i).at(j);
    }
  }
  vector<bool> row(H,true),line(W,true);
  for(int i=0;i<H;i++){
    bool flag=true;
    for(int j=0;j<W;j++){
      if(a.at(i).at(j)=='#'){
        flag=false;
        break;
      }
    }
    if(flag){
      row.at(i)=false;
    }
  }
  for(int i=0;i<W;i++){
    bool flag=true;
    for(int j=0;j<H;j++){
      if(a.at(j).at(i)=='#'){
        flag=false;
        break;
      }
    }
    if(flag){
      line.at(i)=false;
    }
  }

  for(int i=0;i<H;i++){
    if(!row.at(i)){
      continue;
    }
    for(int j=0;j<W;j++){
      if(row.at(i)&&line.at(j)){
        cout<<a.at(i).at(j);
      }
    }
    cout<<endl;
  }
}


Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    if (N <= 2) {
        cout << 0 << endl;
        return 0;
    }
    if (N % 2 == 0) {
        cout << (N - 2) / 2 << endl;
    } else {
        cout << (N - 1) / 2 << endl;
    }
    return 0;
}

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

int main(int argc, char **argv)
{
    int N, Y;
    std::cin >> N >> Y;

    for(int i = 0; i <= N; i++){ // 10000-yen
        for(int j = 0; j <= N-i; j++){ // 5000-yen
            int k = N-i-j;
            if(10000*i+5000*j+1000*k == Y){
                std::cout << i << " " << j << " " << k << std::endl;
                return 0;
            }
        }
    }  
    std::cout << -1 << " " << -1 << " " << -1 << std::endl;
}



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

int main() {
    int n;
    cin >> n;
    int r = sqrt(n);
    int cnt = 0;
    for(int i = 1; i <= r; i++){
        for(int j = i; j < n; j++){
            if(i * j < n) cnt++;
            else break;
            if( i != j) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int n;
int x[24];
int y[24];
int c[24];
int r[24];
char memo[1<<24];
int hit(int i,int j){
	int L = r[i]*r[i] + r[j]*r[j] + 2 * r[i] * r[j];
	int X = (x[i]-x[j])*(x[i]-x[j]);
	int Y = (y[i]-y[j])*(y[i]-y[j]);
	return X + Y < L;
}
int nocover(int n,int bit){
	for(int i = 0 ; i < n ; i++){
		if( (bit>>i&1) && hit(i,n) ) return false;
	}
	return true;
}
int dfs(int bit){
	if(~memo[bit]) return memo[bit];
	int ans = 0;
	for(int i = 0 ; i < n ; i++){
		for(int j = i+1 ; j < n ; j++){
			if( (bit >> j & 1) && (bit >> i & 1) && c[i] == c[j] && nocover(i,bit) && nocover(j,bit) ){
				ans = max(ans , dfs( bit - (1<<j) - (1<<i) ) + 2);
			}
		}
	}
	return memo[bit] = ans;
}
int main(){
	while(cin >> n , n){
		for(int i = 0 ; i < n ; i++){
			cin >> x[i] >> y[i] >> r[i] >> c[i];
		}
		memset(memo,-1,sizeof(memo));
		cout << dfs((1<<n)-1) << endl;
	}
}

Measured memory_bytes: 16000
N = int(input())
S = input()
mod = 10**9 + 7

S_dict = {}
for s in S:
    if s not in S_dict:
        S_dict[s] = 1
    else:
        S_dict[s] += 1

ans = 1
for v in S_dict.values():
    ans *= (v + 1)
    ans %= mod

print(ans - 1)

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

using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i > 0; i--)
#define all(v) v.begin(), v.end()
#define debug(x) cout << x << endl
#define vout(v) rep(i, v.size()) cout << v[i] << " ";
#define INF INT_MAX

int N;

int main() {
	cin >> N;
	vi a(N, 0);
	rep(i, N - 1) { cin >> a[i + 1]; }
	vi ans(N, 0);
	rep(i, N - 1) { ans[a[i + 1] - 1]++; }
	rep(i, N) { cout << ans[i] << endl; }
	return 0;
}


Measured memory_bytes: 4844
#[allow(unused_imports)]
use std::cmp::{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),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::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),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

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

fn solve() {
    let mut s = get!(String);

    let mut k = 0usize;
    let mut before = String::new();
    let mut now = String::new();
    for c in s.chars() {
        now.push(c);
        if before == now {
            continue;
        }
        before = now.clone();
        now.clear();
        k += 1;
    }
    println!("{}", k);
}


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

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

void solve(void) {
  ll n; cin >> n;
  vector<ll> a(n);
  rep(n, i) {
    ll ta; cin >> ta;
    a[i] = ta;
  }

  vector<ll> bucket(n+1, 0);
  rep(n, i) bucket[a[i]]++;

  map<ll, ll> m;
  rep(n+1, i) {
    if(bucket[i] < 2) m[i] = 0;
    else m[i] = (bucket[i] * (bucket[i]-1)) / 2;
  }

  ll sum = 0;
  rep(n+1, i) sum += m[i];

  rep(n, i) {
    ll tmp = 0;
    if((bucket[a[i]] -1) < 2) tmp = 0;
    else tmp = (bucket[a[i]]-1) * (bucket[a[i]] -2) / 2;
    cout << sum - m[a[i]] + tmp << endl;
  }
}

int main(void) {
  solve();
  return 0;
}

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

int main(){
  int i;
  string s;
  long long k;
  cin >> s >> k;
  for(i = 0; i < s.size(); i++) if(s[i] != '1') break;
  if(k < i+1) cout << '1' << endl;
  else cout << s[i] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define INF 200000000

typedef struct ca{
  char mark;
  int num;
} Card;

void quicksort(Card *, int, int);
int Partition(Card *, int, int);
void merge(Card *, int, int, int);
void mergesort(Card *, int, int);
int checkstable(Card *, Card *);

int n;

int main(){
        Card *A, *B;
        int i, p, r, q, left, right;

        scanf("%d", &n);
        A = malloc(sizeof(Card) * n);
		B = malloc(sizeof(Card) * n);
        for(i = 0 ; i < n ; i++){
                scanf(" %c %d", &A[i].mark, &A[i].num);
                B[i] = A[i];
        }

		p = 0;
		r = n - 1;
		quicksort(A, p, r);

		left = 0;
		right = n;
		mergesort(B, left, right);

		int stable = checkstable(A, B);
		if(stable)printf("Stable\n");
		else printf("Not stable\n");
		for(i = 0 ; i < n ; i++){
			printf("%c %d\n", A[i].mark, A[i].num);
		}

        return 0;
}

int Partition(Card *A, int p, int r){
        int x, i, j;
		Card buf;
        x = A[r].num;
        i = p - 1;
        for(j = p  ; j < r ; j++){
                if(A[j].num <= x){
                        i = i + 1;
                        buf = A[i];
                        A[i] = A[j];
                        A[j] = buf;
                }
        }
        buf = A[i + 1];
        A[i + 1] = A[r];
        A[r] = buf;
        return i + 1;
}

void quicksort(Card *A, int p, int r){
  int q;
  if(p < r){
    q = Partition(A, p, r);
    quicksort(A, p, q-1);
    quicksort(A, q+1, r);
  }
}

void merge(Card *B, int left, int mid, int right){
	int n1, n2, i, j, k;
	Card *L, *R;
	n1 = mid - left;
	n2 = right - mid;

	L = malloc((n1+1) * sizeof(Card));
	R = malloc((n2+1) * sizeof(Card));

	for(i = 0 ; i < n1 ; i++){
		L[i] = B[left + i];
	}
	for(i = 0 ; i < n2 ; i++){
		R[i] = B[mid + i];
	}

	L[n1].num = INF; R[n2].num = INF;

	i = 0; j = 0;
	for(k = left ; k < right ; k++){
		if(L[i].num <= R[j].num){
			B[k] = L[i];
			i++;
		}else{
			B[k] = R[j];
			j++;
		}
	}
}

void mergesort(Card *B, int left, int right){
  if(left + 1 < right){
    int mid = (left + right) / 2;
    mergesort(B, left, mid);
    mergesort(B, mid, right);
    merge(B, left, mid, right);
  }
}

int checkstable(Card *A, Card *B){
	int i;
	for(i = 0 ; i < n ; i++){
		if(A[i].mark != B[i].mark)return 0;
	}
	return 1;
}


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

using namespace std;

int main() {
  int n;
  bool good =true;
  uint64_t count=0;
  cin >> n;
  vector<uint64_t> v(n); 
  
  for(int i=0;i<n; i++){
    cin >> v.at(i);
  }
  while(good){
    
  for(int i=0; i<n;i++){
    if( v.at(i) %2 ==1){
      good =false;
      break;
    }
    v.at(i)/=2;
    if(i==n-1)
      count++;
  }
    
  }
  cout <<count <<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int n;  scanf("%d", &n);
    int a[n];
    int min, max;

    int i;

    scanf("%d", &a[0]);
    min = a[0];
    max = a[0];
    for(i = 1; i < n; i++){
        scanf("%d", &a[i]);

        if(max < a[i]){
            max = a[i];
        }
        if(min > a[i]){
            min = a[i];
        }
    }

    printf("%d\n", max - min);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
using namespace std;
string s;
int main() {
	int i, j;
	cin >> s;
	for(i=0; ; i++) if(s[i]=='A') break;
	for(j=s.size()-1; ; j--) if(s[j]=='Z') break;
	cout << j - i + 1;
	return 0;
}

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

vector<vector<long long>> Factrization(long long X);
    //////////////////////////////////////////
    //    因数分解する関数
    //    in   : 整数
    //    out  : 2次元のvector 
    //    ver  : 1.0
    //    概要 : 正の整数での使用のみを想定
    //    include: <vector>, <cmath>
    //////////////////////////////////////////


int main(){
    long long N, ans;
    std::cin >> N;

    vector<vector<long long>> facts;
    facts = Factrization(N);
    ans = N - 1;

    for(long long i = 0; i < facts.size(); i++){
        if(facts[i][0] + facts[i][1] -2 < ans){
            ans = facts[i][0] + facts[i][1] -2;
        }
    }

    std::cout << ans;


}

vector<vector<long long>> Factrization(long long X){
    vector<vector<long long>> factors = {};
    long long n_loop, a, b;

    n_loop = (long long)floor(sqrt((float)X));
    for(long long i =1; i <= n_loop; i++){
        if(X%i == 0){
            a = i;
            b = X/i;
            factors.push_back({a, b});
        }
    }
    return factors;
}

Measured memory_bytes: 3612
import java.util.Scanner;

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

        double a =sc.nextDouble();
        double b =sc.nextDouble();
        double c =Math.toRadians(sc.nextDouble());

        System.out.println(a*b*Math.sin(c)/2);
        System.out.println((a+b)+(Math.sqrt((a*a)+(b*b)-2*a*b*Math.cos(c))));
        System.out.println(b * Math.sin(c));
    }
}



Measured memory_bytes: 27992
' Imports System.Collections.Generic
' Imports System.Text.RegularExpressions

Class Main
    Public Shared Sub Main()
        Dim S As Char() = Console.ReadLine().ToCharArray()
        Dim flg As Boolean = S(2) = S(3) AndAlso S(4) = S(5)
        Console.WriteLine(If(flg, "Yes", "No"))
    End Sub
End Class


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

void solve(long long S, long long W){
    if (W >= S) cout << "unsafe" << '\n';
    else cout << "safe" << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long S;
    scanf("%lld",&S);
    long long W;
    scanf("%lld",&W);
    solve(S, W);
    return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

string s,t;

void input(){
    cin >> s;
    cin >> t;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    bool flg = true;
    map<char, char> scnt, tcnt;
    int sz = s.size();
    for(int i=0;i<sz;++i){
        if (scnt.count(s[i])) if (scnt[s[i]] != t[i]) flg = false;
        if (tcnt.count(t[i])) if (tcnt[t[i]] != s[i]) flg = false;
        scnt[s[i]] = t[i];
        tcnt[t[i]] = s[i];
    }
    if (flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 916
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  cin >> n;
  double res = 0;
  for(int i = 0; i < n; i++){
    double x;
    cin >> x;
    res += 1.0 / x;
  }
  cout << 1.0 / res;
}

Measured memory_bytes: 256
#include <cstdio>
#include <memory.h>
#include <algorithm>
using namespace std;

int dis[111111];

int main(void)
{
	int d, n, m, k, i, ans;
    
    while (1)
    {
        scanf("%d" ,&d);
        if (d == 0)
            break;
        scanf("%d %d" ,&n, &m);
        
        memset(dis, 0, sizeof(dis));
        
    	for (i = 1; i < n; i++)
    		scanf("%d" ,&dis[i + 1]);
    	dis[++n] = d;

    	sort(dis + 1, dis + n + 1);
    
        ans = 0;
    	while (m--)
    	{
    		scanf("%d" ,&k);
    
    		int next = lower_bound(dis + 1, dis + n + 1, k) - dis;
    
    		ans += min(dis[next] - k, k - dis[next - 1]);
    	}
    
    	printf("%d\n" ,ans);   
    }
	return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(void) {
    ll W, H, x, y, mx, my;
    long double result;
    cin >> W >> H >> x >> y;

    mx = min(x, W - x);
    my = min(y, H - y);

    result = W * H / 2.0;

    cout << result << " ";

    if(x == W / 2.0 && y == H /2.0)
        cout << "1" << endl;
    else
        cout << "0" << endl;
}

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

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s1,s2;
    int br=0;
    cin >> s1 >> s2;
    for (int i=0;i<s1.size();i++)
        if(s1[i]!=s2[i])
            br++;
    cout << br;
}


Measured memory_bytes: 3752
"use strict"
let input=require('fs').readFileSync('/dev/stdin','utf8');
let arr=input.split('\n');
for(let i in arr){
	let list=arr[i].split(' ');
	let a=parseInt(list[0]);
	let b=parseInt(list[1]);
	if(a===0&&b===0)break;
	if(a<=b) console.log(a+' '+b);
	else console.log(b+' '+a);
}



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

int main(int argc, char** argv){
	
	int		i;
	char	buff[BUFSIZ];
	char*	mes;
	
	scanf("%512[^\n]%*[^\n]%*c", buff);
	
	if((mes = (char *)malloc(strlen(buff) + 1)) == NULL)
		return 0;

	strcpy(mes, buff);
	
	
	for(i = 0; i < strlen(mes); i++){
		if		(0x40 < mes[i] && mes[i] < 0x5b)	mes[i] += 0x20;
		else if	(0x60 < mes[i] && mes[i] < 0x7b)	mes[i] -= 0x20;
	}
	
	printf("%s\n", mes);
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define maxn 203040

using namespace std;
typedef long long ll;
ll n,m,r,d,ans;

int main()
{
    scanf("%d%d",&n,&m);
    if (m==0){cout << n*n << endl;return 0;}n++;
    for (int i=m+1;i<n;i++)
    {
        r=n/i; ans+=r*(i-m);
        d=n%i; ans+=max(0ll,d-m);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

class UnionFind {
	vector<int> data;
	int num;
public:
	UnionFind(int size) : data(size, -1), num(size) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
			num--;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
	int numSet() {
		return num;
	}
};

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


	ll n,k,l;
	cin >> n >> k>>l;

	UnionFind uni_k(n),uni_l(n);

	REP(i, k) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		uni_k.unionSet(a, b);
	}

	REP(i, l) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		uni_l.unionSet(a, b);
	}

	map<P, ll> mp;
	REP(i, n) {
		mp[make_pair(uni_k.root(i), uni_l.root(i))]++;
	}

	REP(i, n) {
		cout << mp[make_pair(uni_k.root(i), uni_l.root(i))] << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main() {
  ld a,b,x;
  cin>>a>>b>>x;

  cout << fixed << setprecision (20);

  if(2*x>a*a*b) {
    cout << atan(2*(a*a*b-x)/(a*a*a))*180/pi << endl;
  }

  else {
    cout << atan(a*b*b/(2*x))*180/pi << endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
int bit[100001];
int query(int i) {
    int s = 0;
    while(i) {
        s += bit[i];
        i -= i&(-i);
    }
    return s;
}

void update(int i) {
    while(i < 100001) {
        bit[i]++;
        i += i&(-i);
    }
}

int main(){
    memset(bit, 0, sizeof bit);
    int n, q, a, b;
    sc("%d %d\n", &n, &q);
    int ant = 'F';
    for(int i = 1; i <= n; i++) {
        char ch = getchar();
        if (ch == 'C' && ant == 'A') update(i);
        ant = ch;
    }
    for(int i = 1; i <= q; i++) {
        sc("%d %d", &a, &b);
        pr("%d\n", query(b) - query(a));
    }
 	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
ll A[100010];
ll sum[100010];
bool ok[100010];

int main () {
  cin >> N;
  for (auto i = 0; i < N; ++i) {
    cin >> A[i];
  }
  sort(A, A+N);
  fill(sum, sum+100010, 0);
  sum[0] = A[0];
  for (auto i = 1; i < N; ++i) {
    sum[i] = A[i] + sum[i-1];
  }
  ok[N-1] = true;
  for (auto i = 1; i < N; ++i) {
    ok[i-1] = (sum[i-1] * 2 >= A[i]);
  }
  for (auto i = N-1; i >= 1; --i) {
    if (!ok[i]) {
      ok[i-1] = false;
    }
  }
  int cnt = 0;
  for (auto i = 0; i < N; ++i) {
    if (ok[i]) ++cnt;
  }
  cout << cnt << endl;
}


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

int main()
{
	int n, m; cin >> n >> m;
	
	vector<int> s(m), c(m);
	for (int i = 0; i < m; i++) cin >> s[i] >> c[i];

	for (int x = 0; x <= 999; x++) {
		string sx;
		sx = to_string(x);
		if (sx.size() != n) continue;		
		
		vector<int> b;
		for (int i = 0; i < sx.size(); i++) {
			b.push_back((int)(sx.at(i) - '0'));
		}

		bool exist = true;
		for (int i = 0; i < m; i++) {
			if (b[s[i] - 1] != c[i]) {
				exist = false;
			}
		}
		if (exist) {
			cout << x << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
k =[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
a = int(input())

print(k[a-1])

Measured memory_bytes: 2940
//
// Created by Pulak on 02-11-2019.
//
#include <iostream>
#include <bits/stdc++.h>
typedef  long long int ll;
ll dp[100005][105];
ll solve(ll done, ll no);

using namespace std;
ll n, tWeight;
vector <int> w;
vector <int> v;

int main(){
  //  n, tWeight;
    cin>>n>>tWeight;
  //  w (n), v(n);
  memset(dp, -1, sizeof(dp));
  w.resize(n);
  v.resize(n);
    for (ll i = 0; i < n; ++i) {
        cin >> w[i]>>v[i];
    }
   cout << solve(0,0);
}

ll solve(ll done, ll no) {
    if(dp[done][no] != -1)
        return dp[done][no];
    if (done >= tWeight || no == n ) return 0;
    if (tWeight - done < w[no]) return dp[done][no] = solve(done, no + 1);
    return dp[done][no] = max(v[no] + solve(done + w[no], no + 1), solve(done, no + 1));
}

Measured memory_bytes: 82432
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
vector<int> G[100000];
int DD[100000];
int D1[100000], D2[100000], Ds[100000];

int dfs1(int x, int p) {
  int s = 0;
  for (int t : G[x]) {
    if (t == p) continue;
    s = max(s, dfs1(t, x)+1);
  }
  return DD[x] = s;
}
int dfs2(int x, int p) {
  int s = 0;
  vector<P> vs;
  for (int t : G[x]) {
    if (t == p) continue;
    vs.pb(P(DD[t]+1, t));
  }
  if (p != -1) {
    int m = 0;
    if (Ds[p] == x) m = D2[p];
    else m = D1[p];
    vs.pb(P(m+1, p));
  }
  assert(!vs.empty());
  sort(all(vs), greater<P>());
  D1[x] = vs[0]._1;
  Ds[x] = vs[0]._2;
  if (vs.size() > 1) D2[x] = vs[1]._1;
  for (int t : G[x]) {
    if (t == p) continue;
    dfs2(t, x);
  }
  return D1[x];
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N-1) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    G[u].pb(v);
    G[v].pb(u);
  }
  dfs1(0, -1);
  dfs2(0, -1);
  rep(i, N) cout << 2*(N-1) - D1[i] << "\n";
  return 0;
}

Measured memory_bytes: 25808
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws Exception {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader (is);
		int N = Integer.parseInt(br.readLine());
		int count = 0;
		int cardList[] = new int[N];
		long result = 0;
		while(br.ready()) {
			int card = Integer.parseInt(br.readLine());
			cardList[count] = card;
			if(count!=0) {
				if(cardList[count-1]>0 && cardList[count]>0) {
					if(cardList[count-1]%2 !=0) {
						cardList[count-1] -= 1;
						cardList[count] -= 1;
						result += 1;
					}
				}
				result  += cardList[count-1]/2;
			}
			if(N-1 == count) {
				result += cardList[count]/2;
			}
			count++;
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 32684
using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        static void Main(){
            long[] ab = ILongs();
            WriteLine(Max(Max(ab[0]+ab[1],ab[0]*ab[1]),ab[0]-ab[1]));
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // cin, cout の高速化
#define MOD 1000000007
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i <= (n); i++)
 
const ll INF = 1e15;
 
int main()
{
    long d,n;
    long tmp=1;
    cin >> d >> n;
 
    REP(i,d){
        tmp *= 100;
    }
    if(n%100==0){n+=1;}
    long ans = tmp*n;
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
N, Y  = map(int, input().split())
flag = False

for i in range(N+1): # 10000
    for j in range(N-i+1): #5000
        k=N-i-j
            
        total = i*10000 + j*5000 + k*1000
           
        if(0<= k and total==Y):
            print(i, j, k)
            exit()

print(-1, -1, -1)

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

int main(){
  string s1, s2;
  cin >>s1>>s2;
  if (s1.size()<s2.size()){
    cout << "LESS"<<endl;
    return 0;
  }
  if (s1.size()>s2.size()){
    cout << "GREATER" <<endl;
    return 0;
  }
  int h=0;
  while(h<s1.size()){
    if(s1[h]==s2[h]) h++;
    if(s1[h]<s2[h]){
      cout << "LESS"<<endl;
      return 0;
    }
    else if(s1[h]>s2[h]){
      cout << "GREATER"<<endl;
      return 0;
    }
  }
  cout << "EQUAL"<<endl;
}

Measured memory_bytes: 256