akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define pi(n,m) n.insert(n.begin(),m);
#define ee(n) n.erase(n.end()-1)
#define eb(n) n.erase(n.begin())
#define check(n) reverse(all(n));rep(z,0,n.size())cout<<n[z];co("");reverse(all(n));
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int n,c=0,d=0,ans=1000000;
  cin>>n;
  vector<int> a(n);
  rep(i,0,n){
    cin>>a[i];
    c+=a[i];
  }
  rep(i,0,n-1){
    d+=a[i];
    c-=a[i];
    ans=min(ans,abs(c-d));
  }
  co(ans);
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int null=-1;

struct Node{
	int parent;
	int child;
	int sibling;
	int depth;
	int degree;
};
Node *nodes;

int traceRoot(Node *nodes, int id){
	if(nodes[id].parent==null) return id;
	else return traceRoot(nodes, nodes[id].parent);
}

int rootSearch(Node *nodes, int n){
	int start;
	for( int i=0;; i++ ){ 
		if( nodes[i].parent==null ) return i;
		else start=i;
	}
	return traceRoot(nodes, start);
}
		


void setDepth( Node *nodes, int id, int d ){
	nodes[id].depth=d;
	if( nodes[id].sibling !=null ){
		setDepth( nodes, nodes[id].sibling, d );
	}
	if( nodes[id].child !=null ){
		setDepth( nodes, nodes[id].child, d+1 );
	}
	
}

void show(Node *nodes, int n){
	for( int id=0; id<n; id++ ){
		cout<<"node "<<id<<": "
			<<"parent = "<<nodes[id].parent<<", "
			<<"depth = "<<nodes[id].depth<<", ";
		if( nodes[id].parent==null ) cout<<"root, ";
		else if( nodes[id].child==null ) cout<<"leaf, ";
		else cout<<"internal node, ";

		cout<<"[";
		if( nodes[id].child !=null ){
			int tp=nodes[id].child;
			cout<<tp;
			for( int i=1; i<nodes[id].degree; i++ ){
				tp=nodes[tp].sibling;
				cout<<", "<<tp;
			}
		}
		cout<<"]"<<endl;

	}
}

int main()
{
	int n;cin>>n;
	nodes=new Node[n];

	for( int i=0; i<n; i++ ) nodes[i].parent=nodes[i].child=nodes[i].sibling=null;

	for( int i=0, id, deg, cld, prevcld; i<n; i++ ){
		cin>>id>>deg;
		nodes[id].degree=deg;
		
		if( deg>0 ){
			for( int j=0; j<deg; j++ ){ //??????????????????.
				cin>>cld;
				nodes[cld].parent=id; //?????????????????????????????????????????????
				
				if( j==0 ){
					nodes[id].child=cld; //????????????????????????????????????
				}else{
					nodes[prevcld].sibling=cld; //??????????????????????????????
				}
				prevcld=cld;
			}

		}
	}
	setDepth(nodes, rootSearch(nodes, n) , 0);
	show(nodes, n);
}


		

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

int main(){
	bool nonprime[10001] = {};
	nonprime[0] = nonprime[1] = true;
	for(int i = 2; i < 10001; i++){
		if(!nonprime[i]){
			for(int j = i+i; j < 10001; j+=i){
				nonprime[j] = true;
			}
		}
	}
	
	int n;
	while(cin >> n){
		int cnt = 0;
		for(int i = 1; i <= n; i++){
			if(!nonprime[i] && !nonprime[n-i+1])
				cnt++;
		}
		cout << cnt << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3040
h,w = map(int,input().split())
s = ["" for i in range(h)]
for i in range(h):
    s[i] = input()

def pl(x1,y1,x2,y2):
    if s[x1][y1] == "." and s[x2][y2] == "#":
        return 1
    else:
        return 0

dp = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    for j in range(w):
        if i == 0 and j == 0 and s[i][j] == "#":
            dp[i][j] += 1
        elif i == 0:
            dp[i][j] = dp[i][j-1]+pl(i,j-1,i,j)
        elif j == 0:
            dp[i][j] = dp[i-1][j]+pl(i-1,j,i,j)
        else:
            dp[i][j] = min(dp[i][j-1]+pl(i,j-1,i,j),dp[i-1][j]+pl(i-1,j,i,j))

print(dp[h-1][w-1])


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
  int s,k,c=0;
  cin>>k>>s;
  for(int i=0;i<=s;i++){
    for(int j=0;j<=s-i;j++){
      int a=s-i-j;
      if(i<=k&&j<=k&&a<=k){
        c++;
      }
    }
  }
  cout<<c;
}

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

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

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int x = sc.nextInt();
		sc.nextLine();
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		Arrays.sort(array);
		
		int sum = 0;
		for(int i=0;i<n;i++){
			sum = sum + array[i];
			if(sum > x){
				System.out.println(i);
				return;
			}else if(sum == x){
				System.out.println(i+1);
				return;
			}
		}
		
		
		System.out.println(n-1);
	}
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define REP_(i, a, b) for(int i = a; i <= b; i++)
#define sl(n) scanf("%lld", &n);
#define si(n) scanf("%d", &n);
#define RepAll(a) for(auto x: a)
#define cout(ans) cout << ans << endl;
typedef long long ll;
/**
 *    This code has been written by YueGuang, feel free to ask me question. Blog: http://www.yx.telstudy.xyz
 *    created:
 */
 const int mod = 1e9+7;
