akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long N, P, A[1 << 18];
long long dp[59][2];

int main() {
	cin >> N >> P;
	for (int i = 1; i <= N; i++) cin >> A[i];
	dp[0][0] = 1;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < 2; j++) {
			dp[i][j] += dp[i - 1][j];
			dp[i][j ^ (A[i] % 2)] += dp[i - 1][j];
		}
	}
	cout << dp[N][P] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main() {
    bool s[13] = { false };
    bool h[13] = { false };
    bool c[13] = { false };
    bool d[13] = { false };
    int n;
    char l;
    int a;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> l >> a;
        if (l == 'S'){
            s[a-1] = true;
        }else if (l=='H'){
            h[a-1] = true;
        }else if (l=='C'){
            c[a-1] = true;
        }else if (l=='D'){
            d[a-1] = true;
        }
    }
    for (int i = 0; i < 13; i++){
        if (s[i] == false) {
            cout << "S " << i+1 << endl;
        }
    }
    for (int i = 0; i < 13; i++) {
        if (h[i] == false) {
            cout << "H " << i+1 << endl;
        }
    }
    for (int i = 0; i < 13; i++) {
        if (c[i] == false) {
            cout << "C " << i+1 << endl;
        }
    }
    for (int i = 0; i < 13; i++) {
        if (d[i] == false) {
            cout << "D " << i+1 << endl;
        }
    }
    cin >> l;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){    

    int n,m,k;
    cin>>n>>m>>k;

    vi a(n+1), b(m+1);
    a[0] = b[0] = 0;
    rep(i,1,n+1){
    	cin>>a[i];
    	a[i] += a[i-1];
    }
    rep(i,1,m+1){
    	cin>>b[i];
    	b[i] += b[i-1];
    }
    int ans = 0;
    for(int i = 0,j = m;i<=n;i++){
    	if(a[i]>k) break;
    	while(a[i] + b[j]>k)
    		j--;
    	ans = max(ans,i+j);
    }
    cout<<ans;
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 6348
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;


int main(void){
  int n,l,i;
  string s[105];
  
  cin >> n >> l;
  for (i=0;i<n;i++) cin >> s[i];
  
  sort(s,s+n);
  
  for (i=0;i<n;i++) cout << s[i];
  cout << endl;
  
  return 0;
}

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//切り上げ除算
long long cutup(long long a,long long b){return (a+b-1)/b;}

//累乗
template<typename t>
constexpr t my_pow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
    }
    return x;
}
#define pow my_pow

//chmin,chmax
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;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll k;
    cin>>k;
    vl A(k);
    rep(i,k)cin>>A[i];
    ll ma,mi;
    ma=mi=2;
    rep(i,k){
        if(ma/A[k-1-i]-(mi-1)/A[k-1-i]==0){
            cout<<-1<<endl;
            return 0;
        }
        mi=cutup(mi,A[k-i-1])*A[k-1-i];
        ma=(ma/A[k-i-1]+1)*A[k-i-1]-1;
    }
    cout<<mi<<" "<<ma<<endl;
}

Measured memory_bytes: 3952
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    vector<vector<ll> >arr(3,vector<ll>(3));
    for(ll i=0;i<3;i++)
    {
        for(ll j=0;j<3;j++)
            cin>>arr[i][j];
    }
    ll n;
    cin>>n;
    for(ll k=0;k<n;k++)
    {
        ll a,flag=0;
        cin>>a;
        for(ll i=0;i<3;i++)
        {
            for(ll j=0;j<3;j++)
            {
                if(arr[i][j]==a)
                {
                    arr[i][j]=-1;
                    flag=1;
                    break;
                }
            }
            if(flag)
                break;
        }
    }
    string ans="NO";
    ll flag=0;
    for(ll i=0;i<3;i++)
    {
        for(ll j=0;j<3;j++)
        {
            if(arr[i][j]!=-1)
                break;
            if(j==2)
            {
                cout<<"Yes";
                return 0;
            }
        }
    }
    for(ll j=0;j<3;j++)
    {
        for(ll i=0;i<3;i++)
        {
            if(arr[i][j]!=-1)
                break;
            if(i==2)
            {
                cout<<"Yes";
                return 0;
            }
        }
    }
    ll i=0,j=0;
    while(i<=2 && j<=2)
    {
        if(arr[i][j]!=-1)
            break;
        if(j==2)
        {
            cout<<"Yes";
            return 0;
        }
        i++;
        j++;
    }
    i=0,j=2;
    while(i<3 && j>=0)
    {
        if(arr[i][j]!=-1)
            break;
        if(j==0)
        {
            cout<<"Yes";
            return 0;
        }
        i++;
        j--;
    }
    cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int N, W;
