akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#define _USE_MATH_DEFINES
#include<math.h>
#include<algorithm>
#include<memory>
#include<string>
#define Rep(i,n) for(int i = 0;i < (n);i++)	
typedef long long ll;

int gcd(int a, int b) { if (b == 0)  return a;  else  return gcd(b, a % b);  }
int lcm(int a, int b) { return a * b / gcd(a, b); }
void swap(int& a, int& b) { int temp = a; a = b; b = temp; return; }
int ncr(int n, int r) { int a = 1; Rep(i, r) a = (a * (n - i)) / (i + 1); return a; }
int npr(int n, int r) { int a = 1; Rep(i, r) a *= n - i; return a; }
int mod(int a, int b) { return a % b; }

class list {
public:
	class element {
	public:
		char data;
		element* next;
		element(element* _next, char item) :
			next(_next), data(item) {}
	};
	std::vector<element*> elements;
	void insert(element* l, int k, char item) {
		element* p;
		if (k > 1) { insert(l->next, k - 1, item); }
		else {
			elements.emplace_back(new element(l->next, item));
			l->next = elements.back();
		}
	}
	void erase(element* l, int k) {
		if (k > 1) { erase(l->next, k - 1); }
		else { l->next = l->next->next; }
	}
	char access(element* l, int k) {
		if (k > 1) { return access(l->next, k - 1); }
		else { return l->next->data; }
	}
	list() {elements.emplace_back(new element(NULL, NULL));}
};

class stack {
public:
	std::vector<char> box;
	int top;
	stack():top(0){}
	void push(char item) {}
};

class machi {
public:
	int next;
	int flag;
	int houmon;
	machi(int j) :
		next(j),
		flag(0),
		houmon(NULL)
	{
	}
};

int main() {
	/*std::string s;
	std::string t;
	std::cin >> s >> t;
	t = t.substr(0, t.size() - 1);
	if (s == t) {
		std::cout << "Yes";
	}
	else {
		std::cout << "No";
	}*/
	/*
	ll a, b, c;
	ll k;
	std::cin >> a >> b >> c >> k;
		if (a > k) {
		std::cout << k;
	}
	else if (a + b > k) {
		std::cout << a;
	}
	else {
		std::cout << 2 * a + b - k;
	}*/
	/*
	int n, m, x;
	std::cin >> n >> m >> x;
	bool flag = true;
	std::vector<int> bookflag(12, 0);
	std::vector<int>C;
	std::vector<int>A(12,0);
	int rikaido[12][12];
	Rep(i, n) {
		int _c;
		std::cin >> _c;
		C.emplace_back(_c);
		Rep(j, m) {
			int _a;
			std::cin >> _a;
			rikaido[i][j] = _a;
			A[j] += _a;
		}
	}
	Rep(i, x) {
		if (A[i] < x) {
			std::cout << -1;
			flag == false;
			break;
		}
	}
	if (flag == true) {
		Rep(i, n) {
			Rep(j, m) {

			}
		}
	}*/
	int n;
	ll k;
	std::vector<machi>A;
	int visit = 0;
	std::cin >> n >> k;
	A.emplace_back(1);
	Rep(i, n) {
		int j;
		std::cin >> j;
		A.emplace_back(j);
	}
	bool flag2 = false;
	for (int i = 0; i <= k;i++) {
		visit = A[visit].next;
		//std::cout << visit;
		A[visit].flag++;
		if (A[visit].flag > 1&&flag2 == false) {
			k = (k - i) % (i - A[visit].houmon);
			i = 0;
			flag2 = true;
		}
		A[visit].houmon = i;
		
	}
	std::cout << visit;
	return 0;
}

Measured memory_bytes: 6392
#include<bits/stdc++.h>
using namespace std;
#define ll long long
struct Info
{
    int val,x,y;
    bool operator<(const Info& ob) const
    {
        return val>ob.val;
    }
};
int main()
{
    int n;
    cin>>n;
    vector<ll>arr(n+1, 0);
    vector<Info> in;
    Info ob;
    for(int i=1; i<n; i++){
        cin>>ob.val;
        ob.x = i;
        ob.y = i+1;
        in.push_back(ob);
    }
    sort(in.begin(), in.end());
    for(int i=0; i<in.size(); i++){
        //cout<<in[i].val<<endl;
        arr[ in[i].x ] = arr[ in[i].y ] = in[i].val;
    }
    ll ans = 0;
    for(int i=1; i<=n; i++) ans+=arr[i];
    cout<<ans<<endl;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    vector<int> cnt(3, 0);
    for (char c : s) {
        cnt[c - 'a']++;
    }
    sort(cnt.rbegin(), cnt.rend());
    cnt[0] -= cnt[2];
    cnt[1] -= cnt[2];
    if ((cnt[0] == 0 && cnt[1] == 0) || (cnt[0] == 1 && cnt[1] == 0) || (cnt[0] == 1 && cnt[1] == 1)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
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;}
const ll INF = 1LL << 60;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    int ans = 0;
    ans += (x/500) * 1000;
    x %= 500;
    ans += (x/5) * 5;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int a,g[1000000];
  int b=0,c=1,d;
  cin>>a;
  for(int i=0;i<a*3;i++){
    cin>>g[i];
  }
  sort(g,g+(a*3),greater<int>());
  for(int i=1;i<=3*a;i=i+2){
    b+=g[i];
    if(c==a) break;
    ++c;
    //cout<<g[i]<<" ";
  }
  cout<<b<<"\n";
}

