akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h =sc.nextInt();
        int w =sc.nextInt();
        char[][] c = new char[h][w];
        boolean[][] b = new boolean[h][w];
        boolean[] x = new boolean[h];
        for (int i = 0; i < h; i++) {
            String s = sc.next();
            x[i] = true;
            for (int j = 0; j < w; j++) {
                b[i][j] = true;
                c[i][j] = s.charAt(j);
            }
        }
        // ->
        for (int i = 0; i < h; i++) {
            boolean f = true;
            for (int j = 0; j < w; j++) {
                if(c[i][j] == '#'){
                    f = false;
                }
            }
            if(f){
                for (int j = 0; j < w; j++) {
                    b[i][j] = false;
                }
                x[i] = false;
            }
        }

        for (int j = 0; j < w; j++) {
            boolean f = true;
            for (int i = 0; i < h; i++) {
                if(c[i][j] == '#'){
                    f = false;
                }
            }
            if(f){
                for (int i = 0; i < h; i++) {
                    b[i][j] = false;
                }
            }
        }

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if(b[i][j]){
                    System.out.print(c[i][j]);
                }
            }
            if(x[i]){
                io.br();
            }
        }

    }
}

class io{
    public static void br(){
        System.out.println("");
    }

    public static void YesNo(boolean f) {
        System.out.println(f?"Yes":"No");
    }
    public static void YESNO(boolean f) {
        System.out.println(f?"YES":"NO");
    }

}

class Algo{
    public static boolean isOdd(int n){
        return n % 2 == 1;
    }
    public static boolean isEven(int n){
        return n % 2 == 0;
    }


}



Measured memory_bytes: 23972
#include <iostream>
using namespace std;
int main(){
int inf;
inf=1e9;
int N,T;cin >>N>>T;
int x=inf;
for(int i=1;i<=N;i++){
  int c,t;cin >>c>>t;
  if(t<=T){
    if(c<x){
      x=c;
    }
  }
}
if(x==inf){
  cout<<"TLE"<<endl;
}
else{
  cout <<x<<endl;
}
return 0;
}


Measured memory_bytes: 256
package main

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

func push(queue []string, args []string, head int, tail int) ([]string, int, int) {
	if args[0] == "0" {
		head--
		queue[head] = args[1]
	} else {
		queue[tail] = args[1]
		tail++
	}
	return queue, head, tail
}

func pop(arg string, head int, tail int) (int, int) {
	if arg == "0" {
		head++
	} else if arg == "1" {
		tail--
	}

	return head, tail
}

func main() {
	var sc = bufio.NewScanner(os.Stdin)
	sc.Scan()
	length, _ := strconv.Atoi(sc.Text())

	var queue = make([]string, length*2)
	head := length
	tail := head
	for sc.Scan() {
		inputs := strings.Split(sc.Text(), " ")

		switch inputs[0] {
		case "0":
			queue, head, tail = push(queue, inputs[1:], head, tail)
		case "1":
			num, _ := strconv.Atoi(inputs[1])
			fmt.Println(queue[head+num])
		case "2":
			head, tail = pop(inputs[1], head, tail)
		}
	}
}



Measured memory_bytes: 24696
{-# LANGUAGE OverloadedStrings #-}

import qualified Data.ByteString.Char8 as B
import Data.Attoparsec.ByteString.Char8

type Input  = (Int, Int, Int, [Int], [[Int]])
type Output = Int

input :: Parser Input
input = do
  (_N, _M, _C) <- decimalTriple
  _Bs <- decimalList
  _Ass <- count _N decimalList
  return (_N, _M, _C, _Bs, _Ass)

decimalTriple :: Parser (Int, Int, Int)
decimalTriple = (,,)
  <$> signed decimal <* char ' '
  <*> signed decimal <* char ' '
  <*> signed decimal <* endOfLine

decimalList :: Parser [Int]
decimalList = signed decimal `sepBy` char ' ' <* endOfLine

main :: IO ()
main = B.interact
  $ B.pack . show . either (error "parse err") solve . parseOnly input

solve :: Input -> Output
solve (_N, _M, _C, _Bs, _Ass) =
  length [ _As | _As <- _Ass, inner _As _Bs + _C > 0 ]

inner :: [Int] -> [Int] -> Int
inner xs ys = sum $ zipWith (*) xs ys

Measured memory_bytes: 892
#include <cstdio>
#include <queue>
#include <algorithm>
#include <iostream>
using namespace std;

int main(){
    long long a, b, c;
    cin >> a >> b;
    if((b - a)%2) printf("IMPOSSIBLE");
    else printf("%lld\n", (a+b)/2);


    return 0;
}


Measured memory_bytes: 256
import copy

def CakesandDonuts(n):

    ans = "No"
    a = copy.copy(n)

    if n % 7 == 0 or n % 4 == 0:
        ans = "Yes"
    else:
        while a > 0:
            n -= 7
            a -= 4
            if (n > 0 and n % 4 == 0) or (a > 0 and a % 7 == 0):
                ans = "Yes"

    return ans

def main():
    n = int(input())
    print(CakesandDonuts(n))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1LL << 60;



int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  string s;cin >> s;
  if(s=="SAT") cout << 1;
  if(s=="FRI") cout << 2;
  if(s=="THU") cout << 3;
  if(s=="WED") cout << 4;
  if(s=="TUE") cout << 5;
  if(s=="MON") cout << 6;
  if(s=="SUN") cout << 7;
  
  return 0;
}


