akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <cmath> 
#include <algorithm>
using namespace std; 
inline int gi() {
    register int data = 0, w = 1;
    register char ch = 0;
    while (!isdigit(ch) && ch != '-') ch = getchar(); 
    if (ch == '-') w = -1, ch = getchar(); 
    while (isdigit(ch)) data = 10 * data + ch - '0', ch = getchar(); 
    return w * data; 
} 
const int Mod = 1e9 + 7; 
const int MAX_N = 5e3 + 5; 
struct Graph { int to, next; } e[MAX_N << 1]; 
int fir[MAX_N], e_cnt; 
void clearGraph() { memset(fir, -1, sizeof(fir)); }
void Add_Edge(int u, int v) { e[e_cnt] = (Graph){v, fir[u]}, fir[u] = e_cnt++; } 
int N, f[MAX_N][MAX_N], g[MAX_N], tmp[MAX_N]; 
int size[MAX_N]; 
void dfs(int x, int fa) { 
	f[x][1] = 1, size[x] = 1; 
	for (int i = fir[x]; ~i; i = e[i].next) { 
		int v = e[i].to; if (v == fa) continue; 
		dfs(v, x); 
		for (int j = 0; j <= size[x] + size[v]; j++) tmp[j] = 0; 
		for (int j = 0; j <= size[x]; j++) 
			for (int k = 0; k <= size[v]; k++) 
				tmp[j + k] = (tmp[j + k] + 1ll * f[x][j] * f[v][k] % Mod) % Mod; 
		size[x] += size[v]; 
		for (int j = 0; j <= size[x]; j++) f[x][j] = tmp[j]; 
	} 
	int res = 0; 
	for (int i = 0; i <= size[x]; i += 2) res = (res + (Mod - 1ll * g[i] * f[x][i] % Mod)) % Mod; 
	f[x][0] = res; 
} 
int main () { 
	clearGraph(); 
	N = gi(); 
	for (int i = 1; i < N; i++) {
		int u = gi(), v = gi(); 
		Add_Edge(u, v), Add_Edge(v, u); 
	} 
	g[0] = 1; 
	for (int i = 2; i <= N; i += 2) g[i] = 1ll * g[i - 2] * (i - 1) % Mod; 
	dfs(1, 0); 
	printf("%d\n", Mod - f[1][0]); 
    return 0; 
} 

Measured memory_bytes: 97152
import java.util.*;

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 first = sc.nextInt();
        a[0] = first;
        int second = sc.nextInt();
        a[1] = second;
        if(first < second){
            int tmp = first;
            first = second;
            second = tmp;
        }
        for(int i = 2; i < N; i++){
            int A = sc.nextInt();
            a[i] = A;
            if(first < A){
                second = first;
                first = A;
            }else if(second < A){
                second = A;
            }
        }
        for(int i = 0; i < N; i++){
            if(a[i] == first){
                System.out.println(second);
            }else{
                System.out.println(first);
            }
        }
    }
}


Measured memory_bytes: 94832
#include <iostream>

void calc(int i, int n, int& cnt) {
	if (n==0) {
		cnt++;
		return;
	}
	if (i>=4) {
		return;
	}
	int max = n < 9 ? n : 9;
	for (int j=0; j<=max; j++) {
		calc(i+1, n-j, cnt);
	}
}

int main() {
	int n, cnt;
	while (std::cin >> n) {
		cnt = 0;
		calc(0, n, cnt);
		std::cout << cnt << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N;
	cin >> N;
	vector<string> W(N);
	bool yes = true;
	REP(i, N) {
		cin >> W[i];
		if (i == 0) continue;
		if (W[i][0] != W[i - 1][W[i - 1].size() - 1]) yes = false;
		REP(j,i) {
			if (W[j] == W[i]) yes = false;
		}
	}
	if (yes) cout << "Yes\n";
	else cout << "No\n";


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <utility>
#include <functional>
#include <numeric>

template <class T>
using vec = std::vector<T>;

constexpr int nil = -1;
constexpr int inf = 1 << 30;

struct Edge
{
    int to;
    int cost;
};

int prim(const vec<vec<Edge>>& edges)
{
    const int n = edges.size();
    vec<bool> reached(n);
    vec<int> parents(n, nil);
    vec<int> distances(n, inf);

    distances[0] = 0;

    while (true)
    {
        int minCost {inf};
        int u {};
        
        for (int i = 0; i < n; ++i)
        {
            if (!reached[i] && distances[i] < minCost)
            {
                u = i;
                minCost = distances[i];
            }
        }
        
        if (minCost == inf)
            break;

        reached[u] = true;

        for (auto e : edges[u])
        {
            if (!reached[e.to])
            {
                if (e.cost < distances[e.to])
                {
                    distances[e.to] = e.cost;
                    parents[e.to] = u;
                }
            }
        }
    }

    int sum = std::accumulate(distances.begin(), distances.end(), 0);

    return sum;
}

void solve()
{
    using namespace std;
    int n;
    cin >> n;

    //隣接リスト形式
    vec<vec<Edge>> edges(n);

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0, cost; j < n; ++j)
        {
            cin >> cost;
            if (cost != -1)
                edges[i].push_back({j, cost});
        }
    }

    cout << prim(edges) << endl;
}

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