Measured memory_bytes: 4608
// Fibonacci Number
#include <stdio.h>

#define MAX 45
#define NIL -1 // フィボナッチ数列の値として使われない値を番兵としておく

int F[MAX];

// フィボナッチ数列を計算 //
// 計算したn番目の要素は配列に入れておくことで、
// 必要な再帰の回数を減らす
int fibonacci(int n){
  if(n == 0 || n == 1)return F[n] = 1;
  if(F[n] != NIL)return F[n]; // 要素nがすでに計算されているとき
  else return F[n] = fibonacci(n-1) + fibonacci(n-2);
}

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

  for(i=0; i < MAX; i++){ // 配列の初期化
    F[i] = NIL;
  }
  
  printf("%d\n", fibonacci(n));
  return 0;
}



Measured memory_bytes: 2104
n = int(input())
x = list(map(int, input().split()))
y = list(x)
y.sort()

med1 = y[(n//2)-1]
med2 = y[(n//2)]

for i in range(n):
	if x[i] <= med1:
		print(med2)
	else:
		print(med1)

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

using namespace std;
int main() {
    long int X;
    cin >> X;

    long int A, B;
    bool flag = false;
    for (A = -500; A < 500; ++A){
        for(B = -500; B < 500; ++B){
            long int ans  = A*A*A*A*A-B*B*B*B*B;
            if(ans == X){
                flag = true;
                break;
            };
        }
        if (flag) break;
    }

    cout << A << " " << B << endl;
    return 0;
}


Measured memory_bytes: 3164
///   Journey to the End of earth   ///
/// Gunjan Kumar ///
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional> // for less 
// using namespace __gnu_pbds; 
using namespace std;
#define ll  long long
#define s(n) scanf("%d",&n)
#define ls(n) scanf("%lld",&n)
#define p(n) printf("%d",n)
// #define ln() printf("\n")
#define pln(n) printf("%d\n",n)
#define lpln(n) printf("%lld\n",n)
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rev(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define tc           ll t1; cin>>t1; while(t1--)
#define inp         ll n; cin>>n; ll arr[n]; rep(i,0,n) cin>>arr[i];
#define vect vector<ll>
#define sortv(v)       sort(v.begin(),v.end())
#define lower(v,n)    lower_bound(v.begin(),v.end(),n)-v.begin()
#define upper(v,n)    upper_bound(v.begin(),v.end(),n)-v.begin()
#define bitcount(n) __builtin_popcount(n)
#define ln <<endl
#define inf          LONG_MAX
#define ninf         LONG_MIN
#define fast         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const   ll mod=1e9+7;
const ll N=3e2+5;



int main()
{

         
       int n;
       cin >> n;
       ll arr[n];
       rep(i,0,n)
       cin >> arr[i];
       ll  dp[n][n];
       memset(dp,0,sizeof(dp));
       for(int i=n-1;i>=0;i--)
       {
         for(int j=i;j<n;j++)
         {
          if(i==j)
            dp[i][j]=arr[i];
          else
             dp[i][j]=max(arr[i]-dp[i+1][j],arr[j]-dp[i][j-1]);
         }
       }
       cout<<dp[0][n-1];

     return 0;
}



Measured memory_bytes: 73936
#include<cstdio>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<iostream>
#include<sstream>
using namespace std;
typedef long long ll;

int ko,n;
ll ans=0;
int main(){
    scanf("%d",&n);
    vector<int> ar(n-1);
    for(int i=0;i<n-1;i++)scanf("%d",&ar[i]);
    scanf("%d",&ko);
    vector<vector<ll> > comar(n-1,vector<ll>(20+1,0));
    comar[0][ar[0]]=1;
    for(int i=1;i<n-1;i++){
        for(int j=0;j<=20;j++){
            if(j+ar[i]<=20)comar[i][j+ar[i]]+=comar[i-1][j];
            if(j-ar[i]>=0)comar[i][j-ar[i]]+=comar[i-1][j];
        }
    }
    printf("%lld\n",comar[n-2][ko]);
}

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

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

    long long sum = 0;

    for (int i = 1; i <= n; ++i)
    {
        if (i % 3 != 0 && i % 5 != 0)
        {
            sum += i;
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
制約のn*mとn,mを読み違えない
操作の逆順を考える
オーバーフローしないか確かめる
Codeforcesではscanfを使う
modの引き算には+modをする
エラー出力は消す
エラー出力を消せ！！！！！
数値の区切り位置を誤読しない
木はn-1ノード
関数単位で調べる
cout << fixed;
cout << setprecision(n) << ans;
 */

int main() {
    string s;
    cin >> s;
    int k;
    cin >> k;
    int n=s.length();
    int dp0[n][k+3];
    int dp1[n][k+3];
    rep(i,n){
        rep(j,k+1){
            dp0[i][j]=0;
            dp1[i][j]=0;
        }
    }
    rep(i,n){
        if(!i){
            int num=s[0]-'0';
            dp0[0][0]=1;
            dp0[0][1]=num-1;
            dp1[0][1]=1;
        }
        else{
            int num=s[i]-'0';
            if(num){
                rep(j,k+2){
                    dp0[i][j]+=dp0[i-1][j]+dp1[i-1][j];
                    dp0[i][j+1]+=dp0[i-1][j]*9+dp1[i-1][j]*(num-1);
                    dp1[i][j+1]+=dp1[i-1][j];
                }
            }
            else{
                rep(j,k+2){
                    dp0[i][j]+=dp0[i-1][j];
                    dp0[i][j+1]+=dp0[i-1][j]*9;
                    dp1[i][j]+=dp1[i-1][j];
                }
            }
        }
    }    
    cout << dp0[n-1][k]+dp1[n-1][k];
	cerr << dp1[0][1];
    
}

/*
*/



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c, d;
    
    cin >> a >> b >> c;
    
    d =  c - (a - b);
    
    if (0 <= d) {
        cout << d << endl;
    } else {
        cout << 0 << endl;
    }
    
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int64 dp[50][2] = {};
int64 N, K;
vector<int64> A(N);

int64 dfs(int64 dig = 49, bool tight = 1) {
	if (dig < 0) return 0;
	if (~dp[dig][tight]) return dp[dig][tight];
	int64 lim = tight ? (K >> dig & 1) : 1;
	dp[dig][tight] = 0;
	REP (i, lim+1) {
		int64 sum = 0;
		REP (j, N) {  
			if ((A[j] >> dig & 1) ^ i) {
				sum += 1LL << dig;
			}
		}
		dp[dig][tight] = max(dp[dig][tight], sum + dfs(dig-1, tight && i == lim));
	}
	return dp[dig][tight];
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	memset(dp, -1, sizeof dp);
	cin >> N >> K;
	A.resize(N);
	REP(i, N) cin >> A[i];

	cout << dfs() << endl;
}


Measured memory_bytes: 1024
a, b, c, d = gets.chomp.split(" ").map(&:to_i)
c2 = (b / c - a / c)
c2 += 1 if a % c == 0
d2 = (b / d - a / d)
d2 += 1 if a % d == 0
lcm_cd = c.lcm(d)
cd2 = (b / lcm_cd - a / lcm_cd)
cd2 += 1 if a % lcm_cd == 0

ans = (b - a + 1) - (c2 + d2 - cd2)

puts ans

Measured memory_bytes: 14312
#include<stdio.h>

int main()
{
	int n,i;
	scanf("%d",&n);
	long long int x10=1,x9=1,x8=1;
	for(i=0;i<n;i++)
	{
		x10=(10*x10)%1000000007;
		x9=(9*x9)%1000000007;
		x8=(8*x8)%1000000007;
	}
	printf("%lld",(x10-2*x9+x8+2*1000000007)%1000000007);
	return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
    
    long long N, A, B, C, D;
    long long c,d;
    
    
    cin >> N;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;
    
    long long x = B - A;
    
    for ( int i = 0; i < N; i++ ) {
        
        if ( C*i - D*(N-1-i) <= x && x <= D*i - C*(N-1-i) ) {
            cout << "YES" << endl;
            return 0;
        }
        
    }
    
    cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    map <string, int> m;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        m[s]++;
    }
    long long ans = 0;
    for(auto i : m){
        //cout << i.first << " " << i.second << "\n";
        long long j = i.second;
        if(j <= 1)
            ans += 0;
        else if(j == 2)
            ans++;
        else
        {
            ans += j*(j-1)/2;
        }
        
    }
    cout << ans << "\n";
}

Measured memory_bytes: 11136
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  int N;
  ci(N);
  if(N % 2 == 0){
    co(N);
  }
  else{
    co(N * 2);
  }
}

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

int main(int argc, char const *argv[])
{
    string s;cin >> s;
    int cnt =0;
    int ret =0;
    for(int i=0;i<s.length();++i){
        if(s[i]=='A' || s[i]=='G' || s[i]=='C' || s[i]=='T'){
            cnt++;
        }
        else{
            ret = max(ret,cnt);
            cnt = 0;
        } 
    }
    ret = max(ret,cnt);
    cout << ret<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1e9;
const double EPS = 1e-12;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;

int K, R, L;
double P, E, T;

double solve(int k, double r, double  l)
{
    double H = (r+l)/2.0;

    if (k == K) {
        if (abs(H-T) <= E) return 1.0;
        else return 0.0;
    }

    // 枝刈り
    if (l < T-E || T+E < r) return 0.0;
    if (T-E <= r && l <= T+E) return 1.0;

    double res = 0.0;
    if (H >= T) {
        res += P * solve(k+1, r, H);
        res += (1.0 - P) * solve(k+1, H, l);
    } else {
        res += P * solve(k+1, H, l);
        res += (1.0 - P) * solve(k+1, r, H);
    }

    return res;
}

int main()
{
    cin>>K>>R>>L;
    cin>>P>>E>>T;
    P = 1.0 - P;

    cout << fixed << setprecision(6);
    cout << solve(0, R, L) << endl;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  string s[h * 2];
  for (int i = 0; i < h; i++) {
    string S;
    cin >> S;
    s[i * 2] = S;
    s[i * 2 + 1] = S; 
  }
  for (int i = 0; i < h * 2; i++) {
    cout << s[i] << '\n';
  }
  return 0;
}

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

public class Main {
	static FastReader in = new FastReader();

	public static void main(String[] args) {
		solve();
	}

	static void solve() {
		int n = in.nextInt();
		int d = in.nextInt();
		
		int count = 0;
		while(n-- > 0)
		{
			int x =in.nextInt();
			int y = in.nextInt();
			if(Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)) <= d) count++;
		}
		System.out.println(count);
	}

	static 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: 55256
import math

N = int(input())
a = list(map(int, input().split(' ')))
a.insert(0, -1)
#print(a)

mid = math.floor(N / 2)
#print(mid)

M = 0
b = [0 for i in range(N)]
b.insert(0, -1)
for i in reversed(range(1, N + 1)):
    num = 0
    for j in range(1, N // i + 1):
        num += b[j * i]
    if num % 2 == 0:
        if a[i] == 0:
            b[i] = 0
        else:
            M += 1
            b[i] = 1
    else:
        if a[i] == 0:
            M += 1
            b[i] = 1
        else:
            b[i] = 0

print(M)
for i in range(1, N + 1):
    if b[i] == 1:
        print(i, end=' ')

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

int h,w,a,b,ans[1005][1005];

int main(){

	cin>>h>>w>>a>>b;
	
	for(int i=0;i<b;i++){
		for(int j=0;j<a;j++){
			ans[i][j]=1;
		}
	}
	
	for(int i=b;i<h;i++){
		for(int j=a;j<w;j++){
			ans[i][j]=1;
		}
	}
	
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++)cout<<ans[i][j];
		cout<<"\n";
	}

return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void vcin(vector<T> &a);
template <class T>
inline void vcout(const vector<T> a, const string separate = "\n");
int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  vcin(v);
  int r = min(n, k);
  auto begin = v.begin();
  auto end = v.end();
  int maxjewelry = -2 << 24;
  for (int a = 0; a <= r; a++)
  {
    for (int b = 0; a + b <= r; b++)
    {
      vector<int> take(n);
      // lout << a <<" " << b << endl;
      copy(begin, begin + a, take.begin());
      copy(end - b, end, take.begin() + a);
      while (take.back() == 0 and not take.empty())
      {
        take.pop_back();
      }
      // vcout(take, " ");
      // cout << endl;

      sort(take.begin(), take.end(), greater<int>());
      //vcout(take, " ");
      //cout << endl;

      int t = k - (a + b);
      for (int cd = 0; cd < t; cd++)
      {
        if (take.back() < 0)
        {
          take.pop_back();
        }
        else
        {
          break;
        }
      }
      int jewelry = accumulate(take.begin(), take.end(), 0);
      maxjewelry = max(maxjewelry, jewelry);
    }
  }

  cout << maxjewelry << endl;
  return 0;
}

template <class T>
inline void vcin(vector<T> &a)
{
  for (unsigned int i = 0; i < a.size(); i++)
  {
    cin >> a[i];
  }
}
template <class T>
inline void vcout(const vector<T> a, const string separate)
{
  for (T t : a)
  {
    cout << t;
    if (t == a.back())
    {
      break;
    }
    cout << separate;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
const int inf=1e18;
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n,k;
    cin >> n >> k;
    int a[n+1],vis[n+1]={0};
    for(int i=1;i<=n;i++)
    	cin >> a[i];
    int p=1;
    vis[1]=1;
    while(k--){
    	int nx=a[p];
    	if(vis[nx]){
    		int l=vis[p]-vis[nx]+1;
    		k%=l;
    	}
    	vis[nx]=vis[p]+1;
    	p=nx;
    }
    cout << p;
}

Measured memory_bytes: 6768
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007


ll n, a, b, c;
string s;

int main() {
	cin >> a >> b >> c;
	cout << min(c,b /a)<< endl;
}


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

class Main {

    static final int X = 0;
    static final int Y = 1;
    static final int SIZE = 10;
    static boolean success;
    
    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);

	while ( true ) {

	    final int px = stdin.nextInt();
	    final int py = stdin.nextInt();

	    if( px == 0 && py == 0 ) {
		break;
	    }
	    final int n = stdin.nextInt();
	    int[][] sprinkler = new int[n][2];
	    for ( int i = 0; i < n; i++ ) {
		sprinkler[i][X] = stdin.nextInt();
		sprinkler[i][Y] = stdin.nextInt();
	    }
	    success = false;
	    if ( dfs( sprinkler, 0, px, py ) ) {
		System.out.println( "OK" );
	    } else {
		System.out.println( "NA" );
	    }
	}	
    }

    static final int[] dx = { 2, 2, 2, 1 ,0, -1, -2, -2, -2, -1, 0, 1 };
    static final int[] dy = { -1, 0, 1, 2, 2, 2, 1, 0, -1, -2, -2, -2 };
    
    static boolean dfs( final int[][] sprinkler, final int index, final int x, final int y ) {
	if ( index == sprinkler.length ) {
	    success = true;
	    return success;
	}

	for ( int i = 0; i < dx.length; i++ ) {
	    final int nx = x + dx[i];
	    final int ny = y + dy[i];
	    if ( 0 <= nx && nx < SIZE && 0 <= ny && ny < SIZE &&
		 sprinkler[index][X] - 1 <= nx && nx <= sprinkler[index][X] + 1 &&
		 sprinkler[index][Y] - 1 <= ny && ny <= sprinkler[index][Y] + 1) {
		dfs( sprinkler, index + 1, nx, ny );
		
	    }
	    if ( success ) {
		return true;
	    }
	}
	return success;
    }    
}

Measured memory_bytes: 18112
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

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

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int m, d; cin >> m >> d;
  int ans = 0;
  for (int mi = 1; mi <= m; mi++) {
    for (int di = 1; di <= d; di++) {
      int d1  = di % 10;
      int d10 = di / 10;
      if (d1 >= 2 && d10 >= 2 && d1 * d10 == mi) ans++;
    }
  }
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 888
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	double EPS = 1e-10;
	int[] x, y, id;
	int n;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			n = sc.nextInt();
			if( n == 0 ) break;
			
			x = new int[n];
			y = new int[n];
			id = new int[n];
			
			for(int i=0;i<n;i++) {
				id[i] = sc.nextInt();
				x[i] = sc.nextInt();
				y[i] = sc.nextInt();
			}
			
			int m = sc.nextInt();
			for(int i=0;i<m;i++) {
				int s = sc.nextInt();
				int g = sc.nextInt();
				for(int j=0;j<n;j++) if( id[j] == s ) {
					s = j; break;
				}
				for(int j=0;j<n;j++) if( id[j] == g ) {
					g = j; break;
				}

				int[] path = dijkstra(s, g);
				int[] rev = new int[n];
				if(path[0] == -1) {
					System.out.println("NA");
					continue;
				}
				int c = 0;
				int p = g;
				rev[c++] = p;
				while( path[p] != p ) {
					p = path[p]; rev[c++] = p;
				}

				System.out.print(id[ rev[--c] ]);
				for(;c>0;) {
					System.out.print(" " + id[ rev[--c] ]);
				}
				System.out.println();
			}
		}
	}
	
	int[] dijkstra(int s, int g) {
		double d[] = new double[n];
		int[] path = new int[n];
		boolean[] visited = new boolean[n];
		fill(d, INF);
		d[s] = 0;
		for (int i = 0; i < n; i++) path[i] = i;
		
		for(;;) {
			int v = -1;
			for(int u=0;u<n;u++) if(!visited[u]) {
				if(v == -1 || d[v] > d[u]) v = u;
			}
			
			if( v == g ) {
				if( d[g] == INF ) return new int[] {-1};
				return path;
			}
			visited[v] = true;
			
			for(int u=0;u<n;u++) {
				int dist = d(u, v);
				if( dist == INF ) continue;
				if( d[u] > d[v] + sqrt( dist ) ) {
					d[u] = d[v] + sqrt( dist );
					path[u] = v;
				}
			}
		}
	}
	
	int d(int u, int v) {
		int dx = x[u] - x[v];
		int dy = y[u] - y[v];
		return (dx*dx + dy*dy > 50*50? INF: dx*dx+dy*dy);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
#include<iostream>
using namespace std;
#define max 500000

int H, A[max + 1];

int left(int i) {
    return 2 * i;
}

int right(int i) {
    return 2 * i + 1;
}

void maxheapify(int i) {
    int l, r, largest;
    l = left(i);    
    r = right(i);
    if (l <= H && A[i] < A[l]) {
        largest = l;
    } else {
        largest = i;
    } 
    if ( r <= H && A[largest] < A[r]) {
        largest = r;
    }

    if (largest != i) {
        swap(A[i], A[largest]);
        maxheapify(largest);
    }
}

void buildmaxheap() {
    for (int i = H / 2; i > 0; i--) {
        maxheapify(i);
    }
}
int main() {
    cin >> H;
    for (int i = 1; i <= H; i++) {
        cin >> A[i];
    }
    
    buildmaxheap();
    for (int i = 1; i <= H; i++) {
        cout << " " << A[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 4964
n = int(input())
x = 1
y = 1
z = 1
a = [0]*(10**5)
for j in range(x,101):
    for k in range(y,101):
      for l in range(z,101):
        a[j**2+k**2+l**2+j*k+k*l+l*j]+=1
for i in range(1,n+1):
  print(a[i])

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

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		String ss = sc.next();
		if(ss.contains("2")) {
			char[] s = ss.toCharArray();
			boolean[] arr = new boolean[n];
			for(int i = 0; i < n; i++) {
				arr[i] = (s[i] == '2');
			}
			
			boolean[] res = arr;
			while(n > 1) {
				res = reduce(res, n);
				n = res.length;
			}
			System.out.println(res[0] ? "1" : "0");
		}
		else {
			char[] s = ss.toCharArray();
			boolean[] arr = new boolean[n];
			for(int i = 0; i < n; i++) {
				arr[i] = (s[i] == '3');
			}
			
			boolean[] res = arr;
			while(n > 1) {
				res = reduce(res, n);
				n = res.length;
			}
			System.out.println(res[0] ? "2" : "0");
		}
	}
	static boolean[] reduce(boolean[] arr, int n) {
		int d = 1;
		while((d<<1) < n) d <<= 1;
		int m = n - d;
		boolean[] res = new boolean[m];
		for(int i = 0; i < m; i++) {
			res[i] = arr[i] ^ arr[i+d];
		}
		return res;
	}
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch(IOException e) {
				throw new RuntimeException(e);
			}
		}
	}

}


Measured memory_bytes: 34308
#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 = 2e5 + 5;

int n, m, k, ans = 0;
int a[N], b[N];

int32_t main()
{
	IOS;
	cin >> n >> m >> k;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		a[i] += a[i - 1];
	}
	for(int i = 1; i <= m; i++)
	{
		cin >> b[i];
		b[i] += b[i - 1];
	}
	int ans = 0;
	int idx = m;
	for(int i = 0; i <= n; i++)
	{
		if(a[i] > k)
			break;
		while(a[i] + b[idx] > k)
			idx--;
		ans = max(ans, i + idx);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 6764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n;
  cin >> n;
  int d[n];
  rep(i,n)cin >> d[i];
  sort(d,d+n);
  cout << d[n/2] - d[n/2-1] << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
	int n, m, l;
	int i, j, k;
	int A[101][101];
	int B[101][101];
	long long int C[101][101];

	scanf("%d %d %d\n", &n, &m, &l);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			scanf("%d", &A[i][j]);
		}
		scanf("\n");
	}

	for (i = 0; i < m; i++) {
		for (j = 0; j < l; j++) {
			scanf("%d", &B[i][j]);
		}
		scanf("\n");
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++) {
			C[i][j] = 0;
			for (k = 0; k < m; k++) {
				C[i][j] += (A[i][k] * B[k][j]);
			}

			printf("%lld", C[i][j]);
			if (j < l - 1) {
				printf(" ");
			}
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2052
#include <cstdio>

struct Card
{
  char suit;
  char value;
  Card() : suit(0), value(0) {}
  Card(char s, char v) : suit(s), value(v) {}
};

Card C1[101], C2[101], C3[101];

void swap(Card *A, int i, int j)
{
    Card t = A[i];
    A[i] = A[j];
    A[j] = t;
}

int selection_sort(Card *A, int N)
{
    int swap_count = 0;
    for (int i = 0; i < N; ++i)
    {
        int mini = i;
        for (int j = i; j < N; ++j)
            if (A[j].value < A[mini].value)
                mini = j;
        if (i != mini) {
            swap(A, i, mini);
            swap_count++;
        }
    }
    return swap_count;
}

int bubble_sort(Card *A, int N)
{
    int swap_count = 0;
    for (int i = 0; i < N; ++i)
        for (int j = N-1; j > i; --j)
            if (A[j].value < A[j-1].value) {
                swap(A, j, j-1);
                swap_count++;
            }
    return swap_count;
}

int find(Card c, Card *A, int N)
{
    for (int i = 0; i < N; ++i)
        if (A[i].suit == c.suit && A[i].value == c.value)
            return i;
    return -1;
}

bool is_stable(Card *A, Card *sorted_A, int N)
{
    int last_value = 0;
    int last_ix = -1;
    for (int i = 0; i < N; ++i)
    {
        int ix = find(sorted_A[i], A, N);
        if (last_value == sorted_A[i].value)
        {
            if (last_ix >= ix)
                return false;
        }
        last_value = sorted_A[i].value;
        last_ix = ix;
    }
    return true;
}

void print_r(Card *A, int N)
{
    for (int i = 0; i < N; ++i)
    {
        if (i > 0) putchar(' ');
        printf("%c%c", A[i].suit, A[i].value);
    }
    putchar('\n');
}

int main(int argc, char const *argv[])
{
    int N;
    scanf("%d\n", &N);
    for (int i = 0; i <= N; i++ ) {
        scanf("%c%c ", &C1[i].suit, &C1[i].value);
        C2[i] = C1[i];
        C3[i] = C1[i];
    }

    bubble_sort(C1, N);
    print_r(C1, N);
    printf("%s\n", is_stable(C3, C1, N) ? "Stable" : "Not stable");

    selection_sort(C2, N);
    print_r(C2, N);
    printf("%s\n", is_stable(C3, C2, N) ? "Stable" : "Not stable");

    return 0;
}

Measured memory_bytes: 1044
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2")
typedef long long ll;

ll a[200005], b[200005];
ll n;

int main()
{
	ios::sync_with_stdio(false);
    cin >> n;
    int l, r;
    for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
    sort(a + 1, a + n + 1);
    sort(b + 1, b + n + 1);
    if (n % 2) l = a[(n + 1) / 2], r = b[(n + 1) / 2];
    else l = a[n / 2] + a[n / 2 + 1], r = b[n / 2] + b[n / 2 + 1];
    cout << r - l + 1;
	return 0;
}


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

//省略形
#define rep(i,n) for(auto i=0; i<n ; ++i)
#define REP(i,a,b) for(auto i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//よく使う定数
const int INF = 1e9;
const int MOD = 1e9+7;
//逆元
const int INV = 1e9+5;

//UnionFindTree
struct union_find{
  vector<int> data;
  union_find(int size) : data(size , -1) { }

  void merge(int x , int y){
    x = root(x); y = root(y);
    if(x == y) return;
    if(data[y] < data[x]) swap(x , y);
    data[x] += data[y];
    data[y] = x;
    return; 
  }

  bool same(int x , int y){
    x = root(x) , y = root(y);
    return x == y;
  }

  int root(int x){
    return data[x] < 0 ? x : (data[x] = root(data[x]));
  }

  int size(int x){
    return -data[root(x)];
  }
};

//プロトタイプ宣言
void faster(void);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);
template <class T>
T modpow(T , T , T);
bool is_palindrome(string);

