akhauriyash/Code-Regression huggingface dataset:
def solve():
    n = int(input())
    
    P = set()
    for i in range(n):
        x,y,h = map(int,input().split())
        if h != 0:
            P.add((x,y,h))
    x,y,h = P.pop()
    if not P:
        return x,y,h
    for cx in range(101):
        for cy in range(101):
            H = h + abs(x-cx) + abs(y-cy)
            for p in P:
                if H != p[2] + abs(p[0]-cx) + abs(p[1]-cy):
                    break
            else:
                return cx,cy,H
        
if __name__ == '__main__':
    print(*(solve()))


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#define MAX 200000
#define INFTY 1<<30
using namespace std;
typedef long long llong;

int n, k;
llong T[MAX];

int check(llong p)
{
  int j = 0;
  for(int i = 0; i < k; i++)
  {
    llong s = 0;
    while(s + T[j] <= p)
    {
      s += T[j];
      j++;
      if(j == n) return j;
    }
  }
  return j;
}

int solve()
{
  llong left = 0;
  llong right = 100000 * 10000;
  llong mid;
  while(right - left > 1)
  {
    mid = (right + left)/2;
    int v = check(mid);
    if(v >= n) right = mid;
    else left = mid;
  }
  return right;
}

int main()
{
  cin >> n >> k;
  for(int i = 0; i < n; i++) cin >> T[i];
  cout << solve() << endl;
  return 0;
}

Measured memory_bytes: 1956
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>

#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second

using namespace std;
using ll = long long;
using namespace __gnu_pbds;

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 2e5 + 10 , inf = 2e9 + 7;
const ll INF = 1e18 , mod = 1e9+7;

int a[N] , cnt[N][2];

void solve() {
    int n;
    string s;
    cin >> n >> s;
    for(int i = 0; i < s.size(); i ++) {
        a[i+1] = (s[i] == 'W');
    }
    for(int i = 1; i <= n; i ++) {
        cnt[i][a[i]] ++;
        cnt[i][0] += cnt[i-1][0];
        cnt[i][1] += cnt[i-1][1];
    }
    int ans = min(cnt[n][0] , cnt[n][1]);
    for(int i = 1; i < n; i ++) {
        ans = min(ans , max(cnt[i][1] , (cnt[n][0] - cnt[i][0])));
    }
    cout << ans;
}
/*
*/
main() {
    ios;
    int tt = 1;
    //cin >> tt;
    while(tt --) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 6072
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int A, B, C, D, E, F;

int dp[3000+2] = {0}; // 0 未, 1不可, 2可能

int possibleWater(int water){
	int ret = 1;
	if(dp[water] != 0){
		return dp[water];
	}
	for(int i=0; (100 * A * i) <= F; i++){
		for(int j=0; (100 * B * j) <= F; j++){
			int tmp = (100 * A * i) + (100 * B * j) ;
			if(tmp <= F)
				dp[tmp] = 2;
			if(water == tmp){
				ret = 2;
				break;
			}
		}
		if(ret == 2){
			break;
		}
	}
	if(water <= F){
		dp[water] = ret;
	}
	return ret;
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> A >> B >> C >> D >> E >> F;
	double maxconc = (double)(E) / (double)(100 + E);
	
	// 水 100A g : x回 
	// 水 100B g : y回 
	// さとう C g : u 回
	// さとう D g : v 回
	int water, water1;
	int sugar, sugar1;
	water1 = 100 * A , sugar1 = 0;
	//double conc1 = -1.0; // 0.0だと最大濃度0の時WA
	for(water = 100; water <= F; water += 100){
		int possibleW = possibleWater(water);
		if(possibleW != 2) continue;
		double conc2 = -1.0; //0.0だと最大濃度0の時WA
		int water2 = 100 * A, sugar2 = 0;
		int k = water / 100;
		int u, v;
		//for(v = 0; (D * v) <= (E * k); v++){
		for(v = 0; (D * v) <= F - water; v++){
			for(u = 0; (C * u) <= F - water - (D * v); u++){
				//u = max( ((E * k) - (D * v)) / C , 0);
				sugar = (C * u) + (D * v);
				if( sugar > (E * k) ) continue;
				if((water + sugar) > F) continue;
				if( (sugar + C) <= E * k && (sugar + C + water) <=F){
					u = u + 1;
					sugar = sugar + C;
				}
				double tmp = ((double) sugar) / ((double) (water + sugar));
				if(sugar * (100 + E) > E * (sugar + water)) continue;
				if(sugar2 * (water + sugar) <= sugar * (water2 + sugar2)){
				sugar2 = sugar;
				water2 = water;
			}
			}
		}
		if(sugar1 * (water2 + sugar2) <= sugar2 * (water1 + sugar1)){
			water1 = water2;
			sugar1 = sugar2;
		}
	}
	printf("%d %d\n", water1+sugar1, sugar1);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))

