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

const int mod = 1e9 + 7;

void add_self (int & a, int b) {
	a += b;
	if (a >= mod) a -= mod;
}

int mul (int a, int b) {
	return (int) (((ll) a * b) % mod);
}

int power (int a, int k) {
	int ans = 1;
	while (k >= 1) {
		if (k & 1) ans = mul (ans, a);
		a = mul (a, a);
		k >>= 1;
	}
	return ans;
}

int inverse (int a) {
	return power (a, mod - 2);
}

void max_self (int & a, int b) {
	if (a < b) a = b;
}

const int mx = 1e6 + 5;

int main() {
	int N;
	scanf ("%d", &N);
	vector < int > A (N);
	for (int & x : A) scanf ("%d", &x);
	vector < int > answer (mx);
	for (int x : A) {
		map < int, int > m;
		for (int i = 2; i * i <= x; i++) {
			while (x % i == 0) {
				m[i]++;
				x /= i;
			}
		}
		if (x != 1) {
			m[x]++;
		}
		for (auto it = m.begin(); it != m.end(); it++) {
			max_self (answer[it -> first], it -> second);
		}
	}
	int lcm = 1;
	for (int i = 2; i < mx; i++) {
		lcm = mul (lcm, pow (i, answer[i]));
	}
	int ans = 0;
	for (int x : A) {
		add_self (ans, mul (lcm, inverse (x)));
	}
	printf ("%d\n", ans);
	return 0;
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> hen(N);
    
    for (int i = 0; i < M; i++) {
        int u, v;
        cin >> u >> v;
        hen[u-1].push_back(v-1);
    }
    int S, T;
    cin >> S >> T;
    S--;
    T--;
    
    vector<vector<int>> flag(N, vector<int>(3, 0));
    flag[S][0] = 1;
    queue<vector<ll>> que;
    for (int i = 0; i < hen[S].size(); i++) {
        flag[hen[S][i]][1] = 1;
        vector<ll> a = {hen[S][i], 1, 0};
        que.push(a);
    }
    
    ll ans = -1;
    while(!que.empty()) {
        vector<ll> p = que.front();
        que.pop();
        //cout << p[0] << " " << p[1] << " " << p[2] << endl;
        for (int i = 0; i < hen[p[0]].size(); i++) {
            if (p[1] < 2 && flag[hen[p[0]][i]][p[1]+1] == 0) {
                flag[hen[p[0]][i]][p[1]+1] = 1;
                vector<ll> a = {hen[p[0]][i], p[1]+1, p[2]};
                que.push(a);
            }
            else if (p[1] == 2 && flag[hen[p[0]][i]][0] == 0) {
                if (hen[p[0]][i] == T) {
                    ans = p[2]+1;
                    break;
                }
                flag[hen[p[0]][i]][0] = 1;
                vector<ll> a = {hen[p[0]][i], 0, p[2]+1};
                que.push(a);
            }
        }
        if (ans != -1)
            break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 11136
#include <stdio.h>
#include <string.h>
typedef struct {char name[11];int t;}queue;
queue que[1000000];

int main(void){
    int i,n,q;
    scanf("%d %d",&n,&q);
    int cnt=n,st=1,el=0;
    for(i=1;i<=n;i++){scanf("%s %d",que[i].name,&que[i].t);}
    while (cnt>0){
        if (que[st].t<=q){
            el+=que[st].t;
            printf("%s %d\n",que[st].name,el);
            st++;cnt--;
        }
        else{
            el+=q;que[st+cnt].t=(que[st].t)-q;
            strcat(que[st+cnt].name,que[st].name);
            st++;
        }
    }
    return 0;
}




Measured memory_bytes: 4684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n;
  string s;
  cin >> n >> s;
  string temp1, temp2;
  vector<int> count(n - 1, 0);

  for (int i = 1; i < n; i++) {
    temp1 = s.substr(0, i);
    temp2 = s.substr(i, n - i);
    // cout << temp1 << " " << temp2 << endl;
    for (char ch = 'a'; ch <= 'z'; ch++) {
      if (temp1.find(ch) != string::npos && temp2.find(ch) != string::npos) {
        count[i - 1]++;
      }
    }
  }

  int ans = *max_element(count.begin(), count.end());
  cout << ans << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

AC, WA, C = 0, 0, [0] * N
for _ in range(M):
    p, S = input().split()
    p = int(p) - 1
    if C[p] >= 0:
        if S == 'AC':
            AC, WA, C[p] = AC + 1, WA + C[p], -1
        else:
            C[p] += 1

print(AC, WA)


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

using namespace std;
typedef long long ll;
#define int ll

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

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

int N;
string C;

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

    cin >> N >> C;

    int l = 0, r = N-1;
    int ans = 0;
    while(l < r) {
        if(C[l] != 'W') { l++; }
        if(C[r] != 'R') { r--; }
        if(C[l] == 'W' && C[r] == 'R') {
            swap(C[l], C[r]);
            l++;
            r--;
            ans++;
        }
    }
    printf("%lld\n", ans);

    return 0;
}


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

int main() {
  long a,b,k;
  cin >> a >> b >> k;
  if(a>=k){
    cout << a-k << " " << b;
  }else if(k>=a+b){
    cout << 0 << " " << 0;
  }else{
    long c = k-a;
    cout << 0 << " " << b-c;
  }
  
}


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

using namespace std;
using p=pair<int,int>;
typedef long long ll;

int main() {
  char i;
  cin >> i ;
  i++;
  cout << i << endl;

  return 0;

}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
const int maxn=1e5+7;
int main()
{
	int n,a,cntj=0;
	bool o=0;
	scanf("%d",&n);
	if(n==0)
	{
		printf("NO");
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		if(a&1)
		cntj++;
		else
		o=1;
		if(cntj==2)
		o=1,cntj=0;
	}
	if(cntj&&o)
	printf("NO");
	else
	printf("YES");
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> B;
    for (int i = 0; i + 1 < n; ++i) {
        int x;
        cin >> x;
        B.push_back(x);
    }
    int res = 0;
    for (int i = 0; i < n; ++i) {
        int l = 1 << 24;
        int r = 1 << 24;
        if (i - 1 >= 0) {
            l = min(l, B[i - 1]);
        }
        if (i + 1 < n) {
            r = min(r, B[i]);
        }
        res += min(l, r);
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n, m;
    cin >> n >> m;
    bool start[n], end[n], boat = false;
    for (long long i = 0; i < n; i++)
    {
        start[i] = false;
        end[i] = false;
    }
    for (long long i = 0; i < m; i++)
    {
        long long a, b;
        cin >> a >> b;
        if (a == 1) start[b - 1] = true;
        if (b == n) end[a - 1] = true;
    }
    for (long long i = 1; i < n; i++)
    {
        if (start[i] == true && end[i] == true)
        {
            boat = true;
            break;
        }
    }
    if (boat == true) cout << "POSSIBLE";
    else cout << "IMPOSSIBLE";
}

Measured memory_bytes: 3896
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
n=0
for i in range(N):
  A=list(map(int,input().split()))
  s=0+C
  for a,b in zip(A,B):
    c=a*b
    s=s+c
  if s >0:
    n=n+1
print(n)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir [] = {
	{ 0, 1 },{ -1 ,1 },{ -1, 0 },
	{ -1 ,-1 },{ 0,-1 },{ 1 ,-1 },
	{ 1,0 },{ 1 ,1 }
};

signed main() {
	int n, m, h;
	scanf("%d %d %d", &n, &m, &h);
	vector<vector<pii>> g(n,vector<pii>());
	vector<ll> ver(n);
	REP(i, n) {
		scanf("%lld", &ver[i]);
	}
	REP(i, m) {
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		a--; b--;
		g[a].push_back({ b,c });
		g[b].push_back({ a,c });
	}
	priority_queue<pair<pll, ll>, vector<pair<pll, ll>>, greater<pair<pll, ll>>> que;
	vector<ll> al(n,-1);
	que.push({ {0,h},0 });
	while (que.size()) {
		pair<pll, ll> cur = que.top();
		que.pop();

		if (al[cur.second] != -1)
			continue;
		al[cur.second] = cur.first.first;

		for (auto itr : g[cur.second]) {
			pll nex = { cur.first.first + itr.second, cur.first.second - itr.second };
			ll setp = cur.first.second;
			if (nex.second < 0) {
				setp += -nex.second;
				nex.first += -nex.second;
				nex.second = 0;
			}
			else if (nex.second > ver[itr.first]) {
				setp -= nex.second - ver[itr.first];
				nex.first += nex.second - ver[itr.first];
				nex.second = ver[itr.first];
			}
			if (setp <= ver[cur.second]) {
				if (itr.first == n - 1) {
					nex.first += ver[itr.first] - nex.second;
					nex.second = ver[itr.first];
				}
				que.push({ nex,itr.first });
			}
		}

	}
	printf("%lld\n", al[n-1]);
	return 0;
}

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

using namespace std;
typedef long long int lli;
typedef pair<int,int> pii;

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

	int ans = n*(n - 1);
	ans += m*(m - 1);

	printf("%d\n",ans/2);
}

Measured memory_bytes: 256
#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;

int main()
{
	string S;
	cin >> S;
	int ans = 0;
	int temp = 0;
	rep(i,3)
	{
		if (S[i] == 'R') temp++;
		else temp = 0;
		ans = max(ans,temp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(void){
  char pattern[8][8];
  char c1,c2,c3,c4,c5,c6,c7,c8,_;
  for(int i=0;i<8;i++){
    scanf("%c%c%c%c%c%c%c%c%c",&c1,&c2,&c3,&c4,&c5,&c6,&c7,&c8,&_);
    pattern[i][0]=c1;
    pattern[i][1]=c2;
    pattern[i][2]=c3;
    pattern[i][3]=c4;
    pattern[i][4]=c5;
    pattern[i][5]=c6;
    pattern[i][6]=c7;
    pattern[i][7]=c8;
  }
  printf("90\n");
  for(int i=0;i<8;i++){
    for(int j=0;j<8;j++){
      printf("%c",pattern[7-j][i]);
    }
    printf("\n");
  }
  printf("180\n");
  for(int i=0;i<8;i++){
    for(int j=0;j<8;j++){
      printf("%c",pattern[7-i][7-j]);
    }
    printf("\n");
  }
  printf("270\n");
  for(int i=0;i<8;i++){
    for(int j=0;j<8;j++){
      printf("%c",pattern[j][7-i]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 1960
import math

n = int(input())
vector_x = [float(x) for x in input().split(" ")]
vector_y = [float(y) for y in input().split(" ")]

p1 = sum([abs(x - y) for x, y in zip(vector_x, vector_y)])
p2 = sum([abs(x - y) ** 2 for x, y in zip(vector_x, vector_y)]) ** (1/2)
p3 = sum([abs(x - y) ** 3 for x, y in zip(vector_x, vector_y)]) ** (1/3)
t = max([abs(x - y) for x, y in zip(vector_x, vector_y)])

print("{:.6f}".format(p1))
print("{:.6f}".format(p2))
print("{:.6f}".format(p3))
print("{:.6f}".format(t))

Measured memory_bytes: 7820
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;scanf("%d",&n);
    vector<pair<int,int>> m(n);
    for(int i=0;i<n;i++)scanf("%d%d",&m[i].first,&m[i].second);
    int dp[n][n];
    fill(dp[0],dp[0]+n*n,1e9);
    for(int i=0;i<n;i++)dp[i][i]=0;
    for(int k=1;k<n;k++){
        for(int i=0;i<n-k;i++){
            int j=i+k;
            for(int l=i;l<j;l++){
                dp[i][j]=min(dp[i][j],dp[i][l]+dp[l+1][j]+m[i].first*m[l].second*m[j].second);
            }
        }
    }
    printf("%d\n",dp[0][n-1]);
    return 0;
}


Measured memory_bytes: 3232
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int x,y,r=1;/* 変数の宣言 */
  scanf("%d%d",&x,&y);/* 変数の格納 */
  if(x<1 || y >1000000000){/* 制約 */
    exit(0);/* 変数が正しくない場合、プログラムを終了する */
  }
  r = x % y;
  while(r!=0){
    x = y;
    y = r;
    r = x % y;
  }/* ユークリッドの互除法 */
  printf("%d\n",y);/* 最大公約数の表示 */

  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;
 
#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)
 
void ii(ll &x){ cin >> x; }
void is(string &x){ cin >> x; }
void oi(ll &x){ cout << x << " "; }
void os(string &x){ cout << x; }
void oie(ll &x){ cout << x << endl; }
void ose(string &x){ cout << x << endl; }
void oe(){ cout << endl; }
 
int main(){
    string s; is(s);
    ll dp[s.size()+1][2];
    REP(i,0,s.size()){dp[i][0]=0;dp[i][1]=0;}
    dp[0][1]=1;
    REP(i,0,s.size()){
        ll n = s[i]-'0';
        dp[i+1][0]=min(dp[i][0]+n, dp[i][1]+(10-n));
        dp[i+1][1]=min(dp[i][0]+n+1, dp[i][1]+(10-n-1));
    }
    oie(dp[s.size()][0]);
    return 0;
}

Measured memory_bytes: 17028
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String A = sc.next();
    String B = sc.next();
    String C = sc.next();
    
    boolean ans = 
      A.charAt(A.length()-1) == B.charAt(0)
      && B.charAt(B.length()-1) == C.charAt(0);
    
    System.out.println(ans ? "YES" : "NO");
  }
}

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

using Cost = int;
struct Edge{
    Cost cost;
    int to;
    bool operator>(const Edge &right)const{
        return cost > right.cost;
    }
};

int INF = 1e9;
vector<Cost> dp;

void dijkstra(vector<vector<Edge>> &g, Edge start){
    priority_queue<Edge, vector<Edge>, greater<Edge>> qu;
    dp[start.to] = start.cost;
    qu.push(start);
    while(qu.size()){
        Edge cur = qu.top();
        qu.pop();
        int v = cur.to;
        if(dp[v] < cur.cost) continue;
        for(Edge e : g[v]){
            if( dp[e.to] > cur.cost + e.cost){
                dp[e.to] = cur.cost + e.cost;
                qu.push({dp[e.to], e.to});
            }
        }
    }
}


int main(){
    int n;
    cin>>n;
    vector<string> s(n);

    vector<vector<Edge>> g(n);
    dp = vector<Cost>(n, INF);
    vector<int> last(26,-1);
    rep(i,n){
        cin>>s[i];
    }
    rep(i,n-1){
        g[i].push_back({1, i+1});
    }
    rep(i,n){
        // int alpha_idx = (s[i][0]-'a')+n;
        // g[i].push_back({0, alpha_idx});
        // g[alpha_idx].push_back({0, i});
        int idx = (s[i][0]-'a');
        if(last[idx] != -1){
            g[last[idx]].push_back({0, i});
        }
        last[idx] = i;
    }
    dijkstra(g, (Edge){0,0});
    cout<<dp[n-1]+1<<endl;
}


Measured memory_bytes: 16280
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll A,B;
  cin>>A>>B;
  A-=2*B;
  if(A>0) {
cout<<A<<endl;
  }
else {
cout<<0<<endl;
}
}
  


Measured memory_bytes: 3624
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In,' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int H = cin.ReadInt;
            int W = cin.ReadInt;
            int h = cin.ReadInt;
            int w = cin.ReadInt;

            WriteLine(H*W - H*w - W*h + h*w);
        }

    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream,char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0;i < tmp.Length;i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }

}

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

const int N = 200005;

int n, a[N];
vector<int> z;
priority_queue < int, vector<int>, greater<int> > pq[N];
long long res;

void merge(int u, int v) { // merge u -> v
    if (pq[u].size() > pq[v].size()) pq[u].swap(pq[v]);
    while(!pq[u].empty()) pq[v].push(pq[u].top()), pq[u].pop();
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i], z.push_back(a[i]);
    sort(z.begin(), z.end());
    z.erase(unique(z.begin(), z.end()), z.end());

    for (int i = 1; i <= n; ++i) {
        a[i] = lower_bound(z.begin(), z.end(), a[i]) - z.begin() + 1;
    }

    deque <int> dq;
    for (int i = 1; i <= n; ++i) dq.push_back(i), pq[i].push(a[i]);

    for (int i = 1; i <= n; ++i) {
        while(!dq.empty() && pq[dq.front()].top() != i) {
            int u = dq.front(); dq.pop_front();
            int v = dq.front();
            merge(u, v);
        }
        
        int x = dq.front(); dq.pop_front();
        pq[x].pop();

        res += pq[x].size();

        if (pq[x].size()) dq.push_back(x);
    }

    cout << res << endl;
}