using namespace std;
//求解所有能组成的矩形的和再取mod
/*
    x1,y1 x5,y5
 xi -  xj , yl - yk
 xi -  xj) * (yl - yk
*/
#define N 100010
ll x[N], y[N];
ll xx, yy, maxy;
int main(){
    int n, m;

    cin >> n >> m;
  //  long long *x = long long new [n];
   // long long *y = long long new [m];

    REP(i, 0, n){
        cin >> x[i];
        /*if(i == 0){
            minx = x;
            maxx = x;
        }
        minx = min(minx, x);
        maxx = max(maxx, x);
        */
    }
    REP(i, 0, m){
        cin >> y[i];
        /*if(i == 0){
            miny = y;
            maxy = y;
        }
        miny = min(miny, y);
        maxy = max(maxy, y);
        */
    }
    //计算每个边长对面积,类似于边权？
    //cout << (maxx - minx);
    //cout << '\n' <<(maxy - miny);
    //cout << ((maxx - minx)%mod * (maxy - miny)%mod)%mod << '\n';
    //REP(i, 0, m){ }
    //yy = (yy % mod; + (y[i] - y[m - i])% mod) * (m - 2*i) % mod;
    for(int i = 0, j = m-1; j > i; j--, i++){
        yy = (yy +abs (y[i] - y[j]) * (j - i))  % mod;
    }
    for(int i = 0, j = n-1; i < j; j--, i++)
    {   xx = (xx + abs(x[i] - x[j]) * (j - i))  % mod;
     }

cout << xx*yy%mod << '\n';
}
// 9 8 7 6 5


Measured memory_bytes: 1792
#include <vector>

template<class T = long long>
class bit {
public:
    std::vector<T> dat;
    int N;

    bit(){}
    bit(int N) : N(N) { dat.assign(N,0); }

    T sum(int i){
        int ret = 0;
        for(--i; i>=0; i=(i&(i+1))-1) ret += dat[i];
        return ret;
    }

    T sum(int i, int j) { return sum(j) - sum(i); }
    void add(int i, T x) { for(; i < N; i|=i+1) dat[i] += x; }
};

#include <iostream>

int main() {
    int n;

    std::cin >> n;

    bit<> A(n), B(n);

    for(int i = 0; i < n; ++i) {
        A.add(i, 1);
        B.add(i, 1);
    }

    int i;
    long long min = n + 1;
    for(int k = 0; k < n; ++k) {
        std::cin >> i;
        --i;

        if(k == 0)
            continue;

        auto a = A.sum(i + 1);
        auto b = B.sum(n) - B.sum(i);

        auto diff = min - (a + b);

/*        std::cout << diff <<  " " << a << " " << b << std::endl;
        std::cout << "\t";
        for(int i = 0; i < n; ++i) {
            auto a = A.sum(i + 1);
            std::cout << a << (n - 1 == i ? "\n" : " ");
        }
        std::cout << "\t";
        for(int i = 0; i < n; ++i) {
            auto b = B.sum(n) - B.sum(i);
            std::cout << b << (n - 1 == i ? "\n" : " ");
        }*/

        A.add(i, diff + 1);
        B.add(i, diff + 1);

        min = a + b + (diff + 1) * 2;
    }

    for(int i = 0; i < n; ++i) {
        auto a = A.sum(i + 1);
        std::cout << a << (n - 1 == i ? "\n" : " ");
    }
    for(int i = 0; i < n; ++i) {
        auto b = B.sum(n) - B.sum(i);
        std::cout << b << (n - 1 == i ? "\n" : " ");
    }
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  string ans="No";
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if(N==i*j)ans="Yes";
    }
  }
  cout<<ans<<endl;
}
    

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())

using namespace std;
typedef vector<long> VI;
typedef vector<VI> VVI;
typedef pair<long,long> pr;
struct Order {
	bool operator() (pr const& a,pr const& b) const {
		return a.first > b.first || ((a.first == b.first) && (a.second > b.second));
	}
};

bool pairCompare(const pr& firstElof, const pr& secondElof)
{
    return (firstElof.first < secondElof.first || ((firstElof.first == secondElof.first) && (firstElof.second < secondElof.second)));
}
typedef priority_queue<pr,vector<pr>,Order> pq;
typedef vector<pr> VP;

class Prim {
private:
	vector<vector<pr>> E; //隣接リスト
	pq mincost;
	vector<bool> used;
	size_t V;
public:
	Prim() : V(0) {}

	Prim(size_t v) : 
		V(v),E(v,vector<pr>(0)),used(v,false){}
		
	size_t size() {return V;}

	void add_edge_directed(long start,long goal,long weight){
		E[start].push_back(pr(goal,weight));
	}

	void add_edge_undirected(long start,long goal,long weight){
		E[start].push_back(pr(goal,weight));
		E[goal].push_back(pr(start,weight));
	}

	long min_spanning_tree(void){
		long minval = 0;
		mincost.push(pr(0,0));
		while(1) {
			if (mincost.empty()) break;
			pr node = mincost.top();
			mincost.pop();
			if (used[node.second]) continue;
			minval += node.first;
			used[node.second] = true;

			REP(i,E[node.second].size()){
				if (!used[E[node.second][i].first])
					mincost.push(pr(E[node.second][i].second,E[node.second][i].first));
			}
					
		}

		return minval;
	}

};


int main(void){
	long N;
	long x,y;
	cin >> N;
	VP X_dis(N),Y_dis(N);

	REP(i,N) {
		cin >> x >> y;
		X_dis[i] = pr(x,i);
		Y_dis[i] = pr(y,i);
	}

	sort(X_dis.begin(),X_dis.end(),pairCompare);
	sort(Y_dis.begin(),Y_dis.end(),pairCompare);

	Prim sp(N);

	REP(i,N-1){
		sp.add_edge_undirected(X_dis[i].second,X_dis[i+1].second,(X_dis[i+1].first - X_dis[i].first));
		sp.add_edge_undirected(Y_dis[i].second,Y_dis[i+1].second,(Y_dis[i+1].first - Y_dis[i].first));
	}

	cout << sp.min_spanning_tree() << endl;

	return 0;
}

