akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
 
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef pair<int,int> pii;
// tree <pii,null_type,greater<pii>,rb_tree_tag,tree_order_statistics_node_update> tr;
// cin.tie(0);
// std::ios::sync_with_stdio(false);
typedef long long LL;
const int N = 200005;
const int M = 205;
// const int V = 207;
// const int E = 60007;
const int INF = 0x3f3f3f3f;
const double inf = 2e9;
const double Pi = acos(-1);
const int MOD = 1e9+7;
const double eps = 1e-8;
int n,m;
int s[N];
int vis[N];
bool sat(int x)
{
    memset(vis,0,sizeof vis);
    int pre = 0;
    vis[0]++;
    for (int i=1;i<=n;i++)
    {
        int a = s[i];
        if (a-pre < x)
            vis[24-a]++;
        else
        {
            vis[a]++;
            pre = a;
        }
    }
    // cout<<"bug "<<x<<endl;
    // for (int i=0;i<=24;i++)
    //     cout<<vis[i]<<" ";
    // cout<<endl;
    int f = 0;
    for (int i=0;i<=24;i++)
    {   
        if (vis[i]==1)
        {
            for (int j=1;j<x;j++)
            {
                int a = (i+j)%24;
                int b = (i-j+24)%24;
                if (vis[a] || vis[b])
                    return false;
            }
        }
        else if (vis[i]>1)
            return false;
    }
    return true;
}
int main()
{
    while (~scanf("%d",&n))
    {
        s[0] = 0;
        for (int i=1;i<=n;i++)
            scanf("%d",&s[i]);
        sort(s,s+n+1);
        int f = 0;
        if (n>=2)
            for (int i=0;i<=n-2 && f==0;i++)
                if (s[i]==s[i+1] && s[i+1]==s[i+2])
                    f=1;
        if (s[1]==0 || f==1)
        {
            printf("0\n");
            continue;
        }
        int l=0,r=12;
        int ans=0,mid;
        while (l<r)
        {
            mid = (l+r)>>1;
            if (sat(mid))
            {
                ans = mid;
                l = mid+1;
            }
            else
                r = mid;
        }
        printf("%d\n",ans);
    }
    return 0;
}
/*

3
7 12 8

2
11 11

1
0

*/

Measured memory_bytes: 1024
// In the Name of God
#include<bits/stdc++.h>

#define test(t) int t; cin>>t; while(t--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORE(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ll long long int
#define em emplace_back
#define pb push_back
#define INF 1e7+5
#define MOD 1e9+7
#define print printf
#define in scanf
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

template<class type>
void displaySingle(type &arr)
{
	for(auto i:arr)
		cout<<i<<" ";
	cout<<endl;
}

template<class type>
void displayDouble(type &arr)
{
	for(auto &&i : arr) 
	{
    	for(auto &&j : i) 
    		cout << j << " ";
    	cout << std::endl;
  	}

}