int v[1111], w[1111];
int dp[1111][11111];

//?????????:????????????????????????????????????????????§???
int solve(int i, int r) // i: index, r: ?????????????????\??????
{
	if (dp[i][r] >= 0) return dp[i][r];
	if (i == N) return 0;
	int res = 0;
	res = solve(i + 1, r); //??\???????????´???
	if (r >= w[i]) res = max(res, solve(i + 1, r - w[i]) + v[i]); //??\????????´???
	dp[i][r] = res;
	return res;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	for (int i = 0; i < 1111; i++)
	{
		for (int j = 0; j < 11111; j++)
		{
			dp[i][j] = -1;
		}
	}
	cin >> N >> W;
	for (int i = 0; i < N; i++)
	{
		cin >> v[i] >> w[i];
	}
	int ans = solve(0, W);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 51436
//https://atcoder.jp/contests/aising2019/tasks/aising2019_a
//A - Bulletin Board
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
    ll N,H,W; cin>>N>>H>>W;    
    ll a=N-H+1;
    ll b=N-W+1;
    cout<<a*b<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法でnは？？
n,k=mii()

def bb(X, n):
    if (int(X/n)):
        return bb(int(X/n), n)+str(X%n)
    return str(X%n)

print(len(str(bb(n,k))))

Measured memory_bytes: 65388
import sys
import numpy as np
from numba import njit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

INF = 10**9 + 1

N, M = map(int, readline().split())
data = np.array(read().split(), np.int64)
A = data[::3]
B = data[1::3]
C = data[2::3]

D = A[N:]
E = B[N:]
F = C[N:]
A = A[:N]
B = B[:N]
C = C[:N]

X = np.unique(np.concatenate([A, B, D, [0, -INF, INF]]))
Y = np.unique(np.concatenate([C, E, F, [0, -INF, INF]]))
DX = X[1:] - X[:-1]
DY = Y[1:] - Y[:-1]

A = np.searchsorted(X, A)
B = np.searchsorted(X, B)
C = np.searchsorted(Y, C)
D = np.searchsorted(X, D)
E = np.searchsorted(Y, E)
F = np.searchsorted(Y, F)

H, W = len(X), len(Y)
N = H * W

@njit
def set_ng(A, B, C, D, E, F):
    ng = np.zeros((N, 4), np.bool_)

    for i in range(len(A)):
        for x in range(A[i], B[i]):
            v = x * W + C[i]
            ng[v][1] = 1
            ng[v - 1][0] = 1

    for i in range(len(D)):
        for y in range(E[i], F[i]):
            v = D[i] * W + y
            ng[v][3] = 1
            ng[v - W][2] = 1
    return ng

ng = set_ng(A, B, C, D, E, F)

x0, y0 = np.searchsorted(X, 0), np.searchsorted(Y, 0)
v0 = x0 * W + y0

@njit
def solve():
    visited = np.zeros(N, np.bool_)
    visited[v0] = 1
    stack = np.empty(N, np.int32)
    p = 0
    ret = 0

    def area(x):
        x, y = divmod(x, W)
        return DX[x] * DY[y]

    def push(x):
        nonlocal p, ret
        stack[p] = x
        visited[x] = 1
        ret += area(x)
        p += 1

    def pop():
        nonlocal p
        p -= 1
        return stack[p]

    push(v0)
    move = (1, -1, W, -W)
    while p:
        v = pop()
        for i in range(4):
            if ng[v][i]:
                continue
            w = v + move[i]
            if visited[w]:
                continue
            x, y = divmod(w, W)
            if x == 0 or x == H - 1 or y == 0 or y == W - 1:
                return 0
            push(w)
    return ret

x = solve()
if x == 0:
    print('INF')
else:
    print(x)

Measured memory_bytes: 172988
(defun choice (n)
  (/ (* n (- n 1)) 2))

(defun read-nums (n arr balls)
  (loop :as i
        :below n
        :do (let ((n (read)))
              (setf (aref balls i) n)
              (incf (aref arr (- n 1))))))

(defun calc-sum (n arr)
  (loop :as i
        :below n
        :sum (choice (aref arr i))))

(defun princ-answers (n arr balls)
  (let ((sum (calc-sum n arr)))
    (loop :as i
          :below n
          :do (format t 
                      "~A~%"
                      (+ (- sum (choice (aref arr (- (aref balls i) 1)))) 
                         (choice (- (aref arr (- (aref balls i) 1)) 1)))))))

(let* ((n (read))
       (balls (make-array n :initial-element 0 
                           :element-type 'fixnum))
       (arr (make-array n :initial-element 0 
                          :element-type 'fixnum)))
  (read-nums n arr balls)
  (princ-answers n arr balls))

Measured memory_bytes: 68260
# include <iostream>
using namespace std; 
int main(){
  int n,i,count; 
  cin>>n; 
  int ar[n];
  for(i=0;i<n;i++){
    cin>>ar[i];
  }
  count=0;
  for(i=0;i<n;i=i+2){
    if(ar[i]%2!=0){
      count++;
    }
  }
  cout<<count; 
  return 0;
}

Measured memory_bytes: 3592
// compile option: g++ -std=c++11
#include <algorithm>
#include <iostream>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// typedef pair<ll, ll> P;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n, q;
  cin >> n >> q;
  int s[n], t[n], x[n];
  REP(i, n) cin >> s[i] >> t[i] >> x[i];
  int d[q];
  REP(i, q) cin >> d[i];
  set<P> st;
  REP(i, q) st.insert(P(d[i], i));
  vector<T> vc;
  REP(i, n) vc.push_back(make_tuple(x[i], s[i] - x[i], t[i] - x[i]));
  sort(ALL(vc));
  int ans[q];
  REP(i, q) ans[i] = -1;
  REP(i, n) {
    int a, b, c;
    tie(a, b, c) = vc[i];
    auto it = st.lower_bound(P(b, -1));
    while (it != st.end()) {
      if (c <= it->first) break;
      ans[it->second] = a;
      st.erase(it++);
    }
  }
  REP(i, q) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 18288
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N; cin >> N;

    unordered_map<string, long long> appreared_pattern;
    for (int i = 0; i < N; i++) {
        string input_str; cin >> input_str;
        sort(input_str.begin(), input_str.end());
        appreared_pattern[input_str]++;
    }
    
    long long result = 0;
    for(auto &p: appreared_pattern){
        long long val = p.second;
        result += val * (val - 1) / 2;  // _{N}C_2
    }
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 10660
import java.util.Scanner;

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

	int N, K;
	N = sc.nextInt();
	K = sc.nextInt();

	int count = 0;
	do {
	    N = N / K;
	    count++;
	} while (N > 0);

	System.out.println(count);
    }
}

Measured memory_bytes: 23892
import sys
#sys.stdin=open("input1.in","r")
#sys.stdout=open("outpul.out","w")
# for _ in range(int(input())):
H1,M1,H2,M2,K=map(int,input().split())
mins=H2*60+M2-(H1*60+M1)
mins=mins-K
if(mins<=0):
    print(0)
else:
    print(mins)


Measured memory_bytes: 61628
x = int(input())

if x >= 400 and x<= 599:
  print(8)
elif x >= 600 and x<= 799:
  print(7)
elif x >= 800 and x<= 999:
  print(6)
elif x >= 1000 and x<= 1199:
  print(5)
elif x >= 1200 and x<= 1399:
  print(4)
elif x >= 1400 and x<= 1599:
  print(3)
elif x >= 1600 and x<= 1799:
  print(2)
else:
  print(1)

Measured memory_bytes: 61608
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[10];
	for (int i=0;i<10;i++){
		cin >> a[i];
	}
	sort(a, a+10);
	reverse(a, a+10);
	cout << a[0] << endl << a[1] << endl << a[2] << endl;
}


Measured memory_bytes: 3136
from collections import deque

def main():
    N, M = map(int, input().split())

    next_rooms = [ [] * (N+1) for i in range(N+1) ]
    for i in range(M):
        a, b = map(int, input().split())
        next_rooms[a].append(b)
        next_rooms[b].append(a)

    labeled = [False] * (N+1)
    # 部屋1は道しるべを付与済み
    labeled[1] = True

    labels = [-1] * (N+1)

    queue = deque([1])

    while len(queue) > 0:
        room = queue.popleft()
        nexts = next_rooms[room]
        for n in nexts:
            if labeled[n]:
                continue
            labels[n] = room
            labeled[n] = True
            queue.append(n)

    for i in range(1, N+1):
        if not labeled[i]:
            print("No")
            return

    print("Yes")
    for i in range(2, N+1):
        print(labels[i])


main()


Measured memory_bytes: 98984
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int N, M;
pair<pair<int, int>, int>e[100000];
ll tree[1 << 18];

void update(int l, int r, int p, int q, int k, ll x) {
	if (r < p || q < l)return;
	if (p <= l&&r <= q) {
		tree[k] = min(tree[k], x);
		return;
	}
	update(l, (l + r) / 2, p, q, k * 2, x);
	update((l + r) / 2 + 1, r, p, q, k * 2 + 1, x);
}

ll get(int x) {
	ll a = llmax;
	x += (1 << 17);
	while (x) {
		a = min(a, tree[x]);
		x /= 2;
	}
	return a;
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> e[i].first.first >> e[i].first.second >> e[i].second;
	}
	sort(e, e + M);
	for (int i = 0; i < (1 << 18); i++) {
		tree[i] = llmax;
	}
	update(0, (1 << 17) - 1, 1, 1, 1, 0);
	int p = 0;
	for (int i = 1; i <= N; i++) {
		ll t = get(i);
		if (t == llmax) {
			cout << -1 << endl;
			return 0;
		}
		for (; p < M&&e[p].first.first == i; p++) {
			update(0, (1 << 17) - 1, i, e[p].first.second, 1, t + e[p].second);
		}
	}
	cout << get(N) << endl;
}

Measured memory_bytes: 3456
x1, y1, x2, y2 = map(int, input().split())

vec = (x2 - x1, y2 - y1)

vec2 = (-vec[1], vec[0])
vec3 = (-vec2[1], vec2[0])

x3, y3 = (x2 + vec2[0], y2 + vec2[1])
x4, y4 = (x3 + vec3[0], y3 + vec3[1])

print(x3, y3, x4, y4)


Measured memory_bytes: 9180
import java.util.Scanner;
public class Main {


    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String str[];
        str = new String[5];
        int num[];
        num = new int[5];
        for(int i=0; i<=4; i++)
            {
            str[i] = in.next();
            num[i] = Integer.parseInt(str[i]);
            }
        if(num[4]<=num[2] && num[4]<=num[3] && num[2]<=num[0]-num[4] && num[3]<= num[1]-num[4])
            {
            System.out.println("Yes");
            }else{
            System.out.println("No");
            }
    }
}

Measured memory_bytes: 26296
/**
*   author:  akifpathan
*   created: Sunday 20.09.2020 06:04:15 PM
**/

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#ifdef LOCAL
#include "debug.h"
#else
#include<bits/stdc++.h>
using namespace std;
#define debug(x...)
#endif
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> 
using ordered_set= tree<T, null_type, 
		less<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
template<class T> 		
using ordered_mset= tree<T, null_type, 
		less_equal<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
		
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

struct DSU
{
	vector<int>par;
	vector<int>sz;
	
	DSU(int n)
	{
		par.resize(n+1);
		iota(par.begin(),par.end(),0);
		sz.assign(n+1,1);
	}
	
	int Find(int a)
	{
		return par[a]==a?a:par[a]=Find(par[a]);
	}
	
	bool same(int a,int b)
	{
		a=Find(a);
		b=Find(b);
		return a==b;
	}
	
	void Union(int a,int b)
	{
		a=Find(a);
		b=Find(b);
		
		if(sz[a]<sz[b]) swap(a,b);
		sz[a]+=sz[b];
		par[b]=a;
	}
};


void solve()
{
	int n;
	cin>>n;
	
	vector<pair<pii,int>>edge(n);
	for(int i=0;i<n;i++)
	{
		pii x;
		cin>>x.first>>x.second;
		edge[i].first=x;
		edge[i].second=i+1;
	}
	
	sort(edge.begin(),edge.end());
	map<int,int>parent;
	for(auto it: edge) parent[it.first.second]=it.second;
	
	//for(auto it: edge) cout<<it.first.first<<" "<<it.first.second<<" "<<it.second<<"\n";
	
	DSU dsu(n);
	
	set<int>st;
	
	for(int i=n-1;i>=0;i--)
	{
		st.insert(edge[i].first.second);
		auto it=st.upper_bound(edge[i].first.second);
		int u=-1;
		while(it!=st.end())
		{
			u=*it;
			int v=parent[u];
			if(!dsu.same(v,edge[i].second)) dsu.Union(v,edge[i].second);
			parent[u]=dsu.Find(v);
			st.erase(u);
			it=st.upper_bound(u);
		}
		st.insert(u);
		if(u!=-1) st.erase(edge[i].first.second);
		debug(st);
	}
	
	for(int i=1;i<=n;i++)
	{
		int x=dsu.Find(i);
		cout<<dsu.sz[x]<<"\n";
	}
	
}		

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int testcase=1;
	//cin>>testcase;
	
	for(int i=1;i<=testcase;i++)
	{
		//cout<<"Case "<<i<<": ";
		solve();
	}
	
	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}



