akhauriyash/Code-Regression huggingface dataset:
/*
 * Author : Sadi
 * Thu 09/07/2020
 * 21:53:16.66
 */
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    unordered_map<string, string> umap;
    umap["Sunny"] = "Cloudy";
    umap["Cloudy"] = "Rainy";
    umap["Rainy"] = "Sunny";
    string s;
    cin >> s;
    cout << umap[s] << endl;
    return 0;
}


Measured memory_bytes: 3628
package main

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

func main() {
	resolve(parseProblem(os.Stdin))
}

func parseProblem(r io.Reader) ([][]int, intSet) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	a := nextMatrix(3, 3, sc)
	n := nextInt(sc)
	s := newIntSet()
	for i := 0; i < n; i++ {
		s.add(nextInt(sc))
	}
	return a, s
}

type intSet map[int]none

func newIntSet() intSet {
	return map[int]none{}
}

func (s intSet) add(i int) (added bool) {
	_, ok := s[i]
	added = !ok
	s[i] = mark
	return
}

func (s intSet) remove(i int) (removed bool) {
	_, removed = s[i]
	delete(s, i)
	return
}

func (s intSet) doesContain(i int) bool {
	_, ok := s[i]
	return ok
}

func (s intSet) size() int {
	return len(s)
}

func (s intSet) members() chan int {
	ch := make(chan int)
	go func() {
		defer close(ch)
		for k := range s {
			ch <- k
		}
	}()
	return ch
}

type none struct{}

var mark none

