akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
 int main(void)
 {
     int a,b,c;
   
     scanf("%d%d%d",&a,&b,&c);
   
     if(a+b==c) printf("Yes\n");
     else if(b+c==a) printf("Yes\n");
     else if(c+a==b) printf("Yes\n");
     else printf("No\n");
   
     return 0;
 }

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>a>>b;
      if(a>0)Cout("Positive");
      else{
        if(a<=0&&b>=0)Cout("Zero");
        else{
          a*=-1;b*=-1;
          ans=a-b;
          if(ans%2==0)Cout("Negative");
          else Cout("Positive");
        }
      }
     

       
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        String strInput = input.nextLine();
        String[] str = new String[2];
        str = strInput.split(" ");
        System.out.println(Integer.parseInt(str[0])*Integer.parseInt(str[1])+ " " + (Integer.parseInt(str[0])*2+Integer.parseInt(str[1])*2));
    }
}


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

int main() {
  int K, S;
  cin >> K >> S;
  int sum = 0;
  for(int i = 0; i <= K; i++) {
    for(int j = 0; j <= K; j++) {
      if(S - i - j >= 0 && S - i - j <= K) sum++;
    }
  }

  cout << sum;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;cin>>N;
    vector<int> cnt(26);
    string S;cin>>S;
    for(int i=0;i<S.size();i++){
        cnt[S[i]-'a']++;
    }
    for(int i=0;i<N-1;i++){
        vector<int> ncnt(26);
        cin>>S;
        for(int j=0;j<S.size();j++){
            ncnt[S[j]-'a']++;
        }
        for(int j=0;j<26;j++){
            cnt[j]=min(cnt[j],ncnt[j]);
        }
    }
    for(int i=0;i<26;i++){
        while(cnt[i]--)cout<<(char)('a'+i);
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
a=input()
if a[-1]=='2'or a[-1]=='4' or a[-1]=='5'or a[-1]=='7'or a[-1]=='9':
    print('hon')
elif a[-1]=='0'or a[-1]=='1'or a[-1]=='6'or a[-1]=='8':
    print('pon')
else:
    print("bon")

Measured memory_bytes: 9120
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int N, K;
int H[100005];

int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int N;
  cin >> N >> K;
  rep(i, N) cin >> H[i];

  vector<int> DP(100005, 1000000007);
  DP[0] = 0;
  rep(i, N) {
    if (i==0) {
      rep(j, K) DP[j+1] =abs(H[j+1] - H[0]); 
      continue;
    }

    rep(j, K) {
      int next = j+i+1;
      DP[next] = min(DP[next], abs(H[next]-H[i])+DP[i]);
    }
  }
  cout << DP[N-1] << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <string.h>


char S_in[1001];
char T_in[1001];

int main(int argc, char* argv[]){
    int i,j,k;
    int S_l,T_l;
    int max_s=0;
    int temp=0;
    int temp_max=0;
    int *T_same;
    scanf("%s",S_in);
    scanf("%s",T_in);
    S_l = strlen(S_in);
    T_l = strlen(T_in);
    //T_same = (long int *) malloc( sizeof(long int) *(S_in+1)  );
    for(i=0;i<S_l;i++){
        for(j=0;j<T_l;j++){
            if(S_in[i]==T_in[j] && i>=j && i+T_l-j-1<S_l){
                for(k=0;k<T_l;k++){
                    if(S_in[i-j+k]==T_in[k]){
                        temp++;
                    }
                }
                if(temp>temp_max){
                    temp_max = temp;
                }
                temp=0;
            }
        }

    }
    printf("%d",T_l-temp_max);    

    return 0;
}

Measured memory_bytes: 1736
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, m, l;
  cin >> n >> m >> l;
  int a[n][m], b[m][l];
  ll c[n][l] = {};
  rep(i, n) rep(j, m) cin >> a[i][j];
  rep(i, m) rep(j, l) cin >> b[i][j];

  rep(i, n) {
    rep(j, l) {
      rep(k, m) {
        c[i][j] += a[i][k] * b[k][j];
      }
    }
  }

  rep(i, n) {
    rep(j, l) {
      cout << c[i][j];
      if (j != l - 1)
        cout << " ";
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3248
def partition(a, p, r)
	x = a[r][1]
	i = p-1
	p.upto(r-1) do |j|
		if a[j][1] <= x
			i += 1
			a[i], a[j] = a[j], a[i]
		end
	end
	a[i+1], a[r] = a[r], a[i+1]
	return i+1
end

def quickSort(a, p, r)
	if p < r
		q = partition(a, p, r)
		quickSort(a, p, q-1)
		quickSort(a, q+1, r)
	end
end

INFTY = 9999999999

def merge(a, left, mid, right)
	n1 = mid - left
	n2 = right - mid
	l = []
	r = []
	0.upto(n1-1) do |i|
		l[i] = a[left + i]
	end
	0.upto(n2-1) do |i|
		r[i] = a[mid + i]
	end
	l[n1] = []
	r[n2] = []
	l[n1][1] = INFTY
	r[n2][1] = INFTY
	i = 0
	j = 0
	left.upto(right-1) do |k|
		if l[i][1] <= r[j][1]
			a[k] = l[i]
			i += 1
		else
			a[k] = r[j]
			j += 1
		end
	end
end

def mergeSort(a, left, right)
	if left+1 < right
		mid = (left + right)/2
		mergeSort(a, left, mid)
		mergeSort(a, mid, right)
		merge(a, left, mid, right)
	end
end

n = gets.to_i
arr = []
n.times do
	suit, value = gets.split
	value = value.to_i
	arr.push([suit, value])
end

#quickSort
arr2 = Marshal.load(Marshal.dump(arr))
quickSort(arr2, 0, n - 1)

#mergeSort
arr3 = Marshal.load(Marshal.dump(arr))
mergeSort(arr3, 0, n)

if arr2 == arr3
	puts "Stable"
else
	puts "Not stable"
end

puts arr2.map{|x|x[0]+" "+x[1].to_s}.join("\n")

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

int main() {
  int N, ans = 0;
  cin >> N;
  vector<int> value(N);
  vector<int> cost(N);
  for (int i = 0; i < N; i++) {
    cin >> value.at(i);
  }
  for (int i = 0; i < N; i++) {
    cin >> cost.at(i);
  }
  vector<int> difference(N);
  for (int i = 0; i < N; i++) {
    difference.at(i) = value.at(i) - cost.at(i);
    if (difference.at(i) > 0) {
      ans = ans + difference.at(i);
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#include <iomanip>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 1e5 + 5;
const int Mod = 1e9 + 7;
#define PP pair<int, P>

int main(){
    int h, w, x, y;
    cin >> h >> w >> x >> y;
    cout << fixed << setprecision(6) <<1.0 * h * w / 2 << " ";
    if(x == h/2 && y == w/2 && h % 2 == 0 && w % 2 == 0)
        cout << "1" << endl;
    else cout << "0"  << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define db(a) cout << a << endl
#define db2(a,b) cout << a << " " << b << endl
#define dbp(a) cout << a.first << " " << a.second << endl
#define adb(a) for(auto i:a) cout << i << " "; cout << endl
#define adb2(a) for(auto i:a) cout << i.first << " " << i.second << endl;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define N 100010
using namespace std;

int main()
{
    /*#ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif*/

    fastIO;
    string s;
    cin >> s;

    deque<char> dq;
    for(auto i:s) dq.push_back(i);

    int q;  
    cin >> q;

    bool rev = false;
    while(q--)
    {
        int t;
        cin >> t;
 
        if(t == 1) rev ^= 1;
        else
        {
            int f;
            char c;

            cin >> f >> c;
            if(rev) f = f%2 + 1;

            if(f == 1) dq.push_front(c);
            else dq.push_back(c);
        }
    }

    string ans = "";
    for(auto i:dq) ans.push_back(i);

    if(rev) reverse(ans.begin(), ans.end());
    cout << ans << endl; 
}

Measured memory_bytes: 1368
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdlib.h>
#include<math.h>
#include<cmath>
#include<cstdlib>
#include<stack>
#include<map>
#include<queue>
#include<iterator>
#include<set>
#include<vector>
using namespace std;
#define  M 100050

int main()
{
	int n;
	while(scanf("%d", &n) == 1, n)
	{
		int a[3], b[3];
		memset(a, 0, sizeof(a));
		memset(b, 0, sizeof(b));
		for(int i = 0; i < n; i++)
		{
			int h, m, mm;
			int tt;
			scanf("%d:%d %d", &h, &m, &mm);
			if(h >= 11 && h <= 14)
			{
				a[0]++;
				if(m <= mm)
					tt = mm - m;
				else
					tt = (60 - m) + mm ;
				if(tt <= 8)
					b[0]++;
			}
			else
				if(h >= 18 && h <= 20)
				{
					a[1]++;
					if(m <= mm)
						tt = mm - m;
					else
						tt = (60 - m) + mm ;
					if(tt <= 8)
						b[1]++;
				}
				else
					if(h >= 21 || h <= 1)
					{
						a[2]++;
						if(m <= mm)
							tt = mm - m;
						else
							tt = (60 - m) + mm ;
						if(tt <= 8)
							b[2]++;
					}
		}
		printf("lunch ");
		if(a[0] == 0)
			printf("no guest\n");
		else 
			printf("%d\n",int(((b[0] * 1.0) / a[0]) * 100));
		printf("dinner ");
		if(a[1] == 0)
			printf("no guest\n");
		else 
			printf("%d\n",int(((b[1] * 1.0) / a[1]) * 100));
		printf("midnight ");
		if(a[2] == 0)
			printf("no guest\n");
		else 
			printf("%d\n",int(((b[2] * 1.0) / a[2]) * 100));
	}
}

Measured memory_bytes: 1196
n,k=(int(i) for i in input().split())
r=[0 for i in range(n)]
l=[int(i) for i in input().split()]
wazap=[]
count=1
saver=None
temp=0
while r[temp]==0:
  r[temp]=count
  wazap.append(temp)
  temp=l[temp]-1
start=l[wazap[-1]]
left=None
for i in range(len(wazap)):
  if wazap[i]==start-1:
    left=i
    break
loop=len(wazap)-left
if k<left:
  print(wazap[k]+1)
else:
  print(wazap[(k-left)%loop+left]+1)

Measured memory_bytes: 33896
import java.util.HashMap;
import java.util.Scanner;

class Main {

	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		String order="";
		String str="";
		HashMap<String,String> dic=new HashMap<String,String>();
		for (int i = 0; i < n; i++) {
			order=in.next();
			str=in.next();
			if(order.equals("insert")) {
				dic.put(str,"0");
			}else if(order.equals("find")) {
				if(dic.containsKey(str)) {
					System.out.println("yes");
				}else {
					System.out.println("no");
				}
			}

		}

		in.close();
	}

}



Measured memory_bytes: 209536
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
lint ans;

signed main(){
  string s; cin >> s;
  lint K; cin >> K;
  lint counter = 0;
  lint start = 0;
  for(lint start = 0; start < s.size(); start++){
    if(s[start] == 'a') continue;
    lint need = 'z' - s[start] + 1;
    if(K - counter >= need){
      s[start] = 'a';
      counter += need;
    }
  }
  s[s.size() - 1] += (K - counter) % 26;
  cout << s << endl;
}


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

int main() {
  int X;
  cin >> X;
  int K = 1;
  int th = X;
  while(th%360!=0){
    th += X;
    K++;
  }
  cout << K<< endl;
  return 0;
}

Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long num = sc.nextLong();
		List<Long> list = method(num);
		list.add(num);
		int size = list.size();
		if (size % 2 == 0) {
			int pos = size / 2;
			long a = list.get(pos);
			long b = list.get(pos - 1);
			System.out.println(a + b - 2);
		} else {
			int pos = size / 2;
			long a = list.get(pos);
			System.out.println(a + a - 2);
		}

	}

	public static List<Long> method(Long num) {
		List<Long> list = new ArrayList<>();
		Long sNum = Double.valueOf(Math.sqrt(num.doubleValue())).longValue();
		if (sNum % 2L != 0L) {
			sNum++;
		}
		for (Long i = 1L; i <= sNum; i++) {
			if (num % i == 0L) {
				list.add(i);
			}
		}
		Long temp = list.get(list.size() - 1);

		int size = list.size();
		if (num / temp == temp) {
			size = size - 1;
		}
		for (int i = size - 1; i > 0; i--) {
			Long n = list.get(i);
			list.add(num / n);
		}
		return list;
	}
}


Measured memory_bytes: 40788
#include <cmath>
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
 
using namespace std;
 
int main (int argc, char* argv[]) {
	string s;
	cin >> s;

	vector<long long> dp(s.size());

	for (int i = 0; i < s.size(); i++) {
		long long total = 0;
		long long current = 0;
		long long power = 1;
		for (int j = i; j >= 0; j--) {
			current = current + (s[j] - '0') * power;
			power *= 10;
			long long prev_res = (j == 0 ? 0 : dp[j - 1]);
			total += prev_res + (current * pow(2, j == 0 ? 0 : j - 1));
		}
		dp[i] = total;
	}

	cout << dp.back() << endl;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n;
  cin >> n;
  vll a(n);
  REP(i, n)
    cin >> a[i];

  sort(a.begin(), a.end());
  ll ans = 0;
  ll now = 0;
  REP(i, n){
    if(now*2<a[i])
      ans = 1;
    else
      ans++;
    now += a[i];
  }

  cout << ans << endl;


}



Measured memory_bytes: 1024
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
#include<bits/stdc++.h>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;
int main(){
  int p,q,r;
  cin >> p >> q >> r;
  int ans=min(p+q,min(q+r,r+p));
  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(ii, jj, ll, ss) for(int ii = jj; ii < ll; ii += ss)

int n, m;
set <int> s;
int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m;
	int lo = 0, hi = 100000;
	rep(i, 0, m, 1) {
		int l, r;
		cin >> l >> r;
		lo = max(l, lo);
		hi = min(r, hi);
	}
	int ans = hi - lo + 1;
	cout << max(0ll, ans);
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())
#define mp make_pair

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<pair<int,int>, pair<int, int> > PP;
const int MAX=2e5+10;
const int INF=1e9;

template <typename T>
struct SegmentTree{
  using F = function<T(T,T)>;
  int n;
  F f;
  T ti;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(F f,T ti):f(f),ti(ti){}
  void init(int n_){    
    n=1;
    while(n<n_) n<<=1;
    dat.assign(n<<1,ti);
  }
  void build(const vector<T> &v){
    int n_=v.size();
    init(n_);
    for(int i=0;i<n_;i++) dat[n+i]=v[i];
    for(int i=n-1;i;i--)
      dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
  }
  void set_val(int k,T x){
    dat[k+=n]=x;
    while(k>>=1)
      dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);    
  }
  T query(int a,int b){
    T vl=ti,vr=ti;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[l++]);
      if(r&1) vr=f(dat[--r],vr);
    }
    return f(vl,vr);
  }
  template<typename C>
  int find(int a,int b,C &check,int k,int l,int r){
    if(!check(dat[k])||r<=a||b<=l) return -1;
    if(k>=n) return k-n;
    int m=(l+r)>>1;
    int vl=find(a,b,check,(k<<1)|0,l,m);
    if(~vl) return vl;
    return find(a,b,check,(k<<1)|1,m,r);
  }
  template<typename C>
  int find(int a,int b,C &check){
    return find(a,b,check,1,0,n);
  }
};

int main(){
	int N;
	cin>>N;
	int p[MAX];
	rep(i,N)cin>>p[i];
	
	auto f=[](P a,P b){
		if(a.first < b.first) return mp(a.first, a.second);
		else return mp(b.first, b.second);
	};
	P ti=mp(INF, INF);
	SegmentTree<P> even(f,ti), odd(f,ti);
	vector<P> ve(N), vo(N);
	rep(i,N){
		if(i%2==0){
			ve[i]=mp(p[i],i);
			vo[i]=ti;
		}
		else{
			ve[i]=ti;
			vo[i]=mp(p[i],i);
		}
	}
	even.build(ve);
	odd.build(vo);
  	vi ans;
	priority_queue<PP, vector<PP>, greater<PP> > q;

	q.push(mp(even.query(0,N), mp(0,N)));
	while(!q.empty()){
		PP pp=q.top();
		P p1=pp.first, p2=pp.second;
		int mn=p1.first, nl=p1.second;
		int l=p2.first, r=p2.second;
		q.pop();
		
		ans.push_back(mn);
      	int nr;
		if(l%2==0){
			P od=odd.query(nl+1,r);
			ans.push_back(od.first);
			nr=od.second;
        }
		else{
			P ev=even.query(nl+1,r);
			ans.push_back(ev.first);
			nr=ev.second;
		}
		if(l<nl){
			if(l%2==0) q.push(mp(even.query(l,nl),mp(l,nl)));
			else q.push(mp(odd.query(l,nl),mp(l,nl)));
		}
		if(nl+1<nr){
			if((nl+1)%2==0) q.push(mp(even.query(nl+1,nr),mp(nl+1,nr)));
			else q.push(mp(odd.query(nl+1,nr),mp(nl+1,nr)));
		}
		if(nr+1<r){
			if((nr+1)%2==0) q.push(mp(even.query(nr+1,r),mp(nr+1,r)));
			else q.push(mp(odd.query(nr+1,r),mp(nr+1,r)));
		}
	}
	rep(i,sz(ans))cout<<ans[i]<<" ";
}

Measured memory_bytes: 15220
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>

int main(){
    int n;
    cin >> n;
    vector<long long> p(n),a(n+1),b(n+1);
    for (int i=0;i<n;i++) cin >> p.at(i);
    a.at(0)=0;b.at(0)=(n+1)*20000;
    for (int i=1;i<n+1;i++){
        a.at(i)=a.at(i-1)+20000;
        b.at(i)=b.at(i-1)-20000;
    }
    for (int i=0;i<n;i++){
        a.at(p.at(i))+=i;
    }
    for (int i=1;i<n;i++){
        cout << a.at(i) << " ";
    }
    cout << a.at(n) << endl;
    for (int i=1;i<n;i++){
        cout << b.at(i) << " ";
    }
    cout << b.at(n) << endl;
}

Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#include<string>
#include<cstdlib>
#include<cstring>
using namespace std;

int main(){
  int n,counter;
  string s,hs;
  char Sin[1000000],sets;

  while(true){
    cin >> n;
    if(n == 0)break;
    cin >> s;
    hs.clear();
    while(n-->0){
      sets = s[0];
      counter = 0;
      for(int i=0;i<s.length();i++){

	if(sets == s[i])counter++;
	if(sets != s[i+1] || i == s.length()-1){
	  sprintf(Sin,"%d",counter);
	  hs+=Sin;
	  hs+=sets;
	  sets=s[i+1]; 
	  counter=0;
	}
      }
      s.clear();
      s=hs;
      hs.clear();
    }
    cout << s << endl;
  }
    
  return 0;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  std::string s;
  std::cin >> s;
  int b = std::atoi(s.substr(0, 2).c_str());
  int e = std::atoi(s.substr(2, 2).c_str());

  if (1 <= b && b <= 12 && (e == 0 || 13 <= e)) {
    std::cout << "MMYY" << std::endl;
  } else if (1 <= e && e <= 12 && (b == 0 || 13 <= b)) {
    std::cout << "YYMM" << std::endl;
  } else if (1 <= e && e <= 12 && 1 <= b && b <= 12) {
    std::cout << "AMBIGUOUS" << std::endl;
  } else {
    std::cout << "NA" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(), (x).rend()
#define pll pair<long long, long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
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;}
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp


ll popcount(ll n){
    ll count=0;
    while(n!=0){
        if(n%2==1) count++;
        n/=2;
    }
    return count;
}

ll takemod(string x,ll mod){
    ll div=1;
    ll ans=0;
    rep(i,x.size()){
        if(x[x.size()-1-i]=='1') ans+=div%mod;
        div*=2;
        div%=mod;
        ans%=mod;
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    string x;
    cin>>x;
    ll count=0;
    vll takedmod(3);
    vll twopow1(n+3,0);
    vll twopow2(n+3,0);
    ll di=1;
    rep(i,n){
        if(x[i]=='1'){
            count++;
        }
    }
    rep(i,n+1){
        ll mod=count-1;
        if(mod==0) break;
        twopow1[i]=di;
        di*=2;
        di%=mod;
    }
    di=1;
    rep(i,n+1){
        ll mod=count+1;
        twopow2[i]=di;
        di*=2;
        di%=mod;
    }
    rep(i,3){
        if(i==1) continue;
        if(count-1+i>0)takedmod[i]=takemod(x,count-1+i);
    }
    rep(i,n){
        ll ans=0;
        ll nn=0;
        ll co=count;
        if(x[i]=='1'){
            co--;
            if(co==0){
                cout<<0<<endl;
                continue;
            }
            nn=takedmod[0];
            nn-=twopow1[n-i-1];
            nn%=co;
            if(nn<0) nn+=co;
        }else{
            co++;
            nn=takedmod[2];
            nn+=twopow2[n-i-1];
            nn%=co;
        }
        co=popcount(nn);
        ans++;
        while(nn!=0){
            nn%=co;
            co=popcount(nn);
            ans++;
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 6792
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
using namespace std;
#define vel vector<long long>
#define vvel vector<vel>
#define int  long long
#define rep(i,n) for(long long i=0;i<n;i++)
#define rp(i,n) for(long long i=1;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 1000000007;
vel rui(19, 1);
vel par;
int ru(int a,int  r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; ans %= p; }
	return ans;
}
int inv(int a) {
	return ru(a, p - 2);
}
int dig(int n) {
	for (int i = 0; i < 18; i++) {
		if (rui[i] <= n and n < rui[i + 1]) { return i+1; }
	}
}
int ret1(int diff, int dg) {
	if (diff == 0) { return 0; }
	else if (diff == 1) { return 1; }
	int hl = diff / 2;
	int ans1 = ret1(hl,dg);
	ans1 *= (ru(ru(10, dg),hl) + 1); ans1 %= p;
	if (diff % 2 == 1) {
		ans1 += ru(ru(10, dg),(diff - 1));
	}
	return ans1 % p;
}
int ret2(int diff, int dg) {
	if (diff <= 0) { return 0; }
	else if (diff == 1) { return 1; }
	int hl = diff / 2;
	int ans2 = ret2(hl, dg);
	ans2 *= (ru(ru(10, dg),hl) + 1); ans2 %= p;
	ans2 += ret1(hl, dg)*hl; ans2 %= p;
	if (diff % 2 == 1) {
		ans2 += ret1(diff, dg);
	}
	return ans2 % p;
}
signed main() {
int a,b,c;cin >> a>>b>>c;
vel v={a,b,c};
sor(v);
if(v[0]==5 and v[1]==5 and v[2]==7){cout << "YES"<<endl;}
else{cout <<"NO"<<endl;}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N,K,result;
  cin >> N >> K ;
  result =1;
  rep(i,N){
    if(result*2<result+K){
      result*=2;
    }
    else{
    result+=K;
    }
  }
  cout << result << endl;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

template<typename FI,typename Compare>
pair<FI,FI> search_continuous(FI first,FI last,Compare comp){
	FI top = find_if(first,last,comp);
	if(top==last){
		return make_pair(last,last);
	}
	FI end = find_if_not(top,last,comp);
	return make_pair(top,end);
}

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

	string S=in<string>();
	int maxL = 0;
	auto start_s = S.begin();
	while(true){
		auto res = search_continuous(start_s,S.end(),[](char c){return (c=='A' || c=='G' || c=='C' || c=='T');});
		if(res.first==S.end()) break;
		int dist = distance(res.first,res.second);
		maxL = max(maxL,dist);
		start_s = res.second;
	}
	cout << maxL << endl;
	return 0;
}


Measured memory_bytes: 256
// atcoder/sumitrust2019/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int x;
  while (cin >> x) {
    const int N = 100000 + 5;
    bool dp[N];
    fill(dp, dp + N, false);
    dp[0] = true;

    vector<int> v;
    for (int i = 100; i <= 105; ++i) {
      v.push_back(i);
    }
    for (int i = 0; i < N; ++i) {
      each (j, v) {
        if (i + j < N) {
          dp[i + j] |= dp[i];
        }
      }
    }

    cout << (int)(dp[x]) << endl;
  }

  return 0;
}


Measured memory_bytes: 384
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# # input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

s = input()
count = len(s) // 2
ans = 0
for i in range(count):
    if(s[i] != s[len(s) - i - 1]):
        ans += 1
print(ans)


Measured memory_bytes: 75000
using System;
using System.Linq;

namespace AtCoder20200404
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] inputs = Console.ReadLine().Split(' ');
            long N = long.Parse(inputs[0]);
            long K = long.Parse(inputs[1]);
            long x = N % K;
            long y = Math.Abs(K - x);
            if(x >= y)
            {
                Console.WriteLine(y);
            }
            else 
            {
                Console.WriteLine(x);
            }
        }
    }
}


Measured memory_bytes: 13140
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,ans,x;
void read(int &x)
{
    int f=1;x=0;char s=getchar();
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    x*=f;
}
int PD(int x)
{
	int cnt=0;
	while(x%2==0&&x>0)
	{
		cnt++;
		x/=2;
	}
	return cnt;
}
int main()
{
	read(n);
	for(int i=1;i<=n;i++)
	{read(x);
		ans+=PD(x);
	}
	printf("%d",ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};


int main(){
   int n,m; cin >> n >> m;
   cout << (n - 1) * (m - 1) << endl;
}

Measured memory_bytes: 256
def main():
    x = int(input())
    if x >= 400 and x < 600:
        print(8)
    elif x >= 600 and x < 800:
        print(7)
    elif x >= 800 and x < 1000:
        print(6)
    if x >= 1000 and x < 1200:
        print(5)
    if x >= 1200 and x < 1400:
        print(4)
    if x >= 1400 and x < 1600:
        print(3)
    if x >= 1600 and x < 1800:
        print(2)
    if x >= 1800 and x < 2000:
        print(1)
if __name__=='__main__':
    main()


Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
const int maxn = 10000001;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    map<ll,int>mp;
    mp[0] = 1;
    ll cur = 0;
    ll ans = 0;
    f(n) {
        ll x;
        cin >> x;
        cur += x;
        ans += mp[cur];
        mp[cur]++;
    }
    cout << ans << '\n';
}  

Measured memory_bytes: 12800
x, y = gets.chomp.split(" ").map(&:to_i)
cal_x = x - 1
cal_y = y - 1
sum = 0

while cal_x > 0 do
  sum += cal_x
  cal_x -= 1
end

while cal_y > 0 do
  sum += cal_y
  cal_y -= 1
end

puts sum


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

bool check(string sub, string t){
	rep(i,sub.size()){
		if(sub[i] == '?') continue;
		if(sub[i] != t[i]) return false;
	}
	return true;
}

int main(){
	string s, t;
	cin >> s >> t;

	vector<string> ans;
	rep(i,s.size() - t.size() + 1){
		if(check(s.substr(i,t.size()), t)){
			string cp = s;
			range(j,i,i + t.size()){
				cp[j] = t[j - i];
			}
			ans.emplace_back(cp);
		}
	}
	if(ans.empty()){
		cout << "UNRESTORABLE" << endl;
	}else{
		sort(all(ans));
		for(auto& i: ans[0]){
			if(i == '?') i = 'a';
		}
		cout << ans[0] << endl;
	}
}


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

void Main() {
  int K;
  cin >> K;

  int a[K];
  a[0] = 7 % K;
  for (int i = 1; i < K; i++) {
    a[i] = (a[i - 1] * 10 + 7) % K;
  }

  for (int i = 0; i < K; i++) {
    if (a[i] == 0) {
      cout << i + 1 << endl;
      return;
    }
  }
  cout << -1 << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 7508
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
#define MOD 1000000007
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> p;
typedef vector<int> vi;
set <int> st;
int a,b;

int main(int argc,char const* argv[])
{
  cin >> a >> b;
  if(a<=0 && b>=0)
    {
      cout << "Zero" << endl;
      return 0;
    }
  else if(a>0 && b>0)
    {
      cout << "Positive" << endl;
      return 0;
    }
  else if(a<0 && b<0)
    {
      if((a-b)%2 !=0)
	{
	  cout <<"Positive" << endl;
	  return 0;
	}
      else
	{
	  cout << "Negative" << endl;
	  return 0;
	}
    }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int INF = 1e9;
int N, A, B, C;
int L[8];

int dfs(int i, int a, int b, int c){
  int ret = INF;
  if(a > 0 and b > 0 and c > 0)
    ret = min(ret,abs(A-a)+abs(B-b)+abs(C-c));
  if(i < N){
    ret = min(ret,dfs(i+1,a,b,c));
    int a_ = dfs(i+1,a+L[i],b,c),
      b_ = dfs(i+1,a,b+L[i],c),
      c_ = dfs(i+1,a,b,c+L[i]);
    if(a > 0) a_ += 10;
    if(b > 0) b_ += 10;
    if(c > 0) c_ += 10;
    ret = min(a_,ret);
    ret = min(b_,ret);
    ret = min(c_,ret);
  }
  return ret;
}

int main(){
  cin >> N >> A >> B >> C;
  for(int i = 0; i < N; ++i) cin >> L[i];
  cout << dfs(0,0,0,0) << endl;
}


Measured memory_bytes: 256
/**
 *   Author   :  Nguyen Canh Toan
 *   Created  :  20.05.2020 10:42:40
**/
#include <bits/stdc++.h>

using namespace std;

const int INF = 1e9 + 5;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	vector<int> dp(n, INF);
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j <= i + k; j++) {
			if (j < n) {
				dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
			}
		}
	}
	cout << dp[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, answer = INT_MAX, x;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (int y = *min_element(a,a+N), n = *max_element(a,a+N); y <= n; y++) {
    x = 0;
    for (int i = 0; i < N; i++) {
      x += (a[i]-y)*(a[i]-y);
    }
    answer = min(answer,x);
  }
  cout << answer;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F2(i,a,b) for(int i=(a);i<(b);++i)
#define dF(i,a,b) for(int i=(a);i>=(b);--i)
#define dF2(i,a,b) for(int i=(a);i>(b);--i)
#define dF3(i,a,b) for(int i=(a)-1;i>=(b);--i)
using namespace std;typedef long long ll;typedef double ld;int INF=0x3f3f3f3f;int INF2=0x7fffffff;ll LNF=0x3f3f3f3f3f3f3f3f;ll LNF2=0x7fffffffffffffff;

int n;
ll a[200001],a1[200001],a2[200001];
int id[200001];
int dat[524289],dat1[524289],dat2[524289];
ll Sum;
int m(ll*arr,int p1,int p2){return arr[p1]<arr[p2]?p1:p2;}
void build(int i,int l,int r){
	if(l==r) {id[l]=i; return;}
	int mid=l+r>>1; build(i<<1,l,mid), build(i<<1|1,mid+1,r);
}
void Mod(int p,ll x){
	a[p]=x; a1[p]=x-p; a2[p]=x+p;
	dat[id[p]]=dat1[id[p]]=dat2[id[p]]=p;
	for(int i=id[p]>>1;i;i>>=1) dat[i]=m(a,dat[i<<1],dat[i<<1|1]), dat1[i]=m(a1,dat1[i<<1],dat1[i<<1|1]), dat2[i]=m(a2,dat2[i<<1],dat2[i<<1|1]);
}
int Qur1(int i,int l,int r,int a,int b){
	if(b<l||r<a) return 0; if(a<=l&&r<=b) return dat1[i];
	int mid=l+r>>1; return m(a1,Qur1(i<<1,l,mid,a,b),Qur1(i<<1|1,mid+1,r,a,b));
}
int Qur2(int i,int l,int r,int a,int b){
	if(b<l||r<a) return 0; if(a<=l&&r<=b) return dat2[i];
	int mid=l+r>>1; return m(a2,Qur2(i<<1,l,mid,a,b),Qur2(i<<1|1,mid+1,r,a,b));
}
int main(){
	memset(a,0x3f,sizeof a);
	memset(a1,0x3f,sizeof a1);
	memset(a2,0x3f,sizeof a2);
	int q,A,B,lst,now;
	scanf("%d%d%d%d%d",&n,&q,&A,&B,&lst);
	build(1,1,n);
	Mod(A,abs(B-lst));
	Mod(B,abs(A-lst));
	F(i,2,q){
		scanf("%d",&now);
		int tmp1=Qur1(1,1,n,1,now),tmp2=Qur2(1,1,n,now,n);
		ll k=min(a1[tmp1]+now,a2[tmp2]-now)-abs(now-lst);
		Sum+=abs(now-lst);
		if(a[lst]>k) Mod(lst,k);
		lst=now;
	}
	printf("%lld",a[dat[1]]+Sum);
	return 0;
}

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

int main(){
  int n;cin>>n;
  int odd=0,even=0;
  rep(i,n){
    if(i%2==0)
      even++;
    else
      odd++;
  }
  cout<<even*odd;
}
      

    

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

minus = 1
for i,a in enumerate(A) :
    if a < 0 :
        minus *= -1
        A[i] = -a

ans = sum(A)

A.sort()

if minus == -1 :
    ans -= A[0] * 2

print(ans)


Measured memory_bytes: 14412
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    string s;
    cin >> s;
    vector<int> v(26);
    for (int i = 0; i < s.size(); i++)v[s[i] - 'A']++;
    bool ret = true;
    for (auto x:v)
        if (x != 2 && x != 0)ret = false;

    cout << (ret ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

void prime_factor(map<int, int>& cnt, int n) {
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			++cnt[i];
			n /= i;
		}
	}
	if (n != 1) ++cnt[n];
}

template<ll mod = 1000000007LL>
ll solve(int n) {
	map<int, int> cnt;
	for (int i = 2; i <= n; ++i)
		prime_factor(cnt, i);
	ll res = 1;
	for (auto& e : cnt)
		res = res * (e.second + 1) % mod;
	return res;
}

int main(void) {
	int N; cin >> N;
	cout << solve<>(N) << endl;
	return 0;
}

Measured memory_bytes: 3628
a,b=map(int,input().split())
if a==1:
    if b==1:
        print('Draw')
    else:
        print('Alice')
elif b==1:
    print('Bob')
else:
    if a>b:
        print('Alice')
    elif a<b:
        print('Bob')
    else:
        print('Draw')

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

int inf = (int) 1e9 + 7;
int A[200005], dp[200005][5];

int solve(int N, int k)
{
    if(N == 0)
        return 0;
    
    if(dp[N][k] != -1)
        return dp[N][k];
    
    int ans = inf;
    
    if(k == 4)
    {
        if(A[N] == 0)
            ans = solve(N-1, k);
        else if(A[N] % 2 == 1)
            ans = min(solve(N-1, 4) + A[N], min(solve(N-1, 2), solve(N-1, 3) + 1));
        else
            ans = min(solve(N-1, 4) + A[N], min(solve(N-1, 3), solve(N-1, 2) + 1));
    }
    else if(k == 3)
    {
        if(A[N] == 0)
            ans = min(solve(N-1, 0) + A[N], min(solve(N-1, 2) + 1, solve(N-1, 3) + 2));
        else if(A[N] % 2 == 1)
            ans = min(solve(N-1, 0) + A[N], min(solve(N-1, 2), solve(N-1, 3) + 1));
        else
            ans = min(solve(N-1, 0) + A[N], min(solve(N-1, 2) + 1, solve(N-1, 3)));
    }
    else if(k == 2)
    {
        if(A[N] == 0)
            ans = min(solve(N-1, 0) + A[N], min(solve(N-1, 1) + 2, solve(N-1, 2) + 1));
        else if(A[N] % 2 == 1)
            ans = min(solve(N-1, 0) + A[N], min(solve(N-1, 1) + 1, solve(N-1, 2)));
        else
            ans = min(solve(N-1, 0) + A[N], min(solve(N-1, 1), solve(N-1, 2) + 1));
    }
    else if(k == 1)
    {
        if(A[N] == 0)
            ans = min(solve(N-1, 0) + A[N], solve(N-1, 1) + 2);
        else if(A[N] % 2 == 1)
            ans = min(solve(N-1, 0) + A[N], solve(N-1, 1) + 1);
        else
            ans = min(solve(N-1, 0) + A[N], solve(N-1, 1));
    }
    else
        ans = solve(N-1, 0) + A[N];
    
    return dp[N][k] = min(ans, inf);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int L;
    cin >> L;
    
    int ans = 0;
    
    for(int i=1; i<=L; i++)
        cin >> A[i];
    
    memset(dp, -1, sizeof(dp));
    
    cout << solve(L, 4) << "\n";
    return 0;
}

Measured memory_bytes: 14336
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  
  // template
  string temp = "";
  for(int i = 0; i < s.length(); i++) {
    if(s[i] == '?') temp += 'a';
    else temp += s[i];
  }
  
  bool found = false;
  for(int i = s.length() - t.length(); i >= 0; i--) {
    bool works = true;
    for(int j = 0; j < t.length(); j++) {
      if(s[i + j] != '?' && s[i + j] != t[j]) {
        works = false;
        break;
      }
    }
    if(works) {
      string ans = temp.substr(0, i) + t + temp.substr(i + t.length());
      cout << ans << endl;
      found = true;
      break;
    }
  }
  
  if(!found) {
    cout << "UNRESTORABLE" << endl;
  }
  return 0;
}

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

