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

string to_string(string s) { return '"' + s + '"'; }
string to_string(char c) { string s = "'"; s += c; return s + "'"; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
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 first = true; 
    string res = "{";
    for (const auto &x : v) {
        if (!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}"; 
    return res;
}
istream_iterator<string> eos;
void dbg_out(istream_iterator<string> it) { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(istream_iterator<string> it, Head H, Tail... T) {
    cerr << *it << " = " << to_string(H);
    if(++it != eos) cerr << ", ";
    dbg_out(it, T...);
}
#ifdef LOCAL
    #define dbg(...) { string _s = #__VA_ARGS__; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); dbg_out(_it, __VA_ARGS__); }
#else
    #define dbg(...)
#endif

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define MP make_pair
#define sz(v) ((int)(v).size())
#define fr(i, j, k) for(int i = j; i < k; i++)
#define nl "\n"
typedef pair<int, int> pii;
typedef vector <int> vi;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

const int inf = (1LL << 60), mod = 1e9+7, nn = 2e5+5;

void solve(){
    int n;
    cin >> n;
    vi cnt(n+1, 0);
    fr(i, 1, n) {
        int x; cin >> x;
        cnt[x]++;
    }
    fr(i, 1, n+1) cout << cnt[i] << nl;
}

int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 4784
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

#include <bits/stdc++.h>
using namespace std;

int main() {
  ll n,k;
  cin>>n>>k;
  
  vector<ll> h(n);
  rep(i,n) cin>>h[i];
  
  sort(ALL(h));
  if(n<=k) cout<<0<<endl;
  else{
    ll ans=0;
    rep(i,n-k) ans+=h[i];
    cout<<ans<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG


int has_key_using_count(map<string, int> &m, string key){
    if (m.count(key) == 0){
        //cout << "m doesn't have " << key << "." << endl;
        return 0;
    }
    else{
        //cout << "m has " << key << "." << endl;
        return m.at(key);
    }
}

int main() {
  map<string, int> dict;  ;
  ll N; 
  cin >> N;

  for(ll i=0; i< N; i++){
    string tmp;
    cin >> tmp;
    int val = has_key_using_count(dict, tmp);
    dict[tmp] = val+1;
  }
  
  ll max = 0;
  queue<string> buf;

  for (auto p : dict) {
    auto k = p.first;
    auto v = p.second;

    if(v > max){
      buf = queue<string>();
      buf.push(k);
      max = v;
    }else if(v == max){
      buf.push(k);
    }

  }

  while (!buf.empty()) {
    cout << buf.front() << endl;  // 先頭の値を出力
    buf.pop();  // 先頭の値を削除
  }

  return 0;
}


Measured memory_bytes: 25656
#include<bits/stdc++.h>
#define int			long long
#define ll 			long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define dep(i,a,b)	for(int i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

ll n;
vi a[N];
bool vis[N];
ll dp[N][2];

void dfs(ll node, ll par){
	dp[node][0]=1;
	dp[node][1]=1;
	for(auto i:a[node]){
		if(i==par)continue;
		dfs(i,node);
		dp[node][0]=(dp[node][0]*(dp[i][0]+dp[i][1])%hell)%hell;
		dp[node][1]=(dp[node][1]*dp[i][0])%hell;
	}

}

void solve()
{
	cin>>n;
	rep(i,0,n-1){
		ll x,y;
		cin>>x>>y;
		a[x].pb(y);
		a[y].pb(x);
	}
	dfs(1,0);
	cout<<(dp[1][0]+dp[1][1])%hell<<endl;

}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 17648
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	if ((tmp & ma0) ^ ma0) {
		int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
		tmp = tmp << dig & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += (72 - dig >> 3);
	}
	else {
		tmp = tmp & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += 8;
		if ((ct = *ci++) >= '0') {
			tmp = tmp * 10 + ct - '0';
			if (*ci++ == '0') {
				tmp = tmp * 10;
				ci++;
			}
		}
	}
	return tmp;
}
void okuri() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	if ((tmp & ma0) ^ ma0) {
		ci += 4 + __builtin_ctzll((tmp & ma0) ^ ma0) >> 3;
	}
	else {
		ci += 8;
		tmp = *(ll*)ci;
		ci += 4 + __builtin_ctzll((tmp & ma0) ^ ma0) >> 3;
	}
}

int A[200001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint(), M = getint(), K = getint();

	int p = 0;
	for (; p < N; p++) {
		A[p + 1] = A[p] + getint();
		if (A[p + 1] > K) break;
	}
	for (int q = p + 1; q < N; q++) okuri();

	while (A[p] > K) p--;
	ll kotae = p;

	rep1(i, M) {
		K -= getint();
		if (K < 0) break;
		while (A[p] > K) p--;
		if (kotae < i + p) kotae = i + p;
	}

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

	Would you please return 0;
}

Measured memory_bytes: 2472
N = gets.to_i
A = gets.split.map {|item| item.to_i}
a1 = A.sort.slice_when(&:!=).map {|x| [x.first, x.size] }
a2 = [*1..N].map {|item| [item, 0]}.to_h
ans = a2.merge(Hash[a1])
puts ans.values


Measured memory_bytes: 68524
#include <bits/stdc++.h>
#define INF 1000000000000000001
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll H, W, N;
  cin >> H >> W >> N;
  ll sr, sc;
  cin >> sr >> sc;
  string S, T;
  cin >> S >> T;
  vector<ll> lrud(4, 0);
  vector<ll> need = {sc, W - sc + 1, sr, H - sr + 1};
  vector<char> move = {'L', 'R', 'U', 'D'};
  // bool fin = false;
  for (ll i = 0; i < N; ++i)
  {
    for (ll j = 0; j < 4; ++j)
    {
      if (S[i] == move.at(j))
      {
        lrud.at(j) += 1;
      }
    }
    for (ll k = 0; k < 4; ++k)
    {
      if (lrud.at(k) >= need.at(k))
      {
        cout << "NO" << endl;
        return 0;
        // fin = true;
        // break;
      }
    }
    // if (fin)
    // {
    //   break;
    // }
    for (ll j = 0; j < 4; ++j)
    {
      // cout << "J" << j << "fix" << (j + 1) % 2 + (j / 2) * 2 << endl;
      if (T[i] == move.at(j) && lrud.at((j + 1) % 2 + (j / 2) * 2) != -need.at(j) + 1)
      {
        lrud.at((j + 1) % 2 + (j / 2) * 2) -= 1;
      }
    }
  }
  // cout << "need" << endl;
  // for (ll i = 0; i < 4; ++i)
  // {
  //   cout << need.at(i) << ' ';
  // }
  // cout << endl;
  // cout << "lrud" << endl;
  // for (ll i = 0; i < 4; ++i)
  // {
  //   cout << lrud.at(i) << ' ';
  // }
  // cout << endl;
  cout << "YES" << endl;
}


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

bool solve(int n, int* A, int p, int M){
    //cout << "start from " << p << " compared with " << M << endl;
    if (M==0){
        return true;
    }
    if (p<n){
        if (M==0){
            return true;
        }else if (M<0){
            return false;
        }else{
            bool k = solve(n, A, p+1, M) || solve(n, A, p+1, M-A[p]);
            //cout << "returned " << (k?"true":"false") << endl;
            return k;
        }
    }
    return false;
}

int main(){
    int n, q;
    cin >> n;
    int A[n];
    for(int i=0; i<n; ++i){
        cin >> A[i];
    }
    cin >> q;
    int M[q];
    for(int i=0; i<q; ++i){
        cin >> M[i];
    }
    
    for(int i=0; i<q; ++i){
        cout << (solve(n, A, 0, M[i]) ? "yes" : "no") << endl; 
    }
}

Measured memory_bytes: 1156
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	a := make([][3]int, n)
	for i := range a {
		for j := range a[i] {
			a[i][j] = scanInt()
		}
	}

	dp := make([][3]int, n+1)
	for i := 0; i < n; i++ {
		for j := 0; j < 3; j++ {
			for k := 0; k < 3; k++ {
				if j == k {
					continue
				}
				dp[i+1][k] = max(dp[i+1][k], dp[i][j]+a[i][k])
			}
		}
	}

	var ans int
	for i := 0; i < 3; i++ {
		ans = max(ans, dp[n][i])
	}
	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int k,s; cin>>k>>s;
	int ans = 0;
	rep(a,k+1)rep(b,k+1){
		if(s-a-b>=0&&s-a-b<=k) ans++;
	}

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


Measured memory_bytes: 256
N,K = map(int,input().split())
number = N+1-K+1
W = 0
for i in range(number):
    min = (K+i)*(K+i-1)/2
    max = (K+i)*(2*N-K-i+1)/2
    W += (max-min+1)
w = W % (1000000007)
print(int(w))

Measured memory_bytes: 9060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer x = nil->next;
  while(x->key != key){
    if(x == nil) break;
    x = x->next;
  }
  return x;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cr = nil->next;
  int isl = 1;
  while(1){
    if (cr == nil) {
      break;
    }
    if (isl == 0) {
      printf(" ");
    }
    printf("%d", cr->key);
    cr = cr->next;
    isl = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if (t == nil) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer x = nil->prev;
  if(x == nil) return;
  deleteNode(x);
}

void delete(int key){
  NodePointer x;
  x = listSearch(key);
  if(x == nil) return;
  deleteNode(x);
}

 void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  x->prev = nil;
  nil->next = x;
  x->next->prev = x;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int nop = 0, nod = 0;
  scanf("%d", &n);
  init();
  for(i = 0; i < n; i++){
    scanf("%s%d", com, &key);
    if (com[0] == 'i') {
      insert(key);
      nop++;
      size++;
    } else if (com[0] == 'd') {
      if (strlen(com) > 6) {
        if (com[6] == 'F') deleteFirst();
        else if (com[6] == 'L') deleteLast();
      } else {
    delete(key); nod++; 
      }
      size--;
    }
  }

  printList();

  return 0;
}

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