Measured memory_bytes: 3192
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int A[310][310],num[310],pd[310],now[310];
int n,m;
int getmax(){
	int ans=0;
	for (int i=1;i<=m;i++) ans=max(ans,num[i]);
	return ans;
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++) scanf("%d",&A[i][j]);
	memset(num,0x00,sizeof num);
	for (int i=1;i<=n;i++) now[i]=1,num[A[i][1]]++;
	int ans=getmax();
	for (int noww=1;noww<m;noww++){
		int where=1;
		for (int i=1;i<=m;i++)
			if (num[i]>num[where]) where=i;
		pd[where]=1; 
		memset(num,0x00,sizeof num);
		for (int i=1;i<=n;i++){
			while (pd[A[i][now[i]]]) now[i]++;
			num[A[i][now[i]]]++;
		}
		ans=min(ans,getmax());
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
 //    String[] nyu=sc.nextLine().split(" ");

     String nyu=sc.nextLine();
//int A=Integer.parseInt(nyu[0]);
//int B=Integer.parseInt(nyu[1]);
int C=Integer.parseInt(nyu);



//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(C){
case 7:
case 5:
case 3:
System.out.println("YES") ;
break;
default:
System.out.println("NO") ;

break;
}
*/

int res=(24-C)+24;
//if(res%2==0){

System.out.println(res);
//}else{
//System.out.println("Odd");

//}




	}
}

Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


ll a,b,d;
struct Ans{
    ll x,y;
    Ans(ll x=-1,ll y=-1):x(x),y(y){}
    bool operator < (const Ans &p)const{
        if(x+y != p.x+p.y)return x+y < p.x+p.y;
        if(a*x+b*y != a*p.x+b*p.y)return a*x+b*y < a*p.x+b*p.y;
        if(x != p.x)return x < p.x;
        return y < p.y;
    }
};
template<class Type>
Type solve(Type res = Type()){
    while(cin >> a >> b >> d,a){
        Ans ans(LINF,LINF);
        for(ll x = 0; x <= 1000000; x++){
            
            // a*x + b*y = d => b*y = d - a*x
            if(d >= a*x && (d-a*x)%b == 0){
                ll y = (d-a*x)/b;
                ans = min(ans,Ans(x,y));
            }
            // a*x - b*y = d => b*y = a*x - d
            if(a*x >= d && (a*x-d)%b == 0){
                ll y = (a*x-d)/b;
                ans = min(ans,Ans(x,y));
            }
            // -a*x + b*y = d => b*y = a*x + d
            if((a*x+d)%b == 0){
                ll y = (a*x + d)/b;
                ans = min(ans,Ans(x,y));
            }
        }
        cout << ans.x << " " << ans.y << endl;
    }
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    //cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}



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

using namespace std;

int main(){
	long long a, b, c; cin >> a >> b >> c;
	
	long long t = 0;
	
	if(b == c){
		t = b + c;
	}
	else if(b < c){
		t = b + b + 1;
		c -= (b + 1);
		if(a){
			t += min(a, c);	
		}
	}
	else {
		t = b + c;
	}
	
	cout << t;
	return 0;
}


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

int getDigit(int n){
  int i = 0;
  while(n >= 1){
    i = i + 1;
    n = n / 10;
  }
  return(i);
}

int main(){
  int N,d, ans=0;
  cin >> N;
  for(int i = 1; i <= N; i++){
    d = getDigit(i);
    if(d %2 ==1) ans += 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
    int n,m,s=0;
    cin>>n>>m;
    int ar[n+5];
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
        s+=ar[i];
    }
    double k = 1.0*s/(m*4);
    int c=0;
    for(int i=0;i<n;i++)
    {
        if(ar[i]>=k)
            c++;
    }
    if(c>=m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
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 dx[6] = {1,1,0,-1,-1,0};
int dy[6] = {0,1,1,0,-1,-1};

#define pluska 60
int data[300][300];
int t,n;

queue<int> qx,qy,qturn;

int search(){
	ll int rst = 0;
	while(!qx.empty()){
		int sx = qx.front(); int sy = qy.front(); int nturn = qturn.front();
		qx.pop(); qy.pop(); qturn.pop();
		REP(i,6){
			if(nturn == 0) i = 6;
			int nx = sx + dx[i]; int ny = sy + dy[i];
			if(data[nx][ny]==0){
				rst++;
				qx.push(nx);
				qy.push(ny);
				qturn.push(nturn-1);
				data[nx][ny] = 1;
			}
		}
	}
	return rst;
}


int main(){
	while(1){
		cin >> t >> n;
		if(t==0&&n==0) break;
		REP(i,300) REP(j,300) data[i][j] = 0;
		REP(i,n){
			int tx,ty;
			cin >> tx >> ty;
			data[tx+pluska][ty+pluska] = -1;
		}
		int sx,sy;
		cin >> sx >> sy;
		qx.push(sx+pluska);
		qy.push(sy+pluska);
		qturn.push(t);
		data[sx+pluska][sy+pluska] = 1;
		cout << search()+1 << endl;
	}
}

Measured memory_bytes: 1572
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	string s,t;
	cin >> s >> t;
	for(int i=0;i<2*n;i++)
	{
		if(i%2)
		cout<<t[i/2];
		else 
		cout<<s[i/2];
	}cout<<endl;
	return 0;
}

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

typedef long long ll;

struct edge { int to, cost; };
typedef pair<ll,ll> P; //firstは最短距離,secondは頂点の番号

int n;
vector<edge> G[100010];
ll d[100010];

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d,d+n,INF);
    d[s]=0;
    que.push(P(0,s));

    while(!que.empty()){
        P p=que.top();que.pop();
        ll v=p.second;
        if(d[v]<p.first)continue;
        for(int i=0;i<G[v].size();i++){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}

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

    cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b,c;
        cin>>a>>b>>c;
        a--;
        b--;
        G[a].push_back(edge{b,c});
        G[b].push_back(edge{a,c});
    }
    int q,k;
    cin>>q>>k;
    dijkstra(k-1);
    //for(int i=0;i<n;i++)cout<<d[i]<<" ";
    for(int i=0;i<q;i++){
        int x,y;
        cin>>x>>y;
        cout<<d[x-1]+d[y-1]<<endl;
    }
}

