akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

// find_by_order(k) returns the iterator to the kth largest element (start from 0)
// order_of_key(k) returns the number of elements in the set which are strictly less than the value k

using namespace std;
using namespace __gnu_pbds;

#define ff              first
#define ss              second
#define all(v)          v.begin(), v.end()
#define int             long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mem(dp,x)       memset(dp,x,sizeof dp);
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define rightmostbit(x) __builtin_ffsll(x)
#define mod             1000000007
#define inf             1e18
#define pi              3.141592653589793238
#define mk(a,n)         int n;cin>>n;vi a(n);for(int i=0;i<n;i++) cin>>a[i]
#define w(x)            int x; cin>>x; while(x--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

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

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void g_b()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}
// .Always initialize dp array
// 1, 1, 2, 5, 14, 42, 132, 429, 1430, CATALAN NUMBER
bool vis[100005];
vi adj[100005];
int dp[100005];
void dfs(int node)
{
	dp[node] = 0;
	vis[node] = 1;
	for (auto child : adj[node])
	{
		if (!vis[child])
			dfs(child);
		dp[node] = max(dp[node] , 1 + dp[child] );
	}
}
int32_t main()
{
	g_b();
	int n , m ; cin >> n >> m;
	for (int i = 1; i <= m; i++)
	{
		int u, v; cin >> u >> v;
		adj[u].pb(v);
	}
	for (int i = 1; i <= n; i++)
	{
		if (!vis[i])
			dfs(i);
	}
	int ans = -1;
	for (int i = 1; i <= n; i++)
	{
		ans = max(ans, dp[i]);
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 12660
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}


unordered_map<ll,int> prime_factor(ll n){
    unordered_map<ll,int> ret;
    for(ll j=2; j<=n; j++){
    int pos=j;
    for(ll i=2; i*i<=pos; i++){
        while(pos % i == 0){
            ret[i]++;
            pos /= i;
        }
    }
    if(pos != 1) ret[pos]++;
    }
    return ret;
}

main() {
    ll ans=0;
    int N; cin >> N;
    ll a=0,b=0,c=0,d=0,e=0;
    for(auto p:prime_factor(N)){
        if(p.second>=2)a++;
        if(p.second>=4)b++;
        if(p.second>=14)c++;
        if(p.second>=24)d++;
        if(p.second>=74)e++;
    }
    if(a>=3 && b>=2) ans+=(a-2)*b*(b-1)/2;
    if(b>=2) ans+=(b-1)*c; 
    if(a>=2) ans+=(a-1)*d; 
    ans+=e;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

long long floor_sum(long long n, long long m, long long a, long long b){
    long long ans = 0;
    if(a >= m){
        ans += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if(b >= m){
        ans += n * (b / m);
        b %= m;
    }

    long long y_max = (a * n + b) / m, x_max = (y_max * m - b);
    if(y_max == 0)  return ans;
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
    return ans;
}

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

    int T;
    cin >> T;
    for(int i = 0; i < T; ++i){
        int N, M, A, B;
        cin >> N >> M >> A >> B;
        cout << floor_sum(N, M, A, B) << '\n';
    }
}

Measured memory_bytes: 3612
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author varunvats32
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BPapersPlease solver = new BPapersPlease();
        solver.solve(1, in, out);
        out.close();
    }

    static class BPapersPlease {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            for (int i = 1; i <= n; i++) {
                int num = in.nextInt();
                if (num % 2 == 0) {
                    if (!(num % 3 == 0 || num % 5 == 0)) {
                        out.println("DENIED");
                        return;
                    }
                }
            }
            out.println("APPROVED");
        }

    }
}



Measured memory_bytes: 23892
#include<fstream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string.h>
#include<cstring>
#include<iostream>
#include<stack>
#include<string>
#include<map>
#include<set>

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pin;
typedef std::pair<int,std::pair<int, int> > ppin;

using namespace std;