Measured memory_bytes: 256
n, x, mod = map(int, input().split())

dp = [None]*mod

a = x
arr = [a]

for i in range(n-1):
  if dp[a] is not None:
    idx = arr.index(a)
    sum_early = sum(arr[:idx])
    cycle = i - idx
    sum_repeat = sum(arr[idx:-1])
    repeat_num = (n - idx) // cycle
    end_num = (n - idx) % cycle
    sum_end = sum(arr[idx:idx+end_num])
    ans = sum_early + sum_repeat*repeat_num + sum_end
    print(ans)
    exit()
  tmp = pow(a, 2, mod)
  dp[a] = tmp
  a = tmp
  arr.append(a)

print(sum(arr))

Measured memory_bytes: 69900
const bool submit = 1;
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) if(!submit) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
bool B(int x,int i){return (x>>i)&1;}
int N,V;
const int MN=200000;
const int MD=20;
int D;
int x_[MN];
int d[MN-1];
int xv2id[MN][MD];

const int MX=MN*MD;
int id2v[MX];
int id2l[MX];
int id2r[MX];
int I;


bool ans[MN];

int dp[1<<20];
int main(){
	cin>>N>>V;
	rep(i,N) cin>>x_[i];
	rep(i,N-1) d[i]=x_[i+1]-x_[i];
	rep(v,MD){
		int l=0;
		rep(x,N){
			if(x==N-1 || d[x]>V){
				for(int i=l;i<=x;i++) xv2id[i][v]=I;
				id2v[I]=v;
				id2l[I]=l;
				id2r[I]=x+1;

				// show(I);
				// show(v);
				// printf("(%d,%d]\n",l,x+1);
				// puts("");
				I++;
				l=x+1;
			}
		}
		if(V==0){
			D=v+1;
			break;
		}
		V/=2;
	}
	int K = xv2id[N-1][0]+1;

	if(K>D){
		rep(i,N){
			puts("Impossible");
		}
		return 0;
	}

	show(D);
	show(K);
	rep(elim,K){
		rep(b,1<<D) dp[b]=0;
		bool ok=0;
		rep(b,1<<D){
			int x = dp[b];
			if(x==N){
				ok=1;
				break;
			}
			rep(i,D) if(!B(b,i)){
				int id = xv2id[x][i];
				if(i==0&&id!=elim) continue;
				int nx=max(x,id2r[id]);
				chmax(dp[b|(1<<i)],nx);
			}
//			printf("dp[%d]=%d\n",b,dp[b]);
		}
		int l = id2l[elim];
		int r = id2r[elim];
		for(int x=l;x<r;x++) ans[x]=ok;
	}
	rep(i,N){
		if(ans[i]) puts("Possible");
		else puts("Impossible");
	}
}


Measured memory_bytes: 35968
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

long long N;
long long sx, sy, gx, gy;
long long x[1005];
long long y[1005];
long long r[1005];

vector<pair<double, int> >tree[1005];