/*
ll gcds(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    ll r=a%b;
    if(r==0){
        return b;
    }
    while(r>0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
 
 
ll lcms(ll a,ll b){
    ll mmr=gcds(a,b);
    a=a/mmr;
    b=b/mmr;
    return a*b*mmr;
}
*/
int main(){
    int X,Y,Z;//" "<<
    cin>>X>>Y>>Z;
    cout<<Z<<" "<<X<<" "<<Y;
}

Measured memory_bytes: 256
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-06-07 16:28:56
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll q , n , A[MAXN];
string s;

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

    cin >> q;
    while(q--){
        cin >> n;
        for(int i = 0 ; i < n ; i++)    cin >> A[i];
        cin >> s;
        vector<ll> vec;
        ll ok = 1;
        for(int i = n - 1 ; i >= 0 ; i--){
            ll x = A[i];
            for(ll j : vec){
                ll y = (j & (-j));
                if(x & y)   x ^= j;
            }
            if(x != 0){
                vec.push_back(x);
                if(s[i] == '1') ok = 0;
            }
        }
        cout << 1 - ok << endl;
    }

    return 0;
}
/*

*/


Measured memory_bytes: 3576
import sys


def main():
    input = sys.stdin.readline

    N, W = map(int, input().split())
    dp = [0] * (W + 1)

    WV = (map(int, input().split()) for _ in range(N))

    for w, v in WV:
        for j in range(W, w - 1, -1):
            tmp = dp[j - w] + v
            if tmp > dp[j]:
                dp[j] = tmp

    print(dp[-1])


