akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m;
  string s,t;
  cin>>n;
  cout<<(n*n*n)<<endl;

  return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

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

typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1ll<<29;
const bool debug = 0;

int N;
ll X[112345], R[112345];

long double solve(long double x) {
	long double res = 1e18;
	REP(i, N) chmin(res, R[i]*R[i] - (x-X[i])*(x-X[i]));
	return res;
}

int main() {
	cin >> N;
	REP(i, N) scanf("%lld %lld", X + i, R + i);
	
	long double l = -INF, r = INF;
	
	REP(i, N) {
		chmax(l, X[i] - R[i]);
		chmin(r, X[i] + R[i]);
	}
	
	REP(i, 300) {
		long double x1 = l + (r - l) / 3;
		long double x2 = r - (r - l) / 3;
		
		long double y1 = solve(x1), y2 = solve(x2);
		
		if (y1 <= y2) l = x1;
		else r = x2;
	}
	
	long double ans = sqrt(solve(l));
	printf("%.15lf\n", (double)ans);
	
	return 0;
}

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

int main(int argc, char* argv[])
{
    int a, b, c;
    cin >> a >> b >> c;
    if( a<b && b<c)
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

//BIT
ll bit[12345678], nn;//[1, nn]
ll sum(ll i) {
	ll s = 0;
	while (i > 0) {
		s += bit[i]; i -= i & -i;
	}
	return s;
}
void add(ll i, ll x) {//iの値にxを加える
	while (i <= nn) {
		bit[i] += x; i += i & -i;
	}
}
signed main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	
	ll n, q; cin >> n >> q;
	vector<ll> in(n + 2); nn = n + 2;
	rep2(i, n) { ll a; cin >> a; in[i] = a; add(i, a); }
	rep(i, q) {
		ll a, b, c; cin >> a >> b >> c;
		if (a == 0) {
			b++; add(b, c);
		}
		else {
			cout << sum(c) - sum(b) << endl;
		}
	}
	return 0;
}

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

#define ll long long

ll dp[3003][3003];
ll n, k, arr[3003];

ll solve (int l, int r, int turn) {
	if (l > r) {
		return 0;
	}

	if (dp[l][r] != -1) {
		return dp[l][r];
	}
	if (turn == 0)
		return dp[l][r] = max (arr[l] + solve (l + 1, r, !turn), arr[r] + solve (l, r - 1, !turn));

	return dp[l][r] = min (solve (l + 1, r, !turn), solve (l, r - 1, !turn));
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	ll sum = 0;
	memset (dp, -1, sizeof dp);

	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		sum += arr[i];
	}

	ll x = solve (0, n - 1, 0);
	ll y = sum - x;
	ll ans = x - y;
	//cout << x << " " << y << " ";
	cout << ans;
	return 0;
}


Measured memory_bytes: 70912
/**
*    created: 31.05.2020 20:59:43
**/
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

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

    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<string>