Measured memory_bytes: 16676
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);// TODO Auto-generated method stub
		String s=input.next();
		String t=input.next();
		char[] s1=s.toCharArray();
		char[] t1=t.toCharArray();
		int suma=0;
		for(int i=0;i<s.length();i++) {
			if(s1[i]!=t1[i]) {
				suma++;
			}
		}
		System.out.println(suma);
			
	}

}


Measured memory_bytes: 33652
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    map<char,int> mp;
    char c;
    for(int i=0;i<n;i++){
        cin >> c;
        mp[c]++;
    }
    int ans=0;
    for(auto u:mp)ans++;
    if(ans==3)cout << "Three";
    else cout << "Four";
}

Measured memory_bytes: 3608
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

/* sample input

*/
ll gcd(ll a, ll b) {
	ll t;    // 補助変数
	while (b != 0) {          
		t = a%b; a = b; b = t;   	}
	return a;                   
}

int T;
ll a, b, c, d;
ll start;
void judge() {
	if (a < b) {
		cout << "No" << endl;
		return;
	}
	if (b > d) {
		cout << "No"<<endl;
		return;
	}
	if (c >= b) {
		cout << "Yes" << endl;
		return;
	}

	//if (a - (a / b)*b > c) {
	//	cout << "No"<<endl;
	//	return;
	//}
	

	//if (d%b == 0) {
	//	cout << "Yes" << endl;
	//	return;
	//}
	

	ll e = gcd(b, d);
	start = b - e + a%e;
	if (start > c) {
		cout << "No" << endl;
		return;
	}
	else {
		cout << "Yes" << endl;
		return;
	}

}

