akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define ll long long

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "YES"
#define FALSE__ "NO"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

signed main()
{
	string a, b, c;
	cin >> a >> b >> c;
	int la = a.length();
	int lb = b.length();
	PRINT(a[la-1] == b[0] && b[lb-1] == c[0]);
}



Measured memory_bytes: 256
#include<stdio.h>

#define ABMAX 2000000
#define CMAX 10000

long gn;
 
void countingSort( short A[], short B[], short k )
{
	long i,j;
	int C[CMAX+1];

	for( i=0; i<=k; i++ ) {
		C[i]=0;
	}
	for( j=1; j<=gn; j++ ) {
		C[ A[j] ]=C[ A[j] ]+1;
	}

	for( i=1; i<=k; i++ ) {
		C[i]=C[i]+C[ i-1 ];
	}

	for( j=gn; 0<j; j-- ) {
		B[ C[ A[j] ] ]=A[j];
		C[ A[j] ]=C[ A[j] ]-1;
	}

	return;
}


int main( void ) 
{	
	long i;
	short A[ABMAX+1];
	short B[ABMAX+1];
	short k;
		
    scanf( "%ld", &gn );
	k=0;
	for( i=1; i<=gn; i++ ) {
		scanf( "%hd", &A[i] );
		if( k < A[i] ) {
			k=A[i];
		}
	}
	countingSort( A, B, k );
	for( i=1; i<=gn; i++ ) {
		printf( "%hd", B[i] );
		if( i < gn ) {
			printf( " " );
		}
	}
	printf( "\n" );

    return 0;
}

Measured memory_bytes: 8452
N, K = [int(s) for s in input().split()]

def check_digits(n, k):
    if k == 10:
        return len(str(n))
    
    count = 0
    while n > 0:
        n //= k
        # print(n)
        count += 1
    return count

print(check_digits(N, K))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define sset(s) cout<<#s<<":";each(i,s)cout <<" "<<i;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

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

int main()
{
    while(1){
        string s;
        cin >> s;
        if(s == "#"){
            break;
        }
        int i = 0;
        vector<int> vec;
        while(i < s.length()){
            if(s[i] == 'n'){
                vec.pb(-1);
                i += 5;
            }else{
                vec.pb(1);
                i += 4;
            }
        }
        int a1 = 0;
        int a2 = pow(2,vec.size()-1);
        for(int i = vec.size()-1;i>=0;i--){
            if(vec[i] > 0 || a1 > 0){
                a1 += pow(2,i)*vec[i];
            }
        }
        if(a1 == 0){
            cout << "0\n";
        }else{
            a1 *= 90;
            int hoge = gcd(a1,a2);
            a1 /= hoge;
            a2 /= hoge;
            if(a2 ==1){
                cout << a1 << "\n";
            }else{
                cout << a1 << "/" << a2 << "\n";
            }
        }
    }
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18

int main() {
    int n ;
    cin >> n ;
    vector<int> a (n) ;
    vector<ll> b (200005) ;
    ll tot = 0 ;
    rep(i, n){
        cin >> a[i] ;
        b[a[i]]++ ;
    }
    rep(i, 200005){
        tot += (b[i] * (b[i] - 1))/ 2 ;
    }
    vector<ll> ans ;
    rep(i, n){
        ll t = b[a[i]] ;
        ll nw = tot - (t*(t - 1))/2 ;
        nw += (t-1)*(t-2)/2 ;
        ans.push_back(nw) ;
    }
    rep(i, n){
        cout << ans[i] << endl ;
    }
    return 0 ;
}  

Measured memory_bytes: 7712
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = (int)1e5 + 10;

int n, m, p[N], d[N], g[N];
VI child[N], pref[N], suf[N];

void dfs1(int v) {
  d[v] = 1;
  for (int i = 0; i < child[v].size(); ++i) {
    int c = child[v][i];
    if (c == p[v]) {
      if (pref[v].size() == 0)
        pref[v].PB(1);
      else
        pref[v].PB(pref[v].back());
    }
    else {
      p[c] = v;
      dfs1(c);
      d[v] = (d[v]*(1+d[c]))%m;
      if (pref[v].size() == 0)
        pref[v].PB(d[v]);
      else
        pref[v].PB((pref[v].back()*(1+d[c]))%m);
    }
  }
  for (int i = child[v].size()-1; i >= 0; --i) {
    int c = child[v][i];
    if (c == p[v]) {
      if (suf[v].size() == 0)
        suf[v].PB(1);
      else
        suf[v].PB(suf[v].back());
    }
    else {
      if (suf[v].size() == 0)
        suf[v].PB((1+d[c])%m);
      else
        suf[v].PB((suf[v].back()*(1+d[c]))%m);
    }
  }
  reverse(suf[v].begin(), suf[v].end());
}

void dfs2(int v) {
  if (v == 1)
    g[v] = 0;
  if (v != 1) {
    int oj = p[v];
    g[v] = 1+g[oj];
    int x1 = 0, x2 = pref[oj].size()-1, x3;
    while (x2-x1 > 1) {
      x3 = (x1+x2)/2;
      if (child[oj][x3] <= v)
        x1 = x3;
      else
        x2 = x3;
    }
    int co = x1;
    if (child[oj][x2] == v)
      co = x2;
    if (co > 0)
      g[v] = (g[v]*pref[oj][co-1])%m;
    if (co+1 < suf[oj].size())
      g[v] = (g[v]*suf[oj][co+1])%m;
  }
  for (int c: child[v])
    if (c != p[v])
      dfs2(c);
}

signed main() {
  init_ios();
  cin >> n >> m;
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    child[x].PB(y);
    child[y].PB(x);
  }
  for (int i = 1; i <= n; ++i)
    sort(child[i].begin(), child[i].end());
  dfs1(1);
  dfs2(1);
  for (int i = 1; i <= n; ++i) {
    if (i == 1)
      cout<<d[i]<<"\n";
    else
      cout<<(d[i]*(1+g[i]))%m<<"\n";
  }
}