Measured memory_bytes: 9460
#include <stdio.h>
 
int main()
{
    int a = 0, b= 0, c=0;

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);

    if(a<b && b < c)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 1008
import sys
alp = [["a",0],["b",0],["c",0],["d",0],["e",0],
       ["f",0],["g",0],["h",0],["i",0],["j",0],
       ["k",0],["l",0],["m",0],["n",0],["o",0],
       ["p",0],["q",0],["r",0],["s",0],["t",0],
       ["u",0],["v",0],["w",0],["x",0],["y",0],["z",0]]
for line in sys.stdin:
    s = line.lower()
    for i in range(len(s)):
        for j in range(len(alp)):
            if s[i] == alp[j][0]:
                alp[j][1] += 1
                break
for i in range(len(alp)):
    print("{0} : {1}".format(alp[i][0], alp[i][1]))

Measured memory_bytes: 7468
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int a, b; cin >> a >> b;
    out(2 * b - a);
}


Measured memory_bytes: 256
import sys
import os

def file_input():
    f = open('ARC081/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    N=int(input())
    A=list(map(int, input().split()))

    n=0
    m=0
    a=dict()

    for i in A:
        if not i in a:
            a[i]=True
        elif not a[i]:
            a[i]=True
        elif n<i or m<i:
            if n<m:
                n=i
            else:
                m=i
            a[i]=False

    if n==0 and m==0:
        print(0)
    else:
        print(str(n*m))


if __name__ == '__main__':
    main()


Measured memory_bytes: 18152
def prnt(c, unit)
  if c != "1" && c != "0"
    print (c + unit)
  elsif c == "1"
    print unit
  end
end

gets.to_i.times do
  count = Hash["m", 0, "c", 0, "x", 0, "i", 0]
  str = gets.chomp.split
  str.each do |s|
    s.gsub(/(?<![1-9])([mcxi])/, '1\1').split("").each_slice(2) do |w|
      count[w[1]] += w[0].to_i
    end
  end
  ans = 0
  count.values.each_with_index{ |n, i| ans += 10 ** (3 - i) * n }
  ans.to_s.rjust(4, "0").split("").each_with_index{ |c, i| prnt(c, count.keys[i]) }
  puts
end

Measured memory_bytes: 9368
#include <algorithm>
#include <array>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
constexpr int INF = 100100100;

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

using namespace std;

// |a| = |b|
int hamming_distance(string const &a, string const &b) {
  int cnt = 0;
  for (int i = 0, len = a.length(); i < len; ++i) {
    if (a[i] != b[i]) { ++cnt; }
  }
  return cnt;
}

string make_string(int n, char init) {
  char arr[2] = {init, static_cast<char>( '1' - init + '0' ) };
  string str(n, '0');
  for (int i = 0; i < n; ++i) {
    str[i] = arr[i&1];
  }
  return str;
}

int main() {
  // cout << fixed << setprecision(10);
  string S;
  cin >> S;
  int n = S.length();
  cout << min(
      hamming_distance(S, make_string(n, '0')),
      hamming_distance(S, make_string(n, '1')))
    << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
typedef long long ll;
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, m;
  cin >> n >> m;
  Graph G(n);
  vector<vector<int>> dist(n, vector<int>(3,-3));
  rep(i, m){
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].emplace_back(b);
  }
  int s, t;
  cin >> s >> t;
  s--, t--;
	queue<P> que;
  dist[s][0] = 0;
  que.push(P(s, 0));
  while (!que.empty()){
  	P p = que.front();
		que.pop();
		int x = p.first;
		int ny = p.second;
		for(auto e : G[x]){
			int nt = (ny + 1) % 3;
			if(dist[e][nt] != -3)continue;
			dist[e][nt] = dist[x][ny] + 1;
			que.push(P(e, nt));
		}
  }
	cout << dist[t][0] / 3 << endl;
}