int main(){
    int A, B, K;
    std::cin >> A >> B >> K;
    int minVal = std::min(A, B);
    int cnt = 0;
    for(int i = minVal; i > 0; i--){
        if(A % i == 0 && B % i == 0){
            cnt++;
            if(cnt == K){
                std::cout << i << std::endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

C = zip(A, B)

C = sorted(C)

A, B = zip(*C)

A = list(A)
B = list(B)

A.reverse()
B.reverse()

C = zip(B, A)

C = sorted(C)

B, A = zip(*C)

A = list(A)
B = list(B)

for i in range(N):
    if i!=0:
        A[i]=A[i-1]+A[i]

flag = 0

for i in range(N):
    if A[i]>B[i]:
        flag = 1

if flag == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 49228
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define pb                     push_back
#define ll                     long long int
#define fi                     first
#define se                     second
#define ii                     pair<long long int, long long int>
#define vi                     vector <long long int>
#define vii                    vector <pair <long long int, long long int > >
#define all(cont)              cont.begin(), cont.end()
#define EPS                    1e-9
#define MOD                    1000000007
#define range
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
 

int main(){
 
    IOS;
    clock_t clk = clock();
    //freopen("input.txt",  "r", stdin);
   // freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    vi a(n);
    forn(i,n)
    {
    cin >> a[i];
    }
    int sum=0;
    forn(i,n)
    {
       for(int j=i+1;j<n;j++)
       {
         sum+= a[i]*a[j];
       }
    }
   cout<<sum;
    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
ans = 0
for i in range(1,n+1):
    if i % 2 == 0:
        continue
    count = 0
    for j in range(1,i+1):
        temp = i // j
        if i == temp * j:
            count += 1
    if count == 8:
        ans += 1
print(ans)


Measured memory_bytes: 2940
# coding: utf-8

line = input().split(" ")
if line[0] == line[1]:
    if line[0] == line[2]:
        print("No")
    else:
        print("Yes")
elif line[0] == line[2]:
    if line[0] == line[1]:
        print("No")
    else:
        print("Yes")
elif line[1] == line[2]:
    if line[0] == line[1]:
        print("No")
    else:
        print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
class UnderflowError(Exception):
    pass


class Mystack:

    def __init__(self, _max):
        self.S = [None for _ in range(_max)]
        self.top = 0
        self.max = _max

    def is_empty(self):
        return self.top == 0

    def is_full(self):
        return self.top >= self.max - 1

    def push(self, x):
        if self.is_full():
            raise OverflowError
        self.top += 1
        self.S[self.top] = x

    def pop(self):
        if self.is_empty():
            raise UnderflowError
        self.top -= 1
        return self.S[self.top + 1]


stack = Mystack(200)

for n in input().split():
    try:
        n = int(n)
    except ValueError:
        pass
    else:
        stack.push(n)
        continue
    if n == '+':
        stack.push(stack.pop() + stack.pop())
    elif n == '-':
        stack.push(- stack.pop() + stack.pop())
    elif n == '*':
        stack.push(stack.pop() * stack.pop())

print(stack.pop())




Measured memory_bytes: 5608
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
list<int> l;
vector<int> v;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n,increasing=0,money=1000;
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		l.push_back(x);
	}
	for(auto i=l.begin();i!=l.end();i++){
		if(i==l.begin())
			continue;
		auto Prev=i;
		Prev--;
		if((*i)==(*Prev))
			continue;
		if(((*i)>(*Prev) && increasing==false) || (((*i)<(*Prev) && increasing))){
			increasing=(!increasing);
			v.push_back(*Prev);
		}
	}
	v.push_back(*l.rbegin());
	for(int i=1;i<v.size();i++)
		if(v[i]>v[i-1])
			money+=(money/v[i-1])*(v[i]-v[i-1]);
	cout<<money;
	return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<P, int> PP;
int main() {
	ll k; cin >> k;
	ll d = k / (ll)50; ll r = k % (ll)50; r = (ll)50 - r;
	cout << 50 << endl;
	rep(i, 50) {
		if (i > 0)cout << " ";
		if (i < r)cout << d + r - (ll)1;
		else cout << d + (ll)50 + r;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,x;
  cin >> N >> x;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  ll ans = 0;
  rep(i,N-1) {
    if(A[i]+A[i+1] <= x) continue;
    ll t = 0;
    if(A[i] > x) {
      t += A[i]-x;
      A[i] = x;
    }
    if(A[i+1] > x) {
      t += A[i+1]-x;
      A[i+1] = x;
    }
    if(A[i]+A[i+1] > x) {
      t += A[i+1] + A[i] - x;
      A[i+1] -= A[i+1] + A[i] - x;
    }
    ans+= t;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String input = scanner.nextLine();
        String[] data = input.split(" ");

        char data1End = data[0].charAt(data[0].length()-1);
        char data2Head = data[1].charAt(0);
        char data2End = data[1].charAt(data[1].length()-1);
        char data3Head = data[2].charAt(0);

        if(data1End == data2Head) {
            if(data2End == data3Head) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m; cin >> n >> m;
    vi tbl(m, 1);
    rep(i, n){
        int K; cin >> K;
        vi cur(m);
        rep(_, K){
            int t; cin >> t; t--;
            cur[t] = 1;
        }
        rep(i, m){
            tbl[i] &= cur[i];
        }
    }

    int res = 0;
    for(auto& e : tbl) res += e;
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int p=1e9+7;

void up(int &a,int b){(a+=b)>=p&&(a-=p);}

int f[3001][3002][2],n,m,ans;

int main()
{
    scanf("%d%d",&n,&m),f[0][0][1]=1;
    for(int i=1;i<=n;++i)f[0][i][0]=1;

    for(int i=0;i<m;++i)
    {
	up(f[i+1][1][1],f[i][0][1]);
	up(f[i+1][1][1],f[i][1][0]);
	up(f[i+1][2][0],f[i][1][0]);
	up(f[i+1][1][1],f[i][1][1]);
	up(f[i+1][2][1],f[i][1][1]);
	for(int j=2;j<=n;++j)
	    for(int k=0;k<2;++k)
	    {
		up(f[i+1][j][k],f[i][j][k]);
		up(f[i+1][j+1][k],f[i][j][k]);
	    }

	for(int j=1;j<=n;++j)
	    for(int k=0;k<2;++k)
		up(f[i+1][j-1][k],f[i+1][j][k]);
    }

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


Measured memory_bytes: 70656
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  vector<ll> left(n+1,0),right(n+1,0);
  rep(i,n) left[i+1]=GCD(left[i],v[i]);
  for(ll i=n-1;i>=0;i--) right[i]=GCD(right[i+1],v[i]);
  ll ans=0;
  rep(i,n) chmax(ans,GCD(left[i],right[i+1]));
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>













const int N=1e5+10;
ll n,a,c,c2;

void solve()
{
	cin>>n;
	c=0;
	c2=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		if(a%4==0)c++;
		else if(a%2==0)c2++;
	}
	if(n>(2*c)+1&&(2*c)+c2<n)
	{
		cout<<"No\n";
	}
	else
	{
		cout<<"Yes\n";
	}
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 256
def main():
    X, Y, Z, K = map(int, input().split())
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    C = [int(i) for i in input().split()]

    AB = []
    ABappend = AB.append
    for i in range(X):
        for j in range(Y):
            ABappend(A[i] + B[j])
    AB.sort(reverse=True)
    ABC = []
    ABCappend = ABC.append
    for i in range(min(K, X*Y)):
        for j in range(Z):
            ABCappend(AB[i] + C[j])
    ABC.sort(reverse=True)
    print('\n'.join(map(str, ABC[:K])))


if __name__ == '__main__':
    main()


Measured memory_bytes: 148364
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)

ll i,o,t,j,l,s,z;
int main(){
	scanf("%lld%lld%lld%lld%lld%lld%lld",&i,&o,&t,&j,&l,&s,&z);
	//(o),(i,i),(l,l),(j,j),(j,i,l)のいずれかしかない
	if(i%2==j%2&&j%2==l%2){
		//使い切れる
		printf("%lld\n",i+j+l+o);
	}else if(i==0||j==0||l==0){
		//それぞれ2つずつ組みにするしかない
		printf("%lld\n",i/2*2+j/2*2+l/2*2+o);
	}else{
		//偶奇性から使い切ることはできない
		//必要なら(j,i,l)を使って、奇数は1つとしてよく、余るのは1個だけにできる
		printf("%lld\n",i+j+l+o-1);
	}
	return 0;
}

Measured memory_bytes: 128
((stdin) => {
	let [l1, l2] = stdin.split('\n');
	let [n, k] = l1.split(' ');
	let p = l2.split(' ');

	p.sort((a, b) => +a - +b);
	let sum = 0;
	for (let i = 0; i < k; i++) {
		sum += +p[i];
	}

	console.log(sum);
})(require("fs").readFileSync("/dev/stdin", "UTF-8"));

Measured memory_bytes: 29744
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
 
int main() {
  char s[11];
  int l = 0;
  scanf("%s", s);
  l = strlen(s);
  if (s[0] != 'A') {
    printf("WA");
    return 0;
  }
 
  int i = 0;
  int t = 0;
  for (i = 2; i < l-1; i++) {
    if (s[i] == 'C') {
      t++;
    }
  }
 
  if (t != 1) {
    printf("WA");
    return 0;
  }
  t = 0;
  for (i = 0; i < l; i++) {
    if (s[i] <= 'Z') {
      t++;
    }
  }
 
  if (t == 2) {
    printf("AC");
  }
  else {
    printf("WA");
  }
  return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 A, B;
  cin >> A >> B;
  cout << max(A-2*B, (int64)0) << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#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 ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    ll a=0,b=0,d=0,n=0,y=0;
    //VI a(N);
    string s,s1,s2;
    cin >> a >> b;
    if((a+b)% 2 == 0) cout << (a+b)/2 <<endl; 
    else cout << "IMPOSSIBLE" <<endl; 
    return 0;
}


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

int main()
{
    int n, a, b;
    std::cin >> n >> a >> b;

    int sum = 0;
    for (int ii = 0; ii <= n; ++ii)
    {
        int x = 0;
        int cur = ii;
        while (true)
        {
            x += cur % 10;
            cur /= 10;
            if (cur == 0)
            {
                break;
            }
        }
        if (x >= a && x <= b)
        {
            sum += ii;
        }
    }

    std::cout << sum;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int X,A,B;
	scanf("%d %d %d",&X,&A,&B);
	if(A>=B){
		printf("delicious\n");
	}
	else if(A<B){
		if(B-A<=X){
			printf("safe\n");
		}
		else if(B-A>X){
			printf("dangerous\n");
		} 
	}
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

template <class T>
using lp_queue=priority_queue<T, deque<T>, greater<T>>;

using Weight=long long;
static const Weight INF=1LL<<57;

struct Arc {
    // accessible to the reverse edge
    size_t src, dst;
    Weight capacity, cost, flow;
    size_t rev;
    Arc() {}
    Arc(size_t src, size_t dst, Weight capacity, Weight cost=0):
        src(src), dst(dst), capacity(capacity), cost(cost), flow(0), rev(-1)
    {}
    Weight residue() const {
        return capacity - flow;
    }
};

bool operator<(const Arc &e, const Arc &f) {
    if (e.cost != f.cost) {
        return e.cost > f.cost;
    } else if (e.capacity != f.capacity) {
        return e.capacity > f.capacity;
    } else {
        return e.src!=f.src? e.src<f.src : e.dst<f.dst;
    }
}

using Arcs=vector<Arc>;
using Node=vector<Arc>;
using FlowNetwork=vector<Node>;

void connect(FlowNetwork &g, size_t s, size_t d, Weight c=1, Weight k=0) {
    g[s].push_back(Arc(s, d, c, k));
    g[d].push_back(Arc(d, s, 0, -k));

    g[s].back().rev = g[d].size()-1;
    g[d].back().rev = g[s].size()-1;
}

void join(FlowNetwork &g, size_t s, size_t d, Weight c=1, Weight k=0) {
    g[s].push_back(Arc(s, d, c, k));
    g[d].push_back(Arc(d, s, c, k));

    g[s].back().rev = g[d].size()-1;
    g[d].back().rev = g[s].size()-1;
}

pair<Weight, Weight> mincost_flow(
    FlowNetwork &g, size_t s, size_t t, Weight F=INF
) {
    size_t V=g.size();
    vector<Weight> pot(V);

    pair<Weight, Weight> total;  // <cost, flow>
    while (F > total.second) {
        vector<Weight> d(V, INF); d[s]=0;
        vector<Arc *> prev(V, NULL);
        lp_queue<pair<Weight, size_t>> q; q.push(make_pair(0, s));
        while (!q.empty()) {
            pair<Weight, size_t> p=q.top(); q.pop();
            size_t v=p.second;
            if (d[v] < p.first) continue;

            for (Arc &e: g[v]) {
                if (e.capacity <= 0) continue;

                if (d[e.dst] > d[e.src] + e.cost + pot[e.src] - pot[e.dst]) {
                    d[e.dst] = d[e.src] + e.cost + pot[e.src] - pot[e.dst];
                    prev[e.dst] = &e;
                    q.push(make_pair(d[e.dst], e.dst));
                }
            }
        }

        if (d[t] == INF) {
            total.first = -1;
            return total;
        }

        for (size_t v=0; v<V; ++v)
            pot[v] += d[v];

        Weight f=F-total.second;
        for (Arc *e=prev[t]; e!=NULL; e=prev[e->src])
            f = min(f, e->capacity);

        total.second += f;
        total.first += f * pot[t];
        for (Arc *e=prev[t]; e!=NULL; e=prev[e->src]) {
            e->capacity -= f;
            g[e->dst][e->rev].capacity += f;
        }
    }

    return total;
}

int main() {
    size_t V, E;
    Weight F;
    scanf("%zu %zu %lld", &V, &E, &F);

    FlowNetwork g(V);
    for (size_t i=0; i<E; ++i) {
        size_t u, v;
        Weight c, d;
        scanf("%zu %zu %lld %lld", &u, &v, &c, &d);

        connect(g, u, v, c, d);
    }

    printf("%lld\n", mincost_flow(g, 0, V-1, F).first);
    return 0;
}

Measured memory_bytes: 2848
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] inputs = br.readLine().split(" ");
		int n = Integer.parseInt(inputs[0]);

		ArrayList<ArrayList<Edge>> nodes = new ArrayList<>();
		for ( int i = 0; i < n; i++ ) {
			nodes.add(new ArrayList<Edge>());
		}

		for ( int i = 0; i < n - 1; i++ ) {
			inputs = br.readLine().split(" ");
			int u = Integer.parseInt(inputs[0]) - 1;
			int v = Integer.parseInt(inputs[1]) - 1;
			int w = Integer.parseInt(inputs[2]);
			nodes.get(u).add(new Edge(v, w));
			nodes.get(v).add(new Edge(u, w));
		}
		br.close();

		ArrayDeque<Integer> q = new ArrayDeque<>();
		q.add(0);
		int[] tree = new int[n];
		tree[0] = 1;
		while ( !q.isEmpty() ) {
			int idx = q.poll();

			for ( Edge e : nodes.get(idx) ) {
				if ( tree[e.to] == 0 ) {
					q.add(e.to);

					if ( e.dist % 2 == 0 ) tree[e.to] = tree[idx];
					else tree[e.to] = tree[idx] * (-1);
				}
			}
		}

		StringBuilder sb = new StringBuilder();
		for ( int i : tree ) {
			sb.append(Math.max(i, 0) + "\n");
		}
		System.out.println(sb);
	}
}

class Node {

	ArrayList<Edge> nexts = new ArrayList<>();
}

class Edge {

	int	to		= 0;
	int	dist	= 0;

	public Edge(int t, int d) {
		to = t;
		dist = d;
	}
}

Measured memory_bytes: 72264
#include <algorithm>
#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 ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) { cin >> A[i]; }

    ll ans = 0;
    sort(all(A), greater<ll>());
    priority_queue<ll> pq;
    pq.push(A[0]);
    for (int i = 1; i < N; i++) {
        ans += pq.top();
        pq.pop();
        pq.push(A[i]);
        pq.push(A[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 6888
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(10)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}

ll dp[401][401];
ll a[401];
ll pre[401];
ll n;
ll sol(int i,int j)
{
	if(i==j)
	return dp[i][i]=0;
	
	
	if(i==j-1)
	return dp[i][j]=(a[i]+a[j]);
	
		
	ll &x=dp[i][j];
	if(x!=-1)
	return x;
	
	x=inf;
	
	for(int k=i;k<j;k++)
	{
		ll h;
		if(i==0)
		h=0;
		else if(i>j)
		h=ninf;
		else
		h=pre[i-1];
		ll cand=sol(i,k)+sol(k+1,j)+pre[j]-h;
		x=min(cand,x);
	}
	
	return x;
}


int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{
mems(dp,-1);

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

for(int i=1;i<n;i++)
pre[i]+=pre[i-1];

cout<<sol(0,n-1);



}return 0;}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  int n;
  string s;
  cin >> n >> s;
  if (s.size() <= n) {
    cout << s << endl;
  } else {
    rep(i, n) {
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int gcd(int i, int j) {
  int l = max(i,j), s = min(i, j);
  if (s==0) return l;
  return gcd(s, l%s);
}

int main() {
  int N, X; cin >> N >> X;
  int x[N]; rep(i, N) { cin >> x[i]; x[i]=abs(x[i]-X);}

  int result = x[0];
  for(int i=1; i<N; i++) result = gcd(result, x[i]);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	int count = a;
      	if(b < a){
        	count = a - 1;
        }
      	System.out.println(count);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <regex>
#include <set>
#include <cmath>
#include <sstream>
#include <numeric>
#include <set>

using namespace std;




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

    std::vector<int> primes;

    for(int i = 2; i <= std::sqrt(n); i++)
    {
        bool is_prime = true;
        for(auto num : primes)
        {
            if(i % num == 0)
            {
                is_prime = false;
                break;
            }
        }

        if(is_prime)
        {
            primes.push_back(i);
        }
    }

    int ans = n;

    while(true)
    {
        bool is_prime = true;
        for(auto num : primes)
        {
            if(ans % num == 0)
            {
                is_prime = false;
                break;
            }
        }
        if(is_prime)
            break;
        else
        {
                ans++;
        }
    }

    std::cout << ans;


    return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <cstdio>
using namespace std;

inline void read(int& sum)
{
    char ch; sum=0;
    ch=getchar();
    while(ch<'0'||ch>'9') ch=getchar();
    while(ch>='0'&&ch<='9')
        sum=(sum<<1)+(sum<<3)+ch-'0',ch=getchar();
}

int main(void)
{
	int a,b;
	read(a),read(b);
	printf("%d\n",(--a)*(--b));
	return 0;
}

Measured memory_bytes: 128
/*  AC祈願アンコウ
   　／￣＼
   ○    ／￣￣￣＼ヘ
    　 /・　 ・　 ＼>   
    ／￣￣￣＼　　  Ｖ| 
   ｜  ―――  ｜      ｜|
    ＼＿＿＿／　　  ∧|
    　　＼　　　　／
    　　　￣￣￣￣
*/

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

typedef int64_t ll;
//static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define YESNO(x) puts((x)?"YES":"NO")
#define YesNo(x) puts((x)?"Yes":"No")

signed main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    printf("%d\n",min(a,b)+min(c,d));

    return 0;
}


Measured memory_bytes: 256
import fractions
import itertools
import math

# nの約数をすべて求める
def make_divisors(n):
    divisors = []
    #for i in range(1, int(n**0.5)+1):
    for i in itertools.takewhile(lambda i: i**2<=n, itertools.count(1)):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    
    return divisors

# 素因数分解
# 素因数とその指数をペアにして配列で返す
def factorize(n):
    # 素因数の候補
    # i=2,...,floor(sqrt(n)) つまりi**2<=nになるまで
    remainder = n
    ret = []
    for i in itertools.takewhile(lambda i: i**2<=n, itertools.count(2)):
        # 現在の余りをiで割れるだけ割る
        if remainder % i:
            continue
        else:
            # 割れるなら，割れる回数と余りを求める
            p = 0
            while remainder % i == 0:
                remainder //= i
                p += 1

            ret.append((i,p))

    # 2以上の余りが残っていれば，追加
    if remainder > 1: ret.append((remainder,1))

    return ret
        
    
A,B = map(int,input().split())

# 答えの集合は1or素数で構成されるとして良い (a*b,a>1,b>1となる要素があれば，aも公約数だから，a*bをaに置き換えても最適解になるから)
# つまり，A,Bをそれぞれ素因数分解し，共通の素因数の数を数えればよい
# これは，gcd(A,B)の素因数の数と同じ
gcd = fractions.gcd(A,B)
divs = factorize(gcd)
print(len(divs) + 1) # + 1は"1"の数

Measured memory_bytes: 5076
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mod 1000000007
signed main(){
  int n,m;
  cin>>n>>m;
  int fact[100005];
  fact[0]=1;
  for(int i=1;i<=100000;i++){
    fact[i]=(fact[i-1]*i)%mod;
  }
  int ans=(fact[n]*fact[m])%mod;
  if(n==m)	cout<<(2*ans)%mod<<endl;
  else if(abs(n-m)==1)	cout<<ans<<endl;
  else	cout<<0<<endl;
  return 0;
}

Measured memory_bytes: 1024
import itertools

n, m, q = map(int, input().split())
data = []
for _ in range(q):
  data.append( list(map(int, input().split())) )

l = [i for i in range(1, m+1)]

p = itertools.product(l, repeat=n)
p = itertools.combinations_with_replacement(l, n)
list_p = list(p)
cmb = []
for p in list_p:
  cmb.append(list(p))



ans = 0

# 処理系
for cm in cmb:
  tmp = 0
  for d in data:
    b_point = d[1]
    a_point = d[0]
    c_point = d[2]
    d_point = d[3]
    if cm[b_point - 1] - cm[a_point - 1] == c_point:
      tmp += d_point

  ans = max(ans, tmp)


print(ans)


Measured memory_bytes: 35736
package main

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

func solution(n int, a []int) int {
        curI := make([]int, n)
        curD := make([]int, n)
        curI[0], curD[n-1] = a[0], a[n-1]
        for i := 1; i < n; i++ {
                curI[i] = a[i] + curI[i-1]
        }
        for i := n - 2; i >= 0; i-- {
                curD[i] = a[i] + curD[i+1]
        }
        out := 1 << 31
        for i := 0; i < n-1; i++ {
                out = min(out, abs(curI[i]-curD[i+1]))
        }
        return out
}

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

func min(x, y int) int {
        if x < y {
                return x
        }
        return y
}

func main() {
        r := bufio.NewReader(os.Stdin)
        var n int
        fmt.Fscan(r, &n)
        a := make([]int, n)
        for i := range a {
                fmt.Fscan(r, &a[i])
        }
        fmt.Println(solution(n, a))
}

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

using namespace std;

int n,k,tmp,ans,d[100003];
int main(){
while(1){
ans = 0;
tmp = 0;
	scanf("%d%d",&n,&k);
if(n == 0)break;
	for(int i = 0;i < n;i++){
		scanf("%d",&d[i]);
	}
	for(int i = 0;i < k;i++){
		tmp += d[i];
	}
	ans = tmp;
	for(int i = k;i < n;i++){
		tmp += d[i] - d[i-k];
		ans = max(ans,tmp);
	}
	printf("%d\n",ans);
}
	return 0;
}


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

using namespace std;

const int N = (int) 1e5 + 7;
int n, a[N];

struct T {
  int x;
  int l, r;
};

void check(T it) {
  if (it.l > it.r) {
    cout << "error\n";
    exit(0);
  }
}

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

  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  reverse(a + 1, a + n + 1);
  vector<T> col, ran;
  int i = 1;
  while (i <= n) {
    int j = i;
    while (j + 1 <= n && a[j + 1] == a[i]) {
      j++;
    }
    ran.push_back({a[i], i - 1, j});
    i = j + 1;
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] != a[i + 1]) {
      col.push_back({i, a[i + 1], a[i]});
    }
  }
  for (auto &it : col) {
    check(it);
  }
  for (auto &it : ran) {
    check(it);
  }
  bool wi = 0;
  for (auto &it : ran) {
    if (it.l <= it.x && it.x <= it.r) {
      if ((it.r - it.x) % 2 == 1) {
        wi = 1;
      }
    }
  }
  for (auto &it : col) {
    if (it.l <= it.x && it.x <= it.r) {
      if ((it.r - it.x) % 2 == 1) {
        wi = 1;
      }
    }
  }
  if (wi) {
    cout << "First\n";
  } else {
    cout << "Second\n";
  }
}


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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    print(n/3);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    long long x, d, k;
    cin >> x >> k >> d;
    x = abs(x);
    long long t = x / d;
    if(t >= k)
        cout << x - k * d << endl;
    else {
        k -= t;
        x -= t * d;
        if(k % 2 == 1)
            cout << -1 * (x - d) << endl;
        else
            cout << x << endl;
    }
    return 0;
}


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

using namespace std;

int main() {
    int a[5], k;
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
    }
    cin >> k;
    cout << (a[4] - a[0] > k ? ":(" : "Yay!") << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		out.println(n%k == 0 ? 0 : 1);
		
		out.flush();
	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 21204
import java.util.*;
import java.io.*;
class Main{
  static int count = 0;
  public static void main(String args[])throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    int array[] = new int[n];
    StringTokenizer token = new StringTokenizer(br.readLine());

    for(int i = 0; i<n; i++){
      array [i] = Integer.parseInt(token.nextToken());
    }

    merge_sort(array,n,0,n);
    for(int i = 0; i<n-1; i++){
      System.out.print(array[i]+" ");
    }
    System.out.println(array[n-1]);
    System.out.println(count);
  }

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

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


Measured memory_bytes: 127500
/*author : Yashvardhan
Tuesday, May 14, 2019
11:51 AM
*/

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

typedef long long ll;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define endl '\n'

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << 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 debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	string s;
	cin>>s;
	int n = s.size();

	stack<int> st;
	int count = 0;
	for(int i = 0; i < n ; i++){
		int val = s[i] - '0';
		if(st.empty()){
			st.push(val);
			continue;
		}
		if(st.top() == 0){
			if(val == 1){
				st.pop();
				count += 2;
			}
			else st.push(0);
		}
		else if(st.top() == 1){
			if(val == 0){
				st.pop();
				count += 2;
			}
			else st.push(1);
		}
	}
	cout<<count<<endl;
	

	t2 = clock();
	cerr<<endl<<t2-t1<<endl;
	
	return 0;
}



Measured memory_bytes: 1232
#include<stdio.h>
int main(void){
	int i,N,count=0;
	char S[100];
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%c",&S[i]);
		if(S[i]=='Y'){
			count=1;
		}
	}
	if(count==0){
		printf("Three\n");
	}else{
		printf("Four\n");
	}
	return 0;
}

Measured memory_bytes: 128