int main()
{
	int n,k;
	cin>>n>>k;
	vector <int> arr(n);
	REP(i,n)
		cin>>arr[i];
	int i = 0;
	int j = k;
	while(j < n)
	{
		if(arr[i] < arr[j])
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
		i++;
		j++;
	}
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
 
typedef long long int ll; 
typedef long double ld; 
 
#define MAX 200005
#define endl endl


bool check(ll *arr, int n, int k, int mid){
	ll tcut = 0;
	for(ll i=0;i<n;i++){
		tcut += arr[i]/mid;
		if(arr[i]%mid == 0)tcut--;
	}
	return (tcut<=k)? true: false;
}

int main()
{
	
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll n, k;
	cin>>n>>k;
	ll arr[n];
	ll ma = 0;
	for(ll i=0;i<n;i++){
		cin>>arr[i];
		ma = max(ma, arr[i]);
	}
	
	ll mi = 1;
	ll ans = ma;
	while(mi<=ma){
		ll mid = mi + (ma-mi)/2;
		if(check(arr, n, k, mid)){
			ans = mid;
			ma = mid-1;
		}
		else{
			mi = mid+1;
		}	
	}
	cout<<ans<<endl;
}


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

#define REP(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ALL(c) c.begin(), c.end()
#define SZ(c) (int) c.size()
#define DBG1(x) cout<<#x<<" = "<<x<<"\n"
#if USE_CP_REDIR
#define CP \
    freopen("input.txt","r", stdin); \
    freopen("output.txt","w", stdout);
#endif

using ll = long long;
const ll MOD = 1'000'000'007;
const int MN = 1'000'000;

int main()
{
ios::sync_with_stdio(false);
#ifdef CP
    CP;
#endif
    string S, T;
    cin >> S >> T;
    int ans = SZ(T);
    for(int i = 0; i < SZ(S) - SZ(T) + 1; i++)
    {
        int cnt = 0;
        for(int j = 0; j < SZ(T); j++){
            if(S[i+j] != T[j]) cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    /*
    for(int l = SZ(T); l; l--){
        for(int i = 0; i < SZ(T) - l + 1; i++){
            string tt = T.substr(i, l);
            size_t pos = S.find(tt);
            if(pos != S.npos && pos >= (size_t)i){
                ans = SZ(T) - l;
                goto imprime;
            }
        }
    }
    imprime:
    cout << ans << endl;
    */
}

Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {

	Scanner sca = new Scanner(System.in);
	String s = sca.next();
	for(int i = 0; i < s.length(); i++) {
		System.out.print("x");
	}
	System.out.println("");

	// 後始末
	sca.close();
	}
}

Measured memory_bytes: 23508
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from math import factorial
import numpy

def calc_index(xs, n):
  remaining = numpy.ones(n)
  index = 0
  for i, x in enumerate(xs):
    remaining[x-1] = 0
    index += numpy.sum(remaining[:(x-1)]) * factorial(n-(i+1))
  return int(index)


def main():
  n = int(input())
  Ps = list(map(int, input().strip().split()))
  Qs = list(map(int, input().strip().split()))
  print(abs(calc_index(Ps, n) - calc_index(Qs, n)))

if __name__=='__main__':
  main()

Measured memory_bytes: 13320
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	int a[100001];
	int two=0,four=0;
	scan(N);
	rep(i,N){
		scan(a[i]);
		if(a[i]%4==0) four++;
		else if(a[i]%2==0) two++;
	}
	if(two+four*2>=N||four*2+1>=N) prin("Yes");
	else prin("No");

	return 0;
}


Measured memory_bytes: 640
// Bismillahir Rahmanir Rahim
// Mr_Emrul

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

typedef long long int ll;
typedef pair <ll, ll> pll;
typedef pair <ll, pll> plp;
typedef pair <int, int> pii;
typedef pair <int, pii> pip;
const ll MX = 100005;

#define LCM(a,b)        (a / __gcd(a,b) ) *-b
#define gcd(a,b)        __gcd(a,b)
#define all(x)          (x).begin(), (x).end()
#define mem(a, n)       memset(a,n,sizeof(a))
#define for1(i, n)      for(i=1; i<=n; i++)
#define for0(i, n)      for(i=0; i<n; i++)
#define rof0(i, n)      for(i=n-1; i>=0; i--)
#define rof1(i, n)      for(i=n; i>=1; i--)
#define forab(i, a, b)  for(i=a; i<=b; i++)
#define rofab(i, a, b)  for(i=b; i>=a; i--)
#define pb              push_back
#define pbb             pop_back
#define YES             cout << "YES" << endl
#define NO              cout << "NO" << endl
#define sin(s)          getline(cin, s)
#define scf(a)          cin >> a
#define scf2(a, b)      cin >> a >> b
#define scf3(a, b, c)   cin >> a >> b >> c
#define scf4(a,b,c,d)   cin >> a >> b >> c >> d
#define pnf(a)          cout << (a) << endl
#define pnf2(a, b)      cout << (a) << " " << (b) << endl
#define pnf3(a, b, c)   cout << (a) << " " << (b) << " " << (c) << endl
#define pnfa(a)         cout << (a) << " "
#define pf(a)           cout << (a)
#define sp              cout << " "
#define nl              cout << endl
#define sz(n)           n.size()
#define clear(v)        v.clear()
#define bug(n)          cout << ">> " << n << " <<" << endl
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in              freopen("in.txt", "r", stdin)
#define out             freopen("out.txt", "w", stdout)
#define fast            ios_base::sync_with_stdio(false);
#define F               first
#define S               second
#define mpp             make_pair

ll ar[MX], br[MX];
//ll ans[MX];
//vector <ll> v;
//map <ll, ll> mp, st, xx;
//map <string, ll> mps;
//map <ll, string> mpi;
//map <char, ll> mpc;
//set <ll> st;
string s;


int main()
{
    ll n, m, t, a, b, c, x, y, sum=0, cnt=0, i, j, k;
    //scf2(n, m);
    string s1, s2;
    scf2(s1, s2);
    n = s1.size();
    m = s2.size();
    if(n>m)
        return pnf("GREATER"),0;
    if(n<m)
        return pnf("LESS"),0;
    for0(i, n)
    {
        if(s1[i]>s2[i])
        return pnf("GREATER"),0;
    if(s1[i]<s2[i])
        return pnf("LESS"),0;
    }
    pnf("EQUAL");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    if((b-a)%2 == 0)
        printf("Alice\n");
    else
        printf("Borys\n");
    return 0;
}


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

int main(){
    int n, k;
    cin >> n >> k;

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

    int sum = 0;
    for(int i=0; i<k; i++){
        sum += a[i];
    }
    cout << sum << endl;
}	

Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define p(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define int long long


using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(ll a, ll n) {//aのn乗を計算します。
	ll x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


const int MOD = 1000000007;

bool arr[1050000];
int sosuu[100010];
void Eratosthenes() {
	ll N = 1050000;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (int i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (int j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (int i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu[c] = i;
			//cout << sosuu[c] << " ";
			c++;
		}
	}
	//cout << endl;
	//cout << c << endl;
}


vector<int> graph[100010];
int a[100010];
int d[100010];
signed main() {
	int K;
	int N; cin >> N;
	ll sum = 0;
	REP(i, N) {
		cin >> a[i];
		sum += a[i];
	}
	if (2 * sum % (N*(N + 1)) != 0) {
		p("NO");
		return 0;
	}
	K = 2*sum / (N*(N+1));
	d[N - 1] = a[0] - a[N - 1];
	REP(i, N - 1) {
		d[i] = a[i + 1] - a[i];
	}
	bool ok = true;
	REP(i, N) {
		if (d[i] > K) {
			ok = false;
			break;
		}
		if ((K - d[i]) % N != 0) {
			ok = false;
			break;
		}
	}
	if (ok) {
		p("YES");
	}
	else p("NO");
}

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

using namespace std;

int x, y;

int main() {
    scanf("%d %d", &x, &y);

    if(x + y > 16 || x > 8 || y > 8) {
        cout << ":(" << endl;
    } else cout << "Yay!" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	pair<int,int> a[n];
	for(int i=0; i<n; i++){
		cin >>  a[i].first;
		a[i].second=i;
	}
	sort(a, a+n);
	int x_index=-1;
	int x_value=0;
	int res=0;
	for(int i=0; i<n; i++){
		if(a[i].first-x_value==1 && x_index<a[i].second){
			res++;
			x_index=a[i].second;
			x_value=a[i].first;
		}
	}
	cout << (res==0? -1: n-res);	
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)2e5 + 9;
const int LOG = 62;
vector<int> idx[N];
int pi[N];
int gr[N];
int arr[N];
bool has[N];
int par[LOG][N];
ll sm[LOG][N];

int main(){
  fastIO;
  int n;
  ll k;
  cin >> n >> k;
  --k;
  int a;
  for(int i = 1; i <= n; i ++ ){
    cin >> a;
    arr[i] = a;
    idx[a].push_back(i);
  }
  for(int i = 1; i < N ; i ++ ){
    if(idx[i].empty()) continue;
    for(int j = 1; j < idx[i].size(); j ++ ){
      pi[idx[i][j-1]] = (idx[i][j] + 1 == n + 1 ? 1 : idx[i][j] + 1);
      gr[idx[i][j-1]] = ((idx[i][j] + 1) == n + 1);
    }
    gr[idx[i].back()] = (idx[i][0] + 1 == n + 1) + 1;
    pi[idx[i].back()] = (idx[i][0] + 1 == n + 1 ? 1 : idx[i][0] + 1);
  }
  for(int i = 1;i <= n; i++ )
    par[0][i] = pi[i], sm[0][i] = gr[i];
  for(int j = 1; j < LOG; j ++ ){
    for(int i = 1; i <= n; i ++ ){
      par[j][i] = par[j - 1][par[j - 1][i]];
      sm[j][i] = sm[j - 1][i] + sm[j - 1][par[j-1][i]];
    }
  }
  int pr = 1;
  for(int t = LOG - 1; t >= 0; t -- ){
    if(sm[t][pr] < k){
      k -= sm[t][pr];
      pr = par[t][pr];
    }
  }
  if(k >= sm[0][pr])pr = par[0][pr];
  vector<int> res;
  for(int i = pr ; i <= n; i ++ ){
    if(!has[arr[i]]){
      res.push_back(arr[i]);
      has[arr[i]] = true;
    }
    else{
      while(has[arr[i]]){
        has[res.back()] = false;
        res.pop_back();
      }
    }
  }
  for(auto x : res)
    cout << x << " ";
  return 0;
}


Measured memory_bytes: 161272
#include<bits/stdc++.h>
using namespace std;
 
void fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}


int main()
{
    fast();
    int k , x  ; 
    cin>>k>>x;
    for(int i = x - (k -1 ); i<= x+k-1 ;i++)
    	cout<<i<<" ";
	return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cout << "[" << #var << "] " << var << endl
const ll mod = 1000000007;


int main(){
    int n, m;
    cin >> n >> m;
    int ans;
    vector<int> fac;
    for (int i=1; i*i<=m; i++) {
        if (m%i==0) {
            fac.push_back(i);
            if (i*i!=m) {
                fac.push_back(m/i);
            }
        }
    }
    sort(fac.begin(), fac.end());
    auto it = upper_bound(fac.begin(), fac.end(), m/n);
    it--;
    ans = *it;
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
t=[[0 for i in range(26)] for i in range(n)]
for i in range(n):
    for c in input():
        t[i][ord(c)-ord('a')]+=1
for i in range(26):
    mn=999999
    for j in range(n):
        mn=min(mn,t[j][i])
    for j in range(mn):
        print(chr(i+ord('a')),end='')
print()

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <tuple>
#include <algorithm>
#include <map>
#include <cmath>
#include <tuple>
using namespace std;
long long int MOD = 1000000000 + 7;
using ll = long long;
ll LARGE = 1000000;


int main() {
	ll n, k;
	cin >> n >> k;
	if (k == 1 || n == 1) {
		cout << 1;
		return 0;
	}
	cout << (k * n + 1) / 2;
	return 0;
}


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

int main()
{
  int A, B;
  char S[12];
  
  scanf("%d %d", &A, &B);
  scanf("%s", S);
  if(S[A] != '-') printf("No\n");
  else
  {
    int len = strlen(S);
    bool IsValid = true;
    
    for(int i=0;i<len;i++)
    {
      if(i == A) continue;
      if(S[i] < '0' || S[i] > '9')
      {
        IsValid = false;
        break;
      }
    }
    
    if(IsValid) printf("Yes\n");
    else printf("No\n");
    
  }
  return 0;
}

Measured memory_bytes: 256
import math

def isprime(N):
	if N == 2:
		return True
	if N <= 1 or N % 2 == 0:
		return False
	lim = int(math.sqrt(N))
	for i in range(3, lim + 1, 2):
		if N % i == 0:
			return False
		i += 2
	return True

N = int(input())
ans = 0
for i in range(N):
	ans += int(isprime(int(input())))
print(ans)




Measured memory_bytes: 5672
// #define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto&& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto&& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<lint> a(n); std::cin>>a;
  int count = 0;
  for (lint x : a) {
    if (x < 0) count++;
  }
  for (lint & x : a) {
    if (x < 0) x = -x;
  }

  lint sum = std::accumulate(all(a),0ll);
  if (count % 2 == 1) {
    lint min = *std::min_element(all(a));
    sum -= 2 * min;
  }
  std::cout << sum << std::endl;
  return 0;
}

Measured memory_bytes: 1024
N,X=map(int,input().split())
L=[int(i) for i in input().split()]
S=[0 for i in range(N+1)]
for i in range(N):
    S[i+1]=S[i]+L[i]
ans=0
for i in range(N+1):
    if S[i]<=X:
        ans+=1
print(ans)


Measured memory_bytes: 38384
n,t = map(int, input().split())
CT = [list(map(int, input().split())) for i in range(n)]
C = []
for i in range(n):
  if CT[i][1] <= t:
    C.append(CT[i][0])
if all(CT[i][1] > t for i in range(n)) == True:
  print("TLE")
else:
  print(min(C))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=1010,M=1e9+7,OO=1e18;
struct ed{
    int x,y,w;
}es[N+N];
int p[N],rk[N];
vector<pii> g[N];
int get(int x){return x==p[x]?x:(p[x]=get(p[x]));}
bool un(int x,int y){
    if((x=get(x))==(y=get(y)))return 0;
    if(rk[x]<rk[y])swap(x,y);
    rk[x]+=(rk[x]==rk[y]),p[y]=x;
    return 1;
}
int mst(int n,int m,int good){
    for(int i=1;i<=n;++i)p[i]=i,rk[i]=0;
    int w=0;
    if(good!=-1){
        un(es[good].x,es[good].y);
        w+=es[good].w;
    }
    forn(i,m){
        if(un(es[i].x,es[i].y)){
            g[es[i].x].pb(es[i].y,es[i].w);
            g[es[i].y].pb(es[i].x,es[i].w);
            w+=es[i].w;
        }
    }
    for(int i=1;i<=n;++i)if(get(i)!=get(1))return OO;
    return w;
}
int32_t main(){
    int n,m,tar;
    cin>>n>>m>>tar;
    forn(i,m)cin>>es[i].x>>es[i].y>>es[i].w;    
    sort(es,es+m,[](const ed&p1,const ed&p2){return p1.w<p2.w;});
    int w=mst(n,m,-1);
    int cnt=0,ans=1,ov=0;
    if(w==tar){
        forn(i,m)if(mst(n,m,i)==w)cnt++;
        forn(i,cnt)(ans*=2)%=M;
        ans-=2;
        forn(i,m-cnt)(ans*=2)%=M;
        ans+=M;
        ans%=M;
    }else{
        forn(i,m){
            int res=mst(n,m,i);
            if(res==tar)cnt++;
            if(res>tar)ov++;
        }
        forn(i,cnt)(ans*=2)%=M;
        ans--;
        forn(i,ov+1)(ans*=2)%=M;
        ans+=M;
        ans%=M;
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 75940
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<climits>
#define MOD 1000000007
typedef long long ll;
using namespace std;

const int MAX = 200005;
int N,K;
ll modK[MAX];
int main(){
  cin >> N >> K;
  for(int i=1;i<=N;i++) modK[i%K]++;
  
  ll ans = 0;
  for(int a=0;a<K;a++){
    int b = (K-a)%K;
    int c = (K-a)%K;
    if((b+c)%K != 0) continue;
    ans += modK[a] * modK[b] * modK[c];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
use proconio::input;
use std::cmp;

fn main() {
    input! {
        n: usize,
        mut com: [isize; 3],
        l: [isize; n],
    }
    com.sort_by(|a, b| b.cmp(a));
    let mut v: Vec<usize> = vec![];
    let ans = solve(0, n, &mut v, &l, &com);
    println!("{}", ans);
}

fn solve(
    index: usize,
    limit: usize,
    v: &mut Vec<usize>,
    l: &Vec<isize>,
    target: &Vec<isize>,
) -> isize {
    let mut res = std::isize::MAX;

    if index == limit {
        let mut cost = 0;
        let mut com = vec![0isize; 3];
        for i in 0..limit {
            match v[i] {
                0 => {
                    com[0] += l[i];
                    cost += 10;
                }
                1 => {
                    com[1] += l[i];
                    cost += 10;
                }
                2 => {
                    com[2] += l[i];
                    cost += 10;
                }
                _ => (),
            };
        }
        if com.iter().any(|x| *x == 0) {
            return std::isize::MAX;
        }
        com.sort_by(|a, b| b.cmp(a));
        for i in 0..3 {
            cost += (com[i] - target[i]).abs();
        }
        return cost - 30;
    }

    for i in 0..4 {
        v.push(i);
        res = cmp::min(res, solve(index + 1, limit, v, l, target));
        v.pop();
    }

    res
}


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

public class Main {

	public void go() {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();

		PriorityQueue<Double> queue = new PriorityQueue<>();
		for (int i = 0; i < x; i++) {
			queue.add(sc.nextDouble());
		}

		while (queue.size() != 1) {
			Double a = queue.poll();
			Double b = queue.poll();
			queue.add((a + b) / 2);
		}

		System.out.println(queue.poll());

	}

	public static void main(String[] args) throws IOException {

		Main m = new Main();
		m.go();
	}

}


Measured memory_bytes: 25044
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// 入力
		Scanner sc = new Scanner(System.in);
		double cx = sc.nextDouble();
		double cy = sc.nextDouble();
		double r = sc.nextDouble();
		int q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			double x1 = sc.nextDouble();
			double y1 = sc.nextDouble();
			double x2 = sc.nextDouble();
			double y2 = sc.nextDouble();
			System.out.println(solve(cx, cy, r, x1, y1, x2, y2));
		}
		sc.close();
	}

	static class Vector2d {
		Vector2d(double x, double y) {
			this.x = x;
			this.y = y;
		}

		double x;
		double y;

		public String toString() {
			return String.format("%1$.6f %2$.6f", x, y);
		}

		public static double product(Vector2d v1, Vector2d v2) {
			return v1.x;
		}

	}

	static class Vector2dComparator implements Comparator<Vector2d> {
		@Override
		public int compare(Vector2d v1, Vector2d v2) {
			double x = v1.x - v2.x;
			double y = v1.y - v2.y;
			if (x == 0) {
				if (y < 0) {
					return -1;
				} else {
					return 1;
				}
			} else if (x < 0) {
				return -1;
			} else {
				return 1;
			}
		}
	}

	public static String solve(double cx, double cy, double r, double x1, double y1, double x2, double y2) {
		List<Vector2d> ans = new ArrayList<>();
		double lx = x2 - x1;
		double ly = y2 - y1;
		double pcx = cx - x1;
		double pcy = cy - y1;
		double lSqNorm = lx * lx + ly * ly;
		double discriminant = Math.sqrt(r * r * lSqNorm - Math.pow(lx * pcy - ly * pcx, 2));
		double k1 = (lx * pcx + ly * pcy + discriminant) / lSqNorm;
		double k2 = (lx * pcx + ly * pcy - discriminant) / lSqNorm;
		ans.add(new Vector2d(x1 + k1 * (x2 - x1), y1 + k1 * (y2 - y1)));
		ans.add(new Vector2d(x1 + k2 * (x2 - x1), y1 + k2 * (y2 - y1)));
		ans.sort(new Vector2dComparator());
		return String.format("%1$.8f %2$.8f %3$.8f %4$.8f", ans.get(0).x, ans.get(0).y, ans.get(1).x, ans.get(1).y);
	}


}



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

int main() {
   int a,b,c;
  string s;
  cin>>a>>b;
  c=1;
  int count=0;
 
  while(c<b){
  	c = c-1;
    c += a;
    count++;
  }
  
  cout<<count<<endl;
  
}
  

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
using namespace std;
typedef pair<ll, ll> P;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main(void){
	int n, ans = 0;
	string s;
	set<char>alpha;
	cin >> n >> s;
	for (int i = 0;i < s.length() - 1;i++) {
		int num = 0;
		for (int j = 0;j <= i;j++) {
			alpha.insert(s[j]);
		}
		for (int j = i + 1;j < s.length();j++) {
			if (alpha.count(s[j]) == 1) {
				num++;
				alpha.erase(s[j]);
			}
		}
		ans = max(ans, num);
		alpha.clear();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// luogu-judger-enable-o2
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<map>
#include<queue>
#define For(i,j,k)	for(int i=j;i<=k;++i)
#define Dow(i,j,k)	for(int i=k;i>=j;--i)
#define ll long long
#define inf 1e9
using namespace std;
inline ll read()
{
	ll t=0,f=1;char c=getchar();
	while(!isdigit(c))	{if(c=='-')	f=-1;c=getchar();}
	while(isdigit(c))	t=t*10+c-'0',c=getchar();
	return t*f;
}
inline void write(ll x){if(x<0)	{putchar('-');write(-x);return;}if(x>=10)	write(x/10);putchar(x%10+'0');}
inline void writeln(ll x){write(x);puts("");}
inline void write_p(ll x){write(x);putchar(' ');}
int f[201][201],n,x[2001],y[2001],use[2001],vis[2001];
inline bool dfs(int x)
{
	For(i,1,n)
	{
		if(f[x][i]&&!use[i])
		{
			use[i]=1;
			if(!vis[i]|| dfs(vis[i]))
			{
				vis[i]=x;
				return 1;
			}
		}
	}
	return 0;
}
int main()
{
	n=read();
	For(i,1,n)	x[i]=read(),y[i]=read();
	For(i,1,n)	x[i+n]=read(),y[i+n]=read();
	For(i,1,n)	
		For(j,n+1,n+n)
		{
			if(x[i]<x[j]&&y[i]<y[j])	f[i][j-n]=1;
		}
	int ans=0;
	For(i,1,n)
	{
		memset(use,0,sizeof use);
		if(dfs(i))	ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main (void) {
    long long N;
    cin >> N;

    long long digit_sum = 0;
    long long tmp = N;

    while ( tmp != 0 ) {
        digit_sum += tmp % 10;
        tmp /= 10;
    }

    if ( N % digit_sum == 0 )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include <ios>
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>
#include <iomanip>

typedef long long ll;

using namespace std;

int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    double theta_h = (H * 60 + M) * M_PI / 360;
    double hx = A * cos(theta_h);
    double hy = A * sin(theta_h);
    double theta_m = M * M_PI / 30;
    double mx = B * cos(theta_m);
    double my = B * sin(theta_m);
    cout << fixed << setprecision(20) << sqrt(pow(hx - mx, 2) + pow(hy - my, 2)) << endl;
    return 0;
}



Measured memory_bytes: 4124
import sys
from collections import deque
n = int(sys.stdin.readline())
lines = sys.stdin.readlines()

Q = deque()
for i in range(n):
    command = lines[i].split()
    if command[0] == 'insert':
        Q.appendleft(command[1])
    elif command[0] == 'delete':
        try:
            Q.remove(command[1])
        except:
            pass
    elif command[0] == 'deleteFirst':
        Q.popleft()
    elif command[0] == 'deleteLast':
        Q.pop()
print(' '.join(Q))

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

using ll = long long int;
using vi = vector<int>;
using vll = vector<long long int>;
using vii = vector<vi>;
using pii = pair<int, int>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int MOD = 1e9 + 7;

const int M = 1e5 + 2;

int main(){
  int n; cin >> n;
  vector<int> A(M, 0);
  int k;
  REP(i, n){
    scanf("%d", &k);
    A.at(k)++;
    A.at(k + 1)++;
    A.at(k + 2)++;
  }
  int ans = *max_element(A.begin(), A.end());
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))

if N==1:
    print(0)
else:
    B = [A[i]-i for i in range(N)]
    B.sort()
    b_pl = B[N//2]
    b_mn = B[N//2-1]
    
    sadness_pl = sum([abs(B[i]-b_pl) for i in range(N)])
    sadness_mn = sum([abs(B[i]-b_mn) for i in range(N)])
    
    print(min(sadness_pl, sadness_mn))

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

using namespace std;

vector< int > g[1001];
int sz[1001], num[1001];

void Latte(int &idx, int cnt)
{
  int now = idx, dd;
  num[cnt] = now;
  for(int i = 0; i < sz[now] - 1; i++) {
    cin >> dd;
    if(dd < 0) {
      --sz[num[dd + cnt]];
      g[num[dd + cnt]].push_back(now);
      g[now].push_back(num[dd + cnt]);
    } else if(dd > 0) {
      sz[++idx] = dd;
      g[now].push_back(idx);
      g[idx].push_back(now);
      Latte(idx, cnt + 1);
    } else {
      throw (0);
    }
  }
}

int main()
{
  int T;
  cin >> T;
  while(T--) {
    memset(sz, 0, sizeof(sz));
    memset(num, 0, sizeof(num));
    for(int i = 0; i < 1001; i++) g[i].clear();

    cin >> sz[0];
    int idx = 0;
    try {
      Latte(idx, 0);
      cin >> sz[0];
    } catch(int x) {};
    for(int i = 0; i <= idx; i++) {
      sort(begin(g[i]), end(g[i]));
      cout << i + 1;
      for(int j : g[i]) cout << " " << j + 1;
      cout << endl;
    }
  }
}

Measured memory_bytes: 3084
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

k,n = mi()
a = li()

b = 0
tmp = 0
am = a[0]
for i in range(1,n):
    tmp = a[i] -a[i-1]
    am = max(am,tmp)
am = max(am,k -  a[-1] + a[0])

print(k-am)


Measured memory_bytes: 77388
import java.io.*;
 
public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    long n = Long.parseLong(br.readLine());
    
    long result = 0;
    
    for (long i=1; i<=n; i++){
      if (i % 3 != 0 && i % 5 != 0){
        result += i;
      }
    }
    System.out.println(result);
  }
}

Measured memory_bytes: 32568
#include <bits/stdc++.h>
#define pb emplace_back
#define mp make_pair

using namespace std;

int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10);
	int n; cin >> n;
	vector<int> a(n); for (int o = 0; o < n; o++) { cin >> a[o]; }
	for (int i = 1; i < n; ++i) {
		a[i] += a[i - 1];
	}
	int su = 10000000;
	for (int i = 0; i < n - 1; ++i) {
		su = min(abs(a[n - 1] - 2 * a[i]), su);
	}
	cout << su;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define MOD (long long)(1e9+7)
using namespace std;

ll n,k,vis[5005];
ll p[5005],c[5005],sum[5005],ans=-1e18;
int main(){
    cin >> n >> k;
    for(int i=1; i<=n; i++) cin >> p[i];
    for(int i=1; i<=n; i++) cin >> c[i];
    for(int i=1; i<=n; i++){
        ll s=c[i];
        vector<ll> t; t.push_back(s);
        for(int j=p[i]; j!=i; j=p[j]) s+=c[j],t.push_back(s);
        int len=t.size();
        for(int j=0; j<len; j++){
            ll rest=k-j-1;
            if(rest<0) break;
            ans=max(ans,t[j]+(rest/len)*max(s,0LL));
        }
    }
    cout << ans;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<int>>;
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; }
// 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;}

Graph G;
int color[100050];

bool dfs(int v, int c) {
  color[v] = c;
  for (auto e : G[v]) {
    if (color[e] == c) return false;
    if (color[e] == 0 && !dfs(e, -c)) return false;
  }
  return true;
}

int main(void){
  ll n,m; cin >> n >> m;
  G.assign(n,vector<int>());
  FOR(i,0,m-1){
    int a,b; cin >> a >> b;
    --a; --b;
    G[a].PB(b);
    G[b].PB(a);
  }
  FOR(i,0,n-1){
    if(color[i]==0){
      if(!dfs(i,1)){
        cout << n*(n-1)/2 - m << "\n";
        return 0;
      }
    }
  }
  ll color1 = 0;
  FOR(i,0,n-1) if(color[i]==1) ++color1;
  cout << color1 * (n-color1) - m << "\n";
}


Measured memory_bytes: 6528
x,y=map(int,input().split())
if x%y==0:
  print(-1)
else:
  flag=0
  for i in range(10**18//x):
    if (i*x)%y!=0:
      print(i*x)
      flag=1
      break
  if flag==0:
    print(-1)
      

Measured memory_bytes: 2940
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int a;
    cin >> a;
    string s;
    cin >> s;

    if (a < 3200) {
        cout << "red" << "\n";
    } else {
        cout << s << "\n";
    }

    return 0;
}

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

int main(){
	int N;
  	cin >> N;
  	stringstream ss;
  	ss << N;
  	char s = (ss.str())[ss.str().size()-1];
  	
  	if(s =='0' || s=='1' || s=='6' || s=='8')
        cout<<"pon"<<endl;
  	else if(s =='3')
        cout<<"bon"<<endl;
	else
        cout<<"hon"<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
string s;
int main()
{
    cin>>s;
    if (s.length()%2) return 0*puts("No");
    for (int i=0;i<(int)s.length();i+=2)
        if (s[i]!='h'||s[i+1]!='i')
            return 0*puts("No");
    return 0*puts("Yes");
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

const int MAXN = 200010;
int res[MAXN];

int n, x;

set<int> used;

int main() {
    GI(n); GI(x);

    FOR1(i, 2 * n - 1) used.insert(i);

    if (x == 1 || x == 2 * n - 1) {
        printf("No\n");
        return 0;
    }
    else {
        printf("Yes\n");
        memset(res, 0, sizeof res);

        res[n-1] = x-1; used.erase(x-1);
        res[n] = x; used.erase(x);
        res[n+1] = x+1; used.erase(x+1);

        if (n > 2) {
            if (x + 2 <= n) {
                res[n-2] = x+2; used.erase(x+2);
            }
            else { // x-2 >= 1
                res[n+2] = x-2; used.erase(x-2);
            }
        }

        FOR1(i, 2 * n - 1) {
            if (res[i] == 0) {
                res[i] = *used.begin();
                used.erase(res[i]);
            }

            printf("%d\n", res[i]);
        }
    }
    
    return 0;
}

Measured memory_bytes: 11648
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)

/*
bool isprime(int x){
	for(int i = 2;i*i<=x;i++){
		if(x%i == 0)return false;
	}
	return x!=1;
}
int gcd(int a, int b) 
{ 
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    if (a == b) 
        return a; 
   
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
} 
void dfs(int x,int y){
		if(x == n+1){
			int tmp = 0;
			FOR(i,0,k){
				if(tmp1[mortyy[i]]-tmp1[morty[i]] == mortyyy[i])tmp+=mortyyyy[i];
			}
			rick = max(rick,tmp);
			return ;
		}
		int i;
		for(i = y;i<=n1;i++){
			tmp1[x] = i;
			dfs(x+1,i);
		}
	}
*/


//3111111111111111111111111111111


	void solve(){

		ini(n);
		FOR(i,0,1000){
			FOR(i1,0,1000){
				if(pow(i,5)+pow(i1,5) == n){
					return out(i,-i1);
				}
			}
		}
		FOR(i,0,1000){
			FOR(i1,0,i+1){
				if(pow(i,5)-pow(i1,5) == n){
					return out(i,i1);
				}
			}
		}





	}









































int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}

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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int r; cin >> r;
	cout << r * r << endl;
} 

Measured memory_bytes: 256
N = int(input())
S = input()
cnt = 0

for i in range(1000):
    str_i = '{:03}'.format(i)
    found = 0
    for s in S:
        if(s==str_i[found]):
            found += 1
            if(found == 3):
                cnt += 1
                break
print(cnt)      

Measured memory_bytes: 41180
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

signed main(){
    ll n,k;
    cin >> n >> k;
    ll a[n];
    rep(i,0,n) cin >> a[i];

    double ans = 0,memo = 0;
    rep(i,0,k){
        memo += a[i];
    }
    ans = (memo+k)/2.0;

    rep(i,k,n){
        memo -= a[i-k];
        memo += a[i];
        ans = max(ans,(memo+k)/2.0);
    }

    cout << setprecision(15) << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


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

  int n;
  cin>>n;
  int ans=0;
  int s=n/25;
  ans+=s;
  n-=s*25;
  s=n/10;
  ans+=s;
  n-=s*10;
  s=n/5;
  ans+=s;
  n-=s*5;
  ans+=n;

  cout<<ans<<endl;

}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()





int main() {
    int a, b;
    cin >> a >> b;
    cout << max({a + b, a - b, a * b}) << endl;
    return 0;
}





Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

sys.setrecursionlimit(100005)

n, k = na()
g = [[] for _ in range(n)]
for i in range(n-1):
    a, b = na()
    g[a-1].append(b-1)
    g[b-1].append(a-1)


# res
def dfs(cur, pre, k, g):
    mod = 1000000007
    ret = 1
    nc = 0 if pre == -1 else 1
    for e in g[cur]:
        if e == pre:
            continue
        nc += 1
        ret = ret * (k-nc) % mod
        ret = ret * dfs(e, cur, k, g) % mod
    return ret % mod


print(dfs(0, -1, k, g) * k % 1000000007)


Measured memory_bytes: 92924
import java.util.*;

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

class Solver {

    private int count2(int v, Map<Integer, Integer> m) {
        if (v % 2 == 1) return 0;
        else if (m.containsKey(v)) return m.get(v);
        else {
            int ret = (count2(v/2, m) + 1);
            m.put(v, ret);
            return ret;
        }
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int N = S.length();

        List<Integer> A = new ArrayList<Integer>();

        for (int i = 0; i + 2 < N; i++) {
            char ch1 = S.charAt(i);
            char ch2 = S.charAt(i + 1);
            char ch3 = S.charAt(i + 2);
            // i: base of parsing
            int v = (ch1 - '0') * 100;
            v += (ch2 - '0') * 10;
            v += (ch3 - '0') * 1;

            A.add(v);
        }


        int min = Integer.MAX_VALUE;
        for (int a : A) {
            min = Math.min(min, Math.abs(a - 753));
        }

        System.out.println(min);

        return;
    }

}

Measured memory_bytes: 21844