akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s; i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;


int main(){
    int n, cnt = 0; cin >> n;
    map<int, int> mp;
    REP(i, n){
        int a; cin >> a;
        ++mp[a];
    }
    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
        if(itr->second % 2) ++cnt;
    }
    cout << cnt << "\n";
    return 0;
}


Measured memory_bytes: 4864
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <map>
#include <vector>
#include <set>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cctype>
#include <cmath>
#include <fstream>

using namespace std;

typedef long long ll;
#define REP(i,k) for(int (i)=0;(i)<(k);(i)++)
#define INF ~(1<<31)
#define CLR(a) memset((a),0,sizeof((a)))
#define EPS 1e-9
#define DBG 1
#define D(s,v) if(DBG) cout<<(s)<<": "<<(v)<<endl;
#define DVEC(s,v) if(DBG) {cout<<(s)<<": "; for(int i=0;i<(v).size();i++) cout<<(v)[i]<<" "; cout<<endl;}
#define DARR(s,v,n) if(DBG) {cout<<(s)<<": "; for(int i=0;i<n;i++) cout<<(v)[i]<<" "; cout<<endl;}


int main(){
    ios_base::sync_with_stdio(0);
    int H, W;

    while(cin>>H>>W){
        char grid[H][W];
        int black = 0;

        for(int i=0;i<H;i++)
        for(int j=0;j<W;j++){
            cin>>grid[i][j];
            if(grid[i][j]=='#') black++;
        }


        queue<pair<pair<int,int>,int> > q;
        q.push(make_pair(make_pair(0,0),1));

        bool vis[H][W]; CLR(vis);
        vis[0][0]=1;

        int di[] = {0,0,1,-1};
        int dj[] = {-1,1,0,0};        

        int shortest = -1;

        while(!q.empty()){
            pair<pair<int,int>,int> cur = q.front();
            q.pop();

            int curi = cur.first.first;
            int curj = cur.first.second;
            int dist = cur.second;

            if(curi == H-1 && curj == W-1){
                shortest = dist;
                break;
            }

            for(int k=0;k<4;k++){
                int ni = curi + di[k];
                int nj = curj + dj[k];
                if(ni>=0 && ni<H && nj>=0 && nj<W && grid[ni][nj]=='.' && !vis[ni][nj]){
                    vis[ni][nj] = 1;
                    q.push(make_pair(make_pair(ni,nj),dist+1));
                }
            }
        }

        if(shortest==-1) cout<<-1<<endl;
        else cout<<(H*W)-black-shortest<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i=0,j=0,k=0;
    int a[30];
    cin>>n;
    while(n!=0)
    {
        m = n%10;
        if(m==7)
        {
            k++;
            break;
        }
        n/=10;
    }
    if(k==0)
    {
        cout<<"No";
    }
    else
    {
        cout<<"Yes";
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define lol long long
#define dob double
#define ull unsigned long long
using namespace std;
const double eps = 1e-7;
const int N=3e5+10;
const int M=4e3+10;
const int mod=1222;
const int oo=214748364;
const int INF=0x7fffffff;
const double DOF=999999999.99999;
#define ak * 
inline lol read() {
    lol zzl=0,ioi=1; char ch=' ';
    while(!isdigit(ch)){ch=getchar();if(ch=='-')ioi=-1;}
    while(isdigit(ch)){zzl=zzl*10+ch-'0';ch=getchar();}
    return zzl ak ioi;
}
int n,a[N];
bool check(int x) {
	 for(register int i=0;i<n-1;i++) {
	 	if((a[n+i]>x&&a[n+i+1]>x)||(a[n-i]>x&&a[n-i-1]>x)) return 0;
	 	else if((a[n+i]<=x&&a[n+i+1]<=x)||(a[n-i]<=x&&a[n-i-1]<=x)) return 1;
	 }
	 return a[1]<=x;
}
int main()
{
	n=read();
	for(register int i=1;i<=2*n-1;i++)
		a[i]=read();
	int l=0,r=2*n-1,ans=0;
	while(l<=r) {
		int mid=(l+r)>>1;
		if(check(mid)) r=mid-1,ans=mid;
		else l=mid+1;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define MOD 1000000007
#define intMAX 9223372036854775807
#define intMIN -9223372036854775808
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
 
int n;
int M=1e5+1;
 
//bit全探索
vi bt;
void setbit(int i){
  bt.clear();
  for(int tmp=0;i>0;i/=2){
    if (i%2==1) bt.push_back(tmp);
    tmp++;
  }
}
 
 
 
 
int main(){
  int ans=0,q;
  cin >>n;
  n++;
  int nlg=ceil(log2(n));
  vi V(n),W(n);
  REP(i,n-1) cin>>V[i+1]>>W[i+1];
 
  cin >>q;
  vi u(q),L(q);
  REP(i,q) cin>>u[i]>>L[i];
 
  //上半分
  int nhi=nlg-(nlg/2);
  if (nhi==9)nhi=10;
  vvi data(1<<nhi, vi(M));  // N * M の2次元配列
 
  for(int i=1;i<(1<<nhi);i++){
    for(int j=0;j<M;j++){
      if ((j-W[i])>=0)
      {
        data[i][j]=max(data[i/2][j-W[i]]+V[i],data[i/2][j]);
      }
      else
      {
        data[i][j]=data[i/2][j];
      }
    }
  }
 
 
int uiv[10];
int wuiv=0;
 
 
//下半分
for(int loop=0;loop<q;loop++){
  int uidx=u[loop];
  if (uidx<(1<<nhi)){
    cout<<data[uidx][L[loop]]<<endl;
  }else{//上＋下
    int maxval=0;
    //vi uiv;
    int nn=0;
    wuiv=0;
    for(;;uidx/=2){
      if (uidx<(1<<nhi))break;
      uiv[wuiv]=uidx;
      wuiv++;
      nn++;
    }
 
    int bn=1<<nn;
    for(int i=0;i<bn;i++){
      setbit(i);
      int tmpw=0;
      int tmpv=0;
      /*
      for(int j=0;j<nn;j++){
        if (i&(1<<j)){
          tmpv+=V[uiv[j]];
          tmpw+=W[uiv[j]];
        }
      }
      */
      for (auto j : bt) {
        tmpv+=V[uiv[j]];
        tmpw+=W[uiv[j]];
      }
      if (tmpw<=L[loop]){
        maxval=max(data[uidx][L[loop]-tmpw]+tmpv,maxval);
      }
    }
 
    cout<<maxval<<endl;
  }
 
 
 
 
 
 
 
 
 
 
 
 
}
 
 
  return 0;
}

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

int main() {
    int N;
    string S, T;
    cin >> N >> S >> T;
    rep(i, N) {
        cout << S[i] << T[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N;

int main() {
    while (true) {
        cin >> N;
        if (N == 0) break;

        vi A(N);
        ll sum = 0;
        for (int i = 0; i < N; i++) {
            cin >> A[i];
            sum += A[i];
        }

        float m = sum / N;

        int ans = 0;
        for (int i = 0; i < N; i++) {
            if (A[i] <= m) ans++;
        }

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



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

template<class T>
ostream& operator<<(ostream& os,vector<T> const& v){for(auto itr=v.begin();itr!=v.end();++itr){if(itr!=v.begin())os<<' ';os<<*itr;}return os;}

signed main(){

  int n;
  cin>>n;
  
  using T = tuple<int,int,char,int64_t,string>;
  vector<T> a;
  a.reserve(n);
  for(int i=0;i<n;++i){
    int v,w;
    char t;
    int64_t d;
    string s;
    cin>>v>>w>>t>>d>>s;
    a.emplace_back(v,w,t,d,s);
  }
  sort(a.begin(),a.end());
  for(auto& ai:a){
    int v,w;
    char t;
    int64_t d;
    string s;
    tie(v,w,t,d,s) = ai;
    cout<<v<<" "<<w<<" "<<t<<" "<<d<<" "<<s<<endl;
  }

}


Measured memory_bytes: 12128
#include<bits/stdc++.h>
#define eps 1e-8
#define pr pair<int,int>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int maxx = 1e5;

int main()
{
	string str;
	while(cin >> str)
	{
		if(str[2] == str[3] && str[4] == str[5])
			cout << "Yes" << endl;
		else
			cout << "No" << endl;

	}

	
	return 0;
}



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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    string s; cin >> s;
    ll num = 0;
    int n = s.size();
    rep(i,n)num += s[i] - '0';
    if(num % 9 == 0)out("Yes");
    else out("No");
}

Measured memory_bytes: 3792
#include <iostream>
#include <vector>
#include <string>
#define input std::cin

using vector = std::vector<int>;
using lint = long long int;
using string = std::string;

int main() {
  int n, m; input >> n >> m;
  vector components (n, -1);
  vector sizes (n, 1);

  auto parent = [&] (int i) -> int {
	int j = i;
	while (components[j] != -1) {
	  j = components[j];
	}
	while (i != j) {
	  int tmp = components[i];
	  components[i] = j;
	  i = tmp;
	}
	return j;
  };

  auto merge = [&] (int i, int j) -> void {
	int p1 = parent (i);
	int p2 = parent (j);
	if (p1 == p2)
	  return;
	if (sizes[p1] < sizes[p2]) {
	  std::swap (p1, p2);
	  std::swap (i, j);
	}
	components[p2] = p1;
	sizes[p1] += sizes[p2];
  };

  for (int i=0; i<m; i++) {
	int a, b; input >> a >> b;
	merge (a-1, b-1);
  }

  int maxsz = 0;
  for (int sz : sizes)
	if (sz > maxsz)
	  maxsz = sz;
  std::cout << maxsz << std::endl;
}



Measured memory_bytes: 4832
import java.util.Scanner;

public class Main {

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

        System.out.println((N * (N - 1) / 2) + (M * (M - 1) / 2));

    }

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m, int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
	return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t, sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;

map<string, int> memo;

using P=pair<int, int>;
/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value, vector<ll> a)
{

	for (ll i = 0; i < (ll)a.size(); i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}

void comb(vector<vector <long long int> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (ll j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}



int main() {
	string s;
	cin >> s;
	ll k;
	cin >> k;
	rep(i, min((ll)s.size(), k)) {
		if (s[i] >= '2') {
			cout << s[i];
			return 0;
		}
	}
	cout << 1;

	return 0;
}













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

int main(void) {
        int a[3];
        int res, count = 0;

        for(int i = 0; i < 3; i++) {
                cin >> a[i];
        }
        
        for(int i = 1; i <= a[2]; i++) {
                res = a[2] % i;
                if(res == 0 && a[0] <= i && a[1] >= i) {
                        count++;
                }
        }

        cout << count << endl;
        
        return 0;
}

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

int main() {

	int a, b, c;
	int out = 0;

	cin >> a >> b >> c;
	
	for (int i = a; i <= b; i++) {
		if (c % i == 0) {
			out++;
		}
	}
	cout << out << endl;
	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
using namespace std;
typedef long long ll;
ll x, n, ans;

ll gcd(ll a, ll b){
	if (!b) return a;
	return gcd(b, a % b);
}

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

int main(){
	cin >> n;
	ans = 1;
	for (int i = 1; i <= n; i++){
		cin >> x;
		ans = lcm(x, ans);
	}
	cout << ans;
	return 0;
}


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

using namespace std;

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

    int x500, x100, x50, x10, x5, x1;

    x500 = int(X / 500);
    if (x500 != 0)
        X = X % (x500*500);
    // cout << X << endl;

    // x100 = int(X / 100);
    // if (x100 != 0)
    //     X = X % (x100*100);
    // // cout << X << endl;

    // x50 = int(X / 50);
    // if (x50 != 0)
    //     X = X % (x50*50);
    // // cout << X << endl;

    // x10 = int(X / 10);
    // if (x10 != 0)
    //     X = X % (x10*10);
    // // cout << X << endl;

    x5 = int(X / 5);
    if (x5 != 0)
        X = X % (x5*5);

    // x1 = int(X / 1);
    // if (x1 != 0)
    //     X = X % x1;

    cout << x500*1000 + x5*5 << endl;

    return 0;
}

Measured memory_bytes: 256
import heapq
import math
N, M = map(int, input().split())
A = list(map(int,input().split()))

A = list(map(lambda x: x*(-1), A))
heapq.heapify(A)

for i in range(M):
    a = heapq.heappop(A)
    a = math.ceil(a / 2)
    heapq.heappush(A, a)

A = list(A)
print(sum(A)* (-1))

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

#define pi 3.141592654
#define fix(n) cout << fixed << setprecision(n)

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

#define si(d)  scanf("%d",&d)
#define sll(d) scanf("%lld",&d)
#define pin(d) printf("%d\n",d)
#define pln(d) printf("%lld\n",d)
#define nl 	   printf("\n")

#define ll long long
#define ull unsigned long long

#define mp make_pair
#define pb push_back
#define fi first
#define se second

#define vi vector<int>
#define pii pair<int,int> 
#define piii pair<pair<int,int>,int> 
#define all(v) v.begin(), v.end()

#define chalne_de continue
int mod=1000000007;
const int N = 1000005;

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int cnt1 = 0, cnt2 = 0;
	stack<char> st;
	for ( int i =0; i < n; i++)
	{
		if ( s[i] == ')')
		{
			if ( st.empty())
				cnt1 ++;
			else
				st.pop();
		}
		else
			st.push('(');
	}
	cnt2 =st.size();
	for ( int i = 0; i < cnt1; i++)
		cout << "(";
	cout << s ;
	for ( int i = 0; i < cnt2; i++)
		cout << ")";
	return 0;
}


Measured memory_bytes: 256
/*
   Author : BabaYaga42,
   BITS Pilani, Hyderabad.
   Don't give up ;)
   */  
#include<bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(nullptr);
#define int long long
 
const int N = 1e3+4;
int a[N][3];

bool comp(int a , int b)
{
 	return a > b;
}
int32_t main()
{
	IOS;	
	int n,m,ans = -1e15;
	cin >> n >> m;
	for(int i = 0; i < n; i++)
	{
	 	for(int j = 0; j < 3; j++)
	 	{
	 	 	cin >> a[i][j];
	 	}
	}
	for(int k = 0; k < 8; k++)
	{
	 	vector<int> v;
	 	int tot = 0;
	 	for(int i = 0; i < n; i++)
	 	{
	 		tot = 0;
	 	 	for(int j = 0; j < 3; j++)
	 	 	{
	 	 		int temp = 1;
	 	 	 	if(k&(1 << j))
	 	 	 		temp = -1;
	 	 	 	tot += temp*a[i][j];	 		
	 	 	}
	 	 	v.push_back(tot);
	 	}
	 	int full = 0;
	 	sort(v.begin(),v.end(),comp);
	 	for(int i = 0; i < m; i++)
	 		full += v[i];	
	 	ans = max(ans,full);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
  int N; //データの数
  cin >> N;
  
  int data1=0,data2=0;//AliceとBobの点数
  
  vector <int> a(N);
  
  for(int i=0;i<N;i++)
    cin >>a.at(i);//データの収納
  
  sort(a.begin(),a.end());//小さい順に並べ替え
  reverse(a.begin(),a.end());//順番を逆にする（大きい順に変更）
  
  for(int i=0;i<N;i++){
    if(i%2 == 0)
      data1 += a.at(i);//aliceのデータ
      
    if(i%2 == 1)
      data2 += a.at(i);//Bobのデータ
  }
  cout << data1 -data2 <<endl;//出力部
}



Measured memory_bytes: 3524
import heapq
N = int(input())
A = list(map(int,input().split()))
Af = A[:N]
Ab = [-i for i in A[2*N:]]
asum = sum(Af)
bsum = -sum(Ab)
bsum2 = -sum(Ab)
heapq.heapify(Af)
heapq.heapify(Ab)
flist = [sum(Af)]
blist = []
for i in range(N,2*N):
    mina = heapq.heappop(Af)
    if A[i] > mina:
        asum = asum -mina + A[i]
        flist.append(asum)
        heapq.heappush(Af,A[i])        
    else:
        flist.append(asum)
        heapq.heappush(Af,mina)
    
for i in range(2*N-1,N-1,-1):
    maxa = heapq.heappop(Ab)
    if (-A[i]) > maxa:
        bsum2 = bsum2 + maxa +A[i]
        blist.append(bsum2)
        heapq.heappush(Ab,-A[i])
    else:
        blist.append(bsum2)
        heapq.heappush(Ab,maxa)    
blist = blist[::-1]
ans = []
blist.append(bsum)
for i in range(N+1):
    ans.append(flist[i]-blist[i])
print(max(ans))

Measured memory_bytes: 121488
#include<stdio.h>

int main(void){
  int p[5];
  int k;
  
  for(int i = 0; i < 5; i++){
    scanf("%d", &p[i]);
  }
  scanf("%d",&k);
  
  for(int j = 0; j < 4; j++){
  	for(int i = j+1; i < 5; i++){
  		int x = p[i] - p[j];
    	if(x > k){
      		printf(":(");
        	return 0;
        }
  	}
  }
  printf("Yay!");
  return 0;
}

Measured memory_bytes: 128
/*
AizuOnline A0077
Title Run Length
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
#define LENGTH 100
char output[LENGTH+1];
char input[9*LENGTH+1];
//
main()
{
  int i,j,k,st,rep;
  char c;

  while(EOF != scanf("%s",input))
    {
      memset(output,0,sizeof(output));
      st=0;j=0;
      for(i=0;i<strlen(input);i++)
	{
	  c=input[i];
	if(st==0)
	  {
	    if(c=='@')
	      st=1;
	    else
	      output[j++]=c;
	  }
	else if(st==1)
	  {
	    rep = c-'0';
	    st = 2;
	  }
	else
	  {
	    for(k=0;k<rep;k++)
	      output[j++]=c;
	    st=0;
	  }
	}
      output[j]='\0';
      printf("%s\n",output);
    }
return(0);
}

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

int main(){
    int X,N;
    cin>>X>>N;
    int p[N];
    rep(i,N)cin>>p[i];
    int ans=0;
    rep(i,102){
        if(abs(X-i)<abs(X-ans)){
            int count=0;
            rep(j, N){
                if(p[j]==i)count++;
            }
            if(count==0)ans=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3620
# coding: utf-8
# Your code here!
import sys
input = sys.stdin.readline

def itercomb(n,k):
    _a = (1<<k)-1
    yield _a
    while 1:
        _x = _a & -_a
        _y = _a + _x
        _a = (((_a & ~_y) // _x) >> 1) | _y
        if _a >= _ALL: break
        yield _a

n=int(input())
A= [[int(i) for i in input().split()] for j in range(n)]

MOD=10**9+7
_ALL=1<<n
dp = [0]*(_ALL)
dp[0] = 1

for m in range(1,n+1):
    for a in itercomb(n,m):
        for c,i in enumerate(A[m-1]):
            if (1<<c)&a and i:
                dp[a] += dp[a^(1<<c)]
                if dp[a] > MOD:
                    dp[a] -= MOD


#print(dp)
print(dp[2**n-1])

Measured memory_bytes: 57436
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
struct each{
	int x,y;
}a[N];
int bm[N],bi[N];
int n,_max,_min=INT_MAX,ak,ik;
bool com(each x,each y){
	return x.x<y.x;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i].x,&a[i].y);
		if(a[i].x>a[i].y)	swap(a[i].x,a[i].y);
		if(_max<a[i].y)	_max=a[i].y;
		if(_min>a[i].x)	_min=a[i].x;
	}
	int ml=_max,mr=_min;
	for(int i=1;i<=n;i++){
		ml=min(ml,a[i].y);
		mr=max(mr,a[i].x);
	}
	long long ans=1LL*(_max-ml)*(mr-_min);
	sort(a+1,a+n+1,com);
	ml=INT_MAX,mr=0;
	for(int i=1;i<=n;i++){
		ans=min(ans,1LL*(_max-_min)*(max(mr,a[n].x)-min(ml,a[i].x)));
		ml=min(ml,a[i].y),mr=max(mr,a[i].y);
	}

	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>

using namespace std;

#define N 8
#define FREE -1
#define NOT_FREE 1

bool X[N][N];
int row[N], col[N], lowerLeft[N * 2 - 1], lowerRight[N * 2 - 1];

void printBoard() {
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (X[i][j]) {
				if (row[i] != j) {
					return;
				}
			}
		}
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (row[i] == j) {
				cout << "Q";
			} else {
				cout << ".";
			}
		}
		cout << endl;
	}
}

void backTrack(int i) {
	if (i == N) {
		printBoard();
		return;
	}
	for (int j = 0; j < N; ++j) {
		if (col[j] == NOT_FREE || lowerLeft[i + j] == NOT_FREE || lowerRight[i - j + N - 1] == NOT_FREE) {
			continue;
		}
		row[i] = j;
		col[j] = lowerLeft[i + j] = lowerRight[i - j + N - 1] = NOT_FREE;

		backTrack(i + 1);

		row[i] = col[j] = lowerLeft[i + j] = lowerRight[i - j + N - 1] = FREE;
	}
}

int main() {

	int k;
	scanf("%d", &k);

	for (int i = 0; i < N; ++i)
		for (int j = 0; j < N; ++j)
			X[i][j] = false;
	for (int i = 0; i < N; ++i) {
		row[i] = col[i] = FREE;
	}
	for (int i = 0; i < N * 2 - 1; ++i) {
		lowerLeft[i] = lowerRight[i] = FREE;
	}

	for (int i = 0; i < k; ++i) {
		int r, c;
		scanf("%d %d", &r, &c);
		X[r][c] = true;
	}
	backTrack(0);

	return 0;
}

Measured memory_bytes: 3212
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main()
{
	int d, t;
	cin >> d;
	vector<int> c(26);
	rep(i, 0, 26)cin >> c[i];
	vector<vector<int>> s(d, vector<int>(26));
	vector<int> last(26, 0);
	rep(i, 0, d) {
		rep(i2, 0, 26)cin >> s[i][i2];
	}
	ll ans = 0;
	rep(i, 1, d + 1) {
		cin >> t;
		t--;
		last[t] = i;
		ans += s[i - 1][t];
		rep(i2, 0, 26)ans -= c[i2] * (i - last[i2]);
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,n,k,l;
	cin>>n;
		
	ll mn=1e18;
	for(i=1;i*i<=n;i++){
		if(n%i==0){
			k=i-1; l=(n/i)-1;
			mn=min(mn,k+l);
		}
	}
	cout<<mn;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
using ll = long long;
#define rep(i,n) for (ll i=0;i<n;i++)
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    for(ll i=1;i<n;i++){
        if(a[i-1]>a[i]){
            ans += a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 4776
S = input()

count1 = 0
count2 = 0
for s_i, s in enumerate(S):
    if s_i % 2 == 0:
        if s == "0":
            count1 += 1
        else:
            count2 += 1
    else:
        if s == "1":
            count1 += 1
        else:
            count2 += 1

out = min(count1, count2)
print(out)

Measured memory_bytes: 3188
a = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]

c = [[0 for _ in range(3)] for _ in range(3)]
result = ""

for i in range(3):
    for j in range(3):
        if a[j][i] in b:
            c[j][i] = 1

for i in range(3):
    if c[i][0] == c[i][1] == c[i][2] == 1:
        result = "Yes"
        break
    elif c[0][i] == c[1][i] == c[2][i] == 1:
        result = "Yes"
        break

if c[0][0] == c[1][1] == c[2][2] == 1:
    result = "Yes"
elif c[0][2] == c[1][1] == c[2][0] == 1:
    result = "Yes"

if result == "":
    result ="No"

print(result)


Measured memory_bytes: 9240
#include<iostream>
#include<string>
using namespace std;
long long int gcd(long long int a, long long int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
int main()
{
	int n;
	cin>>n;
	long long sum=0;
	long long int x;
	for(int i=1;i<=n;++i)
	{
		
		for(int j=1;j<=n;++j)
		{
			
			for(int k=1;k<=n;++k)
			{
				x=gcd(gcd(i,j),k);
				sum+=x;
			}
		}
	}
	cout<<sum<<endl;
}

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

using namespace std;

#define INF 210000000
#define int long long

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

int lcm(int a, int b) { return a * b / gcd(a, b); }

signed main() {
		string s;
		cin >> s;
		s[5] = ' ';
		s[13] = ' ';
		cout << s << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, y;
    cin >> x >> y;
    if(x % y == 0){
        cout << -1 << endl;
        return 0;
    }
    for(int i = x;; i += x){
        if(i % y != 0){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

template<class T>
T gcd(T n,T m){
    if(n>m) return gcd(m,n);
    else if(n==0) return m;
    else return gcd(m-n*(m/n),n);
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<b-a+1-(b/c-(a-1)/c+b/d-(a-1)/d)+b/(c*d/gcd(c,d))-(a-1)/(c*d/gcd(c,d));
}

Measured memory_bytes: 256
import java.util.*;

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

class Solver {

    private void mark(int[][] card, int v) {
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (card[i][j] == v) {
                    card[i][j] = 0;
                }
            }
        }
    }

    private void bingo() {
        System.out.println("Yes");
        System.exit(0);
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        int[][] card = new int[3][3];

        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                card[i][j] = sc.nextInt();
            }
        }

        int N = sc.nextInt();
        int[] b = new int[N];
        for (int i = 0; i < N; i++) {
            b[i] = sc.nextInt();
            mark(card, b[i]);
        }

        // horizontal check
        for (int i = 0; i < 3; i++) {
            if (card[i][0] == 0 && card[i][1] == 0 && card[i][2] == 0) bingo();
        }

        // vertical check
        for (int j = 0; j < 3; j++) {
            if (card[0][j] == 0 && card[1][j] == 0 && card[2][j] == 0) bingo();
        }

        if (card[0][0] == 0 && card[1][1] == 0 && card[2][2] == 0) bingo();
        if (card[0][2] == 0 && card[1][1] == 0 && card[2][0] == 0) bingo();

        System.out.println("No");

        return;
    }

}

Measured memory_bytes: 22228
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
using namespace std;
bool cloud[101][101] = {false};
int graph[101][101] = { -1 };
int main() {
	int h, w;
	scanf("%d%d", &h, &w);
	for (int i = 0;i < h;++i) {
		char hoge[101] = { NULL };
		scanf("%s", &hoge);
		for (int q = 0;q < w;++q) {
			if (hoge[q] == 'c') {
				cloud[i][q] = true;
			}
		}
	}
	for (int i = 0;i < 101;++i) {
		for (int q = 0;q < 101;++q) {
			graph[i][q] = -1;
		}
	}
	for (int i = 0;i < h;++i) {
		for (int q = 0;q < w;++q) {
			if (cloud[i][q] == true) {
				for (int p = q;p <= w;++p) {
					graph[i][p] = p - q;
				}
			}
		}
	}
	for (int i = 0;i < h;++i) {
		for (int q = 0;q < w;++q) {
			printf("%d", graph[i][q]);
			if (q != w - 1) {
				printf(" ");
			}
			else {
				printf("\n");
			}
		}
	}
	return 0;
}


Measured memory_bytes: 1080
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

mgcd x y = mgcd' (max x y) (min x y) 1
  where
    mgcd' a b i = let (a',b') = (b, a`mod`b) in if b'==0 then (a', i) else mgcd' a' b' (i+1)

main = do
    [x,y] <- getInts
    unless (x==0 && y==0) $ putStrLn (tjoin $ mgcd x y) >> main
    


Measured memory_bytes: 4076
A, B =gets.split.map(&:to_i)
res = []
K = 40
W = 90
K.times{
  res << [*1..W].map{|i| "#"}
}
K.times{
  res << [*1..W].map{|i| "."}
}
index_black = [*0..(B-2)].map{|i| i*2}
index_white = [*0..(A-2)].map{|i| i*2}
index_white.each{|i|
  y = i/W*2
  x = i%W
  res[y][x] = "."
}

index_black.each{|i|
  y = i/W*2 + K+1
  x = i%W + y%2
  res[y][x] = "#"
}
puts (K*2).to_s+" "+W.to_s
res.each{|r|
  puts r.join("")
}


Measured memory_bytes: 2172
N,K = map(int,input().split())
A = list(map(int,input().split()))
#最終的にすべての値は1になる
if N==K:
    print(1)
    exit()
ans = 1
t = K
while(1):
    if t >= N:
        print(ans)
        exit()
    t += (K-1)
    ans += 1


Measured memory_bytes: 13880
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
static const ll LOGN=55;


int main(void) {
  ll D, G;
  cin >> D >> G; G/=100;
  ll i, j;
  ll p[11], c[11];
  
  for(i=0; i<D; i++) {
    cin >> p[i] >> c[i];
    c[i]/=100;
  }
  
  ll ans=INF;
  for(ll mask=0; mask<1<<D; mask++) {
    ll score=0;
    ll cnt=0;
    
    for(i=0; i<D; i++) {
      if(mask>>i&1) {
        score+=(i+1)*p[i];
        score+=c[i];
        cnt+=p[i];
      }
    }
    
    for(i=D-1; i>=0; i--) {
      if(mask>>i&1) continue;
      if(score>=G) continue;
      
      ll t=G-score;
      ll c=min(p[i]-1, (t+i)/(i+1));
      score+=(i+1)*c;
      cnt+=c;
      break;
    }
    
    if(score>=G) chmin(ans, cnt);
  }
  
  pt(ans);
  
  
  
}






Measured memory_bytes: 256
// https://atcoder.jp/contests/abc147/tasks/abc147_a

#include "algorithm"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N = 3;
  ll sum = 0;

  rep(i, N) {
    ll a;
    cin >> a;
    sum += a;
  }

  if (sum >= 22) drop("bust");
  drop("win");
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int H,W,i,j;
    while ( scanf("%d %d", &H, &W) ){
        if ( H == 0 && W == 0 ) break;
        for ( i = 0 ; i < H ; i++ ){
            for ( j = 0 ; j < W ; j++ ){
                if ( i == 0 || j == 0 || i == (H-1) || j == (W-1) ) {
                    printf("#");
                } else {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2128
import java.util.PriorityQueue
import java.util.Comparator
import scala.io.StdIn.{readLine,readInt}
import scala.collection.mutable.ArrayBuffer

object Main {

  class Node(var cost:Int, var id:Int) { }

  class NodeComparator extends Comparator[Node] {
    def compare(node1:Node,node2:Node) = { node1.cost-node2.cost }
  }

  def main(args:Array[String]) = {
    val comp:Comparator[Node] = new NodeComparator()
    val n = readInt
    val pq = new PriorityQueue[Node](n, comp)
    val g = for(i<-0 until n) yield { readLine.trim.split(" ").map(_.toInt) }
    val dist = new Array[Int](n)
    val nodes = new Array[Node](n)
    nodes(0) = new Node(0,0)
    pq.add(nodes(0))
    for(i<-1 until n) {
      dist(i) = 1000000
      nodes(i) = new Node(1000000, i)
    }
    dist(0) = 0

    while(!pq.isEmpty()) {
      val nd = pq.poll()
      val v = g(nd.id)

      for(i<-0 until v(1)) {
        val j = i*2+2
        val k = i*2+3
        val alt = v(k) + dist(v(0))
        if(alt < dist(v(j))) {
          dist(v(j)) = alt
          val node = nodes(v(j))
          if(pq.contains(node)) {
            pq.remove(node)
          }
          node.cost = dist(v(j))
          node.id = v(j)
          pq.add(node)
        }
      }
    }

    println{
      { for(i<-0 until n) yield (i.toString + " " + dist(i).toString) }.mkString("\n")
    }
  }
}

Measured memory_bytes: 158404
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    ll n,A[200000],B[200000]={0},ans=0;
  
    cin>>n;
  
    rep(i,n)
      cin>>A[i],B[A[i]]=i+1;
  
    set<ll> C;
  
    C.insert(0),C.insert(n+1);
  
    rep(i,n) ans+=(i+1)*(B[i+1]-(*--C.lower_bound(B[i+1])))*(*C.upper_bound(B[i+1])-B[i+1]),C.insert(B[i+1]);
    cout<<ans;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    string d[k];
    rep(i,k) cin >> d[i];
    int ans = n;
    while (true) {
        string s = to_string(n);
        bool ok = true;
        rep(i,k) {
            string t = d[i];
            if (s.find(t) != string::npos) ok = false;
        }
        if (ok) {
            ans = n;
            break;
        }
        n++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long int mod = 1000000007;
main()
{
	long long int n , k, ans = 0, sum1 = 0, sum2 = 0;
	cin >> n >> k;
	long long int i, a[n];
	for(i=0;i<k;i++)
	sum1+= i;
	for(i=n; i>n-k;i--)
	sum2+=i;
	sum2++;
	sum1+=mod;sum1%=mod;
	sum2+=mod;sum2%=mod;
	
	for(i=k;i<=n;i++)
	{
		long long int x = sum2-sum1;
		x+=mod;
		x%=mod;
		ans = (ans%mod+x%mod)%mod;
		ans+=mod;
		ans%=mod;
		sum1 = (sum1%mod+(i)%mod)%mod;
		sum2 = (sum2%mod+(n-(i+1))%mod)%mod;
		sum1+=mod;sum1%=mod;
		sum2 = sum2%mod + 1%mod;
		sum2+=mod;sum2%=mod;
		
		//cout << sum1 << " " << sum2 << endl;
	
	}
	ans+=1;
	ans%=mod;
	cout << ans;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
  int M;
  cin >> M;
  cout << (24 - M) + 24 << endl;
}

Measured memory_bytes: 3568
//AGC041-B
//二分探索の応用

#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
//typedef pair<int, int> P;
//typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

int N, M, V, P;

bool ok(int n, vi &A) {
    if(n<P) return true;
    if(A[P-1] > A[n]+M) return false;
    int sum = 0;
    sum += M*(P-1); sum+=M*(N-n);
    FOR(i, P-1, n) {
        sum += min(M, max(0, A[n]+M-A[i]));
    }
    return sum>=M*V;
}

signed main() {
    cin >> N >> M >> V >> P;
    vi A(N);
    rep(i, N) {
        cin >> A[i];
    }
    GSORT(A);

    int l=-1, r=N, mid;
    while(abs(l-r)>1) {
        mid = (l+r)/2;
        if(ok(mid, A)) l=mid;
        else r = mid;
    }

    cout << l+1 << endl;
    
    return 0;
}

Measured memory_bytes: 1152
def main():
    s = input()

    na, nb, nc = 0, 0, 0

    for c in s:
        if c == "a":
            na += 1

        if c == "b":
            nb += 1
        
        if c == "c":
            nc += 1

    mi = min(na, nb, nc)

    na -= mi
    nb -= mi
    nc -= mi

    if na >= 2 or nb >= 2 or nc >= 2:
        print("NO")
    else:
        print("YES")
        
if __name__ == "__main__":
    main()

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

int main(){
    string s;
    cin >> s;
    int N=0,W=0,S=0,E=0;
    for(int i = 0;i < s.size();i ++){
        if(s[i]=='N') N = 1;
        if(s[i]=='W') W = 1;
        if(s[i]=='S') S = 1;
        if(s[i]=='E') E = 1;       
    }
    if(N-S==0&&W-E==0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

using namespace std;

const int maxn=1e5+5;

typedef long long ll;

int a[maxn];

int main(){
	ll n;
	scanf("%lld",&n);
	if(n==1) printf("0");
	else if(n==2) printf("1");
	else{
		ll ans=1;
		ans+=(n-1+1)*(n-1)/2-1;
		printf("%lld",ans);
	}
	return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;
using namespace boost::multiprecision;

int main() {
  cpp_int X, Y, answer = 0;
  cin >> X >> Y;
  for (; X <= Y; X *= 2, answer++) {
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
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; }


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m; cin>>n>>m;
    vector<vector<int>> p(m+1);
    rep(i,n){
        int a,b;cin>>a>>b;
        if(a>m) continue;
        p[a].push_back(b);
    }

    priority_queue<int> q;
    
    int ans=0;
    for(int i = 1; i <=m; i++){
    
    for(int x : p[i]){
        q.push(x);
    }

        if(!q.empty()){
            ans+=q.top();
            q.pop();
        }
    }

    cout<<ans<<endl;
    return 0;

}

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

struct Card{
	char type;
	int value;
};

vector<Card> BubbleSort(vector<Card> C,int N){
	for(int i=0;i<N;++i){
		for(int j=N-1;j>=i+1;--j){
			if(C[j].value<C[j-1].value) swap(C[j],C[j-1]);
		}
	}
	return C;
}

vector<Card> SelectionSort(vector<Card> C,int N){
	for(int i=0;i<N;++i){
		int minj=i;
		for(int j=i+1;j<N;++j){
			if(C[j].value<C[minj].value) minj=j;
		}
		swap(C[i],C[minj]);
	}
	return C;
}

int main(){
	int N;cin>>N;
	vector<Card> C(N);
	for(int i=0;i<N;++i){
		string str;
		cin>>str;
		C[i].type=str[0];
		C[i].value=str[1]-'0';
	}
	
	auto stable=BubbleSort(C,N);
	auto ustable=SelectionSort(C,N);
	for(int i=0;i<N;++i){
		if(i==0) cout<<stable[i].type<<stable[i].value;
		else cout<<" "<<stable[i].type<<stable[i].value;
	}
	puts("");
	puts("Stable");
	bool flag=true;
	for(int i=0;i<N;++i){
		if(i==0) cout<<ustable[i].type<<stable[i].value;
		else cout<<" "<<ustable[i].type<<ustable[i].value;
		if(stable[i].type!=ustable[i].type) flag=false;
	}
	puts("");
	if(!flag) puts("Not stable");
	else puts("Stable");
}



Measured memory_bytes: 3184