akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#define ll long long
using namespace std;

ll x;

int main() {
	cin >> x;
	ll sum = 0, a = 0;
	for (int i = 1;; i++) {
		sum += i;
		if (sum >= x) {
			a = i;
			break; 
		}
	}
	cout << a << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;

ll y[10000005];

int main() {
    int n; cin >> n;

    for(int i = 1; i <= 10000004; i++){
        for(int j = 1; j <= 10000004/i;j++){
            y[i*j]++;
        }
    }

    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        ans += i * y[i];
    }
    cout << ans << endl;

}




Measured memory_bytes: 81708
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int a,b,c,d;
    std::cin >> a>>b>>c>>d;
    std::cout << min({max(0,b-c),max(0,d-a),d-c,b-a}) << std::endl;
}

Measured memory_bytes: 256
try :
  while True :
    (a,b,c,d,e,f) = map(float, raw_input().split())

    print "%.3f %.3f"%((c*e-b*f)/(a*e-b*d)+0, (a*f-c*d)/(a*e-b*d)+0)
except EOFError :
  pass

Measured memory_bytes: 4236
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

typedef pair<int, int> PII;

int main() {
  int N,M;
  int a, L;
  bool arr[210];

  for(int i = 0 ; i < 210 ; i++) arr[i] = false;
  
  map<int, int> ans;
  
  cin >> N >> M;
  for(int i = 0 ; i < M ; i++){
    cin >> a >> L;
    for(int j = a ; j < a+L ; j++) arr[j%N] = true;
  }
  
  bool f = false;
  for(int i = 0 ; i < N ; i++){
    if(!arr[i]) f = true;
  }
  if(!f){
    cout << N << ' ' << 1 << endl;
    return 0;
  }
  
  
  for(int i = 0 ; i < N ; i++){
    arr[N+i] = arr[i];
  }
  
  bool flag = false;
  for(int i = 0 ; i < N ; i++){
    int pos = i, len = 0;
    while(arr[pos]) pos++, len++;
    i = pos;
    if(!(arr[0] && arr[N-1] && !flag)) ans[len]++;
    flag = true;
  }
  
  vector<PII> res;
  for(map<int,int>::iterator it = ans.begin() ; it != ans.end() ; it++){
    res.push_back(PII(it->first, it->second));
  }
  
  sort(res.begin(), res.end());
  reverse(res.begin(), res.end());

  for(int i = 0 ; i < res.size() ; i++){  
    if(res[i].first == 0) continue;
    cout << res[i].first << ' ' << res[i].second << endl;
  }
  
  return 0;
	
}


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

		public static void main(String[] args) {
			Scanner scan = new Scanner(System.in);
			int a,b;
			a=scan.nextInt();
			b=scan.nextInt();
			if(a<=8&&b<=8)System.out.println("Yay!");
			else System.out.println(":(");
			scan.close();
		}
}

Measured memory_bytes: 21076
none = gets.to_i
nums = gets.strip.split.map(&:to_i)
count = 0
flag = false
while true
  nums = nums.map do |num|
    if num.odd? || num <= 1
      flag = true
      break
    end
    num / 2
  end
  break if flag
  count = count.next
end
puts count

Measured memory_bytes: 1788
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	scanInit()

	n := nextInt()
	k := nextInt()
	a := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = nextInt() - 1
	}

	ans := doubling(a, k)

	ans++ // 0-indexに直したから
	fmt.Println(ans)

}

// ans := doubling(a, k)  で遷移配列aの k番目の遷移結果を得る。
func doubling(a []int, query int) int {
	n := len(a) // n=遷移配列の大きさ

	// doubling 前処理[1]: doubling配列確保と初期化
	logOfQuery := 1 + int(math.Log2(float64(query))) // queryのビット数
	doubling := makemat(logOfQuery, n)               // doubling[p][i] : i番目から 2^p 進んだ点
	for p := 0; p < n; p++ {
		doubling[0][p] = a[p] // 2^0(=1) 回目の遷移
	}

	// doubling 前処理[2]: doubling計算
	for p := 0; p < logOfQuery-1; p++ {
		for i := 0; i < n; i++ {
			doubling[p+1][i] = doubling[p][doubling[p][i]]
		}
	}

	// doubling Query処理  (Bit全探索と同じ要領)
	ans := 0
	bit := query
	for p := 0; p < logOfQuery; p++ {
		if bit&(1<<p) != 0 { // 今回ヒットした場合
			ans = doubling[p][ans]
		}
	}

	return ans
}

