akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<math.h>


int main(){
   int n,t,j=0,c=0;
   scanf("%d", &n);
   int aa[n],num[n];
   for(int i=0;i<n;i++){
    	num[i] = i+1;
   }
   for(int i=0;i<n;i++){
   	scanf("%d ", &t);
    if(num[j]==t){
    	j++;
    }else {
      c++;
    }
   }
   if(c==n){
    printf("-1");
   }else{
   	printf("%d" , c);
   }
   return 0;
 
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const int INF = 1e9;

int main(void){

	int N, K; cin >> N >> K;
	int ans = 0;
	while(N != 0){
		N /= K;
		ans++;
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
        out << '(' << p.first << ',' << p.second << ')';
            return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
        in >> p.first >> p.second;
            return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
        for (T &x : v)
                    in >> x;
            return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
        for (const vector<T> &x : v)
                    out << x << '\n';
            return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
        for (const T &x : v)
                    out << x << ' ';
            return out;
}

template <class T>
ostream& operator << (ostream& out,const set<T> &s)
{
        for (const T &x : s)
                out << x << ' ';
            return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.000000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

int main()
{
    fast();
    ll n,m;
    cin>>n>>m;
    vi a(n,n);
    for(ll i=0;i<m;i++)
    {
        ll u,v;
        cin>>u>>v;
        u--;v--;
        a[u]=min(a[u],v);
    }
    
    ll ans=0;
    ll index=0;
    while(index<n)
    {
        ll low=index;
        ll last=a[low];
        
        while(low<last)
        {
            low++;
            if(low<n)
            {
                last=min(last,a[low]);
            }
        }
        ans++;
        index=low;
    }
    cout<<ans-1<<nl;
}


Measured memory_bytes: 3992
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int Row=sc.nextInt();
        int Col=sc.nextInt();
        int table[][] =new int[Row+1][Col+1];
        for(int i=0;i<Row;i++){
            for(int j=0;j<Col;j++){
                table[i][j]=sc.nextInt();
            }
        }
        for(int i = 0; i < Row; i++){
			for(int j = 0; j < Col; j++){
				table[i][Col] += table[i][j];
			}
		}

		for(int i = 0; i <= Col; i++){
			for(int j = 0; j < Row; j++){
				table[Row][i] += table[j][i];
			}
		}

		for(int i = 0; i <= Row; i++){
			System.out.printf("%d", table[i][0]);
			for(int j = 1; j <= Col; j++){
				System.out.printf(" %d", table[i][j]);
			}
			System.out.printf("\n");
		}
    }
}


Measured memory_bytes: 53212
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# # input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
S = input()

s1 = set()
s2 = set()
s3 = set()

for s in S:
    for ss2 in s2:
        s3.add(ss2+s)
    for ss1 in s1:
        s2.add(ss1+s)
    s1.add(s)

print(len(s3))

Measured memory_bytes: 10480
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n, m;
    cin >> n >> m;
    Graph denkyu(m);
    vector<int> onofflag(m);
    rep(i, m) {
        int k;
        cin >> k;
        denkyu[i].resize(k);
        rep(j, k) cin >> denkyu[i][j];
    }
    rep(i,m) cin >> onofflag[i];

    int ans = 0;
    for(int bit = 0; bit < (1 << n); ++bit) {
        int lightnum = 0;
        for(int i = 0; i < m; ++i) {
            int num = 0;
            for(auto v : denkyu[i]) {
                if(bit & (1 << (v - 1))) {
                    num++;
                }
            }
            if(num % 2 == onofflag[i]) {
                lightnum++;
            }
        }
        if(lightnum == m) ans++;
    }

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


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

const int maxN=100000;
vector<int> d[300001];
ll ans[300001];

int main(){
    ll N,M; cin>>N>>M;
    for(int i=0;i<M;i++){
        int u,v; cin>>u>>v;
        d[u].push_back(v+N);
        d[u+N].push_back(v+N*2);
        d[u+N*2].push_back(v);
    }
    int S,T; cin>>S>>T;
    /*for(int i=1;i<=3*N;i++){
        cout<<i<<"::";
        for(int j=0;j<d[i].size();j++) cout<<d[i].at(j)<<' ';
        cout<<endl;
    }*/
    for(int i=0;i<300001;i++) ans[i]=-1;
    
    queue<int> Q;
    Q.push(S);
    ans[S]=0;
    while(!Q.empty()){
        int a=Q.front();
        if(a==T) break;
        Q.pop();
        if(d[a].size()!=0){
            for(int i=0;i<d[a].size();i++){
                int p=d[a].at(i);
                if(ans[p]==-1){
                    ans[p]=ans[a]+1;
                    Q.push(p);
                }
            }
        }
    }
    if(ans[T]!=-1) cout<<ans[T]/3<<endl;
    else cout<<ans[T]<<endl;

}




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

using namespace std;
const int N = 30;

int a[N];
int main(){
    int n; cin >> n;
    for (int i = 0; i < n; ++ i)
        cin >> a[i];

    int ans = 0;
    for (int i = 1; i+1 < n; ++ i){
        int cnt = 0;
        if (a[i] > a[i-1]) ++ cnt;
        if (a[i] > a[i+1]) ++ cnt;
        if (cnt == 1) ++ ans;
    }
    cout << ans;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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  lINF = 1LL << 60;
const int iINF = 1 << 29;

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

  cout << (a<=x&&a+b>=x ? "YES" : "NO") << endl;
  return 0;
} 

Measured memory_bytes: 3584
#include<iostream>
using namespace std;
int main(){
int x, y, t;
while(1){
cin >> x >> y;
 if ( x == 0 && y == 0 )break;
 if ( x < y ){
 cout << x << " " << y << endl;
 }else{
 cout << y << " " << x << endl;
}
}
return 0;
}

Measured memory_bytes: 2976
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

double a,b,h,m;
void input(){
    fast_io();
    cin >> a >> b >> h >> m;
}

int solve(){
    double radH = (h+m/60)/12*2*M_PI;
    double radM = m/60*2*M_PI;
    double radtheta = abs(radH-radM);
    double ans = sqrt(a*a+b*b-2*a*b*cos(radtheta));
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}   

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

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

int a[101];

int main()
{
	int n,x;
	cin>>n;
	
	for(int i=1;i<=n;i++){
		cin>>x;
		a[x]=1;
	} 
	
	int s=0;
	for(int i=1;i<=100;i++){
		if(a[i]==1) s++;
	}
	
	cout<<s;
	return 0;
}

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

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

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

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

    double sum = 0;
    for (int i = 0; i < n; i++) sum += a[i];

    if (a[m-1] < sum/(4*m)) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <math.h>
int main()
{int a,b,c,d;
while(scanf("%d",&a)!=EOF){
b=a;
c=b/10;
d=b%10;
if(c==9)
printf("Yes\n");
else if(d==9){
printf("Yes\n");}
else {
printf("No\n");
}
}

return 0;
}

Measured memory_bytes: 128
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l  
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |   
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) reverse((a).begin(),(a).end())
#define REP(i, n) for(int i = 0; i < n; i++)
const int MOD = 1e9+7;
typedef long long ll;