int main(){
    
    int n;
    cin>>n;
    
    while(n--){
        int m;
        cin>>m;
        int a=0,b=0;
        m-=2;
        int tem,t2;
        cin>>tem>>t2;
        a=max(a,tem-t2);
        b=max(b,t2-tem);
        while(m--){
            tem=t2;
            cin>>t2;
            a=max(a,tem-t2);
            b=max(b,t2-tem);
        }
        cout<<b<<" "<<a<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n;
    cin >> n;
    int x[n],y[n],p[n],N=1ll<<n;
    for(int i=0;i<n;i++)
    	cin >> x[i] >> y[i] >> p[i] ;
    int ans[n+1],mx[N][n]={0},my[N][n]={0};
    fill(ans,ans+n+1,1e18);
    for(int s=0;s<N;s++){
    	for(int i=0;i<n;i++){
    		int u=min(abs(x[i]),abs(y[i]))*p[i];
    		int v=u;
    		for(int j=0;j<n;j++){
    			if(s&(1ll<<j)){
    				u=min(u,abs(x[i]-x[j])*p[i]);
    				v=min(v,abs(y[i]-y[j])*p[i]);
    			}
    		}
    		mx[s][i]=u,my[s][i]=v;
    	}
    }
    for(int s=0;s<N;s++){
    	int m=N-1-s;
    	for(int t=m;;t=(t-1)&m){
    		int r=0;
    		for(int i=0;i<n;i++)
    			r+=min(mx[s][i],my[t][i]);
    		int c=__builtin_popcount(s)+__builtin_popcount(t);
    		ans[c]=min(ans[c],r);
    		if(!t)break;
    	}
    }
    for(int i=0;i<=n;i++)
    	cout << ans[i] << '\n';
}


Measured memory_bytes: 11276
#include <iostream>

using namespace std;

int main(void)
{
  int N, M;
  int L[100000];
  int R[100000];
  int smallest, biggest;
  int ans;
  cin >> N >> M;
  for(int i = 0; i < M; i++)
    cin >> L[i] >> R[i];
  smallest = L[0];
  for(int i = 1; i < M; i++)
    if(L[i] > smallest)
      smallest = L[i];
  biggest = R[0];
  for(int i = 1; i < M; i++)
    if(R[i] < biggest)
      biggest = R[i];
  ans = biggest - smallest + 1;
  if(ans < 0)
    cout << 0;
  else
    cout << ans;

  return 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int mod = 1000000007;

int main(){
    ll lm=0,rm=100009;
    ll n,m;
    cin>>n>>m;
    rep(i,m){
        ll l,r;
        cin>>l>>r;
        lm = max(l,lm);
        rm = min(r,rm);
    }
    ll dm = max(0LL,rm-lm+1);
    cout<<dm<<endl;
}


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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 3e3 + 5;
const int M = 998244353;
int n, s;
int arr[maxr], dp[maxr][maxr];
int pre1, pre2;

int power(int a, int b) {
	if (a == 0)
		return 0;
	if (b == 0)
		return 1;
	int small = power(a, b / 2);
	int ans = (small * small) % M;
	if ((b & 1))
		ans = (a * ans) % M;

	return ans;
}

int solve(int idx, int sum) {
	if (sum < 0)
		return 0;

	if (idx == n) {
		if (sum == 0)
			return pre2;
		return 0;
	}
	int & ans = dp[idx][sum];
	if (ans > -1)
		return ans;
	ans = 0;
	int a = solve(idx + 1, sum);
	int b = (solve(idx + 1, sum - arr[idx]) * pre1) % M;
	ans = (a + b) % M;
	return ans;
}

int32_t main()
{
	GO;
	cin >> n >> s;
	for (int i = 0; i < n; i++)
		cin >> arr[i];

	pre1 = power(2, M - 2);
	pre2 = power(2, n);
	memset(dp, -1, sizeof(dp));
	int ans = solve(0, s);
	cout << ans << endl;
	return 0;
}

//!

Measured memory_bytes: 74376
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,m,ans = 1;
	cin >> n >> m;
	if(abs(n - m) >= 2){
		cout << 0 << endl;
		return 0;
	}
	for(int i = 1;i <= n;i++) ans = (ans * i) % MOD;
	for(int i = 1;i <= m;i++) ans = (ans * i) % MOD;
	if(n == m) ans = (ans * 2) % MOD;
	cout << ans << endl;
	return 0;
}

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

// ---------------------------template starts here-------------------------- 

#define int long long int
#define pb push_back
#define MAX INT_MAX
#define F first
#define S second 
#define mp make_pair
#define MIN INT_MIN
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

set <int> s;
bool ar[100001];
void seive() {
    ar[0] = ar[1] = true;

    for(int p=2; p*p<=100001; p++) {
        if(ar[p] == false) {
            for(int i=p*p;i<=100001;i+=p)
                ar[i] = true ;
        }
    }

    for(int p=2;p<=100001;p++) {
        if(ar[p] == false)
            s.insert(p);
    }
}

bool is_palindrome(string str) {
    int len = str.length();
    for(int i=0;i<=len/2;i++) {
        if(str[i] != str[len-1-i])
            return false;
    }
    return true;
}

// --------------------------template ends here------------------------------

void solve() {
    int n;
    cin >> n;
    vector <int> v(n);
    int f[200001] = {0};
    for(int i=0;i<n;i++) {
        cin >> v[i];
        f[v[i]]++;
    }
    int c=0;
    for(int i=0;i<200001;i++) {
        if(f[i] >= 2)
            c += f[i]*(f[i]-1)/2;
    }
    // cout << c << endl;
    for(int i=0;i<n;i++) {
        int x = f[v[i]];
        cout << c - x*(x-1)/2 + (x-1)*(x-2)/2;
        cout << endl;
    }   
    return;
}
int32_t main() {
    FO;
    solve();
    return 0;
}

Measured memory_bytes: 5760
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

void Eratosthenes(vi& isp)
{
	isp[0]=isp[1]=0;
	fill(2+all(isp),1);
	for(int i=2;i*i<isp.size();i++)
		if(isp[i])
			for(int j=i*i;j<isp.size();j+=i)
				isp[j]=0;
}

int main()
{
	vi isp(123456*2);
	Eratosthenes(isp);
	vi ps;
	rep(i,isp.size()) if(isp[i])
		ps.push_back(i);
	
	for(int n;cin>>n,n;)
		cout<<upper_bound(all(ps),2*n)-upper_bound(all(ps),n)<<endl;
	
	return 0;
}

Measured memory_bytes: 2328
from copy import deepcopy
import itertools

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






def main():
    h,w,k = mi()
    slist = []

    for i in range(h):
        tmp = list(input())
        slist.append(tmp)

    anslist = [[0 for i in range(w)] for j in range(h)]  

    flag = True
    count = 0
    pcount = 1
    lplace = []

    for i in range(h):
        place = []

        for j in range(w):
            if slist[i][j] == '#':
                place.append(j)
        if not place:
            count+=1
            continue
        np = 0
#        print(place)
        for e,j in enumerate(place):
            if e == len(place)-1:
                for tate in range(i-count,i+1):
                    for yoko in range(np,w):
                        anslist[tate][yoko] = pcount
                        #print(tate,yoko)
                pcount+=1
            else:
#                print('yes')
                for tate in range(i-count,i+1):
                    for yoko in range(np,j+1):
                        anslist[tate][yoko] = pcount
                pcount+=1
                np = j+1
        lplace = deepcopy(place)
        count = 0

#        print(anslist)

    pcount-=1


    if not count == 0:
        np = 0
        for e,j in enumerate(lplace):
            if e == len(lplace)-1:
                for tate in range(i-count,i+1):
                    for yoko in range(np,w):
                        anslist[tate][yoko] = pcount
            else:
                for tate in range(i-count,i+1):
                    for yoko in range(np,j+1):
                        anslist[tate][yoko] = pcount-len(lplace)+1+e
                np = j+1

    for i in range(h):
        print(*anslist[i])


main()


Measured memory_bytes: 8792
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

int main(){

    int n,result=0;
    cin >> n;

    if(n==10||n==100||n==1000||n==10000||n==100000){
        cout << 10 << endl;
        return 0;
    }
    while(n%10!=n){
        result += n % 10;
        n /= 10;
    }
    result += n;
    cout << result << endl;
    

    return 0;
}

Measured memory_bytes: 888
def min(a,b); a < b ? a : b; end
def max(a,b); a > b ? a : b; end

A,B,C,X,Y = gets.split.map(&:to_i)

if A + B <= 2 * C
  puts A * X + B * Y
else
  m = min(X, Y)
  puts min(max(X - m, 0) * A + max(Y - m, 0) * B + 2 * m * C, 2 * max(X,Y) * C )
end


Measured memory_bytes: 1788
a = list(range(13))
b = []
for i in a:
    num = int(str(i) + '0') % 13
    l = []
    for j in range(13):
        l.append((num+j)%13)
    b.append(l)

s = input()
MOD = 10**9+7
dp = [[0 for _ in range(13)] for _ in range(len(s))]
if s[0] == '?':
    for i in range(10):
        dp[0][i] += 1
else:
    dp[0][int(s[0])] += 1

for i in range(1, len(s)):
    if s[i] == '?':
        for j in range(13):
            for k in range(10):
                dp[i][b[j][k]] += dp[i-1][j]
                dp[i][b[j][k]] %= MOD
    else:
        for j in range(13):
            n = b[j][int(s[i])]
            dp[i][n] += dp[i-1][j]
            dp[i][n] %= MOD
print(dp[-1][5]%MOD)


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

using namespace std;

typedef long long ll;

const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T>
inline void chkmin(T&a, T b) { a = a < b ? a : b; }

const int MAXN = 100010;

int a[MAXN];

inline bool cmp(int a, int b) { return a > b; }

int main() {
#ifdef LOCAL
	FILE("");
#endif

	int n = ri;
	for(int i = 1; i <= n; i++) a[i] = ri;
	sort(a + 1, a + 1 + n, cmp);

	int pos = 1;
	while(a[pos + 1] >= pos + 1) ++pos;
	int U = a[pos] - pos, R = 0;
	while(a[pos + R + 1] >= pos) ++R;
	if((U & 1) || (R & 1)) puts("First");
	else puts("Second");
	return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scn = new Scanner(System.in);

        int x = scn.nextInt();
        int y = scn.nextInt();
        int ans = 1;

        while(true){
            if(x == 0) {
                ans = y;
                break;
            }
            if(y == 0) {
                ans = x;
                break;
            }

            if(x > y){
                x %= y;
            }
            else{
                y %= x;
            }
        }

        System.out.println(ans);

    }
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}

