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

int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i=0; i<N; ++i){
        cin >> A[i];
    }
    vector<long long> CS(N+1);
    for(int i=0; i<N; ++i) CS[i+1] = CS[i] + A[i];
    map<long long, long long> m;
    for(int i=0; i<=N; ++i){
        m[CS[i]]++;
    }
    long long res = 0;
    for(auto p=m.begin(); p!=m.end(); p++){
        long long n = p->second;
        res +=  n*(n-1)/2;
    }
    cout << res << endl;
    return 0;
}

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

int main(){
    int x,y;
    cin >> x >> y;
    if(x%y==0){
        cout<<-1<<endl;
        return 0;
    }
    cout<<x<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
 
  int64_t n,k;
  cin>>n>>k;

  vector<char> d(k);
  for(int64_t i=0;i<k;i++){
    cin>>d.at(i);
  }

  bool flg=true;
  int64_t number=0;
  for(int64_t i=n;i<=n*10;i++){
    string str=to_string(i);
    flg=true;
    for(int j=0;j<str.size();j++){
      for(int l=0;l<k;l++){
        if(str.at(j)==d.at(l)){
          flg=false;
        }
      }
    }
    if(flg){
      number=i;
      break;
    }
  }
  
  cout<<number<<endl;


  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}


map<ll,bool> broken;
ll dp[100005];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N , M ;
    cin >> N >> M ;

    rep(i, M){
        ll inp;
        cin >> inp;
        broken[inp] = true;
    }
    
    
    if(broken[0] == false) dp[0] = 1;
    if(broken[1] == false) dp[1] = 1;
    
    for(ll i = 2; i <= N ; i ++){
        if(broken[i]) dp[i] = 0;
        else dp[i] = dp[i-1] + dp[i-2];
        dp[i] %= 1000000007;
    }
    
    cout << dp[N] << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 7296
