akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>>
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("input.txt","r",stdin);freopen("ans.txt","w",stdout)
#define mp make_pair
#define pll pair <lli,lli>
#define vll vector <lli>
#define pq2 priority_queue<pair<lli,lli>>
#define f first
#define s second
#define pb push_back
#define pf push_front
#define minii LLONG_MAX
#define all(x) x.begin(), x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define ld long double
const long double pi = 3.1415926535898;
#define dec greater<lli>()
const lli mod=1000000007;
//const lli mod=100000000;
using namespace std;
lli lcm (lli a, lli b) {return ((a*b)/__gcd(a,b));}
lli modpower (lli a,lli b)
{
    if(b==0) return 1;
    lli c=modpower(a,b/2)%mod;
    if (b%2) return (((a*c)%mod)*c)%mod;
    else return (c*c)%mod;
}
lli power (lli a,lli b)
{
    if(b==0) return 1;
    lli c=power(a,b/2);
    if (b%2) return (a*c*c);
    else return c*c;
}
bool prime (lli k)
{
    if (k==1||k==0) return 0;
    bool flag=1;
    lli a=sqrt(k);
    for (int i=2;i<=a;i++)
    {
        if (k%i==0)
        {flag=0;break;}
    }
    return flag;
}
lli sieve (int n)
{
    bool qrr[n+1];
    for (int i=0;i<=n;i++)
    qrr[i]=1;qrr[0]=0;qrr[1]=0;
    for (int i=2;i<=n;i++)
    {
        if (qrr[i]==1)
        {
            for (int j=i;j<=n;j+=i)
            {qrr[j]=0;}
        }
    }
    return 0;
}
int main()
{
    lli n,k;
    cin>>n>>k;
    lli a[n];
    for (int i=0;i<n;i++)
    cin>>a[i];
    lli l=1,r=1e9,mini=1e18;
    while (l<=r)
    {
        lli mid=(l+r)/2;
        lli sum=0,maxi=0;
        for (int i=0;i<n;i++)
        {
            sum+=a[i]/mid;
            if (a[i]%mid==0)
            sum--;
            maxi=max(maxi,min(mid,a[i]));
        }
        //cout<<mid<<" "<<sum<<"\n";
        if (sum<=k)
        {
            mini=min(maxi,mini);
            r=mid-1;
        }
        else 
        {
            l=mid+1;
        }
    }
    cout<<mini;
    return 0;
}

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

int main()
{
  int a, b;

  while (cin >> a >> b){
    if (a < b)  swap(a, b);
    while (b != 0){
      int r = a % b;
      a = b;
      b = r;
    }
    cout << a << endl;
  }
  return (0);
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const int Maxn = 1e6;
const ll MAX=-1e18;

ll dp_f[Maxn],dp_e[Maxn],a[Maxn];

priority_queue<ll,vector<ll>,greater<ll> > que;
priority_queue<ll>pque;

void Slove_f(int n){
	ll sum_f=0;
	for(int i=1;i<=3*n;i++){
		que.push(a[i]);
		sum_f+=a[i];
		dp_f[i]=sum_f;
		if(que.size()>n){
			sum_f -= que.top();
			que.pop();
			dp_f[i] =sum_f;
		}
	}
}

void Slove_e(int n){
	ll sum_e=0;
	for(int i=3*n;i>=1;i--){
		pque.push(a[i]);
		sum_e+=a[i];
		dp_e[i]=sum_e;
		if(pque.size()>n){
			sum_e-=pque.top();
			pque.pop();
			dp_e[i]=sum_e;
		}
	}
}

int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=3*n;i++) scanf("%lld",&a[i]);

	Slove_f(n);
	Slove_e(n);

	ll ans=MAX;
	for(int i=n;i<=2*n;i++){
		ans=max(ans,dp_f[i]-dp_e[i+1]);
	}
	printf("%lld\n",ans);
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define RREP(i, a, b) for (int i = int(a) - 1; i >= int(b); i--)
#define sz(x) (int)(x).size()

