akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define int long long
int n;
vector<pair<int, pair<int, int> > > d;

int par[100005];
long long res[100005];
int lazy[100005];

vector<int> child[100005];

void Union(int u, int v, int w)
{
    if (child[par[u]].size() > child[par[v]].size())
    {
        swap(u, v);
    }
    int k = par[u];
    lazy[par[v]] += w*child[k].size();
    for (int i = 0; i < child[k].size(); i++)
    {
        par[child[k][i]] = par[v];
        res[child[k][i]] += w*child[par[v]].size() - lazy[par[v]] + lazy[k];
    }
    for (int i = 0; i < child[k].size(); i++)
    {
        child[par[v]].push_back(child[k][i]);
    }
    lazy[k] = 0;
    child[k].clear();
}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for (int i = 1; i < n; i++)
    {
        int x, y, l; cin >> x >> y >> l;
        d.push_back({l,{x,y}});
    }
    for (int i = 1; i <= n; i++)
    {
        child[i].push_back(i);
        par[i] = i;
        lazy[i] = 0;
    }
    sort(d.begin(), d.end());
    memset(res, 0, sizeof res);
    memset(lazy, 0, sizeof lazy);
    reverse(d.begin(), d.end());
    for (int i = 0; i < n-1; i++)
    {
        Union(d[i].second.first, d[i].second.second, d[i].first);
    }
    for (int i = 1; i <= n; i++)
    {
        cout << res[i] + lazy[par[i]] << endl;
    }
}


