akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n;
    cin>>n;
    map<ll,ll> mp;
    ll sum=0;
    fr(i,0,n)
    {
        ll x;
        cin>>x;
        mp[x]++;
        sum+=x;
    }
    ll q;
    cin>>q;
    fr(i,0,q)
    {
        ll b,c;
        cin>>b>>c;
        sum-=(b*mp[b]);
        ll tmp=mp[b];
        mp.erase(b);
        mp[c]+=tmp;
        sum+=(tmp*c);
        cout<<sum<<endl;
    }
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 7508
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
/*cout <<"Debug"
cout <<x-30<<' '<<y-30<<endl;
typedef pair<pair<int ,int>, int> P;
vector<pair<pair<int ,int>, int> > v_ans;
vector<int>v_;
vector<long int>v_ansl;
/*taro tenn,hanako_ten,sum*/
/*
bool cmp(P h, P r){
  return h.second < r.second;
}
*/
int v[101];
int main(){
  int N,M;
  int P;
  cin >>N>>M>>P;
  while(!(N == 0 && M == 0 && P == 0)){
    int NUMP = 0;
    int ans = 0;
    for(int i = 0;i < N ; i++){
      cin >>v[i];
      NUMP += v[i];
    }
    if(v[M-1] == 0){
      ans = 0;
      cout <<ans<<endl;
    }
    else{
    cout <<100*NUMP*(100-P)/(100*v[M-1])<<endl;
  }
  cin >>N>>M>>P;
  }
  return 0;
}



Measured memory_bytes: 3068
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;



void solve() {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	int ans = 0;
	rep1(i, n - 1) {
		if (a[i] > a[i - 1])ans++;
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(4);
	//init();
	solve();
	stop
		return 0;
}



Measured memory_bytes: 3360
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  long long a, b, n;
  cin >> n >> a >> b;
  
  if (a > b) swap(a, b);
  if ((a & 1) == (b & 1)) 
    cout << (b - a) / 2;
  else 
   cout << (b - a) / 2 + min(a, n - b + 1); 
    
  return 0;
}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    int N,D;
    cin >>N>>D;
    
    //-----------------------------------
    int x=2*D+1,ans;
    ans=N/x;
    cout << ((N%x==0) ? ans : ans+1) <<endl;
    return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <queue>
     
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;


struct pair_hash
{
	size_t operator()(const std::pair<ll, ll> &v) const 
    {
      
        return std::hash<ll>()(v.first) ^ std::hash<ll>()(v.second);
    }
};

struct state
{
    ll a,b,c;

    state(ll a, ll b, ll c) : a(a), b(b), c(c)
    {

    }

  bool operator==(const state &other) const
  { return (a == other.a
            && b == other.b
            && c == other.c);
  }
};

struct KeyHasher
{
    size_t operator()(const state& k) const
  {
    //using std::size_t;
    //using std::hash;
    //using std::string;

    return ((hash<ll>()(k.a)
               ^ (hash<ll>()(k.b) << 1)) >> 1)
               ^ (hash<ll>()(k.c) << 1);
  }
};  


ull A[200005];
bool visited[200005];
ull N;
ull K;

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

	for (int i = 0; i < N; i++)
	{
		ull x;
		cin >> x;
		x--;
		A[i] = x;
	}

	// find start of the cycle
	ull current = 0;
	
	while (!visited[current])
	{
		visited[current] = true;
		current = A[current];
	}

	ull cycleStart = current;

	// find length of the cycle
	for (int i = 0; i < N; i++) visited[i] = false;
	ull len = 0;

	while (!visited[current])
	{
		visited[current] = true;
		len++;
		current = A[current];
	}

	//cout << "len = " << len << endl;

	//K %= len;

	//cout << "K mod len = "<<  K << endl;
	ull cnt = 0;
	current = 0;

	if (current == cycleStart) K %= len;

	while (K > 0)
	{
		K--;
		current = A[current];

		if (current == cycleStart) K %= len;
	}

	cout << current + 1 << endl;
}


int main()
{
	solve();

	return 0;
}




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

using ll = long long;
using P = pair<int, int>;
using PP = pair<int, P>;
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define rep0(i,n) for (int i=0; i<(n); i++)
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; }
#ifdef _DEBUG
string _format(string args) { string r = "", t; istringstream s(args); while (getline(s, t, ',')) r += t+":%ld "; return r + "\n"; }
#define debug(...) do { printf(_format(#__VA_ARGS__).c_str(), __VA_ARGS__); } while(0)
#define fast_ios() do {} while(0);
#else //_DEBUG
#define debug(...) do {} while(0)
#define fast_ios() do { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } while(0)
#endif //_DEBUG

