akhauriyash/Code-Regression huggingface dataset:
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

ll dx8[8]={1,0,-1,0,1,-1,1,-1};
ll dy8[8]={0,1,0,-1,1,-1,-1,1};
ll dx4[4]={0,0,1,-1};
ll dy4[4]={1,-1,0,0};



int main(){
    IOS;
    make(ll,n);
    unordered_map <ll,ll> um;
    fr(i,n){
        make(ll,x);
        um[x]^=1;
    }
    ll ans=0;
    for(auto x : um) {if(x.second) ans++;}
    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 7224
use std::io::BufRead;

pub struct StdinReader<R: BufRead> {
    pub buf_reader: R,
    pub buf: String,
}

impl<R: BufRead> StdinReader<R> {
    pub fn new(r: R) -> Self {
        StdinReader {
            buf_reader: r,
            buf: String::with_capacity(10000),
        }
    }
}

#[macro_export]
macro_rules! input {
    ($reader : expr, $t : ty) => { // one variable
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().parse().unwrap();
                reader.buf.clear();
                tmp_var
            },
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty) => { // 2 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone())
            }
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty, $t2 : ty) => { // 3 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone(), tmp_var[2].clone())
            }
        }
    };
    ($reader : expr, $t : ty; $size : expr) => { // Vector
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                tmp_var
            }
        }
    };
}

fn main() {
    solve_a();
}

fn solve_a() {
    let handle = std::io::stdin();
    let mut r = StdinReader::new(handle.lock());
    let (a, b, c) = input!(r, usize, usize, usize);
    if (a == b && a == c) {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


int n, k, a[101010];
string s;

int main(){
	cin >> n >> k >> s;
	
	bool z = !(s[0] == '0');
	int cnt = 1, c = z;
	
	for(int i = 1; i < n; i++){
		if(s[i] == s[i-1]) cnt++;
		else{
			a[c] = cnt;
			cnt = 1;
			c++;
		}
	}a[c] = cnt;c++;
	
	int ans = 0, K = 0;
	cnt = 0;
	for(int i = z; i < c; i++){
		cnt += a[i];
		if(i % 2 == 0) K++;
		if(k < K){K--; cnt -= a[i-k*2]+a[i-k*2-1];}
		ans = max(ans, cnt);
	}
	
	cout << ans << endl;
	
	return 0;
}

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

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

#define st first
#define nd second

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

const int MAXN = 5E2 + 10;

int n;
char s[MAXN][MAXN];
int row[MAXN], col[MAXN];

int main(){
	scanf("%d", &n);
	for (int i = 0; i < n; ++i){
		scanf("%s", s[i]);
		row[i] = count(s[i], s[i] + n, '#');
		for (int j = 0; j < n; ++j)
			col[j] += s[i][j] == '#';
	}
	if (accumulate(row, row + n, 0) == 0)
		puts("-1");
	else if (find(row, row + n, n) != row + n)
		printf("%d\n", n - count(col, col + n, n));
	else{
		int scol = n - count(col, col + n, n);
		int srow = n;
		for (int i = 0; i < n; ++i){
			if (col[i] > 0)
				srow = min(srow, n - row[i]);
			else{
				srow = min(srow, n - row[i] + 1);
			}
		}
		printf("%d\n", srow + scol);
	}
	return 0;
}


Measured memory_bytes: 512
<?php
fscanf(STDIN,"%d",$n);
fscanf(STDIN,"%d",$k);
fscanf(STDIN,"%d",$x);
fscanf(STDIN,"%d",$y);
$result = $n>$k ? $k*$x+($n-$k)*$y : $n*$x;

echo($result);

Measured memory_bytes: 3700
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文
int main() {
	int x;
	cin >> x;
	if (x < 1200) dump ("ABC") else dump("ARC")
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int n = in.i();
        long ans = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                ans += i;
            }
        }
        out.println(ans);
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 25660
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};
 
typedef struct node * NodePointer;
 
NodePointer nil;
 
NodePointer listSearch(int key){
  NodePointer t;
  for (t = nil->next; t != nil; t = t->next) {
    if (t->key == key) {
      return t;
    }
  }
  return nil;
}
 
void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}
 
void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}
 
