akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

//wierd debugging stuff
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n" ; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//end of weird debugging stuff
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
 
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define fo(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define foe(i,x) for(auto& i: x)
#define ar array
#define pb push_back
#define vt vector
#define F first
#define S second

template<class T> bool umin(T& a,const T& b){return b<a?a=b,1:0;}
template<class T> bool umax(T& a,const T& b){return b>a?a=b,1:0;}

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {cin>>x;}
void read(double& d) {string t;read(t);	d=stod(t);}
void read(long double& d) {	string t;read(t);d=stold(t);}
template<class H, class... T> void read(H& h, T&... t) {read(h);read(t...);}
template<class A> void read(vt<A>& x) {	foe(a, x)read(a);}
int nxt(){int a;read(a);return a;}   // iota(all(v),0); genrate(all(v),nxt);

// no change 
const ll MOD = 1e9+7;  
int mx = 1e6+1;
void Titan(){
	char a,b;
	cin >> a >> b;
	cout << (a^b ? "D" : "H");
}

	

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int T = 1;
	//cin >> T;		//cmt if one test case
    fo(T){
		//cout << "Case #" << i+1 << ": " ;
		Titan();
	}
}
/*///////////////////////////////////////////////////////////
Important Notes : 
* check long long 
* check base cases
* do not loose Hope
* if case fails on 2nd test case maybe some cases are missing check them
* do not sit idle
* try to do it using pen/paper.
*/


Measured memory_bytes: 3640
n, k = gets.split.map(&:to_i)
s = gets.chomp

ans = 0
c_l2r = 0
c_r2l = 0
n.times do |i|
    if s[i] == "R"
        next if i == n - 1
        ans += 1 if s[i+1] == "R"
    else
        next if i == 0
        ans += 1 if s[i-1] == "L"
    end
end

n.times do |i|
    next if i == 0
    if s[i] != s[i-1]
        if s[i] == "R"
            c_l2r += 1 
        else 
            c_r2l += 1 
        end
    end
end


if c_l2r > c_r2l
    c_l2r, c_r2l = c_r2l, c_l2r
end

ans += 2*[k, c_l2r].min
k -= c_l2r
if k > 0 and c_r2l > c_l2r
    ans += 1
end

puts ans

Measured memory_bytes: 14628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Map.Entry;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			long t = in.nextLong();
			List<Long> list = new ArrayList<Long>();
			long total = 0;
			for (int i = 0; i < n; i++) {
				list.add(in.nextLong());
			}
			for (int i = 0; i < n - 1; i++) {
				long present = list.get(i + 1);
				long prev = list.get(i);
				if (prev + t > present) {
					total += present - prev;
				} else {
					total += t;
				}
			}
			total += t;
			out.println(total);
		}
	}

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

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = 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 char nextChar() {
			return next().charAt(0);
		}

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

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

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

	}
}


Measured memory_bytes: 55044
# -*- coding: utf-8 -*-
import sys
from collections import deque,defaultdict

H,W=map(int, sys.stdin.readline().split())
A=[ map(int, sys.stdin.readline().split()) for _ in range(H) ]
B=[ map(int, sys.stdin.readline().split()) for _ in range(H) ]

for h in range(H):
    for w in range(W):
        A[h][w]=abs(A[h][w]-B[h][w])

dp=[ [ 0 for _ in range(W) ] for __ in range(H) ]

Center=80*80      #中心地のセット マイナスの値もセットできるようにbitsetのゼロを80*80+1桁目に置く

#初期化
r,c=0,0
val=A[r][c]
dp[r][c]=1<<val+Center

q=deque()
q.append((0,0))
D=[(1,0),(0,1)]
Visit=defaultdict(lambda: 0)     #訪問済みの頂点にフラグ1を立てる
Visit[(0,0)]=1
D=[(1,0),(0,1)]

for r in range(H):
    for c in range(W):
        for dr,dc in D: #横に1つ移動か、下に1つ移動
            if r+dr<H and c+dc<W:   #移動しようとするマスが存在するならばif文内の処理を行う
                next_r=r+dr
                next_c=c+dc
                next_val=A[next_r][next_c]
                dp[next_r][next_c]|=dp[r][c]<<next_val  #次のマスの値が+の場合は、bitshift全体を左にシフト
                dp[next_r][next_c]|=dp[r][c]>>next_val  #次のマスの値が-の場合は、bitshift全体を右にシフト
                q.append((next_r,next_c))

ans=float("inf")
for i in range(Center*2):
    bit=dp[H-1][W-1]>>i&1
    if bit==1:
        ans=min(ans,abs(i-Center))

print ans