int main() {
    int a,b;
    cin>>a>>b;
    cout<<6-a-b<<endl;
    
}


Measured memory_bytes: 256
x,y = map(int,input().split())
n = 0
mod = 10**9+7
ans = 0
if not (x+y)%3:
  n = (x+y)//3
  x-=n
  y-=n
  if not x<0 or y<0:
    ans = 1
    for i in range(x):
      ans = ans*(n-i)*pow(i+1,mod-2,mod)%mod
print(ans)

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

int main() {
	char s;
  	for(int i=0;i<4;i++){
    	cin>>s;
      	cout<<s;
    }
  		cout<<" ";
  	for(int i=0;i<8;i++){
    	cin>>s;
      	cout<<s;
    }
  		cout<<endl;
  
}

Measured memory_bytes: 256
n = int(input())
res = 0

if n >= 9: res += 9
else: res += n

if n >= 100:
    if n <= 999:
        res += n - 100 + 1
    else: res += 900

if n >= 10000:
    if n <= 99999:
        res += n - 10000 + 1
    else: res += 90000

print(res)

Measured memory_bytes: 3060
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <map>

using namespace std;


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

	vector<int> prime_vec = { 2 };
	vector<int> ans_vec = {};
	int index = 3;
	while (ans_vec.size() < num) {
		bool wrong = false;
		for (int prime : prime_vec) {
			int mod = index % prime;
			if (mod == 0) {
				wrong = true;
				break;
			}
		}
		if (!wrong) {
			prime_vec.push_back(index);
			if (1 == (index%10)) {
				ans_vec.push_back(index);
			}
		}
		index++;
	}

	string str;
	for (int prime : ans_vec) {
		str += to_string(prime) + ' ';
	}
	//str.erase(str.size() - 1);
	cout << str;
}

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