func makemat(a, b int) [][]int {
	dp := make([][]int, a)
	for i := 0; i < a; i++ {
		dp[i] = make([]int, b)
		for j := 0; j < b; j++ {
			dp[i][j] = 0
		}
	}
	return dp
}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 102164
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
const double EPS=1e-10;
struct point{
	double x,y;
	point(const point&a):x(a.x),y(a.y){}
	point(const double&x=0,const double&y=0):x(x),y(y){}
	point operator+(const point&p)const{return point(x+p.x,y+p.y);}
	point operator-(const point&p)const{return point(x-p.x,y-p.y);}
	point operator*(const double&k)const{return point(x*k,y*k);}
	point operator/(const double&k)const{return point(x/k,y/k);}
	double norm(){return x*x+y*y;}
	double abs(){return sqrt(norm());}
	void operator=(const point&a){
		x=a.x,y=a.y;
	}
	bool operator<(const point&p)const{
		return x!=p.x?x<p.x:y<p.y;
	}
	bool operator==(const point&p)const{
		return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
	}
	friend double dot(const point&a,const point&b){
		return a.x*b.x+a.y*b.y;
	}
	friend double cross(const point&a,const point&b){
		return a.x*b.y-a.y*b.x;
	}
};
typedef point vector;
struct segment{
	point p1,p2;
	segment(const double&a,const double&b,const double&c,const double&d){
		p1.x=a,p1.y=b,p2.x=c,p2.y=d;
	}
	segment(const point&a, const point&b):p1(a),p2(b){}
	point get_vec()const{return point(p2.x-p1.x,p2.y-p1.y);}
};
point project(const segment&s,const point&p){
	vector base=s.get_vec();
	double r=dot(p-s.p1,base)/base.norm();
	return s.p1+base*r;
}
point reflect(const segment&s,const point&p){
	return p+(project(s,p)-p)*2.0;
}
int main(){
	double a,b,c,d;
	cin>>a>>b>>c>>d;
	segment s(a,b,c,d);
	int q;
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>a>>b;
		point t=reflect(s,point(a,b));
		cout<<setprecision(8)<<fixed<<t.x<<' '<<t.y<<endl;
	}
	return 0;
}



Measured memory_bytes: 3288
def solve(string):
    n, q, *abpx = map(int, string.split())
    t, c, d, check = [[] for i in range(n + 1)], [0] * (n + 1), [1], [True] * (n + 1)
    for a, b in zip(*[iter(abpx[:2 * n - 2])] * 2):
        t[a].append(b)
        t[b].append(a)
    for p, x in zip(*[iter(abpx[2 * n - 2:])] * 2):
        c[p] += x
    while len(d) > 0:
        curr = d.pop()
        check[curr] = False
        next_ = [i for i in t[curr] if check[i]]
        for n_ in next_:
            c[n_] += c[curr]
        d.extend(next_)
    return " ".join(list(map(str, c[1:])))


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n + m - 1)])))


Measured memory_bytes: 99888
#include <stdio.h>
int H;
int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}
void maxH(int a[], int i){
  int M;
  int k, l, r;
  l=left(i);
  r=right(i);

  if(l<=H && a[l]>a[i]){
    M=l;
  }
  else{
    M=i;
  }
  if(r<=H && a[r]>a[M]){
    M=r;
  }

  if(M!=i){
    k=a[i];
    a[i]=a[M];
    a[M]=k;
    maxH(a, M);
  }
}

int main(){
  int  i, j, a[500000];
  scanf("%d", &H);

  for(i=1;i<=H;i++){
    scanf("%d", &a[i]);
  }
  
  for(i=H;i>=1;i--){
    maxH(a,i);
  }
  for(i=1;i<H;i++){
    printf(" %d",a[i]);  
  }
  printf(" %d\n",a[H]);
  return 0;
}



Measured memory_bytes: 3668
#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>;

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

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

int main() {
  int k;
  cin >> k;

  int total = 0;
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= k; j++) {
      for (int l = 1; l <= k; l++) {
        int temp = gcd(i, j);
        total += gcd(temp, l);
      }
    }
  }
  cout << total << endl;

  return 0;
}

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

bool check(){
    rep(i,n){
        if(a[i]!=b[i]){
            return true;
        }
    }
    return false;
}