Measured memory_bytes: 16500
#include<bits/stdc++.h>
using namespace std;
inline int combined(int x,int y){
	return x+100*y;
}
struct beaker{
	int volume,sugar,water,solubility,now_sugar,now_water;
	inline bool dissolve(int x,int y){
		return x<=y*solubility;
	}
	bool add(int x,int y){
		if (combined(x,y)<=volume&&dissolve(x,y)){
			if ((now_sugar==0&&now_water==0)||now_sugar*(x+y)<x*(now_sugar+now_water)) now_sugar=x,now_water=y;
			return 1;
		}
		else return 0;
	}
	void out(){
		printf("%d %d",combined(now_sugar,now_water),now_sugar);
	}
}t;
int a,b,c,d;
vector<int> gs;
int main(){
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&t.solubility,&t.volume);
	for (int i=0; i<=1500; i++)
	for (int j=0; j<=1500; j++)
	if (combined(i*c+j*d,0)*2<=t.volume) gs.push_back(i*c+j*d);
	sort(gs.begin(),gs.end());
	gs.erase(unique(gs.begin(),gs.end()),gs.end());
//	for (vector<int>::iterator it=gs.begin(); it!=gs.end(); ++it) printf("%d ",*it);
	for (int i=0; i<=30; i++)	
	for (int j=0; j<=30; j++)
	if (i*a+j*d&&combined(0,i*a+j*b)<=t.volume){
		for (int l=0,r=gs.size()-1,mid=(l+r)>>1; l<=r; mid=(l+r)>>1)
		if (t.add(gs[mid],i*a+j*b)) l=mid+1; else r=mid-1;
	}
	t.out();
}

Measured memory_bytes: 640
import java.util.LinkedList;
import java.util.Scanner;

//Petoris
public class Main{

	class R{
		int h, w;
		LinkedList<LinkedList<Character>> p;
		public R(char[][] m) {
			p = new LinkedList<LinkedList<Character>>();
			for(int i=0;i<m.length;i++){
				LinkedList<Character> l = new LinkedList<Character>();
				for(int j=0;j<m[i].length;j++)l.add(m[i][j]);
				p.add(l);
			}
			for(;;){
				boolean f = true;
				for(char c:p.get(0))if(c=='#')f=false;
				if(!f)break;
				p.remove(0);
			}
			for(;;){
				boolean f = true;
				for(char c:p.get(p.size()-1))if(c=='#')f=false;
				if(!f)break;
				p.remove(p.size()-1);
			}
			h = p.size();
			for(;;){
				boolean f = true;
				for(int i=0;i<h;i++)if(p.get(i).get(0)=='#')f=false;
				if(!f)break;
				for(int i=0;i<h;i++)p.get(i).remove(0);
			}
			for(;;){
				boolean f = true;
				for(int i=0;i<h;i++)if(p.get(i).get(p.get(i).size()-1)=='#')f=false;
				if(!f)break;
				for(int i=0;i<h;i++)p.get(i).remove(p.get(i).size()-1);
			}
			w = p.get(0).size();
//			System.out.println("H:"+h+" W:"+w);
//			p(m);
		}
	}
	
	void p(char[][] a){
		for(int i=0;i<a.length;i++)System.out.println(new String(a[i]));
		System.out.println();
	}
	