int main() {
  int N, X; cin >> N >> X;
  vector<int> L(N); REP(i, N) cin >> L[i];

  int bound = 1;
  int div = 0;

  for(int i = 0; i < N; ++i) {
    div += L[i];
    if(div <= X) bound++;
    else break;
  }
  cout << bound << endl;
}

Measured memory_bytes: 256
while 1:
    input = raw_input()
    num = len(input)
    input = int(input)
    
    if input == 0:
        break
        
    count = 0
    for i in range(num, 0, -1):
        value = int(input / 10**(i-1))
        input -= value * 10 ** (i-1)
        count += value

    print(count)

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

int main()
{
    int K;
    cin >> K;
    queue<long long> q;

    // init
    int counter = 0;
    for (int i = 1; i < 10; i++)
    {
        q.push(i);
        counter += 1;
        if (counter == K)
        {
            cout << i << endl;
            return 0;
        }
    }

    // breadth first search
    while (true)
    {
        long long x = q.front();
        q.pop();
        rep(i, 10)
        {
            if (abs(x % 10 - i) <= 1)
            {
                q.push(x * 10 + i);
                counter += 1;
                if (counter == K)
                {
                    cout << x * 10 + i << endl;
                    return 0;
                }
            }
        }
    }
}


Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <set>

using namespace std;