void deleteNode(NodePointer t){
  NodePointer a_del = t->next, b_del = t->prev;
  if (a_del == nil) {
    nil->prev = b_del;
    b_del->next = nil;
  } else if (b_del == nil) {
    nil->next = a_del;
    a_del->prev = nil;
  } else {
    a_del->prev = b_del;
    b_del->next = a_del;
  }
  free(t);
}
 
void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}
 
void deleteLast(){
  NodePointer t = nil->prev;
  if (t == nil) return;
  deleteNode(t);
}
 
void delete(int key){
  NodePointer t = listSearch(key);
  if (t == nil) return;
  deleteNode(t);
}
 
 
void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
 
  if (nil->prev == NULL) {
    nil->prev = x;
  }
   
  if (nil->next == NULL) {
    nil->next = x;
    x->prev = nil;
    x->next = nil;
  } else {
    nil->next->prev = x;
    x->next = nil->next;
    x->prev = nil;
    nil->next = x;
  }  
}
 
int main(){
  int key, n, i;
  
  char com[20];
  
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); }
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
        if ( com[6] == 'F' ) deleteFirst();
        else if ( com[6] == 'L' ) deleteLast();
      } else {
        delete(key); 
      }
      
    }
  }
 
  printList();
  return 0;
}


Measured memory_bytes: 32944
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	long long a, b, k; cin >> a >> b >> k;
	for (long long i = a; i <= min(b, a + k - 1); i++)cout << i << endl;
	for (long long i = max(b - k + 1, a + k); i <= b; i++)cout << i << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {	
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		
		int sum=0;
		if(a>b) {
			sum += a;
			a--;
		}else {
			sum += b;
			b--;
		}
		
		if(a>b) {
			sum += a;
			a--;
		}else {
			sum += b;
			b--;
		}
		
		System.out.println(sum);
	}
}


Measured memory_bytes: 21716
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    if N % 2 == 0:
        print(N)
    else:
        print(N*2)

#
# main
#

# 1. use list instead of stdin

#contents = '''\
#999999999\
#'''
#lines = contents.split('\n')

# 2. use stdin

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll MOD = 998244353;
void add(int &a, int b)
{
    a = (a + b) % MOD;
    a = (a + MOD) % MOD;
}
int main()
{
    int n, k;
    cin >> n >> k;
    vector<P> v(k);
    for(int i = 0; i < k; i++)
    {
        int l, r;
        cin >> l >> r;
        r++;
        v[i] = P(l, r);
    }
    vector<int> dp(n+1, 0);
    vector<int> num(n+1, 0);
    dp[1] = 1;
    for(int i = 1; i <= n; i++)
    {
        add(num[i], num[i-1]);
        if(i > 1) dp[i] = num[i];
        for(int j = 0; j < k; j++)
        {
            int l = v[j].first;
            int r = v[j].second;
            if(i+l <= n) add(num[i+l], dp[i]);
            if(i+r <= n) add(num[i+r], -dp[i]);
        }
        //for(int i = 1; i <= n; i++)
        //{
        //    cout << dp[i] << " ";
        //}
        //cout << endl;
        //for(int i = 1; i <= n; i++)
        //{
        //    cout << num[i] << " ";
        //}
        //cout << endl;
        //cout << endl;
    }
    cout << dp[n] << endl;
}


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

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

  vector<string> S(N);

  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  for (int i = 0; i < N-1; i++) {
      if(S.at(i).at(S.at(i).size()-1)!=S.at(i+1).at(0)) {
          cout << "No" << endl;
          return 0;
      }
  }
  sort(S.begin(), S.end());
  for (int i = 0; i < N-1; i++) {
      if(S.at(i)==S.at(i+1)) {
          cout << "No" << endl;
          return 0;
      }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
s = input()
flag = 0
cnt = 0
ans = 0
for i in range(len(s)):
  if flag == 1:
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
      cnt += 1
    else:
      flag = 0
      if cnt > ans:
        ans = cnt
  else:
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
      flag = 1
      cnt = 1
if cnt > ans:
  ans = cnt
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)

