akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int rec(ll x) {
  if (x == 0) return 0;
  return rec(x%popcount(x)) + 1;
}


int main() {
  ll n; cin >> n;
  string s; cin >> s;

  ll pc = 0;
  rep(i, n) if (s[i] == '1') ++pc;



  V r0(n), r1(n);
  ll s0 = 0;
  ll s1 = 0;

  if (pc > 1) {
    r0[n-1] = 1 % (pc-1);
    drep(i, n-1) r0[i] = r0[i+1]*2 % (pc-1);
    rep(i, n) if (s[i] == '1') (s0 += r0[i]) %= (pc-1);
  }
  r1[n-1] = 1 % (pc+1);
  drep(i, n-1) r1[i] = r1[i+1]*2 % (pc+1);
  rep(i, n) if (s[i] == '1') (s1 += r1[i]) %= (pc+1);

  rep(i, n) {
    if (s[i] == '0') {
      ll z = s1;
      (z += r1[i]) %= (pc+1);
      cout << (rec(z)+1) << '\n';
    }
    if (s[i] == '1') {
      if (pc == 1) {
        cout << 0 << '\n';
        continue;
      }
      ll z = s0;
      (z += pc-1 - r0[i]) %= (pc-1);
      cout << (rec(z)+1) << '\n';
    }
  }
  return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		Arrays.sort(a);
		int b = 0;
		for(int i = 0 ; i < n ; i++) {
			if(b < Math.min(a[i], a[n - 1] - a[i])) {
				b = a[i];
			}
		}
		System.out.println(a[n - 1] + " " + b);
	}
}


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

void Main() {
    // input
    int N, M, Q;
    cin >> N >> M >> Q;
    int a[Q+1], b[Q+1], c[Q+1], d[Q+1];
    for (int i = 1; i <= Q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }



    // translate    
    // 数列 A_1, …, A_N の総当り
    vector<int> vec(M+N-1, 1); // 0 を ○, 1 を棒として, 各1の左にある0の数を数える
    for (int i = 0; i < M - 1; i++) {
        vec[i] = 0;
    }


    u_int64_t ans = 0;
    do {
        // 数列A 列挙部
        int zero_count = 0;
        vector<int> A(1); // 数列A
        for (int i = 0; i < N+M-1; i++) {
            if (vec[i] == 0) {
                zero_count++;
            } else {
                A.push_back(zero_count);
            }
        }
        u_int64_t score = 0;
        // d_i の計算
        for (int i = 1; i <= Q; i++) {
            if (A[b[i]] - A[a[i]] == c[i]) {
                score += d[i];
            }
        }
        ans = max(ans, score);
    } while (next_permutation(vec.begin(), vec.end()));


    // output
    cout << ans << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using ll= long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (ll)1e9 //10^9:∞
#define LLINF (ll)1e12
#define MOD (ll)(1e9+7) //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)
#define endl "\n"

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTIONS ......................*/



/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__


	ll N;
	cin>>N;
	VI a(N+1);
	FOR(i,1,N)cin>>a[i];

	VI ball(N+1,0);

	for (ll i = N; i >=1 ; --i)
	{
		ll now=0;
		ll j=2;
		while(i*j<=N){
			if(ball.at(i*j)==1)++now;
			j++;
		}
		if(a[i]!=now%2)ball[i]=1;
	}
	ll sum=0;
	for(auto b:ball)sum+=b;

	cout<<sum<<endl;


	FOR(i,1,N){
		if(ball[i]==1)cout<<i<<" ";
	}
	cout<<endl;
	



	

		return 0;
}


Measured memory_bytes: 4764
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

using namespace std;

typedef long long ll;