const int MAXN = 200 + 100;
const int MOD = 998244353;

struct Point
{
	int x, y;
	Point(int _x = 0, int _y = 0) : x(_x), y(_y)
	{}
};

typedef Point Vector;

Vector operator - (const Vector &a, const Vector &b)
{
	return Vector(a.x - b.x, a.y - b.y);
}
int cross(const Vector &a, const Vector &b)
{
	return a.x * b.y - a.y * b.x;
}

bool on_line(const Point &p, const Point &a, const Point &b)
{
	return cross(b - a, p - a) == 0;
}

typedef pair<int, int> pii;

pii min2(const pii &p, int x)
{
	if(x <= p.first) return make_pair(x, p.first);
	if(p.first < x && x <= p.second) return make_pair(p.first, x);
	return p;
}

int fpow(int x, int p)
{
	int ret = 1;
	for(; p; p >>= 1, x = (long long)x * x % MOD)
		if(p & 1)
			ret = (long long)ret * x % MOD;
	return ret;
}

int n, ans = 0;
Point p[MAXN];
vector<int> num;
set<pair<int, int> > vis;

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> p[i].x >> p[i].y;
	for(int i = 1; i <= n; i++)
		for(int j = i + 1; j <= n; j++)
		{
			pii mn = make_pair(i, j);
			int cnt = 2;
			for(int k = 1; k <= n; k++)
				if(k != i && k != j && on_line(p[k], p[i], p[j]))
					cnt++, mn = min2(mn, k);
			if(!vis.count(mn))
				vis.insert(mn), num.push_back(cnt);
		}
	// cerr << num.size() << ' ' << num[0] << endl;
	ans = (fpow(2, n) - n - 1 + MOD) % MOD;
	// cerr << ans << endl;
	for(int i = 0; i < num.size(); i++)
		ans = (ans - (fpow(2, num[i]) - num[i] - 1) + MOD) % MOD;
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

