akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <tuple>

using namespace std;
using pii = pair<int, int>;
using tiiii = tuple<int, int, int, int>;

int main(){
	ios_base::sync_with_stdio(false);
	int n, h;
	cin >> n >> h;
	vector<tiiii> pieces;
	for(int i = 0; i < n; ++i){
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		pieces.emplace_back(c, a, d, b);
	}
	sort(pieces.begin(), pieces.end());
	map<pii, pii> ranges;
	for(int i = 0; i < n; ){
		const int c = get<0>(pieces[i]), a = get<1>(pieces[i]);
		int j = i;
		if(c == 0){
			while(j < n && get<0>(pieces[j]) == 0 && get<1>(pieces[j]) == a){
				++j;
			}
		}else{
			while(j < n && get<0>(pieces[j]) == c){ ++j; }
		}
		ranges.emplace(pii(c, c == 0 ? a : 0), pii(i, j));
		i = j;
	}
	for(int i = 0; i < n; ++i){
		const int d = get<2>(pieces[i]), b = get<3>(pieces[i]);
		if(d == 0){
			ranges.emplace(pii(b, 0), pii(0, 0));
		}else{
			ranges.emplace(pii(0, d), pii(0, 0));
		}
	}
	vector<pair<pii, pii>> v_ranges(ranges.begin(), ranges.end());
	const int m = v_ranges.size();
	vector<int> in_deg(m), out_deg(m);
	vector<vector<int>> conn(n + m);
	for(int i = 0; i < m; ++i){
		const auto r = v_ranges[i].second;
		for(int j = r.first; j < r.second; ++j){
			conn[n + i].push_back(j);
			conn[j].push_back(n + i);
			++out_deg[i];
		}
	}
	for(int i = 0; i < n; ++i){
		const int d = get<2>(pieces[i]), b = get<3>(pieces[i]);
		pii key(0, 0);
		if(d == 0){
			key.first = b;
		}else{
			key.second = d;
		}
		const auto it = lower_bound(
			v_ranges.begin(), v_ranges.end(), make_pair(key, pii(0, 0)));
		const int j = it - v_ranges.begin();
		conn[i].push_back(n + j);
		conn[n + j].push_back(i);
		++in_deg[j];
	}
	bool answer = true;
	vector<bool> done(n + m);
	for(int i = 0; i < n; ++i){
		if(done[i]){ continue; }
		int in_over = 0, out_over = 0;
		queue<int> q;
		q.push(i);
		done[i] = true;
		while(!q.empty()){
			const int u = q.front();
			q.pop();
			if(u >= n){
				const int k = u - n;
				const auto r = v_ranges[k].first;
				if(r.first == 0){
					if(out_deg[k] < in_deg[k]){
						answer = false;
					}else{
						out_over += out_deg[k] - in_deg[k];
					}
				}else{
					if(in_deg[k] < out_deg[k]){
						answer = false;
					}else{
						in_over += in_deg[k] - out_deg[k];
					}
				}
			}
			for(const auto& v : conn[u]){
				if(done[v]){ continue; }
				done[v] = true;
				q.push(v);
			}
		}
		if(in_over != out_over || in_over == 0){ answer = false; }
	}
	cout << (answer ? "YES" : "NO") << endl;
	return 0;
}



Measured memory_bytes: 9328
*s, = input()
for _ in range(int(input())):
    *t, = map(str, input().split())
    t.append("")
    c = t.pop(0)
    a = int(t.pop(0))
    b = int(t.pop(0))
    *p, = t.pop(0)

    if c == "print":
        print("".join(s[a:b+1]))
    elif c == "reverse":
        s = s[:a]+list(reversed(s[a:b+1]))+s[b+1:]
    elif c == "replace":
        s = s[:a]+p+s[b+1:]


Measured memory_bytes: 5632
#include <stdio.h>


int main(void){

  int i,j,k,n,min,tmp;
  int r[101],m[100][100];
	
	scanf("%d",&n);
	
	for (i=0; i<n; i++) {
		scanf("%d %d",&r[i], &r[i+1]);
	}
	
	for (i=0; i<n; i++) {
		m[i][i] = 0;
	}
	
	for (i = 1; i < n; i++) {
		for (j = 0; j < n-i; j++) {
			for (k = j; k < j+i; k++) {
				tmp = m[j][k] + m[k+1][j+i] + r[j]*r[k+1]*r[j+i+1];
				if (k == j || min > tmp) min = tmp;
			}
			m[j][j+i] = min;
		}
	}
	
	printf("%d\n",m[0][n-1]);
	
	return 0;
}



Measured memory_bytes: 2108
S = gets.chomp
sum = S.to_i
n = S.size-1

1.upto(n) do |i|
  (1..n).to_a.combination(i).each do |c|
    k = 0
    c.each do |j|
      sum += S[k...j].to_i
      k = j
    end
    sum += S[k..-1].to_i
  end
end

puts sum

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

using namespace std;

#define ll long long
ll n , m;

