akhauriyash/Code-Regression huggingface dataset:
import static java.util.Collections.*;

import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

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

		int n = sc.nextInt();
		int m = sc.nextInt();
		Queue<Long> priceQueue = new PriorityQueue<>(reverseOrder());
		for (int i = 0; i < n; i++) {
			priceQueue.add(sc.nextLong());
		}
		for (int i = 0; i < m; i++) {
			priceQueue.add(priceQueue.poll() / 2);
		}

		long total = 0;
		for (int i = 0; i < n; i++) {
			total += priceQueue.poll();
		}
		System.out.println(total);
		sc.close();
	}
}


Measured memory_bytes: 61560
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool c=false,f=false;
  for(int i=0;i<s.size();i++){
    if(s[i]=='C'){
      c=true;
    }
    if(c&&s[i]=='F'){
      f=true;
    }
  }
  if(f){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX (int)1e+5

int N;
int H[MAX];

int main() {
    cin >> N;
    for (int i=0; i<N; i++) cin >> H[i];

    int ans = 0;
    int M = 0;
    for (int i=1; i<N; i++) {
        if (H[i-1]>=H[i]) M++;
        else {
            ans = max(M, ans);
            M = 0;
        }
    }
    
    ans = max(M, ans);

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 640
S = list(input())
c = 0
flag = 0
if S[0] == "A":
    for i in range(len(S)-3):
        if S[2+i] == "C":
            c += 1
            this = 2+i
    if c == 1:
        S.pop(this)
        S.pop(0)

    for i in S:
        if ord(i) < 97:
            flag = 0
            break
        else:
            flag = 1

if flag == 1:
    print("AC")
else:
    print("WA")

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

const double PI = M_PI;
const double theta = PI / 3;
struct point{
    double x;
    double y;
};

point getp(point p1, point p2){
    double x = p2.x - p1.x;
    double y = p2.y - p1.y;
    point p3 = {
        x*cos(theta) - y*sin(theta) + p1.x,
        x*sin(theta) + y*cos(theta) + p1.y
    };
    return p3;
}

void koch(point p1, point p2, int cnt){
    if (cnt == 0){
        printf("%.10f %.10f\n", p1.x, p1.y);
        return;
    }else cnt--;

    point s = {(2*p1.x + 1*p2.x)/3, (2*p1.y + 1*p2.y)/3};
    point t = {(1*p1.x + 2*p2.x)/3, (1*p1.y + 2*p2.y)/3};
    point u = getp(s, t);

    koch(p1, s, cnt);
    koch(s, u, cnt);
    koch(u, t, cnt);
    koch(t, p2, cnt);
}

int main(int argc, char* argv[]) {
    int n;
    cin >> n;
    point p1 = {0.0, 0.0}, p2 = {100.0, 0.0};
    koch(p1, p2, n);
    printf("%.10f %.10f\n", p2.x, p2.y);
    return 0;
}




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

typedef long long ll;
//loop
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//STL
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

void Main() {
    string s, ignore;
    cin >> ignore >> s >> ignore;
    cout << "A";
    cout << s[0];
    cout << "C" << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	Main();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

    int n;
    cin >> n;
    FOR(i,1,10){
        FOR(j,1,10){
            if(n==i*j){
                cout << "Yes" <<endl;
                return 0;
            }
        }
    }
    cout << "No" <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    string s;
    cin >> s;
    int n = s.size();
    cout << s[0] << n-2 << s[n-1] << endl;
}

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

class Program {
    const int mod = 1000000007;

    static void Main() {
#if USE_IDE
        var exStdIn = new System.IO.StreamReader("./../../TestStdin.txt");
        Console.SetIn(exStdIn);
#endif
        var ints = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        var trees = new int[ints[0]];
        for (int i = 0; i < ints[0]; i++) {
            trees[i] = int.Parse(Console.ReadLine());
        }

        var ans = 1000000000;
        var k = ints[1] - 1;
        Array.Sort(trees);
        for (int i = 0; i < ints[0] - k; i++) {
            int diff = trees[i + k] - trees[i];
            if (diff < ans) {
                ans = diff;
            }
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 15452
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double theta_a = 2 * M_PI * (60 * h + m) / (12 * 60);
    double theta_b = 2 * M_PI * m / 60;

    double x_a, x_b, y_a, y_b;
    x_a = a * sin(theta_a);
    y_a = a * cos(theta_a);
    x_b = b * sin(theta_b);
    y_b = b *cos(theta_b);

    double dx = x_b - x_a;
    double dy = y_b - y_a;
    double d = sqrt(dx * dx + dy * dy);

    cout << setprecision(20);
    cout << d << endl;

    return 0;
}

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

numbers = list(map(int, input().split()))

# max_x = max(numbers) + 1
# max_x = int(sum(numbers) / len(numbers))
# res = 0
test = set()
for n in numbers:
    test.add(n)
    test.add(n - 1)
    test.add(n + 1)
length = len(test)
res = {}
# print(test)
# for i in range(max_x + 1):
for n in numbers:
    c = 0
    sub = set([n - 1, n, n + 1]) & test
    # print(sub)
    for s in sub:
        if res.get(s) is None:
            res[s] = 1
        else:
            res[s] += 1
# for i in test:
#     c = 0
#     for n in numbers:
#         if n - 1 == i or n == i or n + 1 == i:
#             c += 1
#     if res < c:
#         res = c

# print(res)
res = max(res.values())
print(res)

Measured memory_bytes: 27396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    ll x[N];
    rep(i, N) cin >> x[i];
    ll fac[N+1];
    fac[0] = 1;
    rep2(i, 1, N){
        fac[i] = (fac[i-1]*i)%MOD;
    }
    ll ans = 0;
    ll sum[N];
    sum[1] = fac[N-1];
    ll n = N, m = MOD, inv[n+1];
    rep2(i, 1, n){
        inv[i] = 1;
        ll e[31];
        e[0] = i;
        rep2(j, 1, 30) e[j] = (e[j-1]*e[j-1]) % m;
        ll k = m-2;
        int cnt = 0;
        while(k > 0){
            if(k % 2 == 1) inv[i] *= e[cnt], inv[i] %= m;
            k /= 2;
            cnt++;
        }
    }
    rep2(i, 2, N-1){
        ll tmp = fac[N-1];
        tmp *= inv[i], tmp %= MOD;
        sum[i] = sum[i-1] + tmp;
        sum[i] %= MOD;
    }
    rep2(i, 1, N-1){
        ans += ((x[i]-x[i-1])*sum[i])%MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;

    if(n==2){
        cout << "1 2 2" << "\n";
        return 0;
    }

    for(ll w = 3*n/4; w*4>n ; w--) {
        for(ll h = w; h*(4*w-n) <=2*n*w ; h++) {
            ll u=n*h*w;
            ll b=4*w*h-n*h-n*w;
            if(u%b==0 && b>0){
                cout << w << " " << h << " " << u/b << "\n";
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define MKP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}

int fpow(int a,int b,int m)
{
	if(b==0) return 1;
	if(b==1) return a;
	int tmp=fpow(a,b/2,m);
	if(b%2) return a*tmp%m*tmp%m;
	return tmp*tmp%m;
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	ll n,a,b,c,d,e;
	cin>>n>>a>>b>>c>>d>>e;
	ll m=min(a,min(b,min(c,min(d,e))));
	cout<<((n+m-1)/m+4)<<"\n";
	return 0;
}









Measured memory_bytes: 256
use proconio::marker::Chars;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        s: Chars,
        t: Chars,
    };

    let s: Vec<char> = s;
    let t: Vec<char> = t;

    let mut count = std::i32::MAX;

    for i in 0..s.len() - t.len() + 1 {
        let mut x = 0;
        for j in 0..t.len() {
            if t[j] != s[i + j] {
                x += 1;
            }
        }
        count = std::cmp::min(count, x);
    }

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


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define ll long long
#define str string
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define pq priority_queue
#define ff fflush(stdout)
using namespace std;
ll bit[100005];
ll bit2[100005];
ll freq[100005];
pll seq[100005];
pair<pll, ll> num[100005];
vector< pair<pll, ll> > usa;
map<ll, ll> hsh;
set<ll> inp;
void update (ll i, ll v) {
	if (i > 100000) return;
	bit[i] += v;
	update(i + (i & (-i)), v);
}
void update2 (ll i, ll v) {
	if (i > 100000) return;
	bit2[i] += v;
	update2(i + (i & (-i)), v);
}
ll query (ll i) {
	return ((i == 0) ? 0 : bit[i] + query(i - (i & (-i))));
}
ll query2 (ll i) {
	return ((i == 0) ? 0 : bit2[i] + query2(i - (i & (-i))));
}
int main () { 
	ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q;
	scanf("%lld", &a);
	b = c = 0;
	for (i = 1; i <= a; i++) {
		scanf("%lld", &seq[i].se);
		inp.insert(seq[i].se);
	}
	i = 1;
	for (auto r : inp) {
		hsh[r] = i; i++;
	}
	for (i = 1; i <= a; i++) {
		seq[i].fi = hsh[seq[i].se];
		if (seq[i].fi > b) b = seq[i].fi, c = i;
	}
	for (i = c; i >= 1; i--) {
		num[i] = {seq[i], i};
	}
	stable_sort(num + 1, num + c + 1);
	pair<pll, ll> r;
	for (i = c, j = a; i >= 1; i--) {
		if ((i > 1 && num[i].fi.fi == num[i - 1].fi.fi) || (i < c && num[i].se > r.se)) continue;
		usa.pb(num[i]); r = num[i];
	}
	usa.pb({{0, 0}, 0});
	SET(bit, 0); SET(bit2, 0); m = 0;
	for (i = 0, j = a; i + 1 < usa.size(); i++) {
		e = usa[i].se;
		for(; j >= e; j--) {
			update(seq[j].fi, seq[j].se);
			update2(seq[j].fi, 1);
		}
		f = query(a) - query(usa[i + 1].fi.fi);
		g = query2(a) - query2(usa[i + 1].fi.fi);
		h = f - g * usa[i + 1].fi.se - m;
		freq[e] += h; m += h;
	}
	for (i = 1; i <= a; i++) {
		printf("%lld\n", freq[i]);
	}
	return 0; 
}

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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String o = sc.next();
		String e = sc.next();
		for(int i = 0;i < o.length();i++) {
			System.out.print(o.charAt(i));
			if(i < e.length()) {
				System.out.print(e.charAt(i));
			}
		}
		System.out.println("");
	}

}


Measured memory_bytes: 21844
H, W = map(int,input().split())
ans1 = 10**18
ans2 = 10**18
for i in range(1, H):
  Sa = i*W
  w = int(W/2)
  Sb = (H-i)*w
  Sc = (H-i)*(W-w)
  l = [Sa, Sb, Sc]
  S1 = max(l)-min(l)
  h = int((H-i)/2)
  Sb1 = h*W
  Sc1 = ((H-i)-h)*W
  l = [Sa, Sb1, Sc1]
  S2 = max(l)-min(l)
  ans = min(S1,S2)
  ans1 = min(ans, ans1)
for i in range(1, W):
  Sa = i*H
  h = int(H/2)
  Sb = (W-i)*h
  Sc = (W-i)*(H-h)
  l = [Sa, Sb, Sc]
  S1 = max(l)-min(l)
  w = int((W-i)/2)
  Sb1 = w*H
  Sc1 = ((W-i)-w)*H
  l = [Sa, Sb1, Sc1]
  S2 = max(l)-min(l)
  ans = min(S1,S2)
  ans2 = min(ans, ans2)  
print(min(ans1, ans2))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
    using namespace std;
    #define ll long long
    #define ld long double
    #define vll vector<ll>
    #define mll map<ll,ll>
    #define pll pair<ll,ll>
    #define ff first
    #define ss second
    #define pb push_back
    #define deb(x) cout<<#x<<" : "<<x<<endl;
    #define deb2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
    #define deb3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;
    #define deb4(w,x,y,z) cout<<#w<<" : "<<w<<"\t"<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;
    #define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define printv(a)  for(ll i=0;i<a.size();i++)  cout<<a[i]<<" ";
   
   
    const ll mod=1e9+7;
    const int N=1e6+5; 
    const ll inf=1e18+5;
   
    bool sortbysec(const pair<pair<ll,ll>,ll> &a, 
                      const pair<pair<ll,ll>,ll> &b) 
        { 
            return (a.second > b.second); 
        } 
        ll powermod(ll x, ll y, ll p)
        {
            ll res = 1;
            x = x % p;
            while (y > 0)
            {
                if (y & 1) res = (res*x) % p;
                y = y>>1;
                x = (x*x) % p;
            }
            return res;
        }
       
        bool isprime(int n) 
        { 
            if (n <= 1)  return false; 
            if (n <= 3)  return true; 
            if (n%2 == 0 || n%3 == 0) return false; 
            for (int i=5; i*i<=n; i=i+6) 
                if (n%i == 0 || n%(i+2) == 0) 
                   return false; 
           return true; 
        }
      ll dp[10003][103][2];
int main() {
         FAST;
        string s;
        ll d;
        cin>>s;
        cin>>d;
       
       dp[0][0][0]=1;
       for(int i=0;i<s.size();i++)
       {
           for(ll j=0;j<d;j++)
           {
               for(ll k=0;k<2;k++)
               {
                   for(ll digit=0;digit<10;digit++)
                   {
                       int nk=k;
                       if(!k && digit>s[i]-'0')
                       break;
                       if(digit<s[i]-'0')
                       nk=1;
                       dp[i+1][(j+digit)%d][nk]+=dp[i][j][k];
                       dp[i+1][(j+digit)%d][nk]%=mod;
                   }
               }
           }
       }
       ll ans=(dp[s.size()][0][0]+dp[s.size()][0][1])%mod;
       ans--;
       if(ans<0)
       ans+=mod;
       cout<<ans<<"\n";
      
     return 0;
}

 

Measured memory_bytes: 16384
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=2e5;
int n=read(),a[yuzu|10];
ll ans;
int main(){
int i,j;
for (i=1;i<=n;++i) a[i]=read();
for (int l=1,r=1,now=0;l<=n;){
  for (;r<=n&&(now^a[r])==now+a[r];) now^=a[r++];
  ans+=r-l,now^=a[l++];
}
write(ans);
}

Measured memory_bytes: 1024
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}

int n, m, q;
int a[55], b[55], c[55], d[55];
int sum = 0;
VI A(55, 1);

void sub(int i, int prev){
    if(i == n){
        int temp = 0;
        for(int i = 0; i < q; i++) if(A[b[i]] - A[a[i]] == c[i]) temp += d[i];
        sum = max(sum, temp);
        return;
    }
    for (int j = prev; j <= m; j+=1){
        A[i+1] = j;
        sub(i+1, j);
    }
}

int main(){
    cin >> n >> m >> q;
    for (int i = 0; i < q; i+=1){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    sub(1, 1);
    printf("%d\n", sum);
    return 0;
}



Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d) cout << "Left" << endl;
  else if (a + b < c + d) cout << "Right" << endl;
  else cout << "Balanced" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

// A - Security
// https://atcoder.jp/contests/abc131/tasks/abc131_a
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        char[] S = scanner.next().toCharArray();
        scanner.close();

        char oldC = S[0];

        for (int i = 1; i< S.length; i++) {
            if (oldC == S[i]) {
                System.out.println("Bad");
                return;
            }
            oldC = S[i];
        }

        System.out.println("Good");
    }
}


Measured memory_bytes: 23764
from itertools import product

N, M, *XYZ = map(int, open(0).read().split())

A = [[] for _ in range(8)]
for x, y, z in zip(*[iter(XYZ)] * 3):
    for i, (a, b, c) in enumerate(product([1, -1], repeat=3)):
        A[i].append(a * x + b * y + c * z)

B = []
for a in A:
    a.sort(reverse=True)
    B.append(sum(a[:M]))

print(max(B))

Measured memory_bytes: 3572
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<string.h>
#include<bitset>
#include<set>
using namespace std;

struct S {
	int cost, x, y, o, xh;
	S(int c, int in_x, int in_y, int in_o, int in_xh) : cost(c), x(in_x), y(in_y), o(in_o), xh(in_xh){}
	bool operator<(const S &s) const { 
		if (cost != s.cost)
			return cost < s.cost;
		else
			return o < s.o;
	}
};

const int INF = -1000000000, INF2=10000000;
int w, h, f, m, o, ans;
int stratum[110][110];
int c[11][11][51];
priority_queue<S> pq;

void dijkstra(){
	int move[3] = { 1, -1, 1 };//?´y,?´x,?´x
	while (!pq.empty()){
		S a = pq.top();
		pq.pop();
		if (a.o == 0) continue;
		if (a.y == h){
			if (-a.cost <= f)
				ans = -a.cost;
			break;
		}
		if (a.o == 1) continue;
		for (int i = 0; i < 3; i++){
			int x = a.x;
			int y = a.y;
			if (i)
				x += move[i];
			else
				 y += move[i];
			int xx = 1<<(w-x);
			xx = xx&a.xh;
			if (!xx || !i){
				if (x <= w && 0 < x&&y <= h){
					if (stratum[y][x] < 0){
						if (a.cost + stratum[y][x] >= -f&&a.cost + stratum[y][x] > c[y][x][a.o - 1]){
							c[y][x][a.o - 1] = a.cost + stratum[y][x];
							if (i)
								pq.push({ c[y][x][a.o - 1], x, y, a.o - 1, a.xh | 1 << (w-x) });
							else
								pq.push({ c[y][x][a.o - 1], x, y, a.o - 1, 1 << (w-x) });
						}
					}
					else if (stratum[y][x] >0){
						int hokyuuu;
						hokyuuu = stratum[y][x] + a.o - 1;
						if (hokyuuu + a.o - 1 >= m)
							hokyuuu = m;
						c[y][x][hokyuuu] = a.cost;
						if (i)
							pq.push({ c[y][x][hokyuuu], x, y, hokyuuu, a.xh | 1 << (w-x) });
						else
							pq.push({ c[y][x][hokyuuu], x, y, hokyuuu, 1 << (w-x) });
					}
					else{
						pq.push({ 0, x, y, o, a.xh | 1 << (w-x) });
					}
				}
			}
			/*else{
				if (a.cost > c[y][x][a.o - 1] && a.o - 1){
					c[y][x][a.o - 1] = a.cost;
					pq.push({ c[y][x][a.o - 1], x, y, a.o - 1, a.xh });
				}
			}*/
		}
	}
}


int main(){
	while (cin >> w >> h&&w&&h){
		cin >> f >> m >> o;
		memset(stratum, sizeof(stratum), 0);
		ans=INF2;
		for (int i = 1; i <= 10; i++)
			for (int j = 1; j <= 10; j++)
				fill(c[i][j], c[i][j] + 51, INF);
		while (!pq.empty())
			pq.pop();
		for (int i = 1; i <= h; i++)
			for (int j = 1; j <= w; j++)
				cin >> stratum[i][j];
		pq.push({ 0, 1, 0, o, 1<<(w-1) });
		dijkstra();
		if (ans!=INF2)
			cout << ans << endl;
		else
			cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true){
            final int n = Integer.parseInt(br.readLine());
            if (n == 0) { break; }
             
            Map<String, Long> data = new HashMap<>(n);
            Map<String, Long> out = new HashMap<>(n);
            for (int i=1; i <= n; i++) {
                String[] st = br.readLine().split(" ");
                String e = st[0];
                Long p = Long.parseLong(st[1]);
                Long q = Long.parseLong(st[2]);
                Long total = data.getOrDefault(e, 0L) + p * q;
                data.put(e, total);
                if (total >= 1_000_000L) {
                    if (out.containsKey(e) == false) {
                        System.out.println(e);
                        out.put(e, total);
                    }
                }
            }
            if (out.isEmpty()) {
                System.out.println("NA");
            }
        }
    }
}

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