int main(){
	cin >> sx >> sy >> gx >> gy;
	cin >> N;
	x[0] = sx;
	y[0] = sy;
	x[N+1] = gx;
	y[N+1] = gy;
	for(int i = 1; i <= N; i++){
		cin >> x[i] >> y[i] >> r[i];
	}


	for(int i = 0; i <= N + 1; i++){
		for(int j = 0; j <= N + 1; j++){
			double x1 = x[i];
			double y1 = y[i];
			double r1 = r[i];
			double x2 = x[j];
			double y2 = y[j];
			double r2 = r[j];
			double len = max(0.0, sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2)) - r1 - r2);
			tree[i].push_back(make_pair(len, j));
		}
	}

	/*
	for(int i = 0; i <= N + 1; i++){
		cout << "from " << i << endl;
		for(int j = 0; j < tree[i].size(); j++){
			cout << i << " -> " << tree[i][j].second << " : " << tree[i][j].first << endl;
		}
	}
	*/

	set<int> done;
	priority_queue<pair<double, int> , vector<pair<double, int> >, greater<pair<double, int> > > Q;

	Q.push(make_pair(0, 0));
	while(!Q.empty()){
		int dst = Q.top().second;
		double cost = Q.top().first;
		Q.pop();
		if(dst == N+1){
			printf("%.20f\n", cost);
			return 0;
		}
		if(done.count(dst) != 0){
			continue;
		}
		done.insert(dst);
		for(int i = 0; i < tree[dst].size(); i++){
			int next = tree[dst][i].second;
			double ncost = tree[dst][i].first;
			if(done.count(next) != 0){
				continue;
			}
			Q.push(make_pair(cost + ncost, next));
		}
	}
}


Measured memory_bytes: 24720
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[][] graph = new int[n][n];
      String[] vInfo;
      int degree;

      for(int i=0,v=0; i<n; i++) {
        vInfo = br.readLine().split(" ");
        degree = Integer.parseInt(vInfo[1]);
        for(int j=0,k=2; j<degree; j++) {
          v = Integer.parseInt(vInfo[k++]);
          graph[i][v-1] = 1;
        }
      }

      StringBuilder buf = new StringBuilder(n*n*2);
      for (int[] vertex : graph) {
        for (int v : vertex) {
          buf.append(v).append(" ");
        }
        buf.setLength(buf.length()-1);
        buf.append("\n");
      }

      System.out.print(buf);
    }
    catch (IOException e) {
      System.out.println("IOException!");
    }
  }
}


Measured memory_bytes: 25300
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
As = nl()

n_left = 0
n_right = 0
n_lefts = []
n_rights = []

p_left = 0
p_right = 0
p_lefts = []
p_rights = []

for i in range(1, N+1):
    if i % 2 > 0:
        n_left -= As[i-1]
        p_left += As[i-1]
        n_right -= As[N-1-i+1]
        p_right += As[N-1-i+1]
    else:
        n_left += As[i-1]
        p_left -= As[i-1]
        n_right += As[N-1-i+1]
        p_right -= As[N-1-i+1]

    n_lefts.append(n_left)
    p_lefts.append(p_left)
    n_rights.append(n_right)
    p_rights.append(p_right)
n_rights = n_rights[::-1]
p_rights = p_rights[::-1]

ress = []
for i in range(1, N+1):
    res = As[i-1]
    if i > 1:
        res += As[i-2]

    if i % 2 > 0:
        if i > 2:
            res += n_lefts[i - 3]
        if i <= N - 1:
            res += p_rights[i]
    else:
        if i > 2:
            res += p_lefts[i - 3]
        if i <= N - 1:
            res += n_rights[i]
    ress.append(str(res))

print(' '.join(ress))





Measured memory_bytes: 33920
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,k; cin>>n>>k;
    vector<int> p(n);
    rep(i,n) cin>>p[i];
    ll ans = 0;
    sort(p.begin(), p.end());
    rep(i,k) ans += p[i];
    cout << ans << '\n';
    return 0;
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    int n; string s; cin >> n >> s;
    cout << (count(all(s), 'R') > count(all(s), 'B') ? "Yes" : "No") << endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int n,m,q;
vector<int>a,b,c,d;
int result=0;

void dfs(vector<int> ca){
  if(ca.size() == n+1){
    int now = 0;
    rep(i, q) if(ca[b[i]] - ca[a[i]] == c[i])now += d[i];
    result = max(result, now);
    return;
  }

  ca.push_back(ca.back());
  while(ca.back()<=m){
    dfs(ca);
    ca.back()++;
  }
}

int main(){
  cin>>n>>m>>q;
  a=b=c=d=vector<int>(q);
  rep(i, q)cin>>a[i]>>b[i]>>c[i]>>d[i];

  dfs(vector<int>(1,1));

  cout<<result<<endl;

  return 0;
}