long pow(int, int);
using namespace std;

int main(){
    string s;
    cin >> s;
    long sum=0;
    for(int i=0;i<s.size();i++){
        int k = (int)(s[i]-'0');
        for(int j=i;j<s.size();j++){
            int b = s.size()-2-j;
            int a = max(0 , b ) + i;
            sum = sum + k*pow(10,(j-i))*pow(2 , a);

        }
    }
    cout << sum <<endl;
    return 0;
}

long pow(int a, int b){
    long value=1;
    for(int i=0; i<b;i++){
        value=value*a;
    }
    return value;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int r, g; cin >> r >> g;
    cout << 2*g - r << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W;
multiset<int> M;
set<pair<int,int>> S;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
	FOR(x,W) {
		S.insert({x,x});
		M.insert(0);
	}
	S.insert({-1,-2000000});
	M.insert(20202020);
	S.insert({W,W});
	
	FOR(y,H) {
		int A,B;
		cin>>A>>B;
		A--,B--;
		while(1) {
			auto it=S.lower_bound({A,0});
			if(it->first>B) break;
			if(next(it)->first<=B+1) {
				M.erase(M.find(it->first-it->second));
				S.erase(it);
			}
			else {
				x=it->second;
				M.erase(M.find(it->first-it->second));
				S.erase(it);
				S.insert({B+1,x});
				M.insert({B+1-x});
			}
		}
		x=*M.begin()+y+1;
		if(x>=H+W) x=-1;
		cout<<x<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 22364
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define _GLIBCXX_DEBUG

int main(){
  
  int r;
  cin >> r;
  if(r >= 2800)
    cout << "AGC" << endl;
  else if(r >= 1200)
    cout << "ARC" << endl;
  else
    cout << "ABC" << endl;

}

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

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

Measured memory_bytes: 256
n = int(input())
col = [0] * 10
gra = 0

a = list(map(int, input().split()))
flag = False
for i in range(n):
    if a[i] < 3200:
        flag = True

    if 1 <= a[i] < 400:
        col[0] = 1
    elif a[i] < 800:
        col[1] = 1
    elif a[i] < 1200:
        col[2] = 1
    elif a[i] < 1600:
        col[3] = 1
    elif a[i] < 2000:
        col[4] = 1
    elif a[i] < 2400:
        col[5] = 1
    elif a[i] < 2800:
        col[6] = 1
    elif a[i] < 3200:
        col[7] = 1
    else:
        gra += 1

if flag:
    print(sum(col), sum(col) + gra)
else:
    print(1, gra)

Measured memory_bytes: 3064
integer N
integer,allocatable,dimension(:)::p
integer ans
read*,N
allocate(p(N))
read*,P

ans=0
do i=2,N-1
  if((p(i)-p(i-1))*(p(i+1)-p(i))>0)ans=ans+1
end do

print"(i0)",ans
end

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  int c = a + b;
  if(a % 3 == 0 || b % 3 == 0 || c % 3 == 0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $n, $y);
$man = 0;
$go = 0;
$result = 0;
for ($man = 0; $man <= $n; $man++) {
    for ($go = 0; $go <= $n; $go++) {
        $sen = $n - $man - $go;
         if( (10000 * $man) + (5000 * $go) + (1000 * $sen) == $y && $sen >= 0) {
             echo $man . ' ' . $go . ' ' . $sen;
             exit();
         }
    } 
}

echo "-1 -1 -1";

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

int main(){
  long N;
  cin >> N;
  long total = 0;
  for (long i=0;i<=N;i++){
    if (i % 15 == 0)continue;
    else if (i % 3 == 0)continue;
    else if (i % 5 == 0)continue;
    else{
      total += i;
    }
  }
  cout << total << endl;

}


Measured memory_bytes: 3144
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

const int maxi=100010;

vector <int> v[maxi];

int gr[maxi],ob[maxi],x,y,n,t;

void dfs(int x){
    ob[x]=1;

    for (int i=0;i<v[x].size();i++)
    if (ob[v[x][i]]==0){
        dfs(v[x][i]);
        gr[x]=gr[x]^(gr[v[x][i]]+1);
    }
}

void mainmain(){
    scanf("%d",&n);

    for (int i=0;i<maxi;i++)
    {
        v[i].clear();
        gr[i]=0;
        ob[i]=0;
    }

    for (int i=1;i<n;i++)
    {
        scanf("%d%d",&x,&y);
        v[x].push_back(y);
        v[y].push_back(x);
    }

     dfs(1);

   if (gr[1]==0) printf("Bob\n"); else printf("Alice\n");

}



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

Measured memory_bytes: 11264
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    long double res = powl(n / k, 3);
    if (k % 2 == 0) 
        res += powl(2 * n / k - n / k, 3);
    cout << (long long)(res) << '\n';
}

Measured memory_bytes: 512
#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 MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


int main(){
  int n;
  cin >> n;
  cout << (n+1)/2 << endl;

}



Measured memory_bytes: 256
C_0 = [int(num) for num in raw_input().split()]
C_1 = [int(num) for num in raw_input().split()]
C_2 = [int(num) for num in raw_input().split()]
C_s = [C_0, C_1, C_2]
flag = 1
if ((C_1[0] - C_0[0]) == (C_1[1] - C_0[1]) == (C_1[2] - C_0[2])) == False:
   flag = 0
   
if ((C_2[0] - C_0[0]) == (C_2[1] - C_0[1]) == (C_2[2] - C_0[2]))== False:
   flag = 0
   
if ((C_2[0] - C_1[0]) == (C_2[1] - C_1[1]) == (C_2[2] - C_1[2]))== False:
   flag = 0
   
if ((C_s[0][0] - C_s[0][1]) == (C_s[1][0] - C_s[1][1]) == (C_s[2][0] - C_s[2][1]))== False:
   flag = 0
   
if ((C_s[0][0] - C_s[0][2]) == (C_s[1][0] - C_s[1][2]) == (C_s[2][0] - C_s[2][2]))== False:
   flag = 0  

if ((C_s[0][1] - C_s[0][2]) == (C_s[1][1] - C_s[1][2]) == (C_s[2][1] - C_s[2][2]))== False:
   flag = 0  

if flag == 1:
   print "Yes"
else:
   print "No"

Measured memory_bytes: 2696
#include <cstdio>
#include <complex>
using namespace std;

int main()
{
    double x1, y1, x2, y2, xq, yq;

    while(scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq) != EOF){
       
        complex<double> p(x2 - x1, y2 - y1), q(xq - x1, yq - y1);
        double angle = acos(-1) / 2 - arg(p);
        q *= polar(1.0, angle);
        complex<double> res(-q.real(), q.imag());
        res *= polar(1.0,-angle);
        res += complex<double>(x1, y1);
        printf("%.6f %.6f\n", res.real(), res.imag());
    }
}