int main() {
    fast_ios();

    int n, k;
    cin >> k >> n;
    int a[n];
    rep0(i,n) {
        cin >> a[i];
    }
    int max = k - a[n-1] + a[0];
    rep0(i,n-1) {
        if (max < a[i+1]-a[i]) {
            max = a[i+1]-a[i];
        }
    }
 
    ll ans = 0;
    cout << k - max << endl;
}


Measured memory_bytes: 4420
n=int(input())
S=input()
R=[]
G=[]
B=[]
for i in range(n):
	if S[i]=='R':
		R.append(i)
	elif S[i]=='G':
		G.append(i)
	else:
		B.append(i)
r=len(R)
g=len(G)
b=len(B)

c=0
for i in range(n):
	for j in range(i+1,n):
		k=2*j-i
		if k<n:
			if len(set([S[i],S[j],S[k]]))==3:
				c+=1

print(r*g*b-c)

Measured memory_bytes: 74036
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cerr << v[a][b] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

bool cant[20][20];
int mp[20][20];
int a,b,ans;

void dfs(int x,int y)
{
	if(cant[x][y])return;
	
	if(x == a-1 && y == b-1)
	{
		ans++;
		return;
	}
	
	if(x < a-1)
	{
		dfs(x+1,y);
	}
	if(y < b-1)
	{
		dfs(x,y+1);
	}

}

int main()
{
	
	while(cin >> a >> b,a)
	{
		REP(i,20)REP(j,20)cant[i][j] = false;
		ans = 0;
		int n;
		cin >> n;
		
		REP(i,n)
		{
			int x,y;
			cin >> x >> y;
			cant[x-1][y-1] = true;
		}
		
		dfs(0,0);
		
		cout << ans << endl;
	}
		
	
	
	return 0;
}

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

int main() {
	int K;
	cin >> K;
	vector<ll> a(K);
	for (int i = 0; i < K; ++i) { cin >> a[i]; }
	reverse(a.begin(), a.end());

	ll low = 2, high = 2;
	for (int i = 0; i < K; ++i) {
		ll nlow = ((low + a[i] - 1) / a[i]) * a[i];
		ll nhigh = (high / a[i])*a[i] + (a[i] - 1);

		if (nlow > high) {
			cout << -1 << endl;
			return 0;
		}
		low = nlow;
		high = nhigh;
	}

	cout << low << " " << high << endl;

	return 0;
}


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

int main() {
int N,K;
  cin >> N >> K;
  vector<int> count(N);
  int d;
  int member;
  for (int i = 0; i < K; i++){
    cin >> d;
    for(int j = 0; j < d; j++){
    	cin >> member;
      	count[member-1]++;
    }
  }
  int ans = 0;
  for(int i = 0; i < N; i++){
 //   cout << i << ":" << count[i] << " ";
  	if(count[i] == 0){
    	ans++;
    }
  }
 cout << ans << endl;
}

Measured memory_bytes: 3624
import sys
input=sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
m=n//2
if n%2==0:
    dp=[[-10**18]*2 for _ in range(m)]
    dp[0][0]=a[0]
    dp[0][1]=a[1]
    for i in range(1,m):
        for j in range(2*i,2*(i+1)):
            for k in range(2*(i-1),2*i):
                if j-k>1:
                    dp[i][j%2]=max(dp[i][j%2],dp[i-1][k%2]+a[j])
else:
    dp=[[-10**18]*3 for _ in range(m)]
    dp[0][0]=a[0]
    dp[0][1]=a[1]
    dp[0][2]=a[2]
    for i in range(1,m):
        for j in range(2*i,2*(i+1)+1):
            for k in range(2*(i-1),2*i+1):
                if j-k>1:
                    dp[i][j-2*i]=max(dp[i][j-2*i],dp[i-1][k-2*(i-1)]+a[j])
print(max(dp[-1]))

Measured memory_bytes: 42812
#include<stdio.h>

int main(){
    char s[2000];
    int m,n = 1;
    scanf("%s",s);
    scanf("%d",&m);
    for(int i = 0;;i++){
        for(int j = 0;j < m;j++){
            if(s[i * m + j + 1] == '\0') n = 0;
        }
        printf("%c",s[i * m]);
        if(n == 0) break;
    }
     printf("\n");
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const ll MOD = 1e9 + 7;
const int N = 2e6 + 5;
ll fact[N];

void init() {
	fact[0] = 1;
	for (int i = 1; i < N; i++)
		fact[i] = (fact[i-1] * i) % MOD;
}

ll powmod(ll a, ll b) {
	ll r = 1;
	while (b > 0) {
		if (b&1) r = (r * a) % MOD;
		a = (a * a) % MOD;
		b /= 2;
	}
	return r;
}

ll comb(int n, int k) {
	assert(n >= k && k >= 0);
	ll a = (fact[k] * fact[n-k]) % MOD;
	a = (fact[n] * powmod(a, MOD-2)) % MOD;
	//printf("comb(%d, %d) = %lld\n", n, k, a);
	return a;
}

ll g(int r, int c) {
	ll ret = (comb(r + c + 2, c + 1) + MOD - 1) % MOD;
	return ret;
}

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	//~ cout.tie(0);
	init();

	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	--r1, --c1;
	ll a = (g(r1, c1) + g(r2, c2)) % MOD;
	ll b = (g(r1, c2) + g(r2, c1)) % MOD;
	ll ans = (a - b + MOD) % MOD;
	cout << ans << endl;
}


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