Measured memory_bytes: 3580
/*
author : seryu
title : ABC170B_"Crane and Turtle"
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }

void solve()
{
	int x, y;
	cin >> x >> y;
	rep(i, x+1)
	{
		int crane = i;
		int turtle = x-i;
		int legs = 2*crane + 4*turtle;
		if(legs == y)
		{
			cout << "Yes" << endl;
			return;
		}
	}
	cout << "No" << endl;
	return;	
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
 
int main(void){
    int i,j,a,b,c,d;
    c=100000000;
    d=0;
    char N[300000];
    int W[300000];
    
    scanf("%d",&a);
    scanf("%s",N);
    W[0]=N[0]=='W';
    for(i=1;i<a;i++){
        W[i]=W[i-1]+(N[i]=='W');
    }
    for(i=0;i<a;i++){
        if(i==0)d=0;
        else d=W[i-1];
        d+=a-W[a-1]-i+W[i]-1;
        if(d<c)c=d;
    }
    printf("%d\n",c);
    return 0;
}

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

//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
ll a[200001];
ll sum[200001];
int main() {
	// 오늘 할 것!  종만북 보기! 
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n;
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	sum[0] = a[0];
	for (int i = 1; i < n; i++)sum[i] = sum[i - 1] + a[i];
	ll ans = 1000000000 * 2;
	int l = 0;
	int r = 2;
	for (int i = 1; i < n - 1; i++) {
		while (l < i && abs((sum[i] - sum[l]) - sum[l]) > abs((sum[i] - sum[l + 1] - sum[l + 1])))l++;
		while (r < n - 1 && abs((sum[n - 1] - sum[r]) - (sum[r] - sum[i]))> abs((sum[n - 1] - sum[r + 1]) - (sum[r + 1] - sum[i])))r++;
		ll x = sum[l];
		ll y = sum[i] - sum[l];
		ll nx = sum[n - 1] - sum[r];
		ll ny = sum[r] - sum[i];
		ll Max = max({ x,y,nx }); Max = max({ Max,ny });
		ll Min = min({ x,y,nx }); Min = min({ Min,ny });
		ans = min({ ans,abs(Max - Min) });
	}
	cout << ans << '\n';

}


Measured memory_bytes: 3328
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int hugo(int j){
	if(j) return 1;
	else return -1;
}
int main(){
	int N;
	ll A[100001];
	int mnum=0;
	//ll dp[100001][2][2]={};
	ll sum=0,msum=0,psum=0;
	scan(N);
	rep(i,N){
		scan(A[i]);
		sum+=A[i];
		if(A[i]>0) psum+=A[i];
		else{
			msum+=A[i];
			mnum++;
		}
	}
	sort(A,A+N);
	if(A[0]>=0){
		prin(sum);
		return 0;
	}
	else if(A[N-1]<=0){
		if(N%2) prin(-sum+2*A[N-1]);
		else prin(-sum);
		return 0;
	}
	int mmax=lower_bound(A,A+N,0)-A-1,pmin=mmax+1;
	if(mnum%2==1){
		if(-A[mmax]>A[pmin]){
			prin(psum-msum-2*A[pmin]);
		}
		else{
			prin(psum-msum+2*A[mmax]);
		}
	}
	else{
		prin(psum-msum);
	}
	return 0;
}


Measured memory_bytes: 1024
a = input().split()
b = int(a[0])
c = int(a[1])

def Base_10_to_n(X, n):
	if (int(X/n)):
		return Base_10_to_n(int(X/n), n)+str(X%n)
	return str(X%n)

print(len(Base_10_to_n(b, c)))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n,fl=0;
    double z,y;
    cin>>n>>y>>z;
    double nx=1e6,x;
    for(int i=0;i<n;i++)
    {
        double a;
        cin>>a;
        x=y-(a*.006);
        if(abs(x-z)<nx)
        {
          fl=i;
          nx=abs(x-z);
        }
    }
    cout<<fl+1<<nl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>


using namespace std;
int main()
{
	string s;
	cin >> s;

	bool exist_different = false;

	for (int i = 0; i < s.size() - 1; i++) {
		for (int j = i + 1; j < s.size(); j++) {
			if (s[i] == s[j]) exist_different = true;
		}
	}

	if (exist_different) cout << "no" << endl;
	else cout << "yes" << endl;

	return 0;
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  
  int ans = 1;
  for(int i = 1; i < n; i++){
    if(s.at(i - 1) != s.at(i)) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int a = 0; a <= n; a+=4) {
			for(int b = 0; b <= n; b+=7) {
				if(a+b == n) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include<climits>
#include <string>
#include <map>
#include <set>
#include <list>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////
#define isIn(A,B) (0<=A&&A<H&&0<=B&&B<W)

ll H,W,MAX;
int coin[3333][3333];
ll bS[333][333],bSB[333][333];
ll S[3333][3333],BS[3333][3333];
ll ans;
ll i,j,k;

int main(){
    scanf("%lld%lld",&H,&W);
    MAX=H>W?H:W;
    fornum(i,0,H){
        char str[333];
        scanf("%s",str);
        fornum(j,0,W){
            if(str[j]=='#'){
                coin[i+1000][j+1000]=1;   
            }
        }
    }
    
    fornum(i,1,2000){
        fornum(j,1,2000){
            //BS[i+j+1000]++;
            //S[W+i-j-1+1000]++;
            BS[i][j]=BS[i-1][j-1]+(coin[i][j]?1:0);
            S[i][W-j+1999]=S[i-1][W-j+2000]+(coin[i][W-j+1999]?1:0);
        }
    }
    /*
    fornum(i,0,H){
        fornum(j,0,W){
            printf("%lld:%lld ",BS[i+1000][j+1000],S[i+1000][j+1000]);
        }
        printf("\n");
    }*/

    fornum(i,0,H){
        fornum(j,0,W){
            for(k=1;k<MAX*2;k++){
                if(coin[i+k+1000][j+1000]&&coin[i+1000][j+k+1000]){
                    ans+=S[i+1000][j-k+1000]-S[i-k+999][j+1001];
                    //printf("a%lld,%lld,%lld:%lld %lld\n",i,j,k,S[i+1000][j-k+1000],S[i-k+999][j+1001]);
                }
                if(coin[i-k+1000][j+1000]&&coin[i+1000][j-k+1000]){
                     ans+=S[i+k+1000][j+1000]-S[i+999][j+k+1001];
                     //printf("b%lld,%lld,%lld:%lld %lld\n",i,j,k,S[i+k+1000][j+1000],S[i+999][j+k+1001]);
                     //cout<<"a";
                    //ans+=BS[i+j+k+1000];
                }
                if(coin[i-k+1000][j+1000]&&coin[i+1000][j+k+1000]){
                    //ans+=S[W+i-j-1+k+1000];
                    //cout<<"b";
                    ans+=BS[i+k+999][j+999]-BS[i+1000][j-k+1000];
                    //printf("c%lld,%lld,%lld:%lld %lld\n",i,j,k,BS[i+k+1000][j+1000],BS[i+999][j-k+999]);
                }
                if(coin[i+k+1000][j+1000]&&coin[i+1000][j-k+1000]){
                    ans+=BS[i+999][j+k+999]-BS[i-k+1000][j+1000];
                    //printf("d%lld,%lld,%lld:%lld %lld\n",i,j,k,BS[i+1000][j+k+1000],BS[i-k+999][j+999]);
                    //cout<<"c";
                    //ans+=S[W+i-j-1-k+1000];
                }
            }
        }
    }

    printf("%lld\n",ans);
    
    return 0;
}

