akhauriyash/Code-Regression huggingface dataset:
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        if k<0 or n<k:
            return 0
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

######################################################

S=input()
if S[len(S)-1]=='s':
    print(S+'es')
else:
    print(S+'s')

Measured memory_bytes: 67976
import collections

def main():
    k = int(input())
    Q = collections.deque([int(i) for i in range(1, 10)])
    chk = False
    for i in range(k):
        x = Q.popleft()
        if i + len(Q) > k:
            chk = True
        if chk:
            continue
        else:
            if x%10:
                Q.append(10*x + x%10 - 1)
            Q.append(10*x + x%10)
            if x%10 != 9:
                Q.append(10*x + x%10 + 1)
    print(x)

if __name__ == "__main__":
    main()

Measured memory_bytes: 12108
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
int N,i,j,k;
int64_t A,B,sm,ans,mx=0;
int64_t h[100010];
bool check(int64_t t){
  sm=0;
  for(i=0;i<N;i++){
    if(h[i] - B*t > 0){
      sm+=(h[i] - B*t + A - B - 1)/(A - B);
    }
  }
  if(sm<=t){
    return false;
  }else{
    return true;
  }
}

int64_t BinarySearch(int64_t low, int64_t high, std::function<bool(int64_t)> check){
  while(1){
    if(high-low==1){
      return high;
      break;
    }
    ll mid=low+(high-low)/2;
    if(check(mid)){
      low=mid;
    }else{
      high=mid;
    }
  }
}
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  cin>>N>>A>>B;
  for(i=0;i<N;i++){
    cin>>h[i];
    mx=max(mx, h[i]);
  }

  ans = BinarySearch(0LL, mx+1, check);
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e13;
int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll i, j, k;
    set<ll> st;
    map<ll, ll> mp;
    for(i = 0; i < n; i++) {
        cin >> a[i];
        st.insert(a[i]);
        mp[a[i]]++;
    }
    ll bit = 0;
    for(i = 0; i < n; i++) {
        bit ^= a[i];
    }
    bool flag3 = false;
    if(n % 3 != 0 || st.size()!=3){
        flag3 = true;
    } else {
        ll b = 0;
        for(pair<ll, ll> p : mp) {
            if(p.second != n / 3) {
                flag3 = true;
            }
            b ^=p.first;
        }
        if(b!=0)flag3 = true;
    }

    bool flag2 = true;
    sort(a.begin(),a.end());
    if(3*mp[0]==n && 3*mp[a[n-1]] == 2*n)flag2 = false;
    if(bit==0 && (!flag3 || !flag2) || (st.size()==1 && a[0]==0)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 9344
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        
        if(a < b && b < c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
    }
}
 


Measured memory_bytes: 26068
using System;

class Kai
{
    static void Main()
    {
        var input = Console.ReadLine();
        Console.WriteLine(Solution(input));
    }

    static string Solution(string s)
    {
        var l  = (s.Length - 1) / 2;
        var s1 = s.Substring(0, l);
        var s2 = s.Substring(l + 1, l);

        return IsKai(s) && IsKai(s1) && IsKai(s2) ? "Yes" : "No";
    }

    static bool IsKai(string s)
    {
        for (var i = 0; i < s.Length / 2; i++)
        {
            if (s[i] != s[s.Length - 1 -i])
            {
                return false;
            }
        }

        return true;
    }
}

Measured memory_bytes: 13140
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 1234;
const LL MOD = (LL)1e9 + 7;
LL dp[MAXN][MAXN];
char maze[MAXN][MAXN];


int main() {
    int H, W;
    scanf("%d %d", &H, &W);
    dp[0][0] = 1;
    for (int i = 0; i < H; i++) {
        scanf("%s", maze[i]);
        for (int j = 0; j < W; j++) {
            if (j && maze[i][j - 1] != '#')
               dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
            if (i && maze[i - 1][j] != '#')
               dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
        }
    }
    printf("%lld\n", dp[H - 1][W - 1]);
    return 0;
}


Measured memory_bytes: 12288
#include <stdio.h>
//#include <string.h>