vector<int> v[11];
int p[11];
int main()
{
    int n, m;
    cin >> n >> m;

    for(int i=0; i<m; i++)
    {
        int k;
        cin >> k;
        for(int j=0; j<k; j++)
        {
            int tmp;
            cin >> tmp;
            v[tmp-1].push_back(i);
        }
    }

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

    int counts = 0;
    for(int i=0; i<(1<<n); i++)
    {
        int cur[11];
        for(int j=0; j<n; j++)
            cur[j] = 0;
        for(int j=0; j<n; j++)
        {
            if(i&(1<<j))
            for(int k=0; k<v[j].size(); k++)
            {
                cur[v[j][k]] ^= 1;
            }
        }

        bool flag = true;
        for(int j=0; j<m; j++)
        {
            if(cur[j] != p[j])
                flag = false;
        }
        if(flag)
            counts++;
    }
    cout << counts << endl;
    return 0;
}

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

int main() {
  int n;
  scanf("%d", &n);
  v1i v(n+2, 0), u(n+2, 0), w(n);
  rep(i, n) scanf("%d", &v[i+1]);
  rep(i, n+1){
    u[i+1] = u[i] + abs(v[i+1]-v[i]);
    if(i < n) w[i] = abs(v[i+2]-v[i]);
  }
  rep(i, n) printf("%d\n", u[i]+w[i]+u[n+1]-u[i+2]);
  return 0;
}

Measured memory_bytes: 2432
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MAX_V=114514LL;
//const ll MAX = 510000LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};
//約数の列挙O(√n)
vector<ll>divisor(ll n){
  vector<ll>res;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      res.push_back(i);
      if(i != n/i) res.push_back(n/i);
    }
  }
  return res;
}
ll factorial(ll x){
  if(x==0)return 1;
  return x*factorial(x-1)%MOD;
}

