akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define debug(x) cerr<<#x<<" "<<x<<endl;
#define f(i,n) for(ll i=0; i<n; i++)
#define f1(i,n) for(ll i=1; i<=n; i++)
#define fr(i,n) for(ll i=n-1; i>=0; i--)
#define f1r(i,n) for(ll i=n; i>0; i--)
#define mst(arr,val) memset(arr,val,sizeof(arr))
#define all(x) x.begin(),x.end()

typedef long long int ll;
typedef pair<ll,ll> pii;
ll M=1e9+7;
ll M2=998244353;
ll M3 = 1e8;
ll MAX = 5001;
string s = "Everything correct till here!";

void show(vector<ll> v)
{
    for(ll i=0; i<v.size(); i++)
        cout<<v[i]<<" ";
    cout<<"\n";
}
void showrev(vector<ll> v)
{
    for(ll i=0; i<v.size(); i++)
        cout<<v[v.size()-i-1]<<" ";
    cout<<"\n";
}
void showarr(ll arr[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<arr[i]<<" ";
    cout<<"\n";
}
void showpv(vector<pair<ll,ll> > v)
{
    f(i,v.size())
        cout<<v[i].ff<<" "<<v[i].ss<<"\n";
}
int main()
{
    IOS
    ll T = 1,Q=1;
    //cin>>T;
    while(T--)
    {
        ll n; cin>>n;
        ll a[n],b[n],c[n]; f(i,n) cin>>a[i]>>b[i]>>c[i];
        ll dp[n][3]; mst(dp,0);

        f(i,n)
        {
            f(j,3)
            {
                if(i == 0)
                {
                    if(j == 0) dp[i][j] = a[i];
                    else if(j == 1) dp[i][j] = b[i];
                    else dp[i][j] = c[i];
                }
                else
                {
                    f(k,3)
                    {
                        if(j == k) continue;
                        if(j == 0) dp[i][j] = max(dp[i][j], dp[i-1][k]+a[i]);
                        else if(j == 1) dp[i][j] = max(dp[i][j], dp[i-1][k]+b[i]);
                        else dp[i][j] = max(dp[i][j], dp[i-1][k]+c[i]);
                    }
                }
            }
        }
        ll ans = max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
        cout<<ans;
    }
    return 0;
}



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

int main(){
	int N,M;
	cin >>N;
	M=N/2;
	int d[N];
	for(int i=0;i<N;i++){
		cin >>d[i];
	}
	sort(d,d+N);
	cout <<(d[M]-d[M-1])<<endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ

    Scanner sc = new Scanner(System.in);
    String s = sc.next();

    int c0 = 0;
    for (int i = 0; i < s.length(); i++) {
      if (s.charAt(i) == '0') c0++;
    }
    int c1 = s.length() - c0;

    System.out.println(Math.min(c0, c1) * 2);
  }
}


