akhauriyash/Code-Regression huggingface dataset:
import sys
reverse = {
    "E":"W",
    "W":"E",
    "S":"N",
    "N":"S"
    }
        
class dice:
    def __init__(self,A):
        self.list = sorted(A)
        self.max = max(A)
        self.min = min(A)
        self.side = {
            "TOP":A[0],
            "S":A[1],
            "E":A[2],
            "W":A[3],
            "N":A[4],
            "BOT":A[5],
            }
    def get_list(self):
        return self.list
    def get_dict(self):
        return self.side
    def check(self):
        pass
    def main(self,A):
        for s in A:
            var = int(self.side[s])
            self.side[s] = self.side["TOP"]
            self.side["TOP"] = self.side[reverse[s]]
            self.side[reverse[s]] = self.side["BOT"]
            self.side["BOT"] = var
    def rot(self):
        var = self.side["N"]
        self.side["N"] = self.side["E"]
        self.side["E"] = self.side["S"]
        self.side["S"] = self.side["W"]
        self.side["W"] = var
    def rotate(self,top,flont):
        self.top_set(top)
        for x in range(4):
            if self.side["S"] == flont:
                break
            else:
                var = int(self.side["N"])
                self.side["N"] = self.side["E"]
                self.side["E"] = self.side["S"]
                self.side["S"] = self.side["W"]
                self.side["W"] = var
        return list([self.side["TOP"],self.side["S"],self.side["E"]])
    def top_set(self,top):
        if self.side["BOT"] == top:
            self.main("NN")
        elif self.side["N"] == top:
            self.main("S")
        elif self.side["S"] == top:
            self.main("N")
        elif self.side["E"] == top:
            self.main("W")
        elif self.side["W"] == top:
            self.main("E")


a = dice(list(map(int,input().split())))
b = dice(list(map(int,input().split())))

a_list = a.get_list()
b_list = b.get_list()

if a_list != b_list:
    print("No")
else:
    a_dict = a.get_dict()
    for do in ["N","N","N","N","E","EE"]:
        b.main(do)
        for i in range(4):
            b.rot()
            if a_dict == b.get_dict():
                print("Yes")
                sys.exit()
                break
        else:
            continue
        break

print("No")
    



Measured memory_bytes: 5624
def resolve():
    n,k,q = map(int,input().split())
    ans = [0]*n
    for _ in range(q):
        a = int(input())
        ans[a-1] += 1
    for i in ans:
        if 0 < k-q+i:
            print('Yes')
        else:
            print('No')
resolve()

Measured memory_bytes: 9852
s = input()
t = input()

s1 = s[0]
s2 = s[1]
s3 = s[2]

t1 = t[0]
t2 = t[1]
t3 = t[2]

count = 0
if s1 == t1:
    count = count + 1
if s2 == t2:
    count = count +1
if s3 == t3:
    count = count +1

print(count)

Measured memory_bytes: 3064
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
def main():
    # from math import gcd
    def input():
        return sys.stdin.readline()[:-1]
    def ruiseki(lst):
        return [0]+list(accumulate(lst))
    mod=pow(10,9)+7
    al=[chr(ord('a') + i) for i in range(26)]
    direction=[[1,0],[0,1],[-1,0],[0,-1]]

    h,w=map(int,input().split())
    a=[input() for i in range(h)]

    cnt=0

    itta=[[10**9]*w for i in range(h)]

    d=deque()
    # aaa=d.append
    for i in range(h):
        for j in range(w):
            if a[i][j]=="#":
                d.append((i,j))
                itta[i][j]=0

    # print(d)
    # print(itta)

    while d:
        cnt+=1
        for l in range(len(d)):
            nh,nw=d.popleft()
            for i in range(4):
                d1,d2=direction[i]
                if 0<=nh+d1<h and 0<=nw+d2<w:
                    if itta[nh+d1][nw+d2]==10**9:
                        itta[nh+d1][nw+d2]=cnt
                        d.append((nh+d1,nw+d2))
        # print(d)

    # print(itta)
    print(cnt-1)

if __name__ == '__main__':
    main()

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N;
int A[300010];
ll dp[2][300010];

// 小さい方からN個を計算する
void solve(int *inary, ll *outary){
    ll sum = 0;
    multiset<ll> minset;
    multiset<ll> maxset;
    for(int i = 0; i < N; i++){
        minset.insert(inary[i]);
        sum += inary[i];
    }
    outary[N - 1] = sum;
    for(int i = N; i < 2 * N; i++){
        if(*(--minset.end()) >= A[i]){
            ll a = *(--minset.end());
            minset.erase(minset.find(a));
            maxset.insert(a);
            minset.insert(A[i]);
            sum -= a;
            sum += A[i];
        }
        else{
            maxset.insert(A[i]);
        }
        outary[i] = sum;
    }
}