int main()
{
	cin >> T;

	for (int i = 0; i < T; i++) {
		cin >> a >> b >> c >> d;
		judge();
	}
	return 0;
}

Measured memory_bytes: 256
# AGC039B - Graph Partition (153ms)
from collections import deque


def is_bipartite() -> bool:
    stack, color = [(1, 1)], [0] * (N + 1)
    color[1] = 1
    while stack:
        v, cur_color = stack.pop()
        next_color = -cur_color
        for u in E[v]:
            if color[u] == cur_color:
                return False
            if not color[u]:
                color[u] = next_color
                stack.append((u, next_color))
    return True


def bfs(source: int) -> int:
    queue = deque([source])
    dist = [0] * (N + 1)  # dist[i] := distance from V_source to V_i
    dist[source] = 1
    while queue:
        v = queue.popleft()
        cur = dist[v]
        for u in E[v]:
            if not dist[u]:
                dist[u] = cur + 1
                queue.append(u)
    return max(dist)


def main():
    # if bipartite graph -> diameter of the graph + 1
    global N, E
    N, *S = open(0)
    N = int(N)
    E = [0] + [[i for i, flg in enumerate(s, 1) if flg == "1"] for s in S]
    if is_bipartite():
        ans = max(bfs(i) for i in range(1, N + 1))
        print(ans)
    else:
        print(-1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3692
from sys import stdin
n = int(stdin.readline())
c = stdin.readline()[:-1]

red = c.count("R")
ans = red
numwhite = 0
for i in range(n):
    numwhite += 1 if c[i] == "W" else 0
    numred = i - numwhite + 1
    resred = red - numred
    ans = min(ans,max(resred,numwhite))
print(ans)

Measured memory_bytes: 69268
#include <iostream>

using namespace std;

int main(void){
  int n, c = 0, sum = 0, i = 0;
  char s;
  cin >> n;
  for(i = 0; i < n; i++){
    cin >> s;
    if(s == 'A'){
      c = 1;
    }else if(s == 'B' && c == 1){
      c = 2;
    }else if(s == 'C' && c == 2){
      c = 0;
      sum++;
    }else{
      c = 0;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcount((unsigned int)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll N; cin >> N;
    vpl X(2*N);
    rep(i, 2*N){
        ll x; cin >> x;
        if(i < N) X[i] = {x, 1};
        else X[i] = {x, -1};
    }
    sort(X.begin(), X.end());
    
    const ll mod = 1e9+7;
    
    ll ans = 1, sum = 0, idx = 0;
    while(idx < 2*N){
        if(sum == 0){
            sum = X[idx].ss;
        }
        else{
            if(X[idx].ss * sum > 0){
                sum += X[idx].ss;
            }
            else{
                ans = ans * abs(sum) % mod;
                sum += X[idx].ss;
            }
        }
        idx++;
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main() {
	
	int a, b;
	cin >> a >> b;

	int matrix[100][100] = { 0 };

	for (int i = 0; i < a; i++)
	{
		for (int j = 0; j < b; j++)
		{
			cin >> matrix[i][j];
		}
	}
	
	int vector[100] = { 0 };

	for (int i = 0; i < b; i++)
	{
		cin >> vector[i];
	}

	int resv[100] = { 0 };
	for (int i = 0; i < a; i++)
	{
		int sum = 0;
		for (int j = 0; j < b; j++)
		{
			sum += matrix[i][j] * vector[j];
		}
		resv[i] = sum;
	}

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

	return 0;
}





Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int a,b,c;
    string s;
    cin>>c>>a>>b;
    if(a%c!=0&&b%c!=0&&a/c==b/c){
        cout<<"NG"<<endl;
        return 0;
    }
    cout<<"OK"<<endl;
    return 0;
}




Measured memory_bytes: 3628
/******************************************
* AUTHOR : HRITIK AGGARWAL *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
ll po(ll a, ll x,ll m){ if(x==0){return 1;}ll ans=1;ll k=1;  while(k<=x) {if(x&k){ans=((ans*a)%m);} k<<=1; a*=a; a%=m; }return ans; }
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)    
        cin>>a[i];
    int cnt=0;
    for(int i=1;i<n-1;i++){
        if((a[i]>a[i-1] && a[i]<a[i+1]) ||(a[i]<a[i-1] && a[i]>a[i+1]))
            cnt++;
    }
    cout<<cnt<<"\n";
return 0;
}

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

using namespace std;

vector<int> G[100010];
vector<int> ans;
bool used[100010];

void dfs(int u, vector<int> &a) {
  a.push_back(u);
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (used[v]) continue;
    used[v] = true;
    dfs(v, a);
    return;
  }
}

int main(void) {
  int n, m;
  cin >> n >> m;

  int a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  used[a] = used[b] = true;

  dfs(a, ans);
  reverse(ans.begin(), ans.end());
  dfs(b, ans);

  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 9336
import math
S = input()

P = []
stack = 0

for i in range(1, len(S)):
    stack += 1
    if S[i] != S[i-1]:
        P.append((i-1, stack))
        stack = 0
P.append((i-1, stack+1))

bef = 0
ans = []

for i in range(0, len(P), 2):
    l = math.ceil(P[i][1] / 2) + P[i+1][1] // 2
    r = P[i][1] + P[i+1][1] - l

    index = P[i][0]
    for j in range(bef, index):
        ans.append(0)
    ans.append(l)
    ans.append(r)

    bef = index + 2

for j in range(len(S) - bef):
    ans.append(0)

print(' '.join(list(map(str, ans))).strip())


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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    int ans;
    rep(i, N){
        cin >> A[i];
        if(i == 0){
            ans = A[i];
        } else {
            ans = __gcd(ans, A[i]);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3764
#!/usr/bin/env python3
import sys
from collections import deque
def input(): return sys.stdin.readline().rstrip()


def main():
    N, D, A = map(int, input().split())
    mlist = []
    for _ in range(N):
        x, h = map(int, input().split())
        mlist.append([x, (h+A-1)//A])
    mlist.sort(key=lambda x: x[0])
    db = deque()
    dnotb = deque()
    left = mlist[0][0]
    ans = 0
    for monster in mlist:
        if monster[0] <= left+2*D:
            db.append(monster)
        else:
            dnotb.append(monster)
    ans = 0
    while db or dnotb:
        if not db:
            monster = dnotb.popleft()
            monster[1] += ans
            db.append(monster)
        bmonster = db.popleft()
        while dnotb:
            if dnotb[0][0] <= bmonster[0]+2*D:
                monster = dnotb.popleft()
                monster[1] += ans
                db.append(monster)
            else:
                break
        ans = max(ans, bmonster[1])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 50544
#include<bits/stdc++.h>
#define llt long long  int
#define ullt unsigned long long int
using namespace std;
void fast(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    }
int main()
{
    fast();
    llt a,b,p,q,s=0;
    cin>>a>>b;
    p=a;
    q=b;
    llt arr1[b],arr2[a];
    for(int i=0;i<b;i++)
    arr1[i]=a;
    for(int i=0;i<a;i++)
    arr2[i]=b;
    if(a<b)
    for(int i=0;i<a;i++){
    if(!(arr1[i]<arr2[i]))
    {
        s=1;
        break;
    }}
    else
    for(int i=0;i<b;i++)
    if(!(arr1[i]<arr2[i]))
    {
        s=1;
        break;
    }
    if(a==b)
    for(int i=0;i<b;i++)
    cout<<arr1[i];
    else if(s==0)
    for(int i=0;i<b;i++)
    cout<<arr1[i];
    else
        for(int i=0;i<a;i++)
        cout<<arr2[i];
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a=0, b = 0,c,d, n, k;
string s, t;


int main()
{
	int x, a;
	cin >> x >> a;
	if (x < a)
		cout << 0 << endl;
	else
		cout << 10 << endl;
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
  const arr = input.split('\n');
  var numbers = arr[1].split(' ').map(x=>Number(x));
  var count = 0;

  while (numbers.every(x=>x%2===0)) {
    numbers = numbers.map(x=>x/2);
    count += 1;
  }

  console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

int main() {
    string s;
    cin >> s;
    int countMax=0;
    int countCur=0;
    // vector<int> notATGC(s.length()+2, -1);
    for (int i=0; i<s.length(); i++) {
        if (s[i]!='A' && s[i]!='T' && s[i]!='G' && s[i]!='C') {
            if (countCur > countMax) {
                countMax = countCur;
            }
            countCur=0;
            // notATGC.push_back(i);
        }else{
            countCur++;
        }
    }
    if (countCur > countMax) {
        countMax = countCur;
    }
    cout << countMax << endl;
    // if (notATGC[0]==-1) {
    //     cout << s.length() << endl;
    // }else{

    // }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
int main() {
	string s;
	cin >> s;
	int n;
	n = s.size();
	//cout << n << endl;
	int n1=((n-1)/2);
	int n2 = ((n + 3) / 2)-1;
	
	string a = s.substr(0, n1);
	string b = s.substr(n2, n1);
	string aa, bb,ss;
	//string aa = 
	reverse_copy(a.begin(), a.end(), back_inserter(aa));
	reverse_copy(b.begin(), b.end(), back_inserter(bb));
	reverse_copy(s.begin(), s.end(), back_inserter(ss));
	if (a == aa) {
		if (b == bb) {
			if (s == ss) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
		cout << "No" << endl;
	
}

Measured memory_bytes: 256
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val a, b = sc.nextInt
//  val list = List.fill(3)(sc.nextInt)

  val ans = if ((a + b) % 2 == 0) ((a + b) / 2).toString else "IMPOSSIBLE"

  println(ans)

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

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 25420
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
 
using namespace std;
int MOD = 1000000007;

signed main(){
    string s;
    cin >> s;

    int ans = 0;

    for(int i = 0;i < (1<<(s.size()-1));i++){
        int x = 1;
        for(int j = s.size()-1;j >= 0;j--){
            ans += (s[j]-'0')*x;
            //cerr << (s[j]-'0')*x << endl;
            if(j != 0){
                if(i&(1<<(s.size()-1-j)))x *= 10;
                else x = 1;
            }
        }
    }
    cout << ans << endl;
    
    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://arc061.contest.atcoder.jp/tasks/arc061_a
// rm -r -f test;oj dl http://yahoo-procon2017-qual.contest.atcoder.jp/tasks/yahoo_procon2017_qual_c

Measured memory_bytes: 256
# from pprint import pprint
# import math
# import collections
import numpy as np

n = int(input())
# n, k = map(int, input().split(' '))
a = list(map(int, input().split(' ')))

minus_signs = sum([1 for _ in a if np.sign(_) == -1])

if minus_signs % 2 == 0:
    res = sum([abs(_) for _ in a])
else:
    _min = min([abs(_) for _ in a])
    res = sum([abs(_) for _ in a])

    res = res - _min - _min

print(res)


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


int main(){
    string s, t;
    cin >> s >> t;
    int ss = s.size(), ts = t.size();
    vector<vector<int>> dp(ss+1, vector<int>(ts+1, 0));
    rep(i,ss){
        rep(j,ts){
            if(s[i] == t[j]) dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1);
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j]);
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1]);
        }
    }
    string res = "";
    while (ss > 0 && ts > 0)
    {
        if(dp[ss][ts] == dp[ss-1][ts]) --ss;
        else if (dp[ss][ts] == dp[ss][ts-1]) --ts;
        else{
            res = s[ss-1] + res;
            --ss, --ts;
        }
    }
    cout << res << endl;
}
	


Measured memory_bytes: 35584
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

int main() {
	int a, b, ans;
	cin >> a >> b;
	if (a + b == 0) { ans = 0; }
	else if (a + b > 0) { ans = 1; }
	else { ans = -1; }
	cout << ans << endl;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
int main()
{
 	int i,a,b,c;
 	cin>>a;
 	for(i=1;i<=a;i++)
 	{
 		//cout<<i<<endl;
 		if(i%2==0) b++;
		else c++;
	}
	//cout<<b<<" "<<c<<" "<<i;
	cout<<b*c;
	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 repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
  

  int main(){
        lint n,k;
        cin>>n>>k;
        lint rangemin=0;
        lint rangemax=0;
        lint ans=0;
        rep(i,k)rangemin+=i;
        rep(i,k)rangemax+=(n-i);
        repp(i,k,n+2){
         //   cout<<rangemin<<" "<<rangemax<<" "<<ans<<endl;
           lint g=rangemax-rangemin+1;
           ans+=g;
           rangemax+=(n-i);
           rangemin+=i;
           ans+=MOD;
           ans%=MOD;
        }
    cout<<ans<<endl;
  }
  
     


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

int main() {
 int a,b,c,d;
  cin>>a>>b>>c>>d;
  
  if(a>b){
    cout<<b*c+(a-b)*d<<endl;
  }
  else{
    cout<<a*c<<endl;
  }
  
}

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

#define REP(i, n) for(int i = 0;i < n;i++)

using namespace std;

const int INF = 100000000;

int main(){
  int d;
  cin >> d;
  string ans;
  switch (d) {
    case 25:
             ans = "Christmas";
               break;
    case 24:
             ans = "Christmas Eve";
               break;
    case 23:
             ans = "Christmas Eve Eve";
               break;
    case 22:
             ans = "Christmas Eve Eve Eve";
               break;
  }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	long long n,a[100001],i,cnt,p,sum;
	cin>>n;
	for(i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	cnt=0; p=a[0]; sum=0;
	a[n]=pow(10,9)+7;
//	for(i=0;i<=n;i++) cout<<a[i]<<endl;
	for(i=0;i<=n;i++){
//		cout<<i<<' '<<a[i]<<' '<<p<<endl;
		if(a[i]==p) cnt++;
		else {
			if(cnt!=p){
				if(cnt>p) sum+=cnt-p;
				else sum+=cnt;
			}
			cnt=1;
			p=a[i];
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1024
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n = read::<usize>();
    let mut ls = read_vec::<usize>();

    ls.sort();
    ls.reverse();

    let mut count = 0;

    for i in 0..n {
        let mut l = i+1;
        let mut r = n-1;

        while l < r {
            if ls[i] < ls[l] + ls[r] {
                count += r - l;
                l += 1;
            } else {
                r -= 1;
            }
        }
    }
    
    println!("{}", count);
}



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

int main() {
  int N;
  cin >> N;
  bool b = false;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N; j++) {
      if ((i * 4 + j * 7) == N) {
        b = true;
        break;
      }
    }
  }
  if (b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256