Measured memory_bytes: 19696
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  string S;
  cin >> S;
  if(!(S[0] == S[1] && S[0] == S[2] && S[0] == S[3]) &&
     ((S[0] == S[1] && S[2] == S[3]) ||
      (S[0] == S[2] && S[1] == S[3]) ||
      (S[0] == S[3] && S[1] == S[2]))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
include Math

until (n = $<.gets.to_i).zero?
  points = Array.new(n) { Complex(*$<.gets.split(",").map(&:to_f))  }
  ym = points.map(&:imaginary).max
  start_po = po0 = points.find {|po| po.imaginary == ym}
  prev_arg = PI
  
  result = loop do
    points = (points - [start_po] + [po0]).uniq
    selected = points.map.with_index {|po, i| [po - start_po, po]}
      .reject {|pos| pos.first == 0}
      .sort_by {|pos| a = pos.first.angle + PI - prev_arg; a >= 0 ? a : a + 2 * PI}
      .first.last
    points.select! {|po| po != start_po}
    if selected == po0
      break points.size - 1
    else
      prev_arg = (selected - start_po).angle + PI
      start_po = selected
    end
  end
  
  puts result
end


Measured memory_bytes: 7004
import sys

N,K = list(map(lambda x: int(x), input().split()))
monsters=list(map(lambda x: int(x), input().split()))

# ソート
monsters.sort(reverse=True)

# これでもN > Kの時の場合分けいるか
if N <= K:
  print(0)
  sys.exit()

# Kの数だけ削除
monsters = monsters[K:N]

# 配列の合計値を出力
print(sum(monsters))

Measured memory_bytes: 26764
N,M = map(int,input().split())
AB = [tuple(map(int,input().split())) for _ in range(N-1+M)]

A = [[] for _ in range(N)]
P = [0]*N
C = [0]*N
root = -1

for (a,b) in AB:
    # a -> b
    A[a-1].append(b-1)
    C[b-1] += 1

for i in range(N):
    if C[i]==0:
        root = i
P[root] = -1

from collections import deque
que = deque((a,root) for a in A[root])
while que:
    n,par = que.popleft()
    C[n] -= 1
    if C[n]==0:
        P[n] = par
        for i in A[n]:
            que.append((i,n))

for p in P:
    print(p+1)



Measured memory_bytes: 36636
def f(mtrx):
	maxSum = -10000000
	for colStart in range(n):
		partSum = [0]*n
		for colEnd in range(colStart,n):
			for row in range(n):
				partSum[row] += mtrx[row][colEnd]
			calcSum = maxPart(partSum)
			maxSum = max(calcSum, maxSum)
	return maxSum

def maxPart(array):
	maxSum = -10000000
	calcSum = 0
	for i in range(n):
		calcSum += array[i]
		maxSum = max(calcSum,maxSum)
		if calcSum < 0:
			calcSum = 0
	return maxSum
	
n = int(raw_input())
mtrx = [map(int, raw_input().split()) for i in range(n)]
print f(mtrx)

Measured memory_bytes: 4572
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll n,k;
    cin >> n >> k;
    ll l[n],i;
    for(i=0;i<n;i++){
      cin >>l[i];
    }
    sort(l,l+n,greater<int>());
    ll ans=0;
    for(i=0;i<k;i++){
      ans+=l[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void DFS( 
  int p, int prevp,
  vector<vector<int>> &neighbors, 
  vector<int> &Point){
  for ( int n : neighbors.at(p-1) ){
    if ( n == prevp){ 
      continue;
    }
    Point.at(n-1) += Point.at(p-1);
    DFS( n, p, neighbors, Point );
  }
}

int main() {
  long long N, Q;
  cin >> N >> Q;

  vector<int> Point(N,0);
  vector<vector<int>> neighbors(N);

  for (int i = 1; i < N; i++) {
    int a, b;
    cin >> a >> b;
    // 隣接頂点を保持
    neighbors.at(a-1).push_back(b);
    neighbors.at(b-1).push_back(a);
  }

  for ( int i = 0; i < Q; i++ ){
    long long index, Number;
    cin >> index >> Number;
    Point.at(index - 1) += Number;
  } 

  // 探索する
  DFS( 1, 0, neighbors, Point);


  for ( int i = 0; i < N - 1; i++ ){
    cout << Point.at(i) << " ";
  }
  cout << Point.at(N-1) << endl;
}

Measured memory_bytes: 32896
/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

import java.util.*;
import java.lang.*;
import java.math.*;

public class Main{

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

        int a = sc.nextInt();
        int p = sc.nextInt();
        System.out.println((a * 3 + p)/2 );

        sc.close();
    }

    /**
     * Pair_int
     */
    public static class Pair {
        public int x;
        public int y;

        /**
         * Constructor 
         * Sample Code
         * 
         *      Pair[] pair = new Pair[5];
                for (int i = 0; i < 5; i++) {
                    pair[i] = new Pair(sc.nextInt(), sc.nextInt());
                }
                for (int i = 0; i < 5; i++) {
                    System.out.println(pair[i].x + " " + pair[i].y);
                }
         *
         */
        public Pair(int x, int y){
            this.x = x;
            this.y = y;
        }
        
        public String toString() {
            return "(" + x + ", " + y + ")";
        }

    }

}





Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int top, INT[1000];
void push(int x)
{
    top++;
    INT[top] = x;
}
int pop()
{
  // if(top > 0)
        top--;
    return INT[top+1];
}
int main()
{
    int a,b;
    char s[100];
    top = 0;
    while(scanf("%s", s)!= EOF)
    {
        if(s[0] == '+')
        {
            a = pop();
            b = pop();
            push(a+b);
        }
        else if(s[0]=='-')
        {
            b = pop();
            a = pop();
            push(a-b);
        }
        else if(s[0] == '*')
        {
            a = pop();
            b = pop();
            push(a*b);
        }
        else
            push(atoi(s));
    }
    printf("%d\n", pop());

    return 0;
}



Measured memory_bytes: 2104
import sys
from io import StringIO

def resolve():
    s=input().strip()
    k=int(input().strip())

    dp = [[[0 for a in range(2)] for b in range(5)]for c in range(105)]

    #0 same 1 under
    dp[0][0][0]=1

    keta=1
    for a in s:
        for b in range(4):
            for c in range(2): #0 same 1 under
                n=int(a)
                for d in range(10):
                    if c==0 and d > n:
                        #out
                        continue

                    b2 = b
                    if d != 0:
                        b2 += 1
                    
                    c2=c
                    if c==0 and n != d:
                        c2 = 1

                    dp[keta][b2][c2]+=dp[keta-1][b][c]
        keta+=1

    ans = dp[len(s)][k][0] + dp[len(s)][k][1]

    print(ans)

    return

resolve()

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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

vector<int> G[100005];
int d[2][100005];

void dfs(int v, int p, int c) {
	for(int x: G[v]) {
		if(x == p) continue;
		d[c][x] = d[c][v]+1;
		dfs(x,v,c);
	}
}

int main(){
	int n,s,t,a,b;

	scanf("%d%d%d", &n,&s,&t);

	for(int i = 1; i < n; i++) {
		scanf("%d%d", &a, &b);
		G[a].push_back(b);
		G[b].push_back(a);
	}

	dfs(s,s,0);
	dfs(t,t,1);

	int f = s;
	for(int i = 1; i <= n; i++) {
		if(d[1][i] > d[0][i] && d[1][i] > d[1][f]) f = i;
	}

	printf("%d\n", d[1][f]-1);

	return 0;
}

Measured memory_bytes: 12928
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//#define int long long  ←保留
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/*-------------ここまで---------------------------------------------*/

//C++(GCC9.2.1)

signed main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        int n = i + 1;
        if (n % 2 != 0) {
            if (s.at(i) == 'L') {
                cout << "No" << endl;
                return 0;
            }
        }
        else {
            if (s.at(i) == 'R') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3552
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

n = ini()
s = ins()
a = [0] * n
b = [0] * n
e = 0
w = 0
for i in range(n):
    a[-i-1] = e
    b[i] = w
    if s[i] == "W":
        w += 1
    if s[-i-1] == "E":
        e += 1
ans = 1e9 + 6
for i in range(n):
    ans = min(ans, a[i] + b[i])
print(ans)

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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 0, 1, -1, 1, -1, -1, 1};
int dx[]={1, -1, 0, 0, 1, 1, -1, -1};


int main() {
    cout<<fixed<<setprecision(10);
    ll n,x,t; cin>>n>>x>>t;

    cout<< (n/x + (ll)(n%x!=0))*t <<endl;

    return 0;

}

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

using namespace std;

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

    int flag=0;
    for(int i=0; i<n; i++)
    {
        if(a[i]%2==0)
        {
            if(a[i]%3==0 || a[i]%5==0)
                flag++;

        }
        else
            flag++;
    }
    if(flag==n)
        cout<<"APPROVED\n";
    else
        cout<<"DENIED\n";


    return 0;
}


Measured memory_bytes: 256
Sa = input().strip()
Sb = input().strip()
Sc = input().strip()
 
sa = list(Sa[::-1])
sb = list(Sb[::-1])
sc = list(Sc[::-1])
 
turn = 'a'
while True:
  if turn=='a' and len(sa)==0:
    print('A')
    break
  elif turn=='b' and len(sb)==0:
    print('B')
    break
  elif turn=='c' and len(sc)==0:
    print('C')
    break
 
  if turn=='a':
    turn = sa.pop()
  elif turn=='b':
    turn = sb.pop()
  elif turn=='c':
    turn = sc.pop()

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        String s = sc.next();
        char[] c = s.toCharArray();
        c[k - 1] += 32;
        System.out.println(new String(c));
        sc.close();
    }
}

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