	char[][] rot(char[][] a){
		int h = a.length, w = a[0].length;
		char[][] r = new char[w][h];
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)r[j][i] = a[h-i-1][j];
		return r;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		while(T--!=0){
			int H = sc.nextInt(), W = sc.nextInt();
			R[] r = new R[4];
			char[][] p = new char[H][];
			for(int i=0;i<H;i++)p[i]=sc.next().toCharArray();
			for(int i=0;i<4;i++){
				r[i] = new R(p);
				p = rot(p);
			}
			H = sc.nextInt(); W = sc.nextInt();
			p = new char[H][];
			for(int i=0;i<H;i++)p[i]=sc.next().toCharArray();
			int res = -1;
			for(int k=0;k<4;k++){
				int h = r[k].h, w = r[k].w;
				for(int i=0;i+h<=H;i++)for(int j=0;j+w<=W;j++){
					boolean f = true;
					for(int y=0;y<h;y++)for(int x=0;x<w;x++){
						if(r[k].p.get(y).get(x)=='.')continue;
						if(p[i+y][j+x]=='#')f = false;
					}
					if(!f)continue;
					for(int y=0;y<h;y++)for(int x=0;x<w;x++){
						if(r[k].p.get(y).get(x)=='#')p[i+y][j+x] = '#';
					}
//					System.out.println("BEFORE:");
//					p(p);
					int c = 0;
					for(int y=0;y<h;y++){
						boolean ok = true;
						for(int x=0;x<W;x++)if(p[i+y][x]=='.')ok = false;
						if(ok)c++;
					}
					res = Math.max(res, c);
					for(int y=0;y<h;y++)for(int x=0;x<w;x++){
						if(r[k].p.get(y).get(x)=='#')p[i+y][j+x] = '.';
					}
//					System.out.println("AFTER:");
//					p(p);
				}
			}
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 14000
#include<stdio.h>
int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if(a==b)
	{
		printf("%d\n", c);
	}
	else if(a==c)
	{
		printf("%d\n", b);
	}
	else if(b==c)
	{
		printf("%d\n", a);
	}
	return 0;
}


Measured memory_bytes: 128
# https://atcoder.jp/contests/abc147/tasks/abc147_c

N = gets.to_i
As = Array.new(N) { Array.new(N, '.') }
N.times do |i|
  k = gets.to_i
  k.times do |j|
    x, y = gets.chomp.split
    As[i][x.to_i - 1] = y
  end
end
ps = As.map { |a| /#{a.join}/ }

S = 1 << N
ans = 0
S.times do |s|
  ng = false
  h = 0
  q = s.to_s(2).rjust(N, '0')
  ps.each_with_index do |p, i|
    # p([q, p.source, i])
    if q[i] == '1'
      if q =~ p
        h += 1
        # puts "honest"
      else
        # puts "ng"
        ng = true
        break
      end
    else
      # puts "unkind"
    end
  end
  next if ng
  ans = [ans, h].max
end

puts ans


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

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

    for(int i = 1; i <= 9; i++) {
        for(int j = 1; j <= 9; j++) {
            if(i * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;

// typedef
typedef pair<int, int> P;
typedef tuple<int, int, int> P3;
typedef vector<vector<int>> Graph;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n), f(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.begin(), f.end(), greater<int>());
    ll worst = 1e12;
    ll ans = worst / 2;
    while (true) {
        ll sum = 0;
        rep(i, n) {
            sum += max((ll)0, a[i] - ans / f[i]);
        }
        if (sum <= k) {
            if (worst == ans) break;
            worst = ans;
            ans /= 2;
        } else {
            if (worst - ans <= 1) break;
            ans = (worst + ans) / 2;
        }
    }
    out(worst);
}


Measured memory_bytes: 3456
N = int(input())
S = input()

l_count = 0
r_count = sum([1 for c in S if c == "."])
count_if_contain_black = l_count+r_count
count_if_all_white = 0
for c in S:
    if c == "#":
        l_count += 1
        count_if_all_white += 1
    else:
        r_count -= 1
        
    count_if_contain_black = min(count_if_contain_black, l_count+r_count)

print(min(count_if_all_white, count_if_contain_black))

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s; cin >> s;
	string t;

	vl a;
	ll cnt = 0;
	FOR(i,0,sz(s)) {
		if (s[i] == 'x') cnt++;
		else a.pb(cnt), t.pb(s[i]), cnt = 0;
	}
	a.pb(cnt);
	
	string u = t;
	reverse(all(u));
	
	if (t != u) {
		cout << -1 << endl;
	} else {
		ll res = 0;
		for (ll i = 0, j = sz(a)-1; i < j; i++, j--) res += abs(a[i]-a[j]);
		cout << res << endl;
	}
}



Measured memory_bytes: 1608
#ifndef LOCAL
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

bitset<17000> dp;

void check(int x, vector<int> vv) {
	int sum = 0;
	for (int i: vv)
		sum += i;
	x += sum;
	for (int i = 0; i < vv.size(); ++i)
		vv[i] *= 2;
	dp.reset();
	dp[0] = 1;
	for (int i: vv)
		dp |= (dp << i);
	if (!dp[x]) {
		cout << "No\n";
		exit(0);
	}
}


string s;
int x, y;

vector<int> vv[2];

int main() {
	cin >> s >> x >> y;
	int cur = 0;
	while (cur < s.size() && s[cur] == 'F')
		--x, ++cur;
	int tp = 0;
	while (cur < s.size()) {
		++cur;
		tp ^= 1;
		int cnt = 0;
		while (cur < s.size() && s[cur] == 'F') {
			++cur;
			++cnt;
		}
		vv[tp].push_back(cnt);
	}
	x = abs(x), y = abs(y);
	check(x, vv[0]);
	check(y, vv[1]);
	cout << "Yes\n";
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=1e7+5,Mod=998244353;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
inline int Fp(int x,int k){int ans=1;for(;k;k>>=1,x=1ll*x*x%Mod)if(k&1)ans=1ll*ans*x%Mod;return ans;}
int n,A,B,Fac[MAXN],iFac[MAXN];ll ans;
inline int C(int n,int m){return n<0||m<0||n<m?0:1ll*Fac[n]*iFac[m]%Mod*iFac[n-m]%Mod;}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),A=read(),B=read();if(!A)return puts("1"),0;
	Fac[0]=1;Rep(i,1,n)Fac[i]=1ll*Fac[i-1]*i%Mod;iFac[n]=Fp(Fac[n],Mod-2);
	Red(i,n,1)iFac[i-1]=1ll*iFac[i]*i%Mod;
	for(int i=0;i<=A&&i+B<n;i++)
		ans+=1ll*(C(i+B-1,B-1)-C(i+B-1,B))*C(A-i+n-B-i-1,n-B-i-1)%Mod;
	if(A+B==n)ans+=C(A+B-1,B-1)-C(A+B-1,B);cout<<(ans%Mod+Mod)%Mod<<'\n';
	return 0;
}




Measured memory_bytes: 81604
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
a=n1()
b=n1()
c=n1()

a.sort()
b.sort()
c.sort()

from bisect import bisect_left,bisect_right
b2=[]
for i in b:
    b2.append(bisect_left(a,i))

import itertools
b3=list(itertools.accumulate(b2))
    
ans=0
for i in c:
    t=bisect_left(b,i)
    if t>0:
        ans+=b3[t-1]
    
print(ans)

Measured memory_bytes: 113124
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
using namespace std;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b&&b == c)cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
from collections import deque
import math
import sys
mod = 10**9+7
N,K = map(int,input().split())

#k
Kperm =[1,K]
pre = K
for i in range(2,K+1):
    pre = (pre*(K+1-i))%mod
    Kperm.append(pre)


