akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<math.h>
#include<queue>
#include<stdio.h>
#include<stdlib.h>
#include<stack>
#include<string>
#include<vector>

#define ll long long
#define ull unsigned long long

using namespace std;
int main(void) {

	char str[101] = "\0";
	char c = '\0';
	ll i = 0;

	while ((c = getchar()) != '\n') {
		str[i] = c;
		i += 2;
	}

	i = 1;
	while ((c = getchar()) != '\n') {
		str[i] = c;
		i += 2;
	}

	printf("%s", str);

	return 0;
}

Measured memory_bytes: 256
H,W,K = list(map(int,input().split()))
cells = [input() for i in range(H)]
ans = 0
for i in range(2**H):
    for j in range(2**W):
        cnt = 0
        for a in range(H):
            for b in range(W):
                if i>>a & 1 or j>>b & 1: #塗る
                    continue
                else:
                    if cells[a][b] == "#":
                        cnt += 1
        if cnt == K:
            ans += 1

print(ans)

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

int main() {
	int n, a[10];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] %= 2;
	}
	int x = 1, y = 1;
	for (int i = 0; i < n; i++) {
		x *= 3;
		if (!a[i]) {
			y *= 2;
		}
	}
	cout << x - y << endl;
	return 0;
}


Measured memory_bytes: 256
// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii         pair<int,int>
#define psi         pair<string,int>
#define vi          vector<int>
#define vpii        vector<pii>
#define vvi         vector<vi>
#define sz(x)       (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n)     fixed<<setprecision(n)
#define ini(a, i)   memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "Yes" : "No")<<endl;
using namespace std;
 
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------

signed main() {
    tezz
 

    int n, p, q;
    cin >> n;
    int c=0;
    for(int i=0; i<n; i++){
        cin >> p >> q;
        if(p==q)c++;
        else{
            c=0;
        }
        if(c>=3){
            output(1);
            return 0;
        }
    }
    output(0);
 
    return 0;
}  

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array);


int main(){

	IOS
	string s;
	cin>>s;
	if(s=="ARC"){
		cout<<"ABC"<<endl;

	}
	else cout<<"ARC"<<endl;

	
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
        ifstream in("input.txt");
        //ofstream out("output.txt");
        #define cin in
        //#define cout out
#endif
int const MAXN=110000, M=1000000007;
long long int bianco[MAXN], nero[MAXN], n;
vector<int> g[MAXN], t[MAXN];
void make_tree(int node=1, int parent=-1){
	for(auto x:g[node])
		if(x!=parent){
			t[node].push_back(x);
			make_tree(x,node);
		}
}
void dp(int node=1){
	if(t[node].empty()){
		bianco[node]=1LL;
		nero[node]=1LL;
	}
	else{
		for(auto x:t[node])
			dp(x);
		nero[node]=1LL;
		for(auto x:t[node]){
			nero[node]*=bianco[x];
			nero[node]%=M;
		}
		bianco[node]=1LL;
		for(auto x:t[node]){
			bianco[node]*=nero[x]+bianco[x];
			bianco[node]%=M;
		}
	}
}
int main(){
	cin>>n;
	for(int i=0;i<n-1;i++){
		int from, to;
		cin>>from>>to;
		g[from].push_back(to);
		g[to].push_back(from);
	}
	make_tree();
	dp();
	cout<<(nero[1]+bianco[1])%M;
}

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

int SomarDigitos(int);

int main(void)
{
	int n;
	int min = 999999;
	int aux;

	scanf("%d", &n);

	aux = 1;
	while (aux <= n / 2) {
		min = (int)fmin(min, SomarDigitos(n - aux) + SomarDigitos(aux));
		aux++;
	}

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

	return 0;
}

int SomarDigitos(int N){
    // DECLARAÇÕES
    int soma = 0;
    int aux;

    // INSTRUÇÕES
    aux = N;

    while (aux > 0){
        soma += aux%10;
        aux = aux/10;
    }

    return soma;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));
#define FIND(v,i) find(v.begin(),v.end(),i);

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	ll a,b,c;
    cin >> a >> b >> c;
  int ans=0;
  if(a==0) ans=1;
    cout << (b/c)-max(0,int((a-1)/c))+ans << endl;
/////////////////////////////////////////////
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define plll pair<pll,ll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;


int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll n,m;
    cin>>n>>m;
    pll p1[m];
    ll minval=NEGINF;
    ll maxval=INF;
    for(ll i=0;i<m;i++)
    {
        cin>>p1[i].first>>p1[i].second;
        minval=max(minval,p1[i].first);
        maxval=min(maxval,p1[i].second);
    }
    ll ans=maxval-minval+1;
    ans=max(ans,0LL);
    cout<<ans;
    return 0;
}

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

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;

    vector<int>x(101,0);
    rep(i,a,b){
        x[i]++;
    }
    rep(i,c,d){
        x[i]++;
    }

    int answer=0;
    rep(i,0,101){
        if(x[i]==2){
            answer++;
        }
    }
    cout<<answer<<endl;
}


