akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

long long int calc(long long int K, vector<long long int> &A) {
  long long int N = A.size();
  long long int mult = 1;
  long long int ans = 0;
  for (int i = 0; i < 42; i++) {
    long long int count = 0;
    for (int j = 0; j < N; j++) {
      if ((A[j] & mult) > 0) {
        count++;
      }
    }

    if ((K & mult) > 0) {
      ans += mult * max(count, N - count);
    } else {
      ans += mult * count;
    }
    mult <<= 1;
  }

  return ans;
}

int main() {
  long long int N, K;
  cin >> N >> K;

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

  long long int mult = 1;
  long long int best = calc(K, A);
  while (K >= mult) {
    if ((K & mult) == 0) {
      K -= mult;
      best = max(best, calc(K, A));
    }
    mult <<= 1;
  }

  cout << best << endl;

  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define DEBUG2(x, y) cerr << #x << ": " << x << " " << #y << ": " << y << "\n"
#define DEBUG3(x, y, z)                                                        \
  cerr << #x << ": " << x << " " << #y << ": " << y << " " << #z << ": " << z  \
       << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair< int, int >
#define ld long double
using namespace std;
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
#define SIGN(X) ((X) > 0) - ((X) < 0)
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vec< int > a(N);
  REP(i, N) cin >> a[i];
  int ans = 0;
  if (N == 1) {
    print(1);
  } else {
    vec< int > b;
    REP(i, N - 1) {
      int val = SIGN(a[i + 1] - a[i]);
      if (val != 0)
        b.pb(val);
    }
    if (b.size() == 0) {
      print(0);
    } else {

      int init = b[0];
      REP(i, (int)b.size() - 1) {
        if (init == 0) {
          //          DEBUG(i);
          init = b[i + 1];
          continue;
        } else if (init != b[i + 1]) {

          init = 0;
          ans++;
        }
      }
      print(ans + 1);
    }
  }
}

Measured memory_bytes: 2168
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;