int main(){
  cin >> n >> m; // node edge

  //一発でいけるとこの頂点  
  vector<vector<ll>> _1step;
  _1step.resize(n);
  
  for(ll i =0; i < m; ++i){
    ll a,b;cin >> a >>b ;
    _1step[a - 1].push_back(b-1);
  }
  ll s,t;cin >> s  >> t;
  s--;t--;

  queue<pair<ll, ll>> q;
  q.push({s, 0});
  vector<bitset<3>> visit(n);
  visit[s][0] = 1;
  while(!q.empty()){
    ll now_pos = q.front().first;
    ll now_cnt = q.front().second;
    q.pop();
    for(auto&&e:_1step[now_pos]){
      ll nxt_pos = e;
      ll nxt_cnt = now_cnt+1;
      if(nxt_pos == t && nxt_cnt %3== 0){
	cout << nxt_cnt / 3 << endl;
	return 0;
      }
      if(visit[nxt_pos][nxt_cnt%3] == 1)continue;
      visit[nxt_pos][nxt_cnt%3] = 1;
      q.push({nxt_pos, nxt_cnt});
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 6528
import math
N = int(input())
ans = 10**12
for i in range(1,10**6+1):
  j = math.ceil(N/(i+1))
  if (1+i)*j == N:
    ans = min(i+j-1,ans)
  if i == 10**6 and ans == 10**12:
    ans = N-1
    break
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<string.h>
#include<cstring>
#include<math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<cctype>
#include<utility>
#include<set>
#include<map>
#include<sstream>
#include<iterator>
#include<limits>
#include<map>
#include<deque>
using namespace std;
#define pb push_back
#define F(i,a,b) for(int i=a;i<b;++i)
#define Fl(i,a,b) for(long long i=a;i<b;++i)
#define all(v) v.begin(), v.end() 
#define X first
#define Y second
#define mp make_pair
typedef long long ll;
typedef std::vector<int> vec;
typedef std::vector<long long> vecl;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef std::pair<int,int> pii;
typedef pair<ll,ll> pll; 
const int MOD = 1000000007;
#define pie 3.141592653589793238462643383279


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

 	int t{},T{};
 	//cin>>t;T=t;
    t=1;
 	while(t--){
        //cout<<"------------- #"<<T-t<<endl;
        ll n{},m{},tt,d,s,ans{},k{},a{},b{},c{},f{1};
        cin>>d>>tt>>s;
        
        if(d<=tt*s){
            cout<<"Yes\n";
        }else{
            cout<<"No\n";
        }
    }
    
    
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	string S;
	cin >> S;
	sort(all(S));
	if(S[0] == S[1] && S[1] != S[2] && S[2] == S[3])cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <time.h>
#include <random>
#include <fstream>
#include <set>

using namespace std;

const int N = 1e7 + 2;

int n;

int c[N];
int p[N];
int a[200];

vector<int> graph[400];

int paired[400];
int marked[400];

int TryKuhn(int v)
{
    if (marked[v]) return 0;
    marked[v] = 1;
    for (auto u : graph[v])
    {
        if (paired[u] == -1 || TryKuhn(paired[u]))
        {
            paired[u] = v;
            return 1;
        }
    }
    return 0;
}

int G()
{
    int res = 0;
    fill(paired, paired + 400, -1);
    for (int i = 0; i < n; i++)
    {
        fill(marked, marked + 400, 0);
        if (TryKuhn(i))
            res++;
    }
    return res;
}

signed main()
{
    srand(time(NULL));
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    for (int i = 2; i < N; i++)
    {
        if (p[i] == 0)
        {
            for (int j = 2; j * i < N; j++) p[i * j] = 1;
        }
    }
    p[2] = 1;
    p[1] = 1;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        c[x] = 1;
    }
    n = 0;
    for (int i = 0; i + 1 < N; i++)
    {
        if (c[i] != c[i + 1])
        {
            a[n] = i;
            n++;
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (a[i] % 2 == 0 && a[j] % 2 == 1)
            {
                if (!p[abs(a[i] - a[j])])
                {
                    graph[i].push_back(200 + j);
                    graph[200 + j].push_back(i);
                }
            }
        }
    }
    /*for (int i = 0; i < 400; i++)
    {
        for (auto u : graph[i])
        {
            cout << i << " " << u << endl;
        }
    }*/
    int c0 = 0, c1 = 0, c2 = G();
    for (int i = 0; i < n; i++)
    {
        if (a[i] % 2 == 0) c0++;
        else c1++;
    }
    int ans = c2 + ((c0 - c2) / 2) * 2 + ((c1 - c2) / 2) * 2 + ((c1 - c2) % 2) * 3;
    cout << ans;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef string str;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define pb(x)                       push_back(x)
#define pf(x)                       push_front(x)
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const ll MAXN = 1e5 + 10;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

ll ans = 1 , n , k , mark[MAXN] , h[MAXN];
vector <ll> adj[MAXN];

void dfs(ll v , ll bro){

    ll son = 0;
    mark[v] = 1;
    ans = (ans * (k - min(h[v] , 2LL) - bro)) % MOD;
    for(auto u: adj[v]){
        if(!mark[u]){
            h[u] = h[v] + 1;
            dfs(u , son);
            son ++;
        }
    }

}

int main(){

    cin >> n >> k;
    for(int i = 1; i < n; i++){
        ll v , u;
        cin >> v >> u;
        adj[v].pb(u);
        adj[u].pb(v);
    }
    h[1] = 0;
    dfs(1 , 0);
    cout << ans;

}


Measured memory_bytes: 10752
// Author: pankaj_m05 
// Problem: B
//Created: 17.05.2020 17:34:43

#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define f_in(file) freopen(file, "r", stdin)
#define f_out(file) freopen(file, "w", stdout)
#define sz(a) int((a).size())
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c) c.begin(), c.end()
#define tr(c,i) for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) (c.find(x) != c.end())  // Set and Maps
#define cpresent(c,x) (find(allc,x) != c.end()) // Vectors
using namespace std;

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
typedef long long ll;

const int mod = 1e9 + 7;

int main(void) { 
	fast
	int k;
	string s;
	cin >> k >> s;
	int len = s.length();
	if(len > k)           
		s = s.substr(0, k) + "...";
	cout << s << '\n';
	return 0;
}                                          

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll N;
  scanf("%lld",&N);
  vector<ll> p(N);
  ll ans=0;
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&p[i]);
    ans+=p[i];
  }
  sort(p.begin(),p.end());
  cout << ans-p.back()/2 << endl;
}

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


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            String text = sc.next();
            if(text.equals("-")){
                break;
            }
            
            int m = sc.nextInt();
            
            for(int i = 0; i < m; i++){
                int h = sc.nextInt();
                String s1 = text.substring(0, h);
				String s2 = text.substring(h);
				text = s2 + s1;
            }
            System.out.println(text);
        }
    }
}