Measured memory_bytes: 256
def main():
    import sys
    import numpy as np
    sys.setrecursionlimit(10**6)

    def input(): return sys.stdin.readline().rstrip()
        
    def dfs(upper, lower, left, right, cnt):
        
        if cnt == 1:
            ans[upper:lower, left:right] = np.max(ans[upper:lower, left:right])
            return

        elif cnt != max(cntrow[upper:lower]):
            for i in range(upper, lower):
                if cntrow[i]:
                    ncnt = sum(cntrow[upper:i+1])
                    dfs(upper, i+1, left, right, ncnt)
                    dfs(i+1, lower, left, right, cnt-ncnt)
                    break
            
        else:
            idx = cntrow[upper:lower].index(cnt)+upper
            for j in range(left, right):
                if g[idx][j] == '#':
                    dfs(upper, lower, left, j+1, 1)
                    cntrow[idx] -=1
                    dfs(upper, lower, j+1, right, cnt-1)
                    break

      
    h, w, k = map(int, input().split())
    g = ['']*h
    ans = np.zeros(shape=(h, w), dtype=int)
    cnt = 1
    cntrow = [0]*h
    for i in range(h):
        g[i] = input()
        for j in range(w):
            if g[i][j] == '#':
                ans[i, j] = cnt
                cntrow[i] += 1
                cnt += 1
    dfs(0, h, 0, w, k)
    for i in range(h):
        print(*ans[i])

        
        
if __name__ == '__main__':
    main()

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int r;
  cin >> r;
  printf("%.15f\n", r * 2 * M_PI);
  return 0;
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;

void dfs(int v, int p, int d, vector<ll> &dep, vector<vector<int>> &g) {
    dep[v] = d;
    for (int nv: g[v]) {
        if (nv == p) continue;
        dfs(nv, v, d + 1, dep, g);
    }
}

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

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

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

    vector<vector<int>> g(n);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }


    ll cmi = INF, lmi = INF;
    rep(i, n) {
        vector<ll> d(n, INF);
        dfs(i, -1, 0, d, g);
        ll ma = 0;
        rep(j, n) {
            chmax(ma, d[j]);
        }
        ll cm = cmi;
        if (chmin(cmi, ma + 1)) {
            vector<ll> cnt(cmi + 1, 0);
            cnt[0] = (int) g[i].size();
            rep(j, n) {
                if (j == i) continue;
                chmax(cnt[d[j]], (ll) g[j].size() - 1);
            }
            ll res = 1;
            for (int j = 0; j < ma; ++j) {
                res *= cnt[j];
            }
            if (cm == ma + 1) chmin(lmi, res);
            else lmi = res;
        }
    }


    rep(i, n) {
        for (int j: g[i]) {
            vector<ll> d(n, INF);
            dfs(i, j, 0, d, g);
            dfs(j, i, 0, d, g);
            ll ma = 0;
            rep(k, n) {
                chmax(ma, d[k]);
            }
            int cm = cmi;
            if (chmin(cmi, ma + 1)) {
                vector<ll> cnt(cmi + 1, 0);
                cnt[0] = max((int) g[i].size() - 1, (int) g[j].size() - 1);
                rep(k, n) {
                    if (k == i || k == j) continue;
                    chmax(cnt[d[k]], (ll) g[k].size() - 1);
                }
                ll res = 2;
                for (int k = 0; k < ma; ++k) {
                    res *= cnt[k];
                }
                if (cm == ma + 1) chmin(lmi, res);
                else lmi = res;
            }
        }
    }

    cout << cmi << " " << lmi << endl;

}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
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; }
const ll MOD = 1e9+7;

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

    map<int, int> will;
    map<int, int> get;
    map<int, int> left[10];
    map<int, int> right[10];
    set<pair<int, int> > have[10];
    REP(i,N){
        int t = S[i] - '0';
        will[t]++;
    }

    REP(i,N){
        int t = S[i] - '0';
        will[t]--;
        REP(l,10){
            if(get[l] == 0) continue;
            REP(r,10){
                if(will[r] == 0) continue;
                have[t].insert(make_pair(l, r));
            }
        }
        get[t]++;
    }

    ll ans = 0;
    REP(i,10){
        ans += have[i].size();
    }

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


Measured memory_bytes: 384
N,W=map(int,input().split())

DP=[[0 for i in range(W+1)]for j in range(N+1)]#容量W横軸、品物の数N縦軸
v=[0]*(N+1)
w=[0]*(N+1)

for i in range (1,N+1):
    v[i],w[i]=map(int,input().split())
    
