akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;

ll DP[110][10];
int main(){
    int H, W, K;
    cin >> H >> W >> K;

    DP[0][0] = 1; 
    for(int i = 0; i < H; i++){
        vector<ll> tmp(W);
        fill(tmp.begin(), tmp.end(), 0);
        for(int j = 0; j < (1 << (W-1)); j++){
            bool fail = false;
            for(int k = 0; k < W-2; k++){
                bool x = (j >> k) & 1;
                bool y = (j >> (k+1)) & 1;
                if(x && y) fail = true;
            }
            if(fail) continue;

            for(int k = 0; k < W; k++){
                bool x = (j >> (k-1)) & 1;
                bool y = (j >> k) & 1;

                if(k == 0) x = false;
                if(k == W-1) y = false;

                if(x){
                    tmp[k] += DP[i][k-1];
                }
                else if(y){
                    tmp[k] += DP[i][k+1];
                }
                else{
                    tmp[k] += DP[i][k];
                }
                tmp[k] %= MOD;
            }
        }

        for(int k = 0; k < W; k++){
            DP[i+1][k] = tmp[k];
        }
    }

    //printf("\n");
    //REP(i,H+1){
    //    REP(j,W){
    //        printf("%lld ", DP[i][j]);
    //    }
    //    printf("\n");
    //}
    //printf("\n");

    ll ans = 0;
    ans = DP[H][K-1];

    cout << ans % MOD<< endl;
    return 0;
}


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

using namespace std;


int main(){
    string input;
    stack<char> s;
    cin >> input;
    for(auto item:input){
        if(item == 'B'){
            if(!s.empty()){
                s.pop();
            }
        }else{
            s.push(item);
        }
    }
    string result = "";
    while(!s.empty()){
        result += s.top();
        s.pop();
    }

    reverse(result.begin(),result.end());

    cout << result;

}






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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    set<int> B;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        B.insert(A[i]);
    }
    sort(A.begin(), A.end());
    int cnt = 0;
    int now = A[0];
    for(int i = 1; i < N; i++){
        if(A[i] == now)cnt++;
        else now = A[i];
    }
    
    int ans = B.size();
    if(cnt % 2 == 1)ans--;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5376
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.DP
{
    class ARC059_F
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            string s = Read();
            int remain = n - s.Length;
            int poses = s.Length;
            long mask = 1000000000 + 7;

            long[] dp = new long[n + 1];
            dp[0] = 1;
            for (int i = 1; i <= n; i++)
            {
                long[] next = new long[n + 1];
                for (int j = 0; j < i; j++)
                {
                    if (dp[j] == 0) continue;

                    if (j == 0)
                    {
                        next[j] += dp[j];
                        next[j] %= mask;
                    }
                    else
                    {
                        next[j - 1] += dp[j];
                        next[j - 1] %= mask;
                    }
                    next[j + 1] += dp[j] * 2;
                    next[j+1] %= mask;
                }
                dp = next;
            }

            long res = dp[s.Length];
            long pats = 1;
            for(int i = 0; i < s.Length; i++)
            {
                pats *= 2;
                pats %= mask;
            }
            res = MultiMod(res, ReverseMod(pats, mask - 2, mask), mask);
            WriteLine(res);
        }

        static long MultiMod(long a, long b, long mask)
        {
            return ((a % mask) * (b % mask)) % mask;
        }

        static long ReverseMod(long a, long pow, long mask)
        {
            if (pow == 0) return 1;
            else if (pow == 1) return a % mask;
            else
            {
                long halfMod = ReverseMod(a, pow / 2, mask);
                long nextMod = MultiMod(halfMod, halfMod, mask);
                if (pow % 2 == 0)
                {
                    return nextMod;
                }
                else
                {
                    return MultiMod(nextMod, a, mask);
                }
            }
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 29784
# import math
# import fractions
# import numpy as np

MOD = 10 ** 9 + 7

# ゼロ埋め
# list = [0] * N

# 二次元配列
# [[inf, inf, inf], [inf, inf, inf]]
# dp = [[float('inf')] * (H + 1) for i in range(N + 1)]

def solve(N, M, A):
    max = 0
    A.sort()

    for i in range(1, N):
        max += A[i] * cmb(i,  M-1, MOD)

    min = 0
    A.sort(reverse=True)
    for i in range(1, N):
        min += A[i] * cmb(i,  M-1, MOD)

    return int((max - min) % MOD)

# S = input()
# N = int(input())
N, M = map(int, input().split())
A = list(map(int, input().split()))
# B = [int(input()) for _ in range(n)]
# A = []
# B = []
# for _ in range(N):
#     a, b = list(map(int, input().split()))
#     A.append(a)
#     B.append(b)

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
 
p = 10 ** 9 + 7
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)




print(solve(N, M, A))


Measured memory_bytes: 20560
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);

	string s;
	cin >> s;

	if (s == "ABC")
	{
		cout << "ARC";
	}
	else
	{
		cout << "ABC";
	}

	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ll N, W;
  cin >> N >> W;
  vector<ll> w(N), v(N);
  for (int i = 0; i < N; ++i) {
    cin >> w[i] >> v[i];
  }
  
  vector<vector<ll>> dp(N+1, vector<ll>(W+1, 0));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j <= W; ++j) {
      if (j - w[i] >= 0) {
        chmax(dp[i+1][j], dp[i][j - w[i]] + v[i]);
      }
      chmax(dp[i+1][j], dp[i][j]);
    }
  }
  cout << dp[N][W] << endl;
}