using namespace std;
using ll = long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  int b = a[2] * 2 - a[1] - a[0];
  int sum = a[0] + a[1] + 2 [a];
  if (sum % 2 == a[2] % 2) {
    cout << b / 2 << endl;
  } else {
    cout << b / 2 + 2 << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int m,n,s,e;
	int sum;
	int i;
	while(cin >> m,m)
	{
		sum=0;
		cin >> n;
		for(i=0;i<n;i++)
		{
			cin >> s >> e;
			sum+= e-s;
		}
		if(sum>=m) cout << "OK\n";
		else cout << m-sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
N = int(input())
num = list(map(int, input().split()))

ans = 0
del_num = []

for index, i in enumerate(num):
    if i == ans + 1:
        ans += 1
    else:
        del_num.append(index)

if len(num) == len(del_num):
    print(-1)

else:
    print(len(del_num))

Measured memory_bytes: 24872
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<math.h>
#define rep(i,l,r) for(int i=l;i<r;i++)

typedef long long ll;

ll min(ll a, ll b) { return a < b ? a : b; }

int main() {
    ll n, k, h[100000];
    scanf("%lld%lld", &n, &k);
    rep(i, 0, n) scanf("%lld", &h[i]);
    ll dp[100000];
    dp[0] = 0;
    rep(i, 1, n) {
        dp[i] = dp[i - 1] + labs(h[i] - h[i - 1]);
        rep(j, 2, k + 1) {
            if (i >= j)dp[i] = min(dp[i], dp[i - j] + labs(h[i] - h[i - j]));
        }
    }
    printf("%lld", dp[n - 1]);

    return 0;
}

Measured memory_bytes: 3696
K = int(input())
S = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'
A = list(map(int, S.split(',')))
print(A[K-1])

Measured memory_bytes: 38384
package main

import (
	"fmt"
)

func main() {
	var text string
	fmt.Scan(&text)

	bCnt := 0
	wCnt := 0

	for i, r := range text {
		if i%2 == 0 {
			if r == '1' {
				bCnt++
			} else {
				wCnt++
			}
		} else {
			if r == '0' {
				bCnt++
			} else {
				wCnt++
			}
		}
	}

	if bCnt < wCnt {
		fmt.Printf("%v\n", bCnt)
	} else {
		fmt.Printf("%v\n", wCnt)
	}
}


Measured memory_bytes: 1280
n=int(input())
dp=[0]*(n+1)
for i in range(n+1):
  t=i
  count=0
  while t>0:
    count+=t%6
    t//=6
  t=n-i
  while t>0:
    count+=t%9
    t//=9
  dp[i]=count
print(min(dp))

Measured memory_bytes: 9460
using System;
class Program
    {
        static void Main(string[] args)
        {           
            // A,B,Cの入力
            string[] str = Console.ReadLine().Split(' ');
            // 1回a円
            int a = int.Parse(str[0]);
            // 持っている金額b円
            int b = int.Parse(str[1]);
            // 最大回数
            int c = int.Parse(str[2]);

            if(b/a < c)
            {
                Console.WriteLine(b/a);
            }
            else
            {
                Console.WriteLine(c);
            }
        } 
    }

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=310;
int C[N][N],f[N][N],s[N][N];
int main() {
    int n,k,Mo;
    cin>>n>>k>>Mo;
    for(int i=0;i<=n;i++)
	for(int j=C[i][0]=1;j<=i;j++)
	    C[i][j]=(C[i-1][j]+C[i-1][j-1])%Mo;
    for(int i=0;i<=k;i++) f[i][0]=1;
    for(int i=1;i<=n;i++) {
	for(int j=k;j;j--)
	    s[j][i-1]=(s[j+1][i-1]+f[j][i-1])%Mo;
	for(int j=0;j<=k;j++)
	    for(int p=0;p<i;p++)
		f[j][i]=(f[j][i]+1LL*s[j+1][p]*f[j][i-1-p]%Mo*C[i-1][p])%Mo;
    }
    cout<<f[0][n];
    return 0;
}

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

int main(){
  int n, k;
  k = 0;
  string s;
  cin >> n >> s;
  if(n % 2 == 0){
    for(int i = 0; i < n / 2; i++){
      if(s[i] != s[i + n / 2])
        k = 1;
      if(i == n / 2 - 1 && k == 0){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
a = int(input())
b = []
c = list(map(int, input().split()))
d = 0
for i in range(1, len(c)):
    if c[i] == c[i-1]:
        d += 1
    else:
        if d != 0:
            b.append(d+1)
            d = 0
if d != 0:
    b.append(d+1)
e = 0
for i in b:
    e += i // 2
print(e)


Measured memory_bytes: 3060
N, M = map(int, input().split())

class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return False
        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return True

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

uf = UnionFind(N)
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.union(a, b)
print(sum(x < 0 for x in uf.parents)-1)

Measured memory_bytes: 10800
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define INF 999999999
using namespace std;
int main() {
  int N,M;
  int sum = 0;
  std::cin >> N >> M;
  for (size_t i = 0; i < M; i++) {
    int a;
    std::cin >> a;
    sum += a;
  }
  if (N-sum >= 0) {
    std::cout << N-sum << '\n';
  }
  else{
    std::cout << -1 << '\n';
  }

}


Measured memory_bytes: 3636
#[allow(unused_imports)] use proconio::{input, marker::{Bytes, Chars, Usize1, Isize1}};
#[allow(unused_imports)] use std::cmp::{min, max};
#[allow(unused_imports)] use superslice::Ext as _;

#[proconio::fastout]
fn main() {
	input! {
		n: usize,
		a: [usize; n],
	}

	// すべてのaiについて、下位から0が並ぶ個数の和

	let mut ans = 0;
	for i in 0..n {
		ans += a[i].trailing_zeros();
	}

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


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

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

    int64_t ans = 0;
    if (A <= K)
    {
        ans += A;
        if (K-A >= B)
        {
            if (K-A-B >= C)
            {
                ans -= C;
                cout << ans;
                exit(0);
            }
            else
            {
                ans -= K-A-B;
                cout << ans;
                exit(0);
            }
            
            
        }
        else
        {
            cout << ans;
            exit(0);
        }
        
        
    }
    else
    {
        ans += K;
        cout << ans;
        exit(0);
    }
    
    
    
}

Measured memory_bytes: 3644
#include <iostream>

using namespace std;

int main()
{
   int N,M,ar,br;
   cin>>N>>M;
   int a[M],b[M],r[N+1];
   //N=number of cities
   //M=number of roads
   //r=number of roads from that city
   for(int h=1;h<N+1;h++){
       r[h]=0;
   }
   for(int i=0;i<M;i++){
       cin>>a[i]>>b[i];
       
   }
   for(int j=0;j<M;j++){
       for(int l=1;l<N+1;l++){
           if(a[j]==l||b[j]==l){
               r[l]++;
           }
           
       }
   }
   for(int k=1;k<N+1;k++){
       cout<<r[k]<<endl;
   }
   return 0;
}

Measured memory_bytes: 256
package main

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

func main() {

	N := nextInt()
	a := N % 10

	if a == 3 {
		fmt.Println("bon")
	} else if a == 0 || a == 1 || a == 6 || a == 8 {
		fmt.Println("pon")
	} else {
		fmt.Println("hon")
	}
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 1788
import math


class SegmentTree:
    __slots__ = ["elem_size", "tree_size", "tree"]

    def __init__(self, a: list, default: int):
        real_size = len(a)
        self.elem_size = 1 << math.ceil(math.log2(real_size))
        self.tree_size = 2 * self.elem_size + 1
        self.tree = [default] * (self.elem_size - 1) + a + [default] * (self.elem_size - real_size)

    def get_range_index(self, x, y, k=0, l_end=0, r_end=None):
        '''[x, y], tree[k], [l_end, r_end)'''
        default, tree = 0, self.tree
        if r_end is None:
            r_end = self.elem_size

        if l_end == x and y == r_end-1:
            return tree[k]

        mid = (l_end + r_end) // 2
        left_y = y if y < mid-1 else mid-1
        right_x = x if x > mid else mid

        left = self.get_range_index(x, left_y, 2*k+1, l_end, mid) if x <= left_y else default
        right = self.get_range_index(right_x, y, 2*k+2, mid, r_end) if right_x <= y else default
        return left + right

    def get_value(self, x, y):
        tree = self.tree
        return self.get_range_index(x, y)

        # return sum(tree[n] for n in index_list)

    def update_tree(self, k: int):
        tree = self.tree

        while k > 0:
            k = (k-1) // 2
            left, right = tree[2*k+1], tree[2*k+2]
            tree[k] = left + right

    def set_value(self, i: int, value: int, op: str):
        k = self.elem_size - 1 + i
        if op == "=":
            self.tree[k] = value
        elif op == "+":
            self.tree[k] += value
        self.update_tree(k)


n, q = map(int, input().split())
rsq = SegmentTree([0]*n, 0)
ans = []
for _ in [0]*q:
    c, x, y = map(int, input().split())
    if c == 0:
        rsq.set_value(x-1, y, "+")
    else:
        ans.append(rsq.get_value(x-1, y-1))
print("\n".join([str(n) for n in ans]))

Measured memory_bytes: 18596
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

main :-
    get_number(A, B),
    X is (A + B + 1) div 2,
    writeln(X).


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

ll calcPaths(vector<vector<char>> grid, int H, int W) {
    vector<vector<ll>> dp(H, vector<ll>(W, 0));
    dp[0][0] = 1ll;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (grid[i][j] != '#') {
                if (i > 0 && grid[i-1][j] != '#') dp[i][j] = (dp[i][j] + dp[i-1][j])%MOD;
                if (j > 0 && grid[i][j-1] != '#') dp[i][j] = (dp[i][j] + dp[i][j-1])%MOD;
            }
        }
    }
    return dp[H-1][W-1];
}

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> grid(H, vector<char>(W));
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++)
            cin >> grid[i][j];
    cout << calcPaths(grid, H, W) << endl;
    return 0;
}

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

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int keta(ll n){
  ll tmp=0;
  while(n>0){
    tmp += n%10;
    n = n/10;
  }
  return tmp;
}

int main(){
  ll n;
  cin >> n;
  n++;
  string sn = to_string(n);
  char c = sn[0];
  int first = c - '0';

  int size = sn.size();

  int ans = 9*(size-1) +  first-1;

  cout << ans;

}

Measured memory_bytes: 3640
// "include" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>
// }}}

using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9+7;

int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<pii> task(n);
	rep(i,n){
		cin >> task[i].second >> task[i].first;
	}
	sort(all(task));
	int time = 0;
	rep(i,n){
		time += task[i].second;
		if(task[i].first < time){
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;	
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount



int t, n, m, k, a[300010], q, l, r;



int32_t main(){
INIT
char c; cin>>c;

if( c<='z' && c>='a'){
    cout<<"a";
}
else{
    cout<<"A";
}



return 0;
}



Measured memory_bytes: 3644
#include <stdio.h>

int main (void)
{
	int a, b, c, d, n, cnt;
	
	while ( scanf("%d", &n) != EOF )
	{
		cnt = 0;
		
		for (a = 0; a <= 9; a++)
		{
			for (b = 0; b <= 9; b++)
			{
				for (c = 0; c <= 9; c++)
				{
					for (d = 0; d <= 9; d++)
					{
						if(a+b+c+d == n)
						{
							cnt++;
						}
					}
				}
			}
		}
		
		printf("%d\n", cnt);
	}
	
	return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
template <typename Abelian>
struct BIT {
  BIT(int n, const Abelian UNITY = 0) : n(n), UNITY(UNITY) {
    ++n;
    dat.assign(n, UNITY);
  }

  void add(int idx, Abelian value) {
    while (idx < n) {
      dat[idx] += value;
      idx += idx & -idx;
    }
  }

  Abelian sum(int idx) {
    Abelian res = UNITY;
    while (idx > 0) {
      res += dat[idx];
      idx -= idx & -idx;
    }
    return res;
  }

  int lower_bound(Abelian value) {
    if (value < UNITY) return 0;
    int res = 0, exponent = 1;
    while (exponent < n) exponent <<= 1;
    for (int mask = exponent >> 1; mask > 0; mask >>= 1) {
      if (res + mask < n && dat[res + mask] < value) {
        value -= dat[res + mask];
        res += mask;
      }
    }
    return res + 1;
  }

private:
  int n;
  const Abelian UNITY;
  vector<Abelian> dat;
};
// BIT<long long> bit(n, 単位元 = 0) = 要素数 n の BIT を考える
// bit.add(idx, value) = (a[idx] += value)
// bit.sum(idx) = Σ_[i=1,idx]a[i]
// bit.lower_bound(value) = min{k : Σ_[i=1,k]a[i] >= value}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> a(n), com;
  REP(i, n) {
    cin >> a[i];
    com.emplace_back(a[i]);
  }
  sort(ALL(com));
  com.erase(unique(ALL(com)), com.end());
  REP(i, n) a[i] = lower_bound(ALL(com), a[i]) - com.begin() + 1;
  int ans = 0;
  BIT<int> bit(n);
  REP(i, n) {
    int s = bit.sum(a[i] - 1);
    if (s == 0) {
      ++ans;
      bit.add(a[i], 1);
      continue;
    }
    int idx = bit.lower_bound(s);
    bit.add(idx, -1);
    bit.add(a[i], 1);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1528
#include<bits/stdc++.h>
#define N 1005
#define int long long
using namespace std;
int n,m,a[N],cnt[N],tot;
char c[N];
bool b[N];
signed main(){
	scanf("%lld",&n);
	bool bo=1;int t=10,ans=0;
	for(int i=1;i<=n;i++){
		if(i%t==0)bo=!bo,t*=10;
		if(bo)ans++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, x, m int
	fmt.Scan(&n, &x)
	l := 1001
	for i := 0; i < n; i++ {
		fmt.Scan(&m)
		x -= m
		if l > m {
			l = m
		}
	}
	fmt.Println(x/l + n)
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void){
	double a, b, c, d, e, f;
	double alpha, beta;
	double x, y;
	double ratio;

	while(1){
		if(scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != 6){
			break;
		}

		ratio = 1 /(a*e - b*d);
		x = ratio * (e * c + -1 * b * f);
		y = ratio * (-1 * d * c + a * f);

		if(x == 0){
			x = 0;
		}
		if(y == 0){
			y = 0;
		}

		printf("%.3f %.3f\n", x, y);
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int n;
    cin >> n;
    int a[30];
    int b[30];
    int c[30];
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i, n-1) cin >> c[i];
    int ans = 0;
    int prev_ai = -10;
    rep(i, n){
        ans += b[a[i] - 1];
        if(prev_ai + 1 == a[i]){
            ans += c[prev_ai - 1];
        }
        prev_ai = a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const long long MOD = 998244353;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
constexpr auto PI = 3.14159265358979323846264338327950L;
int needleX[4] = { -1,0,1,0 };
int needleY[4] = { 0,1,0,-1 };

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> a(N);
    map<ll, ll> mp;
    ll sum = 0;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        mp[a[i]]++;
        sum += a[i];
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        ll b, c;
        cin >> b >> c;
        ll temp = mp[b] * b;
        ll add=c*mp[b];
        mp[c] += mp[b];
        mp[b] = 0;
        sum += add;
        sum -= temp;
        cout << sum << endl;
        
    }
    return 0;
}


Measured memory_bytes: 10120
#include <stdio.h>
#include <string.h>
int main(int argc, const char * argv[]) {
    char s[300], p[300], ssub[300];
    scanf("%s",s);
    scanf("%s",p);
    strcpy( ssub , s );
    strcat( s , ssub );
    if( strstr(s,p) != 0 ){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

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

int main(){
    char s[4], t[4];
    cin >> s;
    cin >> t;
    int ans = 0;
    REP(i,3){
        if(s[i] == t[i])
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include <algorithm>
#include<cstring>
#include <math.h>
#include <iomanip>
using namespace std;

class saikoro
{
 public:
  int one;
  int two;
  int three;
  int four;
  int five;
  int six;
};


int main()
{
  saikoro a;
  cin>>a.one>>a.two>>a.three>>a.four>>a.five>>a.six;
  string s;
  cin>>s;
  int n;
  for(int i=0;i<s.length();i++){
    if(s[i]=='N'){
      n=a.one;
      a.one=a.two;
      a.two=a.six;
      a.six=a.five;
      a.five=n;
    }
    else if(s[i]=='E'){
      n=a.one;
      a.one=a.four;
      a.four=a.six;
      a.six=a.three;
      a.three=n;
    }
    else if(s[i]=='W'){
      n=a.one;
      a.one=a.three;
      a.three=a.six;
      a.six=a.four;
      a.four=n;
    }
    else if(s[i]=='S'){
      n=a.one;
      a.one=a.five;
      a.five=a.six;
      a.six=a.two;
      a.two=n;
    }
  }
  cout<<a.one<<endl;
  return 0;
  
}      



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

int main(){
    int ANS = 0;

    int N, K;
    cin >> N >> K;

    char temp[N];
    int stats[N];
    int LR = 0;
    int RL = 0;
    int limit;
    for(int i=0; i<N; i++){
        cin >> temp[i];
        if(temp[i] == 'L') stats[i] = 0;
        else stats[i] = 1;

        if(i!=0){
            if(stats[i-1]==stats[i]) ANS++;
            else if(stats[i-1]==0 && stats[i]==1) LR++;
            else RL++;
        }
    }

    limit = min(LR, RL);

    for(int i=0; i<K; i++){
        if(LR>0 && RL>0){
            ANS += 2;
            LR--;
            RL--;
        }else if(LR>0 || RL>0){
            if(LR>0){
                ANS++;
                LR--;
            }else{
                ANS++;
                RL--;
            }
        }else{
            break;
        }
    }

    cout << ANS << endl;
}

Measured memory_bytes: 768
import sys
import math
#n = int(input())
#s, t = map(str, input().split())
n, k = map(int, input().split())
#s = input()
p = list(map(int, input().split()))

x = sum(p[:k])
y = 0
max = 0
for i in range(n-k):
  y = y + p[k+i] - p[i]
  if y > max:
    max = y

print((x+max+k) / 2)


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong W, H, x, y;
	cin >> W >> H >> x >> y;

	ldbl S = W*H/2.0;
	cout << S << endl;
	if (x == W/2 && W%2 == 0 && y == H/2 && H%2 == 0)
		cout << 1 << endl;
	else
		cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
s = ns()
t = ns()
cons = 0
for i in range(1,n+1):
    if s[n-i:] == t[:i]:
        cons = i
        
print(2*n-cons)

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


void solve(long long N, std::vector<long long> a){
    sort(a.begin(), a.end());
    cout << a[a.size()-1]-a[0]<< endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
p = [int(x) for x in input().split()]
cnt = 0
for i in range(N-1):
    if (i + 1) == p[i]:
        p[i], p[i+1] = p[i+1], p[i]
        cnt += 1
if p[-1] == N:
    print(cnt + 1)
else:
    print(cnt)

Measured memory_bytes: 13876
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(auto i = (a); i < (b); i++)
#define pb push_back
#define fs first
#define sc second
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const double EPS = 1e-9;

ll PREF[200'020][12];
ll md = 998244353;

ll n,q;
ll solve(ll l, ll r, ll digit) {
    ll at1 = n-(l+1);
    ll at2 = n-(r+1);
    ll sm = PREF[at1+1][digit] - PREF[at2][digit];
    if(sm < 0) sm += md;
    return sm % md;
}

struct node {
        node* left = NULL;
        node* right = NULL;
        ll atl, atr, val;
        ll lazy = 0;

        node(node* l, node* r, ll v, ll al, ll ar) {
                left = l; right = r; val = v;
                atl = al; atr = ar;
        }

        void lazyupdate(ll l, ll r, ll by) {
                if(lazy != 0) propagate();

                if(l > atr || r < atl) return;
                if(l <= atl && atr <= r) {
                        val = solve(atl,atr,by);
                        if(left != NULL) {
                                left->lazy = by;
                                right->lazy = by;
                        }
                        return;
                }
                left->lazyupdate(l,r,by);
                right->lazyupdate(l,r,by);
                val = (left->val+right->val) % md;
        }
        ll lazyquery(ll l, ll r) {
                if(l > atr || r < atl) return 0;
                if(lazy != 0) propagate();
                if(l <= atl && atr <= r) return val;
                ll val = left->lazyquery(l,r) + right->lazyquery(l,r);
                return val % md;
        }

        void propagate() {
                val = solve(atl,atr,lazy);
                if(left != NULL) {
                        right->lazy = lazy;
                        left->lazy = lazy;
                }
                lazy = 0;
        }
};
node* build(ll l, ll r) {
        if(l > r) return NULL;
        if(l == r) return new node(NULL, NULL, 0, l, r);
        ll m = (l+r)/2;
        node* left = build(l,m);
        node* right = build(m+1,r);
        node* cur = new node(left,right,0,l,r);
        return cur;
}



int main() {
    cin.sync_with_stdio(false);
    cin >> n >> q;
    memset(PREF,0,sizeof(PREF));
    rep(j,1,10) {
        ll val = j;
        rep(i,0,n) {
            PREF[i+1][j] = (PREF[i][j] + val) % md;
            val *= 10;
            val %= md;
        }
    }
    node* root = build(0,n+10);
    rep(i,0,n) root->lazyupdate(i,i,1);


    rep(i,0,q) {
        ll l,r,d;
        cin >> l >> r >> d;
        l--;r--;
        root->lazyupdate(l,r,d);
        cout << root->lazyquery(0,n-1) << endl;
    }
}



Measured memory_bytes: 47412
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mod 1000000007
#define vll vector<ll>
#define inf 1e18
#define pll pair<ll,ll>
#define ff first 
#define ss second 
#define PI acos(-1)
using namespace std;

int main() 
{
    fastio; 
    ll T=1;
    //cin>>T; 
    while(T--)
    { 	
    	ll x;
    	cin>>x;
    	if(x>=30)cout<<"Yes";
    	else cout<<"No";
	}
}
 

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;
    int m,day,r;
    cin>>n>>m;
    pii arr[n];
    rep(i,0,n)
    {
        cin>>arr[i].F>>arr[i].S;
    }
    sort(arr,arr+n);
    priority_queue<int> pq;
    int h=0;
    ll ans=0;
    for(i=1;i<=m;i++)
    {
        while(h<n && arr[h].F<=i)
        {
            pq.push(arr[h].S);
            h++;
        }
        if(!pq.empty())
        {
            ans+=pq.top();
            pq.pop();

        }
    }
    cout<<ans;
    return 0;
}



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

int main() {
  ll n,k;
  cin >> n >> k;
  vector<ll> x(n);
  for(ll i=0;i<n;i++) {
    cin >> x[i];
  }
  ll ans=0;
  for(ll i=0;i<n;i++) {
    ans+=2*min(abs(x[i]),abs(x[i]-k));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
 vector<int> vi[maxii];
 vector<int>:: iterator child;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];
bool check[maxii];

bool dfs(int node,int c)
{
    check[node]=true;
    arr2[node]=c;
    for(int child=0;child<vi[node].size();child++)
    {
        if(check[vi[node][child]]==false)
        {
            if(dfs(vi[node][child],c^1)==false)
            {
                return false;
            }
        }
        else if(arr2[node]==arr2[vi[node][child]])
        {
            return false;
        }
        //else if()
    }
    return true;
}

int main()
{
    int n;
    cin>>n;
    int res=n*(n+1);
    res/=2;
    cout<<res;

}






Measured memory_bytes: 5992
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll N,K;cin>>N>>K;
    ll n1=N%K;
    ll n2=K-n1;
    cout<<min(n1,n2)<<"\n";
}

Measured memory_bytes: 256
n, m, x = map(int, input().split())
ca = []
price = 10**10
for _ in range(n):
    tmp = list(map(int, input().split()))
    ca.append(tmp)

for i in range(2 ** n):
    tmp_price = 0
    lst = [0] * (m + 1)
    for j in range(n):
        if((i >> j) & 1):
            lst = [z + y for (z, y) in zip(lst, ca[j])]
    a = lst[1:]

    if all(t >= x for t in a):
        tmp_price = lst[0]
        price = min(tmp_price, price)

if price != 10**10:
    print(price)
else:
    print(-1)

Measured memory_bytes: 9232
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector< pair<int,int> > A(N);
	for(int i =0; i < N; i++) {
		cin >> A[i].ff >> A[i].ss;
		A[i].ff +=A[i].ss;
	}
	sort(begin(A),end(A));

	cat H =0;
	set< pair<int,int> > Hs;
	for(int i =0; i < N; i++) {
		if(H+A[i].ss <= A[i].ff) {
			Hs.insert(make_pair(A[i].ss,i));
			H +=A[i].ss;
			continue;
		}
		if(!Hs.empty() && Hs.rbegin()->ff >= A[i].ss) {
			H +=A[i].ss-Hs.rbegin()->ff;
			Hs.erase(--Hs.end());
			Hs.insert(make_pair(A[i].ss,i));
			continue;
		}
	}

	cout << Hs.size() << "\n";
	return 0;}

// look at my code
// my code is amazing


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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
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(0);
    ios::sync_with_stdio(false);
    
    int a, b, c;
    cin >> a >> b  >> c;

    cout << max(0, c - (a-b)) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N,K;
  cin >> N >>K;
  
  int ans;
  if(K >= N)ans=1;
  
  else {
    int now=K;
    for (int i=1;;i++){
      now += K-1;
      if(now>=N){ans=i+1;break;}
    }
  }
 cout << ans;
  
}
  
  
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

ll gcd(ll x, ll y)
{
  return y ? gcd(y, x % y) : x;
}
ll lcm(ll x, ll y)
{
  return x * y / gcd(x, y);
}
bool is_prime(int x)
{
  for (int i = 2; i * i <= x; i++)
  {
    if (x % i == 0)
      return 0;
  }
  return true;
}
vector<bool> prime_table(int n)
{
  vector<bool> prime(n + 1, 1);
  prime[0] = 0;
  prime[1] = 0;
  for (int i = 2; i * i <= n; i++)
  {
    if (!prime[i])
      continue;
    for (int j = i * i; j <= n; j++)
      prime[j] = 0;
  }
  return prime;
}
map<int, int> prime_factor(int n)
{
  map<int, int> res;
  for (int i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
ll modpow(ll a,ll n, ll mod)
{
  ll res=1;
  while(n>0){
    if(n & 1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}
ll modinv(ll a,ll mod)
{
  return modpow(a,mod-2,mod);
}

int main()
{
  int n;
  cin>>n;
  vector<int> a(n);
  REP(i,n) cin>>a[i];

  map<int,int> mp;
  REP(i,n){
    map<int,int> f=prime_factor(a[i]);
    for(auto p:f) mp[p.first]=max(mp[p.first],p.second);
  }

  ll lcm=1;
  for(auto p:mp){
    REP(i,p.second) lcm=lcm*p.first%1000000007;
  }
  // cout<<lcm<<endl;

  ll ans=0;
  REP(i,n){
    ll b=lcm*modinv(a[i],1000000007);
    b%=1000000007;
    // cout<<b<<endl;
    ans=(ans+b)%1000000007;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 768
n = int(input())
a = [int(i) for i in input().split()][::-1]
count = 0
f = 0
c = a.pop()
for i in range(1,n):
  c,p = a.pop(),c
  if f == 0:
    if c < p:
      f = 1
    elif c > p:
      f = 2
  if f == 1:
    if c > p:
      count += 1
      f = 0
  if f == 2:
    if c < p:
      count += 1
      f = 0
print(count + 1)

Measured memory_bytes: 14228
#include<bits/stdc++.h>
using namespace std;
long int dp[100001];
long int arr[100001];
long int solve(long int i){
	if(i<=0)
	return INT_MAX-10001;
	if(dp[i]!=-1)
	return dp[i];
	dp[i]=min(abs(solve(i-1))+abs(arr[i]-arr[i-1]),abs(solve(i-2))+abs(arr[i]-arr[i-2]));
	return dp[i];
}
int main(){
	long int n;
	cin>>n;
	//long int arr[n];
	for(long int i=1;i<=n;i++)
	cin>>arr[i];
	arr[0]=0;
	for(long int i=0;i<=n;i++)
	dp[i]=-1;
	dp[1]=0;
	long int ans=solve(n);
	//dp[n]=min(dp[n-1]+abs(arr[n]-arr[n-1]),dp[n-2]+abs(arr[n]-arr[n-2]));
	cout<<dp[n];
}

Measured memory_bytes: 3328
#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 - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll h, w;
    cin >> h >> w;
    string s;
    vvll a(h, vll(w));
    REP(i, h){
        cin >> s;
        REP(j, w){
            if(s[j] == '.') a[i][j] = 1;
        }
    }
    vvll pl(h, vll(w)), pr(h, vll(w)), pd(h, vll(w)), pu(h, vll(w));
    REP(i, h){
        REP(j, w){
            if(a[i][j]){
                if(j == 0) pr[i][j] = 1;
                else pr[i][j] = pr[i][j - 1] + 1;
            }
        }
        REPR(j, w){
            if(a[i][j]){
                if(j == w - 1) pl[i][j] = 1;
                else pl[i][j] = pl[i][j + 1] + 1;
            }
        }
    }
    REP(j, w){
        REP(i, h){
            if(a[i][j]){
                if(i == 0) pu[i][j] = 1;
                else pu[i][j] = pu[i - 1][j] + 1;
            }
        }
        REPR(i, h){
            if(a[i][j]){
                if(i == h - 1) pd[i][j] = 1;
                else pd[i][j] = pd[i + 1][j] + 1;
            }
        }
    }
    
    ll res = 0;
    REP(i, h){
        REP(j, w){
            ll tmp = pl[i][j] + pr[i][j] + pd[i][j] + pu[i][j] - 3;
            res = max(res, tmp);
        }
    }
    cout << res << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    string A, B, C;

    cin >> A >> B >> C;

    cout << 'A' << B[0] << 'C' << endl;

    return 0;
}

Measured memory_bytes: 256
# 2019/08/07
# かんにんぐ

n=int(input())
a=[0]+list(map(int,input().split()))+[0]

s=[]
for i in range(n+1):
    s.append(abs(a[i]-a[i+1]))
S=sum(s)
for i in range(1,n+1):
    ans=S+abs(a[i-1]-a[i+1])-(abs(a[i-1]-a[i])+abs(a[i]-a[i+1]))
    print(ans)


Measured memory_bytes: 14048
#include "bits/stdc++.h"

using namespace std;


signed main(void) {

  int n; cin >> n;
  int d, x; cin >> d >> x;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];

  int num = x + n;

  for (int i = 0; i < n; ++i) {
    num += (d - 1) / a[i];
  }

  cout << num << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

long long int p[101], q[101], r[101], b[101];
long long int w[101];
long long int ans;

long long int gcd(long long int m, long long int n){
	if(n == 0) return m;
	 return gcd(n, m%n);
}

long long int lcm(long long int m, long long int n){
	long long int g = gcd(m, n);
	m /= g;
	n /= g;
	return g * m * n;
}

long long int f(int x){
	if(w[x] != 0) return w[x];
/*	long long int g = gcd(p[x], q[x]);
	p[x] /= g;
	q[x] /= g;
	return w[x] = (p[x] + q[x]) * lcm(f(r[x]), f(b[x]));
*/
	long long int l = lcm(p[x] * f(r[x]), q[x] * f(b[x]));
	return w[x] = l / p[x] + l / q[x];

}

int main(){
	while(1){
		int n;
		scanf("%d", &n);
		if(n == 0) break;

		memset(w, 0, sizeof(w));
		w[0] = 1;
		ans = 0;
		for(int i=1; i<n+1; ++i) scanf("%lld %lld %lld %lld", &p[i], &q[i], &r[i], &b[i]);
		for(int i=1; i<n+1; ++i){
			w[i] = f(i);
			ans = max(ans, w[i]);
		}

		printf("%lld\n", ans);

/*		for(int i=0; i<n+1; i++){
			printf("%d %lld\n", i, w[i]);
		}
*/	}
}

Measured memory_bytes: 2568
N = int(input())
W = list(map(int, input().split()))
sumlist = []
sum = 0
for i in range(0, N):
	sum += W[i]
	sumlist.append(sum)

min = 5000000000000000
for i in range(0, N):
	if abs(sumlist[i]*2-sumlist[-1]) < min:
		min = abs(sumlist[i]*2-sumlist[-1])
print(min)

Measured memory_bytes: 38384
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;

//aの倍数とbの倍数の和で作れるd以下の最大の数
int mxsum(int a,int b,int d){
	int mx=0;
	for(int i=0;i<=d;i+=a){
		int pam=i+((d-i)/b)*b;
		mx=max(mx,pam);
	}
	return mx;
}

int main(){
	int w1,w2,s1,s2,E,F;
	cin>>w1>>w2;
	cin>>s1>>s2;
	cin>>E>>F;
	
	double con=-1;
	int ansall=0;
	int anssug=0;
	
	//水の量で全探索
	
	for(int i=0;i<=F;i+=w1*100){
		for(int j=0;j<=F-i;j+=w2*100){
			int water=i+j;
          	if(water==0)continue;
			int slim=min(F-water,(i+j)*E/100);
          	//cout<<slim<<" ";
			//制限内で入れれる量の最大。関数を用意
			int sugar=mxsum(s1,s2,slim);
			double pcon=(double)sugar/(sugar+water);
          	//cout<<pcon<<endl;
			if(pcon>con){
				con=pcon;
				ansall=sugar+water;
				anssug=sugar;
			}
		}
	}
	cout<<ansall<<" "<<anssug;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
cin >> N;
 if(N%2==0){
     cout << "0.5"<<endl;
 }
 else{
     int c;
     c=(N/2+1)*1000000/N;
     cout << 0.000001*c << endl;
 }
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
#define NMAX 100005



int main()
{   int n;
    cin>>n;
    map<int,int> tab;
    set<int> div;
    for (int i = 0; i < n; ++i)
    {
        int a;
        cin>>a;
        div.insert(a);
        if(tab.count(a))
            tab[a]++;
        else
            tab[a]=1;
    }
    for(auto it : div){
        int x=it*2;
        while(x<1e6+6){
            if(div.count(x)){
                div.erase(x);
            }
            x+=it;
        }
    }
    
    for(int i=0 ; i<1e6+1 ; ++i){
        if(tab.count(i) && tab[i]>1 && div.count(i)){
            div.erase(i);
        }
    }
    
    cout<<div.size();
   return 0;
}


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

using namespace std;
int main()
{
    long long n,k;
    long long buf;
    std::vector<long long> s;
    long long i = 0;
  
    cin >> n >> k;

    while(i<n){
        cin >> buf;
        s.push_back(buf);
        i++;
    }
    std::sort(s.begin(), s.end());

    long long ans = 0;
    i = 0;
    while(i<k){
        ans += s[i];
        i++; 
    }

    cout << ans;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
int main(){
  int n,t,a,s,r=1e9,z;
  scanf("%d%d%d",&n,&t,&a);
  for(int i=0;i<n;i++){
    scanf("%d",&s);
    if(abs(1000*t-s*6-1000*a)<r){
      r=abs(1000*t-s*6-1000*a);
      z=i;
    }
  }
  printf("%d",z+1);
  return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef map<string, int> msi;
typedef pair<int, int> PII;

vector<int> a, b, c, d;
int n, m, q;
int ans = 0;

void dfs(vector<int> A){
    if(A.size() == n){
        int now = 0;
        rep(i, q){
            if(A[b[i]] - A[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans, now);
        return;
    }
    A.push_back(A.back());
    while(A.back() <= m){
        dfs(A);
        A.back()++;
    }
}

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

    dfs(vector<int>(1, 1));

    cout << ans << endl;
}

Measured memory_bytes: 3612