for i in range(1,N+1):
    for j in range(1,W+1):
        c=W #cは袋の容量、iは品物の番号
        if j-w[i]<0:
            DP[i][j]=DP[i-1][j]
        else:
            if v[i]+DP[i-1][j-w[i]]>DP[i-1][j]:
                DP[i][j]=v[i]+DP[i-1][j-w[i]]
            else:
                DP[i][j]=DP[i-1][j]

print(DP[N][W])


Measured memory_bytes: 25940
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[110];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	std::sort(p,p+a);
	int ret=0;
	for(int i=0;i<b;i++)ret+=p[a-1-i];
		printf("%d\n",ret);
}


Measured memory_bytes: 128
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

class Node:
    def __init__(self,value,index=0):
        self.value = value
        self.index = index

    def __str__(self):
        return 'val : ' + str(self.value) + ' index : ' + str(self.index)

# 0-indexed SegmentTree
class SegmentTree:
    def __init__(self,N,default_list,default_value=INF):
        self.N0 = pow(2,(N-1).bit_length())
        self.nodes = [Node(default_value,i+1-self.N0) for i in range(2*self.N0-1)]
        for i in reversed(range(2*self.N0-1)):
            ind = i+1-self.N0
            if ind >= N:
                self.nodes[i].value = default_value
            elif N > ind >= 0:
                self.nodes[i].value = default_list[ind]
            else:
                self.nodes[i] = self.process(self.nodes[i*2+1],self.nodes[i*2+2])

    def __getitem__(self,key): # getiten : ST[i]
        return self.nodes[key+self.N0-1].value

    def __setitem__(self,i,x): # update : ST[i] = x
        i += self.N0 - 1
        self.nodes[i].value = x
        while i > 0:
            i = (i-1)//2
            self.nodes[i] = self.process(self.nodes[i*2+1],self.nodes[i*2+2])

    def __str__(self):
        return '['+', '.join(map(str,[self.nodes[i+self.N0-1].value for i in range(self.N0)]))+']'

    def query(self,L,R): #[L,R)の値
        retnode = Node(0,0)
        L += self.N0
        R += self.N0
        while L < R:
            if R&1 :
                R -= 1
                retnode = self.process(retnode,self.nodes[R-1])
            if L&1 :
                retnode = self.process(retnode,self.nodes[L-1])
                L += 1
            L >>= 1; R >>= 1
        return retnode

    def process(self,node_x,node_y): #x,yが子の時，親に返る値
        return Node(node_x.value|node_y.value)

N = inp()
S = list(input())

a = ord("a")
slist = []
for s in S:
    slist.append(1<<(ord(s)-a))


ST = SegmentTree(N, default_list=slist, default_value=0)

Q = inp()
ans = []
for _ in range(Q):
    a,b,c = input().split()
    if a == "2":
        ret = ST.query(int(b)-1,int(c))
        ans.append(str(bin(ret.value)).count("1"))
    else:
        tmp = 1<<(ord(c)-ord("a"))
        ST[int(b)-1] = tmp


print("\n".join(map(str,ans)))


Measured memory_bytes: 205232
n = int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

ans = factorization(n)
val = 0
for arr in ans:
    tmp = arr[1]
    for i in range(1,50):
        tmp = tmp -(i)
        if tmp < 0:
            val +=i - 1
            break
if n == 1:
    print(0)
else:
    print(val)

Measured memory_bytes: 9492
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    int sum = H * W;
    sum -= h * W;
    sum -= (H-h)*w;
    cout << sum;
}


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

int H , W;
vector<string> fields ;
int continuousBlack[101][101]; //最大100なので
char black='#';
char white='.';
//今いる座標、手前が黒か白か、これまで連続する数
void createRoute(){
  int fromLeftCost,fromUpCost;
  for(int x=0;x < W;x++){ //全座標ループ
    for(int y=0;y < H;y++){
      if (x==0){ //上からのルートのみ
        fromLeftCost=999; //左からのコストを巨大にしてしまう
      } else {
        if(fields[y][x-1]==white && fields[y][x]==black){ //白から黒に変わった？
          fromLeftCost=continuousBlack[y][x-1]+1;
        } else {
          fromLeftCost=continuousBlack[y][x-1];
        }
      }
      if (y==0){ //左からのルートのみ
        fromUpCost=999; //上からのコストを巨大にしてしまう
      } else {
        if(fields[y-1][x]==white && fields[y][x]==black){ //白から黒に変わった？
          fromUpCost=continuousBlack[y-1][x]+1;
        } else {
          fromUpCost=continuousBlack[y-1][x];
        }
      }
      //上下どっちからくるとコストが安い？
      //最初の座標だけ
      if (x==0 && y==0){
        if (fields[0][0]==black){
          continuousBlack[0][0]=1;
        }else{
          continuousBlack[0][0]=0;
        }
      } else {
        continuousBlack[y][x]=min(fromLeftCost,fromUpCost);
      }
    }
  }
}


