akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=110;
const int mod=1e9+7;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,a[N],f[N][N][2];
vector<pii> line[N];
int qpow(int a,int b) {
    int ret=1;
    while(b) {
        if(b&1) ret=1ll*ret*a%mod;
        a=1ll*a*a%mod,b>>=1;
    }
    return ret;
}
void solve(int l,int r,int h) {
    if(l>r) return;
    int mn=inf+1,k=0;
    for(int i=l;i<=r;i++) if(chkmin(mn,a[i])) k=i;
    //cerr<<l<<" "<<r<<" "<<qpow(2,mn-h)<<endl;
    line[r].pb(mp(l,qpow(2,mn-h)));
    solve(l,k-1,mn),solve(k+1,r,mn);
}
int main() {
    n=gi();
    for(int i=1;i<=n;i++) a[i]=gi();
    solve(1,n,1);
    if(line[1].empty()) f[1][1][0]=f[1][1][1]=1;
    else f[1][1][0]=f[1][1][1]=line[1][0].se;
    for(int i=1;i<n;i++)
        for(int j=1;j<=n;j++)
            for(int k=0;k<2;k++) {
                if(!f[i][j][k]) continue;
                int nxt=f[i][j][k];
                for(pii x:line[i+1]) if(x.fi>=j) nxt=1ll*nxt*x.se%mod;
                inc(f[i+1][j][k^1],nxt);
                nxt=f[i][j][k];
                for(pii x:line[i+1]) if(x.fi>=i+1) nxt=1ll*nxt*x.se%mod;
                inc(f[i+1][i+1][k],nxt);
            }
    int ans=0;
    for(int j=1;j<=n;j++)
        for(int k=0;k<2;k++) inc(ans,f[n][j][k]);
    printf("%d\n",ans);
    return 0;
}


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

//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define FI ios_base::sync_with_stdio(0); cin.tie(NULL);

#define LL long long

const int INF = 1e9 + 9;
const int MX = 1e5 + 5;

LL multiply(LL a, LL b, LL mod)
{
        LL res = 0;
        while(b > 0)
        {
                int lastdigit = b & 1;
                if(lastdigit > 0)
                        res = (res + a)%mod;
                a = (a + a)%mod;
                b = b >> 1;
        }
        return res;
}

int main() {
	LL x, k, d;
	cin >> x >> k >> d;
	x = abs(x);

	LL mod = 2 * d;

	if(k <= x/d) {
		//+ve
		cout << x - k*d << endl;
	} else {
		//-ve
		LL c = x%mod - multiply(k, d, mod);
		c = (c + mod)%mod;

		LL ans = min(c, mod - c);

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


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n, k;
    cin >> n >> k;
    cout << (n-k+1) << endl;
    return 0;
}


Measured memory_bytes: 3552
n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())

s = sorted(a)

max1 = s[-1]
max1_ind = a.index(max1)
max2 = s[-2]

# print(max1, max2)

for i in a:
    if i is a[max1_ind]:
        print(max2)
    else:
        print(max1)


Measured memory_bytes: 14096
#include <stdio.h>