Measured memory_bytes: 112512
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int cnt1,cnt2;
vector<int>letak;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        char isi=s[i];
        if(isi=='B')letak.pb(i);
    }
    ll byk=letak.size();
    int idx=s.size()-1-byk+1;
    ll ans=0;
    for(auto isi:letak){
        ans+=(idx-isi);
        idx++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4380
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int n;
  cin >> n;
  vector<pii> p(n);
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    p[i] = make_pair(b,a);
  }
  SORT(p);
  ll t = 0;
  rep(i,n) {
    t += p[i].se;
    if (t > p[i].fi) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;  
  return 0;
}

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

int main() {
	int n, x, y;
	cin >> n >> x >> y;
	int d[2000][2000];
	//d[i][j] : i to j
	for (int i = 1; i <= n - 1; i++) {
		for (int j = i + 1; j <= n; j++) {
			if (i <= x && j <= x)
				d[i][j] = j - i;
			else if (i <= x && x <= j && j <= y)
				d[i][j] = x - i + min(j - x, y - j + 1);
			else if (i <= x && y <= j)
				d[i][j] = x - i + 1 + j - y;
			else if (x <= i && i <= y && x <= j && j <= y)
				d[i][j] = min(j - i, i - x + 1 + y - j);
			else if (x <= i && i <= y && y <= j)
				d[i][j] = min(y - i, i - x + 1) + j - y;
			else if (y <= i && y <= j)
				d[i][j] = j - i;
		}
	}
	vector<int> k(n);
	for (int i = 1; i <= n - 1; i++)
		for (int j = i + 1; j <= n; j++)
			k[d[i][j]]++;
	for (int i = 1; i <= n - 1; i++)
		cout << k[i] << endl;
	return 0;
}