main()


Measured memory_bytes: 7668
# -*- coding: utf-8 -*-

'''
5 3
10 30 40 50 20
'''

N, K = map(int,input().split())
h = list(map(int, input().split()))

dp = [None] * N

dp[0] = 0
dp[1] = abs(h[0] - h[1])

# for k in range(1, K):
    # dp[k] = abs(h[0] - h[k])

for i in range(2, N):
    temp = min(i, K)
    dp[i] = min([dp[i-k] + abs(h[i] - h[i-k]) for k in range(1, temp + 1)])

# print(dp)
print(dp[N-1])


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

int main(){
  vector<long long> v(3);
  bool flag = false;
  for(int i = 0 ; i < 3 ; i++){
    cin >> v[i];
    if(v[i] % 2 == 0){
      flag = true;
    }
  }
  if(flag){
    cout << 0 << endl;
  }else{
    sort(v.begin(), v.end());
    long long ans = v[0] * v[1];
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
	double ax, ay, bx, by, cx, cy, dx, dy;
	while (cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy) {
		if (ax > dx || bx < cx || ay > dy || by < cy) {
			cout << "NO";
		} else {
			cout << "YES";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
program name

    implicit none
    integer N,M,X,X_to_1,X_to_N
    integer,allocatable :: A(:)
    read*, N,M,X
    allocate(A(M))
    read*, A(:)
    X_to_1 = count(A<=X)
    X_to_N = count(A>=X)
    if ( X_to_1>=X_to_N ) then
        print*, X_to_N
    else
        print*, X_to_1
    end if
end program

Measured memory_bytes: 512
#include <stdio.h>
#define ll long long
const int maxn = 2e5+1;

ll fw[200001];
ll max(ll a,ll b){ return a>b? a : b ; }

ll getMax(int id){
	if (id<=0) return 0;
	ll ret = 0;
	while(id){
		ret = max(ret, fw[id] );
		id-= (id&-id);
	}
	return ret;
}
void upd(int id,ll val){
	if(id<=0) return;
	while (id<=maxn){
		fw[id]=max(fw[id],val);
		id+= (id&-id);
	}
}
int a[200001];
int h[200001];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&h[i]);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	ll premax;
	ll ans = 0;
	for(int i=0;i<n;i++){
		premax = getMax(h[i]);
		ans = max(ans,premax + a[i]);
		upd(h[i],premax+a[i]);
	}
	printf("%lld",ans);
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int r;
	cin >> r;
	cout << r * r << endl;
	return 0;
}

Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> a >> b;
    if (a % 3 && b % 3 && (a + b) % 3)
        cout << "Impossible"<<"\n ";
    else cout<< "Possible"<<"\n ";
}


Measured memory_bytes: 3644
import collections
s = map(int,raw_input())

dp = [0] * 2019
count = 0
for j in range(len(s)):
    ndp = [0] * 2019
    ndp[s[j]] += 1
    for k in range(len(dp)):
        ndp[(10*k + s[j]) % 2019] += dp[k]
    count += ndp[0]
    dp = ndp[::]

print count




Measured memory_bytes: 106396
#include <iostream>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
using namespace std;
int main(){
  string str;
  cin >> str;
  
  for(int i= 0;i < str.size();i++){
    if(str[i] - 'A' - 3 >= 0)cout << (char)(str[i]-3);
    else cout << (char)((str[i]-3)+26);
  }
  cout << endl;
  return 0;
}
vector<string> split(string str,string delim){
  vector<string> items;
  size_t dlm_idx;
  if(str.npos == (dlm_idx = str.find_first_of(delim))){
    items.push_back(str.substr(0,dlm_idx));
  }
  while(str.npos != (dlm_idx = str.find_first_of(delim))){
    if(str.npos == str.find_first_not_of(delim)){
      break;
    }
    items.push_back(str.substr(0,dlm_idx));
    dlm_idx++;
    str = str.erase(0,dlm_idx);
    if(str.npos == str.find_first_of(delim) && "" != str){
      items.push_back(str);
      break;
    }
  }
  return items;
}

Measured memory_bytes: 1180
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var xn = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var x = xn[0];
        var n = xn[1];

        long[] p;
        try
        {
            p = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        catch
        {
            Console.WriteLine(x);
            return;
        }

        long ans = -100;

        for(int i = -100; i < 1000; i++)
        {
            if (p.Any(t => t == i)) continue;

            if (Math.Abs(x - i) < Math.Abs(x - ans)) ans = i;
        }

        Console.WriteLine(ans);
    }
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int x,y; cin >> x >> y;
    vector<int> A{1,3,5,7,8,10,12};
    vector<int> B{4,6,9,11};

    bool isx=false, isy=false;
    REP(i,A.size()){
        if(A[i]==x) isx = true;
        if(A[i]==y) isy = true;
    }
    if(isx && isy){
        cout << "Yes" << endl;
        return 0;
    }
    isx=false, isy=false;
    REP(i,B.size()){
        if(B[i]==x) isx = true;
        if(B[i]==y) isy = true;
    }
    if(isx && isy){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int a,b,c;
  	cin >> a >> b >> c;
	if (a == b and b == c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  pb push_back
#define nl "\n"
#define fastScan ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
long double p[3123];
long double dp[3123][3123];
int main()
{
	fastScan;
	int n;cin>>n;
	for(int i=1;i<=n;i++)
		cin>>p[i];
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<i;j++)
		{
			dp[i][j+1]+=dp[i-1][j]*p[i];
			dp[i][j]+=dp[i-1][j]*(1-p[i]);
		}
	}
	long double ans=0;
	for(int i=n/2+1;i<=n;i++)
		ans+=dp[n][i];
	cout<<setprecision(14)<<ans<<nl;
}


Measured memory_bytes: 145920
import java.util.*;

public class Main {
    
    public static void main(String arg[]) {
        try{
            Scanner scan = new Scanner(System.in);
            int a = scan.nextInt();
            int b = scan.nextInt();
            if(0<a && a<101 && 0<b && b<101){
            int x = a*b;
            int y = (a + b)*2;
            System.out.println(x+" "+y);
            }else{
                System.out.println("1??????100?????§???????????§???");
            }
            
        }catch(InputMismatchException ex){
            System.out.println("1??????100?????§????????¶??°?????\?????????????????????");
        }
    }
}

Measured memory_bytes: 26096
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mod 1000000007
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    int a[n];
    for(int i = 0; i < n; i++)
    cin >> a[i];
    sort(a, a + n, greater<int>());
    for(int i = k; i < n; i++)
    ans += a[i];
    cout << ans << "\n";
    
	return 0;
}



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

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

    vector<long long> l(n);

    for(long long i = 0; i < n; i++) cin >> l[i];

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

    long long cnt = 0;

    for(long long i = 0; i < n; i++){
        for(long long j = i + 1; j < n ; j++){
            long long k = lower_bound(l.begin(), l.end(), l[i]+l[j]) - l.begin();
            cnt += k - (j+1);
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3612
n,k=map(int,input('').split(' '))
s=0
h=0

n=n%k
while s==0:
    h=n
    n=n-k
    if n<0:
        n=n*(-1)
    if h>n:
        s=0
    else:
        s=1
        n=h

print(n)

Measured memory_bytes: 3060
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cmath>
#include<cstring>
#define loop(i,r,l) for(int (i)=(r);(i)<(l);(i)++)
#define rep(i,n) loop(i,0,n)
#define INF 1000000007
using namespace std;

int main(){
    string s;
    cin>>s;
    rep(i,s.size()){
        if(s[i]=='C'){
            loop(j,(i+1),s.size()){
                if(s[j]=='F'){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 384
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,K = IL()
a = IL()
rui = [0]
tmp = 0
for i in range(N):
  tmp += a[i] + 1
  rui.append(tmp)

ans = 0
for i in range(0,N-K+1):
  ans = max(ans, (rui[i+K] - rui[i])/2)
print(ans)

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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slowly
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;
// using rational = mp::cpp_rational;  // double d = static_cast<double>(r);

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

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  int N, M;
  cin >> N >> M;

  if (N==M) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n = int(input())
a = list(map(int, input().split()))
flag = 0

for i in range(n):
    if a[i] % 2 == 0:
        if ( a[i] % 3 != 0 )and( a[i] % 5 != 0 ):
            flag = 1

if flag:
    print('DENIED')
else:
    print('APPROVED')

Measured memory_bytes: 3060
a,b,q=gets.split.map(&:to_i)
shrines=a.times.map{gets.to_i}
temples=b.times.map{gets.to_i}

LB=-10**15
RB=10**15
shrines.unshift LB
shrines.push RB
temples.unshift LB
temples.push RB

q.times{
  x=gets.to_i
  sidx=shrines.bsearch_index{|v|x<=v}
  tidx=temples.bsearch_index{|v|x<=v}
  ls=shrines[sidx-1]
  rs=shrines[sidx]
  lt=temples[tidx-1]
  rt=temples[tidx]

  lslt=x-[ls,lt].min
  rsrt=[rs,rt].max-x
  lsrt=rt-ls+[x-ls,rt-x].min
  rslt=rs-lt+[x-lt,rs-x].min

  puts [lslt,rsrt,lsrt,rslt].min
}

Measured memory_bytes: 5300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))


int main(){
    
    set<int> x = {1, 3, 5, 7, 8, 10, 12}, y={4, 6, 9, 11};
    int a, b;   cin >> a >> b;
    string ans="No";
    if(x.find(a)!=x.end() && x.find(b)!=x.end()) ans = "Yes";
    else if(y.find(a)!=y.end() && y.find(b)!=y.end()) ans = "Yes";

    cout << ans << endl;

}

Measured memory_bytes: 384
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



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

    if((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3]))Yes;
    else No;
	return  0;
}

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

int main(){
    int N; cin >> N;
    string S; cin >> S;
    rep(i, S.size()){
        S[i] = (S[i] - 'A' + N)%26 + 'A';
    }
    cout << S << endl;
    return 0;
}

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

namespace CSharpSample01
{


	class Program
	{
		static void Main(string[] args)
		{
			// スペース区切りの整数の入力
			var N = int.Parse(Console.ReadLine());
			var answer = N / 2;
			if(N % 2 == 0)
			{
				Console.WriteLine(answer);
			}
			else
			{
				Console.WriteLine(answer + 1);
			}
		}
	}
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;



vector<int> parent;

int find(int u){
	if(parent[u] == u){
		return u;
	}
	parent[u] = find(parent[u]);
	return parent[u];
}

void join(int u, int v){
	int pu = find(u);
	int pv = find(v);
	if(pu==pv) return;
	parent[pu] = pv;
}


int main(){
	int n,m;
	cin>>n>>m;
	parent.resize(n+1);
	for(int i=1;i<=n;i++) parent[i] = i;
	for(int i=0;i<m;i++){
		int x,y,z;	
		cin>>x>>y>>z;
		join(x,y);
	}
	
	set<int> st;

	for(int i=1;i<=n;i++){
		st.insert(find(i));
	}
	cout<<st.size()<<endl;

}

Measured memory_bytes: 5376
N=int(input())

s_dic={}
for i in range(N):
  s=list(input())
  s.sort()
  s_str="".join(s)
  
  if s_str in s_dic:
    s_dic[s_str]+=1
  else:
    s_dic[s_str]=1

#print(s_dic)
answer=0
for key in s_dic:
  answer+=(s_dic[key]*(s_dic[key]-1))//2

print(answer)

Measured memory_bytes: 17800
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n,x;
  cin>>n>>x;
  vector<Int> xs(n);
  for(Int i=0;i<n;i++) cin>>xs[i];
  xs.emplace_back(x);
  sort(xs.begin(),xs.end());
  Int k=xs[1]-xs[0];
  for(Int i=0;i<n;i++) k=__gcd(k,xs[i+1]-xs[i]);
  cout<<k<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}




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



string s;
cin >> s;

bool my = false, ym = false;

if(s[0] == '0') if( s[1] >='1' && s[1] <= '9') my = true;
if(s[0] == '1') if( s[1] >='0' && s[1] <= '2') my = true;
if(s[2] == '0') if( s[3] >='1' && s[3] <= '9') ym = true;
if(s[2] == '1') if( s[3] >='0' && s[3] <= '2') ym = true;

if(my){
    if(ym) cout << "AMBIGUOUS" << endl;
    else cout << "MMYY" << endl;
}else{
     if(ym) cout << "YYMM" << endl;
    else cout << "NA" << endl;
}
return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

  for (int i = 1; i <= 10000; ++i) {
    if (floor((double)i * 0.08) == a && floor((double)i * 0.1) == b) {
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
object Main extends App {
  for(line <- io.Source.stdin.getLines()) {
    val numAry = line.split(' ').map { _.toInt }
    
    if(numAry(0) == numAry(1))
        println("a == b")
    else if(numAry(0) > numAry(1))
        println("a > b")
    else
        println("a < b")
  }
}


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

using namespace std;
using ll = long long;

int main() {
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    if(e-a<=k)cout<<"Yay!"<<endl;
    else cout<<":("<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()

int s[1005][1005];

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H,W,A,B;
	cin >> H >> W >> A >> B;
	if(W>2*A && H> 2*B){
		for(int i=0;i<B;i++)for(int j=0;j<A;j++)s[i][j]=0;
		for(int i=0;i<B;i++)for(int j=A;j<W;j++)s[i][j]=1;
		for(int i=B;i<H;i++)for(int j=0;j<A;j++)s[i][j]=1;
		
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cout << s[i][j];
			}
			cout << endl;
		}
	}else{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int b=0;
    int w=0;
    int n;
    string s;
    cin>>n>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='.')w++;
    }
    int ans=w;
    for(int i=0;i<n;i++){
        if(s[i]=='.'){
            w--;
        }else{
            w++;
        }
        ans=min(ans,w);
    }
    cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {

//    int N;
//    cin >> N;
//    vector<long> BS;
//    for (int i = 0; i < N - 1; ++i) {
//        long B;
//        cin >> B;
//        BS.push_back(B);
//    }
//
//    long sum = BS[0];
//    for (int i = 1; i < N - 1; ++i) {
//        cout << sum << endl;
//        sum += min(BS[i], BS[i - 1]);
//    }
//    cout << sum << endl;
//    sum += BS[N - 2];
//
//    cout << sum << endl;

    int N;
    cin >> N;
    vector<long> BS;
    for (int i = 0; i < N - 1; ++i) {
        long B;
        cin >> B;
        BS.push_back(B);
    }

    long m = BS[N - 2];
    long sum = m;
    for (int i = N - 3; i >= 0; --i) {
        sum += min(m, BS[i]);
        m = BS[i];
    }
    sum += BS[0];

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n, a, i, min = 1000000000, cnt;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &a);
        for (cnt = 0; a % 2 == 0; cnt++)
            a /= 2;
        min = (cnt < min ? cnt : min);
    }
    printf("%d\n", min);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;


/* ITP1_1_C
 * class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        int area = a*b;
        int around = (a+b)*2;

        System.out.println(area + " " + around);
    }
}*/

// ITP1_1_D
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int S = sc.nextInt();

        int h = S/3600;
        int m = (S%3600)/60;
        int s = S%60;

        System.out.println(h + ":" + m + ":" + s);
    }
}