//メモ
//最大公約数:__gcd　|　最小公倍数:__lcm
//回文は反転させて一致すればよい


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


























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//繰り返し自乗法
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//繰り返し自乗法(剰余)
template <class T>
T modpow(T x , T y , T mod){
  if(y == 0) return 1;
  if(y%2 == 1){
    ll temp = modpow(x,y-1,mod);
    return temp*x%mod;
  }
  else{
    ll temp = pow_mod(x,y/2,mod);
    return temp*temp%mod;
  }
}

bool is_palindrome(string s){
    string t(s.rbegin(),s.rend());
    return s == t;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=1e5;

int main(){
	int N;
	int a[MAX+1];
	cin>>N;
	rep1(i,N)cin>>a[i];
	int ans=0;
	rep1(i,N)if(a[a[i]]==i)ans++;
	cout<<ans/2<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>

using namespace std;

int main(){
  int N, M, a[51], b[51], c[51], d[51], mn, mn_max, ans[51];

  cin >> N >> M;

  for(int i = 0; i < N; i++) cin >> a[i] >> b[i];
  for(int i = 0; i < M; i++) cin >> c[i] >> d[i];

  for(int i = 0; i < N; i++){
    mn_max = INT_MAX;
    for(int j = 0; j < M; j++){
      mn = abs(a[i] - c[j]) + abs(b[i] - d[j]);

      if(mn < mn_max){
        mn_max = mn;
        ans[i] = j+1;
      }
    }
  }

  for(int i = 0; i < N; i++) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main (String[] args) throws IOException {
        
        BufferedReader reader = new BufferedReader (new InputStreamReader (System.in));
        StringBuilder builder = new StringBuilder();

        String line = reader.readLine();
        int count = Integer.parseInt(line);

        line = reader.readLine();
        String[] columns = line.split(" ");
        int[] numbers = new int[count];
        for (int i = count-1; i >= 0 ; i-- ) {
            if ( builder.length() != 0 ) {
                builder.append(" ");
            }
            builder
                .append(Integer.parseInt(columns[i]));
        }
        System.out.println(builder);
    }
}

Measured memory_bytes: 24228
main = do
    [s,t] <- words <$> getLine
    [a,b] <- (map read . words) <$> getLine
    u <- getLine
    if s == u
    	then putStrLn $ show (a-1) ++ " " ++ show b
        else putStrLn $ show a ++ " " ++ show (b-1)

Measured memory_bytes: 508
#include <stdio.h>
#include <math.h>
#include <string>
#include <iostream>
using namespace std;

class Dice {

private:
	int TOP = 0;
	int FRONT = 1;
	int RIGHT = 2;
	int LEFT = 3;
	int BACK = 4;
	int BOTTOM = 5;
	int pips[6];
	void swap(int tp, int fr, int bt, int ri, int lf, int bk);

public:
	Dice();
	void rotate(char op);
	void spin();
	void setTopAndFront(int top, int front);
	int getPip(int i);
};

Dice::Dice() {
	for (int i = 0; i < 6; i++) cin >> pips[i];
}

void Dice::rotate(char op) {
	switch (op) {
	case 'N': swap(FRONT, BOTTOM, RIGHT, LEFT, TOP, BACK); break;
	case 'S': swap(BACK, TOP, RIGHT, LEFT, BOTTOM, FRONT); break;
	case 'E': swap(LEFT, FRONT, TOP, BOTTOM, BACK, RIGHT); break;
	case 'W': swap(RIGHT, FRONT, BOTTOM, TOP, BACK, LEFT); break;
	}
}

void Dice::spin() {
	swap(TOP, LEFT, FRONT, BACK, RIGHT, BOTTOM);
}

void Dice::swap(int tp, int fr, int ri, int lf, int bk, int bt) {
	int wk[6] = { pips[tp], pips[fr], pips[ri], pips[lf], pips[bk], pips[bt] };
	for (int i = 0; i < 6; i++) pips[i] = wk[i];
}

void Dice::setTopAndFront(int top, int front) {
	if (pips[LEFT] == top) rotate('E');
	if (pips[RIGHT] == top) rotate('W');
	while (pips[TOP] != top) rotate('N');
	while (pips[FRONT] != front) spin();
}

int Dice::getPip(int i) {
	return pips[i];
}

int main()
{
	Dice dice = Dice();
	int n, t, f;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t >> f;
		dice.setTopAndFront(t, f);
		cout << dice.getPip(2) << "\n";
	}
}



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

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;

unsigned long long clp(unsigned long long x) {
    x -= 1;
    x = x | (x >>  1);
    x = x | (x >>  2);
    x = x | (x >>  4);
    x = x | (x >>  8);
    x = x | (x >> 16);
    x = x | (x >> 32);
    return x + 1;
}

template <class T>
class segment_tree {
private:
    const size_t n;
    const T UNIT;
    const std::function<T(const T&, const T&)> f;
    std::vector<T> a;
public:
    segment_tree(size_t size, std::function<T(const T&, const T&)> f, T UNIT) : n(clp(size)), UNIT(UNIT), f(f) {
        a.resize(2 * n - 1, UNIT);
    }

    void update(size_t i, const T &x) {
        i += n - 1;
        a[i] = min(a[i], x);
        while (i) {
            i = (i - 1) / 2;
            a[i] = f(a[2 * i + 1], a[2 * i + 2]);
        }
    }

    T query(size_t query_first, size_t query_last, size_t k = 0, size_t node_first = 0, size_t node_last = 0) const {
        if (k == 0) {
            node_last = n;
        }
        if (node_last <= query_first || query_last <= node_first) {
            return UNIT;
        }
        if (query_first <= node_first && node_last <= query_last) {
            return a[k];
        } else {
            size_t node_mid = (node_first + node_last) / 2;
            T vl = query(query_first, query_last, k * 2 + 1, node_first, node_mid);
            T vr = query(query_first, query_last, k * 2 + 2, node_mid, node_last);
            return f(vl, vr);
        }
    }
};

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

    constexpr ll INF = LLONG_MAX;

    int N, M;
    cin >> N >> M;
    vector<vector<pii>> g(N);
    REP(i, M) {
        int L, R, C;
        cin >> L >> R >> C;
        --L;
        --R;
        g[L].emplace_back(R, C);
    }

    vector<ll> dp(N, INF);
    segment_tree<ll> st(N, [](ll x, ll y) { return min(x, y); }, INF);
    st.update(0, 0);
    REP(L, N) {
        dp[L] = st.query(L, N);
        if (dp[L] == INF)
            continue;
        for (auto [R, C] : g[L]) {
            st.update(R, dp[L] + C);
        }
    }
    ll result = dp[N - 1];
    if (result == INF)
        result = -1;
    cout << result << endl;

    return 0;
}


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

