akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
	return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
	os << "{";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << *it;
	}
	return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin()) os << ", ";
		os << *it;
	}
	return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << it -> first << " = " << it -> second ;
	}
	return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
	for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
	cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/



int main()
{
	FASTIO
	///*
// #ifndef ONLINE_JUDGE
// 	freopen("in.txt", "r", stdin);
// 	freopen("out.txt", "w", stdout);
// 	freopen("error.txt", "w", stderr);
// #endif
//*/
	int T;
	//scanf("%d", &T);
	T = 1;
	for (int cs = 1; cs <= T; cs++) {
		int n, k;
		string s;
		cin >> n >> k >> s;
		int block_cnt = 0;
		char last = 0;
		int ans = 0;
		for (int i = 0; i < n; i++) {
			if (s[i] != last) {
				block_cnt++;
				last = s[i];
			}
			if (s[i] == 'L' && i > 0 && s[i - 1] == 'L') ans++;
			if (s[i] == 'R' && i < n - 1 && s[i + 1] == 'R') ans++;
		}

		int x = (block_cnt - 1) / 2;
		if (k > x) ans = n - 1;
		else ans += (2 * k);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solveA();
		// new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		String[] wkArray = new String[3];

		try {
			StringBuffer buff = new StringBuffer();
			scanner = new Scanner(System.in);
			for (int i = 0; i < 3; i++) {
				wkArray[i] = scanner.next();
			}

			for (int i = 0; i < 3; i++) {
				for (int j = 0; j < 3; j++) {
					if (i == j) {
						buff.append((wkArray[i].toCharArray())[j]);
					}
				}
			}

			System.out.println(buff.toString());

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 22740
import math

def cal(sum_, F, N, K, d):
    count = 0
    for i in range(N):
        if sum_[i] > d:
            count += math.ceil((sum_[i] - d) / F[i])
            if count > K:
                #作ることができない
                return False
    return True


def main():
    N, K = map(int, input().split())
    A = [int(i) for i in input().split()]
    F = [int(i) for i in input().split()]
    A.sort()
    F.sort(reverse=True)
    sum_ = []
    for i in range(N):
        sum_.append(A[i] * F[i])

    right = 10 ** 12
    left = 0
    count = 0
    pre_mid = 0
    while True:
        mid = (right + left) // 2
        if pre_mid == mid:
            break
        if cal(sum_, F, N, K, mid):
            # midを小さくすることができる
            right = mid
        else:
            # midを大きくしなければならない
            left = mid + 1
        pre_mid = mid
        count += 1
    print(mid)


if __name__ == "__main__":
    main()


Measured memory_bytes: 119500
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >>n;
    vl a(n),b(n),c(n);
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    rep(i,n)cin >> c[i];
    sort(all(a));
    sort(all(b));
    sort(all(c));
    ll ans=0;
    rep(i,n){
        ll x=lower_bound(all(a),b[i])-a.begin();
        ll y=c.end()-upper_bound(all(c),b[i]);
        ans+=x*y;
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 2560
//#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
ll fac[1000000];
ll finv[1000000];
ll inv[1000000];

void comb_init(){
  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 comb(ll n,ll k){
  ll c = fac[n];
  c *= finv[k];c %= MOD;
  c *= finv[n-k];c %= MOD;
  return c;
}



int main(){
  ll n;
  cin >> n;
  ll a,b;
  vector<pair<ll,ll> > graph[n];
  ll vcolor[n];
  ll ecolor[n];
  for(ll i=0;i<n-1;i++){
    cin >> a >> b;
    a -= 1;
    b -= 1;
    graph[a].push_back(make_pair(i,b));
    graph[b].push_back(make_pair(i,a));
    vcolor[i] = 0;
    ecolor[i] = 0;
  }
  vcolor[n-1] = 0;
  ecolor[n-1] = 0;
  queue<pair<ll,ll> > q;
  q.push(make_pair(0,0));
  vcolor[0] = 1;
  while(!q.empty()){
    pair<ll,ll> now = q.front();
    q.pop();
    ll temp = now.first;
    ll before_color = now.second;
    ll basic = 1;
    ll next;
    ll next_edge;
    for(int i=0;i<graph[temp].size();i++){
      next = graph[temp][i].second;
      next_edge = graph[temp][i].first;
      if(vcolor[next] != 0) continue;
      vcolor[next] = 1;
      if(basic == before_color) basic += 1;
      ecolor[next_edge] = basic;
      q.push(make_pair(next,basic));
      basic += 1;
    }
  }
  ll ans = 0;
  for(int i=0;i<n-1;i++){
    ans = max(ans,ecolor[i]);
  }
  cout << ans << endl;
  for(int i=0;i<n-1;i++){
    cout << ecolor[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
char a[105],b[105];
int lena,lenb;
int main()
{
	gets(a);
	lena=strlen(a);
	gets(b);
	lenb=strlen(b);
	for(int i=0;i<max(lena,lenb);i++)
	{
		if(a[i]) cout<<a[i];
		if(b[i]) cout<<b[i];
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    if((a*b)%2==0){
      System.out.println("Even");
    }else{
      System.out.println("Odd");
    }
  }
}


Measured memory_bytes: 35600
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	int H,W;
	while(cin>>H>>W){
		if(H==0&&W==0) break;
		for(int i=1;i<=H;i++){
			for(int j=1;j<W;j++){
				cout<<"#";
				}
			cout<<"#"<<endl;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
K, N = map(int, input().split())
A = list(map(int, input().split()))
def circle_distances(A,K,N):
    ret = []
    for i in range(N):
        if i == N-1:
            d = K - abs(A[0] - A[i])
        else:
            d = A[i+1] - A[i]
        ret.append(d)
    return ret
distances = circle_distances(A,K,N)
print(K -max(distances))

Measured memory_bytes: 25644
A = range(60, 180, 20)
B = [2] + range(5, 30, 5)
C = range(600, 1800, 200)

while 1:
  n = int(raw_input())
  if n==0: break
  s = 0
  for _ in [0]*n:
    x, y, h, w = map(int, raw_input().split())
    r = 0
    size = x + y + h
    for a, b in zip(A, B):
      if size > a or w > b: r+=1
      else: break
    if r<6: s += C[r]
  print s

Measured memory_bytes: 4304
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005


int N,M;
int P[SIZE],loc[SIZE];
int boss[SIZE],height[SIZE];

int get_boss(int id){
	if(boss[id] == id)return id;
	else{
		return boss[id] = get_boss(boss[id]);
	}
}

int isSame(int x,int y){
	return get_boss(x) == get_boss(y);
}

void unite(int x,int y){
	int boss_x = get_boss(x);
	int boss_y = get_boss(y);

	if(boss_x == boss_y)return;

	if(height[boss_x] > height[boss_y]){

		boss[boss_y] = boss_x;

	}else if(height[boss_x] < height[boss_y]){

		boss[boss_x] = boss_y;

	}else{ //height[boss_x] == height[boss_y]

		boss[boss_y] = boss_x;
		height[x]++;
	}
}

int main(){

	scanf("%d %d",&N,&M);

	for(int i = 0; i < N; i++){

		scanf("%d",&P[i]);
		loc[P[i]] = i+1;
	}

	for(int i = 1; i <= N; i++){

		boss[i] = i;
		height[i] = 0;
	}

	int a,b;

	for(int i = 0; i < M; i++){

		scanf("%d %d",&a,&b);

		unite(a,b);
	}

	int ans = 0;
	for(int i = 1; i <= N; i++){

		if(isSame(i,loc[i])){

			ans++;
		}
	}

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

	return 0;
}


Measured memory_bytes: 5292
from math import gcd

def sieve(n):
    res = [i for i in range(n+1)]
    for i in range(2, int(n**0.5) + 1):
        if res[i] < i:
            continue
        for j in range(i*i, n + 1, i):
            if res[j] == j:
                res[j] = i
    return res

def factor(n, min_factor):
    res = []
    while n > 1:
        res.append(min_factor[n])
        n //= min_factor[n]
    return res

N = int(input())
A = list(map(int,input().split()))

flag = [0] * (10 ** 6 + 1)

D = sieve(10 ** 6)

flag1 = 0
flag2 = 1

GCD = A[0]

for i in range(N):
    GCD = gcd(GCD, A[i])

if GCD == 1:
    flag1 = 1

for i in range(N):
    L = factor(A[i], D)
    L = set(L)
    for j in L:
        if flag[j]:
            flag2 = 0
            break
        flag[j] = 1
    if not flag2:
        break

if flag2:
    print('pairwise coprime')
elif flag1:
    print('setwise coprime')
else:
    print('not coprime')

Measured memory_bytes: 218824
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A,B,C;
    cin>>A>>B>>C;
    if(A==B&&A!=C){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(B==C&&A!=B){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(C==A&&C!=B){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  string s, t;
  cin >> s;
  int n = s.length();
  vector<int> num;
  for(int i = 0; i < n; i++) {
    if(s[i] != 'x') {
      t += s[i];
      num.push_back(i);
    }
  }
  int m = t.length();
  string rt = t, rs = s;
  reverse(rt.begin(), rt.end());
  reverse(rs.begin(), rs.end());
  if(s == rs) {
    cout << 0 << endl;
  } else if(t != rt) {
    cout << -1 << endl;
  } else {
    string u;
    int ans = 0;
    if(m % 2 == 1) {
      for(int i = 0; i < m / 2; i++) {
        int l = num[(m + 1) / 2 - i - 1] - num[(m + 1) / 2 - i - 2];
        int r = num[(m + 1) / 2 + i] - num[(m + 1) / 2 + i - 1];
        ans += abs(l - r);
      }
    } else {
      for(int i = 0; i < m / 2 - 1; i++) {
        int l = num[m / 2 - i - 1] - num[m / 2 - i - 2];
        int r = num[m / 2 + i + 1] - num[m / 2 + i];
        ans += abs(l - r);
      }
    }
    ans += abs((n - num[m - 1] - 1) - num[0]);
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1148
import sys

# sys.stdin = open('d1.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()


def main():
    h, w = read_int_list()
    n = read_int()
    a = read_int_list()
    color = [0] * (h * w)
    t = 0
    for i in range(n):
        for k in range(a[i]):
            color[t] = i + 1
            t += 1

    c = [[0] * w for i in range(h)]
    t = 0
    for i in range(h):
        if i % 2 == 0:
            start = 0
            stop = w
            step = 1
        else:
            start = w - 1
            stop = -1
            step = -1

        for j in range(start, stop, step):
            c[i][j] = color[t]
            t += 1

    for row in c:
        print(*row)


main()


Measured memory_bytes: 3956
from itertools import permutations
N = int(input())

o = {}
for i, p in enumerate(permutations(range(1,N+1))):
  	o[p] = i
P = tuple(int(x) for x in input().split())
Q = tuple(int(x) for x in input().split())
print(abs(o[P] - o[Q]))

Measured memory_bytes: 16148
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	int n;
	scanf("%d",&n);
	printf("%d",48-n);
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

ll dp[2010][2010];

int main(){
  int n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  vector<pll> v(0);
  rep(i,n){
    v.emplace_back(a[i],i);
  }
  sort(all(v));
  reverse(all(v));
  ll ans=0;
  rep(i,n)for(int j=0;j<=i;j++){
    chmax(dp[i+1][j],dp[i][j]+v[i].first*abs(v[i].second-((n-1)-(i-j))));
    chmax(dp[i+1][j+1],dp[i][j]+v[i].first*abs(v[i].second-j));
  }
  rep(j,n+1){
    chmax(ans,dp[n][j]);
  }
  /*
  rep(i,n+1){
    rep(j,n+1){
      cout << dp[i][j];
    }cout << endl;
  }*/
  cout << ans << endl;
}

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

int main() {
    ll N, A, B; cin >> N >> A >> B;
    vector<ll> X(N); for(int i = 0; i < N; i++) cin >> X[i];
    vector<ll> D(N-1);
    for(int i = 1; i < N; i++){
        D[i-1] = (X[i] - X[i-1])*A;
    }
    ll ans = 0;
    for(int i = 0; i < N-1; i++){
        if(D[i] < B) ans+=D[i];
        else ans += B;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>

class dice{
    public:
    int num[6];
    int u;
    int bt;
    int r;
    int l;
    int f;
    int bk;
    
    void turn(char seq);
};

void dice::turn(char seq){
   // for(int i=0; i<seq.size(); i++){
        int a;
        if(seq=='N'){
            a=bk;
            bk=u;
            u=f;
            f=bt;
            r=r;
            l=l;
            bt=a;
        }
        else if(seq=='S'){
            a=f;
            f=u;
            u=bk;
            bk=bt;
            r=r;
            l=l;
            bt=a;
        }
        else if(seq=='E'){
            a=r;
            r=u;
            u=l;
            l=bt;
            bt=a;
            f=f;
            bk=bk;
        }
        else if(seq=='W'){
            a=l;
            l=u;
            u=r;
            r=bt;
            bt=a;
            f=f;
            bk=bk;
        }
   //}
    
}

int main(){
    dice dice1;
    dice dice2;
    std::string all="NSNNNENNNENNNWNNNWNNNENNN";
    
    for(int i=0; i<6; i++){
        std::cin>>dice1.num[i];
    }
    dice1.u=dice1.num[0];
    dice1.bt=dice1.num[5];
    dice1.r=dice1.num[2];
    dice1.l=dice1.num[3];
    dice1.f=dice1.num[1];
    dice1.bk=dice1.num[4];
    
    for(int i=0; i<6; i++){
        std::cin>>dice2.num[i];
    }
    dice2.u=dice2.num[0];
    dice2.bt=dice2.num[5];
    dice2.r=dice2.num[2];
    dice2.l=dice2.num[3];
    dice2.f=dice2.num[1];
    dice2.bk=dice2.num[4];
    
    for(int i=0; i<all.size(); i++){
        dice2.turn(all[i]);
        if(dice1.u==dice2.u && dice1.bt==dice2.bt && dice1.r==dice2.r && dice1.l==dice2.l && dice1.f==dice2.f && dice1.bk==dice2.bk){
            std::cout<<"Yes"<<std::endl;
            break;
        }else{
            if(i==all.size()-1){
                std::cout<<"No"<<std::endl;
                break;
            }
        }
    }
    return 0;
}


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

la,lb,lc = 0,0,0

for _ in range(N):
    a,b,c = map(int,input().split())
    la, lb, lc = a+max(lb,lc), b+max(lc,la), c+max(la,lb)
print(max(la,lb,lc))

Measured memory_bytes: 47172
#include <bits/stdc++.h>
//........................</HEADER>................................
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
//........................</CONSTANT DEFINE>........................
const unsigned int MOD = 1000000007;
#define ll long long
#define Imax 1e9+5
#define LLmax 1e18
#define Imin -1e9-5
#define LLmin -1e18
#define PI acos(-1.0)
#define EPS 1e-9
#define INF 1<<28

//........................</LOOP >.................................
#define loop(i,a,b) for(int i=a;i<=b;i++)
#define rloop(i,a,b) for(int i=b;i>=a;i--)

//................</ STANDARTD TEMPLATE LIBRARY>...................
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair((a),(b))

//........................</ TYPE CONVERSION>......................
#define toRad(a) ((a)*(PI)/180)
#define toDeg(a) ((a)*180/(PI))

//........................</ MATH>.................................
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sq(a) ((a)*(a))
inline bool isEq(double a,double b){
    return (abs(a-b)<EPS);
}
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}

//........................</ ARRAY DEFAULT>........................
#define mem(a,v) memset(a,v,sizeof(a))
string day [] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
int month[]={31,28,31,30,31,30,31,31,30,31,30,31};  //Not Leap Year

//........................</DIRECTION>.............................
int dx4[]={1,0,-1,0};
int dy4[]={0,1,0,-1}; //4 Direction

int dx8[]={1,1,0,-1,-1,-1,0,1};
int dy8[]={0,1,1,1,0,-1,-1,-1};//8 direction

int dxh[]={2,1,-1,-2,-2,-1,1,2};
int dyh[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction (horse)

//........................</ INPUT/OUTPUT>.........................
#define read(n) scanf("%d",&n)
#define readll(n) scanf("%lld",&n)
#define read2(n,m) scanf("d",&n,&m)
#define read3(n,m,w) scanf("d%d",&n,&m,&w)
#define read2ll(n,m) scanf("lld",&n,&m)
#define write(n) printf("%d\n",n)
#define write(n,m) printf("%d %d\n",n,m)
#define PRECISION(x) cout << fixed << setprecision(x);
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//.......................</ PRE DEFINED FUNCTIONS>..............................
bool sortByFirst(const pair<int,int>&a,const pair<int,int>&b){
    return a.first>b.first;
}
vector <string> v;
void dfs (string str, string t = "", int cnt = 0) {
    if (cnt == 2) {
        v.push_back (t);
        return;
    } else {
        for (int i = 0; i <str.size (); i ++) {
            dfs (str, t + str [i], cnt + 1);
        }
    }
}
int main () {
    FAST_IO
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    while(cin>>n){
        int sum=0,m=n;
        while(n>0){
            int r=n%10;
            sum+=r;
            n/=10;
        }
        m%sum==0?cout<<"Yes"<<endl:cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
i = 0

def cookie(a, b, c):
    global i
    if a == b and b == c:
        return -1
    elif a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
        i += 1
        cookie((b+c)//2, (a+c)//2, (a+b)//2)
        return i

A, B, C = map(int, input().split())
if A % 2 != 0 or B % 2 != 0 or C % 2 != 0:
    print(0)
else:
    print(cookie(A, B, C))

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



int main() {

   char c;cin>>c;
   
   int ascii= (int) c;
//    cout<<ascii<<endl;

   if(ascii>=65 && ascii<=90)
   {
       cout<<'A';
   }
   else
   {
       cout<<'a';
   }
   

   return 0; 

}


Measured memory_bytes: 3612
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;

map<long long, int>flag;
int n;
int main()
{
	int ans = 0;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		int p;
		scanf("%d", &p);
		if(flag[p] == 0) {
			flag[p] = 1;
			ans++;
		}
		else if(flag[p] == 1) {
			flag[p] = 0;
			ans--;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main()
{
  int N, M;
  cin >> N >> M;
  int Lmax, Rmin;
  Lmax = 0;
  Rmin = N;
  vector<int > L(M), R(M);
  for (int i = 0;i < M; i ++){
    cin >> L[i] >> R[i];
    if(L[i] > Lmax){
      Lmax = L[i];
    }
    if(R[i] < Rmin){
      Rmin = R[i];
    }
  }
  if(Lmax > Rmin){
    cout << 0 << endl;
  }else{
    cout << Rmin - Lmax + 1 << endl;
  }

}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

uint64_t getZ() {
  uint64_t v = 0; int c;
  while((c = getchar_unlocked()) >= '0') v=v*10+c-'0';
  return v;
}

int main() {
  int N = getZ();
  int pB = getZ(), ans = pB;
  for(int i = 1; i < N-1; ++i) {
    int B = getZ();
    ans += std::min(pB, B);
    pB = B;
  }
  ans += pB;
  fin(ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int K,m=0,n=0;
	cin>>K;
	for(int i=1;i<=K;i++){
		if(i%2!=0)
		m++;
		else
		n++;
	}
	cout<<n*m<<endl;
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, q;
    cin >> n >> q;
    
    vector<tuple<ll, ll, ll>> p(n);
    rep(i, n) {
        ll s, t, x;
        cin >> s >> t >> x;
        s -= x;  t -= x;
        p[i] = tie(x, s, t);
    }
    sort(all(p));
    
    set<P> st;
    rep(i, q) {
        ll d;
        cin >> d;
        st.insert(make_pair(d, i));
    }
    
    vl ans(q, -1);
    rep(i, n) {
        ll x = get<0>(p[i]);
        ll l = get<1>(p[i]);
        ll r = get<2>(p[i]);
        auto it = st.lower_bound(make_pair(l, -1));
        while(it != st.end()) {
            if(it->first >= r) {
                break;
            }
            ans[it->second] = x;
            st.erase(it++);
        }
    }
    
    rep(i, q) {
        out(ans[i]);
    }
    
    re0;
}

Measured memory_bytes: 21504
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _001_FindingMissingCards
{


    class Program
    {
        static void Main()
        {
            var n = Convert.ToInt32(Console.ReadLine());
            var a = Array.ConvertAll(Console.ReadLine().Split(' '), i=>Int32.Parse(i));

            var flag = true;
            var count = 0;

            while (flag)
            {
                flag = false;
                for (int j = n - 1; j > 0; j--)
                {
                    if (a[j] < a[j - 1])
                    {
                        var tmp = a[j];
                        a[j] = a[j - 1];
                        a[j - 1] = tmp;
                        count++;
                        flag = true;
                    }
                }

            }

            for (int i = 0; i < n - 1; i++)
            {
                Console.Write("{0} ", a[i]);
            }
            Console.WriteLine("{0}", a[n - 1]);

            Console.WriteLine(count);
            
        }
    }
}

Measured memory_bytes: 9240
#include <iostream>

using namespace std;

int main()
{
	int A, B, C, D;
  	cin >> A >> B >> C >> D;
  	if(A + B > C + D){
      cout << "Left";
    }else if(A + B == C + D){
      cout << "Balanced";
    }else{
      cout << "Right";
    }
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e4;

int n;
int ng[101][4];
int dp[101][4][4];

int search(int i, int a, int b)
{
	int &res = dp[i][a][b];
	if (~res) return res;
	if (ng[i][b]) return res = 0;
	if (i == n) return res = 1;
	
	res = 0;
	for (int ne = 1; ne <= 3; ne++){
		if (a == b && b == ne) continue;
		res += search(i + 1, b, ne);
		res %= MOD;
	}
	return res;
}

int main()
{
	memset(dp, -1, sizeof(dp));
	
	int k;
	scanf("%d %d", &n, &k);
	for (int i = 0; i < k; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		ng[a][(b + 1) % 3 + 1] = true;
		ng[a][b % 3 + 1] = true;
	}
	
	int res = search(0, 0, 0);
	
	printf("%d\n", res);
}

Measured memory_bytes: 1200
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int MOD=1000000007;
signed main(){
    string s;cin>>s;
    int y,m,d;
    y=(s[0]-'0')*1000+(s[1]-'0')*100+(s[2]-'0')*10+(s[3]-'0');
    m=(s[5]-'0')*10+s[6]-'0';
    d=(s[8]-'0')*10+s[9]-'0';
    if(m<5)cout<<"Heisei"<<endl;
    else cout<<"TBD"<<endl;
    return 0;
}

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

int main() {
  int n; // even is n
  int m; // odd is m
  cin >> n >> m;

  if (n == 1 && m == 1) {
    cout << 0 << endl;
    return 0;
  } else {
    int bunshi = 1;
    for (int i = 0; i < 2; i++) {
      bunshi *= (n + m - i);
    }
    int result = bunshi / 2;

    cout << result - n*m << endl;
    return 0;
  }
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"
using namespace std;
#define INF (1LL<<60)
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n)  FOR(i,0,(n))


class BSubstring {
public:
	void solve(std::istream& in, std::ostream& out) {
    string s,t;
    in >> s >> t;
    int loop = s.length() - t.length() + 1;
    int ans = INF;
    REP(i,loop){
      string tmp = s.substr(i, t.length());
      int tmpi = 0;
      REP(j, t.length()){
        if(tmp[j] != t[j]){
          tmpi++;
        }
      }
      if(ans > tmpi) ans = tmpi;
    }
    out << ans << endl;
	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
	BSubstring solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <queue>

using namespace std;
typedef pair<string, int> info;

int main()
{
    queue<info> que;
    int n,q;
    string a;
    int b;
    int t=0;
    cin >> n >> q;
    for (int i = 0; i < n; i++)
    {
        cin >> a >> b;
        que.push(info(a, b));
    }

    while (!que.empty())
    {
        info tmp;
        tmp = que.front();
        que.pop();
        if (tmp.second - q <= 0)
        {
            t += tmp.second;
            cout << tmp.first << " " << t << "\n";
        }
        else
        {
            t += q;
            que.push(info(tmp.first, tmp.second - q));
        }
    }
}


Measured memory_bytes: 6336
n = int(input())
lista = [4*i for i in range((100//4)+1)]
listb = [7*i for i in range((100//7)+1)]
flag = False
for i in lista:
    for j in listb:
        if i+j == n:
            flag = True
if flag:
    print('Yes')
else:
    print('No')    

Measured memory_bytes: 3060
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int digit(long long q)
{
        int  f1,d1;
   d1=((int)(log10(q)));
   f1=(int) (q/(int)(pow(10,d1)));
   return f1;
}
int main()
{
    long long q,i,j,k=0,p;
    cin>>q;
    int a[10][10]={0};
    for(i=1;i<=q;i++)
    {
         if(i%10==0)continue;
         else
         {
             j=digit(i);
             a[j][i%10]++;
         }
    }
    for(i=1;i<=9;i++)
    {
        for(j=1;j<=9;j++)
        {
           k+=a[i][j]*a[j][i];
        }

    }
    cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 4072
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 
 using namespace std;
 
 int main()
 {
   double arr[20+2][2];
   int count=0;
   double x,y;
   char temp;
   while(cin>>x>>temp>>y)
   {
     if(x==100&&y==100) break;
     arr[count][0]=x;
     arr[count][1]=y;
     count++;                     
   } 
   double sum=0;
   int i=0;
   double a=sqrt(pow((arr[i][0]-arr[i+1][0]),2)+pow((arr[i][1]-arr[i+1][1]),2)); 
   double b=sqrt(pow((arr[i+1][0]-arr[i+2][0]),2)+pow((arr[i+1][1]-arr[i+2][1]),2));
   double c=sqrt(pow((arr[i][0]-arr[i+2][0]),2)+pow((arr[i][1]-arr[i+2][1]),2));
   double m=1.0/2*(a+b+c);
   sum+=sqrt(m*(m-a)*(m-b)*(m-c));
   //cout<<sum<<endl;
   x=arr[0][0];
   y=arr[0][1];
   for(i=2;i<count-1;i++)
   {
     double b1=sqrt(pow((arr[i][0]-x),2)+pow((arr[i][1]-y),2)); 
     double b2=sqrt(pow((arr[i+1][0]-x),2)+pow((arr[i+1][1]-y),2));
     double k=sqrt(pow((arr[i][0]-arr[i+1][0]),2)+pow((arr[i][1]-arr[i+1][1]),2)); 
     double z=1.0/2*(b1+b2+k);
     double S=sqrt(z*(z-b1)*(z-b2)*(z-k));
     //cout<<sum<<endl;
     sum+=S;         
   }
   printf("%.6lf\n",sum);
   //while(1);
   return 0; 
 }

Measured memory_bytes: 3168
//writer：Sakura
//problem：
//id：
//from：

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
//#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

//快读（可去）
/*
inline int read(){
	int S=0,W=1;
	char CH=getchar();
	while(CH<='0' || CH>'9'){
		if(CH=='-')W=-1;
		CH=getchar();
	}
	while(CH>='0' && CH<='9')S=S*10+CH-'0',CH=getchar();
	return S*W;
}*/

int a,b;
int add,sub,mul;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	//a=read();b=read();
	scanf("%d %d",&a,&b);
	add=a+b;sub=a-b;mul=a*b;
	int Max=max(add,max(mul,sub));
	printf("%d\n",Max);
	return 0;
}



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




int main() {
	
	int a,b;
	cin>>a>>b;
	
    int n = min(a,b);
    
    if(n==a){
        for(int i=0;i<b;i++)
        cout<<a;
    }
    else
    {
        for(int i=0;i<a;i++)
        cout<<b;
    }
    
	
	
	return 0;
}

Measured memory_bytes: 256
N=int(input())
a=list(input().split())
mydict={}
for i in range (len(a)):
    num=int(a[i])
    if str(str(num-1) in mydict)==str(False):
        mydict[str(num-1)]=1
    else:
        mydict[str(num-1)]+=1
    if str(str(num) in mydict)==str(False):
        mydict[str(num)]=1
    else:
        mydict[str(num)]+=1
    if str(str(num+1) in mydict)==str(False):
        mydict[str(num+1)]=1
    else:
        mydict[str(num+1)]+=1
  
print(max(mydict.values()))

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

int A[20];
bool dp[21][2001];

bool isSolve(int i,int m,int n){
    if(dp[i][m] == true)
        return dp[i][m];

    if(m==0){
        dp[i][m] = true;
    }else if(i>=n){
        dp[i][m]=false;
    }else if(isSolve(i+1,m,n)){
        dp[i][m] = true;
    }else if(isSolve(i+1,m-A[i],n)){
        dp[i][m] = true;
    }else{
        dp[i][m] = false;
    }

    return dp[i][m];
}

int main(){
    int n,q;
    cin >> n;
    REP(i,n){
        scanf("%d",&A[i]);
    }
    cin >> q;
    int M[q];
    REP(i,q){
        scanf("%d",&M[i]);
    }

    REP(i,q){
        if(isSolve(0,M[i],n)){
            printf("yes\n");
        }else{
            printf("no\n");
        }
    }

}


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

signed main(){
	vector<char> S(3);
	scanf("%c%c%c", &S[0], &S[1], &S[2]);
	sort(S.begin(), S.end());
	if(S[0] == 'a' && S[1] == 'b' && S[2] == 'c'){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	if(b>=0&&d>=0){
		cout<<max(a*c,b*d)<<endl;
		return 0;
	}
	if(b>=0){
		cout<<max(a*c,max(a,0LL)*d)<<endl;
		return 0;
	}
	else if(d>=0){
		cout<<max(a*c,max(c,0LL)*b)<<endl;
		return 0;
	}
	else cout<<a*c<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

struct rank {
	int right;
	int left;
};

int main(void) 
{
	struct rank A = {0, 0};
	struct rank B = {0, 0};
	struct rank C = {0, 0};
	struct rank D = {0, 0};
	float left, right;

	while (scanf("%f %f", &left, &right) != EOF) {
		if (left >= 1.1) {
			A.left++;
		} else if (left >= 0.6) {
			B.left++;
		} else if (left >= 0.2) {
			C.left++;
		} else {
			D.left++;
		}

		if (right >= 1.1) {
			A.right++;
		} else if (right >= 0.6) {
			B.right++;
		} else if (right >= 0.2) {
			C.right++;
		} else {
			D.right++;
		}
	}

	printf("%d %d\n", A.left, A.right);
	printf("%d %d\n", B.left, B.right);
	printf("%d %d\n", C.left, C.right);
	printf("%d %d\n", D.left, D.right);

	return 0;
}

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

int main(){
    int i, j, m, f, r, s;
    while (1) {
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) break;
        s = m + f;
        if (m == -1 || f == -1) {
            cout << "F" << endl;
        } else if (s > 79){
            cout << "A" << endl;
        } else if (s < 80 && s > 64){
            cout << "B" << endl;
        } else if (s < 65 && s > 49){
            cout << "C" << endl;
        } else if (s < 50 && s > 29){
            if (r > 49){
                cout << "C" << endl;
            } else{
                cout << "D" << endl;
            }
        } else{
            cout << "F" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3092
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <complex>
#include <cfloat>
using namespace std;
 
void intrx(vector<double> &v, double w, double a1, double p1, double q1, double a2, double p2, double q2){
    double A = a1 - a2;
    double B = a2 * p2 - a1 * p1;
    double C = a1 * p1 * p1 + q1 - a2 * p2 * p2 - q2;
    double D = B * B - A * C;
     
    if(abs(A) < 1e-9){
        double x = -0.5 * C / B;
        if(x > 0.0 && x < w){ v.push_back(x); }
    }
    else if(D >= 0.0){
        D = sqrt(D);
         
        double x;
        x = (-B - D) / A;
        if(x > 0.0 && x < w){ v.push_back(x); }
        x = (-B + D) / A;
        if(x > 0.0 && x < w){ v.push_back(x); }
    }
}
 
void aty(vector<double> &v, double w, double a, double p, double q, double y){
    double t = (y - q) / a;
    if(t >= 0.0){
        t = sqrt(t);
        double x;
         
        x = p + t;
        if(x > 0.0 && x < w){ v.push_back(x); }
        x = p - t;
        if(x > 0.0 && x < w){ v.push_back(x); }
    }
}
 
double integ(double a, double p, double x){
    double rt = sqrt((x - p) * (x - p) + 0.25 / (a * a));
    return abs(a) * ((x - p) * rt + log(abs(x - p + rt)) / (4.0 * a * a));
}
 
double length(double a, double p, double x1, double x2){
    return integ(a, p, x2) - integ(a, p, x1);
}
 
int main(){
    int n;
    double w, h, x, y;
    scanf("%lf%lf%d", &w, &h, &n);
     
    vector<double> a(n), p(n), q(n);
    for(int i = 0; i < n; ++i){
        scanf("%lf%lf%lf", &a[i], &p[i], &q[i]);
    }
     
    vector<double> xs;
    xs.push_back(0.0);
    xs.push_back(w);
     
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            intrx(xs, w, a[i], p[i], q[i], a[j], p[j], q[j]);
        }
         
        aty(xs, w, a[i], p[i], q[i], 0.0);
        aty(xs, w, a[i], p[i], q[i], h);
    }
     
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
     
    double sum = 0.0;
    for(int i = 1; i < xs.size(); ++i){
        double mid = (xs[i-1] + xs[i]) * 0.5;
        double maxy = -1e300;
        int idx = -1;
         
        for(int j = 0; j < n; ++j){
            double y = a[j] * (mid - p[j]) * (mid - p[j]) + q[j];
            if(maxy < y){
                maxy = y;
                idx = j;
            }
        }
         
        if(maxy > 0.0 && maxy < h){
            sum += length(a[idx], p[idx], xs[i-1], xs[i]);
        }
    }
     
    printf("%.15f\n", sum);
}

Measured memory_bytes: 1332
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1000000000000
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	if(a*b % 2 == 0) cout << "Even" << endl;
	else cout << "Odd" << endl;
	return 0;
}


Measured memory_bytes: 256
def water(n,h):
    start = 0
    tempmin = 1000
    counter = 0
    for i in range(n):
        if h[i] == 0 or i == n-1:
            if i == n-1 and h[i] != 0:
                if h[i] < tempmin:
                    tempmin = h[i]
                i += 1
            check = False #水をまいたかどうか
            for k in range(start,i):
                h[k] -= tempmin
                check = True
            if check:
                counter += tempmin
            start = i + 1
            tempmin = 1000
        else:
            if h[i] < tempmin:
                tempmin = h[i]
    return h,counter

n = int(input())
h = list(map(int,input().split()))

counter = 0
while max(h) != 0:
    h,c = water(n,h)
    counter += c
print(counter)

Measured memory_bytes: 3064
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int N=sc.nextInt();
        int K=sc.nextInt();
        int a[]=new int[N];
        for(int i=0; i<N; i++){
            a[i]=sc.nextInt();
        }
        Arrays.sort(a);
        
        int l=0;
        int r=a[N-1];
        int mid;
        int J=0;
        while(r-l>1){
            J=0;
            mid=(r+l)/2;
            for(int i=0; i<N; i++){
                if(a[i]>mid){
               J+=(int)Math.ceil((double)a[i]/mid)-1;
                }
            }
            if(J>K){
                l=mid;
            }else{
                r=mid;
            }
        }
        System.out.println(r);
    }
}

Measured memory_bytes: 61656
n = int(input())
l = list(map(int, input().split()))

flag = False
counter = 0

while True:
    for i, v in enumerate(l):
        if v % 2 == 0:
            l[i] = v / 2
        else:
            flag = True
            break
    if flag == False:
        counter += 1
    else:
        break

print(counter)


Measured memory_bytes: 2940
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int A, B, C;
	std::cin >> A >> B >> C;
	if (C >= A && C <= B)
		std::cout << "Yes\n";
	else
		std::cout << "No\n";
}


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

namespace COJ1_7
{
    public class Node
    {
        public int value;
        public Node parent;
        public Node left;
        public Node right;
    }
    class Program
    {

        static void Main(string[] args)
        {
            Node root = new Node();
            int cnt = int.Parse(Console.ReadLine());

            while (cnt-- > 0)
            {
                var command = Console.ReadLine().Split(' ');
                switch (command[0])
                {
                    case "insert": Insert(root, int.Parse(command[1])); break;
                    default: Print(root); break;
                }
            }
        }

        public static void Insert(Node node, int key)
        {
            Node x = node;
            Node y = null;
            while (x != null&&x.value!=0)
            {
                y = x;
                if (key < x.value)
                    x = x.left;
                else x = x.right;
            }
            Node tmp = new Node();
            tmp.value = key;
            tmp.parent = y;

            if (y==null) 
            {
                node.value = key;
            }
            else if (key < y.value)
            {
                y.left = tmp;
            }
            else
            {
                y.right = tmp;
            }
        }

        public static void Print(Node node)
        {
            StringBuilder builder = new StringBuilder();
            InOrder(node, builder);
            builder.Append("\n");
            PreOrder(node, builder);
            builder.Append("\n");
            Console.Write(builder.ToString());
        }
        public static void InOrder(Node node, StringBuilder builder)
        {
            if (node == null) return;
            InOrder(node.left, builder);
            builder.Append(" ").Append(node.value);
            InOrder(node.right, builder);
        }
        public static void PreOrder(Node node, StringBuilder builder)
        {
            if (node == null) return;
            builder.Append(" ").Append(node.value);
            PreOrder(node.left, builder);
            PreOrder(node.right, builder);
        }
    }
}

Measured memory_bytes: 78216