ll modpow(ll a, ll n, ll mod) {
  
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll comb(ll n, ll r){
  ll res=1;
    for(ll i=0;i<r;i++){
      res*=n-i;
      res%=MOD;
    }
  res*=modpow(factorial(r),MOD-2,MOD);
  res%=MOD;
  return res;
}

int main(){
  
  ll k,a,b;cin>>k>>a>>b;
  ll two=max(b-a,2LL);
  ll ans=a;
  k-=a-1;
  if(k<=0){
    cout<<k+1<<endl;
    return 0;
  }
  cout<<ans+k/2*two+k%2<<endl;
}

Measured memory_bytes: 256
from sys import stdin
s = int(stdin.readline().rstrip())
A = []
while True:
    if s not in A:
        A.append(s)
    else:
        break
    if s % 2 == 0:
        s = s // 2
    else:
        s = 3 * s + 1
print(len(A) + 1)


Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <string_view>
#include <vector>

#include <cmath>
#include <cctype>

int main() {
  long n, m, k;
  std::cin >> n >> m >> k;

  std::vector<long> a(n);
  std::vector<long> b(m);

  for (auto& i : a) {
    std::cin >> i;
  }

  for (auto& i : b) {
    std::cin >> i;
  }

  long time_spent = 0;
  long n_read_a = 0;
  long n_read_b = 0;

  for (auto const& i : a) {
    if (i <= (k - time_spent)) {
      ++n_read_a;
      time_spent += i;
    } else {
      break;
    }
  }

  long n_total_read = n_read_a;

  for (auto const& i : b) {
TRYAGAIN:
    if (i <= (k - time_spent)) {
      ++n_read_b;
      time_spent += i;

      if (n_read_a + n_read_b > n_total_read) {
        n_total_read = n_read_a + n_read_b;
      }
    } else if (n_read_a > 0) {
      --n_read_a;
      time_spent -= a[n_read_a];
      goto TRYAGAIN;
    } else {
      break;
    }
  }

  std::cout << n_total_read << '\n';
}


Measured memory_bytes: 6272
// B.

#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	int a, b, c;
	cin >> a >> b >> c;
	bool ans = false;
	for (int i = a; i < 1000000; i += a) {
		if ((i % b) == c) {
			ans = true;
			break;
		}
	}
	cout << (ans ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 

////////////////////////////////////////////////////////


int main() {
    ll n, k; cin >> n >> k;
    if(k%2!=0){
        ll ans = 0;
        ans = n/k;
        ans = ans*ans*ans;
        co(ans);
    }else{
        ll a = 0, b = 0;
        a = n/k;
        a = a*a*a;
        b = (n+k/2)/k;
        b = b*b*b;
        co(a+b);
    }

    return 0;
}


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

const int MAX_DIGITS = 10;

int main() {
	vector<long long> digits(MAX_DIGITS);
	digits[0] = 0;
	for(int i = 1; i < MAX_DIGITS; ++i) {
		digits[i] = digits[i - 1] + (pow(10.0, i) - pow(10.0, i - 1)) * i;
	}

	for(int n, k; cin >> n >> k && (n | k);) {
		const int digit = lower_bound(digits.begin(), digits.end(), n) - digits.begin();
		n -= digits[digit - 1];
		const int idx = n / digit;
		int offset = n - idx * digit - (digit == 1 ? 0 : 1);
		int num = pow(10.0, digit - 1) + idx - (digit == 1 ? 1 : 0);

		if(offset == -1) {
			--num;
			offset += digit;
		}

		string str;
		while(static_cast<int>(str.size()) < k + offset) {
			str += to_string(num++);
		}

		cout << str.substr(offset, k) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1280
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	k := scanInt()
	a := scanInts(n)

	sum := make([]int, n+1)
	for i := 0; i < n; i++ {
		sum[i+1] = sum[i]+a[i]
	}

	// debug(sum)

	b := make([]int, 0, n*(n+1)/2)
	for i := 0; i < n; i++ {
		for j := i+1; j < n+1; j++ {
			b = append(b, sum[j]-sum[i])
		}
	}

	f := make([]bool, len(b))
	ans := 0

	for i := 40; i >= 0; i-- {
		c := 0
		for j := 0; j < len(b); j++ {
			if f[j] {
				continue
			}
			if b[j] >> uint(i) & 1 == 1 {
				c++
			}
		}

		if c >= k {
			ans += 1 << uint(i)
			for j := 0; j < len(b); j++ {
				if f[j] {
					continue
				}

				if b[j] >> uint(i) & 1 == 0 {
					f[j] = true
				}
			}
		}
	}

	// ans := 1<<63-1
	// for i := 0; i < len(b); i++ {
	// 	if f[len(b)-1-i] {
	// 		continue
	// 	}
	// 	ans &= b[len(b)-1-i]
	// 	// debug(b[len(b)-1-i])
	// 	k--
	// 	if k == 0 {
	// 		break
	// 	}
	// }

	fmt.Fprintln(wr, ans)
}


Measured memory_bytes: 5248
#include <vector> // vectorを使うためにインクルードする
#include <iostream>
using namespace std;


int main() {
	int x,y,z;
	cin >> x >> y >> z;
	if((y*10+z) %4 == 0){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
	}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    char A[4];
    int  y=0;
    rep(i,1){
        cin >> A;
    }
    rep(i,4){
        if(A[i]=='+')  y++;
        else y--;
    }
    cout << y << endl;
}

Measured memory_bytes: 256
#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 MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int N;
  cin >> N;
  vector<string> A(N);
  map<string,int> mp;
  REP(i, N){
    cin >> A[i];
    mp[A[i]]++;
  }
  

  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
}

Measured memory_bytes: 6384
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int i = 1;
    while(a != 0){
      System.out.println("Case "+ i + ": " + a);
      a = sc.nextInt();
      i++;
    }
  }
}

Measured memory_bytes: 41632
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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 x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int n;
  cin>>n;

  vector<string> p(n);
  vector<vector<int>> g(n);
  rep(i,n){
    string s;
    cin>>s;
    p[i]=s;
    rep(j,n){
      if(s[j]=='1') g[i].pb(j);
    }
  }

  int ans=-1;
  rep(i,n){
    vector<int> dist(n,-1);
    deque<int> que;
    vector<bool> ch(n,true);
    vector<vector<int>> q(n);
    dist[i]=0;
    que.pb(i);
    q[0].pb(i);
    while(!que.empty()){
      int v=que.front();
      que.pop_front();

      if(ch[dist[v]]) {
        ch[dist[v]]=false;
        bool ok=true;
        for(int y : q[dist[v]]){
          for(int z : q[dist[v]]){
            if(p[y][z]=='1') ok=false;
          }
        }
        if(!ok) {
          dist[i]=-1;
          break;
        }
      }

      for(int nv : g[v]){
        if(dist[nv]!=-1) continue;
        dist[nv]=dist[v]+1;
        que.pb(nv);
        q[dist[nv]].pb(nv);
      }
    }
    if(dist[i]==-1) continue;
    rep(j,n){
      chmax(ans,dist[j]+1);
    }
  }

  cout << ans << endl;

}

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