int main(){

    cin >> n;
    a=vector<ll>(n);
    b=vector<ll>(n);
    rep(i,n){
        cin >> a[i] ;
    }
    rep(i,n){
        cin >> b[i];
    }

    ll ans=0;
    if(!check()){cout << 0 << endl;return 0;}
    while(true){
        int i=0;
        bool c=false;
        int cnt=0;
        while(i<n){
            int l=i-1;
            int r=i+1;
            if(l<0)l=n-1;
            if(r==n)r=0;
            if(b[i]==a[i]){
                cnt++;
                i++;
                if(cnt==n){
                    cout << ans << endl;
                    return 0;
                }
                continue;
            }
            if(b[i]-a[i]>=b[l]+b[r]){
                ans+=(b[i]-a[i])/(b[l]+b[r]);
                b[i]=(b[i]-a[i])%(b[l]+b[r])+a[i];
                c=true;
                // rep(j,n){
                //     cout << b[j] << " ";
                // }cout << "| " << ans << endl;
            }
            i++;
        }
        if(!c){
            cout << -1 << endl;
            return 0;
        }
    }

    return 0;
}

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


int main(){
  ll n;
  cin >> n;
  ll min;
  for(ll i = sqrt(n); i >= 1; i--){
    if(n % i == 0){
      min = i;
      break;
    }
  }
  cout << min + n / min - 2<< endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

vector<int> binary(int i, int n, int N){
    int x = 1;
    rep(j,N){
        x *= n;
    }
    vector<int> vec(N);
    rep(j,N){
        x /= n;
        vec[j] = i / x;
        i -= x * vec[j];
    }
    return vec;
}

int main(){
    int N;
    cin >> N;
    vector<vector<int> > open(N,vector<int>(10));
    vector<vector<int> > profit(N,vector<int>(11));
    rep(i,N){
        rep(j,10){
            cin >> open[i][j];
        }
    }
    rep(i,N){
        rep(j,11){
            cin >> profit[i][j];
        }
    }
    int ans = -1000000007;
    vector<int> joisino(10);
    for(int i = 1; i <= 1023; i++){
        joisino = binary(i,2,10);
        int ans_sub = 0;
        rep(j,N){
            int count = 0;
            rep(k,10){
                if (open[j][k] == 1 && joisino[k] == 1) count++;
            }
            ans_sub += profit[j][count];
        }
        ans = max(ans, ans_sub);
    }
    cout << ans << endl;
}


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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;

//----------------------------------------------------------

int N;
ll A[10005];

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

int64_t mul(int64_t a, int64_t b){
    return ((a % MOD) * (b % MOD)) % MOD;
}

int64_t power(int64_t x, int64_t y){
    if   (y == 0) return 1;
    else if (y == 1) return x % MOD;
    else if (y % 2 == 0) {int64_t tmp = power(x, y/2);return mul(tmp,tmp) % MOD;}
    else {int64_t tmp = power(x, y/2);return mul(mul(tmp,tmp),x) % MOD;}
}

int64_t division(int64_t a, int64_t b){
    return mul(a, power(b, MOD-2));
}

int main(){
    cin >> N;
    FOR(i,1,N+1)cin >> A[i];
    int64_t ans=0;
    sort(A+1,A+N+1,greater<>());
    map< int64_t, int > g = prime_factor(A[1]);
    FOR(i,2,N+1)
    {
        map< int64_t, int > b = prime_factor(A[i]);
        for(auto it = b.begin();it!=b.end();it++)
        {
            chmax(g[(*it).first],(*it).second);
        }
    }
    int64_t total=1;
    for(auto it=g.begin();it!=g.end();it++)
    {
        int64_t a1=1;
        REP(i,(*it).second)
        {
            a1=mul(a1,(*it).first);
        }
        total = mul(total,a1);
    }
    FOR(i,1,N+1)
    {
        ans+=division(total,A[i]);
    }
    cout << (ans%MOD) << endl;
    return 0;
}

Measured memory_bytes: 896
// In the name of ALLAH
#include <bits/stdc++.h>
using namespace std;

#define int ll

#define PB push_back
#define PF push_front
#define MP make_pair
#define FF first
#define SS second
#define _sz(x) (int)x.size()

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

int n, a, b, x, y;

int32_t main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n; x = y = 1;
	for (int i = 0; i < n; i ++){
		cin >> a >> b;
		if (y % b) y = (y / b + 1) * b;
		if (x % a) x = (x / a + 1) * a;

		x = max(x, y / b * a);
		y = max(y, x / a * b);
	}

	cout << x + y << '\n';
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  int D, N;
  std::cin >> D >> N;

  if (D == 0) {
    if (N == 100) {
      std::cout << 101 << std::endl;
    } else {
      std::cout << N << std::endl;
    }
  } else if (D == 1) {
    if (N == 100) {
      std::cout << 10100 << std::endl;
    } else {
      std::cout << N * 100 << std::endl;
    }
  } else {
    if (N == 100) {
      std::cout << 1010000 << std::endl;
    } else {
      std::cout << N * 10000 << std::endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int n, m = 0;
  cin >> n;
  v1i v(n), u(n, 0);
  rep(i, n) cin >> v[i];
  priority_queue<int, vector<int>, greater<int>> p;
  rrep(i, n){
    int tmp = i+1, t = 0;
    while(tmp <= n){
      t += u[tmp-1];
      tmp += i+1;
    }
    if(t % 2 != v[i]){
      ++m;
      u[i] = 1;
    }
  }
  cout << m << endl;
  if(m > 0){
    rep(i, n){
      if(u[i] == 1){
        cout << i+1;
        --m;
        if(m > 0) cout << " ";
        else{
          cout << endl;
          break;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 2432
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
using namespace std;
int main()
{
	int a, b, c,d;
	cin >> a >> b >> c >> d;
	if (((abs(a - b) <= d) && (abs(c - b) <= d)) || (abs(c - a) <= d)){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
S = input()
startblack, startwhite = 0, 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "0":startwhite += 1
        else: startblack += 1
    else:
        if S[i] == "0": startblack += 1
        else: startwhite += 1
print(min(startblack, startwhite))


Measured memory_bytes: 3188
#include <cmath>
#include <vector>
#include <iostream>
#include <limits>
#include <iostream>
#include <vector>
#include <cassert>
#include <complex>
#include <cstdio>
#include <set>
#include <cstring>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <queue>
#include <bitset>
#include <ctime>
#include <unordered_map>
#include <numeric>
#include <climits>

using namespace std;
typedef long long Long;
typedef long double Double;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
typedef pair<Long,Long> PLL;

int read(int &x) { return scanf("%d", &x); }
int read(int &x, int &y) { return scanf("%d%d", &x, &y); }
int read(int &x, int &y, int &z) { return scanf("%d%d%d", &x, &y, &z); }
int read(Long &x) { return scanf("%lld", &x); }
char buff[1000010];
int read(string &s) { int r = scanf("%s", buff); s = buff; return r; }

#define dlog2(n) (31-__builtin_clz(n))



int main() {

	int N;
	read(N);
	map<string, int> S;
	Long ans = 0;
	for (int i = 0; i < N; ++i) {
		string s; read(s);
		sort(s.begin(), s.end());
		ans += S[s]++;
	}
	cout << ans << endl;

	return 0;
}

/*
3 -> 2 -> 1
3 -> 1 -> 1
2 -> 1 -> 1
1 -> 2 -> 1
1 -> 1 -> 1



*/

Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

class UnionFind
{
public:
	UnionFind() {};
	void init(int n)
	{
		max = n;
		par.resize(max);
		rank.resize(max);
		for (int i = 0; i < max; ++i)
		{
			par[i] = i;
			rank[i] = 0;
		}
	}
	int find(int x)
	{
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	bool same(int x, int y)
	{
		return find(x) == find(y);
	}
	void unit(int x, int y)
	{
		x = find(x);
		y = find(y);
		if (x == y)return;

		if (rank[x] < rank[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (rank[x] == rank[y])
			{
				rank[x]++;
			}
		}
	}

private:
	std::vector<int> par;
	std::vector<int> rank;
	int max;
};

int main()
{
	int N, K, L;
	cin >> N >> K >> L;
	UnionFind road, line;
	road.init(N);
	line.init(N);
	REP(i, K)
	{
		int p, q;
		cin >> p >> q;
		p--; q--;
		road.unit(p, q);
	}
	REP(i, L)
	{
		int p, q;
		cin >> p >> q;
		p--; q--;
		line.unit(p, q);
	}

	std::map<pii, int> map;
	REP(i, N)
	{
		pii p(road.find(i), line.find(i));
		map[p]++;
	}
	REP(i, N)
	{
		pii p(road.find(i), line.find(i));
		cout << map[p] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 15104
#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;
  if (x == 0) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void){

	int a,b;

	scanf("%d %d",&a,&b);

	if (a < b){
		printf("a < b\n");
	}else if (a > b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
fun main(args : Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map { it.toLong() }.toMutableList()


    var sum1 = 0L
    if (A.filter { it < 0 }.size.mod(2) == 0) {
        (0..N-1).forEach {
            A[it] = Math.abs(A[it])
        }
        sum1 = A.sum()
    }

    (0..N-1).forEach {
        A[it] = Math.abs(A[it])
    }
    A.sort()
    A[0] = -1 * A[0]
    val sum2 = A.sum()

    println(listOf(sum1, sum2).max())
}

Measured memory_bytes: 59696
h,w,k=map(int,input().split())
s=[input() for _ in range(h)]
t=[[s[i][j] for i in range(h)] for j in range(w)]
ans=[]
c=1
for si in s:
  ans.append([c]*w)
  c+=si.count('#')
ans.append([c]*w)
p=0
q=1
while q<=h:
  if ans[q][0]-ans[p][0]>=1:
    c=ans[p][0]
    for j in range(w):
      for i in range(p,q):
        ans[i][j]=c
        if s[i][j]=='#':
          c=min(c+1,ans[q][0]-1)
    p=q
    if ans[q-1][-1]==k:
      while q<h:
        ans[q]=ans[q-1]
        q+=1
  q+=1
for a in ans[:-1]:
  print(*a)

Measured memory_bytes: 8312
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
ll mod=1000000007;

int main() {
  int n;cin >>n;
  vector<int> v(n);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  int cnt =0;
  for(int i = 1; i < n-1; i++){
    if((v[i-1]<v[i]) && v[i]<v[i+1]){
      ++cnt;
    } else if((v[i-1]>v[i]) && v[i]>v[i+1]) {
      ++cnt;
    }
  }
  cout << cnt << endl;
  return 0;
}


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

int main() 
{
    string S,T;
    cin >> S >> T;
    T = T.erase(T.length()-1);
    if (S == T) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3600
fun main (args : Array<String>) {
	val (n, k) = readLine()!!.split(" ")
	val K : Int = k.toInt()
	val list = readLine()!!.split(" ")
	var count : Int = 0
	for (i in 0..list.size - 1) {
		if (list[i].toInt() >= K) {
			count++
		}
	}
	println("${count}")
}

Measured memory_bytes: 47944
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
inline int GCD(int a,int b){return(a==0)?b:GCD(b%a,a);}
int x[maxn],X,n;
void work(){
    for (int i=0;i<n;i++) scanf("%d",&x[i]);
    x[n++] = X;
    sort(x,x+n);
    int gcd = x[1] - x[0];
    for (int i=1;i<n && gcd > 1;i++) gcd = GCD(gcd,x[i]-x[i-1]);

    printf("%d\n",gcd);
}
int main(){
    while (~scanf("%d%d",&n,&X)) work();
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
int a[1000],i,n;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=n-1;i>=1;i--)
{
printf("%d ",a[i]);
}
printf("%d\n",a[0]);
return 0;
}




Measured memory_bytes: 2036
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int a[1005], b[1005];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int h, n; cin >> h >> n;
    rep(i,n) {
        cin >> a[i] >> b[i];
    }

    vector<int> dp(10005,INF);
    dp[0] = 0;

    rep(i,h+1) {
        if(dp[i]==INF) continue;
        rep(j,n) {
            int A = a[j], B = b[j];
            int ni = min(h,i+A);
            dp[ni] = min(dp[ni],dp[i] + B);
        }
    }
    cout << dp[h] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define vii vector<pii>
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


int solve(){
    int n=5;
    rep0(n){
        int x;cin>>x;
        if(x==0) return cout<<i+1,0;
    }



    return 0;
}
signed main(){
    asdf
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3600
import java.util.Scanner;

 public class Main {
	 
	
	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		int N=in.nextInt();
		int A=in.nextInt();
		int B=in.nextInt();
		int s=0;
		 for (int i=1; i <= N; i++) {
	            if( ((int)i/10000 + ( (int)i/1000 % 10) + ( (int)i/100 % 10) + ( (int)i/10 % 10) + i%10) >= A && ((int)i/10000 + ( (int)i/1000 % 10) + ( (int)i/100 % 10) + ( (int)i/10 % 10) + i%10) <= B)
		     s=s+i;
		 }
	            	System.out.println(s);
		
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>

typedef long long int64;

int main(void) {
  const double PI = 3.14159265358979323846;
  int r;
  std::cin >> r;
  std::cout << 2 * PI * r << std::endl;
  return 0;
}


Measured memory_bytes: 3792
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    vector <vector <int>> suf(n + 1, vector <int> (10));
    for (int i = n - 1; i >= 0; --i) {
        suf[i] = suf[i + 1];
        suf[i][s[i] - '0'] |= 1;
    }
    vector <int> used(10);
    set <string> ans;
    forn (i, 1, n - 1) {
        used[s[i - 1] - '0'] |= 1;
        forn (j, 0, 10) {
            forn (k, 0, 10) {
                if (used[j] && suf[i + 1][k]) {
                    string t;
                    t += static_cast <char> (j + '0');
                    t += s[i];
                    t += static_cast <char> (k + '0');
                    ans.insert(t);
                }
            }
        }
        /*for (int j : used)
            cout << j << " ";
        cout << "\n";*/
    }
    cout << ans.size();
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n, z, w;cin >> n >> z >> w;
	vector<int> a(n);
	rep(i,n)cin >> a[i];
	if(n==1)
	{
		cout<<abs(w-a[0])<<endl;
		return 0;
	}

	cout<<max(abs(w-a[n-1]),abs(a[n-1]-a[n-2]))<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		
		long[] arr=new long[n];
		
		for(int i=0;i<n;i++)
		{
			arr[i]=s.nextLong();
		}
		
		Arrays.sort(arr);
		
		int[] count=new int[n];
		count[n-1]=1;
		
		int ptr=n-1;
		
		long ans=0;
		
		for(int i=n-2;i>=0;i--)
		{
			if(count[ptr]==2)
			{
				ans=ans+arr[ptr];
				count[ptr]--;
			}
			else
			{
				ans=ans+arr[ptr];
				count[ptr]=0;
				ptr--;
				count[ptr]=2;
			}
		}
		
		System.out.println(ans);
		
	}
	
}

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

ll solution() {
	ll sol = 0;
	ll A = 0;
	for (int i=0; i <N-1; i++) {
		if (str[i] == 'A') {
			A++;
		}
		else if (str[i] == 'B' && str[i+1] == 'C') {
			sol += A;
			i++;
		}
		else {
			A = 0;
		}
	}
	return sol;
}

int main() {
	cin >> str;
	N = str.size();
	ll ans = solution();
	cout << ans << endl;
}

Measured memory_bytes: 640
X = int(input())
cand = [0]
n = 1
while n**5 - (n-1)**5 <= X:
    cand.append(n)
    cand.append(-n)
    n += 1
for a in cand:
    for b in cand:
        if a**5 - b**5 == X:
            print(a, b)
            exit()


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

int main(){
  int n;
  cin >> n;
  int a[n];

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

  int num,b;
  b = n/2;

  for(int i=0;i<b;i++){
    num = a[i];
    a[i] = a[n-1-i];
    a[n-1-i] = num;
  }

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



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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    ll A, B, C, D, E, K;
    cin >> A >> B >> C >> D >> E >> K;
    if (E - A > K)
        cout << ":(" << endl;
    else
        cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    double ans = 0;
    for(int i = 0; i < n; i++){
        double x;
        string u;
        cin >> x >> u;
        ans += x * (u == "BTC" ? 38e4 : 1);
    }
    cout << fixed << setprecision(20) << ans << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

#define SENTINEL 1000000000000000000

void merge(long long A[], long long left, long long mid, long long right){
  long long n1, n2, i, j, k;
  long long *L,*R;
  
  n1 = mid-left;
  n2 = right-mid;
  
  L = (long long*)malloc(sizeof(long long) *(n1 + 1));
  R = (long long*)malloc(sizeof(long long) *(n2 + 1));
  
  for(i = 0; i <= n1 - 1; i++){
    L[i] = A[left + i];
  }
  for(j = 0; j <= n2 - 1; j++){
    R[j] = A[mid + j];
  }
  
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  
  i = 0;
  j = 0;
  
  for(k = left; k <= right - 1; k++){
   if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
  }
  free(L);
  free(R);
}

void mergeSort(long long A[], long long left, long long right){
  long long mid;
  
  if(left + 1 < right){
    mid=(left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main(void){

    int N;

    scanf("%d", &N);

    long long A[N];

    for(int i = 0; i < N; i++){
        scanf("%lld", &A[i]);
    }

    mergeSort(A, 0, N);

    int c = 0;

    for(int i = 1; i < N; i++){
        if(A[i] == A[i-1]){
            c++;
        }
    }

    if(c % 2 == 0){
        printf("%d\n", N - c);
    }else{
        printf("%d\n", N - c - 1);
    }

    return 0;
}

Measured memory_bytes: 2968
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int f(int n) {
  if (n % 2 == 0)
    return n / 2;
  else
    return 3 * n + 1;
}

int main() {
  int s;
  cin >> s;
  vector<int> a;
  a.push_back(s);
  for (int i = 1;; i++) {
    a.push_back(f(a[i - 1]));
    for (int j = 0; j < a.size() - 1; j++) {
      if (a[j] == a[i]) {
        cout << i + 1 << endl;
        return 0;
      }
    }
  }
  return 0;
}

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

int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	
	string t;
	cin >> t;
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	
	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3596
def calc(pr, s):
    cnt = 0
    i = 0
    while i < len(s)-1:
        if len(pr) == 1:
            if s[i+1] == pr:
                if i+2 < len(s):
                    cnt += 1
                    pr = s[i+1:i+3]
                    i += 1
                else:
                    break
            else:
                cnt += 1
                pr = s[i+1]
                i += 1
        else:
            if i+2 < len(s):
                cnt += 1
                pr = s[i+2]
                i += 2
            else:
                break
    return cnt+1

s = input()
pr1 = s[0]
pr2 = s[:2]
print(max(calc(pr1, s), calc(pr2, s)))

Measured memory_bytes: 3628
#include<iostream>
#include<map>
using namespace std;
int main(){
	int n,t,ans;
	while(cin>>n,n){
		map<int,int> d; ans=-1;
		for(int i=0;i<n;i++){
			cin>>t,d[t]++;
			if(d[t]>n/2)ans=t;
		}
		if(ans<0)cout<<"NO COLOR"<<endl;
		else cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1940
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    k, s = list(map(int, input().split()))
    count = 0

    for x in range(k + 1):
        for y in range(k + 1):
            z = s - (x + y)

            if 0 <= z <= k:
                count += 1

    print(count)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

pair<int, int> E[200001];
int H[100001], P[100001], PM[100001], Pm[100001];
bool V[100001], V2[100001];
int kotae[100001];
bool OK = true;
pair<int, int> sagasu(int A) {
	if (V[A]) return mp((int)1e7, 0);
	V[A] = true;
	PM[A] = 5e6;
	Pm[A] = -5e6;
	bool odd = false;
	bool even = false;
	if (P[A] != -1) {
		PM[A] = P[A];
		Pm[A] = P[A];
		if (P[A] & 1) odd = true;
		else even = true;
	}
	for (int i = H[A]; i; i = E[i].second) {
		auto p = sagasu(E[i].first);
		if (p != mp((int)1e7, 0)) {
			if (p.first < 4e6) {
				if (p.first & 1) odd = true;
				else even = true;
			}
			PM[A] = min(PM[A], p.first);
			Pm[A] = max(Pm[A], p.second);
		}
	}
	if (odd && even) OK = false;
	if (PM[A] < Pm[A]) OK = false;
	return mp(PM[A] + 1, Pm[A] - 1);
}
void sagasu2(int A, int M) {
	if (V2[A]) return;
	V2[A] = true;
	if (M + 1 <= PM[A] && M + 1 >= Pm[A]) kotae[A] = M + 1;
	else kotae[A] = M - 1;
	for (int i = H[A]; i; i = E[i].second) {
		sagasu2(E[i].first, kotae[A]);
	}
}

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


	int N;
	cin >> N;
	for (int i = 1; i < 2 * (N - 1); i += 2) {
		int a, b;
		cin >> a >> b;
		E[i] = mp(a, H[b]);
		H[b] = i;
		E[i + 1] = mp(b, H[a]);
		H[a] = i + 1;
	}
	int K;
	cin >> K;
	int v, p;
	rep1(i, N) P[i] = -1;
	rep(i, K) {
		cin >> v >> p;
		P[v] = p;
	}

	sagasu(v);

	if (OK) {
		sagasu2(v, p - 1);
		co("Yes");
		rep1(i, N) co(kotae[i]);
	}
	else co("No");

	Would you please return 0;
}

Measured memory_bytes: 10880
/*
 ____________________________________________________________
|                                                            |
|                   Author: ay2306                           |
|____________________________________________________________|

*/
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define ord_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
const ll maxn = 1e5;
const ll inf = LLONG_MAX/2;
int main(){
    int n;
    cin >> n;
    V<ll> arr(n);
    loop(i,0,n)cin >> arr[i];
    int neg = 0;
    loop(i,0,n){
        if(arr[i] < 0)neg++;
        arr[i] = abs(arr[i]);
    }
    if(neg%2 == 1)cout << accumulate(all(arr),0*1LL) - 2*(*min_element(all(arr)));
    if(neg%2 == 0)cout << accumulate(all(arr),0*1LL);
    return 0;
}

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

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

    if( a == b || a == c || b == c) {
        if(((a == b) && (b == c))) {
            cout << "No" << endl;
            return 0;
        }
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,a[N],b[N],c[N];
bool vis[N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n;i++) scanf("%d",&b[i]);
    for(int i=1;i<n;i++) scanf("%d",&c[i]);
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(i-1>=1&&a[i-1]+1==a[i])
            ans+=c[a[i-1]];
        ans+=b[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int p[n];
  int mp;
  int mx = 0;
  for(int i = 0; i < n; ++i) {
    cin >> p[i];
    if(p[i] > mx) mx = p[i], mp = i;
  }
  
  int ans = 0;
  for(int i = 0; i < n; ++i) {
    if(i == mp) ans += p[i] / 2;
    else ans += p[i];
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define sll set<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define fo(i,n) for(i=0;i<n;i++)
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    #ifdef UJJWAL_HOME
        freopen("000.txt","r",stdin);
    #endif // UJJWAL_HOME

    ll n,i,j,k,t,q,a[51]={0};
    multiset<ll> m;
    cin>>n;

    fo(i,n)
    {
        cin>>a[i];
    }

    ll ans=0;
    while(true)
    {
        ll ma=0,b;
        fo(i,n)
        {
            if(ma<a[i])
            {
                ma=a[i];
                j=i;
            }
        }
        if(ma<n)
            break;

        b=ma/n;
        ans+=b;
        fo(i,n)
        {
            if(i==j)
                a[i]-=b*n;
            else
                a[i]+=b;
        }
    }

    cout<<ans;
    return 0;
}


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

char tolower(char c);
int main(){
  int count = 0;
  string W,str;
  cin >> W;
  while(1){
    cin >> str;
    if(str == "END_OF_TEXT") break;
    for(int i = 0;i < (int)str.size();i++){
      str[i] = tolower(str[i]);
    }
    if(str == W) count++;
  }
  cout << count << endl;
  return 0;
}

char tolower(char c){
  if('A' <= c && c <= 'Z'){
    return c - 'A' + 'a';
  }
  else return c;
}




Measured memory_bytes: 3124
import java.util.Scanner;

public class Main {

	public static boolean isSort(int[] list){
		for(int i=0;i<list.length-1;i++) {
			if(list[i] > list[i+1]) {
				return false;
			}
		}
		return true;
	}

	public static boolean Sort(int[] list){

		for(int i = list.length - 1;i>0;i--) {
			if(list[i] < list[i-1] ) {
				list[i-1] -= 1;
				if(list[i] < list[i-1]) {
					return false;
				}
			}
		}
		return true;
	}

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] array = new int[N];
		for(int i=0;i<N;i++) {
			array[i] = sc.nextInt();
		}
		if(isSort(array) || Sort(array)) {
			System.out.println("Yes");
		}else  {
			System.out.println("No");
		}


		sc.close();
	}

}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
//#define ll __int128
//#define int ll
//#define int ll
//#define char ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef MAX_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(4) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


void smain() {

    ll a, b, c;
    cin >> a >> b >> c;

    ll dif = 1e18 + 1000;

    vl kek = {a, b, c};

    sort(ALL(kek));
    do {
        ll a = kek[0], b = kek[1], c = kek[2];
        inmin(dif, abs((a / 2 - (a - a / 2)) * b * c));
    } while (next_permutation(ALL(kek)));
    cout << dif;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

string divide[4] = { "dream","dreamer","erase","eraser" };
int main()
{
	int n;
	cin >> n;
	vector<int> data(n);
	for (int i = 0; i < n; i++)
	{
		cin >> data.at(i);
	}
	int cnt = 1, type = 0;
	for (int i = 1; i < n; i++)
	{
		if (type == 0 && data.at(i) < data.at(i - 1))
		{
			type = 2;
		}
		else if (type == 0 && data.at(i) > data.at(i - 1))
		{
			type = 1;
		}
		else if (type == 2 && data.at(i) > data.at(i - 1))
		{
			type = 0;
			cnt++;
		}
		else if (type == 1 && data.at(i) < data.at(i - 1))
		{
			type = 0;
			cnt++;
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <math.h>

int main() {
	int bit, i, j , N, M, onoff, cont, acont = 0;
	int k[10], s[10][10], P[10];

	{ /*入力 */
		scanf("%d %d", &N, &M);
		for (i = 0; i < M; i++) {
			scanf("%d", &k[i]);
			for (j = 0; j < k[i]; j++) {
				scanf("%d", &s[i][j]);
			}
		}
		for (i = 0; i < M; i++) {
			scanf("%d", &P[i]);
		}
	}


	{ /* 計算 */
		for (bit = 0; bit < pow(2.0, (double)N); bit++) {
			for (i = 0; i < M; i++) {
				cont = 0;
				for (j = 0; j < k[i]; j++) {
					onoff = (bit >> (s[i][j] - 1)) % 2;
					cont += onoff;
				}
				if (cont % 2 != P[i]) break;
			}
			if (i == M)acont++;
		}
	}

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

	return 0;
}

Measured memory_bytes: 128