akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <deque>
#include <functional>
#include <initializer_list>
#include <math.h>
#include <map>
#include <random>
#include <set>
#include <stack>
#include <tuple>
#include <type_traits>
#include <queue>
#include <vector>


#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); --(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define SORT(A) std::sort((A).begin(), (A).end())
#define ALL(A) (A).begin(), (A).end()
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())

using lli = long long int;
using pii = std::pair<int, int>;

// グリッド上の縦横移動
constexpr std::array<std::pair<int, int>, 4> dxdy = {
    std::pair<int, int>( 1,  0),
    std::pair<int, int>(-1,  0),
    std::pair<int, int>( 0,  1),
    std::pair<int, int>( 0, -1)
};

void VintOut(std::vector<int>& A){
    const int n = A.size();
    if(n == 0){putchar('\n'); return;}
    printf("%d", A[0]);
    for(int i = 1; i < n; ++i) printf(" %d", A[i]);
    putchar('\n');
}
void VintOut(std::vector<long long int>& A){
    const int n = A.size();
    if(n == 0){ putchar('\n'); return;}
    printf("%lld", A[0]);
    for(int i = 1; i < n; ++i) printf(" %lld", A[i]);
    putchar('\n');
}

template <typename T>
inline bool chmin(T& a, T b){
    if(b < a){ a = b; return true;}
    return false;
}

template <typename T>
inline bool chmax(T& a, T b){
    if(a < b){ a = b; return true;}
    return false;
}

inline bool isIn(int x, int y, int H, int W){
    return 0 <= x and x < H and 0 <= y and y < W;
}
inline bool bitUP(int state, int k){ return (state >> k) & 1; }
inline bool bitUP(long long int state, int k){ return (state >> k) & 1;}

// z-algorithm
template <class T> std::vector<int> z_algorithm(const T &str) {
    const int n = str.size();
    std::vector<int> resOfCP(n); resOfCP[0] = n;
    int i = 1, j = 0;
    while (i < n) {
        while (i + j < n and str[j] == str[i + j]) ++j;
        resOfCP[i] = j;
        if (j == 0) { ++i; continue;}
        int k = 1;
        while (i + k < n and k + resOfCP[k] < j) resOfCP[i + k] = resOfCP[k], ++k;
        i += k; j -= k;
    }
    return resOfCP;
}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


int main(void){
    int H, n; scanf("%d%d", &H, &n);
    int S = 0;
    REP(i, n){
        int a; scanf("%d", &a); S += a;
    }
    if(H <= S) puts("Yes");
    else puts("No");
    
    
    return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())

N_list=list(range(1,N+1))
ans=N
for i in range(K):
    d=int(input())
    A=list(map(int,input().split()))
    for j in A:
        if j in N_list:
            ans=ans-1
            N_list.remove(j)
    

print(len(N_list))

Measured memory_bytes: 9196
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


int main(){
    
    int a,b;
    cin >> a >> b;
    if(b%a == 0)P(a+b);
    else P(b-a);
    return  0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int sosu[10000];
  int i, a,j,n, k=2;

  for(i=0;i<10000;i++) sosu[i]=0;

  sosu[0]=2;
  sosu[1]=3;

  for(i=4; ;i++){
    a=0;
    for(j=0;sosu[j] !=0 ;j++){
      if(i%sosu[j]==0){
	a = 1;
	break;
      }
    }
    if(a==0){
      sosu[k]=i;
      k++;
      if(k==10000) break;
    }
  }

  while(1){
    a =0;
    scanf("%d", &n);
    if(n==0) break;
    for(i=0;i<n;i++){
      a += sosu[i];
    }
    printf("%d\n", a);
  }
  return 0;
}

Measured memory_bytes: 316
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String S=sc.next();
int a=0;
for(int i=0;i<4;i++){
if(S.charAt(i)=='+')a++;
if(S.charAt(i)=='-')a--;
}
System.out.println(a);
}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

void solve() {
	int n;
	cin >> n;
	map<string, int> u;
	for(int i = 0; i < n; i++) {
		string s;
		cin >> s;
		u[s]++;
	}
	
	int mx = 0;
	for(auto s : u) {
		mx = max(mx, s.ss);
	}
	
	vector<string> sc;
	for(auto s : u) {
		if(s.ss == mx) {
			sc.pub(s.ff);
		}
	}
	
	sort(all(sc));
	for(int i = 0; i < sc.size(); i++) cout << sc[i] << endl;
	
	return;
}

int main(){
#define MULTITEST 0
#if MULTITEST   
 
    CASET {
        solve();
    }
    
#else

    solve();
    
#endif

    return 0;
}

Measured memory_bytes: 27200
#include<stdio.h>

int main()
{
	int n;
	int p[100];
	int ans=0;
	scanf("%d", &n);
	for (int i = 0;i < n;i++) {
		scanf("%d", &p[i]);
	}
	for (int i = 1;i <= n-2;i++) {
		if (p[i - 1] < p[i] && p[i] < p[i + 1])
			ans++;
		if (p[i - 1] > p[i] && p[i] > p[i + 1])
			ans++;
	}
	printf("%d", ans);
	return 0;
}

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