bool is_same(vector<string> A, vector<string> B){
    int N = A.size();
    for (int i=0; i<N; i++){
        for (int j=0; j<N; j++){
            if (A[i][j] != B[i][j])return false;
        }
    }
    return true;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<string>As(N);
    vector<string>Bs(M);

    for (int i=0; i<N; i++)cin >> As[i];
    for (int j=0; j<M; j++)cin >> Bs[j];

    for (int y=0; y<=N-M; y++){
        for (int x=0; x<=N-M; x++){
            //y,x ~ y+M, x+M
            int i = 0;
            bool ans = true;
            rep(i, M){
                if (As[y+i].substr(x, M) != Bs[i]){
                    ans = false;
                    break;
                }
            }

            if (ans){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX=100010;

int n, A[MX], B[MX];
ll med;

int tree[4*MX], lim=300010;

void upt(int x){
	x+=100001;
	for(; x<=lim; x+=x&(-x)) tree[x]++;
}
int get(int r){
	int res=0; r+=100001;
	for(; 0<r; r-=r&(-r)) res+=tree[r];
	return res;
}


ll check(int x){
	for(int i=0; i<4*MX; i++) tree[i]=0;
	int S[MX]={};
	for(int i=1; i<=n; i++) if(A[i]<=x) S[i]++;
	for(int i=1; i<=n; i++) S[i]+=S[i-1];
	ll cnt=0;
	upt(1);
	for(int i=1; i<=n; i++){
		int x=2*S[i]-i;
		cnt+=get(x);
		upt(x+1);
	}
	return cnt;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n; med=1LL*n*(n+1)/2; med=med/2+1;
	for(int i=1; i<=n; i++) cin>>A[i], B[i]=A[i];
	sort(B+1, B+n+1);

	int s=1, e=n;
	while(s<e){
		int m=(s+e)/2, x=B[m];
		if(check(x)>=med) e=m;
		else s=m+1;
	}
	cout<<B[s]<<'\n';
	return 0;
}

Measured memory_bytes: 2944
//
// Created by Hideaki Imamura on 2020-03-22.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int H, W, K;
vector<string> S;

int main() {
    cin >> H >> W >> K;
    S.resize(H);
    for (int i = 0; i < H; ++i) cin >> S[i];

    int ans = INF;
    for (int yoko = 0; yoko < (1 << (H-1)); ++yoko) {
        int nb = 1 + __builtin_popcount(yoko);
        vector<int> counter(nb, 0);
        int now_ans = __builtin_popcount(yoko);
        bool suc = false;
        for (int j = 0; j < W; ++j) {
            int now = 0;
            for (int i = 0; i < H; ++i) {
                if (S[i][j] == '1') counter[now]++;
                if ((yoko >> i) & 1) now++;
            }
            if (*max_element(counter.begin(), counter.end()) > K) {
                if (suc) {
                    now_ans = INF;
                    break;
                }
                now_ans++;
                counter.assign(nb, 0);
                j--;
                suc = true;
                continue;
            }
            suc = false;
        }
        chmin(ans, now_ans);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  
  int d;
  int t;
  int s;

  cin >> d;
  cin >> t;
  cin >> s;
  
  int c = t*s ;

  if (c < d) {
    cout << "No";
  }
  
 else{cout << "Yes";}
  
	return 0;
}

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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = m - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template< typename T >
T binomial(int64_t N, int64_t K) {
  if(K < 0 || N < K) return 0;
  T ret = 1;
  for(T i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll n,a,b;cin>>n>>a>>b;
  vector<ll>v(n);
  rep(i,0,n)cin>>v[i];
  sort(ALLR(v));
  ld avg=0;
  ll cntx=0;
  ll cnty=0;
  rep(i,0,a){
    avg+=v[i];
    if(v[i]>v[a-1])cnty++;
  }
  avg/=a;
  rep(i,0,n)if(v[i]==v[a-1])cntx++;
  if(cnty==0){
    rep(i,a,b+1){
      res+=binomial<ll>(cntx,i);
    }
  }
  else{ 
    //cout<<cntx spa cnty<<endl;
    res=binomial<ll>(cntx,a-cnty);
  }
  cout<<avg<<endl;
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int n,m;
cin >> n >> m;
ll l,r;
ll mi =1e10;
ll ma =0;

for(int i =0;i < m;++i){
cin >> l >> r;
ma = max(l,ma);
mi = min(mi,r); 
}
if(ma <= mi)
cout << mi-ma +1 << endl;
else
    cout << 0 << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String S = scan.next();
    String T = scan.next();
    
    char[] forcast = S.toCharArray();
    char[] real    = T.toCharArray();
    
    int count=0;
    for (int i=0;i<3;i++) {
      if(forcast[i] == real[i]) count++;
    }
    System.out.println(count);
  
  }
 
}

Measured memory_bytes: 22868
// Problem : D - Knapsack 1
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define nl cout<<"\n"
#define endl "\n"
#define all(c) (c).begin(),(c).end()
#define trav(a,x) for(auto a = x.begin() ; a != x.end() ; a++)
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define vll vector<ll>
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull ;
typedef long double ld;

inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b) {if(b==0) return a; a%=b;return gcd(b,a);}
ll power(ll x, ll y){if(y == 0) return 1; ll a = power(x,y/2);if (y % 2 == 0) return a * a; else return x * a * a; }
ll powermod(ll x, ll ex , ll md) {ll ans = 1ll;while (ex > 0) {if (ex & 1ll) ans = (ans * x) % md; ex >>= 1ll;x = (x * x) % md;}return ans;}

const ll inf = 1e18 + 9;
const ll mod = 1e9 + 7;
const ld PI = acos(-1);
const ld eps = 1e-9;
const ll N = 111;
const ll W = 1e5 + 111;
ll n , mxwt ;
ll wt[N];
ll val[N];
ll dp[N][W]; // dp[i][j] = max value attained after choosing items till i and attaining max weight of j
void solve(){
	cin >> n >> mxwt;
	rep(i , n) cin >> wt[i + 1] >> val[i + 1];
	// base 
	for(ll j = 0 ; j <= mxwt ; j++){
		if(j < wt[1]) dp[1][j] = 0;
		else if(j >= wt[1]) dp[1][j] = val[1]; 
	}
	// trans
	for(ll i = 2 ; i <= n ; i++){
		for(ll j = 0 ; j <= mxwt ; j++){
			if(j < wt[i]) dp[i][j] = dp[i - 1][j];
			else{
				dp[i][j] = max(dp[i - 1][j] , val[i] + dp[i - 1][j - wt[i]]);
			}
		}
	}
	ll ans = -inf;
	rep(i , mxwt + 1){
		ans = max(ans , dp[n][i]);	
	}
	cout << ans << endl;
}
int main(){
    IOS;
    cout << fixed << setprecision(20);
    ll NTC=1;
    // cin>>NTC;
    ll PTC=0;
    while(PTC++<NTC){
        // cout<<"Case #"<<PTC<<":"<<' ';
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 79360
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper

s1 = input()
s2 = input()
if s1[::-1] == s2:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3568
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int A = Integer.parseInt(st.nextToken());
        int B = Integer.parseInt(st.nextToken());
        int C = Integer.parseInt(st.nextToken());
        int K = Integer.parseInt(st.nextToken());

        if(A >= K) {
            pw.println(K);
        } else if(A + B >= K) {
            pw.println(A);
        } else if(A + B + C >= K) {
            pw.println(A - (K-(A+B)));
        }
       
        br.close();
        pw.close();
    }
}

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

#define mp make_pair
#define pb push_back
#define x first
#define y second
#define DEBUG(x) cout << #x << " = " << x << endl;

using namespace std;

typedef long long LL;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int inf = INT_MAX;
const LL INF = LLONG_MAX;

template <typename T> inline int chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }

template <typename T> inline T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + (ch - '0');
	return sum * fl;
}

const int maxn = 15;
const int mod = 1e9 + 7;

int N, M;
int E[maxn + 1];

inline void add (int &x, int y) { x = x + y >= mod ? x + y - mod : x + y; }

inline void solve ()
{
	static int F[1 << maxn], pw[maxn * maxn + 1], cnt[1 << maxn];

	pw[0] = 1; F[0] = 1;
	for (int i = 1; i <= M; ++i) pw[i] = 2ll * pw[i - 1] % mod;
	for (int i = 1; i < (1 << N); ++i) cnt[i] = __builtin_popcount (i);
	
	for (int i = 1; i < (1 << N); ++i)
	{
		for (int S = i; S > 0; S = (S - 1) & i) //SG = 0的集合
		{
			if ((S & 3) != 0 && (S & 3) != 3) continue; //1,2要在一起

			int sum = 0, least = 1, T = i - S;	
			for (int k = 1; k <= N; ++k) 
			{
				if ((S >> k - 1) & 1) sum += cnt[E[k] & T]; //S 到 T 随便连边
				if ((T >> k - 1) & 1) least = (LL)least * (pw[cnt[E[k] & S]] - 1) % mod;//T 每个点到 S 至少要有一条边 
			}

			add (F[i], (LL)F[T] * pw[sum] % mod * least % mod);
		}
	}

	printf ("%d\n", (pw[M] - F[(1 << N) - 1] + mod) % mod);
}

inline void input ()
{
	N = read<int>(), M = read<int>();
	for (int i = 1; i <= M; ++i) 
	{
		int x = read<int>(), y = read<int>();
		E[x] |= 1 << y - 1;
	}
}

int main ()
{


	input ();
    solve ();

    return 0;
}


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

struct Process {
    Process() = default;
    Process(std::string name, int time) : name(name), time(time) {};
    std::string name;
    int time;
};

class Queue {
  public:
    void initialize() {
        head = tail = 0;
    }
    
    void enqueue(Process x) {
        queue[tail] = x;
        tail = (tail + 1) % len;
    }

    Process dequeue() {
        Process val = queue[head];
        head = (head + 1) % len;
        return val;
    }

    bool isEmpty() {
        return head == tail;
    }

  private:
    static const int len = 100000;
    int head, tail;
    Process queue[len];
};

int main() {
    int n, q;
    std::cin >> n >> q;

    Queue qu;

    for (int i = 0; i < n; i++) {
        std::string name;
        int time;
        std::cin >> name >> time;
        qu.enqueue(Process(name, time));
    }

    int elapsed = 0;
    while (!qu.isEmpty()) {
        Process p = qu.dequeue();
        if (p.time <= q) {
            elapsed += p.time;
            std::cout << p.name << " " << elapsed << std::endl;
        } else {
            elapsed += q;
            qu.enqueue(Process(p.name, p.time - q));
        }
    }
}



Measured memory_bytes: 6948
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
//#define inf 2000000000
#define inf 8000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
const int maxn=300005;
//i_am_noob
int n;

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n;
    print1(1-n);
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <set>
using namespace std;
int s[205];
int main()
{
    long long a,b;
    int k;
    set<int>aa;
    set<int>::iterator iter;
    cin>>a>>b>>k;
    int cnt=0;
    for(int i=a;i<a+k;i++)
    {
        if(i>b)
            break;
        aa.insert(i);
    }
    for(int i=b;i>b-k;i--)
    {
        if(i<a)
            break;
        aa.insert(i);
    }


    for(iter=aa.begin();iter!=aa.end();iter++)
        cout<<*iter<<endl;
    return 0;
}


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

typedef long long ll;
#define MOD = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
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;}
template<class T> inline bool is_overlap(const T& as, const T& ae, const T& bs, const T& be)
{ return bs <=ae && as <= be; }
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
#define ANS(a) cout<<a<<endl
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

template<class T> void sort3d(T& a,T& b,T& c) {if (a<b) swap(a,b); if (b<c) swap(b,c); if (a<b) swap(a,b);}

#define PI 3.141592653589793

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N, L; cin >>N >> L;

    int value_sum;
    int value_eat;
    
    value_sum = N * L - N + N * (N + 1) / 2;
    if (L >= 0) {
        value_eat = L;
    } else {
        value_eat = L + min(-L+1, N) - 1;
    }
    
    cout << value_sum - value_eat << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
mod = 10**9+7
dp = [[1] * (M+1) for _ in range(N+1)]
for i in range(1, N+1):
    for j in range(1, M+1):
        dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]) % mod
        if S[i-1] == T[j-1]:
            dp[i][j] = (dp[i][j] + dp[i-1][j-1]) % mod