int main(){
    string s;
    while(getline(cin, s)){
        int l[10],v[2];
        sscanf(s.c_str(), "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v[0],&v[1]); 

        int total = 0; REP(i,10) total += l[i];
        double d = (double)total * v[0] / (v[0]+v[1]);
        REP(i,10){
            if(d <= l[i]){
                cout << i+1 << endl;
                break;
            }
            d -= l[i];
        }
    }
    return 0;
}

Measured memory_bytes: 1232
import java.util.HashMap;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        HashMap<Integer, Integer> hm = new HashMap();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            if (hm.get(a[i]) == null) {
                hm.put(a[i], 1);
            }
            else {
                hm.put(a[i], hm.get(a[i]) + 1);
            }
        }
        long sum = 0;
        for( int key : hm.keySet()) {
            long tmp = hm.get(key);
            if (tmp < 2) continue;
            sum += (tmp * (tmp - 1)) / 2;
        }

        for (int ansIndex = 0; ansIndex < n; ansIndex++) {
            long ans = sum;
            long tmp = hm.get(a[ansIndex]);
            ans = ans - (tmp * (tmp - 1) / 2) + ((tmp - 1) * (tmp - 2) / 2);
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 109744
import java.io.*;
import java.util.*;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        char C = sc.next().charAt(0);

        final Solver solver = new Solver();
        solver.solve(C);
    }
}

class Solver {
    public void solve(char C) {
        System.out.println((char) (C + 1));
    }
}



Measured memory_bytes: 21588
from functools import reduce

def main():
    n, a, b = [int(e) for e in input().split()]
    mod = 10**9 + 7

    ans = pow(2, n, mod) - 1

    anu = reduce(lambda p1, p2: p1*p2%mod, range(n, n - a, -1))
    ade = reduce(lambda p1, p2: p1*p2%mod, range(1, a + 1))
    ans -= anu*pow(ade, mod - 2, mod)%mod

    bnu = reduce(lambda p1, p2: p1*p2%mod, range(n, n - b, -1))
    bde = reduce(lambda p1, p2: p1*p2%mod, range(1, b + 1))
    ans -= bnu*pow(bde, mod - 2, mod)%mod

    ans %= mod
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 39536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int A;
  int B;
  cin >> A;
  cin >> B;
  int plus;
  int minus;
  int time;
  plus = A + B;
  minus = A -B;
  time = A*B;  
   
 cout << max(max(plus,minus), max(plus,time)) << endl;
 
  
 }

Measured memory_bytes: 256
import java.util.*
import kotlin.math.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main() {
    println(readInts().indexOf(0) + 1)
}


Measured memory_bytes: 36456
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 7;
set <int> g[N];
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        g[u].insert(v); g[v].insert(u);
    }   
    for (int i = 2; i < n; ++i) {
        if (g[i].find(1) != g[i].end() && g[i].find(n) != g[i].end()) {
            cout << "POSSIBLE\n";
            exit(0);
        }   
    }   
    cout << "IMPOSSIBLE\n";
}   