int casenumber = 0;

const int dx[] = {-1, 0, 1};
const int dy[] = {-1, 0, 1};
const int dz[] = {-1, 0, 1};

bool inField(int x, int y, int z){
  return 0 <= x && 0 <= y && 0 <= z && x < 5 && y < 5 && z < 5;
}


int main(void){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  bool flg = false;
  while(cin >> N, N){
    if(flg) cout << '\n';
    flg = true;
    int M1, M2;
    set<int> m1, m2;
    //int g[5][5][5];
    vector< vector< vector<int> > > g(5, vector< vector<int> >(5, vector<int>(5)));
    for(int i=0; i < 5; i++){
      for(int j=0; j <5; j++){
        string str; cin >> str;
        for(int k=0; k < 5; k++){
          g[i][j][k] = str[k] - '0';
        }
      }
    }
    cin >> M1;
    for(int i=0; i < M1; i++){
      int tmp; cin >> tmp; m1.insert(tmp);
    }
    cin >> M2;
    for(int i=0; i < M2; i++){
      int tmp; cin >> tmp; m2.insert(tmp);
    }

    while(N--){
      vector< vector< vector<int> > > org = g;
      for(int i=0; i < 5; i++){
        for(int j=0; j < 5; j++){
          for(int k=0; k < 5; k++){

            int lvcnt = 0;
            for(int x=0; x < 3; x++){
              for(int y=0; y < 3; y++){
                for(int z=0; z < 3; z++){
                  if(x == 1 && y == 1 && z == 1) continue;
                  int nx = k + dx[x], ny = j + dy[y], nz = i + dz[z];
                  if(!inField(nx, ny, nz)) continue;
                  if(org[nz][ny][nx] == 1){
                    lvcnt++;
                  }
                }
              }
            }
            if(org[i][j][k] == 1){
              if(m2.find(lvcnt) == m2.end()) g[i][j][k] = 0;
            }else{
              if(m1.find(lvcnt) != m1.end()) g[i][j][k] = 1;
            }

          }
        }
      }
    }

    cout << "Case " << ++casenumber << ":" << '\n';
    for(int i=0; i < 5; i++){
      for(int j=0; j < 5; j++){
        for(int k=0; k < 5; k++){
          cout << g[i][j][k];
        }
        cout << '\n';
      }
      if(i < 4)
        cout << '\n';
    }
  }

  return 0;
}