print(dp[N][M])


Measured memory_bytes: 72796
#include<cstdio>
#include<algorithm>
#define maxn 100005
#define LL long long
using namespace std;
int n,k,cnt,a[maxn],b[maxn],tree[maxn*4];
LL sum[maxn],t[maxn*2],l[maxn],r[maxn],dp[maxn];
void Pushdown(int i)
{
	if(!tree[i]) return;
	tree[i<<1]=tree[i<<1|1]=tree[i];
	tree[i]=0;
}
void Modify(int i,int l,int r,int ql,int qr,int d)
{
	if(l>r||ql>qr) return;
	if(ql<=l&&r<=qr) { tree[i]=d; return; }
	Pushdown(i);
	int mid=(l+r)>>1;
	if(ql<=mid) Modify(i<<1,l,mid,ql,qr,d);
	if(qr>mid) Modify(i<<1|1,mid+1,r,ql,qr,d);
}
int Query(int i,int l,int r,int p)
{
	if(l==r) return tree[i];
	Pushdown(i);
	int mid=(l+r)>>1;
	if(p<=mid) return Query(i<<1,l,mid,p);
	else return Query(i<<1|1,mid+1,r,p);
}
LL Query(int p)
{
	int c=Query(1,1,cnt,p);
	if(!c) return 0;
	return 1ll*dp[c]+(t[l[c]]-t[p]+k)%k;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		sum[i]=sum[i-1]+a[i];
		if(b[i]==1&&2*a[i]>k) { printf("-1\n"); return 0; }
	}
	for(int i=1;i<=n;i++)
	{
		if(b[i]==1) l[i]=(-2*sum[i-1]%k+k)%k,r[i]=(-2*sum[i]%k+k)%k;
		else l[i]=0,r[i]=k-1;
		t[i*2-1]=l[i],t[i*2]=r[i];
	}
	sort(t+1,t+n*2+1);
	cnt=unique(t+1,t+n*2+1)-t-1;
	for(int i=1;i<=n;i++)
		l[i]=lower_bound(t+1,t+cnt+1,l[i])-t,r[i]=lower_bound(t+1,t+cnt+1,r[i])-t;
	for(LL i=n;i;i--)
	{
		dp[i]=Query(l[i]);
		if(l[i]>r[i]) Modify(1,1,cnt,r[i]+1,l[i]-1,i);
		else { Modify(1,1,cnt,1,l[i]-1,i); Modify(1,1,cnt,r[i]+1,cnt,i); }
	}
	LL ans=dp[1];
	for(int i=1;i<=cnt;i++) ans=min(ans,Query(i));
	printf("%lld\n",ans+sum[n]*2);
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n = in();
  map<string,int> mp;
  rep(i,n) {
    //string s = in<string>();
    string s;
    cin >> s;
    mp[s]++;
  }
  int mx = 0;
  for (auto p : mp) mx = max(mx, p.se);
  for (auto p : mp) {
    if (p.se != mx) continue;
    cout << p.fi << '\n';
  }
  return 0;
}

