akhauriyash/Code-Regression huggingface dataset:
def examF():
    T = LI()
    A = LI()
    B = LI()
    loop1 = T[0]*(A[0]-B[0])
    loop2 = T[1]*(A[1]-B[1])
    now = loop1
    cur = loop1 + loop2
    if now>0 and cur>0:
        ans = 0
    elif now<0 and cur<0:
        ans = 0
    else:
#        print(now,cur)
        if cur!=0:
            ans = abs(now)//abs(cur)*2
            if abs(now)%abs(cur)!=0:
                judge = now + cur*ans//2
                if (now>0 and judge+loop1>0) or (now<0 and judge+loop1<0):
                    ans +=1
        else:
            ans = "infinity"
    print(ans)
    return

import sys,copy,bisect,itertools,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examF()


Measured memory_bytes: 38384
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<queue>
#define Max 2*100002
using namespace std;




priority_queue<pair<int,int> >q;

int main(){
	
	char s[5],t[5];

	scanf("%s",s);
	scanf("%s",t);
	int c = 0,i;
	for(i=0;i<3;i++){
		if(s[i] == t[i]){
			c++;
		}
	}

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

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	int a,b,c,t;
	
	while(scanf("%d",&a)!=EOF){
		scanf("%d",&b);
		c=a+b;
		
		for(t=1;c/10!=0;t++){
			c=c/10;
		}
		printf("%d\n",t);
		
	}
	return 0;
}

Measured memory_bytes: 2600
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sx = Integer.parseInt(sc.next());
		int sy = Integer.parseInt(sc.next());
		int tx = Integer.parseInt(sc.next());
		int ty = Integer.parseInt(sc.next());
		StringBuilder sb = new StringBuilder();
		for(int i=sy; i<ty; i++) {
		    sb.append("U");
		}
		for(int i=sx; i<tx+1; i++) {
		    sb.append("R");
		}
		for(int i=ty; i>sy-1; i--) {
		    sb.append("D");
		}
		for(int i=tx+1; i>sx; i--) {
		    sb.append("L");
		}
		sb.append("U");
		sb.append("L");
		for(int i=sy; i<ty+1; i++) {
		    sb.append("U");
		}
		for(int i=sx-1; i<tx; i++) {
		    sb.append("R");
		}
		for(int i=ty+1; i>sy; i--) {
		    sb.append("D");
		}
		for(int i=tx; i>sx; i--) {
		    sb.append("L");
		}
		System.out.println(String.valueOf(sb));
	}
	
}

Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		
		while(a < 1 && b > 100) { 
			a = stdIn.nextInt();
			b = stdIn.nextInt();
		}
		
		System.out.println(a * b + " " + 2 * (a + b));
		
	}
}


Measured memory_bytes: 26200
def main():
    s = input()
    t = input()
    s_len = len(s)
    t_len = len(t)
    def t_check(t_true,t_can):
            for tt,tc in zip(t_true,t_can):
                if tc != '?' and tt != tc:
                    return False
            else:
                return True

    if s_len < t_len:
        print('UNRESTORABLE')
    elif s_len == t_len:
        if t_check(t,s):
            print(t)
        else:
            print('UNRESTORABLE')
    else:
        ans = ""
        for i in range(s_len - t_len + 1)[::-1]:
            if t_check(t,s[i:i+t_len]):
                ans = s[:i] + t + s[i+t_len:]
                ans = ans.replace('?','a')
                print(ans)
                break
        else:
            print('UNRESTORABLE')
if __name__ == "__main__":
    main()

Measured memory_bytes: 38756
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr auto MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n, k;
    cin >> n >> k;
    VI a(n);
    multiset<int> s;
    FOR(i, 0, n) {
        cin >> a[i];
        s.insert(a[i]);
    }
    auto itr = s.begin();
    map<int, ll> map;
    int MIN = *itr;
    ll L = k * (k - 1) / 2 % mod;
    FOR(i, 0, s.size()) {
        if (i == 0 || (*itr != MIN && map[*itr] == 0)) {
            map[*itr] = i;
            map[*itr] = map[*itr] * L % mod;
        }
        itr++;
    }

    vector<ll> b(n);
    FOR(i, 0, n){
        ll cnt = 0;
        FOR(j, i + 1, n) {
            if (a[i] > a[j])cnt++;
        }
        b[i] = cnt * k % mod;
    }

    ll ans = 0;
    FOR(i, 0, n) {
        ans += b[i];
        ans %= mod;
        ans += map[a[i]] % mod;
        ans %= mod;
    }
    cout << ans << "\n";
}

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