typedef pair<int,int> P1;
typedef pair<int,P1> P2;
const ll inf=100000000000000;
struct edge{
	int to,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

#define MAX_N 200002
int dp[26][MAX_N]={};
bool d[MAX_N]={};
int pa[MAX_N];
vector<edge> G[MAX_N];
P1 cost[MAX_N]={};
vector<int> child[MAX_N];
vector<int> ra[MAX_N];
priority_queue<P2,vector<P2>,greater<P2>> que;
int main() {
	ll x,y;
	int t=0;

	cin>>x>>y;
	if(abs(x)>abs(y)){
		if(x>0)t++;
		t+=abs(x)-abs(y);
		if(y>0)t++;
	}else{
		if(x<0)t++;
		t+=abs(y)-abs(x);
		if(y<0)t++;
	}
	cout<<t<<endl;
	return 0;
}





Measured memory_bytes: 16640
#include <stdio.h>

int main(void)
{
  int i;
  char s[27];
  char c[100002];
  i = 0;
  scanf("%s", c);
  while(1){
    if(c[i] == '\0') break;
    s[(int)c[i]-97] = c[i];
    i++;
  }

  for(i = 0; i != 26; i++){
    if(s[i] == '\0'){
      printf("%c\n", i+97);
      return 0;
    }
  }
    printf("None\n");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=1; i<=N; i++){
        if(N%i == 0){
            bool can = true;
            for(int j=0; i+j<N; j++){
                if(A[j] != A[i+j]){
                    can = false;
                    break;
                }
            }
            if(can){
                cout << N/i << enld;
                return 0;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 3632
n=int(input())
a=list(map(int,input().split()))
MOD=10**9+7
def findProductSum(A, n): 
    array_sum = 0
    for i in range(0, n, 1): 
        array_sum=array_sum+A[i]
    array_sum_square = array_sum * array_sum 
    individual_square_sum = 0
    for i in range(n): 
        individual_square_sum += A[i] * A[i]
    return (array_sum_square - individual_square_sum)//2

print(findProductSum(a,n)%MOD)

Measured memory_bytes: 94200
using System;
class gcd{
  public static void Main(){
    String[] str = Console.ReadLine().Split(' ');
    int n = int.Parse(str[0]);
    int m = int.Parse(str[1]);
    if(m > n){
      int temp = n;
      n = m;
      m = temp;
    }
    while(true){
      if(n%m == 0){
        break;
      }
      else{
        int a = n/m;
        int b = n - m*a;
        n = m;
        m = b;
      }
    }
    Console.WriteLine(m);
  }
}



Measured memory_bytes: 15972
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main() {
	string s, t;
	cin >> s >> t;
	string ans = t + s;
	col(ans);
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <iomanip>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main()
{
	double a, b, c;
	cin >> a >> b >> c;
	cout << a*b/2 <<endl;
	return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    S=input()
    T=input()

    if len(T)-len(S)!=1 or (not S.islower()) or (not T.islower()) or len(S)==0 or len(S)>10:
        print("No")
    else:
        if S!=T[:-1]:
            print("No")
        else:
            print("Yes")

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

#ifdef DEBUG
#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))

#define LOGM(msg) (cerr << (msg))

#define LOGV(vec, sep) {                                        \
    cerr << #vec << " =";                                       \
    for (const auto& v : (vec)) cerr << " " << v;               \
    cerr << (sep); }

#define LOGA(arr, N, sep) {                                     \
        cerr << #arr << " =";                                   \
        for (int i = 0; i < N; ++i) cerr << " " << (arr)[i];    \
        cerr << (sep); }

#define LOGA2(arr, N, M, sep) {                                 \
        cerr << #arr << " =\n";                                 \
        for (int i = 0; i < N; ++i) {                           \
            for (int j = 0; j < M; ++j)                         \
                cerr << (arr)[i][j] << " ";                     \
            cerr << endl;                                       \
        } cerr << (sep); }
#else
#define LOG(var, sep)
#define LOGM(msg)
#define LOGV(vec, sep)
#define LOGA(arr, N, sep)
#define LOGA2(arr, N, M, sep)
#endif

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll count(ll m, const vector<ll>& xs)
{
    ll c = 0;

    for (auto x : xs)
        c += ((x + m - 1)/m - 1);

    return c;
}

ll solve(ll N, ll K, const vector<ll>& xs)
{
/*    ll to_zero = 0;

    for (auto x : xs)
        to_zero += (10*x + 3)/4;

LOG(to_zero, endl);
    if (to_zero <= K)
        return 0;
*/ 
    ll a = 1, b = 1000000000, ans = 0;

    while (a <= b)
    {
        auto m = a + (b - a)/2;

        if (count(m, xs) <= K)
        {
            ans = m;
            b = m - 1;
        } else
            a = m + 1;
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;

    vector<ll> xs(N);

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

    auto ans = solve(N, K, xs);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 4744
#include<bits/stdc++.h>
using namespace std;
const int maxN = 3010;
const long long P = 998244353;
long long a[maxN],sumL[maxN][maxN];
int main()
{
    int N,S;
    scanf("%d%d",&N,&S);
    for(int i=1;i<=N;i++)scanf("%lld",&a[i]);
    long long ans=0;
    for(int i=1;i<=N;i++)
    {
        if(a[i]==S)ans=(ans+i*(N-i+1))%P;
        else if(i-1>0&&S-a[i]>0)ans=(ans+((sumL[i-1][S-a[i]]*(N-i+1))%P))%P;
        sumL[i][a[i]]=i%P;
        for(int k=1;k<=S;k++)
        {
            sumL[i][k]=(sumL[i][k]+sumL[i-1][k])%P;
            if(k-a[i]>0)sumL[i][k]=(sumL[i][k]+sumL[i-1][k-a[i]])%P;
        }
    }
    printf("%lld",ans%P);
}


Measured memory_bytes: 70912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
const int MAXN=2e3+10;
int a[MAXN],n,k;
const int P=1e9+7;
int add(int a,int b)
{
	return (a+b>=P)?(a+b-P):(a+b);
}
int mul(int a,int b)
{
	return 1LL * a * b % P;
}
const int inv2=(P+1)>>1;
int ans=0,s=0;
int sum[MAXN];
int main()
{
	n=read(),k=read();
	for(int i=1;i<=n;++i)
	{
		a[i]=read();
		sum[a[i]]++;
	}
	for(int i=1;i<=2000;++i)
		sum[i]+=sum[i-1];
	for(int i=2;i<=n;++i)
		for(int j=1;j<i;++j)
			if(a[j]>a[i])
				++ans;
	ans=mul(ans,k);
	for(int i=1;i<=n;++i)
		s=add(s,sum[2000]-sum[a[i]]);
	int tmp=mul(k,mul(k-1,mul(s,inv2)));
	ans=add(ans,tmp);
	cout<<ans<<endl;
	return 0;
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    # ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    return 0;
}


Measured memory_bytes: 3584
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

ans = 0

for i in range(n):
    if a[i]>=b[i]:
        ans += b[i]
    else:
        ans += a[i]
        b[i]-=a[i]
        if a[i+1]>=b[i]:
            ans += b[i]
            a[i+1]-=b[i]
        else:
            ans += a[i+1]
            a[i+1]=0

print(ans)

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

int main() {
	int s,i,l,m,n;
	while(cin >> l && l>0) {
		for (s=0,i=1;i<13;i++) {
			cin >> m >> n;
			l=l-m+n;
			if (l<=0 && s==0) s=i;
		}
	if (s==0) cout << "NA"; else cout << s;
	cout << endl;  	
	}
	return 0;
}

Measured memory_bytes: 1164
local mmi, mma = math.min, math.max
local bls, brs = bit.lshift, bit.rshift
local bor = bit.bor
local mfl, mce = math.floor, math.ceil
local n = io.read("*n")
local edge = {}
for i = 1, n do
  edge[i] = {}
  for j = 1, n do
    edge[i][j] = io.read("*n")
  end
end
if n == 1 then
  print(0)
  os.exit()
elseif n == 2 then
  print(mma(0, edge[1][2]))
  os.exit()
end

local all = bls(1, n)
local bdp = {}
local inf = 1000000007 * 1000
for i = 1, all - 1 do
  bdp[i] = -inf
end

local edgesum = {}
for it = 1, all - 1 do
  local tmp = it
  local box = {}
  for j = n, 1, -1 do
    if tmp % 2 == 1 then
      table.insert(box, j)
    end
    tmp = brs(tmp, 1)
  end
  local c = 0
  for i = 1, #box - 1 do
    for j = i + 1 , #box do
      c = c + edge[box[i]][box[j]]
    end
  end
  edgesum[it] = c
end

local base = 0
do
  -- use 1 and others
  local tot1 = bls(1, n - 1)
  base = base + tot1
  for it = 0, tot1 - 1 do
    local dst = base + it
    bdp[dst] = edgesum[dst]
  end
end
local map_devide_or1, map_devide_or2 = {}, {}
for it = 0, 3^(n - 3) - 1 do
  local tmpit = it
  local a, b = 0, 0
  local mul = 1
  for j = 4, n do
    if tmpit % 3 == 2 then
      a = a + mul
    elseif tmpit % 3 == 1 then
      b = b + mul
    end
    mul = mul * 2
    tmpit = mfl(tmpit / 3)
  end
  map_devide_or1[it + 1], map_devide_or2[it + 1] = a, b
end
--use i
for i = 2, n do
  local totrem = 3^(n - i)
  local basei = 2^(n - i)
  for it = 0, totrem - 1 do
    local add_from_i = 0
    local marge_src = 0
    if i == 2 then
      if 2 * (3^(n - 3)) <= it then
        marge_src = marge_src + 2^(n - 3)
        it = it - 2 * (3^(n - 3))
      elseif 3^(n - 3) <= it then
        add_from_i = add_from_i + 2^(n - 3)
        it = it - (3^(n - 3))
      end
    end
    add_from_i = add_from_i + basei + map_devide_or1[it + 1]
    marge_src = marge_src + base + map_devide_or2[it + 1]
    local dst = bor(add_from_i, marge_src)
    bdp[dst] = mma(bdp[dst], bdp[marge_src] + edgesum[add_from_i])
  end
  base = base + basei
end
print(bdp[all - 1])


Measured memory_bytes: 37744
#include <stdio.h>

int main(void){
    char order[10];
    int j, q, k;
    
    fgets(order, 10, stdin);
    sscanf(order, "%d %d", &j, &q);
    k = j * q % 2;
    if(k == 0)
        printf("Even\n");
    else
        printf("Odd\n");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include <math.h>
using namespace std;
int main(){
    long long n;
    cin >> n;

    int ans = 10;
    for(long long i=1; i<=sqrt(n); i++){
        long long j = n / i;
        if(n == i*j){
            int f = max((int)log10(i)+1, (int)log10(j)+1);
            ans = min(ans, f);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
(defun lucas (n)
  (let ((memo '(1 2)))
    (loop :for i :from 2 :upto n :do
          (setq memo (cons (+ (car memo) (cadr memo)) memo)))
    (if (= n 0) (cadr memo) (car memo))
    ))

(defun main()
  (let ((n (read)))
    (princ (lucas n))
    (princ #\newline)
    )
)
(main)

Measured memory_bytes: 11876
antennas = Array.new(5) do
  gets.chomp.to_i
end
k = gets.chomp.to_i

max_diff = antennas
                .combination(2)
                .map{|a,b| (a - b).abs}
                .sort
                .max

if max_diff <= k
  puts 'Yay!'
else
  puts ':('
end


Measured memory_bytes: 3836
#include "bits/stdc++.h"
using namespace std;
using long_t = int64_t;

struct Solver {
	Solver() {
		ios::sync_with_stdio( false );
		cout << fixed << setprecision( 10 );
	}

	void solve() {
		long_t A, B;
		cin >> A >> B;
		long_t x = gcd( A, B );
		cout << prime_factors( x ).size() + 1 << endl;
	}

	static vector<long_t> prime_factors( long_t x ) {
		vector<long_t> fac;
		if( x <= 1 ) { return fac; }

		long_t y = x;
		for( long_t i = 2; i*i <= x; ++i ) {
			if( y%i == 0 ) {
				fac.push_back( i );
				do { y /= i; } while( y%i == 0 );
			}
		}

		if( y != 1 ) {
			fac.push_back( y );
		}

		return fac;
	}

	static long_t gcd( long_t a, long_t b ) { return b ? gcd( b, a%b ) : a; }
};

int main() {
	Solver().solve();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

const int N=100005;

int n,a[N];

int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int main()
{
	n=read();
	for (int i=1;i<=n;i++) a[i]=read();
	LL ans=0;
	for (int i=1;i<=n+1;i++) ans+=abs(a[i]-a[i-1]);
	for (int i=1;i<=n;i++) printf("%lld\n",ans-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]));
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define gc getchar
#define pc putchar
#define cs const
#define int ll

inline
int getint(){
	re int num;
	re char c;
	re bool f=0;
	while(!isdigit(c=gc()))f^=c=='-';num=c^48;
	while(isdigit(c=gc()))num=(num<<1)+(num<<3)+(c^48);
	return f?-num:num;
}

inline
void outint(ll a){
	static char ch[23];
	if(a==0)pc('0');
	if(a<0)pc('-'),a=-a;
	while(a)ch[++ch[0]]=a-a/10*10,a/=10;
	while(ch[0])pc(ch[ch[0]--]^48);
}

cs ll INF=9223372036854775807L;
cs int N=1005;
cs ll dx[4]={1,-1,0,0};
cs ll dy[4]={0,0,-1,1};
cs char s[4]={'R','L','D','U'};

int n;
ll x[N],y[N];
vector<ll> len;
bool flag;

signed main(){
	n=getint();
	for(int re i=1;i<=n;++i){
		x[i]=getint(),y[i]=getint();
		if(i==1)flag=(x[i]+y[i])&1;
		else {
			if(flag!=((x[i]+y[i])&1))return puts("-1"),0;
		}
	}
	for(int re i=0;i<=30;++i){
		len.push_back(1ll<<i);
	}
	if(flag==0)len.push_back(1);
	
	sort(len.rbegin(),len.rend());
	
	outint(len.size()),pc('\n');
	for(int re i=0;i<len.size();++i)
	outint(len[i]),pc(' ');
	pc('\n');
	
	for(int re i=1;i<=n;++i){
		ll xx=0,yy=0;
		for(int re j=0;j<len.size();++j){
			int pos=0;
			ll minn=INF;
			for(int re k=0;k<4;++k){
				ll tmpx=xx+len[j]*dx[k];
				ll tmpy=yy+len[j]*dy[k];
				if(abs(tmpx-x[i])+abs(tmpy-y[i])<minn){
					minn=abs(tmpx-x[i])+abs(tmpy-y[i]);
					pos=k;
				}
			}
			pc(s[pos]);
			xx=xx+len[j]*dx[pos];
			yy=yy+len[j]*dy[pos];
		}pc('\n');
	}
	return 0;
}

Measured memory_bytes: 256
s=list(input())
r=b=ans=0
for i in range(len(s)):
    if b==0 and s[i]=="0":
        r+=1
    elif r==0 and s[i]=="1":
        b+=1
    elif b>0 and s[i]=="0":
        b-=1
        ans+=2
    elif r>0 and s[i]=="1" :
        r-=1
        ans+=2
print(ans)


Measured memory_bytes: 3956
# 三井住友信託銀行プログラミングコンテスト 2019 D - Lucky PIN
N = int(input())
S = str(input())

ans = 0
for i in range(10):
    code1 = S.find(str(i))
    if code1 == -1:
        continue
    for j in range(10):
        code2 = S.find(str(j), code1 + 1)
        if code2 == -1:
            continue
        for k in range(10):
            code3 = S.find(str(k), code2 + 1)
            if code3 != -1:
                ans += 1

print(ans)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
int dp[100005],n;
vector<int> v;
int solve(int i){
  if(i>=n-1)return 0;
  if(dp[i]!=-1)return dp[i];
  int ans=1e18;
  if(i<n-1)ans=min(ans,llabs(v[i+1]-v[i])+solve(i+1));
  if(i<n-2)ans=min(ans,llabs(v[i+2]-v[i])+solve(i+2));
  dp[i]=ans;
  return ans;
}
int32_t main(){
  clr(dp,-1);
  cin>>n;
  rep(i,0,n){
    int t; cin>>t;
    v.pub(t);
  }
  cout<<solve(0)<<"\n";
   return 0;
}
/*
Edge cases? n=1? a[i]<=0?
long vs int? 1LL? 64bits?
Re-read problem. Is it as easy as it seems?
KEEP CORRECTING AND SUBMITTING!
*/


Measured memory_bytes: 7924
#include <stdio.h>
#define NIL -1
#define N 100



struct Node{
  int p,l,r;
};
struct Node A[N];


main()
{

  int i,j;
  int n,id,e,c;

  scanf("%d",&n);
  
  for(i = 0; i < n; i++){
   A[i].p = NIL;
   A[i].l = NIL;
   A[i].r = NIL;
  }
  for(i = 0; i < n; i++){
    scanf("%d%d%d",&id,&e,&c);
    
    A[e].p = id;
    A[c].p = id;
    A[id].l = e;
    A[id].r = c;
  
  }
  for(i = 0; i < n; i++){
    if(A[i].p == NIL){
      break;
    }
  }
  printf("Preorder\n");
  Pre(i);
  printf("\n");
   
  printf("Inorder\n");
  In(i);
  printf("\n");
   
  printf("Postorder\n");
  Post(i);
  printf("\n");

  return 0;
}

int Pre(int s)
{

 printf(" %d",s);
 
 if(s != NIL){
   if(A[s].l!=NIL)Pre(A[s].l);
   
    if(A[s].r!=NIL)Pre(A[s].r);
 }
}

int In(int s){
  
  if(s != NIL){
   
    if(A[s].l != NIL){
      
      In(A[s].l);
    }
    printf(" %d",s);
     
    if(A[s].r != NIL){
      In(A[s].r);
    }
  }
}
 
int Post(int s){
  
  if(s != NIL){
    
    if(A[s].l!=NIL)Post(A[s].l);
   
    if(A[s].r!=NIL)Post(A[s].r);
    
  }

  printf(" %d",s);
}

Measured memory_bytes: 616
#include<bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(b);i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(d);j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for((a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for((a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRvl(c) for (vl::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvll(c) for (vll::iterator it = (c).begin(); it != (c).end(); it++)
#define gc getchar_unlocked
#define pc putchar_unlocked3
#define pb(a) push_back((a))
 
 
void solve()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)cout<<"bust"<<endl;
    else cout<<"win"<<endl;
}
 
int main()
{
    
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif 
    */
        ll t;
    //cin>>t;
    //while(t--)
        solve();
}

Measured memory_bytes: 256
// 時計
#include<stdio.h>
int main()
{
	int s,h,m;
	scanf("%d",&s);
	
	h=s/3600;// 時を求める
	s=s-h*3600;// 時を引いた秒数を求める
	m=s/60;// 分を求める
	s=s-m*60;// 秒を求める
	printf("%d:%d:%d\n",h,m,s);
	return 0;

}

Measured memory_bytes: 592
#include<stdio.h>

int main(void){
  int x;
  scanf("%d",&x);
  switch(x%7){
    case 0:
      printf("thu\n");
      break;
    case 1:
      printf("fri\n");
      break;
    case 2:
      printf("sat\n");
      break;
    case 3:
      printf("sun\n");
      break;
    case 4:
      printf("mon\n");
      break;
    case 5:
      printf("tue\n");
      break;
    case 6:
      printf("wed\n");
      break;
  }
  return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <vector>

using namespace std;
using vi = vector<int>;

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

    int sum = 0;
    for (int i = 0; i < N; i++)
        sum += a[i];
    int ave = sum / N;

    int sum1 = 0;
    for (int i = 0; i < N; i++)
    {
        int d = ave - a[i];
        sum1 += d*d;
    }

    ++ave;
    int sum2 = 0;
    for (int i = 0; i < N; i++)
    {
        int d = ave - a[i];
        sum2 += d*d;
    }

    int ans = min(sum1, sum2);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	int N;
	cin>>N;
	int a[N];
	int T=999999;
	int cnt=0;
	
	int M;
	for(int i=0;i<N;i++) {
		cin>>a[i];
		if(i==0) {
			cnt++;
			if(a[i]<T) T=a[i];
		}
		else {
			if(a[i]<a[i-1]&&a[i]<T) {
				cnt++;
				if(a[i]<T) T=a[i];
			}
		}
	}
	cout<<cnt;
	
}

Measured memory_bytes: 1024
#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 <queue>
#include <bitset>
#include <stack>
#include <functional>

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

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, q; cin >> a >> b >> q;
    vector<ll> s(a), t(b), x(q);
    for (ll &e : s) cin >> e; sort(all(s));
    for (ll &e : t) cin >> e; sort(all(t));
    for (ll &e : x) cin >> e;
    for (ll qu : x) {
        ll ans = (ll)1e18;
        auto ups = lower_bound(all(s), qu);
        auto upt = lower_bound(all(t), qu);
        int x = distance(s.begin(), ups), y = distance(t.begin(), upt);
        if (x > 0 && y > 0) chmin(ans, qu - min(s[x - 1], t[y - 1]));
        if (x > 0 && y < b) chmin(ans, t[y] - s[x - 1] + min(t[y] - qu, qu - s[x - 1]));
        if (x < a && y > 0) chmin(ans, s[x] - t[y - 1] + min(s[x] - qu, qu - t[y - 1]));
        if (x < a && y < b) chmin(ans, max(s[x], t[y]) - qu);
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  ll n,a,b;
  std::cin >> n >> a >> b;

  if((b-a)%2==0){
    std::cout << (b-a)/2 << '\n';
    return 0;
  }

  std::cout << std::min(a-1,n-b) + (b-a+1)/2 << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int H,W,j,i;
while(1) {scanf("%d %d",&H,&W);
if (H==0&&W==0)
break;
for (j = 0;j<H;j++){
    for(i=0;i<W;i++){
        printf("#");
    }
    printf("\n");
}

printf("\n");
}
return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

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

    int cnt = 0;
    for ( int i = 0; i < 2; i++ ) {
        if ( a > b ) {
            cnt += a;
            a--;
        }
        else {
            cnt += b;
            b--;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())

ans = max(A, B, C) * (X + Y)
for i in range(max(X, Y) * 2 + 1):
    price = i * C
    price += max(X - i//2, 0) * A
    price += max(Y - i//2, 0) * B
    ans = min(ans, price)
    # print(i, X-i//2, Y-i//2, price, ans)
print(ans)

Measured memory_bytes: 9192
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

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

    vector<int> a(n), b(n);

    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);

    for (int i = 0; i < n; i++)
        scanf("%d", &b[i]);

    for (int i = 1; i < n; i++)
        a[i] += a[i - 1];

    for (int i = n - 2; i >= 0; i--)
        b[i] += b[i + 1];

    int ans = 0;

    for (int i = 0; i < n; i++)
        ans = max(ans, a[i] + b[i]);

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

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(long long i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    ll n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<ll> score(3);
    score[0] = a;
    score[1] = b;
    score[2] = c;
    vector<string> s(n);
    vector<ll> input(n);
    rep(i, n) {
        cin >> s[i];
        if (s[i]=="AB") input[i] = 2;
        if (s[i]=="AC") input[i] = 1;
        if (s[i]=="BC") input[i] = 0;
    }
    string ans = "Yes";
    vector<char> res(n);

    rep(i, n) {
        int x = input[i];
        int y = (x+1)%3;
        int z = (x+2)%3;
        if (score[y]==0 && score[z]==0) {
            ans = "No";
            break;
        }
        if (score[y]>score[z]) {
            score[y]--;
            score[z]++;
            res[i] = z;
            //cout << score[0] << " " << score[1] << " " << score[2] << endl;
            continue;
        }
        if (score[y]<score[z]) {
            score[y]++;
            score[z]--;
            res[i] = y;
            //cout << score[0] << " " << score[1] << " " << score[2] << endl;
            continue;
        }
        if (score[y]==score[z]) {
            int next = input[i+1];
            if (next==x) {
                score[y]++;
                score[z]--;
                res[i] = y;
                //cout << score[0] << " " << score[1] << " " << score[2] << endl;
            }
            else {
                if (next==y) {
                    score[y]--;
                    score[z]++;
                    res[i] = z;
                    //cout << score[0] << " " << score[1] << " " << score[2] << endl;
                }
                else {
                    score[y]++;
                    score[z]--;
                    res[i] = y;
                    //cout << score[0] << " " << score[1] << " " << score[2] << endl;
                }
            }
        }
    }
    
    
    
    cout << ans << endl;
    if (ans=="Yes") {
        rep(i, n) {
            char cc = 'A' + res[i];
            cout << cc << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 7224
#include <iostream>
#include <vector>
using namespace std;
int main(){
 int N;
 cin>>N;
 vector<int> A(N);
 for(int i=0;i<N;i++) cin>>A[i];
 vector<int> rev(N);
 for(int i=0;i<N;i++) rev[A[i]-1]=i+1;
 for(int i=0;i<N;i++) cout<<rev[i]<<endl;
 return 0;
}


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

#define D(x) cout << #x << " = " << (x) << endl;

string query(int i) {
  string sex;
  cout << i << endl;
  cin >> sex;

  if (sex == "Vacant") {
    exit(0);
  }

  return sex;
}

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

  string sex_a = query(0);

  while (true) {
    int mid = (a + b) / 2;
    string sex_mid = query(mid);

    int odd = (mid - a) % 2;
    bool equal_sex = (sex_mid == sex_a);
    if ((odd and equal_sex) or (!odd and !equal_sex)) {
      b = mid;
    } else {
      a = mid;
      sex_a = sex_mid;
    }
  }

  return 0;
}


Measured memory_bytes: 852
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define SORT(x) sort((x).begin(),(x).end())
int main(void){
    
    int a, b, c, d;
    cin >>a >>b >>c >>d;
    
    cout <<((abs(a-c)<=d)||((abs(a-b)<=d)&&(abs(b-c)<=d))?"Yes":"No");
    
    cout <<endl;
}

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

int main(){
   vector<int>a(5);
   int ans=0;
   rep(i,5){
      cin>>a[i];
      if(a[i]==0)ans=i+1;
   }
   cout<<ans<<endl;

}

Measured memory_bytes: 3544
#include <stdio.h>

int main(void){
  
  char s[6];
  for(int i = 0; i < 6; i++){
    scanf(" %c",&s[i]);
  }
  if( s[2] == s[3] && s[4] == s[5] ) printf("Yes");
  else printf("No");
  
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < n; 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 INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


const int NM = 1000;//ここを問題の制約を見ながらいじる．配列の確保に使う．
//ll P[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//ll dp[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
int A[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//int B[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//double Perf[NM];

ll MOD = 1000000007;
int digit_length(int num)
{
    int count = 0;
    while (num) {
        num = num / 10;
        ++count;
    }
    return count;
}


ll gcd(ll a, ll b) {
    ll v0 = a, v1 = b, v2 = a % b;
    while (v2 != 0) {
        v0 = v1;
        v1 = v2;
        v2 = v0 % v1;
    };
    return v1;
}


// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//ll lcm(ll a, ll b) {
//    return a / (gcd(a, b) % MOD) * (b % MOD);
//}

ll lcm(ll a, ll b) {
    return( (a % MOD) *modinv(gcd(a, b), MOD) * (b % MOD)) % MOD;
}
       // Main program



void solve() {
    ll  N;
    cin >> N;

    bool flag = true;

    for (ll i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] % 2 == 0) {
            if ((A[i] % 3 == 0) || A[i] % 5 == 0) {
                ;
            }
            else {
                flag = false;
            }
        }
    }


    if (flag) {
        cout << "APPROVED";
    }
    else {
        cout << "DENIED";
    }
    return;

}



int main() {
    solve();
    return 0;
}







Measured memory_bytes: 256
import java.util.Scanner;

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

	String a = scan.next();
	String b = scan.next();

	String sq = a + b;
	int n = Integer.parseInt(sq);

	int sqrt = (int)Math.sqrt(n);

	if(Math.pow(sqrt, 2) == n){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
    }
}


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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
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; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
vector<int>a(n);
rep(i,n)cin>>a[i];
int mode=-1;
int ans = 1;
int before = a[0];
reps(i,n,1){
    int val=a[i]-before;
    if(val==0) continue;

    if(val>0){
        if(mode==-1){
            mode=0;
        }
        else if(mode!=0){
            ans++;
            mode=-1;
        }
    }
    else{
        if(mode==-1){
            mode=1;
        }
        else if(mode!=1){
            ans++;
            mode=-1;
        }
    }
    before=a[i];
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 640
// Copyright (C) 2018 Sayutin Dmitry.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.

#include <iostream>
#include <vector>
#include <stdint.h>
#include <algorithm>
#include <set>
#include <map>
#include <array>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <string>
#include <assert.h>
#include <iterator>
#include <cstdint>
#include <cinttypes>
#include <string.h>
#include <random>
#include <numeric>
#include <tuple>


using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define pb push_back
#define eb emplace_back


int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    // code here.
    int n = input<int>();
    int64_t C = input<int64_t>();
    
    vector<int64_t> x(n), v(n);
    for (int i = 0; i != n; ++i)
        cin >> x[i] >> v[i];

    int64_t ans = 0;
    for (int swp = 0; swp < 2; ++swp) {
        std::multiset<int64_t> suffix = {0};
        vector<int64_t> sum_of(n + 1);
        for (int i = n - 1; i >= 0; --i) {
            sum_of[i] = v[i] + sum_of[i + 1];
            suffix.insert(sum_of[i] - C + x[i]);
        }

        int64_t cur_sum = 0;
        for (int i = 0; i <= n; ++i) {
            auto pos = (i == 0 ? 0 : x[i - 1]);

            ans = max(ans, cur_sum - 2 * pos + *(suffix.rbegin()));

            if (i != n) {
                suffix.erase(suffix.find(sum_of[i] - C + x[i]));
                cur_sum += v[i];
            }
        }
        
        for (int i = 0; i != n; ++i)
            x[i] = C - x[i];
        std::reverse(ALL(x));
        std::reverse(ALL(v));
    }

    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 8560
#include<bits/stdc++.h>
using namespace std;
#define int long long

int32_t main() 
{
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif 
  ios::sync_with_stdio(0); 
  cin.tie(0); cout.tie(0);
  
  int n, k;
  cin >> n >> k;
  int x[n];
  for(int i = 0; i < n; i++)
     cin >> x[i];

  int ans = 1e18;

  for(int i = 0; i + k - 1 < n; i++){
      if(x[i] * x[i + k - 1] >= 0)
          ans = min(ans, max(abs(x[i]), abs(x[i + k - 1])));
      else
          ans = min(ans, abs(x[i]) + abs(x[i + k - 1]) + min(abs(x[i]), abs(x[i + k - 1])));
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 4420
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] head = br.readLine().split(" ");
    int n = Integer.parseInt(head[0]);
    int m = Integer.parseInt(head[1]);
    int sum = 0;
    String[] line = br.readLine().split(" ");
    for (int i = 0; i < m; i++) {
      sum += Integer.parseInt(line[i]);
    }
    System.out.println(Math.max(n - sum, -1));
  }
}


Measured memory_bytes: 34656
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < 3; ++i) {
		if (s[i] == '1')
			ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
i =input()

#SUN,MON,TUE,WED,THU,FRI,SAT 
  
if i == "SUN":
  print("7")
elif i == "MON":
  print("6")
elif i == "TUE":
  print("5")
elif i == "WED":
  print("4")
elif i == "THU":
  print("3")
elif i == "FRI":
  print("2")
else:
  print("1")


Measured memory_bytes: 2940
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;

  int C[VMAX+1];
  int n, i, j;
  scanf("%d",&n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for ( i = 0 ; i <= VMAX ; i++ )
    C[i] = 0;

  for ( i = 0 ; i < n ; i++ ){
    scanf("%d",&A[i+1]);
    C[A[i+1]]++;
  }

  for ( i = 1 ; i <= VMAX ; i++ )
    C[i] = C[i] + C[i-1];

  for ( j = 1 ; j <= n ; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1 ; i <= n ; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 9628
N, W = map(int, input().split())

IN = list(list(map(int, input().split())) for _ in range(N))
sumw = 0
sumv = 0
for w, v in IN:
    sumw += w
    sumv += v

DP = dict()
DP[sumv] = sumw

def minv(i, v):
    if not DP.get(i):
        DP[i] = v
    else:
        if v < DP[i]:
            DP[i] = v

if sumw <= W:
    ans = sumv
else:
    ans = 0
    for w, v in IN:
        DPpre = DP.copy()
        for i in DPpre:
            answ = i - v
            minv(answ, DPpre[i]-w)
            if answ > ans:
                if DP[answ] <= W:
                    ans = answ
                    continue

print(ans)


Measured memory_bytes: 19676