Measured memory_bytes: 25216
#include <iostream>
using namespace std;
void solve()
{
    double n;
    cin >> n;
    int ans = 0;
    int a, b;
    double res;
    for (a = 1; a < n; a++)
    {
        for (b = 1; b < n; b++)
        {
            res = n - (a * b);
            if (res > 0)
            {
                ++ans;
            }
            else
            {
                break;
            }
        }
    }
    cout << ans << "\n";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3728
#include <stdio.h>
int main()
{
	int N, X, T, k, p;
	scanf("%d %d %d", &N, &X, &T);
	k = N / X;
	if (N % X != 0)
		k = k + 1;
	else
		k = k;
	p = k * T;
	printf("%d\n", p);

	return 0;
}

Measured memory_bytes: 1712
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str=Console.ReadLine().Split(' ');
      int[] arr=str.Select(int.Parse).ToArray();
      if((arr[0]+arr[1])>(arr[2]+arr[3])){
        Console.WriteLine("Left");
      }else if((arr[0]+arr[1])==(arr[2]+arr[3])){
        Console.WriteLine("Balanced");
      }else{
        Console.WriteLine("Right");
      }
    }
    
  }

}


Measured memory_bytes: 28288
n = gets.to_i

set = Hash.new(-1)
"abcdefghijklmnopqrstuvwxyz".each_char {|c| set[c] += 1}