int main() {
	string s;
	int n;
	cin>>n;
	cin>>s;
	if(n&1){
		cout<<"No\n";
		return 0;
	}
	cout<<(s.substr(0,n/2)==s.substr(n/2,n/2)?"Yes\n":"No\n");
}

Measured memory_bytes: 256
let change a = 
	let rec change a n = 
    	if a land 1 = 0 then change (a lsr 1) (n + 1) else n
    in change a 0
let calc n = 
	let rec calc n ans = 
    	if n = 0 then ans else calc (n - 1) (ans + Scanf.scanf " %d" change)
    in calc n 0
let main = print_int (Scanf.scanf "%d" calc)

Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>

using namespace std;

int* a;

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

	vector<int>* s = new vector<int>[M];
	int* p = new int[M];

	a = new int[N];

	for (int i = 0; i < M; i++) {
		int k; cin >> k;
		for (int j = 0; j < k; j++) {
			int _s; cin >> _s;
			s[i].push_back(_s - 1);
		}
	}

	for (int i = 0; i < M; i++) {
		cin >> p[i];
	}

	for (int i = 0; i < N; i++) { a[i] = 0; }

	int nMax = 1;
	for (int i = 0; i < N; i++) { nMax *= 2; }
	int count = 0;

	for (int n = 0; n < nMax; n++) {
		int b = n;
		for (int i = 0; i < N; i++) {
			a[i] = b % 2;
			b /= 2;
		}

		bool flag = true;
		for (int i = 0; i < M; i++) {
			int sum = 0;
			for (auto itr = s[i].begin(); itr != s[i].end(); itr++) {
				sum += a[*itr];
			}
			if (sum % 2 != p[i]) {
				flag = false;
				break;
			}
		}
		if (flag) {
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>

using namespace std;
using ll = long long int; 

void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;

    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}


ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

ll keta(ll a){
  ll ans = 1;
  while(1){
    if(a/10 > 0){
      ans++;
      a = a/10;
    }
    if(a<10) break;
  }
  return ans;
}

const int MAX = 50;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void){

    ll n, k;
    cin>>n>>k;

    vector<pair<ll, ll>> v(n);

    for(int i=0;i<n;i++){
        ll a, b;
        cin>>a>>b;
        v[i] =  make_pair(a, b);
        
    } 

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

    ll sum = 0;
    for(int i=0;i<n;i++){
        sum += v[i].second;
        if(sum>=k){
            cout<<v[i].first<<endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    string s;
    cin >> s;
    if(s=="ABC"){
        cout<<"ARC"<<endl;
    }
    else{
        cout<<"ABC"<<endl;
    }
}
    



Measured memory_bytes: 3600
import sys
a, b = input().split()
ab = int(str(a) + str(b))
s = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, 1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849, 1936, 2025, 2116, 2209, 2304, 2401, 2500, 2601, 2704, 2809, 2916, 3025, 3136, 3249, 3364, 3481, 3600, 3721, 3844, 3969, 4096, 4225, 4356, 4489, 4624, 4761, 4900, 5041, 5184, 5329, 5476, 5625, 5776, 5929, 6084, 6241, 6400, 6561, 6724, 6889, 7056, 7225, 7396, 7569, 7744, 7921, 8100, 8281, 8464, 8649, 8836, 9025, 9216, 9409, 9604, 9801, 10000, 10201, 10404, 10609, 10816, 11025, 11236, 11449, 11664, 11881, 12100, 12321, 12544, 12769, 12996, 13225, 13456, 13689, 13924, 14161, 14400, 14641, 14884, 15129, 15376, 15625, 15876, 16129, 16384, 16641, 16900, 17161, 17424, 17689, 17956, 18225, 18496, 18769, 19044, 19321, 19600, 19881, 20164, 20449, 20736, 21025, 21316, 21609, 21904, 22201, 22500, 22801, 23104, 23409, 23716, 24025, 24336, 24649, 24964, 25281, 25600, 25921, 26244, 26569, 26896, 27225, 27556, 27889, 28224, 28561, 28900, 29241, 29584, 29929, 30276, 30625, 30976, 31329, 31684, 32041, 32400, 32761, 33124, 33489, 33856, 34225, 34596, 34969, 35344, 35721, 36100, 36481, 36864, 37249, 37636, 38025, 38416, 38809, 39204, 39601, 40000, 40401, 40804, 41209, 41616, 42025, 42436,
42849, 43264, 43681, 44100, 44521, 44944, 45369, 45796, 46225, 46656, 47089, 47524, 47961, 48400, 48841, 49284, 49729, 50176, 50625, 51076, 51529, 51984, 52441, 52900, 53361, 53824, 54289, 54756, 55225, 55696, 56169, 56644, 57121, 57600, 58081, 58564, 59049,
59536, 60025, 60516, 61009, 61504, 62001, 62500, 63001, 63504, 64009, 64516, 65025, 65536, 66049, 66564, 67081, 67600, 68121, 68644, 69169, 69696, 70225, 70756, 71289, 71824, 72361, 72900, 73441, 73984, 74529, 75076, 75625, 76176, 76729, 77284, 77841, 78400, 78961, 79524, 80089, 80656, 81225, 81796, 82369, 82944, 83521, 84100, 84681, 85264, 85849, 86436, 87025, 87616, 88209, 88804, 89401, 90000, 90601, 91204, 91809, 92416, 93025, 93636, 94249, 94864, 95481, 96100, 96721, 97344, 97969, 98596, 99225, 99856]
print("Yes" if ab in s else "No")


Measured memory_bytes: 3192
'use strict'

const main = input => {
	const args = input.split('\n')
	if (args[0][0] === args[1][2] && args[0][1] === args[1][1] && args[0][2] === args[1][0]) console.log('YES')
	else console.log('NO')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const long long INF = 9223372000000000000/2145;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define itn int
#define scnaf scanf
#define reutnr return
#define scamf scanf
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
//#define int ll

signed main(){
    char A,B,C,D;
    scanf("%c%c%c%c",&A,&B,&C,&D);
    int a = A-48;
    int b = B-48;
    int c = C-48;
    int d = D-48;
    //printf("%d%d%d%d\n",a,b,c,d);
    int op1,op2,op3;
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                op1 = i, op2 = j, op3 = k;
                int tmp=a;
                if(op1) tmp += b;
                else tmp -= b;
                if(op2) tmp += c;
                else tmp -=c;
                if(op3) tmp += d;
                else tmp -= d;
                if(tmp==7){
                    printf("%d",a);
                    if(op1) printf("+");
                    else printf("-");
                    printf("%d",b);
                    if(op2) printf("+");
                    else printf("-");
                    printf("%d",c);
                    if(op3) printf("+");
                    else printf("-");
                    printf("%d=7\n",d);
                    return 0;
                }
            }
        }
    }
}

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

