akhauriyash/Code-Regression huggingface dataset:
num = gets.to_i
array_a = gets.split(" ").map(&:to_i)
array_b = gets.split(" ").map(&:to_i)
array_c = gets.split(" ").map(&:to_i)
result = 0

array_b.each do |b|
  result += b
end

(0...array_a.length).each do |i|
  if (array_a[i] + 1) == array_a[i + 1]
    result += array_c[array_a[i] - 1]
  end
end

puts result

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
void file(){
    #ifdef LOCAL
    freopen("demo.in","r",stdin);
    freopen("demo.out","w",stdout);
    #endif
}
int main(){
    fastio;
    file();
    int t;
    cin>>t;
    vv v(t*2);
    for(int i=0;i<2*t;++i){
      cin>>v[i];
    }
    sortv(v);
    int sum=0;
    for(int i=0;i<2*t-1;i=i+2){
      sum+=min(v[i],v[i+1]);
    }
    test(sum);
}
// 5
// 100 1 2 3 14 15 58 58 58 29

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

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

	queue<long long> que;
	for( int x = 1; x < 10; x++ ) que.push( x );
	long long ans;
	for( int i = 0; i < K; i++ ) {
		ans = que.front();
		que.pop();
		int t = ans % 10;
		if( t ) que.push( ans * 10 + t - 1 );
		que.push( ans * 10 + t );
		if( t != 9 ) que.push( ans * 10 + t + 1 );
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
<?php
//$t = trim(fgets(STDIN));
//fscanf(STDIN, "%d", $a);
//echo $a * $a * $a;

while(true) {
    fscanf(STDIN, "%d", $w);
    if(feof(STDIN))
        break;
    $b = 100000;
    for ($i=0;$i<$w;$i++) {
        $b = $b * 1.05;
        $c = 1000 * ceil($b/1000);
        $b = $c;
    }
    printf("%d", $b);
    echo PHP_EOL;
}

Measured memory_bytes: 15152
#include<stdio.h>
#define N 100

void bubble_sort(int a[],int n){
  int i;
  int hoge;
  int rs;

  for(;rs;){
    rs=0;
    for(i=0;i<n-1;i++){
      if(a[i]>a[i+1]){
        rs=1;
        hoge=a[i];
        a[i]=a[i+1];
        a[i+1]=hoge;
      }
    }
  }
}

int main(void){
  int i,j;
  int n,m;
  int t[N],h[N];
  int sumT,sumH;
  int exchsum;
  int ansi,ansj;

  for(;;){
    scanf("%d%d",&n,&m);
    if(n==0 && m==0)
      break;

    for(i=0;i<n;i++)
      scanf("%d",&t[i]);
    for(i=0;i<m;i++)
      scanf("%d",&h[i]);

    bubble_sort(t,n);
    bubble_sort(h,m);

    sumT=0;
    for(i=0;i<n;i++){
      sumT+=t[i];
    }
    sumH=0;
    for(i=0;i<m;i++){
      sumH+=h[i];
    }

    exchsum=210;
    ansi=200;
    ansj=200;
    for(i=0;i<n;i++)
      for(j=0;j<m;j++)
        if(sumT-t[i]+h[j]==sumH-h[j]+t[i]){
          if(exchsum>t[i]+h[j]){
            exchsum=t[i]+h[j];
            ansi=i;
            ansj=j;
          }
        }

    if(ansi==200 || ansj==200)
      printf("-1\n");
    else
      printf("%d %d\n",t[ansi],h[ansj]);
  }

  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int main(void){
    int x, y, i;
    0 <= x,y <= 10000;
    for(i = 1; i <= 3000; i++){
        scanf("%d %d",&x, &y);
       if(x == 0){
           if(y == 0){
           break;
           }
       }
       if(x <= y)
           printf("%d %d\n",x, y);
           else if(x > y)
           printf("%d %d\n",y, x);
    }
   return 0;
}



Measured memory_bytes: 2028
import sys

def main():
    input = sys.stdin.readline
    H, W = map(int, input().split())
    C = [input().strip() for _ in range(H)]

    D = []
    for i in range(2 * H):
        D.append(C[i//2])

    return '\n'.join(D)


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


Measured memory_bytes: 3060
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  long long N;
  cin >> N;
  long long ok = N, ng = 0;
  while (abs(ok - ng) > 1) {
    long long X = (ok + ng) / 2;
    if ((X - 1) * X / 2 >= N - X)
      ok = X;
    else
      ng = X;
  }
  while (N) {
    cout << ok << '\n';
    N -= ok;
    ok = min(N, ok - 1);
  }
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
//#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  string s, t;
  cin >> s >> t;
  rep(i, 0, s.length()) {
    string ss = "";
    rep(j, 0, s.length()) {
      ss += s[(i + j) % s.length()];
    }
    if(ss == t) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<pii,int> ppiii ;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
int main(){
	int n;
	cin>>n;
	ll x=1,y=1,a,b,now=0;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		ll t=((x-(ll)1)/a+(ll)1),s=((y-(ll)1)/b+(ll)1);
		int c=0;
		if(x<=a*s&&y<=b*s)x=a*s,y=b*s,c=1;
		if(x<=a*t&&y<=b*t){
			if(c==1)x=min(x,a*t),y=min(y,b*t);
			else x=a*t,y=b*t;
		}
		//cout<<x<<" "<<y<<endl;
	}
	cout<<x+y<<endl;
}

Measured memory_bytes: 256
//Leonidas
#pragma GCC optimize("Ofast")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container'.',hpp>
//#include <ext/pb_ds/tree_policy'.',hpp>
//typedef tree < int , null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> TREE;
#define ll long long
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define pld pair<long double,long double >
#define ld long double
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
#define pll pair<ll,ll>
#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define M_PI 3.14159265358979323846
//#define int long long
const int mod=1e9+7;
//const int mod=1009;
//const int mod=998244353;
const int inf=1000000009;
const long long INF=1000000000000000009;
const long long big=1000000000000000;
const long double eps=0.000000000000000000001;
using namespace std;
ll S[200005][2];
vi W[200005][2];
void czysc(int n)
{
    for(int i=0; i<=n+1; i++)
        for(int j=0; j<=1; j++)
        {
            S[i][j]=0;
            W[i][j].clear();
        }
}
int32_t main()
{
    speed
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        ll suma=0;
        for(int i=1; i<=n; i++)
        {
            int k,a,b;
            cin>>k>>a>>b;
            suma+=min(a,b);
            if(a>=b)
                W[k][0].pb(a-b);
            else
                W[k+1][1].pb(b-a);
        }
        priority_queue<int> Q,K;
        for(int i=n; i>=1; i--)
        {
            for(auto v:W[i][0])
            {
                Q.push(v);
            }
            if(!Q.empty())
            {
                K.push(Q.top());
                Q.pop();
            }
        }
        ll pom=0;
        for(int i=1; i<=n; i++)
        {
            if(!K.empty())
            {
                pom+=K.top();
                K.pop();
            }
            S[i][0]=pom;
        }
        while(!Q.empty())
            Q.pop();
        while(!K.empty())
            K.pop();
        for(int i=1; i<=n; i++)
        {
            for(auto v:W[i][1])
            {
                Q.push(v);
            }
            if(!Q.empty())
            {
                K.push(Q.top());
                Q.pop();
            }
        }
        pom=0;
        for(int i=n; i>=1; i--)
        {
            if(!K.empty())
            {
                pom+=K.top();
                K.pop();
            }
            S[i][1]=pom;
        }
        ll wynik=0;
        for(int i=0; i<=n; i++)
            wynik=max(wynik,S[i][0]+S[i+1][1]);
        czysc(n);
        cout<<wynik+suma<<"\n";
    }
    return 0;
}


Measured memory_bytes: 20896
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;

struct LCA{
    int n, bit; // n < 1<<bit
    vector<int> depth;
    vector<vector<int>> par, v;

    LCA(int n) : n(n){
        depth.resize(n, -1);
        bit = 0;
        while(1<<bit <= n)  bit++;
        par.resize(bit);
        for(int i = 0; i < bit; i++)    par[i].resize(n);
        v.resize(n);
    }

    void add_edge(int a, int b){
        v[a].push_back(b);
        v[b].push_back(a);
    }

    void dfs(int now, int p, int d){
        par[0][now] = p;
        depth[now] = d;
        for(int child : v[now]){
            if(child == p)  continue;
            dfs(child, now, d+1);
        }
    }

    void build(){
        for(int i = 0; i < n; i++){
            if(depth[i] == -1)    dfs(i, -1, 0);
        }
        for(int k = 0; k+1 < bit; k++){
            for(int i = 0; i < n; i++){
                if(par[k][i] < 0)   par[k+1][i] = -1;
                else                par[k+1][i] = par[k][par[k][i]];
            }
        }
    }

    int lca(int a, int b){
        // make b deeper
        if(depth[a] > depth[b]) swap(a, b);
        for(int k = 0; k < 30; k++){
            // depth(b)-depth(a) is equal to or bigger than 2^k
            if(((depth[b]-depth[a])>>k)&1){
                b = par[k][b];
            }
        }
        if(a == b)  return a;
        for(int k = bit-1; k >= 0; k--){
            if(par[k][a] != par[k][b]){
                a = par[k][a];
                b = par[k][b];
            }
        }
        return par[0][a];
    }
};

int main(){
    int n;
    scanf("%d", &n);
    LCA l(n);
    for(int i = 0; i < n; i++){
        int k;
        scanf("%d", &k);
        while(k--){
            int x;  scanf("%d", &x);
            l.add_edge(i, x);
        }
    }
    l.build();
    int q;
    scanf("%d", &q);
    while(q--){
        int u, v;
        scanf("%d %d", &u, &v);
        printf("%d\n", l.lca(u,v));
    }
    return 0;
}


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

int main(void)
{
  int n, d = 0, ans[30];
  scanf("%d", &n);
  if(n == 0){
    printf("%d\n", 0);
    return 0;
  }
  while(n != 0){
    int r = abs(n)%2;
    ans[d++] = r;
    if(r == 1 && n < 0)
      n--;
    n /= -2;
  }
  for(int i = 0; i < d; i++)
    printf("%d", ans[d-1-i]);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;
const int mod = 1000000007;


int main(){
    int H, W, K; cin >> H >> W >> K;
    vector<vector<int>> m(H, vector<int>(W));

    rep(i, H){
        rep(j, W){
            char c; cin >> c;
            if(c == '.') m[i][j] = 0;
            else m[i][j] = 1;
        }
    }
    int ans = 0;
    for(int i = 0; i < (1 << H);i++){
        for(int j = 0; j < (1 << W); j++){
            auto cp = m;
            bitset<6> si(i);
            bitset<6> sj(j);
            rep(n, H){
                if(si.test(n)){
                    rep(k, W) cp[n][k] = 2;
                }
            }
            rep(n, W){
                if(sj.test(n)){
                    rep(k, H) cp[k][n] = 2;
                }
            }
            int tmp = 0;
            rep(i, H)rep(j, W) if(cp[i][j] == 1)tmp++;
            if(tmp == K) ans++;
            
        }
    }
    cout << ans << endl;

}



Measured memory_bytes: 3612
n = int(input())
xys = []
for i in range(n):
    a = int(input())
    xys.append([list(map(int, input().split())) for _ in range(a)])
ret = 0
for b in range(1 << n):
    ok = True
    c = 0
    for i in range(n):
        if (b >> i) & 1 != 0:
            c += 1
            for x, y in xys[i]:
                if y != (b >> (x - 1)) & 1:
                    ok = False
    if ok:
        ret = max(ret, c)
print(ret)


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

namespace ABC043A
{
    class Program
    {
        static void Main(string[] args)
        {
            int N,X;
            X = 0;
            N=int.Parse(Console.ReadLine());
            for (int i = 0; i <= N; i++)
            { X = X + i; }
            Console.WriteLine(X);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();

		int[] A = nextIntArray1origin(sc, N);
		int[] B = nextIntArray1origin(sc, N);
		int[] C = nextIntArray1origin(sc, N - 1);

		sc.close();

		int prev = -100;

		int ans = 0;
		for (int i = 1; i <= N; i++) {
			int d = A[i];
			ans += B[d];

			if (d == prev + 1) {
				ans += C[prev];
			}
			prev = d;
		}

		out.println(ans);

	}

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

	@SuppressWarnings("unused")
	private int[] nextIntArray1origin(Scanner sc, int n) {
		int[] result = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 23252
#include<stdio.h>
#define max(a,b) ((a>b) ? (a):(b))
int dp[201][201];
int main(void){
    int d,n;
    int T[201],C[201];
    int suit[201][201];
    int i,j,k,A[201],B[201];
    int ans;

    scanf("%d%d",&d,&n);
    for(i=1;i<=d;i++){
	scanf("%d",&T[i]);
    }

    for(i=1;i<=n;i++){
	scanf("%d%d%d",&A[i],&B[i],&C[i]);
    }

    for(i=1;i<=d;i++){
	for(j=1;j<=n;j++){
	    if(A[j]<=T[i] && T[i]<=B[j]) suit[i][j]=1;
	}
    }

/*
    for(j=1;j<=n;j++){
	if(suit[1][j]) dp[1][j]=0;
	else dp[1][j]=-1;
    }
*/

    for(i=2;i<=d;i++) for(j=1;j<=n;j++){
	if(suit[i][j]){
	    for(k=1;k<=n;k++){
		if(suit[i-1][k]){
		    dp[i][j]=max(dp[i][j],dp[i-1][k]+abs(C[k]-C[j]));
		}
	    }
 	}
    }

/*
    for(i=1;i<=d;i++){
	for(j=1;j<=n;j++){
	    printf("%d ",dp[i][j]);
	}
	printf("\n");
    }
*/

    ans=0;
    for(j=1;j<=n;j++){
	if(dp[d][j]>ans) ans=dp[d][j];
    }
    printf("%d\n",ans);
   
    return 0;
}   

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

struct Team
{
    int id, be, so, pe;
    bool selected;
};

void swap( Team& a, Team& b )
{
    Team t = a;
    a = b;
    b = t;
}

void bubbleSort( Team* t, int n, int judge )
{
    for( int i = 0; i < n; i++ )
        for( int j = n - 1; j >= i + 1; j-- )
        {
            if( judge == 0 && t[j].so > t[j-1].so )
                swap( t[j], t[j-1] );
            if( judge == 1 && t[j].so == t[j-1].so && t[j].pe < t[j-1].pe )
                swap( t[j], t[j-1] );
            if( judge == 2 && t[j].so == t[j-1].so && t[j].pe == t[j-1].pe && t[j].id < t[j-1].id )
                swap( t[j], t[j-1] );
        }
}

int main()
{
    int n, a[1001];

    while( cin >> n )
    {
        if( !n )
            break;
        
        for( int i = 0; i < 1001; i++ )
            a[i] = 0;

        Team* t = new Team[n];

        for( int i = 0; i < n; i++ )
        {
            t[i].selected = false;
            cin >> t[i].id >> t[i].be >> t[i].so >> t[i].pe;
        }

        bubbleSort( t, n, 0 );
        bubbleSort( t, n, 1 );
        bubbleSort( t, n, 2 );

        int cnt = 0;
        for( int i = 0; i < n; i++ )
        {
            if( cnt < 10 && a[t[i].be] < 3 )
            {
                t[i].selected = true;
                cnt++;
                a[t[i].be]++;
                continue;
            }
            if( cnt < 20 && a[t[i].be] < 2 )
            {
                t[i].selected = true;
                cnt++;
                a[t[i].be]++;
                continue;
            }
            if( cnt < 26 && a[t[i].be] == 0 )
            {
                t[i].selected = true;
                cnt++;
                a[t[i].be]++;
            }
        }

        for( int i = 0; i < n; i++ )
            if( t[i].selected )
                cout << t[i].id << endl;

        delete t;
    }

    return 0;
}


Measured memory_bytes: 3092
a, b, x = map(int,input().split())

import math
if x >= (a**2) * b / 2:
    rad = math.atan((2*(a**2)*b-(2*x))/(a**3))
    print(rad/math.pi*180)
else:
    rad = math.atan(( a*(b**2) ) / (2*x))
    print(rad/math.pi*180)

Measured memory_bytes: 3060
#include <stdio.h>

int gcd(int m, int n)
{
  if(m<n){
    int tmp = m;
    m = n;
    n = tmp;
  }

  while(1){
    if(n==0){
      return m;
    }

    int tmp = n;
    n = m%n;
    m = tmp;
  }
}

int lcm(int m, int n)
{
  return m/gcd(m,n)*n;
}

int main(void)
{
  int a,b;
  while(scanf("%d %d", &a, &b) != EOF){
    printf("%d %d\n", gcd(a,b), lcm(a,b));
  }

  return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
static const int MAX=200000;

int main() {
    int R[MAX],n;
    cin >> n;
    for(int i=0;i<n;i++) cin >> R[i];
    int maxv=-2000000000;
    int minv=R[0];
    for(int i=1;i<n;i++) {
        maxv=max(maxv,R[i]-minv);
        minv=min(minv,R[i]);
    }
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 3864
import fractions
A, B, C, D = map(int, input().split())
waric = 1 if A%C == 0 else 0
warid = 1 if A%D == 0 else 0
l = (C*D)//(fractions.gcd(C,D))
waricd = 1 if A%l == 0 else 0
cnd = B - A + 1 - (B//C - A//C + waric)
dnd = B - A + 1 - (B//D - A//D + warid) 
cdnd = B - A + 1 - (B//l - A//l + waricd)
print(cnd + dnd - cdnd)

Measured memory_bytes: 5048
package main

import (
	"fmt"
	"os"
)

func ReadInt(f *os.File) int {
	var n int
	fmt.Fscanf(f, "%d", &n)
	return n
}

func ReadInts(f *os.File, n int) []int {
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(f, "%d", &nums[i])
	}
	return nums
}

func main() {
	N := ReadInt(os.Stdin)
	M := ReadInt(os.Stdin)

	likes := make([]int, M)

	for i := 0; i < N; i++ {
		k := ReadInt(os.Stdin)
		for _, j := range ReadInts(os.Stdin, k) {
			likes[j-1]++
		}
	}

	c := 0
	for _, v := range likes {
		if v == N {
			c++
		}
	}
	fmt.Println(c)
}

Measured memory_bytes: 512
n = int(input())
  
for i in range(n):
    x1,y1,x2,y2,x3,y3,x4,y4 = [ float(s) for s in input().split() ]
    diff = (x2-x1)*(y4-y3) - (x4-x3)*(y2-y1)
    if diff < 1e-10 and diff > -1*(1e-10):
        print('YES')
    else:
        print('NO')


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

int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  for (int i = 0; i < N; i++)
    cin >> V.at(i);
  
  int count = 0;
  for (int j = 1; j < N - 1; j++) {
    if ((V.at(j - 1) < V.at(j) && V.at(j) < V.at(j + 1)) 
        || (V.at(j + 1) < V.at(j) && V.at(j) < V.at(j - 1)))
      count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <functional>
#include <cstdint>
using namespace std;


int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string ans="No";
  int n;
  cin >> n;
  
  for(int i = 1; i < 10; i++) {
    for(int j = 1; j < 10; j++){
      if(i*j==n) ans = "Yes";
      //break;
    }
  }
  cout << ans << endl;

}
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pb(x) push_back(x)
#define vvi vector<vector<int>>
#define vec vector<int>
#define un unsigned
#define dbl double
#define wking(t) cout<<"Working "<<t<<endl;
#define loop(i,s,n) for(auto i=s;i!=n;i++)
#define eps 0.000000001
using namespace std;

int f(int a[],int n,int k,int dp[])
{
    if(dp[n]!=-1) return dp[n];
    int min = INT_MAX;
    loop(i,1,k+1)
        if(n-i>0 && min>f(a,n-i,k,dp)+abs(a[n]-a[n-i])) min = f(a,n-i,k,dp)+abs(a[n]-a[n-i]);
    return dp[n]=min;
}

int calc(int a[],int n,int k)
{
    int dp[n+1];
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    dp[1]=0;
    dp[2] = abs(a[2]-a[1]);
    dp[n] = f(a,n,k,dp);
    // loop(i,0,n+1) cout<<dp[i]<<" ";
    // cout<<endl;
    return dp[n];
}

int main()
{
    int n,k;
    cin>>n>>k;
    int a[n+1];
    a[0]=0;
    loop(i,1,n+1) cin>>a[i];
    cout<<calc(a,n,k)<<endl;
    return 0;
}


Measured memory_bytes: 10368
n = int(input())

l = []

for i in range(1, n+1):
    s, p = input().split()
    l.append([s, int(p), i])

l = sorted(l, key=lambda x: x[1],reverse=True)
l = sorted(l, key=lambda x: x[0])       

for j in l:
    print(j[2])

Measured memory_bytes: 38384
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

ll n, m, x, y;
vector<ll> edge[110000];
ll dp1[110000];
ll dp2[110000];

void dfs1(ll x, ll last = -1){
    ll prod= 1;
    for(auto to:edge[x]){
        if(to == last)continue;
        dfs1(to, x);
        prod = prod * dp1[to] % m;
    }
    dp1[x] = prod + 1;
}

void dfs2(ll x, ll last = -1){
    if(last == -1)dp2[x] = 1;
    vector<ll> lprod= vector<ll>(edge[x].size(), 1);
    vector<ll> rprod= vector<ll>(edge[x].size(), 1);
    for(ll i = 0;i < edge[x].size();i++){
        ll to = edge[x][i];
        if(i-1 >= 0)lprod[i] = lprod[i-1];
        if(to == last)continue;
        lprod[i] *= dp1[to];lprod[i] %= m;
    }
    for(ll i = (ll)edge[x].size() - 1;i >= 0;i--){
        ll to = edge[x][i];
        if(i+1 < rprod.size())rprod[i] = rprod[i+1];
        if(to == last)continue;
        rprod[i] *= dp1[to];rprod[i] %= m;
    }
    for(ll i = 0;i < edge[x].size();i++){
        ll to = edge[x][i];
        if(to == last)continue;
        ll rest_prod = 1;
        if(i-1 >= 0)rest_prod = rest_prod * lprod[i-1] % m;
        if(i+1 < rprod.size())rest_prod = rest_prod * rprod[i+1] % m;
        dp2[to] = (dp2[x] * rest_prod + 1) % m;
        dfs2(to, x);
    }
}

ll ans[110000];

void dfs3(ll x, ll last = -1){
    ans[x] = dp2[x];
    for(auto to:edge[x]){
        if(to == last)continue;
        ans[x] *= dp1[to];
        ans[x] %= m;
        dfs3(to, x);
    }
}

int main(){
    cin >> n >> m;
    for(ll i = 0;i < n-1;i++){
        cin >> x >> y;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }

    dfs1(1);
    dfs2(1);
    dfs3(1);

    for(ll i = 1;i <= n;i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 19712
n, c, k = [int(i) for i in input().split()]
# 合計n人,バス容量c人,到着後k以内に乗る
t = [0 for _ in range(n)]
first = 0  # バス待ちの先頭人の到着時刻
num = 0  # バス待ちの人の数
bass = 0
for i in range(n):
    # 乗客iが到着する時刻
    t[i] = int(input())
t = sorted(t)
for i in range(n):
    # 乗客iが到着する時刻
    if num == 0:
        first = t[i]
        num += 1
    elif first + k < t[i]:
        # print("timeup t:{}".format(t[i]))
        bass += 1
        first = t[i]
        num = 1
    elif num == c:
        # print("over people t:{}".format(t[i]))
        bass += 1
        first = t[i]
        num = 1
    else:
        num += 1
print(bass + 1)
# 必要なバスの台数を出力
# 単純に到着がc人になるか,
# 先頭の人が到着してからk秒たったらバスを出す


Measured memory_bytes: 8264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll a; cin >> a;
    ll sum = 0;
    sum = a+ pow(a,2) + pow(a,3);
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 4040
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    vector <int > h(n);
    REP(i,n) cin >> h[i];
    int cnt=0,preflower = 0 ;
    REP(i,n){
        if(h[i] > preflower){
            cnt +=h[i]-preflower;
        }
        preflower = h[i];
    }
    cout << cnt << endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  string S; cin >> S;
  int N = S.size();
  vector<int> mod(2019, 0);
  int d = 1;
  int m = 0;
  for(int i = 0; i < N; i++) {
    m += (S.at(N - 1 - i) - '0') * d;
    m %= 2019;
    //cout << m << endl;
    d *= 10; d %= 2019;
    mod.at(m)++;
  }
  mod.at(0)++;
  long long count = 0;
  for(int i = 0; i < 2019; i++) {
    count += (mod.at(i) * (mod.at(i) - 1) / 2);
  }
  cout << count << endl;
}

Measured memory_bytes: 3736
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
	static void Main() => new Program().Solve();

	void Solve()
	{
		var s = Console.ReadLine();

		Console.WriteLine(s.Replace('?', 'D'));
	}

	/// <summary>最大公約数</summary>
	long gcd(long a, long b) => (a == 0) ? b : gcd(b % a, a);

	#region Console.Read 関係
	long[] ReadLongArray() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
	long ReadLong() => long.Parse(Console.ReadLine());
	#endregion
}


Measured memory_bytes: 27060
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  int N, K; cin >> N >> K;
  ll X[N], Y[N];
  for (int i = 0; i < N; i++) cin >> X[i] >> Y[i];

  ll ans = 4e18;
  for (int i1 = 0; i1 < N; i1++){
    for (int i2 = 0; i2 < N; i2++){
      for (int i3 = 0; i3 < N; i3++){
        for (int i4 = 0; i4 < N; i4++){
          ll x1 = min(min(X[i1], X[i2]), min(X[i3], X[i4]));
          ll x2 = max(max(X[i1], X[i2]), max(X[i3], X[i4]));
          ll y1 = min(min(Y[i1], Y[i2]), min(Y[i3], Y[i4]));
          ll y2 = max(max(Y[i1], Y[i2]), max(Y[i3], Y[i4]));
          int cnt = 0;
          for (int i = 0; i < N; i++){
            if (x1 <= X[i] && X[i] <= x2 && y1 <= Y[i] && Y[i] <= y2) cnt++;
          }
          if (cnt >= K){
            ans = min(ans, (x2 - x1) * (y2 - y1));
          }
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[1005][1005];
int d[1005][1005];
int x[1000005],y[1000005];
int h,w;
int dx[4]={0,0,-1,1};
int dy[4]={1,-1,0,0};
int main(){
	scanf("%d%d",&h,&w);
	getchar();
	int t=0;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			scanf("%c",&s[i][j]);
			if(s[i][j]=='.')
				d[i][j]=1e9;
			else{
				d[i][j]=0;
				x[t]=i;
				y[t++]=j;
			}
		}
		getchar();
	}
	int s=0,ans=0;
	while(s<t){
		int xx=x[s],yy=y[s++];
		for(int i=0;i<4;i++){
			int u=xx+dx[i];
			int v=yy+dy[i];
			if(u<1||u>h||v<1||v>w||d[u][v]<=d[xx][yy]+1)
				continue;
			d[u][v]=d[xx][yy]+1;
			ans=max(ans,d[u][v]);
			x[t]=u;
			y[t++]=v;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 16524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n , x) for (int i = (int)(x); i < (int)(n); ++i)
#define repB(i, n) for (int i = n; i >= 1; --i)
#define repBX(i, n , x) for (int i = (int)(n); i >= int(X); --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    string S;
    cin >> S;
    string ans = "";
    rep(i,S.size()){
        ans = ans + "x";
    }
    cout << ans << endl;
    
    return 0;
}

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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

//#define int int64_t
//int a[N+2];

int32_t  main(){
	IOS;
  string s;cin>>s;
  string a,b;
  int n=s.size();
  
  for(int i=0;i<n;++i){
    if(i&1)a+='0';
    else a+='1';
  }
  for(int i=0;i<n;++i){
    if(i&1)b+='1';
    else b+='0';
  }
  int ans1=0,ans2=0;
  for(int i=0;i<n;++i){
    if(s[i]!=a[i])ans1++;
    if(s[i]!=b[i])ans2++;
  }
  cout<<min(ans1,ans2)<<endl;
  return 0;
}



Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    char str[1000],*p;
    cin.getline(str,10);
    for(int i=0;i<strlen(str);i++)
    {
        if(str[i]==' ')
        {
            for(int j=i;j<strlen(str);j++)
                str[j]=str[j+1];
            break;
        }
    }
    p=&str[0];
    int a=atoi(p);
    int b=sqrt(a);
    if(a==b*b)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
/*

                                  In the name of Allah, Most Gracious, Most Merciful


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

//*** constant value ***
const long double PI = 3.141592653589793238;
const double EPS = 1e-6 ;
//*** constant value ***

//****** define ********
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define dd double
#define vll vector<ll>
#define vs vector<string>
#define fn(i,n) for(ll i = 0; i<n; i++)
#define f(i,a,b) for(i=a;i<b;i++)
#define f1(i,a,b) for(i=b-1;i>=a;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define vpl vector<pll>
#define pb push_back
#define mk make_pair
#define x first
#define y second
#define tt cout<<"Came here"<<endl;
//****** define ********


int main()
{
    IOS;
    ll n,i;
    cin>>n;
    ll rem = 0;
    ll ans = -1;
    f(i,0,n+1)
    {
         rem = (rem*10) + 7;
         rem %= n;
         if(rem==0) {
             ans = i + 1;
             break;
         }
    }

    cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main()
{
    int n,m,anum=0,wnum=0;
    cin>>n>>m;
    int wa[n+1];
    bool ac[n+1];
    for(int i=0;i<=n;i++)
      {
          ac[i]=false;
          wa[i]=0;
      }
    
    while(m--)
     {
         int p;string s;
         cin>>p>>s;
         if(s=="WA"&& ac[p]==false)
               ++wa[p];
          if(s=="AC"&& ac[p]==false)
             ac[p]=true;
          if (ac[p])
             continue;
     }
     
     for(int j=1;j<=n;j++)
       {
             if(ac[j])
               {
                   wnum+=wa[j];
                   anum++;
               }
       }
    
    cout<<anum<<" "<<wnum;
    return 0;
}

Measured memory_bytes: 768
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> cell(h);
	REP(i, h)
		cin >> cell[i];
	int gx, gy;
	int sx, sy, dir;
	REP(i, h) {
		REP(j, w) {
			if (cell[i][j] == 'G') {
				gy = i;
				gx = j;
			}
			if (cell[i][j] != 'G'&&cell[i][j] != '#'&&cell[i][j] != '.') {
				sy = i;
				sx = j;
				if (cell[i][j] == '<')
					dir = 0;
				if (cell[i][j] == 'v')
					dir = 1;
				if (cell[i][j] == '>')
					dir = 2;
				if (cell[i][j] == '^')
					dir = 3;
			}

		}
	}
	set<pii> visited;
	set<pair<pii, int>> G;
	bool clear = true;
	while (1) {
		visited.insert(pii(sy,sx));
		if (sx == gx&&sy == gy) {
			break;
		}
		if (G.find(pair<pii, int>(pii(sy, sx), dir)) != G.end()) {
			clear = false;
			break;
		}
		G.insert(pair<pii, int>(pii(sy, sx), dir));
		if (0 <= sx + dx[(dir + 3) % 4] && sx + dx[(dir + 3) % 4] < w && 0 <= sy + dy[(dir + 3) % 4] && sy + dy[(dir + 3) % 4] < h&&cell[sy + dy[(dir + 3) % 4]][sx + dx[(dir + 3) % 4]] != '#') {
			sx += dx[(dir + 3) % 4];
			sy += dy[(dir + 3) % 4];
			dir = (dir + 3) % 4;
			continue;
		}
		if (0 <= sx + dx[dir] && sx + dx[dir] < w && 0 <= sy + dy[dir] && sy + dy[dir] < h&&cell[sy + dy[dir]][sx + dx[dir]] != '#') {
			sx += dx[dir];
			sy += dy[dir];
			continue;
		}
		dir++;
		dir %= 4;
	}
	if (clear)
		cout << visited.size() << endl;
	else
		cout << -1 << endl;
}

Measured memory_bytes: 3380
n=int(input())
a=list(int(x) for x in input().split())

count=0
z=True
j=0

if  1 not in a:
    print(-1)
else:
    for k in range(j,n):
        if a[k]==count+1:
            j=k
            count=count+1

    print(n-count)

Measured memory_bytes: 32076
#include <iostream>
#include <vector>
#include<algorithm>
#include <string>
#include <cmath>
#include<queue>
#define PI 3.141592653589793238
using namespace std;

int main()
{
	string str;
	int len;
	int ans = 0;

	cin >> str;
	len = str.length();

	for (int i = 0; i < len / 2; i++) {
		if (str[i] != str[len - i - 1]) {
			ans++;
		}
	}

	cout << ans;

	return 0;
}

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

using namespace std;

#define int ll
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pi> vp;
typedef vector<pl> vpl;

signed main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr); 
    cerr.tie(nullptr);    

    int n;
    cin >> n;

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

    double dp[n + 1][n + 1]; //sansa da dobijes tacno j novcica iz prvih i
    for (int i = 0; i <= n; ++i)
        for (int j = 0; j <= n; ++j)
            dp[i][j] = 0;

    dp[0][0] = 1.0;
    for (int i = 1; i <= n; ++i){
        dp[i][0] = (1.0-a[i - 1]) * dp[i - 1][0]; 
    }
    for (int j = 1; j <= n; ++j){
        dp[0][j] = 0;
    }

    for (int i = 1; i <= n; ++i){
        for (int j = 1; j <= n; ++j){
            dp[i][j] = dp[i - 1][j] * (1.0 - a[i - 1]) + dp[i - 1][j - 1] * a[i - 1];
        }
    }

    double sol = 0;
    for (int j = n / 2 + 1; j <= n; ++j)
        sol += dp[n][j];

    cout << fixed << setprecision(12) << sol << '\n';
}

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

int main(){
    int n;
    cin >> n;
    int ans[n+1];
    fill(ans,ans+n+1,0);
    for(int i=0; i<n-1; i++){
        int a;
        cin >> a;
        ans[a]++;
    }
    for(int i=1; i<=n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 4364
#include <iostream>
using namespace std;
const long long maxn =1e6 + 10;
long long  need[maxn];
long long calc(long long h){
    if (h < maxn) return need[h];
    else return 2ll * calc(h / 2) + 1ll;
}
int main(){
    need[1] = 1;
    for (int i = 2;i < maxn;i++){
        need[i] = 2ll * need[i / 2] + 1ll;
    }
    long long h;
    cin >> h;
    cout << calc(h) << endl;

}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
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; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

string s, t;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> s;
    int l = 0, r = s.size()-1, ans = 0;
    while (r - l > 0) {
      if (s[l] == s[r]) {
        l++, r--;
      } else if (s[l] == 'x') {
        ans++;
        l++;
      } else if (s[r] == 'x') {
        ans++;
        r--;
      } else {
        cout << -1 << endl;
        return 0;
      }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 512
#include <stdio.h>
  int main() {
      int r, g, b, i; 
      
      scanf("%d %d %d",&r ,&g ,&b);
      i = (10*g+b) % 4;
      if(i == 0){
      printf("YES\n");
      }
      
      else{
      printf("NO\n");
      }
      return 0;
      }

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	int A, B;
	cin >> A >> B;
	if (A > 9) {
		cout << "-1" << endl;
		return 0;
	}
	if (B > 9) {
		cout << "-1" << endl;
		return 0;
	}
	int ans = A * B;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
// 2:50
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <tuple>
using namespace std;
using ll = long long;
#define for1(i,n) for (ll i=0;i<(n);(i)++)
#define for2(i,m,n) for (ll (i)=(m);(i)<(n);(i)++)
#define for3(i,m,n,d) for (ll (i)=(m);(i)<(n);(i)+=(d))
#define INF (1LL << 60)
#define STRING(str) #str
#define DEBUG 0
#if DEBUG
    #define dump(var) dump2(STRING(var), var)
#else
    #define dump(var)
#endif

template <typename T>
void dump2(const string& name, const T& value)
{
    cerr << name << ": " << value << endl;
}
void dump2(const string& name, const tuple<ll,ll,ll>& value)
{
    ll a,b,c;
    tie(a,b,c) = value;
    cerr << name << ": (" << a << ", " << b << ", " << c << ")" << endl;
}

template <typename T>
void print(const T& value)
{
    cout << value << endl;
}


void solve()
{
    char c;
    cin >> c;
    string s = "aeiou";
    for (auto c1 : s) {
        if (c == c1) {
            print("vowel");
            return;
        }
    }
    print("consonant");
}

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


Measured memory_bytes: 256
//
//  main.cpp
//  ALDS1_4_B
//
//  Created by ptyuan on 2018/10/23.
//  Copyright © 2018 YY. All rights reserved.
//

#include <iostream>
#include <cstdio>
static const int kNotFound = -1;

int binarySearch(int *array, int n, int key) {
    int low = 0;
    int hight = n - 1;
    
    
    while (low <= hight) {
        int middle = (low + hight) * 0.5;
        int middleValue = array[middle];
        if (middleValue == key) {
            return middle;
        } else if (key > middleValue) {
            low = middle + 1;
        } else {
            hight = middle - 1;
        }
    }
    
    return kNotFound;
}

int main(int argc, const char * argv[]) {
    int n = 0;
    int s[100010] = {0};
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", s + i);
    }
    
    int q = 0;
    int sum = 0;
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        int temp = 0;
        scanf("%d", &temp);
        if (kNotFound != binarySearch(s, n, temp)) {
            sum++;
        }
    }
    printf("%d\n", sum);
    return 0;
}



Measured memory_bytes: 3628
#include <iostream>
#include <sstream>
#include <algorithm>
#include <set>
#include <vector>

using namespace std;

int ceil(int a, int b)
{
    return (a + b - 1) / b;
}

int main()
{
    int n, k;
    cin >> n >> k;
    cout << ceil(n - 1, k - 1);
}

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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define ford(i, n) for (int i = int(n)-1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define de(x) cout<<#x<<" = "<<(x)<<endl
#define de2(x,y) cout<<#x<<" = "<<(x) <<' '<< #y<<" = "<<y<<endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
ll nxt(){ll x;cin>>x;return x;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int l;
	cin>>l;
	double x=l/3.0;
	cout<<fixed<<setprecision(6);
	cout<<x*x*x;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	char op;
	int c = 0;
	while(1)
	{
		scanf("%d %c %d",&a,&op,&b);
		if(op == '+'){
			c = a+b;
			printf("%d\n", c);
		}else if(op == '-'){
			c = a-b;
			printf("%d\n", c);
		}else if(op== '*'){
			c = a*b;
			printf("%d\n", c);
		}else if(op== '/'){
			c = a/b;
			printf("%d\n", c);
		}else{
			if(op=='?')
				break;
		}
		
	}
return(0);
}

Measured memory_bytes: 1028
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint

INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)


# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))

def divisor_list(n):
    ret = set()
    i = 1
    while i * i <= n:
        if n % i == 0:
            ret.add(i)
            ret.add(n // i)
        i += 1
    return ret


N = int(input())
tmp = [int(x) for x in input().split()]
A = [-999]
for a in tmp:
    A.append(a)

B = []

for i in range(N, 0, -1):
    # print(i)
    if A[i] == 1:
        B.append(str(i))
        DL = divisor_list(i)
        for j in DL:
            A[j] = (A[j] + 1) % 2

print(len(B))
print(" ".join(B))

pass


Measured memory_bytes: 77188
import itertools,math
def dist(x,y):
    return ((x[0]-y[0])**2 + (x[1]-y[1])**2)**(1/2)
n = int(input())
data = [list(map(int,input().split()))for i in range(n)]
ans = 0
for v in itertools.permutations(data):
    for i in range(1,n):
        ans += dist(v[i],v[i-1])

print(ans/math.factorial(n))

Measured memory_bytes: 40684
//
// Created by Huang,Zhiqiang on 2018/7/28.
//

#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int n;
    int ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int t;
        cin >> t;
        ans += t - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
s = input()
ns = []
ss = 0
for i in range(len(s) - 1):
    if s[i:i + 2] == 'LR':
        ns.append(s[ss:i + 1])
        ss = i + 1
ns.append(s[ss:])
ans = []
for nsi in ns:
    l = len(nsi)
    for j in range(l):
        if nsi[j:j + 2] == 'RL':
            r = j; break
    ansi = [0] * l
    ansi[r:r+2] = [l // 2] * 2
    if l % 2 == 1: ansi[r + r % 2] += 1
    ans += ansi
print(' '.join(map(str, ans)))

Measured memory_bytes: 13724