int main () {
  cin >> H >> W;
  string s;
  //Ｈが縦、Ｗが横
  for (int y=0;y < H;y++){
    cin >> s;
    fields.push_back(s);
  }
  //0で初期化されているはず
  //memset(continuousBlack,-1,sizeof(continuousBlack);

  createRoute();
  cout << continuousBlack[H-1][W-1]; //ゴールの数値
  return 0 ;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		int[] C = new int[N-1];
		for(int i=0;i<N;i++){
			A[i] = sc.nextInt();
		}
		for(int i=0;i<N;i++){
			B[i] = sc.nextInt();
		}
		for(int i=0;i<N-1;i++){
			C[i] = sc.nextInt();
		}
		int score = 0;
		int before = -1;
		for(int i=0;i<N;i++){
			score += B[A[i]-1];
			if(before+1 == A[i]){
				score += C[before-1];
			}
			before = A[i];

		}
		System.out.println(score);
	}
}

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

#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define pll     pair<long long, long long>
#define ll      long long

int main() {
        int a, b;
        cin >> a >> b;
        cout << a * a - b << endl;
        return 0;
}



Measured memory_bytes: 256
// 重複を許す組合せを深さ優先探索で全探索して，
// 条件に合致する組合せを数えてる
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> graph) {
    if (graph.size() == n + 1) { // n + 1 の深さまで来たら計算して return する
        int sum = 0;
        REP(i, q)
            if (graph[b[i]] - graph[a[i]] == c[i])
                sum += d[i];
        ans = max(ans, sum);
        return ;
    }
    graph.push_back(graph.back()); // 重複を許すので最後と同じものから探索を行う
    while (graph.back() <= m) { // ツリーの横の個数の上限を設定してる
        dfs(graph);
        graph.back()++; // ツリーの横の値を1つずつ増やして探索してる
    }
}

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

    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    REP(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];

    dfs(vector<int>(1, 1));

    cout << ans << '\n';
    return 0;
}


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

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	ll y = ty - sy;
	ll x = tx - sx;
	for (int i = 0; i < y; i++)cout << "U";
	for (int i = 0; i < x; i++)cout << "R";
	for (int i = 0; i < y; i++)cout << "D";
	for (int i = 0; i <= x; i++)cout << "L";
	for (int i = 0; i <= y; i++)cout << "U";
	for (int i = 0; i <= x; i++)cout << "R";
	cout << "D";
	cout << "R";
	for (int i = 0; i <= y; i++)cout << "D";
	for (int i = 0; i <= x; i++)cout << "L";
	cout << "U" << endl;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
  return x;
}

Node treeSearch(Node u, int k){
  
  if(u == NIL || k == u->key) return u;
  if(k < u->key) return treeSearch(u->left, k);
  else return treeSearch(u->right, k);
}

Node treeSuccessor(Node x){
  Node y;
  
  if(x->right != NIL) return treeMinimum(x->right);

  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL) x = y->left;
  else x = y->right;

  if(x != NIL) x->parent = y->parent;

  if(y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;

  if(y != z) z->key = y->key;

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if(u != NIL){
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
  }
}
void preorder(Node u){
  printf(" %d", u->key);
  if(u->left!=NIL) preorder(u->left);
  if(u->right!=NIL) preorder(u->right);
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

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

std::vector<bool> Sieve(int n) {
  std::vector<bool> v(n + 1, true);
  v[0] = v[1] = false;
  for (int i = 2; i * i <= n; ++i) {
    if (!v[i]) {
      continue;
    }
    for (int j = i * 2; j <= n; j += i) {
      v[j] = false;
    }
  }
  return v;
}

std::vector<int> Primes(int n) {
  std::vector<bool> sieve = Sieve(n);
  std::vector<int> v;
  for (int i = 2; i <= n; ++i) {
    if (sieve[i]) {
      v.push_back(i);
    }
  }
  return v;
}

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  vector<int> ps = Primes(200000);
  in(int, x);
  for (int p : ps) if (p >= x) {
    out(p);
    return 0;
  }
}


Measured memory_bytes: 512
#include <cstdio>

using namespace std;
int N, D;
int P[1000];
int main(){
	scanf("%d %d", &N, &D);
	int ans = 0;
	for(int i = 0; i < N; i++){
		scanf("%d", &P[i]);
		if(P[i] > D){
			ans += P[i] - D;
		}
	}
	if(ans > 0){
		printf("%d\n", ans);
	}else{
		printf("kusoge\n");
	}

}
	

Measured memory_bytes: 1028
import math
a, b, h, m = map(int, input().split())

hpm = 0.5
mpm = 6

dif = abs(mpm * m - hpm * h * 60 - hpm * m)
if dif == 360.0:
    dif = 0.0