//AtCoder ABC071 B - Not Found
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    string S;
    cin>>S;
    vector<ll> tbl(26,0);
    for(const auto& s: S){
        ++tbl[s-'a'];
    }
    for(int i=0;i<tbl.size();++i){
        if (tbl[i]==0) {
            cout<<(char)('a'+i)<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
#define MAXX 500005
 
#define PI   3.14159265358979323846264338327950
 
#define PB push_back 
#define PF push_front
#define F first
#define S second
 
#define fixx(n) fixed << setprecision(n)
 
#define ll 	  long long 
 
#define mod  1000000007



int main()
{
	FAST;
	int n, k;
	cin >> n >> k;
	int a[k+5];
	int x = 0;
	for(int i = 0 ;i < k; i ++){
		cin >> a[i];
		x += a[i];
	}
	if(x >= n){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 3996
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ull)(1e9)+7)
#define MAX ((ull)(1e9)+1)

int main(){
	int n, k;
	cin >> n >> k;
	ll x[n];
	for(int i=0; i<n; i++) cin >> x[i];
	ll ans=x[n-1]-x[0]+min(abs(x[0]), abs(x[n-1]));
	for(int l=0; l<=n-k; l++){
		int r=l+k-1;
		ll dist=x[r]-x[l]+min(abs(x[l]), abs(x[r]));
		if(dist<ans) ans=dist;
	}
	cout << ans << endl;
 	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using lint = long long;

lint bit1_num(lint x, lint d)
{
    x = x + 1;
    lint half = pow(2, d - 1);
    lint full = half * 2;

    lint out = 0;
    out += half * (x / full);
    out += std::max(0ll, x % full - half);

    return out;
}

int main()
{

    lint ans = 0;
    lint base = 1;

    lint a, b;
    scanf("%lld", &a);
    scanf("%lld", &b);

    for (int i = 1; i < 41; ++i)
    {
        ans += base * ((bit1_num(b, i) - bit1_num(a - 1, i)) % 2);
        base *= 2;
    }

    printf("%lld", ans);

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def dist(x1,y1,x2,y2):
	return abs(x1-x2)+abs(y1-y2)

def main():
	S = input().rstrip()
	res = 1

	n,w,s,e=[S.count(x) for x in "NWSE"]
	
	if n+s and not n*s: res=0
	if w+e and not w*e: res=0
	
	sT = "No Yes".split()
	print(sT[res])
	

if __name__ == "__main__":
	main()


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

int main() {
  ll n,m; cin >> n >> m;
  vector<ll>v(n);
  ll sum = 0;
  for(ll i = 0; i<n; i++){
    cin >> v[i];
    sum+=v[i];
  }
  ll h = 0;
  for(ll i = 0; i<n; i++){
    if(v[i]*4*m>=sum) h++;
  }
  if(m<=h) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS; // PS a(n);

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理  int main で　COMinit();を実行する
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算 
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
  ll n,k,m,x=0,y=0,z = 0,cnt=0,h=0,w=0,ans=0,sum = 0, Max = -1, Min = 3e9+1;
  string s;
  cin >> n;
  COMinit();
  VS a(n);
  VL b(5);
  rep(i,n) {
    cin >> a[i];
    if(a[i][0] == 'M'){ b[0]++; }
    if(a[i][0] == 'A'){ b[1]++; }
    if(a[i][0] == 'R'){ b[2]++; }
    if(a[i][0] == 'C'){ b[3]++; }
    if(a[i][0] == 'H'){ b[4]++; }
  }
  rep(i,5){
    for(int j=i+1; j<4;j++){
      for(int k=j+1; k<5; k++){
        ans += b[i]*b[j]*b[k];
      }
    }
  }
  pri(ans);
  return 0;
}

Measured memory_bytes: 18308
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = (int)1e9+7;
const double PI = 3.14159265359;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t;
	//ctrl + /cin>>t;
	t = 1;
	while(t--){
		int n;
		cin>>n;
		char s[n+1];
		cin>>(s+1);
		int dp[n+2][5];
		memset(dp,0,sizeof(dp));
	
		for(int i=1;i<=n;i++){
			if(s[i]=='R'){
				dp[i][1] = dp[i-1][1] + 1;
				dp[i][2] = dp[i-1][2];
				dp[i][3] = dp[i-1][3];
			}
			else if(s[i]=='G'){
				dp[i][2] = dp[i-1][2] + 1;
				dp[i][1] = dp[i-1][1];
				dp[i][3] = dp[i-1][3];
			}
			else{
				dp[i][3] = dp[i-1][3] + 1;
				dp[i][2] = dp[i-1][2];
				dp[i][1] = dp[i-1][1];
			}
		}
		
		ll ans = 0;
		for(int i=1;i<=n;i++){
			for(int k=i+2;k<=n;k++){

				if((s[i]=='R' && s[k]=='G') || (s[i]=='G' && s[k]=='R')){
					ans += dp[k][3] - dp[i-1][3];
					if((k-i)%2==0){
						if(s[i + (k-i)/2] =='B')
							ans--;
					}
					
				}
				else if((s[i]=='R' && s[k]=='B') || (s[i]=='B' && s[k]=='R')){
					ans += dp[k][2] - dp[i-1][2];
					if((k-i)%2==0){
						if(s[i + (k-i)/2] =='G')
							ans--;
					}
				}
				else if((s[i]=='B' && s[k]=='G') || (s[i]=='G' && s[k]=='B')){
					ans += dp[k][1] - dp[i-1][1];
					if((k-i)%2==0){
						if(s[i + (k-i)/2] =='R')
							ans--;
					}
				}
			}
		}
		
		
		cout<<ans;
		
	}
	return 0;
}
































Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
bool B(int x,int i){return (x>>i)&1;}

int N,M;
int cost[15][15];
bool e[15][15];
int inf = 1e9;

int dp[1<<15][15];
int al[1<<15];
int costS[1<<15][15];

int main(){
	cin>>N>>M;
	rep(i,N) rep(j,N) if(i!=j) cost[i][j] = inf;
	rep(i,1<<N) rep(j,N) dp[i][j] = -1;

	rep(i,M){
		int x,y,c;
		cin>>x>>y>>c;
		x--,y--;
		cost[x][y] = cost[y][x] = c;
		e[x][y] = e[y][x] = 1;
	}

	rep(b,1<<N){
		rep(x,N) if(B(b,x)){
			rep(y,x) if(B(b,y)){
				if(e[x][y]) al[b] += cost[x][y];
			}
		}
	}

	rep(b,1<<N){
		rep(x,N) if(!B(b,x)){
			int sum = 0;
			rep(y,N) if(B(b,y) && e[x][y]) sum += cost[x][y];
			costS[b][x] = sum;
		}
	}

	dp[1][0] = 0;
	rep(b,1<<N) rep(v,N) if(dp[b][v]!=-1){
		rep(u,N) if(!B(b,u) && e[v][u]){		//append u to line
			int nb = b|(1<<u);
			chmax(dp[nb][u],dp[b][v] + cost[v][u]);
		}
		int left = (1<<N)-1-b;

		for(int S = left; S!=0; S=(S-1)&left){
			int sum = al[S] + costS[S][v];

			int nb = b|S;
			chmax(dp[nb][v],dp[b][v] + sum);
		}
	}
	int ans = al[(1<<N)-1] - dp[(1<<N)-1][N-1];
	cout<<ans<<endl;
}

Measured memory_bytes: 4224
"""
CODE FESTIVAL 2016
"""
N,A,B = map(int,input().split())
S = input()
sum_a = 0
sum_b = 0
for i in S:
    if(i == 'a'):
        if((sum_a + sum_b) < (A+B)):
            print('Yes')
            sum_a +=1
        else:
            print('No')
    elif(i == 'b'):
        if((sum_a + sum_b) < (A+B) and sum_b < B):
            print('Yes')
            sum_b +=1
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 9204
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    S = input()
    print('ARC' if S == 'ABC' else 'ABC')
if __name__ == '__main__':
  main()


Measured memory_bytes: 10968
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int a, b;

int32_t main()
{
	IOS;
	cin>>a>>b;
	if(b%a==0)
		cout<<a+b;
	else
		cout<<b-a;
	return 0;
}


Measured memory_bytes: 384
/*
--> WHEN IT'S OBVIOUS THAT THE GOAL CANNOT BE REACHED,
	DON'T ADJUST THE GOALS,
	ADJUST THE ACTION STEPS.

--> THE WAY YOU CONQUER SELF-DOUBT IS BY DOING THINGS THAT MAKE YOU UNCOMFORTABLE.

--> IT IS DURING OUR DARKEST MOMENTS WE MUST FOCUS TO SEE LIGHT.
*/

#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <climits>
using namespace std;
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortAll(x) sort(all(x))
#define sz(x) (int)x.size()
#define clr(x) memset(x, 0, sizeof(x))
#define PI 3.1415926535897932384626
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); IO();
typedef long long ll;
typedef pair< int, int >	pii;
typedef pair< ll, ll >		pl;
typedef vector< int >		vi;
typedef vector< ll >		vl;
typedef vector< pii >		vpii;
typedef vector< pl >		vpl;
typedef vector< vi >		vvi;
typedef vector< vl >		vvl;

const int MOD = 1e9 + 7;

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 powm(ll a, ll b)
{
	a %= MOD;
	ll ans = 1;

	while (b > 0)
	{
		if (b & 1)
			ans = (ans * a) % MOD;
		a = (a * a) % MOD;
		b >>= 1;
	}
	return ans;
}

void IO()
{
	#ifndef ONLINE_JUDGE
		freopen("Input.txt", "r", stdin);
		freopen("Output.txt", "w", stdout);
	#endif
}

//================================

int main()
{
	FAST;
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	int turn = 1;
	while (a > 0 && c > 0)
	{
		if (turn)
		{
			c -= b;
			turn = 0;
		}
		else
		{
			a -= d;
			turn = 1;
		}
	}

	if (a > 0)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 3668
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
def ddprint(x):
  if DBG:
    print(x)

n,q = inm()
s = input()
ddprint("n {} q {} s {}".format(n,q,s))
t = []
d = []
for i in range(q):
    tt,dd = input().split()
    t.append(tt)
    d.append(dd)
l = -1
r = n
for i in range(q-1,-1,-1):
    ddprint("i {} l {} r {}".format(i,l,r))
    if l < n-1 and t[i] == s[l+1] and d[i] == 'L':
        l += 1
    if l >= 0 and t[i] == s[l] and d[i] == 'R':
        l -= 1
    if r > 0 and t[i] == s[r-1] and d[i] == 'R':
        r -= 1
    if r < n and t[i] == s[r] and d[i] == 'L':
        r += 1
print(r-l-1)


Measured memory_bytes: 92076
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut a = a;
    a.sort();
    a.reverse();
    let mut x = 0;
    let mut y = 0;
    for i in 0..n {
        if i % 2 == 0 {
            x += a[i];
        } else {
            y += a[i];
        }
    }
    println!("{}", x - y);
}


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

int main() {
	int n;
	cin >> n;
	int i = 1;
	while(1){
		int x = i;
		if (x % 3 == 0) {
			cout << " " << i;
			if (++i <= n) {
				continue;
			}
			else {
				break;
			}
		}

		do {
			if (x % 10 == 3) {
				cout << " " << i;
				break;
			}
			x /= 10;
		} while (x);

		if (++i <= n) {
			continue;
		}
		else {
			break;
		}
	}
	cout << endl;

	return 0;
}

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

using ll = long long;

class ST {
    vector<ll> t;
    int n;

    void updateUtil(int v, int tl, int tr, int pos, ll newVal) {
        if(tl == tr) {
            t[v] = newVal;
            return;
        }
        int tm = (tl + tr)/2;
        if(pos <= tm) updateUtil(v*2, tl, tm, pos, newVal);
        else updateUtil(v*2+1, tm+1, tr, pos, newVal);
        t[v] = max(t[v*2], t[v*2+1]);
    }

    ll queryUtil(int v, int tl, int tr, int l, int r) {
        if(l > r) return 0;
        if(tl == l && tr == r) return t[v];
        int tm = (tl + tr)/2;
        return max( queryUtil(v*2, tl, tm, l, min(r, tm)),
                queryUtil(v*2+1, tm+1, tr, max(l, tm+1), r) );
    }

public :

    ST(int n) {
        this->n = n;
        t.assign(4*n, 0);
    }

    void update(int pos, ll newVal) {
        updateUtil(1, 0, n-1, pos, newVal);
    }

    ll query(int l, int r) {
        return queryUtil(1, 0, n-1, l, r);
    }
};

int main() {
    int n;
    cin>>n;
    vector<int> height(n), beauty(n);
    for(int i=0; i<n; i++) cin>>height[i];
    for(int i=0; i<n; i++) cin>>beauty[i];

    vector<ll> dp(n+1, 0);
    ST maxST(n+1);
    for(int i=0; i<n; i++) {
        ll best = maxST.query(0, height[i]-1);
        if(best + beauty[i] > dp[height[i]]) {
            dp[height[i]] = best + beauty[i];
            maxST.update(height[i], dp[height[i]]);
        }
        // ll best = 0;
        // for(int j=1; j<height[i]; j++) best = max(dp[j], best);
        // dp[height[i]] = max(best + beauty[i], dp[height[i]]);
    }
    cout<< *max_element(dp.begin(), dp.end()) <<endl;

    return 0;
}


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

int main() {
  int n,ans = 0;
  cin >> n;
  for(int i = 0;i < n;i++){
    long long a;
    cin >> a;
    for(int j = 0;j < 100;j++){
      if(a%2 == 0) ans++;
      else break;
      a = a/2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}());
const ll mod=998244353;
//int rnd(int x) { return mrand() % x;}
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;}
// head

const int N=2e5+5;
int nd[N],n,coor_y[N];
ll ans;

struct point {
	int x,y,II,III,I,IV;
}p[N];
struct cmp1 {
	bool operator()(const point &a,const point &b) const {
		if (a.x==b.x) return a.y<b.y;
		return a.x<b.x;
	}
};
struct cmp2 {
	bool operator()(const point &a,const point &b) const {
		if (a.y==b.y) return a.x<b.x;
		return a.y<b.y;
	}
};

void modify(int p,int val) {
	for (int i=p;i<=n;i+=i&(-i)) nd[i]+=val;
}

int query(int p) {
	int res=0;
	for (int i=p;i;i-=i&(-i)) res+=nd[i];
	return res;
}

int main() {
	scanf("%d",&n);
	rep(i,0,n) {
		scanf("%d%d",&p[i].x,&p[i].y);
		coor_y[i]=p[i].y;
	}
	sort(coor_y,coor_y+n); sort(p,p+n,cmp1());
	rep(i,0,n) {
		int pos=lower_bound(coor_y,coor_y+n,p[i].y)-coor_y+1;
		p[i].III=query(pos); p[i].II=i-p[i].III; modify(pos,1);
	}
	sort(p,p+n,cmp2());
	rep(i,0,n) {
		p[i].IV=i-p[i].III; p[i].I=n-1-p[i].II-p[i].III-p[i].IV;
	}
	rep(i,0,n) {
		ll a=powmod(2,p[i].I),b=powmod(2,p[i].II),c=powmod(2,p[i].III),d=powmod(2,p[i].IV),
		p1=(((a*c)%mod*(b-1))%mod*(d-1))%mod,p2=(((b*d)%mod*(a-1))%mod*(c-1))%mod,p3=((((a-1)*(b-1))%mod*(c-1))%mod*(d-1))%mod;
		ans=(ans+p1+p2-p3+mod)%mod;
	}
	ans=(ans+n*powmod(2,n-1))%mod;  //  n
	printf("%lld\n",ans);			// SUM k (n k) = n 2^{n-1}
}									// k=0


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  map<int, int> mp;
  for(int i=0;i<n;i++){
    int t;cin>>t;
    mp[t]++;
  }
  if(mp.size() > 3) {
    cout<<"No"<<endl;
    return 0;
  }

  if(mp.size()==1){
    if (mp[0]==n)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
  }

  if (n%3==2){
    cout<<"No"<<endl;
    return 0;
  }

  if (n%3==0){
    if (mp.size()==2&&mp[0]==n/3) {
      cout<<"Yes"<<endl;
      return 0;
    }
    if (mp.size()==3) {
      vector<int> v;
      for (auto& kv : mp) {
        if (kv.second != n / 3){
          cout<<"No"<<endl;
          return 0;
        }
        v.push_back(kv.first);
      }
      if( (v[0]^v[1]) ==v[2]){
        cout<<"Yes"<<endl;
      }else{
        cout<<"No"<<endl;
      }
      return 0;
    }
    cout<<"No"<<endl;
    return 0;
  }
  if (n%3==1){
    cout<<"No"<<endl;
    return 0;
  }

  return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
inline void read(int &x){
    char c = getchar();
    int p = 1;
    x = 0;
    while(!isdigit(c)){
        if(c == '-')p = -1;
        c = getchar();
    }
    while(isdigit(c)){
        x = (x << 1) + (x << 3) + (c ^ '0');
        c = getchar();
    }
    x *= p;
}
int a[100050], n;
inline bool dfs(){
    int cnt1, cnt2;
    cnt1 = cnt2 = 0;
    for(register int i = 1; i <= n; ++i){
        if(a[i] % 2 == 1){
            if(a[i] == 1)return 0;
            a[i]--;
            break;
        }
    }
    int GCD = a[1];
    for(register int i = 2; i <= n; ++i){
        GCD = __gcd(GCD, a[i]);
    }
    for(register int i = 1; i <= n; ++i){
        a[i] /= GCD;
    }
    for(register int i = 1; i <= n; ++i){
        if(a[i] % 2 == 0)cnt1++;
        else cnt2++;
    }
    if(cnt1 % 2 == 1)return 0;
    else{
        if(cnt2 > 1)return 1;
        else return dfs() ^ 1;
    }
}
int main(){
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    read(n);
    int cnt1, cnt2;
    cnt1 = cnt2 = 0;
    for(register int i = 1; i <= n; ++i){
        read(a[i]);
        if(a[i] % 2 == 0)cnt1++;
        else cnt2++;
    }
    if(cnt1 & 1)puts("First");
    else{
        if(cnt2 > 1)puts("Second");
        else if(dfs())puts("First");
        else puts("Second");
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define MAX 2000001
#define VMAX 10000

int main(void)
{
    int C[VMAX + 1];
    int n;
    cin >> n;

    unsigned short A[n + 1], B[n + 1];

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

    for (int i = 0; i < n; ++i) {
        cin >> A[i + 1];
        C[A[i + 1]]++;
    }

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

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

    for (int i = 1; i <= n; ++i) {
        if (i > 1) cout << " ";
        cout << B[i];
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 10888
#include <bits/stdc++.h>
using namespace std;
 
# define INF 0x3f3f3f3f
#define MOD 1000000007
#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d%d",&x,&y)
#define siii(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d%d",x,y)
#define piii(x,y,z) printf("%d%d%d",x,y,z) 
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld%lld",&x,&y)
#define slll(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld%lld",x,y)
#define plll(x,y,z) printf("%lld%lld%lld",x,y,z) 
 
#define ll long long
#define mp make_pair
#define pb push_back
#define pp pop_back
#define nl printf("\n");
#define sf scanf
#define pf printf
#define rep(i,n) for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<int>
#define tci int t;scanf("%d",&t);while(t--)
const int maxn=10e6+4;

int main()
{
    ifstream myFile("task.in");
    if(!myFile.fail())
    {
        assert(freopen("task.in", "r", stdin));
    }
    
    int n;
    si(n);
    cout<<(24-n) + 24;    

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var a,b,c float64
	fmt.Scan(&a,&b,&c)

	if (a+b+c)/2 == a+b+c - math.Max(a,math.Max(b,c)) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rn0(const i64 e) noexcept { return ran(e); }
constexpr ran rn0(const i64 b, const i64 e) noexcept { return ran(b, e); }
constexpr ran rn1(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rn1(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

int main() {
  i64 a,b;
  cin >> a >> b;
  if(a <= 5) {
    cout << 0 << endl;
  }
  else if(a <= 12) {
    cout << b / 2 << endl;
  }
  else {
    cout << b << endl;
  }
}


Measured memory_bytes: 256
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
cd=[list(map(int,input().split())) for _ in range(m)]

for i in range(n):
    ans=-1
    min=100000000000
    for j in range(m):
        dis=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if(min>dis):
            min=dis
            ans=j+1
    print(ans)


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

constexpr int MAXN = 1e5;
int h[MAXN][3];
int t[MAXN][3];

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

    t[0][0] = h[0][0];
    t[0][1] = h[0][1];
    t[0][2] = h[0][2];

    for (int i = 1; i < n; i++)
    {
        t[i][0] = h[i][0] + max(t[i - 1][1], t[i - 1][2]);
        t[i][1] = h[i][1] + max(t[i - 1][0], t[i - 1][2]);
        t[i][2] = h[i][2] + max(t[i - 1][1], t[i - 1][0]);
    }
    cout << max(t[n - 1][0], max(t[n - 1][1], t[n - 1][2])) << "\n";
}

Measured memory_bytes: 2560
#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 for1(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define endl '\n'
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int cnt_minus = 0;
    for1(i, a, b+1) {
        if (i == 0) {
            puts("Zero");
            return 0;
        } else if (i < 0) {
            cnt_minus++;
        }
    }
    if (cnt_minus % 2 == 0) {
        puts("Positive");
    } else {
        puts("Negative");
    }
	return 0;
}

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 H,W,K;
  cin >> H >> W >> K;
  vector<string> A(H);
  REP(i, H) cin >> A[i];
  
  vector<vector<int>> B(H,vector<int>(W));
  int cnt = 1;
  int flag2=0;
  REP(i,H){
    int now=0;
    int flag=0;
    REP(j,W){
      if(A.at(i).at(j)=='#'){
        FOR(k,now,j+1){
          B.at(i).at(k)=cnt;
        }
        cnt++;
        now=j+1;
        flag=1;
      }
    }
    if(flag==1&&flag2==1){
      FOR(k,now,W){
        B.at(i).at(k)=cnt-1;
      }
    }else if(flag==1&&flag2==0){
      FOR(k,now,W){
        B.at(i).at(k)=cnt-1;
      }
      flag2=1;
      REP(k,i){
        REP(l,W){
          B.at(k).at(l)=B.at(i).at(l);
        }
      }
    }else if(flag==0&&flag2==0){
      continue;
    }else if(flag==0&&flag2==1){
      REP(k,W){
        B.at(i).at(k)=B.at(i-1).at(k);
      }
    }
  }

  REP(i,H){
    REP(j,W){
      if(j!=W-1){
        cout << B.at(i).at(j) << " ";
      }else{
        cout << B.at(i).at(j);
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 1280
n,m=(int(i) for i in input().split())
l=[int(i) for i in input().split()]
r=[1 for i in range(n)]
for i in range(m):
  a,b=(int(j) for j in input().split())
  if l[a-1]>l[b-1]:
    r[b-1]=0
  elif l[b-1]>l[a-1]:
    r[a-1]=0
  else:
    r[a-1]=0
    r[b-1]=0
print(sum(r))

Measured memory_bytes: 20120
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

struct node{
  int id,left,right;
  node(int x){
    id=x;
    left=-1;
    right=-1;
  }
};

int main(){
  int n;
  ll l;
  cin>>n>>l;
  string s[n+1];
  for(int i=0;i<n;i++){
    cin>>s[i];
  }

  vector<node> v;
  v.push_back(node(0));

  for(int i=0;i<n;i++){
    int now=0;
    for(int j=0;j<s[i].size();j++){
      if(s[i][j]=='0'){
        if(v[now].left!=-1) now=v[now].left;
        else{
          v[now].left=v.size();
          v.push_back(node(v[now].id+1));
          now=v[now].left;
        }
      }else{
        if(v[now].right!=-1) now=v[now].right;
        else{
          v[now].right=v.size();
          v.push_back(node(v[now].id+1));
          now=v[now].right;
        }
      }
    }
  }

  ll win=0;
  for(int i=0;i<v.size();i++){
    if(v[i].left==-1&&v[i].right==-1) continue;
    else if(v[i].left==-1||v[i].right==-1){
      ll tmp=1;
      for(int k=1;;k++){
        if((l-v[i].id)%(tmp*2)==0) tmp*=2;
        else break;
      }
      win^=tmp;
    }
  }

  if(win) cout<<"Alice"<<endl;
  else cout<<"Bob"<<endl;

  return 0;
}


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

int main() {
  using namespace std;
  int n,a,b,p;
  int ans;
  int la=0,lb=0,lc=0;
  cin >> n;
  cin >> a >> b;

  for(int i=0;i<n;i++){
    cin >> p;
    if(p<=a)   la++;
    else if(p<=b)  lb++;
    else lc++;
  }
  ans = min(lc,min(la,lb));
  cout << ans << endl;

}

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

int main(){
	int n;
	cin>>n;
	int count = 0;
	bool ans = false;
	while(n--){
		int a,b;
		cin>>a>>b;
		if(a==b){
			count++;
		}
		else{
			count = 0;
		}
		if(count >= 3){
			ans = true;
		}
	}
	if(ans){
		cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	}
	return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

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

        while (true) {
            int x = scan.nextInt();
            if (x == 0) {
                break;
            }

            System.out.println("Case " + i + ": " + x);
            i++;
        }
    }
}

Measured memory_bytes: 41564
x = int(input())
nzk = 1
nzj = 0
while nzk**5 - (nzk-1)**5 < 10**9:
    nzk += 1
while nzj**5 - (nzj-1)**5 < 10**9:
    nzj -= 1
for i in range (nzj, nzk+1):
    for j in range(nzj, nzk+1):
        if x ==  i ** 5 - j ** 5:
            print(i, j)
            break
    else:
        continue
    break

Measured memory_bytes: 9216
#include <stdio.h>

int main(void) {
	int n,d,a;
	scanf("%d%d",&n,&d);
	d=d*2+1;
	a=n/d;
	if(n%d>0){
		a++;
	}
	printf("%d\n",a);
		
		
		// your code goes here
	return 0;
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).expect("failed to read line.");
    let lsd: String = line.chars().next().unwrap().to_string();//.parse().expect("not a number.");
    let number: u32 = line.trim().parse().expect("not a number.");
    let first_number: u32 = format!("{}{}{}", lsd, lsd, lsd).parse().expect("not a number.");
    if first_number >= number { println!("{}", first_number); }
    else {
        let lsd_next: u8 = lsd.parse::<u8>().expect("not a number.") + 1;
        let second_number: u32 = format!("{}{}{}",lsd_next.to_string(), lsd_next.to_string(), lsd_next.to_string()).parse().expect("not a number.");
        println!("{}", second_number);
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e6;

int main()
{
    double t,x;
    cin>>t>>x;
    cout<<t/x;
}

Measured memory_bytes: 256
module ABC136

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_B
  private :: calculate_solution
  
  contains
  
  subroutine task_B (val_range)

    ! arguments for this <subroutine>
    integer(INT32), intent(in) :: val_range

    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') calculate_solution(val_range)
    
    ! STEP.END
    return

  end subroutine task_B

  recursive function calculate_solution (val_range) result(num_integers_satisfied)

    ! arguments for this <function>
    integer(INT32), intent(in) :: val_range

    ! return value of this <function>
    integer(INT32) :: num_integers_satisfied

    select case (val_range)
      case(1_INT32:9_INT32)
        num_integers_satisfied = val_range
      case(10_INT32:99_INT32)
        num_integers_satisfied = 9_INT32
      case(100_INT32:999_INT32)
        num_integers_satisfied = calculate_solution(99_INT32) + val_range - 99_INT32
      case(1000_INT32:9999_INT32)
        num_integers_satisfied = calculate_solution(999_INT32)
      case(10000_INT32:99999_INT32)
        num_integers_satisfied = calculate_solution(9999_INT32) + val_range - 9999_INT32
      case(100000_INT32)
        num_integers_satisfied = calculate_solution(99999_INT32)
    end select

  end function calculate_solution

end module ABC136

program main

  ! <module>s to import
  use,     intrinsic :: iso_fortran_env
  use, non_intrinsic :: ABC136

  ! variables for this <program>
  integer(INT32) :: N

  read(unit=INPUT_UNIT, fmt=*) N
  
  call task_B (N)

end program main

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
		int N;
		int mini;
		int count = 0;
		cin >> N;
		int A[N];
		for(int i = 0; i < N; i++){
			cin >> A[i];
		}
		for(int i = 0; i < N; i++){
			mini = i;
			for(int j = i; j < N; j++){
				if(A[j] < A[mini]){
					mini = j;
				}
			}
			if(A[mini] != A[i]){
				int temp = A[mini];
				A[mini] = A[i];
				A[i] = temp;
				count++;
			}
		}
		for(int i = 0; i < N-1; i++){
			cout << A[i] << " ";
		}
		cout << A[N-1] << endl;
		cout << count << endl;
		return 0;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  string s;
  cin>>s;
  reverse(all(s));
  int dp[100010][13]={0};
  dp[0][0]=1;
  int mul=1;
  int mod=1000000000+7;
  for(int i=1;i<=s.size();i++){
    if(s[i-1]=='?'){
      for(int j=0;j<10;j++){
        int r=j*mul;
        int g=r%13;
        rep(h,13){
          dp[i][(h+g)%13]+=dp[i-1][h];
          dp[i][(h+g)%13]%=mod;
        }
      }
    }
    else{
      int c=(s[i-1]-'0');
      int e=c*mul%13;
      rep(h,13){
        dp[i][(h+e)%13]+=dp[i-1][h];
        dp[i][(h+e)%13]%=mod;
      }
    }
    mul*=10;
    mul%=13;
  }
  int q=s.size();
  COUT(dp[q][5]);
}


Measured memory_bytes: 5504
n = int(input())
B_=0
_A=0
AB = 0
B_A=0
for i in range(n):
    s = input()
    AB += s.count('AB')
    if s[0] == 'B' and s[-1] == "A":
        B_A += 1
    elif s[0] == 'B':
        B_ += 1
    elif s[-1] == 'A':
        _A += 1
    
if B_A == 0:
    ans = AB + min(_A,B_)
else:
    if _A == 0 and B_ == 0:
        ans = AB + (B_A-1)
    else:
        ans = AB + B_A + min(_A,B_)
        
print(ans)

Measured memory_bytes: 3064
N, M = map(int, input().split())
if N < M:
    N, M = M, N

if N - M > 1:
    print(0)
    exit()


MOD = 10 ** 9 + 7
class modint:
    def __init__(self, x):
        self.x = x.x if isinstance(x, modint) else x % MOD
    def __str__(self): return str(self.x)
    __repr__ = __str__
    def __int__(self): return self.x
    __index__ = __int__
    def __add__(self, other): return modint(self.x + modint(other).x)
    def __sub__(self, other): return modint(self.x - modint(other).x)
    def __mul__(self, other): return modint(self.x * modint(other).x)
    def __pow__(self, other): return modint(pow(self.x, modint(other).x, MOD))
    def __floordiv__(self, other): return modint(self.x * pow(modint(other).x, MOD - 2, MOD))
    def __eq__(self, other): return self.x == modint(other).x
    def __ne__(self, other): return self.x != modint(other).x
    def __inv__(self): return pow(self.x, MOD - 2, MOD)

def fact(n):
    r = n
    for i in range(n - 1, 1, -1):
        r *= i
    return r

fn = fact(modint(N))
fm = fact(modint(M))

if N == M:
    print(fn * fm * 2)
else:
    print(fn * fm)


Measured memory_bytes: 3444
def main():
    N,W = map(int,input().split(" "))
    dp = [0 for _ in range(W+1)]
    V = [tuple(map(int,input().split(" "))) for _ in range(N)]
    for i in range(W+1):
        for j in range(N):
            v,w = V[j]
            if i-w < 0:continue
            else:
                dp[i] = max(dp[i],dp[i-w]+v)
    print(max(dp))

if __name__ == "__main__":
    main()


Measured memory_bytes: 5924
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define pb push_back
#define mod 1000000007
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int dx8[]={1,-1,0,0,1,1,-1,-1};
int dy8[]={0,0,1,-1,1,-1,1,-1};

ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

 // void dfs(ll node){
 // 	vis[node]=1;
 // 	res.pb(node);
 //    vector<ll> ans;


 // 	for(auto i:v[node]){
 // 		if(!vis[i]){
 // 			ans.pb(i);

 // 		}
 // 	}
 // 	sort(ans.begin(),ans.end());

 // 	for(auto i:ans){
 // 		if(!vis[i])
 // 			dfs(i);
 // 	}




 // }
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
bool sortbyme(const pair<int,int> &a, 
              const pair<int,int> &b){
	return (a.first+a.second > b.first+b.second);

}
void solve(){

ll n;
cin>>n;
vector<ll> a,b;
ll x,y;
for(ll i=0;i<n;i++){
	cin>>x>>y;
	a.pb(x+y);
	b.pb(x-y);

}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
ll ans=INT_MIN;
ans=max(abs(a[n-1]-a[0]),abs(b[n-1]-b[0]));
cout<<ans<<endl;





return;
}



int main()
{  
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
    fast;
    

    ll t;
    t=1;
    // cin>>t;
    while(t--){
    	solve();
    }
    
   
  



#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}

Measured memory_bytes: 6700
# -*- coding: utf-8 -*-

import sys
import os
import math


N = int(input())


def is_prime(n):
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            return False
    return True

cnt = 0
for i in range(N):
    v = int(input())
    if is_prime(v):
        cnt += 1

print(cnt)

Measured memory_bytes: 7804
n, m, l = gets.split.map(&:to_i)
a = (0..n-1).map { gets.split.map(&:to_i) }
b = (0..m-1).map { gets.split.map(&:to_i) }
c = (0..n-1).map { (0..l-1).map { 0 } }
(0..n-1).each do |i|
  (0..l-1).each do |j|
    (0..m-1).each do |k|
      c[i][j] += a[i][k] * b[k][j]
    end
  end
end
c.each do |row|
  puts row * " "
end


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	char T;
	cin >> T;
	if(T>='A' && T<='Z')
	{
		cout <<"A\n";
	}
	else
	{
		cout <<"a\n";
	}
	
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;
typedef vector<lint> poly;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 998244353;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    lint n;
    scanf("%lld", &n);
    if(n%2){
        printf("%d\n", 0);
        return 0;
    }
    lint ans=0;
    lint m=n;
    while(m){
        ans+=m/5;
        m/=5;
    }
    lint a=5;
    int cur=1;
    while(a<=n){
        lint tmp=n/a;
        tmp=(tmp-1)/2+1;
        ans-=tmp;
        a*=5;
        ++cur;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderTest
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int h = int.Parse(s[0]);
            int w = int.Parse(s[1]);

            for (int i = 0; i < h*2; i++)
            {
                string c = Console.ReadLine();
                Console.WriteLine(c);
                Console.WriteLine(c);
            }
        }
    }
}


Measured memory_bytes: 2776
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int i,j,k;
  int w,h;
  while(cin>>w>>h,w||h){
    int gx,gy,n=0;
    vector<int> x[2500],y[2500];
    for(i=0;i<h;++i){
      for(j=0;j<w;++j){
	char s[5];
	cin>>s;
	if(0){
	}else if(s[0]=='.'){
	}else if(s[0]=='S'){
	  x[0].push_back(j);
	  y[0].push_back(i);
	}else if(s[0]=='G'){
	  gx=j;
	  gy=i;
	}else{
	  int p=atoi(s);
	  x[p].push_back(j);
	  y[p].push_back(i);
	  n=max(n,p);
	}
      }
    }
    ++n;
    x[n].push_back(gx);
    y[n].push_back(gy);
    vector<int> a(1,0);
    for(i=0;i<n;++i){
      vector<int> b(x[i+1].size(),1<<30);
      for(j=0;j<(int)x[i].size();++j)
	for(k=0;k<(int)x[i+1].size();++k)  
	  b[k]=min(b[k],a[j]+abs(x[i][j]-x[i+1][k])+abs(y[i][j]-y[i+1][k]));
      a=b;
    }
    cout<<a[0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 0