#K-2Pxの計算のメモ化
K_2perm =[1,K-2]
pres = K-2
for i in range(2,K-1):
    pres = (pres*(K-1-i))%mod
    K_2perm.append(pres)

child = [[] for i in range(N)]
for hoge in range(N-1):
    a,b = [int(i)-1 for i in input().split()]#点を0-indexedになおす
    child[a].append(b)
    child[b].append(a)

if len(child[0])>=K:
    print(0);sys.exit()
ans = Kperm[len(child[0])+1]
#DFSしながら塗る
went = [False] * N
queue = deque()
queue.append(0)
went[0] = True
while queue:
    cur = queue.pop()
    if cur!=0 and len(child[cur])>=K:
        print(0)
        sys.exit()
    if cur!=0:
        ans *= K_2perm[len(child[cur])-1]
        ans %= mod
    for togo in child[cur]:
        if not went[togo]:
            went[togo] = True
            queue.append(togo)
print(ans)



Measured memory_bytes: 31736
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;


signed main(){
	long double A;
	long double B;
	cin >> A >> B;
	int ans = A*B;
	out(ans);
}

Measured memory_bytes: 3792
#!/usr/bin/env python3
#第5回　ドワンゴからの挑戦状予選 B

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
a = LI()
ans = 0
s = [0] + list(accumulate(a))
lst = []
for i in range(n):
    for j in range(i+1,n+1):
        lst.append(s[j] - s[i])
ans = 0
for b in range(40)[::-1]:
    num = sum([(i>>b)&1 for i in lst])
    if num >= k:
        ans += 1 << b
        lst = [i for i in lst if (i>>b) & 1]
print(ans)


Measured memory_bytes: 88548
#include <bits/stdc++.h> 
using namespace std;
int main()
{
 long long   b,c=1,i;
 cin>>b;
 long long  s=0;
 for(i=0;;i++)
{
if(b==1)
break;	
b=b/2;
s++;	
}
c=pow(2,s+1);
cout<<(c-1)<<endl;
 return 0;
 }


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define NL << endl
using namespace std;
using ll = long long;
const int INFINT = 1 << 30;
const ll INFLL = 1LL << 60;
const int MOD = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a%b) : a;}

int main() {

	int n, k;

	cin >> n >> k;

	int v = 1;
	REP(i, n) {
		if (v < k) {
			v *= 2;
		}
		else {
			v += k;
		}
	}

	cout << v NL;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
 	int n;
  cin >> n;
  	int v[n+5];
  	int c[n+5];
  	int i;
  for ( i=0; i < n; i++)
    cin >> v[i];
  for ( i=0; i < n; i++)
    cin >> c[i];
  ll sum=0;
  for ( i=0; i < n; i++)
  {
    if ( v[i] - c[i] >=0 )
      sum+= v[i] -c[i];
  }
  cout << sum;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <string>
#define SIZE 100005

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

vector <int> vec[SIZE];

int solve(int v=0,int p=-1)
{
	int ret=0;
	for(int i=0;i<vec[v].size();i++)
	{
		int to=vec[v][i];
		if(to!=p)
		{
			ret^=solve(to,v);
		}
	}
	return ret+1;
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);a--;b--;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	int ret=solve();
	if(ret==1) puts("Bob");
	else puts("Alice");
	return 0;
}


Measured memory_bytes: 11904
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <unordered_map>
using namespace std;

class CountOrder
{
public:
	long n;
	string p;
	string q;
	long idx;
	// set<string> st;
	unordered_map<string, int> um;

	CountOrder() {
		cin >> n;
		p = "";
		q = "";
		idx = 1;
		for (long i = 0; i < n; ++i)
		{
			string tmp;
			cin >> tmp;
			p = p + tmp;	 
		}
		for (long i = 0; i < n; ++i)
		{
			string tmp;
			cin >> tmp;
			q = q + tmp;	 
		}
	}
	void exec() {
		string tmp = "";
		for (long i = 1; i < n + 1; ++i)
		{
			tmp = tmp + to_string(i);
		}
		permutation(tmp, "");

		cout << abs(um[p] - um[q]) << endl;

		// auto itr_begin = st.find(p);
		// auto itr_end = st.find(q);
		// long ans = 0;
		// while(itr_begin != st.end()) {
		// 	if(itr_begin == itr_end) {
		// 		cout << ans << endl;
		// 		return;
		// 	}
		// 	ans++;
		// 	itr_begin++;
		// }

		// ans = 0;
		// itr_begin = st.find(p);
		// itr_end = st.find(q);
		// while(itr_begin != st.end()) {
		// 	if(itr_begin == itr_end) {
		// 		cout << ans << endl;
		// 		return;
		// 	}
		// 	ans++;
		// 	itr_begin++;
		// }
	}
	void permutation(string a, string b) {
		if(a.length() <= 1) {
			// cout << b+a << endl;
			um[b+a] = idx;
			idx++;
			// st.insert(b + a);
		} else {
			for (long i = 0; i < a.length() ; ++i)
			{
				CountOrder::permutation(a.substr(0, i) + a.substr(i+1) , b + a[i]);
			}
		}
	}
};


int main(){
	CountOrder co = CountOrder();
	co.exec(); 
}


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


void frog(int *A,int n)
{
    ll t[n+1];
    
    for(int i=1;i<=n;i++)
    {
        if(i==1)
        t[i]=0;
        else if(i>=3){
                t[i]= min( (t[i-1]+abs(A[i]-A[i-1])),
                    (t[i-2]+abs(A[i]-A[i-2])) );
    }
        else t[i]=t[i-1]+abs(A[i]-A[i-1]);
    }
    
    std::cout  <<  t[n];
    
}