int main(){
    int A,B,C, me, t=0;
    cin >> A >> B >> C;
    if(A<B && A<C){
        t+=A;
        if(B<C){
            t+=B;
        }
        else{
            t+=C;
        }
    }
    else if(B<A && B <C){
        t+=B;
        if(A<C){
            t+=A;
        }
        else{
            t+=C;
        }
    }
    else{
        t+=C;
        if(A<B){
            t+=A;
        }
        else{
            t+=B;
        }
    }
    cout << t;
    return 0;
}

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

int main() {
  int N = 0, P = 0, W = 0, G = 0, Y = 0;
  string S;

  cin >> N;

  while (N > 0) {
    cin >> S;

    if (S == "P") {
      P++;
    }

    else if (S == "W") {
      W++;
    }

    else if (S == "G") {
      G++;
    }

    else if (S == "Y") {
      Y++;
    }

    N--;
  }

  if (P * W * G * Y == 0) {
    cout << "Three" << endl;
  }

  else if (P * W * G * Y > 0) {
    cout << "Four" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //ライブラリ全読み込み
using namespace std; //std:を省略できる

int swap(int& a,int& b){
    int buf = a;
    a = b;
    b = buf;
}

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a>b) swap(a,b);
    if(b>c) swap(b,c);
    if(a>b) swap(a,b);
    cout << a <<" "<<b<<" "<<c<<endl;
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector <vector <int> > vv;
vector <int> used, cur, ch;

void dfs(int v)
{
    used[v] = 1;
    cur.push_back(v);
    for(int i = 0; i < vv[v].size(); i++)
    {
        int to = vv[v][i];
        if(!used[to])
            dfs(to);
    }

}


int main()
{
    int n, m;
    cin >> n >> m;
    vector <int> a(n + 1);
    vv.resize(n + 1); used.resize(n + 1);
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    for(int i = 0; i < m; i++)
    {
        int f, t;
        cin >> f >> t;
        vv[f].push_back(t);
        vv[t].push_back(f);
    }
    int ans(0);
    for(int i = 1; i <= n; i++)
    {
        if(!used[i])
        {
            cur.clear();
            ch.clear();
            dfs(i);
            for(int j = 0; j < cur.size(); j++)
                ch.push_back(a[cur[j]]);
            sort(ch.begin(), ch.end());
            sort(cur.begin(), cur.end());
            /*for(int j = 0; j < cur.size(); j++)
                cout << cur[j] << " ";
            cout << '\n';
            for(int j = 0; j < ch.size(); j++)
                cout << ch[j] << " ";
            cout << '\n';*/
            int id1(0), id2(0);
            while(id1 < cur.size() && id2 < ch.size())
            {
                if(cur[id1] == ch[id2])
                {
                    //cout << "!" << cur[id1] << " " << ch[id2] << '\n';
                    ans++, id1++, id2++;
                    continue;
                }
                if(cur[id1] < ch[id2])
                    id1++;
                else
                    id2++;
            }
        }
    }
    cout << ans;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

int N, K, C, L[200010], R[200010];
bool S[200010];

signed main(){
    cin >> N >> K >> C;
    string str; cin >> str;
    REP(i, N){
        if(str[i] == 'o') S[i] = true;
        else S[i] = false;
    }
    int l = 0;
    REP(i, K){
        while(!S[l]) l++;
        L[i] = l;
        l += C + 1;   
    }
    int r = N - 1;
    REP(i, K){
        while(!S[r]) r--;
        R[K - 1 - i] = r;
        r -= C + 1;
    }
    REP(i, K){
        if(L[i] == R[i]) PRINT(L[i] + 1);
    }
    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value


void solve() {

	int A, B, K;

	cin >> A >> B >> K;

	vi l;

	int cnt = 0;
	for (int i = 1; i <= min(A, B); i++) {
		if (A%i == 0 && B%i == 0) {
			l.eb(i);
		}
	}

	sort(l.begin(), l.end(), greater<int>());
	cout << l[K - 1] << endl;

	return;

}

int main() {

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

	solve();

	return 0;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 998244353;

int main() {
  int r;
  cin >> r;
  cout << r * r << endl;
  return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
const int N=2005,K=10005;
char ch[N][K];
int n,k,len[N];
bitset<K> f[N];
pair<int,int> v[2][K];
int main(){
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++){
		scanf("%s",ch[i]+1);
		len[i]=strlen(ch[i]+1);
	}
	f[n+1][0]=1;
	for (int i=n;i;i--)f[i]=f[i+1]|(f[i+1]<<len[i]);
	int cnt=0;
	for (int i=1;i<=n;i++)
		if (f[i+1][k-len[i]])v[0][++cnt]=mp(i,1);
	for (int i=1;i<=k;i++){
		char Ans='z';
		int ncnt=0,ID=n+1;
		for (int j=1;j<=cnt;j++)Ans=min(Ans,ch[v[i-1&1][j].fi][v[i-1&1][j].se]);
		putchar(Ans);
		for (int j=1;j<=cnt;j++){
			int id=v[i-1&1][j].fi,pos=v[i-1&1][j].se;
			if (ch[id][pos]!=Ans)continue;
			if (pos<len[id])v[i&1][++ncnt]=mp(id,pos+1);
			else ID=min(ID,id);
		}
		for (int j=ID+1;j<=n;j++)
			if (k-i-len[j]>=0&&f[j+1][k-i-len[j]])v[i&1][++ncnt]=mp(j,1);
		cnt=ncnt;
	}
	return 0;
}


Measured memory_bytes: 21504
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int m, f, r;
    while(cin >> m >> f >> r) {
        if(m == -1 && f == -1 && r == -1) break;
        if(m == -1 || f == -1) cout << 'F' << endl;
        else if(m + f < 30) cout << 'F' << endl;
        else if(m + f < 50) {
            if(r >= 50) cout << 'C' << endl;
            else cout << 'D' << endl;
        }
        else if(m + f < 65) cout << 'C' << endl;
        else if(m + f < 80) cout << 'B' << endl;
        else cout << 'A' << endl; 
    }

    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>  // ver2.2.3
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){Vout(a[lY]);}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define Verr(a) rep(iZ,0,a.size()-1)cerr<<a[iZ]<<' ';cerr<<a.back()<<endl
#define VVerr(a) rep(iY,0,a.size()){Verr(a[iY]);}
#define VPerr(a) rep(iX,0,a.size())cerr<<a[iX].FI<<' '<<a[iX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void press(auto &v){v.erase(unique(ALL(v)),v.end());}  //  圧縮
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n;
  cin >> n;
  Vi a(n);
  Vin(a);
  int ans = n;
  queue<int> big;
  int now = 0;
  rep(i,0,n){
    while((a[i]^now) != a[i]+now){
      now = now^(big.front());
      big.pop();
    }
    now += a[i];
    big.push(a[i]);
    ans += big.size()-1;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3456
#include<iostream>
#include<algorithm>
using namespace std;
long long a[100001],b[100001];
int main()
{
	int n,h;
	cin>>n>>h;
	long long sum=0,num=0,max1=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
		max1=max(max1,a[i]);
	}
	for(int i=0;i<n;i++)
	{
		if(b[i]>=max1)
		{
			sum+=b[i];
			num++;
		} 
	}
	if(sum>=h)
	{
		sort(b,b+n);
		int i=0;
		while(sum-b[i]>=h)
		{
			if(b[i]>=max1)
			{
				num--;
		     	sum-=b[i];
			} 
			i++;
		}
		cout<<num<<endl;
		return 0;
	}
	else
	{
		while(sum<h)
		{
			h-=max1;
			num++;
		}
		cout<<num<<endl;
		return 0;
	}
}


Measured memory_bytes: 1792
S = input()

ans = 0
count_list = [[2 ** (len(S)-1)]]

for i in range(1, len(S)):
    if i == 1:
        count_list.append([2 ** (len(S)-2), 2 ** (len(S)-2)])
    else:
        a = []
        for j in count_list[i-1][:i-1]:
            a.append(j)
        a.append(count_list[i-1][-1]//2)
        a.append(count_list[i-1][-1]//2)
        count_list.append(a)

count_list = count_list[::-1]

for i in range(len(S)):
    flag = 1
    for j in count_list[i]:
        ans += int(S[i]) * flag * j
        flag *= 10

print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {

	private class Node {
		int p = -1, l, r;
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		Node[] nodes = new Node[n];
		for (int i = 0; i < n; i++)
			nodes[i] = new Node();
		for (int i = 0; i < n; i++) {
			StringTokenizer st = new StringTokenizer(reader.readLine());
			int id = Integer.parseInt(st.nextToken());
			int l = Integer.parseInt(st.nextToken());
			int r = Integer.parseInt(st.nextToken());
			nodes[id].l = l;
			nodes[id].r = r;
			if (l != -1)
				nodes[l].p = id;
			if (r != -1)
				nodes[r].p = id;
		}
		reader.close();

		int rootId = -1;
		for (int i = 0; i < n; i++) {
			if (nodes[i].p == -1) {
				rootId = i;
				break;
			}
		}

		System.out.println("Preorder");
		preOrder(nodes, rootId);
		System.out.println("Inorder");
		inOrder(nodes, rootId);
		System.out.println("Postorder");
		postOrder(nodes, rootId);
	}
	
	private void preOrder(Node[] nodes, int rootId) {
		Stack<Integer> stack = new Stack<Integer>();
		stack.push(rootId);
		while (!stack.isEmpty()) {
			int cur = stack.pop();
			System.out.print(" " + cur);
			if (nodes[cur].r != -1)
				stack.push(nodes[cur].r);
			if (nodes[cur].l != -1)
				stack.push(nodes[cur].l);
		}
		System.out.println("");
	}

	private void inOrder(Node[] nodes, int rootId) {
		Stack<Integer> stack = new Stack<Integer>();
		int cur = rootId;
		while (cur != -1 || !stack.isEmpty()) {
			if (cur != -1) {
				stack.push(cur);
				cur = nodes[cur].l;
			} else {
				cur = stack.pop();
				System.out.print(" " + cur);
				cur = nodes[cur].r;
			}
		}
		System.out.println("");
	}

	private void postOrder(Node[] nodes, int rootId) {
		Stack<Integer> stack = new Stack<Integer>();
		int lastVisited = -1;
		int cur = rootId;
		while (cur != -1 || !stack.isEmpty()) {
			if (cur != -1) {
				stack.push(cur);
				cur = nodes[cur].l;
			} else {
				int peekId = stack.peek();
				if (nodes[peekId].r != -1 && nodes[peekId].r != lastVisited) {
					cur = nodes[peekId].r;
				} else {
					System.out.print(" " + peekId);
					lastVisited = stack.pop();
				}
			}
		}
		System.out.println("");
	}
}


Measured memory_bytes: 24268
# coding: utf-8
def II(): return int(input())
def ILI(): return list(map(int, input().split()))


def read():
    N, K = ILI()
    A, B = [], []
    for __ in range(N):
        a, b = ILI()
        A.append(a)
        B.append(b)
    return N, K, A, B


def solve(N, K, A, B):
    l_K = [K]
    len_bin_K = len(bin(K)) - 2
    all_1 = sum([2 ** x for x in range(len_bin_K - 1)])
    l_K.append(all_1)
    for i in range(len(bin(K)) - 4, -1, -1):
        if K >> i & 1 == 1:
            now = K >> i
            now = now & ~1
            now = ~now
            now = now << (i)
            now = ~now
            l_K.append(now)

    l_ans = [0] * len(l_K)
    for i in range(N):
        for j in range(len(l_K)):
            if l_K[j] | A[i] == l_K[j]:
                l_ans[j] += B[i]
    ans = max(l_ans)
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()


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

int N;
int A[210];

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

    int res = 0;

    while(true){
        bool exist_odd = false;
        for(int i=0;i < N; ++i){
            if(A[i] % 2 != 0) exist_odd = true;
        }

        if(exist_odd) break;

        for(int i = 0; i< N; i++){
            A[i] /= 2;
        }
        ++res;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
import scala.io.Source.stdin
import scala.collection.mutable.{ Queue }

case class Node(
  id: Int,
  children: List[Int],
  var distance: Int = -1
)

object Main {
  var currentDist: Int = 0
  var nodes: Array[Node] = null

  def main(argv: Array[String]) = {
    val head :: tail = stdin.getLines.toList
    val count = head.toInt
    nodes = new Array[Node](count)

    tail foreach { line =>
      val id :: length :: children = line.split(" ").map(_.toInt).toList
      nodes(id-1) = Node(id, children)
    }

    nodes.head.distance = 0
    val q = new Queue[Node]()
    q.enqueue(nodes.head)
    bfs(q)

    nodes foreach { node =>
      println(s"${node.id} ${node.distance}")
    }
  }

  def bfs(q: Queue[Node]): Unit = {
    while (q.length > 0) {
      val current = q.dequeue()
      current.children.foreach { n =>
        if (nodes(n-1).distance == -1) {
          nodes(n-1).distance = current.distance + 1
          q.enqueue(nodes(n-1))
        }
      }
    }
  }
}



Measured memory_bytes: 44604
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
/*
d : diagonal
l : left
u : up
*/
int main(){
  string s,t;
  cin>>s>>t;
  int n=s.size(),m=t.size();
  int dp[n+1][m+1];

  for(int i=0;i<=m;i++)  dp[0][i] = 0;
  for(int i=0;i<=n;i++)  dp[i][0] = 0;

  char dir[n+1][m+1];
  for(int i=0;i<=n;i++)
  for(int j=0;j<=m;j++)
  dir[i][j] = 'n';
  string str = "";
  for(int i=1;i<=n;i++)
  for(int j=1;j<=m;j++){
    if(s[i-1] == t[j-1]){
      dir[i][j] = 'd';
      dp[i][j] = dp[i-1][j-1] + 1;
      //str+=s[i-1];
    }
    else{
      if(dp[i-1][j] >= dp[i][j-1]){
        dir[i][j] = 'u';
        dp[i][j] = dp[i-1][j];
      }
      else{
        dir[i][j] = 'l';
        dp[i][j] = dp[i][j-1];
      }
    }
  }

/*for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++)
  cout<<dp[i][j]<<dir[i][j]<<" ";
  cout<<endl;
}*/
int x=n,y=m;
for(int i=0;i<(m+n);i++){
  if(dir[x][y] == 'n')  break;
  if(dir[x][y] == 'd'){
    //cout<<dp[x][y];
    str+=s[x-1];
    x--;
    y--;
  }
  if (dir[x][y] == 'u')
  x--;
  if(dir[x][y] == 'l')
  y--;
}

reverse(str.begin(),str.end());
cout<<str<<endl;

}


Measured memory_bytes: 44288
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <cmath>

int gcd_euclid(int u, int v)
{
    int r;
    while (0 != v)
    {
        r = u % v; u = v; v = r;
    }
    return u;
}

int main()
{
    int N;
    std::cin >> N;
    std::vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        std::cin >> A[i];
    }

    int ans = 0;

    std::vector<int> L(N), R(N);
    L[0] = 0;
    for (int i = 1; i < N; i++)
    {
        L[i] = gcd_euclid(L[i - 1], A[i - 1]);
    }
    R[N - 1] = 0;
    for (int i = N - 2; i >= 0; i--)
    {
        R[i] = gcd_euclid(R[i + 1], A[i + 1]);
    }

    for (int i = 0; i < N; i++)
    {
        ans = std::max(gcd_euclid(L[i], R[i]), ans);
    }

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

Measured memory_bytes: 1408
import sys
sys.setrecursionlimit(100000)
n,m = map(int,input().split())
def find(x):
  if par[x] == x:
    return x
  else:
    return find(par[x])

def unite(x,y):
  x = find(x)
  y = find(y)

  if x != y:
    if rank[x] < rank[y]:
      par[x] = y
      size[y] += size[x]
    else:
      par[y] = x
      size[x] += size[y]
      if rank[x]==rank[y]:
        rank[x] += 1

def same(x,y):
  return find(x) == find(y)


par = [0]*n
for i in range(n):
  par[i] = i
rank = [1]*n
size = [1]*n

edge = [tuple(map(int,input().split())) for i in range(m)]
edge = edge[::-1]
for i in range(m):
  edge[i] = (edge[i][0]-1,edge[i][1]-1)

res = []
for i in range(m):
  fi = find(edge[i][0])
  se = find(edge[i][1])
  if fi == se:
    res.append(0)
  else:
    res.append(size[fi]*size[se])
    unite(fi,se)
  #print("rank:{}".format(rank))
  #print("size:{}".format(size))
  #print("par:{}".format(par))
  #print("res:{}".format(res))
  #print("======")
ass = 0
for i in range(m):
  ass += res[m-1-i]
  print(ass)

Measured memory_bytes: 24088
a,b,c=map(int,input().split())

if a>b:
    temp=a
    a=b
    b=temp

if b>c:
    temp=b
    b=c
    c=temp
    
if a>b:
    temp=a
    a=b
    b=temp
    
print(a,b,c)    


Measured memory_bytes: 5596
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n;cin >> n;
    int ans = 0;
    rep1(i, n) ans+=((i+(n/i)*i)*(n/i))/2;
    cout << ans << endl;
    return 0;
}

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

int main() {
  long long n,k; cin >> n >> k;
  long long foo = n / k;
  long long ans = n - (k * foo);

  while(true) {
    long long current = abs(ans - k);
    if(ans < current){
      break;
    } else {
      ans = current;
    }
  }
  
  cout << ans << endl;
  
  
  return 0; 
}

// abs(a,b ) -> absolute

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

typedef pair<int, int> P;
const int M = 1000000007;

vector<int> dijkstra(int s, vector<vector<P>> edge) {
    int n = edge.size();
    vector<int> dist(n, M);
    priority_queue<P, vector<P>, greater<P>> q;
    dist[s] = 0;
    q.push(P(0, s));
    while (!q.empty()) {
        P p = q.top();
        q.pop();
        int d = p.first;
        for (auto& e : edge[p.second]) {
            if (dist[e.second] > p.first + e.first) {
                dist[e.second] = p.first + e.first;
                q.push(P(p.first + e.first, e.second));
            }
        }
    }
    return dist;
}


int main() {
    int n;
    cin >> n;
    vector<vector<P>> edge(n);
    for (int i = 0; i < n; ++i) {
        int u, k;
        cin >> u >> k;
        if (i != u) exit(1);
        for (int j = 0; j < k; ++j) {
            int v, c;
            cin >> v >> c;
            edge[i].push_back(P(c, v));
        }
    }
    vector<int> d = dijkstra(0, edge);
    for (int i = 0; i < n; ++i) {
        cout << i << " " << d[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define int long long
#define swap(x,y) (x^=y^=x^=y)

#define debug1(a) cerr<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

using namespace std;

#define mod 1000000007
long long modexpo(long long x, long long p){
    int res = 1;x = x%mod;
    while(p){
        if(p%2)res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

// int max(int a,int b){return (a>b?a:b);} 
// int min(int a,int b){return (a<b?a:b);}


struct compare{
    bool operator() (const pair<int,int> a, const pair<int,int> b) const{
        return a.first < b.first;
    }
};

const int nax = 1e5 + 5;
vector<pair<int,int>> g[nax][3];
int n,m,s,t;
int dist[nax][3];
int32_t main(){
    IOS
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        g[a][0].pb({b,1});
        g[a][1].pb({b,2});
        g[a][2].pb({b,0});
    }
    cin >> s >> t;
    for(int i = 1; i <= n; i++){
        dist[i][0] = dist[i][1] = dist[i][2] = 1e12;
    }
    set<pair<int, pair<int,int>>> q;
    q.insert({0,{s,0}});
    dist[s][0] = 0;
    int ans = 1e18;
    while(!q.empty()){
        int x = q.begin()->second.first;
        int y = q.begin()->second.second;
        q.erase(q.begin());
        for(auto it : g[x][y]){
            if(dist[it.first][it.second] > dist[x][y] + 1){
                q.erase({dist[it.first][it.second], {it.first, it.second}});
                dist[it.first][it.second] = dist[x][y] + 1;
                q.insert({dist[it.first][it.second], {it.first, it.second}});
                if((dist[it.first][it.second])%3 == 0 && it.first == t){
                    // debug3(it.first, it.second, dist[it.first][it.second]);
                    ans = min(ans, dist[it.first][it.second]);
                }
            }
        }
    }
    if(ans == 1e18){
        cout << -1 << endl;
    }
    else{
        cout << ans/3 << endl;
    }
} 

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

int main() {
  int h,w;
  cin>>h>>w;
  char a[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
    }
  }
  int b[h][w];
  int c[h][w];
  for(int i=0;i<h;i++){
    int d=-1;
    for(int j=0;j<w;j++){
      if(a[i][j]=='#'){
        for(int k=d+1;k<j;k++){
          b[i][k]=j-d-1;
        }
        b[i][j]=0;
        d=j;
      }
    }
    for(int j=d+1;j<w;j++){
      b[i][j]=w-d-1;
    }
  }
  
  for(int i=0;i<w;i++){
    int d=-1;
    for(int j=0;j<h;j++){
      if(a[j][i]=='#'){
        for(int k=d+1;k<j;k++){
          c[k][i]=j-d-1;
        }
        c[j][i]=0;
        d=j;
      }
    }
    for(int j=d+1;j<h;j++){
      c[j][i]=h-d-1;
    }
  }
  int ans=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      ans=max(ans,b[i][j]+c[i][j]);
    }
  }
  cout<<ans-1<<endl;
}


Measured memory_bytes: 35456
#include <iostream>

using namespace std;

int main(void)
{
  unsigned long long N, M;
  cin >> N >> M;

  unsigned long long count = 0;

  if( N*2 < M){
    count += N;
    M -= N*2;
  }
  else{
    N = M/2;
    count += N;
    M-=N*2;
  }
  if(M >= 4){
    count += M/4;
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
	double x1 = scan.nextDouble();
	double y1 = scan.nextDouble();
	double x2 = scan.nextDouble();
	double y2 = scan.nextDouble();
	double X = Math.pow(x2 - x1, 2);
	double Y = Math.pow(y2 - y1, 2);
	double len = Math.sqrt(X + Y);
	System.out.println(len);
	}
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

signed main(){
    string s;cin>>s;
    cout<<s.substr(0,s.size()-8)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;
 
#define Pr(f,...) printf(f,##__VA_ARGS__),fflush(stdout)

typedef long long ll;

const ll oo=1e18;
ll a,b,c,k,ans;

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	//freopen("dat.in","r",stdin); 
	//freopen("my.out","w",stdout); 
#endif
	cin>>a>>b>>c>>k;
	if(k%2==0)ans=a-b;else ans=b-a; 
	if(ans>oo)cout<<"Unfair"<<endl;
	else cout<<ans<<endl;
	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	ios::sync_with_stdio(false);
	int n,k;cin>>n>>k;
	if(k==1){
		cout<<0;
		return 0;
	}
	
	n-=k;
	cout<<n;
	return 0;
}

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

int main(){
  int N; cin >> N;
  int R, retval=-1000000009, R_min;
  
  rep(i,N){
    cin >> R;
    if (i==0){
      R_min = R;
      continue;
    }
    retval = max(retval, R-R_min);
    R_min = min(R_min, R);
  }
  cout << retval << endl;  

  return 0;
}

 


Measured memory_bytes: 3104
from math import pi, atan

a, b, x = map(int, input().split())

if a**2 * b * 0.5 <= x:
    theta = atan(2 * (a**2 * b - x) / a**3)
else:
    theta = atan(a * b**2 * 0.5 / x)

print("{:.10f}".format(theta / pi * 180))


Measured memory_bytes: 2940
N = int(input())
As = list(map(int, input().split()))

ans = float('inf')
iB, iD = 1, 3
(P, Q, R), S = As[:3], sum(As[3:])

# 真ん中の区切りを全通り試す
for iC in range(2, N - 1):
    while P < Q and As[iB] <= Q - P:
        P += As[iB]
        Q -= As[iB]
        iB += 1

    while R < S and As[iD] <= S - R:
        R += As[iD]
        S -= As[iD]
        iD += 1

    ans = min(ans, max(P, Q, R, S) - min(P, Q, R, S))

    Q += As[iC]
    R -= As[iC]

print(ans)

Measured memory_bytes: 24684
var lines = [];

var readline = require('readline');
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var tmp = lines.shift().split(" ");
    var A = Number(tmp[0]);
    var B = Number(tmp[1]);

    var result =0;
    for (var i = 0; i < 2; i++) {
        if(A < B){result += B; B--;}
        else{result += A; A--;}
    }

    console.log(result);
});

Measured memory_bytes: 7500
import numpy as np

N, M = map(int,input().split())
H = list(map(int,input().split()))
A = []
B = []
for i in range(M):
  a, b = map(int,input().split())
  A.append(a)
  B.append(b)
  
link = {}
for i in range(M):
  if A[i] in link.keys():
    link[A[i]].append(H[B[i]-1])
  else:
    link[A[i]] = [H[B[i]-1]]
  if B[i] in link.keys():
    link[B[i]].append(H[A[i]-1])
  else:
    link[B[i]] = [H[A[i]-1]]
  
ans = 0
for i in range(1, N+1, 1):
  if i not in link.keys():
    ans += 1
  else:
    if H[i-1] > max(link[i]):
      ans += 1
      
print(ans)

Measured memory_bytes: 51952
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#define Debug 0
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 998244353;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

//入出力高速化(非同期化)
void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    int N; cin >> N;
    vector<int> a(N);
    int cnt = 0;
    long long sum = 0;
    int mi = 1000000001;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        mi = min(abs(a[i]), mi);
        sum += abs(a[i]);
    }
    for (int i = 0; i < N; i++) {
        if (a[i] < 0) cnt++;
        if (a[i] == 0) {
            cnt = 0;
            break;
        }
    }
    if (cnt % 2) {
        cout << sum-mi*2 << endl;
    } else {
        cout << sum << endl;
    }

}



Measured memory_bytes: 768
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
using namespace std;

/*
const int MAX_E=2*(100-1);
const int MAX_V=100;
const long long int INF=100000000;
struct edge { int from,to,cost;};
edge es[MAX_E];
//int d[MAX_V];
int V,E;
void shortest_path(int s,int e,vector<int>& d);
int main(){
	int n,k;
	while(cin >> n >> k&&n!=0&&k!=0){
		int V=n;
		int E=2*(n-1);
		vector<int> land(V);
		int l=0;
		for(int i=0; i<E; ++i){
			es[i].cost=-1;
			es[i].from=-1;
			es[i].to=-1;
		}
		for(int i=0; i<k; ++k){
			int m;
			cin >> m;
			if(m==0){
				int a,b;
				cin >> a >> b;
				shortest_path(a,b,land);
				cout << land[b] << "\n";
			} else if(m==1){
				int c,d,e;
				cin >> c >> d >> e;
				es[l].from=c;
				es[l].to=d;
				es[l].cost=e;
				es[l+1].from=d;
				es[l+1].to=c;
				es[l+1].cost=e;
				l+=2;
			}
		}
	}
	return 0;
}
*/
void func(string str,vector<int>& a);
const int INF=10000000;
int main(){
	int n,m;
	cin >> n >> m;
	vector< vector<int> > wf(n+1,vector<int>(n+1));
	for(int i=1; i<n+1; ++i){
		for(int j=1; j<n+1; ++j){
			wf[i][j]=INF;
		}
	}
	for(int i=1; i<n+1; ++i){
		for(int j=1; j<n+1; ++j){
			if(i==j)wf[i][j]=0;
		}
	}
	for(int i=0; i<m; ++i){
		string str;
		vector<int> abcd(4);
		cin >> str;
		func(str,abcd);
		wf[abcd[0]][abcd[1]]=abcd[2];
		wf[abcd[1]][abcd[0]]=abcd[3];
	}
	vector<int> xy(4);
	string hoge;
	cin >> hoge;
	func(hoge,xy);
	for(int i=1; i<n+1; ++i){
		for(int j=1; j<n+1; ++j){
			for(int k=1; k<n+1; ++k){
				wf[j][k]=min(wf[j][k],wf[j][i]+wf[i][k]);
			}
		}
	}
	//cout << xy[2] << " " << xy[3] << " " << wf[xy[0]][xy[1]] << " " << wf[xy[1]][xy[0]] << "\n";
	cout << xy[2]-xy[3]-wf[xy[0]][xy[1]]-wf[xy[1]][xy[0]] << "\n";
	return 0;
}

void func(string str,vector<int>& a){
	int n;
	n=str.size();
	int j=0;
	string tmp;
	for(int i=0; i<n; ++i){
		if(i==n-1){
			tmp+=str[i];
			a[j]=atoi(tmp.c_str());
		} else {
			if(str[i] != ','&&i!=n-1) {
				tmp+=str[i];
			} else{
				a[j]=atoi(tmp.c_str());
				++j;
				tmp="";
			}
		}
	}
}

Measured memory_bytes: 1244
import bisect
n = int(input())

def Prime(m):
    res = {}
    x = m
    i = 2
    while i*i <= m:
        if x%i == 0:
            res[i] = 0
            while x%i == 0:
                x //= i
                res[i] += 1
        i += 1
    if x > 1:
        if x not in res:res[x] = 0
        res[x] += 1
    return res
array = [0]*1000
for i in range(1000):
    array[i] = i*(i+1)//2
ans = 0
for v in Prime(n).values():
    ans += bisect.bisect_right(array,v) - 1
print(ans)


Measured memory_bytes: 9220
S = input()
N = len(S)

a = S[0:(N - 1) // 2]
b = S[(N + 3) // 2 - 1:]

if S[::] != S[::-1]:
    print('No')
    exit()

N2 = len(a)
c = a[::-1]
d = b[::-1]
#print(a, b)

if N2 % 2 == 0:
    # print(a[0:N2 // 2])
    # print(c[0:N2 // 2])
    # print(b[0:N2 // 2])
    # print(d[0:N2 // 2])
    if a[0:N2//2] == c[0:N2//2] and b[0:N2//2] == d[0:N2//2]:
        print('Yes')
    else:
        print('No')

if N2 % 2 == 1:
    # print(a[0:(N2 + 1) // 2])
    # print(c[0:(N2 + 1) // 2])
    # print(b[0:(N2 + 1) // 2])
    # print(d[0:(N2 + 1) // 2])
    if a[0:(N2+1)//2] == c[0:(N2+1)//2] and b[0:(N2+1)//2] == d[0:(N2+1)//2]:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX

#include <bits/stdc++.h>
#define db(x) cout << (x) << '\n';
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
typedef pair<double,ll> pdi;
typedef pair<ld,ld> pdd;
typedef pair<double,ll> pdi;
typedef pair<double,pii> pdp;
typedef pair<string,ll> psi;
typedef pair<ll,string> pls;
typedef pair<string,string> pss;
typedef pair<ll,pii> pip;
typedef pair<pii,pii> ppp;
typedef complex<ld> point;
typedef pair<point,int> ppi;
#define mod (int)(1e9+7)
#define eps (1e-9)
#define oo (ll)(0x3f3f3f3f)
#define pi acos(-1)
#define MAXN (ll)(1e3+5)

char mm[7][7];
bool mk[7][7];

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

    int n,m,k;
    cin >> n >> m >> k;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin >> mm[i][j];
    int res=0;
    for(int i=0;i<(1<<n);i++)
        for(int j=0;j<(1<<m);j++)
        {
            for(int x=0;x<n;x++)
                if(i&(1<<x))
                    for(int y=0;y<m;y++)
                        mk[x][y]=1;
            for(int y=0;y<m;y++)
                if(j&(1<<y))
                    for(int x=0;x<n;x++)
                        mk[x][y]=1;
            int cont=0;
            for(int x=0;x<n;x++)
                for(int y=0;y<m;y++)
                {
                    if(!mk[x][y] && mm[x][y]=='#')
                        cont++;
                    mk[x][y]=0;
                }
            if(cont==k)
                res++;
        }
    db(res)

    return 0;
}


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

using ll = long long;

ll func(ll a,ll b){
  if(a>b)swap(a,b);
  if(a==1 and b==1)return 1;
  if(a==1)return max(b-2,0ll);
  return max(a-2,0ll) * max(b-2,0ll);
}

int main(){
  ll a;
  ll b;
  cin >> a >> b;
  cout << func(a,b) << endl;
}


Measured memory_bytes: 3584
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

const int MAX_N = 200001;
int N, A[MAX_N], cnt[MAX_N];
int64_t ans;

int main() {
    cin >> N;
    rep(i, N) {
        cin >> A[i];
        ans += cnt[A[i]];
        cnt[A[i]]++;
    }
    rep(i, N) {
        cout << ans - cnt[A[i]] + 1 << endl;
    }
}

Measured memory_bytes: 3712
#include <stdio.h>

int main(){
  int i, n, min, max, x, y;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){

    scanf("%d",&x);

    if(i == 0) y = x;

    if(i == 1) max = x - y;
    else if (max < x - min) max = x - min;

    if(i == 0) min = x;
    else if (min > x) min = x;
  }

  printf("%d\n", max);

  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};


int main(){
    SCIN(N);
    if(N.size()==1){
        COUT("ABC00"+N);
        return 0;
    }
    if(N.size()==2){
        COUT("ABC0"+N);
        return 0;
    }
    if(N.size()==3){
        COUT("ABC"+N);
        return 0;
    }
    return 0;
}


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

using namespace std;

int main()
{
    long x,y;
    cin>>x;
    y=x%10;
    if(y==2||y==4||y==5||y==7||y==9)
        cout<<"hon"<<endl;
    else if(y==0||y==1||y==6||y==8)
        cout<<"pon"<<endl;
    else if(y==3)
        cout<<"bon"<<endl;
    return 0;
}


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

int main(){

  int h, w;

  while(1) {

    cin >> h >> w;

    if(h == 0 && w == 0) break;
    
    for(int i=1; i<=h; i++) {
      for(int i=1; i<=w; i++) cout << "#";
      cout << "\n";  
    }
    cout << "\n";
  }
    
  return 0;
}

Measured memory_bytes: 1120
import java.util.*;
import java.lang.*;
import java.io.*;
 
public class Main
{
	public static void main (String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
		int left = in.nextInt() + in.nextInt();
		int right = in.nextInt() + in.nextInt();
 
		if(left > right) {
			System.out.println("Left");
 
		} else if(left < right) {
			System.out.println("Right");
		} else 
		System.out.println("Balanced");
 	}
}

Measured memory_bytes: 21844