Measured memory_bytes: 28416
/**In the name of Allah, the Most Merciful, the Most Merciful.**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define INF 9223372036854775806
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define PI 2*acos(0.0)
#define EPS 1e-9
ll max(ll a,ll b) {if(a>b) return a; else return b;}
ll min(ll a,ll b) {if(a<b) return a; else return b;}

int main()
{
    int n;
    cin>>n;
    string s;
    vector<string> v{"AC", "WA", "TLE","RE"};
    map<string,int> cnt;
    for(int i=1;i<=n;i++){
        cin>>s;
        cnt[s]++;
    }
    for(string s:v){
        cout<<s<<" x "<<cnt[s]<<endl;
    }

    return 0;
}




Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main() {
	long long i, n, count, x, y, tmp;
	double d;
	cin >> n;
	tmp =(long long) sqrt(n);
	for (i = tmp; i > 1;i--) {
		if (n % i == 0) {
			break;
		}
	}
	cout << n / i + i - 2;

	return 0;
}

Measured memory_bytes: 256
s = input()
flag = 1
for i in range(len(s)):
    if i %2 == 0: #奇数文字目
        if s[i] not in ["R","U","D"]:
            flag = 0
    else:
        if s[i] not in ["L","U","D"]:
            flag = 0
if flag:
    print("Yes")
else :
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define r double
int n,a,b;
ll v[51];
ll c[51][51];

void comb_table(void){
  for(int i=0;i<=n;i++){
    for(int j=0;j<=i;j++){
      if(j==0||j==i){
        c[i][j] = 1LL;
      }
      else{
        c[i][j]=(c[i-1][j-1]+c[i-1][j]);
      }
    }
  }
}

int main(){
  cin>>n>>a>>b;

  for(int i=0;i<n;i++)
    cin>>v[i];

  comb_table();

  sort(v,v+n);
  reverse(v,v+n);

  r max = 0.0;
  for(int i=0;i<a;i++)
    max += v[i];
  max /= a;

  int num=0,pos=0;
  for(int i=0;i<n;i++){
    if(v[i]==v[a-1]){
      num++;
      if(i<a)
        pos++;
    }
  }

  ll cnt = 0LL;
  if(pos==a){
    for(pos=a;pos<=b;pos++)
      cnt+=c[num][pos];
  }
  else
    cnt+=c[num][pos];

  cout.precision(20);
  cout<<fixed<<max<<endl;
  cout<<cnt<<endl;

  return 0;
}


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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

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

void solution() {
  int n;
  cin >> n;
  int v[n + 1];
  for(int i=0; i<=n; i++){
    cin >>v[i];
  }
  
  // check if it's valid
  int cur = 1;
  for(int i=0; i<=n; i++){
    cur -= v[i];
    if(cur < 0){
      cout << -1 << endl;
      return;
    }
    cur *= 2;
    cur = min(cur, (int)(INF));
  }
  
  cur = 1;
  
  int s = 0;
  for(int i=0; i<=n; i++) s += v[i];
  
  int ans = 0;
  for(int i=0; i<=n; i++){
    ans += min(cur, s);
    s -= v[i];
    cur -= v[i];
    cur *= 2;
    cur = min(cur, (int)(INF));
  }
  cout << ans << endl;
}

int32_t main() {
  // DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  solution();
}

Measured memory_bytes: 4372
#include <bits/stdc++.h>
using namespace std;
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;
 
ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}
ll powerm(ll base,ll exp,ll mod) 
{ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
 
struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
	{
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const 
	{
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
/* DSU 
int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}
void make_set(int v) {
    parent[v] = v;
    rank[v] = 0;
}
void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rank[a] < rank[b])
            swap(a, b);
        parent[b] = a;
        if (rank[a] == rank[b])
            rank[a]++;
    }
}
*/ 
int main()
{  
	fast; 
	unordered_map<string,ll>mp;
	ll n; cin>>n;
	for(ll i = 0; i < n; i++)
	{
		string s; cin>>s;
		mp[s]++;
	}
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;
	return 0;
}

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

int main() {
	static long long N, A[100000], B[100000], C[100000], DP[100000][3] = {};
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i] >> B[i] >> C[i];
	DP[0][0] = A[0], DP[0][1] = B[0], DP[0][2] = C[0];
	for (int i = 1; i < N; i++) {
		DP[i][0] = max(DP[i - 1][1], DP[i - 1][2]) + A[i];
		DP[i][1] = max(DP[i - 1][2], DP[i - 1][0]) + B[i];
		DP[i][2] = max(DP[i - 1][0], DP[i - 1][1]) + C[i];
	}
	cout << max(max(DP[N - 1][0], DP[N - 1][1]), DP[N - 1][2]) << endl;
}

Measured memory_bytes: 4992
a, b, c, x, y = [int(i) for i in input().split()]

if c < a/2 and c < b/2:
    cost = max(x, y)*2*c
elif c < a/2:
    if x < y:
        cost = x*2*c + (y-x)*b
    else:
        cost = x*2*c
elif c < b/2:
    if y < x:
        cost = y*2*c + (x-y)*a
    else:
        cost = y*2*c
elif c < (a+b)/2:
    cost = min(x, y)*2*c+(x-min(x,y))*a + (y-min(x,y))*b
else:
    cost = x*a+y*b