Measured memory_bytes: 15872
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


int main() {
	ll x;
	cin >> x;

	vector<ll> bucket(2000,0);
	if (x == 1) {
		cout << 1 << endl;
		return 0;
	}
	for (int i = 2; i <= 31; i++) {
		for (int j = 2; j <= 9; j++) {
			int temp = pow(i, j);
			//cout << temp << endl;
			if (temp <= x)bucket[temp]++;
			else break;
		}
	}

	for (int i = 1200; i >= 0; i--) {
		if (bucket[i] > 0) {
			cout << i << endl;
			break;
		}
	}
	
	system("pause");
	return 0;
}

Measured memory_bytes: 632
fn main() {
    let mut sc = Scanner::new();
    let h: usize = sc.read();
    let w: usize = sc.read();
    let d: usize = sc.read();
    let a: Vec<Vec<usize>> = (0..h).map(|_| {
        (0..w).map(|_| sc.read()).collect()
    }).collect();

    let mut place = vec![(0, 0); h * w + 1];
    for i in 0..h {
        for j in 0..w {
            let x = a[i][j];
            place[x] = (i, j);
        }
    }

    let mut sum = vec![0; h * w + 1];

    for e in 1..(d + 1) {
        let mut cur = e;
        while cur + d <= h * w {
            let (fi, fj) = place[cur];
            let (ti, tj) = place[cur + d];
            let ei = if fi > ti { fi - ti } else { ti - fi };
            let ej = if fj > tj { fj - tj } else { tj - fj };

            sum[cur + d] = sum[cur] + (ei + ej);
            cur += d;
        }
    }


    let q: usize = sc.read();
    for _ in 0..q {
        let l: usize = sc.read();
        let r: usize = sc.read();
        let a = sum[r] - sum[l];
        println!("{}", a);
    }
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}



Measured memory_bytes: 7292
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ll a[100010], mxx[100010];
int main(){
    ll n;
    while(cin>>n){
        ll ans=0;
        bool l=1;
        mxx[0]=1;
        for(ll i=0; i<=n; ++i){
            scanf("%lld",a+i);
            // a[i]=0;
            if(i>0){
	            mxx[i]=mxx[i-1]*2-a[i];
	            if(mxx[i]<0){
	            	l=0;
	            }
	            mxx[i]=min(mxx[i], (ll)1e14);
            }
        }
        // a[n]=1;
        // ans=1;
        ll tmp;
        ll sm=0;
        for(ll i=n; i>=1; --i){
        	tmp=mxx[i-1];
        	ans+=a[i];
        	a[i]+=sm;
        	// if(a[i]>mxx[i-1]*2){
        	// 	l=0;
        	// 	break;
        	// }
        	// else{
        		ans+=min(tmp, a[i]);
        	// }
        	sm=min(tmp, a[i]);
        }
        if(a[0]>0){
        	l=0;
        }
        if(n==0){
        	if(a[0]==1){
        		l=1;
        		ans=1;
        	}
        	else{
        		l=0;
        	}
        }
        if(l==0){
        	printf("-1\n");
        }
        else{
        	printf("%lld\n",ans);
        }
    }
  return 0;
}




Measured memory_bytes: 5228
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main() {
    int n, a, b;
    scanf("%d\n", &n);
    if(n == 1){
        printf("Hello World");
    }else{
        scanf("%d%d\n", &a, &b);
        printf("%d\n", a+b);
    }
    return 0;
}


Measured memory_bytes: 384
#include <map>
#include <list>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
char s[5];
int ans=700;
int main()
{
	fast; 
	cin>>s;
	for (int i=0;i<=2;i++)
	   if (s[i]=='o')
	      ans+=100;
	cout<<ans; 
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
    int t[30];
    for(int i=0;i<30;i++)t[i]=i+1;
    int a,b;
    scanf("%d%d",&a,&b);
    for(int i=0;i<b;i++){
        int c,d;
        scanf("%d,%d",&c,&d);
        int s=t[c-1];
        t[c-1]=t[d-1];
        t[d-1]=s;
    }
    for(int i=0;i<a;i++)printf("%d\n",t[i]);
}


Measured memory_bytes: 2572
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=100010, LOG=20;

int n, m, k, u, v, a, b;
ll x, y, z, ans;
int col[MAXN];
vector<int> G[MAXN];