Measured memory_bytes: 26236
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

V<V<int>> to;
V<ll> d(100010, -1);
map<pair<int, int>, ll> cost;

void dfs(int n, ll dist = 0) {
  d[n] = dist;
  for (auto e : to[n]) {
    if (n == e) continue;
    if (d[e] >= 0) continue;
    dfs(e, dist + cost[{n, e}]);
  }
}

int main() {
  int n;
  cin >> n;
  to.resize(n);

  rep(i, n - 1) {
    int a, b;
    ll c;
    cin >> a >> b >> c;
    --a;
    --b;
    to[a].push_back(b);
    to[b].push_back(a);
    cost[{a, b}] = c;
    cost[{b, a}] = c;
  }
  int q, k;
  cin >> q >> k;
  --k;

  dfs(k);

  rep(i, q) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    ll ans = d[x] + d[y];
    printf("%ld\n", ans);
  }
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  string s; std::cin >> s;
  int slen = s.size();
  vvi dp(slen+1, vi(2, inf));
  dp[0][0] = 0;
  dp[0][1] = 1;
  rep(i, slen) {
    int d = s[i] - '0';
    dp[i+1][0] = min(dp[i][0]+d, dp[i][1]+(10-d));
    dp[i+1][1] = min(dp[i][0]+d+1, dp[i][1]+(10-(d+1)));
  }
  std::cout << dp[slen][0] << "\n";
}


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