Measured memory_bytes: 27136
s = list(input())
flag = True
for i, fs in enumerate(s):
    i += 1
    if not((i%2 == 0 and fs in ("L","U","D")) or (i%2 == 1 and fs in ("R","U","D"))):
        flag = False
if flag:
    print("Yes")
else:
    print("No")

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

int main()
{
    char a,b;
    cin>>a>>b;
    int aa=(int)a;
    int bb=(int)b;

    if(a>b)
    {
        printf(">\n");
    }
    else if(a<b)printf("<\n");
    else printf("=\n");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int N, K; cin >> N >> K;
  vi A(N); rep(i,N) cin >> A[i];

  int ans = 0;
  int right = 0;
  while(true) {
    if (ans == 0) right += K;
    else right += K-1;
    ans++;

    if (right >= N) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int factorial(int x){
    int tmp = 1;
    for (int i = 0; i < x; i++){
        tmp *= (i + 1);
    }
    return tmp;
}

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

    vector<int> vec(n);
    for(int i = 0; i < n; i++){
        vec.at(i) = i+1;
    }

    int wanted;

    int a = 0;
    for (int i = 0; i < n; i++){
        cin >> wanted;

        vector<int>::iterator itr;
        itr = find(vec.begin(), vec.end(), wanted);
        int wanted_index = distance(vec.begin(), itr);
        vec.erase(vec.begin() + wanted_index);

        a += factorial(n-1-i)*wanted_index;
    }

    a += 1;

    // cout << a << endl;

    vector<int> vec2(n);
    for(int i = 0; i < n; i++){
        vec2.at(i) = i+1;
    }

    wanted = 0;
    
    int b = 0;
    for (int i = 0; i < n; i++){
        cin >> wanted;

        vector<int>::iterator itr;
        itr = find(vec2.begin(), vec2.end(), wanted);
        int wanted_index = distance(vec2.begin(), itr);
        vec2.erase(vec2.begin() + wanted_index);

        b += factorial(n-1-i)*wanted_index;
    }

    b += 1;
    cout << abs(a-b) << endl;

    // cout << wanted_index << endl;

}

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

typedef long long int int64;

const int mod=998244353;

int modPow(int r,int n){
  int t=1;
  int s=r;
  while(n>0){
    if(n&0x01) t=(int64)t*s%mod;
    s=(int64)s*s%mod;
    n>>=1;
  }
  return t;
}

int *fact=NULL;
int *iFact=NULL;
void init(int n){
  fact=(int *)calloc(n+1,sizeof(int));
  iFact=(int *)calloc(n+1,sizeof(int));
  fact[0]=1;
  int i;
  for(i=1;i<=n;i++) fact[i]=(int64)i*fact[i-1]%mod;
  iFact[n]=modPow(fact[n],mod-2);
  for(i=n-1;i>=0;i--) iFact[i]=(int64)(i+1)*iFact[i+1]%mod;
  return;
}

int comb(int n,int k){
  if(!(0<=k && k<=n)) return 0;
  return (int64)fact[n]*iFact[k]%mod*iFact[n-k]%mod;
}

void run(void){
  int k,n;
  scanf("%d%d",&k,&n);
  init(2*(n+k));
  int i;
  for(i=2;i<=2*k;i++){
    int64 ans=0;
    if(i%2!=0){
      int p=0;
      for(int j=1,l=i-1;j<=l;j++,l--) if(j<=k && l<=k) p++;
      for(int q=0;q<=p;q++){
	ans+=(int64)comb(p,q)*modPow(2,q)%mod*comb(n-q+(k-(2*p-q))-1,k-(2*p-q)-1)%mod;
	ans%=mod;
      }
    } else {
      int p=0;
      for(int j=1,l=i-1;j<l;j++,l--) if(j<=k && l<=k) p++;
      for(int q=0;q<=p;q++){
	ans+=(int64)comb(p,q)*modPow(2,q)%mod*comb(n-q+(k-1-(2*p-q))-1,k-1-(2*p-q)-1)%mod;
	ans%=mod;
	ans+=(int64)comb(p,q)*modPow(2,q)%mod*comb(n-1-q+(k-1-(2*p-q))-1,k-1-(2*p-q)-1)%mod;
	ans%=mod;
      }
    }
    printf("%lld\n",ans);
  }
}

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


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

int main() {
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    string c;
    cin >> c;
    if(c=="Y"){
      cout << "Four" << endl;
      break;
    }
    if(i==n-1){
      cout << "Three" << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

N = iin()
A = iln()

isOK = True
for i in range(N):
    if A[i] % 2 == 0:
        if not (A[i] % 3 == 0 or A[i] % 5 ==0):
            isOK = False
            break
if isOK:
    print('APPROVED')
else:
    print('DENIED')



Measured memory_bytes: 5812
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;

int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  ////////////
  ll ans=0;
  if(a==b) {
    cout<<1<<endl;
    return 0 ;
  }
  if(b<a){
    cout<<ans<<endl;
   return 0 ; 
  }
  if(n==1) {
    cout<<0<<endl; 
    return 0;
  }
  ans++;
  ans+=b*(n-1)+a-(a*(n-1)+b);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  /* code */
  int n ;
  int cnt = 1;
  string s;
  cin >> n >> s;
 
  for (int i = 0; i < n-1; i++)
  {
    if (s[i] == s[i+1])
    {
      
    }else{
      cnt ++;
    } 
  }  
  cout << cnt << "\n" ;
  return 0;
}


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

int power(int b, int e, int mod) {
    if (e == 0) return 1;
    int x = power(b, e >> 1, mod);
    x = 1LL * x * x % mod;
    if (e & 1)
        x = 1LL * x * b % mod;

    return x;
}


long long modInverse(long long a, int m)
{
    return power(a, m-2, m);
}


int n, a, b, m;
long long ans, mod = 1e9 + 7, fact[200005], ifact[200005];
long long solve(int N, int r){
    if (N < r)
        return 0;
//    cout << N << ' ' << r << endl;
    long long denum = (ifact[N-r] * ifact[r])%mod;
    return (fact[N]*denum)%mod;
}

int main(){
    cin >> n >> m >> a >> b;
    fact[0] = 1;
    ifact[0] = modInverse(1, mod);
    for(int i = 1; i<=200000; i++) {
        fact[i] = fact[i - 1] * i % mod;
        ifact[i] = modInverse(i, mod)*ifact[i-1], ifact[i]%=mod;
    }
    int js = b, je = m - 1, ie = n - 1;
    for(int i = 0; i < n-a; i++){
        ans+=(solve(js - 1 + i, js - 1) * solve(je - js + ie - i, je - js)) % mod;
        ans%=mod;
//        cout << je - js + ie - i << ' ' <<  je - js << ' ' << solve(je - js + ie - i, je - js) << endl;
    }
    cout << ans;
}

Measured memory_bytes: 3328
n=gets.to_i
l=[]
n.times do
  l << []
end
(n-1).times do |i|
  a,b=gets.split.map(&:to_i)
  l[a-1] << b-1
  l[b-1] << a-1
end
c=gets.split.map(&:to_i).sort.reverse
s=[0]
v=[nil]*n
v[0]=c[0]
vi=1
while s!=[]
  z=[]
  s.each do |ss|
    l[ss].each do |lss|
      if v[lss]==nil
        v[lss]=c[vi]
        vi+=1
        z << lss
      end
    end
  end
  s=z.dup
end
puts c[1..n-1].sum
puts v.join(" ")


Measured memory_bytes: 16076
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main(){
    int n; cin >> n;
    string s,t; cin >> s >> t;
    rep(i,n){
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;

#define pll pair<ll,ll>
#define ff first
#define snd second
#define pb push_back
#define vll vector<ll>
#define vpll vector<pll>
#define endl "\n"
#define MOD 1000000007
using namespace std;

ll const N = 1e5+1;


void solve()
{
  ll n;
  cin>>n;
  ll a,b;
  cin>>a>>b;
  ll p = b/n;
  ll k = (a-1)/n;
  if(p-k>0)
  {
        cout<<"OK";  
  }
  else
  {
        cout<<"NG";  
  }
}
 
int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
	    int t=1;
	    //cin>>t;
	    while(t--)
	    {
	            solve();
	    }
	    return 0;
}

Measured memory_bytes: 3612
@s=split//,<>;@t=split//,<>;
@a=(LESS,GREATER,EQUAL);
if(@s!=@t){
	print$a[@s>@t];
}
else{
	$f=$a[2];
	for(0..@s-2){
		if($s[$_]!=$t[$_]){
			$f=$a[$s[$_]>$t[$_]];
			last;
		}
	}
	print$f
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define inf 100000000000000000
#define mod 1000000007
#define MAX 100005
#define pb push_back
#define vit vector<int>::iterator
typedef pair<lint,lint> pii;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    lint n,m,s;
    cin>>n>>m>>s;
    if(m*s>=n) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3652
#![allow(unused)]
use std::io::{self, Read};

fn get_stdin() -> String {
    let mut buf = String::new();
    let mut stdin = io::stdin();
    stdin.read_to_string(&mut buf);
    return buf
}

fn to_nums(ss: &str) -> Vec<i32> {
    ss.split_whitespace()
        .map(|x| x.parse::<i32>().unwrap())
        .collect()
}

fn main() {
    let input = get_stdin();
    let v = to_nums(&input);
    let a = v[0];
    let b = v[1];
    let d = a / b;
    let r = a % b;
    let f = (a as f64) / (b as f64);
    println!("{} {} {:.5}", d, r, f);
}



Measured memory_bytes: 5048
def solve(eq)
  m = []
  m << eq[0..2]
  m << eq[3..5]

  # 前進消去
  r0 = m[0][0]
  m[0].map! {|x| x / r0}
  r1 = -m[1][0]
  m[1].map!.with_index {|x, i| x + r1 * m[0][i]}

  # 後退消去
  r1 = m[1][1]
  m[1].map! {|x| x / r1}
  r0 = -m[0][1]
  m[0].map!.with_index {|x, i| x + r0 * m[1][i]}

  [m[0][2], m[1][2]]
end

eqs = ARGF.each_line.map {|line| line.split(" ").map {|v| v.to_f}}

eqs.each do |eq|
  solution = solve(eq)
  puts solution.map {|x| "%.3f".%(x)}.join(" ")
end

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

int func(int N, int t, int b) {
  long ans = 0;
  if (t == b) {
    if (t <= N) {
      ans++;
    }
  }
  int num = (b * pow(10, 1)) + t;
  if (num > N) {
    return ans;
  }
  ans++;
  for (int i = 0; i < 10; i++) {
    int num = (b * pow(10, 2)) + (i * pow(10, 1)) + t;
    if (num > N) {
      return ans;
    }
    ans++;
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      int num = (b * pow(10, 3)) + (i * pow(10, 2)) + (j * pow(10, 1)) + t;
      if (num > N) {
        return ans;
      }
      ans++;
    }
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        int num = (b * pow(10, 4)) + (i * pow(10, 3)) + (j * pow(10, 2)) + (k * pow(10, 1)) + t;
        if (num > N) {
          return ans;
        }
        ans++;
      }
    }
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        for (int l = 0; l < 10; l++) {
        int num = (b * pow(10, 5)) + (i * pow(10, 4)) + (j * pow(10, 3)) + (k * pow(10, 2)) + (l * pow(10, 1)) + t;
        if (num > N) {
          return ans;
        }
        ans++;
        }
      }
    }
  }
  return ans;
}

