akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

//I read this page
//http://www004.upp.so-net.ne.jp/s_honma/number/binomialcoefficient3.html

int main(){

	ll N;

	scanf("%lld",&N);

	if(N%2 == 0){
		printf("1\n");
		return 0;
	}else{
		N++;

		ll ans = 1;

		while(N%2 == 0){
			N /= 2;
			ans *= 2;
		}
		printf("%lld\n",ans);
	}

	return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const ll inf = 1e18;

int main() {
   int n, k;
   cin >> n >> k;
   vector<int> a(n);
   rep(i,n) cin >> a[i];
   ll ans = inf;
   rep(i,1<<n) {
      ll t = 0;
      if (!(i & 1)) continue;
      if (__builtin_popcount(i) != k) continue;
      int high = a[0];
      for (int j = 1; j < n; j++) {
         if (i>>j & 1) {
            high = max(a[j],high+1);
            t += high-a[j];
         }
         else high = max(a[j],high);
      }
      ans = min(ans,t);
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
#include<numeric>
#include<set>
#include<map>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i,n) for(int i=0;i<n;i++)
char ca;
ll  c, d = 0, e,n, i, j, k, h, w,  o, p,ii;
queue<ll> q;
string s;
vector<pair<ll,ll>> m;
vector<ll> v;

int main() {
	cin >> n>>w;
	rep(i, n) {
		cin >>o;
		v.push_back(o);
	}
	rep(i, w) {
		cin >> o >> p;
		m.push_back(make_pair(-p, o));
	}
	
	sort(m.begin(), m.end());
	k = 0;
	i = 1;
	j = 0;
	while (i <= n) {
		o = -m[j].first;
		p = m[j].second;
		rep(ii, p) {
			v.push_back(o);
			i++;
			if (i > n)break;
		}
		j++;
		if (j >= m.size())break;
	}
	sort(v.begin(), v.end(), greater<ll>());

	rep(i, n)k += v[i];
	cout << k;
	return 0;
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    string s; cin >> s;

    string ans;

    for (int i = 0; i < s.size(); ++i) {
        if (i % 2 == 0) {
            ans += s[i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] Hs = new int[N+1];
		Hs[0] = Integer.MAX_VALUE;
		for (int i = 1; i <= N; ++i) Hs[i] = sc.nextInt();
		int[] dp = new int[N+1];
		Arrays.fill(dp, 0);
		dp[2] = Math.abs(Hs[2]-Hs[1]);
		if(N == 2) {

			System.out.println(Math.abs(Hs[2]-Hs[1]));

		}else {

			for (int i = 3; i <= N; ++i) {

				dp[i] = Math.min(dp[i-1] + Math.abs(Hs[i-1]-Hs[i]), dp[i-2] + Math.abs(Hs[i-2]-Hs[i]));
			}
			System.out.println(dp[N]);
		}
	}

}


Measured memory_bytes: 50520
#include <bits/stdc++.h>
using namespace std;
// 最後に塗り替えられるものたちはどうでもよい
// 上から順番に決めていってDP
int64_t MOD = 1e9 + 7;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N;
    cin >> N;
    vector<int> C;
    int last = 0;
    for(int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        if(last == tmp) {
            continue;
        }
        C.push_back(tmp);
        last = tmp;
    }
    N = C.size();
    vector<int64_t> ans(N + 1);
    ans[N] = 1;
    // 色, そのインデックス一覧
    map< int, int64_t > list;
    for(int i = N - 1; i >= 0; i--) {
        int cur = C[i];
        ans[i] = ans[i + 1];
        if(list.count(cur) == 0) {
            list[cur] = 0;
        } else {
            ans[i] += list[cur];
            ans[i] %= MOD;
        }
        list[cur] += ans[i + 1];
        list[cur] %= MOD;
    }
    cout << ans[0] << endl;
    return 0;
}

Measured memory_bytes: 15092
#ifdef __unix__
#include <bits/stdc++.h>
#else
#include <iostream>
#include <algorithm>
#include <math.h>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <unordered_set>
#endif


#define fastIO ios_base::sync_with_stdio(0), cin.tie(NULL)
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl '\n'
#define mkp make_pair
/*#define NUMTOSTR(x)  (unsigned char)((x) + 48);*/
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long  ull;
using namespace std;



int main() {
	fastIO;
	int x;
	int i = 1;
	while (cin >> x)
	{
		if (x == 0) {
			cout << i;
			break;
		}
		i++;
	}
	return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 500000
#define DUMMY 2000000001

struct Node{
  int key;
  struct Node *left,*right;
};

struct Node *make_node(int x){
  struct Node *node = malloc(sizeof(struct Node));
  if(node != NULL){
    node->key = x;
    node->left = NULL;
    node->right = NULL;
  }
  return node;
}

struct Node *root;

int search_min(struct Node*);
struct Node *delete_min(struct Node *node);

struct Node *insert(int,struct Node*);
void insort(struct Node*);
void presort(struct Node*);
void find(int,struct Node*);
struct Node *Delete(int,struct Node*);

int main(void){
  int m,n=0;
  int i;
  int k;
  char order[7];

  root = NULL;

  scanf("%d",&m);

  for(i=0;i<m;i++){
    scanf("%s",order);
    if(strcmp(order,"insert") == 0){
      scanf("%d",&k);
      root = insert(k,root);
    }else if(strcmp(order,"print") == 0){
      insort(root);
      printf("\n");
      presort(root);
      printf("\n");
    }else if(strcmp(order,"find") == 0){
      scanf("%d",&k);
      find(k,root);
    }else if(strcmp(order,"delete") == 0){
      scanf("%d",&k);
      Delete(k,root);
    }
  }
}

struct Node *insert(int key,struct Node *node){
  if (node == NULL)
    return make_node(key);
  else if (key < node->key)
    node->left = insert(key, node->left);
  else if (key > node->key)
    node->right = insert(key, node->right);
  return node;
}

void find(int key,struct Node *node){
  while (node != NULL) {
    if (node->key == key){
      printf("yes\n");
      return;
    }
    else if(key < node->key)
      node = node->left;
    else
      node = node->right;
  }
  printf("no\n");
  return;
}

int search_min(struct Node *node){
  while (node->left != NULL) node = node->left;
  return node->key;
}

struct Node *delete_min(struct Node *node){
  if (node->left == NULL) {
    struct Node *temp = node->right;
    free(node);
    return temp;
  }
  node->left = delete_min(node->left);
  return node;
}

struct Node *Delete(int key,struct Node *node){
  if (node == NULL) return NULL;
  if (key == node->key) {
    if (node->left == NULL) {
      struct Node *temp = node->right;
      free(node);
      return temp;
    }
    if (node->right == NULL) {
      struct Node *temp = node->left;
      free(node);
      return temp;
    }
    node->key = search_min(node->right);
    node->right = delete_min(node->right);
  } else if (key < node->key)
    node->left = Delete(key, node->left);
  else
    node->right = Delete(key, node->right);
  return node;
}

void insort(struct Node *node){

  if(node == NULL) return;

  insort(node->left);

  printf(" %d",node->key);

  insort(node->right);
}

void presort(struct Node *node){

  if(node == NULL) return;

  printf(" %d",node->key);
  
  presort(node->left);
  presort(node->right);
}


Measured memory_bytes: 14284
from collections import Counter

n = int(input())

a = input()
c = Counter(a)

for _ in range(1, n):
    x = input()
    cx = Counter(x)

    for string, count in c.items():
        c[string] = min(count, cx[string])

ans = []
for string, count in c.items():
    ans += [string] * count

ans.sort()
print("".join(ans))

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;

    for(int i = 0; i < a; i++){
        if(!('0' <= s[i] && s[i] <= '9')){
            p("No");
            return 0;
        }
    }

    if(s[a] != '-') {
        p("No");
        return 0;
    }

    for(int i = a + 1; i < a + b; i++){
        if (!('0' <= s[i] && s[i] <= '9')){
            p("No");
            return 0;
        }
    }
    p("Yes");
}


Measured memory_bytes: 256
N=int(input().strip())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A=sorted(A)
B=sorted(B)
C=sorted(C,reverse=True)
def binsearch_int(func, min_x, max_x):
    """func(x) == Trueとなる最大のxを返す
    """
    if func(max_x):
        return max_x
    if not func(min_x):
        return -1
    left,right=min_x,max_x
    while left+1<right:
        mid=(left+right)//2
        if func(mid):
            left=mid
        else:
            right=mid
    return left
smaller=[binsearch_int(lambda x: A[x]<i,0,N-1)+1 for i in B]
bigger=[binsearch_int(lambda x: C[x]>i,0,N-1)+1 for i in B]
print(sum(a*c for a,c in zip(smaller, bigger)))

Measured memory_bytes: 24184
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<cmath>
#include<queue>
#include<map>
#include<set>

using namespace std;

int read()
{
	int ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}

const double pi=3.14159265358979323846;
int n;
double ans;

int main()
{
	n=read();
	ans=2.0*n*pi;
	printf("%.20lf",ans);
	return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
#define INF 200000

int n, m;
bool is_edge[110][110];
int d[110][110];

void warshall_floyd() {
    for (int k=0; k<n; k++) {
        for (int i=0; i<n; i++) {
            for (int j=0; j<n; j++) {
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
}

int main() {
    while (true) {
        cin >> n >> m;
        
        if (n==0 && m==0) {
            break;
        }
        
        for (int i=0; i<n; i++) {
            for (int j=0; j<n; j++) {
                is_edge[i][j] = false;
                d[i][j] = (i==j) ? 0 : INF;
            }
        }
        
        for (int i=0; i<m; i++) {
            int a, b, c; cin >> a >> b >> c;
            is_edge[a-1][b-1] = true, is_edge[b-1][a-1] = true;
            d[a-1][b-1] = c, d[b-1][a-1] = c;
        }
        
        warshall_floyd();
        
        int ans = d[0][n-1];
        
        for (int i=0; i<n; i++) {
            for (int j=i+1; j<n; j++) {
                for (int k=0; k<n; k++) {
                    if (is_edge[k][i] && is_edge[k][j]) {
                        ans = min({ans, d[0][i]+d[j][n-1], d[0][j]+d[i][n-1]});
                        break;
                    }
                }
            }
        }
        
        cout << ans << endl;
    }
}


Measured memory_bytes: 3160
#include <stdio.h>
#define MAX 100000
 
int Partition(int *,int);
 
int main() {
  int i,n,A[MAX],m;
 
  scanf("%d",&n);
  for (i = 0; i < n; i++) {
    scanf("%d",&A[i]);
  }
  n--;
  m = paritition(A,n);
 
  for(i = 0; i < m ; i ++) {
    printf("%d ",A[i]);
  }
  printf("[%d] ",A[m]);
 
  for(i = m + 1; i < n; i++) {
    printf("%d ",A[i]);
  }
  printf("%d\n",A[n]);
 
  return 0;
}
 
int paritition(int *A, int n) {
  int x,i,j,a;
  x = A[n];
  i = 0;
  for(j = 0; j < n; j++) {
    if(A[j] <= x) {
      a = A[i];
      A[i] = A[j];
      A[j] = a;
      i++;
    }
  }
  A[n] = A[i];
  A[i] = x;
  return i;
}

Measured memory_bytes: 988
def mygets():
    return list(map(int, input().strip().split(' ')))

n, x = mygets()
a = mygets()

b1 = a

ans = sum(a)

def f(k, u):
    j = k - 1
    if j < 0:
        j = n - 1
    w = b1[j]
    if u < w:
        return u
    return w

for i in range(1, n):
    b2 = [f(k, u) for k, u in enumerate(a)]
    ans = min(ans, sum(b2) + i * x)
    b1 = b2

print(ans)

Measured memory_bytes: 3188
#!/usr/bin/env python3

N = int(input())
d = {}
for i in range(N):
    a = int(input())
    if a in d and d[a]:
        d[a] = 0
    else:
        d[a] = 1
cnt = 0
for a in d:
    if d[a]:
        cnt += 1
print(cnt)



Measured memory_bytes: 15076
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<30)
int R[]={0,30,60,90,120,150,180};
int D[]={100,200,300,400,500};
int main(){
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    int r,t; cin >> r >> t;
    if(r%100 == 0 && t%30 == 0){
      cout << r/100+t/30*5 << endl;
    } else if(r % 100 == 0){
      for(int i=0;i<6;i++){
	if(R[i]<t && R[i+1]>t){
	  cout << r/100+R[i]/30*5 << " ";
	  cout << r/100+R[i+1]/30*5 << endl;
	  break;
	}
      }
    } else if(t % 30 == 0){
      for(int i=0;i<5;i++){
	if(D[i]<r && D[i+1]> r){
	  cout << D[i]/100+t/30*5 << " ";
	  cout << D[i+1]/100+t/30*5 << endl;
	  break;
	}
      }
    } else {
      int T,Y;
      for(int i=0;i<6;i++){
	if(R[i]<t && R[i+1]>t){
	  Y = i;
	  break;
	}
      }
      for(int i=0;i<5;i++){
	if(D[i]<r && D[i+1]> r){
	  T = i;
	  break;
	}
      }
      cout << D[T]/100+R[Y]/30*5 << " ";
      cout << D[T+1]/100+R[Y]/30*5 << " ";
      cout << D[T]/100+R[Y+1]/30*5 << " ";
      cout << D[T+1]/100+R[Y+1]/30*5 << endl;
    }
  }
}

Measured memory_bytes: 1172
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;
int main() {
	int n; cin >> n;
	vector<int>p(n);
	for (auto& e : p)cin >> e;

	sort(p.begin(), p.end());

	int ans=0;
	for (int i = p[n/2]; i > p[n/2-1]; --i)
		++ans;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#coding:utf-8
x1,y1,x2,y2=map(int,input().split())
dx = x2-x1
dy = y2-y1
x3 = x2-dy
y3 = y2+dx
x4 = x3-dx
y4 = y3-dy
print (x3,y3,x4,y4)


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

int main(){
vector<int> x(4),y(4);
cin>>x[0]>>y[0]>>x[1]>>y[1];
 x[2]=x[1]-y[1]+y[0];
  y[2]=y[1]+x[1]-x[0];
  x[3]=x[0]-y[1]+y[0];
  y[3]=y[0]-x[0]+x[1];
cout<<x[2]<<" "<<y[2]<<" "<<x[3]<<" "<<y[3]<<endl;


}



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

using namespace std;

typedef pair<int, int> P;

vector<int> x, X;
struct Queue {
	int id;
	int l, r, e;
	int a, b;
	int ap, bp;
	int aCnt, bCnt;

	Queue(int id, int l, int r, int e) : id(id), l(l), r(r), e(e) {
		int a = min(x[l], x[r]) - e;
		int b = max(x[l], x[r]) + e;
		ap = (int)(lower_bound(X.begin(), X.end(), a) - X.begin()) - 1;
		bp = (int)(upper_bound(X.begin(), X.end(), b) - X.begin());
	}
};
bool comp_ap(const Queue& q1, const Queue& q2) {
	return q1.ap < q2.ap;
}
bool comp_bp(const Queue& q1, const Queue& q2) {
	return q1.bp > q2.bp;
}
bool comp_id(const Queue& q1, const Queue& q2) {
	return q1.id < q2.id;
}

int getId(int v) {
	return (int)(lower_bound(X.begin(), X.end(), v) - X.begin());
}

class Bit {
public:
	int size;
	int a[100001];
	Bit(int sz) {
		size = sz;
		fill(&a[0], &a[0]+(size+1), 0);
	}
	void add(int pos, int v) {
		++pos;
		while (pos <= size) {
			a[pos] += v;
			pos += pos & -pos;
		}
	}
	int get(int pos) {
		++pos;
		int res = 0;
		while (pos > 0) {
			res += a[pos];
			pos -= pos & -pos;
		}
		return res;
	}
};

int main() {
	int D; cin >> D; x.resize(D);
	for (int i = 0; i < D; ++i) cin >> x[i];

	X = x;
	sort(X.begin(), X.end());
	X.erase(unique(X.begin(), X.end()), X.end());

	vector<Queue> v;
	int Q; cin >> Q;
	for (int q = 0; q < Q; ++q) {
		int l, r, e; cin >> l >> r >> e; --l, --r;
		v.push_back( Queue(q, l, r, e) );
	}

	vector<P> dt;
	for (int i = 0; i < x.size(); ++i) {
		dt.push_back( P(x[i], i) );
	}
	sort(dt.begin(), dt.end());

	int l = 0;
	Bit aBit(x.size());
	sort(v.begin(), v.end(), comp_ap);
	for (int i = 0; i < v.size(); ++i) {
//		cout << v[i].l << " " << v[i].r << " " << v[i].e << ":" << v[i].ap << endl;
		for (; l < dt.size(); ++l) {
			if (getId(dt[l].first) > v[i].ap) break;
			aBit.add(dt[l].second, 1);
//			cout << "add:" << dt[l].first << " " << dt[l].second << endl;
		}
		v[i].aCnt = aBit.get(v[i].r) - aBit.get(v[i].l-1);
//		cout << ":" << v[i].aCnt << endl;
	}
//cout << "-------------------------------------" << endl;
	int r = dt.size()-1;
	Bit bBit(x.size());
	sort(v.begin(), v.end(), comp_bp);
	for (int i = 0; i < v.size(); ++i) {
//		cout << v[i].l << " " << v[i].r << " " << v[i].e << ":" << v[i].ap << endl;
		for (; r >= 0; --r) {
			if (getId(dt[r].first) < v[i].bp) break;
			bBit.add(dt[r].second, 1);
//			cout << "add:" << dt[r].first << " " << dt[r].second << endl;
		}
//		cout << v[i].r << " " << bBit.get(v[i].r) << " " << v[i].l << " " << bBit.get(v[i].l-1) << endl;
		v[i].bCnt = bBit.get(v[i].r) - bBit.get(v[i].l-1);
//		cout << ":" << v[i].bCnt << endl;
	}

	sort(v.begin(), v.end(), comp_id);
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i].aCnt + v[i].bCnt << endl;
	}
}

Measured memory_bytes: 9352
#include "bits/stdc++.h"
using namespace std;
int main(){
    int N;
    cin >> N;
    int m = 0, sum = 0, i = 0, k;
    while(i < N){
        cin >> k;
        sum = sum + k;
        if(k > m){
            m = k;
        }
        i++;
    }
    if(sum > m * 2){
        cout << "Yes" << endl;
        
    }
    else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>

using namespace std;

#define ll long long

int main(){
    int N,tmp,a;
    cin >> N;
    tmp = N % 10;
    a = N /100;
    if(a == tmp){
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }
    
}


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

int main(){
  vector<unsigned long long> L(87);
  int N;
  vector<int> n(N);

  cin >> N ;

  if(N >= 2){
    L.at(0) = 2;
    L.at(1) = 1;
    for(int i = 2; i <= N; i++){
      L.at(i) = L.at(i-1) + L.at(i-2);
    }
    cout << L.at(N) << endl;

  }
  else if(N == 0){
    cout << 2 << endl;
  }
  else if(N == 1){
    cout << 1 << endl;
  }
}

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

int main(){
	while(1){
	int n,sougaku,kingaku=0;
	cin>>sougaku;
	if(sougaku==0) break;
	for(int i=0;i<9;i++){
	cin>>n;
	kingaku=kingaku+n;
	}
	cout<<sougaku-kingaku<<endl;
	}
	
    return 0;
}


Measured memory_bytes: 3096
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int maxn=100005;
string s;
int ans;

int main(){
	cin>>s;
	rep(i,s.size()-1)if(s[i]!=s[i+1])ans++;
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 512
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    ps <- getIntList
    qs <- getIntList
    let as = sort $ permutations [1..n]
    let p = fromJust $ elemIndex ps as
    let q = fromJust $ elemIndex qs as
    print . abs $ p - q

Measured memory_bytes: 21116
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define p pair<int,int>
int N, M, S, T;
vector<int> G[100010];
int dp[3][100010];
bool flag[3][100010];

struct edge{
    int m, n, cost;

    bool operator < (const edge& e) const {
        return cost < e.cost; 
    }

    bool operator > (const edge& e) const {
        return cost > e.cost; 
    }
};

void dij(){
    for(int i = 0; i < 3; i++){
        for(int j = 0; j <= N; j++){
            dp[i][j] = 1 << 30;
        }
    }

    queue<edge> pq;
    pq.push(edge{0, S, 0});
    dp[0][S] = 0;

    while(!pq.empty()){
        edge e = pq.front();
        int n = e.n, m = e.m, cost = e.cost;
        pq.pop();

        cost++;
        m = (m + 1) % 3;

        for(auto& u : G[n]){
            if(dp[m][u] > cost && !flag[m][u]){
                flag[m][u] = true;
                dp[m][u] = cost;
                pq.push(edge{m, u, cost});
            }
        }
    }
}

int main(){
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
    }
    cin >> S >> T;
    dij();
    cout << (dp[0][T] != 1 << 30 ? dp[0][T] / 3 : -1) << endl;
    return 0;
}


Measured memory_bytes: 7168
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep(i,n)    for(ll i=1; i<=n; i++)
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n'
#define no cout<<"No"<<'\n'
using namespace std;

int main()
{
    godspeed

    ll i,j,n,m,x,d,lft=0,ryt=0;
    cin>>n>>m>>x;
    ll a[m];
    for(i=0;i<m;i++){
        cin>>d;
    if(d>x) ryt++;
    else lft++;

    }
        cout<<min(lft,ryt)<<endl;

    return 0;
}





Measured memory_bytes: 3652
def main():
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    h = 40
    w = 100
    print(h, w)
    for i in range(10):
        X = "#." * min(A, 50) + "##" * max(50-A, 0)
        A = max(A-50, 0)
        print(X)
        print("#" * 100)
    for i in range(10):
        X = ".#" * min(B, 50) + ".." * max(50-B, 0)
        B = max(B-50, 0)
        print("." * 100)
        print(X)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include <iostream>
using namespace std;
int main(){
  int n,count = 0;
  cin >> n;
  int x = n;
  while(x > 0){
    int r = x % 10;
    count = count + r;
    x = x / 10;
  }
  if(n % count == 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin

num, qt = (int(s) for s in stdin.readline().split())
rrs = []
for _ in range(num):
    name, time = stdin.readline().split()
    rrs.append([name, int(time)])

process = 0
while rrs:
    rrs[0][1] -= qt
    if rrs[0][1] <= 0:
        process += qt + rrs[0][1]
        print(rrs.pop(0)[0], process)
    else:
        process += qt
        p = rrs.pop(0)
        rrs.append(p)

Measured memory_bytes: 13516
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long
#define ld long double
int main()
{
	ll N,M;
	cin >> N >> M;
	map <ll,ll> mp;
	map <ll,ll> mp1;
	ll cr=0;
	ll wr=0;
	for(ll i=0;i<M;i++)
	{
		ll x;
		string s;
		cin >> x >> s;
		if(s=="WA")
		{
			mp[x]++;
		}
		else
		{
			if(mp1[x]==0)
			{
				cr++;
				mp1[x]++;
				if(mp[x]>0)
				{
					wr+=mp[x];
				}
			}
		}
	}
	cout << cr << " " << wr << "\n";
}


Measured memory_bytes: 12800
n = int(input())
a = [int(i) for i in input().split()]

a_dict = {}
for v in a:
    if v in a_dict:
        a_dict[v] += 1
    else:
        a_dict[v] = 1

 
if n % 2 == 0:
    possible_list = {i: True for i in range(1, n, 2)}
    for k, v in a_dict.items():
        if v != 2 or k not in possible_list:
            print(0)
            exit()
else:
    possible_list = {i: True for i in range(0, n, 2)}
    if a_dict[0] != 1:
        print(0)
        exit()
    else:
        a_dict[0] = 2
        for k, v in a_dict.items():
            if v != 2 or k not in possible_list:
                print(0)
                exit()
 
print(2 ** (n // 2) % (10 ** 9 + 7))

Measured memory_bytes: 18016
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <bitset>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define iter(it,c) for(auto it=(c).begin(); it!=c.end(); ++it)

typedef vector<int> vi;
typedef map<int, int> mii;

int const score[] = { 0, 0, 60, 70, 80 };
int eval(int n){
    int s = 0;
    rep(i, 5){
        s += score[n & 7];
        n >>= 3;
    }
    return s;
}

int flip(int n, int f){
    f <<= 2;
    int r = 0;
    rep(i, 5){
        int t = n >> (i * 3) & 7;
        if (t){
            int c = (f >> (i * 2) & 3) + (f >> (i * 2 + 2) & 3);
            t = ((t - 1 + c) & 3) + 1;
        }
        r |= t << (i * 3);
    }
    return r;
}

int solve(vi const& v){
    mii prev;
    prev[v[0]] = eval(v[0]);
    rep(i, 4){
        mii next;
        iter(it, prev){
            int bef = eval(it->first);
            rep(f, 1 << 8){
                int aft = flip(it->first, f);
                int suc = flip(v[i + 1], f);
                int e = it->second - bef + eval(aft) + eval(suc);
                int x = eval(aft);
                int y = eval(suc);
                next[suc] = max(next[suc], e);
            }
        }
        swap(prev, next);
    }

    int ans = 0;
    iter(it, prev) ans = max(it->second, ans);
    return ans;
}

int main(){
    int n; cin >> n;
    rep(_,n){
        vi v(5);
        rep(i, 5){
            rep(j, 5){
                int t = 0; cin >> t;
                v[i] <<= 3;
                v[i] |= t;
            }
        }
        cout << solve(v) << endl;
    }
}

Measured memory_bytes: 1220
// 1_lis0_a
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }

    int length = 0;
    vector<int> l;
    l.push_back(a[0]);

    for(int i = 1; i < n; i++){
        if(a[i] > l[length]){
            l.push_back(a[i]);
            length++;
        }else{
            auto k = lower_bound(l.begin(), l.end(), a[i]);
            int j = k - l.begin();
            l[j] = a[i];
        }
    }

    cout << length + 1 << endl;
    return 0;
}



Measured memory_bytes: 3700
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;


struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge> >;

int main() {
    // 頂点数と辺数
    int N; cin >> N;

    // グラフ
    Graph G(N);
    for (int i = 0; i < N-1; ++i) {
        int from, to, weight;
        cin >> from >> to >> weight;
        from--;to--;weight%=2;
        G[from].push_back(Edge(to, weight));
        G[to].pb(Edge(from,weight));
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int i=0;i<G[v].size();i++) {
          int nv = G[v][i].to;
          if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
          dist[nv] = (dist[v] + G[v][i].weight)%2;
          que.push(nv);
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    for (int v = 0; v < N; ++v) cout << dist[v] << endl;


}


Measured memory_bytes: 6784
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using D = double;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int N, Q;

template<class T> struct SegmentTree {
private:
	int n;
	vector<T> node;
public:
	SegmentTree(vector<T> v) {
		int sz = v.size();
		n = 1; while (n < sz) n *= 2;
		node.resize(2 * n - 1, INF);
		for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--) node[i] = min(node[2 * i + 1], node[2 * i + 2]);
	}

	void update(int x, T val) {
		x += (n - 1);
		node[x] = val;
		while (x > 0) {
			x = (x - 1) / 2;
			node[x] = min(node[2 * x + 1], node[2 * x + 2]);
		}
	}
	//[a,b)の最小値を求める
	T getmin(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		if (r <= a || b <= l) return INF;
		if (a <= l && r <= b) return node[k];

		T vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
		T vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
};

int main() {
	cin >> N >> Q;
	SegmentTree<int> seg(vector<int>(N, INF));
	for (int i = 0; i < Q; i++) {
		int c, x, y; cin >> c >> x >> y;
		if (c == 0) seg.update(x, y);
		else cout << seg.getmin(x, y + 1) << endl;
	}
}


Measured memory_bytes: 4144
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int n=sc.nextInt();
        int y=sc.nextInt();
        boolean cd=false;
        for(int z=y/10000;z>=0;z--){
            for(int x=y/5000;x>=0;x--){
                int tmp=(y-(z*10000+x*5000));
                if(tmp%1000==0 && tmp>=0 && (z+x+tmp/1000)==n){
                    System.out.println(z+" "+x+" "+tmp/1000);
                    cd=true;
                    break;
                }
            }
            if(cd){
                break;
            }
        }
        if(!cd){
            System.out.println("-1 -1 -1");
        }
    }
}


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

int main(){
	int N;
	cin >> N;
	vector<long long> a(3*N);
	for(auto &i:a)cin >> i;
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	
	long long ans=0;
	for(int i=0;i<N;i++){
		ans+=a[2*i+1];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>

void solve(int n) {
	int a = (n % 2 == 0) ? 0 : 1;
	int m = (a - n) / 2;
	if (m != 0) solve(m);
	printf("%d", a);
}

int main() {
	int N;
	scanf("%d", &N);
	solve(N);
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
class ITP1
{
    static void Main(string[] args)
    {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //System.Console.SetIn(exStdIn);

        Q3_C();

        //int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<String, int>(s => int.Parse(s)));
    }

    static void Q1()
    {
        int input = int.Parse(Console.ReadLine());

        int h = input / 3600;
        int m = input % 3600 / 60;
        int s = input % 3600 % 60;

        Console.WriteLine(String.Format("{0}:{1}:{2}", h, m, s));
    }

    static void Q2_A()
    {
        int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<String, int>(s => int.Parse(s)));

        String sign = a[0] - a[1] > 0 ? ">" : a[0] - a[1] == 0 ? "==" : "<";

        Console.WriteLine(String.Format("a {0} b",sign));
    }

    static void Q2_B()
    {
        int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<String, int>(s => int.Parse(s)));
        String answer = a[2] - a[1] > 0 ? a[1] - a[0] > 0 ? "Yes" : "No" : "No";

        Console.WriteLine(answer);
    }

    static void Q2_C()
    {
        List<int> a = new List<int>(Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<String, int>(s => int.Parse(s))));
        a.Sort();

        Console.WriteLine(String.Format("{0} {1} {2}",a[0],a[1],a[2])); 
    }

    static void Q2_D()
    {
        int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<String, int>(s => int.Parse(s)));

        int chk = 0;

        //x-max
        if (a[0] - a[2] - a[4] >= 0) chk++;
        //x-min
        if (a[2] - a[4] >= 0) chk++;
        //y-max
        if (a[1] - a[3] - a[4] >= 0) chk++;
        //y-min
        if (a[3] - a[4] >= 0) chk++;

        String answer = chk == 4 ? "Yes" : "No";
        Console.WriteLine(answer);
        
    }

    static void Q3_A()
    {
        for (int i = 0; i < 1000; i++)
        {
            Console.WriteLine("Hello World");
        }
    }

    static void Q3_B()
    {
        String a = "";
        for (int i = 1; i <= 10000; i++)
        {
            a = Console.ReadLine();
            if (a != null)
            {
                Console.WriteLine("Case {0}: {1}", i, a);
            }
            else
            {
                break;
            }

        }
    }

    static void Q3_C()
    {
        while(true)
        {
            String str = Console.ReadLine();
            if (str == null || str == "0 0") break;
            int[] a = Array.ConvertAll(str.Split(' '), new Converter<String, int>(s => int.Parse(s)));
            
            List<int> tempList = new List<int>(a);
            tempList.Sort();
            Console.WriteLine(String.Format("{0} {1}",tempList[0],tempList[1]));
        }
    }
}

Measured memory_bytes: 9516
#include<bits/stdc++.h>
#define mems(a,x) memset(a,x,sizeof(a))
#define first fi
#define second se
using namespace std;
typedef long long ll;
const int mod=1e9+7,N=105;
const double eps=1e-8,pi=3.1415926535898;
ll inv(ll x){return x==1?x:(mod-mod/x)*inv(mod%x)%mod;}
ll inv(ll x,ll mod){return x==1?x:(mod-mod/x)*inv(mod%x,mod)%mod;}
ll qpow(ll a,ll n){ll ans=1;while(n){if(n&1) ans=ans*a%mod;a=a*a%mod;n>>=1;}return ans;}
ll mul(ll a,ll b){ll ans=0;while(b){if(b&1) ans=(ans+a)%mod;a=(a+a)%mod;b>>=1;};return ans;}
ll qpow(ll a,ll n,ll mod){ll ans=1;while(n){if(n&1) ans=ans*a%mod;a=a*a%mod;n>>=1;}return ans;}
ll mul(ll a,ll b,ll mod){ll ans=0;while(b){if(b&1) ans=(ans+a)%mod;a=(a+a)%mod;b>>=1;};return ans;}
struct vec
{
    double x,y;
    int id;
    vec(double x=0,double y=0):x(x),y(y){}
    vec operator+(const vec&o)const{ return vec(x+o.x,y+o.y);}
    vec operator-(const vec&o)const{ return vec(x-o.x,y-o.y);}
    double operator*(const vec&o)const{ return x*o.x+y*o.y;}
    double operator^(const vec&o)const{ return x*o.y-y*o.x;}
    vec operator/(const double&o)const{ return vec(x/o,y/o);}
    vec operator*(const double&o)const{ return vec(x*o,y*o);}
    void sc(){scanf("%lf%lf",&x,&y);}
    double len(){return sqrt(x*x+y*y);}
}a[N],s[N];
int n,top;
bool cmp(vec x,vec y)
{
    double k1=atan2(x.y-a[1].y,x.x-a[1].x),k2=atan2(y.y-a[1].y,y.x-a[1].x);
    if(fabs(k1-k2)<eps) return x.x<y.x;
    return k1<k2;
}
double ans[N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) a[i].sc(),a[i].id=i;
    for(int i=1;i<=n;i++)
        if(a[i].y<a[1].y||a[i].y==a[1].y&&a[i].x<a[1].x)
        swap(a[i],a[1]);
    sort(a+2,a+1+n,cmp);
    for(int i=1;i<=n;i++)
    {
        while(top>=2&&((s[top-1]-a[i])^(s[top]-a[i]))<=0) top--;
        s[++top]=a[i];
    }
    if(top==1) ans[s[1].id]=1;
    else if(top==2) ans[s[1].id]=ans[s[2].id]=0.5;
    else
        for(int i=1;i<=top;i++)
        {
            vec l,r;
            if(i==1) l=s[top];
            else l=s[i-1];
            if(i==top) r=s[1];
            else r=s[i+1];
            double res=(r-s[i])*(l-s[i]);
            res/=(r-s[i]).len()*(l-s[i]).len();
            res=pi-acos(res);
            res/=2*pi;
            ans[s[i].id]=res;
        }
    for(int i=1;i<=n;i++)
        printf("%.10f\n",ans[i]);
}


Measured memory_bytes: 384
from collections import defaultdict

def conv(s):
    if "." not in s:
        s += '.'
    s = s.rstrip('0')
    t = len(s) - s.find('.') - 1
    a = int(s.replace('.', ''))
    if a == 0:
        return (0, 0)
    x, y = -t, -t
    while a % 5 == 0:
        x += 1
        a //= 5
    y += len(bin(a&-a))-3
    return (x, y)

_, *A = open(0).read().split()

d = defaultdict(int)
for a in A:
    d[conv(a)] += 1

result = 0
d = list(d.items())
for i, ((x, y), cnt) in enumerate(d):
    if x >= 0 and y >= 0:
        result += cnt * (cnt - 1) // 2
    for (m, n), cnt2 in d[i+1:]:
        if x + m >= 0 and y + n >= 0:
            result += cnt * cnt2
print(result)


Measured memory_bytes: 26008
import java.util.Scanner
import scala.util.control.Breaks

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val N, H, W = sc.nextInt

    var ans = 0
    for (i <- 1 to N) {
      val A, B = sc.nextInt
      if ((A >= H) && (B >= W)) {
        ans += 1
      }
    }

    println(ans)
  }
}

Measured memory_bytes: 29636
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
int a[300100];
int d[300100];

signed main() {
  // DP???
  // probably not
  int N; cin >> N;
  
  for (int i = 0; i < N; i++) a[i] = 0;
  for (int i = 0; i < N; i++) {
    cin >> d[i];
    if (d[i]/10==0&&a[i]-1<=0) {
      cout << "no" << endl;
      return 0;
    } else {
      a[i+1] = max(d[i]/10,a[i]-1);
    }
  }

  for (int i = 0; i < N; i++) a[i] = 0;
  for (int i = N-1; i >= 0; i--) {
    if (d[i]/10==0&&a[i]-1<=0) {
      cout << "no" << endl;
      return 0;
    } else {
      a[i-1] = max(d[i]/10,a[i]-1);
    }
  }

  cout << "yes" << endl;
}



Measured memory_bytes: 7756
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n,a,b,c;
int dp[100010][3];

signed main(){
    I(n);
    REPS(i,n){
        I(a); I(b); I(c);
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a;
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b;
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c;
    }
    int ret = *max_element( dp[n], dp[n]+3 );
    cout << ret << endl;
}

Measured memory_bytes: 2560
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <iostream>

using namespace std;

#define N 1000000000000000

int main() {
    string S;
    int w;

    cin >> S;
    cin >> w;

    for(int i = 0; i < S.size(); i += w)
        cout << S[i];
    cout << endl;
    return 0;
}


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

int n;
int a[20];
int x[20][20];
int y[20][20];

int counter(int n){
  if(n==0)return 0;
  return counter(n >> 1) + (n & 1);
}

int main(){
  int n; cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    for(int j=1;j<=a[i];j++){
      cin>>x[i][j] >>y[i][j];
    }
  }
  
  int ans=0;
  for(int bits=1;bits < (1<<n);bits++){
    bool ok=true;
    for(int i=1;i<=n;i++){
      if(!(bits & (1<<(i-1))))continue;
      for(int j=1;j<=a[i];j++){
        if(((bits>>(x[i][j]-1)) & 1) ^ y[i][j])ok=false;
      }
    }
    if(ok)ans=max(ans, counter(bits));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <stack>
#include <vector>
#include <set>
#include <queue>
#pragma comment (linker,"/STACK:102400000,102400000")
#define maxn 100005
#define MAXN 2005
#define mod 1000000009
#define INF 0x3f3f3f3f
#define pi acos(-1.0)
#define eps 1e-6
#define lson rt<<1,l,mid
#define rson rt<<1|1,mid+1,r
#define FRE(i,a,b)  for(i = a; i <= b; i++)
#define FREE(i,a,b) for(i = a; i >= b; i--)
#define FRL(i,a,b)  for(i = a; i < b; i++)
#define FRLL(i,a,b) for(i = a; i > b; i--)
#define mem(t, v)   memset ((t) , v, sizeof(t))
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pf          printf
#define DBG         pf("Hi\n")
typedef long long ll;
using namespace std;
 
ll father[maxn];
int n,q;
 
ll find_father(ll x)
{
    if (x==father[x])
        return father[x];
    return find_father(father[x]);
}
 
int main()
{
    int i,j;
    ll x;
    char s[2];
    while (sff(n,q))
    {
        if (n==0&&q==0) break;
        father[1]=1;
        FRE(i,2,n)
        {
            sf(x);
            father[i]=x;
        }
        ll ans=0;
        while (q--)
        {
            scanf("%s%lld",s,&x);
            if (s[0]=='M')
                father[x]=x;
            else
                ans+=find_father(x);
        }
        pf("%lld\n",ans);
    }
    return 0;
}



Measured memory_bytes: 3884
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <map>
#include <iostream>

using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

vector<ll> fact, ifact;

void init_table(int n) {
  fact.assign(n + 1, 1), ifact.assign(n + 1, 1);
  for (int i = 2; i < n + 1; ++i) fact[i] = i * fact[i - 1] % MOD;
  ifact[n] = modinv(fact[n], MOD);
  for (int i = n; i > 2; --i) ifact[i - 1] = i * ifact[i] % MOD;
}

ll comb(int n, int r) {
  return fact[n] * (ifact[r] * ifact[n - r] % MOD) % MOD;
}

ll H(int n, int r) {
  init_table(n + r - 1);
  return comb(n + r - 1, r);
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  init_table((int)1e6);
  map<int, int> mp;
  for (int i = 2; i * i <= m; ++i) {
    while (m % i == 0) {
      m /= i;
      mp[i]++;
    }
  }
  if (m > 2) mp[m]++;
  ll ans = 1;
  for (auto e: mp) {
    ans *= comb(e.second + n - 1, n - 1);
    ans %= MOD;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 15872
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
	a.append(a[i]+A[i])
for i in range(M):
	b.append(b[i]+B[i])
	
ans, j = 0, M
for i in range(N+1):
	if a[i] > K:
		break
	while b[j] > K - a[i]:
		j -= 1
	ans = max(ans, i+j)
	
print(ans)

Measured memory_bytes: 47480
import numpy as np
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = np.zeros(n,dtype = int)
h = np.array(h)
for i in range(1,n):
  start = max(0, i-k)
  dp[i] = min(dp[start:i] + np.abs(h[i] - h[start:i]))
print(dp[-1])

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - One out of Three
            var line = ReadLine();
            int a = line[0];
            int b = line[1];
            int c = line[2];

            if (a == b)
            {
                Console.WriteLine(c);
            }
            else if (a == c)
            {
                Console.WriteLine(b);
            }
            else
            {
                Console.WriteLine(a);
            }            
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}


Measured memory_bytes: 13268
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 100005
int n;
struct node{
	int v,p;
}a[MAXN];
bool cmp(node x,node y)
{
	return x.v<y.v;
}
int main()
{
	int ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i].v);
		a[i].p=i;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)
		if((a[i].p+i)%2) ans++;
	printf("%d\n",ans/2);
}

Measured memory_bytes: 896