akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-10;

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}

ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};
// ll pas[5001][5002];

template <class Abel> class BIT {
	using OP = std::function<Abel(Abel, Abel)>;

  private:
	int n;
	std::vector<Abel> dat;
	OP op;
	Abel e;

  public:
	BIT(int n, OP op, Abel e = 0) : n(n), op(op), e(e) {
		dat.resize(n + 1);
		for (int i = 0; i <= n; ++i) {
			dat[i] = e;
		}
	}
	void add(int k, Abel val) {
		while (k <= n) {
			dat[k] = op(val, dat[k]);
			k += k & -k;
		}
	}
	Abel acum(int k) {
		Abel sum = e;
		while (k > 0) {
			sum = op(sum, dat[k]);
			k -= k & -k;
		}
		return sum;
	}
};

int main() {
	IOS();
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n), b(n + 1), d(n + 1);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll sum = 0;
	b[0]   = 0;
	for (int i = 1; i <= n; i++) {
		sum += a[i - 1];
		b[i] = sum - i * k;
	}
	vector<ll> c = b;
	sort(c.begin(), c.end());
	for (int i = 0; i <= n; i++) {
		d[i] = lower_bound(c.begin(), c.end(), b[i]) - c.begin() + 1;
	}
	ll ans = 0;

	function<ll(ll, ll)> f = [](ll i, ll j) { return i + j; };
	BIT<ll> bit(n + 1, f, 0);

	for (int i = 0; i <= n; i++) {
		ll tmp = bit.acum(d[i]);
		// dump(b[i]);
		ans += tmp;
		bit.add(d[i], 1);
	}

	dump(ans);
	return 0;
}

Measured memory_bytes: 8064
# 割り切る数は、Aの総和の約数である
# 約数について大きい順にすべて試して、当てはまるものがあれば答え

# 8,20を7の倍数に近づけるとき、
# 8 -> mod 7が1であり、-1か+6で7の倍数になる
# 20 -> mod 7が6であり、-6か+1で7の倍数になる
# 負の和と正の和が一致したとき、そのときの絶対値が答え
# 1,1,2,3,4,5と並べて、前から足していくのが最善。入れ替えると絶対値が増加するので損しかしない

import sys
readline = sys.stdin.readline

N,K = map(int,readline().split())
A = list(map(int,readline().split()))