print(cost)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int mod = 1000000007;
    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
        sum %= mod;
    }
 
    long ans = 0;
 
    //i について全探索する
    for (int i = 0; i < N; i++)
    {
        //A[i+1] ... A[N] の値を更新する
        sum -= A[i];
        if (sum < 0) sum += mod;
 
        ans += A[i] * sum;
        ans %= mod;
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 4008
from sys import setrecursionlimit
setrecursionlimit(100000000)

NIL = -1
n = int(input())
class Node:
    def __init__(self, p, l, r, s=-1, c=0, d=0, h=0, t='nil'):
        self.p = p 
        self.l = l
        self.r = r
        self.s = s
        self.c = c
        self.d = d
        self.h = h
        self.t = t

T = [Node(NIL, NIL, NIL) for _ in range(n)]
#入力から二分木の情報を受け取る 
for _ in range(n):
    data = [int(i) for i in input().split()]
    node_id = data[0]
    cl = data[1]
    cr = data[2]
    T[node_id].l = cl
    T[node_id].r = cr
    cnt_child = 0
    if cl != NIL:
        T[cl].p = node_id
        T[cl].s = cr
        cnt_child += 1
    if cr != NIL:
        T[cr].p = node_id
        T[cr].s = cl
        cnt_child += 1
    T[node_id].c = cnt_child 

#node id: parent = p, sibling = s, degree = deg, height = h, typeを出力するプログラムを作る

def setDepth(node_id, depth):
    T[node_id].d = depth
    l = T[node_id].l
    r = T[node_id].r
    if l != NIL:
        setDepth(l, depth+1)
    if r != NIL:
        setDepth(r, depth+1)

#rootのノードを探す関数
def searchRoot():
    for i in range(n):
        if T[i].p == NIL:
            return i
    return 

#高さを求める関数
#sovelHeight関数はnode_idの高さを返す関数
def solveHeight(node_id):
    hl = 0
    hr = 0
    #node_idから子を辿る
    if T[node_id].l != NIL: 
        hl = solveHeight(T[node_id].l)+1
    if T[node_id].r != NIL:
        hr = solveHeight(T[node_id].r)+1
    res = max(hl, hr)
    T[node_id].h = res
    return res


#nodeの種類を求める関数
def nodeType(node_id):
    if T[node_id].p == NIL:
        T[node_id].t = 'root'
        return  

    if (T[node_id].l == NIL) and (T[node_id].r == NIL):
        T[node_id].t = 'leaf'
        return 
    #rootでもleafでもないnodeはindternal nodeである
    T[node_id].t = 'internal node'

#全てのnodeの種類を決める
def allNodeTypeDiff():
    for i in range(n):
        nodeType(i)

#node_idのノードの情報をprintする
def nodeInfo(node_id):
    p = T[node_id].p
    s = T[node_id].s
    c = T[node_id].c
    d = T[node_id].d
    h = T[node_id].h
    t = T[node_id].t
    node_info = "node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}".format(node_id, p, s, c, d, h, t)
    print(node_info)
#全てのノードの情報をprintする
def allNodeInfo():
    for i in range(n):
        nodeInfo(i)

def main():
    root = searchRoot()
    solveHeight(root)
    setDepth(root, 0)
    allNodeTypeDiff()
    allNodeInfo()
main()


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

int main(){
    for(int i=0; i<2; i++){
        int a[10];
        for(int j=0; j<10; j++){
            cin >> a[j];
        }
        sort(a, a+10);
        cout << a[9]+a[8]+a[7];
        if(i==0){
        	cout << " ";
        }else{
        	cout << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3168
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}

constexpr ll LNF = 1LL<<50;

constexpr int INF = 1e9+7;

const long double PI=3.14159265358979323846;


vector<int> dx = {1,0,-1,1,-1,0};
vector<int> dy = {1,1,1,0,0,-1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.size();
    vector<vector<int>> dp(n+1,vector<int>(2,0));
    dp[0][1] = 1;
    rep(i,0,n){
        int a = ctoi(s[i]);
        dp[i+1][0] = min(dp[i][0]+a,dp[i][1]+10-a);
        if(i!=n-1){
            dp[i+1][1] = min(dp[i][0]+a+1,dp[i][1]+9-a);
        }
    }
    cout << dp[n][0] << endl;
}

Measured memory_bytes: 58896
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;

void solve() {
	int N; cin >> N;
	vector<int>A(N);
	REP(i, N) {
		cin >> A[i];
	}
	VSORT(A); VREVERSE(A);
	int ans = 0;
	int k = 1;
	ans += A[0];
	k++;
	FOR(i, 1, N) {
		REP(j, 2) {
			if (k == N)break;
			ans += A[i];
			k++;
		}
	}
	print(ans);
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();
}


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

int main() {
int n,m;
cin >>n >> m;
priority_queue<int> a;
for(int i=0;i<n;i++){
    int z;
    cin >> z;
    a.push(z);
}
for(int i=0;i<m;i++){
    int zz = a.top();
     zz/=2;
    a.pop();
    a.push(zz);
}
long long ans =0;
for(int i=0;i<n;i++){
    ans+=a.top();
    a.pop();
}
cout << ans << endl;
}


Measured memory_bytes: 892
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			String line = sc.next();
			Panel root = new Parser(line).parse();
			for (int i = 0; i < N; ++i) {
				int x = sc.nextInt();
				int y = sc.nextInt();
				Panel p = root.hit(x, y);
				if (p == null) {
					System.out.println("OUT OF MAIN PANEL 1");
				} else {
					System.out.println(p.name + " " + p.child.size());
				}
			}
		}
	}

	static class Parser {

		char[] str;
		int pos;

		Parser(String line) {
			this.str = line.toCharArray();
		}

		Panel parse() {
			++pos;
			StringBuilder name = new StringBuilder();
			while (str[pos] != '>') {
				name.append(str[pos]);
				++pos;
			}
			++pos;
			int x1 = parseInt();
			++pos;
			int y1 = parseInt();
			++pos;
			int x2 = parseInt();
			++pos;
			int y2 = parseInt();
			Panel ret = new Panel(x1, y1, x2, y2, name.toString());
			while (str[pos + 1] != '/') {
				ret.child.add(parse());
			}
			while (str[pos] != '>') {
				++pos;
			}
			++pos;
			return ret;
		}

		int parseInt() {
			int ret = 0;
			while ('0' <= str[pos] && str[pos] <= '9') {
				ret *= 10;
				ret += str[pos] - '0';
				++pos;
			}
			return ret;
		}
	}

	static class Panel {
		int x1, y1, x2, y2;
		String name;
		ArrayList<Panel> child = new ArrayList<Panel>();

		Panel(int x1, int y1, int x2, int y2, String name) {
			this.x1 = x1;
			this.y1 = y1;
			this.x2 = x2;
			this.y2 = y2;
			this.name = name;
		}

		Panel hit(int x, int y) {
			if (x < this.x1 || this.x2 < x || y < this.y1 || this.y2 < y) return null;
			for (Panel c : child) {
				Panel ret = c.hit(x, y);
				if (ret != null) return ret;
			}
			return this;
		}
	}

}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <iomanip>
#define ll long long