nagasa_beki = a ** 2 + b ** 2 - (2 * a * b * math.cos(math.radians(dif)))
kyori = math.sqrt(nagasa_beki)

print(kyori)


Measured memory_bytes: 9504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+1;int n,a[N],cnt,x;
int  main(){

	cin>>n;
	for(int i=1,x;i<=n;i++){
		cin>>x;
		cnt+=a[x];
		a[x]=1;
	}
	printf("%d\n",n-(cnt+1)/2*2);
return 0;
}


Measured memory_bytes: 640
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define a first
#define b second
#define all(x) x.begin(), x.end()

// 与えられた正の整数のすべての約数を抽出.
// @param X: 約数を抽出したい正の整数.
// @return ret: すべての約数.
vector<LL> div(LL X){
    vector<LL> ret;
    ret.pb(1);
    for(LL d = 2; d * d <= X; d++){
        if(X % d == 0){
            ret.pb(d);
            if(d * d != X) ret.pb(X / d);
        }
    }
    if(X > 1) ret.pb(X);
    sort(all(ret));
    return ret;
}

int main(){
    
    // 1. 入力情報.
    LL N;
    scanf("%lld", &N);
    
    // 2. N の 約数 を 保存.
    vector<LL> divisors = div(N);
    
    // 3. お気に入りの数を抽出.
    // N = q * m + q となる 素因数q から, m を 逆算.
    // 但し, m は q より大きい値として抽出.
    LL ans = 0;
    for(auto &q : divisors){
        LL m = N / q - 1;
        // printf("q=%lld m=%lld\n", q, m);
        if(m > q) ans += m;
    }
    
    // 4. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 3868
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r, g, b;
  cin >> r >> g >> b;

  int num = r * 100 + g * 10 + b;

  if (num % 4 == 0){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

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

using int64 = long long;

map<pair<int, int>, int> comb;
int64 pow10[30];

int get_digit(int64 n, int idx) {
    string sn = to_string(abs(n));
    if (idx >= sn.size()) return 0;
    else return sn[sn.size() - idx - 1] - '0';
}

int64 dfs(int digits, int idx, int64 n) {
    // cerr << "n: " << n << endl;
    if (idx >= (digits + 1) / 2) return n == 0;
    if (idx == digits - idx - 1) return (n == 0) ? comb[{0, idx == 0}] : 0;

    int64 res = 0;

    int a = get_digit(n, idx);
    if (n < 0) a = -a;

    for (int i = 0; i < 2; i++) {
        int b = -a;
        // cerr << "a: " << a << " b: " << b << endl;

        int64 com = comb[{a, (idx == 0)}];
        // cerr << "calc: " << n - a * pow10[idx] - b * pow10[digits - idx - 1] << endl;
        res += com * dfs(digits, idx + 1, n - a * pow10[idx] - b * pow10[digits - idx - 1]);

        if (a > 0) a = -(10 - a);
        else if (a < 0) a = 10 + a;
        else break;
    }
    return res;
}

int main() {
    for (int a = 0; a < 10; a++) {
        for (int b = 0; b < 10; b++) {
            comb[{a - b, 0}]++;
            if (a > 0) comb[{a - b, 1}]++;
        }
    }
    pow10[0] = 1;
    for (int n = 1; n <= 19; n++) pow10[n] = 10 * pow10[n - 1];

    // for (int D = 1; D <= 2000; D++) {
    /*
    for (int D = 189; D <= 2000; D++) {
        int64 ans = 0;
        for (int digits = 1; digits <= 19; digits++) {
            ans += dfs(digits, 0, D);
        }

        int64 ans2 = 0;
        vector<int> numbers;
        for (int n = 1; n <= 100000; n++) {
            string s1 = to_string(n),
                   s2 = s1;
            reverse(s2.begin(), s2.end());
            if (stol(s2) - stol(s1) == D) {
                ans2++;
                numbers.push_back(n);
            }
        }
        cout << "[D] " << D << " [ans1] " << ans << " [ans2] " << ans2 << endl;
        for (int num : numbers) {
            cout << num << endl;
        }
        if (ans != ans2) break;
    }
    */

    int64 D;
    cin >> D;

    int64 ans = 0;
    for (int digits = 1; digits <= 19; digits++) {
        ans += dfs(digits, 0, D);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
typedef unsigned long long ULL;
typedef long long LL;
typedef unsigned long UL;
typedef unsigned int UI;
typedef unsigned short US;
typedef unsigned char UC;
#define RNG(v) (v).begin(), (v).end()
#define REP(v, e) for(UI v = 0U; v < e; ++v)
#define REP_(v, s, e) for(UI v = s; v < e; ++v)
#define REPV(v, e) for(v = 0; v < e; ++v)
#define REPV_(v, s, e) for(v = s; v < e; ++v)
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    int tt=1;
    //cin>>tt;
    while(tt--)
    {   
        string s,t;int c=0,i;
        cin>>s>>t;
        for(i=0;i<s.length();i++)
        if(s[i]!=t[i])
        c++;
        cout<<c;
    }
        
    return 0;
}

Measured memory_bytes: 3888
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N; cin >> N;
  if(N % 10 == 3) cout << "bon";
  else if(N%10 == 0 ||N%10 == 1 ||N%10 == 6 ||N%10 == 8) cout << "pon";
  else cout << "hon";
  
  return 0;
}

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

const int MAX_N = 246912;

int prime[MAX_N];
bool is_prime[MAX_N + 1];

int sieve(int n) {
    int p = 0;
    for(int i = 0; i <= n; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i <= n; i++) {
        if(is_prime[i]) {
            prime[p] = i;
            p++;
            for(int j = 2 * i; j <= n; j += i) is_prime[j] = false;
        }
    }
    return p;
}

int main(void) {
    int n;
    while(1){
        cin >> n;
        if(!n) break;
        cout << sieve(2*n) - sieve(n) << endl;
    }

    return 0;
}

Measured memory_bytes: 3364
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    rep(i,0,n-1){
        int a;
        cin >> a;
        if(a%2 == 1)continue;
        if((a%3 != 0) && (a%5 != 0)){
            puts("DENIED");
            return 0;
        }
    }
    puts("APPROVED");

    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') cout<<"Yes";
	else cout<<"No";
	cout<<endl;
	return 0;
 } 

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

#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
int n,k;
  cin >> n >> k;
  if(n==0) return 0;
  vector<int> a(n+2,0);
  int c;
  int z=0;
  for(int i=0;i<k;i++){
    cin >> c;
    if(c==0) z++;
    else a[c]++;
  }
  int ans=0;
  int aaa=0;
  int tmp=0;
  if(z){
    for(int i=1;i<=n;i++){
      if(a[i]==0){
        tmp=1;
        for(int j=i-1;j>=0;j--){
          if(a[j]==0) break;
          tmp++;
        }
        for(int j=i+1;j<=n;j++){
          if(a[j]==0) break;
          tmp++;
        }
        ans=max(ans,tmp);
        aaa=1;
      }
    }
    if(aaa) cout << ans << endl;
    else cout << n << endl;
  }else{
    for(int i=1;i<=n+1;i++){
      if(a[i]){
        tmp++;
      }else{
        ans=max(ans,tmp);
        tmp=0;
      }
    }
    cout << ans << endl;
  }
  }
  
  return 0;
}