bool dfs(int node, int c){
	bool res=1;
	col[node]=c;
	for (int v:G[node]){
		if (!col[v]) res&=dfs(v, 3-c);
		else res&=(col[v]!=col[node]);
	}
	return res;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>m;
	while (m--){
		cin>>u>>v;
		G[u].pb(v);
		G[v].pb(u);
	}
	for (int i=1; i<=n; i++) if (!col[i]){
		if (G[i].empty()) x++;
		else if (dfs(i, 1)) y++;
		else z++;
	}
	//cerr<<x<<' '<<y<<' '<<z<<endl;
	ans=2*x*n-x*x+z*z+2*y*z+2*y*y;
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std;
int main(){
	char c;
	cin>>c;
	switch(c){
		case 'a':cout<<"vowel";return 0;
		case 'e':cout<<"vowel";return 0;
		case 'i':cout<<"vowel";return 0;
		case 'o':cout<<"vowel";return 0;
		case 'u':cout<<"vowel";return 0;
	}
	cout<<"consonant";
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const int MAXS = 114514;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    int n;
    cin>>n;
    vector<pair<int,int>> a(MAXS),b(MAXS);
    for(int i=0;i<MAXS;i++){
        a[i].first=0;
        a[i].second=i;
        b[i].first=0;
        b[i].second=i;
    }
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        x--;
        if(i&1)a[x].first++;
        else b[x].first++;
    }
    sort(All(a));
    sort(All(b));
    reverse(All(a));
    reverse(All(b));
    int res;
    if(a[0].second!=b[0].second){
        res=n-a[0].first-b[0].first; 
    }
    else{
        res=min(n-a[0].first-b[1].first,n-a[1].first-b[0].first);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 2048
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

int main(void) {
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	int ans=0;
	for (int i=a; i<b; i++) {
		if (i>=c && i<d) {
			ans++;
		//	cout<<i<<'\n';
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#define pb push_back
#define ll long long
#include<bits/stdc++.h>
using namespace std;
int cv(string s){
	int sign = 1, val = 0, i = 0;
	if(s[0] == '-'){
		sign = -1;
		i++;
	}
	while(i < s.size()){
		val = val * 10 + s[i] - '0';
		i++;
	}
	return sign * val;
}
int main(){
	string s;
	getline(cin, s);
	int n = s.size(), i = 0;
	stack<int> st;
	while(i < n){
		if(s[i] == ' '){
			i++;
			continue;
		}
		string tt = "";
		while(i < n && s[i] != ' ') tt += s[i++];
		if(tt[0] == '-'){
			int v1 = st.top(); st.pop();
			int v2 = st.top(); st.pop();
			st.push(v2 - v1);
		}else if(tt[0] == '+'){
			int v1 = st.top(); st.pop();
			int v2 = st.top(); st.pop();
			st.push(v2 + v1);
		}else if(tt[0] == '*'){
			int v1 = st.top(); st.pop();
			int v2 = st.top(); st.pop();
			st.push(v2 * v1);
		}else{
			st.push(cv(tt));
		}
	}
	cout << st.top() << endl;
	return 0;
}


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

#define all(v) (v).begin(), (v).end()
typedef long long LL;
using namespace std;

int ceil(LL numerator, LL denominator)
{
	return (numerator/denominator + (numerator%denominator != 0));
}

int possible(vector <LL> H, LL A, LL B, LL explosions)
{
	for(int i = 1; i < H.size(); i++)
	{
		H[i] -= (explosions*B);
	}

	LL explosions_used = 0;
	for(int i = H.size() - 1; i > 0 && H[i] > 0; i--)
	{
		explosions_used += ceil(H[i], A - B);
	}

	return (explosions_used <= explosions);
}

int main()
{
    int no_of_monsters, A, B;
    cin >> no_of_monsters >> A >> B;

    vector <LL> health(no_of_monsters + 1);
    for(int i = 1; i <= no_of_monsters; i++)
    	cin >> health[i];

    sort(all(health));

    int left = 1, right = 1e9;
    while(left <= right)
    {
    	int mid = (left + right) >> 1;

    	if(possible(health, A, B, mid))
    	{
    		if(mid == left || !possible(health, A, B, mid - 1))
    		{
    			cout << mid;
    			break;
    		}
    		else
    		{
    			right = mid - 1;
    		}
    	}
    	else
    	{
    		left = mid + 1;
    	}
    }
	return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define MOD 1000000007
#define INF 1000000000000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main()
{
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++)
	cin >> a[i];
	int s1=a[0],s2=a[n-1];
	int l=1,r=n-2;
	while(l<=r)
	{
		
		if(s2>s1)
		{
			s1=s1+a[l];
			l++;
		}
		else
		{
			s2=s2+a[r];
			r--;
		}
	}
	cout << abs(s2-s1);
}


Measured memory_bytes: 256
#include <stdio.h>

void p(int A[],int n){
    int i;
    for (i = 0; i < n; i++) {
        if (i != 0) putchar(' ');
        printf("%d", A[i]);
    }
    putchar('\n');
}

int main(){
    int n, A[100], i, j, min, c = 0, swap;
    scanf("%d", &n);
    for (i = 0;i < n;i++) scanf("%d", A + i);
    for (i = 0;i < n; i++) {
        min = i;
        for (j = i;j < n; j++) if (A[j] < A[min]) min = j;
            if (i != min){
                swap = A[i];
                A[i] = A[min];
                A[min] = swap;
                c++;
            }
    }
    p(A, n);
    printf("%d\n", c);
    return 0;
}

Measured memory_bytes: 604
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        int max = Integer.MAX_VALUE;
        for(int i = 0; i < n; i++){
            int p = sc.nextInt();
            if(max > p){
                ans++;
                max = p;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 64928
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vll x(n),y(n),h(n);
    REP(i,n){
        cin >> x[i] >> y[i] >> h[i];
    }
    for(int cx = 0;cx<=100;cx++){
        for(int cy = 0;cy<=100;++cy){
            ll hig = 0;
            bool f = true;
            REP(i,n){
                if(h[i]>0){
                    if(hig==0){
                        hig=h[i]+abs(cx-x[i])+abs(cy-y[i]);
                    }else if(hig!=h[i]+abs(cx-x[i])+abs(cy-y[i])){
                        f=false;
                        break;
                    }
                }
            }
            if(!f){
                continue;
            }
            REP(i,n){
                ll hi = max(hig-abs(x[i]-cx)-abs(y[i]-cy),0LL);
                if(hi!=h[i]){
                    f=false;
                    break;
                }
            }
            if(f){
                cout << cx << " " << cy << " " << hig << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(int argc, char const* argv[])
{
    int K, N;
    cin >> K >> N;

    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    sort(A.begin(), A.end());
    ll ans = K + A[0] - A[N-1];
    for (int i = 1; i < N; i++) {
        ans = max(ans, abs(A[i] - A[i-1]));
    }

    cout << K - ans << endl;

    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

class Main{
  public static void main(String args[]){
	  Scanner s = new Scanner(System.in);
	  int a = s.nextInt();
	  int b = s.nextInt();
	  int c = s.nextInt();

	  if (a < b && b < c) 
		  System.out.println("Yes");
	  else
		  System.out.println("No");
	  s.close();
  }
}


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

using namespace std;

int main() {
//	freopen("1.in", "r", stdin);
	int n;
	scanf("%d", &n);
	vector<int> a;
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		a.push_back(x);
	}
	int pre = 0;
	long long ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (a[i] > i || a[i] < pre) {
			printf("-1\n");
			return 0;
		}
		if (a[i] != pre) {
			ans += 1LL * a[i];
		}
		pre = a[i] - 1;
	}
	printf("%lld\n", ans);
	return 0;
}


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    string s;
    cin >> s;
    if(s[0]=='9' || s[1]=='9') cout << "Yes" << "\n";
    else cout << "No" << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

int main() {
    cin>>N;
    cout<<(N >= 30 ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(20);

	ll R;
	cin >> R;

	cout << (double)R * 2 * 3.14159265358979323846264338327950288 << endl;
}


Measured memory_bytes: 3804
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      n: usize,
      ab: [(usize, usize); n],
      cd: [(usize, usize); n],
   }
   let mut dot = vec![((0, 0), 0); 2 * n];
   for i in 0..n {
      dot[i] = (ab[i], 0);
      dot[n + i] = (cd[i], 1);
   }
   dot.sort();

   let mut ans = 0;
   let mut red = BTreeSet::new();
   for &((_, y), c) in dot.iter() {
      if c == 0 {
         red.insert(y);
      } else if let Some(&r) = red.range(..y).rev().next() {
         red.remove(&r);
         ans += 1;
      }
   }
   println!("{}", ans);
}


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

int main(){
  long long int a;
  double b;
  long long ans = 1;

  cin >> a >> b;

  long long int ib = b * 100 + 0.5;

  ans = a * ib;
  ans /= 100;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3728