int main(void){
  int N, T, c, minc = INT_MAX, t;
  cin >> N >> T;
  for(int i = 0; i < N; i++){
    cin >> c >> t;
    if(t <= T && c < minc) minc = c;
  }
  if(minc == INT_MAX) cout << "TLE" << endl;
  else cout << minc << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
d = list(map(int, input().split()))
b = 1
ans = 1
max = 0
dd=[0]*10**5
for i in d:
    dd[i]+=1
    if(max<i):
        max=i
if d[0] == 0 and d.count(0) == 1:
    for i in range(1, max+1):
        if dd[i] == 0:
            print(0)
            exit()
        if dd[i] == 1:
            ans *= b
        else:
            if b != 1:
                ans *= pow(b, dd[i], 998244353)
        b = dd[i]
    print(ans % 998244353)
else:
    print(0)

Measured memory_bytes: 14396
MOD = 10**9 + 7
S = input()
 
cur = [0] * 13
cur[0] = 1
r = 1
base = 0
for i in range(len(S)):
    s = S[-(i+1)]
    if s == '?':
        prev = cur
        cur = [sum(prev)] * 13
        for m in range(13):
            for d in range(10,13):
                cur[(m + r*d) % 13] -= prev[m]
        for m in range(13):
            cur[m] %= MOD
    else:
        base = (base + r*int(s)) % 13
 
    r = (10 * r) % 13
 
print(cur[(5-base) % 13])

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl '\n'
#define ld long double
typedef pair<ll,ll> pii;
const int maxn=500;
const int mod=1e9+7;
int a[maxn],b[maxn];
ll qp(ll a,ll b)
{
    ll ret=1;
    while(b)
    {
        if(b&1) ret=ret*a%mod;
        b>>=1;
        a=a*a%mod;
    }
    return ret;
}
ll f[maxn][maxn];
ll g[maxn][maxn];
void init()
{
    for(int i=1;i<=400;i++)
    {
        for(int j=0;j<=400;j++)
        {
            f[i][j]=f[i-1][j]+qp(i,j);
            f[i][j]%=mod;
        }
    }
}
int n,c;
ll solve(int now,int k)
{
    if(g[now][k]) return g[now][k];
    if(now==n) return g[now][k]=(f[b[now]][k]-f[a[now]-1][k])%mod;
    ll ret=0;
    for(int i=0;i<=k;i++)
    {
        ret+=(f[b[now]][i]-f[a[now]-1][i])*solve(now+1,k-i)%mod;
        ret%=mod;
    }
    return g[now][k]=ret;
}
int main()
{
    #ifdef local
    freopen("in.txt","r",stdin);
    #endif // local
    IOS;
    init();
    cin>>n>>c;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    ll ans=solve(1,c);
    ans=(ans+mod)%mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 3456
<?php
  
	list($num, $kinds) = explode(' ', trim(fgets(STDIN)));
	$children = array_fill(1, $num, true);

	for ($i = 1; $i <= $kinds; $i++) {
      $cnt = trim(fgets(STDIN));
	  $tmp = explode(' ', trim(fgets(STDIN)));
      $tmp = array_flip($tmp);
	  $children = array_diff_key($children, $tmp);
    }

echo count($children);

Measured memory_bytes: 16112
k,s = map(int,input().split())

count=0
for x in range(k+1):
  y_z = s-x
  if y_z < 0:
    count +=0
  elif 2*k < y_z:
    count += 0
  elif y_z <= 2*k:
    count += min(y_z+1,2*k-y_z+1)
        
print(count)

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

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define eps 1e-9
#define fast_cin ios_base::sync_with_stdio(false)

const int MOD = 1e9+7;

typedef long long ll;
typedef pair<int,int> pii;

ll gcd(ll a, ll b){
	if (b == 0)
	{
		return a;
	}
	else
		return gcd(b, a % b);
}

int main()
{
	//freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);
	fast_cin;
	int x,a,b;
	cin >> x >> a >> b;
	if (abs(x-a) > abs(x-b))
	{
		cout << "B\n";
	}
	else
		cout << "A\n";
	return 0;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
ll a[1000000+9]= {0},b[1000000+9]= {0};
using namespace std;
int main ()
{
    ll n,ans=0,i;

    cin>>n;
    a[0]=0;
    b[0]=0;
    for(i=1; i<=n; i++)
    {
        cin>>a[i];
        a[i]+=a[i-1];
    }

    for(i=1; i<=n; i++)
    {
        cin>>b[i];
        b[i]+=b[i-1];
    }
    //cout<<a[n]<<endl;
    //cout<<b[n]<<endl;
    ll p,x;
    for(i=1; i<=n; i++)
    {
        x=(b[n]-b[i-1]);
        p=a[i]+x;
        ans=max(ans,p);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
#define fcout cout<<fixed<<setprecision(10)
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
//template<typename T>void pp(T x){cout<<x<<endl;}

using namespace std;

int main(){
    int n,nn;
    cin>>n;
    nn=n;
    int t=0;
    while(n>0){
        t+=n%10;
        n/=10;
    }
    if(nn%t==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
//#include<algorithm>
//#include<cmath>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	cout << a / b << " " << a%b << " ";
	printf("%.8lf\n",1.0*a / b);
	return 0;
}

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

int a[9];
bool bingo[9];

int direction[8][3] = {
	{0, 1, 2},
	{3, 4, 5},
	{6, 7, 8},
	{0, 3, 6},
	{1, 4, 7},
	{2, 5, 8},
	{0, 4, 8},
	{2, 4, 6},
};

int main(){
	for(int i = 0; i < 9; i++)
		scanf("%d", &a[i]);
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		for(int j = 0; j < 9; j++)
			if(a[j] == x) bingo[j] = true;
	}
	for(int i = 0; i < 8; i++) {
		if(bingo[direction[i][0]] && bingo[direction[i][1]] && bingo[direction[i][2]]) {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll ai, ao, at, aj, al, as, az;
  cin >> ai >> ao >> at >> aj >> al >> as >> az;
  ll ans1 = ao, ans2 = ao;
  if (ai > 0 && aj > 0 && al > 0) {
    ans1 += 3;
    ans1 += ((ai - 1) / 2) * 2;
    ans1 += ((aj - 1) / 2) * 2;
    ans1 += ((al - 1) / 2) * 2;
  }
  ans2 += (ai / 2) * 2;
  ans2 += (aj / 2) * 2;
  ans2 += (al / 2) * 2;

  cout << max(ans1, ans2) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc=new Scanner(System.in);
    	int N=sc.nextInt();
    	int num=0;
    	for(int i=1;i<=9;i++){
    	    if(N<=(i*100+i*10+i)){
    	        num=i*100+i*10+i;
    	        break;
    	    }     
    	}
    	System.out.println(num);
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define bash push_back
#define alles(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
int dx[]={1,0,-1,0,1,1,-1,-1};
int dy[]={0,-1,0,1,-1,1,-1,1};
const int INF=1 << 30;
bool inside(int x,int y,int w,int h){
  return (x>=0 && y>=0 && x<w && y<h);}
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vit;
typedef map<string,int> mstit;
typedef priority_queue<int> pqit;
 
 
 
 
 
int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n;
  cin >>n;
  if(n==7||n==5||n==3) cout <<"YES\n";
  else cout <<"NO\n" ;
  

  return 0;
}


Measured memory_bytes: 256
a,b=map(str,input().split())
ab=""
ba=""
for i in range(int(a)):
    ab+=b
for i in range(int(b)):
    ba+=a
#print(ab)
#print(ba)
if(ab>ba):
    print(int(ba))
elif(ab==ba):
    print(int(ab))
else:
    print(int(ab))

Measured memory_bytes: 3064
#!/usr/bin/env python3

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

n, k = LI()
p = LI()
p.sort()
print(sum(p[:k]))

Measured memory_bytes: 67224
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
typedef pair<int,int> P;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define INF LLONG_MAX
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    set<lint> s;
    int n;
    cin>>n;
    while(n--){
        int a;
        cin >>a ;
        auto itr=s.find(a);
        if(itr==s.end()){
            s.insert(a);
        }else{
            s.erase(a);
        }
    }
    cout<<s.size()<<endl;
    return 0;
}


Measured memory_bytes: 4864
import Data.List

main :: IO ()
main = do
       [k,n] <- (map read . words) <$> getLine
       a <- (sort . map read . words) <$> getLine
       print $ solve k a
       
solve :: Int -> [Int] -> Int
solve k as = let space = sub (as ++ [(head as) + k]) 0
             in  k - space
               
sub :: [Int] -> Int -> Int
sub [] n      = n 
sub [x] n     = n
sub (x:xs) n  = sub xs $ max n (abs $ (head' xs) - x )

head' :: [Int] -> Int
head' [] = 0
head' xs = head xs 

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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)

#define ll long long int

int ctoi(char c) {return c-'0';}
int ord(char c) {return c-'a';}
int len(string s) {return s.length();}
int itoc(int i) {return i+'a';}

int main() {
double H,W;
cin>>H>>W;
if(H==1 or W==1) cout<<1<<endl;
else {
    H *= W;
    cout<<(long long int)(H+1)/2<<endl;
}
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
void Fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
}
inline int D()
{
    int t;
    scanf("%d",&t);
    return t;
}
inline ll llD()
{
    ll t;
    scanf("%lld",&t);
    return t;
}
const int Max=1e5+8;
const int OO=-1e6;
int xt[4]= {1,0,0,-1};
int yt[4]= {0,1,-1,0};
ll n,m,f,l;
bool valid(int x,int y)
{
    return x>-1 && y>-1 && x<n && y<m;
}

int mem[209][209][209],k;
        string st,st2;

void init()
{
    memset(mem,-1,sizeof mem);
}
/////////////////////////////////////////////////////////////////////
int solve (int i=0,int t=0,int j=n )
{

}

int main()
{

    int T=1;
///T=D();
    while(T-->0)
    {
       n=D();
      int x=D();
      int t= D();
    int ans=  (n/x)*t;
    if(n%x)ans+=t;
    cout<<ans;

    }

}


Measured memory_bytes: 3656
#include <cstdio>
#define ll long long
#define rep(i,j,k) for (i=j;i<=k;i++)
#define down(i,j,k) for (i=j;i>=k;i--)
using namespace std;
const int N=1e5+5;
ll n,m,top,i,div,rest,q[N],num[N],s[N],stk[N];
ll erfen(ll x)
{
	ll l=0,r=m,mid;
	while (l<r)
	{
		if (r-l>1) mid=(l+r)>>1;
		else mid=r;
		if (q[mid]<x) l=mid;
		else r=mid-1;
	}
	return l;
}
int main()
{
//	freopen("seq.in","r",stdin);
//	freopen("seq.out","w",stdout);
	scanf("%I64d%I64d",&n,&m); q[1]=n;
	rep(i,2,m+1) scanf("%lld",&q[i]);
	rep(i,1,m+1)
	{
		while (q[i]<=stk[top]) top--;
		stk[++top]=q[i];
	}
	m=top;
	rep(i,1,m) q[i]=stk[i];
	num[m]=1;
	down(i,m,1)
	{
		if (!num[i]) continue;
		rest=q[i];
		while (rest>0)
		{
			div=erfen(rest);
			if (!div) break;
			num[div]+=rest/q[div]*num[i];
			rest%=q[div];
		}
		s[1]+=num[i]; s[rest+1]-=num[i];
	}
	rep(i,1,n) { s[i]+=s[i-1]; printf("%lld\n",s[i]); }
	return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
const int somod = 1e9 + 7;
const int maxn = 307;

int n, m, l[maxn], r[maxn], cnt[maxn], dp[maxn][maxn][maxn];
vector<int> ask[maxn];

void add(int &a, int b)
{
   a += b;
   if(a >= somod) a -= somod;
}

int32_t main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   if(fopen("test.inp", "r")) freopen("test.inp", "r" ,stdin);
   cin >> n >> m;
   for(int i = 1; i <= m; i++)
   {
      cin >> l[i] >> r[i] >> cnt[i];
      if(cnt[i] > r[i] - l[i] + 1) return cout << 0 , 0; 
      ask[r[i]].push_back(i);
   }
   dp[1][0][0] = 1;
   dp[0][1][0] = 1;
   dp[0][0][1] = 1;
   int ans = 0;
   for(int mx = 1; mx < n; mx++)
   {
      for(int j = 0; j < max(mx, 1); j++)
      {
         for(int k = 0; k < max(mx, 1); k++)
         {
            if(j != 0 && j == k) continue;
            bool ok = 1;
            for(auto x: ask[mx])
            {
               int dem = 1;
               if(j >= l[x]) dem++;
               if(k >= l[x]) dem++;
               if(dem != cnt[x]) 
               {
                  ok = 0;
                  break;
               }
            }
            if(!ok) continue;
            /// case 1 (mx, j, k)
            add(dp[mx + 1][j][k], dp[mx][j][k]);
            add(dp[mx][mx + 1][k], dp[mx][j][k]);
            add(dp[mx][j][mx + 1], dp[mx][j][k]);
            /// case 2 (j, mx, k)
            add(dp[mx + 1][mx][k], dp[j][mx][k]);
            add(dp[j][mx + 1][k], dp[j][mx][k]);
            add(dp[j][mx][mx + 1], dp[j][mx][k]);
            /// case 3 (j, k, mx)
            add(dp[mx + 1][k][mx], dp[j][k][mx]);
            add(dp[j][mx + 1][mx], dp[j][k][mx]);
            add(dp[j][k][mx + 1], dp[j][k][mx]);
         }
      }
   }
   for(int j = 0; j < max(n, 1); j++)
   {
      for(int k = 0; k < max(n, 1); k++)
      {
         if(j != 0 && j == k) continue;
         bool ok = 1;
         for(auto x: ask[n])
         {
            int dem = 1;
            if(j >= l[x]) dem++;
            if(k >= l[x]) dem++;
            if(dem != cnt[x]) 
            {
               ok = 0;
               break;
            }
         }
         if(ok)
         {
            add(ans, dp[n][j][k]);
            add(ans, dp[j][n][k]);
            add(ans, dp[j][k][n]);
         }
      }
   }
   cout << ans;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<ld,ld> id;

#define FOR(i, a, b) for(int i=(a); i<=(b); i++)
#define ROF(i, a, b) for(int i=(a); i>=(b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
#define FILL(x, n, v) fill(x, x+n, v);
#define ALL(x) x.begin(), x.end()
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define f first
#define s second
#define ins insert
#define e emplace
#define eb emplace_back
#define ef emplace_front
#define p push
#define pf push_front
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ft front
#define bk back
#define pp pop
#define ppb pop_back
#define ppf pop_front

#define db cout<<"YEET\n";
#define ct(x) cout<<x<<'\n';

const ll MOD = 1e9+7; //998244353
const ll MAXN = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);

int main(){
    FAST
    ll n, k, c;
    string s;
    vector<ll> work;
    deque<ll> sd;

    ll pt1=0, pt2=0;
    cin >> n >> k >> c >> s;
    FOR(i,0,n-1){
        if (s[i] == 'o') work.pb(i+1);
    }

    ll sz = (ll)(work.size())-1;
    ll lastindex=-1;
    vector<ll> us, su;

    FOR(i,0,sz){
        if (lastindex == -1 || work[i]-c > lastindex) {
            lastindex = work[i];
            us.pb(work[i]);
        }
    }

    lastindex = -1;
    ROF(i,sz,0){
        if (lastindex == -1 || work[i]+c < lastindex) {
            lastindex = work[i];
            su.pb(work[i]);
        }
    }

    if (us.size() == k && su.size() == k){
        FOR(i,0,k-1){
            if (us[i] == su[k-i-1]) cout << us[i] << '\n';
        }
    }
}

Measured memory_bytes: 6664
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;
const ll maxn = 1e5 + 101;
ll m=0,p[200],c[200];
void divide(ll n){
    m=0;
    for(ll i=2;i*i<=n;++i){
        if(n%i==0){
            p[++m]=i,c[m]=0;
            while(n%i==0) n/=i,c[m]++;
        }
    }
    if(n>1) p[++m]=n,c[m]=1;
}
int main() {
    ll n;
    scanf("%lld",&n);
    divide(n);
    ll ans=0;
    for(ll i=1;i<=m;++i){
        ll fi=0,sum=0;
        while(sum<c[i]){
            fi++;
            sum+=fi;
        }
        if(sum==c[i]) ans+=fi;
        else ans+=fi-1;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3820
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;



int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    ll sum=0LL;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }

    int x = 0;//ラストが二郎の手番なら0
    if(n&1) {
        x = 1;
    }
    vector<vector<ll> > dp(n+1, vector<ll>(n+1, 0LL));
    rep(i, n+1) {
        rep(j, i+1) {
            if(!((i-j)%2) && i != j && x){
                dp[i][j] = INT64_MAX;
                dp[j][i] = INT64_MAX;
            }
            if(((i-j)%2) && !x) {
                dp[i][j] = INT64_MAX;
                dp[j][i] = INT64_MAX;
            }
        }
    }

    rep(i, n) {
        rep(j, n+1-i) {
            if(x) {
                if(j>0) {
                    dp[j-1][j+i] = max(dp[j-1][j+i], dp[j][j+i]+a[j-1]);
                }
                if(j+i<n) {
                    dp[j][j+i+1] = max(dp[j][j+i+1], dp[j][j+i]+a[j+i]);
                }
            } else {
                if(j>0) {
                    dp[j-1][j+i] = min(dp[j-1][j+i], dp[j][j+i]);
                }
                if(j+i<n) {
                    dp[j][j+i+1] = min(dp[j][j+i+1], dp[j][j+i]);
                }
            }

            
            
        }
        x ^= 1;
    }


    cout << 2*dp[0][n] - sum << '\n';
}

Measured memory_bytes: 70784
#include<stdio.h>
 
int main(void){
 
  int i;
  char moji;
 
  scanf("%c", &moji);
 
  if((moji>= 'a') && (moji<='z')){
    printf("a\n");
  }
  else if((moji>= 'A') && (moji<='Z')){
    printf("A\n");
  }
 
  return 0;
}

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


int main(){
  int N,M,sum=0,check=0;
  int A[100];
  cin >> N >> M;
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  for(int i=0;i<N;i++){
    sum+=A[i];
  }
    for(int i=0;i<N;i++){
    if(sum<=4*M*A[i]){
      check++;
    }
  }
  if(check<M){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma _attribute_((optimize("-O2")))
#pragma comment(linker, "/STACK:102400000,102400000")

#include <iostream>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <cstdio>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <string>
#include <sstream>
#include <time.h>
#include <complex>
#include <iomanip>
#define Endl endl
#define int long long

//#define Local

using namespace std;


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

	//freopen("input1.txt","r",stdin);
	//freopen("output1.txt","w",stdout);

	int n;
	cin>>n;
	vector<pair<int,int> > all;
	for(int i=0;i<n;i++)
	{
		int tmp;
		cin>>tmp;
		all.push_back({tmp,i});
	}
	vector<int> res(n);
	sort(all.begin(),all.end());
	for(int i=0;i<n;i++)
	{
		if(i<n/2)
			res[all[i].second]=all[n/2].first;
		else
			res[all[i].second]=all[n/2-1].first;
	}
	for(int i=0;i<n;i++)
		cout<<res[i]<<endl;


	#ifdef Local
	cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif
	return 0;
}


Measured memory_bytes: 7276
N = int(input())
s_dict = {}
for i in range(N):
  s = "".join(sorted(input()))
  if s in s_dict:
    s_dict[s] += 1
  else:
    s_dict[s] = 1
result = sum(v * (v - 1) // 2 for v in s_dict.values())
print(result)

Measured memory_bytes: 17848
#include <iostream> 
#include <bits/stdc++.h>
#include <vector> 
#include <algorithm> 
#include <string>
#include <cmath>
#include <iomanip> 
#include<climits> 
#include <utility>   
#include <set>
#include <numeric> 
#include <iterator>
#include <map> 
using namespace std; 
#define ll long long int
//typedef pair<ll,ll> p; 
int main()
{
      int n,x,y;
      cin>>n>>x>>y;
      map<int,int>m;
      for(int i=1;i<=n;i++)
      {
          for(int j=i+1;j<=n;j++)
          {
              int p;
              p=min(j-i,min(abs(x-i)+1+abs(y-j),abs(i-y)+1+abs(j-x)));
              m[p]++;
          }
      }
      for(int i=1;i<n;i++)
      {
          cout<<m[i]<<endl;
      }
      
      
      
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 171, task a, 2020/06/21
//ms,
/*
*/

#define MAX 1000
#define PMAX 1000

int main(void){
  int N;
  int K;
  vector<int> p(MAX);
  int ans=0;

  for(int i=0;i<MAX;i++) p[i] = PMAX+1;

  cin >>N >>K;
  for(int i=0;i<N;i++){
    cin >>p[i];
  }

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

  for(int i=0;i<K;i++) ans += p[i];

  cout <<ans;
  return 0;
}
/*
*/


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

int main(void){
  long long int n,k;
  cin >> n >> k;
  //if (n < k){
  //  cout << n << endl;
  //  return 0;
 // }
  long long int r = n/k;
  cout << min(abs(k*r-n),abs((r+1)*k-n)) << endl;
  return 0;
}

Measured memory_bytes: 3564
n, d = gets.chomp.split(" ").map(&:to_i)

points = []
ans = 0
n.times do
    input_point = gets.chomp.split(" ").map(&:to_i)
    points.each do |point|
        square_distance = 0.0
        d.times do |i|
            square_distance += (point[i] - input_point[i]) ** 2
        end
        distance = Math.sqrt(square_distance)
        if distance % 1 == 0
            ans += 1
        end
    end
    points.push(input_point)
end
puts ans


Measured memory_bytes: 1788
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	n := readInt()
	a := make([]int, n)
	b := make([]int, n)
	for i := range a {
		a[i] = readInt()
		b[i] = readInt()
	}
	var ans int
	for i := n - 1; i >= 0; i-- {
		c := ans + a[i]
		m := c % b[i]
		if m > 0 {
			ans += b[i] - m
		}
	}
	println(ans)

}

// -----------------------------------------------------------------------------


Measured memory_bytes: 5376
P = [2, 10, 3, 12, 5, 15]
Q = [380, 1520, 550, 1870, 850, 2244]
MAX = 50
Range = [0] + [1000000] * MAX

for p, q in zip(P, Q):
    for i in range(MAX - p + 1):
        Range[i + p] = min(Range[i + p],Range[i] + q)
while 1:
    v = int(input())
    if v == 0:
        break
    print(Range[v // 100])



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

void maxHeapify(int *,int);
void buildMaxHeap(int *);

int n=0;

int main(){
  int i;
  int *a;
  scanf("%d",&n);
  a=malloc(sizeof(int)*(n+1));
  for(i=1; i<=n; i++){
    scanf("%d",&a[i]);
  }
  /*for(i=1; i<=n; i++) printf(" %d",a[i]);
    printf("\n");*/
  buildMaxHeap(a);
  for(i=1; i<=n; i++) printf(" %d",a[i]);
  printf("\n");
  return 0;
}

void maxHeapify(int *a,int i){
  int l,r,largest;
  l=i*2;
  r=i*2+1;
  if(l<=n && a[l]>a[i]) largest=l;
  else largest=i;
  if(r<=n && a[r]>a[largest]) largest=r;
  //printf("DEBUG: largest=%d,a[largest]=%d,i=%d,a[i]=%d\n",largest,a[largest],i,a[i]);
  if(largest!=i){
    l=a[i];a[i]=a[largest];a[largest]=l;
    maxHeapify(a,largest);
  }
}

void buildMaxHeap(int *a){
  int i;
  //printf("DEBUG: a[1]=%d,n=%d\n",a[1],n);
  for(i=n/2; i>=1; i--){
    maxHeapify(a,i);
  }
}



Measured memory_bytes: 3648
n = input()
a = map(int, raw_input().split())
oo = sum(a) * n
cumul = [0] * (n + 1)
for i in range(n):
    cumul[i + 1] = cumul[i] + a[i]

dp = [[oo] * n for _ in range(n)]
for i in range(n):
    dp[i][i] = 0
for i in range(1, n):
    for j in range(n - i):
        k = j + i
        for l in range(j, k):
            dp[j][k] = min(dp[j][k], dp[j][l] + dp[l + 1][k])
        dp[j][k] += cumul[k + 1] - cumul[j]
print(dp[0][n - 1])

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};



int main()
{
  ll a;
  string _b;
  cin >> a >> _b;
  int b = (_b[0]-'0')*100 + (_b[2]-'0')*10 + (_b[3]-'0');
  a *= b;
  a /= 100;
  cout << a << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

template <int M> class ModInt {
    int x;

  public:
    constexpr ModInt() : x(0) {}
    constexpr ModInt(int64_t y) : x(y >= 0 ? y % M : (M - (-y) % M) % M) {}
    constexpr ModInt &operator+=(const ModInt p) {
        if((x += p.x) >= M) x -= M;
        return *this;
    }
    constexpr ModInt &operator-=(const ModInt p) {
        if((x += M - p.x) >= M) x -= M;
        return *this;
    }
    constexpr ModInt &operator*=(const ModInt p) {
        x = (int)(1LL * x * p.x % M);
        return *this;
    }
    constexpr ModInt &operator/=(const ModInt p) {
        *this *= p.inverse();
        return *this;
    }
    constexpr ModInt operator-() const { return ModInt(-x); }
    constexpr ModInt operator+(const ModInt p) const {
        return ModInt(*this) += p;
    }
    constexpr ModInt operator-(const ModInt p) const {
        return ModInt(*this) -= p;
    }
    constexpr ModInt operator*(const ModInt p) const {
        return ModInt(*this) *= p;
    }
    constexpr ModInt operator/(const ModInt p) const {
        return ModInt(*this) /= p;
    }
    constexpr bool operator==(const ModInt p) const { return x == p.x; }
    constexpr bool operator!=(const ModInt p) const { return x != p.x; }
    constexpr ModInt inverse() const {
        int a = x, b = M, u = 1, v = 0, t = 0;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
    constexpr ModInt pow(int64_t k) const {
        ModInt ret(1), mul(x);
        while(k > 0) {
            if(k & 1) ret *= mul;
            mul *= mul;
            k >>= 1;
        }
        return ret;
    }
    constexpr friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }
    constexpr friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t = 0;
        is >> t;
        a = ModInt(t);
        return (is);
    }
};
using mint = ModInt<mod>;

int n, c[200009];
mint ans, color[200009];

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

    cin >> n;
    rep(i, n) {
        cin >> c[i];
        c[i]--;
        if(i && c[i - 1] == c[i]) {
            i--;
            n--;
        }
    }
    ans = 1;
    rep(i, n) color[c[i]] = ans += color[c[i]];
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 5092
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <limits.h>
#include <float.h>
#include <numeric>
#include <queue>
#include <typeinfo>
#include <memory>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define fs first
#define sc second


int main(){
    int a, p;
    cin >> a >> p;
    cout << (a * 3 + p) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
//#define int long long
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define loop(s, v, it) for (s::iterator it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = e[i].nxt)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 200010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
const double eps = 1e-7 ;
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }
template <class T> void print(T a) { cout << a << endl ; exit(0) ; }
template <class T> void chmin(T &a, T b) { if (a > b) a = b ; }
template <class T> void chmax(T &a, T b) { if (a < b) a = b ; }
template <class T> void upd(T &a, T b) { (a += b) %= MOD ; }
template <class T> void mul(T &a, T b) { a = (ll) a * b % MOD ; }

int n, ans ;
int a[N], b[N] ;

signed main(){
//	file("test") ;
	scanf("%d", &n) ;
	string s ; cin >> s ;
	rep(i, 0, n - 1)
	a[i + 1] = a[i] + (s[i] == '#') ;
	per(i, n - 1, 0)
	b[i] = b[i + 1] + (s[i] == '.') ;
	int ans = n ;
	rep(i, 0, n) chmin(ans, a[i] + b[i]) ;
	printf("%d\n", ans) ;


	return 0 ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
	6.逆向思维？
*/




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

using pii = pair<int, int>;
using vvi = vector<vector<int>>;
using vi  = vector<int>;
#define sz(x) ((int)x.size())

struct UnionFind {
    vi data;
    int comp;
    UnionFind() {}
    UnionFind(int size) {
        init(size);
    }
    void init(int size) {
        data.assign(size, -1);
        comp = size;
    }
    void unite(int x, int y) {
        x = root(x); y = root(y);
        if(x != y) {
            if(data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
            comp--;
        }
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        if (data[x] < 0) {
            return x;
        } else {
            return data[x] = root(data[x]);
        }
    }
    int size(int x) {
        return -data[root(x)];
    }
    int components() {
        return comp;
    }
};

template <class Graph>
struct LCA {
    using Query = pii;
    Graph g;
    vi color;
    vi ancestor;
    vector<vector<pair<int, Query>>> query_set;
    vi res;
    UnionFind uf;
    LCA(const Graph &g, vector<Query> &query) :
            g         (g),
            color     (sz(g)),
            ancestor  (sz(g)),
            query_set (sz(g)),
            res       (sz(query)),
            uf        (sz(g))
    {
        int qs = sz(query);
        rep(i, 0, qs) {
            query_set[query[i].first ].emplace_back(i, query[i]);
            query_set[query[i].second].emplace_back(i, query[i]);
        }
    }
    void visit(int s, int prev) {
        ancestor[uf.root(s)] = s;
        for (auto &e : g[s]) {
            if (e == prev) {
                continue;
            }
            visit(e, s);
            uf.unite(s, e);
            ancestor[uf.root(s)] = s;
        }
        color[s] = 1;
        for (auto &p : query_set[s]) {
            Query q = p.second;
            int w = (q.second == s ? q.first : (q.first == s ? q.second : -1));
            if (w == -1 || !color[w]) {
                continue;
            }
            res[p.first] = ancestor[uf.root(w)];
        }
    }
    vi solve(int root) {
        visit(root, -1);
        return res;
    }
};

signed main() {
    int N;
    cin >> N;
    vector<vector<int>> G(N);
    rep(i, 0, N) {
        int K;
        cin >> K;
        rep(k, 0, K) {
            int X;
            cin >> X;
            G[i].push_back(X);
            G[X].push_back(i);
        }
    }
    int Q;
    cin >> Q;
    vector<pii> queries;
    rep(i, 0, Q) {
        int U, V;
        cin >> U >> V;
        queries.emplace_back(U, V);
    }
    LCA<vvi> lca(G, queries);
    vi res = lca.solve(0);

    for (int ans : res) {
        cout << ans << endl;
    }
}



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

using ll = long long;

ll K;

void solve(){
    queue<ll> q;
    for(ll i = 1; i <= 9; ++i){
        q.push(i);
    }
    ll i = 1;
    while(true){
        ll t = q.front();
        q.pop();
        if(i == K) { cout << t; return; }
        ll u = t * 10 + t % 10;
        if(u % 10 != 0) q.push(u - 1);
        q.push(u);
        if(u % 10 != 9) q.push(u + 1);
        i++;
    }
}
int main(){
    cin >> K;
    solve();
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#define N 100000

typedef struct point{
	int x;
	int y;
}point;


int compare_pointX(const void *a,const void *b){
	point *A=(point *)a;
	point *B=(point *)b;
	return A->x-B->x;
}

int compare_pointY(const void *a,const void *b){
	point *A=(point *)a;
	point *B=(point *)b;
	return A->y-B->y;
}


int main(){
	int n,i,cnt;
	point P[N];
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&P[i].x,&P[i].y);
	}
	
	qsort(P,n,sizeof(point),compare_pointX);
	
	cnt=1;
	for(i=1;i<n;i++){
		if(P[i].x==P[i-1].x)cnt++;
		else {
			qsort(&P[i-cnt],cnt,sizeof(point),compare_pointY);
			cnt=1;
		}
	}
	if(cnt!=1)qsort(&P[n-cnt],cnt,sizeof(point),compare_pointY);
	
	
	for(i=0;i<n;i++){
		printf("%d %d\n",P[i].x,P[i].y);
	}
	
	return 0;
	
}


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

int A, B, C, D;

int main() {
	cin >> A >> B >> C >> D;
	int t = min(B, D) - max(A, C);
	if(t >= 0) cout << min(B, D) - max(A, C) << endl;
	else cout << 0 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    double x1,y1,x2,y2;
    cin >> x1 >> y1;
    cin >> x2 >> y2;
    double d=pow(x1-x2,2)+pow(y1-y2,2);
    double D=sqrt(d);
    cout << fixed << setprecision(8) << D;
    cout << endl;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n));

void fast() {
    cin.tie(0);
    cin.sync_with_stdio(0);
}





int main() {
int n,k;cin>>n>>k;
int arr[n];
    for (int i = 0; i <n ; ++i) {
        cin>>arr[i];
    }
    int dp[100009];
    clr(dp,0);
    for (int j = 0; j <=k ; ++j) {
        for (int i = 0; i < n; ++i) {
            if (arr[i] <= j) {
                if (!dp[j - arr[i]]) {
                        dp[j] = 1;
                        break;
                    }
                }
            }
        }
    cout<<(dp[k]?"First":"Second");
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

int main() {
	ll x, t, ans;
	cin >> x >> t;
	ans = max(0LL, x - t);
	wrln(ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n;
  cin>>n;
  if(n%26==0)
  {
      
  }
  string s="";
  while(n>0)
  {
      n--;
    s+='a'+n%26;
    n/=26;
  }
  reverse(s.begin(),s.end());
  cout<<s;
}

Measured memory_bytes: 3540