int main() {
    int n;
    cin >>n;
    int A[n+1];

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

    frog(A,n);
}

Measured memory_bytes: 4724
N, Y = map(int, input().split())

a = Y - 1000*N
total = 0
x = -1
y = -1
z = -1
for i in range(0, N+1):
    total = i*9000
    if total > a:
        break
    else:
        for j in range(0, N+1-i):
            total = i*9000 + j*4000
            if total > a:
                break
            if total == a:
                x = i
                y = j
                z = N-i-j

print("{} {} {}".format(x,y,z))

Measured memory_bytes: 3064
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int w = sc.nextInt();
			int h = sc.nextInt();
			if (w == 0 && h == 0) {
				break;
			}
			char[][] m = new char[h][];
			for(int i=0;i<h;i++) {
				m[i] = sc.next().toCharArray();
			}
			BigInteger ans = BigInteger.ZERO;
			BigInteger[][] dp = new BigInteger[h][w];
			for(int i=0;i<h;i++) {
				for(int j=0;j<w;j++) {
					dp[i][j] = BigInteger.ZERO;
					if (!Character.isDigit(m[i][j])) {
						continue;
					}
					BigInteger d = BigInteger.valueOf(m[i][j] - '0');
					dp[i][j] = d;
					if (i > 0) {
						dp[i][j] = dp[i][j].max(dp[i-1][j].multiply(BigInteger.TEN).add(d));
					}
					if (j > 0) {
						dp[i][j] = dp[i][j].max(dp[i][j-1].multiply(BigInteger.TEN).add(d));
					}
					ans = ans.max(dp[i][j]);
				}
			}
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 55640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
  
namespace ConsoleApplication1
{   
    class Program
    {
         static void Main(string[] args) {
           while(true){int g =0;
            string a =Console.ReadLine();
            if(a==null)break;
            int b =int.Parse(a);
            for(int e=2;b>=e;e++){
                bool f=false;
                int h =(int)(Math.Sqrt((double)e));
                if(e%2==0 && e>2)f=true;
                for(int d=3;d<=h;d+=2){  
                    if(e%d==0)f=true;
                    if(f)break;
                }
                if(f==false)g++;
            }
            Console.WriteLine(g);
           }
        }
    }
   }


Measured memory_bytes: 15892
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace ConsoleApplication2
{

    class Program
    {
        static void Main(string[] args)
        {

            string[] input = Console.ReadLine().Split(' ');
            int num1,num2;
            int result;

            num1 = int.Parse(input[0]);
            num2 = int.Parse(input[1]);

            result = num1 * num2;

            Console.WriteLine(result);
            

        }
    }
}