min_alp = Hash.new(51)
n.times do
    alp = set.dup

    gets.chomp!.each_char {|c| alp[c] += 1}

    alp.each do |key,value|
        if min_alp[key] > value
            min_alp[key] = value
        end
    end
end

ans = ""
min_alp.each do |key,value|
    ans += key * value
end

puts ans

Measured memory_bytes: 1916
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = Long.parseLong(sc.next());
		//String t = sc.next();
//		String buff="";
		long b = Long.parseLong(sc.next());
		int c = Integer.parseInt(sc.next());
		//int n = Integer.parseInt(sc.next());
		//long res=n;
		//int l = Integer.parseInt(sc.next());
		//int sum=0;
		//String s = sc.next();
		//String t = sc.next();
		//String w = sc.next();
		//int a = Integer.parseInt(sc.next());
		//String t = sc.next();

		if(c>=a&&c<=b) {//a、e、i、o、u
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		/*for(int i=0;i<t.length();i++) {
			if(t.substring(i,i+1).equals(",")) {
				buff+=" ";
			}else {
				buff+=t.substring(i, i+1);
			}
		}*/
		//System.out.println(t.substring(0,1).toUpperCase()+s.substring(0,1).toUpperCase()+w.substring(0,1).toUpperCase());
	}
}




Measured memory_bytes: 22740
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a == 0 && b == 0){break;}
			for(int i = 0; i < a; i++){
				String s ="";
				for(int i2 = 0; i2 < b; i2++) {
					if(i == 0 || i == a - 1) {
						s += "#";
					}else if(i2 == 0 || i2 == b - 1){
						s += "#";
					}
					else{
						s += ".";
					}
				}
				System.out.println(s);
			}
			System.out.println();
		}
	}
}