int main()
{
	int x, y;
	int t;

	for (;;) {
		scanf("%d%d", &x, &y);
		if (x == 0 && y == 0) break;
		if (x > y) t = x, x = y, y = t;
		printf("%d %d\n", x, y);
	}
	return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    i32 n; cin >> n;
    string reply, L;

    cout << 0 << endl;
    fflush(stdout);
    cin >> L;
    if(L=="Vacant") return 0;

    i32 l = 0, mid, r = n;
    while(r-l > 1) {
        mid = (r+l)/2;
        cout << mid << endl;
        fflush(stdout);

        cin >> reply;
        if(reply == "Vacant") return 0;
        if((mid&1) ^ reply==L) l = mid;
        else r = mid;
    }

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 980
#include<stdio.h>
int main()
{
	long int n, s = 0, nn;
	scanf("%ld", &n);
	nn = n;
	while (n > 0)
	{
		s += n % 10;
		n /= 10;
	}
	if (nn%s == 0)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
N, K = gets.split.map(&:to_i)
xs, ys = [], []
N.times do |i|
    xs[i], ys[i] = gets.split.map(&:to_i)
end

xss = xs.sort
yss = ys.sort

accum = Array.new(N){Array.new(N, 0)}
N.times do |i|
    x = xss.find_index(xs[i])
    y = yss.find_index(ys[i])
    accum[x][y] = 1
end

(N - 1).times do |i|
    N.times do |j|
        accum[i + 1][j] += accum[i][j]
    end
end

(N - 1).times do |i|
    N.times do |j|
        accum[j][i + 1] += accum[j][i]
    end
end


amin = Float::INFINITY

N.times do |i1|
    ((i1+1)...N).each do |i2|
        N.times do |j1|
            ((j1+1)...N).each do |j2|
                left = xss[i1]
                right = xss[i2]
                bottom = yss[j1]
                top = yss[j2]
                a = (right - left) * (top - bottom)
                next if amin <= a

                sum = accum[i2][j2]
                sum -= accum[i2][j1 - 1] if j1 > 0
                sum -= accum[i1 - 1][j2] if i1 > 0
                sum += accum[i1 - 1][j1 - 1] if j1 > 0 && i1 > 0

                amin = a if sum >= K
            end
        end
    end
end

print amin

Measured memory_bytes: 1788
N=int(input())
inp=input().split()
x=[]
for k in range(N):
  x.append(int(inp[k]))
minim=10**6+1 
for i in range(1,101):
  cost=0
  for j in range(N):
    cost+=(x[j]-i)**2
  if cost<minim:
    minim=cost
print(minim)    

Measured memory_bytes: 3060
def selection_sort(num_list):
    list_length = len(num_list)
    cnt = 0
    
    for i in range(list_length):
        min_element = i
        for j in range(i+1,list_length):
            if num_list[j] < num_list[min_element]:
                min_element = j
        if i != min_element:
            num_list[i],num_list[min_element] = num_list[min_element],num_list[i]
            cnt += 1
    return num_list,cnt

n = int(input())
num_list = list(map(int,input().split()))
ans_list,cnt = selection_sort(num_list)
str_ans_list = [str(i) for i in ans_list]
print('{}\n{}'.format(' '.join(str_ans_list),cnt))


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

typedef long long ll;

const int Maxn = 200005;

int n;
ll k;
int a[Maxn];
int nxt[Maxn];
int fir[Maxn];
int tim[Maxn];
vector <int> res;

void Solve(int v, ll cur, ll k)
{
    while (cur < k) {
        int jump = nxt[v] <= v? 1: 0;
        int u = (nxt[v] + 1) % n;
        if (cur + jump < k) {
            if (u == 0) jump++;
            cur += jump; v = u;
        } else {
            res.push_back(a[v]);
            if (v == n - 1) cur++;
            v = (v + 1) % n;
        }
    }
    for (int i = 0; i < res.size(); i++)
        printf("%d%c", res[i], i + 1 < res.size()? ' ': '\n');
}

int main()
{
    scanf("%d %lld", &n, &k);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    for (int i = 0; i < Maxn; i++)
        fir[i] = n;
    for (int i = n - 1; i >= 0; i--) {
        nxt[i] = fir[a[i]];
        fir[a[i]] = i;
    }
    for (int i = 0; i < n; i++)
        if (nxt[i] == n) nxt[i] = fir[a[i]];
    if (k <= 2 * n + 10) Solve(0, 0, k);
    else {
        for (int i = 0; i < Maxn; i++)
            tim[i] = Maxn;
        int v = 0, cur = 0;
        while (tim[v] == Maxn) {
            tim[v] = cur;
            int jump = nxt[v] <= v? 1: 0;
            if (nxt[v] == n - 1) { jump++; v = 0; }
            else v = nxt[v] + 1;
            cur += jump;
        }
        ll my = (k - 1 - tim[v]) / (cur - tim[v]) * (cur - tim[v]);
        Solve(v, my, k);
    }
    return 0;
}


Measured memory_bytes: 4980
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef complex<double> xy_t;
typedef vector<lint> poly;

const lint mod = 1e9 + 7;
const lint INF = mod * mod;

int main(){
    int n;
    scanf("%d", &n);
    lint bm = INF, sum = 0;
    rep(i, n){
        lint a, b;
        scanf("%lld%lld", &a, &b);
        if(a > b) bm = min(bm, b);
        sum += a;
    }
    printf("%lld\n", bm < INF ? sum-bm : 0);
}

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

int main()
{
	while (true) {
	int a, b;
	char op;
	cin >> a >> op >> b;
	if (op == '+') cout << a + b << endl;
	if (op == '-') cout << a - b << endl;
	if (op == '*') cout << a * b << endl;
	if (op == '/') cout << a / b << endl;
	if (op == '?') break;
	}
	return 0;
}

Measured memory_bytes: 3008
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
using namespace std;
using ll = long long;
vector<ll> memo(100001,-1);

ll dfs(ll N){
    if(N<=0)return 0;
    if(memo[N]>=0)return memo[N];
    ll _min=999999999;
    _min = min(_min,dfs(N-1)+1);
    // cout<<"N:"<<N<<endl;
    for(ll i=1;pow(6,i)<=N;i++){
        _min = min(_min,dfs(N-pow(6,i))+1);
        // cout<<_min<<endl;
    }
    for(ll i=1;pow(9,i)<=N;i++){
        _min = min(_min,dfs(N-pow(9,i))+1);
    }
    memo[N] = _min;
    return _min;
}

int main(){
    ll N;
    cin>>N;
    ll res = dfs(N);
    cout<<res<<endl;


}
 

Measured memory_bytes: 5760
#include <stdio.h>

int main(void){
  int x,a,b,c;
  int i,j,k;
  int X;
  int counta=0;
  //read input
  scanf("%d %d %d %d",&a,&b,&c,&x);
  X=x/50;
  for(i=0;i<=a;i++){
    for(j=0;j<=b;j++){
      for(k=0;k<=c;k++){
	if((X-(10*i+2*j))==k)
	  counta++;
      }
    }
  }
  printf("%d",counta);
    
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	int a, b;
	cin >> a >> b;
	int c = b - a;
	cout << c*(c+1)/2-b;
}

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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

  string s;
  cin >> s;

  cout << (s == "ABC" ? "ARC" : "ABC") << '\n';




  
  return 0;
}

Measured memory_bytes: 3568
import numpy as np
N = int(input())
S = input()

l_r = []
l_g = []
l_b = []
for i in range(N):
  if S[i]=='R':
    l_r.append(i)
  if S[i]=='G':
    l_g.append(i)
  if S[i]=='B':
    l_b.append(i)
    
l_r = set(l_r)
l_g = set(l_g)
l_b = set(l_b)

ans = len(l_r)*len(l_g)*len(l_b)

for r in l_r:
  for g in l_g:
    mi = min(r, g)
    ma = max(r, g)
    l = ma - mi
    if ma+l in l_b:
      ans -= 1
    if mi-l in l_b:
      ans -= 1
    if l%2==0 and l//2 + mi in l_b:
      ans -= 1

print(ans)

Measured memory_bytes: 27208
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] v = new int[n];
        int ans = 0;
        for (int i = 0; i < n; i++) {
            v[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            int c = sc.nextInt();
            if (v[i] > c) {
                ans += v[i] - c;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
/*
#include<algolithm>
#include<array>
#include<vector>
*/
using namespace std;

typedef double Real;
constexpr Real EPS = 1e-8;

int sign(Real d) {
	if (d>EPS) { return 1; }
	if (d<-EPS) { return -1; }
	return 0;
}

struct Point {
	Real x,y;

	Point(Real x_=0, Real y_=0): x(x_), y(y_) {}

	Point operator+(const Point &p) const {
		return Point(x+p.x,y+p.y);
	}
	Point operator-(const Point &p) const {
		return Point(x-p.x,y-p.y);
	}
	Point operator*(Real s) const {
		return Point(x*s,y*s);
	}
	Point operator/(Real s) const {
		return Point(x/s,y/s);
	}
	Point operator<(const Point &p) const {
		return sign(x - p.x) == -1 || (sign(x - p.x)==0 && sign(y - p.y)==-1);
	}
	Point operator==(const Point &p) const { return sign(x-p.x) == 0 && sign(y - p.y)==0; }

};

istream &operator>>(istream &is, Point &p) {
	return is >> p.x >> p.y;
}
ostream &operator<<(ostream &os, const Point &p) {
	return os << '(' << p.x << ", " << p.y << ')';
}

struct Line : public array<Point, 2> { //??????
	Line(const Point &a, const Point &b) { at(0) = a; at(1) = b; }
};

struct Segment : public array<Point, 2> { //??´???
	Segment(const Point &a, const Point &b) { at(0) = a; at(1) = b; }
};

struct Circle {
	Point c;
	Real r;
	Circle(const Point &c_, Real r_): c(c_), r(r_) {}
};

typedef vector<Point> Polygon;




//--- solve ---
Point rotate90(const Point &p) { //???????¨???????
	return Point(-p.y,p.x);
}

Point rotate(const Point &p, Real theta) {
	const Real s = sin(theta), c = cos(theta);
	return Point(c*p.x - s*p.y, s*p.x + c*p.y);
}

Real angle(const Point &p) {
	return atan2(p.y, p.x);
}

Real norm(const Point &p) {
	return p.x * p.x + p.y * p.y;
}

Real abs(const Point &p) {
	return sqrt(norm(p));
}

Real dot(const Point &a, const Point &b) { //??????
	return a.x * b.x + a.y * b.y;
}

Real cross(const Point &a, const Point &b) {
	return a.x * b.y + a.y * b.x;
}

Point project(const Line &l, const Point &p) { //?°???±
	const Point a = p - l[0];
	const Point b = l[1] - l[0];
	return l[0] + b * (dot(a,b) / norm(b));
}

Point reflect(const Line &l, const Point &p) { //?°???±
	const Point t = project(l, p);
	return t + (t-p);
}


bool intersect(const Line &a, const Line &b) { //
	return sign(cross(a[1]-a[0], b[1]-b[0])) != 0
		|| sign(cross(a[1]-a[0], b[1]-a[0])) == 0;
}

int main() {
	Point p1,p2;
	int q;
	int x,y;

	cout.setf(ios::fixed);
	cout.precision(10);
	cin >> p1.x >> p1.y >> p2.x >> p2.y;
	Line l(p1,p2);
	cin >> q;
	for(int i=0; i < q; i++) {
		Point p;
		cin >> p.x >> p.y;
		Point ans_p = reflect(l,p);
		cout << ans_p.x << " " << ans_p.y << endl;
	}

	return EXIT_SUCCESS;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    int N; cin>>N;
    vector<ll> L(N);
    rep(i,N)cin>>L.at(i);
    sort(L.begin(),L.end());
    ll res = 0;
    rep(i,N-2){
        for(int j = i+1; j < N-1; j++){
            if(L.at(i)==L.at(j))continue;
            for(int k = j+1; k < N; k++){
                if(L.at(i)==L.at(k)||L.at(j)==L.at(k))continue;
                if(L.at(i)+L.at(j)>L.at(k)&&L.at(i)+L.at(k)>L.at(j)&&L.at(k)+L.at(j)>L.at(i))res++;
            }
        }
    }
    cout<<res<<endl;
}

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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  int ans = N;
  for (int i = 1; i < N; i++) {
    if (S.at(i - 1) != S.at(i)) ans = min(ans, max(i, N - i));
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3756
#include <iostream>
int main(){
	int S;
	std::cin>>S;

	int h;
	int m;
	int s;

	h=S/3600;
	m=(S-3600*h)/60;
	s=S-((h*3600)+(m*60));

	std::cout<<h<<":"<<m<<":"<<s<<std::endl;
}


Measured memory_bytes: 3100
#include <iostream>

int main()
{
    int number;
    std::cin >> number;

    int price[number];
    for (int i = 0; i < number; i++) {
        std::cin >> price[i];
    }

    int maximum = price[1] - price[0];
    int low_index = 0;
    int high_index = 1;
    for (int i = 0; i < number; i++) {
        if (price[low_index] < price[i]) {
            continue;
        }
        for (int j = i + 1; j < number; j++) {
            if (price[j] < price[high_index] && i < high_index) {
                continue;
            }

            if (maximum < price[j] - price[i]) {
                maximum = price[j] - price[i];
                high_index = j;
                low_index = i;
            }
        }
    }
    std::cout << maximum << std::endl;
}



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

int main(){
	int a, b, c, num;
	cin >>num;
	
	
	for(int i = 0; i < num; i++){
		cin >>a >>b >>c;
		a *= a;
		b *= b;
		c *= c;
		if(a == b + c || b == a + c || c == a + b) cout <<"YES"<<endl;
		else cout <<"NO"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;

int main () {
	string n;
	int end;
	
	getline(cin,n);
	
	for ( int i = 0; i < n.size(); i++ ) {
		if ( n[i] >= 'a' && n[i] <= 'z' ) {
			n[i] = n[i] + 'A' - 'a';
		}
	}
	cout << n <<  endl;
	return 0;
}

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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	LL K,A,B; cin >> K >> A >> B;
	if(A+2 > B || K < A) cout << K+1 << endl;
	else cout << A+(K-(A-1))/2*(B-A)+(K-(A-1))%2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007ll;
int main(){
	int n,k;
	std::cin >> n>>k;
	std::vector<int> h(n);
	rep(i,n)std::cin >> h[i];
	sort(all(h));
	std::cout << n-(int)(lb(all(h),k)-h.begin()) << std::endl; 
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int long long

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N, A[300000]; cin >> N;
  int onecnt[62] = {}, zerocnt[62] = {};

  REP(i, N){
  	cin >> A[i];
  	REP(j, 62){
      if((A[i]>>j) & 1ll) onecnt[j]++;
      else zerocnt[j]++;
  	}
  }

  // REP(i, N) for(int j = i+1; j < N; j++){
  //   hoge += A[i]^A[j]; hoge %= MOD;
  // }
  // cerr << hoge << endl;

  int ans = 0;
  REP(i, 62){
    ans += ((((1ll<<i) % MOD) * zerocnt[i]%MOD) * onecnt[i]%MOD);
    ans %= MOD;
  }
  cout << ans << endl;
}

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

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795

ll no_of_div(ll a)
{
  ll cnt=0,i;
  if (a==2)return 1;
  for(i=2;i*i<a;i++)
  {
if(a%i==0)cnt+=2;
  }
  if(i*i==a)cnt++;
  return cnt;
}

//vl a(1001);

ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}





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

ll n;cin>>n;
cout<<"ABC"<<n<<"\n";
  return 0;


}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a, b, c, X;
	scanf("%d %d %d", &a, &b, &c);
	if(a > b)
	{
		X = a;
		a = b;
		b = X;
	}
	if(b > c)
	{
		X = b;
		b = c;
		c = X;
	}
	if(a > b)
	{
		X = a;
		a = b;
		b = X;
	}
		printf("%d %d %d\n", a, b, c);
	return 0;
}


Measured memory_bytes: 2104
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


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

Left = [A[0]]
for i in range(N-1):
    Left.append(gcd(Left[i], A[i+1]))

Right = [A[N-1]]
for i in range(N-1):
    Right.append(gcd(Right[i], A[N-2-i]))
Right.reverse()

ans_list = []
ans_list.append(Right[1])
for i in range(1, N-1):
    ans_list.append(gcd(Left[i-1], Right[i+1]))
ans_list.append(Left[N-2])

print(max(ans_list))

Measured memory_bytes: 20684
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 1e6 + 1;

int n, nxt[26];
int tr[N], tnx[N][26];
int dp[N];
string s;

int32_t main() { cin.tie(0)->sync_with_stdio(0);
  cin >> s;
  n = s.size();
  s = ' ' + s;
  for (int i = 1; i <= n; i++) {
    s[i] -= 'a';
  }
  memset(dp, 0x3f, sizeof dp);
  memset(nxt, -1, sizeof nxt);
  dp[0] = 0;
  for (int i = n; i >= 1; i--) {
    nxt[s[i]] = i;
    for (int c = 0; c < 26; c++) {
      dp[i] = min(dp[i], dp[nxt[c] + 1] + 1);
      tnx[i][c] = nxt[c];
    }
    for (int c = 0; c < 26; c++) {
      if (dp[i] == dp[nxt[c] + 1] + 1) {
        tr[i] = c;
        break;
      }
    }
  }
  int mn = dp[1], i = 1;
  string ans;
  while (mn) {
    ans += tr[i] + 'a';
    i = tnx[i][tr[i]] + 1;
    mn = dp[i];
  }
  cout << ans;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String line;
		int[][] c = new int[][] { { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 }, { 0, 3, 6 }, { 1, 4, 7 }, { 2, 5, 8 }, { 0, 4, 8 }, { 2, 4, 6 } };
		while ((line = bf.readLine()) != null) {
			char[] b = line.toCharArray();
			boolean f = false;
			char k = 'o';
			for (int i = 0; i < c.length; i++) {
				if (b[c[i][0]] == k && b[c[i][1]] == k && b[c[i][2]] == k) {
					System.out.println(k);
					f = true;
					break;
				}
			}
			if (f)
				continue;
			k = 'x';
			for (int i = 0; i < c.length; i++) {
				if (b[c[i][0]] == k && b[c[i][1]] == k && b[c[i][2]] == k) {
					System.out.println(k);
					f = true;
					break;
				}
			}
			if (!f)
				System.out.println('d');
		}
	}
}

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

int main(){
  int N; cin >> N;
  long long A[200000];
  for(int i=0; i<N; i++){
    cin >> A[i];
    A[i]-=i;
  }
  sort(A,A+N);
  long long mid=A[N/2];
  long long kanashisa=0;
  for(int i=0; i<N; i++){
    kanashisa+=abs(A[i]-mid);
  }
  cout << kanashisa << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() 
{
    int l,r,d;
    cin>>l>>r>>d;

    int count=0;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0)
        {
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<lint, lint> pi;
const int MAXN = 40005;

int n, a[305][305];

int main(){
	cin >> n;
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			cin >> a[i][j];
		}
	}
	lint ret = 0;
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			bool rep = 0;
			for(int k=0; k<n; k++){
				if(a[i][j] > a[i][k] + a[k][j]){
					puts("-1");
					return 0;
				}
				if(i != k && k != j && a[i][j] == a[i][k] + a[k][j]){
					rep = 1;
				}
			}
			if(!rep) ret += a[i][j];
		}
	}
	cout << ret /2<< endl;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
using namespace std;
//using namespace __gnu_pbds;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long 
#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,arr,n) for(int i=arr;i<=n;i++)
#define repd(i,arr,n) for(int i=arr;i>=n;i--)
#define trav(arr,x) for(auto& arr:x)
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(arr) arr.size()
#define pi 3.14159265358979323846
#define MAX 500003
#define vi vector<int>
#define pii pair<int,int>
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int,vi,greater<int> >
//#define endl "\n"
 
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const int mod=998244353;
int power(int a,int b)
{
    int ans=1;
    while(b)
    {
        if(b&1)
        {
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b>>=1;
    }
    return ans;
}

int32_t main()
{
    fast;
    int cnt=0;
    string s,t;
    cin>>s>>t;

    rep(i,sz(s))
    {
        if(s[i]!=t[i])cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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

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

int main(){
    int h, w; cin >> h >> w;
    int k; cin >> k;
    vector<vector<char>> data(h,vector<char>(w));
    rep(i,h) rep(j,w) cin >> data[i][j];

    int ans = 0;
    rep(i,1<<h) rep(j,1<<w){
        vector<bool> re(h,false);
        rep(k,h) if(i & 1<<k) re[k] = true;
        vector<bool> gyo(w,false);
        rep(k,w) if(j & 1<<k) gyo[k] = true;

        int count = 0;
        rep(ii,h) rep(jj,w) if(!re[ii] && !gyo[jj] && data[ii][jj] == '#') count++;
        if(count == k) ans++;
    }
    cout << ans << endl;
}

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

int main(void)
{
  char ch[10];
  gets(ch);
  if(!strcmp(ch,"Sunny"))
    printf("Cloudy\n");
  else if(!strcmp(ch,"Cloudy"))
    printf("Rainy\n");
  else if(!strcmp(ch,"Rainy"))
    printf("Sunny\n");

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
    int n,a[105]={};
    int alice=0,bob=0;

    cin>>n;
    rep(i,0,n){
        cin>>a[i];
    }
    sort(a,a+n);
    reverse(a,a+n);

    rep(i, 0, n){
        if(i%2==0){
            alice+=a[i];
        }else{
            bob+=a[i];
        }
    }
    
    cout<<alice-bob<<endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        ArrayList<Integer> a = new ArrayList<Integer>();
        for (int i = 0; i < 10; i++) {
            a.add(sn.nextInt());
        }
        Collections.sort(a);
        for (int i = 0; i < 3; i++) {
            System.out.println(a.get(a.size() - i - 1));
        }
    }
}

Measured memory_bytes: 17176
#include<cstdio>
#include<cstring>

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

using namespace std;

int main(){
	for(int n;scanf("%d",&n),n;){
		int pt[30]={};
		rep(i,30) pt[i]=n+1;

		char name[20][11];
		int m[20],d[20][30];
		rep(i,n){
			scanf("%s%d",name[i],m+i);
			rep(j,m[i]){
				scanf("%d",d[i]+j);
				pt[d[i][j]]--;
			}
		}

		int ans,ians;
		rep(i,n){
			int sum=0;
			rep(j,m[i]) sum+=pt[d[i][j]];
			if(i==0 || ans>sum || ans==sum && strcmp(name[ians],name[i])>0){
				ans=sum;
				ians=i;
			}
		}
		printf("%d %s\n",ans,name[ians]);
	}

	return 0;
}

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

using namespace std;

#define cerr if(false)cerr
#define what(x) cerr<<#x<<" = "<<x<<endl
 
typedef long long ll;
typedef pair<ll, ll> ii;

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 322;

vector<int> primes;

void fact(ll x){
	for(ll i = 2; i * i <= x; i++){
		if(x % i == 0){
			int cont = 0;
			while(x % i == 0){
				x /= i;
				++cont;
			}
			primes.push_back(cont);
		}
	}
	if(x > 1)
		primes.push_back(1);
}

int main(){

	ios_base::sync_with_stdio(false); 
	cin.tie(0);
	cout.tie(0);


	ll x;
	cin >> x;
	ll max_ans = 0;
	fact(x);
	for(int i = 0; i < primes.size(); i++){
		ll ans = 0;
		for(ll j = 1; j < x; j++){
			if((j * (j+1) / 2) > primes[i]){
				break;
			}
			ans = j;
		}
		max_ans += ans;
	}

	cout << max_ans << endl;

	return 0;
}

Measured memory_bytes: 3628
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int K = sc.nextInt();
	if(K%2 == 0) {
	    System.out.println((K/2)*(K/2));
	} else {
	    System.out.println(((K+1)/2)*(K/2));
	}
    }
}

Measured memory_bytes: 23124
#include <stdio.h>
#define MAX 1000000000

int count,n,L[MAX/20],R[MAX/20];

void merge(int A[],int left,int mid,int right){
  int i,k;
  int n1 = mid - left;
  int n2 = right - mid;
  
  for(i=0;i<n1;i++)
    L[i] = A[left+i];
  for(i=0;i<n2;i++)
    R[i] = A[mid+i];
  
  L[n1] = MAX;
  R[n2] = MAX;
  int j=0;
  i = 0;
  
  for(k=left;k<right;k++){
    count++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(int A[], int left, int right){
  int mid;
  if(left+1 < right){
    mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main(){
  int i,S[500000];

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);

  mergeSort(S,0,n);

  for(i=0;i<n-1;i++){
    printf("%d",S[i]);
    printf(" ");
  }
  printf("%d\n%d\n",S[i],count);

  return 0;
}


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

using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace
#define fi first
#define se second

#define all(n) (n).begin(), (n).end()
#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);	
    //cout << setprecision(15);
    ll n;
    cin >> n;
    set<ll> s;
    FOR(i, n)
    {
        ll x;
        cin >> x;
        s.emp(x);
    }
    if (n == s.size()) cout << "YES\n";
    else cout << "NO\n";
}



Measured memory_bytes: 9600
N = int(input())
AC =[]
WA =[]
TLE =[]
RE =[]

for i in range(N):
    s = str(input())
    if s == "AC":
        AC.append(s)
    elif s == "WA":
        WA.append(s)
    elif s == "TLE":
        TLE.append(s)
    elif s =="RE":
        RE.append(s)
print("AC x "+str(len(AC)))
print("WA x "+str(len(WA)))
print("TLE x "+str(len(TLE)))
print("RE x "+str(len(RE)))


Measured memory_bytes: 16576
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
 
int main() {
  char S ; 
  cin >> S ;
  if( S == 'A' )cout << 'T' << endl ;
  if( S == 'T' )cout << 'A'<< endl ;
    if( S == 'G' )cout << 'C'<< endl ;
      if( S == 'C' )cout << 'G'<< endl ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define eps 1.0E-14
using namespace std;

int main(){
    long long a,b,c;
    cin>>a>>b>>c;
    //if(sqrt(a)+sqrt(b)+eps<sqrt(c)) cout<<"Yes"<<endl;
    //else cout<<"No"<<endl;
    long long d =c-a-b;
    if(d>0&&d*d>4*a*b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
p = [0] + list(map(float, input().split()))
dp = [[0] * (n+1) for i in range(n+1)]
dp[0][0] = 1

for i in range(1,n+1):
    for j in range(0,i+1):
        if j >= 1:
            dp[i][j] = dp[i-1][j-1] * p[i] + dp[i-1][j] * (1-p[i])
        else:
            dp[i][j] = dp[i-1][j] * (1-p[i])
            
print(sum(dp[i][n//2+1:]))

Measured memory_bytes: 264584
//#define debug(x) cout<<#x<<":"<<x<<endl;
//#define UL unsigned long long
#define vi vector<long long>
#include<algorithm>
#include<vector>

#define ll long long
#include<iostream>
using namespace std;

int main(){
	int n;
	ll max=0,x=0,ans=1000000000000000000LL;
	cin>>n;
	vi v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
		max+=v[i];
	}
	for(int i=0;i<n;i++){
		x+=v[i];
		if(i+1<n)ans=min(ans,abs(max-2*x));
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(void){
	char str[1000];
	int len, i;
	gets(str);
	len = strlen(str);
	for(i = 0; i < len; i++){
		if(str[i] == 'p' && str[i+1] == 'e' && str[i+2] == 'a' && str[i+3] == 'c' && str[i+4] == 'h'){
			str[i] = 'a';
			str[i+1] = 'p';
			str[i+2] = 'p';
			str[i+3] = 'l';
			str[i+4] = 'e';
		}else if(str[i] == 'a' && str[i+1] == 'p' && str[i+2] == 'p' && str[i+3] == 'l' && str[i+4] == 'e'){
			str[i] = 'p';
			str[i+1] = 'e';
			str[i+2] = 'a';
			str[i+3] = 'c';
			str[i+4] = 'h';
		}
	}
	
	for(i = 0; i < len; i++){
		printf("%c", str[i]);
	}
	
	putchar('\n');
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  srand((unsigned)time(NULL));
  string S, T;
  cin >> S >> T;
  ll N = S.size();
  ll counter = 0;
  for(int i = 0; i < N; i++){
    if(S.at(i) != T.at(i)) counter++;
  }
  cout << counter << endl;
}

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

field=[list(input())]
field.append(list(input()))

M=1000000007

b=[field[0][0],field[1][0]]
if b[0]==b[1]:
    bdeffer=False
    count=3
else:
    bdeffer=True
    count=6

for j in range(1,len(field[0])):
    count=count%M
    a=[field[0][j],field[1][j]]

    if a[0]==b[0]:
        b=a
        if a[0]==a[1]:
            bdeffer=False
        else:
            bdeffer=True
        continue

    if a[0]==a[1]:
        if not bdeffer:
            count*=2
    else:
        if bdeffer:
            count*=3
        else:
            count*=2

    b=a[:]

    if a[0]==a[1]:
        bdeffer=False
    else:
        bdeffer=True

print(count%M)

Measured memory_bytes: 3064
#include <stdio.h>

#define N 100
#define MAX 100

int main() {
  int data[N];
  int i, j, n, minj, count = 0, temp, flag = 0;;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%d", &data[i]);
  }
  
  for (i = 0; i < n; i++) {
    minj = i;
    for (j = i; j < n; j++) {
      if (data[j] < data[minj]) {
	minj = j;
      }
    }
    if (i != minj) count++;
    temp = data[i];
    data[i] = data[minj];
    data[minj] = temp;
  }
  
  for (i = 0; i < n; i++) {
    printf("%d", data[i]);
    if (i == n-1) printf("\n");
    else printf(" ");
  }

  printf("%d\n", count);
  
  return 0;
}



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

int main(){
  int count = 0;
  long long X,yokin = 100;

  cin >> X ;

  while(1){
    count++;
    yokin += yokin * 0.01;
    if(yokin >= X){
      cout << count << endl;
      break;
    }
  }
}


Measured memory_bytes: 3636
# すぬけくんはレストランに通うのが好きです。
# すぬけくん行きつけのレストランは何を食べても1食 800円で、15食食べる毎にその場で 200円もらえます。
# すぬけくんは今までで合計 N食食べました。 今までに払った金額をx円、レストランからもらった金額を y円として、x−yを求めなさい。

N = int(input())

print(N *800 - (N // 15 *200))

Measured memory_bytes: 9000
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=105;
const int MAXM=105;
const int mod=1e9+7;
int pow_mod(int a,int b)
{
	int ret=1;
	for(;b;b>>=1,a=1LL*a*a%mod)if(b&1)ret=1LL*ret*a%mod;
	return ret;
}
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
struct edge{int x,y,next;}a[2*MAXM];int len,last[MAXN];
void ins(int x,int y){len++;a[len].x=x;a[len].y=y;a[len].next=last[x];last[x]=len;}
int n,m,low[MAXN],dfn[MAXN],root,sta[MAXN],tp,id,cnt,cut[MAXN],K;
vector<int> dcc[2*MAXN];
void tarjan(int x,int fa)
{
	low[x]=dfn[x]=++id;sta[++tp]=x;int flag=0;
	for(int k=last[x];k;k=a[k].next)if(a[k].y^fa)
	{
		int y=a[k].y;
		if(!dfn[y])
		{
			tarjan(y,x);low[x]=min(low[x],low[y]);
			if(low[y]>=dfn[x])
			{
				++flag;int i;++cnt;
				do
				{
					i=sta[tp--];
					dcc[cnt].emplace_back(i);
				}while(i!=y);dcc[cnt].emplace_back(x);
			}
		}else low[x]=min(low[x],dfn[y]);
	}if(flag>1||flag==1&&x!=root)cut[x]=1;
}
int gcd(int a,int b){return a==0?b:gcd(b%a,a);}
int vis[MAXN],tim;
bool tag[MAXN];
int pre[MAXN*2],inv[MAXN*2];
int C(int n,int m){return 1LL*pre[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
	pre[0]=1;for(int i=1;i<2*MAXN;i++)pre[i]=1LL*pre[i-1]*i%mod;
	inv[2*MAXN-1]=pow_mod(pre[2*MAXN-1],mod-2);
	for(int i=2*MAXN-2;i>=0;i--)inv[i]=1LL*inv[i+1]*(i+1)%mod;
	n=read();m=read();K=read();
	for(int i=1;i<=m;i++)
	{
		int x=read(),y=read();
		ins(x,y);ins(y,x);
	}
	int ans=1;
	for(int i=1;i<=n;i++)if(!dfn[i])root=i,tarjan(i,0);
	for(int i=1;i<=cnt;i++)if(SZ(dcc[i])>2)
	{
		++tim;for(auto p:dcc[i])vis[p]=tim;int num=0;
		for(int j=2;j<=len;j+=2)if(vis[a[j].x]==tim&&vis[a[j].y]==tim)
			++num,tag[j>>1]=1;
		if(num==SZ(dcc[i]))
		{
			int N=SZ(dcc[i]);int sum=0;
			for(int j=1;j<=N;j++)ad(sum,pow_mod(K,gcd(N,j)));
			ans=1LL*ans*pow_mod(N,mod-2)%mod*sum%mod;
		}
		else ans=1LL*ans*C(num+K-1,K-1)%mod;
	}
	for(int i=1;i<=m;i++)if(!tag[i])ans=1LL*ans*K%mod;
	pr2(ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    ll x,a,b;
    cin >> x >> a >> b;
    if (abs(a-x)<abs(b-x)){
        cout << "A" << endl;
    }else{
        cout << "B" << endl;
    }
}


Measured memory_bytes: 256