if N < M:
    print('NO')
else:
    D.sort()
    T.sort()
    cnt = 0
    i = 0
    for t in T:
        while i < N:
            if D[i] == t:
                cnt += 1
                i += 1
                break
            i += 1
    if cnt == M: print('YES')
    else: print('NO')

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


int main() {
int n;
int a[100];
int x = 0;
int y = 0;

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

sort(a,a+n,greater<int>());
for(int i=0;i<n;i++){
    if(i%2==0){
        x+=a[i];
    }else{
        y+=a[i];
    }
}

cout << x-y << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import deque

S = deque(input())
Q = int(input())

rev_stetus = False
for _ in range(Q):
    ipt = input().split()
    if ipt[0] == "1":
        rev_stetus = not rev_stetus
    else:
        f = int(ipt[1])
        c = ipt[2]
        if rev_stetus:
            if f == 1:
                S.append(c)
            else:
                S.appendleft(c)
        else:
            if f == 1:
                S.appendleft(c)
            else:
                S.append(c)

if rev_stetus:
    S.reverse()
    print("".join(S))
else:
    print("".join(S))

Measured memory_bytes: 8436
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int main()
{
	int num;
	double w,h;
	bool c=true;
	while(scanf("%d,%lf,%lf",&num,&w,&h)!=EOF)
	{
		if(w/(h*h)>=25)
		{
			cout << num  << endl;
			c=false;
		}
	}
	if(c) cout << "該当なし" << endl;
	return 0;
}

Measured memory_bytes: 1232
#include <cstddef>
#include <limits>
#include <climits>
#include <cfloat>
#include <cstdint>
#include <cstdlib>
#include <new>
#include <typeinfo>
#include <exception>
#include <initializer_list>
#include <cstdalign>
#include <stdexcept>
#include <cassert>
#include <cerrno>
#include <system_error>
#include <string>

#if __has_include(<string_view>)
#   include <string_view>
#endif

#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>

#if __has_include(<filesystem>)
#   include <filesystem>
#endif

#include <cstdio>
#include <cinttypes>


#include <regex>
#include <atomic>
#include <thread>
#include <mutex>
#include <shared_mutex>
#include <condition_variable>
#include <future>

using namespace std::literals ;
using namespace std;

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

    unsigned int N, h;
    cin >> N >> h;

    vector<unsigned int> hs;
    int input;
    while (cin >> input) {
        hs.push_back(input);
        if (hs.size() == N)
            break;
    }

    int count = 0;
    for (unsigned int i = 0; i != N; i++) {
        if (hs[i] >= h) {
            count++;
        }
    }
    cout << count;
}


Measured memory_bytes: 892
# Binary Indexed Tred
# https://www.slideshare.net/hcpc_hokudai/binary-indexed-tree
# http://hos.ac/slides/20140319_bit.pdf
# https://ikatakos.com/pot/programming_algorithm/data_structure/binary_indexed_tree


from collections import defaultdict
import sys
input = sys.stdin.readline


class FenwickTree:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 100)

    def add(self, i, x):
        i = i + 1
        while i <= self.size + 1:
            self.tree[i] += x
            i += i & -i
        return

    def sum(self, i):
        i = i + 1
        _sum = 0
        while i > 0:
            _sum += self.tree[i]
            i -= i & -i
        return _sum


def solve(n, A):
    ans = 0
    bit = FenwickTree(n)
    B = sorted(A)

    d = defaultdict(int)
    for i in range(n):
        d[B[i]] = i

    for i in range(n):
        t = A[i]
        ind = d[t] + 1
        ans += i - bit.sum(ind)
        bit.add(ind, 1)

    return ans


def main():
    n = int(input().strip())
    A = [int(i) for i in input().strip().split()]

    ans = solve(n, A)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 40264
#include <bits/stdc++.h>
#include <iostream> 
#include <iterator>
#include <vector>
using namespace std;