Measured memory_bytes: 80256
#include <iostream>

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

int main(){
    int a,b,c,d; std::cin >> a >> b >> c >> d;
    while(1){
        c -= b;
        if(c <= 0) break;
        a -= d;
        if(a <= 0) break;
    }
    std::string ans="Yes";
    if(a<=0)
        ans="No";
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9 +7  ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////



///////////////////////////////////////////////////////////////
void solve(){
   int n ;
   cin >> n ;
   while(n){
        if(n%10==7){
            cout << "Yes";
            return ;
        }
        n/=10;
   }
   cout << "No\n";
}
int main(){
    int t = 1 ;
//    cin >> t ;
//    int cnt = 1 ;
    while(t--){
        //cout << "Case #" << cnt << ": ";
        solve( );
      //  cnt++;
    }
}




Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
using namespace std;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	string s;
	cin>>s;
	s[5]=' ';
	s[13]=' ';
	cout<<s<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for(int i=0; i<h; ++i)
        cin >> s[i];

    vector<vector<int> > maxLen(h, vector<int>(w, 0));
    for(int y=0; y<h; ++y){
        int x = 0;
        while(x < w){
            if(s[y][x] == '#'){
                ++ x;
                continue;
            }
            int len = 1;
            while(x + len < w && s[y][x+len] == '.')
                ++ len;
            for(int i=0; i<len; ++i)
                maxLen[y][x+i] = len;
            x += len;
        }
    }

    int ans = 0;
    for(int x=0; x<w; ++x){
        int y = 0;
        while(y < h){
            if(s[y][x] == '#'){
                ++ y;
                continue;
            }
            int len = 1;
            while(y + len < h && s[y+len][x] == '.')
                ++ len;
            for(int i=0; i<len; ++i)
                ans = max(ans, len + maxLen[y+i][x] - 1);
            y += len;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 20096
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>

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

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;
}

using namespace std;
array<array<int64_t, 100010>, 110> dp;

int main() {
  uint64_t N, W;
  cin >> N >> W;
  vector<int> v(N);
  vector<int> w(N);

  rep(i, N) { cin >> w[i] >> v[i]; }


  rep(i, N) {
    rep(sum_w, W+1) {
      // pick
      if (w[i] <= sum_w) {
        chmax(dp[i + 1][sum_w], v[i] + dp[i][sum_w - w[i]]);
      }
      // not pick
      chmax(dp[i+1][sum_w], dp[i][sum_w]);
    }
  }

  cout << dp[N][W] << endl;

  return 0;
}


Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n);
	std::vector<int> ans(n, -1);
	for(int i = 0; i < n; i++) {
		int a; scanf("%d", &a);

		ans[a - 1] = i;
	}
	
	for(int i = 0; i < n; i++) printf("%d ", ans[i] + 1);
	printf("\n");
	return 0;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    for (int i = 1; i < 300; i++) {
        if (a * i % b == c) {
            cout << "YES" << endl;
            return 0;
        }
    } 
    cout << "NO" << endl;
}   

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int a,b;
    cin>>a>>b;
    if(a>=13)
        cout<<b<<endl;
    if(6<=a&&a<=12)
        cout<<b/2<<endl;
    if(a<=5)
        cout<<"0"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
  string S, T;
  cin >> S >> T;
  ll s = S.size();
  ll t = T.size();
  ll dp[s+1][t+1];
  for(int i=0; i<s+1; i++) for(int j=0; j<t+1; j++) dp[i][j] = 0;
  // dp[i+1][j+1] = dp[i][j] + 1 or dp[i+1][j] or dp[i][j+1]
  dp[0][0] = 0;
  for(int i=0; i<s; i++){
    for(int j=0; j<t; j++){
      if(S[i] == T[j]){
        dp[i+1][j+1] = dp[i][j]+1;
      }else{
        dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
      }
    }
  }
//  cout << dp[s][t] << endl;
  string ret = "";
  ll i = s;
  ll j = t;
  while(i > 0 && j > 0){
    if(dp[i][j] == dp[i-1][j]) i--;
    else if(dp[i][j] == dp[i][j-1]) j--;
    else if(dp[i][j] == dp[i-1][j-1] + 1){
      i--;
      j--;
      ret = S[i] + ret;
    }        
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 70656
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		if(S[2] == S[3] && S[4] == S[5])
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}


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