int main(){
	int n;
	const int smax = 1000;
	string s[smax];
	while(cin >> n){
		if(n == 0) break;
		for(int i = 0; i < n; i++){
			cin >> s[i];
		}
		int c = 0;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				int count = 0;
				if(s[i][j] == '.'){
					int m = min(n - i, n - j);
					int k = 1;
					while(k < m){
						int a = 0, b = 0;
						while(a<k){
							if(s[i+k][j+a] == '*') break;
							a++;
						}while(b<k){
							if(s[i+b][j+k] == '*') break;
							b++;
						}
						if((a != k || b != k) || s[i+k][j+k] == '*') break;
						k++;
					}
					c = max(c,k);
				}
			}	
		}
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
#define pi 3.14159265359
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p;
    cin >> k;
    string s, t;
    cin >> s;
    if(s.length() <= k){
        cout << s;
    }
    else{
        t = s.substr(0,k);
        t += "...";
        cout << t;
    }


    return 0;
}


Measured memory_bytes: 3656
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		char op = sc.next().charAt(0);
		int b = sc.nextInt();
		
		int ans = a + (op == '+' ? b : -b);
		System.out.println(ans);
		
		sc.close();
	}
}



Measured memory_bytes: 27056
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	int a;
	cin >> a;
	cout << a + a*a + a*a*a << endl;
	
}





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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int n, k; cin >> n >> k;
	int d[101];
	int a[101][101];
	int cnt[101];
	for(int i=1;i<=n;i++){
		cnt[i] = 0;
	}
	for(int i=0;i<k;i++){
		cin >> d[i];
		for(int j=0;j<d[i];j++){
			cin >> a[i][j];
			cnt[a[i][j]]++;
		}
	}
	int ans = 0;
	for(int i=1;i<=n;i++){
		if(cnt[i]==0) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
S = list(input())
tf = [False for _ in range(7)]
key = list("keyence")
for n in range(7):
    if S[n] == key[n]:
        tf[n] = True
    else:
        break
for n in range(1, 8):
    if S[-n] == key[-n]:
        tf[-n] = True
    else:
        break
if all(tf):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 38384
N = int(input())
a = list(map(int,input().split()))

b = [0 for i in range(N//2)]+a[N//2:]

for i in range(N//2-1,-1,-1):
    if sum(b[i::i+1])%2 == 0:
        b[i] = a[i]
    else:
        b[i] = 1-a[i]

ans = []
for i in range(N):
    if b[i] == 1:
        ans.append(i+1)

print(len(ans))
print(' '.join(map(str,ans)))


Measured memory_bytes: 20276
//#include <bits/stdc++.h>
#include <utility>
#include <math.h>
#include <string.h>
#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>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second

vector<char> add = { '0', '3', '5', '7' };
int f(string &s, int p, int low, int m)
{
	if (p == s.length())
		return m == 168;
	int ans = 0;
	for (auto i : add)
		if ((i != '0' && (low || i <= s[p])) || (i == '0' && m == 0))
			ans += f(s, p+1, low || i < s[p], m | (i!='0')<<(i-'0'));
	return ans;
}

int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
	#endif
	ios_base::sync_with_stdio(0), cin.tie(0);

	string s;
	cin >> s;
	cout << f(s, 0, 0, 0) << "\n";

	return 0;
}


Measured memory_bytes: 256
def main():
    N, x = (int(i) for i in input().split())
    a = [int(i) for i in input().split()]
    num = 0
    for i in sorted(a):
        x -= i
        if x >= 0:
            num += 1
        else:
            break
    if x > 0:
        num -= 1
    print(num)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import collections

def gcd(a,b):
  if a < b:
    a,b = b,a
  while a % b != 0:
    r = a % b
    a,b = b,r
  return b

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

A, B = map(int, input().split())
t = gcd(A, B)

c = collections.Counter(prime_factorize(t))
print(len(c.keys())+1)



Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    sc.nextLine();
    char[] S = sc.nextLine().toCharArray();
    Main abc150B = new Main();
    System.out.println(abc150B.solve(S));
  }

  public Integer solve(char[] S){
    Integer ret = 0;
    char[] a = {'A', 'B', 'C'};
    int ai = 0;
    for(int i = 0; i < S.length; i++ ){
      if(S[i] != a[ai]) {
        ai = 0;
      }
      if(S[i] == a[ai]) {
        ai++;
        if(ai >= a.length) {
          ret += 1;
          ai = 0;
        }
      } 
    }
    return ret;
  }
}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,W; cin >> N >> W;
    VI v(N),w(N);
    REP(i,N) cin >> v[i] >> w[i];

    int dp[105][10005] = {};

    REP(i,N) for(int j = W; j >= 0; j--){
        if(j >= w[i]) dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
        else dp[i+1][j] = dp[i][j];
    }
    cout << dp[N][W] << endl;

}