Measured memory_bytes: 17840
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main() {
	int A, B;
	int count = 0;
	int output = 1;
	cin >> A >> B;
	while (output < B) {
		output += A - 1;
		count++;
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define int ll
#define INF 999999999
//#define INF (1LL<<59)

int data[1010][1010];
int dp[1010][1010];

int h,w,n;

void move(int y,int x){
	if(y==h||x==w) cout<<y+1<<" "<<x+1<<endl;
	
	if(data[y][x]==0)move(y+1,x);
	if(data[y][x]==1)move(y,x+1);
}


signed main(){
	while(cin>>h>>w>>n&&(h||w||n)){
		
		rep(i,1010)rep(j,1010)data[i][j]=-1;
		rep(i,h){
			rep(j,w){
				cin>>data[i][j];
			}
		}
		
		
		rep(i,1010)rep(j,1010)dp[i][j]=0;
		dp[0][0] = n-1;
		
		rep(i,h){
			rep(j,w){
				int d=dp[i][j]/2, r=dp[i][j]/2;
				if(data[i][j]==0) d+=dp[i][j]%2;
				if(data[i][j]==1) r+=dp[i][j]%2;

				dp[i+1][j] += d;
				dp[i][j+1] += r;
			}
		}
		
		rep(i,h){
			rep(j,w){
				if(dp[i][j]%2==1) data[i][j] = !data[i][j];
			}
		}
		
		
		move(0,0);
	}
}

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

using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

long long firsttime[100010]={};
long long sums[100010];
void solve(long long N, long long X, long long M){
  long long A=X;
  firsttime[A]=1;
  sums[0]=0;
  sums[1]=A;
  long long K=min(N,100010LL);
  long long i=2;
  for(;i<=K;i++){
    A=(A*A)%M;
    sums[i]=sums[i-1]+A;
    if(firsttime[A]!=0){
      break;
    }
    firsttime[A]=i;
  }
  if (i==N+1){
    cout<<sums[N]<<endl;
    return;
  }
  long long loop_begin=firsttime[A];
  long long loop_length=i-loop_begin;
  long long loop_count=(N-(loop_begin-1))/loop_length;
  //cout<<i<<" "<<A<<" "<<loop_length<<" "<<loop_count<<endl;
  //cout<<sums[i]-sums[loop_begin]<<endl;
  long long result=(sums[i]-sums[loop_begin])*loop_count;
  long long j=N-loop_length*loop_count;
  //cout<<j<<endl;
  result+=sums[j];
  cout<<result<<endl;
}

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


Measured memory_bytes: 4856
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		int t = fs.nextInt();
		ArrayList<Meshi> meshiList = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			int time = fs.nextInt();
			int umasa = fs.nextInt();
			
			meshiList.add(new Meshi(umasa,time));
		}
		Comparator<Meshi> meshiComparator = Comparator.comparing(Meshi::getTime);
		meshiList.sort(meshiComparator);
		int cumulative = 0;
		int[] manzokuArr = new int[100000];
		for(int i = 0; i < n; i++) {
			Meshi meshi = meshiList.get(i);
			for(int j = Math.min(cumulative, t-1); j >= 1 ; j--) {
				if(manzokuArr[j] > 0) {
//					System.out.println(j);
					manzokuArr[j+meshi.time] = Math.max(manzokuArr[j+meshi.time], manzokuArr[j] +meshi.umasa);
				}
			}
			manzokuArr[meshi.time] = Math.max(manzokuArr[meshi.time], meshi.umasa);
			cumulative = Math.min(t-1, cumulative+meshi.time);
		}
		
		int ans = 0;
		for(int i = 0; i < 100000;i++) {
			ans = Math.max(ans, manzokuArr[i]);
		}
		System.out.println(ans);
	}

	class Meshi {
		int umasa;
		int time;
		Meshi(int umasa, int time){
			this.umasa = umasa;
			this.time = time;
		}
		int getTime() {
			return time;
		}
	}
	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  if (A == B && B != C) {
    cout << C << endl;
  } else if (A == C && A != B) {
    cout << B << endl;
  } else if (B == C && B != A) {
    cout << A << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i;
	string s,ans;
	cin>>s;
	for(i=0;i<s.size();i++)
	{
		if(s[i]=='?')ans+='D';
		else ans+=s[i];
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3920
#include<bits/stdc++.h>
using namespace std;
int x[101],y[101],h[101];
int main()
{
	int n,k;
	int i,j;
	int xc,yc;
	int hh; 
	cin>>n;
	for(i=1;i<=n;i++){
	 cin>>x[i]>>y[i]>>h[i];
} 
	int t;
	for(i=1;i<=n;i++) if(h[i]!=0) break;
	t=i;
	for(xc=0;xc<=100;xc++)
	for(yc=0;yc<=100;yc++){
		bool f=1;
		hh=h[t]+abs(x[t]-xc)+abs(y[t]-yc);
		for(i=1;i<=n;i++){
			if(h[i]==0){
				if(hh-(abs(x[i]-xc)+abs(y[i]-yc))>0){
					f=0;break;
				}
			}
			else if(h[i]!=hh-(abs(x[i]-xc)+abs(y[i]-yc))){
				f=0;break;
			}
		}
		if(f){
			cout<<xc<<" "<<yc<<" "<<hh<<endl;
			return 0;
		}
	}
	
}
	

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

int t[100005];

int main()
{
	int N,c,k;
	
	cin>>N>>c>>k;
	
	int i;
	for (i=1;i<=N;i++)
	cin>>t[i];
	
	sort(t+1,t+N+1);
	
	int f=1,start=t[1],cap=0;
	
	for (i=1;i<=N;i++)
	{
		if(t[i]-start>k)
		{
			f++;
			start=t[i];
			cap=1;
		}
		
		else if(cap==c)
		{
			f++;
			start=t[i];
			cap=1;
		}
		
		else cap++;
	}
	
	cout<<f;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int> >;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll W,H,x,y;
cin>>W>>H>>x>>y;
double ans_S=(double)(W)*H/2.0;
int multi=0;
if(x*2==W && y*2==H){
    multi=1;
}
cout<<fixed<<setprecision(10)<<ans_S<<" "<<multi<<endl;
//system("pause");
return 0;
}

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

int main()
{
    int n,m[5],l;
    cin>>n;
    l=n;
    for(int i=0;i<5;i++){
        m[i]=l%10;
        l=l/10;
    }
    if(n==10||n==100||n==1000||n==10000||n==100000){
        m[0]=10; m[1]=0; m[2]=0; m[3]=0; m[4]=0;
    }
    cout<<m[0]+m[1]+m[2]+m[3]+m[4]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstring>

using namespace std;

string s1,s2;
int l[1010][1010];
bool flag[1010][1010];

int L(int i,int j){
	//cout<<i<<" "<<j<<endl;
	if(i<0||j<0){
		return 0;
	}
	else if(s1.at(i)==s2.at(j)){
		if(!flag[i][j]){
			l[i][j]=1+L(i-1,j-1);
			flag[i][j]=true;
		}
		return l[i][j];
	}
	else{
		if(!flag[i][j]){
			int a=L(i,j-1);
			int b=L(i-1,j);
			l[i][j]=a>b?a:b;
			flag[i][j]=true;
		}
		return l[i][j];
	}
}

int main(){
	int q;
	cin>>q;
	for(int i=0; i<q; i++){
		cin>>s1>>s2;
		for(int j=0; j<1010; j++){
			for(int k=0; k<1010; k++){
				flag[j][k]=false;
			}
		}

		cout<<L(s1.size()-1,s2.size()-1)<<endl;
	}
}

Measured memory_bytes: 6236
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 62;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, K;
	cin >> N >> K;

	vector<vector<Int>> xy(N, vector<Int>(2));
	vector<Int> x(N);
	vector<Int> y(N);

	for (Int i = 0; i < N; i++) {
		cin >> xy[i][0] >> xy[i][1];
		x[i] = xy[i][0];
		y[i] = xy[i][1];
	}


	sort(x.begin(), x.end());
	sort(y.begin(), y.end());

	Int ans = INF;
	Int cnt;
	Int xmin, xmax, ymin, ymax;
	Int S;
	for (Int i = 0; i < N; i++) {//x一つ目
		for (Int j = i+1; j < N; j++) {//x二つ目
			//if (i == j)continue;
			xmin = x[i];
			xmax = x[j];


			for (Int k = 0; k < N; k++) {//y一つ目
				for (Int m = k+1; m < N; m++) {//y二つ目
					//if (k == m)continue;


					ymin = y[k];
					ymax = y[m];

					cnt = 0;
					for (Int n = 0; n < N; n++) {
						if (xy[n][0] >= xmin && xy[n][0] <= xmax && xy[n][1] >= ymin && xy[n][1] <= ymax) {
							cnt++;
						}
					}

					if (cnt >= K) {
						S = (xmax - xmin) * (ymax - ymin);
						ans = min(ans, S);
					}

				}
			}

		}
	}

	cout << ans << "\n";
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(b-a==c-b)puts("YES");
    else puts("NO");
}


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

using namespace std;

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  
  for(int i=0;i<n;i++){
     cin>>a[i];
  }
  int x=0;
  for(int i=0;i<n;i++){
    x+=a[i]-1;
  }  
  cout<<x<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int p, q, r;
    cin >> p >> q >> r;
    
    int pq=p+q, qr=q+r, rp=r+p, min=300;
    if(min>pq) min = pq;
    if(min>qr) min = qr;
    if(min>rp) min = rp;
    
    cout << min << endl;

    return 0;
    
}

Measured memory_bytes: 256
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 100001, MD = 1000000007;

int pp[N];

int main() {
	string s; cin >> s;
	int n = s.length();
	for (int p = 1, i = 0; i < n; i++, p = p * 3LL % MD)
		pp[i] = p;
	long long ans = 0, cnt = 1;
	for (int i = 0; i < n; i++)
		if (s[i] == '1') {
			ans = (ans + cnt * pp[n - 1 - i]) % MD;
			cnt = cnt * 2 % MD;
		}
	ans = (ans + cnt) % MD;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 4048
import numpy as np

n,m=map(int,input().split())
a=[]
for _ in range(n):
	a.append([int(i) for i in input().split()])
b=np.array(a).T

x0=[1,1,1,1,-1,-1,-1,-1]
x1=[1,1,-1,-1,1,1,-1,-1]
x2=[1,-1,1,-1,1,-1,1,-1]

ans=0
if m>0:
	for i in range(8):
		t=np.sum(sorted(x0[i]*b[0]+x1[i]*b[1]+x2[i]*b[2])[-m:])
		if ans<t:
			ans=t
print(ans)


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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)

ll N,M;
ll A[100005];
ll s[100005];
map<ll,ll> mp;
ll ans;

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N>>M;

rep(i,N){
	cin>>A[i];
}

s[0]=A[0];
rep(i,N){
	if(i==0) continue;
	s[i]=s[i-1]+A[i];
}

rep(i,N){
	ll rem=s[i]%M;
	if(rem==0){
		ans++;
	}
	ans+=mp[rem];
	mp[rem]++;
}

cout<<ans<<endl;

}
	