Measured memory_bytes: 26496
S = input()

# ■のマスは2, ▲のマスは1でカウントする

def scan_forward(F:list, S):

    depth = 0  # 深さ（開始点を基準）
    start = 0  # 「池」が始まった高さ
    is_pond = True  # 池が始まっているか？

    for s in S:
        if s == '\\':  # 下り
            if not is_pond:
                is_pond = True
                start = depth
            depth -= 1
            F.append(2*(start - depth) - 1)
            continue

        if s == "/":  # 上り
            depth += 1
            if start < depth:  # 池の開始位置より高くなった場合
                is_pond = False
                F.append(0)
                continue
            else:
                F.append(2*(start - depth) + 1)

        if s == "_":
            if is_pond:
                F.append(2*(start - depth))
            else:
                F.append(0)

def scan_backward(B:list, S):
    
    depth = 0  # 深さ（開始点を基準）
    start = 0  # 「池」が始まった高さ
    is_pond = True  # 池が始まっているか？

    for s in S:
        if s == '/':  # 下り
            if not is_pond:
                is_pond = True
                start = depth
            depth -= 1
            B.append(2*(start - depth) - 1)
            continue

        if s == "\\":  # 上り
            depth += 1
            if start < depth:  # 現在地が池の開始位置より高い場合
                is_pond = False # 「池」終了
                B.append(0)
                continue
            B.append(2*(start - depth) + 1)

        if s == "_":
            if is_pond:
                B.append(2*(start - depth))
            else:
                B.append(0)