int main()
{
    int n, k;
    int score[3];
    string s;
    cin >> n >> k >> score[0] >> score[1] >> score[2] >> s;
    map<char, int> m;
    m['s'] = 0;
    m['p'] = 1;
    m['r'] = 2;
    int ans = 0;
    for( int i = 0; i < n; i++ )
    {
        if( m.count(s[i]) > 0 )
        {
            if( i < k || s[i] != s[i - k] )
            {
                ans += score[m[s[i]]];
            }
            else
            {
                s[i] = '-';
            }
//            cout << ans << endl;
        }        
    }

    cout << ans;
}

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

using namespace std;
#define ll  long long
#define ld long double
ll k;
ll dp[100005]={0};
ll a[100005]={0};
ll check(ll v) {
set<ll> b;
    for(ll i = 1;i<=k && i<v;i++) {
        b.insert(dp[v-i]+abs(a[v]-a[v-i]));
    }
  //  for(auto it = b.begin();it!=b.end();it++) {
  //      cout<<*it<<" ";
  //  }
  //  cout<<endl;
    return *b.begin();
}
int main()
{
 // freopen("input.txt","r",stdin);
 //  freopen("output.txt","w",stdout);
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[100005][3];
    ll dp[100005][3];
    for(ll i =1;i<=n;i++) {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    dp[1][0]=a[1][0];
    dp[1][1] =a[1][1];
    dp[1][2] = a[1][2];
  //  cout<<dp[1][0]<<" "<<dp[1][1]<<" "<<dp[1][2]<<endl;
    for(ll i =2;i<=n;i++) {
            for(ll j =0;j<3;j++) {
        if(j==0) {
            dp[i][j] = a[i][j]+ max(dp[i-1][1],dp[i-1][2]);
        } else
        if(j==1) {
             dp[i][j] = a[i][j]+ max(dp[i-1][0],dp[i-1][2]);
        } else {
             dp[i][j] = a[i][j]+ max(dp[i-1][1],dp[i-1][0]);
        }
      //  cout<<dp[i][j]<<" ";
            }
        //    cout<<endl;
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
}



Measured memory_bytes: 4992
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
struct CAL{
int a,b;
bool c;
};
int main(){
while(1){
int i,j,n,k,p[100000],o=0,ans=0;
struct CAL q[100000];
scanf("%d%d",&n,&k);
if(n==0&&k==0)return 0;
for(i=0;i<k;i++)
scanf("%d",&p[i]);
sort(p,p+k);
if(p[0]==0){
	q[0].a=p[1];
	q[0].b=p[1];
	q[0].c=true;
	for(i=2;i<k;i++){
		if(q[o].b+1==p[i])
			q[o].b++;
		else{
			o++;
			q[o].a=q[o-1].b+1;
			q[o].b=p[i]-1;
			q[o].c=false;
			o++;
			q[o].a=p[i];
			q[o].b=p[i];
			q[o].c=true;
		}
	}
	for(i=0;i<=o;i++){
		if(q[i].c&&!q[i+1].c&&q[i+1].a-q[i+1].b==0&&q[i+2].c)
			ans=max(ans,q[i+2].b-q[i].a+1);
		else if(q[i].c){
			if(o>=2)
				ans=max(ans,q[i].b-q[i].a+2);
			if(i!=0)
				ans=max(ans,q[i].b-q[i].a+2);
			ans=max(ans,q[i].b-q[i].a+1);
		}
	}
}
else{
	q[0].a=p[0];
	q[0].b=p[0];
	q[0].c=true;
	for(i=1;i<k;i++){
		if(q[o].b+1==p[i])
			q[o].b++;
		else{
			o++;
			q[o].a=q[o-1].b+1;
			q[o].b=p[i]-1;
			q[o].c=false;
			o++;
			q[o].a=p[i];
			q[o].b=p[i];
			q[o].c=true;
		}
	}
	for(i=0;i<=o;i++){
		if(q[i].c){
			ans=max(ans,q[i].b-q[i].a+1);
		}
	}
}
printf("%d\n",ans);
}
return 0;
}



Measured memory_bytes: 3932
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	cout << setprecision(13) << fixed;
	int n; cin >> n;
	vi x(n), y(n);
	rep(i, 0, n) cin >> x[i];
	rep(i, 0, n) cin >> y[i];
	double p1 = 0.0, p2 = 0.0, p3 = 0.0, t;
	int p0 = 0;
	rep(i, 0, n) {
		t = abs(x[i] - y[i]);
		p1 += t;
		p2 += pow(t, 2);
		p3 += pow(t, 3);
		if (p0 < t) p0 = t;
	}
	P(p1);
	P(sqrt(p2));
	P(cbrt(p3));
	P(double(p0));
	return 0;
}

Measured memory_bytes: 3468
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    N = int(input())
    A = list(map(int,input().split()))
    tot = 0
    for a in A:
        tot ^= a
    
    ans = []
    for a in A:
        ans.append(tot^a)
    print(*ans)
if __name__ == '__main__':
    main()

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

using namespace std;

int main()
{
	int n;
	cin>>n;
	long long sum = 0;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		sum += b-a+1;
	}
	cout<<sum;
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<map>
#include <algorithm>
#include<cstdlib>
#include<cmath>
#include<deque>
#include <numeric>
#include<valarray>
typedef unsigned long long ull;
typedef  long long ll;

int main() {
	int N;
	double suma = 0.0;

	std::cin >> N;
	for (int i = 0; i < N; i++)
	{
		int tmpa;
		std::cin >> tmpa;
		suma += (double)(1.0 / (double)tmpa);
	}
	std::cout << (double)(1.0 / suma) <<std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
#define ms(a,b) memset(a,b,sizeof(a))
const int inf = 0x3f3f3f3f;

int n, b;

int main()
{
	cin >> n >> b;
	cout << n*n-b << endl;

	return 0;
}

Measured memory_bytes: 256
import sys


N = int(sys.stdin.readline().rstrip())
H = [int(h) for h in sys.stdin.readline().rstrip().split()]

B = [False for _ in H]

i = 0
while i < N - 1:
    L = H[i]
    R = H[i + 1]

    if L <= R:
        i += 1
        continue

    if (L - R <= 1) and not B[i]:
        H[i] -= 1
        B[i] = True
        i = max(i - 1, 0)
        continue

    print("No")
    sys.exit(0)

print("Yes")


Measured memory_bytes: 14224
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(N, K, inputs):
    values = list(map(string_to_int, inputs))
    values.sort(key=lambda x: x[0])
    count = 0
    for v in values:
        count += v[1]
        if count >= K:
            return v[0]


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    [N, K] = string_to_int(input())
    ret = solve(N, K, inputs(N))
    print(ret)


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int t[110] = {};
    int cnt = 0;
    t[a]++, t[b]--, t[c]++, t[d]--;
    repl(i, 0, 101) {
        if (i > 0)t[i] += t[i - 1];
        if (t[i] == 2) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

using ll = long long;

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

    ll a,b,c,k;
    cin>>a>>b>>c>>k;

    cout<<(a-b)*(k%2?-1:1)<<"\n";

    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
	unsigned long long n,k;
	cin>>n>>k;
	if(k==1||n==0){
		cout<<'0';
		return 0;
	} 
	unsigned long long a;
	a=n-((n/k)*k);
	a=min(a,((n/k+1)*k)-n);
	cout<<a;
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 1e5 + 5;
int n;
long long a[maxn];
vector<int> g[maxn];

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
  	g[i].clear();
  }
  for (int i = 0; i < n; i++) {
  	scanf("%lld", &a[i]);
  }
  for (int i = 0; i < n - 1; i++) {
  	int v, u;
  	scanf("%d%d", &v, &u);
  	v--;
  	u--;
  	g[v].push_back(u);
  	g[u].push_back(v);
  }
  return true;
}

vector<long long> ch[maxn];
int deg[maxn];
int used[maxn];

void solve() {
	for (int i = 0; i < n; i++) {
		deg[i] = sz(g[i]);
		ch[i].clear();
		used[i] = false;
	}
	ch[n].clear();
	vector<int> q;
	for (int i = 0; i < n; i++) {
		if (deg[i] == 1) {
			q.push_back(i);
			used[i] = true;
		}
	}
	for (int i = 0; i < sz(q); i++) {
		int v = q[i];
		eprintf("v = %d\n", v);
		if (ch[v].empty()) {
			int p = g[v][0];
			if (used[p]) {
				ch[n].push_back(a[v]);
				continue;
			}
			deg[p]--;
			ch[p].push_back(a[v]);
			eprintf("p = %d\n", p);
			if (deg[p] == 1) {
				q.push_back(p);
				used[p] = true;
			}
			continue;
		}
		long long s = 0;
		for (int j = 0; j < sz(ch[v]); j++) {
			s += ch[v][j];
		}
		eprintf("%lld\n", s);
		sort(ch[v].begin(), ch[v].end(), greater<long long>());
		long long x = s - a[v];
		long long y = 2 * a[v] - s;
		eprintf("x = %lld, y = %lld\n", x, y);
		if (x < 0 || y < 0) {
			printf("NO\n");
			return;
		}
		if (ch[v][0] - y > x) {
			printf("NO\n");
			return;
		}
		int p = -1;
		for (int j = 0; j < sz(g[v]); j++) {
			if (!used[g[v][j]]) {
				p = g[v][j];
			}
		}
		if (p == -1) {
			ch[n].push_back(y);
			continue;
		}
		deg[p]--;
		ch[p].push_back(y);
		if (deg[p] == 1) {
			q.push_back(p);
			used[p] = true;
		}
	}
	eprintf("%lld %lld\n", ch[n][0], ch[n][1]);
	if (ch[n][0] != ch[n][1]) {
		printf("NO\n");
		return;
	}
	printf("YES\n");
}

int main() {
  precalc();
#ifdef LOCAL
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}

Measured memory_bytes: 13176
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val abcs = Array.fill[Array[Int]](n)(Array.fill[Int](3)(0))
    for (i <- 0 until n) {
      abcs(i)(0) = sc.nextInt //a
      abcs(i)(1) = sc.nextInt //b
      abcs(i)(2) = sc.nextInt //c
    }

    val dp = Array.fill[Array[Int]](n + 1)(Array.fill[Int](3)(0))
    for (i <- 0 until n) {
      for (j <- 0 until 3) {
        for(k <- 0 until 3) {
          if(j != k) {
            dp(i + 1)(k) = math.max(dp(i + 1)(k), dp(i)(j) + abcs(i)(k))
          }
        }
      }
    }
    println(dp(n).toList.max)
  }
}