all = sum(A)
divisors = []
for i in range(1,int(all ** 0.5) + 1):
  if all % i == 0:
    divisors.append(i)
    divisors.append(all // i)

divisors = sorted(divisors,reverse = True)

for d in divisors:
  mods = [0] * (N)
  for i in range(len(A)):
    mods[i] = A[i] % d
  mods = sorted(mods)
  mods_front = [0] * N
  mods_front[0] = mods[0]
  for i in range(1,N):
    mods_front[i] = mods_front[i - 1] + mods[i]
  mods_back = [0] * N
  mods_back[-1] = d - mods[-1]
  for i in range(N - 2,-1,-1):
    mods_back[i] = mods_back[i + 1] + (d - mods[i])
  for i in range(N - 1):
    if mods_front[i] == mods_back[i + 1]:
      if K >= mods_front[i]:
        print(d)
        exit(0)
else:
  print(1)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

map<lli,lli> cnt;

map<lli,lli> makePrimeList2(lli n){
	map<lli,lli> m;
	lli a = 2;
	while(n>=a*a){
		if(n%a==0){
			m[a]++;
			n /= a;
		}
		else a++;
	}
	if(n!=1)m[n]++;
	return m;
}

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


signed main(){

	lli n;
	cin>>n;

	vector<lli> a(n);
	REP(i,0,n){
		cin>>a[i];
		map<lli,lli> d = makePrimeList2(a[i]);

		for(auto e:d){
			cnt[e.first]=max(cnt[e.first],e.second);
		}
	}

	lli sum=0;
	lli lcm=1;

	for(auto e:cnt){
		REP(i,0,e.second){
			lcm*=e.first;
			lcm%=MOD;
		}
	}

	REP(i,0,n){
		sum += lcm*modinv(a[i],MOD);
		sum%=MOD;
	}
	cout<<sum<<endl;



	return 0;
}

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

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

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int N, M;
    std::cin >> N >> M;

    vector<ll> a_sum(1, 0);
    a_sum.reserve(N + 1);
    REP(i, N) {
        ll a;
        std::cin >> a;
        a_sum.push_back(a + a_sum[i]);
    }

    map<ll, ll> map;
    for(const auto& v : a_sum) {
        map[v % M]++;
    }

    ll ans = 0;
    for(const auto& v : map) {
        ans += (v.second * (v.second + 1)) / 2 - v.second;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 4992
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

int main(void) {
    int n, k;
    std::scanf("%d %d", &n, &k);
    int ans = 1;
    for (int i = 0; i < n; i++) {
        if (ans * 2 < ans + k) {
            ans *= 2;
        }
        else {
            ans += k;
        }
    }
    std::printf("%d\n", ans);
    return 0;
}

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

int main() {
  	int a,b; cin>>a>>b;
  	string s;
  	int count=0;
  	for (a;a<=b;a++){
    	s=to_string(a);
      	if(s.at(0)==s.at(4) && s.at(1)==s.at(3)){
        	count++;
        }
    }
  		cout<<count<<endl;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
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 T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int i = 1;
    while (A >= 1 && C >= 1) {
        if (i % 2) C -= B;
        else A -= D;
        i++;
    }
    if (C <= 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
package main

import (
	"fmt"
	"io"
	"os"
)

func answer(reader io.Reader, writer io.Writer) {
	var n, k int
	var in string
	fmt.Fscan(reader, &n, &k)
	fmt.Fscan(reader, &in)
	a := make([]int, n)
	last := "1"
	ind := 0
	for i := 0; i < len(in); i++ {
		c := string(in[i])
		if last != c {
			ind++
			last = c
		}
		a[ind]++
	}
	sum := 0
	max := 0
	for i := 0; i < n; i++ {
		sum += a[i]
		if i > k*2 {
			sum -= a[i-k*2-1]
		}
		if i%2 == 0 && max < sum {
			max = sum
		}
	}
	_, _ = fmt.Fprintf(writer, "%d\n", max)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 2432
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <iomanip>

#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")
 
using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define endl '\n';
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <class T> inline T gcd(T a, T b) { while (b) { a %= b; swap(a, b); } return a; }
template <class T> inline T lcm(T a, T b) { return a * b / gcd(a, b); }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
    #define eprintf(...) 42
#endif

clock_t startTime;
double getCurrentTime() {
    return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

const ll INF = (ll)1e18;
ll MOD;

ll add(ll x, ll y) {
    x += y;
    if (x >= MOD) return x - MOD;
    return x;
}
ll sub(ll x, ll y) {
    x -= y;
    if (x < 0) return x + MOD;
    return x;
}
ll mul(ll x, ll y) {
    return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(x, bin_pow(x, p - 1));
    return bin_pow(mul(x, x), p / 2);
}

const int N = 100100;
int n, ans, k;
vector<int> g[N];

int dfs(int v) {
    int x = 0;
    for (int u : g[v]) {
        int y = dfs(u);
        if (v != 0 && y == k)
            ans++;
        else
            x = max(x, y);
    }
    return x + 1;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    startTime = clock();
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        --x;
        if (i == 0) {
            if (x)
            ++ans;
            continue;
        }
        g[x].push_back(i);
    }
    dfs(0);
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 12236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main(){
  int n,W;cin>>n>>W;
  ll w[n],v[n];
  rep(i,n)cin>>w[i]>>v[i];
  ll dp[n+1][W+1]={};
  rep(i,n){
    rep(j,1,W+1){
      if(j<w[i]){
        dp[i+1][j]=dp[i][j];
        continue;
      }
      dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
    }
  }
  cout<<dp[n][W]<<endl;
}
    



  


Measured memory_bytes: 79104
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long long p[110000];
long long L[110000];
long long R[110000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%lld",p+i);
	long long cur=0;
	for(int i=0;i<a;i++){
		L[i+1]=cur+max(0LL,p[i]);
		cur=L[i+1];
	}
	cur=0;
	for(int i=a-1;i>=0;i--){
		R[i+1]=cur+max(0LL,p[i]);
		cur=R[i+1];
	}
	long long ret=-inf;
	long long tmp=0;
	for(int i=0;i<b;i++)tmp+=p[i];
	for(int i=0;i<=a-b;i++){
		ret=max(ret,L[i]+R[i+b+1]+max(0LL,tmp));
		tmp+=p[i+b];
		tmp-=p[i];
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 2560
n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
for i in range(1,4):
    a = 0
    for j in range(n):
        if x[j] - y[j] < 0:
            a += (y[j] - x[j]) ** i
        else:
            a += (x[j] - y[j]) ** i
    a = a ** (1/i)
    print(a)
b = 0
for k in range(n):
    c = x[k] - y[k]
    if c < 0:
        c = c * -1
    if b < c:
        b = c
print(b)


Measured memory_bytes: 5636
package main

import "fmt"

func main() {
	var H, W int
	fmt.Scan(&H, &W)
	s := make([]string, H)
	for i := 0; i < H; i++ {
		fmt.Scan(&s[i])
	}

	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if s[i][j] == '.' {
				continue
			}

			if i > 0 && s[i-1][j] == '#' {
				continue
			}
			if i < H-1 && s[i+1][j] == '#' {
				continue
			}

			if j > 0 && s[i][j-1] == '#' {
				continue
			}
			if j < W-1 && s[i][j+1] == '#' {
				continue
			}

			fmt.Println("No")
			return

		}
	}

	fmt.Println("Yes")
}


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

int main()
{
    string S;
    cin >> S;
    set<char> s;
    for(int i=0;i<26;i++){
        s.insert('a'+i);
    }
    for(auto c : S){
        s.erase(c);
    }

    if(s.empty()){
        if(S=="zyxwvutsrqponmlkjihgfedcba"){
            cout<<"-1"<<endl;
        }else{
            auto S2 = S;
            next_permutation(S2.begin(), S2.end());
            for(int i=0;i<S.size();i++){
                if(S[i] == S2[i]) continue;
                S2.erase(i+1);
                break;
            }
            cout<<S2<<endl;
        }
    }else{
        cout<<S<<*s.begin()<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

#define Fast register
inline char Getchar(){
	static char BUF[16384],*S=BUF,*T=BUF;
	return(S==T)&&(T=(S=BUF)+fread(BUF,1,16384,stdin),S==T)?EOF:*S++;
}
inline int Getint(){
	Fast int s=0;Fast char c;
	while(c=Getchar(),c<48||c>57);
	while(s=s*10+c-48,c=Getchar(),c>47&&c<58);
	return s;
}
inline bool Getcol(){
	Fast char c;
	while(c=Getchar(),c!='.'&&c!='#');
	return c=='.';
}

bool Map[52][52];
bool vis[52][52];
struct Node{int x,y,step;Node(const int&x=0,const int&y=0,const int&s=0):x(x),y(y),step(s){}};
Node Queue[2500];

inline int BFS(const int&i,const int&j,const int&H,const int&W){
	Fast int QL=0,QR=1;
	Queue[0]=Node(i,j,1);
	vis[1][1]=true;
	while(QL!=QR){
		Fast Node now=Queue[QL++];
		Fast int x=now.x,y=now.y,step=now.step;
		if(x==H&&y==W)return step;
		if(!vis[x-1][y]&&Map[x-1][y])Queue[QR++]=Node(x-1,y,step+1),vis[x-1][y]=true;
		if(!vis[x+1][y]&&Map[x+1][y])Queue[QR++]=Node(x+1,y,step+1),vis[x+1][y]=true;
		if(!vis[x][y-1]&&Map[x][y-1])Queue[QR++]=Node(x,y-1,step+1),vis[x][y-1]=true;
		if(!vis[x][y+1]&&Map[x][y+1])Queue[QR++]=Node(x,y+1,step+1),vis[x][y+1]=true;
	}
	return 0;
}

int main(){
	Fast int H=Getint(),W=Getint();
	Fast int cnt=0,Ans;
	for(Fast int i=1;i<=H;++i){
		for(Fast int j=1;j<=W;++j){
			cnt+=!(Map[i][j]=Getcol());
		}
	}
	return(printf("%d",(Ans=BFS(1,1,H,W))?H*W-cnt-Ans:-1),0);
}

Measured memory_bytes: 256
def insertionSort(a, n):
    for i in range(n):
        if i != n-1:
            print(a[i], end=" ")
        else:
            print(a[i], end="")
    print("")
    for i in range(1, n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
        for i in range(n):
            if i != n-1:
                print(a[i], end=" ")
            else:
                print(a[i], end="")
        print("")

if __name__ == '__main__':
    n = int(input())
    a = []
    a = list(map(int, input().split()))
    insertionSort(a, n)



Measured memory_bytes: 5984
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  int n = in();
  vector<int> line(n);
  foreach(i,line)i=in();
  int q = in();
  rep(_,q){
    int x = in();
    cout << lower_bound(all(line),x)-line.begin() << " "
         << upper_bound(all(line),x)-line.begin() << endl;
  }
}



Measured memory_bytes: 3524
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a < b) {
			System.out.println("a < b");
		} else if (a > b)

		{
			System.out.println("a > b");
		} else {
			System.out.println("a == b");
		}

	}
}


Measured memory_bytes: 26264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


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

    if(a==0){
        cout<<b/x+1<<endl;
    }else{
        cout << (b/x)-(a-1)/x << endl;
    }
    


    return 0;
    

}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;

int main(){
    string S;
    cin >> S;
    
    if(S == "SAT") cout << 1 << endl;
    if(S == "FRI") cout << 2 << endl;
    if(S == "THU") cout << 3 << endl;
    if(S == "WED") cout << 4 << endl;
    if(S == "TUE") cout << 5 << endl;
    if(S == "MON") cout << 6 << endl;
    if(S == "SUN") cout << 7 << endl;
}


Measured memory_bytes: 256
from heapq import heappush, heappop
n, m = map(int, raw_input().split())
G = [[] for i in xrange(n)]
E = {}
for i in xrange(m):
    a, b, c = map(int, raw_input().split())
    G[a-1].append((b-1, c))
    G[b-1].append((a-1, c))
    E[a-1, b-1] = E[b-1, a-1] = [c, 0]
def dijkstra(s):
    dist = [10**18]*n
    prev = [-1]*n
    que = [(0, s)]
    dist[s] = 0
    dic = set()
    while que:
        co, v = heappop(que)
        if dist[v] < co:
            continue
        for t, cost in G[v]:
            if co + cost < dist[t]:
                dist[t] = co + cost
                heappush(que, (co+cost, t))
                prev[t] = v
    for i in xrange(n):
        if prev[i] != -1:
            dic.add((i, prev[i]))
    return dic

ans = m
for i in xrange(n):
    dic = dijkstra(i)
    for k in dic:
        e = E[k]
        if e[1] == 0:
            ans -= 1
            e[1] = 1
print ans

Measured memory_bytes: 3328
#include <bits/stdc++.h>
 
#define ff first
#define ss second
#define mp make_pair
 
using namespace std;

typedef long long ll;

int d[10000005];

int main(){
	int n;
	
	scanf("%d", &n);

	for(int i = 1; i <= n; i++)
		for(int j = i; j <= n; j+=i)
			d[j]++;

	ll ans = 0;

	for(int i = 1; i <= n; i++)
		ans += (ll)i*d[i];

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 42780
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
 
 
using namespace std;
 
const int N = 10 * 1000 + 5;
long long a[N];
long long b[N];
long long s1;
long long s2;
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> b[i];
	}
	for (int i = 0; i < n; i++)
	{
		if (a[i] < b[i])
		{
			s1 += (b[i] - a[i]) / 2;
		}
		else
		{
			s2 += a[i] - b[i];
		}

	}
	if (s2 > s1)
	{
		cout << "No" << endl;
		exit(0);
	}
	cout << "Yes" << endl;
 
}

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

struct Graph
{
    int n;
    vector<vector<int>> g;
    
    Graph(int n) : n(n){
        g.resize(n);
    }
    
    void init(int n_){
        n = n_;
        g.resize(n_);
    }
    
    void add_edge(int from, int to){
        g[from].push_back(to);
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    Graph g(n);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g.add_edge(a, b);
        g.add_edge(b, a);
    }
    int u = 0, v = 0;
    bool b[100005]{0};
    b[0] = true;
    vector<int> l, r;
    bool f = true;
    while(f){
        f = false;
        for(int w : g.g[u]){
            if(!b[w]){
                b[w] = true;
                l.push_back(w);
                u = w;
                f = true;
                break;
            }
        }
        for(int w : g.g[v]){
            if(!b[w]){
                b[w] = true;
                r.push_back(w);
                v = w;
                f = true;
                break;
            }
        }
    }
    cout << (int)l.size() + (int)r.size() + 1 << endl;
    reverse(l.begin(), l.end());
    for(int u : l) cout << u + 1 << " ";
    cout << 1 << " ";
    for(int u : r) cout << u + 1 << " ";
    cout << endl;
}


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


int main() {

int N;
  long long int N8=1;
  long long int N9=-1;
  long long int N10=1;

cin >> N;
  for(int i=0;i<N;i++){
    N8=(8*N8)%1000000007LL;
    N9=(9*N9)%1000000007LL;
    N10=(10*N10)%1000000007LL;
  }
  

cout << (N10+2*N9+N8+400000002800LL)%1000000007LL;

}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi p(n), q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    vi p2 = p, q2 = q;
    VSORT(p2); VSORT(q2);
    int a = 0, b = 0;
    do {
        ++a;
        if (p2 == p) break;
    } while (next_permutation(all(p2)));
    do {
        ++b;
        if (q2 == q) break;
    } while (next_permutation(all(q2)));
    cout << abs(b-a) << endl;
    return 0;
}


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

int main(){
    long long n,cur,next,res=1;
    cin >> n >> cur;
    int vec=0;
    
    for(int i=1;i<n;i++){
        cin >> next;
        if(cur==next)continue;
        
        if(vec){
            if((vec==1 && cur>next) || (vec==-1 && cur<next)){
                res++;
                vec=0;
            }
        }else vec=(cur<next)?1:-1;
        
        cur=next;
    }
    cout << res;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

struct BIT {
  int n;
  vector<ll> tree;
  BIT(int n):n(n),tree(n+1) {} 
  void fill(ll val) {
    REP(i, n+1) tree[i] = (i&-i) * val;
  }
  void add(int idx, ll val) {
    for (int x=idx+1; x<=n; x+=x&-x) tree[x] += val;
  }
  // sum[0, idx]
  ll range(int idx) {
    ll sum=0;
    for (int x=idx+1; x>0; x-=x&-x) sum += tree[x];
    return sum;
  }
  // sum[a, b]
  ll range(int a, int b) {
    return range(b) - range(a - 1);
  }
};

// 座標圧縮
vector<ll> normalize(vector<ll> v) {
  const int N = v.size();
  vector<pair<ll,int> > t(N);
  REP(i, N) {
    t[i].first = v[i];
    t[i].second = i;
  }
  sort(ALL(t));
  int r = 0;
  REP(i, N) {
    r += (i > 0 && t[i - 1].first != t[i].first);
    v[t[i].second] = r;
  }
  return v;
}

const int MAX_N = 212345;
ll a[MAX_N];

int main2() {
  int N = nextInt();
  int K = nextInt();
  REP(i, N) a[i] = nextInt() - K;

  vector<ll> s(N+1);
  s[0] = 0;
  for (int i = 1; i <= N; i++) s[i] = s[i-1] + a[i-1];
  s = normalize(s);

  // pv(ALL(s));

  BIT bit(N + 10);
  ll ans = 0;
  for (int i = 0; i <= N; i++) {
    ans += bit.range(s[i]);
    bit.add(s[i], 1);
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 8064
object Main {
  def is_prime(i: Int): Boolean = {
    if (i == 1) return false
    var x = 2
    while(i >= x * x) {
      if(i % x == 0) return false
      x += 1
    }
    true
  }

  def from(n: Int, d: Int): Stream[Int] = Stream.cons(n, from(n + d, d))

  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    var a, d, n = sc.nextInt
    while(a != 0 || d != 0 || n != 0) {
      println(from(a, d).filter(is_prime).take(n).last)
      a = sc.nextInt; d = sc.nextInt; n = sc.nextInt
    }
  }
}

Measured memory_bytes: 59052
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum[1000000], ans, dp[110000];
Pll a[200000], b[2000000];
string str, ss, dd;
bool f,ff;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL to, cost; };
vector<Edge>vec[10000];
vector<Pll>v;
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n >> m >> k;
	rep(i, n+1) {
		LL num = i;
		cnt = 0;
		while (num > 0) {
			cnt += num % 10;
			num /= 10;
		}
		if (cnt >= m && cnt <= k)
			ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
N = int(input())
TXY = [list(map(int, input().split())) for _ in range(N)]
TXY.sort(key=lambda x:x[0])

check = [False for i in range(N)]

for i in range(N):
        if i == 0:        
                t = TXY[0][0]
                x = TXY[0][1]
                y = TXY[0][2]
                if t >= (x+y) and t%2 ==(x+y)%2 :
                        check[0] = True
                else:
                        break
        else :
                t = TXY[i][0] - TXY[i-1][0]
                x = TXY[i][1] - TXY[i-1][1]
                y = TXY[i][2] - TXY[i-1][2]
                if t >= (x+y) and t%2 ==(x+y)%2 :
                        check[i] = True
                else:
                        break

ans = check.count(True)
if ans == N :
        print('Yes')
else:
        print('No')  

Measured memory_bytes: 28900
#include<cstdio>
#include<algorithm>
using namespace std;
int cnt=0,j,n,aut,i,seq[105],col[205],anm,pr,l,r,mid;
char s[10];
int ask()
{
	cnt++;
	int i;
	printf("?");
	for(i=1;i<=n;i++)printf(" %d",seq[i]);
	printf("\n");fflush(stdout);
	scanf("%s",s);
	if(s[0]=='R')return 0;
	return 1;
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;i++)seq[i]=i;
	aut=ask();
	l=1;r=n+1;
	while(l+1<r)
	{
		mid=(l+r)/2;
		for(i=1;i<=n;i++)seq[i]=mid+i-1;
		anm=ask();
		if(anm==aut)l=mid;
		else r=mid;
	}
	pr=r;
	for(j=0;j<n-1;j++)seq[j+1]=pr+j;
	for(i=1;i<pr;i++)
	{
		seq[n]=i;
		col[i]=ask();
	}
	for(i=pr+n-1;i<=2*n;i++)
	{
		seq[n]=i;
		col[i]=ask();
	}
	for(i=1;i<pr-1;i++)seq[i]=i;
	for(i=pr+n;i<=2*n;i++)seq[i-n-1]=i;
	for(i=pr;i<pr+n-1;i++)
	{
		seq[n]=i;
		col[i]=ask();
	}
	printf("! ");
	for(i=1;i<=2*n;i++)printf("%c",(col[i]==0)?'R':'B');
	printf("\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<string>
#include<algorithm>
#include<set>
#include<map>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORS(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)
#define SORT(v,n) sort(v,v+n)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FORR(i,n,0)
#define si(n) scanf("%d",&n)
#define sc(s) scanf("%s",s)
#define EPS (1e-7)
#define INF (1e9)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}

template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

int N,D;
int X[10][10];
int main(void){
    cin >> N >> D;
    rep(i,N) rep(j,D) cin >> X[i][j];

    int count= 0;
    rep(i,N) for(int j=i+1;j<N;j++){
        double val = 0;
        rep(k, D) val += pow(X[i][k] - X[j][k], 2);
        val = pow(val,0.5);
        if (ceil(val) == floor(val)) count++;
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    vector<pair<lint, lint>> ab, ba;
    for (int i = 0; i < n; ++i) {
        lint a, b;
        cin >> a >> b;
        ab.emplace_back(a, b);
        ba.emplace_back(b, a);
    }
    sort(ab.begin(), ab.end());
    sort(ba.begin(), ba.end(), greater<>());
    if (n % 2 == 1) {
        lint mini = ab[n / 2].first;
        lint maxi = ba[n / 2].first;
        cout << maxi - mini + 1 << "\n";
    } else {
        lint mini = ab[n / 2 - 1].first + ab[n / 2].first;
        lint maxi = ba[n / 2 - 1].first + ba[n / 2].first;
        cout << maxi - mini + 1 << "\n";
    }
    return 0;
}

Measured memory_bytes: 9800
//file_name:ABC42_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n,l;
    scanf("%d%d",&n,&l);
    string s[n];
    rep(i,n){
        cin >> s[i];
    }
    sort(s,s+n);
    rep(i,n){
        cout << s[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    int A, B, C; cin >> A >> B >> C;
    if(A == B && B == C){
        cout << ((A%2) ? 0 : -1) << endl; return 0;
    }
    if(A%2 || B%2 || C%2){
        cout << 0 << endl; return 0;
    }
    int cnt(1);
    while(1){
        int a(B/2 + C/2), b(C/2 + A/2), c(A/2 + B/2);
        if(a%2 || b%2 || c%2){
            cout << cnt << endl; return 0;
        }
        ++cnt;
        A = a; B = b; C = c;
    }
    return 0;
}


Measured memory_bytes: 256
/*Filename: aoj0016.cpp
 *Author: Mushiyo
 */

#include <stdio.h>
#include <cmath>

using namespace std;

int main() {
	double x = 0, y = 0;
	int direction = 90;
	int d = 0, t = 0;

	while (scanf("%d, %d", &d, &t) == 2) {
		if (d == 0 && t == 0) {
			break;
		}

		double dx = d * cos(direction * M_PI / 180.0);
		double dy = d * sin(direction * M_PI / 180.0);

		x += dx;
		y += dy;

		direction -= t;
		direction %= 360;
		if (direction < 0) {
			direction += 360;
		}
	}

	printf("%d\n", (int)x);
	printf("%d\n", (int)y);

	return 0;
}

Measured memory_bytes: 1036
#include<stdio.h>
#define True 1
#define False -1
int search (int a,int b,int c);
int num[50];
int main(){
  int n,u,m,i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&num[i]);
  }
  scanf("%d",&u);
  for(i=0;i<u;i++){
    scanf("%d",&m);
    if(search(0,m,n)==True)printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int search(int a,int b,int c){

  if(b==0)return True;
  if(a>=c)return False;
  if(search(a+1,b,c)==True||search(a+1,b-num[a],c)==True)return True;
  if(search(a+1,b,c)==True||search(a+1,b-num[a],c)==False)return False;
  if(search(a+1,b,c)==False||search(a+1,b-num[a],c)==True)return False;
  if(search(a+1,b,c)==False||search(a+1,b-num[a],c)==False)return False;
}

Measured memory_bytes: 580
#098c
N = int(input())
S = "0" + str(input())

#累積和を使う
cumsum_E = [0]
cumsum_W = [0]

for i in range(1,N+1):
    if S[i]=="E":
        cumsum_E.append(cumsum_E[i-1]+1)
        cumsum_W.append(cumsum_W[i-1])
    elif S[i]=="W":
        cumsum_E.append(cumsum_E[i-1])
        cumsum_W.append(cumsum_W[i-1]+1)

cumsum_E.pop(0)
cumsum_W.pop(0)
        
#print("E:",cumsum_E)
#print("W:",cumsum_W)

ans = N

for i in range(0,N):
    E_to_W = cumsum_E[N-1] - cumsum_E[i]
    if i!=0:
        W_to_E = cumsum_W[i-1]
    else:
        W_to_E = 0
    
    change = E_to_W + W_to_E
    #print(i,E_to_W,W_to_E,change)
    if change < ans:
        ans = change
        
print(ans)

Measured memory_bytes: 18248
fun main(){
    var (a, b, c) = readLine()!!.split(" ").map { it.toInt() }
    val k = readLine()!!.split(" ")[0].toInt()
    var count = 0
    for (i in 1 until 10000){
        if (b <= a){
            b *= 2
        } else {
            count += (i - 1)
            break
        }
    }
    for (i in 1 until 10000){
        if (c <= b){
            c *= 2
        } else {
            count += (i - 1)
            break
        }
    }

    if (count <= k){
        println("Yes")
    } else {
        println("No")
    }
}

Measured memory_bytes: 36304
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;


    
    int main(){
       int n;cin>>n;
       VEC(int,h,n);
       bool f = true;
       rep(i,n){
           if(i==0)continue;
           if(h[i]>h[i-1])h[i]--;
           if(h[i]<h[i-1])f = false;
       }
       cout<<(f?"Yes":"No");
    }
    


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int A,B;
int main(){
    cin>>A>>B;
    for(int i=0;i<B+2;i++)cout<<'#';
    cout<<endl;
    while(A--){
        cout<<'#';
        string s;
        cin>>s;
        cout<<s;
        cout<<'#';
        cout<<endl;
    }
    for(int i=0;i<B+2;i++)cout<<'#';
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
using namespace std;

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    set<int> ans;
    for (int i = 0; i < k;i++){
      if (a+i > b){
        break;}
      ans.insert(a + i);}
    for (int i = 0; i < k;i++){
      if (a+i > b){
        break;}
      ans.insert(b- i);}
    for (int x : ans) {
        cout << x << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int uhen = sc.nextInt();
		int jouhen = sc.nextInt();
		int sahen = 0;
		int teihen = 0;

		int N = sc.nextInt();
		for (int i = 0; i < N; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int a = sc.nextInt();

			switch (a) {
			case 1:
				if (sahen < x)
					sahen = x;
				break;
			case 2:
				if (x < uhen)
					uhen = x;
				break;
			case 3:
				if (teihen < y)
					teihen = y;
				break;
			case 4:
				if (y < jouhen)
					jouhen = y;
				break;
			}
		}
		int height = (jouhen - teihen);
		int width = (uhen - sahen);
		if (height < 0) {
			height = 0;
		}
		if (width < 0) {
			width = 0;
		}
		System.out.println(height * width);
	}
}


Measured memory_bytes: 24148
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int R = cin.nextInt();

        WriteLine(3 * R * R);
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13140