using namespace std;

int main(void){
    ll n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    ll ans = 0;
    vector<ll> check;
    check.push_back(0);
    for(ll i = 0; i < s.length(); i++){
        if(s[i]!=s[i-1] && i!=0){
            check.push_back(i);
        }
    }
    ll len = s.length();
    for(ll i = 0; i < check.size(); i++){
        ll a = check[i];
        if(s[a]=='1'){
            ll b = check[i+2*k+1];
            if(i+2*k+1 >= check.size())
                ans = max(ans, len-a);
            else ans = max(ans, b-a);
        }
        else if(s[a]=='0'){
            ll b = check[i+2*k];
            if(i+2*k >= check.size())
                ans = max(ans, len-a);
            else ans = max(ans, b-a);
        }
    }
    cout << ans << endl;
    return 0;
}


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

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

    //good luck kittu!
    int n; cin>>n;
    vector<int> a(n), b(n), e(n);
    for(int i = 0; i<n; i++) cin>>a[i];
    for(int i = 0; i<n; i++) cin>>b[i];
    for(int i = 0; i<n; i++) e[i] = i+1; 

    int ox, bull;
    
    for(int i = 0; ; i++){
        bool ok = 1;
        for(int j = 0; j<n; j++){
            if(a[j]!=e[j]){
                ok = 0;
                break;
            }
        }
        if(ok){
            ox = i;
            break;
        }
        next_permutation(e.begin(), e.end());
    }
    
    //for(int x : e) cout<<x<<" ";
    
    sort(e.begin(), e.end());
    
    for(int i = 0; ; i++){
        bool ok = 1;
        for(int j = 0; j<n; j++){
            if(b[j]!=e[j]){
                ok = 0;
                break;
            }
        }
        if(ok){
            bull = i;
            break;
        }
        next_permutation(e.begin(), e.end());
    }
    cout<<abs(ox-bull)<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <iostream>