Measured memory_bytes: 113336
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		boolean first=true;
        String str="";
        int i=0,length=0;
        int[] amida = null;

		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
            	if(first){
            		amida=new int[Integer.parseInt(line)];
            		for(int j=0;j<amida.length;j++){
            			amida[j]=j;
            		}
            		line = br.readLine();
            		length =Integer.parseInt(line);
            		first=false;
            	}else{
            		String[] tokens=line.split(",");
            		int store=amida[Integer.parseInt(tokens[0])-1];
            		amida[Integer.parseInt(tokens[0])-1]=amida[Integer.parseInt(tokens[1])-1];
            		amida[Integer.parseInt(tokens[1])-1]=store;
            		i++;
            		if(i==length){
            			break;
            		}
            	}
            }
            for(int k=0;k<amida.length;k++){
            	System.out.println(amida[k]+1);
            }
		}
	}

}

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

int check(vector<int> a){
	int s=0;
	for(int i=0 ; i < a.size() ; i++ ){
		s += a[i];
	}
	return s;
}

void solve(vector<int> a, int n, int ans[10] ){
	if( check(a) == 0 ){
		ans[n] = 1;
		return;
	}

	for(int i=1; i <= 9 ; i++ ){
		if( a[i] >= 3 ){
			a[i] -= 3;
			solve( a , n , ans );
			a[i] += 3;
		}
	}
	for(int i=3 ; i <= 9 ; i++ ){
		if( a[i-2] && a[i-1] && a[i] ){
			a[i-2]--;
			a[i-1]--;
			a[i]--;
			solve( a , n , ans );
			a[i-2]++;
			a[i-1]++;
			a[i]++;
		}
	}
}