using namespace std;

int n;

int main()
{
    cin>>n;
    int flag=0;
    for(int i=1;i<=9;i++)
    {
        int b=n/i;
        if(b<=9&&b>=0&&b*i==n)
        {
            puts("Yes");
            flag=1;
            break;
        }
    }
    if(flag==0)puts("No");
}


Measured memory_bytes: 256
def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n % 2 == 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res


def modinv(a, mod):
    return modpow(a, mod - 2, mod)


if __name__ == "__main__":
    n, k = map(int, input().split())
    m = 10 ** 9 + 7
    
    rev2 = modinv(2, m)
    rev6 = modinv(6, m)

    f = (n + 1) * ((n + 1) * (n + 2) % m - (k - 1) * k % m) % m * rev2 % m
    s = n - k + 2
    t = ((n + 1) * (n + 2) % m * (2 * n + 3) % m - (k - 1) * k % m * (2 * k - 1)% m) % m * rev6 % m

    ans = (f + s - t) % m

    print(int(ans))

Measured memory_bytes: 9236
#include<stdio.h>
#define NIL -1 /*??????????????????????????????????????????????????\?????????????????????*/
struct Node{

  int left;
  int right;
  int parent;

};

int sibling(int);
int children(int);
int depth(int);
int height(int);
void judge(int);
struct Node inputNodedata[10000];