int main(){

    cin >> N;
    for(int i = 0; i < 3 * N; i++) cin >> A[i];
    reverse(A, A + 3 * N);
    for(int i = 0; i < 2; i++){
        solve(A, dp[i^1]);
        reverse(A, A + 3 * N);
        for(int j= 0; j < 3 * N; j++) A[j] *= -1;
    }
    for(int i = 0; i < 3 * N; i++) dp[0][i] *= -1;
    ll ans = -(1LL << 60);
    for(int i = N - 1; i < 2 * N; i++){
        ans = max(ans, dp[0][i] - dp[1][3 * N - 2 - i]);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 14848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0);
	//freopen("in.txt", "r", stdin);
	int n;
	cin >> n;
	vi a(n), b(n);
	rep(i,0,n) {
		cin >> a[i];
	}
	rep(i,0,n) {
		cin >> b[i];
	}
	vi c(n);
	rep(i,0,n) {
		c[i] = i+1;
	}
	int x, y;
	int k = 1;
	do {
		bool flag = true;
		rep(i,0,n) {
			if(c[i] != a[i]) {
				flag = false;
				break;
			}
		}
		if(flag) {
			x = k;
		}
		flag = true;
		rep(i,0,n) {
			if(c[i] != b[i]) {
				flag = false;
				break;
			}
		}
		if(flag) {
			y = k;
		}
		k++;
	} while(next_permutation(all(c)));
	cout << abs(x-y) << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll h,w;
  cin >> h >> w;
  vector<vector<string>> s(h,vector<string> (w));
  for(ll i=0;i<h;i++) {
    for(ll j=0;j<w;j++) {
      cin >> s[i][j];
    }
  }
  for(ll i=0;i<h;i++) {
    for(ll j=0;j<w;j++) {
      if(s[i][j]=="snuke") {
        cout << char('A'+j) << i+1 << endl; 
      }
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
const int maxn = 1e5 + 7;

int n;
ll s;

struct node {
	ll x, p;
}a[maxn];

pair<ll, ll> solve(int l, int r) {
	// cout << l << ' ' << r << endl;
	if (s <= a[l].x ) return make_pair(a[r].x - s, 1);
	if (s >= a[r].x ) return make_pair(s - a[l].x, -1);
	if (a[l].p < a[r].p) {
		a[r].p += a[l].p;
		pair<ll, ll> rt = solve(l + 1, r);
		ll t = rt.first, d = rt.second;
		if (d == 1) {
			return make_pair(t + a[r].x - a[l].x, -1);
		}
		else if (d == -1) {
			return make_pair(t + a[l + 1].x - a[l].x, -1);
		}
	}
	else {
		a[l].p += a[r].p;
		pair<ll, ll> rt = solve(l, r - 1);
		ll t = rt.first, d = rt.second;
		if (d == 1) {
			return make_pair(t + a[r].x - a[r - 1].x, 1);
		}
		else if (d == -1) {
			return make_pair(t + a[r].x - a[l].x, 1);
		}
	}
}

int main() {
	scanf("%d%lld", &n, &s);
	for (int i = 1; i <= n; ++i) scanf("%lld%lld", &a[i].x, &a[i].p);
	printf("%lld\n", solve(1, n).first);
	return 0;
}

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

#define int long long

const int N = 3e3 + 10 ;
int dp[N][N] ;

int solve(string &a , string &b , int i = 0 , int j = 0){
	if(i == a.size() || j == b.size()) return 0 ;
	if(~dp[i][j]) return dp[i][j] ;
	if(a[i] == b[j]) {
		return dp[i][j] = 1 + solve(a , b , i + 1 , j + 1) ;
	}
	else {
		return dp[i][j] = max(solve(a , b , i + 1 , j ) , solve(a , b , i , j + 1)) ;
	}
}	

void getval(string &a , string &b , string& ans ,  int i = 0 , int j = 0){
	if(i == a.size() || j == b.size()) return ;
	if(a[i] == b[j]) {
		ans += a[i] ;
		getval(a , b , ans , i + 1 , j + 1) ;
	} else {
		if(solve(a,b,i+1,j) > solve(a,b,i,j+1)){
			getval(a,b,ans,i+1,j) ;
		} else {
			getval(a,b,ans,i,j+1) ;
		}
	}
}

int32_t main(){
	memset(dp , -1 , sizeof(dp)) ;
	string a , b ;
	cin >> a >> b ;
	solve(a,b) ;
	string ans = "" ;
	getval(a,b,ans) ;
	cout << ans ;
	return 0 ;
}

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

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i += 2) {
        int num = 0;
        for (int j = 1; j <= i; ++j) {
            if (i % j == 0) num++;
        }
        if (num == 8) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define INF (INT_MAX / 2)
#define INFL (INT64_MAX /2)
typedef pair<int, int> P;

























int main() {
    int n,m;
    cin >> n >> m;
    vector<int> a(m+1),b(m+1);
    rep(i,m) {
        cin >> a[i] >> b[i];
    }
    vector<vector<int>> possible(n+1);
    rep(i,m) {
        possible[a[i]].push_back(b[i]);
        possible[b[i]].push_back(a[i]);
    }

    vector<int> d(n+1,INF), ans(n+1);
    d[1] = 0;
    queue<int> que;
    que.push(1);

    while (!que.empty()) {
        int a = que.front(); que.pop();
        rep(i, possible[a].size()) {
            if (d[possible[a][i]] > d[a] + 1) {
                d[possible[a][i]] = d[a] + 1;
                ans[possible[a][i]] = a;
                que.push(possible[a][i]);
            }
        }
    }
    bool bo = false;
    rep(i,n) {
        if (d[i+1] == INF) {
            cout << "No" << endl;
            break;
        }
        bo = true;
    }
    if (bo) {
        cout << "Yes" << endl;
        rep (i,n-1) {
            cout << ans[i+2] << endl;
        }
    }
}

Measured memory_bytes: 12108
#include<stdio.h>
#include<math.h>

int main()
{
	long long h,num,ans=0;
	num=1;
	scanf("%lld",&h);
	while (h>0)
	{
		ans+=num;
		num=num*2;
		h=floor(h/2); 
	}
	printf("%lld",ans);
	return 0;
}



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

typedef long long ll;
const int N = 100010;

int n;
ll a[N], x1, x2, S;
struct lb {
	ll p[62];
	void insert(ll x) {
		for(ll i = 61; i >= 0; --i) {
			if(!((S >> i) & 1) && ((x >> i) & 1)) {
				if(p[i]) x ^= p[i];
				else {
					p[i] = x;
					return;
				}
			}
		}
		for(ll i = 61; i >= 0; --i) {
			if(((S >> i) & 1) && ((x >> i) & 1)) {
				if(p[i]) x ^= p[i];
				else {
					p[i] = x;
					return;
				}
			}
		}
	}
} B;

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%lld", &a[i]), S ^= a[i];
	for(int i = 1; i <= n; ++i) B.insert(a[i]);
	for(int i = 60; i >= 0; --i) if(!((S >> i) & 1) && !((x1 >> i) & 1)) x1 ^= B.p[i];
	for(int i = 60; i >= 0; --i) if(((S >> i) & 1) && ((x1 >> i) & 1)) x1 ^= B.p[i];
	printf("%lld\n", x1 + (S ^ x1));
	
}

Measured memory_bytes: 1152
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A,B;cin>>A>>B;
  cout<<((A*B)&1? "Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            // Input
            int N = Integer.parseInt(sc.next());
            int M = Integer.parseInt(sc.next());
            int K = Integer.parseInt(sc.next());
            long[] a = new long[N + 1];
            long[] b = new long[M + 1];
            for (int i = 1; i <= N; i++) {
                a[i] = Long.parseLong(sc.next());
                a[i] += a[i - 1];
            }
            for (int i = 1; i <= M; i++) {
                b[i] = Long.parseLong(sc.next());
                b[i] += b[i - 1];
            }

            // Calc
            int bi = M, max = 0;
            for (int i = 0; i <= N; i++) {
                for (int j = bi; j >= 0; j--) {
                    bi = j;
                    if (a[i] + b[j] <= K) {
                        int total = i + j;
                        max = Math.max(max, total);
                        break;
                    }
                }
            }
            System.out.println(max);
        }
    }
}