int main(){
	string s;
	while( cin >> s ){
		vector<int> a;
		int ans[10] = {0};
		for(int i=0 ; i <= 9 ; i++ ){
			a.push_back( 0 );
		}
		for(int i=0 ; i < s.size() ; i++ ){
			a[s[i]-'0']++;
		}

		for(int i=1 ; i <= 9 ; i++ ){
			if( a[i] == 4 ){
				continue;
			}else{
				a[i]++;
				for(int j=1 ; j <= 9 ; j++ ){
					if( a[j] >= 2 ){
						a[j] -= 2;
						solve( a , i , ans );
						a[j] += 2;
					}
				}
				a[i]--;
			}
		}

		bool NA = true;
		for(int i=1 ; i <= 9 ; i++ ){
			if( ans[i] ){
				NA = false;
			}
		}
		if( NA ){
			cout << 0 << endl;
		}else{
			bool flag = true;
			for(int i=1 ; i <= 9 ; i++ ){
				if( ans[i] == 1 ){
					if( flag ){
						flag = false;
					}else{
						cout << " ";
					}
					cout << i;
				}
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
string s;
int l;
int main()
{
    cin>>s;
    l=s.size();
    for (register int i(0);i<l;++i)
        if (s[i]=='C')
            for (register int j(i+1);j<l;++j)
                if (s[j]=='F')
                {
                    printf("Yes");
                    return 0;
                }
    printf("No");
    return 0;
}

Measured memory_bytes: 256