akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <iomanip>

void getOrder(std::vector<std::vector<int>>& ret,
std::vector<int>& tmp, bool isIncluded[], int i, int N){
    if(i == N) return ret.emplace_back(tmp);

    for(int j = 0; j < N; ++j){
        if(!isIncluded[j]){
            isIncluded[j] = true;
            tmp.emplace_back(j);
            getOrder(ret, tmp, isIncluded, i+1, N);
            tmp.pop_back();
            isIncluded[j] = false;
        }
    }

    return;
}

std::ostream& operator<<(std::ostream& os, const std::vector<std::vector<int>>& matrix){
    for(auto it = matrix.begin(); it != matrix.end(); ++it){
        os << "{ ";
        for(auto it_in = it->begin(); it_in != it->end(); ++it_in){
            os << *it_in << " ";
        }
        os << "}\n";
    }
    return os;
}

long double getAverageDistance(const std::vector<std::vector<int>>& vec, const std::vector<std::pair<int, int>>& points){
    long double averageDistance = 0.0;
    int size = vec.size();
    int size_in = vec[0].size();
    for(int i = 0; i < size; ++i){
        for(int j = 1; j < size_in; ++j){
            int before = vec[i][j-1];
            int now = vec[i][j];
            averageDistance += std::sqrt(std::pow((points[now].first - points[before].first), 2) + std::pow((points[now].second - points[before].second), 2));
        }
    }
    return averageDistance/size;
}

int main(void){
    int N;
    std::cin >> N;
    std::vector<std::vector<int>> ret;
    std::vector<int> tmp;
    bool* isIncluded= new bool[N];
    for(int i = 0; i < N; ++i) isIncluded[i] = false; 
    getOrder(ret, tmp, isIncluded, 0, N);
    std::vector<std::pair<int, int>> vec;
    std::pair<int , int> p;
    for(int i = 0; i < N; ++i){
        std::cin >> p.first >> p.second;
        vec.push_back(p);
    }
    std::cout << std::setprecision(10) << getAverageDistance(ret, vec);
    delete[] isIncluded;
    return 0;
}

Measured memory_bytes: 3256
n=int(input())
a=list(map(int,input().split()))
ans=[]
b=a.copy()
del b[0]
a1=0
a2=a[0]
for i in b:
    a1=a1^i
ans.append(a1)
for i in b:
    ansii=a1^i
    ansi=a2^ansii
    ans.append(ansi)

for i in range(n):
    print(ans[i],end=' ')

Measured memory_bytes: 31532
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace DISCO2020予選D
{
    class Program
    {
        static void Main(string[] args)
        {
            var M = int.Parse(Console.ReadLine());

            long ans = 0;

            long dSum = 0;
            long c = 0;
            for (int i = 0; i < M; i++)
            {
                var input = ReadLong();
                long di = input[0];
                long ci = input[1];

                dSum += di * ci;
                c += ci;
            }

            ans = c - 1 + (dSum - 1) / 9;

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
//#define int long long
const int INF = 1e9;

ll dp[54][54][2554];

void solve(){
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];

  dp[0][0][0] = 1LL;
  for (int i = 0; i < n; i++){
    for (int cnt = 0; cnt < n; cnt++){
      for (int sum = 0; sum < 2554; sum++){
        if (!dp[i][cnt][sum]) continue;

        dp[i+1][cnt][sum] += dp[i][cnt][sum];
        dp[i+1][cnt+1][sum+a[i]] += dp[i][cnt][sum];
      }
    }
  }

  ll ans = 0LL;
  for (int cnt = 1; cnt <= n; cnt++){
    for (int sum = 0; sum < 2554; sum++){
      if (cnt * x == sum) ans += dp[n][cnt][sum];
    }
  }

  cout << ans << '\n';
}

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

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

    solve();

    return 0;
}


Measured memory_bytes: 12984
n , m = map(int,input().split())
mod = 10**9 + 7
if abs(n-m) >= 2:
    print(0)
elif abs(n-m) <= 1:
    p = 1
    q = 1
    t = 1
    for i in range(n):
        p *= (i+1)
        p %= mod
    for i in range(m):
        q *= (i+1)
        q %= mod
    if abs(n-m) == 0:
        t = 2
    print(t*p*q%mod)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001
#define mod 1000000007
#define pi 3.141592653589793
#define all(v) v.begin(),v.end()

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main(){
    int n;
    cin >> n;
    int x=800*n;
    int y=(n/15)*200;
    cout << x-y <<endl;
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i = 0;i < n;i++)cin >> a[i];
  deque<ll> deq;

  if(n % 2 == 0){
    for(int i = 0;i < n;i++){
      if(i % 2 == 0)deq.push_back(a[i]);
      else deq.push_front(a[i]);
    }
  }
  else{
    for(int i = 0;i < n;i++){
      if(i % 2 == 0)deq.push_front(a[i]);
      else deq.push_back(a[i]);
    }
  }



  for(ll i:deq)cout << i  << " ";
  cout << endl;
}


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