Measured memory_bytes: 19900
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[100000+10];
ll zs[100000+10][10][15];
int p[100000+10];
const ll mod=1000000007;
int my_min(int a,int b)
{
	return a<b?a:b;
}
int main()
{
	//	printf("%d\n",100%13);
	scanf("%s",s);
	int sum=1;
	int len=strlen(s);
	int js=0;
	int last=-1;
	for(int i=len-1;i>=0;i--)
	{
		if(s[i]!='?')
			js=(js+sum*(s[i]-'0'))%13;
		else
		{
			if(last==-1)
			{
				for(int k=0;k<10;k++)
				{
					int ns=(js+sum*k)%13;
					zs[i][k][ns]=1;
			//		printf("%d %d\n",js,ns);
				}
			}
			else
			{
				for(int k=0;k<10;k++)
				{
					for(int qm=0;qm<13;qm++)
					{
						int ns=(js+sum*k)%13;
						int w=(qm-ns+13)%13;
						for(int y=0;y<10;y++)
							zs[i][k][qm]=(zs[i][k][qm]+zs[last][y][w])%mod;
					}
				}
			}
			last=i;
			js=0;
		}
		sum=(sum*10)%13;
	}
	if(last==-1)
	{
		if(js==5)
			printf("1\n");
		else
			printf("0\n");
	}
	else
	{
		ll qqqq=0;
		for(int i=0;i<10;i++)
		 qqqq=(qqqq+zs[last][i][(5-js+13)%13])%mod;
		printf("%d\n",qqqq);
	}
	return 0;
}

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