Measured memory_bytes: 3012
import sys

N, M = map(int, sys.stdin.readline().strip().split())

A = []
for _ in range(N):
    A.append(list(sys.stdin.readline().strip()))

B = []
for _ in range(M):
    B.append(list(sys.stdin.readline().strip()))

for i in range(N-M+1):
    for j in range(N-M+1):
        flag = True
        for y in range(M):
            for x in range(M):
                if A[i+y][j+x] != B[y][x]:
                    flag = False
            if not flag:
                break
        if flag:
            print("Yes")
            sys.exit()
print("No")

Measured memory_bytes: 39664
#include <iostream>

using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a>b){
        b = a^b;
        a = a^b;
        b = a^b;
    }
    if(b>c){
       c = b^c;
       b = b^c;
       c = b^c;        
    }
    if(a>b){
        b = a^b;
        a = a^b;
        b = a^b;
    }
    cout << a << ' ' << b << ' ' << c <<endl;
    return 0;
}

Measured memory_bytes: 3104
if __name__ == '__main__':

	line = int(input())
	A = [i+1 for i in range(line)]
	n = int(input())

	for _ in range(n):
		j,k = map(int,input().split(","))

		A[j-1],A[k-1] = A[k-1],A[j-1]

	for i in range(line):
		print(A[i])



Measured memory_bytes: 5604
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[]args) {
		int higth[] = new int[10];
		Scanner sc = new Scanner(System.in);
		for(int i=0; i<10 ; i++)higth[i]=sc.nextInt();//入力を10回繰り返す
		Arrays.sort(higth);
		System.out.println(higth[9]);
		System.out.println(higth[8]);
		System.out.println(higth[7]);

	}

}


Measured memory_bytes: 26268
#include<iostream>
#include<vector>

using namespace std;