Measured memory_bytes: 7300
#include <bits/stdc++.h>
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(i,n) rep2(i,0,n)
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> a(n);
    rep(i,n){
        cin >> a[i].first;
        a[i].second=i;
    }
    sort(a.begin(),a.end());
    int ans=0;
    rep(i,n)if(i%2!=a[i].second%2)++ans;
    cout << ans/2 << endl;
    return 0;
}

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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30

#define P 1000000007

int n[2];
ll x[2][100010];

int main()
{
	ll ret[2] = {0,0};

	cin >> n[0] >> n[1];
	rep(i,2)rep(j,n[i]) cin >> x[i][j];

	rep(i,2)rep(j,n[i]-1){
		ret[i] = ( ret[i] + (ll)(j+1) * (n[i]-1-j) * (x[i][j+1] - x[i][j]) ) % P;
	}

	printf("%lld\n", ret[0] * ret[1] % P );

	return 0;
}


Measured memory_bytes: 1792
if __name__ == "__main__":
    i = 0
    while True:
        v = map( int, raw_input().split())
        if v[0] == 0:
            if v[1] == 0:
                break
        i += 1
        if v[0] > v[1]:
            print "{0} {1}".format(v[1],v[0])
        else:
            print "{0} {1}".format(v[0],v[1])

Measured memory_bytes: 6376
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long MOD = 1e9 + 7;
long long repow(long long x, long long y){
    if(y == 0) return 1;
    if(y % 2 == 0){
        long long t = repow(x, y / 2);
        return t* t % MOD;
    }
    return x * repow(x, y - 1) % MOD;
}
const int MAX = 1000000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = 1;
    finv[0] = 1;
    inv[0] = 1;
    for(int i = 1; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = repow(i, MOD - 2);
        finv[i] = finv[i -1] * inv[i] % MOD;
    }
}
long long COM(long long n, long long k){
    if(k > n || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n - k] % MOD;
}
int main(){
    COMinit();
    int N, K;
    cin >> N >> K;
    int aka = N - K;
    for(int i = 1; i <= K; i++){
        long long ans = COM(aka + 1, i) * COM(K - 1, i - 1) % MOD;
        cout << ans << endl;
    }
}

Measured memory_bytes: 27072
#include<iostream>
#include<cstring>
#include<cstdio>
#define MN 100000
using namespace std;
inline 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;
}
char s[5];long long f[MN+5][4];
int a[MN+5],op[MN+5],n;
#define S(x) ((x)?-1:1)
inline void R(long long&x,long long y){y>x?x=y:0;}
int main()
{
	n=read();a[1]=read();
	for(int i=2;i<=n;++i) scanf("%s",s),op[i]=s[0]=='-',a[i]=read();
	memset(f,200,sizeof(f));f[1][0]=a[1];
	for(int i=2;i<=n;++i)
		for(int j=0;j<4;++j) 
			for(int k=0;k<2;++k)
			{
				int OP=j>>k&1;
				if(!k) R(f[i][j],f[i-1][j]+S(OP^op[i])*a[i]),
					   R(f[i][(j&2)|(OP^op[i])],f[i-1][j]+S(OP^op[i])*a[i]);
				R(f[i][OP<<1|(OP^op[i])],f[i-1][j]+S(OP^op[i])*a[i]);	
			}
	long long ans=-1e18;
	for(int i=0;i<4;++i) R(ans,f[n][i]);
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 4096
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}

signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    /*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    int n,x,y;
    cin>>n>>x>>y;
    x--;y--;
    int count[n+1];
    for (int i = 0; i < n; ++i)
    {
        count[i+1]=0;
    }
    for (int i = 0; i < n; ++i)
    {
        for (int j = i+1; j < n; ++j)
        {
            int dist1 =  j-i;
            int dist2 =  abs(j-x)  +  abs(i-y) + 1;
            int dist3 = abs(i-x) + abs(j-y) + 1;
            int dist = min({dist1,dist3,dist2});
           // cout<<i<<" "
            count[dist]++;
        }
    }

    for (int i = 0; i < n-1; ++i)
    {
        cout<<count[i+1]<<endl;
    }

    printclock;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [2*int(_) for _ in input().split()]
t = a[-1]
x = [0 for _ in range(n)]
for i in range(-2, -n-1, -1):
    t = a[i] - t
x[0] = t // 2
for i in range(0, n-1):
    x[i+1] = a[i] - x[i]
for i in range(len(x)):
    print(x[i])

Measured memory_bytes: 65252
S = str(input())
vertical,side = ['N', 'S'], ['W', 'E']

ans1,ans2 = 0,0

for l in vertical:
  if l in S:
    ans1 += 1
for l in side:
  if l in S:
    ans2 += 1
if ans1 >= 2 and ans2 >= 2:
  print('Yes')
elif ans1 >= 2 and ans2 == 0:
  print('Yes')
elif ans1 == 0 and ans2 >= 2:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9064
#include <stdio.h>

int main(void)
{
  int h, w, a, b;
  scanf("%d %d %d %d", &h, &w, &a, &b);
  
  int s[w];
  for (int i = 0; i < a; i++){
    s[i] = 1;
  }
  for (int i = a; i < w; i++){
    s[i] = 0;
  }
  
  for (int i = 0; i < b; i++){
    for (int j = 0; j < w; j++){
      printf("%d", s[j]);
      if (j == w - 1) printf("\n");
    }
  }
  
  for (int i = 0; i < w; i++){
    if (s[i] == 1) s[i] = 0;
    else s[i] = 1;
  }
  
  for (int i = 0; i < h - b; i++){
    for (int j = 0; j < w; j++){
      printf("%d", s[j]);
      if (j == w - 1) printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
#include<stdlib.h>
int *t,n;

void maxheapify(int i){
  int l=2*i,r=2*i+1,large,v;
  if(l<=n&&t[l]>t[i])large=l;
  else large=i;
  if(r<=n&&t[r]>t[large])large=r;
  if(large!=i){
    v=t[i];
    t[i]=t[large];
    t[large]=v;
    maxheapify(large);
  }
}

int main(){
  int i;
  scanf("%d",&n);
  t=(int*)malloc(n*sizeof(int));
  for(i=1;i<=n;i++)scanf("%d",&t[i]);
  for(i=n/2;i>=1;i--)maxheapify(i);
  for(i=1;i<=n;i++)printf(" %d",t[i]);
  printf("\n");
  return 0;
}
    



Measured memory_bytes: 3668
#include <iostream>
#include <string>

using namespace std;

int main() {
	string x;
	int answer;
	char c[1000];

	while (cin >> x && x != "0") {
		answer = 0;
		
		for (int i = 0; i < x.length(); i++)
			answer += int(x.c_str()[i] - '0');


		cout << answer << endl;
	}
}



Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define int long long 
#define endl "\n"
using namespace std ; 


int32_t main()
{ 
	ios_base::sync_with_stdio(false) ;	
	cin.tie(NULL);
	
	int n ;	
	cin >>  n ;	 
	string  s ;	
	cin >> s ;	
	string s1 = s ;
	sort(s.begin() , s.end()) ;	
	int  cnt = 0 ;	 
	for(int i = 0 ; i  < n ; ++i)
	{
		if(s[i] != s1[i])
			cnt++ ; 
	}
	cout << cnt/2 ; 
                                         
}              













Measured memory_bytes: 3800
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

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

    int ans = 1;
    repi(ri, n, 0)
    {
        if (ans < k)
        {
            ans *= 2;
        }
        else
        {
            ans += k;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector> 
#include <algorithm> 
#include <bits/stdc++.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <functional> 
#include<math.h> 
#include<cstring>
using namespace std;
int main(void){
    // Your code here!
   string s;
   cin >> s;
   int n;
   n = s.size();
   cout << s.at(0) << n-2 << s.at(n-1) << endl;
}
#include <iostream> 


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

#define debug(x) cerr<<#x<<'='<<x<<'\n'

struct point {
	long long x, y;
	bool operator < (point B) const {
		return x==B.x ? y<B.y : x<B.x;
	}
} p[55];

int main(void) {
	int n, K;
	cin>>n>>K;
	for (int i=1; i<=n; i++) {
		cin>>p[i].x>>p[i].y;
	}
//	sort(p+1, p+1+n);
	long long ans=9223372036854775807;
	//debug(ans);
	for (int o=1; o<=n; o++) {
		for (int i=o; i<=n; i++) {
			for (int j=1; j<=n; j++) {
				for (int k=j; k<=n; k++) {
					long long x1=p[o].x, x2=p[i].x, y1=p[j].y, y2=p[k].y;
					if (abs(x1-x2)*1ll*abs(y1-y2)>ans) continue;
					int cnt=0;
					for (int l=1; l<=n; l++) {
						if (p[l].x<=max(x1, x2) && p[l].x>=min(x1, x2) && p[l].y>=min(y1, y2) && p[l].y<=max(y1, y2)) {
							cnt++;
						}
					}
					if (cnt>=K) {
						ans=min(ans, abs(x1-x2)*1ll*abs(y1-y2));
					}
				}
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
use proconio::*;

#[fastout]
fn run() {
    input! {
        n: usize,
        a: [usize; n],
        q: usize,
        ask: [(usize, usize); q],
    }
    let m = 100_000;
    let mut cnt = vec![0; m + 1];
    let mut sum = 0;
    for a in a {
        cnt[a] += 1;
        sum += a;
    }
    for (b, c) in ask {
        sum += cnt[b] * (c - b);
        cnt[c] += cnt[b];
        cnt[b] = 0;
        println!("{}", sum);
    }
}

fn main() {
    run();
}

Measured memory_bytes: 6844
import itertools
import bisect
import sys
input = sys.stdin.readline


def main():
    A, B, Q = map(int, input().split())
    S = [int(input()) for _ in range(A)]
    T = [int(input()) for _ in range(B)]
    X = [int(input()) for _ in range(Q)]

    for x in X:
        i_s = bisect.bisect_left(S, x)
        i_t = bisect.bisect_left(T, x)
        Cs = []
        Ct = []
        if i_s!=0:
            s_l = S[i_s - 1]
            Cs.append(s_l)
        if i_s!=len(S):
            s_r = S[i_s]
            Cs.append(s_r)
        if i_t!=0:
            t_l = T[i_t - 1]
            Ct.append(t_l)
        if i_t!=len(T):
            t_r = T[i_t]
            Ct.append(t_r)
        # print(x)
        # print(Cs)
        # print(Ct)
        ans = float('inf')
        for C in itertools.product(Cs, Ct):
            ans = min(ans, abs(x-C[0])+abs(C[0]-C[1]))
            ans = min(ans, abs(x-C[1])+abs(C[1]-C[0]))
            # print(C)
        print(ans)


if __name__ == '__main__':
    main()

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

string s;

int main(){
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]) cout << "Yes" << endl;
    else cout << "No" <<endl;
}

Measured memory_bytes: 256
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
    i = bisect.bisect_left(A, b)
    j = bisect.bisect_right(C, b)
    ans += i*(N-j)
print(ans)

Measured memory_bytes: 23232
n=int(input())
listd = [int(i) for i in input().split()]

ans=0
temp=0
for i in range(n-1):
	for j in range(i+1,n):
		temp=listd[i]*listd[j]
		ans=ans+temp
	#	print(temp)
		#print(ans)
		
print(ans)

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

int main(){
	int a, b;
	cin >> a >> b;;
	if(b == 1){
		cout << 0 << endl;
      	return 0;
	}
	if(b-a<=0){
		cout << 1 << endl;
      	return 0;
	}
	int ans = 1;
	b -= a;
	while(b>0){
		b -= a-1;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 105
#define MAXC 2005
#define INF 2e8

int A[MAX][MAX], w[MAXC], stat[MAX], n;

int minimum(int a, int b){
	if (a>b)
		return b;
	else return a;
}

int main(void) {
	int a, i, j, min, cost=0;
 
	scanf("%d",&n);
	for(i=0; i<n; i++){
  		w[i]=INF;
  		stat[i]=0;
	for(j=0; j<n ;j++)
  		scanf("%d",&A[i][j]);
	}
	w[0]=0;
	
	while(1){
		min = -1;
		for(i=0; i<n; i++){
			if(stat[i]==0 && (w[i] < w[min] || min==-1))
				min = i;
		}
		if(min == -1)
			break;
		stat[min] = 1;
		cost += w[min];
		for(i=0; i<n; i++){
			if(A[min][i]==-1)
  				continue;
  			w[i] = minimum(w[i],A[min][i]);
		}
	}

	printf("%d\n", cost);
  
	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int i=0,j,c=0,a[1000],saidai=0,m,n;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> a[i];
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            m=abs(a[i]-a[j]);
                if(m>saidai)
                {
                    saidai=m;
                }
        }
    }
    cout << saidai << endl;
    return 0;

}


Measured memory_bytes: 3564
#include <iostream>
#include <string>

using namespace std;
int N;
int A[210];

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

  while(true){
    bool checker = false;
    for(int i = 0;i<N;i++){
      if(A[i]%2!= 0)checker = true;
    }
    if(checker)break;

    for(int i = 0;i<N;i++){
      A[i] /= 2;
    }
    res++;
  }
  cout << res << endl;
}


Measured memory_bytes: 256