Measured memory_bytes: 1148
//ABC076B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	int ans = 1;
	for(int i=0;i<n;i++){
		ans = min(2*ans,ans +k);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*
    if you can't see the repay
    Why not just work step by step
    rubbish is relaxed
    to ljq
*/
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
using namespace std;

#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define lc (rt<<1)
#define rc (rt<<11)
#define mid ((l+r)>>1)

typedef pair<int,int> pll;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int _inf = 0xc0c0c0c0;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll _INF = 0xc0c0c0c0c0c0c0c0;
const ll mod =  (int)1e9+7;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}
void exgcd(ll a,ll b,ll &x,ll &y,ll &d){if(!b) {d = a;x = 1;y=0;}else{exgcd(b,a%b,y,x,d);y-=x*(a/b);}}//printf("%lld*a + %lld*b = %lld\n", x, y, d);
const int MAX_N = 100025;
ll dp[MAX_N],arr[MAX_N];
int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int n,k;scanf("%d%d",&n,&k);
    for(int i = 1;i<=n;++i) scanf("%lld",&arr[i]);
    for(int i = 2;i<=n;++i)
    {
        dp[i] = 0x3f3f3f3f;
        for(int j = 1;j<=k;++j)
        {
            if(i-j<1) break;
            dp[i] = min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
        }
    }
    printf("%lld\n",dp[n]);
    //fclose(stdin);
    //fclose(stdout);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}



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

public class Main {
    public static final long MOD = 1000000007;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        Integer a=0,b=0,c=0,i,j,k,n=0,m=0,ans=0;
        List<Integer> l = new ArrayList<>();

        a=sc.nextInt();
        
        for(i=0; i<a; i++){
            b=sc.nextInt();
            l.add(b);
            if(i==a-1){
                m=b;
            }else{
                ans+=b;
            }
        }

        for(i=a-1;i>0;i--){
            if(i==a-1){
                n=Math.abs(m-ans);
            }else{
                m+=l.get(i);
                ans-=l.get(i);
                n=Math.min(n,Math.abs(m-ans));
            }
        }