int main(int argc, char const *argv[])
{
	int N, K, X, Y;
	int sum = 0;
	cin >> N >> K >> X >> Y;
	if(N>K){
		sum += X * K;
		sum += Y * (N-K);
		}else if(N < K){
			sum += X * N;
			}		
		else{
			sum += X * K;
			}
	cout << sum;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    if (k == 0)
    {
        putout(n * n);
        return 0;
    }
    //bを決定
    Loop(i, 1, n + 1)
    {
        ll b = i;
        //a->0~nとすると、あまりは順に0,1,..b-1,0,1,...b-1,.......,0,1,...r
        ll round = (n + 1) / b;
        ans += max(0ll, b - k) * round;
        if ((n + 1) % b != 0)
            ans += max(0ll, ((n + 1) - b * round) - k);
    }
    putout(ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define all(v) v.begin(),v.end()
using namespace std;

signed main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n)cin>>a[i];
    int q;
    cin>>q;
    rep(i,q){
        int b,m,e;
        cin>>b>>m>>e;
        rotate(a+b,a+m,a+e);
    }
    rep(i,n){
        cout<<(i?" ":"")<<a[i];
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 3164
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define endl '\n'
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

struct Edge {
    int src, to;
    i64 cost;
    Edge(int src,  int to, i64 cost) : src(src), to(to), cost(cost) {}
    Edge(int to, i64 cost = 0) : Edge(-1, to, cost) {}
    bool operator< (const Edge &o) const { return cost < o.cost; }
    bool operator> (const Edge &o) const { return cost > o.cost; }
};
using Edges = vector<Edge>;
using WGraph = vector<vector<Edge>>;
using Ugraph = vector<vector<int>>;

vector<i64> bellmanFord(const Edges &es, int V, int src)
{
    vector<i64> dist(V, LINF);
    dist[src] = 0;

    bool updated = true;
    for (int i = 0; updated && i < V-1; ++i) {
        updated = false;
        for (const auto &e : es) {
            if (dist[e.src] == LINF) continue;
            updated |= chmin(dist[e.to], dist[e.src] + e.cost);
        }
    }

    return dist;
}

vector<bool> checkNegativeCycle(const Edges &es, int V, const vector<i64> &dist)
{
    vector<bool> negative(V, false);
    for (int i = 0; i < V; ++i) {
        for (const auto &e : es) {
            if (dist[e.src] < LINF) {
                if (dist[e.to] > dist[e.src] + e.cost) negative[e.src] = true;
                if (negative[e.src]) negative[e.to] = true;
            }
        }
    }
    return negative;
}

signed main()
{
    int V, E;
    cin >> V >> E;

    Edges es;
    for (int i = 0; i < E; ++i) {
        int s, t, c;
        cin >> s >> t >> c;
        --s, --t;
        es.emplace_back(s, t, -c);
    }

    const auto dist = bellmanFord(es, V, 0);

    if (checkNegativeCycle(es, V, dist)[V-1]) {
        cout << "inf" << endl;
    } else {
        cout << -dist[V-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000],cnt[1000000];
long long M=998244353;
long long int power(long long int x, long long int y, long long int p) 
{ 
    int res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = ((res%p)*(x%p)) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = ((x%p)*(x%p)) % p;   
    } 
    return res; 
} 
int main()
{
	long long n,i,mx,ans;
	cin>>n;
	ans=1;
	mx=-1;
	for (i=0;i<n;i++)
	
	{
		cin>>arr[i];
		cnt[arr[i]]++;
		mx=max(arr[i],mx);
	}
	if (arr[0]!=0 || cnt[0]>1)
	{
		cout<<0<<endl;
		return 0;
	}
	for(i=0;i<mx;i++)
	{
		if (cnt[i]==0)
		{
			cout<<0<<endl;
			return 0;
		}
	}
	for(i=mx;i>=1;i--)
	{
		ans=(ans*power(cnt[i-1],cnt[i],M))%M;
	}	
	cout<<ans<<endl;
}

Measured memory_bytes: 5120
#include<stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int h[n];

    for (int i = 0; i < n; i++){
        scanf("%d", &h[i]);
    }
    int max = 0;
    int cnt = 0;
    for (int i = 0; i < n-1; i++){
        if ( h[i] >= h[i+1]){
            cnt++;
            
        }else {
            if (max < cnt) max = cnt;
            cnt = 0;
        }
    }
    if (max < cnt) max = cnt;

    printf("%d\n", max);

}

Measured memory_bytes: 512
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	n,k,c=MI()
	s=RD()

	A=[]
	now=0

	while now<n and len(A)<k:
		if s[now]=="o":
			A.append(now+1)
			now+=c+1
		else:
			now+=1
	#print(A)

	B=[]
	now=0
	while now<n and len(B)<k:
		if s[n-1-now]=="o":
			B.append(n-now)
			now+=c+1
		else:
			now+=1


	ans=[]
	for i,j in zip(A,B[::-1]):
		if i==j:
			ans.append(i)

	print(*ans,sep="\n")










if __name__ == "__main__":
	main()


Measured memory_bytes: 29620
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    int ans = (n + 1) / 2;
    int x = (n - 1) / 2;
    int a = (n - 2) / 2;
    int b = (n + 1) / 2;
    while(0 <= a && s[a] == s[x] && s[b] == s[x]){
        ++ ans;
        -- a;
        ++ b;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using p  = pair<int, int>;
using vec_int = vector<int>;
using vec_str = vector<string>;
#define INF (1<<29)
ll ans = 0;

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

void debug_input(vec_str& argv)
{
    // デバッグ用引数読み込み
    ifstream file("./input.txt");
    string str;
    while( getline(file, str) ) {
        argv.push_back(str);
    }
}

void debug_split_string(const string& str, vec_str& v)
{
    stringstream ss{str};
    string buf;
    while (getline(ss, buf, ' ')) {
        v.push_back(buf);
    }
}

void debug_split_int(const string& str, vec_int& v)
{
    stringstream ss{str};
    string buf;
    while (getline(ss, buf, ' ')) {
        istringstream ss(buf);
        int temp;
        ss >> temp;
        v.push_back(temp);
    }
}

int main()
{
    string S;
	cin >> S;
    int n = S.size();
    reverse(S.begin(), S.end());
    int x = 1, tot = 0;
    const int m = 2019;
    std::vector<int> cnt(m);

    rep(i, n) {
        cnt[tot]++;
        tot += (S[i] - '0')*x;
        tot %= m;
        ans += cnt[tot];
        x = (x*10) % m;
        //cout << v[i] << endl;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3732
using System;

    class Program
    {
        static void Main(string[] args)
        {
            string[] inputs = Console.ReadLine().Split(' ');

            int capacity = int.Parse(inputs[0]);
            int waterlevel = int.Parse(inputs[1]);
            int addWater = int.Parse(inputs[2]);
            int remainWater;
            int canInWater;

            canInWater = capacity - waterlevel;

            if (canInWater <= addWater)
            {
                remainWater = addWater - canInWater;
            }else
            {
                remainWater = 0;
            }
            Console.WriteLine(remainWater);

        }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
    int N, K;
    int A[200010] = {};
    int B[200010] = {};

    cin >> N >> K;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    int max_val = 0;
    for(int i = 0; i < N; i++) {
        B[A[i]]++;
    }

    sort(B+1, B + N+1, greater<int>() );


    int count = 0;
    for(int i = K + 1; i <= N; i++) {
        count += B[i];
    }

    cout << count << endl;

}

Measured memory_bytes: 1792
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();

        int rem = N % 10;
        int div = N / 10;
        if(rem == 0){
        	if(N >= 100){
        		while(div >= 100){
        			div /= 10;
        		}
        	}else{
        		div = N;
        	}
    		System.out.println(div);
        }else{
        	while(div >= 10){
            	rem += div % 10;
            	div /= 10;
        	}
    		System.out.println(div + rem);
		}
    }
}

Measured memory_bytes: 23252
#include<iostream> 
#include<vector> 
#include<string> 
#include<algorithm> 
using namespace std; 
int main()
{
	int n, k; 
	cin >> n >> k;
	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());
	int ans = 0;
	for (int i = 0; i < k; i++)
	{
		ans += a.at(i);
	} 
	cout << ans << endl;
}

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

int main()
{
  int n, ans{0};
  string a, b, c;
  cin >> n >> a >> b >> c;
  for (auto i = 0; i < n; i++) {
    map<char, int> mp;
    int m{0};
    m = max(m, ++mp[a[i]]);
    m = max(m, ++mp[b[i]]);
    m = max(m, ++mp[c[i]]);
    ans += 3 - m;
  }
  cout << ans << endl;
}


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

typedef long long i64;

struct Edge
{
    int nxt, to;
} e[200010];
int head[100010], cnt;
int val[100010];
bool ok = 1;

void add_edge(int a, int b)
{
    e[++cnt] = { head[a], b };
    head[a] = cnt;
}

int dfs(int nod, int tata)
{
    int sum(0);
    int vmax(0);
    for (int i(head[nod]); i; i = e[i].nxt) {
        if (e[i].to == tata)
            continue;
        int x = dfs(e[i].to, nod);
        sum += x;
        vmax = max(vmax, x);
    }
    if (e[head[nod]].nxt == 0)
        return val[nod];

    if (sum < 0 || sum > 2 * val[nod])
        ok = 0;

    vmax = max(1ll * vmax, 2ll * val[nod] - sum);
    if (vmax > val[nod])
        ok = 0;
    return 2 * val[nod] - sum;
}

int main()
{
    int n, a, b;
    cin >> n;

    for (int i(1); i <= n; i++)
        cin >> val[i];

    for (int i(1); i < n; i++) {
        cin >> a >> b;
        add_edge(a, b);
        add_edge(b, a);
    }

    if (n == 2) {
        if (val[1] == val[2])
            cout << "YES\n";
        else
            cout << "NO\n";
        return 0;
    }

    int root = 0;
    for (int i(n); i >= 1; i--)
        if (e[head[i]].nxt)
            root = i;

    int x = dfs(root, 0);

    if (x || !ok)
        cout << "NO\n";
    else
        cout << "YES\n";
    return 0;
}



Measured memory_bytes: 7936
n = int(input())
s = list(map(int, input().split()))
evens, odds = 0, 0
for i in s:
    if i % 2 == 0:
        evens += 1
    else:
        odds += 1
if odds % 2 == 0:
    ok = True
else:
    ok = False
print('YES' if ok else 'NO')


Measured memory_bytes: 14108
import java.util.Scanner;

public class Main {

	static final boolean debugMode = false;

	static final long DIV_INF = 1000000007l;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = readLong(sc);
		long k = readLong(sc);

		long cnt = 0;

		for (long i = k; i <= n + 1; i++) {

			cnt = modPlus(cnt, (n * i - i * i + i + 1l), DIV_INF);
		}

		System.out.println(cnt % 1000000007l);

	}

	static long modPlus(long a, long b, long div) {
		return a + b > div ? (a + b) % div : a + b;
	}

	// con.) a >= b
	static int gcm(int a, int b) {
		while (true) {
			if (b == 0)
				break;

			int mod = a % b;
			a = b;
			b = mod;
		}
		return a;
	}

	// con.) a >= b
	static int lcm(int a, int b) {
		return a * b / gcm(a, b);
	}

	static int readInt(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	static Long readLong(Scanner sc) {
		return Long.parseLong(sc.next());
	}

	static void log(String s) {
		if (debugMode) {
			System.out.println(s);
		}
		return;
	}
}

class Pair {
	private int x;
	private int y;

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public Pair() {

	}

	public Pair(int x, int y) {
		this.x = x;
		this.y = y;
	}

}


Measured memory_bytes: 27176
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int  main(){
int n;
cin >> n;
vector<int>a(n);
bool che = true;
for(int i=0;i<n;i++){
    cin >> a.at(i);
}
sort(a.begin(),a.end());
int  ans = 10e8;
for(int i=1;i<n;i++){
   ans = min(ans,gcd(a.at(0),a.at(i)));
}
cout << ans << endl;
}





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

using namespace std;

struct DATA{
  int number;
  int score;
  int rank;
};

bool Compare1(const DATA&, const DATA&);
bool Compare2(const DATA&, const DATA&);

int main(){
  int i, n, m, a, b, c, d;
  DATA onedata;
  vector<DATA> data;

  cin >> n;
  for(i=0; i<n; ++i){
    onedata.number = i+1;
    onedata.score = 0;
    onedata.rank = 0;
    data.push_back(onedata);
  }

  m = n * (n-1) / 2;
  for(i=0; i<m; ++i){
    cin >> a >> b >> c >> d;
    if(c > d){
      data[a-1].score += 3;
    }else if(c < d){
      data[b-1].score += 3;
    }else{
      ++data[a-1].score;
      ++data[b-1].score;
    }
  }

  sort(data.begin(), data.end(), Compare1);

  data[0].rank = 1;
  for(i=1; i<data.size(); ++i){
    if(data[i].score == data[i-1].score)
      data[i].rank = data[i-1].rank;
    else
      data[i].rank = i+1;
  }

  sort(data.begin(), data.end(), Compare2);

  for(i=0; i<data.size(); ++i)
    cout << data[i].rank << endl;

  return 0;
}

bool Compare1(const DATA& x, const DATA& y){
  return (x.score > y.score);
}

bool Compare2(const DATA& x, const DATA& y){
  return (x.number < y.number);
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <climits>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int cnt = 0;
int main(){
    int A[3];
    rep(i, 3) cin >> A[i];
    while(!(A[0] == A[1] && A[1] == A[2])){
        sort(A, A+3);
        if(A[1] == A[2] || A[2] - A[0] > 1){
            A[0] += 2;
        }else{
            A[0]++;
            A[1]++;
        }
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

//#define PRAGMA 448
#ifdef PRAGMA
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

#ifdef LUCARIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif

typedef int intt;
typedef pair<long long,long long> pll;
typedef pair<int,int> pii;

#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define int long long
#define pb push_back
#define bs binary_search
#define up upper_bound
#define fs first 
#define sd second 
#define mp make_pair    
#define endl "\n"

#define fore(i,a,b) for(ll i = a; i < b; i++)
#define rfore(i, a, b) for(ll i = a - 1; i >= b; i--)
#define forev(a,b) fore(i,0,b)cout<<a[i]<<" "; 
#define ing(g,u,v)  g[u].pb(v); g[v].pb(u);
#define ingp(g,u,v,c) (g[u].pb({v,c});g[v].pb({u,c});)
#define mm(a,b) memset(a , b , sizeof a) 
#define ALL(a) a.begin(),a.end() 
#define SZ(n) ((ll) (n).size())
#define sfind(s,t) (s.find(t) != string::npos)

#define infll (ll)1e15
#define infi  (int)(1e9+1)
#define PI 3.14159265359 
#define mod (ll)(1e9+7)
#define eps  1e-6

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

int n;
pii a[200001];

#define oper max
#define NEUT 0
struct STree { // segment tree for min over integers
        vector<int> st;int n;
        STree(int n): st(4*n+5,NEUT), n(n) {}
        void init(int k, int s, int e, int *a){
                if(s+1==e){st[k]=a[s];return;}
                int m=(s+e)/2;
                init(2*k,s,m,a);init(2*k+1,m,e,a);
                st[k]=oper(st[2*k],st[2*k+1]);
        }
        void upd(int k, int s, int e, int p, int v){
                if(s+1==e){st[k]=v;return;}
                int m=(s+e)/2;
                if(p<m)upd(2*k,s,m,p,v);
                else upd(2*k+1,m,e,p,v);
                st[k]=oper(st[2*k],st[2*k+1]);
        }

        int query(int k, int s, int e, int a, int b){
                if(s>=b||e<=a)return NEUT;
                if(s>=a&&e<=b)return st[k];
                int m=(s+e)/2;
                return oper(query(2*k,s,m,a,b),query(2*k+1,m,e,a,b));
        }
        void dump(int n){
                fore(i,0,n){
                        cout<<st[i]<<" ";
                }
                cout<<endl;
        }

        void init(int *a){init(1,0,n,a);}
        void upd(int p, int v){upd(1,0,n,p,v);}
        int query(int a, int b){return query(1,0,n,a,b);}
}; // usage: STree rmq(n);rmq.init(x);rmq.upd(i,v);rmq.query(s,e);
        

int32_t main(int32_t argc, char const *argv[]){
    FIN;
    cin>>n;
    fore(i,0,n)cin>>a[i].fs;
    fore(i,0,n)cin>>a[i].sd;
    STree st(2*n);
    fore(i,0,n){
        st.upd(a[i].fs,st.query(0,a[i].fs+1)+a[i].sd);
    }
    cout<<st.query(0,n+2);

    return 0;
}


























































































































































//PROGRAMADO POR xXLucarioXx    

Measured memory_bytes: 14336
using System;

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

            var k = int.Parse(s);
            Console.WriteLine(Problem1.GetAnswer(k));
        }
    }

    public class Problem1
    {
        public static int GetAnswer(int k)
        {
            var data = new[] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
            return data[k - 1];
        }
    }
}

Measured memory_bytes: 13140
#include<cstdio>
#include<map>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<cctype>
#include <iostream>
using namespace std;
int main()
{
    long long a,b;
    while(~scanf("%lld%lld",&a,&b))
    {
        if(abs(a-b)>1)
            printf("Alice\n");
        else printf("Brown\n");
    }
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func NextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := NextInt()

	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = NextInt()
		b[i] = NextInt()
	}
	sort.Ints(a)
	sort.Ints(b)

	var ans int

	if n%2 == 1 {
		ans = b[n/2] - a[n/2] + 1
	} else {
		ans = (b[n/2] + b[n/2-1]) - (a[n/2] + a[n/2-1]) + 1
	}
	fmt.Println(ans)
}


Measured memory_bytes: 8356
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cstring>
#include <algorithm>
#include <vector>
//#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <map>
#include <numeric>
using namespace std;
#define fin << '\n'
#define finl << '\n';
#define finn cout << '\n'
#define unless(flg) if(!(flg))
#define alles(obj) obj.begin(), obj.end()
// bashise
#define elif else if
#define echo cout <<
#define read cin >>
// javaise
#define bash push_back
#define makePair make_pair
#define isEmpty empty
// germanise
#define drucken(obj) cout << obj << '\n'
#define lesen(obj) cin >> obj
#define fur for
#define wenn if
#define sonst else
#define Zahl int
// type-define
#define String string
#define Stack stack
#define Queue queue
#define pQueue priority_queue
#define Vector vector
#define Pair pair
#define Map map
typedef long long llong;
typedef bool boolean;
typedef Pair<int,int> Pii;
typedef Vector<int> Vi;
// utils
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
boolean isMovable(int x,int y,int w,int h){return (x>=0&&y>=0&&x<w&&y<h);};
const int INF = 1 << 29;

int ans;

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

    int n;
    String s, t;
    read n;
    read s >> t;
    
    for ( int i = 0; i < n; i++ ) {
        for ( int j = 0; j < n; j++ ) {
            int tmp = 0;
            for ( int k = 0; k+j < n; k++ ) {
                if ( s[k+j] == t[k] ) {
                    tmp++;
                }
                else break;
            }
            ans = max(tmp, ans);
        }
    }

    echo (n*2)-ans fin;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 int main(void)
{
	int a,b;
 
	scanf("%d%d",&a,&b);
	if((a+b)%2==0)
		printf("%d\n",(a+b)/2);
	else 
                 printf("IMPOSSIBLE\n");
	return 0;
        getch();
}
 

Measured memory_bytes: 128
using System;

namespace abc139_d
{
    static class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine().ToLong();
            // 9 % 1 = 0
            // 8 % 9 = 8
            // 7 % 8 = 7
            //   :
            // 2 % 3 = 2
            // 1 % 2 = 1
            // 8 7 6 5 4 3 2 1
            // (8 + 1) * 4
            // 7 6 5 4 3 2 1
            // (7 + 1) * 3 + 4
            // (7 + 1) * 3.5

            // ((n - 1) + 1) * ((n - 1) / 2)
            var m = n * (n - 1) / 2;

            Console.WriteLine($"{m}");
        }

        static long ToLong(this string s)
        {
            return long.Parse(s);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
using namespace std;
#define ll long long
#define fori(n) for(int i=0;i<n;i++)
#define forr(s,n) for(int i=s;i<n;i++)
#define forj(j,s,n) for(int j=s;j<n;j++)

int main(int argc, char const *argv[])
{
    ll n;cin>>n;
    ll a[n];fori(n)cin>>a[i];
    ll sum=0;fori(n)sum+=a[i];
    ll ts=0, min=2020202023;
    fori(n){
        ts+=a[i];
        ll x=sum-ts;
        if(abs(x-ts)<min)min=abs(x-ts);
    }
    cout<<min<<endl;
    return 0;
}


Measured memory_bytes: 1792
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private int N;
    private int A;
    private int B;
    private int[] h;
 
    private void solve(Scanner sc) {
        N = sc.nextInt();
        A = sc.nextInt();
        B = sc.nextInt();
        h = new int[N];
        for (int i = 0; i < N; ++i) {
            h[i] = sc.nextInt();
        }
 
        int max = Arrays.stream(h).max().getAsInt();
 
        int left = 0;
        int right = 1_000_000_000;
        int ans = (int)Math.ceil(1d * max / B);
        while (left < right) {
            int c = (left + right) / 2;
            if (enough(c)) {
                right = c;
                ans = c;
            } else {
                left = c + 1;
            }
        }
 
        _out.println(ans);
    }
    private boolean enough(int t) {
        int total = 0;
        for (int i = 0; i < N; ++i) {
            if (h[i] > (long)B * t) {
                total += Math.ceil(((double)h[i] - B * t) / (A - B));
            }
        }
        return total <= t;
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 52408
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# import numpy as np
sys.setrecursionlimit(int(pow(10,6)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]



x,y=l()
for a in range(1000):
    for b in range(1000):
        if a+b==x and 2*a+4*b==y:
            print("Yes")
            exit()
print("No")
exit()

Measured memory_bytes: 10676
#include<bits/stdc++.h>
using namespace std;
double dp[3001][3001];	// prob of j heads in first i coins
int main()
{
	int i,j,n;
	double p[3001];
	cin>>n;
	for(i=0;i<n;i++)
		cin>>p[i];
	for(i=0;i<n;i++)
	{
		for(j=0;j<=i+1;j++)
		{
			if(i==0)
			{
				if(j==0)
					dp[i][j]= 1-p[i];
				else
					dp[i][j]=p[i];
			}
			else if(j==0)
				dp[i][j]=dp[i-1][j]*(1-p[i]);
			else
				dp[i][j] = (dp[i-1][j-1]*p[i])+(dp[i-1][j]*(1-p[i]));
		}
	}
	double ans;
	for(i=n/2+1;i<=n;i++)
		ans=ans+dp[n-1][i];
	cout<<setprecision(10)<<ans<<endl;
}


Measured memory_bytes: 68864
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    string S; cin >> S;
    int N = S.size();
    int K; cin  >> K;
    string T = S;

    rep(i,N) {
        if (S[i] == 'a') continue;
        int toa = 'z' + 1 - S[i];
        if (toa <= K) K-=toa, S[i] = 'a';
    }

    if (S[N-1] != 'a') {
        int toa = 'z' + 1 - S[N-1];
        if (toa <= K) K-=toa, S[N-1] = 'a';
        else {
            S[N-1] += K;
            K = 0;
        }
    }
    K = K % 26;
    S[N-1] += K;

    cout << S << endl;
}


Measured memory_bytes: 3844
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{ 
  	ll m,d,c,ct=0,sum=0;
  	cin>>m;

  	for(ll i=0;i<m;i++)
  	{
  		cin>>d>>c;
  		sum+=(d*c);
  		ct+=c;
  	}
  	cout<<ct-1+((sum-1)/9);
   }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int N, T;
    cin >> N >> T;
    ll ans = 0;
    vector<int> t(N);
    rep(i, N) cin >> t[i];
    ans = T*t.size();
    FOR(i, 1, N) {
        if (t[i] - t[i - 1] < T) {
            ans -= T - t[i] + t[i - 1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
main(){
  int count[4][3][10]={{0},{0},{0}};
  int n,b,f,r,v;
  int i,j,k;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d%d%d",&b,&f,&r,&v);
    count[b-1][f-1][r-1]=count[b-1][f-1][r-1]+v;
  }

  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
          printf(" ");
          count[i][j][k];
          printf("%d",count[i][j][k]);
      }
      printf("\n");
    }
    if(i<3)
      printf("####################\n");
  }
  return 0;
}

Measured memory_bytes: 612
#include <stdio.h>
int main(){
	int x,y;
	while(1){
		scanf("%d %d",&x ,&y);
		if( x == 0 && y == 0 ) break;
	if(x < y){
		printf("%d %d\n",x ,y);
	}else {
    		printf("%d %d\n",y ,x);
	}
    }return 0;
} 

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;
 
string s[51], t[51];
 
signed main(){
    int n, m;
    cin >> n >> m;
    rep(i, 0, n) cin >> s[i];
    rep(i, 0, m) cin >> t[i];
    rep(i, 0, n){
        rep(j, 0, n){
            bool g = true;
            rep(k, 0, m){
                rep(l, 0, m){
                    if(s[i + k][j + l] != t[k][l]){
                        g = false;
                        l = m; k = m;
                    }
                }
            }
            if(g){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    
}

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

class Program
{
    static void Main()
    {
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var N = input[0];
        var K = input[1];

        var p = Console.ReadLine().Split().Select(int.Parse).ToArray();

        Console.WriteLine(p.OrderBy(x => x).Take(K).Sum());
    }
}


Measured memory_bytes: 28712
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long  ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

//�ő����
int ans;


signed main(){
    int n;
    cin>>n;
    cout<<n*n*n<<endl;
}

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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

int n;
int a[MAXN], b[MAXN];

bool read() {
    if (!(cin >> n))
        return false;

    forn (i, n)
        cin >> a[i];

    return true;
}

void solve() {
    forn (i, n)
        b[i] = abs(2 * i - n + 1);

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

    forn (i, n)
        if (a[i] != b[i]) {
            cout << 0 << endl;
            return ;
        }

    ll res = 1;

    forn (i, n / 2)
        res = 2ll * res % INF;

    cout << res << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 4736
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main() {
	int i,count=0;
	char w[10] = { 0 }, t[1000] = { 0 };

	scanf("%s", w);

	while (1) {
		scanf("%s", t);

		if (strcmp(t, "END_OF_TEXT") == 0) {
			break;
		}
		
		for (i = 0; t[i] != '\0'; i++) {
			t[i] = tolower(t[i]);
		}
		
		if (strcmp(t, w) == 0) {
			++count;
		}
		
	}

	printf("%d\n", count);

	return 0;
}


Measured memory_bytes: 2100
import sys

input = sys.stdin.readline

def main():
    ans = 0
    ex = []
    for _ in range(5):
        t = int(input())
        e = 10 - t%10
        if e != 10:
          ex.append(e)
        ans += t
    ex.sort()
    ans += sum(ex[:-1])

    print(ans)

if __name__ == '__main__':
    main()

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int m, n;
bool check(vector<int> v,int mid){
  int h = 1;
  int w = 0;
  rep(i,n){
    if(v[i] > mid){
      return false;
    }
    if(w + v[i] <= mid){
      w += v[i];
    }
    else{
      w = v[i];
      ++h;
    }
  }
  if(h > m){
    return false;
  }
  return true;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(cin >> m >> n&&m&&n){
    vary(int,v,n,0);
    rep(i,n){
      cin >> v[i];
    }
    int lb = 1,ub = 1500000;
    while(1){
      int mid = (lb+ub)/2;
      if(mid == lb) break;
      if(check(v,mid)){
        ub = mid;
      }
      else{
        lb = mid;
      }
    }
    cout << ub << endl;
  }
  return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    if (n == 1){
        puts("1");
        puts("1");
        return 0;
    }
    if (n == 2){
        puts("2");
        puts("1");
        puts("00");
        return 0;
    }
    cout << n - 1 << endl;
    for (int i = n; i >= 2; i--){
        cout << '0' + string(i - 2, '1') + '0' << endl;
    }
}


Measured memory_bytes: 3216