vector<int> D(int x){
  vector<int> ans(0);
  for(int i=1;i*i<=x;i++){
    if(x%i==0){
      ans.push_back(i);
      if(i*i!=x){
        ans.push_back(x/i);
      }
    }
  }
  sort(ans.begin(),ans.end());
  
    return ans;
  }


/*vector< int > d(int n) {
  vector< int > ret(0);
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}*/


int main() {
  int N;
  cin>>N;
  vector<int> box(N,0);
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  //cout<<3<<a.at(0);
  for(int i=N-1;i>=0;i--){
    box.at(i)=a.at(i);
    if(box.at(i)==1){
      vector<int> num=D(i+1);
     
      for(int j=0;j<num.size();j++){
        a.at(num.at(j)-1)=(a.at(num.at(j)-1)+1)%2;
      }
     // a.at(0)=(a.at(0)+1)%2;
    }
  }
  int ans=0;
  for(int i=0;i<N;i++){
    if(box.at(i)==1){
      ans++;
    }
  }
  cout<<ans<<endl;
  for(int i=0;i<N;i++){
    if(box.at(i)==1){
      cout<<i+1<<" ";
    }
  }
  


 
}


Measured memory_bytes: 2560
n , m = map(int, input().split())

num = [-1] * n

for _ in range(m):
    s, c = map(int, input().split())
    if s == 1 and c == 0 and n > 1:
        print(-1)
        exit()
    if num[s-1] == -1 or num[s-1] == c:
        num[s-1] = c
    else:
        print(-1)
        exit()