using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin >> a >> b;
    int ans = max(a+b,a-b);
    ans = max(ans,a*b);
    cout << ans << endl;
    
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;

int main() {
    int N, C, ans = 1e9;
    cin >> N >> C;
    vector<vector<int>> D(C, vector<int>(C)), c(N, vector<int>(N)), t(3, vector<int>(C, 0));
    rep(i, C) {
        rep(j, C) {
            cin >> D[i][j];
        }
    }
    rep(i, N) {
        rep(j, N) {
            cin >> c[i][j];
            c[i][j]--;
            t[(i + j) % 3][c[i][j]]++;
        }
    }
    rep(i, C) {
        rep(j, C) {
            if (i == j) continue;
            rep(k, C) {
                if (i == k) continue;
                if (j == k) continue;
                int s = 0;
                rep(l, C) {
                    s += D[l][i] * t[0][l];
                    s += D[l][j] * t[1][l];
                    s += D[l][k] * t[2][l];
                }
                ans = min(ans, s);
            }
        }
    }
    cout << ans << "\n";
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    long long total = 1000;
    long long stocks = 0;
    vector<int> v(n);
    for(int i = 0;i<n;i++)
    {
        cin>>v[i];
    }
  int mi = v[0];
    int ma;
    bool buy = false;
    for(int i = 0;i<n;i++)
    {
        if(!buy)
        {
           if(v[i] > mi)
                {
                    stocks = total/mi;
                    total -= stocks*mi;
                    ma = v[i];
                    buy = true;
                }
                else
                {
                    mi = min(v[i],mi);
                }
        }
        else
        {
           if(v[i] < ma)
                {
                    total += stocks*ma;
                    buy = false;
                    mi = v[i];
                }
                else
                {
                    ma = max(ma, v[i]);
                }
        }
    }

    if(buy)
    {
        total += stocks*ma;
    }

    cout<<total;

    return 0;
}