#include <math.h>
#include <algorithm>
 
using namespace std;
 
 
 
int main() {
    int d,d1,i,j,k;
    int c[26];
    int s[365][26];
    cin >> d;
    d1 = 0;
    for(i = 0; i < 26; ++i) cin >> c[i];
    for(i = 0; i < d; ++i) for(j = 0; j < 26; ++j) cin >> s[i][j];
 
    int arr[365] = {};
 
    int t1,t2,s1,s2, diff, count;
    count = 0;
    int max, loc;
    int a[26];
    for(int i = 0; i < 26; ++i) a[i] = 1;
    int b[26] = {};
    for(i = 0; i < 365; ++i) {
        for(j = 0; j < 26; ++j) {
            b[j] = s[i][j]+2*a[j]*c[j];
            a[j]++;
        }
        max = *max_element(b,b+26);
        loc = find(b,b+26,max)-b;
        arr[i] = loc;
        a[loc] = 1;
    }
    
    
    while(true) {
 
 
        label1:
        for(i = 0; i < d; ++i) {
            for(j = 0; j < 26; ++j) {
                if(arr[i]==j) continue;
                if(count>20000000) goto label2;
                ++count;
                for(s1 = i+1; s1 < d; ++s1) {
                    if(arr[s1]==arr[i]) break;
                }
                for(t1 = i-1; t1 >= 0; --t1) {
                    if(arr[t1]==arr[i]) break;
                }
                for(s2 = i+1; s2 < d; ++s2) {
                    if(arr[s2]==j) break;
                }
                for(t2 = i-1; t2 >= 0; --t2) {
                    if(arr[t2]==j) break;
                }
                diff = s[i][j]-s[i][arr[i]]+(((s1-i)*(s1-i-1))/2+((i-t1)*(i-t1-1))/2-((s1-t1)*(s1-t1-1))/2)*c[arr[i]] + (-((s2-i)*(s2-i-1))/2-((i-t2)*(i-t2-1))/2+((s2-t2)*(s2-t2-1))/2)*c[j];
                if(diff>0) {
                    arr[i] = j;
                    goto label1;
                }
            }
        }
    }
    label2:
    for(i = 0; i < d; ++i) {
        cout<<(arr[i]+1)<<"\n";
    }
 
 
    return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int a,J[1000];
void push(int);
int pop();
void push(int x){
  J[++a]=x;
}
int pop(){
  a--;
  return J[a+1];
}

int main(){
  int c,d;
  a=0;
  char b[100];
  
  while(scanf(" %s ",b) != EOF){
    if(b[0]=='+'){
      c=pop();
      d=pop();
      push(c + d);
      
    }else if(b[0]=='-'){
      d=pop();
      c=pop();
      push(c-d);
      
    }else  if(b[0]=='*'){
      c=pop();
      d=pop();
      push(c*d);
      
    }else{
      push(atoi(b));
    }
  }
  printf("%d\n",pop());
  return 0;
}



Measured memory_bytes: 2088
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
  int i=0,j=0;
  char op,c;
  int stack[2000],num,flag;
  for(i=0;i<2000;i++){
    stack[i]='\0';
  }
  i=0;
  while(1){
    flag=-1;
    c=getchar();
    if(feof(stdin)!=0){
      break;
    }
    if('1'<=c && c<='9'){
      ungetc(c,stdin);
      flag=1;
      scanf("%d",&num);
    }else if(c!=' ' && c!='\n'){
      ungetc(c,stdin);
      flag=0;
      scanf("%c",&op);
    }
    if(flag==1){
      stack[j]=num;
    }
    if(flag==0){
      stack[j]=op;
    }
    if(stack[j]=='+' && flag==0){
      stack[j-2]=stack[j-2]+stack[j-1];
      stack[j]='\0';
      stack[j-1]='\0';
      j=j-2;
    }else if(stack[j]=='-'&& flag==0){
      stack[j-2]=stack[j-2]-stack[j-1];
      stack[j]='\0';
      stack[j-1]='\0';
      j=j-2;
    }else if(stack[j]=='*'&& flag==0){
      stack[j-2]=stack[j-2]*stack[j-1];
      stack[j]='\0';
      stack[j-1]='\0';
      j=j-2;
    }
    if(flag==0 || flag==1){
      j++;
    }
  }
  printf("%d\n",stack[0]);
}

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