Measured memory_bytes: 63324
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main(){
  string s,t;
  cin >> s >> t;
  map<char,int> S,T;
  int cnt = 0;
  for(int i = 0;i < s.size();i++){
    if(S.count(s[i]) ^ T.count(t[i])){
      cout << "No" << endl;
      return 0;
    }
    else if(S.count(s[i]) && T.count(t[i])){
      if(S[s[i]] != T[t[i]]){
        cout << "No" << endl;
        return 0;
      }
    }
    else{
      S[s[i]] = cnt;
      T[t[i]] = cnt;
      cnt++;
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 776
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
const int INF=1e9+5;
int main(){
	int n,k;
  	cin>>n>>k;
  	vector<int> h(n+1);
  	for(int i=1;i<=n;i++) cin>>h[i];
	vector<int> dp(n+1,INF);
    dp[1]=0;
  	dp[2]=abs(h[2]-h[1]);
    for(int i=2;i<=n;i++){
        for(int jump=1;i-jump>0 && jump<=k;jump++){
            dp[i]=min(dp[i-jump]+abs(h[i]-h[i-jump]) ,dp[i]);
        }
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
import sys

# sys.stdin = open('b1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


n = read_int()
res = 0
for i in range(100):
    r = 2 ** i
    if r <= n:
        res = r
    else:
        break
print(res)


Measured memory_bytes: 2940
n = int(input())

ans = ''

for i in range(13):
    if n >= 26 and n%26 == 0:
        ans = 'z' + ans
        n -= 26
    else:
        ans = chr(97 -1 + n%26) + ans
        n -= n%26

    n = n //26

print(ans.replace("`", ""))


Measured memory_bytes: 9156
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	int mp[n]; 
	int a[n];
	int b[n];

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


	for(int i = 0; i < n; i++){
		int it = mp[i];
		// cout << it << endl;
		for(int j = it+1; j < n; j++){
			a[j] += n-i;
		}
		for(int j = 0; j < it; j++){
			b[j] += n-i;
		}

	}

	for(int i = 0; i < n; i++){
		cout << a[i] << " ";
	}
	cout << endl;

	for(int i = 0; i < n; i++){
		cout << b[i] << " ";
	}
	cout << endl;


	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

int n,a[100005];
void solve(){
    cin>>n;
    rep(i,1,n+1){
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    int ans1=0,ans2=0,ans3=0,ans4=0;
    vi v,vv;
    int f=1,l=1,r=n,ll=1,rr=n;
    rep(i,1,n+1){
        if(f) v.pb(a[l++]),vv.pb(a[rr--]);
        else v.pb(a[r--]),vv.pb(a[ll++]);
        f^=1;
    }
    rep(i,1,n){
        ans1+=abs(v[i]-v[i-1]);
        ans2+=abs(vv[i]-vv[i-1]);
    }
    reverse(v.begin(),v.end()-1);
    reverse(vv.begin(),vv.end()-1);
    rep(i,1,n){
        ans3+=abs(v[i]-v[i-1]);
        ans4+=abs(vv[i]-vv[i-1]);
    }
    cout<<max({ans1,ans2,ans3,ans4})<<endl;
}

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

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

int main() {
	int N, L;
	cin >> N >> L;
	if (L >= 0) cout << (L + L + N) * (N - 1) / 2 << endl;
	else {
		if (L + N - 1 < 0) cout << (L + L + N - 2) * (N - 1) / 2 << endl;
		else cout << (L + L + N - 1) * N / 2 << endl;
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
using namespace std;
using lint = long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };

const lint INF = 1ll << 60;
const int mod = 1000000007;
void speed() {
	std::cin.tie(nullptr);
	std::ios::sync_with_stdio(false);
	return;
}



int main(void) {
	speed();
	int n; cin >> n;
	for (int i = 0; i < n; i++) cout << "ACL";
	cout << endl;

	return 0;
}

Measured memory_bytes: 3600
# -*- coding: utf-8 -*-
import numpy as np
def inpl(): return list(map(int, input().split()))

N, M, C = inpl()
B = np.array(inpl(), dtype=np.int64).reshape(1, -1)
A = np.zeros((N, M), dtype=np.int64)

for i in range(N):
    A[i] = inpl()

print(((A*B).sum(axis=1) + C >0).sum())

Measured memory_bytes: 20644
n,m = map(int,input().split())
a_n = list(map(int,input().split()))
b_and_c = []
for i in range(m):
    b_and_c.append(list(map(int,input().split())))

a_n.sort()

b_and_c.sort(key = lambda x : x[1], reverse = True)
index = 0
for i in range(m):
    if index >= n:
        break
    elif a_n[index] >= b_and_c[i][1]:
        break
    for j in range(index, n):
        if a_n[j] < b_and_c[i][1]:
            for k in range(j, min(j + b_and_c[i][0], n)):
                if a_n[k] < b_and_c[i][1]:
                    a_n[k] = b_and_c[i][1]
                else:
                    break
            index = k + 1
            break

print(sum(a_n))

Measured memory_bytes: 34176
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, readline().split()))
    n += 1 if n % 2 != 0 else 0
    print("YES" if n // 2 >= k else "NO")


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38256
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
using namespace std;

struct P
{
	int x,y;
};

P getP(int x,int y){
	P p={x,y};
	return p;
}

int main(){
	int w,h;
	int dx[]={0,0,-1,1};
	int dy[]={-1,1,0,0};

	while(cin >> w >> h, w|h){

		vector< vector<bool> > map;
		vector<bool>b;

		for(int ix=0;ix<w*2-1+2;ix++)
			b.push_back(true);
		map.push_back(b);

		for(int iy=0;iy<h*2-1;iy++){
			b.clear();
			b.push_back(true);
			if(iy%2==0){
				for(int ix=0;ix<w*2-1;ix++){
					bool t=0;
					if(ix%2==1)
						cin >> t;
					b.push_back(t);
				}
			}else{
				for(int ix=0;ix<w*2-1;ix++){
					bool t=0;
					if(ix%2==0)
						cin >> t;
					b.push_back(t);
				}
			}
			b.push_back(true);
			map.push_back(b);
		}
		b.clear();
		for(int ix=0;ix<w*2-1+2;ix++)
			b.push_back(true);
		map.push_back(b);

		queue<P> que;
		que.push(getP(1,1));
		que.push(getP(0,0));
		int path=0;
		while(!que.empty()){

			P p=que.front();que.pop();
			if(p.x==0&&p.y==0){
				path++;
				if(que.empty()){
					path=-1;
					break;
				}
				que.push(getP(0,0));
				continue;
			}
			if(p.x==w*2-1&&p.y==h*2-1)
				break;

			/*
			cout << endl;
			for(int iy=0;iy<map.size();iy++){
				for(int ix=0;ix<map.at(iy).size();ix++)
				if(p.x!=ix||p.y!=iy)
					cout << map[iy][ix];
				else
					cout << X;
				cout << endl;
			}
			cout << endl;
			*/

			if(!(p.x+p.y))path++;
			map[p.y][p.x]==true;
			for(int i=0;i<4;i++){
				if(!map[p.y+dy[i]][p.x+dx[i]]){
					map[p.y+dy[i]][p.x+dx[i]]=true;
					que.push(getP(p.x+dx[i]*2,p.y+dy[i]*2));
				}
			}
		}
		cout << path+1 << endl;
	}

	return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
#define pb push_back
#define sf scanf
#define pf printf
#define FAST ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
using namespace std;
#define ll long long
const int N=2e5+9;
void slv()
{
    int n;
    cin>> n;
    int a[n+3],b[n+3];
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) cin >> b[i];
    int l=0,r=n-1;
    reverse(b,b+n);
    for(int i=0;i<n;i++) {
        if(a[i]==b[i]) {
            if(b[l]!=b[i] && a[l]!=b[i]) {
                swap(b[l],b[i]);
                l++;
            } else if(b[r]!=b[i] && a[r]!=b[i]) {
                swap(b[r],b[i]);
                r--;
            } else {
                puts("No");
                return ;
            }
        }
    }
    for(int i=0;i<n;i++) {
        if(a[i]==b[i]) {
            puts("No");
            return ;
        }
    }
    puts("Yes");
    for(int i=0;i<n;i++) cout<<b[i]<< " ";
}
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int t;
    t=1;
    int cs=1;
    while (t--)
    {
        //cout<<"Case : "<<cs++<<endl;
        slv();
    }
    return 0;
}

Measured memory_bytes: 5148
///////////////////////////
//         INFO          //
//                       //
//    Handle -> Scayre   //
//                       //
//   Template vers. 1.1  //
//                       //
//   It'll be accepted   //
//                       //
///////////////////////////

//████╗████████╗██╗███████╗══███╗═══███╗████████╗════//
//═██╔╝═══██╔══╝╚█║██╔════╝══████╗═████║██╔═════╝═══//
//═██║════██║════╚╝███████╗══██╔████╔██║█████╗══════//
//═██║════██║══════╚════██║══██║╚██╔╝██║██╔══╝══════//
//████╗═══██║══════███████║══██║═╚═╝═██║███████╗═════//


#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <complex>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iterator>
#include <iostream>
#include <algorithm>
//#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define ull unsigned ll
#define ioi exit(0);

#define f first
#define s second

#define inf (int)1e9 + 7

#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define mp(x,y) make_pair(x,y)

#define lb(x) lower_bound(x)
#define ub(x) upper_bound(x)

#define pb push_back
#define ppb pop_back

#define bitcoin __builtin_popcount

#define endl "\n"

#define in(x) insert(x)

#define sz(x) (int)x.size()

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

#define pw2(x) (1<<x) //2^x

#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)

#define sqr(x) ((x) * 1ll * (x))

using namespace std;

const int N = (int)5e5 + 7, MOD = (int)1e9 + 7;

int n;

map <int,int> m[4];

int a[N];

int l,r;

bool u[N];

vector<int> v[4];

int ans;

int main(){

	#ifdef IOI2019
		freopen ("in.txt", "r", stdin);
	#endif

	NFS

	cin >> n;

	for(int i=1;i<=n;i++){
		cin >> a[i];
		m[i%2][a[i]]++;
		if(m[i%2][a[i]]==1){
			v[i%2].pb(a[i]);
		}
	}

	int mx=0,mx2=0,val=0;

	for(int i=0;i<sz(v[1]);i++){
		int cur=v[1][i];
		if(mx<m[1][cur]){
			mx=m[1][cur];
			val=cur;
		}
	}

	for(int i=0;i<sz(v[0]);i++){
		int cur=v[0][i];
		if(mx2<m[0][cur] && val!=cur){
			mx2=m[0][cur];
		}
	}

	ans=n-(mx+mx2);

	mx=0,mx2=0,val=0;

	for(int i=0;i<sz(v[0]);i++){
		int cur=v[0][i];
		if(mx<m[0][cur]){
			mx=m[0][cur];
			val=cur;
		}
	}

	for(int i=0;i<sz(v[1]);i++){
		int cur=v[1][i];
		if(mx2<m[1][cur] && val!=cur){
			mx2=m[1][cur];
		}
	}

	ans=min(ans,n-(mx+mx2));

	cout << ans << endl;


	#ifdef IOI2019
		cout << "\nTime Elapsed : " << clock () * 1.0 / CLOCKS_PER_SEC << endl;
	#endif

	ioi
}

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

int main()
{
    int N;
    cin >> N;
    map<int, pair<int, int>> P;
    int cur = 0;
    int B[N];
    for(int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        if(P[A].second == 0) {
            B[cur] = 0;
            P[A].first = cur;
            ++cur;
            ++P[A].second;
        }
        B[P[A].first ]++;
    }
    int res = 0;
    for(int i = 0; i < cur; ++i) {
        //cout << B[i] << " ";
        if(B[i]%2) ++res;
    }
    //cout << endl;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 6912
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int a = in.nextInt();
		int b = in.nextInt();
		
		int  ab = a+b;
		int  x = ab/2;
		int  X = ab%2;
		int  C = x += X;
		
		System.out.println(C);

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int)N;i++)
#define p(s) cout<<(s)<<endl
#define ck(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9;


int main(){
	ll N,K;
	cin>>N>>K;
	pair<ll,ll> p[100010];
	REP(i,0,N){
		ll a,b;
		cin >>a>>b;
		p[i]={a,b};
	}
	sort(p,p+N);
	ll cnt=K;
	ll ans;
	REP(i,0,N){
		cnt-=p[i].S;
		if(cnt<=0){
			ans=p[i].F;
			break;
		}
	}
	p(ans);
	return 0;
}


Measured memory_bytes: 1792
n = int(input())
A = list(map(int,input().split()))

rem = A[0]
count = 0
for i in range(1,n):
  if rem >= A[i]:
    sa = rem - A[i]
    A[i] += sa
    count += sa
  else:
    rem = A[i]
    
print(count)

Measured memory_bytes: 32216
/**
 *    author:  tourist
 *    created: 03.06.2018 15:12:14       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> x(n + 1), y(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  sort(x.rbegin(), x.rend());
  sort(y.begin(), y.end());
  long long ans = 0;
  for (int i = 0; i < n + 1; i++) {
    if (x[i] > y[i]) {
      ans += 2 * (x[i] - y[i]);
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,c,d;
  string s;
  cin >> n >> a >> b >> c >> d >> s;
  bool cana=true,canb=true,can2=false;
  for(int i=a-1;i<c-2;i++){
    if(s[i]=='#'&&s[i+1]=='#'){
      cana=false;
    }
  }
  for(int i=b-1;i<d-2;i++){
    if(s[i]=='#'&&s[i+1]=='#'){
      canb=false;
    }
  }
  if(c>d){
    for(int i=b-1;i<=d-1;i++){
      if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.'){
        can2=true;
      }
    }
  }
  else{
    can2=true;
  }
  if(cana&&canb&&can2){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=3005,MOD=1e9+7;
inline int mod1(int x){return x<MOD?x:x-MOD;}
inline int mod2(int x){return x<0?x+MOD:x;}
inline int pow_mod(int x,int i){int y=1;while(i){if(i&1)y=(ll)y*x%MOD;x=(ll)x*x%MOD;i>>=1;}return y;}
int n,q,a[MAXN],f[MAXN][MAXN],g[MAXN][MAXN],tmp[MAXN][MAXN];
int gt(int i,int j){
	//a[i]>a[j]
	if(i==j)return 0;
	if(i<j)return f[i][j];
	assert(g[i][j]==g[j][i]);
	return mod2(mod2(1-f[j][i])-g[i][j]);
}
int main() {
	n=read();q=read();
	for(int i=1;i<=n;++i)a[i]=read();
	for(int i=1;i<=n;++i)for(int j=i+1;j<=n;++j)if(a[i]>a[j])f[i][j]=1;
	for(int i=1;i<=n;++i)for(int j=1;j<=n;++j)if(a[i]==a[j])g[i][j]=1;
	int inv2=pow_mod(2,MOD-2);
//	for(int i=1;i<=n;++i){
//		for(int j=1;j<=n;++j){
//			cout<<f[i][j]<<" ";
//		}
//		cout<<endl;
//	}
//	cout<<endl;
	for(int t=1;t<=q;++t){
		int x=read(),y=read();
		
		for(int i=1;i<x;++i)tmp[i][x]=mod1((ll)inv2*f[i][x]%MOD+(ll)inv2*((i!=y)?gt(i,y):gt(x,i))%MOD);
		for(int i=x+1;i<=n;++i)tmp[x][i]=mod1((ll)inv2*f[x][i]%MOD+(ll)inv2*((i!=y)?gt(y,i):gt(i,x))%MOD);
		for(int i=1;i<y;++i)tmp[i][y]=mod1((ll)inv2*f[i][y]%MOD+(ll)inv2*((i!=x)?gt(i,x):gt(y,i))%MOD);
		for(int i=y+1;i<=n;++i)tmp[y][i]=mod1((ll)inv2*f[y][i]%MOD+(ll)inv2*((i!=x)?gt(x,i):gt(i,y))%MOD);
		
		for(int i=1;i<x;++i)f[i][x]=tmp[i][x];
		for(int i=x+1;i<=n;++i)f[x][i]=tmp[x][i];
		for(int i=1;i<y;++i)f[i][y]=tmp[i][y];
		for(int i=y+1;i<=n;++i)f[y][i]=tmp[y][i];
		
		for(int i=1;i<=n;++i)tmp[i][x]=tmp[x][i]=tmp[i][y]=tmp[y][i]=mod1((ll)inv2*g[i][x]%MOD+(ll)inv2*g[i][y]%MOD);
		tmp[x][y]=tmp[y][x]=g[x][y];
		for(int i=1;i<=n;++i)g[i][x]=tmp[i][x],g[x][i]=tmp[x][i],g[i][y]=tmp[i][y],g[y][i]=tmp[y][i];
		g[x][x]=g[y][y]=1;
		
		//debug:
//		for(int i=1;i<=n;++i)for(int j=1;j<=n;++j)if(i==j)assert(g[i][j]==1);else assert(g[i][j]==0);
//		for(int i=1;i<=n;++i){
//			for(int j=1;j<=n;++j){
//				cout<<f[i][j]<<" ";
//			}
//			cout<<endl;
//		}
//		cout<<endl;
	}
	int ans=0;
	for(int i=1;i<=n;++i)for(int j=i+1;j<=n;++j)ans=mod1(ans+f[i][j]);
	cout<<(ans=(ll)ans*pow_mod(2,q)%MOD)<<endl;
	return 0;
}

Measured memory_bytes: 105216
/**************************************************
filename       :A.cpp
author         :maksyuki
created time   :2018/1/14 19:46:35
last modified  :2018/1/14 20:05:49
file location  :C:\Users\abcd\Desktop\atcoder
***************************************************/

#pragma comment(linker, "/STACK:102400000,102400000")
#include <set>
#include <bitset>
#include <list>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <vector>
#include <ios>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <complex>
#include <numeric>
#include <functional>
#include <cmath>
#include <ctime>
#include <climits>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cassert>
using namespace std;

#define CFF freopen ("in", "r", stdin)
#define CFO freopen ("out", "w", stdout)
#define CPPFF ifstream cin ("in")
#define CPPFO ofstream cout ("out")
#define	DB(ccc)	cout << #ccc << " = " << ccc << endl
#define	DBT printf("time used: %.2lfs\n", (double) clock() / CLOCKS_PER_SEC)
#define PB push_back
#define MP(A, B) make_pair(A, B)

typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
typedef pair <int, int> PII;
typedef pair <int, bool> PIB;

const int INF = 0x7F7F7F7F;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = 2 * acos (0.0);
const int maxn = 1e5 + 6666;

int main()
{
#ifdef LOCAL
    CFF;
    //CFO;
#endif
    
    int n, a, b;
    while(cin >> n >> a >> b) {
        if(abs(a - b) % 2 == 0) puts("Alice");
        else puts("Borys");
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

const int MOD = 1000000007;

using namespace std;



int main(){

    int c=0,i,n;
    cin >> n;
    int p[n],min = n;
    for(i=0;i<n;i++){
        cin >> p[i];
    }
    for(i=0;i<n;i++){
        if(p[i]!=i+1){
            c++;
            if(c==3){
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }



void solve(std::string S){
	if (S=="Sunny") cout << "Cloudy" << "\n";
	else if (S=="Cloudy") cout << "Rainy" << "\n";
	else cout << "Sunny" << "\n";
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split())) 
for i in range(n):
    v = x[i]
    j = i-1
    while j >=0 and x[j]>v:
        x[j+1] = x[j]
        j = j-1
    x[j+1] = v
    print(*x)


Measured memory_bytes: 5976
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;

bool is_prime(int n)
{
    for (int i = 2; i * i < n; ++i)
    {
        if (n % i == 0)
            return false;
    }
    return true;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long a;
    cin >> a;
    vector<pair<long long, long long>> vec;
    long long c = 0;
    long long s = -1;
    for (long long i = 2; i * i <= a; ++i)
    {
        if (a % i == 0)
        {
            pair<long long, long long> pr = {i, a / i};
            vec.push_back(pr);
        }
    }

    if (vec.size() == 0)
    {
        cout << a - 1 << "\n";
        return 0;
    }
    long long Min = 1000000000000;

    for (auto i : vec)
        Min = min(Min, i.first + i.second - 2);
    cout << Min << "\n";
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k<=a) cout << k << endl;
    else if(k<=a+b) cout << a << endl;
    else cout << a-(k-a-b) << endl;
}




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

using namespace std;
mt19937_64 rng(58);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int x;
    cin >> x;
    cout << (x >= 30 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main(void)
{
	int S,h,m,s;

	scanf("%d", &S);

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

	printf("%d:%d:%d\n", h, m, s);

	return(0);
}


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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int plan_a = n * a;
  int plan_b = b;
  if(plan_a < plan_b)
    cout << plan_a << endl;
  else
    cout << plan_b << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;




int main() {
	int mod = 39;
	int n;
	while (cin >> n) {
		n %= mod;
		if (n == 0)n = mod;
		printf("3C%02d\n", n);
	}
}

Measured memory_bytes: 1160
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#include <cstdio>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef std::vector<int> VI;
typedef std::pair<int,int> P;
int read()
{
    int x=0,flag=1; char c=getchar();
    while((c>'9' || c<'0') && c!='-') c=getchar();
    if(c=='-') flag=0,c=getchar();
    while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return flag?x:-x;
}

int main()
{
    int d=read(),t=read(),s=read();
    puts(s*t>=d?"Yes":"No");

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
list<int> L;
stack<int> S;
queue<int> Q;
deque<int> dq;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
static const int MAX=100000;
static const int MOD=1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int cunt;
int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    
    if(s.size()==1){
        cout<<0<<"\n";
        return 0;
    }
    
    for(int i=1;i<s.size();i++){
        if(s[i]!=s[i-1])cunt++;
    }
    
    cout<<cunt<<"\n";
    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

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

const int mod = (int)1e9 + 7;
const int mod2 = 998244353;

ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll a, b, n; cin>>a>>b>>n;
	n < b ? cout<<(a*n)/b : cout<<(a*(b-1))/b;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int N, K;
	cin >> N >> K;
	vector<double> A;
	pb(A,0)
	fx(N) {
		double a;
		cin >> a;
		pb(A,((a+1)*a/2)/a)
	}
	double sum = 0, ans = 0;
	fx(N+1) {
		sum += A[x];
		if (x>=K) {
			sum -= A[x - K];
			ans = max(ans, sum);


		}
	}
	cout << fixed << setprecision(10) << ans << endl;

    return 0;
}



Measured memory_bytes: 3444
n=int(input())
c=list(map(int, input().split()))

ans = 1
a = 0

for i in range(n):
    if c[i] != ans :
        a += 1
    if c[i] == ans:
        ans += 1

if ans == 1 and a != 0:
    print(-1)
else:
    print(a)

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

int main() {
    int64_t A,B; cin >> A >> B;
    int C = min(A,B);
    vector<int64_t> vec(A);
    for(int i = 1; i <= C; i++) {
        if(A % i == 0 && B % i == 0) {
            vec.push_back(i);
        }
    }
    reverse(vec.begin(),vec.end());
    cout << A * B / vec.at(0) << endl;
} 

Measured memory_bytes: 1792
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#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++)
const long long INF =  999999999;

int H,W,a[85][85],b[85][85];
bool dp[82][82][30000];

int main(){
  cin>>H>>W;
  FOR(i,1,H+1){
    FOR(j,1,W+1){
      cin>>a[i][j];
    }
  }
  FOR(i,1,H+1){
    FOR(j,1,W+1){
      cin>>b[i][j];
    }
  }

    dp[1][0][0]=true;
    dp[0][1][0]=true;


  FOR(i,1,H+1){
    FOR(j,1,W+1){
      REP(k,13000){
        dp[i][j][k]=false;
      }
    }
  }
  FOR(i,1,H+1){
    FOR(j,1,W+1){
      REP(k,13000){
        if(dp[i-1][j][k]){
          dp[i][j][abs(k+(a[i][j]-b[i][j]))]=true;
          dp[i][j][abs(k-(a[i][j]-b[i][j]))]=true;
        }
        if(dp[i][j-1][k]){
            dp[i][j][abs(k+(a[i][j]-b[i][j]))]=true;
            dp[i][j][abs(k-(a[i][j]-b[i][j]))]=true;
        }
      }
    }
  }
  int ans=0;
  REP(i,13000){
    if(dp[H][W][i]){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
}


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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif

using namespace std;


void trim(vector<pair<int, int> > &deq, int l) {
    assert(l >= 0);
    while (l > 0) {
        if (deq.back().second <= l) {
            l -= deq.back().second;
            deq.pop_back();
        } else {
            deq.back().second -= l;
            assert(deq.back().second > 0);
            l = 0;
        }
    }
}

bool inc(vector<pair<int, int> > &deq, int lim) {
    assert(deq.back().second > 0);
    for (int i = static_cast<int>(deq.size() - 1); i >= 0; i--) {
        if (deq[i].second > 1) {
            deq[i].second--;
            deq.insert(deq.begin() + i + 1, make_pair(deq[i].first, 1));
            i++;
        }
        deq[i].first += 1;
        if (deq[i].first >= lim) {
            deq[i].first = 0;
        } else {
            return true;
        }
    }

    return false;
}


void output(vector<pair<int, int>> deq) {
    for (auto p : deq) cout << string(p.second, p.first + '0');
    cout << endl;
}

bool f(vector<ll> A, int lim) {
    vector<pair<int, int> > deq;


    deq.emplace_back(0, A[0]);
//    output(deq);
    for (int i = 1; i < A.size(); i++) {
        if (A[i - 1] < A[i]) {
            if (deq.back().first == 0) {
                deq.back().second += A[i] - A[i - 1];
            } else {
                deq.emplace_back(0, A[i] - A[i - 1]);
            }
        } else if (A[i - 1] >= A[i]) {
            trim(deq, A[i - 1] - A[i]);
            if (!inc(deq, lim)) {
//                cout << "fail" << endl;
                return false;
            }
        }
//        output(deq);
    }
    return true;
}

void solve(ll N, vector<ll> A) {
    int flg = 1;
    for (int i = 1; i < A.size(); i++) {
        if (A[i - 1] >= A[i]) flg = 0;
    }
    if (flg) {
        cout << 1 << endl;
        return;
    }
    int l = 2, r = 200000;
    while (l != r) {
        int m = (l + r) / 2;
        if (f(A, m)) {
            r = m;
        } else {
            l = m + 1;
        }
    }
    cout << l << endl;
}


void main_(istream &cin) {
    ll N;
    cin >> N;
//    N = 200000;
    vector<ll> A(N - 1 + 1);
    for (int i = 0; i <= N - 1; i++) {
        cin >> A[i];
//        A[i] = i % 3 + 1;
    }
    solve(N, A);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 5504
#include <cstdio>
using namespace std;
int main(){
  char A,B,C;
  char AA,BB,CC;
  scanf("%c %c %c",&A,&B,&C);
  scanf(" %c %c %c",&CC,&BB,&AA);
  if(A==AA&&B==BB&&C==CC) printf("YES\n");
  else printf("NO\n");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

bool check(std::vector<std::pair<int, int> > vec){
  int h=0;
  for (auto &entry: vec){
    if (h+entry.first<0) {
      return false;
    }
    h += entry.second;
  }
  return true;
}

int main(){
  int N;
  scanf("%d", &N);
  std::vector<std::string > S(N);
  for (int i=0; i<N; i++){
    std::cin >> S[i];
  }
  std::vector<std::pair<int, int> > l, r;
  int sum=0;
  for (int i=0; i<N; i++){
    int h=0;
    int min=0;
    for (char s : S[i]){
      if (s=='(') h++;
      else h--;
      min=std::min(min, h);
    }
    sum+=h;
    if (h>=0) l.push_back(std::make_pair(min, h));
    else r.push_back(std::make_pair(min-h, -h));
  }
  std::sort(l.begin(), l.end(), std::greater<std::pair<int, int>>());
  std::sort(r.begin(), r.end(), std::greater<std::pair<int, int>>());
  //printf("%d\n", sum);
  //printf("%d\n", check(l));
  //printf("%d\n", check(r));
  if (sum==0 && check(l) && check(r)){
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 42020