int main(){

  int sumNode,Nodeid,i,j,leftdata,rightdata;

  scanf("%d",&sumNode);
  for(i = 0; i < sumNode; i++){

    inputNodedata[i].left = NIL;
    inputNodedata[i].right = NIL;
    inputNodedata[i].parent = NIL;
  }
 

  for(i = 0; i < sumNode; i++){

    scanf("%d",&Nodeid);
    scanf("%d",&leftdata);
    scanf("%d",&rightdata);

    inputNodedata[Nodeid].left = leftdata; /*????????????????±????????????????????????§??\?????????leftdata??¨rightdata????????¨???Nodeid?????????????????¨??????????????¨???????????¨??????*/
    inputNodedata[Nodeid].right = rightdata;

    if(leftdata != NIL) {

      inputNodedata[leftdata].parent = Nodeid;

    }

    if(rightdata != NIL){

      inputNodedata[rightdata].parent = Nodeid;

    }
    

  }


  for(i = 0; i < sumNode; i++){

    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,inputNodedata[i].parent,sibling(i),children(i),depth(i),height(i));
     judge(i);

  }



  return 0;

}


int sibling(int Nodeid){



  if(inputNodedata[Nodeid].parent == NIL){

    return NIL;

  }

else  if(inputNodedata[inputNodedata[Nodeid].parent].left != Nodeid && inputNodedata[inputNodedata[Nodeid].parent].left != NIL){

    return inputNodedata[inputNodedata[Nodeid].parent].left;

  }

  else if(inputNodedata[inputNodedata[Nodeid].parent].right != Nodeid && inputNodedata[inputNodedata[Nodeid].parent].right != NIL){

    return inputNodedata[inputNodedata[Nodeid].parent].right;

  }


  else {

    return NIL;

  }

}