def count_pond(FB):
    
    P = []

    is_pond = False
    count = 0
    amount = 0
    all_amount = 0
    for i in range(len(FB)):
        all_amount += FB[i]
        if is_pond:  # 池の途中
            amount += FB[i]
            if FB[i] == 1:
                is_pond = False  # ここで一旦終了
                P.append(amount//2)
        else:  # 池でなくなった場合
            if FB[i] == 0: continue
            count += 1
            is_pond = True
            amount = FB[i]
    
    return all_amount//2, count, P

F = []
scan_forward(F, S)

B = []
scan_backward(B, reversed(S))
B.reverse()
# print(F)  # 順方向にスキャンした結果
# print(B)  # 逆方向にスキャンした結果

FB = [0]*len(F)
# print(len(F), len(B))

for i in range(len(F)):
    FB[i] = min(F[i], B[i])


# print(FB)  # 水量

aa, k, P = count_pond(FB)
print(aa)
if k == 0:
    print(k)
else:
    print(k, " ".join(list(map(str, P))))


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

int main() {
	int N;
	int K;
	cin >> N;
	cin >> K;
	int count[N+1];
	for (int i = 0; i < N+1; i++) {
		count[i] = 0;
	}
	int countNum[N+1];
	for (int i = 0; i < N+1; i++) {
		countNum[i] = 0;
	}

	int A;
	for (int i = 0; i < N; i++) {
		cin >> A;
		count[A]++;
	}
	for (int i = 1; i < N+1; i++) {
		int x = count[i];
		countNum[x]++;
	}

	int s = 0;
	if (N - countNum[0] > K) {
		int x = N - countNum[0]; //the number of appeared character
		for (int i = 1; i < N+1; i++) {
			if (x - countNum[i] <= K) {
				s += (x - K) * i;
				break;
			} else {
				x = x - countNum[i];
				s += countNum[i] * i;
			}
		}
	}
	cout << s << endl;
	return 0;
}




Measured memory_bytes: 1792
A,B,C = gets.chomp.split.map &:to_i
K = gets.chomp.to_i
clr_flg = false

while K != -1
  if A >= B
    B *= 2
  elsif B >= C
    C *= 2
  else
    K = 0
    clr_flg = true
  end
  K -= 1
end 

if clr_flg
  print "Yes" 
else
  print "No"
end



Measured memory_bytes: 14244
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

constexpr double eps=1e-9;
constexpr double PI=3.14159265358979323846264338327950;

inline int sgn(double x){
    if(x<-eps) return -1;
    if(x>eps) return 1;
    return 0;
}

inline bool EQ(double x, double y){
    return sgn(x-y)==0;
}

inline bool GE(double x, double y){
    return sgn(x-y)==1;
}

inline bool LE(double x, double y){
    return sgn(x-y)==-1;
}

inline bool GEQ(double x, double y){
    return sgn(x-y)>=0;
}

inline bool LEQ(double x, double y){
    return sgn(x-y)<=0;
}

int main(){
    double r;
    scanf("%lf", &r);
    printf("%.20lf\n", r*2*PI);
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long 
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define pw(x) (1<<(x))
#define inf 1000000005
#define MOD 1000000007 
#define N 505
#define M 1000003
#define LOG 20
#define KOK 250
#define EPS 0.0000001
using namespace std;

int n,add;
int ans;
int ok[N];
char s[N][N];

int main() {

	scanf("%d",&n);

	for(int i=1;i<=n;i++) scanf("%s",s[i]+1);

	for(int i=1;i<=n;i++) {

		for(int j=1;j<=n;j++) {

			ok[j]|=(s[i][j]=='#');

		}

	}

	for(int j=1;j<=n;j++) {

		ans+=::ok[j];

		bool ok=1;

		for(int i=1;i<=n;i++) {

			ok&=(s[i][j]=='#');

		}

		add+=!ok;

	}

	if(!ans) ans=-1;
	else ans=inf; 

	for(int sp=1;sp<=n;sp++) {

		int ad=!ok[sp];

		for(int j=1;j<=n;j++) {

			ad+=(s[sp][j]=='.');

		}

		umin(ans,ad+add);

	}

	printf("%d",ans);

}

Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
while(true) {
int m, n;
vector<pair<int, int> > ms, ns;

scanf("%d", &m);
if(m == 0)
break;
ms.resize(m);
for(int i = 0; i < m; ++i)
scanf("%d%d", &ms[i].first, &ms[i].second);
scanf("%d", &n);
ns.resize(n);
for(int i = 0; i < n; ++i)
scanf("%d%d", &ns[i].first, &ns[i].second);
sort(ms.begin(), ms.end());
sort(ns.begin(), ns.end());
int dx, dy;
for(int i = 0; i < n; ++i) {
dx = ns[i].first - ms[0].first;
dy = ns[i].second - ms[0].second;
bool exist = true;
for(int j = 0; j < m; ++j) {
if(!binary_search(ns.begin(), ns.end(), make_pair(ms[j].first + dx, ms[j].second + dy)))
exist = false;
}
if(exist)
break;
}
printf("%d %d\n", dx, dy);
}
return 0;
}

Measured memory_bytes: 1044
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <bitset>
#include <map>


using namespace std;

int main()
{
    int N, M;
    auto load = [](int l) {
        map<string, int> m;
        for (int i=0; i<l; ++i) {
            string s;
            cin >> s;
            if (m.count(s)) {
                m[s] += 1;
            } else {
                m.insert(make_pair(s, 1));
            }
        }
        return m;
    };
    cin >> N;
    auto blue = load(N);
    cin >> M;
    auto red = load(M);

    for (auto &p : blue) {
        string k = p.first;
        if (red.count(k)) {
            p.second -= red[k];
        }
    }

    int max_val = 0;
    for (auto &p : blue) {
        max_val = ::max(p.second, max_val);
    }    

    cout << max_val << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define pb push_back
#define rep(i,n) for(int i=0; i<n; i++)
#define forp(i,a,b) for(int i=a;i<b;i++)
#define forn(i,a,b) for(int i=a;i>=b;i--)
#define All(x,v) for(auto x:v)
#define arrin(a,n) ll a[n]; rep(i,n) cin>>a[i]
#define vi vector<int>
#define nl "\n"
#define print(arr) All(x,arr) cout<<x<<" "; cout<<nl
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define vdsort(v) sort(v.begin(),v.end(),greater<int>())
#define F first
#define S second
#define mod 1000000007
const int MAXN=100001;
int spf[MAXN];
int gcd(int x, int y){ return y?gcd(y,x%y):x; }

void precal(){  
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++)  spf[i] = i; 
    for (int i=4; i<MAXN; i+=2) spf[i] = 2; 
    for (int i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j)  spf[j] = i; 
    } 
} 
vector<int> getFactorization(int x){
    vector<int> ret; 
    while (x != 1) { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}

ll exp(ll n, ll m){
    ll a = 1;
    while (m){
        if (m & 1) a = (a * n % mod) % mod;
        m /= 2;
        n = (n*n) % mod;
    }
    return a;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int h,w,k,t=1;
    // cin>>t;
    while(t--){
        cin>>h>>w>>k;
        char c[h][w];
        int cnt=0;
        rep(i,h) rep(j,w) {
            cin>>c[i][j];
            cnt+=c[i][j]=='#';
        }
        ll ans=0;
        rep(i,1<<h){
            rep(j,1<<w){
                ll bl=0;
                rep(m,h) rep(l,w){
                    if(((i>>m)&1) && ((j>>l)&1) && c[m][l]=='#') bl++;
                }
                if(bl==k) ans++;
            }
        }
        cout<<ans<<nl;
    }
    return 0;
}

Measured memory_bytes: 3152
#include <iostream>
using namespace std;
int main()
{
    int a,b,s;
    cin>>a>>b;
    s=a+b;
    if(s%2==0){
        s=s/2;
    }else{
        s=(s+1)/2;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(' ').map(String::toInt)
    val board = Array(h + 2) { Array(w + 2) {0} }
    for (i in 1..h) {
        val input = readLine()!!.split(' ').map(String::toInt).toMutableList()
        input.add(0,0)
        input.add(0)
        board[i] = input.toTypedArray()
    }

    var sousaNum = 0
    val sousaList = mutableListOf<List<Int>>()
    for (i in 1..h) {
        for (j in 1..w) {
            if (board[i][j] % 2 == 1) {
                if (j != w) {
                    board[i][j] = board[i][j] - 1
                    board[i][j + 1] = board[i][j + 1] + 1
                    sousaList.add(Arrays.asList(i, j, i, j + 1))
                    sousaNum++
                } else if (i != h) {
                    board[i][j] = board[i][j] - 1
                    board[i + 1][j] = board[i + 1][j] + 1
                    sousaList.add(Arrays.asList(i, j, i + 1, j))
                    sousaNum++
                }
            }
        }
    }

    println(sousaNum)
    sousaList.forEach{println(it.joinToString(" "))}
}


Measured memory_bytes: 95992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static void Main()
    {
        int N = RInt();

        
        var B = new long[20, 20];
        long ans = 0;
        for (int i = 0; i < N; i++)
        {
            var input = decimal.Parse(ReadLine());
            input *= 1000000000;
            long r = (long)input;

            int e2 = 0, e5 = 0;
            while (r % 2 == 0) { r /= 2;e2++; }
            while (r % 5 == 0) { r /= 5;e5++; }
            e2 = Min(e2, 19);
            e5 = Min(e5, 19);

            int a2 = Max(0, 18 - e2);
            int a5 = Max(0, 18 - e5);
            for (int j = a2; j < 20; j++)
            {
                for (int k = a5; k < 20; k++)
                {
                    ans += B[j, k];
                }
            }
            
            B[e2, e5]++;

        }

        WriteLine(ans);
    }
}



class Scanner
{
    public static string RString() => Console.ReadLine();
    public static int RInt() => ReadTuple<int>();
    public static long RLong() => ReadTuple<long>();
    public static double RDouble() => ReadTuple<double>();

    public static string[] RStrings() => Console.ReadLine().Split();
    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();

    public static T1 ReadTuple<T1>()
    {
        var r = RString();
        var r1 = (T1)Convert.ChangeType(r, typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadTuple<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadTuple<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadTuple<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}


Measured memory_bytes: 37588
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
const int T = 1000000001;
int main() {
	string s;
	cin >> s;
	map<char, int> mp;
	for (int i = 0; i < 4; i++) mp[s[i]]++;
	int count = 0;
	for (auto c : mp) {
		count++;
		if (c.second != 2) {
			cout << "No" << endl;
			return 0;
		}
	}
	if (count != 2) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 5e5 + 9, M = 1e6 + 9, OO = 1e9 + 7, MOD = 1e9 + 7, MOD2 = 998244353;
const ll INF = 2e18;
using namespace std;

int main() {
	fastIO;
#ifdef LOCAL
//	freopen("input.in", "rt", stdin);
#endif
	string str;
	cin >> str;
	if(str[0] == '7' || str[1] =='7' || str[2] == '7')
		cout << "Yes";
	else
		cout << "No";
	return 0;
}


Measured memory_bytes: 3652
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int N, K;
  cin >> N >> K;
  
  if (K == 0) {
    cout << 1LL * N * N << '\n';
    return 0;
  }
  
  int64_t result = 0;
  for (int B = K + 1; B <= N; ++B) {
    result += (B - K);
    
    int chunks = (N - B) / B;
    result += 1LL * chunks * (B - K);
    if (N % B != 0) {
      result += max(0, N % B - K + 1);
    }
  }
  
  cout << result << '\n';
  
  return 0;
}


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

using namespace std;

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

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

	int sum = 0;
	for (int i = 0; i < k; i++) {
		sum += l[i];
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
typedef pair<int,int> pii;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1000000000

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

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


void solve(){
   int n;
  cin >> n;
  
  string s,t; 
  cin >> s >> t;
  
  string ans = "";
  for(int i = 0;i<n;i++){
    ans+=s[i];
    ans+=t[i];
}
  cout << ans << endl;
}

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


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

using namespace std;

const int size_k = 1e5+1;
const int size_n = 1e2+1;

bool dp[size_k];
int v_n[size_n];

int main(){

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

  for(int i=0;i<n;i++)
    scanf("%d",v_n+i);

  dp[0]=0;
  for(int i=1;i<=k;i++){
    for(int j=0;j<n;j++){
      if(v_n[j]<=i){
        if(!dp[i-v_n[j]])
          dp[i]=true;
      }
    }
  }
  if(dp[k])
    printf("First\n");
  else
    printf("Second\n");



  return 0;
}


Measured memory_bytes: 384
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Split(bufio.ScanWords)

	n, m := nextInt(), nextInt()

	from1, toN := make([]bool, n), make([]bool, n)
	for i := 0; i < m; i++ {
		a, b := nextInt(), nextInt()
		if a == 1 {
			from1[b] = true
		}
		if b == n {
			toN[a] = true
		}
	}

	ans := "IMPOSSIBLE"
	for i := 2; i < n; i++ {
		if from1[i] && toN[i] {
			ans = "POSSIBLE"
			break
		}
	}
	fmt.Println(ans)
}

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, err := strconv.Atoi(next())
	if err != nil {
		fmt.Println(err)
	}
	return i
}


Measured memory_bytes: 3456
use std::io::BufRead;

fn main() {
  let stdin = std::io::stdin();
  let line = stdin.lock().lines().next().unwrap().unwrap();

  let out = line.trim().chars().map(|c| {
    if c.is_lowercase() {
      c.to_uppercase().next().unwrap()
    } else if c.is_uppercase() {
      c.to_lowercase().next().unwrap()
    } else {
      c
    }
  }).collect::<String>();

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


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

void swap(int &i, int &j) {
    if (i == j) {
    } else if (i < j) {
    } else {
        int tmp;
        tmp = i;
        i = j;
        j = tmp;
    }
}

int main() {
    int i, j, k;
    cin >> i >> j >> k;
    int a, b, c;
    swap(i, j);
    swap(i, k);
    swap(j, k);
    cout << i << " " << j << " " << k << endl;
    return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <map>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SUPrl 13
#define UNDEFCHAN 1145

int rl;
int rs[SUPrl];
int L;
double memf[1<<SUPrl][SUPrl];

void resetf(){
	FOR(s,0,1<<rl) FOR(ri,0,rl) memf[s][ri]=UNDEFCHAN;
}

double f(int s, int ri){			//min_({a0,a1,..ri}=s) (sqrt(a0)-sqrt(a1))^2 + (sqrt(a1)-sqrt(a2))^2 + ..ri))^2
	if(memf[s][ri]!=UNDEFCHAN) return memf[s][ri];
	double re=0;
	
	int a=0;
	FOR(ari,0,rl) if((s>>ari&1)==1) a++;
	
	if(a==1) re=0;
	else{
		FOR(bri,0,rl){
			if((s>>bri&1)==0) continue;
			if(bri==ri) continue;
			re = max(re, f(s-(1<<ri),bri) + pow(sqrt(rs[bri])-sqrt(rs[ri]), 2) );
		}
	}

	memf[s][ri]=re;
	return re;
}

void showf(){
	FOR(s,0,1<<rl) FOR(ri,0,rl) cout << s <<" "<< ri <<" "<< memf[s][ri]<<endl;
}

double solve(){
	double re=0;
	FOR(ri,0,rl) re = max(re,f((1<<rl)-1,ri));
	re = -re;
	FOR(ri,0,rl) re += 2*rs[ri];
	return re;
}

int main(){
	while(cin>>L){//if(!L) return 0;
		rl=0;
		while(cin.peek()!='\n'){
			cin >> rs[rl++];
		}
		resetf();
		double re = solve();
		//showf();
		if(re<=L) cout<<"OK"<<endl; else cout<<"NA"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1576
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

char s[9][9];
int main(){
	rep(i,0,3)scanf("%s",s[i]);
	printf("%c%c%c",s[0][0],s[1][1],s[2][2]);
}

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


int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> vec(m);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		vec[i] = make_pair(a, b);
	}

	for (int t = 1; t <= n; t++) {
		int count = 0;
		for (auto road : vec) {
			if (road.first == t || road.second == t) count++;
		}
		cout << count << endl;
	
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
struct Mint {
	int val;
	Mint() { val = 0; }
	Mint(const ll& x) {
		val = (-MOD <= x && x <= MOD) ? x : x % MOD;
		if (val < 0) val += MOD;
	}
	friend bool operator==(const Mint& a, const Mint& b) { return a.val == b.val; }
	friend bool operator!=(const Mint& a, const Mint& b) { return !(a == b); }
	friend bool operator<(const Mint& a, const Mint& b) { return a.val < b.val; }
	Mint& operator+=(const Mint& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }
	Mint& operator-=(const Mint& m) { if ((val -= m.val) < 0) val += MOD; return *this; }
	Mint& operator*=(const Mint& m) { val = (ll)val * m.val % MOD; return *this; }
	friend Mint pow(Mint a, ll p) {
		Mint ans = 1;
		for (; p; p >>= 1, a *= a) if (p & 1) ans *= a;
		return ans;
	}
	Mint& operator/=(const Mint& m) { return *this *= pow(m, MOD - 2); }
	Mint& operator++() { return *this += 1; }
	Mint& operator--() { return *this -= 1; }
	Mint operator++(int) { Mint result(*this); *this += 1; return result; }
	Mint operator--(int) { Mint result(*this); *this -= 1; return result; }
	Mint operator-() const { return Mint(-val); }
	friend Mint operator+(Mint a, const Mint& b) { return a += b; }
	friend Mint operator-(Mint a, const Mint& b) { return a -= b; }
	friend Mint operator*(Mint a, const Mint& b) { return a *= b; }
	friend Mint operator/(Mint a, const Mint& b) { return a /= b; }
	friend ostream& operator<<(ostream& os, const Mint& x) { return os << x.val; }
};
int main() {
	int n, d, h;
	scanf("%d%d%d", &n, &h, &d);
	vector<Mint> fac(n + 1), dp(h + 1), sumdp(h + 1);
	fac[0] = 1;
	Mint sumfac = 0;
	for (int i = 1; i <= n; ++i) {
		fac[i] = fac[i - 1] * i;
		sumfac += fac[i];
	}
	sumdp[0] = dp[0] = fac[n];
	for (int i = 1; i < h; ++i) {
		dp[i] = (sumdp[i - 1] - (i <= d ? 0 : sumdp[i - d - 1])) * sumfac;
		sumdp[i] = sumdp[i - 1] + dp[i];
	}
	Mint ans = sumdp[h - 1] - (h <= d ? 0 : sumdp[h - d - 1]);
	printf("%d\n", ans.val);
}


Measured memory_bytes: 11904
#include<stdio.h>
#include<iostream>
using namespace std;
int main(void){
	int p[3],j[2],i,t,a;
	for(i=0;i!=3;i++)
		cin>>p[i];
	for(i=0;i!=2;i++){
		for(a=i;a!=3;a++){
			if(p[i]>p[a]){
				t=p[i];
				p[i]=p[a];
				p[a]=t;
			}
		}
	}
	t=p[0];
	cin>>j[0]>>j[1];
	if(j[0]<j[1])
		t+=j[0];
	else
		t+=j[1];
	cout<<t-50<<endl;
}

Measured memory_bytes: 3092
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
                Scanner scan = new Scanner(System.in);
                for(int i=1; i>0; i++){
                        int iNum = scan.nextInt();
                        if(iNum == 0)
                                break;
                        System.out.println("Case " + i + ": " + iNum);
                }
	}
}

Measured memory_bytes: 31344
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 2;
const int INF = 2e18;

signed main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N + 1);
    vector<int> count(N + 1, 0);
    int start = 0;
    {
        set<int> remain;
        for (int i = 1; i <= N; i++) remain.insert(i);
        for (int i = 0; i < N + M - 1; i++) {
            int A, B;
            cin >> A >> B;
            G[A].push_back(B);
            count[B]++;
            remain.erase(B);
        }
        start = *remain.begin();
    }
    vector<int> ans(N + 1, -1), dis(N + 1, -1);
    ans[start] = 0;
    dis[start] = 0;
    queue<int> explore;
    explore.push(start);
    while (!explore.empty()) {
        int now = explore.front();
        explore.pop();
        for (int next : G[now]) {
            count[next]--;
            if (dis[next] < dis[now] + 1) {
                dis[next] = dis[now] + 1;
                ans[next] = now;
            }
            if (count[next] == 0) explore.push(next);
        }
    }
    for (int i = 1; i <= N; i++) cout << ans[i] << endl;
}


Measured memory_bytes: 10240
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define int long long
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e7 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n ; 
    cin >> n ; 
    set<int> s ;
    for(int i = 0; i < n; i++){
        int x ;
        cin >> x ; 
        s.insert(x) ; 
    }
    if ( s.size() == n ) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0; 
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop") 
#define all(a) a.begin(),a.end()
#define bs binary_search
#define ll long long int
#define ps push_back
#define fs first
#define sc second
#define mkp make_pair
#define mod 1000000007
ll dp[3001][3001];
ll maxval(ll ar[],ll l,ll r,ll c){
	if(l==r){
		if(c%2==0) return ar[l];
		else return -ar[l];
	}

	if(dp[l][r]!=-1){
		return dp[l][r];
	}

	if(c%2==0){
		return dp[l][r]=max(ar[l]+maxval(ar,l+1,r,c+1),ar[r]+maxval(ar,l,r-1,c+1));
	}
	else {
		return dp[l][r]=min(maxval(ar,l+1,r,c+1)-ar[l],maxval(ar,l,r-1,c+1)-ar[r]);
	}
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	memset(dp,-1,sizeof(dp));

	ll i,j,k,l,n;
	cin>>n;

	ll ar[n];
	for(i=0;i<n;i++){
		cin>>ar[i];
	}
	
	k=maxval(ar,0,n-1,0);
	cout<<k;
	return 0;
}
//ctrl H replace

Measured memory_bytes: 70912
#include <cstdio>
int f_1[2005][2005],f_2[2005][2005],a[2005][2005],sum[2005][2005];
char mp[2005];
int main(){
	int n,m,q;
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++){
		scanf("%s",mp+1);
		for(int j=1;j<=m;j++){
			a[i][j]=mp[j]-'0';
			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+a[i][j];
			f_1[i][j]=f_1[i-1][j]+f_1[i][j-1]-f_1[i-1][j-1];
			f_2[i][j]=f_2[i-1][j]+f_2[i][j-1]-f_2[i-1][j-1];
			if(a[i][j]==1){
				if(a[i-1][j]==1){
					f_1[i][j]++;
				}
				if(a[i][j-1]==1){
					f_2[i][j]++;
				}
			}
		}
	}
	int x1,y1,x2,y2;
	int ans;
	while(q--){
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		ans=sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1];
		ans-=f_1[x2][y2]-f_1[x1][y2]-f_1[x2][y1-1]+f_1[x1][y1-1];
		ans-=f_2[x2][y2]-f_2[x1-1][y2]-f_2[x2][y1]+f_2[x1-1][y1];
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 64512
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class hawawa
{
  static Printer sw = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };

  static void Main()
  {
    Console.SetOut(sw);
    solve();
    Console.Out.Flush();
  }

  static void solve()
  {
    Scanner scanner = new Scanner();
    string str = scanner.next();
    str = str.Replace("2017/", "2018/");
    Console.WriteLine(str);
  }
}

class Scanner
{
  string[] s;
  int i;


  char[] cs = new char[] { ' ' };

  public Scanner()
  {
    s = new string[0];
    i = 0;
  }

  public string next()
  {
    if (i < s.Length) return s[i++];
    string st = Console.ReadLine();
    while (st == "") st = Console.ReadLine();
    s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
    i = 0;
    return next();
  }

  public int nextInt()
  {
    return int.Parse(next());
  }

  public long nextLong()
  {
    return long.Parse(next());
  }

  public double nextDouble()
  {
    return double.Parse(next());
  }

}

class Printer : StreamWriter
{
  public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
  public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
  public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { }
}


Measured memory_bytes: 13140
#include <iostream>

using namespace std;

using ll = long long;

ll f(ll a, ll b){
  if(a < b)
    swap(a, b);
  if(b == 0)
    return -a;
  else {
    return f(a % b, b) + 2 * b * (a / b);
  }
}

int main()
{
  ll n, x;
  cin >> n >> x;
  cout << n + f(n - x, x);
  return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define MOD 1000000007

int main() {
    string s;
    cin >> s;
    if (s[s.length() - 1] == 's') {
        s += "es";
    } else {
        s += "s";
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3596
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())),reverse=1)
q=sorted(list(map(int,input().split())),reverse=1)
r=list(map(int,input().split()))
a=sorted(p[:x]+q[:y]+r,reverse=1)
print(sum(a[:x+y]))



Measured memory_bytes: 110188
#include <stdio.h>

int main(void){
  int a, b, d, r;
  double f;
  scanf("%d %d",&a,&b);
  d=a/b;
  r=a%b;
  f=(double)a/(double)b;
  printf("%d %d %f\n",d,r,f);

 return 0;
  }

Measured memory_bytes: 636
#include <stdio.h>
int main(void){
    int i, ii, k, n, x, y, a, b, c;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &k);
    n = 0;
    while (a >= b)
    {
        b *= 2;
        n++;
        if (n == 10)
        {
            printf("No");
            return (0);
        }
    }
    while (b >= c)
    {
        c *= 2;
        n++;
        if (n == 10)
        {
            printf("No");
            return (0);
        }
    }
    if (n <= k)
        printf("Yes");
    else
        printf("No");
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(a) (a).begin(),(a).end()

int main(){
  string s;
  cin>>s;
  while (s.size() > 3) {
    vector<int> found(3, false);
    vector<bool> abc(s.size(), false);
    REP(i, s.size()-2) {
      if (s.substr(i, 3) != "ABC") {
        if (!abc[i]) {
          found[s[i] - 'A'] = 1;
        }
      } else {
        abc[i] = abc[i+1] = abc[i+2] = true;
      }
    }
    if (!abc[s.size()-2]) {
      found[s[s.size()-2] - 'A'] = 1;
    } if (!abc.back()) {
      found[s[s.size()-1] - 'A'] = 1;
    }
    if (found[0] + found[1] + found[2] != 2) break;
    char c = 'A';
    if (found[0] && found[1]) c = 'C';
    if (found[1] && found[2]) c = 'A';
    if (found[2] && found[0]) c = 'B';
    string next;
    REP(i, s.size()) {
      if (abc[i]) {
        if (s[i] == 'A') {
          next += c;
        }
      } else {
        next += s[i];
      }
    }
    s = next;
  }
  if (s == "ABC") {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

int main() {
    ll N,W;
    ll w[101],v[101];
    std::cin >> N>>W;
    for (int i = 0; i < N; i++) {
        std::cin >> w[i]>>v[i];
    }
    ll dp[101][100001];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= 100000; j++) {
            dp[i][j] = W+1;
        }
    }
    
    dp[0][0] = 0;
    
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= 100000; j++) {
            dp[i+1][j] = dp[i][j];
            if(j-v[i]>=0){
                dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]] + w[i] );
            }
        }
    }
    
    for (int i = 100000; i >= 0; i--) {
        if(dp[N][i]<=W){
            std::cout << i << std::endl;
            return 0;
        }
    }
    
}



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

int main(){
    int n = 0;
    char s[5];
    char week[7][5] = {"SAT","FRI","THU","WED","TUE","MON","SUN"};
    
    scanf("%s",s);
    for (int i = 0; i < 7; i++){
        if (strcmp(s,week[i]) == 0){
            n = i;
        }
    }
    printf("%d\n",n + 1);
    
    return 0;
}

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

int main(){
    int n,ans=0;
    string s;
    cin >> n >> s;
    for(int i=0;i<n-2;i++){
        string ss = s.substr(i,3);
        if(ss=="ABC") ans++;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256