Measured memory_bytes: 1244
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	ll A[200010] = {};
	ll goukei = 0;
	rep1(i, N) {
		cin >> A[i];
		goukei += A[i];
		A[i] *= 2;
		A[i] += A[i - 1];
	}

	ll saishou = 1e18;
	rep1(i, N - 1) {
		chmin(saishou, abs(A[i] - goukei));
	}
	co(saishou);


	Would you please return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
ll mod = 1e9 + 7;

using namespace std;



int main()

{
	int A,B,C;

	cin >> A >> B>>C;
	bool flg = false;

	if ((A <= C) && (C <= B))
	{
		flg = true;
	}
	
	
	if (flg)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No"<< endl;
	}
	

	return 0;
	
}

Measured memory_bytes: 256
def gcd(a,b)
    loop {
        if b == 0
            return a
        end
        a, b = b, a % b
    }
end

STDIN.each_line {|l| 
    a,b = l.split().map {|v| v.to_i }
    g = gcd(a,b)
    print "%d %d\n" % [g, (a * b)/g]
}

Measured memory_bytes: 8608
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define T() int t; cin>>t; while(t--)                      
#define pb push_back
#define endl "\n"

int main()
{	
	FIO;
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	ll x,y;
	cin>>x>>y;

	if(y%2 == 0 && y>=2*x && y<=4*x) cout<<"Yes\n";
	else cout<<"No\n";

	return 0;
	
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
int n, m;
bool ok(int i, int j) {
    return i >= 0 && i < n && j >= 0 && j < m;
}
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    string s;
    cin >> s;
    int sum = 0;
    forn(i, sz(s)) {
        sum += s[i] - '0';
    }
    if (stoi(s) % sum == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;



class BFS {
private:
    vvi table;
public:
    BFS(int SIZE) {
        table.resize(SIZE);
        for (auto& elem : table) {
            elem.resize(SIZE);
        }
        rep(i, SIZE)rep(j, SIZE) cin >> table[i][j];
    }

    int solve(int start) {
        vi Cost;
        Cost.resize(table.size(), pint_INF);
        Cost[start] = 0;
        queue<int> S;
        S.push(start);

        while (!S.empty()) {
            int u = S.front(); // pop条件で調節
            int v = next(Cost,u);

            if (v == -1) {
                S.pop();
                continue;
            }
            else {
                Cost[v] = Cost[u] + table[u][v];
                S.push(v);
            }

            
        }
        return Cost[1];
    }

    int next(vi& Cost, int u) {
        for (int v = 0; v < table.size(); v++) {
                if (Cost[u] + table[u][v] < Cost[v]) {
                    return v;
                }
        }
        return -1;
    }

};
int main() {
    int H, W; cin >> H >> W;
    vi numbers(10);
    vi minimalCost(10);
    BFS bfs(10);

    rep(n, H * W) {
        int x; cin >> x;
        if (x < 0) continue;
        else {
            numbers[x]++;
        }
    }

    for (int i = 0; i < 10; i++) {
        minimalCost[i] = bfs.solve(i);
    }

    

    ll ans = 0;
    rep(i, 10) {
        ans += numbers[i] * minimalCost[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cmath>
using namespace std;
//イントとダブルが入り乱れるときはどちらかに統一しよう。

int max(int x,int y){
  if(x>y) return x;
  return y;
}

int min(int x,int y){
  if(x<y) return x;
  return y;
}

int main() {
  int n,a,b,kakuketawa,p,q,r,s,t,res=0;
  cin >> n >> a >> b;
  for(int i=1;i<=n;i++){
    p=i/10000;
    q=(i-p*10000)/1000;
    r=(i-p*10000-q*1000)/100;
    s=(i-p*10000-q*1000-r*100)/10;
    t=i-p*10000-q*1000-r*100-10*s;
    kakuketawa=p+q+r+s+t;
  //  cout << kakuketawa << endl;
    if(kakuketawa>=a&&kakuketawa<=b)res+=i;
  }
    cout << res << endl;

}


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

int main(){
    string s;
    cin >> s;
    string copy(s);
    reverse(copy.begin(), copy.end());
    int cnt = 0;

    rep(i, s.size() / 2){
        if(s[i] != copy[i]) cnt++;
    }
    cout << cnt << endl;
}

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

int main(){
    long Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;
    cout << N / 2 * min({Q * 8, H * 4, S * 2, D}) + N % 2 * min({Q * 4, H * 2, S}) << endl;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  int l = 0, r = 1001001001;
  while (r - l > 1) {
    int c = (l + r) / 2;
    auto ok = [&] {
      long long cnt = 0;
      for (int i = 0; i < n; i++) cnt += a[i] / c;
      return cnt <= k;
    };
    (ok() ? r : l) = c;
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 4020
fn main() {
    let n = rv::<usize>()[0];
    let mut s = Vec::with_capacity(n);
    for _ in 0..n {
        s.push(rl().trim_right().bytes().collect::<Vec<u8>>());
    }
    let mut t=0;
    for k in 0..n {
        let mut f=true;
        'outer: for i in 0..n {
            for j in i+1..n {
                if s[i][(j+k)%n]!=s[j][(i+k)%n] {
                    f=false;
                    break 'outer;
                }
            }
        }
        if f {
            t+=n;
        }
    }
    println!("{}",t);
}
fn rl() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s
}
fn rv<T>() -> Vec<T> where T: std::str::FromStr, T::Err: std::fmt::Debug, {
    rl().split_whitespace().map(|x|x.parse::<T>().unwrap()).collect()
}

Measured memory_bytes: 4352
l=list(map(int,input().split()))
 
if l[0]+l[1]>=l[0]-l[1] and l[0]+l[1]>=l[0]*l[1]:
    print(l[0]+l[1])
elif l[0]-l[1]>=l[0]+l[1] and l[0]-l[1]>=l[0]*l[1]:
    print(l[0]-l[1])
elif l[0]*l[1]>=l[0]-l[1] and l[0]*l[1]>=l[0]+l[1]:
    print(l[0]*l[1])

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#include<stack>
#include<iomanip>
#define rep(i,n) for(int i=0;i<((int)n);i++)
#define Rep(i,n0,n) for(int i=n0;i<((int)n);i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<((int)n);j++)
#define W(x) cout<<x<<endl;
#define Debug(x) cout<<"#DEBUG "<<x<<endl;
#define INF (1<<29)
#define INF2 (long long)8*(long long)INF*(long long)INF
#define mod 1000000007
typedef long long ll;

using namespace std;


int min(int x,int y){if(y<x)return y;else return x;}
int max(int x,int y){if(y>x)return y;else return x;}
int fact(int x){int i=1;rep(j,x){i*=(j+1);} return i;}
long long fact(long long x){long long i=1;rep(j,x){i*=(j+1);} return i;}
int gcd(int x, int y)
{
    if(x%y==0)return y;
    else if(y%x==0)return x;
    else return gcd(x%y,y%x);
}
ll gcd(ll x, ll y)
{
    if(x%y==0)return y;
    else if(y%x==0)return x;
    else return gcd(x%y,y%x);
}

bool solve(ll a,ll b,ll c,ll d)
{
    ll g=gcd(b,d);
    if(a>=b&&d>=b)
    {
        if(a>=c)
        {
            if(((a-c-1)%g+c+1>=b))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        else
        {
            return true;
        }
    }
    else
    {
        return false;
    }
}

int main()
{
    int t;
    cin>>t;
    ll a[t],b[t],c[t],d[t];
    rep(i,t)
    {
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    rep(i,t)
    {
        if(solve(a[i],b[i],c[i],d[i])){W("Yes")}
        else {W("No")}
    }
    return 0;
}

Measured memory_bytes: 256
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::*;
use num::BigInt;

fn gcd(a: &BigInt, b: &BigInt) -> BigInt {
    let r = a % b;
    if r == BigInt::from(0) {
        b.clone()
    } else {
        gcd(b, &r)
    }
}

fn main() {
    input! {
        a: [BigInt]
    }

    let lcm = a.iter().cloned().fold1(|a, b| &a * &b / gcd(&a, &b)).unwrap();
    let sum: BigInt = a.iter().map(|x| &lcm / x).sum();
    let ans = sum % 1000000007;
    println!("{}", ans);
}


Measured memory_bytes: 3712
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AServalVsMonster solver = new AServalVsMonster();
        solver.solve(1, in, out);
        out.close();
    }

    static class AServalVsMonster {
        PrintWriter out;
        InputReader in;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;
            int h = ni();
            int a = ni();
            int ans = (h + a - 1) / a;
            pn(ans);

        }

        int ni() {
            return in.nextInt();
        }

        void pn(long zx) {
            out.println(zx);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <bitset>
#include <set>
#include <list>
#include <deque>
#include <map>
#include <queue>
#define mod 998244353
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
using namespace std;
typedef long long ll;
const double PI=3.14159265358979;
const double eps=1e-15;
const ll INF=2000000000000000000;
const int maxn=10000010;
const int maxm=20;

int n,k,x,ans;

int main(){  
    while(~scanf("%d%d", &n, &k)){
        ans=0;
        for(int i=1;i<=n;++i){
            scanf("%d", &x);
            ans+=min(x,k-x);
        }
        printf("%d\n", ans*2);
    }
    return 0;  
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int const INF = 1001001001;


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

string A,B;
cin >> A >> B;

int a = A.size();
int b = B.size();

if(a > b) puts("GREATER");
else if(a < b) puts("LESS");
else {
    if(A > B) puts("GREATER");
    else if(A < B) puts("LESS");
    else puts("EQUAL");
}




return 0;
}

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

int main(){
  string colorNum = "Three";
  int N = 0;
  cin >> N;
  
  vector<char> S(N);
  for(int i = 0; i < N; i++){
    cin >> S.at(i);
  }
  
  for(int i = 0; i < N; i++){
    switch(S.at(i)){
      case 'P' : continue;
      case 'W' : continue;
      case 'G' : continue;
      case 'Y' : colorNum = "Four"; break;
    }
  }
    cout << colorNum << endl; 
}

Measured memory_bytes: 3580
n = int(input())
l = []
for i in range(n):
  l.append(''.join(sorted(input())))
l.sort()

cnt = 0
ans = 0
for i in range(n-1):
  if l[i+1] == l[i]:
    cnt += 1
    ans += cnt
  else:
    cnt = 0
print(ans)

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

inline int rd() {
  int x; scanf("%d", &x);
  return x;
}

const int N = 5050, P = 1e9 + 7;

int n, size[N];
long long way[N];
long long f[N][N], g[N];
std::vector<int> G[N];

void dfs(int x, int fa) {
  size[x] = 1;
  f[x][1] = 1;
  for (int y : G[x]) if (y != fa) {
    dfs(y, x);
    for (int i = 1; i <= size[x]; ++i)
      for (int j = 1; j <= size[y]; ++j)
        g[i + j] = (g[i + j] + f[x][i] * f[y][j]) % P;
    for (int i = 1; i <= size[x]; ++i)
      for (int j = 2; j <= size[y]; j += 2)
        g[i] = (g[i] + P - f[x][i] * f[y][j] % P * way[j] % P) % P;
    size[x] += size[y];
    for (int i = 1; i <= size[x]; ++i)
      f[x][i] = g[i], g[i] = 0;
  }
}

int main() {
  n = rd();
  way[2] = 1;
  for (int i = 4; i <= n; i += 2)
    way[i] = way[i - 2] * (i - 1) % P;
  for (int i = 1; i < n; ++i) {
    int x = rd(), y = rd();
    G[x].push_back(y);
    G[y].push_back(x);
  }
  dfs(1, 0);
  long long ans = 0;
  for (int i = 2; i <= n; i += 2)
    ans = (ans + f[1][i] * way[i]) % P;
  ans = (ans % P + P) % P;
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 198784
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int N, Q;
  cin >> N >> Q;
  vector<vector<int>> G(N);
  FOR(i, N - 1) {
    int a, b;
    cin >> a >> b;
    G[a - 1].push_back(b - 1);
    G[b - 1].push_back(a - 1);
  }
  vector<int> ct(N);
  FOR(i, Q) {
    int p, x;
    cin >> p >> x;
    ct[p - 1] += x;
  }
  queue<int> q;
  q.push(0);
  vector<bool> used(N, 0);
  vector<int> ans(N, 0);
  used[0] = 1;
  ans[0] = ct[0];
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int x : G[v]) {
      if (!used[x]) {
        q.push(x);
        used[x] = 1;
        ans[x] = ans[v] + ct[x];
      }
    }
  }
  FOR(i, N) { cout << ans[i] << " "; }
  cout << endl;
  return 0;
}
#include <algorithm>


Measured memory_bytes: 16372
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=1e3+1,oo=0x3f3f3f3f,MOD=1e9+7;
const double PI = acos(-1);

void solve(){
    string s,t;
    cin>>s>>t;
    int res=1e9;
    loop(sz(s)-sz(t)+1,i,0){
        int cnt=0;
        loop(sz(t),j,0){
            if(s[i+j]!=t[j])
                cnt++;
        }
        min_self(res,cnt);
    }
    cout<<res<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}


Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.TreeMap;



public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int s = sc.nextInt()-1;
		int t = sc.nextInt()-1;

		ArrayList<Node> graph = new ArrayList<Node>();

		for (int i=0;i<n;i++) {
			graph.add(new Node());
			graph.get(i).id=i;
		}

		for (int i=0;i<m;i++) {
			int u = sc.nextInt()-1;
			int v = sc.nextInt()-1;
			int a = sc.nextInt();
			int b = sc.nextInt();
			Edge e = new Edge();
			e.from=u;
			e.to=v;
			e.yen=a;
			e.snuke=b;
			Edge f = new Edge();
			f.from=v;
			f.to=u;
			f.yen=a;
			f.snuke=b;

			graph.get(u).edges.add(e);
			graph.get(v).edges.add(f);
		}


		TreeMap<Long,Node> map = new TreeMap<Long, Node>();
		for(int i=0;i<n;i++) {
			if (i != s) {
				graph.get(i).yen=(long)Math.pow(10, 14);

			} else {
				graph.get(i).yen=0;
			}
			map.put(graph.get(i).yen*n-Long.MAX_VALUE+i, graph.get(i));
		}


		while (!map.isEmpty()) {
			Node node = map.firstEntry().getValue();
			map.remove(map.firstEntry().getKey(), node);
			for (Edge e:node.edges) {
				Node toNode = graph.get(e.to);
				if (toNode.yen > node.yen+e.yen && map.containsKey(toNode.yen*n-Long.MAX_VALUE+toNode.id)) {
					map.remove(toNode.yen*n-Long.MAX_VALUE+toNode.id, toNode);
					toNode.yen = node.yen+e.yen;
					map.put(toNode.yen*n-Long.MAX_VALUE+toNode.id, toNode);
				}
			}
		}


		map = new TreeMap<Long, Node>();
		for(int i=0;i<n;i++) {
			if (i != t) {
				graph.get(i).snuke=(long)Math.pow(10, 14);

			} else {
				graph.get(i).snuke=0;
			}
			map.put(graph.get(i).snuke*n-Long.MAX_VALUE+i, graph.get(i));
		}

		while (!map.isEmpty()) {
			Node node = map.firstEntry().getValue();
			map.remove(map.firstEntry().getKey(), node);
			for (Edge e:node.edges) {
				Node toNode = graph.get(e.to);
				if (toNode.snuke > node.snuke+e.snuke && map.containsKey(toNode.snuke*n-Long.MAX_VALUE+toNode.id)) {
					map.remove(toNode.snuke*n-Long.MAX_VALUE+toNode.id, toNode);
					toNode.snuke = node.snuke+e.snuke;
					map.put(toNode.snuke*n-Long.MAX_VALUE+toNode.id, toNode);
				}
			}
		}

		long min = Long.MAX_VALUE;
		long[] ans = new long[n];
		for (int i=n-1;i>=0;i--) {
			min = Math.min(graph.get(i).yen+graph.get(i).snuke, min);
			ans[i] = min;
		}
		for (int i=0;i<n;i++) {
			System.out.println((long)Math.pow(10, 15)-ans[i]);
		}

	}



}


class Edge {
	int from;
	int to;
	long yen;
	long snuke;
}

class Node {
	int id;
	List<Edge> edges=new ArrayList<Edge>();
	long yen;
	long snuke;
}

Measured memory_bytes: 189020
import itertools
import math
import fractions
import functools


l = [list(map(int, input().split())),list(map(int, input().split())),list(map(int, input().split()))]
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))

ij = []
for i in range(n):
    for j in range(3):
        for k in range(3):
            if b[i] == l[j][k]:
                ij.append([j,k])

for i in range(3):
    count = 0
    for j in range(3):
        for k in range(len(ij)):
            if ij[k] == [i,j]:
                count += 1
        if count >= 3:
            print("Yes")
            quit()

for i in range(3):
    count = 0
    for j in range(3):
        for k in range(len(ij)):
            if ij[k] == [j,i]:
                count += 1
        if count >= 3:
            print("Yes")
            quit()

count = 0
for i in range(3):
    for j in range(len(ij)):
        if ij[j] == [i,i]:
            count += 1
    if count >= 3:
        print("Yes")
        quit()

count = 0
for i in range(len(ij)):
    if ij[i] == [0,2] or ij[i] == [1,1] or ij[i] == [2,0]:
        count += 1
if count >= 3:
    print("Yes")
    quit()

print("No")

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

int main() {
	string S;
	cin >> S;

	int N = S.size();
	int even0odd1 = 0, odd0even1 = 0;

	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			if (S.at(i) == '0')	even0odd1++;
			else                odd0even1++;
		}
		else {
			if (S.at(i) == '1')	even0odd1++;
			else                odd0even1++;
		}
	}

	cout << min(even0odd1, odd0even1) << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <numeric>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline bool Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+" ";
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e17;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
ll m;
void matmul(vector<vector<ll>> &mt1,vector<vector<ll>> &mt2){
    vector<vector<ll>> ret(m,vector<ll>(m,0));
    rep(i,m) rep(j,m) rep(k,m){
        ret[i][j] += mt1[i][k]*mt2[k][j]%MOD;
        ret[i][j] %= MOD;
    }
    rep(i,m) rep(j,m) mt1[i][j] = ret[i][j];
}
vector<vector<ll>> update(vector<vector<ll>> &mt){
    vector<vector<ll>> ret(m,vector<ll>(m,0));
    rep(i,m) rep(j,m) rep(k,m){
        ret[i][j] += mt[i][k]*mt[k][j]%MOD;
        ret[i][j] %= MOD;
    }
    return ret;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    m = n;
    vector<vector<ll>> mt(n,vector<ll>(n)),ans(n,vector<ll>(n,0));
    rep(i,n) rep(j,n){
        cin >> mt[i][j];
        if (i == j) ans[i][j] = 1;
    }
    while(k){
        if (k&1) matmul(ans,mt);
        mt = update(mt);
        k /= 2;
    }
    ll a = 0;
    rep(i,n){
        rep(j,n){
            a += ans[i][j];
            a %= MOD;
        }
    }
    PRINT(a);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	string N;
	cin >> N;

	if (N[0] == '9' || N[1] == '9')
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
/*input
4
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main()
{
	IOS;
	int n;
	cin>>n;
	if(n%2){
		cout<<n*(n-1)/2-n/2<<'\n';
		for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++){
			if(i+j==n) continue;
			cout<<i<<' '<<j<<'\n';			
		}
	}
	else{
		cout<<n*(n-1)/2-n/2<<'\n';
		for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++){
			if(i+j==n+1) continue;
			cout<<i<<' '<<j<<'\n';			
		}
	}
	return 0;
}


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

#define ll long long
#define pb push_back
#define pii pair<int, int>
#define sz size()

int main()
{
	ios::sync_with_stdio(0);
	int i, j, k, n;

	ll a, b_dash;
	long double b;
	cin >> a >> b;
	b_dash = llround(b * 100.0);

	cout << ((a * b_dash) / 100) << "\n";

	return 0;
}

Measured memory_bytes: 3812
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    vector<int> b(n, 0);
    rep(i, n)
    {
        int a;
        cin >> a;
        b[a - 1]++;
    }
    sort(b.begin(), b.end());

    int result = 0;
    rep(i, n - k)
    {
        result += b[i];
    }
    cout << result << endl;

    return 0;
}

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


using namespace std;

int main() {
    int sum, n, t;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &t);
        sum += t;
    }
    printf("%d", sum - n);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	char c;
	cin >> c;
	if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
	{
		cout << "vowel";
	}
	else
	{
		cout << "consonant";
	}
	return 0;
}

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

map<char, long long> counter(string word){
    map<char, long long> frequency;
    for (int i=0;i<word.size();i++){
        frequency[word[i]] += 1;
    }
    return frequency;
}

map<map<char, long long>, long long> map_counter(vector<map<char, long long>> m){
    map<map<char, long long>, long long> frequency;
    for (auto &item : m){
        frequency[item] += 1;
    }

    return frequency;
}
int main(){
    long long n; cin >> n;
    vector<string> words(n); for (long long i=0;i<n;i++){cin >> words[i];}
    
    vector<map<char, long long>> frequency_counter(n);
    transform(words.begin(), words.end(), frequency_counter.begin(), counter);

    auto f = map_counter(frequency_counter);
    long long acc = 0;
    for (auto &i : f){
        if (i.second == 1){
            continue;
        } else {
            acc += (1 + i.second - 1) * (i.second - 1) / 2;
        }
    }
    cout << acc << endl;
    return 0;
}


Measured memory_bytes: 184192