int main(){
  char a, b;
  cin >> a >> b;
  char ans;
  if(a=='H' && b=='H') ans = 'H';
  else if(a=='H' && b=='D') ans = 'D';
  else if(a=='D' && b=='H') ans = 'D';
  else if(a=='D' && b=='D') ans = 'H';

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
ans=10**9

if h%3==0 or w%3==0:print(0);exit()

a=h//2
b=h-a
for i in range(1,w):
    length=w-i
    A=i*a
    B=i*b
    peace_max=max(length*h,A,B)
    peace_min=min(length*h,A,B)
    ans=min(ans,peace_max-peace_min)

a=w//2
b=w-a
for i in range(1,h):
    length=h-i
    A=i*a
    B=i*b
    peace_max=max(length*w,A,B)
    peace_min=min(length*w,A,B)
    ans=min(ans,peace_max-peace_min)

for i in range(1,h):
    length=h-i
    a=i//2
    b=i-a
    peace_max=max(length*w,a*w,b*w)
    peace_min=min(length*w,a*w,b*w)
    ans=min(ans,peace_max-peace_min)
    
for i in range(1,w):
    length=w-i
    a=i//2
    b=i-a
    peace_max=max(length*h,a*h,b*h)
    peace_min=min(length*h,a*h,b*h)
    ans=min(ans,peace_max-peace_min)

print(ans)

Measured memory_bytes: 44400
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
bool chmax(T &a, const T &b) {if (a < b){ a = b; return 1;} return 0;}
template <class T>
bool chmin(T &a, const T &b) {if (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int N;
    cin >> N;

    vi a(N);
    REP(i,N) cin >> a[i];

    vi c(N);
    copy(ALL(a),c.begin());

    sort(ALL(c), greater<>());

    REP(i,N) {
        if (c[0] == a[i]) cout << c[1] << endl;
        else cout << c[0] << endl;
    }


    return 0;
}


Measured memory_bytes: 3200
fun main(args: Array<String>) {
    val line = readLine()
    val nums = line!!.split(" ").map { it.toInt() }
    val ans = solve(nums)
    print(ans)
}

fun solve(nums: List<Int>): String {
    return if (nums[0] <= nums[1]) {
        Safe.unsafe.name
    } else {
        Safe.safe.name
    }
}

enum class Safe {
    unsafe,
    safe
}

Measured memory_bytes: 36388
/* Author : Prasuk Jain */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int              long long int
#define ull              unsigned long long
#define ld               long double
#define fo(i, n)         for(int i=0; i<n; i++)
#define Fo(i, a, b)      for(int i=a; i<b; i++)
#define rfo(i, n)        for(int i=n-1; i>=0; i--)
#define Rfo(i, a, b)     for(int i=b-1; i>=a; i--)
#define tr(it, v)        for(auto it=v.begin(); it!=v.end(); it++)
#define F                first
#define S                second
#define vi               vector<int>
#define vvi              vector<vector<int>>
#define pii              pair<int, int>
#define pqb              priority_queue<int>
#define pqs              priority_queue<int, vi, greater<int>>
#define mii              map<int, int>
#define uset             unordered_set<int>
#define umap             unordered_map<int, int>
#define mp               make_pair
#define pb(x)            push_back(x)
#define hcf(x, y)        __gcd(x, y)
#define lcm(x, y)        boost::math::lcm(x,y)
#define setpre(x, y)     fixed << setprecision(y) << x
#define setbits(x)       __builtin_popcountll(x)
#define zerolead(x)      __builtin_clzll(x)
#define zerotrail(x)     __builtin_ctzll(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define PI               3.1415926535897932384626
const int mod = 1e9+7;
const int inf = 1e18;
int mpow(int base, int exp);
bool isprime(int num);
void prifact(int num);

//*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!//

void coderprasukj(){ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int32_t main() {
    coderprasukj();
    int t, n, k, x, y;
    cin >> n;
    n = n%10;
    string s;
    if(n==2 || n == 4 || n==5 || n==7 || n==9) s = "hon";
    else if(n==3) s = "bon";
    else s = "pon";
    cout << s << '\n';
    return 0;
}

//*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!//

int mpow(int base, int exp) {
    base %= mod;
    int result = 1;
    while (exp > 0) {
        if (exp & 1) result = ((int)result * base) % mod;
        base = ((int)base * base) % mod;
        exp >>= 1;
    }
  return result;
}

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

void prifact(int num){
    for(int i=2; i<=num; i++)
    if(num%i == 0){
        int cnt = 0;
        while(num%i == 0)
        cnt++ , num /= i;
        cout << i << "^" << cnt << " ";
    }
    if(num > 1)
    cout << num << "^" << "1" << " ";
}




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

int main(){
  string S;cin >> S;
  for(int i=0;i<S.size();i++){
    if(S[i]==','){
      cout << " ";
    }else{
      cout << S[i];
    }
  }
  cout << endl;
}

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

#include <bits/stdc++.h>

using namespace std;

class abc088_b {
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<int> a(N);
        for (int i = 0; i < N; ++i) {
            in >> a[i];
        }
        sort(begin(a), end(a), greater<int>());
        int bal = 0;
        for (int i = 0; i < N; ++i) {
            bal += ((i % 2) ? -a[i] : a[i]);
        }
        out << bal << "\n";
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	abc088_b solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
n=int(input())
ans=0
for i in range(1,n+1,2):
  divisor=[]
  for j in range(1,int(i**(1/2))+1):
    if i%j==0:
      divisor.append(j)
      if j!=i//j:
        divisor.append(i//j)
  if len(divisor)==8:
    ans+=1
print(ans)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
typedef long long ll;

int main(){

    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A, B) << " " << max(0, B - (N - A)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(){
    int a,b,k;
    scanf("%d %d %d",&a,&b,&k);
    for(int i=0;i<k;i++){
        if(i%2==0){
            b+=a/2;
            a/=2;
        }
        else{
            a+=b/2;
            b/=2;
        }
    }
    printf("%d %d\n",a,b);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String a[]){
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		for(int i=0;i<N;i++){
			int b = sc.nextInt();
			int c = sc.nextInt();
			int d = sc.nextInt();
			System.out.println(isRightTriangle(b,c,d));
		}
		sc.close();
	}
	
	public static String isRightTriangle(int a, int b ,int c){
		if(a>b){
			int k = a;
			a = b;
			b = k;
		}
		if(b>c){
			int k = b;
			b = c;
			c= k;
		}
		
		if(c*c == a*a+b*b)
			return "YES";
		else
			return "NO";
	}

}


Measured memory_bytes: 32732
n = gets.chomp

def dfs(s, i)
  if i == 3
    if eval(s) == 7
      puts s + "=7"
      exit
    end
  else
    #puts s[0...2*i+1] + '+' + s[2*i+1...s.size]
    dfs(s[0...2*i+1] + '+' + s[2*i+1...s.size], i+1)
    dfs(s[0...2*i+1] + '-' + s[2*i+1...s.size], i+1)
  end
end

dfs(n, 0)


Measured memory_bytes: 1916
import scala.io.StdIn._
object Main {
  def main(args:Array[String]) {
    val NK = readLine().split(' ').map(_.toInt)

    var ans = Array.fill(NK(0))(0)
    for(i <- 0 until NK(1)) {
      var d = readLine().toInt
      var A = readLine().split(' ').map(_.toInt)
      for(j <- A) ans(j - 1) += 1
    }
    var count = 0
    for(i <- 0 until NK(0)) if(ans(i) == 0) count += 1
    println(count)
  }
}


Measured memory_bytes: 54896
import sys

char_list = []
for line in sys.stdin:
    char_list.append([j for j in line.lower()])
char_dict = {i:0 for i in "abcdefghijklmnopqrstuvwxyz"}
for i in range(len(char_list)):
    for j in char_list[i]:
        if j in char_dict:
            char_dict[j] += 1
for i in char_dict:
    print(i+" : {0}".format(char_dict[i]))



Measured memory_bytes: 5580
/*à¥à¥*/
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different.
Change variable names or change some Data structres or anything just make sure MOSS do not
Detect Anything.
Yours Faithfully
Shobhit Yadav */

/* I do not fear this new challenge. Rather like a true warrior I will rise to meet it. 
                                       -Prince Vegeta  */

 /* â€œStrength is the only thing that matters in this world. Everything else is just a delusion for the weak.â€ â€“ Vegeta */

#include<bits/stdc++.h>
using namespace std;
#define ll long long 



ll A,B,K;
/*ll freq[200005];*/
void solve(){
   /*memset(freq,0,sizeof(freq));*/
string s,t;
ll county = 0;

cin>>s>>t;

for(ll i = 0 ; i<s.length() ; i++){
  if(s[i] != t[i])
    county++;
}

 cout<<county<<'\n';


}



int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  
   solve();

  return 0;
}

Measured memory_bytes: 3768
package main

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

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

func main() {
	n := readInt()
	s := readString()

	r := strings.Count(s, "R")
	g := strings.Count(s, "G")
	b := strings.Count(s, "B")

	ans := r * g * b

	for i := 0; i < n; i++ {
		for d := 0; d < n; d++ {
			j := i + d
			k := j + d
			if k >= n {
				break
			}
			if s[i] != s[j] && s[j] != s[k] && s[k] != s[i] {
				ans = ans - 1
			}
		}
	}

	fmt.Println(ans)
}

/*-------------------inputs-------------------*/

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

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

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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

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

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func subL(list []int) []int {
	sl := make([]int, len(list)-1)
	for i := range list {
		if i == len(list)-1 {
			continue
		}
		sub := list[i+1] - list[i]
		sl[i] = sub
	}
	return sl
}

func Combinations(n, k int) [][]int {
	combins := binomial(n, k)
	data := make([][]int, combins)
	if len(data) == 0 {
		return data
	}
	data[0] = make([]int, k)
	for i := range data[0] {
		data[0][i] = i
	}
	for i := 1; i < combins; i++ {
		next := make([]int, k)
		copy(next, data[i-1])
		nextCombination(next, n, k)
		data[i] = next
	}
	return data
}

func nextCombination(s []int, n, k int) {
	for j := k - 1; j >= 0; j-- {
		if s[j] == n+j-k {
			continue
		}
		s[j]++
		for l := j + 1; l < k; l++ {
			s[l] = s[j] + l - j
		}
		break
	}
}

func binomial(n, k int) int {
	errNegInput := "combin: negative input"
	badSetSize := "combin: n < k"
	if n < 0 || k < 0 {
		panic(errNegInput)
	}
	if n < k {
		panic(badSetSize)
	}
	if k > n/2 {
		k = n - k
	}
	b := 1
	for i := 1; i <= k; i++ {
		b = (n - k + i) * b / i
	}
	return b
}


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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<string> a(H);
  
  for(int i=0; i<H; i++){
    cin >> a.at(i);
  }
  
  for(int i=0; i<W+2; i++){
    cout << "#";
    if(i==W+1) cout << endl;
  }
  
  for(int i=0; i<H; i++){
    cout << "#" + a.at(i) + "#" << endl;
  }
  
  for(int i=0; i<W+2; i++){
    cout << "#";
    if(i==W+1) cout << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int N;
    double x;
    cin >> N;
    x = (N/2)/(double)N;
    if (N%2) x += 1.0/(double)N;
    cout << fixed << setprecision(10) << x << endl;

    return 0;
}


Measured memory_bytes: 256
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,k,a[2010],ans=0,cnt;

int main()
{
	cin>>n>>k;
	rep(i,n) cin>>a[i];
	rep(i,n)
	{
		cnt=0;
		for(int j=i+1;j<n;j++) if(a[i]>a[j]) cnt++;
		ans=(ans+(k+1)*k/2%MOD*cnt)%MOD;
		cnt=0;
		rep(j,i) if(a[i]>a[j]) cnt++;
		ans=(ans+k*(k-1)/2%MOD*cnt)%MOD;
	}
	cout<<ans<<endl;
	return 0;
}

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

class Solution
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var sum = 0;
        for (int i = 0; i < n; i++)
        {
            var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            sum += vals[1] - vals[0] + 1;
        }

        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES // for C++
#include <cmath>
using namespace std;

int main(){
  double A,B;
  cin>>A>>B;
  double ans=B*B*B*4*M_PI/3;
  cout<<fixed<<setprecision(12)<<ans<<endl;
}



Measured memory_bytes: 3300
#include <iostream>

int main(){
  int n;
  std::cin >> n;
  long a=2,b=1,c;
  for(int i=1; i<n; ++i){
    c = a + b;
    a = b;
    b = c;
  }
  if(n==1){
    std::cout << "1" << std::endl;
  }else{
    std::cout << c << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    long long int total_height = 0;
    vector<int> v(n);
    for(int i=0; i<n; i++){
        cin>>v[i];
    }

    for(int i=1; i<n; i++){
        if(v[i]<v[i-1]){
            total_height+= (long long)(v[i-1]-v[i]);
            v[i] = v[i-1];
        }
    }
    cout<<total_height<<'\n';

    return 0;
}

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS(N) resize(N)
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

int N;
vector<ll> A;

void init()
{
	cin >> N;
	CINV(A, N);
	sort(all(A), greater<ll>());
}

map<ll, ll> m;

void solve()
{
	rep(i, N) {
		m[A[i]]++;
	}
	ll t = 1LL << 35;
	ll res = 0;
	rep(i, N) {
		while ((t >> 1) > A[i]) t >>= 1;
		if (m[A[i]] == 0) continue;
		m[A[i]]--;
		if (m[t - A[i]] > 0) {
			res++;
			m[t - A[i]]--;
		}
	}
	cout << res << endl;
}




Measured memory_bytes: 26752
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>


int main()
{
    // std::cout << std::fixed << std::setprecision(10);
    int n, l; std::cin >> n >> l;
    std::vector<int> a(n);
    int val = 1000, ans = 0, sum=0;
    for(int i=0; i<n; i++)
    {
        a[i] = l + i;
        std::cerr << a[i] << std::endl;
        if(std::abs(a[i]) < val)
        {
            ans = i;
            val = std::abs(a[i]);
        }
        sum += a[i];
    }
    std::cout << sum - a[ans] << std::endl;

    return 0;
}

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

int main(){
  char a;
  cin >> a;
  if(a=='A'){
    cout<<"T";
  }else if(a=='T'){
    cout<<"A";
  }else if(a=='C'){
    cout<<"G";
  }else if(a=='G'){
    cout<<"C";
  }

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<set>
using namespace std;
typedef long long ll;
const int N=2e5+10;
int a[N],n,k,cnt,c1,ans;
set<int> s;
int main(){
	cin>>n>>k;
	for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	for (int i=1;i<=k;i++)s.insert(a[i]),cnt+=(i>1&&a[i]>a[i-1]);
	c1+=(cnt==k-1);ans=1;
	for (int i=k+1;i<=n;i++){
		if (a[i-k]<a[i-k+1])cnt--;
		if (a[i]>a[i-1])cnt++;
		if (a[i-k]!=*s.begin()||a[i]<*s.rbegin()){
			ans++;
			c1+=(cnt==k-1);
		}
		s.insert(a[i]);
		s.erase(a[i-k]);
	}
	if (c1)ans-=c1-1;
	cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;
const int MOD=1e9+7;

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

  int n;cin>>n;
  int a[100001]={0};
  for(int i=0;i<n;i++){
      int tmp;cin>>tmp;
      a[tmp]++;
  }
  ll res=1;
  if(n%2){
      int k=(n+1)/2;
      bool flag=(a[0]==1);
      for(int i=1;i<k;i++){
          flag= flag&&(a[2*1]==2);
          res=(2*res)%MOD;
      }
      if(flag) cout<<res<<endl;
      else cout<<0<<endl;
  }
  else{
      int k=n/2;
      bool flag=true;
      for(int i=1;i<=k;i++){
          flag= flag&&(a[2*i-1]==2);
          res=(2*res)%MOD;
      }
      if(flag) cout<<res<<endl;
      else cout<<0<<endl;
  }
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
int main() {
  LL N, K;
  cin >> N >> K;
  LL sum=0;
  if(K==0) {
    sum = N*N;
  } else {
    for(LL i=K; i<=N; ++i) {
      sum += (N/i)*(i-K);
      sum += max(0ll, (N%i) - K + 1);
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT()
    C = [LIST() for i in range(N)]
    C.sort(key=lambda x:x[1])
    sum = 0
    for i in range(N):
        sum += C[i][0]
        if sum > C[i][1]:
            No()
            exit()
    Yes()

if __name__ == '__main__':
    main()


Measured memory_bytes: 83932
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define FL "a"
using namespace std;
typedef long long ll;
typedef long double dd;
const int N=2e5+10;
const int inf=2147483647;
const dd pi=acos(-1);
const ll INF=1ll<<60;
const int mod=998244353;
inline ll read(){
  ll data=0,w=1;char ch=getchar();
  while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
  if(ch=='-')w=-1,ch=getchar();
  while(ch<='9'&&ch>='0')data=data*10+ch-48,ch=getchar();
  return data*w;
}
inline void file(){
  freopen(FL".in","r",stdin);
  freopen(FL".out","w",stdout);
}

int n,k,len,b[N],L[N],R[N],o[N],cov[N<<2];ll a[N],dp[N],ans=INF;
inline int get(ll x,int p){return (x%p+p)%p;}
#define mid ((l+r)>>1)
#define ls (i<<1)
#define rs (i<<1|1)
inline void pushdown(int i){if(cov[i])cov[ls]=cov[rs]=cov[i],cov[i]=0;}
void modify(int i,int l,int r,int x,int y,int v){
  if(x>y)return;if(x<=l&&r<=y){cov[i]=v;return;}pushdown(i);
  if(x<=mid)modify(ls,l,mid,x,y,v);if(mid<y)modify(rs,mid+1,r,x,y,v);
}
int query(int i,int l,int r,int p){
  if(l==r)return cov[i];pushdown(i);
  return p<=mid?query(ls,l,mid,p):query(rs,mid+1,r,p);
}
inline ll Qry(int i){
  int p=query(1,1,len,i);return p?dp[p]+get(o[L[p]]-o[i],k):0;
}
int main()
{
  n=read();k=read();for(int i=1;i<=n;i++)a[i]=read(),b[i]=read();
  for(int i=1;i<=n;i++)if(b[i]==1&&a[i]*2>k)return puts("-1"),0;
  for(int i=1;i<=n;i++)a[i]+=a[i-1];
  for(int i=1;i<=n;i++)
    (b[i]==1)?(L[i]=get(-a[i-1]*2,k),R[i]=get(-a[i]*2,k)):(L[i]=0,R[i]=k-1);
  for(int i=1;i<=n;i++)o[++len]=L[i],o[++len]=R[i];
  sort(o+1,o+len+1);len=unique(o+1,o+len+1)-o-1;
  for(int i=n,p;i;dp[i]=Qry(L[i]),i--){
    L[i]=lower_bound(o+1,o+len+1,L[i])-o;
    R[i]=lower_bound(o+1,o+len+1,R[i])-o;
    if(L[i]<=R[i])modify(1,1,len,1,L[i]-1,i),modify(1,1,len,R[i]+1,len,i);
    else modify(1,1,len,R[i]+1,L[i]-1,i);
  }
  for(int i=1;i<=len;i++)ans=min(ans,Qry(i));printf("%lld\n",ans+a[n]*2);
  return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define ll long long int
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int>pii;
typedef pair<ll,ll>pll;
typedef pair<double,double>pdd;
using namespace std;
#define MAX  999999
int main(){
	double tiya,rize;
	while(cin>>tiya>>rize){
		 if(tiya<35.5&&rize<71)
			cout<<"AAA"<<endl;
		else if(tiya<37.5&&rize<77)
			cout<<"AA"<<endl;
		else if(tiya<40&&rize<83)
			cout<<"A"<<endl;
		else if(tiya<43.0&&rize<89)
			cout<<"B"<<endl;
		else if(tiya<50&&rize<105)
			cout<<"C"<<endl;
		else if(tiya<55&&rize<116)
			cout<<"D"<<endl;
		else if(tiya<70&&rize<148)
			cout<<"E"<<endl;
		else cout<<"NA"<<endl;
	}
}

Measured memory_bytes: 3028
def norm(x1, y1, x2, y2):
    return ((x1-x2)**2 + (y1-y2)**2)**0.5
def d(a, b, c, x, y):
    return abs(a*x + b*y + c) / (a**2 + b**2)**0.5
def points2line(x1, y1, x2, y2):
    la = y1 - y2
    lb = x2 - x1
    lc = x1 * (y2 - y1) + y1 * (x1 - x2)
    return la, lb, lc
from numpy import argmax
#def argmax(L):
#    return max(enumerate(L), key=lambda x: x[1])[0]

x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())

a = norm(x3, y3, x2, y2)
b = norm(x1, y1, x3, y3)
c = norm(x1, y1, x2, y2)

xc = (a*x1 + b*x2 + c*x3)/(a+b+c)
yc = (a*y1 + b*y2 + c*y3)/(a+b+c)

iw = argmax([a, b, c])
w = [a, b, c][int(iw)]

L = [[x1, y1], [x2, y2], [x3, y3]]
del L[int(iw)]
m, n = L[0]
p, q = L[1]
s, t, u = points2line(m, n, p, q)
h = d(s, t, u, xc, yc)
print(w*h/(2*h + w))


Measured memory_bytes: 13564
h, w = gets.chomp.split.map(&:to_i)
s = Array.new(h) { gets.chomp.chars }
(0...h).each do |x|
  (0...w).each do |y|
    next if s[x][y] == "."
    flg = false
    [[x - 1, y], [x + 1, y], [x, y - 1], [x, y + 1]].each do |nx, ny|
      next if nx < 0 || ny < 0 || nx >= h || ny >= w
      if s[nx][ny] == "#"
        flg = true
        break
      end 
    end
    if flg == false
      puts "No"
      exit
    end
  end
end
puts "Yes"

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

using namespace std;
#define x first
#define y second
typedef pair <int, int> ii;

struct Node {
	int lazy, mx;
};

struct SegmentTree {
	int n;
	vector <Node> st;
	SegmentTree() {}
	SegmentTree(int _n) {
		this -> n = _n;
		st.assign(4 * n + 5, {0, 0});
	}
	int Left(int x) {return (x << 1);}
	int Right(int x) {return (x << 1) + 1;}
 
	void push(int id) {
		st[Left(id)].lazy += st[id].lazy;
		st[Left(id)].mx += st[id].lazy;
		st[Right(id)].lazy += st[id].lazy;
		st[Right(id)].mx += st[id].lazy;
		st[id].lazy = 0;
	}
 
	void update(int id, int L, int R, int i, int j, int val) {
		if (L > j || R < i) return;
		if (L >= i && R <= j) {
			st[id].lazy += val;
			st[id].mx += val;
			return;
		}
		int mid = (L + R) >> 1;
		push(id);
		update(Left(id), L, mid, i, j, val);
		update(Right(id), mid + 1, R, i, j, val);
		st[id].mx = max(st[Left(id)].mx, st[Right(id)].mx);
	}
 
	int query(int id, int L, int R, int i, int j) {
		if (L > j || R < i) return -1;
		if (L >= i && R <= j) return st[id].mx;
		push(id);
		int mid = (L + R) >> 1;
		return max(query(Left(id), L, mid, i, j), query(Right(id), mid + 1, R, i, j));
	}
	void update(int i, int j, int val) {
		update(1, 0, n, i, j, val);
	}
	int get(int i, int j) {
		return query(1, 0, n, i, j);
	}
};

const int N = 3e5 + 5;
int n, w, h, res;
ii p[N];

void solve() {
	sort(p + 1, p + 1 + n);
	SegmentTree IT(n + 5);
	stack <int> up, down;
	while (!up.empty()) up.pop();
	while (!down.empty()) down.pop();
	up.push(0); down.push(0);
	IT.update(0, n, h);
	for (int i = 1; i <= n; ++i) {
		int v = IT.get(0, i - 1);
		res = max(res, v + p[i].x);
		// cerr << "ans at " << i << " is " << v + p[i].x << endl;
		if (p[i].y > h / 2) {
			if (up.top() == 0) {
				IT.update(0, i - 1, p[i].y - h);
				up.push(i);
				goto mark;
			}
			IT.update(up.top(), i - 1, p[i].y - h);
			while (!up.empty() && up.top() != 0 && p[i].y < p[up.top()].y) {
				int u = up.top(); up.pop();
				int v = up.top();
				IT.update(v, u - 1, p[i].y - p[u].y);
			}
			up.push(i);	
		} else {
			if (down.top() == 0) {
				IT.update(0, i - 1, -p[i].y);
				down.push(i);
				goto mark;
			}
			IT.update(down.top(), i - 1, -p[i].y);
			while (!down.empty() && down.top() != 0 && p[i].y > p[down.top()].y) {
				int u = down.top(); down.pop();
				int v = down.top();
				IT.update(v, u - 1, p[u].y - p[i].y);
			}
			down.push(i);
		}
		mark:;
		IT.update(i, i, -p[i].x);
	}
}

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(0); cin.tie(0);

	cin >> w >> h >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> p[i].x >> p[i].y;
		// cerr << "(" << p[i].x << ", " << p[i].y << ")" << endl;
	}
	n++;
	p[n] = {w, h};
	solve();
	for (int i = 1; i <= n; ++i)
		swap(p[i].x, p[i].y);
	swap(w, h);
	solve();
	cout << (res << 1) << endl;

	return 0;
}

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

using namespace std;

unsigned n;

void f(string s, char up)
{
    if (s.length() == n) {
        cout << s << endl;
        return;
    }

    for (char c = 'a'; c <= up + 1; c++) {
        f(s + c, max(up, c));
    }
}


int main()
{
    cin >> n;
    f("", 'a' - 1);
    return 0;
}


Measured memory_bytes: 1536
n = int(input())
num = list(map(int, input().split(' ')))

negs = 0
for x in num:
    if x < 0:
        negs += 1

num = list(map(lambda x: abs(x), num))
# all poss
if negs % 2 == 0:
    ans = sum(num)
else:
    ans = sum(num)
    ans -= 2 * min(num) # we want this to negatively effect

print(ans)


Measured memory_bytes: 69852
#include <iostream>
#include <vector>
using namespace std;
using ll = long long int;
const ll MOD = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<ll> sum(n);
    sum[n-1] = a[n-1];
    for(int i = n-2; i >= 0; i--){
        sum[i] = sum[i+1]+a[i];
        sum[i] %= MOD;
    }
    ll ans = 0;
    for(int i = 0; i < n-1; i++){
        ans += sum[i+1]*a[i];
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5592
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>
#include<stack>

using namespace std;

#define INF 999999999
#define REP(i,n) for(int i=0; i<(int)(n); i++)

int main(){
	int i, j, t;
	string in;
	int ans, sum, now, cut;
	while(1){
		cin >> t >> in;
		if(!t) break;
		ans = 1000000;
		for(i=1;i<(1<<in.size());i+=2){
			sum = 0;
			now = 0;
			REP(j,in.size()){
				if(!(i&1<<(in.size()-j-1))){
					now *= 10;
					now += in[j] - '0';
				}
				else{
					now *= 10;
					now += in[j] - '0';
					sum += now;
					now = 0;
				}
			}
			if(sum == abs(ans)) ans = -abs(sum);
			else if(sum<=t&&abs(sum-t)<=abs(abs(ans)-t)){
				ans = sum;
				cut = i;
			}
		}
		if(ans < 0) cout << "rejected" << endl;
		else if(ans == 1000000) cout << "error" << endl;
		else{
			//cout << cut << " ";
			cout << ans << " ";
			for(j=in.size()-1;j>=0;j--){
				cout << in[in.size()-j-1];
				if(j>=1&&(cut&1<<j)) cout << " ";
			}
			cout << endl;
		}
	}
	return 0;
}

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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c)

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

const int maxn = 101;

int x[maxn];

int main()
{
  ios::sync_with_stdio(false);
  int n,m;
  cin >> n;
  for(int i = 1; i <= n; i++)
  {
    cin >> x[i];
  }

  int ans = INT_MAX;

  for(int p = 1; p <= 100; p++)
  {
    int val = 0;
    for(int i = 1; i <= n ; i++)
    {
      val += (x[i] - p) * (x[i] - p);
    }
    ans = min(ans, val);
  }

  cout << ans << endl;

  return 0;
}

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

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, minn = 1000, maxx = 0;
	cin >> n;
	while (n--) {
		int x;
		cin >> x;
		minn = min(x, minn);
		maxx = max(x, maxx);
	}
	cout << maxx - minn << endl;
	return 0;
}


































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

using namespace std;


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

	int InputW;
	int InputS = 0;
	vector<int>S;

	for (int i = 0; i < N; i++) {
		cin >> InputW;
		InputS += InputW;
		S.push_back(InputS);
	}

	for (int i = 0; i < N; i++) {
		S[i] = abs(S[N - 1] - 2 * S[i]);
	}

	sort(S.begin(), S.end());
	cout << S[0] << endl;
}



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

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)

const ll MOD = 1000000007;

using namespace std;

int A[100005], B[100005], C[100005];
ll Bs[100005];
int main()
{
	int N;
	cin >> N;
	REP(i, N)
	{
		cin >> A[i];
	}
	REP(i, N)
	{
		cin >> B[i];
	}
	REP(i, N)
	{
		cin >> C[i];
	}
	sort(A, A + N);
	sort(B, B + N);
	sort(C, C + N);

	ll s = 0;
	REP(i, N)
	{
		if (A[0] >= B[i])
		{
			Bs[i] = 0;
			continue;
		}
		int oi = 0, ni = N;
		while (abs(oi - ni) > 1)
		{
			int mid = (oi + ni) / 2;
			if (A[mid] < B[i])
			{
				oi = mid;
			}
			else
			{
				ni = mid;
			}
		}
		s += oi + 1;
		Bs[i] = s;
	}

	ll ans = 0;
	REP(i, N)
	{
		if (B[0] >= C[i])
		{
			continue;
		}
		int oi = 0, ni = N;
		while (abs(oi - ni) > 1)
		{
			int mid = (oi + ni) / 2;
			if (B[mid] < C[i])
			{
				oi = mid;
			}
			else
			{
				ni = mid;
			}
		}
		ans += Bs[oi];
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define INF 100000005
#define MAX 100001
#define dmp make_pair
#define dpb push_back
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

int a[10000];
int solve(int p, int n){
	int l = p-1, r = p+1, t;
	int s1, s2, ans = 0, f = 1;
	while(0 <= l){
		t = a[l];
		s1 = s2 = 0;
		if(f)s1 = 1, f = 0;
		
		while(0 <= l && a[l] == t){s1++;l--;}
		while(r < n && a[r] == t){s2++;r++;}
		if(s1+s2 >= 4)ans += s1+s2;
		else break;
	}
	return n-ans;
}

int main(){
	int n, ans;
	while(1){
	scanf("%d", &n);
		ans = INF;
		rep(i,n)scanf("%d", &a[i]);
		if(!n)break;
		for(int i = 1;i < n-1;i++){
			ans = min(ans, solve(i, n));
		}
		if(ans == INF)printf("%d\n", n-1);
		else printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3236