int main(){
	int N;
	int D,X;
	vector<int> vec;
	
	int ans=0;

	cin>>N>>D>>X;

	for(int i=0;i<N;i++){
		int temp;
		cin>>temp;
		vec.push_back(temp);
	}

	
	for(auto it=vec.begin();it!=vec.end();it++){
		int choko=1;
		int i=1;
		while(choko<=D){
			ans++;
			choko=i*(*it)+1;
			i++;
		}
		//cout<<ans<<endl;
	}

	ans+=X;

	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>

using namespace std;

int main(){
  map<string, vector<int> > m;
  vector<string> keys;

  char s[32];
  int n;
  while(scanf(" %s %d",s,&n)!=EOF){
    string str(s);
    if(m.find(str) != m.end()){
      m[s].push_back(n);
    }else {
      keys.push_back(str);
      m.insert(pair<string,vector<int> >(s, vector<int>(1, n)));
    }
  }

  sort(keys.begin(), keys.end());
  vector<string>::iterator it;
  for(it=keys.begin();it!=keys.end();it++){
    printf("%s\n", (*it).c_str());

    vector<int> v = m[(*it)];

    sort(v.begin(), v.end());

    vector<int>::iterator it2;
    it2=v.begin();
    while(1){
      printf("%d", (*it2));
      it2++;
      if(it2!=v.end()) printf(" ");
      else{ printf("\n");break;}
    }
  }
  return 0;
}

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

int main() {
  int N, K, x, total = 0;
  cin >> N >> K;

  for (int i = 0; i < N; i++) {
    cin >> x;
    2 * x < K ? total += x * 2 : total += (K - x) * 2;
  }

  cout << total << endl;
}


Measured memory_bytes: 256
H,W = map(int, input().split())
List = []
queue = [(0,0,1)]
shape = 0
used ={(0,0)}
for i in range(H):
    x = input()
    shape += x.count('#')
    List.append(x)

def check(x,y,c):
    if(x>W-1 or y>H-1 or x<0 or y<0):
        return
    if(List[y][x] == '#'):
        return
    if(x,y) in used:
        return
    queue.append((x,y,c+1))
    used.add((x,y))

flag = -1
while(len(queue) != 0):
    x,y,c = queue[0]
    if x==W-1 and y==H-1:
        flag = 1
        break
    queue.pop(0)
    check(x+1,y,c)
    check(x, y+1,c)
    check(x-1,y,c)
    check(x, y-1,c)
if(flag == 1):
    print(H*W - c - shape)
else:
    print(-1)


Measured memory_bytes: 3316
#include<stdio.h>
#include<stdlib.h>

int main(){
  int *data, num;
  int s_num, cnt=0;
  int i, j;


  //input
  scanf("%d",&num);
  data=(int *)malloc(sizeof(int)*(num+1));//+1 input search data
  for(i=0;i<num;i++) scanf("%d",&data[i]);


  //search
  scanf("%d",&s_num);
  for(i=0;i<s_num;i++){
    scanf("%d",&data[num]);

    j=0;
    while(data[num]!=data[j]) j++;
    if(j!=num){
      cnt++;
      data[j]=-1;
    }
  }
  

  
  //output cnt
  printf("%d\n",cnt);
  

  free(data);
  return 0;
}



Measured memory_bytes: 2048
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
using namespace std;
 
#define MAX 100002
 
int n;
int m;
 
vector <pair<int, long long int> > v[MAX];
long long int cur[MAX];
bool vis[MAX];
queue<int> q;
int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int l, r, d;
		scanf("%d%d%d", &l, &r, &d);
		l--;
		r--;
		v[l].push_back(make_pair(r, d));
		v[r].push_back(make_pair(l, -d));
	}
	memset(vis, false, sizeof(vis));
	for (int i = 0; i < n; i++) {
		if (vis[i] == false) {
			q.push(i);
			cur[i] = 0;
			vis[i] = true;
			while (!q.empty()) {
				int b = q.front();
				q.pop();
				vis[b] = true;
				for (auto go : v[b]) {
					int node = go.first;
					long long int nex = cur[b] + go.second;
					if (vis[node]) {
						if (cur[node] == nex) {
							continue;
						}
						puts("No");
						exit(0);
					}
					else {
                      vis[node]=true;
						cur[node] = nex;
						q.push(node);
					}
				}
			}
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 13952
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int get() { int r; cin >> r; return r; }
int n, ns, ew; string s;
signed main() {
	cin >> n >> s;
	for0(i, n) {
		if ('A' <= s[i] && s[i] <= 'M')ns++;
		if ('N' <= s[i] && s[i] <= 'Z')ns--;
		if ('a' <= s[i] && s[i] <= 'm')ew++;
		if ('n' <= s[i] && s[i] <= 'z')ew--;
	}
	s = "";
	while (ns != 0) {
		if (ns < 0) { s += 'Z'; ns++; }
		else { s += 'A'; ns--; }
	}
	while (ew != 0) {
		if (ew < 0) { s += 'z'; ew++; }
		else { s += 'a'; ew--; }
	}
	cout << s.size() << endl << s << endl;
}


Measured memory_bytes: 3344
import sys
input=sys.stdin.buffer.readline
import os
from math import*

r,g,b=map(int,input().split())
k=int(input())
while g<=r and k>0:
	g*=2
	k-=1
while b<=g and k>0:
	b*=2
	k-=1
if b>g and g>r:
	print("Yes")
else:
	print("No")


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

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

string s;
int K;

int main() {
    cin >> s >> K;

    vector<string> substrings;
    for (int i = 0; i < s.length(); ++i) {
        for (int j = 1; j <= K; ++j) {
            substrings.push_back(s.substr(i, j));
        }
    }
    sort(substrings.begin(), substrings.end());

    int counter = 0;
    int idx = 0;
    string prev = " ";
    while (counter < K) {
        if (prev != substrings[idx]) {
            prev = substrings[idx];
            counter++;
        }
        idx++;
    }
    cout << substrings[idx-1] << endl;
    return 0;
}

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

int main(){
  int r,d,x[11];cin >> r >> d >> x[0];
  for(int i=1;i<=10;++i){
    x[i] = r*x[i-1] - d;
    cout << x[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll a,b; cin >> a >> b;
  if(a<=9&&b<=9) cout << a*b << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (){
    int a;
    while(true){
        int x,y;
        cin >> x >> y;
        
        if( x == 0 && y == 0) break;
        if(x > y) {
            a = x;
            x = y;
            y = a;
        }
        
        
        cout << x  << " "<< y << endl;
    }
}


Measured memory_bytes: 3088
import sys
a,b,c,x,y = map(int,input().split())
ans = a*x + b*y
for i in range(max(x,y)+1):
    if (x-i >=0) and (y-i >=0):
        id = a*(x-i) + b*(y-i) + 2*c*i
        if id <= ans:
            ans = id
        else:
            print(ans)
            sys.exit()
    elif (x-i <0) and (y-i>=0):
        id = b*(y-i) + 2*c*i
        if id <= ans:
            ans = id
        else:
            print(ans)
            sys.exit()
    elif (x-i >=0) and (y-i<0):
        id = a*(x-i) + 2*c*i
        if id <= ans:
            ans = id
        else:
            print(ans)
            sys.exit()
print(ans)

Measured memory_bytes: 3064
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(M)]
from collections import deque
from collections import defaultdict
# 各ノードから行ける隣接のーどの辞書

ans = [0]*N

new_AB = []
for ab in AB:
    new_AB.append([ab[0],ab[1]])
    new_AB.append([ab[1],ab[0]])
# AB = [[ab[0],ab[1]] if ab[0] < ab[1] else [ab[1],ab[0]] for ab in AB]

adj = defaultdict(list)

for ab in new_AB:
    adj[ab[0]].append(ab[1])

q = deque()
q.append(1)

# print(adj)
# キューが空になるまで繰り返す
while len(q) > 0:
    # キューの先頭（左端）からnodeを取り出す
    node = q.popleft()
    # print(node)

    for next_node in adj[node]:
        if ans[next_node-1] != 0:
            continue
        ans[next_node-1] = node
        q.append(next_node)


# exit()
print("Yes")
for an in ans[1:]:
    print(an)



# def bfs(depth,)

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

int main(){
    while(true){
        string s1;
        cin >> s1;
        if(s1==".") break;
        string s2;
        cin >> s2;
        if(s1==s2){
            cout << "IDENTICAL" << endl;
            continue;
        }
        string t1 = s1;
        string t2 = s2;
        while(true){
            size_t d1b = t1.find('\"');
            if(d1b==string::npos) break;
            t1.replace(d1b, 1, "@");

            size_t d1e = t1.find('\"');
            t1.replace(d1e, 1, "@");

            size_t d2b = t2.find('\"');
            if(d2b==string::npos) break;
            t2.replace(d2b, 1, "@");

            size_t d2e = t2.find('\"');
            t2.replace(d2e, 1, "@");

            string u1 = s1;
            u1.replace(d1b+1, d1e-d1b-1, "");
            string u2 = s2;
            u2.replace(d2b+1, d2e-d2b-1, "");

            if(u1==u2){
                t1 = u1;
                t2 = u2;
                break;
            }
        }
        if(t1==t2){
            cout << "CLOSE" << endl;
        }else{
            cout << "DIFFERENT" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3152
import sys
input=sys.stdin.readline
from itertools import accumulate
def main():
  n,k=map(int,input().split())
  a=list(map(int,input().split()))
  k=k if k<50 else 50
  for _ in range(k):
    b=[0]*(n+1)
    for i in range(n):
      ai=a[i]
      l,r=i-ai,i+ai+1
      l=0 if l<0 else l
      r=n if r>n else r
      b[l]+=1
      b[r]-=1
    b=tuple(accumulate(b))[:-1]
    a=b
    if min(set(b))==n:
      break
  print(*a)
if __name__ == '__main__':
  main()

Measured memory_bytes: 277052
#include <stdio.h>

int main(void)
{
	int a,b,x;
	scanf("%d%d%d",&a,&b,&x);
	if(a>x){
		printf("NO\n");
	}
	else if(b>=x-a){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128