int main() {

  int N = 0;
  cin >> N;

  int top = 0;
  int bottom = 0;

  long ans = 0;

  for (int i = 1; i <= N; i++) {
    int tmp = i;
    bottom = tmp % 10;
    while (tmp / 10 != 0) {
      tmp /= 10;
    }
    top = tmp;
    if (bottom != 0) {
      ans += func(N, top, bottom);
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main(){
    long long h;
    cin>>h;
    long long ans=0;
    long long cur=1;
    while(h>0){
        h/=2;
        ans+=cur;
        cur*=2;
    }
    
    cout<<ans<<endl;
}
    

Measured memory_bytes: 3616
//#include <bits/stdc++.h>                          //include all library
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <string.h>
#include <functional> // greater<int> はfunctionalヘッダ
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)          //REP(i, 10){...} //i=0～i=9までのループ
#define REPR(i, n) for(int i = n;i >= 0;i--)        //REPR(i, 10){...} //i=10～i=0までのループ
#define FOR(i, m, n) for(int i = m;i < n;i++)       //FOR(i, 3, 10){...} //i=3～i=9までのループ
#define FORR(i, m, n) for(int i = m;i >= n;i--)     //FORR(i, 10, 3){...} //i=10～i=3までのループ
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define PI 3.141592653589
#define npos -1


int main(){
	int a, p;
	cin >> a >> p;

	cout << (3*a + p)/2 << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        new Main().A();
    }

    void A(){
        int N;
        
        Scanner sc=new Scanner(System.in);

        N=sc.nextInt();

        int[] P=new int[N];

        for(int i=0;i<N;i++){
            P[i]=sc.nextInt();
        }

        int a=1;

        int min=P[0];

        for(int i=1;i<N;i++){
            if(min>P[i]){
                a++;
                min=P[i];
            }
        }

        System.out.println(a);
    }
}

Measured memory_bytes: 64508
#
import sys
import math
import numpy as np
import itertools

# ひとつ入力
l = int(input())
a=[]
n=0
while l > 0:
    a.append(l%2)
    l=l//2
    n += 1
#print(a,n)
aa=0
for k in range(n):
    aa += a[k]
print(n,2*(n-1)+aa-1)
for k in range(1,n):
    print(k,k+1,0)
    print(k,k+1,2**(k-1))
p=2**(n-1)
for k in range(n-2,-1,-1):
    if a[k]==1:
        print(k+1,n,p)
        p=p+2**(k)

    


Measured memory_bytes: 20640
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        abc: [[i64; 3]; n],
    }
    let mut dp = vec![[0; 3]; n + 1];
    for i in 0 .. n {
        for j in 0 .. 3 {
            for k in 0 .. 3 {
                if j == k { continue; }
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + abc[i][k]);
            }
        }
    }
    puts!("{}\n", dp[n].iter().max().unwrap());
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 18684
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// 標準入力からデータを読み込む準備
Scanner sc = new Scanner(System.in);
// 最初の文字の固まりを整数値と想定して読み込む while (true) {
	int i;
	int j;
	while(true){
		int H = sc.nextInt();
		int W = sc.nextInt();

		if (H == 0 && W == 0) {
			break;
// 二重ループ(forの中にfor)を書いて、H x W個の # を表示しよう!
		}else{
			for(i=0; i<H; i++){
				for(j=0; j<W; j++){
					if(i==0 || j==0 || i==(H-1) || j==(W-1)){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		} 
	}
}
}


Measured memory_bytes: 36268
N,K = map(int, input().split())
A = [0]*N
DP=[0]*N

for i in range(N):
    A[i] = int(input())
    
A.sort()

ans = A[K-1]-A[0]
for i in range(N-K):
    if A[K+i]-A[i+1] < ans:
        ans = A[K+i]-A[i+1]
        
print(ans)

Measured memory_bytes: 8240
import sys
from itertools import permutations as pm
si = sys.stdin.readline
abc = 'abcdefghijklmnopqrstuvwxyz'


def former(i, n):
    s = ''
    for _ in range(i):
        s += abc[n % 26]
        n //= 26
    s = s[::-1]
    print(s)


def main():
    n = int(si())
    size = 26
    i = 1
    while n > size:
        n -= size
        size *= 26
        i += 1
    if i == 1:
        print(abc[n-1])
    else:
        former(i, n-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr
#define INT_MAX_HALF (INT_MAX / 2)

typedef long long ll;

using namespace std;
//using namespace boost::multiprec

int main(){

    int a,b,c,d;
    cin >> a >> b >> c >> d;

    cout << max(min(b,d) - max(a,c), 0) << endl;

    return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)

int M, N, P[10010], S[10010], C[555], E[555];
int dp[10010];

int main() {
	scanf("%d %d", &M, &N);
	for_(i,0,M) scanf("%d", &P[i]);
	for_(i,0,N) scanf("%d %d", &C[i], &E[i]);
	
	sort(P, P+M, greater< int >());
	
	memset(S, 0, sizeof(S));
	for_(i,0,M) S[i + 1] = S[i] + P[i];
	
	fill(dp, dp + M + 1, 1e9);
	dp[0] = 0;
	
	for_(i,0,N) for_rev(j,M+C[i],C[i]) {
		int nx = min(j, M);
		dp[nx] = min(dp[nx], dp[j - C[i]] + E[i]);
	}
	
	int ans = 0;
	for_(i,0,M+1) ans = max(ans, S[i] - dp[i]);
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 1332
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(in, &n)
	m := make(map[int]struct{}, n)
	for i := 0; i < n; i++ {
		var a int
		fmt.Fscan(in, &a)
		if _, ok := m[a]; ok {
			fmt.Println("NO")
			return
		}
		m[a] = struct{}{}
	}
	fmt.Println("YES")
}


Measured memory_bytes: 6016
#include<bits/stdc++.h>
#define eps 1e-6
#define ll long long
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
//#define int long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define fi first
#define se second
#define endl "\n"
#define pii pair<int,int>
#define fi first
#define se second
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll Max(ll a,ll b){return a>=b?a:b;}
ll Min(ll a,ll b){return a<=b?a:b;}
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res,t;res=1;t=a%c;while(b){if(b&1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
using namespace std;
//head file

int main()
{
    int n;
    cin>>n;
    ll ans=7;
    int cnt=1;
    rep(i,0,1000000)
    {
        if(ans%n==0)
        {
            cout<<cnt;
            return 0;
        }
        else
        {
            ans=(ans*10+7)%n;
            cnt++;
        }
    }
    cout<<"-1";
    return 0;
}


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

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

	int a,b,q;
	long long int x;
	vector <long long int> s,t;

	cin >> a >> b >> q;

	for(int i=0;i<a;i++)
	{
		cin >> x;
		s.push_back(x);
	}

	for(int i=0;i<b;i++)
	{
		cin >> x;
		t.push_back(x);
	}

	sort(s.begin(),s.end());
	sort(t.begin(),t.end());

	for(int i=0;i<q;i++)
	{
		cin >> x;
		int idx1 = lower_bound(s.begin(),s.end(),x) - s.begin();
		int idx2 = lower_bound(t.begin(),t.end(),x) - t.begin();
		long long int l1 = -100000000000000;
		long long int r1 = 100000000000000;
		long long int l2 = -100000000000000;
		long long int r2 = 100000000000000;
		if(idx1==0)
		{
			r1 = s[idx1];
		}
		else if(idx1==a)
		{
			l1 = s[idx1-1];
		}
		else
		{
			l1 = s[idx1-1];
			r1 = s[idx1];
		}

		if(idx2==0)
		{
			r2 = t[idx2];
		}
		else if(idx2==b)
		{
			l2 = t[idx2-1];
		}
		else
		{
			l2 = t[idx2-1];
			r2 = t[idx2];
		}
		//cout << x << ' ' << l1 << ' ' << r1 << ' ' << l2 << ' ' << r2 << '\n';
		//cout << max(x-l1,x-l2) << ' ' << min(x-l1,r2-x) + (r2-l1) << ' ' << max(r1-x,r2-x) << ' ' << min(r1-x,x-l2) + (r1-l2) << '\n';
		long long int res = max(x-l1,x-l2);
		res = min(res,min(x-l1,r2-x) + (r2-l1));
		res = min(res,max(r1-x,r2-x));
		res = min(res,min(r1-x,x-l2) + (r1-l2));
		cout << res << '\n';
	}
	return 0;
}

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

#define int long long

struct edge {
  int cost, att; // x軸方向の辺は0、y軸方向は1
};

vector<edge> v;

bool comp(const edge &e1, const edge &e2) {
  return e1.cost < e2.cost;
}

signed main(void) {
  int H, W;
  ios::sync_with_stdio(false);
  cin.tie(0);

  cin >> W >> H;
  for (int i = 0; i < W; i++) {
    edge p;
    cin >> p.cost;
    p.att = 0;
    v.push_back(p);
  }
  for (int i = 0; i < H; i++) {
    edge q;
    cin >> q.cost;
    q.att = 1;
    v.push_back(q);
  }

  sort(v.begin(), v.end(), comp);

  int h = H, w = W, ans = 0;

  for (int i = 0; (h | w); ++i) {
    if(v[i].att == 0) {
      ans += (h+1)*v[i].cost;
      w--;
    } else {
      ans += (w+1)*v[i].cost;
      h--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4592
from sys import stdin
from collections import defaultdict
input = stdin.readline

N = int(input())

d = defaultdict(int)

for _ in range(N):
    S = input().rstrip()
    d[S] += 1

print("AC x", d["AC"])
print("WA x", d["WA"])
print("TLE x", d["TLE"])
print("RE x", d["RE"])


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

int main(int argc, char const *argv[])
{
	int s;
	int h, m;
	int left;

	cin >> s;

	h = s / 3600;
	s = s % 3600;
	m = s / 60;
	s = s % 60; 


	cout << h << ":" << m << ":" << s << endl;
	return 0;
}


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

#define fi first
#define se second
#define FAST cin.tie(0);ios_base::sync_with_stdio(false);
#define int long long
#define MOD 1000000007


int modInv(int a, int m)
{
    if (m == 1)
        return 0;

    int val = m;
    int y = 0, x = 1;
    while (a > 1)
    {

        int temp = m;
        int quotient = a / m;
        m = a % m;
        a = temp;
        temp = y;
        y = x - quotient * y;
        x = temp;
    }

    if (x < 0) {
        x += val;
    }
    return x;
}

signed main()
{
    FAST
//    freopen(PATHIN, "r", stdin);
//    freopen(PATHOUT, "w", stdout);
    int arr_size,i;
    cin >> arr_size;
    vector<int> arr(arr_size);
    int first,second,count1 = 0;
    first = second = INT_MIN;
    for(i = 0;i < arr_size;i++){
        cin >> arr[i];
        if(arr[i] > first){
            first = arr[i];
            count1 = 1;
        }
        else if(first == arr[i]){
            count1++;
        }
    }

    if(count1 > 1){
        for(i = 0;i < arr_size;i++){
            cout << first << endl;
        }
    }
    else {
        for (i = 0; i < arr_size; i++) {
            if (arr[i] > first) {
                second = first;
                first = arr[i];
            } else if (arr[i] > second && arr[i] != first)
                second = arr[i];
        }
        for(i = 0;i < arr_size;i++){
            if(arr[i] != first){
                cout << first << endl;
            }
            else{
                cout << second << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3200
H, W, K = map(int, input().split())
masu = [list(input()) for _ in range(H)]

cnt = 0
for i in range(1 << H):
    for j in range(1 << W):
        tmp_cnt = 0
        for h in range(H):
            if (i >> h) & 1:
                continue
            for w in range(W):
                if (j >> w) & 1:
                    continue
                tmp_cnt += masu[h][w] == "#"
        if tmp_cnt == K:
            cnt += 1
print(cnt)

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    int k,s;
    cin >> k >>s;
    int z;
    int ans=0;

    REP(x,k+1){
        REP(y,k+1){
            z = s - (x + y);
            if(0<=z&&z<=k){
                ans += 1;
            }
        }
    }

    cout << ans <<"\n";

    return 0;
}

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

int main(){
  long long n;
  cin >> n;
  vector<char> ans(0);
  while(n>0){
    int x = n % 26;
    n = n / 26;
    if(x == 1){
      ans.push_back('a');
    }
    else if(x == 2){
      ans.push_back('b');
    }
    else if(x == 3){
      ans.push_back('c');
    }
    else if(x == 4){
      ans.push_back('d');
    }
    else if(x == 5){
      ans.push_back('e');
    }
    else if(x == 6){
      ans.push_back('f');
    }
    else if(x == 7){
      ans.push_back('g');
    }
    else if(x == 8){
      ans.push_back('h');
    }
    else if(x == 9){
      ans.push_back('i');
    }
    else if(x == 10){
      ans.push_back('j');
    }
    else if(x == 11){
      ans.push_back('k');
    }
    else if(x == 12){
      ans.push_back('l');
    }
    else if(x == 13){
      ans.push_back('m');
    }
    else if(x == 14){
      ans.push_back('n');
    }
    else if(x == 15){
      ans.push_back('o');
    }
    else if(x == 16){
      ans.push_back('p');
    }
    else if(x == 17){
      ans.push_back('q');
    }
    else if(x == 18){
      ans.push_back('r');
    }
    else if(x == 19){
      ans.push_back('s');
    }
    else if(x == 20){
      ans.push_back('t');
    }
    else if(x == 21){
      ans.push_back('u');
    }
    else if(x == 22){
      ans.push_back('v');
    }
    else if(x == 23){
      ans.push_back('w');
    }
    else if(x == 24){
      ans.push_back('x');
    }
    else if(x == 25){
      ans.push_back('y');
    }
    else if(x == 0){
      ans.push_back('z');
      n--;
    }
  }
  
  for(int i=(int)(ans.size())-1;i>=0;i--){
    cout << ans.at(i);
  }
  cout << endl;
      
}



Measured memory_bytes: 3632
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int Y = sc.nextInt();
    
    for (int i = 0; i <= N; i++) {
      int x = i*10000;
      if (x > Y) break;
      for (int j = 0; j <= N - i; j++) {
        int y = j * 5000;
        if ((x + y) > Y) break;
        if ((Y - x - y) / 1000 == (N - i - j)) {
          System.out.println(i + " " + j + " " + (Y - x - y) / 1000 );
          return; 
        }
      }
    }
    System.out.println("-1 -1 -1");
  }
}
  

Measured memory_bytes: 22100
n = gets.to_i
s = Array.new(n)
for i in 0..(n-1) do
  s[i] = gets.chomp
end

m = gets.to_i
t = Array.new(m)
for i in 0..(m-1) do
  t[i] = gets.chomp
end

max = 0

for i in 0..(n-1) do
  count = s.count(s[i]) - t.count(s[i])
  max = [count, max].max
end

p max



Measured memory_bytes: 1916
N,M = map(int,input().split())
PY = [list(map(int,input().split())) + [i] for i in range(M)]

PY.sort()

pnow = PY[0][0]
c = 1

ans = [-1 for i in range(M)]

for i in range(M):
    if pnow != PY[i][0]:
        c = 1
        pnow = PY[i][0]
    ans[PY[i][2]] = str(PY[i][0]).zfill(6) + str(c).zfill(6)
    c += 1

print('\n'.join(ans))


Measured memory_bytes: 38836
using System;

namespace ABC051
{
    class B
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int K = int.Parse(input[0]);
            int S = int.Parse(input[1]);

            int count = 0;
            for (int x = 0; x <= K; x++)
            {
                for (int y = 0; y <= K; y++)
                {
                    int z = S - (x + y);
                    if (0 <= z && z <= K) { count++; }
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13140
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> input = new ArrayList<>();
		for(int a = 0 ; a < 3 ;a++){
			input.add(Integer.parseInt(sc.next()));
		}
		System.out.println((input.get(0) - input.get(1) + 1) * (input.get(0) - input.get(2) + 1));
	}
}


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

int main() {
    int64_t N, T;
    cin >> N >> T;
    vector<pair<int64_t,int64_t>> AB(N);
    for ( int64_t i = 0; i < N; ++i){
        int64_t p,q;
        cin >> p >> q;
        AB[i] = make_pair(p,q);
    }
    
    sort(AB.begin(),AB.end());
    
    /*for ( auto p: AB){
        cout << p.first << " " << p.second << endl;
    }*/
    
    vector<vector<int64_t>> dp(N,vector<int64_t>(T,0));
    
    for ( int64_t t = 0; t < T; ++t){
        int64_t A = AB[0].first;
        int64_t B = AB[0].second;
        if ( t < A ) dp[0][t] = 0;
        else dp[0][t] = B;
    }
    
    for ( int64_t i = 1; i < N; ++i){
        int64_t A = AB[i].first;
        int64_t B = AB[i].second;
        for ( int64_t t = 0; t < T; ++t){
            if ( t - A >= 0 ) dp[i][t] = max(dp[i-1][t],dp[i-1][t-A]+B);
            else dp[i][t] = dp[i-1][t];
        }
    }
    
    //int64_t ans_max = dp[0][T];
    int64_t ans_max = 0;
    for ( int64_t i = 1; i < N; ++i){
        int64_t A = AB[i].first;
        int64_t B = AB[i].second;
        int64_t ans = dp[i-1][T-1] + B;
        ans_max = max(ans_max,ans);
    }
    
    cout << ans_max << endl;
    
    return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    int n, v[50];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    for (int i = 0;i < n;i++) {
        for (int j = 0; j < i;j++) {
            if (v[i] < v[j]) {
                int tmp = v[i];
                v[i] = v[j];
                v[j] = tmp;
            }
        }
    }
    double m = v[0];
    for (int i = 1; i < n;i++) {
        m = (m + v[i]) / 2;
    }
    printf("%.6f\n", m);
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline
from fractions import gcd
import math
n = int(input())
a = list(map(int, input().split()))
def lcm(a, b):
    return (a * b) // gcd(a, b)
m = 1
for x in a:
    m = (m * x) // gcd(m, x)
# print(m)
MOD = 1000000007
ans = 0
for x in a:
    b = m // x
    ans = ans + b
ans = ans % MOD
print(math.floor(ans))


Measured memory_bytes: 6104
N,S=map(int,input().split())
A=list(map(int,input().split()))
MOD=998244353
dp=[[0 for _ in range(S+1)] for _ in range(N+1)]
dp[0][0]=1
for i in range(N):
    for j in range(S+1):
        dp[i+1][j]+=dp[i][j]*2
        dp[i+1][j]%=MOD
        if j+A[i]<=S:
            dp[i+1][j+A[i]]+=dp[i][j]
            dp[i+1][j+A[i]]%=MOD
print(dp[-1][-1])

Measured memory_bytes: 147840
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		String ans = "No";
		if((c - a - b) > 0 && (4 * a * b) < (c - a - b) * (c - a - b)){
			ans = "Yes";
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22996
#include<stdio.h>

#define STACK_SIZE 11              /* スタックに積むことのできるデータの最大個数　*/

int stack_data[STACK_SIZE];        /* スタックの本体　*/
int stack_num = 0;                 /* スタック内のデータ数　*/

/* 関数　*/
int pop();

int main(){
  int n,ans;
  while(scanf("%d",&n)!=EOF){
    if(n==0){
      ans = pop(n);
      printf("%d\n",ans);
    } else{
      stack_data[stack_num] = n;
      stack_num++;
    }
  }
  return(0);
}
int pop(){
  int ans;
  stack_num--;
  ans = stack_data[stack_num];
  return ans;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <deque>
#include <queue>

#define pb push_back
#define mp make_pair
#define x first
#define y second
#define FOR(i, a, b) for(int i=a, loop=b; i<=loop; ++i)
#define REV(i, a, b) for(int i=a, loop=b; i>=loop; --i)
#define mize(a, b) a = min(a, b)
#define maxi(a, b) a = max(a, b)
#define shl(k) ((k) << 1)
using namespace std;

const int N = 2000 + 5, mod = 998244353;
int n, k;
int64_t C[N][N], G[N][N], F[N], P[N], d[N], tmp, res[N][2];

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

    cin >> k >> n;

    int r = max(k, n);
    FOR(i, 0, r) C[i][0] = 1;
    FOR(i, 1, r) FOR(j, 1, i) C[i][j] = (C[i-1][j] + C[i-1][j-1]) % mod;

    G[0][1] = 1;
    FOR(i, 1, n) FOR(j, 1, k) G[i][j] = (G[i][j-1] + G[i-1][j]) % mod;
    G[0][0] = 1; G[0][1] = 0;
    FOR(i, 0, n) FOR(j, 1, k) G[i][j] = (G[i][j] + G[i][j-1]) % mod;

    for(int m=1; m+m<=k; ++m) FOR(i, 2, n) F[m] = (F[m] + C[i-1][m+m-1] * G[n-i][k-m-m] % mod) % mod;
    for(int m=1; m+m+1<=k; ++m) FOR(i, 2, n) {
        tmp = G[n-i][k-m-m-1];
        if (n-i-1 >= 0) tmp = tmp + G[n-i-1][k-m-m-1];
        P[m] = (P[m] + C[i-1][m+m-1] * tmp % mod) % mod;
    }

    int64_t ans; int m;
    FOR(i, 0, k) res[i][0] = res[i][1] = -1;
    FOR(t, 2, k+k) {
        m = 0; FOR(i, 1, k) if (1<=t-i && t-i<=k) m += 1;
        if (res[m/=2][t&1] != -1) {
            ans = res[m][t&1];
            goto REP;
        }

        if (t&1) {
            ans = G[n][k];
            REV(i, m, 1) {
                d[i] = F[i];
                FOR(j, i+1, m) d[i] = (d[i] - d[j] * C[m-i][j-i] % mod + mod) % mod;
            }
        } else {
            ans = (G[n][k-1] + G[n-1][k-1]) % mod;
            REV(i, m, 1) {
                d[i] = P[i];
                FOR(j, i+1, m) d[i] = (d[i] - d[j] * C[m-i][j-i] % mod + mod) % mod;
            }
        }

        FOR(i, 1, m) ans = (ans - d[i] * C[m][i] % mod + mod) % mod;
        res[m][t&1] = ans;
        REP: cout << ans << '\n';
    }
}


Measured memory_bytes: 63232
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

void chmax(int* a, int* c, int b){
  if( *a < b ){
     *a = b;
  }else if( b > *c ){
    *c = b;
  }
}

int main(){
  int n;
  cin >> n;
  vector<int> ai(n);
  vector<int> ans(n);
  int max = -1;
  int max2 = -1;
  for(int i=0; i<n; i++){
    cin >> ai[i];
    ans[i] = ai[i];
    chmax(&max, &max2, ai[i]);
  }
  sort(ai.begin(), ai.end(), greater<int>() );
  int maxcount = 0;
  for(int i=0; i<n; i++){
    if( max == ai[i] ){
      maxcount+=1;
      continue;
    }else{
      break;
    }
  }
  for(int i=0; i<n; i++){
    if( maxcount > 1 ){
      cout << max << endl;
    }else{
      if( max == ans[i] ) cout << max2 << endl;
      else cout << max << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N, M;
    cin >> N >> M;
    int ans = 0;
    vector<int> v(M);
    vector<int> diff(M - 1);
    rep(i, M) cin >> v[i];
    sort(v.begin(), v.end());

    for(int i = 0; i < M - 1; i++) {
        diff[i] = abs(v[i + 1] - v[i]);
    }

    sort(diff.begin(), diff.end());

    for(int i = 0; i < (M - 1) - (N - 1); i++) {
        ans += diff[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().ToCharArray();

            int sum = 0;

            foreach(var x in s)
            {
                sum = (x.Equals('+')? sum+1 : sum-1 ) ;
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 13140
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

const P: i64 = 1_000_000_007;

fn main() {
    let mut scan = Scan::new();

    let N = scan.word::<usize>();
    let K = scan.word::<usize>();

    // u[i] = (i+1 個の整数の最小の和)
    let mut u = vec![0];
    for i in 1..N + 1 {
        u.push(u.last().unwrap().clone() + i);
    }

    // v[i] = (i+1 個の整数の最大の和)
    let mut v = vec![N];
    for i in (0..N).rev() {
        v.push(v.last().unwrap().clone() + i);
    }

    let mut total = 0_i64;

    for k in K..N + 2 {
        if u[k - 1] <= v[k - 1] + 1 {
            total += (v[k - 1] + 1 - u[k - 1]) as i64;
            total %= P;
        }
    }

    println!("{}", total);
}


Measured memory_bytes: 5288