for i in range(n):
    if i == 0 and num[i] == -1:
        if n > 1:
            num[i] = 1
        else:
            num[i] = 0
    elif i != 0 and num[i] == -1:
        num[i] = 0

print(''.join(map(str, num)))



Measured memory_bytes: 3064
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#define F first
#define S second
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ld long double
#define pii pair <int ,int >
#define bug(x)  cout<<"passed "<<x<<endl;
long long const inf = 1e18, linf = 2e9, mod = 1e9+7;
int const mxn = 4e5+10;
 
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

ld l[mxn] , sum = 0  ;

int main(){
	int n , m ; 
	cin>>n>>m;
	ld f = 4*m; 
	for (int i = 1 ; i <=n ; i++){
		cin>>l[i];
		sum+=l[i];
	}
	int ans =  0; 
	for (int i = 1 ; i<=n ; i++){
		if (l[i] * f >= sum)
			ans++;
	}
	if (ans >=m)
		cout<<"Yes";
	else
		cout<<"No";
}

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

int main() {
	int n,h,l,s,i,j;
	char da[10],a;
	cin >> n;
	for (n;n>0;n--) {
		scanf("%s",da);
		sort(da,da+8);
		h=l=0;
		for (i=0,s=10000000;i<8;i++,s/=10) {
			h+=(da[7-i]-'0')*s; l+=(da[i]-'0')*s;
		}
        cout << h-l << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) ((a)>(0)?(a):-(a))
#define rep(i,l,r) for((i)=(l);(i)<(r);(i)++)
using namespace std;
int main(){
    int n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        if((int)(log10((double)i))%2)i*=10;
        if(i<=n)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
from heapq import heappop,heappush


def main():
    N,K=map(int,input().split())
    Juwels=list(map(int,input().split()))


    res=0

    for l in range(min(N,K)+1):
        for r in range(min(N,K)-l+1):
            hands=[]
            for juwel in Juwels[:l]:
                heappush(hands,juwel)
            for juwel in Juwels[N-r:]:
                heappush(hands,juwel)

            step=l+r
            while len(hands)>0 and step<K:
                value=heappop(hands)
                if value>=0:
                    heappush(hands,value)
                    break
                step+=1

            res=max(res,sum(hands))

    print(res)

if __name__=="__main__":
    main()




Measured memory_bytes: 3064
// Try AtCoder
// authoer: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let _n = get!();
    let m = get!();
    
    use std::cmp::{min, max};
    let mut l = get!();
    let mut r = get!();
    for _ in 1..m {
        l = max(l, get!());
        r = min(r, get!());
    }
    
    let ans = max(0, r - l + 1);
    
    println!("{}", ans);
}

Measured memory_bytes: 6396
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

int main() {
	int a, b;
	vector<int> v = { 2,3,4,5,6,7,8,9,10,11,12,13,1 };
	cin >> a >> b;
	auto A = find(v.begin(), v.end(), a) - v.begin();
	auto B = find(v.begin(), v.end(), b) - v.begin();
	if (A == B)cout << "Draw" << endl;
	else cout << (A > B ? "Alice" : "Bob") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int h, n; cin >> h >> n;
    VI a(n), b(n);
    FOR(i, 0, n)cin >> a[i] >> b[i];

    VI dp(h + 1, INF);
    dp[0] = 0;
    FOR(i, 0, h)FOR(j, 0, n) {
        chmin(dp[min(i + a[j], h)], dp[i] + b[j]);
    }

    cout << dp[h] << "\n";
}


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

int main(){
  int a,b,c;

  scanf("%d %d %d", &a, &b, &c);

  if(b - a == c - b) printf("YES\n");

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <unistd.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n,k;
    cin >> n >> k;
    put(n-k+1);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

const int N=301;

int n;
int f[N][N]={};
int sumx[N][N]={};
int sumy[N][N]={};

int main()
{
    scanf(" %d", &n);
    rep(i,n)rep(j,n) scanf(" %d", &f[i+1][j+1]);

    for(int i=1; i<=n; ++i)for(int j=1; j<=n; ++j) sumx[i][j] = sumx[i][j-1]+f[i][j];
    for(int i=1; i<=n; ++i)for(int j=1; j<=n; ++j) sumy[j][i] = sumy[j-1][i]+f[j][i];

    int ans = -1000;
    for(int i=1; i<=n; ++i)for(int j=1; j<=n; ++j)for(int k=j; k<=n; ++k) ans = max(ans, sumx[i][k]-sumx[i][j-1]);
    for(int i=1; i<=n; ++i)for(int j=1; j<=n; ++j)for(int k=j; k<=n; ++k) ans = max(ans, sumy[k][i]-sumy[j-1][i]);

    // x????????????
    for(int lx=1; lx<=n; ++lx)for(int rx=lx+1; rx<=n; ++rx)
    {
        int dp = sumx[n][rx]-sumx[n][lx-1];
        for(int y=n-1; y>=1; --y)
        {
            ans = max(ans, dp+(sumx[y][rx]-sumx[y][lx-1]));
            dp = max(dp+f[y][lx]+f[y][rx],(sumx[y][rx]-sumx[y][lx-1]));
        }
    }

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

Measured memory_bytes: 4244
import sys

input = sys.stdin.readline
n = int(input())
ans = n
for i in range(n+1):
    cnt = 0
    t = i
    while t > 0:
        cnt += t % 6
        t = int(t/6)
    t = n - i
    while t > 0:
        cnt += t % 9
        t = int(t/9)
    if ans > cnt:
        ans = cnt
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include <assert.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
#include <climits>
using namespace std;
typedef unsigned long long ull;
#define ll long long int
static const double PI = 3.141592653589793;
ll mod = 1000000007;
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;

int main() {
	string s, t;
	cin >> s >> t;
	vector<vector<ll>> vec(28);
	for (int i = 0; i < s.size(); i++) {
		vec[s[i] - 'a'].push_back(i);
	}
	for (int i = 0; i < t.size(); i++) {
		if (vec[t[i] - 'a'].size() == 0) {
			cout << -1 << endl;
			return 0;
		}
	}
	ll y = 0,ind=-1;
	for (int i = 0; i < t.size(); i++) {
		int it = upper_bound(vec[t[i] - 'a'].begin(), vec[t[i] - 'a'].end(), ind) - vec[t[i] - 'a'].begin();
		if (it >= vec[t[i] - 'a'].size()) {
			y += s.size();
			ind = vec[t[i] - 'a'][0];
		}
		else {
			ind = vec[t[i] - 'a'][it];
		}
	}
	cout << y+ind+1 << endl;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,q,b,e;
	cin >> n;
	vll a(n);  rep(i,n) cin >> a[i];
	cin >> q;
	rep(i,q){
		cin >> b >> e;
		reverse(a.begin()+b,a.begin()+e);
	}
	rep(i,n)cout << a[i] << (i==n-1?"\n":" ");
	return 0;
}


Measured memory_bytes: 3092
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
ostream &operator<<(ostream &out, vector<T> const &v) {
    for (auto &&a : v) out << a << " ";
    out << endl;
    return out;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int D;
    cin >> D;

    vi c(26);
    REP(i, 26) {
        cin >> c[i];
    }
    vvi s(D, vi(26));
    REP(i, D) {
        REP(j, 26) {
            cin >> s[i][j];
        }
    }

    int count = 0;
    REP(i, D) {
        set<int> set26;
        REP(j, 26) {
            set26.insert(j + 1);
        }
        while (!set26.empty()) {
            int a = rand() % 26 + 1;
            if (set26.count(a)) {
                cout << a << "\n";
                set26.erase(a);
                debug(a);
                count++;
                if (count >= D) {
                    return;
                }
            }
        }
    }
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


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

#define mp     make_pair
#define pb     push_back
#define all(v) v.begin(),v.end()

#define endl    "\n"
#define peek(x) cout<<#x<<" = "<<x<<"\n";
#define FAST    ios_base::sync_with_stdio(0);cin.tie(0);

typedef long long     ll;
typedef long double   ld;
typedef pair<int,int> ii;

const int    inf = 2e9;
const ll     INF = 4e17;
const int    mod = 1e9+7;
const double eps = 1e-9;

void solveA() {
	string s;
	cin >> s;
	int ans = 0, streak = 0;
	char prev;
	for(int i = 0; i < 4; i++) {
		if(i == 0) {prev = s[i]; continue;}
		if(prev == s[i]) streak++;
		ans = max(ans, streak);
		if(prev != s[i]) streak = 0, prev = s[i];
	}
	if(ans >= 2) cout << "Yes\n";
	else cout << "No\n";
}

void solveB() {
	int N;
	cin >> N;
	ll a = 2, b = 1;
	if(N == 0) {puts("2");return;}
	if(N == 1) {puts("1");return;}
	for(int i = 2; i <= N; i++) {
		ll tmp = a+b;
		a = b;
		b = tmp;
	}
	cout << b << endl;
}

int arr[4];
string res;
void f(int pos, int sum, string s) {
	if(pos >= 3) {
		if(sum == 7) res = s;
		return;
	}
	f(pos+1, sum+arr[pos+1], s+"+");
	f(pos+1, sum-arr[pos+1], s+"-");
}

void solveC() {
	string s;
	cin >> s;
	for(int i = 0; i < 4; i++) arr[i] = s[i]-'0';
	f(0,arr[0],"");
	res += "=";
	if(res.size() == 4) for(int i = 0; i < 4; i++) cout << arr[i] << res[i];
	else{
		for(int i = 0; i < 4; i++) cout << res[i] << arr[i];
		cout << "=";
	}
	cout << "7";

}
int n, m, c[10][10], dp[10], mat[210][210];
int opt(int x) {
	if(x == 1) return 0;
	if(dp[x] != -1) return dp[x];
	int ret = inf;
	for(int i = 0; i <= 9; i++) {
		if(i == x) continue;
		ret = min(ret, c[x][i] + opt(i));
	}
	return dp[x] = ret;
}

void solveD() {
	cin >> n >> m;
	for(int i = 0; i <= 9; i++) 
		for(int j = 0; j <= 9; j++) 
			cin >> c[i][j];
	memset(dp,-1,sizeof dp);
	for(int i = 0; i <= 9; i++) opt(i);
	for(int i = 0; i <= 9; i++) cout << dp[i] << " ";
	long long ans = 0;
	for(int i = 0; i < n; i++) { 
		for(int j = 0; j < m; j++) {
			cin >> mat[i][j];
			if(mat[i][j] == -1) continue;
			ans += dp[mat[i][j]];
		}
	}
	cout << ans << endl;
}

int main() {
	FAST
	//solveA();
	//solveB();
	solveC();
	//solveD();
	return 0;
}



Measured memory_bytes: 256
import sys
from copy import deepcopy
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**6)
# ----------------------------------------------------------- #

n, k = (int(x) for x in input().split())
A = list(int(x) for x in input().split())
k = min(k, 50)
for _ in range(k):
    B = [0] * n
    for i in range(n):
        l = max(0, i-A[i])
        r = min(n-1, i+A[i])
        B[l] += 1
        if r+1 < n:
            B[r+1] -= 1
    for i in range(1, n):
        B[i] += B[i-1]
    A = deepcopy(B)

print(" ".join(str(b) for b in B))


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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

struct p{
	double x, y;
};
p xy[10];

double calc(double a, double b){

		return (a-b)*(a-b);
}


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

	int n;cin>>n;

	vector<int> d(n);


	for(int i=0; i<n; i++){
		d[i] = i+1;
		double a,b;cin>>a>>b;

		xy[i+1].x=a; xy[i+1].y=b;
	}

	double ans =0.0;
	int ct=0;
	do{
		int from =d[0];
		ct++;
		for(int i=1; i<n; i++){
			/*cout<<from<<" "<<d[i]<<endl;*/
			ans +=sqrt(calc(xy[from].x,xy[d[i]].x)+calc(xy[from].y,xy[d[i]].y));
			/*writeln(sqrt(calc(xy[from].x,xy[d[i]].x)+calc(xy[from].y,xy[d[i]].y)));*/
			from =d[i];
		}

	}while(next_permutation(d.begin(),d.end()));



	printf("%0.10f",ans/ct);



}




Measured memory_bytes: 256
def judge(L):
    for l in L:
        if l % 2:
            return False

    return True

def solve():
  N = int(input())
  A = list(map(int, input().split(" ")))

  cnt = 0
  while judge(A):
      for i in range(N):
          A[i] = A[i] // 2
      cnt += 1

  print(cnt)


solve()

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int N, W, w[110], v[110];

    cin >> N >> W;
    REP(i, N)
    cin >> w[i + 1] >> v[i + 1];

    ll dp[110][100010];

    for (int i = 1; i <= N; i++)
    {
        for (int j = 0; j <= 100000; j++)
        {
            dp[i][j] = INF;
        }
    }

    dp[1][0] = 0;
    dp[1][v[1]] = w[1];

    for (int i = 1; i < N; i++)
    {
        for (int j = 0; j <= 100000; j++)
        {
            dp[i + 1][j + v[i + 1]] = min(dp[i + 1][j + v[i + 1]], dp[i][j] + w[i + 1]);
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        }
    }

    ll res = 0;

    for (int i = 1; i <= 100000; i++)
    {
        if (dp[N][i] <= W)
            res = i;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 80384
def actual(s):
    N = len(s)
    count_operation = 0

    for i in range(N):
        head = s[i]
        tail = s[N - 1 - i]

        if head != tail:
            count_operation += 1

    return int(count_operation / 2)

s = input()
print(actual(s))


Measured memory_bytes: 2940
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################

n = int(input())
arr = list(map(int , input().split()))
ans = 0
for i in range(1,n+1):
	if arr[i-1]&1 and i&1:
		ans+=1
print(ans)









Measured memory_bytes: 67420
N,M = map(int,input().split())

from heapq import heappush, heappop
INF = float("inf")
miti = [-1]*N
def dijkstra(N, G, s):
    dist = [INF] * N
    que = [(0, s)]
    dist[s] = 0
    while que:
        c, v = heappop(que)
        if dist[v] < c:
            continue
        for t, cost in G[v]:
            if dist[v] + cost < dist[t]:
                dist[t] = dist[v] + cost
                if miti[t] == -1:
                    miti[t] = v+1
                heappush(que, (dist[t], t))
    return dist

edge = [[] for _ in range(N)]

for _ in range(M):
    a,b = map(int,input().split())
    edge[a-1].append((b-1,1))
    edge[b-1].append((a-1,1))

dist = dijkstra(N,edge,0)

print("Yes")
for t in miti[1:]:
    print(t)

Measured memory_bytes: 64232
#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 tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

int MinimumNumIncreasingSubsequences(int arr[], int n) 
{ 
    multiset<int> last; 
  
    // last element in each  increasing subsequence  
    // found so far 
    for (int i = 0; i < n; i++) { 
  
        // here our current element is arr[i] 
        multiset<int>::iterator it = last.lower_bound(arr[i]); 
  
        // iterator to the first element larger  
        // than or equal to arr[i] 
        if (it == last.begin()) 
  
            // if all the elements in last larger 
            // than or to arr[i] then insert it into last 
            last.insert(arr[i]); 
  
        else { 
            it--; 
  
            // the largest element smaller than arr[i] is the number 
            // before *it which is it-- 
            last.erase(it); // erase the largest element smaller than arr[i] 
            last.insert(arr[i]); // and replace it with arr[i] 
        } 
    } 
    return last.size(); // our answer is the size of last 
} 


int32_t main()
{
    fast;
    int n;cin>>n;
    int *arr=new int[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];

    cout<<MinimumNumIncreasingSubsequences(arr,n);

}

Measured memory_bytes: 5760