akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n;
string s;
int main(){
// 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> s;
	int ans = 0;
	for(int i = 0;i < n;i++){
		if(s[i] == 'A'){
			if(i + 1 < n && s[i + 1] == 'B'){
				if(i + 2 < n && s[i + 2] == 'C') ans++;
			} 
		}
	}
	cout << ans << endl;
	return 0;
}
//do smt instead of nothing! never give up!
//take care of long long!
//take care of upper or lower case e.g "yes" or "YES"?
//boundary condition! e.g. n = 0?
//brute force is always the first choice!
// print the ans to look for patterns in the data!

Measured memory_bytes: 256
import numpy as np

N,L=map(int,input().split())
taste=list(range(L,L+N))
#print(sum(taste))
min_abs=10**5
for i in range(N):
    if abs(sum(taste)-(sum(taste)-taste[i]))<min_abs:
        min_abs=abs(taste[i])
        rec=taste[i]
        #print(rec)
        
        
print(sum(taste)-rec)

Measured memory_bytes: 12508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if (s == u)
		cout << a - 1 << " " << b;
	else
		cout << a << " " << b - 1;
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <stack>
using namespace std;
using ll = long long int;

int main(){
    int n; cin >> n;
    vector<int> d(n);
    int ans = 0;
    for(auto& v:d){
        cin >> v;
    }
    if(n > 23){
        cout << "0" << endl;
        return 0;
    }
    else if(n > 11){
        vector<int> cnt(13, 0);
        for(auto& v:d){
            cnt[v]++;
        }
        for(int i=1; i<12; i++){
            if(cnt[i] > 2){
                cout << "0" << endl;
                return 0;
            }
        }
        if(cnt[0] > 0 || cnt[12] > 1){
            cout << "0" << endl;
            return 0;
        }
        cout << "1" << endl;
        return 0;
    }
    else{
        for(ll i=0; i<(1L << n); i++){
            vector<int> time(n+2, 0);
            time[n] = 0; time[n+1] = 24;
            for(int j=0; j<n; j++){
                if(i & (1L << j)){
                    time[j] = d[j];
                }
                else{
                    time[j] = 24 - d[j];
                }
            }
            sort(time.begin(), time.end());
            int val = 24;
            for(int j=0; j<n+1; j++){
                val = min(val, time[j+1] - time[j]);
            }
            ans = max(ans, val);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
amax, amin = max(a), min(a)
ans=5*10**6
for i in range(min(a), max(a)+1):
  tmp=0
  for j in range(n):
    tmp+=(a[j]-i)**2
  ans=min(tmp,ans)
print(ans)

Measured memory_bytes: 64012
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cassert>
#include <string.h>

using namespace std;
#define  rep(i,n) for(int i=0;i<n;i++)
#define  rrep(i,n) for(int i=n;i>0;i--)
#define  REP(i,a,b) for(int i=a;i<b;i++)
typedef long long int lld;
typedef vector<lld> vl;
typedef vector<int> vi;
typedef vector<string> vs;



//int arr[N]
////sort(arr,arr +N)

//vector <int> hoge
////sort(hoge.begin(),hoge.end());
///min_element(hoge.begin(),hoge.end();　最小値　　　最大値はmax_element();

int main() {

	string s;
	int a=0,b=0;

	cin>>s;
	int len=s.length();
	//0 1 0 1
	rep(i,len){
		if(i%2==1){
			if(s[i]=='0')
				a++;
		}
		else{
			if(s[i]=='1')
				a++;
		}

	}
	//1 0 1 0
	rep(i,len){
		if(i%2==1){
			if(s[i]=='1')
				b++;
		}
		else{
			if(s[i]=='0')
				b++;
		}

	}
	//cout<<a<<"\n"<<b<<"\n";
	cout<<min(a,b);
	return 0;
}



Measured memory_bytes: 512
#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() {
	int n, r;
	cin >> n >> r;

	if (n >= 10) {
		col(r);
	}
	else {
		col(r + 100 * (10 - n));
	}

	return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <set>

using namespace std;

int main() {
    int n, a, s;
    set<int> d;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a);
        s = d.size();
        d.erase(a);
        if (s == d.size()) d.insert(a);
    }
    printf("%ld\n", d.size());
    return 0;
}


Measured memory_bytes: 4864
char S[12];
char out[2<<20];
int outsz,Slen;
main()
{
	int N,K;
	scanf("%d%d ",&N,&K);
	gets(S);
	Slen=strlen(S);
	S[Slen++]='\n';
	for(int i=0;i<K;i++)
	{
		memcpy(out+i*Slen,S,Slen);
	}
	outsz=K*Slen;
	N-=K;
	for(int i=0;i<N;i++)
	{
		out[outsz+i*2]='7';
		out[outsz+i*2+1]='\n';
	}
	write(1,out,outsz+N*2);
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<pi> vpi;
typedef vector<bool> vbool;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define forall(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define F0(i,n) for(ll i = 0; i < n; i++)
#define F1(i,n) for(ll i = 1; i <= n; i++)
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define per(i,a,b) for(int i = b-1; i >= a; i--)
#define FIN ios::sync_with_stdio(false);cin.tie(0);
#define db(x) cout<<#x<<" = "<<x<<"\n"
#define all(v) v.begin(),v.end()
#define modulo(a,b) ((a%b)+b)%b
#define F first
#define S second
#define INF 1000000010
#define INFLL 1000000000000000000
#define eps 0.000000000001
#define mod 1000000007
template<class C> void mini(C&a, C b){ a=min(a, b);}
template<class C> void maxi(C&a, C b){a=max(a,b);}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

//=======================//
/*
Idea 1
dp con bitmasks:
dp[i][b] es la cantidad de formas de matchear a los primeros i hombres, donde b es la bitmask que
representan las mujeres que estan ya "tomadas".

Idea 2
Puedo quitar la dimension i, porque i siempre va a ser igual a la cantidad de unos en la bitmask.
Entonces dp[bitmask] es la cantidad de formas de "repartir" a las mujeres que tienen un 1. La respuesta
va a ser dp[bitmask-maxima].
Cuando estoy en el estado dp[b], cuento cuantos unos tiene: i. Recorro los valores del hombre i y en las posiciones j
en que los valores y la bitmask valen uno, me muevo al estado con la bitmask b' que es igual a b, salvo que la posicion
j ahora vale 1.
*/

int max_bitmask;
int n;

bool available(int bitmask, int mujer) {
	return ((1 << mujer) & bitmask) == 0;
}

int main () {
	//FIN
	cin >> n;
	max_bitmask = 1 << n;
	bool match[n][n];
	vi dp(max_bitmask,0);
	F0(i,n) F0(j,n) {
		cin >> match[i][j];
	}
	F0(i,max_bitmask) dp[i] = 0;
	dp[0] = 1;
	for(int b = 0; b < max_bitmask; b++) {
		int hombre = __builtin_popcount(b);
		for (int mujer = 0; mujer < n; mujer ++) {
			if (match[hombre][mujer] && available(b, mujer)) {
				dp[b ^ (1<<mujer)] += dp[b]; dp[b ^ (1<<mujer)] %= mod;
			}
		}
	}
	cout << dp[max_bitmask - 1] << "\n";
	return 0;
}


Measured memory_bytes: 11448
h,w=map(int,input().split())

x=[input() for _ in range(h)]
y=[x[i] for i in range(h) if '#'in x[i]]
      
c=[]
for i in range(len(y)):
      for j in range(w):
            if y[i][j]=='#':
                  c.append(j)
d=list(set(c))
z=[]
for i in range(len(y)):
      w=[]
      for j in d:
            w.append(y[i][j])
      z.append(w)

for i in range(len(z)):
      print(''.join(z[i]))

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
        ll x,k,d;
        cin>>x>>k>>d;
        x=abs(x);
        ll t=x/d;
        ll a=x%d;
        if(k<=t)
        {
            a=x-k*d;
        }
        else{
            k-=t;
            if(k%2==1)
            {
                a-=d;
                a=abs(a);
            }
        }
        cout<<a<<'\n';
}

main()
{
//      fastio();
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 3636
const lineList = require('fs').readFileSync('/dev/stdin','utf8').trim().split('\n')

const n = parseInt(lineList[0])
const b = lineList[1].split(' ').map(e => parseInt(e))
var a = 0

a += b[0]
for(var i=0;i<b.length;i++) {
  a += b[i]

  if(b[i-1] > b[i]) {
    a -= b[i-1]
    a += b[i]
  }
}

console.log(a)


Measured memory_bytes: 11468
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };



int main() {
	int A,B,K;
	scanf("%d%d%d", &A,&B,&K);

	int count = 0;

	for (int i = 100; i > 0; i--) {
		if (A % i == 0 && B % i == 0) count++;
		if (count == K) {
			printf("%d", i);
			break;
		}
	}


}




/*         提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
・文字列の＜＜スペル＞＞は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

Measured memory_bytes: 128
import java.io.*;
 
class Main{
    public static void main(String args[]) throws IOException{
        BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(buf.readLine());
        StringBuilder sb = new StringBuilder();
         
        int num = 0;
        for(int j=3; j<=n; j++){
            if(j%3==0){
                sb.append(" "+j);
            } else {
                num = j;
                while(num != 0){
                    if(num%10==3){
                        sb.append(" "+j);
                        break;
                    } else{
                        num = num/10;
                    }   
                }
            }           
 
        }
        System.out.println(sb);
    }
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int a, b;
    cin >> a >> b;
    cout << a * b << endl;

    return 0;
}



Measured memory_bytes: 3652
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

signed main() {
    SS(ll,x)
    vector<bool>dp(101000);
    dp[0]=true;
    rep(i,100001)rep(j,6)if(dp[i])dp[i+100+j]=true;
    dp[x]?p(1):p(0);
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];
#define int long long

signed main(){
    int N; cin >> N;
    double jpy = 0, btc = 0;
    rep(i,N){
        double x; string u;
        cin >> x >> u;
        (u[0]=='J' ? jpy : btc) += x;
    }
    cout << jpy + 380000.0 * btc << endl;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(3*N,0);
    REP(i,3*N){
        cin >> A[i];}
    sort(A.begin(),A.end());
    ll ans = 0;
    REP(i,N){
        ans += A[3*N-2*(i+1)];}
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
N=int(input())
V=[0 for i in range(N)]
for i in range(N):
  k,p=map(int,input().split())
  if p>=k:
    c=k
  else:
    while True:
      b=k-p
      if b<=p:
        c=b
        break
      else:
        k=b
  V[i-1]=c

for i in range(N):
  print(V[i-1])


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

using namespace std;

const double PI = acos(-1);

int main()
{
  long long n;
  cin >> n;
  vector<long long> x(n), y(n);
  for(long long i = 0;i < n;i++)
  cin >> x[i];
  for(long long i = 0;i < n;i++)
  cin >> y[i];

  cout << fixed << setprecision(20);
  
  long long D1 = 0;
  for(long long i = 0;i < n;i++)
  D1 = D1 + abs(x[i] - y[i]);
  cout << D1 << endl;

  long long D2 = 0;
  for(long long i = 0;i < n;i++)
  D2 = D2 + (x[i] - y[i]) * (x[i] - y[i]);
  cout << pow(D2, 1 / 2.) << endl;
  
  long long D3 = 0;
  for(long long i = 0;i < n;i++)
  D3 = D3 + abs(x[i] - y[i]) * abs(x[i] - y[i]) * abs(x[i] - y[i]);
  cout << pow(D3, 1 / 3.) << endl;

  long long D = 0;
  for(long long i = 0;i < n;i++)
  D = max(D, abs(x[i] - y[i]));
  cout << D << endl;
}



Measured memory_bytes: 3476
#include<bits/stdc++.h>
#define ll long long int
const ll mod=1e9+7;
const int maxn=500;
using namespace std;


int main()

{

    int n;cin>>n;
    vector<int> a;
    for(int i=0;i<n;i++)
    {
    	int x;
    	cin>>x;
    	a.push_back(x);
	}
	sort(a.begin(),a.end());
	vector<int> ::iterator low;
	int res=0;
	for(int i=0;i<n-1;i++)
	{
		for(int j=i+1;j<n-1;j++)
		{
		//	cout<<i<<" "<<j<<"plplplp "<<endl;
			int start,finish;
			start=j+1;
			finish=n-1;
			while(finish>=start)
			{
				int mid=(start+finish+1)/2;
				if(a[mid]<a[i]+a[j])
				{
					start=mid+1;
				}
				else
				{
					finish=mid-1;
				}
			}
		//	cout<<i<<" "<<j<<" "<<finish-j<<endl;
			res+=finish-j;
		}
	}
	cout<<res;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,s,e) for(int i=(s);i<=(e);i++)
#define FORD(i,s,e) for(int i=(s);i>=(e);i--)
#define eb emplace_back
#define MAXN 1000009
#define MOD 1000000007
#define mp(x, y) make_pair(x,y)
#define all(v) (v).begin(),(v).end()
#define pb(x) push_back(x)
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second

using namespace std;

typedef unsigned long long LLU;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
const bool print=false;
typedef long long ll;

template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

int n;
vector<pair<PII,PII>>p;
int a[505][505];
int main()
{
    scanf("%d", &n);
    int m;
    scanf("%d", &m);
    for(int i=0;i<n;i++)
    	for(int j=0;j<m;j++){
    		int t;
    		scanf("%d",&t);
    		a[i][j]+= t;
    		if(a[i][j] % 2 == 1){
    			if(i != n - 1){
    				p.pb(mp(mp(i+1,j+1), mp(i+2, j+1)));
    				a[i][j]--;
    				a[i+1][j]++;
				}else if(j != m - 1){
    				p.pb(mp(mp(i+1,j+1), mp(i+1, j+2)));
    				a[i][j]--;
    				a[i][j+1]++;
				}
			}
		}
	printf("%d\n", p.size());
	for(int i = 0; i < p.size(); i ++)
		printf("%d %d %d %d\n", p[i].ff.ff, p[i].ff.ss, p[i].ss.ff, p[i].ss.ss);
}



Measured memory_bytes: 5232
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main(){
  string str,mn,ml;
  map<string,int> cnt;

  while( cin >> str ){
    int xx = ++cnt[str];
    if( xx > cnt[mn] ) mn = str;
    if( str.size() > ml.size()) ml = str;
  }
  cout << mn << " " << ml << endl;

  return 0;
}

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

#define PI 3.14159265359

int main(){
  int N;
  cin >> N;
  int d1, d2;
  bool flag = false;
  for (int i = 0; i < N; i++){
    cin >> d1 >> d2;
    if (d1 == d2 && i < N){
      i++;
      cin >> d1 >> d2;
      if (d1 == d2 && i < N){
        i++;
        cin >> d1 >> d2;
        if (d1 == d2 && i < N){
          cout << "Yes" << endl;
          flag = true;
          break;
        }
      }
    }
  }
  if (!flag) cout << "No" << endl;
}


Measured memory_bytes: 3632
/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
int n,m,q;
vi a(50),c(50),b(50),d(50);
int ans=0;
void solve(vi &A)
{
	int sum=0;
	loop(i,q)
	if(A[b[i]]-A[a[i]]==c[i])
		sum+=d[i];
	ckmax(ans,sum);
}
void rec(int last_element,vi A)
{
	if(sz(A)==n)
	{
		solve(A);
		return;
	}
	l00p(i,last_element,m+1)
	{
		A.pb(i);
		rec(i,A);
		A.pop_back();
	}
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	cin>>n>>m>>q;
	loop(i,q)
	{
		cin>>a[i]>>b[i]>>c[i]>>d[i];
		a[i]--;
		b[i]--;
	}
	vi A;
	A.pb(1);
	rec(1,A);
	cout<<ans;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3664
from heapq import heappush, heappop
import sys
input = sys.stdin.readline

N = int(input())
x = [0] + list(map(int, input().split()))
v = []
heap = []
a = [-1] * (N * N + 1)
for i in range(1, N+1):
    a[x[i]] = i
    for j in range(1, i):
        v.append((x[i] - j, i))
v.sort(reverse=True)
for i in range(1, N * N + 1):
    if a[i] != -1:
        n = a[i]
        for j in range(N - n):
            heappush(heap, (N * N - j, n))
        continue
    if v:
        j, k = v.pop()
        if x[k] < i:
            print('No')
            exit()
        a[i] = k
    else:
        if not heap:
            print('No')
            exit()
        j, k = heappop(heap)
        a[i] = k
print('Yes')
print(*a[1:])

Measured memory_bytes: 101784
#トポロジカルソート

m = int(input())
n = int(input())

edges = [[] for _ in range(m)]
for _ in range(n):
  x, y = map(int, input().split())
  edges[x - 1].append(y - 1)

visited = [False for _ in range(m)]
sorted_lst = []

def visit(i):
  if not visited[i]:
    visited[i] = True
    for to in edges[i]:
      visit(to)
    sorted_lst.append(i)

for i in range(m):
  visit(i)

sorted_lst.reverse()

for i in sorted_lst:
  print(i + 1)


Measured memory_bytes: 5600
import collections
n=int(input())
str_list=[input() for i in range(n)]
cal=collections.Counter(str_list)
cal=cal.most_common()
ans=cal[0][1]
answer=cal.sort()

for i in range(len(cal)):
    if cal[i][1]==ans:
        print(cal[i][0])

        

Measured memory_bytes: 45040
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define mod2 998244353
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	bool isPowerOfTwo(int x) {
    return x && (!(x & (x - 1)));
	}
	int takemod(int x) {
    return (x % mod + mod) % mod;
	}
 
	int fpow(int base, int power, int MOD) {
    int result = 1;
    base = base % MOD;
    while (power) {
        if (power & 1)
            result = (result * base) % MOD;
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result;
	}
 
	int modinv(int x) {return fpow(x, mod - 2, mod);}
	
	void solve()
	{
		ll a;
		ll b;
		//cout<<fixed<<setprecision(18);
		cin>>a>>b;
		char c;
		cin>>c;
		ll d;
		cin>>d;
		b=(b*100);
		b+=d;
		//dbg(b);
		ll ans=(a*b)/100;
		cout<<ans<<endl;
		//cout<< (long long(a*b))<<endl;	
	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
	//	cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		return 0;
	}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    rep(i, 1, n + 1){
        chmax(ans, i&-i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys

def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    MOD = 10**9 + 7

    para = []
    for i, s in enumerate(A):
        a = 0
        d = 0
        for j, t in enumerate(A):
            if s > t:
                d += 1
                if i < j:
                    a += 1
        para.append((a, d))

    ans = 0
    if K == 1:
        for a, _ in para:
            ans = (ans + a) % MOD
    else:
        for a, d in para:
            s = K * (2*a + (K-1)*d) // 2
            ans = (ans + s) % MOD

    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3316
#B - Distance
N,D= map(int,input().split())
B = [list(map(int,input().split())) for i in range(N)]
count = 0
for i in range(N):
    if (B[i][0]**2+B[i][1]**2)<=D**2:
        count+=1
    else:
        pass
print(count)

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

using ll = long long;

int main() {

    ll n, x;

    cin >> n >> x;

    ll count = 0;

    if(x % 2) {
        ll a = n / x;

        count = a * a * a;

    }
    else {

        ll a = n / x;

        count = a * a * a;

        ll b = x / 2;
        ll c;
       // cout << a * x << endl;
       // cout << n - a * x << endl;
        if(n - a * x < b)
            c = a;
        else
            c = a + 1;

       // cout << c << endl;
        count += c * c * c;

    }


    cout << count << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;

typedef pair<ll,pair<int,int>> pli;

int main(){
  int n,m,s;
  cin >> n >> m >> s;
  struct info{
    int to; int cost; int time;
  };
  
  vector<int> c(n),d(n);
  vector<info> v[n];
  rep(i,m){
    int a,b,p,q;
    cin >> p >> q >> a >> b;
    p--; q--;
    v[p].push_back({q,a,b});
    v[q].push_back({p,a,b});
  }
  rep(i,n){
    cin >> c[i] >> d[i];
  }

  vector<vector<ll>> dist(n, vector<ll>(2510,longinf)); //city silvercoin
  priority_queue<pli,vector<pli>,greater<pli>> q;
  dist[0][min(2500,s)]=0;
  q.push({0LL,{0,min(2500,s)}});  //dist city money

  while(q.size()){
    pli p=q.top(); q.pop();
    int now = p.S.F;
    int left = p.S.S;
    if(dist[now][left]!=p.F) continue;
    auto go = [&](int nxt, int nleft, int cost){
      if(dist[nxt][nleft]>p.F+cost) q.push({dist[nxt][nleft]=p.F+cost,{nxt,nleft}});
    };
    go(now, min(2500,left+c[now]), d[now]);
    for(auto it:v[now]){
      if(it.cost > left) continue;
      go(it.to, left-it.cost, it.time);
    }
  }

  REP(i,1,n){
    ll ans = longinf;
    rep(j,2501) ans = min(ans, dist[i][j]);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 6176
// @prefix atcoder
// @description atcoder template

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'
#define INF (1ll << 60)
#define deg_to_rad(deg) (((deg) / 360.0) * 2.0 * M_PI)
#define rad_to_deg(rad) (((rad) / 2.0 / M_PI) * 360.0)

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
const int MOD = 1e9 + 7;

int a, b;
int h, m;

signed main() {
  cin >> a >> b >> h >> m;

  double res = 0.0;

  double theta = deg_to_rad(30.0 * h + 0.5 * m) - deg_to_rad(6.0 * m);

  // 余弦定理

  res = (double)pow(a, 2) + (double)pow(b, 2) - 2.0 * a * b * cos(theta);
  res = sqrt(res);

  cout << fixed << setprecision(10) << res << endl;
  return 0;
}


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

int h, w;
const int N = 88;
int A[N][N], B[N][N];
int ans = INT_MAX;

bool mem[N][N][4 * N * N];

void solve(int i, int j, int sum) {
    if(i == h || j == w) return;
    if(i == h - 1 && j == w - 1) {
        ans = min({ans, abs(sum + A[i][j]), abs(sum + B[i][j])});
        return;
    }

    int s = sum + 2 * N * N;
    if(mem[i][j][s]) return;
    mem[i][j][s] = true;

    solve(i + 1, j, sum + A[i][j]);
    solve(i + 1, j, sum + B[i][j]);
    solve(i, j + 1, sum + A[i][j]);
    solve(i, j + 1, sum + B[i][j]);
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    cin >> h >> w;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> A[i][j];
        }
    }

    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            int temp = A[i][j];
            cin >> B[i][j];
            A[i][j] -= B[i][j];
            B[i][j] -= temp;
        }
    }

    solve(0, 0, 0);
    cout << ans;
}

Measured memory_bytes: 211968
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        FastReader in = new FastReader();
        test a=new test();
        a.solve(in,out);
        out.close();
    }
}
class test{
    public void solve(FastReader in, PrintWriter out){
       String s =in.next();
       if(s.equals("ABC")){
           out.println("ARC");
       }else{
           out.println("ABC");
       }
    }

}

class FastReader{
    BufferedReader br;
    StringTokenizer st;

    public FastReader(){
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next(){
        while(st==null || !st.hasMoreElements()){
            try{
                st=new StringTokenizer(br.readLine());
            }
            catch(IOException e){
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt(){
        return Integer.parseInt(next());
    }

    Long nextLong(){
        return Long.parseLong(next());
    }

    double nextDouble(){
        return Double.parseDouble(next());
    }
    String nextLine(){
        String str="";
        try{
            str=br.readLine();
        }
        catch(IOException e){
            e.printStackTrace();
        }
        return str;
    }
}



Measured memory_bytes: 32916
data = input().split()
N = int(data[0])
M = int(data[1])

AB = []

for lop in range(N):
    data = input().split()
    AB.append( [int(data[0]),int(data[1])] )


AB = sorted(AB)

money = 0
drink = 0
for lop in range(N):
    if AB[lop][1] + drink <= M:
        drink += AB[lop][1]
        money += AB[lop][0] * AB[lop][1]
    else:
        money += AB[lop][0] * (M - drink)
        break

print(money)

Measured memory_bytes: 20780
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	input = input.map(e => toIntArr(e.split(' ')));
	var d = input[0][0];
	var cs = input[1];
	var ss = input.slice(2);
	//var ts = input.slice(d+2).map(e=>e[0]);
	
	var score = 0;
	var ans = [];
	let type;
	var lastday = [];
	lastday.length = 26;
	lastday.fill(-1);

	//let scoreDay = [];

	//day(0~25)にtype(1~26)を選んだ場合の満足度の変化(lastdayのdayは0~)
	function getScore(day,type){
		let ans = 0;
		ans += ss[day][type-1];
		for(let t = 0; t < 26; t++){
			if(t!==type-1) ans -= cs[t] * (day - lastday[t]);
		}
		return ans;
	}

	var tempScore = [];
	let maxType = 1;
	for(let i = 0; i < d; i++){
	tempScore.fill(0);

		for(j = 0; j < 26; j++){
			tempScore[j] = getScore(i,j+1);
		}
		maxType = tempScore.indexOf(Math.max(...tempScore)) +1; //0~25 +1


		type = maxType;
		ans.push(type);
		lastday[type-1] = i;

		score += tempScore[type];

		//scoreDay[i] = score;

	}

	console.log(ans.join('\n'));
}

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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)
#define TRACE(x) cerr << #x << " = " << x << endl

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

const int MAXN = 1e5 + 5;

int n;
int cnt[2][MAXN];
point mx[2][2];

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

  cin >> n;
  REP(i, n){
    int x; cin >> x;
    cnt[i % 2][x] ++;
  }

  REP(i, MAXN) REP(j, 2){
    if(cnt[j][i] > mx[j][0].first){
      mx[j][1] = mx[j][0];
      mx[j][0] = point(cnt[j][i], i);
    }
    else if(cnt[j][i] > mx[j][1].first){
      mx[j][1] = point(cnt[j][i], i);
    }
  }
  if(mx[0][0].second != mx[1][0].second)
    cout << n - mx[0][0].first - mx[1][0].first;
  else
    cout << n - max(mx[0][0].first + mx[1][1].first, mx[0][1].first + mx[1][0].first);
}


Measured memory_bytes: 1024
#define MOD 1000000007;
#define input ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll long long

#include <bits/stdc++.h>

using namespace std;
const int N = 2e1 + 5;

int main() {

    ll n;
    cin >> n;
    vector<int> vec;
    deque<int> ans;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if(i%2)
            ans.push_front(x);
        else ans.push_back(x);
    }
    if(n%2==0)
        reverse(ans.begin(),ans.end());
    for(auto v: ans)
    cout<<v<< " ";


}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
void go();
int main() {
#ifdef tokitsukaze
    freopen("TEST.txt", "r", stdin);
#endif
    go();
    return 0;
}

/*********************************  head  *********************************/

int n, a, b, m;

double PI = 3.141592653589;
void go() {
    cin >> a >> b >> m;
    if (m <=(double) a * a * b /2) {
        double c = (double)m / a;
        double h = (c / b) * 2;
        double l = sqrt(h * h + b * b);
        double ans1 = asin(h / l) * 180.0 / PI;
        printf("%.9f",90-ans1);
    } else {
        double c = (double)a * b - (double)m / a;
        double h = (c / a) * 2;
        double l = sqrt(h * h + a * a);
        double ans1 = asin(h / l) * 180.0 / PI;
        printf("%.9f",ans1);
    }
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

ll v[MAXN];

void solve(){
	ll k;
	cin >> k;
	REP(i, 0, 50){
		v[i] = 49 + k / 50;
	}
	REP(i, 0, k % 50){
		REP(j, 0, 50){
			v[j]--;
		}
		v[i] += 51;
	}
	printf("50\n");
	REP(i, 0, 50){
		printf("%lld ", v[i]);
	}
	putchar('\n');
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

int main() {
  int n, q;
  cin >> n >> q;
  vector<ll> a(n + 1), s(n + 1), e(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i + 1];
    s[i + 1] = s[i] + a[i + 1];
    e[i + 1] = e[i] + ((n - i) % 2 ? a[i + 1] : 0);
  }
  for (; q > 0; q--) {
    int x;
    cin >> x;
    int ok = 0, ng = 1e9;
    int head, tail, first, second;
    while (true) {
      int w = (ok + ng) / 2;
      head = lower_bound(begin(a) + 1, end(a), x - w) - begin(a);
      tail = lower_bound(begin(a) + 1, end(a), x + w) - begin(a);
      first = n + 1 - tail;
      second = tail - head;
      if (!(ok + 1 < ng)) {
        break;
      }
      if (second + 1 <= first) {
        ok = w;
      } else if (second + 1 > first) {
        ng = w;
      }
    }
    if (second + 1 < first) {
      tail++;
    }
    cout << (s[n] - s[tail - 1]) + e[head - 1] << endl;
  }
}


Measured memory_bytes: 4096
from collections import deque
n=int(input())
arr=[[] for _ in range(n)]
for i in range(n-1):
    u,v,w=map(int,input().split())
    arr[u-1].append([v-1,w])
    arr[v-1].append([u-1,w])

que=deque([0])
ans=[0]*n
visited=[0]*n

while que:
    x=que.popleft()
    visited[x]=-1
    dis=ans[x]
    for tup in arr[x]:
        if visited[tup[0]]>-1:
            ans[tup[0]]=(dis+tup[1])%2
            que.append(tup[0])
print(*ans,sep='\n')

Measured memory_bytes: 47788
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 998244353
#define MAX 1000100

ll frequency[MAX];
ll G[MAX],F[MAX];

ll g(ll d){
	vector<ll> t;
	for(int i=d;i<MAX;i+=d){
		For(w,0,frequency[i]) t.pb(i);
	}
	ll sum = 0 , ans = 0;
	for(ll x:t){
		ans += (sum*x)%Mod;
		ans %=Mod;
		sum += x;
		sum %=Mod;
	}
	return ans;
}

ll f(ll d){
	if(d>=MAX) return 0;
	if(F[d]!=-1) return F[d];

	ll ans = G[d];
	for(int i=2*d;i<MAX;i+=d){
		ans = (ans-f(i)+Mod)%Mod;
	}
	F[d] = ans;
	return ans;
}

ll power(ll a,ll b){
	if(b==0) return 1;
	ll temp = power(a,b/2)%Mod;
	if(b%2==0){
		return (temp*temp)%Mod;
	}else{
		return (a*((temp*temp)%Mod))%Mod;
	}
}


int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	memset(F,-1,sizeof(F));
	ll n;cin>>n;
	ll a[n];For(i,0,n){
		cin>>a[i];
		frequency[a[i]]++;
	}
	For(i,1,MAX) G[i] = g(i);
	
	ll ans = 0;
	For(i,1,MAX){
		ans += (f(i)*power(i,Mod-2))%Mod;
		ans %= Mod;
	}
	cout<<ans<<endl;






























	
}

Measured memory_bytes: 27092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (i = 0; i < n; i++)
const long long INF = 1LL << 60;
int V[3001][3001];
long long dp[3001][3001][5];

int main()
{
    int i, j, k, R, C, K;
    cin >> R >> C >> K;
    memset(V, 0, sizeof(V));
    memset(dp, 0, sizeof(dp));
    int r, c, v;
    rep(i, K){
        cin >> r >> c >> v;
        V[r-1][c-1]=v;
    }

    dp[0][0][1] = V[0][0];

    rep(i, R){ rep(j, C) { rep(k, 4){
        // to right
        dp[i][j+1][k+1]=max(dp[i][j+1][k+1],dp[i][j][k]+V[i][j+1]);
        dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
        // to down
        dp[i+1][j][1]=max(dp[i+1][j][1],dp[i][j][k]+V[i+1][j]);
        dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]);
    }}}

    long long ans=0;
    rep(i,4) ans=max(ans,dp[R-1][C-1][i]);

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


Measured memory_bytes: 390648
import Data.List (sort, group)

solve :: [[Int]] -> Int -> Bool
solve a n =
    case length a of
        1 -> k' == n - 1 || 2 * k' <= n
          where k' = a !! 0 !! 0
        2 -> k' + 1 == k && k <= n && y > 0 && x + y == k && x + 2 * y <= n
               where k' = a !! 0 !! 0
                     k  = a !! 1 !! 0
                     x  = length (a !! 0)
                     y  = k - x
        otherwise -> False

main = do
    n <- readLn :: IO Int
    a <- group . sort . map read . words <$> getLine :: IO [[Int]]
    putStrLn $ if solve a n then "Yes" else "No"

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

int main(){
  int prime[10001]={0};

  prime[0]=prime[1]=1;
  for(int i=2;i<sqrt(10000);i++){
    if(!prime[i]){
      for(int j=0;i*(j+2)<10000;j++){
	prime[i*(j+2)]=1;
      }
    }
  }

  int n;
  while(cin>> n,n){
    for(int i=n;i>1;i--){
      if(!prime[i] && !prime[i-2]){
	printf("%d %d\n",i-2,i);
	break;
      }
    }
  }
}

Measured memory_bytes: 1192
n = int(input())
a = input().split()
b = a[:]
frag = 1
while frag:
  frag = 0
  for i in range(n - 1):
    if a[i][1] > a[i + 1][1]:
      a[i], a[i + 1] = a[i + 1], a[i]
      frag = 1
print(*a)
print("Stable")

for i in range(n - 1):
  minj = i
  for j in range(i, n):
    if b[j][1] < b[minj][1]:
      minj = j
  b[i], b[minj] = b[minj], b[i]
print(*b)
if a == b:
  print("Stable")
else:
  print("Not stable")
    
  

Measured memory_bytes: 7752
#include <iostream>
#include <algorithm>
#define MAX_N 1001
using namespace std;
typedef long long ll;
//lcs
int n,m;
string s,t;
int dp[MAX_N+1][MAX_N+1];
void solve(){
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++){
      if(s[i]==t[j]) dp[i+1][j+1]=dp[i][j]+1;
      else dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
    }
  cout<<dp[n][m]<<endl;
}
//lcm
ll lcm(int gcdv,int a,int b){
  return (ll)a*b/gcdv;
}
//greatest common divisor
int main() {
  int a,b;
  while(cin>>a>>b){
    int r=__gcd(a,b);
    cout<<r<<' '<<lcm(r,a,b)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {

	string s;
	cin >> s;

	if (s.size() == 3)
		reverse(s.begin(), s.end());

	cout << s << endl;

	return 0;
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    ll N,D;
    cin >> N >> D;

    int ans = 0;

    rep(i,N) {
        ll x,y;
        cin >> x >> y;
        ll d = x*x + y*y;
        if (d<=D*D) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628