struct SegmentTree {
    using T = int;
    static T op(const T& a, const T& b) { return min(a, b); }
    static constexpr T e() { return numeric_limits<int>::max(); }
    const int n;
    vector<T> t;
    SegmentTree(int _n) : n(_n), t(2 * n, e()) {}
    T& operator[](int i) { return t[i + n]; }
    T query(int l, int r) const {
        T resl = e(), resr = e();
        for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
            if (l & 1) resl = op(resl, t[l++]);
            if (r & 1) resr = op(t[--r], resr);
        }
        return op(resl, resr);
    }
    void update(int i, const T& a) {
        t[i += n] = a;
        while (i >>= 1) t[i] = op(t[2 * i], t[2 * i + 1]);
    }
};

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

    int n, q;
    cin >> n >> q;

    SegmentTree hoge(n);
    for (int i = 0; i < n; i++) {
        hoge.update(i, (1LL << 31) - 1);
    }

    while (q--) {
        int t;
        cin >> t;
        if (t == 0) {
            int a, b;
            cin >> a >> b;
            hoge.update(a, b);
        } else {
            int a, b;
            cin >> a >> b;
            cout << hoge.query(a, b + 1) << '\n';
        }
    }
}



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

#define mem(t, v)   memset ((t) , v, sizeof(t))
#define all(x)      x.begin(),x.end()
#define un(x)       x.erase(unique(all(x)), x.end())
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sl(n)       scanf("%lld", &n)
#define sll(a,b)    scanf("%lld %lld", &a, &b)
#define slll(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define D(x)        cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define DD(x,y)     cerr << __LINE__ << ": " << #x << " = " << x << "   " << #y << " = " << y << '\n'
#define DDD(x,y,z)  cerr << __LINE__ << ": " << #x << " = " << x << "   " << #y << " = " << y << "   " << #z << " = " << z << '\n'
#define DBG         cerr << __LINE__ << ": Hi" << '\n'
#define pb          push_back
#define PI          acos(-1.00)
#define xx          first
#define yy          second
#define eps         1e-9