Measured memory_bytes: 3568
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
int main() {
	int a, b, c, d, e;
	fscanf(stdin, "%d%d%d%d%d", &a, &b, &c, &d, &e);
	while (b>0 || c>0) a--, b -= d, c -= e;
	P(d, a);
	return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n,a,b;cin >> n>>a>>b;
    vector<lint> x(n);
    REP(i, n) { cin >> x[i]; }
    lint ans=0;

    FOR(i,1,n){
        lint d = x[i] - x[i - 1];
        //if(a*d>b){ans += b;}
        ans += min(a * d, b);
    }

    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    int cnt[100005] = {};
    int mx = 0;
    int res = 0;
    for( int i = 0; i < n; ++i ) {
        int a;
        cin >> a;
        if( a <= 100003 ) {
            ++cnt[a];
            mx = max( mx, a );

        } else ++res;

    }

    for( int i = 1; i <= mx; ++i ) {
        if( cnt[i] && i != cnt[i] ) {
            if( cnt[i] < i ) {
                res += cnt[i];

            } else {
                res += cnt[i] - i;

            }
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
	int n, j, sum1, min = 1000, sum2, k;
	cin >> n;
	for (int i = 1; i < n; i++) {
		sum1 = 0;
		sum2 = 0;
		j = i;
		while (j > 0) {
			sum1 += j % 10;
			j /= 10;
		}
		k = n - i;
		while (k > 0) {
			sum2 += k % 10;
			k /= 10;
		}
		if (min > sum1+sum2) {
			min = sum1+sum2;
		}
	}
	cout << min << endl;
	return 0;
}

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

void solve() {
    int N;
    cin >> N;
    vector<int> C(N + 1);
    for (int i = 1; i <= N; i++) cin >> C.at(i);
    vector<int> DP(N + 1), s(200001);
    DP.at(0) = 1;
    for (int i = 1; i <= N; i++) {
        if (C.at(i) != C.at(i - 1)) {
            s.at(C.at(i)) += DP.at(i - 1);
            s.at(C.at(i)) %= 1000000007;
            //cout << "s.at(" << C.at(i) << ")=" << s.at(C.at(i)) << endl;
        }
        DP.at(i) = s.at(C.at(i));
        //cout << "DP.at(" << i << ")=" << DP.at(i) << endl;
    }
    //cout << "DP.at(N)=" << DP.at(N) << endl;
    cout << DP.at(N) << endl;
    return;
}

int main() {
    solve();
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll MOD = 1000000007;
const double PI = 3.141592653589793238463;
const ll N=2e5+9;
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    if (x<1200)
        cout<<"ABC\n";
    else
        cout<<"ARC";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt(), M = sc.nextInt();
        String A[] = new String[N], B[] = new String[M];
        for (int i = 0; i < N; i++) A[i] = sc.next();
        for (int i = 0; i < M; i++) B[i] = sc.next();

        for (int i = 0; i < N - M + 1; i++) {
            for (int j = 0; j < N - M + 1; j++) {
                boolean flag = true;
                for (int r = 0; r < M; r++) {
                    for (int c = 0; c < M; c++) {
                        flag &= A[i+r].charAt(c+j) == B[r].charAt(c);
                    }
                }
                if (flag) {
                    System.out.println("Yes");
                    return ;
                }
            }
        }
        System.out.println("No");
    }
}


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

typedef long long ll;
const int MAXN = 300010;

int n, l, c0, c1, c2;
int x[MAXN], t[MAXN];

int main()
{
	scanf("%d %d", &n, &l);
	for(int i = 1; i <= n; ++i)
		scanf("%d", &x[i]);
	ll ans = 1;
	for(int i = 1; i <= n; ++i)
	{
		scanf("%d", &t[i]);
		ans += t[i] / (2 * l);
		t[i] %= 2 * l;
		if(t[i])
		{
			++ans;
			int f = (t[i] <= (l - x[i]) * 2);
			int g = (t[i] <= x[i] * 2);
			if(i == n)
			{
				if(f) --ans;
				break;
			}
			if(g)
			{
				++c0;
				if(f) ++c2;
			}
			else if(f) ++c1;
			while(c0 - c2 < c1 + c2)
			{
				if(c2) --c2;
				else --c1;
			}
		}
	}
	ans -= c1 + c2;
	printf("%lld\n", ans * l * 2);
	return 0;
}

Measured memory_bytes: 2560
def main():
    N = int(input())
    G = [[] for _ in range(N)]
    edge = [-1] * (N-1)
    for i in range(N-1):
        a, b = (int(i)-1 for i in input().split())
        G[a].append((b, i))
        G[b].append((a, i))

    max_deg = max(len(G[i]) for i in range(N))

    from collections import deque

    def bfs(s):
        que = deque([])
        par = [-1]*N
        que.append(s)
        while que:
            pos = que.popleft()
            c = -1
            k = 1
            for (v, i) in G[pos]:
                if par[pos] == v:
                    c = edge[i]
            for (v, i) in G[pos]:
                if par[pos] == v:
                    continue
                if k == c:
                    k += 1
                par[v] = pos
                edge[i] = k
                k += 1
                que.append(v)

    bfs(0)

    print(max_deg)
    for i in range(N-1):
        print(edge[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 97812
function Main(input) {
  const inputArr = input.split(" ");

  const x = parseInt(inputArr[0], 10);
  const y = parseInt(inputArr[1], 10);

  const t = (y - 2 * x) / 2;
  const c = x - t;

  if (
    Number.isInteger(t) &&
    t >= 0 &&
    Number.isInteger(c) &&
    c >= 0 &&
    t + c !== 0
  ) {
    console.log("Yes");
  } else {
    console.log("No");
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

typedef long long ll;

#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 fi first
#define se second
#define II pair<ll,ll>
#define INFINITY INT_MAX

const int maxn=4e5+10;
const ll maxN=1e18+10;

ll ST[maxn],a[maxn];

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  string s,t;
  cin >> s >> t;
  int a,b;
  cin >> a >> b;
  string s1;
  cin >> s1;
  if (s1==s) cout << a-1 << " " << b;
  else cout << a << " " << b-1;
}
    

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

int main() {
  int x, y;
  cin >> x >> y;
  int ans;
  int absx = abs(x);
  int absy = abs(y);
  if (absx > absy) {
    ans = absx - absy;
    if (x > 0) ans++;
    if (y > 0) ans++;
  } else {
    ans = absy - absx;
    if (x < 0) ans++;
    if (y < 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100000
 
int main() {
   
  int i,n,A[N];
  int parent,left,right;
   
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    scanf("%d",&A[i]);
   
  for(i=1;i<=n;i++) {
    parent = i/2;
    left = 2*i;
    right = 2*i+1;
     
    printf("node %d: key = %d, ",i,A[i]); 
    if(i != 1)
      printf("parent key = %d, ",A[parent]);
     
    if(left <= n)
      printf("left key = %d, ",A[left]);
     
    if(right <= n)
      printf("right key = %d, ",A[right]); 
     
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;



int main()
{
    ll n;
    cin >> n;
    vector<vector<vector<ll>>> f(n, vector<vector<ll>>(5, vector<ll>(2)));
    rep(i,n){
        rep(j,5){
            rep(k,2){
                cin >> f[i][j][k];
            }
        }
    }
    
    vector<vector<ll>> p(n,vector<ll>(11));
    rep(i,n){
        rep(j,11){
            cin >> p[i][j];
        }
    }
    ll ans = -INF;
    ll ans_x = 0;
    for(int i=1;i<(1<<10);i++){
        ll point = 0;
        rep(j,n){
            ll common = 0;
            rep(k,10){
                bool me_open = (i&(1<<k));
                bool other_open = f[j][k/2][k%2];
                if(me_open && other_open){
                    common ++;
                }
                
            }
            /*print(i);
            print(j);
            print(common);
            print2(p);
                        print(point);*/
            point += p[j][common];

        }
        if(ans < point){
            ans = point;
            ans_x = i;
        }
    }
    cout << ans;
}

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

int main() {
	int m, n;
	cin >> n >> m;
	int sum_n=0;

	for (int i = 0; i < n; i++) {
		if (n == 1)break;
		if (i == 0)continue;
		sum_n += n - i;
	}
	int sum_m = 0;
	for (int i = 0; i < m; i++) {
		if (m == 1)break;
		if (i == 0)continue;
		sum_m += m - i;
	}
	cout << sum_n + sum_m << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ull unsigned ll
#define pb push_back
#define popb pop_back
#define mt make_tuple
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define piiii pair <pii,pii>
#define plll pair <pair <ll, ll>, ll>
#define rep0(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<=(ll)n;i++)
#define rep(i,x,y) for(ll i=(ll)x;i<=(ll)y;i++)
#define reprev(i,n) for(ll i=(ll)n;i>=0;i--)
#define all(c) c.begin(),c.end()
#define print(a) rep0(i,a.size()) cout << a[i] << " "
#define hi() cout << "\nHello, I am error. Can you find me? :):):)\n"
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_eppoch().count())
 
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;

const int mod = 1e9+7;
const long double pi = acos(-1);

// FOR DEBUGGING
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", ";
	else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

ll power(ll x, ll y){
	x %= mod;
	ll ans = 1;
	while(y){
		if(y&1) ans = (ans*x)%mod;
		y /= 2;
		x = (x*x)%mod;
	}
	return ans;
}

void solve(){

	float r;
	cin >> r;
	cout << 2*pi*r;

	return;
}

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		// cout << "Case #" << t << ": ";
		solve();
		// cout << "\n";
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

Measured memory_bytes: 3832
//ITP 1_8_B
#include <iostream>
using namespace std;

int main(){
	string a;
	while (getline(cin, a), a != "0") {
		int r = 0;
		for (char c : a) {
			r += c - '0';
		}
		cout << r << endl;
	}
	
	return 0;
}



Measured memory_bytes: 3220
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	N := len(S)
	var cnt int
	for i := 0; i < N; i++ {
		if S[i] == '0' {
			cnt++
		}
	}
	numRed := cnt
	numBlue := N - cnt
	if numRed > numBlue {
		fmt.Println(N - (numRed - numBlue))
	} else {
		fmt.Println(N - (numBlue - numRed))
	}
}

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

//#include<vector>
//#include<iterator>
//#include<utility>
//#include<algorithm>
//#include<cmath>
using namespace std;


#define ll long long
#define fr(m) for(int i=0; i<m; i++)
#define frj(m) for(int j=0; j<m; j++)
#define frr(n) for(int i=n; i>=0; i--)
#define pb push_back
#define orr ||
#define nl \n
#define sci(n) scanf("%lld ", &n)
#define pri(n) printf("%d", n)
#define prl(n) printf("%lld", n)
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl


int main()
{

    deque<char> de1,de2,de3;
    string a,b,c;
    cin>>a>>b>>c;
    for(char d: a){
        de1.pb(d);
    }
    for(char d: b){
        de2.pb(d);
    }
    for(char d: c){
        de3.pb(d);
    }
    char current=de1.front(),ans;
    while(!de1.empty() orr !de2.empty() orr !de3.empty()){
        if(current=='a'){
            if(de1.empty()){
                ans='A';
                break;
            }
            current=de1.front();
            de1.pop_front();

        }
        else if(current=='b'){
            if(de2.empty()){
                ans='B';
                break;
            }
            current=de2.front();
            de2.pop_front();

        }
        else{
            if(de3.empty()){
                ans='C';
                break;
            }
            current=de3.front();
            de3.pop_front();

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


Measured memory_bytes: 256
/*
Author- Aasav Badera
Time- Sun Mar 22 19:53:10 2020
*/
#include<bits/stdc++.h> 
#define ll                 long long                            
#define pb                 push_back                                                     
#define s                  second
#define mii                map<ll ,ll >
#define dbg(x)             { cerr<<#x<<": "<<x<< endl; }
#define dbg2(x,y)          { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define rep(i, a, b)         for(ll  i=a;i<b;i++)
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define f                  first 
#define vi                 vector<ll >
#define vii                vector<pair<ll , ll >>
#define si                 set <ll>
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define hell               1000000007
#define mp                 make_pair
#define yes                cout << "YES" << endl;
#define no                 cout << "NO" << endl;
#define inf                1e18L+1
#define endl               '\n' 
using namespace std;
#define N  300005
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    // // for getting input from input.txt
    // freopen("input.txt", "r", stdin);
    // // for writing output to output.txt
    // freopen("output.txt", "w", stdout);
    // #endif
    ll tests = 1;
    // cin >> tests;
    while(tests--)
    {
    	ll h, w;
    	cin >> h >> w;
    	string s[h];
    	rep(i, 0, h)
    		cin >> s[i];
    	ll dp[h][w];
    	rep(i,0 , h)
    	rep(j,0, w)
    	dp[i][j] = inf;
    	dp[0][0] = (s[0][0] == '#');
    	rep(i, 0, h)
    	{
    		rep(j, 0, w)
    		{
    			if(i < h-1 && s[i][j] == '.' && s[i+1][j] == '#')
    			{
    				dp[i+1][j] = min(dp[i+1][j], dp[i][j]+1);
    			}
    			else if(i < h-1)
    				dp[i+1][j] = min(dp[i+1][j], dp[i][j]);

    			if(j < w-1 && s[i][j] == '.' && s[i][j+1] == '#')
    				dp[i][j+1] = min(dp[i][j+1], dp[i][j]+1);
    			else if(j < w-1)
    				dp[i][j+1] = min(dp[i][j+1], dp[i][j]);
    		}
    	}
    	cout << dp[h-1][w-1];
    }
    return 0;
}

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

int main() {
  int n ;
  cin >> n ;
  vector <int> a(n) ;
  vector <int> count(n,0) ;
  for (int i=0 ; i<n ; i++){
    cin >> a.at(i) ;
  }
  for (int i = 0 ; i<n ; i++){
  for ( int j=a.at(i) ; j%2==0 ; j/=2){
    count.at(i) ++ ;
  }
  }
  sort(count.begin() , count.end());
  cout << count.at(0) << endl;
}

Measured memory_bytes: 3628
def check(s):
    an = True
    for i in range(len(s)//2):
        if s[i] != s[-i-1]:
            an = False
    return an    
a,b = map(int, input().split())
ans = 0
for i in range(a,b+1):
    l = str(i)
    l2 = list(l)
    if check(l2):
        ans += 1
print(ans)

Measured memory_bytes: 9112
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

using std::min;
using std::max;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

inline int nextInt()
{
    int x = 0;
    char c = getchar();
    int mi = (c == '-');
    if (c == '-') c = getchar();
    while ('0' <= c && c <= '9')
    {
        x = 10 * x + c - '0';
        c = getchar();
    }
    if (mi) return x * -1;
    return x;
}

ll a[500][500];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) a[i][j] = 1;
    if (n % 2)
    {
        int sm = n;
        for (int i = 1; i <= sm; i++) a[i][sm - i] = 0;
    }
    else
    {
        int sm = n + 1;
        for (int i = 1; i <= sm; i++) a[i][sm - i] = 0;
    }
    int e = 0;
    F(i, n) F(j, n) if (i - j && a[i + 1][j + 1]) e++;
    e /= 2;
    cout << e << "\n";
    for (int i = 1; i <= n; i++)
    {
        for (int j = i + 1; j <= n; j++)
        {
            if (a[i][j])
            {
                cout << i << " " << j << "\n";
            }
        }
    }
}

Measured memory_bytes: 640
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N, X = map(int, input().split())
    L = list(map(int, input().split()))
    count = 1
    d = 0
    for i in range(N):
        d += L[i]
        if d <= X:
            count += 1
    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
def main():
    ball_num = int(input())
    type_b_initial_y = int(input())
    x_coodinates = list(map(int, input().split()))
    answer = 0
    for i in range(ball_num):
        answer += min(x_coodinates[i] * 2, abs(x_coodinates[i] - type_b_initial_y) * 2)
    print(answer)


if __name__ == '__main__':
    main()



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

using ll = long long;
using db = double;
using pll = pair < ll, ll >;

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

#define pb push_back
#define mp make_pair
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
int main(){
	ll k; cin >> k;
	if(k <= 9){
		cout << k << endl;
		return 0;
	}
	deque <ll> dq;
	for(ll i = 1; i <= 9; i++){
		dq.push_back(i);
	}
	for(ll i = 9; i <= k;){
		ll tar = dq.front();
		dq.pop_front();
		if(tar%10 != 0) {
			dq.push_back(10 * tar + (tar % 10) - 1);
			i++;
			if(i == k) {
				cout << dq.back() << "\n";
				return 0;
			}
		}

		dq.push_back(10 * tar + (tar % 10));
		i++;
		if(i == k) {
			cout << dq.back() << "\n";
			return 0;
		}
		
		if(tar % 10 != 9) {
			dq.push_back(10 * tar + (tar % 10) + 1);
			i++;
			if(i == k) {
				cout << dq.back() << "\n";
				return 0;
			}
		}
	}
	cout << dq.back() << "\n";
}

Measured memory_bytes: 768
#include <stdio.h>
 
int main(){
    int a,i,count=0;
    scanf("%d",&a);
    for(i=0;i<3;i++){
    if(a%10==7) count++;
    a=a/10;}
    if(count>=1)
    puts("Yes");
    else
    {
    puts("No");
    }
    
    return 0;
}    

Measured memory_bytes: 1592
#include <stdio.h>

int main()
{
    int m, f, r;
    while(1) {
        scanf("%d %d %d", &m, &f, &r);
        if(m == -1 && f == -1 && r == -1) {
            break;
        }
        if(m == -1 || f == -1) {
            printf("F\n");
        } else if((m + f) >= 80) {
            printf("A\n");
        } else if((m + f) >= 65) {
            printf("B\n");
        } else if((m + f) >= 50) {
            printf("C\n");
        } else if((m + f) >= 30 && r >= 50) {
            printf("C\n");
        } else if((m + f) >= 30) {
            printf("D\n");
        } else {
            printf("F\n");
        }
    }

    return 0;
}


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

vector<int64_t> layer(51);
vector<int64_t> patty(51);

int64_t sumpatty(int64_t dim, int64_t toeat) {
    if (dim == 0 || toeat == 0) return toeat;
    if (layer[dim] - 1 <= toeat) return patty[dim];
    if (layer[dim-1] + 2 <= toeat) return patty[dim-1] + 1 + sumpatty(dim - 1, toeat - layer[dim-1] - 2);
    return sumpatty(dim - 1, toeat - 1);
}

int main() {
    int64_t n, x;
    cin >> n >> x;

    layer[0] = patty[0] = 1;
    for (int i = 0; i + 1 <= n; i++) {
        layer[i+1] = 2 * layer[i] + 3;
        patty[i+1] = 2 * patty[i] + 1;
    }

    cout << sumpatty(n, x) << endl;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

class UnionFind:
    def __init__(self, n):
        # 初期状態は全要素が根なので、親は自分自身
        self.par = [i for i in range(n+1)]
        # 集団の要素数(size)を格納する(初期は全て1)
        self.size = [1] * (n+1)
    
    # 根を検索する関数
    def find(self, x):
        # 根までたどったらその番号を返す
        if self.par[x] == x:
            return x
        # 根でないなら親の要素で再検索
        else:
            # 検索過程で親を書き換える(圧縮経路)
            self.par[x] = self.find(self.par[x])
            return self.find(self.par[x])
  
    # 結合(unite)する関数
    def unite(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        # サイズを比較し、小さい方を大きい方に繋げる
        if self.size[x] < self.size[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
           
    # 同じグループに属するかを判定する関数
    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    
    # 要素が属する木のサイズを返す関数
    def get_size(self, x):
        return self.size[self.find(x)]
    
    # グループ数を返す関数
    def group_sum(self):
        c = 0
        for i in range(len(self.par)):
            if self.find(i) == i:
                c += 1
        return c
    

def main():
    N,M,*ab = map(int, read().split())
    
    E = [(a, b) for a, b in zip(*[iter(ab)]*2)]

    pair = N * (N - 1) // 2
    ans = []

    uf = UnionFind(N)
    con = 0
    for a, b in reversed(E):
        ans.append(pair)
        if not uf.is_same(a, b):
            n_a = uf.get_size(a)
            n_b = uf.get_size(b)
            pair -= n_a * n_b

        uf.unite(a, b)

    print("\n".join(map(str, ans[::-1])))


if __name__ == "__main__":
    main()


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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;


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



int main() {




  cout<<fixed<<setprecision(10);

  ll n;cin>>n;

  while(n != 0){

    vint s(n);rep(i,n)cin>>s[i];
    double mean = 0.0;
    rep(i,n){
      mean += s[i];
    }
    mean /= n;

    double var = 0;
    rep(i,n){
      var += (s[i] - mean)*(s[i] - mean);
    }
    var /= n;

    cout<<sqrt(var)<<endl;

    cin>>n;
  }

}






//








Measured memory_bytes: 3216
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif


int n, a[N];
char s[N];

int chk() {
	int x = 0;
	REP(i,1,n) if (((n-1)|(i-1))==n-1) x += a[i];
	return x&1;
}

int main() {
	scanf("%d%s", &n, s+1);	
	if (n==1) return puts(s),0;
	REP(i,1,n-1) a[i] = s[i+1]-s[i];
	--n;
	if (chk()) return puts("1"),0;
	REP(i,1,n) { 
		if (a[i]&1) return puts("0"),0;
		a[i] /= 2;
	}
	puts(chk()?"2":"0");
}








Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    ll bit_count[40];
    for(int i=0; i<40; i++) bit_count[i] = 0;

    for(int i=0; i<40; i++){
        for(int j=0; j<N; j++){
            if(A[j] & 1LL<<i) bit_count[i]++;
        }
    }

    ll ans = 0LL;
    for(int i=0; i<40; i++){
        if((K & 1LL<<i) == 0) continue;

        ll tmp = 0LL;
        for(int j=i+1; j<40; j++){
            if(K & 1LL<<j) tmp += (1LL<<j) * (N - bit_count[j]);
            else tmp+= (1LL<<j) * bit_count[j];
        }
        
        tmp += (1LL<<i) * bit_count[i];

        for(int j=0; j<i; j++){
            tmp += (1LL<<j) * max(bit_count[j], N-bit_count[j]);
        }

        ans = max(ans, tmp);
    }

    ll tmp = 0LL;
    for(int i=0; i<N; i++){
        tmp += K^A[i];
    }
    ans = max(ans, tmp);

    cout << ans << endl;
}

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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<ll> vll;
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

/////////////////////////////////

int const MAX = 4e3 + 41;
int const MOD = 998244353;

int add(int a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
	return a;
}

int mult(int a, int b) {
	return (ll) a * b % MOD;
}

int bp(int x, int d) {
	int res = 1;
	while (d) {
		if (d & 1) res = mult(res, x);
		x = mult(x, x);
		d >>= 1;
	}
	return res;
}

int inv(int x) {
	return bp(x, MOD - 2);
}

int f[MAX];
int invf[MAX];
int p2[MAX];

void init() {
	p2[0] = 1;
	fi(1, MAX - 1) {
		p2[i] = mult(p2[i - 1], 2);
	}
	f[0] = 1;
	fi(1, MAX - 1) {
		f[i] = mult(f[i - 1], i);
	}
	fi(0, MAX - 1) {
		invf[i] = inv(f[i]);
	}
}

int getc(int n, int k) {
	if (k > n) return 0;
	if (n == k) return 1;
	if (k < 0) return 0;
	if (n < 0 || k < 0) {
//		err("n = %d k = %d\n", n, k);
	}
	return mult(f[n], mult(invf[k], invf[n - k]));
}

int ans[MAX];

int all, pairs, same;

int n, k;

void prepare(int x) {
	all = 0;
	pairs = 0;
	same = 0;
	fi(1, k) {
		int rem = x - i;
		if (rem == i) {
			same = 1;
			continue;
		}
		if (1 <= rem && rem <= k) {
			pairs++;		
		} else {
			all++;
		}
	}
	assert(pairs % 2 == 0);
	pairs /= 2;
}

int calc(int x) {
	prepare(x);
	/*
	err("x = %d\n", x);
	err("all = %d pairs = %d same = %d\n", all, pairs, same);
	*/
	int res = 0;
	for (int takesame = 0; takesame <= same; takesame++) {	
		fi(0, pairs) {
			int rem = n - i - takesame;
			if (rem < 0) break;
			int v1 = mult(p2[i], getc(pairs, i));
			int v2 = getc(i + all + rem - 1, i + all - 1);
//			err("i = %d rem = %d v1 = %d v2 = %d\n", i, rem, v1, v2);
			int v = mult(v1, v2);
			res = add(res, v);
		}
//		err("takesame = %d res = %d\n",  takesame, res);
	}

	return res;	
}

void solve() {	
//	calc(2);
	
	
	fi(2, k * 2) {
		ans[i] = calc(i);
	}
	

	fi(2, k * 2) {
		printf("%d\n", ans[i]);
	}
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	init();
	scanf("%d %d", &k, &n);
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(){
   long a,mi,s;
   int n,i,m;
    
   scanf("%d",&n);
   for (m=i=0;i<n;i++) {
      scanf("%ld",&a);
      if (i==0) 
         if (a>=0) mi=a;
         else      mi=-a;
      if (a>=0) {
         s+=a;
         if (a<mi) mi=a;
      } else {
         s-=a;
         m++;
         if (-a<mi) mi=-a;
      }
   }
   if (m%2==0) printf("%ld\n",s);
   else        printf("%ld\n",s-mi*2);
   return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N;
  std::cin >> N;
  std::vector< ll > va(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
  }

  ll cnt = 0LL;
  for (ll i = 0; i < N; i++) {
    if (va[i] == 0) {
      cnt = 0LL;
      break;
    }
    if (va[i] < 0) cnt++;
  }

  for (ll i = 0; i < N; i++) {
    va[i] = std::abs(va[i]);
  }
  ll sum = std::accumulate(va.begin(), va.end(), 0LL);

  if (cnt % 2 == 0) {
    print(sum);
  } else {
    ll min_val = *std::min_element(va.begin(), va.end());
    print(sum - 2 * min_val);
  }

  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
 
int main() {

    ll m1, m2, d1, d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;
    if (m1 != m2) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int s, s1, s2, s3;
    cin >> s;
    s1 = s / 100;
    s2 = s / 10 % 2;
    s3 = s % 2;
    cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static final char INCREASE = 'I';
	private static final char DECREASE = 'D';

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			// n
			scanner.nextInt();
			char[] s = scanner.next().toCharArray();
			int max = 0, x = 0;
			for (char c : s) {
				switch (c) {
				case INCREASE:
					x++;
					max = Math.max(x, max);
					break;
				case DECREASE:
				default:
					x--;
					break;
				}
			}
			System.out.println(max);
		}
	}
}


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

long long burger[52],patty[52];
long long n, x;
long long ans=0;


void f(int n)
{
    if(x == burger[n])
	{
		// µÝ¹éÖÕÖ¹Ìõ¼þ 
		// ²âÊÔÊý¾Ýn=2,x=3»á½øÈë±¾·ÖÖ§ 
		ans += patty[n];
		return;	
	}
    else if(x < burger[n])
	{
		if(x)	// x>0
	    {
	        x--;	// ×îµ×ÏÂÄÇÒ»²ãÊÇbun²»ÊÇpatty£¬¼õµô 
	        if(x > burger[n-1])
	        {
	        	ans += patty[n-1];
	            x -= burger[n-1];
	            
	            // ¼ÓÉÏÖÐ¼äÄÇÒ»²ãµÄpatty 
				ans++;
				x--;
				
				// x > burger[n-1]·ÖÎªÁ½ÖÖÇé¿ö£º
				// Ò»ÊÇx>burger[n-1]+1£¬ÕâÀï1Ö¸µÄÊÇÖÐ¼äµÄpatty²ã£¬ÕâÖÖÇé¿ö½øÏÂÃæµÄif
				// ¶þÊÇx==burger[n-1]+1£¬ÕâÖÖÇé¿ö½øÏÂÃæµÄelse 
	            if(x)
				{
					f(n-1);
				}
				else // x==0ÊÇÑ­»·ÖÕÖ¹Ìõ¼þ£¬¿ÉÒÔÊ¡ÂÔ²»Ð´ 
				{
					// ²âÊÔÊý¾Ýn=2,x=4»á½øÈë±¾·ÖÖ§ 
					return;
				} 
				
	        }
	        else // x<=burger[n-1]
			{
				f(n-1);
			}
		}
		else // x==0ÊÇÑ­»·ÖÕÖ¹Ìõ¼þ£¬¿ÉÒÔÊ¡ÂÔ²»Ð´ 
		{ 
			// ²âÊÔÊý¾Ýn=2,x=1»òn=2,x=2»á½øÈë±¾·ÖÖ§ 
			return;
		}
    }
}


int main()
{
    scanf("%lld%lld",&n, &x);
    burger[0] = 1, patty[0] = 1;	// ³õÊ¼»¯n = 0Ê± 
    
    for(int i = 1; i <= 50; i++)
    {
    	// ¼ÆËã1²ã~50²ãµÄºº±¤×Ü²ãÊýºÍ¶ÔÓ¦µÄpatty²ãÊý 
        burger[i] = burger[i-1] * 2 + 3; // ºº±¤µÄ×Ü²ãÊý 
        patty[i] = patty[i-1] * 2 + 1;	 // patty²ãÊý 
        //cout << "n=" << i << ",ºº±¤×Ü²ãÊýºÍpatty²ãÊý£º" << burger[i] << ',' << patty[i] << '\n'; 
    }
    
    f(n);
    printf("%lld\n", ans);
    
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
	"strings"
)

func main() {
	var c = make([][]string, 3)

	for i := 0; i < 3; i++ {
		c[i] = make([]string, 3)
		var t string
		fmt.Scan(&t)
		var strs = strings.Split(t, "")
		for j := 0; j < len(strs); j++ {
			c[i][j] = strs[j]
		}
	}

	fmt.Println(c[0][0] + c[1][1] + c[2][2])
}

/*  ----------------------------------------  */

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return abs(a[i]) < abs(a[j]) }


Measured memory_bytes: 640