func nextMatrix(n, m int, sc *bufio.Scanner) (matrix [][]int) {
	matrix = make([][]int, n)
	for i := 0; i < n; i++ {
		matrix[i] = make([]int, m)
		for j := 0; j < m; j++ {
			matrix[i][j] = nextInt(sc)
		}
	}
	return
}
func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func resolve(mx [][]int, b intSet) {
	for i := 0; i < 3; i++ {
		okL, okC := true, true
		for j := 0; j < 3; j++ {
			okL = okL && b.doesContain(mx[i][j])
			okC = okC && b.doesContain(mx[j][i])
		}
		if okL || okC {
			fmt.Println("Yes")
			return
		}
		// diagonal-l
		// diagonal-r
	}
	okL, okR := true, true
	for i := 0; i < 3; i++ {
		okL = okL && b.doesContain(mx[i][i])
		okR = okR && b.doesContain(mx[i][2-i])
	}
	if okL || okR {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
	return
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 640
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

int n,m,q;
vector<int> a(50),b(50),c(50),d(50);
int ans;
class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

void solve(vector<int> x){
  int temp = 0;
  for(int i=0;i<q;i++){
    if(x[b[i]-1]-x[a[i]-1] == c[i]) temp += d[i];
  }
  ans = max(ans,temp);
} 
void search(vector<int> x){
  if(x.size() == n){
    solve(x);
    return;
  }
  if(x.size() == 0){
    for(int v=1;v<=m;v++) search({v});
    return;
  }
  int bv = x[x.size()-1];
  for(int v=bv;v<=m;v++){
    x.push_back(v);
    search(x);
    x.pop_back();
  }
}

int main(){
  cin >> n >> m >> q;
  for(int i=0;i<q;i++){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  ans = 0;
  search({});
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3572
N = int(input())
A = list(map(int, input().split()))

sum_A = 0
for i in range(1, N, 2):
  sum_A += 2*A[i]

ans = [0]*N
ans[0] = sum(A) - sum_A

for i in range(1, N):
  ans[i] = 2*A[i-1] - ans[i-1]

print(*ans)

Measured memory_bytes: 14028
import sys
readline = sys.stdin.readline


def main():
    A, B = map(int, readline().rstrip().split())
    S = readline().rstrip()
    if S[:A].isdecimal() and S[A] == '-' and  S[A+1:].isdecimal():
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

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

using namespace std;

int main(){
  vector<int> v = {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
};
  int N;
  cin >> N;
  cout << v.at(N-1) << endl;
  
}

Measured memory_bytes: 256
n = int(input())
i = 1
for i in range(1,n + 1):
    if i%3==0:
        print(f" {i}", end="")
        continue
    else:
        x = i
        while x!=0:
            if x%10==3:
                print(f" {i}", end="")
                break
            else:
                x = x//10
print()


Measured memory_bytes: 5884
Imports System

Public Class Program

    Public Shared Sub Main(args As String())

        Dim N As Integer = Integer.Parse(Console.ReadLine)

        Dim ST() As String = Console.ReadLine.Split(" ")

        Dim answer As String = ""

        For i As Integer = 0 To N - 1
            answer = answer & ST(0)(i)
            answer = answer & ST(1)(i)
        Next

        Console.WriteLine(answer)

    End Sub


End Class


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

int main() {
  int a, b, c, min = 0;
  cin >> a;
  for(int i = 0; i < a; i++) {
    cin >> b;
    c = 0;
    while(b % 2 == 0) {
      b /= 2;
      c++;
    }
    if(c < min || i == 0) {
      min = c;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<ll> a(n), c(m);
	vector<int> b(m);
	rep(i, n) cin >> a[i];
	vector<pair<ll, int>> d(m);
	rep(i, m) {
		cin >> b[i] >> c[i];
		d[i] = make_pair(c[i], b[i]);
	}
	sort(d.begin(), d.end());
    reverse(d.begin(),d.end());
	sort(a.begin(), a.end());
	int x = 0;
	bool frag = true;
	rep(i, m) {
		rep(j, d[i].second) {
			if (a[x] < d[i].first) {
				a[x] = d[i].first;
				x++;
			}
			else frag = false;
		}
		if (frag) continue;
		else break;
	}
	ll ans = 0;
	rep(i, n) ans += a[i];
	cout << ans << endl;
}

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


int main(){
    ll a,b;
    cin>>a>>b;
    a--;
    ll ans=0;
    //int c[40]={0};//k桁目
    rep(i,50){
        int c;
        ll t=1LL<<i;
        ll tt=2*t;
        ll quotb=b/tt,remb=b%tt,quota=a/tt,rema=a%tt;
        if(remb<t-1) remb=t-1;
        if(rema<t-1) rema=t-1;
        //cout<<quota<<" "<<rema<<" "<<quotb<<" "<<remb<<" "<<endl;
        ll sumb,suma;
        sumb=quotb*t+remb-t+1;
        suma=quota*t+rema-t+1;
        //cout<<sumb<<suma<<endl;
        c=(sumb-suma)%2;
        //cout<<sumb-suma<<" "<<(b&1LL<<i)<<endl;
        //c=(sumb-suma)%2;
        if(c)ans+=(1LL<<i);
        //cout<<ans<<endl;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void countFunc(int n, int p, int s, int sum, int num, int *count)
{
  if(n == p){
    if(s == sum) ++(*count);
    return;
  }

  if(s < sum) return;
  for(; num <= 9; ++num)
    countFunc(n, p+1, s, sum+num, num+1, count);
}

int main()
{
  int n, s, count;

  while(scanf("%d %d", &n, &s)!=EOF){
    if(n == 0 && s == 0) break;

    count = 0;
    countFunc(n, 0, s, 0, 0, &count);
    printf("%d\n", count);
  }

  return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;


public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int sum_score=0,score;
		for(int i=0;i<5;i++){
			score = sc.nextInt();
			if(score<40){
				score = 40;
			}
			sum_score +=score;
		}
		System.out.println(sum_score/5);
	}
}

Measured memory_bytes: 17164
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int sum = 0;


		sum = B + C;
		if((sum-A)<0) {
			System.out.println(0);
		}else {
			System.out.println(sum-A);
		}
	}

}


Measured memory_bytes: 25300
#include <bits/stdc++.h>
#define BASE 2019
using namespace std;

int main(void) {
    int l, r;
    cin >> l >> r;
    if (r - l + 1 >= BASE) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 2019;
    for (int i = l; i <= r; i++) {
        for (int j = i + 1; j <= r; j++) {
            ans = min(ans, ((i % BASE) * (j % BASE)) % BASE);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

void solve(long long N, vector<long long> A){
	vector<ll> sum(60), res(60);
	rep(i, N) {
		rep(j, 60) {
			if (A[i]&(1ull<<j)) sum[j]++;
		}
	}
	// rep(j, 60) {
	// 	cout << sum[j] << endl;
	// }
	rep(i, N) {
		rep(j, 60) {
			if ((A[i]&(1ull<<j)) == 0) res[j] = (res[j]+sum[j])%mod; else res[j] = (res[j]+N-sum[j])%mod;
		}
	}
	ll resn = 0, two = 1;
	rep(i, 60) {
		resn = (resn+(res[i]%mod*two)%mod)%mod;
		two = (two*2)%mod;
	}
	resn = (resn*modinv(2,mod))%mod;
	cout << resn << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	solve(N, A);
	return 0;
}



Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x;cin>>x;
  for(ll i=1;i<=x/100;i++){
    if(i*105<x)continue;
    else{
      ll num=x-i*100;
      ll nn=0;
      for(ll j=5;j>0;j--){
	nn+=num/j;
	num%=j;
      }
      if(nn <= i){cout<<1<<endl;return 0;}
    }
  }
  cout<<0<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,d,x;
    cin>>n>>d>>x;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin>>a.at(i);
    }
    int ans=0;
   for(int i=0; i<n; i++){
       ans+=1+(d-1)/a.at(i);
   }
    ans+=x;
    cout<<ans<<endl;
}

Measured memory_bytes: 3608
a, b, c, d = map(int, input().split())
turn = 0
while True:
    if not turn:
        c-=b
        turn = 1
    else:
        a-=d
        turn = 0
    if c <= 0:
        flag = 1
        break
    if a <= 0:
        flag = 0
        break
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

template <int mod>
struct ModInt {
    int val;
    ModInt() : val(0) {}
    ModInt(long long x) : val(x >= 0 ? x % mod : (mod - (-x) % mod) % mod) {}
    int getmod() { return mod; }
    ModInt &operator+=(const ModInt &p) {
        if ((val += p.val) >= mod) {
            val -= mod;
        }
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if ((val += mod - p.val) >= mod) {
            val -= mod;
        }
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        val = (int)(1LL * val * p.val % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }
    ModInt operator-() const { return ModInt(-val); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return val == p.val; }
    bool operator!=(const ModInt &p) const { return val != p.val; }
    ModInt inverse() const {
        int a = val, b = mod, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
    ModInt pow(long long n) const {
        ModInt ret(1), mul(val);
        while (n > 0) {
            if (n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.val; }
    friend istream &operator>>(istream &is, ModInt &a) {
        long long t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }
    static int get_mod() { return mod; }
};
const int MOD = 998244353;  // if inv is needed, this shold be prime.
using modint = ModInt<MOD>;

modint dp[3005][6005];
int main() {
    int N, S;
    cin >> N >> S;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

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

    dp[0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int s = 0; s <= S; s++) {
            dp[i + 1][s] += dp[i][s] * 2;
            dp[i + 1][s + A[i]] += dp[i][s];
        }
    }
    cout << dp[N][S] << endl;
}


Measured memory_bytes: 74132
#include <iostream>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <stack>
#include <queue>
#include <deque>

using namespace std;

int main()
{   
    int n;
    cin >> n;
    int i;
    deque<int> deq;
    for (i = 0; i < n;i++)
    {
        int x;
        cin >> x;
        if (i % 2 == 0)
        deq.push_front(x);
        else
        deq.push_back(x);
    }

    if (n % 2 == 1)
    {
        for (i = 0; i < n-1;i++)
        cout << deq[i] << ' ' ;
        cout << deq[n-1] << endl;
    }
    else
    {
        for (i = n-1; i > 0;i--)
        cout << deq[i] << ' ' ;
        cout << deq[0] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 2944
N,K=[int(i) for i in input().split()]
sunuke=[0]*N
for k in range(K):
    dk=int(input())
    A=[int(i) for i in input().split()]
    for a in A:
        sunuke[a-1]+=1
    
n=sum([a==0 for a in sunuke])
print(n)


Measured memory_bytes: 9052
// 0228
#include <iostream>
using namespace std;

int digit[10][7] = {
{0, 1, 1, 1, 1, 1, 1}, 
{0, 0, 0, 0, 1, 1, 0}, 
{1, 0, 1, 1, 0, 1, 1},
{1, 0, 0, 1, 1, 1, 1},
{1, 1, 0, 0, 1, 1, 0},
{1, 1, 0, 1, 1, 0, 1},
{1, 1, 1, 1, 1, 0, 1},
{0, 1, 0, 0, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1},
{1, 1, 0, 1, 1, 1, 1}};

int main(){
	while(1){
		int n, num, display[7] = {0};

		cin>>n;
		if(n == -1)
			break;

		for(int i=0;i<n;i++){
			cin>>num;

			for(int j=0;j<7;j++){
				if(display[j] != digit[num][j])
					cout<<"1";
				else
					cout<<"0";

				display[j] = digit[num][j];
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

int main()
{
    string s;
    cin >> s;
    int prise = 700;
    for(char c : s)
        if(c == 'o')
            prise += 100;

    cout << prise << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[1000000];
int main()
{
	string ans[]={"AKIHABARA",\
								"AKIHABAR",\
								"AKIHABRA",\
								"AKIHBARA",\
								"AKIHBAR",\
								"AKIHBRA",\
								"AKIHBR",\
								"KIHABARA",\
								"KIHABAR",\
								"KIHABRA",\
								"KIHABR",\
								"KIHBARA",\
								"KIHBAR",\
								"KIHBRA",\
								"KIHBR",\
								};
	string s;
	cin>>s;
	for(ll i=0;i<15;i++)if(ans[i]==s){cout<<"YES"<<endl;return 0;}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int k,s,ans=0;
    cin>>k>>s;
    rep(x,s+1)
    {
        rep(y,s+1)
        {
            int z=s-x-y;
            if(z<0)continue;
            if(x<=k && y<=k && z<=k)
            {
                if(x+y+z==s) ans++;
            }
            
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
import sys

def c(x1, y1, x2, y2, x, y):
  return (y2 - y1)*(x - x1) - (x2 - x1)*(y - y1)

for str in sys.stdin:
  x1,y1,x2,y2,x3,y3,xp,yp = map(float, str.split(' '))
  gx, gy = (x1 + x2 + x3)/3, (y1 + y2 + y3)/3

  r1 = c(x1, y1, x2, y2, gx, gy)*c(x1, y1, x2, y2, xp, yp) > 0
  r2 = c(x2, y2, x3, y3, gx, gy)*c(x2, y2, x3, y3, xp, yp) > 0
  r3 = c(x3, y3, x1, y1, gx, gy)*c(x3, y3, x1, y1, xp, yp) > 0
  print 'YES' if r1 and r2 and r3 else 'NO'

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

using namespace std;

int main(){
    long long n;
    cin >> n;
    long long ans = 1;
    while(n > 1){
        n /= 2;
        ans++;
    }
    long long uk = 0;
    for(long long i = 0; i < ans; ++i){
        uk += pow(2, i);
    }
    cout << uk;
    return 0;
}


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

int conv(char suit){
    switch(suit){
    case 'S': return 0;
    case 'H': return 1;
    case 'C': return 2;
    case 'D': return 3;
    }
    return -1;
}

char conv(int suit){
    switch(suit){
    case 0: return 'S';
    case 1: return 'H';
    case 2: return 'C';
    case 3: return 'D';
    }
    return -1;
}

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

    vector<vector<bool> > card(4, vector<bool>(14, false));
    for(int i=0; i<n; i++){
        char suit;
        int rank;
        cin >> suit >> rank;
        card[conv(suit)][rank] = true;
    }
    for(int i=0; i<4; i++){
        for(int j=1; j<=13; j++){
            if(!card[i][j]){
                cout << conv(i) << " " << j << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>   
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
ll dp[2020][2020];
//nCr mod m
#define MOD 1000000007
#define M 1000000
vector<ll> fact;
bool h=false;
void init(){
    h=true;
    fact=vector<ll>(M);
    fact[0]=fact[1]=1;
    loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m){
    ll out=1;
    ll p=a%m;
    while(b){
        if(b&1)out=out*p%m;
        p=p*p%m;
        b>>=1;
    }
    return out;
}
int main(){
    ll n,d,x;
    while(cin>>n>>d>>x,x){
        rep(i,2020)rep(j,2020)dp[i][j]=0;
        dp[0][0]=1;
        rep(i,n)rep(j,n){
            ll t=(dp[i+1][j]+dp[i][j])%MOD;
            if(j+1-x>=0)(t+=MOD-dp[i][j+1-x])%=MOD;
            dp[i+1][j+1]=t;
        }
//      rep(i,n+1){rep(j,n+1)cout<<" "<<dp[i][j];cout<<endl;}
        ll out=0;
        ll q=1;
        ll N=min(n,d);
        rep(i,N+1){
            ll t=dp[i][n]*q%MOD;
            (q*=(d-i)%MOD*powmod(i+1,MOD-2,MOD)%MOD)%=MOD;
            (out+=t)%=MOD;
        }
        cout<<out<<endl;
    }
}

Measured memory_bytes: 34912
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
Def inf = sizeof(Def) == sizeof(long long) ?  2e18:1e9+10;
int main(){
	int n,m;
	while(cin>>n>>m,n){
		int t=n*n+m*m;
		for(int i=t;;i++){
			loop(h,1,160)loop(w,1,160){
				int tt=h*h+w*w;
				if(i==tt){
					if(h>=w)continue;
					if(i==t&&h<=n)continue;
					cout<<h<<" "<<w<<endl;
					goto end;
				}
			}
		}
		end:;
	}
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long a, b; cin >> a >> b; b++;
    long long ans = 0;
    for (int i = 0; i < 60; i++) {
        long long t = (1LL << i);
        long long s = t * 2;
        long long cnt = 0;
        cnt += (b / s) * t + max((b % s) - t, 0LL);
        cnt -= (a / s) * t + max((a % s) - t, 0LL);
        if (cnt & 1) ans += t;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    string a,b;
    cin>>a>>b;
    if (a=="H") {
        if (b=="H") {
            cout<<"H"<<endl;
        }else{
            cout<<"D"<<endl;
        }
    }else{
        if (b=="H") {
            cout<<"D"<<endl;
        }else{
            cout<<"H"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int p, count=0;
  cin >> p;
  vector<int> v(p);
  REP(i,p) cin >> v[i];
  REP(i,p-2) {
    if(v[i]<v[i+1] && v[i+1]<v[i+2]) count++;
    else if (v[i]>v[i+1] && v[i+1]>v[i+2]) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int a[100000];
int b[100000];
int p[100000][2];
long long sum[200000];

int main() {
    int n, i, j;
    long long ans = 1e18, suma = 0, sumb = 0;
    vector <pair<int, pair<int, int>>> v;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) scanf("%d %d", &a[i], &b[i]);
    
    for (i = 0; i < n; i++) {
        suma += a[i];
        sumb += b[i];
        v.push_back(make_pair(a[i], make_pair(i, 0)));
        v.push_back(make_pair(b[i], make_pair(i, 1)));
    }
    
    sort(v.begin(), v.end());
    
    for (i = 0; i < v.size(); i++) p[v[i].second.first][v[i].second.second] = i;
    
    for (i = 0; i < v.size(); i++) sum[i] = v[i].first;
    for (i = 1; i < v.size(); i++) sum[i] += sum[i - 1];
    
    ans = min(ans, suma);
    ans = min(ans, sumb);
    
    for (i = 0; i < n; i++) {
        int c = n;
        long long tmp = sum[n - 1];
        
        if (p[i][0] >= n) {
            c++;
            tmp += a[i];
        }
        
        if (p[i][1] >= n) {
            c++;
            tmp += b[i];
        }
        
        for (j = n - 1; c > n; j--) {
            if (v[j].second.first != i) {
                c--;
                tmp -= v[j].first;
            }
        }
        
        ans = min(ans, tmp);
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


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

int main() {
    long long A, B, C, K; cin >> A >> B >> C >> K;
    long long ans = 0;
    if (K - A >= 0) {
        K -= A;
        ans += A;
    } else {
        ans += K;
        cout << ans << endl;
        return 0;
    }
    if (K - B >= 0) {
        K -= B;
    } else {
        cout << ans << endl;
        return 0;
    }
    ans -= K;
    cout << ans << endl;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int k;
  string s;
  cin >> k >> s;
  if (k >= s.size()) {
    cout << s << '\n';
  }
  else {
    for (int i = 0; i < k; i++) {
      cout << s[i];
    }
    cout << "..." << '\n';
  }
}

Measured memory_bytes: 3636
def e_friendships(N, K):
    if K > (N - 1) * (N - 2) // 2:
        return -1

    ans_graph = []
    for i in range(2, N + 1):
        ans_graph.append('{} {}'.format(1, i))  # スターの構成

    def append_edge(t, lst=[]):
        count = 0
        for i in range(2, N):
            for j in range(i + 1, N + 1):
                if count == t:
                    return lst
                lst.append('{} {}'.format(i, j))
                count += 1
        return lst

    ans_graph = append_edge((N - 1) * (N - 2) // 2 - K, ans_graph)
    return str(len(ans_graph)) + '\n' + '\n'.join(ans_graph)

N, K = [int(i) for i in input().split()]
print(e_friendships(N, K))

Measured memory_bytes: 3316
<?php
  
fscanf(STDIN,"%d",$n);
fscanf(STDIN,"%d %d",$t,$a);
$h_li = explode(" ",trim(fgets(STDIN)));
$ichi = 0;
$re = array();
for($i=0;$i<$n;$i++){
  $re[$i] = abs($a-($t-($h_li[$i]*0.006)));
}


asort($re);

echo (key($re)+1)."\n";


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

// io
#define get(i) scanf("%d", &i)
#define flush fflush(stdin)

// manipulations
#define f(i, n) for (int i = 0; i < n; i++)
#define fr(i, n) for (int i = n - 1; i >= 0; i--)
#define ff(i, a, b) for (int i = a; i <= b; i++)
#define lowbit(x) (x & -x)
#define sz(x) int((x).size())

// built-in
#define bitcount __builtin_popcount
#define gcd __gcd

// short
#define pb push_back
#define fill(arr, a) memset(arr, a, sizeof(arr))

// useful bits
#define IN(i, l, r) (l <= i && i <= r)
#define relax(a, b) (a) = max((a), (b))
#define relaxi(a, b) (a) = min((a), (b))

typedef vector<int> VI;
typedef pair<int, int> PII;
typedef long long ll;
typedef long double ld;

ll modpow(ll a, ll b, ll mod = (ll) (1e9 + 7)) 
{if (!b) return 1; a %= mod; return modpow(a * a % mod, b / 2, mod) * (b & 1 ? a : 1) % mod;}

// for rand
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// use uniform_int_distribution<int>(0, i)(rng)


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);


	int n;
	cin >> n;
	int h[n];
	f(i,n) {
		cin >> h[i];
	}
	int cnt = 0;
	f(i,n) {
		ff(j,0,i) if (h[j]>h[i]) goto end;
		cnt++;
end:{}
	}
	cout << cnt << endl;


	return 0;
}



Measured memory_bytes: 256
N, W = map(int, input().split())
WV = [list(map(int, input().split())) for i in range(N)]

dp = [[0]*(W+1) for i in range(N+1)]
for n in range(1,N+1):
    for w in range(1,W+1):
        if w >= WV[n-1][0]:
            dp[n][w] = max(dp[n-1][w-WV[n-1][0]] + WV[n-1][1], dp[n-1][w])
        else:
            dp[n][w] = dp[n-1][w]
print(dp[-1][-1])




Measured memory_bytes: 120044
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)

using namespace std;
int main()
{
    long long A,B,C,K;
    cin >> A >> B >> C >> K;
    if(K <= A)cout << K << endl;
    else if(A < K && K <= A+B)cout << A << endl;
    else{
        cout << A-(K-(A+B)) << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3624
N = gets.chomp.to_i

a = []
b = Array.new(1, Array.new(3) )

str1 = gets.split
b[0] = 1, str1[0], str1[1].to_i

x = 2
y = 0
while x <= N
  str1 = gets.split
  a = x, str1[0], str1[1].to_i
  y = 0
  i = 0
  while y == 0 && i < x-1
    if a[1] > b[i][1] || (a[1] == b[i][1] && a[2] < b[i][2])
      i += 1
    else
      y = 1
    end
  end
  b.insert(i,a)
  x += 1
end

for x in 0...N
  puts b[x][0]
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
int main(){
    ll n,tmp=0,c=0,c2=0,x1=0,x2=0,ans=0;
    cin>>n;
    priority_queue<ll> q;
    rep(i,0,n){cin>>tmp;q.push(tmp);}
    bool p=true;
    while(p){
        c=q.top()+ans;
        x1=q.top();
        if(c<n){p=false;break;}
        else {
            ll sub =ceil(((ld)c-n+1)/n);
            ans+=sub;
            q.push(x1-sub*n-sub);
            q.pop();
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

void dfs(string s, char mx, int N) {
  if(s.length() == N) {
    fin(s);
  } else {
    for(char c='a'; c<=mx; c++) {
      dfs(s + c, ((c == mx) ? (char)(mx + 1) : mx), N);
    }
  }
}

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  invar(int, N);
  dfs("", 'a', N);
}

Measured memory_bytes: 1536
fun main(args: Array<String>) {

    val (N, K) = readLine()!!.split(" ").map { it.toInt() }

    val list = readLine()!!.split(" ").map { (it.toInt() + 1) / 2.0 }

    var sum = list.take(K).sum()
    var max = sum

    for (i in 0 until N - K) {
        sum += list[i + K] - list[i]
        if(sum > max){
            max = sum
        }
    }

    println(max)
}


Measured memory_bytes: 62220
import java.util.*;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char cstack;
    
    for(int i = 0;i < s.length();i++){
      	cstack = s.charAt(i);
    	if(cstack != ',') System.out.print(cstack);
      	else System.out.print(" ");
    }
   	
  	System.out.println();

  }
}


Measured memory_bytes: 35492
#include <limits>
using ll = long long;
constexpr int INF = std::numeric_limits<int>::max() / 2;
constexpr ll LNF = std::numeric_limits<ll>::max() / 2;

#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> ecnt(N + 1), wcnt(N + 1);
    string S;
    cin >> S;
    for (int i = 0; i < N; i++) {
        switch (S[i]) {
            case 'E': ecnt[i + 1] = 1; break;
            case 'W': wcnt[i + 1] = 1; break;
        }
    }
    for (int i = 1; i <= N; i++) {
        ecnt[i] += ecnt[i - 1];
        wcnt[i] += wcnt[i - 1];
    }
    int m = INF;
    for (int l = 0; l < N; l++) {
        m = min(m, wcnt[l] + ecnt[N] - ecnt[l + 1]);
    }
    cout << m << endl;

    return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }   
    vector<int> dp(N,INF);
    dp[0] = 0;
    REP(i, N-1){
        if(i+1 < N){
            chmin(dp[i+1], dp[i]+abs(H[i+1] - H[i]));
        }
        if(i+2 < N){
            chmin(dp[i+2], dp[i]+abs(H[i+2] - H[i]));
        }
    }

    pr(dp[N-1]);
}

Measured memory_bytes: 1024
#  Copyright: this code was written at 2020. for AtCoder by Silviase


def make_pascal_tri(n):
    array = [[1 for i in range(n + 1)] for i in range(n + 1)]
    for i in range(1, n + 1):
        for j in range(n + 1):
            if j > i:
                array[i][j] = 0
            elif j == 0 or j == i:
                array[i][j] = 1
            else:
                array[i][j] = array[i - 1][j] + array[i - 1][j - 1]
    return array


ar = make_pascal_tri(100)
n, a, b = map(int, input().split())
val = sorted(map(int, input().split()), reverse=True)
res_ave = 0
for i in range(a):
    res_ave += val[i]
res_ave /= a
grat_cnt = 0
same_cnt = 0
for i in range(n):
    if val[i] > val[a - 1]:
        grat_cnt += 1
    elif val[i] == val[a - 1]:
        same_cnt += 1
    else:
        break
result = 0

if grat_cnt == 0:
    for i in range(a, b + 1):
        result += ar[same_cnt][i]
else:
    result = ar[same_cnt][a - grat_cnt]

print(res_ave)
print(result)


Measured memory_bytes: 40176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
const int maxm = 2e3 + 10;
const int inf = 1e9 + 9;

int f[maxn << 2], n, k;
void add(int x, int val){
    while(x > 0){
        f[x] += val;
        x -= x & (-x);
    }
}
int que(int x){
    int s = 0;
    while(x <= n){
        s += f[x];
        x += x & (-x);
    }
    return s;
}
int main()
{
    //ios::sync_with_stdio(0); cin.tie(0); //C++关同步
    cin >> n >> k;
    vector<vector<int> > v(2, vector<int>(n + 1, 0));
    for(int i = 0; i < n; ++i){
        int x;
        cin >> x;
        v[0][i + 1] = x;
    }
    int ins = 0;
    while(k--){
        memset(f, 0, sizeof(f));
        for(int i = 1; i <= n; ++i){
            add(min(n, i + v[ins][i]), 1);
            add(max(0, i - v[ins][i] - 1), -1);
        }
        for(int i = 1; i <= n; ++i){
            v[ins ^ 1][i] = que(i);
        }
        int flag = 1;
        ins ^= 1;
        for(int i = 1; i <= n; ++i){
            if(v[ins][i] != n){
                flag = 0;
                break;
            }
        }
        if(flag == 1)break;
    }
    for(int i = 1; i <= n; ++i){
        cout << v[ins][i];
        if(i == n)cout << '\n';
        else cout << ' ';
    }

    return 0;
}


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

int main(){
    int x,y;
    while(1){
        cin>>x>>y;
        if(x==0&&y==0)break;
        
        if(x<y)cout<<x<<" "<<y<<endl;
        else cout<<y<<" "<<x<<endl;
    }
    return 0;
}


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

#define int long long

int n, x, a[100005];

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

  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  int cnt = 0;

  for (int i = 0; i < n-1; i++) {
    int tmp = a[i] + a[i+1];
    if (tmp > x) {
      tmp = tmp - x;
      a[i+1] = a[i+1] - tmp;
      cnt += tmp;
      if (a[i+1] < 0) {
        tmp = 0 - a[i+1];
        a[i+1] = 0;
        a[i] = a[i] - tmp;
      }
    }
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

struct Info{
	Info(int arg_start,int arg_end,int arg_value){
		start = arg_start;
		end = arg_end;
		value = arg_value;
	}
	bool operator<(const struct Info &arg) const{
		return end < arg.end;
	};
	int start,end,value;
};

int main(){

	int N,dp[367][367],tmp_start,tmp_end,tmp_value,max_end;
	bool FLG;

	vector<Info> V;

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		V.clear();

		for(int i = 0; i <= 366; i++){
			for(int k = 0; k <= 366; k++)dp[i][k] = 0;
		}

		dp[366][366] = 0;
		max_end = 0;

		for(int i = 0; i < N; i++){
			scanf("%d %d %d",&tmp_start,&tmp_end,&tmp_value);
			V.push_back(Info(tmp_start,tmp_end,tmp_value));
			max_end = max(max_end,tmp_end);
		}

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

		for(int i = 0; i < V.size();i++){

			for(int row = 1; row <= V[i].end+1; row++){
				dp[row][V[i].end+1] = max(dp[row][V[i].end+1],dp[row][V[i].start]+V[i].value);
			}

			for(int col = 1; col <= V[i].end;col++){
				dp[V[i].end+1][col] = max(dp[V[i].end+1][col],dp[V[i].start][col]+V[i].value);
			}

			for(int row = 1; row <= max_end+1; row++){
				for(int col = V[i].end+2; col <= max_end+1; col++){
					if(dp[row][col] < dp[row][col-1]){
						dp[row][col] = dp[row][col-1];
					}else{
						break;
					}
				}
			}

			for(int col = 1; col <= max_end+1;col++){
				for(int row = V[i].end+2; row <= max_end+1; row++){
					if(dp[row][col] < dp[row-1][col]){
						dp[row][col] = dp[row-1][col];
					}else{
						break;
					}
				}
			}
		}

		printf("%d\n",dp[max_end+1][max_end+1]);
	}

	return 0;
}

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

typedef long long ll;
#define rep(n, i) for(int i = 0; i < n; ++i)

void solve(void) {
  ll N, K; cin >> N >> K;

  ll res = 0;
  while (N / K != 0) {
    res++;
    N /= K;
  }

  cout << res+1 << endl;

}
int main(void) {
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<int>>;
using P = pair<int,int>;
//int dy[4] = {-1,0,1,0};
//int dx[4] = {0,-1,0,1};

/*
int main()
{
    int N;
    cin >> N;
    vector<int> h(N);
    for(int i=0;i<N;i++)
    {
        cin >> h[i];
    }
    
    
    
    return 0;
}
 */


int main()
{
    long long N;
    cin >> N ;
    long long a=0,b=0;
    
    for(long long i=0;i<200;i++)
    {
        for(long long j=0;j<i+1;j++)
        {
            long long i2 =i*i*i*i*i;
            long long j2 = j*j*j*j*j;
            if(i2 - j2 == N)
            {
                a = i;
                b=j;
                break;
            }
            if(i2 + j2 == N)
            {
                a = i;
                b = -j;
                break;
            }
            
        }
    }
    
    cout << a << " " << b << endl;
}



/*
int main()
{
    int N;
    cin >> N;
    
    
    return 0;
}
*/

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n;

int main() {
	cin >> n;
	cout << "ABC" << n << ln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* library */

/* main */

signed main() {
    ll N, M;
    cin >> N >> M;
    vl A(N);
    ll cnt[N] = {};
    for (auto &x : A) cin >> x;
    // おとく、index
    priority_queue<pair<ll, ll>> pque;
    FOR(i, 0, N) {
        pque.push(make_pair(A[i] - A[i] / pow2(1), i));
    }
    while (M) {
        auto t = pque.top();
        pque.pop();
        cnt[t.second]++;
        pque.push(make_pair((A[t.second] / pow2(cnt[t.second])) - (A[t.second] / pow2(cnt[t.second] + 1)), t.second));
        M--;
    }
    ll ans = 0;
    FOR(i, 0, N) {
        ans += A[i] / pow2(cnt[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3956
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s=sc.next();
		//String t= sc.next();
		int n = sc.nextInt();
		int m = sc.nextInt();
		//int k = sc.nextInt();
		long count=0;
		long count1=0;
		int[] array = new int[3];
		/*array[0]=n-m;
		array[1]=n*m;
		array[2]=n+m;*/
		Arrays.sort(array);

		/*for(int i=0;i<3;i++) {
			if(s.substring(i,i+1).equals(t.substring(i,i+1))) {
				count++;
			}
		}*/

		if(n<=9&&m<=9) {
			System.out.println(n*m);
		}else {
			System.out.println(-1);
		}

		//System.out.println(Math.max(0, n-m*2));
	}
}




Measured memory_bytes: 22868