#define NDEBUG
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


int N;
vi L, R;
vii lefts, rights;

ii minmove(int ix, int here) {
    assert(IN(ix, 0, N-1));
    int move, next;
    if (R[ix] <= here) {
        move = here - R[ix];
        next = R[ix];
    } else if (L[ix] <= here) {
        move = 0;
        next = here;
    } else {
        move = L[ix] - here;
        next = L[ix];
    }
    return ii(move, next);
}

ll sub(int side){
    ll res = 0;
    int here = 0;
    vi visited(N, 0);
    int left_ix = 0, right_ix = 0;

    rep(i, N) {
        int next, move, ix;
        if (side > 0) {
            while (visited[lefts[left_ix].second]) left_ix++;
            assert(left_ix < N);
            ix = lefts[left_ix].second;
            if (i > 0 && L[ix] < here) break;
        } else {
            while (visited[rights[right_ix].second]) right_ix++;
            assert(right_ix < N);
            ix = rights[right_ix].second;
            if (i > 0 && R[ix] > here) break;
        }
        visited[ix] = 1;
        ii mn = minmove(ix, here);
        move = mn.first;
        next = mn.second;

        here = next;
        side *= -1;
        res += move;
    }
    return res + abs(here);
}

ll solve() {
    lefts.resize(N);
    rights.resize(N);
    rep(i,N){
        lefts[i] = ii(L[i], i);
        rights[i] = ii(R[i], i);
    }
    sort(ALL(lefts)); reverse(ALL(lefts));
    sort(ALL(rights));


    ll ans = 0;
    {
        ans = max(ans, sub(-1));
    }
    {
        ans = max(ans, sub(1));
    }
    return ans;
}

int main() {
    scanf("%d", &N);
    L.resize(N);
    R.resize(N);
    rep(i,N) scanf("%d%d", &L[i], &R[i]);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 2948
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o set
const ll  MOD=1e9+7;
signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll n,k;  cin >> n >> k;
    ll ans=0;
    for(ll i=k;i<=n+1;i++){
        ll x=i*(i-1)/2;
        ll y=n*i-x;
        ans+=(y-x+1);
        ans%=MOD;
    }
    cout <<  ans << endl;
}


Measured memory_bytes: 3644
n,m=map(int,input().split())
mod=10**9+7
dp=[0]*(n+1)
dp[0]=1
a=set([int(input()) for _ in range(m)])

for i in range(1,n+1):
    if i in a:
        dp[i]=0
    else:
        dp[i]=dp[i-1]+dp[i-2]
        dp[i]%=mod
print(dp[n])

Measured memory_bytes: 13984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll n;
	long double a[110];
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	long double ans=a[0];
	for(int i=1;i<n;i++)ans=(ans+a[i])/2;
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
extern int compare_int(const void* , const void* );
 
main()
{ int i,j,cnt;
  int a[5];
 
  while(5 == scanf("%d,%d,%d,%d,%d",&a[0],&a[1],&a[2],&a[3],&a[4]))
  {      qsort(a,5,sizeof(int),compare_int ); 
 
         cnt = 0;
         for(i=0;i<4;i++)
           for(j=i+1;j<5;j++)
             cnt += (a[i]==a[j])?1:0;
/*   printf("cnt=%d\n",cnt); */
        if(cnt==1)
          printf("one pair\n");
        else if(cnt==2)
          printf("two pair\n");
        else if(cnt==3)
          printf("three card\n");
        else if(cnt==4)
          printf("full house\n");
        else if(cnt==6)
          printf("four card\n");
        else if((a[0]+1 == a[1] &&
           a[0]+2 == a[2] &&
           a[0]+3 == a[3] &&
           a[0]+4 == a[4])||
           (a[0] == 1 &&
            a[1] == 10 &&
            a[2] == 11 &&
            a[3] == 12 &&
            a[4] == 13 ))
          printf("straight\n");
        else
          printf("null\n");
  }
 
return(0);
}
 
int compare_int(const void* a, const void* b)
{
    return ( *(int*)a - *(int*)b );
}

Measured memory_bytes: 584