Measured memory_bytes: 50248
n, k = gets.split.map(&:to_i)
sushi = Hash.new { |h, k| h[k] = [] }

s_0 = []
s_1 = []

n.times do
  t, d = gets.split.map(&:to_i)
  sushi[t] << d
end
sushi.values.each do |arr|
  arr.sort!.reverse!
  arr.each_with_index do |a, i|
    if i == 0
      s_1 << a
    else
      s_0 << a
    end
  end
end
s_0.sort_by! { |d| -d }
s_1.sort_by! { |d| -d }

n_0 = s_0.size
n_1 = s_1.size

tmp = 0
sum_0 = [0].concat(s_0.map { |si| tmp += si })
tmp = 0
sum_1 = [0].concat(s_1.map { |si| tmp += si })
ans = 0
(k + 1).times do |i|
  next if i == 0
  # s_1 からi個とる
  x = i
  y = k - i
  if x > n_1
    y += x - n_1
    x = n_1
  end
  if y > n_0
    x += y - n_0
    y = n_0
  end
  sum = sum_1[x] + sum_0[y] + x * x
  ans = sum if sum > ans
  # p [i, s_1[0, i].concat(s_0[0, k - i]), sum]
end

p ans


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

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int arr[3],k;
    for(int i=0;i<3;i++)
        cin >> arr[i];
    cin >> k;
    int count = 0;
    for(int i=0;i<3;i++) {
        if(k <= 0)
            break;
        if(k-arr[i] >= 0){
            if(i==0)
                count += arr[i];
            else if(i==2)
                count -= arr[i];
            k -= arr[i];
        }
        else {
            if(i == 0)
                count += k;
            else if(i == 2)
                count -= k;
            k -= arr[i]; 
        }
    }
    cout << count << "\n";
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int v = 1;
    for (int i = 0; i < n; ++i)
    {
        v = min(v + k, v * 2);
    }
    cout << v;
}


Measured memory_bytes: 256
from math import gcd
import sys
input = sys.stdin.readline