int main(){
	int n, m;
	cin >> n >> m;
	vector<vector<char>> a(n, vector<char>(n));
	vector<vector<char>> b(n, vector<char>(m));
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cin >> a.at(i).at(j);
		}
	}
	for(int i = 0; i < m; i++){
		for(int j = 0; j < m; j++){
			cin >> b.at(i).at(j);
		}
	}
	// for(int i = 0; i < n; i++){
	// 	for(int j = 0; j < n; j++){
	// 		cout << a.at(i).at(j) << " ";
	// 	}
	// 	cout << endl;
	// }
	if(n == m){
		bool flag3 = true;
		for(int i = 0; i < n; i++){
			bool flag4 = false;
			for(int j = 0; j < n; j++){
				if(a.at(i).at(j) != b.at(i).at(j)){
					flag3 = false;
					flag4 = true;
				}
			}
			if(flag4){
				break;
			}
		}
		if(flag3){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
		return 0;
	}
	for(int i = 0; i < n - m; i++){
		for(int j = 0; j < n - m; j++){
			bool flag = true;
			for(int k = 0; k < m; k++){
				bool flag2 = false;
				for(int l = 0; l < m; l++){
					if(a.at(i + k).at(j + l) != b.at(k).at(l)){
						flag = false;
						flag2 = true;
						break;
					}
				}
				if(flag2){
					break;
				}
			}
			if(flag){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

int dp[100001][3];

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

int main() {
    int n;
    cin >> n;
    memset(dp, 0, sizeof(dp));

    int a[n][3];

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

    for (int i=0; i<n; i++) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    //for (int i=0; i<=n; i++) {
    //    cout << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << endl;
    //}

    int max = 0;
    chmax(max, dp[n][0]);
    chmax(max, dp[n][1]);
    chmax(max, dp[n][2]);
    cout << max << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
long gcd(long a,long b){
  long tmp = 0;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  if(a%b==0)return b;
  else return gcd(b,a%b);
}

int main(){
  int n;
  cin >> n;
  vector<long>a(n);
  int i;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  vector<long>left(n);
  vector<long>right(n);
  vector<long>gcdWoN(n);

  left[0] = a[0];
  right[n-1] = a[n-1];

  for(i=1;i<n;i++){
    left[i] = gcd(left[i-1],a[i]);
    right[n-1-i] = gcd(right[n-i],a[n-1-i]);
  }
  gcdWoN[0] = right[1];
  gcdWoN[n-1] = left[n-2];
  for(i=1;i<n-1;i++){
    gcdWoN[i] = gcd(left[i-1],right[i+1]);
  }

  long maxx = 0;
  for(i=0;i<n;i++){
    if(maxx<gcdWoN[i])maxx = gcdWoN[i];
  }
  cout << maxx << endl;

}


Measured memory_bytes: 3328
#include<iostream>
int main() {
	int b, d;
	int s[1];
	std::cin >> s[0] >> b >> s[1] >> d;

	if (s[0] > b) { s[0] = b; }
	if (s[1] > d) { s[1] = d; }

	std::cout << s[0] + s[1] << std::endl;

}

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

using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    while (true) {
        cnt += 1000;
        if (n <= cnt) {
            cout << cnt - n << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define gc getchar()
#define pc(x) putchar(x)
template<typename T> void scan(T &x){x = 0;register bool _=0;register T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){register bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;
using ll = long long;
const int MM = 1e5+5;

int n;
ll ans;
pair<int, int> a[MM];

#define lc (rt<<1)
#define rc (rt<<1|1)
#define nm ((nl+nr)>>1)

struct node{
    int maxl, minr;
} tree[MM*3];

inline void push_up(int rt){
    tree[rt].maxl = max(tree[lc].maxl, tree[rc].maxl);
    tree[rt].minr = min(tree[lc].minr, tree[rc].minr);
}

void build(int l = 1, int r = MM-1, int rt = 1){
    int nl = l, nr = r;
    if(l == r){
        tree[rt].maxl = 0, tree[rt].minr = 1e9+2;
        return;
    }
    build(l, nm, lc);
    build(nm+1, r, rc);
    push_up(rt);
}

void update(int l, int vl, int vr, int nl = 1, int nr = MM-1, int rt = 1){
    if(nl == nr){
        assert(nl == l);
        tree[rt].maxl = max(tree[rt].maxl, vl);
        tree[rt].minr = min(tree[rt].minr, vr);
        return;
    }
    if(l <= nm)
        update(l, vl, vr, nl, nm, lc);
    else
        update(l, vl, vr, nm+1, nr, rc);
    push_up(rt);
}

int query1(int l, int r, int nl = 1, int nr = MM-1, int rt = 1){
    if(r < nl || l > nr)
        return 0;
    if(l <= nl && r >= nr)
        return tree[rt].maxl;
    return max(query1(l, r, nl, nm, lc), query1(l, r, nm+1, nr, rc));
}

int query2(int l, int r, int nl = 1, int nr = MM-1, int rt = 1){
    if(r < nl || l > nr)
        return 1e9+2;
    if(l <= nl && r >= nr)
        return tree[rt].minr;
    return min(query2(l, r, nl, nm, lc), query2(l, r, nm+1, nr, rc));
}

int main(){
    
    scan(n);
    
    for(int i = 1,l,r; i <= n; i++){
        scan(l, r);
        ans = max(ans, (r-l+1LL));
        a[i].first = l, a[i].second = r;
    }
    
    sort(a+1, a+n+1);
    build();
    
    for(int i = 1; i <= n; i++){
        update(i, a[i].first, a[i].second);
    }
    
    for(int i = 2; i <= n; i++){
        ll l1 = query1(1, i-1), r1 = query2(1, i-1);
        ll l2 = query1(i, n), r2 = query2(i, n);
        ans = max(ans, max(0LL, r1-l1+1) + max(0LL, r2-l2+1));
        //print(i, l1, r1, l2, r2);
        
        if(i == n) continue;
        ll t = a[i].second-a[i].first+1;
        l1 = max(query1(1, i-1), query1(i+1, n));
        r1 = min(query2(1, i-1), query2(i+1, n));
        t += max(0LL, r1-l1+1);
        ans = max(ans, t);
    }
    
    print(ans);
    
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
ll inf = 1e10;

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> c(n-1), s(n-1), f(n-1);
  rep(i, n-1) cin >> c[i] >> s[i] >> f[i];
  rep(i, n-1){
    int time = s[i]+c[i];
    for(int j = i+1; j <= n-2; ++j){
      int k = max(0, (time-s[j]+f[j]-1)/f[j]);
      time = k*f[j] + s[j] + c[j];
    }
    cout << time << "\n"; 
  }
  cout << 0 << "\n";
}  

Measured memory_bytes: 256
from statistics import median
from operator import itemgetter
N = int(input())
x = list(map(int, input().split()))
x_ = sorted(x)
m0 = median(x_[1:])
m1 = median(x_[:-1])
for i in x:
    if m1 >= i:
        print(m0)
    else:
        print(m1)
    


Measured memory_bytes: 34284
// NOT MY CODE
#include <map>
#include <iostream>
using namespace std;
typedef pair<string,string> pa;
int main() {
    int n;
    long long ans = 0;
    string s;
    map<pa,int> mp;
    cin>>n>>s;
    for(int i = 0;i < 1 << n;i ++) {
        string a = "";
        string b = "";
        for(int j = 0;j < n;j ++) {
            if(i >> j & 1)a += s[j];///二进制位为1 属于a串
            else b += s[j];///二进制位为0 属于ra串
        }
        mp[pa(a,b)] ++;///记录状态个数
    }
    for(int i = 0;i < 1 << n;i ++) {
        string a = "";
        string b = "";
        for(int j = 0;j < n;j ++) {
            if(i >> j & 1)a += s[n * 2 - 1 - j];///二进制位为1 属于a串
            else b += s[n * 2 - 1 - j];///二进制位为0 属于ra串
        }
        ans += mp[pa(a,b)];///加上匹配的状态个数
    }
    cout<<ans;
}

Measured memory_bytes: 91904
#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 k, x;
  cin >> k >> x;

  if (500 * k >= x) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Math;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().ToCharArray();
            var ans  = s.Where((x,i) => i<s.Count()-2).Select(x => x.ToString()).Select((x,i)=> (x+s[i+1]+s[i+2])).Select(x=> Abs(int.Parse(x)-753)).ToList();

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


Measured memory_bytes: 13396
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[200000];
		int b[] = new int[200000];
		int tmp[] = new int[200000];
		long ans = 0;

		for(int i = 0 ; i < n ; i++){
			a[i] = sc.nextInt();
		}
		for(int i = 0 ; i < n ; i++){
			b[i] = sc.nextInt();
			tmp[i] = b[i];
		}

		Boolean changed = true;
		int cnt = 0;

		while(changed){
			changed = false;
			if(b[0] > b[1] + b[n-1]){
					cnt = (tmp[0]-a[0]) / (b[1]+b[n-1]);
					tmp[0] -= (b[1]+b[n-1])*cnt;
					ans += cnt;
					if(cnt >= 1){
						changed = true;
					}
			}
			for(int i = 1 ; i < n-1 ; i++){
				if(b[i] > b[i+1] + b[i-1]){
						
						cnt = (tmp[i]-a[i]) / (b[i+1]+b[i-1]);
						tmp[i] -= (b[i+1]+b[i-1])*cnt;
						ans += cnt;
						if(cnt >= 1){
							changed = true;
						}
				}
			}
			if(b[n-1] > b[0] + b[n-2]){
					cnt = (tmp[n-1]-a[n-1]) / (b[0]+b[n-2]);
					tmp[n-1] -= (b[0]+b[n-2])*cnt;
					ans += cnt;
					if(cnt >= 1){
						changed = true;
					}
			}

			for(int i = 0 ; i < n ; i++){
				b[i] = tmp[i];
			}
		}

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

		System.out.println(ans);
	}

}

Measured memory_bytes: 105488
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;
 
#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  ll x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

class Edge{
  public:
  ll l,r,cost;
};

//非再帰抽象セグ木 0-indexed 単位元はiで指定
template <class T>
class SegmentTree {
 private:
  long long n;
  T init;
  std::vector<T> dat;
  std::function<T(T, T)> fn;

 public:
  SegmentTree(long long i, T para, std::function<T(T, T)> fun)
      : init(para), fn(fun) {
    n = 1;
    while (n < i) {
      n *= 2;
    }
    dat = std::vector<T>(2 * n - 1, init);
  }

  // k番目(0-indexed)を値aで更新,dest=trueのときは更新前を破壊して初期化する
  void update(long long k, T a, bool dest) {
    k += n - 1;
    if (dest)
      dat[k] = a;
    else
      dat[k] = fn(dat[k], a);

    while (k > 0) {
      k = (k - 1) / 2;
      dat[k] = fn(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }

  T query(long long a, long long b){
    assert(0<=a&&b<=n);
    T val=init;

    long long l=a+n-1,r=b+n-1;
    for(;l<r;l=(l>>1),r=(r>>1)){
      if(!(r&1)){
        r--;
        val=fn(val,dat[r]);
      }
      if(!(l&1)){
        val=fn(val,dat[l]);
        l++;
      }
    }

    return val;
  }
};
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  ll n,m;
  std::cin>>n>>m;

  const ll MAX=1e16;

  std::vector<Edge> edge(m);
  rep(i,0,m){
    ll l,r,c;
    std::cin>>l>>r>>c;
    l--;r--;
    edge[i]={l,r,c};
  }

  std::sort(all(edge),[](Edge t1,Edge t2){
    return t1.r<t2.r;
  });

  ll itr=0;

  SegmentTree<ll> seg(n+2,MAX,[](ll a,ll b){return std::min(a,b);});

  seg.update(0,0,true);

  rep(i,1,n){
    while(itr!=m&&edge[itr].r==i){
      seg.update(i,seg.query(edge[itr].l,edge[itr].r)+edge[itr].cost,false);
      
      itr++;
    }
  }

  if(seg.query(n-1,n)==MAX)std::cout<<-1;
  else std::cout<<seg.query(n-1,n);

  return 0;
}

Measured memory_bytes: 4608
#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() {
	string n;
	cin >> n;
	string ans = "No";
	if ((n[0] == n[1] && n[2] == n[1]) ||
		  (n[1] == n[2] && n[3] == n[2])){
		ans = "Yes";
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3572
#include <stdio.h>

int main(void){
	int N;
	scanf("%d",&N);
	int C[N-1],S[N-1],F[N-1],i,ans,j;
	for(i=0;i<N-1;i++){
		scanf("%d %d %d",&C[i],&S[i],&F[i]);
	}
	for(i=0;i<N;i++){
		ans = 0;
		for(j=i;j<N-1;j++){
			if(ans < S[j])	ans = S[j];
			else if(ans%F[j] == 0);
			else ans += F[j] - (ans%F[j]);
			ans += C[j];
		}
		printf("%d\n",ans);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int A,B,C;
    cin>>A>>B>>C;
    if (A!=B&&B!=C&&C!=A or A==B&&B==C&&C==A)
        cout<<"No"<<endl;

    else
        cout<<"Yes"<<endl;
    
    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int a[225816],b[225816];

int main(void){
	int n,k,i,j;
	bool flag;
	std::cin >> n >> k;
	for(i=0; i<n; ++i){
		std::cin >> a[i];
	}
	for(j=0; j<k; ++j){
		for(i=0; i<n; ++i){
			b[i] = 0;
		}
		for(i=0; i<n; ++i){
			++b[std::max(i-a[i],0)];
			--b[std::min(i+a[i]+1,n)];
		}
		for(i=0; i<n; ++i){
			b[i+1] += b[i];
		}
		flag = true;
		for(i=0; i<n; ++i){
			a[i] = b[i];
			if(a[i]<n){
				flag = false;
			}
		}
		if(flag){
			break;
		}
	}
	for(i=0; i<n; ++i){
		std::cout << (i?" ":"") << a[i]; 
	}
	std::cout << std::endl;
	return 0;
}


Measured memory_bytes: 5176
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=998244353;
#define N 400

ll dp[N][N*N*2];
int a[N];
ll inv[N];
void calc_inv(){
    inv[1]=1;
    rep2(i,2,N-1){
        inv[i]=((-(MOD/i)*inv[MOD%i])%MOD+MOD)%MOD;
    }
    return;
}
ll dp2[N][N*N];
main(){
    int n=in();
    calc_inv();
    rep(i,n){
        a[i]=in();
    }
    dp[0][0]=1;
    ll ans=1,sum=0;
    rep2(i,0,n-1){
        ans=ans*3%MOD;
        sum+=a[i];
        rep(j,sum+1){
            dp[i+1][j+a[i]]=(dp[i+1][j+a[i]]+dp[i][j])%MOD;
            dp[i+1][j]=(dp[i+1][j]+2*dp[i][j])%MOD;
        }
    }
    /*rep2(i,0,sum){
        cout<<i<<" "<<dp[n][i]<<endl;
    }
    */
    rep2(i,(sum+1)/2,sum){
        ans=(ans+MOD-dp[n][i]*3ll%MOD)%MOD;
    }
    dp2[0][0]=1;
    rep(i,n){
        rep(j,sum+1){
            dp2[i+1][j+a[i]]=(dp2[i+1][j+a[i]]+dp2[i][j])%MOD;
            dp2[i+1][j]=(dp2[i+1][j]+dp2[i][j])%MOD;
        }
    }
    if(!(sum%2))
    ans=(ans+dp2[n][sum/2]*3ll%MOD)%MOD;
    cout<<ans;
}

Measured memory_bytes: 1008128
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

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

	map<string, int> cnt;
	for(int i=0; i<N; i++) cnt[S[i]]++;

	int n_max = 0;
	for(auto p: cnt){
		n_max = max(n_max, p.second);
	}

	for(auto p: cnt){
		if(p.second==n_max) cout << p.first << endl;
	}

	return 0;
}


Measured memory_bytes: 26752
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <cmath>
#include <stdio.h>
#include <sstream>
#define int_inf 1000000000 //1e9
#define ll_inf  1000000000000000000 //1e18
using namespace std;
template <typename T> std::string to_string(const T& t){
	std::ostringstream os; os<<t; return os.str();
}

int main(){
	int a, b;
	cin>>a>>b;
	if(a%3==0 || b%3==0 || (a+b)%3==0) cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define vll vector<long long>
#define mll map<long long,long long>
#define pb push_back
typedef  long long ll;
typedef long double ld;
long double pi=3.14159265358979323846;

vll al[500005];
ll vis[500005],color[500005],I[101][101];

ll gcd(ll a,ll b)
{
    if (b==0) return a;
    return gcd(b,a%b);
}

bool isPrime(int n)
{
    if (n<=1) return false; 
    if (n<=3) return true; 
    if (n%2==0||n%3==0) return false; 
    for (int i=5;i*i<=n;i=i+6) if (n%i==0||n%(i+2)==0) return false; 
    return true; 
}

ll bpow(ll n, ll po)
{
	ll res=1;
	while(po>0)
	{
		if(po%2)
		{
			res*=n;
			po--;
		}
		else
		{
			n*=n;
			po/=2;
		}
	}
	return res;
}

ll binpow(ll n, ll po, ll mod)
{
	ll res=1;
	while(po>0)
	{
		if(po%2)
		{
			res=(res*n)%mod;
			po--;
		}
		else
		{
			n=(n*n)%mod;
			po/=2;
		}
	}
	return res;
}

ll swap(ll a, ll b)
{
	a=a+b;
	b=a-b;
	a=a-b;
}

ll fact(ll n) { 
   if ((n==0)||(n==1))
      return 1;
   else
      return n*fact(n-1);
}

ll C(ll n, ll r) {
    if(r > n - r) r = n - r; 
    ll ans = 1;
    ll i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
        ans=ans%1000000007;
    }

    return ans;
}

//bool bipartite_dfs(ll node, ll flag)
//{
//	vis[node]=1;
//	ll cflag=flag;
//	color[node]=cflag;
//	for(ll child : al[node])
//	{
//		if(!vis[child])
//		{
//			bool n=bipartite_dfs(child,1-cflag);
//			if(n==false) return false;
//		}
//		else if(color[child]==color[node]) return false;
//	}
//	return true;
//}

void mmul(ll A[][101], ll B[][101], ll dim)
{
	ll res[dim][dim];
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++)
	{
		res[i][j]=0;
		for(ll k=0;k<dim;k++) res[i][j]=(res[i][j]+A[i][k]*B[k][j])%1000000007;
	}
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++) A[i][j]=res[i][j];
}

void mpow(ll A[][101],ll dim, ll po)
{
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++)
	{
		if(i==j) I[i][j]=1;
		else I[i][j]=0;
	}
	while(po>0)
	{
		if(po%2==1)
		{
			mmul(I,A,dim);
			po--;
		}
		else
		{
			mmul(A,A,dim);
			po/=2;
		}
	}
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++) A[i][j]=I[i][j];
}


int main()
{
	ll n,m,x;
	cin>>n>>m>>x;
	ll c[n],a[n][m],sum[m];
	for(ll i=0;i<m;i++) sum[i]=0;
	for(ll i=0;i<n;i++)
	{
		cin>>c[i];
		for(ll j=0;j<m;j++)
		{
			cin>>a[i][j];
			sum[j]+=a[i][j];
		}
	}
	ll flag=0;
	for(ll i=0;i<m;i++) if(sum[i]<x) flag=1;
	if(flag) cout<<-1;
	else
	{
		ll p=1,ans=1000000000;
		p=p<<n;
		for(ll i=0;i<p;i++)
		{
			ll money=0;
			for(ll j=0;j<m;j++) sum[j]=0;
			for(ll j=0;j<n;j++)
			{
				ll q=1;
				q=q<<j;
				if((i&q)!=0)
				{
					for(ll k=0;k<m;k++)
					{
						sum[k]+=a[j][k];
					}
					money+=c[j];
				}
			}
			ll g=0;
			for(ll j=0;j<m;j++)
			{
				if(sum[j]<x) g=1;
			}
			if(g==0)
			{
				if(ans>money) ans=money;
			}
		}
		cout<<ans;
	}
}

Measured memory_bytes: 15388
a,b = map(int,input().split())
if a <= 0 and b >= 0:
    print('Zero')
elif a > 0 and b > 0:
    print('Positive')
else:
    if (abs(a-b)+1) % 2 == 1:
        print('Negative')
    else:
        print('Positive')

Measured memory_bytes: 3060
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main {
  while (true) {
    int n, m;
    cin >> n >> m;
    if (n == 0 && m == 0) break;
    auto v = vectors(m, 1262, 0LL);
    int r;
    cin >> r;
    while (r--) {
      int j, gomi, i, s;
      cin >> j >> gomi >> i >> s;
      v[--i][j] += s ? 1 : -1;
    }
    rep(i, m) loop(j, 1, 1262) v[i][j] += v[i][j - 1];
    int q;
    cin >> q;
    while (q--) {
      int l, r, i;
      cin >> l >> r >> i;
      --i;
      int ans = 0;
      loop(j, l, r) ans += v[i][j] > 0;
      cout << ans << endl;
    }
  }
}



Measured memory_bytes: 98712
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

using lint = long long;

lint N, K;
array<lint, 100000> A;
int main()
{
    cin >> N >> K;
    REP(i, N) scanf("%lld", &A[i]);
    lint gcd = A[0];
    REP(i, N - 1) gcd = __gcd(gcd, A[i + 1]);
    sort(A.begin(), A.begin() + N);
    if (!(A[N - 1] >= K && (A[N - 1] - K) % gcd == 0)) cout << "IM";
    cout << "POSSIBLE" << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
main(){std::string t;int i,n[4]={0,0,0,0};for(;std::cin>>t;){t=t.substr(t.find(",")+1);i=0;if(t=="B")i=1;if(t=="AB")i=2;if(t=="O")i=3;n[i]++;}for(i=0;i<4;i++)std::cout<<n[i]<<"\n";}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
    int a[200000];
    
    int N;
    cin >> N;

    for (int i = 0; i < N; i++)
        cin >> a[i];

    sort(a, a + N);

    int cnt = 0;
    for (int i = 0; i < N - 1; i++)
        if (a[i] == a[i + 1])
            cnt++;

    if (cnt > 0)
        cout << "NO";
    if (cnt == 0)
        cout << "YES";
}

Measured memory_bytes: 4384
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;


int main(){
  int n;
  cin >>n;
  ll a[n+1];
  rep(i,n)cin >> a[i];
  ll ans=1000;
  ll stock=0;
  a[n]=0;

  int i=0;
  int f=0;
  while(i!=n){
    if(a[i]<a[i+1]){
      stock=ans/a[i];
      ans=ans%a[i];
      while(a[i]<a[i+1]){i++;}
      ans=ans+stock*a[i];
      stock=0;
    }else{i++;}
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;
using pll = pair<ll, ll>;

int main(){
  int n;
  ll d, a;
  cin >> n >> d >> a;
  vector<pll> xh(n);
  for(int i = 0; i < n; ++i){
  	cin >> xh[i].first >> xh[i].second;
  }

  sort(xh.begin(), xh.end());
  ll total = 0;
  queue<pll> que;
  ll ans = 0;
  for(int i = 0; i < n; ++i){
  	ll x = xh[i].first;
  	ll h = xh[i].second;
  	while(que.size() && que.front().first < x){
  		total -= que.front().second;
  		que.pop();
  	}
  	h -= total;
  	if(h > 0){
  		ll num = (h + a - 1) / a;
  		ans += num;
  		ll damage = num * a;
  		total += damage;
  		que.emplace(x + 2*d, damage);
  	}
  }

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


Measured memory_bytes: 7992
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>

// namespace
using namespace std;

// int mcm(const vector<int> &p, int i, int j) { // i-th matrix has the size (p[i], p[i+1])
//     if (i == j) return 0;
//     int m = INT_MAX;
//     for (int k = i; k < j; ++k) {
//         m = min(m, mcm(p, i, k) + mcm(p, k + 1, j) + p[i] * p[k + 1] * p[j + 1]);
//     }
//     return m;
// }

// int mcm(const vector<int> &p, int i, int j, vector<vector<int>> &dp) { // i-th matrix has the size (p[i], p[i+1])
//     if (i == j) return 0;
//     if (dp[i][j] < INT_MAX) return dp[i][j];
//     int m = INT_MAX;
//     for (int k = i; k < j; ++k) {
//         m = min(m, mcm(p, i, k, dp) + mcm(p, k + 1, j, dp) + p[i] * p[k + 1] * p[j + 1]);
//     }
//     return dp[i][j] = m;
// }

int mcm(const vector<int> &p) { // i-th matrix has the size (p[i], p[i+1])
    int n = p.size() - 1;
    vector<vector<int>> dp(n, vector<int>(n, INT_MAX));
    for (int i = 0 ; i < n; ++i) dp[i][i] = 0;
    for (int l = 1; l < n; ++l)
        for (int i = 0, j; (j = i + l) < n; ++i)
            for (int k = i; k < j; ++k)
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + p[i] * p[k + 1] * p[j + 1]);
    return dp[0][n-1];
}

int main() {
    int n, r, c;
    cin >> n;
    vector<int> p;
    for (int i = 0; i < n; ++i) {
        cin >> r >> c;
        p.push_back(r);
    }
    p.push_back(c);
    auto ans = mcm(p);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3152
import java.util.*;

public class Main {
	
	
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[][] s = new char[n][10];
		HashMap<String,Long> h = new HashMap<>();
		long ans=0;
		
		for(int i=0;i<n;i++) {
			s[i] = sc.next().toCharArray();
			Arrays.parallelSort(s[i]);
			String st = String.valueOf(s[i]);
			if(h.containsKey(st)) {
				long temp = h.get(st);
				ans+=temp;
				h.put(st,temp+1);
			}else h.put(st,(long)1);
			

		}
		
		System.out.println(ans);
		sc.close();
	}
		


}


Measured memory_bytes: 62756
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;

int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<< max(a*b,c*d) <<endl;
}


Measured memory_bytes: 256
line = gets.chomp.split(' ')
n = line[0].to_i
max = line[1].to_i

min = 100000

for i in 1..n
  d_one = gets.to_i
  max -= d_one
  if (d_one < min)
    min = d_one
  end
end

puts n + max/min

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef long long ll;

int main(void){
	int n;
	cin >> n;
	double a[n];
	rep(i, n) cin >> a[i];

	double sum = 0;
	rep(i, n) {
		sum += 1.0 / a[i];
	}
	cout << 1.0 / sum << endl;

	return 0;
}


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

int main() {
	int n;
	while (cin >> n, n) {
		vector<int> a(n);
		for (int& i : a) cin >> i;
		sort(a.begin(), a.end());
		int ans = INT_MAX;
		for (int i = 1; i < n; ++i) ans = min(a[i] - a[i - 1], ans);
		cout << ans << endl;
	}
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
#include<boost/multiprecision/cpp_int.hpp>
using Int=boost::multiprecision::cpp_int;

struct modint{
    using i64=int_fast64_t;
    i64 a;
    static constexpr i64 MOD=1e9+7;
    modint(){a=0;}
    modint(i64 a_){
        a=a_%MOD;
        if(a<0) a+=MOD;
    }
    modint inv()const{
        i64 n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y;
        y.a=n;
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y;
        y.a=a+x.a;
        if(y.a>MOD) y.a-=MOD;
        return y;
    }
    modint operator-(const modint& x){
        modint y;
        y.a=a-x.a;
        if(y.a<0) y.a+=MOD;
        return y;
    }
    modint operator*(const modint& x){
        modint y;
        y.a=(a*x.a)%MOD;
        return y;
    }
    modint operator/(const modint& x){
        modint y;
        y.a=(a*x.inv().a)%MOD;
        return y;
    }
    modint& operator+=(const modint& x){
        a+=x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint& operator-=(const modint& x){
        a-=x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    modint& operator*=(const modint& x){
        (a*=x.a)%=MOD;
        return *this;
    }
    modint& operator/=(const modint& x){
        (a*=x.inv().a)%=MOD;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    int_fast64_t a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(int_fast64_t a,int_fast64_t b){
    modint _;
    int_fast64_t n=1,A=a;
    while(b){
        if(b&1) (n*=A)%=modint::MOD;
        (A*=A)%=modint::MOD;
        b>>=1;
    }
    _.a=n;
    return _;
}

Int gcd(Int n,Int m){
    if(n>m) swap(n,m);
    while(n){
        m%=n;
        swap(n,m);
    }
    return m;
}


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    in>>n;
    vector<int> a(n);
    for(auto&i:a) in>>i;
    Int lcm{1};
    fr(i,n) lcm*=(Int)a[i]/gcd((Int)a[i],lcm);
    lcm%=1000000007;
    modint ans{};
    fr(i,n) ans+=modint(a[i]).inv();
    ans*=(int)lcm;
    cout<<ans<<endl;
}

Measured memory_bytes: 384
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int T;
	int n=5;
	int[][] a;

	void run(){
		T=sc.nextInt();
		for(int k=0; k<T; k++){
			a=new int[n][n];
			for(int j=0; j<n; j++){
				for(int i=0; i<n; i++){
					a[j][i]=sc.nextInt();
				}
			}
			solve();
		}
	}

	void solve(){
		int max=0;
		for(int y=0; y<n; y++){
			for(int x=0; x<n; x++){
				for(int w=1; w<=n; w++){
					for(int h=1; h<=n; h++){
						// [x, x+w)*[y, y+h)
						boolean ok=true;
						for(int j=y; j<y+h; j++){
							if(j>=n){
								ok=false;
								break;
							}
							for(int i=x; i<x+w; i++){
								if(i>=n){
									ok=false;
									break;
								}
								ok&=a[j][i]==1;
							}
						}
						if(ok){
							max=max(max, w*h);
						}
					}
				}
			}
		}
		println(max+"");
	}

	void debug(Object... os){
		System.err.println(deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}

}

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int w,h;
	cin >> w >> h;
	int x,y,t;
	int n;
	cin >> n;
	int l0=0,l1=w,h0=0,h1=h;
	while(n--){
		cin >> x >> y >> t;
		if(t == 1){
			l0 = max(l0,x);
		}
		else if(t == 2){
			l1 = min(l1,x);
		}
		else if(t == 3){
			h0 = max(h0,y);
		}
		else{
			h1 = min(h1,y);
		}
	}
	int sum = (l1 >= l0 && h1 >= h0 ? (l1 - l0) * (h1 - h0 ): 0);
	cout << sum << '\n';
}


Measured memory_bytes: 256
/*  HARD WORK FOREVER PAYS  */
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define turbo(){	\
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
}
using namespace std;
typedef long long ll;
typedef pair<int,pair<int,int>> PII;
int main() 
{ 
	turbo();
	long long n,i=0;
	cin>>n;
	if(n%11==6){
		i=1;
	}
	cout<<(long long)ceil(((n/11.0)*2))-i<<endl;
    return 0; 
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdlib.h>
#include <vector>
typedef long long unsigned int ll;
using namespace std;

int main() {
    int n;
    cin>>n;
    int a[200005];
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]-=(i+1);
    }
    sort(a,a+n);
    int b;
    ll sum=0;
    
    if(n%2!=0){
        b=a[(n+1)/2-1];
        for(int i=0;i<n;i++){
            sum+=abs(a[i]-b);
        }
        cout<<sum<<endl;
    }
    else{
        b=a[n/2];
        
        for(int i=0;i<n;i++){
            sum+=abs(a[i]-b);
        }
        
        cout<<sum<<endl;
    }
    
    return 0;
    
}


Measured memory_bytes: 1024
#include<stdio.h>
int min(int a, int b)
{
	if (a < b)
		return a;
	else
		return b;
}
int main()
{
	int h, n;
	scanf("%d %d", &h, &n);
	int i, j;
	int a[1003], b[1003];
	for (i = 0; i < n; i++)
		scanf("%d %d", &a[i], &b[i]);
	int dp[10004];
	for (i = 0; i < 10004; i++)
		dp[i] = 1000000009;
	dp[0] = 0;
	for (i = 0; i < n; i++)
		for (j = 0; j < h; j++)
			dp[min(h, j + a[i])] = min(dp[min(h, j + a[i])], dp[j] + b[i]);
	printf("%d\n", dp[h]);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll d, n;
    cin >> d >> n;

    ll p = 1;
    rep(i, d) {
        p *= 100;
    }

    if(n == 100) {
        out((n+1)*p);
    }
    else {
        out(n*p);
    }
    
    re0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,a,b=1001,c=0,i;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		if(a<b)
			b=a;
		if(a>c)
			c=a;
	}
	printf("%d",c-b);
	return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;

constexpr int INF = 1e9;
constexpr ll BIGINF = 1e18;
constexpr double EPS = 1e-16;
constexpr int MOD = 1e9 + 7;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

int n;
int r;

void input() {
  cin >> n >> r;
}

void solve() {
  int ans = r;

  if (n < 10)
    ans = r + 100 * (10 - n);

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

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

  preambule();

  int t = 1;
//  cin >> t;

#ifdef _DEBUG
  t = 2;
#endif

  while (t--) {
    input();
    solve();
  }
}


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

int main() {
  int N, K;
  cin >> N >> K;
  
  int count = 0;
  
  while (N > 0) {
    N /= K;
    count++;
  }
  
  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n = int(input())

a = make_divisors(n-1)
ans = len(a)-1
b = make_divisors(n)[1:]
c=[]
for num in b:
    d = n
    while(d%num==0):
        d = d / num
    if(d%num==1):
        c.append(num)
ans += len(c)
print(ans)

Measured memory_bytes: 3188
// abc053d: Card Eater
#include <stdio.h>

#define upto(i,s,e,d) for(int i=(s);i<=(e);i+=(d))
#define in(n) scanf("%d",n)
#define out(d) printf("%d\n",d)

#define MAX 100000
int b[MAX+1];// set cards (check bits : init all 0)

int main(){
  int n;in(&n);// n is odd!!

  int c=0;
  upto(i,0,n-1,1){
    int a;in(&a);
    if(b[a]==0){
      b[a] = 1;// seting a card (bit on)
      c++;
    }
  }

  // n is odd = set cards is odd + remaining cards is even -> delete a set card
  out(c%2? c: c-1);

  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long

ll n;

int main(){
  scanf("%lld",&n);
  ll ans = n*(n+1)*(n+2)/6;
  ll u,v;
  
  for(int i=0;i<n-1;i++){
    scanf("%lld%lld",&u,&v);
    if(u<v){
      ans -= u*(n-v+1);}
    else{
      ans -= v*(n-u+1);}
    //printf("%lld\n",ans);
  }

  
  
  
  
  printf("%lld\n",ans);
  
  return 0;
}


Measured memory_bytes: 1716
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

i64 calc(i64 n)
{
    i64 cnt = (n + 1) / 2;
    i64 ret = cnt % 2;
    if (n % 2 == 0)
        ret ^= n;
    return ret;
}

int main()
{
    i64 a, b;
    cin >> a >> b;
    cout << (calc(a - 1) ^ calc(b)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int p,q,r,a,b,c;
	cin >> p >> q >> r;
	a = p+q;
	b = q+r;
	c = r+p;
	int l = a<b? a:b;
	int m = l<c?l:c;
	cout << m << endl;
}


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

int main(){
  char s[19];
  cin >> s;
  for (int i=0; i < 19; i++) {
    if (s[i] == ',') {
      cout << ' ';
    } else {
      cout << s[i];
    }
  }
  cout << endl;
  return 0;
}


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

def main():
  if 0 in A:
    print(0)
    return
 
  count = 1
  for i in A:
    count *= i
    if count > 1e18:
      print(-1)
      return
 
  print(count)

main()


Measured memory_bytes: 21660
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  int b=0;
  cin>>a;
  if(a[0]==a[1]&&a[1]==a[2]) cout<<"Yes";
  else {
    if(a[1]==a[2]&&a[2]==a[3]) cout<<"Yes";
    else cout<<"No";
  }
  cout<<"\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include "stdc++.h"
using namespace std;
 
#define int long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
int MOD=1000000007;


int32_t main(){
  int n,m;
  cin>>n>>m;
  int p[m];
  string s[m];
  unordered_map<int,int> mp;
  unordered_set<int> mp2;
  for(int i=1;i<=n;++i){
    mp[i]=0;
  }
  int corr=0,pen=0;
  for(int i=0;i<m;++i){
    cin>>p[i];
    cin>>s[i];
    if(s[i]=="WA"){
      mp[p[i]]++;
    }
    else if(mp2.find(p[i])==mp2.end()){
      pen+=mp[p[i]];
      corr++;
      mp2.insert(p[i]);
    }
  }
  cout<<corr<<" "<<pen<<'\n';


}

Measured memory_bytes: 14756
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long llong;
int f(int n) {
  if (n % 2 == 0)
    return n / 2;
  else
    return 3 * n + 1;
}
int main() {
  int s;
  cin >> s;
  set<int> a;
  int x = s;
  while (a.count(x) == 0) {
    a.insert(x);
    x = f(x);
  }
  cout << a.size() + 1 << endl;
  return 0;
}

Measured memory_bytes: 256
N, *L = map(int, open(0).read().split())
red = []
blue = []
for a, b in zip(*[iter(L[:2*N])]*2):
  red += [(a,b)]
for c, d in zip(*[iter(L[2*N:])]*2):
  blue += [(c,d)]
red.sort(reverse=True)
blue.sort(reverse=True)
S = set(range(N))

ans = 0
for a,b in red:
  k = -1
  m = 10**3
  for j, n in enumerate(blue):
    c,d = n
    if c<a:
      break
    if d-b>0 and d-b<m and j in S:
      k = j
      m = d-b
  if k!=-1:
    ans += 1
    S.remove(k)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


bool cmp(pair<int,int>p,pair<int,int>q) {
    // return p.first>q.first;//descending by first
    // return p.first<q.first;//ascending by first
    // return p.second>q.second;//descending by second
    return p.second<q.second;//ascending by second
}

// bool cmp(int p,int q) {
    // return p>q;//descending
    // return p<q;//ascending
// }


int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    lli n;
    cin>>n;
    double p=n/3.0;
    p=p*p*p;
    cout<<fixed<<setprecision(6)<<p<<endl;

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

Measured memory_bytes: 3772