int children(int Nodeid){

  int sumchild ;

  sumchild = 0;

  if(inputNodedata[Nodeid].left != NIL){

    sumchild = sumchild + 1;

  }

  if(inputNodedata[Nodeid].right != NIL){

    sumchild = sumchild + 1;
  }

  return sumchild;

}

int depth(int Nodeid){/*??¢??°???????§?????????°??§????????????????????????????????????????????§?????£??????????????°?????????????????????return*/

  int depth = 0;
  int id = inputNodedata[Nodeid].parent;
  while(id != NIL){

    id = inputNodedata[id].parent;
    depth = depth + 1;
  }
 
  return depth;

}

int height(int Nodeid){
  int leftheight=0,rightheight=0;

  if(inputNodedata[Nodeid].left != NIL){

    leftheight = height(inputNodedata[Nodeid].left) + 1;
  }

  if(inputNodedata[Nodeid].right != NIL){

    rightheight = height(inputNodedata[Nodeid].right) + 1;

  }

  if(leftheight > rightheight){

    return leftheight;

  }

  else{

    return rightheight;

  }

}


void judge(int i){

  if(inputNodedata[i].parent == NIL){

    printf("root\n");

  }

  else if(inputNodedata[i].left ==NIL && inputNodedata[i].right == NIL){

    printf("leaf\n");

  }

  else{

    printf("internal node\n");

  }

} 

Measured memory_bytes: 612