Measured memory_bytes: 44956
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	a, b       int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func GCD(a, b int) int {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func LCM(a, b int) int {
	return a * b / GCD(a, b)
}

type P struct {
	l, r int
}

func main() {
	var N int
	fmt.Scanf("%d\n", &N)

	P := make([]int, N)
	for i := 0; i < N; i++ {
		var n int
		fmt.Scan(&n)
		P[i] = n
	}
	cnt := 0
	for i := 1; i < N-1; i++ {
		prev, curr, next := P[i-1], P[i], P[i+1]
		if (curr > next && prev > curr) || (curr > prev && curr < next) {
			cnt++
		}
	}

	fmt.Println(cnt)
}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  long N = s.size(),num = 0;
  for (long i = 0; i < N; i++) {
    if (s[i] == '0') {
      num++;
    }
  }
  cout << 2*min(num,N-num) << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const int MAXN=1e5+5;
int a[MAXN];
int G[105][105];

int main()
{
    int h,w;
    while(scanf("%d%d",&h,&w)!=EOF)
    {
        int n;
        cin>>n;
        for(int i=1;i<=n;++i)
            scanf("%d",&a[i]);
        int cnt=1;
        for(int i=1;i<=h;++i)
        {
            if(i&1)
            {
                for(int j=1;j<=w;++j)
                {
                   if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                   else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }else
            {
                for(int j=w;j>=1;--j)
                {
                    if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                    else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }
        }
        for(int i=1;i<=h;++i)
        {
            for(int j=1;j<=w;++j)
            {
                if(j!=w) printf("%d ",G[i][j]);
                else printf("%d\n",G[i][j]);
            }
        }
    }
    return 0;
}


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

const int INF = 1e9;

int main() {
  int n;
  cin>>n;
  if (n == 1) {
    cout<<"Hello World"<<endl;
    return 0;
  }
  int a, b;
  cin>>a>>b;
  cout<<a+b<<endl;

}

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

int main() {
  int n;
  string s, t;
  cin >> n >> s >> t;
  for (int i = 0; i < n; i++) {
    cout << s.at(i) << t.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
int main() 
{ 
   
   
   ll n,sum=0;
   cin>>n;
   map<ll,ll>mp;
   for(int i=0;i<n;i++) {
       ll b;
       cin>>b;
       ++mp[b];
       sum+=b;
   }
   
   int q;
   cin>>q;
   while(q--) {
       ll b,c;
       cin>>b>>c;
       sum-=(mp[b]*b);
       sum+=(mp[b]*c);
       mp[c]+=mp[b];
       mp[b]=0;
       cout<<sum<<'\n';
   }
	return 0; 
} 


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

int main() {

	string s; cin >> s;
	vector<string> c = { "Sunny", "Cloudy", "Rainy" };
	if (s == c[0]) s = c[1];
	else if (s == c[1]) s = c[2];
	else s = c[0];
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3476
n,m=map(int,input().split())
k=[]
c=list(range(1,m+1))
for i in range(n):
    a=list(map(int,input().split()))
    a.pop(0)
    k.append(a)
for i in range(1,m+1):
    cnt=0
    for j in range(n):
        if k[j].count(i)>0:
            cnt+=1
    if cnt!=n:
        c.remove(i)
print(len(c))

    


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

map<int, Pa> mp;
int sum[90001];
int main()
{
	cin >> H >> W >> D;
	rep(i, H) {
		rep(j, W) {
			cin >> A; A--;
			mp[A] = Pa(i, j);
		}
	}
	rep(i, D) {
		sum[i] = 0;
	}
	for (int i = D; i < H * W; i++) {
		sum[i] += sum[i - D] + abs(mp[i].first - mp[i - D].first) + abs(mp[i].second - mp[i - D].second);
	}
	vector<int> ans;
	cin >> Q;
	rep(i, Q) {
		cin >> A >> B; A--; B--;
		ans.push_back(sum[B] - sum[A]);
	}
	rep(i, Q) {
		cout << ans[i] << endl;
	}
}


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

void lift(int u, vector<int> &e, vector<list<int>> &nei, vector<vector<int>> &c, vector<vector<int>> &f, vector<int> &h, int n) {
	int height = 2 * n;
	for (auto it = nei[u].begin(); it != nei[u].end(); it++)
		if (c[u][*it] > f[u][*it])
			height = min(height, h[*it]);
	h[u] = height + 1;
}

void push(int u, int v, vector<vector<int>> &c, vector<vector<int>> &f, vector<int> &e) {
	int d = min(c[u][v] - f[u][v], e[u]);
	f[u][v] += d;
	f[v][u] = -f[u][v];
	e[u] -= d;
	e[v] += d;
}

bool discharge(int u, vector<int> &e, vector<list<int>::iterator> &current, vector<list<int>> &nei, vector<vector<int>> &c, vector<vector<int>> &f, vector<int> &h, int n) {
	bool lifted = false;

	while (e[u] > 0) {
		if (current[u] == nei[u].end()) {
			lift(u, e, nei, c, f, h, n);
			lifted = true;
			current[u] = nei[u].begin();
			continue;
		}
		int v = *current[u];
		if (c[u][v] > f[u][v] && h[u] == h[v] + 1)
			push(u, v, c, f, e);
		else
			current[u]++;
	}

	return lifted;
}

int ltf(int n, vector<vector<int>> c) {
	int u, v;
	vector<list<int>> nei(n);
	vector<list<int>::iterator> current(n);
	for (u = 0; u < n; ++u) {
		for (v = 0; v < n; ++v)
			if (c[u][v] > 0 || c[v][u] > 0)
				nei[u].push_back(v);
		current[u] = nei[u].begin();
	}

	vector<int> h(n, 0), e(n, 0);
	vector<vector<int>> f(n, vector<int>(n, 0));
	h[0] = n;
	for (u = 0; u < n; ++u)
		if (c[0][u] > 0) {
			e[u] = c[0][u];
			f[0][u] = c[0][u];
			f[u][0] = -f[0][u];
		}

	list<int> theList;
	for (u = 1; u < n - 1; ++u)
		theList.push_back(u);
	auto cur = theList.begin();
	while (cur != theList.end()) {
		u = *cur;
		if (discharge(u, e, current, nei, c, f, h, n)) {
			theList.erase(cur);
			cur = theList.insert(theList.begin(), u);
		}
		cur++;
	}
	return e[n - 1];
}

int main() {
	int n, edgeCount;
	ifstream in("input.txt");
	cin >> n >> edgeCount;
    
	vector<vector<int>> c(n, vector<int>(n, 0));
	for (int a = 0; a < edgeCount; ++a) {
		int i, j;
		cin >> i >> j;
		cin >> c[i][j];
	}

	int result = ltf(n, c);

	cout << result << endl;

	return 0;
}




Measured memory_bytes: 3292
// Indrajeet Mishra

/*#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define test(s) if (!(s)) { cout << __LINE__ << " " << #s << endl; exit(-1); }
#define debug(x) do { std::cerr << x; } while (0)
#define endl "\n"
#define pb push_back
#define pf push_front
#define vll vector<ll>
#define dll deque<ll>
#define sll set<ll, greater <ll>>
#define mll map<ll, ll>
#define vii vector<int>
#define dii deque<int>
#define sii set <int, greater <int>>
#define mii map<int, int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define inv2 500000004
#define inv6 166666668
#define N 1000005
#define inf 200000000
#define eps 1e-10
#define PI 3.14159265359
#define all(v) (v).begin(),(v).end()
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define gcd(a,b) __gcd(a,b)

ll dp[100001];
void Indrajeet(){
    memset(dp,-1,sizeof(dp));
}

ll min_cost(ll a[], ll n){
    if(n==2)
    return abs(a[1]-a[0]);
    if(n==1)return 0;
    if(dp[n]!=-1)return dp[n];
    return dp[n]=min((abs(a[n-1]-a[n-2])+min_cost(a,n-1)),(abs(a[n-1]-a[n-3])+min_cost(a,n-2)));
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    Indrajeet();
    ll n=0;cin>>n;
    ll h[n]={0};
    rep(i,0,n){
        cin>>h[i];
    }
    cout<<min_cost(h,n);
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> z(100002);
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        z[a]++;
        z[a+1]++;
        z[a+2]++;
    }
    int m = *max_element(z.begin(),z.end());
    cout << m;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, y, r, p;
string s, t;
// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n;
	set<ll> val;
	for(ll i=0;i<n;i++) {
		cin>>x;
		val.insert(x);
	}
	cout<<val.size();
}

int main() {
	fastio; randomINT;
	//cin>>t;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 238000
#include<stdio.h>
  
void visit(int);
int map[101][101];
int f[101],d[101],color[101];
int n,time;
  
void visit(int u)
{
  int i;
  color[u]=1;
  d[u]=++time;
  for(i=0;i<n;i++){
    if(map[u][i]==1){
      if(color[i]==0)visit(i);
    }
  }
  color[u]=2;
  f[u]=++time;
}
 
int main()
{
  int i,j,k,v,v2;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    color[i]=0;
    for(j=0;j<n;j++){
      map[i][j]=0;
    }
  }
  time=0;
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v2);
      map[v-1][v2-1]=1;
    }
  }
  for(i=0;i<n;i++){
    if(color[i]==0)visit(i);
  }
  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
  return 0;
}

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

 using namespace std;

 int main() {
   int N, X, i;

   cin >> N >> X;

   vector<int> m(N);

   for (i = 0; i < N; i++) cin >> m.at(i);

   int minm = 1000;
   int sum = 0;
   for (i = 0; i < N; i++) {
     minm = min(minm, m.at(i));
     sum += m.at(i);
   }

   cout << N + (X - sum) / minm << endl;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> a(m), b(m), c(m);
    rep(i, m) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--, b[i]--;
        c[i] = -c[i];
    }

    vector<ll> dist(n, 1e18);
    dist[0] = 0;
    rep(loop, n - 1) {
        rep(i, m) {
            if (dist[a[i]] == 1e18) continue;
            if (dist[b[i]] > dist[a[i]] + c[i]) {
                dist[b[i]] = dist[a[i]] + c[i];
            }
        }
    }

    ll ans = dist[n - 1];

    vector<bool> neg(n, false);
    rep(loop, n) {
        rep(i, m) {
            if (dist[a[i]] == 1e18) continue;
            if (dist[b[i]] > dist[a[i]] + c[i]) {
                dist[b[i]] = dist[a[i]] + c[i];
                neg[b[i]] = true;
            }
            if (neg[a[i]] == true) {
                neg[b[i]] = true;
            }
        }
    }
    if (neg[n - 1]) puts("inf");
    else
        cout << -ans << endl;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

struct Mobil{
  int p,q,r,b;
  Mobil(){}
  Mobil(int p, int q, int r, int b):p(p),q(q),r(r),b(b){}
};

typedef long long ll;

int N;
int in[128];
Mobil mb[128];

ll rec(int v){
  ll res = 0, r=0,b=0,rw=1,bw=1;
  Mobil m = mb[v];
  if(m.r){ rw = rec(m.r); r = m.p*rw; }
  else r = m.p;
  if(m.b){ bw = rec(m.b); b = m.q*bw;}
  else b = m.q;
  ll lcm = r*b/__gcd(r,b);
  //  printf("%d\n", v);
  ///  printf("%lld\n", lcm);
  //  printf("%lld %lld %lld %lld\n", rw, r, bw, b);
  res += rw*lcm/r;
  res += bw*lcm/b;
  return res;
}

int main(){
  while(scanf("%d", &N) && N){
    memset(in, 0, sizeof in);
    for(int i=1;i<=N;i++){
      int p,q,r,b; scanf("%d%d%d%d",&p,&q,&r,&b);
      mb[i] = Mobil(p,q,r,b);
      in[r] = in[b] = 1;
    }

    int s = -1;
    for(int i=1;i<=N;i++) if(!in[i]) s = i;
    printf("%d\n", rec(s));
  }
  return 0;
}

Measured memory_bytes: 1028
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int cnt = 0;
        while(num != 0){
            if(num%10 == 1){cnt++ ;}
            num = num/10;
        }
        System.out.println(cnt+"\n");
    }
}

Measured memory_bytes: 22740
#define PROB ChangingChange

#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
#define rep(i, l, r) for (int i = l; i<r;i++)
#define all(b) b.begin() , b.end()
#define mp(a, b) make_pair(a,b)
#define pb(a) push_back(a)
#define vi vector<int>
#define vd vector<double>
#define vs vector<string>
#define vii vector<pair<int,int>>
#define vvi vector<vector<int>>
#define ii pair<int,int>
#define turnOff(k, i) (k&(~(1<<(i-1))))
#define isOn(k, i) (k&&(1<<i-1)?true:false)
#define pll pair<long long int , long long int>
#define ull unsigned long long int
#define ll  long long int
#ifdef  DEBUG
#define MAXN 105
#else
#define MAXN 5000020
#endif
#define MAXLG 20
#define endl '\n'
#define PI 3.141592653589793238
#define MOD (1000000007l)
#define INF (1000)
#define EPS (0.00000001)
#define treap treapNode*
int gcd(int a, int b) {
    while (a != 0) {
        int c = a;
        a = b % a;
        b = c;
    }
    return b;
}




class PROB {
public:



};
struct t {int coins,type,num;};


bool comp(t a,t b){return a.coins < b.coins;}
int main() {
    PROB temp;
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifdef DEBUG
    freopen("input", "r", stdin);
#endif
    int n,k;
    cin>>n>>k;
    vi arr;
    rep (i,0,n) {
        int x;
        cin>>x;
        arr.pb(x);
    }
    sort(all(arr));
    int gcd_ = arr[0];
    rep (i,0,n) {
        gcd_ = gcd(gcd_, arr[i]);
    }

    if ( k<= arr[n-1] && k%gcd_== 0)cout<<"POSSIBLE";
    else cout<<"IMPOSSIBLE";


    return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
main(){
    int n;
    scanf("%d" , &n);
    int arr[n+100];
    for(int  i = 0 ; i< n ; i++){
        scanf("%d" , &arr[i]);
    }
    int cnt =0;
    for(int  i = 0 ; i< n ; i++){
        if(i !=0 && i !=n-1)
        if((arr[i] <arr[i+1] && arr[i]>arr[i-1]) || (arr[i] >arr[i+1] && arr[i]<arr[i-1]))
            cnt++;
    }
    printf("%d" , cnt);

}


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

N,Q = inpl()

lines = defaultdict(set)
for _ in range(N-1):
    a,b = inpl()
    a,b = a-1,b-1
    lines[a].add(b)
    lines[b].add(a)

adds = [0]*N
for _ in range(Q):
    p,x = inpl()
    adds[p-1] += x

visited = [False]*N
ans = [0]*N

q = queue.LifoQueue()
q.put([0,0])

while not q.empty():
    x,cnt = q.get()
    visited[x] = True
    cnt += adds[x]
    ans[x] += cnt
    for t in lines[x]:
        if not visited[t]:
            q.put([t,cnt])

print(' '.join(map(str,ans)))


Measured memory_bytes: 156400
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <string>
#define int long long
#define REP(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define mp make_pair
#define Pii pair< int, int > 
#define Pid pair< int, double > 
#define Pdd pair< double, double > 
#define MOD 1000000007
#define EPS 0.00000001
using namespace std;

using Graph = vector<vector<Pii > >;

vector<bool> seen;
vector<int> color;
bool ok = true;

signed main() {
    int n,k;
    cin >> n >> k;
    vector<int> a;
    REP(i,n) {
        int at;
        cin >> at;
        a.push_back(at);
    }
    while (k > 0) {
        if (*min_element(a.begin(), a.end()) != n) {
            vector<int> b(n+1);
            REP(i,n) {
                b[max(0LL,i-a[i])] ++;
                b[min(n,i+a[i]+1)] --;
            }
            a[0] = b[0];
            REP(i,n-1) {
                int j=i+1;
                b[j] += b[j-1];
                a[j] = b[j];
            }
        } else {
            break;
        }
        k--;
    }
    REP(i,n) {
        cout << a[i] << " ";
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 6404
#include<bits/stdc++.h>
#define rep(i,k,n) for(ll i= (ll) k;i< (ll) n;i++)
#define all(v) (v).begin(), (v).end()
#define SZ(v) (int)((v).size())
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF = 1e18L + 1;
const int IINF = 1e9 + 1;

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define DBG(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const ll N = 1e5, mod = 1e9 + 7;

ll n, a[N + 1];

ll int_pow(ll base, ll exp){
	if(exp == 0){
		return 1ll;
	} else if(exp & 1){
		return base * int_pow(base * base % mod, exp >> 1) % mod;
	} else {
		return int_pow(base * base % mod, exp >> 1);
	}
}

int main()
{
#ifndef LOCAL
	ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
 	cin >> n;
	rep(i, 0, n){
		cin >> a[i];
	}
	ll mlt = 0, res = 0;
	rep(i, 1, n + 1){
		mlt = (mlt + int_pow(i, mod - 2)) % mod;
	}
  	rep(i, 0, n){
		res = (res + mlt * a[i]) % mod;
		mlt = (mod + mlt + int_pow(i + 2, mod - 2) - int_pow(n - i, mod - 2)) % mod;
	}
	rep(i, 1, n + 1){
		res = (res * i) % mod;
	}
	cout << res << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll min_v = 0;
  cout << min(A, B) << " " << max(0LL, A + B - N) << endl;
  return 0;
}

Measured memory_bytes: 3524
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;

    int X = 10 * A + B + C;
    int Y = 10 * B + C + A;
    int Z = 10 * C + A + B;

    cout << max(X, max(Y, Z)) << endl;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int m,d,ans=0;
int main(void){
	cin>>m>>d;
	if(m<4||d<22){cout<<0;return 0;}
	for(int i=4;i<=m&&i<=81;i++)
		for(int j=22;j<=d;j++)
			if(j/10>=2&&j%10>=2&&(j/10)*(j%10)==i){
				ans++;
//				cout<<i<<'-'<<j<<endl;
			}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define oo 666666666

ll DP[1001][20001];
int done[1001][20001];
vector<array<ll,4>>A;//[w+s][val][weight][cap]
ll n;

ll solve(int pos, int cap)
{
    if(cap ==0 || pos >= n)return 0;
    if(done[pos][cap])return DP[pos][cap];

    done[pos][cap]=1;
    if(A[pos][2] <= cap)DP[pos][cap] = A[pos][1] + solve(pos+1, min(cap-A[pos][2], A[pos][3]));
    DP[pos][cap]=max(DP[pos][cap], solve(pos+1,cap));
    return DP[pos][cap];
}

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    A.resize(n);
    for(int i=0; i<n; i++)
    {
        ll w,s,v; //w-block weight, s - block capacity to hold weight, v - value
        cin>>w>>s>>v;
        A[i]={w+s,v,w,s};
    }

    //lets say we have 2 blocks A(s1,w1) and B(s2,w2)
    //if we put A on B remaining cap is s2-w1
    //otherwise its s1-w2
    //so if block A should go on bottom s1-w2 > s2-w1 or s1+w1 > s2+w2

    sort(A.rbegin(),A.rend());
    cout<<solve(0,20000)<<"\n";
}


Measured memory_bytes: 233088
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;

fn main() {
    let (a, b, c): (usize, usize, usize);
    input!(a, b, c);
    if a % c != 0 {
        p(b / c - a / c);
    } else {
        p(b / c - a / c + 1);
    }
}

Measured memory_bytes: 4352
#include <stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u){
  int i, c;
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

  if(T[u].p == NIL/*ここを埋める (fill this blank)*/ ) printf("root, ");
  else if(T[u].l == NIL/*ここを埋める(fill this blank)*/) printf("leaf, ");
  else printf("internal node, ");
  
  printf("[");
  for (i=0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if(i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
  
}

void calcDepth(int u, int p){
  D[u] = p;
  if(T[u].l != NIL  /*ここを埋める(fill this blank)*/) calcDepth(T[u].l, p+1 /*ここを埋める(fill this blank)*/);
  if(T[u].r != NIL  /*ここを埋める(fill this blank)*/) calcDepth(T[u].r, p/*ここを埋める(fill this blank)*/);
}

int main(){
  int i, j, k;
  int n;
  int id, sib, child;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;
  
  for(i=0; i<n; i++){
    scanf("%d %d", &id, &k);
    for(j = 0, sib = NIL; j<k; j++){ //子を入力する (input children)
      scanf("%d", &child);
      T[child].p = id;
      if(j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)
      else { T[sib].r = child; }  //左の兄弟に繋げる (connect to left sibling)
      sib = child;//次の子供の左の兄弟 (the left sibling of the next child)
    }
  }

  //根を求める (find the root)
  for(i=0; i<n; i++){
    if(T[i].p == NIL ) root = i;
  }
  
  //それぞれのノードの深さを求める (find depth of each node)
  calcDepth(root, 0);

  //出力 (output)
  for(i=0; i<n; i++) print(i);
  
  return 0;
}



Measured memory_bytes: 3292
#include<stdio.h>
#include<vector>
#include<string>
using namespace std;

class Node {
public:
	int degree = 0, depth = 0;
	int parent = -1;
	vector<int> children;
	void show_info();
	const char* show_t();
};

void Node::show_info()
{
	printf("parent = %d, depth = %d, %s, [", this->parent, this->depth, this->show_t());
	for (unsigned int i = 0; i < this->children.size(); i++)
	{
		if (i)
			printf(", ");
		printf("%d", this->children[i]);
	}
	printf("]\n");
	return;
}

const char* Node::show_t()
{
	if (this->parent == -1)
		return "root";
	else if (this->children.size() == 0)
		return "leaf";
	else
		return "internal node";
}

class Tree {
public:
	int n;
	Node *nodes;
	void decide_d();
	void decide_drec(int, int);
	void show_info();
};

void Tree::decide_d()
{
	for (int i = 0; i < this->n; i++)
		if (this->nodes[i].parent == -1)
		{
			for (unsigned int j = 0; j < this->nodes[i].children.size(); j++)
				this->decide_drec(nodes[i].children[j], 1);
			break;
		}
	return;
}

void Tree::decide_drec(int num, int d)
{
	this->nodes[num].depth = d;
	for (unsigned int i = 0; i < this->nodes[num].children.size(); i++)
		this->decide_drec(this->nodes[num].children[i], d + 1);
	return;
}

void Tree::show_info()
{
	for (int i = 0; i < this->n; i++)
	{
		printf("node %d: ", i);
		this->nodes[i].show_info();
	}
	return;
}

int main()
{
	int id, k, c;
	Tree tree;
	scanf("%d", &tree.n);
	tree.nodes = new Node[tree.n + 1];
	tree.nodes++;

	for (int i = 0; i < tree.n; i++)
	{
		scanf("%d%d", &id, &k);
		for (int j = 0; j < k; j++)
		{
			scanf("%d", &c);
			tree.nodes[id].children.push_back(c);
			tree.nodes[c].parent = id;
		}
	}

	tree.decide_d();
	tree.show_info();

	tree.nodes--;
	delete[] tree.nodes;
}


Measured memory_bytes: 7088
N = int(input())
m, a, r, c, h = 0, 0, 0, 0, 0
for i in range(N):
    name = input()
    if name[0] == "M":
        m += 1
    elif name[0] == "A":
        a += 1
    elif name[0] == "R":
        r += 1
    elif name[0] == "C":
        c += 1
    elif name[0] == "H":
        h += 1
init_list = [m, a, r, c, h]
ans_list = []
for i in range(32):
    if bin(i).count("1") == 3:
        ans = 1
        for j in range(5):
            if i >> j & 1 == 1:
                ans *= init_list[j]
        ans_list.append(ans)
print(sum(ans_list))

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

using namespace std;

string s;
int main() {
	cin >> s;
	if (s == "abc" || s == "acb" || s == "bac" || s == "bca" || s == "cab" || s == "cba") {
		cout << "Yes";
		return 0;
	}
	cout << "No";
}

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

const int MAX = 510000;
const int MOD = 998244353;

long long fac[MAX],finv[MAX],inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
long long COM(int n,int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

long long N, A, B, K;

int main() {
    COMinit();
    while (cin >> N >> A >> B >> K) {
        long long res = 0;
        for (long long a = 0; a <= N; ++a) {
            long long rem = K - a * A;
            if (rem % B != 0) continue;
            long long b = rem / B;
            if (b > N) continue;
            long long tmp  = COM(N, a) * COM(N, b) % MOD;
            res += tmp;
            res %= MOD;
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<n;i++)
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
#define ll long long

int main(void){
    string a;
    cin >> a;
    if(a.size()==2){
        cout << a << endl;
    }
    else{
        brep(i,3)cout << a[i];
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[10005]={0};
bool cmp(int a,int b)
{
	 return a>b;
}
int main()
{
	 int n;
	 cin>>n;
	 for(int i=0;i<n;i++)
	 cin>>a[i];
	 sort(a,a+n,cmp);
	 int sum=0;
	 sum+=a[0]/2;
	 for(int i=1;i<n;i++)
	 sum+=a[i];
	 printf("%d\n",sum);
	 
 } 

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int H = 0;
  int W = 0;
  int i, j;

  do{
    scanf("%d %d", &H, &W);

    if(H == 0 && W == 0)
      break;

    for(i = 0; i < H; i++){
      if(i % 2 == 0) {
	for(j = 0; j < W; j++)
	  if(j % 2 == 0)
	    putchar('#');
	  else
	    putchar('.');
	
	putchar('\n');
      }
      else{
	if(i % 2) 
	for(j = 0; j < W; j++)
	  if(j % 2 == 0)
	    putchar('.');
	  else
	    putchar('#');
	
	putchar('\n');
      }
    }
    
    putchar('\n');
    
  }while (1);
  
  return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> dp(n+1), dp2(n+1);
    for (int i = 0; i < n; ++i) {
        dp[i+1] = dp[i]+(s[i] == '#');
    }
    for (int j = n-1; j >= 0; --j) {
        dp2[j] = dp2[j+1]+(s[j] == '.');
    }
    int ans = INF<int>;
    for (int i = 0; i <= n; ++i) {
        ans = min(ans, dp[i]+dp2[i]);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 2180
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int H, W; cin >> H >> W;
    long long N = 0;
    vector<vector<char>>A(H, vector<char>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A.at(i).at(j);
            if (A.at(i).at(j) == '#') N++;
        }
    }
    if (N == H + W - 1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

static inline int getint(){
  int ret = 0;
  int g;
  while((g = getchar() - '0'), g<0);
  ret = g;
  while((g = getchar() - '0'), g>=0){
    ret *= 10;
    ret += g;
  }
  return ret;
}

static inline int cnt(unsigned int bits) {
  bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
  bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
  bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
  bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
  return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int memo[1<<20];

int main(){
  int c[20],k,r[20];
  int n,u;
  int *m = memo;
  register unsigned int i,j,l;
  for(i=0; i<(1<<20); i++) *m++ = cnt(i);

  while(n=getint(), u=getint(), n+u){
    int ans = n;
    m = &memo[(1<<n)-1];
    for(i=0; i-n; i++){
      c[i]=getint(); k=getint();
      r[i] = 0;
      for(j=0; j<k; j++){
	int t = getint();
	r[i] |= (1<<t);
      }
    }

    for(i=(1<<n)-1; i; i--){
      int tni = 0;
      int ok  = 0xFFFFFFFF;
      int cc  = *m--;
      if(cc >= ans) continue;

      for(j=0; ok & j-n; j++){
	if(i & (1<<j))
	  tni += c[j];

	//if(!(!(i & (1<<j)) || !((i & r[i]) == r[j])))
	if(!((!(i & (1<<j))) | (!((i & r[j]) ^ r[j]))))
	  ok = 0;
      }

      if(tni >= u & ok)
	ans = cc;
    }
    printf("%d\n",ans);
  }
}

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

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

  int h[100010];
  for (int i=0; i<n; i++) {
    scanf("%d",h+i);
  }
  vector<int> dp(n,1e9); 
  dp[0]=0;
  for (int i=0; i<n-1; i++) {
    for (int j=1; j<=k; j++) {
      if (i+j<n)
	dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
    }
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n, k;
int main() {
    cin >> n >> k;
    vector<bool> d(10, true);
    for(int i = 0; i < k; ++i) {
        int din;
        cin >> din;
        d.at(din) = false;
    }

    int ans = 0;
    for(int i = n; i <= 10*n; ++i) {
        int check = i;
        string scheck = to_string(check);
        int slen = scheck.length();
        bool flg = true;
        for(int i = 0; i < slen; ++i) {
            if(!d.at(scheck.at(i)-'0')) {
                flg = false;
                break;
            }
        }
        if(flg) {
            ans = check;
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
(R,C,K),*RCV = $<.map{|ln| ln.split.map(&:to_i) }

Rs = Array.new(R){ [] }
RCV.each{|s,d,v|
	Rs[s-1] << [d-1,v]
}

r0 = [0]*C
while r = Rs.shift
	r.empty? and next or r.sort!

	c0,vs = 0,[0]*4
	until r.empty?
		c,v = r.shift
		vs[0] = [vs[0],r0[(c0..c).max_by{|i|r0[i]}]].max
		vs[3] = vs[2]+v if vs[3] < vs[2]+v
		vs[2] = vs[1]+v if vs[2] < vs[1]+v
		vs[1] = vs[0]+v if vs[1] < vs[0]+v
		r0[c] = vs.max
		c0 = c+1
	end
end

p r0.max


Measured memory_bytes: 46636
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: usize
    }

    let mut ans = 0;
    for i in 1..=n {
        let c = n / i;
        ans += (i + i * c) * c / 2;
    }

    println!("{}", ans);
}


Measured memory_bytes: 2180
#include<iostream>
using namespace std;
int main() {
  string n;
  cin >> n;
  for(int i=0; i<3; i++){
    if(n[i] == '1'){
      n[i] = '9';
    }else if(n[i] == '9'){
      n[i] = '1';
    }
  }
  cout << n << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector> 
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
int n;
int q;
int sx,tx,sy,ty;
vector <int>viAns;


struct data
{
int x,y;
int index;
};
data pData[500005];
struct node
{
int x,y;
node *l;
node *r;
int index;
};

node *root;

bool cmpx(data a,data b)
{
return a.x<b.x;
}

bool cmpy(data a,data b)
{
return a.y<b.y;
}

node* addNode(int l,int r,bool d)
{
if (l>=r)
	return NULL;
node *now = new node;
int mid = (l+r)/2;
if (!d)
	sort(pData+l,pData+r,cmpx);
else
	sort(pData+l,pData+r,cmpy);
now->x=pData[mid].x;
now->y=pData[mid].y;
now->index=pData[mid].index;

now->l=addNode(l,mid,!d);
now->r=addNode(mid+1,r,!d);
return now;
}

void Find(node *n,bool d)
{
if (n->x>=sx && n->x<=tx && n->y>=sy && n->y<=ty)
	viAns.push_back(n->index);
if(d)
	{
	if(sy<=n->y&&n->l)
		Find(n->l,!d);
	if(ty>=n->y&&n->r)
		Find(n->r,!d);
	}
else
	{
	if(sx<=n->x&&n->l)
		Find(n->l,!d);
	if(tx>=n->x&&n->r)
		Find(n->r,!d);
	}
}

int main()
{
cin >> n;
root = new node;
root->l=NULL;
root->r=NULL;
for (int i = 0 ; i < n ; i ++)
	{
	cin >> pData[i].x >> pData[i].y;
	pData[i].index=i;
	}
root=addNode(0,n,true);
cin >> q;
while (q--)
	{	
	cin >> sx >> tx >> sy >> ty;
	viAns.clear();
	Find(root,true);
	sort(viAns.begin(),viAns.end());
	for (int i = 0 ; i < viAns.size() ; i++)
		printf("%d\n",viAns[i]);
	printf("\n");
	}

} 


Measured memory_bytes: 31724
// D - Add and Remove
#include <bits/stdc++.h>

using namespace std;

long long dfs(const vector<long long> &a, int l, int r, long long lc, long long rc)
{
	if (r - l <= 1) return 0;
	long long best = 1e18;
	for (int m = l + 1; m < r; m++) {
		long long s = a[m] * (lc + rc) + dfs(a, l, m, lc, lc + rc) + dfs(a, m, r, lc + rc, rc);
		best = min(best, s);
	}
	return best;
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	cout << dfs(a, 0, n - 1, 1, 1) + a[0] + a[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1e9+7;
using namespace std;

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


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;


int main(){
    int n;
    cin>>n;
    if(n%2==0){
        cout<<n/2<<endl;
        return 0;
    }else{
        cout<<n/2+1<<endl;
        return 0;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace StartFinish
{
    class Program
    {   
            
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int exchange_count = 0;
            for(int i = n - 1; i >= 0; i--)
            {
                for(int j = 0; j < i; j++)
                {
                    if (array[j] > array[j + 1])
                    {
                        int tmp = array[j + 1];
                        array[j + 1] = array[j];
                        array[j]= tmp;
                        exchange_count++;
                    }
                }
            }


            for(int i = 0; i < n - 1; i++)
            {
                Console.Write("{0} ", array[i]);
            }
            Console.WriteLine(array[n - 1]);
            Console.WriteLine(exchange_count);
        }
    }
}

Measured memory_bytes: 9652