        print(n);
        
        out.flush();
    }

    private static void print(Object o) {
        System.out.println(o.toString());
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 23124
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
    int a, b;
    int x;
    cin >> a >> b >> x;
    long double result;
    if(2*x > a*b*a) {
    long double high = (long double)2*(a*a*b - x)/(a*a);
    long double y = high/a;
    long double si = (180/M_PI)*atan(y);
    result = si;
    } else {
    long double high = (long double)2*x/(b*a);
    long double y = high/b;
    long double si = (180/M_PI)*atan(y);
    result = (long double)90 - si;
    }
    cout << std::fixed;
    cout << setprecision(10) << result << endl; // "3.14"
    return 0;
}

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

#define INF 1e9
#define PI 3.141592653589793238
typedef long long ll;

int main() {
    string s,t;cin>>s>>t;
    int ans=0;
    for(int i=0; i<s.size(); i++){
        if(s[i]!=t[i])ans++;
    }
    cout<<ans<<endl;

    return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll h,w,n;
    cin >> h >> w >> n;
    cout << (n-1)/max(h, w) + 1 << endl;

    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define MAX 200005
int main()
{
    int N,K,i,j;
    scanf("%d %d",&N,&K);
    double ev[N];
    for(i=0;i<N;i++)
    {
        int p;
        scanf("%d",&p);
        ev[i]=p+1;
        ev[i]=ev[i]/2;
        if(i>0) ev[i]=ev[i]+ev[i-1];
    }
    double ans=ev[K-1];
    for(i=K;i<N;i++) ans=max(ans,ev[i]-ev[i-K]);
    printf("%.6f",ans);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
using namespace std;
vector<int> G[1020];
int ch[1020]; 
void dfs(int r,int v){
	
	if(ch[r]>=0) return;
	
	ch[r]=v;
	for(auto g:G[r])dfs(g,1-v);
}

void solve(){

	int n,m;
	cin>>n>>m;
	if(n==0 && m==0)exit(0); 
	//cout<<n<<" "<<m<<endl;
	for(int i=1;i<=n;i++)ch[i]=-1;
	
	for(int i=1;i<=n;i++)G[i].clear();
	for(int i=0;i<m;i++){
		int y,yy;
		cin>>y>>yy;
		G[y].push_back(yy);
		G[yy].push_back(y);
	}
	
	for(int i=1;i<=n;i++){
		if(ch[i]==-1){
			dfs(i,1);
		}
	}
	
	for(int i=1;i<=n;i++){
		for(auto v:G[i])if(ch[v]+ch[i]!=1){
		cout<<0<<endl;
			return ;
		}
	}
	int ze=0,on=0;
	for(int i=1;i<=n;i++){
		if(ch[i])on++;
		else ze++;
	}
	
	set<int> se;
	if(on%2==0) se.insert(on);
	if(ze%2==0) se.insert(ze);
	cout<<(int) se.size()<<endl;
	for(auto it=se.begin();it!=se.end();it++)cout<<*it/2<<endl;
}

    signed main(){
    	while(1){
    		solve();
    	//	cout<<d<<endl;
    	}
    	
return 0;
    	
            }


Measured memory_bytes: 3176
N = int(input())
Alist = list(map(int, input().split()))
c = 0
n0 = 0
Amin = 1000000000

for i in range(N):
    if abs(Alist[i]) < Amin :
        Amin = abs(Alist[i])
    if Alist[i] < 0 :
        c += 1
    elif Alist[i] == 0 :
        c = 0
        Amin = 0
        n0 = i
    Alist[i] = abs(Alist[i])

if n0 == 0 :
    if c % 2 == 0:
        print(sum(Alist))
    else:
        print(sum(Alist) - 2 * Amin)
else:
    if c % 2 == 0:
        print(sum(Alist))
    else:
        print(sum(Alist) - 2 * Amin)

Measured memory_bytes: 14496
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        int a, b, c;
        cin >> a >> b >> c;
        for (int i = 1; i <= b; ++i) {
            if ((a * i) % b == c) {
                cout << "YES" << endl;
                return 0;
            }
        }
        cout << "NO" << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  
  double ans = vec.at(0);
  for (int i = 1;i < N; i++) {
    ans = (ans+vec.at(i))/2.0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const n: number = parseInt(tmp.shift().split(" ")[0]);

    const map: {[key: number]: {[key: number]: boolean}} = {};
    for (let i = 0; i < n; i++) {
      const a: number = parseInt(tmp.shift().split(" ")[0]);
      map[i] = {};
      for (let j = 0; j < a; j++) {
        const [x, y] = tmp.shift().split(" ").map(int => parseInt(int));
        map[i][x - 1] = y == 1;
      }
    }

    return `${this.culc(n, 0, [], map)}`;
  }

  static culc(n: number, i: number, list: boolean[], map: {[key: number]: {[key: number]: boolean}}): number {
    if (i == n) {
      return this.is(n, list, map) ? list.filter(a => a).length : 0;
    }
    const result1 = this.culc(n, i + 1, list.concat([true]), map);
    const result2 = this.culc(n, i + 1, list.concat([false]), map);
    return Math.max(result1, result2);
  }

  static is(n: number, list: boolean[], map: {[key: number]: {[key: number]: boolean}}) {
    for (let i = 0; i < n; i++) {
      if (!list[i]) {
        continue;
      }
      const m: {[key: number]: boolean} = map[i];
      const keys = Object.keys(m);
      for (let j = 0, len = keys.length; j < len; j++) {
        if (list[keys[j]] != m[keys[j]]) {
          return false;
        }
      }
    }
    return true;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 10384
import sys
N, M = map(int, input().split())
A = list(map(int, input().split()))


def LCM(a, b):
    high = max(a, b)
    low = min(a, b)
    while low != 0:
        high, low = low, high % low
    gcd = high
    lcm = a * b // gcd
    return lcm


def Per2(x):
    cnt = 0
    while x % 2 == 0:
        x //= 2
        cnt += 1
    return cnt


A_lcm = A[0]
c = Per2(A[0])
for a in A:
    if c != Per2(a):
        print(0)
        sys.exit()
for i in range(1, N):
    A_lcm = LCM(A_lcm, A[i])
    h_lcm = A_lcm // 2
    if h_lcm > M:
        print(0)
        sys.exit()

ans = (M - (A_lcm//2))//A_lcm + 1
print(ans)

Measured memory_bytes: 14292
N = gets.to_i
K = gets.to_i
x = gets.strip.split.map(&:to_i)
a = 0
for i in 0..N-1
    if x[i].abs < (K-x[i]).abs
        a += x[i].abs
    else
        a += (K-x[i]).abs
    end
end
puts 2 * a

Measured memory_bytes: 1788
#include<cstdio>
int n,v,cn[2][100001],mx[2][2],num[2][2];
int main(){
	scanf("%d",&n);
	if(n==2) return 0*puts("0");
	for(int i=1;i<=n;i++){
		scanf("%d",&v);
		if(i&1) cn[0][v]++;
		else cn[1][v]++;
	}
	for(int j=0;j<=1;j++)for(int i=1;i<=100000;i++){
		if(cn[j][i]>mx[0][j]) mx[1][j]=mx[0][j],num[1][j]=num[0][j],mx[0][j]=cn[j][i],num[0][j]=i;
		else if(cn[j][i]>mx[1][j]) mx[1][j]=cn[j][i],num[1][j]=i;
	}
	if(num[0][0]!=num[0][1]) printf("%d",n-mx[0][0]-mx[0][1]);
	else{
		int ans=100000;
		for(int i=1;i<=100000;i++){
			if(num[0][1]==i) {if(n-mx[1][1]-cn[0][i]<ans) ans=n-mx[1][1]-cn[0][i];}
			else {if(n-mx[0][1]-cn[0][i]<ans) ans=n-mx[0][1]-cn[0][i];}
		}
		printf("%d",ans);
	}
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;
const long long mod=1e9+7;
const long long INF=1LL<<60;

int main(){
    long long n,a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e;
    long long ans=0;
    ans=(n+min({n,a,b,c,d,e})-1)/min({n,a,b,c,d,e})+4;
    cout<<ans<<endl;
}
 
   

Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int N;
    cin >> N;
    vector<string> W(N);
    rep(i, N) cin >> W.at(i);

    bool isOk1 = true;
    rep(i, N - 1) {
        if (W.at(i).at(W.at(i).size() - 1) != W.at(i + 1).at(0)) isOk1 = false;
    }

    bool isOk2 = true;
    map<string, int> table;
    rep(i, N) { // 初期化
        table[(W.at(i))] = 0;
    }
    rep(i, N) {
        table.at(W.at(i))++;
        if (table.at(W.at(i)) > 1) isOk2 = false;
    }

    string ans = (isOk1 && isOk2) ? "Yes" : "No";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632