Measured memory_bytes: 5760
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int n;
	cin>>n;
	while(n){
		int a=n%10;
		if(a==7){
			cout<<"Yes"<<endl;
			return 0;
		}
		n/=10;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  string s;cin>>s;
  int cnt[2][2]={0};
  for(int i=0;i<s.size();i++){
    char c=s[i];
    cnt[i%2][c-'0']++;
  }
  int ans=min(cnt[0][0]+cnt[1][1],cnt[1][0]+cnt[0][1]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

#define mod 1000000007;

long long nikou(int n, int r);

long long c[2001][2001];
int done[2001][2001]={};

int main(void){
  int i, j;
  int n,k;
  long long b_wake;
  long long r_wake;
  long long ans;

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

  for(i=1; i<=k; i++){
    ans=0;
    b_wake=0;
    r_wake=0;
    if(i==1){
      ans=(n-k+1)%mod;
    }else{
      if(k-i<0){
        ans=0;
      }else{
        //bの分け方 k-1Ci-1
        b_wake=nikou(k-1,i-1)%mod;
        //rの分け方
        for(j=i-1; j<=i+1; j++){
          //j=i-1 赤が両端にない
          //j=i 赤が右端のみまたは左端のみにある
          //j=i+1 赤が両端にある
          if(n-k<j) break;
          if(j==i){
            r_wake+=2*nikou(n-k-1,j-1)%mod
          }else{
            r_wake+=nikou(n-k-1,j-1)%mod;
          }
        }
        ans=(b_wake*r_wake)%mod;
      }
    }
    printf("%lld\n", ans);
  }

  return 0;
}

long long nikou(int n, int r){
  // printf("nikou(%d,%d)\n", n,r);
  if(done[n][r]==1) return c[n][r];
  if(r>n){
    done[n][r]=1;
    return c[n][r]=1;
  }

  if(n==0||r==0){
    done[n][r]=1;
    return c[n][r]=1;
  }
  if(r==n){
    done[n][r]=1;
    return c[n][r]=1;
  }

  c[n][r]=(nikou(n-1,r)+nikou(n-1,r-1))%mod;
  done[n][r]=1;
  return c[n][r];
}


Measured memory_bytes: 46336
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int max=a[0];
  int count=0;
  for(int i=0;i<n;i++){
    if(a[i]>=max){
      count++;
      max=a[i];
    }
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
typedef unsigned long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/***********************************************************************/

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n; cin >> n;
  vector<int> b(n - 1);
  for (int &z : b) cin >> z;
  int ans = b[0] + b[n - 2];
  for (int i = 0; i < n - 2; ++i) {
    ans += min(b[i], b[i + 1]);
  }
  kek(ans);
  
}


Measured memory_bytes: 256
import sys
from bisect import bisect_left
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    X = list(map(int, input().split()))
    Y = [(x, i) for i, x in enumerate(X)]
    Y.sort()

    for i, x in enumerate(X):
        idx = bisect_left(Y, (x, i))
        if idx < N // 2:
            print(Y[N//2][0])
        else:
            print(Y[N//2-1][0])


if __name__ == "__main__":
    main()


Measured memory_bytes: 104884