Measured memory_bytes: 26268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pk(x) cout<<(x)<<" ";
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a[100001],b[100001],c[100001],d,n,m,x,y,z,h,w,k,sum,mi=inf,ma=-inf,ans,s,t,l,r,res,tmp,itr,p,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<ll, ll> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<ll,ll> > VP;
P pa;
int main(){
    int H,A;
    cin>>H>>A;
    p((H%A==0)?H/A:H/A+1);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

long long int a ;
long long int b ;

long long int gcd ( ) ;

int main ( )
{
	while ( scanf ( "%lld %lld" , &a , &b ) == 2 ) {
		long long int oa = a ;
		long long int ob = b ;
		long long int tmp = gcd ( ) ;
		printf ( "%lld %lld\n" , tmp , oa / tmp * ob ) ;
	}
	return 0 ;
}

long long int gcd ( )
{
	while ( ( a %= b ) && ( b %= a ) ) ;
	return ( a + b ) ;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int n;
	cin >> n;

	map<string, int> mp;
	string s;

	int max_cnt = 0;
	for(int i = 0; i < n; ++i)
	{
		cin >> s;
		mp[s]++;
		max_cnt = max(max_cnt, mp[s]);
	}

	for(auto& m : mp)
	{
		if (m.second == max_cnt)
		{
			cout << m.first << endl;
		}
	}
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 23808
const main = (input: string) => {
  const strList = input.split('');
  const atcoderStrList = ['A', 'C', 'G', 'T'];
  let matchedNum = 0;
  let isMatched = false;
  let maxNum = 0

  strList.forEach(str => {
    if (atcoderStrList.indexOf(str) >= 0) {
      isMatched = true;
    } else {
      isMatched = false;
    }

    if (isMatched) {
      matchedNum += 1;
    } else {
      matchedNum = 0;
    }

    if (matchedNum > maxNum) {
      maxNum = matchedNum;
    }
  });

  console.log(maxNum)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <numeric>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ll も int も longlongにしてしまう
    #define int long long

    vector<int> vec;

    int tmp;
    cin >> tmp;
    while (cin >> tmp) {
        vec.push_back(tmp);
    }

    cout << *min_element(vec.begin(), vec.end()) << " " <<  
    *max_element(vec.begin(), vec.end()) << " " << 
    accumulate(vec.begin(), vec.end(), 0LL) << endl;

    return 0;
}


Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int( 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong

signed main(){
    int n;
    cin >>n;
    int k;
    cin >> k;
    vector<int> A[n+1];
    REP(i,n+1) A[i].push_back(-1);
    REP(i,n){
        int t;
        int d;
        scanf("%lld%lld",&t,&d);
        A[t].push_back(d);
    }
    REP(i,n+1) sort(A[i].begin() , A[i].end(), [](int x,int y){
        return x > y;
    } );


    vector<int> index2(n+1);
    iota(index2.begin(),index2.end(),0);
    sort(index2.begin(),index2.end(), [&](int x,int y){
        return (A[x][0] > A[y][0]);
    });



    int plus = 1;
    int i = 0;
    while(1){
        if(A[index2[i]][0] == -1) break;
        A[index2[i]][0] += plus;
        plus += 2;
        i ++;
    }


    vector<pair<int,int>> B(n);
    int siz = 0;
    REP(i,n+1){
        itrfor(itr,A[i]){
            if( *itr == -1 ) break;
            B[siz] = make_pair(*itr,i);
            siz ++;
        }
    }
    Sort(B);
    Reverse(B);
    siz = 0;
    int syu = 1;
    set<int> syurui;
    int ans = 0;
    vector<int> index(n+1);
    REP(i,n+1) index[ index2[i]] = i;
    REP(i,n){
        if(syu -1 <= index[B[i].se]){
            if(siz + index[B[i].se] -  syurui.size() + 1 <= k){
                syu = index[B[i].se] + 1;
                ans += B[i].fi;
                siz ++;
                syurui.insert(index[B[i].se]);
            }
        }
        else{
            if(syurui.find( index[B[i].se]) == syurui.end() ){
                ans += B[i].fi;
                siz ++;
                syurui.insert(index[B[i].se]);                
            }
            else if(siz + 1 + syu - syurui.size() <= k){
                ans += B[i].fi;
                siz ++;                 
            }

        }
        if(siz ==k) break;
    }
    cout << ans << endl;

}

Measured memory_bytes: 12672
#include <stdio.h>
#include <math.h>
int main(int argc, char const *argv[]) {
  int n,i=0,sum=0,x;
  scanf("%d",&n );
  x=n;
  for (i = 0; n > 0;) {
    i=n%10;
    sum+=i;
    n=n/10;
  }
  x=fmod(x,sum);
  //ここまではおkz
  if (x==0) {
    printf("Yes\n");
    return 0;
  }
  printf("No\n");
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  int64_t A;
  int64_t ans=0;
  int64_t sum=0;
  map<int64_t,int> m;
  for(int i=0;i<N;i++){
    cin >> A;
    sum+=A;
    if(sum==0){
      ans++;
    }
    if(m.count(sum)){
      ans+=m.at(sum);
      m.at(sum)++;
    }else{
      m[sum]=1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15900
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
using namespace std;
#define ll int64_t
#define REP(i, n) for (ll i=0; i<n; i++)

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

    ll N, M;
    cin >> N;
    map<ll, ll> D, T;
    REP(i, N){
        ll d;
        cin >> d;
        if (D.count(d) == 0) {
            D[d] = 0;
        }
        D[d]++;
    }
    cin >> M;
    REP(i, M){
        ll t;
        cin >> t;
        if (T.count(t) == 0) {
            T[t] = 0;
        }
        T[t]++;
    }

    bool ans = true;
    for (auto e : T) {
        if (T[e.first] > D[e.first]) ans = false;  
    }

    if (ans) cout << "YES\n";
    else cout << "NO\n";
}

Measured memory_bytes: 25216
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int r,D,x;
    cin>>r>>D>>x;
    for(int i=0;i<10;i++){
        x = r*x - D;
        cout<<x<<endl;
    }
    return 0;
}



Measured memory_bytes: 3660
h,w=map(int,input().split())
hw=[input() for i in range(h)]
thw=[]
for i in range(h):
    if hw[i].count('#')!=0:
        thw+=[hw[i]]
ans=['']*len(thw)
for i in range(w):
    flg=False
    for j in range(len(thw)):
        if thw[j][i]=='#':
            flg=True
            break
    if flg:
        for j in range(len(thw)):
            ans[j]+=thw[j][i]
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>
#include <set>
#include <functional>
#include <list>

#define MOD (1000000000 + 7)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 3000000;

long long fac[MAX], finv[MAX], inv[MAX];

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 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;}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

map<ll,ll> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

//O(√n)
//整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
   for(ll i=2;i<=(ll)(l);i++) { //
        if(n%i==0){
            prime_factorize(i);prime_factorize(ll(n/i));return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[n]++;return;
} 

vector<ll> divisor;
void list_divisor(ll n) {
    divisor.clear();
    for(int i = 1; i*i <= n; i++) {
        if(n % i == 0) {
            divisor.push_back(i);
            if(i*i != n) divisor.push_back(n/i);
        }
    }
    sort(divisor.begin(), divisor.end());
}

vector<bool> Eratosthenes(ll N) {
    vector<bool> primes(N, true);
    vector<ll> ret;
    primes[0] = false;
    primes[1] = false;
    for (ll i=2; pow(i,2)<=N; i++) {
        if (primes[i]) {
            for(int j=2; i*j<=N; j++) primes[i*j] = false;
            ret.push_back(primes[i]);
        }
    }
    return primes;//ret;
}

int main() {
    ll X;
    cin >> X;

    if(X >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3720
import itertools
n,m,q=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(q)]
ac=tuple([i for i in range(1,m+1)])
ans=0
for A in list(itertools.combinations_with_replacement(ac,n)):
    count=0
    for j in range(q):
        if A[a[j][1]-1]-A[a[j][0]-1]==a[j][2]:
            count+=a[j][3]
    ans=max(ans,count)
print(ans)

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

int n, k, r, len;
set <int> s;

int main() {
	ios::sync_with_stdio(0);
	n = 7;
	cin >> k;
	r = n % k;
	len = 1;
	while(r != 0) {
		if(s.find(r) != s.end()) {
			cout << -1 << endl;
			return 0;
		}
		s.insert(r);
		n = r * 10 + 7;
		r = n % k;
		len++;
	}
	cout << len << endl;
	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

int main(void){
    string S; cin >> S;
    auto v = split(S, '/');
    int d = 100*toInt(v[1])+toInt(v[2]);
    cout << (d <= 430 ? "Heisei" : "TBD") << endl;
    return 0;
}

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

int main() {
    int n;
    cin>>n;
    map<int,int> a,b;
    for (int i=0;i<n;i++) {
        int x;cin>>x;
        if (i%2==0)
            a[x]++;
        else
            b[x]++;
    }
    vector<pair<int,int>> c,d;
    for (auto p:a)
        c.push_back({p.second,p.first});
    for (auto p:b)
        d.push_back({p.second,p.first});
    sort(c.begin(),c.end(),greater<pair<int,int>>());
    sort(d.begin(),d.end(),greater<pair<int,int>>());
    int ans;
    n/=2;
    c.push_back({0,0});
    d.push_back({0,0});
    if (c[0].second==d[0].second)
        ans=min(n-c[0].first+n-d[1].first,n-c[1].first+n-d[0].first);
    else
        ans=n-c[0].first+n-d[0].first;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6136
#include <iostream>
using namespace std;
int main(){
  int a, b, c, d, e, k; cin >> a >> b >> c >> d >> e >> k;
  int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10;  
  
  a1 = b-a;
  a2 = c-a;
  a3 = d-a;
  a4 = e-a;
  a5 = c-b;
  a6 = d-b;
  a7 = e-b;
  a8 = d-c;
  a9 = e-c;
  a10 = e-d;
  
  if (a1 > k || a2 > k || a3 > k || a4 > k || a5 > k|| a6 > k || a7 > k || a8 > k || a9 > k || a10 > k){
    cout << ":(" << endl;
  }else{
    cout << "Yay!" << endl;
  }
  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <array>
#include <map>
#include <set>

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int left = a + b;
    int right = c + d;
    string ret = (left > right ? "Left" : left < right ? "Right" : "Balanced");
    cout << ret << endl;
}


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

int N;

int f(int a,int b,int c){
    if(a*a == b*b + c*c || b*b == a*a + c*c || c*c == a*a + b*b){
        return 1;
    }
    else return 0;
}

int main(void){
    int i=0;
    scanf("%d",&N);
    for(i=0;i<N;i++){
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);
        if(f(a,b,c)==1)printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

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


int N, L , a[100005];
int main() {
	
	cin>>N>>L;
	for(int i = 0; i < N ; i++){
		cin>>a[i];
	}
	
	int mx = 0;
	int t = -1;
	for(int i = 0; i < N-1 ; i++){
		if(mx < a[i] + a[i+1]){
			mx = a[i] + a[i+1];
			t = i;
		}
	}
	
	if(mx < L){
		cout<<"Impossible"<<endl;
		return 0;
	}
	
	cout<<"Possible"<<endl;
  for(int i = 0; i < t ; i++){
    cout<<i+1<<endl;
  }
   for(int i = N-1; t < i ; i--){
    cout<<i<<endl;
  }
	
	
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
using namespace std;
int main()
{
	int a,b,c,x,n=0;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
			for(int k=0;k<=c;k++)
				if(x==i*500+j*100+k*50) n++;
	cout<<n;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,m,dir[8][2]={{1,0},{0,1},{-1,0},{0,-1},{-1,-1},{1,-1},{1,1},{-1,1}};
char mp[101][101];
void dfs()
{
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            int num=0;
            if(mp[i][j]=='#')cout<<'#';
            if(mp[i][j]=='.')
            {
                for(int k=0;k<8;k++)
                {
                    int x0=i+dir[k][0];
                    int y0=j+dir[k][1];
                    if(mp[x0][y0]=='#')num++;
                }
            cout<<num;
            }

        }
        cout<<endl;
    }

}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            cin>>mp[i][j];
    dfs();
    return 0;
}

Measured memory_bytes: 888
/*    FAILING IS AN ART
       AND 
     I HAVE MASTERED IT
*/
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
#define ld long double
using namespace std;

int main()
{ 


    fast;
ll ct=0;

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

while(n>0)
n/=k,ct++;
cout<<ct<<endl;


}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>
#include<cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define rep(i,n) FOR(i,0,n)

struct edge{int to,cost;};

void dump(ll *b,int n){
	for(int i=0;i<n;i++){
		cout << b[i] << " ";
	}
	cout << "\n";
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n,x;
	cin >> n >> x;
	if(x==1 || x==2*n-1){
		puts("No");
		return 0;
	}
	if(n==2){
		puts("Yes\n1\n2\n3");
		return 0;
	}
	int nb=2*n-1; //bottomの数
	int ans[nb];

	ans[nb/2]=x;
	ans[nb/2 -1]=1;
	ans[nb/2 +1]=nb;
	int l,r,skip;
	if(x==2){
		ans[nb/2-2]=3;
		skip=3;
		l=nb/2-2;
		r=nb/2+2;
	}else{
		ans[nb/2+2]=x-1;
		skip=x-1;
		l=nb/2-1;
		r=nb/2+3;
	}
	int num=2;
	for(int i=0;i<l;i++){
		while(num==x || num==skip) num++;
		ans[i]=num++;
	}

	for(int i=r;i<nb;i++){
		while(num==x || num==skip) num++;
		ans[i]=num++;
	}
	cout << "Yes" << "\n";
	rep(j,nb){
		cout << ans[j] << "\n";
	}

	return 0;
}

Measured memory_bytes: 2304
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    q = int(readline())
    if q == -1:
        return False
    x = q/2
    lim = 0.00001 * q
    while abs(x**3 - q) >= lim:
        x = x - (x**3 - q)/(3*x**2)
    write("%.16f\n" % x)
    return True
while solve():
    ...


Measured memory_bytes: 5672
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            } else {
                for (int i = 0; i < H; i++) {
                    for (int j = 0; j < W; j++) {
                        System.out.print("#");
                    }
                    System.out.print("\n");
                }
                System.out.print("\n");
            }
        }
    }
}


Measured memory_bytes: 36692
def list_join(l: []):
    word_list = ['dream', 'dreamer', 'erase', 'eraser']
    nl = []
    for ele in l:
        for word in word_list:
            nl.append(ele + word)
    return nl


def main():
    S = str(input())
    # S = 'dreamerer'
    lst = ['']
    while True:
        lst = list_join(lst)
        lst = list(filter(lambda word: S.startswith(word), lst))
        if len(lst) == 0:
            print('NO')
            return
        if S in lst:
            print('YES')
            return


if __name__ == '__main__':
    main()


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


def main():
    x1, y1, x2, y2 = map(int, input().split())
    a = x2 - x1
    b = y2 - y1
    x3 = x2 - b
    y3 = y2 + a
    x4 = x1 - b
    y4 = y1 + a
    
    print(' '.join(map(str, [x3, y3, x4, y4])))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int mx[] = {1, 0, -1, 0};
int my[] = {0, 1, 0, -1};
 
signed main()
{
  int N;
  int X[205], Y[205];
  int n, d;
  int miny, maxy, minx, maxx;
  while(cin >> N, N) {
    miny = maxy = minx = maxx = X[0] = Y[0] = 0;
    for(int i = 1; i < N; i++) {
      cin >> n >> d;
      X[i] = X[n] + mx[d], Y[i] = Y[n] + my[d];
      miny = min(miny, Y[i]); minx = min(minx, X[i]);
      maxy = max(maxy, Y[i]); maxx = max(maxx, X[i]);
    }
 
    cout << maxx - minx + 1 << " " << maxy - miny + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3008
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
#define ALL(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}

int main(void) {
    int n;
    cin >> n;
    int N = n / 4 + 1;
    rep(i, n) {
        rep(j, n) {
            if (i * 4 + j * 7 == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_mul(int a,int b)
{
    return (a*b)%MOD;
}

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


const int N =2e5+10;
vi g[N];
int sz[N];
int fact[N];
int ifact[N];

void pre()
{
     //Factorial and Inverse Factorial
    fact[0] = 1;
    for(int i=1;i<N;i++) fact[i] = mod_mul(fact[i-1],i);
        
    ifact[N-1] = mod_pow(fact[N-1],MOD-2);
    for(int i=N-2;i>=0;i--) ifact[i] = mod_mul(ifact[i+1],i+1);  
}

int res1= 1;

void dfs(int node,int par = 0)
{
   sz[node] = 1;
    
    for(auto x : g[node])
        if(x!=par)
    {
        dfs(x,node);
        sz[node]+=sz[x];
    }
    
    res1 = mod_mul(res1,fact[sz[node]-1]);
    
    for(auto x : g[node])
        if(x != par)
        res1 = mod_mul(res1,ifact[sz[x]]);
}

int ans[N];
int n;
int sz2[N];


void dfs2(int node,int par = 0)
{
    int temp = ans[node];
    
    temp = mod_mul(temp,ifact[sz[node]-1]);
    
    for(auto x : g[node])
    {
        if(x == par) continue;
        
        int ttemp = temp;
        
        int newsz = sz[node] - sz[x];
        sz[node] = newsz;
        
        ttemp = mod_mul(ttemp,fact[sz[x]]);
        ttemp = mod_mul(ttemp,fact[newsz-1]);
        
        ttemp = mod_mul(ttemp,ifact[sz[x]-1]);
        ttemp = mod_mul(ttemp,fact[n-1]);
        ttemp = mod_mul(ttemp,ifact[newsz]);
        sz[x] = n;
        
        ans[x] = ttemp;
        dfs2(x,node);
        
        sz[x] = sz2[x];
        sz[node] = n;
    }
    
   
}

void solve()
{
    cin >> n;
    
    int u,v;
    
    f(i,n-1)
    {
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
     
    dfs(1);
    
    ans[1] = res1;
    
    for(int i=1;i<=n;i++) sz2[i] = sz[i];
    
    dfs2(1);
    
    for(int i=1;i<=n;i++) cout << ans[i] << '\n';
}

signed main()
{
    pre();
    fast;
    solve();
}

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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define output(x) cout << ( x ? "YES" : "NO" ) << '\n' ;
#define mxn 100005
using namespace std;

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

int32_t main()
{
	FLASH
	int t = 1;
	// cin >> t;
	while(t--){
		solve();
	}
	return 0;
}



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

typedef ostringstream OSS;
typedef istringstream ISS;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<double> VD;
typedef vector<VD> VVD;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<PII> VPII;
typedef vector<PDD> VPDD;

#define fst first
#define snd second
#define Y first
#define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x) (x).begin(),(x).end()
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a) { OSS oss; oss << a; return oss.str(); };

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

const double EPS = 1e-6;

VD xs;
VD ys;
int N;

double distance(int i, int j) {
    double x = xs[i] - xs[j];
    double y = ys[i] - ys[j];
    return sqrt(x * x + y * y);
}

bool is_over_circle(int i, int j) {
    return distance(i, j) < 2.0;
}

VPDD calc_circle(int i, int j) {
    double d = distance(i, j);
    double a = acos(d / 2.0);
    double b = acos(abs(xs[j] - xs[i]) / d);
    double sita = a + b;
    PDD p, q;
    p.X = xs[i] + cos(sita);
    p.Y = ys[i] + sin(sita);
    q.X = (xs[i] + xs[j]) - p.X;
    q.Y = (ys[i] + ys[j]) - p.Y;
    return VPDD({p, q});
}

int count_inner_points(PDD circle) {
    int cnt = 0;

    for (int i = 0; i < N; i++) {
        double x = circle.X - xs[i];
        double y = circle.Y - ys[i];
//        printf("--- %.3f %.3f %.3f %.3f\n", x, y, x * x + y * y, sqrt(x * x + y * y));
        cnt += x * x + y * y < 1.0 + EPS;
    }

    return cnt;
}

int solve() {
    int res = 1;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (is_over_circle(i, j)) {
                VPDD ps = calc_circle(i, j);

                for (auto p : ps) {
//                    printf("%.3f %3f\n", p.X, p.Y);
                    int cnt = count_inner_points(p);
                    res = max(res, cnt);
                }
            }
        }
    }

    return res;
}

int main(void) {
    while (cin >> N, N) {
        xs.clear();
        ys.clear();
        xs.resize(N);
        ys.resize(N);
        for (int i = 0; i < N; i++) {
            cin >> xs[i] >> ys[i];
        }
        
        cout << solve() << endl;
    }

	return 0;
}

Measured memory_bytes: 1324
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <array>
#include <bitset>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = Mint(2).pow(n);
  Mint pow(long long n) const {
    if (n==0) return Mint(1);
    Mint y = pow(n>>1); // pow(n/2)を計算する
    y *= y;
    if (n%2==1) y *= *this;
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return a.pow(mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    Mint one = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= (i + one);
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

class UnionFind {
private:
  int n;
  std::vector<int > parent;
public:
  UnionFind(int num) :
    n(num) {
      parent = std::vector<int> (n);
      for (int i=0; i<n; i++) {
        parent[i] = i;
      }
    }
  int GetRoot(int i) {
    int n = i;
    while(parent[n]!=n) {
      n = parent[n];
    }
    parent[i] = n;
    return n;
  }

  bool SameGroup(int n, int m) {
    n = this->GetRoot(n);
    m = this->GetRoot(m);
    return n==m;
  }

  bool Unite(int n, int m) {
    n = this->GetRoot(n);
    m = this->GetRoot(m);
    if (n==m) return false;
    parent[n] = m;
    return true;
  }
};

int getgcd(int a, int b) {
  int max = std::max(a, b);
  int min = std::min(a, b);
  if (min==0) return max;
  return getgcd(min, max%min);
}

int main() {
  long long X, Y;
  std::cin >> X >> Y;
  printf("%s\n",(abs(X-Y)<=1)?"Brown":"Alice");
  return 0;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	string S;
	while (getline(cin, S)) {
		if (S == ".") break;
		stack<char>sta;
		bool flag = false;
		for (ll i = 0; i < S.size(); i++) {
			if (S[i] == '(') sta.push('(');
			if (S[i] == '[')sta.push('[');
			if (S[i] == ')') {
				if (sta.size() == 0 || sta.top() != '(') {
					flag = true;
					break;
				}
				sta.pop();
			}
			if (S[i] == ']') {
				if (sta.size() == 0 || sta.top() != '[') {
					flag = true;
					break;
				}
				sta.pop();
			}
		}
		if (!flag&&sta.empty())
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}
}



Measured memory_bytes: 3140
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;

ll seg[1<<20] = {};
int V;

void init(int n){
  V = 1; while(n>V)V<<=1;
}

ll set(int p, ll v){
  int cur = V-1 + p;
  seg[cur] = v;
  while(cur){
    cur = (cur-1)/2;
    if(seg[cur] >= v)break;
    seg[cur] = v;
  }
  return v;
}

ll get(int a, int b, int k, int l, int r){
  if(r<=a || b<=l)return 0;
  if(a<=l && r<=b)return seg[k];
  ll vl = get(a,b,2*k+1,l,(l+r)/2);
  ll vr = get(a,b,2*k+2,(l+r)/2,r);
  return max(vl,vr);
}

int n, a[100100];

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

  init(n);
  ll res = 0;
  for(int i=0;i<n;i++){
    res = max(res,set(a[i]-1,get(0,a[i]-1,0,0,V) + a[i]));
  }

  cout << (ll)n*(n+1)/2 - res << endl;
}

Measured memory_bytes: 5044
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int X = scan.nextInt();
		int N = scan.nextInt();
		int[] box = new int[N];
		int con=0;
		int min = X+100;
		int judge=0;
		int nbox;
		
		for(int i=0;i<N;i++) {
			box[i] = scan.nextInt();
			if(X==box[i]) {
				con=1;
			}
		}
		
		if(con==0) {
			System.out.print(X);
		}
		else {
			for(int i=1;i<=200-X;i++) {
				int a = X-i;
				int b = X+i;
				int acount=0;
				int bcount=0;
				if(a<=min||b<=min) {
					acount=0;
					bcount=0;
					for(int j=0;j<N;j++) {
						if(box[j] != a) {
							acount += 1;
						}
						if(box[j] != b) {
							bcount += 1;
							
							
						}
					}
					if(acount==N) {
						min=a;
						break;
					}
					else if(bcount==N) {
						min=b;
						break;
					}
				}
				
			}
			System.out.print(min);
		}



	}

}

Measured memory_bytes: 36004
#include<stdio.h>
#include<set>
#include<vector>
using namespace std;
typedef long long ll;
int n,m,fa[200100],one[200100],zero[200100],dsu[200100];
ll res;
int find(int x){return dsu[x]==x?x:dsu[x]=find(dsu[x]);}
struct node{
	int x;
	node(int X){x=X;}
	friend bool operator <(const node &x,const node &y){
		ll X=1ll*one[x.x]*zero[y.x],Y=1ll*one[y.x]*zero[x.x];
		return X!=Y?X<=Y:x.x<y.x;
	}
};
set<node>s;
void merge(int x,int y){
	x=find(x),y=find(y);
	if(x!=m)s.erase(node(x));
	res+=1ll*zero[y]*one[x],dsu[y]=x,zero[x]+=zero[y],one[x]+=one[y];
	if(x!=m)s.insert(node(x));
}
int main(){
	scanf("%d",&n);
	for(int i=2;i<=n;i++)scanf("%d",&fa[i]);
	for(int i=1,x;i<=n;i++)scanf("%d",&x),dsu[i]=i,(x?one[i]:zero[i])++;
	for(int i=2;i<=n;i++)s.insert(i);
	while(!s.empty()){
		int x=s.begin()->x;s.erase(s.begin());
		merge(fa[x],x);
	}
	printf("%lld\n",res);
	return 0;
} 

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

#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define deb(x) cout << #x << " " << x << endl;
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define ll long long
#define pb push_back
#define endl "\n"
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007


int main(){
	NINJA;

	long double r; cin >> r;

	long double ans = (double)2*r*(double)3.14159265358979323846;

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

Measured memory_bytes: 3824
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

bool Doable(ll N, ll K, const vector<ll> &A, const vector<ll> &F, ll x) {
  ll cnt = 0;
  for (int i = 0; i < N; ++i) {
    ll a = A[i];
    ll f = F[i];
    // while (a * f > x) {
    //   --a;
    //   ++cnt;
    // }
    ll na = min(a, x / f);
    cnt += a - na;
  }
  if (cnt <= K) return true;
  else return false;
}

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  vector<ll> F(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  for (int i = 0; i < N; ++i) {
    cin >> F[i];
  }
  
  sort(A.begin(), A.end());
  sort(F.begin(), F.end());
  reverse(F.begin(), F.end());

  ll p = -1;  // NG
  ll q = ll(1e13); // OK
  while (p + 1 < q) {
    ll mid = (p + q) / 2;
    if (Doable(N, K, A, F, mid)) {
      q = mid;
    } else {
      p = mid;
    }
  }
  cout << q << endl;
  
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <math.h>
using namespace std;

const int MAX_N=50;
int n,m,MIN=8101919,list[3][MAX_N];
string s[MAX_N];

int main(){
	cin >> n >> m;
	for(int i=0;i<n;i++){
		cin >> s[i];
		for(int j=0;j<m;j++){
			if(s[i][j]!='W') list[0][i]++;
			if(s[i][j]!='B') list[1][i]++;
			if(s[i][j]!='R') list[2][i]++;
		}
	}
	int c=0,sum=0;
	for(int i=1;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=0;k<n;k++){
				if(k==i) c++;
				else if(k==j) c++;
				sum+=list[c][k];
			}
			MIN=min(MIN,sum);
			c=0;
			sum=0;
		}
	}
	
	cout << MIN << endl;
	return 0;
}

Measured memory_bytes: 3196
#include<stdio.h>
int main()
{
	int n,i,m=0;
	char s[54];

	scanf("%d%s",&n,s);
	for(i=0;i<n;i++)
		if((s[i]=='A')&&(s[i+1]=='B')&&(s[i+2]=='C'))
			m++;
	printf("%d",m);
	return 0;
}

Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

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

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

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

use std::collections::HashSet;

fn main() {
    input! {
        n: usize,
        a: [i32; n],
    }
    let mut s = HashSet::new();
    for elm in a { s.insert(elm); }
    println!("{}", if s.len() == n {"YES"} else {"NO"});
}


Measured memory_bytes: 14588
# 入力を受け取る
N, K = input().strip().split()
N, K = [int(N), int(K)]
S = [None] + list(input().strip())

# 操作前のSの中でR→L, L→Rの切り替えの数、幸福な人の数を数える。
# 例えば、'RLR'の場合は2
num_dirchange = 0  # 切り替えの数
num_happy = 0
for i in range(1, N+1): # i = 1, 2, ..., N
    # 方向切り替えの数
    if i > 1 and S[i] is not S[i-1]:
        num_dirchange += 1
    # 幸福な人の数
    if S[i] is 'L':
        if i > 1 and S[i-1] is 'L':
            num_happy += 1
    if S[i] is 'R':
        if i < N and S[i+1] is 'R':
            num_happy += 1

# 1回の操作で2箇所の切り替えを減らすことができ、
# 幸福な人を2人増やすことができる。
# つまり、切り替えの数が2*K以上の場合は、K回の操作で幸福な人を2*K人増やせる
if num_dirchange >= 2 * K:
    num_happy = num_happy + 2*K
else:
    num_happy = N - 1  # RRR...Rの場合右端、LLL...Lの場合左端の人以外は幸福

print(num_happy)

Measured memory_bytes: 4792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

typedef tuple<int,int,int> T;
vector<P> path[1100005];
vector<int> nex[220000];
vector<int> con[220000];
int dis[220000];
bool used_path[220000],used_node[220000];
queue<P> q1;

class union_find_tree{
private:
	const int uft_N=220005;
	queue<int> uft_q1;
	vector<int> uft_parent;
	vector<int> uft_num;
public:
	union_find_tree(int uft_n){
		uft_parent.assign(uft_n,-1);
		uft_num.assign(uft_n,0);
	}
	union_find_tree(){
		uft_parent.assign(uft_N,-1);
		uft_num.assign(uft_N,0);
	}

	void clear(int pos){
		uft_parent[pos]=-1,uft_num[pos]=0;
	}

	int check_parent(int uft_x){
		if(uft_parent[uft_x]!=-1){
			uft_q1.push(uft_x);
			return check_parent(uft_parent[uft_x]);
		}
		int uft_a;
		while(!uft_q1.empty()){
			uft_a=uft_q1.front(),uft_q1.pop();
			uft_parent[uft_a]=uft_x;
		}
		return uft_x;
	}

	bool connect(int uft_x,int uft_y){
		uft_x=check_parent(uft_x),uft_y=check_parent(uft_y);
		if(uft_x==uft_y)return true;
		if(uft_num[uft_x]>uft_num[uft_y])swap(uft_x,uft_y);
		uft_parent[uft_x]=uft_y;
		uft_num[uft_y]+=uft_num[uft_x];
		return false;
	}
};

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>a>>b>>c;
		a--,b--,c--;
		path[c].push_back(make_pair(a,b));
	}
	union_find_tree ua;
	map<int,int> m1;
	int cnt=0;
	for(i=0;i<1e6;i++){
		if(path[i].empty())continue;
		m1.clear();
		for(auto node:path[i]){
			ua.connect(node.first,node.second);
		}
		for(auto node:path[i]){
			for(j=0;j<2;j++){
				a=ua.check_parent(node.first);
				if(m1.find(a)==m1.end())m1[a]=cnt++;
				nex[node.first].push_back(m1[a]);
				con[m1[a]].push_back(node.first);

				swap(node.first,node.second);
			}
		}
		for(auto node:path[i]){
			ua.clear(node.first);
			ua.clear(node.second);
		}
	}

	memset(dis,-1,sizeof(dis));
	q1.push(make_pair(0,0));
	while(!q1.empty()){
		int pos,s;
		tie(pos,s)=q1.front();
		q1.pop();
		if(dis[pos]!=-1 && dis[pos]<s)continue;
		dis[pos]=s;
		for(auto ta:nex[pos]){
			if(used_path[ta])continue;
			used_path[ta]=true;
			for(auto to:con[ta]){
				if(dis[to]!=-1 && dis[to]<s+1)continue;
				if(used_node[to])continue;
				used_node[to]=true;
				q1.push(make_pair(to,s+1));
			}
		}
	}
	cout<<dis[n-1]<<endl;
}


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


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int m, n, s;
  char c;
  cin>>n>>m;
  bool no = false;
  string ans;
  rep(i, n) ans+='a';
  rep(i, m){
    cin>>s>>c;
    if(ans.at(s-1)=='a') {
      ans.at(s-1)=c;
    }
    else{
      if(ans.at(s-1)==c){
        continue;
      }
      else{
        no=true;
        break;
      }
    }
  }
  rep(i, n){
    if(ans.at(i)=='a'){
      if(i==0 && n!=1) ans.at(i)='1';
      else ans.at(i)='0';
    }
  }
  if(ans.at(0)=='0' && n>1) no=true;
  if(no) cout<<-1<<endl;
  else cout<<ans<<endl;
}

Measured memory_bytes: 3636
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		char[] C = sc.next().toCharArray();
		char c = C[0];
		c ++;
		System.out.println(c);

	}
}

Measured memory_bytes: 19924