using ll = long long;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string S; ll K; cin >> S >> K;
	int N = int(S.size());
	if (S == string(N, S[0])) {
		cout << K * N / 2 << '\n';
	} else {
		int prefLen = 0;
		for (int i = 0; S[i] == S[0]; i++) {
			prefLen++;
		}
		int suffLen = 0;
		for (int i = N-1; S[i] == S[N-1]; i--) {
			suffLen++;
		}
		int midVal = 0;
		for (int i = prefLen + 1; i < N - suffLen; i++) {
			if (S[i] == S[i-1]) {
				midVal++;
				i++;
			}
		}
		ll ans = K * midVal + prefLen/2 + suffLen/2 + (S[0] == S[N-1] ? (prefLen + suffLen) / 2 : prefLen/2 + suffLen/2) * (K-1);
		cout << ans << '\n';
	}

	return 0;
}


Measured memory_bytes: 256
N=int(input())
N_str = []
for i in range(N,1000):
    N_new = N
    while N>0:
        N_str.append(N%10)
        N//=10
    N_str.reverse()
    
    N = N_new
          
    if N_str[0]==N_str[1] and N_str[1]==N_str[2]:
        print(N)
        break
    N+=1

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;

const int mod=1e9+7;
const int inf=-1;
const int sz=2e5;

