akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <set>
using namespace std;
#define INF 1010101010
#define MOD 1000000007
#define LL long long
 
int main() {
    char a, b;
    cin >> a >> b;
    bool h = a == 'H';
    bool t = b == 'H';
    cout << (!(h ^ t) ? 'H' : 'D') << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(void)
{
    int R, G;

    cin >> R;
    cin >> G;

    cout << (2 * G) - R << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	string str;
	cin >> str;
	int C=0,F=0;
	for(int i=0;i<str.size();i++)
	{
		if(str[i]=='C')
			C=1;
		if(str[i]=='F'&&C==1)
			F=1;
	}
	if(F==0)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
int mypow(int x,int n){
    int ans=1;
    while(n){
        if(n&1)
            ans=ans*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return ans;
}
int func(int n,int a){
    int foo=1,bar=1;
    for(int i=1;i<=a;i++)
        foo=foo*i%mod;
    for(int i=n-a+1;i<=n;i++)
        bar=bar*i%mod;
    return bar*mypow(foo,mod-2)%mod;
}
signed main(){
    int n,a,b;
    cin>>n>>a>>b;
    int tmp=1;
    cout<<(mypow(2,n)-1-func(n,a)-func(n,b)+mod*2)%mod<<endl;
}


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

#define ROOP(i,n) for(i=0;i<n;i++)

//prototype declaration
int getint();
long long getllint();
double getdint();
char getch();
void setstring(char *s);
void showint(int i);
void showllint(long long i);
void showdint(double i);
void showchar(char c);
void showstring(char *s);

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main(void) {
	int n, i, j;
	n = getint();
	int count[200] = {0};
	int ans = 0;
	for (j = 1; j <= n; j++) {
		for (i = 1; i <= j; i++) {
			if (i % 2 != 0) {
				if (j % i == 0) {
					count[j]++;
				}
			}
		}
		if (count[j] == 8) {
			ans++;
		}
	}
	showint(ans);
	return 0;
}

int getint() {
	int i;
	scanf("%d", &i);
	return i;
}

long long getllint() {
	long long i;
	scanf("%lld", &i);
	return i;
}

double getdint() {
	double i;
	scanf("%lf", &i);
	return i;
}

char getch() {
	char c;
	scanf("%c", &c);
	return c;
}

void setstring(char *s) {
	scanf("%s", s);
}

void showint(int i) {
	printf("%d\n", i);
}

void showllint(long long i) {
	printf("%lld\n", i);
}

void showdint(double i) {
	printf("%lf\n", i);
}

void showchar(char c) {
	printf("%c\n", c);
}

void showstring(char *s) {
	printf("%s\n", s);
}


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

int main(){
    char s[20], t[20];
    scanf("%s", s);
    scanf("%s", t);
    if(strlen(s)+1 != strlen(t)){
        printf("No\n");
        return 0;
    }
    for(int i = 0; i < strlen(s); i++){
        if(s[i]!=t[i]){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 1612
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X, Y;
    cin >> X >> Y;
    cout << X + (Y / 2) << endl;

    return 0;
}


Measured memory_bytes: 256
import sys

S = list(map(str, input()))

for x in range(0, len(S), 2):
    if(S[x]=='L'):
        print('No')
        sys.exit()

for y in range(1, len(S), 2):
    if(S[y]=='R'):
        print('No')
        sys.exit()

print('Yes')

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> k(M), p(M);
    vector<vector<ll>> s(M);
    REP(i, M)
    {
        cin >> k[i];
        REP(j, k[i])
        {
            ll temp;
            cin >> temp;
            temp--;
            s[i].push_back(temp);
        }
    }
    REP(i, M) cin >> p[i];

    ll ans = 0;
    ll countMax = (ll)pow(2, N);
    REP(i, countMax)
    {
        vector<bool> bit(N, false);
        int bitCount = 0;
        int num = i;
        while (num > 0)
        {
            if (num % 2 == 1) bit[bitCount] = true;
            bitCount++;
            num /= 2;
        }
        bool isOn = true;
        REP(j, M)
        {
            int countOn = 0;
            REP(l, k[j]) 
            {
                if (bit[s[j][l]]) countOn++;
            }
            if (countOn % 2 != p[j])
            {
                isOn = false;
                break;
            }
        }
        if (isOn) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;

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


int main(){
  ll n;
  cin >> n;
  vector<ll> a(5);
  rep(i, 5){
    cin >> a[i];
  }
  ll ans = 0;
  ll mi = a[0];
  rep(i, 5){
    mi = min(mi, a[i]);
  }

  ans += 4 + n / mi;
  if(n % mi > 0){
    ans++;
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {a: usize, b: usize};

    let mut v = vec![0, 1, 2, 3];

    v[a] = 0;
    v[b] = 0;
    v.sort();

    println!("{}", v.pop().unwrap())
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;



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

	priority_queue<int> pq;
	string com;
	int x;
	for (;;) {
		cin >> com;
		if (com[0] == 'i') {
			cin >> x;
			pq.push(x);
		}
		else if (com[1] == 'x') {
			cout << pq.top() << endl;
			pq.pop();
		}
		else break;
	}
}


Measured memory_bytes: 6912
import collections
h, w = list(map(int, input().split()))

s = []
for i in range(h):
    line = input()
    s.append(line)

ans = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            continue
        d = [[False for x in range(w)] for y in range(h)]

        stack = collections.deque()
        stack.append((i, j, 0))
        d[i][j] = True
        while stack:
            y, x, score = stack.popleft()
            if y > 0 and s[y-1][x] == '.' and not d[y-1][x]:
                stack.append((y-1, x, score+1))
                d[y-1][x] = True
            if x < w-1 and s[y][x+1] == '.' and not d[y][x+1]:
                stack.append((y, x+1, score+1))
                d[y][x+1] = True
            if y < h-1 and s[y+1][x] == '.' and not d[y+1][x]:
                stack.append((y+1, x, score+1))
                d[y+1][x] = True
            if x > 0 and s[y][x-1] == '.' and not d[y][x-1]:
                stack.append((y, x-1, score+1))
                d[y][x-1] = True
            if score > ans:
                ans = score
print(ans)


Measured memory_bytes: 3316
S = list(str(input()))

det = 0
N = len(S)

for i in range(N):
    if S[i] != S[N-i-1]:
        det = -1

M = (N-1)//2
for i in range(M):
    if S[i] != S[M-i-1]:
        det = -1

for i in range((N+1)//2,N):
    if S[i] != S[N-(i-(N+1)//2)-1]:
        det = -1

if det == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
using namespace std;
int h, w, v[105];
char a[105][105];
int main() {
	int i, j;
	cin>>h>>w;
	for(i=0; i<h; i++) cin>>a[i];
	for(j=0; j<w; j++) {
		for(i=0; i<h && a[i][j]=='.'; i++);
		if(i==h) v[j] = 1;
	}
	for(i=0; i<h; i++) {
		for(j=0; j<w && a[i][j]=='.'; j++);
		if(j<w) {
			for(j=0; j<w; j++) {
				if(!v[j]) printf("%c", a[i][j]);
			}
			puts("");
		}
	}
	return 0;
}

Measured memory_bytes: 256
import math

a, b, C = map(int, input().split())

c = math.sqrt(a**2 + b**2 - (2 * a * b* math.cos(math.radians(C))))
L = a + b + c # 周の長さ
s = L / 2 # 周の長さの半分
S = math.sqrt(s * (s - a) * (s - b) * (s - c))# 面積
h = (2 * S) / a
print("{}\n{}\n{}".format(S, L, h))


Measured memory_bytes: 5700
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main(){
    int K, X; cin >> K >> X;
    for(int i=-1000000; i<=1000000; i++){
        if(abs(X-i)<K) cout << i << " ";
    }
    cout << endl;
    return 0;
}





Measured memory_bytes: 256
import math
import sys
import os

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")


S = list(_S())
if S[-1]=='s':
    S.append('es')
else:
    S.append('s')
ans = S

print(''.join(ans))


Measured memory_bytes: 9128
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	var sumOdd, sumEven int
	for i, v := range s {
		if i%2 == 0 {
			if v != '0' {
				sumOdd++
			} else {
				sumEven++
			}
		} else {
			if v != '1' {
				sumOdd++
			} else {
				sumEven++
			}
		}
	}
	if sumOdd < sumEven {
		fmt.Println(sumOdd)
	} else {
		fmt.Println(sumEven)
	}
}


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

const int N = 2e5+7;
typedef long long LL;

int n,sum;
string s;

int quick(int a,int b,int mod)
{
	LL ans=1;
	while(b){
		if(b&1) ans = ans*a%mod;
		a = (LL)a*a%mod;
		b>>=1;
	}
	return ans;
}

int fun(int n){
	int ans=0;
	while(n){
		ans++;
		n  = n &(n-1);
	} return ans;
}

int main()
{
	cin>>n>>s;
	for(auto c :s) if(c=='1') sum++;
	int cnt1 = 0 ,cnt2 = 0, p1 = sum + 1 , p2 = sum - 1;
	
	for(int i=0;i<n;i++)
		if(s[i]=='1'){
			cnt1 = (cnt1 + quick(2,n-i-1,p1))%p1;
			if(p2!=0) cnt2 = (cnt2 + quick(2,n-i-1,p2))%p2;
		}
	int t,ans=0;
	for(int i=0;i<n;i++){
		ans=1;
		if(s[i]=='0')  t = (cnt1+quick(2,n-i-1,p1)+p1)%p1;
		else if(p2==0) {cout<<0<<"\n"; continue;}
		else t = (cnt2-quick(2,n-i-1,p2)+p2)%p2;
		if(!t) cout<<ans<<"\n";
		else {
			while(t) ans++,t = t%fun(t);
			cout<<ans<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    string ans  = "Three";
    for(int i=0;i<n;i++){
        string x;
        cin >> x;
        if(x == "Y"){
            ans = "Four";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

    int i;
    int from;
    int to;
    int tgt;
    int count = 0;

    scanf("%d %d %d", &from, &to, &tgt);
    
    for(i = from; i <= to; i++) {
        if(tgt % i == 0) {
            count++;
        }
    }

    printf("%d\n", count);

    return 0;
}

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

#define M 2000000
#define NTL (-1)
#define L 14

char H[M][L];

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

long long getkey(char str[]){
  long long sum=0,p=1,i;
  for(i=0;i<strlen(str);i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

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

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

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

Measured memory_bytes: 27952
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<long long> a(n), b;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	b = a;
	for (int i = 1; i < n; i++) {
		b[i] = b[i - 1] + a[i];
	}
	int ans = 1;
	for (int i = n - 2; i >= 0; i--) {
		if (b[i] * 2 >= a[i + 1]) ans++;
		else break;
	}
	cout << ans << endl;
	return 0;	
}


Measured memory_bytes: 1792
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

/* next combination */
int next_combination(int sub) {
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, D;
    cin >> N >> D;
    vector<vector<ll>> X(N, vector<ll>(D));
    REP(i, N) {
        REP(j, D) { cin >> X[i][j]; }
    }

    int k = 2;

    ll ans = 0;
    int bit = (1 << k) - 1;  // bit = {0, 1, 2}
    for (; bit < (1 << N); bit = next_combination(bit)) {
        /* ここに処理を書く */
        // bit の表す集合を求める
        vector<int> S;
        for (int i = 0; i < N; ++i) {
            if (bit & (1 << i)) {  // i が bit に入るかどうか
                S.push_back(i);
            }
        }
        ll dist=0;
        REP(i, D) {
            dist += (X[S[0]][i] - X[S[1]][i]) * (X[S[0]][i] - X[S[1]][i]);
        }
        debug((ll)sqrt(dist), sqrt(dist));
        if ((ll)sqrt(dist) - sqrt(dist) == 0) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 998244353
#define int long long



const int N=3005;
int a[N];
int dp[N][N];
int n;

int solve(int ind,int sum)
{
    //cout<<"here\n";
    if(sum==0)
    {
        return (n-ind+2);
    }
    
    if(sum<0)
    {
        
        return 0;
    }
    
    if(ind>n)
    { 
        //cout<<ind<<" "<<n<<endl;
        return 0;
    }
    
    if(dp[ind][sum]!=-1)
    {
        
        return dp[ind][sum];
    }
   
    int ans=0;
    
    int op1=solve(ind+1,sum);
   // deb(op1);
   
    int op2=solve(ind+1,sum-a[ind]);
     //deb(op2);
    ans=op1+op2;
    ans%=mod;
    dp[ind][sum]=ans;
    
    return ans;
    
}

int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    int sum;
    cin>>n>>sum;
    memset(dp,-1,sizeof dp);
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans+=solve(i,sum);
       // deb(ans);
    }
    cout<<ans%mod;
}

Measured memory_bytes: 71040
import numpy as np
import collections
import math
from decimal import *

a,b,c = map(int,input().split())


def fl(x):
    digits = 13
    form = '%.'+str(digits-1)+'e'
    return float((form % x))

answer=0
if(len(str(c))>5):
    if(Decimal(a).sqrt()+Decimal(b).sqrt()<Decimal(c).sqrt()):
        print("Yes")
        exit()
    else:
        print("No")
        exit()
else:
    if(fl(fl(np.sqrt(a))+fl(np.sqrt(b)))<fl(np.sqrt(c))):
        print("Yes")
        exit()
    else:
        print("No")
        exit()




Measured memory_bytes: 22248
#include<bits/stdc++.h>
using namespace std;
                    
                    
int main(){
	int K, A, B, c, k;
    cin >> K >> A >> B;
    string ans = "NG";
    c = 1;
    while(k <= B){
        k = K * c;
        if(k >= A && k <= B){
            ans = "OK";
        }
        c++;
    }

    cout << ans << endl;

    return 0;
            
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<utility>
#include<queue>
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef pair<int,pii> pip;
ll dp[2010][2010]={0};
int main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	queue<pip>q;
	rep(i,n){
		dp[i][1]=in[i];
		q.push(pip(1,pii(i,1)));
	}
	while(!q.empty()){
		pip a=q.front();pii b=a.second;q.pop();
		int s=b.first,t=b.first+b.second;
		if(t>=n)t-=n;s--;if(s==-1)s=n-1;if(t==n)t=0;
		if(a.first){
			if(in[s]<in[t])s=b.first;
			if(dp[s][b.second+1]<dp[b.first][b.second]){
				dp[s][b.second+1]=dp[b.first][b.second];
				if(b.second+1!=n)q.push(pip(0,pii(s,b.second+1)));
			}
		}else{//JOI
			rep(i,2){
				if(dp[s][b.second+1]<dp[b.first][b.second]+in[(i?t:s)]){
					dp[s][b.second+1]=dp[b.first][b.second]+in[(i?t:s)];
					if(b.second+1!=n)q.push(pip(1,pii(s,b.second+1)));
				}
				s=b.first;
			}
		}
	}
	ll out=0;
	rep(i,n)out=max(out,dp[i][n]);
	cout<<out<<endl;
}

Measured memory_bytes: 32672
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)

using namespace std;
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;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main() {
    ll n;
    cin >> n;
    ll res = 1000000000010;
    ll tmp = 0;
    for(ll i=1; i*i<=n; ++i) {
        if (n%i == 0) {
            tmp = (i-1)+(n/i)-1;
            res = min(tmp, res);
        }
    }
    cout << res << "\n";
}


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

int gcd(int m, int n){
  if(n==0)
   return m;

  return gcd(n, m%n);
}

int main(){
  int W, H , C;
  cin >> W >> H >> C;
  int g = gcd(W, H);
  cout << W/g*H/g*C << endl;
  return 0;
}



Measured memory_bytes: 3084
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>

using namespace std;

int main() {
	int i, j, k;
	int a, b;

	cin >> a >> b;

	if (a + b > 23) {
		cout << abs(24 - (a + b)) << endl;
	}
	else {
		cout << a + b << endl;
	}









	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
int a, b, c, d;
int main() {
  cin >> a >> b >> c >> d;
  if(d >= abs(c-a)) {
    cout << "Yes" << endl;
    return 0;
  }
  if( (d>=abs(b-a)) && (d>=abs(c-b)) ) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N = 1e3 + 5;
#define int long long int

int32_t main() {
    IOS ;
    // int t ; cin >> t ; while(t--) {}
    string str ; cin >> str ; 
    int res = 0, cnt = 0 ;
    for(int i=0; i<3; i++) {
        if(str[i] == 'R') cnt++ ; 
        else cnt = 0 ;
        res = max(res, cnt) ;
    }
    
    cout << res ;
    return 0 ;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e18;
const ll MOD = 1e9 + 7;


int main(){
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];

    vector<ll> s(n+1);
    rep(i, n) s[i+1] = v[i] + s[i];

    ll ans = INF;
    rep(i, n){
        ll tmp = abs(s[i] - (s[n] - s[i]));
        chmin(ans, tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

void makeMoveMap(string s, vector<int>& moveMap){
  int n = s.length();
  int left=0;
  REPS(i, n-1){
    if(s[i-1]==s[i])  continue;
    if(s[i-1]=='R'){
      for(int j=left; j<i; j++){
        moveMap[j] = i-j;
      }
    }else if(s[i-1]=='L'){
      for(int j=left; j<i; j++){
        moveMap[j] = abs(left-1-j);
      }
    }
    left = i;
  }

  for(int j=left; j<n; j++){
    moveMap[j] = abs(left-1-j);
  }
}

int main(){
  string s; cin >> s;
  int n = s.length();
  vector<int> line(n, 0);
  vector<int> move(n, 0);
  makeMoveMap(s, move);
  REP(i, n){
    int p = i;
    char c = s[p];
    int cnt = move[i];
    if(c=='L') p-=move[i];
    if(c=='R') p+=move[i];

    if(c=='R'&&cnt&1)       line[p-1]++;
    else if(c=='L'&&cnt&1)  line[p+1]++;
    else                    line[p]++;
  }
  REP(i, n) cout << line[i] << " ";
  cout << endl;
}


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

int n,a[3005];
LL dp[3005][3005][2];

LL doit(int fr,int to,int now) {
	if (fr > to) {
		return 0;
	}
	if (dp[fr][to][now] < 1e15) return dp[fr][to][now];
	if (now == 0) {
		dp[fr][to][now] = max(doit(fr+1,to,1-now)+a[fr], doit(fr,to-1,1-now)+a[to]);
	}
	else {
		dp[fr][to][now] = min(doit(fr+1,to,1-now)-a[fr], doit(fr,to-1,1-now)-a[to]);
	}
	return dp[fr][to][now];
}

int main() {
	scanf("%d",&n);
	for (int i=0; i<n; i++) {
		scanf("%d",&a[i]);
	}
	memset(dp,62,sizeof(dp));
	printf("%lld\n",doit(0,n-1,0));
	return 0;
}


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

int main() {
    long long N,K;
    cin >> N >> K;
    long long x=N%K;
    long long y=K-N%K;
    if(x<y){
        cout << x << endl;
    }
    else{
        cout << y << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define FI first
#define SE second
#define PB(a) push_back(a)
#define DEBUG(x) cerr << __LINE__ << ":" << #x << ": " << x << "\n";
#define SZ(x) ((int)(x).size())
#define SO(x) sizeof((x)) / sizeof((x)[0])
//#define int long long
using namespace std;
using lint = long long;
struct Fast{Fast(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};} fast;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
inline int in() {int x; cin >> x; return x;}
inline lint IN() {lint x; cin >> x; return x;}
inline void co(int a[], int n) {REP(i, n) cout << a[i] << " "; cout << "\n";}
//if (IO > 1e5){lint a;	scanf(%lld, &a);	printf("%lld\n", a);}

signed main(){
	int h = in();	int w = in();
	int a[h][w];	char temp;
	bool ch = true;	bool cw[h];
	REP(i,h) cw[i] = true;
	REP(i,h){
		REP(j,w){
			cin >> temp;
			if (temp == '.'){
				a[i][j] = 1;
			}else{
				a[i][j] = 2;
				cw[i] = false;
			}
		}
		if (cw[i] == true){
			REP(k,w) a[i][k] = 0;
		}
	}
	
	REP(j,w){
		REP(i,h){
			if (a[i][j] == 2) ch = false;
		}
		if (ch == true){
			REP(k,h) a[k][j] = 0;
		}else{
			ch = true;
		}
	}
	
	/*
	REP(i,h){
		REP(j,w){
			cout << a[i][j];
		}
		cout << "\n";
	}
	*/
	
	REP(i,h){
		REP(j,w){
			if (a[i][j] == 1){
				cout << '.';
			}else if (a[i][j] == 2){
				cout << '#';
			}
		}
		//cout << cw[i];
		if (cw[i] == false) cout << "\n";
	}
return 0;
}


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

using namespace std;

int m;
int x[17], y[17];
int dp[1<<16];
bool dp2[1<<16];
int size[1<<16];

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

int check(int i, int j, int k, int l)
{
  if(x[i] == x[j] || x[k] == x[l]){
    if(x[i] == x[j] && x[k] == x[l]) return 1;
    else return 0;
  }

  int dx1 = x[i] - x[j], dy1 = y[i] - y[j];
  int dx2 = x[k] - x[l], dy2 = y[k] - y[l];
  if(dy1 == 0 || dy2 == 0){
    if(dy1 == 0 && dy2 == 0) return 1;
    else return 0;
  }

  int d1 = gcd(abs(dx1), abs(dy1)), d2 = gcd(abs(dx2), abs(dy2));
  if(dx1 < 0) dx1 *= -1, dy1 *= -1;
  if(dx2 < 0) dx2 *= -1, dy2 *= -1;
  if(dx1/d1 == dx2/d2 && dy1/d1 == dy2/d2) return 1;
  else return 0;
}

int comb(int x){
  return x * (x-1) / 2;
}

int main(void)
{
  cin >> m;
  for(int i = 0; i < m; i++) cin >> x[i] >> y[i];

  int S = 1<<m;
  for(int i = 0; i < S; i++){
    for(int j = 0; j < m; j++) if(i & (1<<j)) size[i]++;
  }

  dp2[0] = true;
  for(int i = 1; i < S; i++){
    if(size[i] % 2) continue;
    int x;
    for(int j = 0; j < m; j++){
      if(i & (1<<j)){
        x = j;
        break;
      }
    }
    for(int j = x+1; j < m; j++){
      int s = i;
      s &= ~(1<<x), s &= ~(1<<j);
      for(int k = 0; k < m; k++){
        if((s & (1<<k)) == 0) continue;
        bool flag = false;
        for(int l = k+1; l < m; l++){
          if((s & (1<<l)) == 0) continue;
          if(!check(x, j, k, l)) continue;
          s &= ~(1<<k), s &= ~(1<<l);
          flag = true;
          break;
        }
        if(!flag) goto ng;
      }
      dp2[i] = true;
      break;
      ng:;
    }
  }

  for(int i = 1; i < S; i++){
    if(dp2[i]) dp[i] = comb(size[i]/2);
    for(int j = (i-1)&i; j > 0; j = (j-1)&i){
      if(!dp2[j]) continue;
      dp[i] = max(dp[i], comb(size[j]/2) + dp[i & ~j]);
    }
  }
  cout << dp[S-1] << endl;

  return 0;
}



Measured memory_bytes: 3652
li = []

for i in range(3):
  li.append(list(input()))

def game(li):
  temp = li[0][0]
  li[0].pop(0)
  for i in range(100**3):
    if temp == "a":
      if not len(li[0]) == 0:
        temp = li[0].pop(0)
      else:
        return temp.upper()
    elif temp == "b":
      if not len(li[1]) == 0:
        temp = li[1].pop(0)
      else:
        return temp.upper()
    elif temp == "c":
      if not len(li[2]) == 0:
        temp = li[2].pop(0)
      else:
        return temp.upper()

print(game(li))

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

int main(){
int a,b,c,d;
  cin >> a >> b >> c >> d;
 int X = b-a;
  int Y = c-b;
  int Z = c-a;
  if(X<0)X *= -1;
  if(Y<0)Y *= -1;
  if(Z<0)Z *= -1;
  if(X<=d&&Y<=d)cout << "Yes" << endl;
  else if(Z<=d)cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int m = a + 1;
	int result = 0;
	while (m <= b) {
		if (m >= c + 1 && m <= d) {
			result++;
		}
		m++;
	}
	cout << result;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define ll  long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define BS binary_search
#define WW 100000
#define INF 1000000000000000000

 //1e18
//get<a>(t) gives ath element of tuple named t, numbering starts from 0
//max({__}) can give maximum of any number of elements. Similarly min also.
//don't forget to initialise freq arrays
int32_t main()
{
    IOS;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int countt=0;
    int counta=0;
    while(c>0){
        countt++;
        c-=b;
    }
    while(a>0){
        counta++;
        a-=d;
    }
    if(countt<=counta)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    boolean check = false;
    loop: for (int i = 1; i < 10; i++) {
      for (int j = 1; j < 10; j++) {
        if (i * j == n) {
          check = true;
          break loop;
        }
      }
    }
    System.out.println(check ? "Yes" : "No");
  }
}


Measured memory_bytes: 23892
/**
 *    author:  tootal    
 *    created: 2020/04/11 15:55:30
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << x2 + y1 - y2 << ' ';
    cout << x2 + y2 - x1 << ' ';
    cout << x1 + y1 - y2 << ' ';
    cout << x2 + y1 - x1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define REPA(x, v) for(auto&& x:v)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(v.rbegin(),v.rend())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string S,T;
    cin >> S >> T;
    int n = S.size();
    int m = T.size();
    bool f2 = false;
    // REP(i, n-m+1){
    for(int i = n-m; i >= 0 ;i--){
        bool f = true;
        REP(j, m){
            if(S[i+j]=='?') continue;
            if(S[i+j]!=T[j]){
                f = false;
                break;
            }
        }
        if(f){
            REP(j, m){
                S[i+j] = T[j];
            }
            f2 = true;
            break;
        }
    }
    if(f2){
        REP(i, n){
            if(S[i]=='?') S[i] = 'a';
        }
        pr(S);
    }else{
        pr("UNRESTORABLE");
    }
}

Measured memory_bytes: 3628
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 11100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

int main(){
	int a;scanf("%d",&a);
	long long ret=0;
	for(int i=1;i<=a;i++)ret+=(long long)i*(a-i+1);
	for(int i=0;i<a-1;i++){
		int p,q;scanf("%d%d",&p,&q);
		if(p>q)swap(p,q);
		ret-=(long long)p*(a-q+1);
	}
	printf("%lld\n",ret);
}

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

 ll modpow(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}
 
int main(){
  
int n;
  cin >> n;
  ll ans = (modpow(10,n)-2*modpow(9,n)+modpow(8,n))%mod;
  if(ans<0)
    ans+=mod;
  
  cout << ans << endl;
  
  
}




Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<random>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

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

int main() {
	init();
	
	int N; cin >> N;
	ll ans = 0;
	rep(i, 0, N) {
		int a; cin >> a;
		ans += a - 1;
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define RI(x) x = rit()
#define RII(a,b) a = rit(), b = rit()
#define RIII(a,b,c) a = rit(), b = rit(), c = rit()
#define RIIII(a,b,c,d) a = rit(), b = rit(), c = rit(), d = rit()
#define REP(I, N) for(int I=0;I<int(N);I++)
#define REPP(I, N) for(int I=1;I<=int(N);I++)
inline int rit(){
    int f=0,key=1;
    char ch;
    do{
        ch = getchar();
        if(ch=='-') key=-1;;
    }while(ch<'0'||ch>'9');
    do{
        f = f*10+ch-'0';
        ch = getchar();
    }while(ch>='0'&&ch<='9');
    return f*key;
}
using namespace std;
int main(void){
    int sx,sy,tx,ty;
    RIIII(sx,sy,tx,ty);
    int x=sx, y=sy;
    string a,b;
    while(y<ty) a+="U", y++;
    while(x<tx) a+="R", x++;
    while(y>sy) b+="D", y--;
    while(x>sx) b+="L", x--;
    printf("%s%sLU%sRDRD%sLU\n",a.c_str(),b.c_str(),a.c_str(),b.c_str());
}


Measured memory_bytes: 256
from collections import Counter

n = int(input())
a = [int(i) for i in input().split()]
c = Counter(a)
ck = list(c.keys())
cv = list(c.values())
ans = 0

for i in range(0,len(ck)):
    if ck[i]>cv[i]:
        ans += cv[i]
    elif ck[i]<cv[i]:
        ans += cv[i] - ck[i]
print(ans)


Measured memory_bytes: 18672
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-06-05 17:38:28
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

#if __cplusplus >= 201703L
template <class Ch, class Tr, class Tuple, std::size_t... Is>
void tuple_out(std::basic_ostream<Ch, Tr>& os, const Tuple& tp, std::index_sequence<Is...>) {
  ((os << (Is ? ", " : "(") << std::get<Is>(tp)), ...) << ")";
}

template <class Ch, class Tr, class... Args>
auto& operator<<(std::basic_ostream<Ch, Tr>& os, const std::tuple<Args...>& tp) {
  tuple_out(os, tp, std::index_sequence_for<Args...>{});
  return os;
}
#endif

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class Compare>
std::ostream& operator<<(std::ostream& os, const std::set<T, Compare>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U, class Compare>
std::ostream& operator<<(std::ostream& os, const std::map<T, U, Compare>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

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

  int n; cin >> n;
  string s; cin >> s;
  int beg = count(all(s), '(');
  int ed = n - beg;

  int cnt = 0;
  int mx = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == ')') {
      ++cnt;
      mx = max(mx, cnt);
    } else {
      --cnt;
    }
  }

  for (int i = 0; i < mx; ++i) cout << '(';
  cout << s;
  for (int i = 0; i < mx + beg - ed; ++i) cout << ')';
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb(a) push_back(a)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;
using P  = pair<int,int>;
using vP = vector<P>;
const int INF = 1001001001;

int main(){
    int n;
    cin>>n;
    
    vector<ll> a(n);
    //map<int,ll> m;
    rep(i,n)cin>>a[i], a[i]--;
    
    vector<ll> m(n,0);
    rep(i,n)m[a[i]]++;
    
    ll ans = 0;
    /*
    for(auto p: m){
        ans += p.second*(p.second-1)/2;
    }
    */
    
    rep(i,n)ans += m[i]*(m[i]-1)/2;
    
    for(int i=0; i<n; i++){
        cout << ans -( m[a[i]] - 1 ) << endl;
    }
    
    return 0;
}

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

int main(void){
    int n; cin >> n;
    vector<bool> a(n + 2, true);
    for(int i = 1; i <= n; i++){
        int in;
        cin >> in;
        if(in == i) a[i] = false;
    }

    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(!a[i]){
            ans++;
            a[i + 1] = true;
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n; cin>>n;
	string s; cin>>s;
	string s2=s;
	string ans=s;
	int a=0,b=0;
	rep(i,0,n){
		if(s[i]==')') continue;
		bool k=true;
		rep(j,i+1,n){
			if(s2[j]==')'){
				k=false;
				s2[j]='!';
				break;
			}
		}
		if(k) a++;
	}
	reverse(all(s));
	s2=s;
	rep(i,0,n){
		if(s[i]=='(') continue;
		bool k=true;
		rep(j,i+1,n){
			if(s2[j]=='('){
				k=false;
				s2[j]='!';
				break;
			}
		}
		if(k) b++;
	}
	//cout<<a<<" "<<b;
	rep(i,0,a) ans.push_back(')');
	reverse(all(ans));
	rep(i,0,b) ans.push_back('(');
	reverse(all(ans));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
    #include <string>
    #include <vector>
    #include <iostream>
    #include <algorithm>
    const int maxn = 110;
    const int mod = 1e9 + 7;
    using namespace std;
     
    vector<int> vi[4];
    long long sum[4][maxn];
    int main()
    {
    	int i, j, k, N, W, w[maxn], v;
    	cin >> N >> W;
    	for (i = 0; i < N; i ++)
    	{
    		cin >> w[i] >> v;
    		vi[w[i] - w[0]].push_back(v);
    	}
    	for (i = 0; i < 4; i ++)
    	{
    		sum[i][0] = 0;
    		if (vi[i].size() > 0)
    		{
    			sort(vi[i].begin(), vi[i].end(), greater<int>());
    			for (j = 0; j < vi[i].size(); j ++)
    			{
    				sum[i][j + 1] = sum[i][j] + vi[i][j];
    			}
    		}
    	}
    	long long ans = 0;
    	
    	for (i = 0; w[0] * i <= W && i <= vi[0].size(); i ++)
    	{
    		int t1 = W - w[0] * i;
    		long long v1 = sum[0][i];
     
    		for (j = 0; (w[0] + 1) * j <= t1 && j <= vi[1].size(); j ++)
    		{
    			long long v2 = v1 + sum[1][j];
    			int t2 = t1 - (w[0] + 1) * j;
    			for (k = 0; (w[0] + 2) * k <= t2 && k <= vi[2].size(); k ++)
    			{
    				int t3 = t2 - (w[0] + 2) * k;
    				long long v3 = v2 + sum[2][k] + sum[3][t3 / (w[0] + 3)];
    				if (v3 > ans)
    					ans = v3;
    			}
    		}
    	}
    	cout << ans;
    	return 0;
    }

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

int main() {
long long int n,ans;
 cin >> n;
  for(int i=n;i>0;i--){
    long long int mint=sqrt(i);
    long double mflt=sqrt(i);
       if(mint==mflt){
       ans=i;
       break;
       }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    string str;
    cin >> str;
    int ans=0;
    int memo=0;
    for(int i=0; i<n; i++){
        if(str[i]=='I'){
            memo++;
        }else{
            memo--;
        }
        ans = max(ans, memo);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	int n;
	int b, f, r, v;
	int room[4][3][10];
	for (int j = 0; j < 4; j++){
		for (int k = 0; k < 3; k++){
			for (int l = 0; l < 10; l++){
				room[j][k][l] = 0;
			}
		}
	}
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> b >> f >> r >> v;
		room[b-1][f-1][r-1] += v;
	}
	for (int j = 0; j < 4; j++){
		for (int k = 0; k < 3; k++){
			for (int l = 0; l < 10; l++){
				cout <<" " << room[j][k][l];
			}
			cout << endl;
		}
		if(j != 3){for (int m = 0; m < 20; m++){
			cout << "#";
		}
		cout << endl;}
	}

	return 0;
}

Measured memory_bytes: 1164