int main() {
    int w, h, i, j;

    while (1) {
        scanf("%d %d", &h, &w);

        if (w == 0 && h == 0)
            break;

        for (i = 0; i < h; ++i) {
            for (j = 0; j < w; ++j) {
                putchar(((i & 1) ^ (j & 1)) == 0 ? '#' : '.');
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2052
package main

import (
	"fmt"
	"math"
)

func main() {
	fmt.Scanf("%d\n", &N)

	X := make([]int, N)
	Y := make([]int, N)

	for i := 0; i < N; i++ {
		var x, y int
		fmt.Scanf("%d %d\n", &x, &y)
		X[i] = x
		Y[i] = y
	}

	for i := 0; i < N; i++ {
		xo := X[i]
		yo := Y[i]
		x := append(append([]int{}, X[:i]...), X[i+1:]...)
		y := append(append([]int{}, Y[:i]...), Y[i+1:]...)
		dfs(0.0, x, y, xo, yo)
	}
	cnt := 1
	for i := 1; i <= N; i++ {
		cnt *= i
	}
	fmt.Println(sum / float64(cnt))
}

var N int
var sum = 0.0

func dfs(d float64, x, y []int, xo, yo int) {
	if len(x) == 0 {
		sum += d
		return
	}

	for i := range x {
		xi := x[i]
		yi := y[i]
		x := append(append([]int{}, x[:i]...), x[i+1:]...)
		y := append(append([]int{}, y[:i]...), y[i+1:]...)
		dfs(d+math.Sqrt(float64((xo-xi)*(xo-xi)+(yo-yi)*(yo-yi))), x, y, xi, yi)
	}
}


Measured memory_bytes: 2688
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String sl[] = s.split(" ");
            int A = Integer.parseInt(sl[0]);
            int B = Integer.parseInt(sl[1]);
            int C = Integer.parseInt(sl[2]);
            int D = Integer.parseInt(sl[3]);

            int AB = A + B;
            int CD = C + D;
            System.out.println(
                AB < CD ? "Right" : CD < AB ? "Left" : "Balanced");
        }
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second



int main() {
	int a, b, c, n;
	string s, t;
	cin >> a >> b>>c;
  cout<<(a+b)*c/2<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    bool j=true;;
    while(true){
        for(int i=2;i<=sqrt(n);i++){
            if(n%i==0){
                j=false;
                break;
            }
        }
        if(j==true){
            cout << n;
            return 0;
        }
        j=true;
        n++;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int n,k;
	cin >> n >> k;
	int h[n];
	for(int i = 0; i < n; i++)
	cin >> h[i];
	ll ans = 0;
	int dp[n]; // cost
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for(int i = 2; i < n; i++)
	dp[i] = 1e9;
	for(int i = 2; i < n; i++)
	{
		for(int j = i-1; j >= 0; j--)
		{
			if(i-j <= k)
			{
			   int x = abs(h[i]-h[j])+dp[j];
			   dp[i] = min(dp[i],x);
		    }
		    else
		    break;
		}
	}
	cout << dp[n-1] << '\n';
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main() {
    int m, f, r;
    while (scanf("%d%d%d", &m, &f, &r) == 3 && (~m || ~f || ~r)) {
        if (m == -1 || f == -1) {
            printf("F\n");
        } else if (m + f >= 80) {
            printf("A\n");
        } else if (m + f >= 65) {
            printf("B\n");
        } else if (m + f >= 50) {
            printf("C\n");
        } else if (m + f >= 30) {
            if (r >= 50) {
                printf("C\n");
            } else {
                printf("D\n");
            }
        } else {
            printf("F\n");
        }
    }
    return 0;
}

Measured memory_bytes: 584
package main

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

func main() {
	h := getInt()
	_ = getInt()

	ss := make([]string, h)
	for i := range ss {
		ss[i] = getString()
	}

	for _, s := range ss {
		fmt.Println(s)
		fmt.Println(s)
	}
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n; 
    cin >> n;
    int k;
    cin >> k;
    vector<int> height(n);
    for (int i = 0; i < n; ++i)
    	cin >> height[i];
    std::vector<int> dp(n, INT_MAX);
    dp[0] = 0;
    for (int j = 1; j < n; ++j) {
    	for (int i = 1; i <= k; ++i) {
    		if (j-i >= 0) {
    			dp[j] = min (dp[j-i] + abs(height[j]-height[j-i]), dp[j]);
    		}
    	}
    }
    cout << dp[n-1] ;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define DEBUG 0
#define nl          '\n'
#if     DEBUG
#define trace(var)  {cerr << "Line " << __LINE__ << ": " << #var << "=" << var << nl;}
#else
#define trace(var)	{}
#endif
#define fori(n)			for(int i = 0; i < n; ++i) 
#define forj(n)			for(int j = 0; j < n; ++j)
#define fork(n)			for(int k = 0; k < n; ++k)
#define forl(n)			for(int l = 0; l < n; ++l)

typedef long long ll;typedef pair<int,int> pii;typedef vector<bool> vbool;typedef vector<int> vint;typedef vector<ll> vll;typedef long double ld;typedef vector<vector<int>> vvi;

const ll N = 100010;
const ll INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;

int n,k,val[N]; 
vector<vector<int>> adj(N);

void bfs(int root, int ways, vbool &seen) {
	 int c = ways;
	 seen[root] = true;
	 for(auto x : adj[root]) {
		if (!seen[x])
			val[x] = --ways;
	 }
	 for(auto x : adj[root]) 
		if (!seen[x])
			bfs(x, k-1, seen);
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	int a,b;
	fori(n-1) {
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	vbool seen(n+1,false);
	val[1] = k;
	bfs(1,k,seen);

	ll ans = 1;
	for(int i = 1; i <= n; ++i) {
		ans *= val[i]; ans %= MOD;
	}
	cout << ans << nl;

	#if DEBUG
	cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << " s" << nl;
	#endif
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int h[n];
    int g = 1;

    rep(i, n) cin >> h[i];
    for(int i = 1; i < n; i ++){
        int jj = 0;
        for(int j = 0; j < i; j ++){
            if(h[i] >= h[j]) jj++;
        }
        if(jj == i ) g ++;
       // if(h[i + 1] >= h[i]) g ++;
    }
   /* int max1 = h[0];
    rep(i, n){
        if(h[i] >= max1){
            g ++;
            max1 = h[i];
        }
    }*/
    cout << g << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
typedef long long ll;
 
int main() {
  ll a;cin>>a;
  if (a==22) cout<<"Christmas Eve Eve Eve";
  else if (a==23) cout<<"Christmas Eve Eve";
  else if (a==24) cout<<"Christmas Eve";
  else cout<<"Christmas";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    ll A;
    cin >> A;
    if(A%2 == 1){
        cout << A/2+1<< endl;
    }
    else
    {
        cout << A/2<< endl;
    }

    return 0;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
int main() {
    string S;
    int coord[2];
    cin >> S >> coord[0] >> coord[1];
    S += "T";
    vector<int> F[2];
    int f = 0, t = -1;
    for(auto c : S) {
        if(c == 'T') {
            if(t < 0) {
                coord[0] -= f;
                t = 0;
            } else if(f > 0) {
                F[t].push_back(f);
            }
            f = 0;
            t = !t;
        } else {
            f++;
        }
    }
    bool ans = true;
    int N = S.size() + 10;
    for(int b = 0; b < 2; b++) {
        vector<bool> dp[2];
        dp[0] = vector<bool>(2 * N, false);
        dp[0][N] = true;
        for(int i = 0; i < F[b].size(); i++) {
            int f = F[b][i];
            dp[!(i & 1)] = vector<bool>(2 * N, false);
            for(int x = 0; x <= 2 * N; x++) {
                if(dp[i & 1][x]) {
                    dp[!(i & 1)][x + f] = dp[!(i & 1)][x - f] = true;
                }
            }
        }
        ans &= coord[b] + N >= 0 &&
            dp[F[b].size() & 1][coord[b] + N];
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;
 
int a[4];
double b[4] = {0.25,0.5,1.0,2.0};
int N;
int ans=INF;
 
 
signed main(){
    for(int i=0;i<4;++i)cin>>a[i];
    cin>>N;
    int n = N;
    for(int i=0;i<4;++i){
        for(int j=0;j<4;++j){
            for(int k=0;k<4;++k){
                for(int l=0;l<4;++l){
                    int p = n/b[i];
                    n-=b[i]*p;
                    int q = n/b[j];
                    n-=b[j]*q;
                    int r = n/b[k];
                    n-=b[k]*r;
                    int s = n/b[l];
                    n-=b[l]*s;
                    if(n!=0)continue;
                    int res = a[i]*p+a[j]*q+a[k]*r+a[l]*s;
                    ans=min(ans,res);
                    n=N;
                }
            }
        }
    }
    cout<<ans<<endl;
    //cout<<Q*a+H*b+S*c+D*d<<endl;
}

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

#include <iostream>
#include <fstream>

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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, _begin, _end) for (__typeof(_end) end = _end, begin = _begin,  i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0, _len = (end); i < (_len); i += 1)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define readint ({int t;cin >> t;t;})

const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class AFiftyFifty {
public:
    map<char, int> M;
void solve(std::istream& cin, std::ostream& cout) {

    string s;
    cin >> s;
    for(auto c : s)M[c]++;
    if(M.size() == 2 && M.begin()->S == 2 && M.rbegin()->S == 2)cout << "Yes" << endl;
    else cout << "No" << endl;

}
};


#undef int
int main() {
	AFiftyFifty solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(0); ios::sync_with_stdio(0); out<<fixed<<setprecision(20);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var A, B, C string
	fmt.Scan(&A, &B, &C)

	if A[len(A)-1] == B[0] && B[len(B)-1] == C[0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
ll n;
ll Dp[2001];
long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    
ll solve(ll s)
{
  if(s == 1 || s == 2)
  return 0LL;
  if(s==3 || s==4 || s==5 || s==0)
  return 1LL;
  if(Dp[s]==-1){ Dp[s]=0;
  for(int j=3;j<=n;j++)
  {
      if(s-j>=0)
      Dp[s] = add(Dp[s],solve(s-j));
  }
  }
  //else Dp[s]++;
  return Dp[s];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(Dp,-1,sizeof(Dp));
    cin>>n;
    cout<<solve(n);//<<endl;
    // for(int i=0;i<=n;i++)
    //cout<<Dp[i]<<" ";
    return 0;
}

Measured memory_bytes: 3672
<?php
list($x,$y)=explode(" ",trim(fgets(STDIN)));
if($x==$y){
echo "=";
}else{
$a=str_split("ABCDEF");
$x=array_search($x,$a);
$y=array_search($y,$a);
if($x<$y){
echo "<";
}else{
echo ">";
}
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N, K;
  cin >> N >> K;

  unordered_map<int, int> count;
  int a;
  REP(i, N) {
    cin >> a;
    if (count.find(a) == count.end()) {
      count.insert(make_pair(a, 1));
    } else {
      ++count.at(a);
    }
  }

  multimap<int, int> r_count;
  for (auto const it : count) {
    r_count.insert(make_pair(it.second, it.first));
  }

  int ans = 0;
  int v_size = count.size();
  for (auto const it : r_count) {
    if (v_size <= K) {
      break;
    }
    ans += it.first;
    --v_size;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 17864
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long H;
  cin >> H;
  long long count = 0;
  long long i = 0;
  while(H > 0){
    H = H/2;
    count = count + pow(2,i);
    i++;
  }
  cout << count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
	int a,b;
	cin >> a >> b;
	cout <<  (a+b+1)/2 << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
m = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

ans = 0
for i in range(n):
    if b[i] >= m[i]:
        ans += m[i]
        b[i] -= m[i]
    else:
        ans += b[i]
        m[i] -= b[i]
        b[i] = 0
    if b[i] > 0:
        if m[i + 1] >= b[i]:
            ans += b[i]
            m[i + 1] -= b[i]
        else:
            ans += m[i + 1]
            m[i + 1] = 0
print(ans)

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

int main() {
	long long k,a,b,c;
	cin>>a>>b>>c>>k;
	if(k%2==0){
	
	if(max(a-b,b-a)>1000000000000000000){
		cout<<"Unfair"<<endl;
	}
	else{
		cout<<a-b<<endl;
	}
	}
	else{
			if(max(a-b,b-a)>1000000000000000000){
		cout<<"Unfair"<<endl;
	}
	else{
		cout<<b-a<<endl;
	}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
using i16 = int16_t;

i16 n;
int ans;
i16 a[2000];
int main(){
  scanf("%hd", &n);
  for(int i = 0; i < n; i++) scanf("%hd", &a[i]);
  sort(a, a + n);
  for(int i = 0; i < n; i++) for(int j = i + 1; j < n; j++) for(int k = j + 1; k < n; k++) if(a[i] + a[j] > a[k]) ans++;
  printf("%d", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//for(int i = ; i < ; i++){}

int main(){
  int a,b;
  cin>>a>>b;
  string s;
  cin>>s;
  bool flag= true;
  for(int i = 0; i < a+b+1; i++){
    if(i == a){
      if(s[a]!='-'){
        flag=false;
        break;
      }
    }
    else{
      if(s[i]<'0'||s[i]>'9'){
        flag = false;
        break;
      }
    }
  }
  if(flag) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){
  int n,i,j,s,r,t=1e9,w[100];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&w[i]);
  for(i=0;i<n-1;i++){
    s=0;
    r=0;
    for(j=0;j<=i;j++)s+=w[j];
    for(;j<n;j++)r+=w[j];
    if(abs(s-r)<t)t=abs(s-r);
  }
  printf("%d",t);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }


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

    map<int, int> num;
    rep(i, N) num[i] = 10;

    vector<int> s(M);
    vector<int> c(M);

    rep(i, M) {
        cin >> s.at(i) >> c.at(i);
        s[i]--;
    }

    rep(i, M) {
        if (num[s[i]] != 10 && num[s[i]] != c[i]) { // 矛盾
            cout << -1 << endl;
            return 0;
        }
        num[s[i]] = c[i];
    }

    if (N > 1) {
        if (num[0] == 0) {
            cout << -1 << endl;
            return 0;
        } else if (num[0] == 10) {
            num[0] = 1;
        }
        rep(i, N) {
            if (num[i] == 10) cout << 0;
            else cout << num[i];
        }
        cout << endl;
        return 0;
    } else { // N == 1
        if (num[0] == 10) num[0] = 0;
        cout << num[0] << endl;
        return 0; 
    }
}

Measured memory_bytes: 256
import sys

N = int(input())
A = [int(s) for s in input().split()]
B = [int(s) for s in input().split()]
dist = [B[i] - A[i] for i in range(N)]
distp = [[i, B[i] - A[i]] for i in range(N)]
if sum(dist) > 0:
    print(-1)
    sys.exit()
distp.sort(key=lambda x: x[1], reverse=True)
C = [v for v in A]
ans = 0
for i, dist in distp:
    if dist <= 0:
        break
    while dist > 0:
        v = min(dist, -distp[-1][1])
        dist -= v
        distp[-1][1] += v
        if distp[-1][1] == 0:
            distp.pop()
            ans += 1
    ans += 1
if len(distp):
    i, v = distp[-1]
    if B[i] - A[i] != v:
        ans += 1
print(ans)


Measured memory_bytes: 34020
#include <bits/stdc++.h>
    #define maxn 100000
    #define INF 1LL<<60
    using namespace std;
    long long h[maxn+3], dp[maxn+3];
    int n;

    long long solve(int cur){
        if(cur >= n) return INF;
        if(cur == n-1) return 0;
        if(dp[cur]!= INF) return dp[cur];
        //long long res1 = INF, res2 = INF;
        long long res1 = solve(cur+1) + llabs(h[cur+1]-h[cur]);
        long long res2 = solve(cur+2) + llabs(h[cur+2]-h[cur]);
        return dp[cur] = min(res1, res2); 
    }

    int main() {
    	// your code goes here
        //freopen("in.txt", "r", stdin);
    	while(scanf("%d",&n)==1){
            
            for (int i = 0; i < n; ++i){
                scanf("%lld",&h[i]);
                dp[i] = INF;
            }

            long long ans = solve(0);
            printf("%lld\n", ans);
        }
    }
     

Measured memory_bytes: 4992
#include<iostream>
#include<vector>
using namespace std;
#define maxn 210000
int a[maxn],v[maxn];
int main ()
{   int n,k;
   cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>v[i];
     while(k--)
     {   for(int i=1;i<=n;i++)
          {   a[max(1,i-v[i])]++;
              a[min(n+1,i+v[i]+1)]--;
		  }
		  for(int i=1;i<n;i++)
		   a[i+1]+=a[i];
		   for(int i=1;i<=n;i++)
		     v[i]=a[i];
		    for(int i=1;i<=n;i++)
		      a[i]=0;
		      int flag=0;
		    for(int i=1;i<=n;i++)
		     {   if(v[i] != n)
		         {  flag=1;break;
				 }
			 }
			 if(!flag) break;
	 }
	for(int i=1;i<=n;i++)
		    cout<<v[i]<<' '; 
			return 0;
}

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

struct Problem {
    int num;
    string ans;
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<Problem> submit(m);
    for (int i = 0; i < m; i++) {
        scanf("%d", &submit.at(i).num);
        cin >> submit.at(i).ans;
    }

    vector<bool> checked(n + 1, false);
    vector<int> wa(n + 1);
    int ac = 0;
    int pn = 0;
    for (auto p : submit) {
        if (!checked.at(p.num)) {
            if (p.ans == "WA") {
                wa.at(p.num)++;
            } else {
                ac++;
                pn += wa.at(p.num);
                checked.at(p.num) = true;
            }
        }
    }

    cout << ac << " " << pn << endl;

    return 0;
}

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

using namespace std;

int parent[200005];
int ranking[200005];
int n, m;

int get_parent(int a)
{
    return (parent[a] = parent[a] == a ? a : get_parent(parent[a]));
}

void join(int a, int b)
{
    if (get_parent(a) == get_parent(b))
        return;
    if (ranking[get_parent(a)] < ranking[get_parent(b)])
        swap(a,b);
    ranking[get_parent(a)] += ranking[get_parent(b)];
    parent[get_parent(b)] = parent[get_parent(a)];
}

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

    cin >> n >> m;

    for (int i = 1; i <= n; i++) {
        parent[i] = i;
        ranking[i] = 1;
    }

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        join(a,b);
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, ranking[i]);
    }

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

Measured memory_bytes: 5160
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

ll da[500100];
ll db[500100];

int main() {
  clr(da,-1);
  clr(db,-1);
  string a,b;
  cin>>a>>b;
  ll index = 0;
  rep(i,0,a.sz){
    if(a[i]==b[index]){
      da[i] = index;
      index++;
    }
  }
  index = b.sz-1;
  per(i,0,a.sz){
    if(a[i]==b[index]){
      db[i] = index;
      index--;
    }
  }
  ll flag = 1;
  rep(i,0,500100){
    if(da[i]!=db[i])flag = 0;
  }
  if(flag==1){
    cout << "yes" << endl;
  }
  else{
    cout << "no" << endl;
  }
  return 0;
}

Measured memory_bytes: 11940
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;
using ll = long long;
using ull = unsigned long long;


#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)

int main() {
	int n;
	vector<int> x;
	cin >> n;
	x.resize(n);
	rep(i, 0, n) {
		cin >> x.at(i);
	}
	int ans = 10000000000;
	rep(i, 1, 100) {
		int tans = 0;
		rep(j, 0, n) {
			tans += (i - x.at(j)) * (i - x.at(j));
		}
		ans = min(tans, ans);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9
#define f first
#define s second

typedef long long ll;

using namespace std;

int main()

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

    int n, cnt = 0;

    cin >> n;

    int a[n];

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

    for (int i = 0; i < n-1; i++) {

        if (a[i] != i+1) cnt++;
    }

    if (cnt > 2) cout << "NO";
    else cout << "YES";

    return 0;
}


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

string t = "RGB";

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<vector<ll>> v(3, vector<ll>(n,0));
	vector<map<int,int>> mp(3);
	rep(i,n){
		if(s[i] == 'R') {
			v[0][i]++;
			mp[0][i]++;
		}
		if(s[i] == 'G'){
			v[1][i]++;
			mp[1][i]++;
		}
		if(s[i] == 'B'){
			v[2][i]++;
			mp[2][i]++;
		}
	}
	rep(i,3){
		rep(j,n){
			if(j>0) v[i][j] += v[i][j-1];
		}
	}
	
	ll ans = 0;
	
	for (int i = 0; i < n; ++i) {
		for (int j = i+1; j < n; ++j) {
			if(s[i] == s[j]) continue;
			int id;
			rep(k,3){
				if(t[k] != s[i] && t[k] != s[j]) id = k;
			}
			ans += v[id][n-1] - v[id][j];
			if(2*j-i<n && mp[id][2*j-i] != 0) ans--;
		}
	}
	cout << ans << endl;
    return 0;
}



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

typedef long long ll;
const ll INF = 1LL << 60;

int main(void){
    int N,K;
    cin >> N >> K;
    
    ll h[110000];
    ll dp[110000];
    
    for(int i = 0 ; i < N ; i++){
        cin >> h[i];
    }
    for(int i = 0 ; i < 110000 ; i++){
        dp[i] = INF;
    }
    
    dp[0] = 0;
    for(int i = 1 ; i < N ; i++){
        for(int j = 1 ; j <= K ; j++){
            if(i > j-1){
                dp[i] = min(dp[i] , dp[i-j] + abs(h[i] - h[i-j]));
            }
        }
    }
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 5232
public class Main {

	public static void main(String[] args) {

		java.util.Scanner sc = new java.util.Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int m1 = java.lang.Math.min(a,b);
		int m2 = java.lang.Math.max(a,b);

		if (c < m1) {
			System.out.println(c + " " + m1 + " " + m2);
		}else if (m2 < c) {
			System.out.println(m1 + " " + m2 + " " + c);
		}else {
			System.out.println(m1 + " " + c + " " + m2);
		}


	}
}

Measured memory_bytes: 25976
#include<bits/stdc++.h>
#define rep(i,k,n)     for (ll i = k; i < n; ++i)
#define repr(i,k,n)    for (ll i = k; i >= n; --i)
#define repp(p,a)      for (p=a.begin();p!=a.end();++p)
#define all(a)         a.begin(),a.end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define reppn(p,a,n)    for (p=a.begin();(p+n)!=a.end();++p)
#define F              first
#define S              second
#define ll             long long
#define hell           1000000007
#define god            LLONG_MAX
#define lb             lower_bound
#define ub             upper_bound
#define pb             push_back
#define ct             continue
#define endl           '\n'
#define setprecision(n) sp(n)
#define srt(a)         sort(all(a))
#define srtd(a)        sort(a.rbegin(),a.rend())
#define sz(a)          ll((a).size())
#define sum(a)         accumulate(all(a),(ll) 0)
#define pdt(a)         accumulate(all(a),double(1),multiplies<double> ())
#define dotpdt(a,b)    inner_product(all(a),b.begin(),0)
#define mkp(a,b)       make_pair(a,b)
#define REP(x,s)       for (auto x : s)
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll t=1;
  //cin>>t;
  while(t--)
  {
     ll n;
     cin>>n;
     vector<ll>v;
     rep(i,0,n)
     {
         ll a;
         cin>>a;
         v.pb(a);
     }
     srt(v);
     ll flag=0;
     rep(i,0,n-1)
     {
         if(v[i]==v[i+1])
         {
             flag=1;
             break;
         }
     }
     if(flag)
     {
         cout<<"NO";
     }
     else
     {
         cout<<"YES";
     }
     
  }      
 
 
 return 0;
}

Measured memory_bytes: 2420
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[100100];

int main() {
  ll n;
  cin >> n;
  vector<pair<ll, ll> > vl;
  vector<pair<ll, ll> > vr;
  rep(i, 0, n) {
    ll a, b;
    cin >> a >> b;
    vl.pb(mp(a, i));
    vr.pb(mp(b, i));
  }
  sort(all(vl));
  reverse(all(vl));
  sort(all(vr));
  ll ans[2];
  clr(ans,0);
  {
    clr(d, 0);
    ll now = 0;
    ll indexl = 0;
    ll indexr = 0;
    ll p = 0;
    while (1) {
      if (now == 0) {
        if (d[vl[indexl].se] == 0) {
          d[vl[indexl].se] = 1;
          if(p<vl[indexl].fi){
            ans[0] += abs(p - vl[indexl].fi);
            p = vl[indexl].fi;
          }
          now = 1;
          indexl++;
        }
        else {
          indexl++;
        }
      }
      else {
        if (d[vr[indexr].se] == 0) {
          d[vr[indexr].se] = 1;
          if(p>vr[indexr].fi){
            ans[0] += abs(p - vr[indexr].fi);
            p = vr[indexr].fi;
          }
          now = 0;
          indexr++;
        }
        else {
          indexr++;
        }
      }
      if (indexl >= n)break;
      if (indexr >= n)break;
    }
    ans[0] += abs(p);
  }
  {
    clr(d, 0);
    ll now = 1;
    ll indexl = 0;
    ll indexr = 0;
    ll p = 0;
    while (1) {
      if (now == 0) {
        if (d[vl[indexl].se] == 0) {
          d[vl[indexl].se] = 1;
          if(p<vl[indexl].fi){
            ans[1] += abs(p - vl[indexl].fi);
            p = vl[indexl].fi;
          }
          now = 1;
          indexl++;
        }
        else {
          indexl++;
        }
      }
      else {
        if (d[vr[indexr].se] == 0) {
          d[vr[indexr].se] = 1;
          if(p>vr[indexr].fi){
            ans[1] += abs(p - vr[indexr].fi);
            p = vr[indexr].fi;
          }
          now = 0;
          indexr++;
        }
        else {
          indexr++;
        }
      }
      if (indexl >= n)break;
      if (indexr >= n)break;
    }
    ans[1] += abs(p);
  }
  cout << max(ans[0],ans[1]) << endl;
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<ll> a(3 * n);
    rep(i, 3 * n) cin >> a[i];

    ll running_sum = 0;
    vector<ll> maxleft(3 * n, -1e18);
    priority_queue<ll, vector<ll>, greater<ll>> pqmin;
    for (int i = 0; i < 3 * n; i++) {
        pqmin.push(a[i]);
        running_sum += a[i];
        if ((int)pqmin.size() < n) continue;
        if ((int)pqmin.size() > n) {
            running_sum -= pqmin.top();
            pqmin.pop();
        }
        maxleft[i] = running_sum;
    }

    running_sum = 0;
    vector<ll> minright(3 * n, 1e18);
    priority_queue<ll> pqmax;
    for (int i = 3 * n - 1; i >= 0; i--) {
        pqmax.push(a[i]);
        running_sum += a[i];
        if ((int)pqmax.size() < n) continue;
        if ((int)pqmax.size() > n) {
            running_sum -= pqmax.top();
            pqmax.pop();
        }
        minright[i] = running_sum;
    }
    ll ans = -1e18;
    for (int i = n - 1; i < 2 * n; i++) {
        ans = max(ans, maxleft[i] - minright[i + 1]);
    }
    cout << ans << endl;
}

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

using namespace std;

int v[2048];

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n, a, b;
  cin >> n >> a >> b;
  for(int i = 0; i < n; ++i)  cin >> v[i];
  if(n == 1)  cout << abs(v[0] - b) << "\n";
  else  cout << max(abs(v[n - 2] - v[n - 1]), abs(v[n - 1] - b)) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n, m;
	cin >> n >> m;
	ll f = n % m;
	cout << min(f, abs(f - m));
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N=int(input())
POINT=[list(map(int,input().split())) for i in range(N)]
mod=998244353

PX=[p[0] for p in POINT]
PY=[p[1] for p in POINT]

compression_dict_x={a: ind for ind, a in enumerate(sorted(set(PX)))}
compression_dict_y={a: ind for ind, a in enumerate(sorted(set(PY)))}

for i in range(N):
    POINT[i]=[compression_dict_x[POINT[i][0]]+1,compression_dict_y[POINT[i][1]]+1]


P_Y=sorted(POINT,key=lambda x:x[1])

# BIT(BIT-indexed tree)

LEN=len(compression_dict_x)# 必要なら座標圧縮する

BIT=[0]*(LEN+1)# 1-indexedなtree

def update(v,w):# vにwを加える
    while v<=LEN:
        BIT[v]+=w
        v+=(v&(-v))# 自分を含む大きなノードへ. たとえばv=3→v=4

def getvalue(v):# [1,v]の区間の和を求める
    ANS=0
    while v!=0:
        ANS+=BIT[v]
        v-=(v&(-v))# 自分より小さい2ベキのノードへ. たとえばv=3→v=2へ
    return ANS


ALL = pow(2,N,mod)-1

ANS= ALL*N%mod

for i in range(N):
    ANS = (ANS - (pow(2,i,mod) -1)*4)%mod

for i in range(N):
    x,y=P_Y[i]
    up=getvalue(x)

    ANS=(ANS+pow(2,up,mod)+pow(2,i-up,mod)-2)%mod

    update(x,1)

P_Y2=P_Y[::-1]
BIT=[0]*(LEN+1)

for i in range(N):
    x,y=P_Y2[i]
    down=getvalue(x)

    ANS=(ANS+pow(2,down,mod)+pow(2,i-down,mod)-2)%mod

    update(x,1)


print(ANS)


Measured memory_bytes: 125796
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;
int ok = 1;
vector<int> edges[110000];
int dfs(int a, int p){
	int ans = 0;
	for(int j = 0; j < edges[a].size(); j++){
		if(edges[a][j] == p) continue;
		ans += dfs(edges[a][j],a);
	}
	if(ans > 1){
		ok = 0;
		return 0;
	}
	return 1-ans;
}
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n-1; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	if(dfs(0,-1) == 1) ok = 0;
	cout << (ok ? "Second" : "First") << endl;
}

Measured memory_bytes: 6016
from itertools import combinations as c
from operator import mul
d = {k: 0 for k in 'MARCH'}
for _ in xrange(input()):
    n = raw_input()[0]
    if n in 'MARCH':
        d[n] += 1
r = [k for k, v in d.iteritems() if v]
print sum([reduce(mul, [d[k] for k in _]) for _ in c(r, 3)])


Measured memory_bytes: 2820
#include <stdio.h>
#include <string.h>

#define N 36

typedef struct{

  char c;
  int n;

} Card;

void bubble_sort(Card*, int);
void selec_sort(Card*, int);

int main(int argc, char const *argv[]) {

  int i;
  int num;

  Card card[N],bubble[N],selec[N];

  scanf("%d",&num);

  for( i = 0 ; i < num ; i++ ){
    scanf(" %c%d",&card[i].c,&card[i].n);

    bubble[i] = selec[i] = card[i];
  }

  bubble_sort(bubble,num);
  selec_sort(selec,num);

  for( i = 0 ; i < num ; i++ ){

    if( i == num-1 ){
      printf("%c%d\n",bubble[i].c,bubble[i].n);
    }else{
      printf("%c%d ",bubble[i].c,bubble[i].n);
    }

  }

  printf("Stable\n");

  for( i = 0 ; i < num ; i++ ){

    if( i == num-1 ){
      printf("%c%d\n",selec[i].c,selec[i].n);
    }else{
      printf("%c%d ",selec[i].c,selec[i].n);
    }

  }

  for( i = 0 ; i < num ; i++ ){

    if( selec[i].c != bubble[i].c && selec[i].n == bubble[i].n ){
      printf("Not stable\n");
      return 0;
    }

  }

  printf("Stable\n");

  return 0;
}

void bubble_sort(Card *a, int n){

  int i,j;
  int tempn;
  char tempc;

  for( i = 0 ; i < n ; i++ ){
    for( j = n-1 ; j > i ; j-- ){

      if( a[j].n < a[j-1].n ){
        tempn = a[j].n;
        a[j].n = a[j-1].n;
        a[j-1].n = tempn;

        tempc = a[j].c;
        a[j].c = a[j-1].c;
        a[j-1].c = tempc;
      }

    }

  }

}

void selec_sort(Card *a, int n){

  int i,j,mini;
  int tempn;
  char tempc;

  for( i = 0 ; i < n ; i++ ){
    mini = i;
    for( j = i ; j < n ; j++ ){
      if( a[j].n < a[mini].n ){
        mini = j;
      }
    }

    if( i != mini ){
      tempn = a[i].n;
      a[i].n = a[mini].n;
      a[mini].n = tempn;

      tempc = a[i].c;
      a[i].c = a[mini].c;
      a[mini].c = tempc;
    }

  }


}



Measured memory_bytes: 2088
#include <iostream>
    #include <vector>
    #include <map>
    #include <algorithm>
    #include <set>
     
    using namespace std;
     
    #define rep(i,n) for(int i=0; i<n; i++)
     
    typedef unsigned int ui;
     
    const double eps = 1e-7;
     
    double sqrdist(double a,double b, double c, double d) {
    return (a-c)*(a-c)+(b-d)*(b-d);
    }
     
    int main() {
    int n;
    double r;
    map<pair<int, int>, set<int> > m;
    cin >> n >> r;
    vector<double> x(n),y(n);
    int ans = n;
    rep(i,n) {
    cin >> x[i] >> y[i];
    m[make_pair((int)(x[i]/r), (int)(y[i]/r))].insert(i);
    }
     
    rep(i, n) {
    int px = (int)(x[i]/r), py = (int)(y[i]/r);
    for (int j=-1; j<=1; j++) {
    for (int k=-1; k<=1; k++) {
    if (m.find(make_pair(px+j, py+k)) == m.end())continue;
    for (typeof(m[make_pair(px+j, py+k)].begin()) it = m[make_pair(px+j, py+k)].begin(); it != m[make_pair(px+j, py+k)].end(); ++it) {
    if (*it == i)continue;
    if (sqrdist(x[i],y[i], x[*it], y[*it]) <= r*r + eps) {
    m[make_pair(px,py)].erase(i);
    ans--;
    goto flg;
    }
    }
    }
    }
    flg:;
    }
    cout << ans << endl;
    return 0;
    }

Measured memory_bytes: 30572