def main():
    n = int(input())

    dict1 = {}
    mod = 1000000007
    cnt00 = 0
    cnt01 = 0
    cnt10 = 0

    for _ in range(n):
        a,b = map(int,input().split())
        if a == 0 and b == 0:
            cnt00 += 1
        elif a == 0:
            cnt01 += 1
        elif b == 0:
            cnt10 += 1
        else:
            c = gcd(a,b)
            if b < 0:
                a *= -1
                b *= -1
            set1 = (a//c, b//c)
            if set1 in dict1:
                dict1[set1] += 1
            else:
                dict1[set1] = 1

    ans = 1

    for k,v in dict1.items():
        a,b = k
        if dict1[(a,b)] == -1:
            continue
        if a > 0:
            if (-b,a) in dict1:
                ans *= 2**v + 2**dict1[(-b,a)] - 1
                dict1[(-b,a)] = -1
            else:
                ans *= 2**v
        else:
            if (b,-a) in dict1:
                ans *= 2**v + 2**dict1[(b,-a)] - 1
                dict1[(b,-a)] = -1
            else:
                ans *= 2**v
        ans %= mod

    ans *= 2 ** cnt01 + 2 ** cnt10 - 1
    ans += cnt00 - 1

    print(ans%mod)

if __name__ == '__main__':
    main()


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

int main(){
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    if (a > b || (n == 1 && a != b))
        printf("0\n");
    else
        printf("%lld\n", (b*1LL*(n-1)+a) - (a*1LL*(n-1)+b)+1);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  long int a,b,c,d;
  long long int ans;
  scanf("%ld%ld%ld%ld", &a,&b,&c,&d);
  ans=b*d;
  if(ans<a*c) ans=a*c;
  if(ans<a*d) ans=a*d;
  if(ans<b*c) ans=b*c;
  printf("%lld", ans);
  return 0;
}


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

//#define int long long
typedef long long ll;
const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    clock_t starttime = clock();
    int D;
    cin >> D;
    vector<int> c(26);
    for (int i=0;i<26;i++) cin >> c[i];
    vector<vector<int>> s(D,vector<int>(26));
    for (int i=0;i<D;i++){
        for (int j=0;j<26;j++){
            cin >> s[i][j];
        }
    }
    vector<int> t(D);
    //初期t[i]の決定
    for (int i=0;i<D;i++) {
        t[i] = i % 26;
    }

    ll oldsum = -INF;
    while (clock()-starttime < 1.9){
        //ここでt[i]を更新していく
        int process = rand()%2;
        if (process == 0){
            int dd = rand()%D;
            int qq = rand()%26;
            int oldval = t[dd];
            t[dd] = qq;
            ll sum = 0;
            vector<int> last(26);
            for (ll i=0;i<D;i++){
                sum += s[i][t[i]];
                last[t[i]] = i+1;
                for (int j=0;j<26;j++){
                    sum -= c[j]*(i+1-last[j]);
                }
            }
            if (sum > oldsum) {
                oldsum = sum;
            } else {
                t[dd] = oldval;
            }
        } else {
            int dd1 = rand()%D;
            int dd2 = min(dd1+13,D);
            int qq1 = t[dd1];
            int qq2 = t[dd2];
            t[dd1] = qq2;
            t[dd2] = qq1;
            ll sum = 0;
            vector<int> last(26);
            for (ll i=0;i<D;i++){
                sum += s[i][t[i]];
                last[t[i]] = i+1;
                for (int j=0;j<26;j++){
                    sum -= c[j]*(i+1-last[j]);
                }
            }
            if (sum > oldsum) {
                oldsum = sum;
            } else {
                t[dd1] = qq1;
                t[dd2] = qq2;
            }
        }
        //=======================       
    }
    for (int i=0;i<D;i++){
        cout << t[i]+1 << "\n";
    }
}

Measured memory_bytes: 3712
using System;
using System.Text;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var length = s.Length;
            var firstAIndex = s.Length;
            var lastZindex = -1;

            for (var i = 0; i < length; i++)
            {
                var c = s[i];

                if (c == 'A')
                {
                    if (i < firstAIndex)
                    {
                        firstAIndex = i;
                    }
                }

                if (c == 'Z')
                {
                    if (lastZindex < i)
                    {
                        lastZindex = i;
                    }
                }
            }

            Console.WriteLine(lastZindex - (firstAIndex - 1));
        }
    }
}

Measured memory_bytes: 26540
n,m = map(int,input().split())
ahoge = []
hanege = []
for i in range(m):
    ai,bi = map(int,input().split())
    if ai == 1:
        ahoge.append(bi)
    if bi == n:
        hanege.append(ai)
ahoge.sort()
hanege.sort()
def bis(i):
    under = 0
    upper = len(hanege)-1
    while under <= upper:
        l = (under+upper)//2
        if i == hanege[l]:
            return 1
        elif i < hanege[l]:
            upper = l-1
        elif i > hanege[l]:
            under = l+1
    return 0
flag = 0
for i in ahoge:
    if bis(i) == 1:
        print("POSSIBLE")
        flag = 1
        break
if flag == 0:
    print("IMPOSSIBLE")

Measured memory_bytes: 11436
#include<cstdio>
 
int main () {
  char a,b,c,d;
  int answer=0;
   scanf("%c", &a);
   scanf("%c", &b);
   scanf("%c", &c);
   scanf("%c", &d);
  int A = a - '0';
  int B = b - '0';
  int C = c - '0';
  int D = d - '0';
  answer=A;
  for(int i=0;i!=2;i++){
  	for(int j=0;j!=2;j++){
  		for(int k=0;k!=2;k++){
  			if(k==1){
            	answer+=D;
            }else{
            	answer-=D;
            }
          if(j==1){
            	answer+=C;
            }else{
            	answer-=C;
            }
          if(i==1){
            	answer+=B;
            }else{
            	answer-=B;
            }
          if(answer==7){
            printf("%d",A);
            if(i==1){printf("%c",'+');}else{printf("%c",'-');}
            printf("%d",B);
            if(j==1){printf("%c",'+');}else{printf("%c",'-');}
            printf("%d",C);
            if(k==1){printf("%c",'+');}else{printf("%c",'-');}
            printf("%d",D);
            printf("%s\n","=7");
          	return 0;
          }
          answer=A;
  		}				
  	}
  }
return 0;
}

Measured memory_bytes: 128