Measured memory_bytes: 13988
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

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

   vector<int> a(n+1);
   vector<int> b(n);

   rep(i,n+1){
      cin>>a[i];
   }
   rep(i,n){
      cin>>b[i];
   }

   ll ans=0;

   for(int i=n-1;i>=0;i--){
      ans+=min(a[i+1],b[i]);
      b[i]-=min(a[i+1],b[i]);

      if(b[i]>0){
         ans+=min(a[i],b[i]);
         a[i]-=min(a[i],b[i]);
      }
   }

   cout<<ans;
   


   


return 0;
}



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

int main(){
    int s,w;
    cin >> s >> w;
    if(s<=w) puts("unsafe");
    else puts("safe");
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;


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

    string s;
    cin>>s;

    if(s == "ABC")cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;


int findSumDigits(int n){
    int sum=0;
    while(n>0){
        sum += n%10;
        n /= 10;
        if(n==0)break;
    }
    return sum;
}


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

    int ans=0;

    for(int i=1;i<=n;i++){
        int sum = findSumDigits(i);
        if(a<= sum && sum <=b){
            ans += i;
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
/*
	0029:English sentence
*/
#include	<iostream>
#include	<string>
#include	<map>

using namespace std;

typedef map<string, int> M_SI;

int main(void) {
	int maxlen = 0, maxcou = 0; 
	string buf_str, maxlenSen, maxcouSen;
	M_SI Sentence;
	
	while(1) {
		cin >> buf_str;
		if(cin.eof()) { break; }
		if(Sentence.empty() || Sentence.count(buf_str) == 0) {
			Sentence.insert( M_SI::value_type(buf_str, 1) );
		} else {
			M_SI::iterator it = Sentence.find(buf_str);
			(*it).second++;
		}
	}
	M_SI::iterator it = Sentence.begin();
	while(it != Sentence.end()) {
		string bff = (*it).first;
		int bfs = (*it).second, bfl = bff.size();
		
		if(maxlen < bfl) {
			maxlenSen = bff;
			maxlen = bfl;
		}
		if(maxcou < bfs) {
			maxcouSen = bff;
			maxcou = bfs;
		}
		it++;
	}
	cout << maxcouSen << ' ' << maxlenSen << endl;
	
	return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<string> vstring;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define mod llint(1e9+7)

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗をmodで割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, (llint)b / 2);
	tmp *= tmp;
	tmp %= mod;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= mod;
	}
	return tmp;
}

int main() {
	string s;
	cin >> s;
	rep(i, s.size())cout << "x";
	cout << endl;
	return 0;
}

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

using namespace std;

int expression();
int term();
int factor();
int number();

int now;
string s;

int expression(){
  int res=term();
  while(true){
    if(s[now]=='+'){
      now++;
      res+=term();
    }else if(s[now]=='-'){
      now++;
      res-=term();
    }else
      break;
  }
  return res;
}

int term(){
  int res=factor();
  while(true){
    if(s[now]=='(')
      res+=factor();
    else if(s[now]=='*'){
      now++;
      res*=factor();
    }else if(s[now]=='/'){
      now++;
      res/=factor();
    }else break;
  }
  return res;
}

int factor(){
  int res=0;
  if(s[now]=='('){
    now++;
    res=expression();
    now++;
  }else
    return number();
  return res;
}

int number(){
  int res=0;
  while('0'<=s[now] && s[now]<='9'){
    res*=10;
    res+=s[now++]-'0';
  }
  return res;
}


int main(void){
  int n;
  cin >> n;
  while(n--){
    cin >> s;
    now=0;
    cout << expression() << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		InputReader r = new InputReader(System.in);
		char[] arr = r.next().toCharArray();
		for (int i = 0; i < arr.length; i++) {
			if (arr[i] == '?')
				arr[i] = 'D';
		}
		System.out.println(new String(arr));
	}

	static class InputReader {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}

		public InputReader(FileReader stream) {
			reader = new BufferedReader(stream);
			tokenizer = null;
		}

		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				return null;
			}
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

void solve(long long N, long long A, long long B)
{
    if (N == 1)
    {
        if (A == B)
        {
            cout << "1" << endl;
            return;
        }
        else
        {
            cout << "0" << endl;
            return;
        }
    }

    if (A > B)
    {
        cout << "0" << endl;
        return;
    }

    cout << (N - 2) * B - (N - 2) * A + 1 << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define inp(k)           ll k;cin>>k;
    #define in2(n,k)       ll n, k; cin>>n;cin>>k;
    #define in3(n,k,r)       ll n, k,r; cin>>n;cin>>k;cin>>r;
    #define ll long long
    #define dl double
    #define ch char
    #define f(i,a,b) for(ll i=a;i<b;i++)
    #define rf(i,a,b) for(ll i=a-1;i>=b;i--)
    #define Godspeed                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define vpl vector< pair<ll,ll> >
    #define vpi vector< pair<int,int> >
    #define vi vector<int>
    #define vl vector<ll>
    #define vdl vector<dl>
    #define vch vector<char>
    #define pll pair<ll,ll>
    #define pb push_back
    #define mp make_pair
    #define fr first
    #define se second
    #define PI 3.14159265
    /*vl v[10005];
    ll cnt=0;
    ll a[51][51]={0};
    bool visited[10005]={0};
    void dfs(ll u)
    {
        visited[u]=1;
        f(i,0,v[u].size())
        {
            ll f=v[u][i];
            if(!visited[f])
            {
                dfs(f);
            }
        }
    }*/
    void solve()
    {
        inp(n);ll a[n+1];f(i,1,n+1)cin>>a[i];
        ll dp[n+1];dp[0]=0;dp[1]=0;dp[2]=abs(a[1]-a[2]);
        f(i,3,n+1)
        {
            dp[i]=min((dp[i-1]+abs(a[i-1]-a[i])),(dp[i-2]+abs(a[i]-a[i-2])));
        }
        cout<<dp[n];

    }

    int32_t main(void)
    {
        Godspeed;
        int q;
        q=1;
        //cin>>q;
        while (q--)
        {
            solve();cout<<endl;
        }
        return 0;
    }


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

using namespace std;

int main(void){
    int A,B,C,X;
    cin >> A >> B >> C >> X;
    int ans = 0;
    for(int i=0;i<=A;i++){
        for(int j=0;j<=B;j++){
            int x = X-(500*i+100*j);
            if(x < 0) continue;
            if(x%50 == 0 && x/50 <= C) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int x;
    cin >> x;
    cout << (x >= 30 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3624
from heapq import heappop, heappush

X, Y, Z, K = [int(s) for s in input().split()]
A = [int(s) for s in input().split()]
B = [int(s) for s in input().split()]
C = [int(s) for s in input().split()]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
counted = set()
h = [(-(A[0] + B[0] + C[0]), 0, 0, 0)]
for _ in range(K):
    s, i, j, k = heappop(h)
    print(-s)
    if X > i+1 and (i+1, j, k) not in counted:
        heappush(h, (-(A[i+1] + B[j] + C[k]), i+1, j, k))
        counted.add((i+1, j, k))
    if Y > j+1 and (i, j+1, k) not in counted:
        heappush(h, (-(A[i] + B[j+1] + C[k]), i, j+1, k))
        counted.add((i, j+1, k))
    if Z > k+1 and (i, j, k+1) not in counted:
        heappush(h, (-(A[i] + B[j] + C[k+1]), i, j, k+1))
        counted.add((i, j, k+1))
    

Measured memory_bytes: 4852
import java.util.Scanner;

class Main {

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

  private Scanner sc = new Scanner(System.in);

  private void run() {
    long N = Long.parseLong(sc.next());
    int K = Integer.parseInt(sc.next());

    long num = N;
    int digits = 1;
    while (true) {
      num /= K;
      if (num == 0) {
        break;
      }
      digits++;
      if (num == 1) {
        break;
      }
    }
    System.out.println(digits);
  }
}


Measured memory_bytes: 21844
from collections import defaultdict
import heapq as hq
n,m,s = map(int,input().split())
edges = [[] for _ in range(n+1)]
INF = float('inf')
limit = 0
for i in range(m):
    u,v,a,b = map(int,input().split())
    edges[u].append((v,a,b))
    edges[v].append((u,a,b))
    limit += a
if s > limit:
    s = limit
exchanges = [0]
for i in range(n):
    c,d = map(int,input().split())
    exchanges.append((c,d))
dp = [[INF]*(limit+1) for _ in range(n+1)]
q = []
hq.heapify(q)
hq.heappush(q,(0,1,s))
dp[1][s] = 0
while q:
    time,place,silver = hq.heappop(q)
    c,d = exchanges[place]
    if silver + c <= limit:
        if time+d < dp[place][silver+c]:
            dp[place][silver+c] = time+d
            hq.heappush(q,(time+d,place,silver+c))
    else:
        if time+d < dp[place][limit]:
            dp[place][limit] = time+d
            hq.heappush(q,(time+d,place,limit))
    for v,a,b in edges[place]:
        if silver-a >= 0 and dp[v][silver-a] > time+b:
            dp[v][silver-a] = time+b
            hq.heappush(q,(time+b,v,silver-a))

for i in dp[2:]:
    print(min(i))

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

int main(void) {
  int N;
  cin >> N;

  int MAX = 0, MIN = 1000000010;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    MAX = max(MAX, a);
    MIN = min(MIN, a);
  }

  cout << MAX - MIN << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;
    int s1, s2, s3, s4, s5;
    int max, min, sum;
    int i;
    
    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }
        
        scanf("%d%d%d%d%d", &s1, &s2, &s3, &s4, &s5);
        
        min = max = s1 + s2 + s3 + s4 + s5;
        
        for (i = 1; i < n; i++){
            scanf("%d%d%d%d%d", &s1, &s2, &s3, &s4, &s5);
            
            sum = s1 + s2 + s3 + s4 + s5;
            
            if (max < sum){
                max = sum;
            }
            if (min > sum){
                min = sum;
            }
        }
        
        printf("%d %d\n", max, min);
        
    }
    return (0);
}

Measured memory_bytes: 600
import * as fs from 'fs'

const getInput = (): string => {
  return (fs.readFileSync('/dev/stdin', 'utf8') as string).trim()
}

export const solveAbc055b = () => {
  const input = getInput()

  const N = Number(input.trim())
  // console.log(N)

  let ans = 1
  for (let i = 1; i <= N; i += 1) {
    ans *= i
    ans = ans % (Math.pow(10, 9) + 7)
  }
  console.log(ans)
}
solveAbc055b()


Measured memory_bytes: 7372
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut a: [usize; n],
    }
    a.sort();
    let amax = a[n-1];
    let mut f = vec![false; amax + 1];
    let mut ans = 0;
    for i in 0..n {
        if f[a[i]] {continue;}
        let mut j = a[i];
        if i+1 == n || a[i] != a[i+1] {ans += 1;}
        while j <= amax {
            f[j] = true;
            j += a[i];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 5840
// RAKSHIT KADAM
 
//  -- Declare array globally...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
// find_by_order returns iterator to  element present at that index...
// order_of_key returns no. of elements having value stricktly less than that given in the order_of_key();
#warning !!!check the size of arrayss!!!
 
// NUMERIC DEFINITIONS :
    #define INF 100000000000000005
    #define inf 1000000003
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 200006
    #define pi 3.1415926535897932384626433832795
#define ld long doubles
 #define ll long long
 #define int long long
 
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 500003;
ll tree[2*maxn];ll n;
void build()
{
    for(ll i=n-1;i>0;i--)
    {
        tree[i]=tree[i<<1] +  tree[i<<1|1];
    }
}
void update(ll val ,ll pos)
{
    
    for(tree[pos+=n]=val;pos>1;pos>>=1)
    {
        tree[pos>>1]=tree[pos]  +   tree[pos^1];
                            //MODIFY THE SIGN AS PER NEED;
    }
}
ll query(ll l,ll r)
{
// for querying [1,2]use 0,2
    ll res=0;
    for(l+=n,r+=n;l<r;l>>=1,r>>=1)
    {
        if(l&1)res+=tree[l++];
        if(r&1)res+=tree[--r];
    }
    return res;
}
vector <pii> v[maxn];
map< ll,ll > m;
ll ans[maxn];
void solve()
{
    cin>>n;ll q;cin>>q;
    ll a[n+1];for(ll i=1;i<=n;i++)cin>>a[i];
    ll aa,bb;
    for(ll i=1;i<=q;i++)
    {
        cin>>aa>>bb;
        v[bb].pb(mp(aa,i));
    }
    for(ll i=1;i<=n;i++)
    {
        update(1,i-1);
        if(m.count(a[i]))
        {
            update(0,m[a[i]]-1);
        }
        m[a[i]]=i;
        for(auto j:v[i])
        {
            ans[j.y] = query(j.x-1,i);
        }
    }
    for(ll i=1;i<=q;i++)
    {
        cout<<ans[i]<<endl;
    }
}
 
signed main()
{
   Need_for_speed(activated);
 
//satisfy
//    {
//  solve();
//   }
//
    solve();
}


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


// Useful container manipulation / traversal macros
#define fori(i,a,b)    for(int i=a;i<=b;i++)
#define ford(i,a,b)   for(int i=a;i>=b;i--)
#define all(a)        a.begin(), a.end()
#define in(a,b)       ( (b).find(a) != (b).end())
#define tr(c,i)       for(auto i = (c).begin(); i != (c).end(); i++)
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define pb             push_back
#define fill(a,v)      memset(a, v, sizeof a)

typedef long long int lli;
typedef vector<int> vi;
typedef vector<long long int> vlli;

int l[10];
int n, a[3];
lli ans = INT64_MAX;

void rec(int cur, lli sum, int x, int y, int z){
    if(cur == n){
        if(x > 0 && y > 0 && z > 0)
            ans = min(ans, sum + abs(x - a[0]) + abs(y - a[1]) + abs(z - a[2]) - 30);
        
        return;
    } else {
        rec(cur+1, sum, x, y, z);
        rec(cur+1, sum+10, x+l[cur], y, z);
        rec(cur+1, sum+10, x, y+l[cur], z);
        rec(cur+1, sum+10, x, y, z+l[cur]);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	
    if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }

    cin>>n>>a[0]>>a[1]>>a[2];

    fori(i, 0, n-1)
    cin>>l[i];

    rec(0, 0, 0, 0, 0);
    cout<<ans;
}

// #include <bits/stdc++.h>
// using namespace std;
// #define REP(i,b,e) for(int i=(b);i<(e);++i)
// #define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
// #define rep(i,e) for(int i=0;i<(e);++i)

// inline void print(void) { cout<<'\n'; }
// template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
// template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

// int n, a, b, c;
// vector<int> l(10);
// int ans = 1<<30;

// void rec(int cur, int sum, int x, int y, int z) {
//   if (cur == n) {
//     if (x > 0 and y > 0 and z > 0) {
//       ans = min(ans, sum + abs(a-x) + abs(b-y) + abs(c-z) - 30);
//     }
//     return;
//   }
//   rec(cur+1, sum, x, y, z);
//   rec(cur+1, sum+10, x+l[cur], y, z);
//   rec(cur+1, sum+10, x, y+l[cur], z);
//   rec(cur+1, sum+10, x, y, z+l[cur]);
// }

// int main() {
//     ios_base::sync_with_stdio(false);
//     cin.tie(NULL);
	
	
//     if (fopen("input.txt", "r")) {
//         freopen("input.txt", "r", stdin);
//         freopen("output.txt", "w", stdout);
//     }

//   cin>>n>>a>>b>>c;
//   rep(i, n) cin>>l[i];
//   rec(0, 0, 0, 0, 0);
//   print(ans);

//   return 0;
// }


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

int n, k, a;
int dp[101][1000001];
int pr[101][1000001];

int main()
{
	cin >> n >> k;
	
	dp[0][0] = 1;
	for(int i = 0; i <= n; i++)
	for(int j = 0; j <= k; j++)
	pr[i][j] = 1;
	
	for(int i = 1; i <= n; i++)
	{
		cin >> a;
		dp[i][0] = 1;
		for(int j = 1; j <= k; j++)
		{
			dp[i][j] = pr[i - 1][j];
			if(j - a - 1 >= 0)
				dp[i][j] = (dp[i][j] - pr[i - 1][j - a - 1] + int(1e9 + 7)) % int(1e9 + 7);
			pr[i][j] = (pr[i][j - 1] + dp[i][j]) % int(1e9 + 7);
		}
	}
	
	cout << dp[n][k] << endl;
}


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	vector <vector<pair<int,int>>> a(n);
	for (int i = 0; i < n; ++i){
		int k;
		cin >> k;
		for (int j = 0; j < k; ++j){
			int x, y;
			cin >> x >> y;
			a[i].emplace_back(x,y);	
		}
	}
	int cnt = -1;
	for (int i = 0; i < (1 << n); ++i){
		bool possible = true;
		int ans = __builtin_popcount(i);
		vector <bool> v(n);
		for (int mask = 0; mask < n; ++mask){
			if ((i & (1 << mask) )!= 0) v[mask] = true;
			else v[mask] = false;	
		}
		for (int mask = 0; mask < n; ++mask){
			if ((i & (1 << mask)) != 0){
				for (auto pp : a[mask]){
					if (v[--pp.first] != pp.second){
						possible = false;
						break;
					}
				}
			}
		}
		if (possible) cnt = max(cnt, ans);
	}
		cout << cnt << "\n";
	return 0;
}


Measured memory_bytes: 3624
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()

print(180*(N-2))

Measured memory_bytes: 4072
X, N = map(int, input().split())
if N!=0:
    p=list(map(int,input().split()))
    checkNum=[0 for j in range(102)]
    for i in range(len(p)):
        checkNum[p[i]]=1
    i=0
    while(X-i>=0 or X+i<=101):
        if X-i>=0:
            if checkNum[X-i]==0:
                print(X-i)
                break
        if X+i<=101:
            if checkNum[X+i]==0:
                print(X+i)
                break
        i+=1
else:
    print(X)

Measured memory_bytes: 9208
fun main(args:Array<String>){
    val n = readLine()!!.split(" ").map { it.toLong() }
    val s = readLine()!!.split(" ").map { it.toLong() }.sorted().toMutableList()
    var count: Long

    if(n[1] >= n[0]){
        println("0")
    }else if(n[1].toInt() == 0){
        println(s.sum())
    }else{
        val a = n[0] - n[1]
        val f = s.filterIndexed{idx, item -> idx < a}
        count = f.sum()
        println(count)
    }
}



Measured memory_bytes: 83500
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll n; cin >> n;
	vector<string> v(n);
	REP(i, n) cin >> v[i];
	vl c(27, TEN(9));
	for (auto& s : v) {
		vl d(27, 0);
		for (char _ : s) {
			d[_ - 'a']++;
		}
		REP(i, 27) c[i] = min(c[i], d[i]);
	}

	REP(i, 27) {
		REP(j, c[i]) cout << (char)(i + 'a');
	}
	cout << endl;
}

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

using namespace std;
using ll = long long;

int main() {
	int N, K;
	cin >> N >> K;

	double res = 0;
	double x = 1.0 / (double)N;
	for (int i = 1; i <= N; ++i) {
		int y = i;
		double tmp = x;
		while (y < K) {
			y *= 2;
			tmp *= 0.5;
		}
		res += tmp;
	}

	cout.precision(15);
	cout << fixed << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e15;
using namespace std;
typedef long long ll;
int main() {
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll ans = n;
  char p = s[0];
  FOR(i, 1, n) {
    if (s[i] == p) ans--;
    p = s[i];
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
	/*input*/
	int n;	cin >> n;
	vector<int>a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	/*calculation*/
	sort(a.begin(), a.end());
	/*output*/
	cout << a[n - 1] - a[0] << 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() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for (int i = 0; i < m; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < m; i++)
    {
        n -= a[i];
    }
    if (n >= 0) cout << n << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3600
import sys

input = sys.stdin.readline


def ii():
    return int(input())


def il():
    return list(map(int, input().split()))


def sum_digits(n: int, base: int) -> int:
    if n < base:
        return n
    else:
        return sum_digits(n // base, base) + (n % base)


N = int(input())
m = float("inf")
for n in range(1, N):
    s = sum_digits(n, 10) + sum_digits(N - n, 10)
    if s < m:
        m = s
print(m)


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <cassert>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

char buf[100000+10];

int main(void) {
  scanf("%s", buf);
  char last = '?';
  int cnt = 0;
  for(int i = 0; buf[i]; ++i) {
    if(last != buf[i]) {
      ++cnt;
    }
    last = buf[i];
  }
  printf("%d\n", cnt-1);
  return 0;
}


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

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

  if (abs(a-c) <= d) {
    cout << "Yes" << endl;
  } else if(abs(a-b) <= d && abs(b-c) <= d) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3572