typedef unsigned long long int ULL;
typedef long long int LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;


inline int setBit(int N, int pos) { return N=N | (1<<pos); }
inline int resetBit(int N, int pos) { return N= N & ~(1<<pos); }
inline bool checkBit(int N, int pos) { return (bool)(N & (1<<pos)); }

//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction

#define MAX     1000000

int s(LL a)
{
    int ret = 0;
    while(a)
    {
        ret += (a%10);
        a /= 10;
    }
    return ret;
}

pair<int,double> val[MAX+10];
bool cmp(pair<int,double>a, pair<int,double>b)
{
    if(fabs(a.yy - b.yy) < eps)
        return a.xx < b.xx;
    return a.yy < b.yy;
}
vector<LL>V, ans;
int main()
{
    //freopen("maxon.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    LL base = 1;
    for(int d = 0; d<3; d++)
    {
        for(int i = 1; i<=9; i++)
        {
            V.pb(i*base+base-1);
//            D(V.back());
        }
        base *= 10;
    }
    int ok = 19;
    int st = 2;
    for(int d = 3; d<=16; d++)
    {
        for(int i = 10; i<=ok; i++)
        {
            V.pb(i*base/10 + base/10 -1 );
//            D(V.back());
//            getchar();
        }
        for(int i = st; i<=9; i++)
        {
            V.pb(i*base+base-1);
        }
        ok += 10;
//        ok = min(99, ok);
        base *= 10;
    }
    sort(all(V));
    un(V);
    int cnt = 0;
    for(int i = 0; i<V.size(); i++)
    {
        double a = (double)V[i]/s(V[i]);
        if(V[i] > 1e15)
            break;
        bool ok = true;
        for(int j = i+1; j<V.size(); j++)
        {
            double b = (double)V[j]/s(V[j]);
            if(a > b+eps)
            {
//                DD(a,b);
//                DD(V[i], V[j]);
                ok = false;
                break;
//                assert(false);
            }
        }
        if(ok)
            ans.pb(V[i]);
    }
//    D(ans.size());
//    for(auto v: ans)
//        D(v);
//    exit(0);
    int n;
    sf(n);
    assert( n <= ans.size());
    sort(all(V));
    for(int i = 0; i<n;i++)
        cout << ans[i] << endl;
    return 0;
}




Measured memory_bytes: 256
n = input()
n = int(n)
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
    wk = input()
    if wk == "AC":
        ac +=1
    elif wk == "WA":
        wa += 1
    elif wk == "TLE":
        tle += 1
    else :
        re += 1
print("AC x {0}".format(ac))
print("WA x {0}".format(wa))
print("TLE x {0}".format(tle))
print("RE x {0}".format(re))


Measured memory_bytes: 9200