#define pi acos(-1)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define gap ' '
#define lb lower_bound
#define ub upper_bound
#define clr(x) memset(x,0,sizeof(x))
#define all(x) sort(x.begin(),x.end())
#define rall(x) reverse(x.begin(),x.end())
#define dbg puts("finding wrong")
#define case(x,y) printf("Case %lld: %lld\n",++x,y)
#define fastio ios::sync_with_stdio(false);cin.tie(0)

map<pair<int,int> ,int>use;
map<int,int>row,col;
int main()
{
  fastio;
  ll i, n, m, k, a, b, pos=0, mx=0, res=0, ans, mx2=0,pos2=0;
  cin>>n>>m>>k;
  for(i=1; i<=k; i++)
  {
      cin>>a>>b;
      use[{a,b}]=1;
      row[a]++;
      col[b]++;
      if(row[a]>mx)
      {
          mx=row[a];
          pos=a;
      }
      if(col[b]>mx2)
      {
          mx2=col[b];
          pos2=b;
      }
  }
  for(i=1; i<=m; i++)
  {
      ans=mx+col[i];
      if(use[{pos,i}])ans--;
      res=max(res,ans);
  }
  for(i=1; i<=n; i++)
  {
      ans=mx2+row[i];
      if(use[{i,pos2}])ans--;
      //cout<<ans<<" "<<mx2<<" "<<row[i]<<endl;
      res=max(res,ans);
  }
  cout<<res<<endl;
  
}


Measured memory_bytes: 88016
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long ans = 1;
        for(int i=0; i<N; i++){
            long T = sc.nextLong();
            ans = lcm(T,ans);
        }
        System.out.println(ans);
    }
    static long gcd(long A, long B){
        while(true){
            long tmp = A%B;
            if(tmp==0){
                break;
            }
            A = B;
            B = tmp;
        }
        return B;
    }
    static long lcm(long A, long B){
        return A/gcd(A,B)*B;
    }
}

Measured memory_bytes: 21844
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val K = nextInt()
    val que = java.util.ArrayDeque<Long>()
    (1L..9L).forEach { que.add(it) }
    repeat(K - 1) {
        val x = que.poll()
        if (x % 10 != 0L) {
            que.add(x * 10 + x % 10 - 1)
        }
        que.add(x * 10 + x % 10)
        if (x % 10 != 9L) {
            que.add(x * 10 + x % 10 + 1)
        }
    }
    println(que.poll())
}

Measured memory_bytes: 44296