akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten53 300005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;

//stack<char> stk;
//set<ll> sll;
//set<pair<ll,ll>> spll;
//map<string,ll> mp;
//map<ll,ll> mp;
//deque<ll> deq;
vector<ll> vll;
ll num[ten52],num2[ten52];
//priority_queue<pair<ll,ll>> pq;          //decreasing

int main(void)
{
    ll m,n,i,j,k=0,k1=0;
    string s;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>m;
        num[i-1]=m-i;
    }
    sort(num,num+n);
    m=n/2;
    if(n&1==1)
    {
        for(i=0;i<n;i++)
            k+=abs(num[i]-num[m]);
    }
    else
    {
        for(i=0;i<n;i++)
        {
            k+=abs(num[i]-num[m]);
            //k1+=abs(num[i]-num[m-1]);
        }
        //k=min(k,k1);
    }
    cout<<k;
    return 0;
}





Measured memory_bytes: 5196
s = input()

a = []
for i in s:
    a.append(i)

cnt1 = 0
cnt2 = 0
memo =24
for i in range(1,4):
    if a[0] == a[i]:
        memo = i
        break;
    

ans = "No"
if(memo != 24):
    for i in range(1,4):
        for j in range(i+1,4):
            if (i != memo and j != memo):
                if a[i] == a[j]:
                    if a[0] != a[i]:
                        ans = "Yes"
                        break;


print(ans)
                        
            
    
    
    
    


Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int h, w;
    char a[110][110];
    cin >> h >> w;
    imfor(i, h) {
        cin >> a[i];
    }
    imfor(i, w + 2) {
        cout << "#";
    }
    cout << endl;
    imfor(i, h) {
        cout << "#";
        cout << a[i];
        cout << "#" << endl;
    }
    imfor(i, w + 2) {
        cout << "#";
    }
    cout << endl;
}

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

int main(){

  int N;
  int h[100];
  int count=0;
  int aaa=0;
  long ans=0;

  cin >> N;
  for(int i=0; i<N; i++){
    cin >> h[i];
  }

  while(aaa!=N){
    count=aaa;
    if(h[aaa]==0){
      while(h[aaa]==0){
        aaa++;
        if(aaa==N) goto Ans;
      }
      count=aaa;
    }
    while(h[count]!=0){
      h[count]--;
      count++;
      if(count == N) break;
    }
    ans++;

  }
  Ans: ;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    c = Counter(A)
    c = sorted(c.items(), key=lambda x: x[0])
    ans = 0
    isOK = [True] * (10 ** 6 + 1)
    for k, v in c:
        if not isOK[k]:
            continue

        if v > 1:
            for i in range(k, 10 ** 6 + 1, k):
                isOK[i] = False
            continue

        ans += 1
        for i in range(2 * k, 10 ** 6 + 1, k):
            isOK[i] = False

    print(ans)


if __name__ == "__main__":
    main()


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

const ll MAXN = 1e9;
ll n, k;
vector<ll> a;

bool check(ll x) {
	ll operations = 0;
	for(int i=0; i<n; i++) {
		operations += ((a[i]-1)/x);
	}
	if(operations > k) {
		return false;
	}
	return true;
}

void search() {
	ll left = 1, right = MAXN;
	while(left < right) {
		ll mid = (left+right)/2;
		if(!check(mid)) {
			left = mid+1;
		}
		else{
			right = mid;
		}
	}
	cout << right << endl;
}

int main() {
	cin >> n >> k;
	for(int i=0; i<n; i++) {
		ll nums;
		cin >> nums;
		a.push_back(nums); 
	}
	sort(a.begin(), a.end());
	search();
	return 0;
}

Measured memory_bytes: 5272
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mn=1e5+7;
ll X[mn];
ll W[mn];
vector<ll> ret;

int main(){
	ll ants,length,time;cin>>ants>>length>>time;
	for(ll a=0;a<ants;++a)cin>>X[a]>>W[a];
	ll passed=0;
	for(ll a=0;a<ants;++a){
		ll n=0;
		if(W[a]==1){
			n=(X[a]+time)%length;
			passed+=(X[a]+time)/length;
		}else{
			n=((X[a]-time)%length+length)%length;
			passed-=(time+length-X[a]-1)/length;
		}
		ret.push_back(n);
	}
	sort(ret.begin(),ret.end());
	passed%=ants;
	if(passed<0)passed+=ants;
	rotate(ret.begin(),ret.begin()+passed,ret.end());
	for(ll a=0;a<ants;++a)cout<<ret[a]<<endl;
}


Measured memory_bytes: 3700
#include <iostream>
#include <map>

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

using namespace std;
//using P = pair<int,int>;


void init(int*,int*,int);
int find(int*,int);
bool same(int*,int,int);
void unite(int*,int*,int,int);

int main()
{
    int N,M,p[100010],G[100010],Grank[100010];
    cin>>N>>M;

    init(G,Grank,N);

    rep(i,N){
        int a;cin>>a;
        p[i]=a-1;
    }
    rep(i,M){
        int x,y; cin>>x>>y;
        unite(G,Grank,x-1,y-1);
    }
    int ans=0;
    rep(i,N){
        if(same(G,G[p[i]],i)) ans++;
    }
    cout << ans << endl;

    return 0;
}




void init(int *par, int *rank, int n)
{
    for(int i=0;i<n;i++){
        par[i]=i;
        rank[i]=0;
    }
}

int find(int *par, int x)
{
    if(par[x]==x){
        return x;
    }else{
        return find(par,par[x]);
    }
}

bool same(int *par, int x,int y)
{
    return find(par,x)==find(par,y);
}

void unite(int *par, int *rank, int x, int y)
{
    int par_x = find(par,x);
    int par_y = find(par,y);
    if(par_x==par_y){
        return;
    }else{
        if(rank[par_x]<rank[par_y]){
            par[par_x]=par_y;
        }else{
            par[par_y]=par_x;
            if(rank[par_x]==rank[par_y]){
                rank[par_x]++;
            }
        }
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
//#pragma GCC optimize "Ofast,omit-frame-pointer,inline"
using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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 int  INF = (1 << 30) - 1;
const ll INFL = 1LL << 60;
const ll mod = 998244353;


int main() {

	ll a;
	cin >> a;

	ll i = 1;
	
	while (true) {
		if ((a*i) % 360 == 0) {
			cout << i << endl;
			return 0;
		}
		i++;

	}

}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
using namespace std;
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51},n;
int main(){
	cin>>n;
	cout<<a[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

int main()
{
	int r, d, x;
	ll sum = 0;
	cin >> r >> d >> x;
	for (int i=0; i<10; i++)
	{
		sum = r * x - d;
		x = sum;
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define ull long long
using namespace std;

template <class T>
bool all_even(const vector<T>& vec);

template <class T>
void divide(vector<T>& vec);

int main()
{
	size_t N;
	cin >> N;
	vector<ull> A(N);
	for (size_t i = 0; i < N; ++i) {
		cin >> A.at(i);
	}

	int count = 0;
	while(all_even(A)) {
		++count;
		divide(A);
	}

	cout << count << endl;
	return 0;
}

template <class T>
bool all_even(const vector<T>& vec) {
	for (size_t i = 0; i < vec.size(); ++i) {
		if (vec.at(i) % 2 == 1) {
			return false;
		}
	}
	return true;
}

template <class T>
void divide(vector<T>& vec) {
	for (size_t i = 0; i < vec.size(); ++i) {
		vec.at(i) /= 2;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#define ll long long

int main(){
  ll n,k,r,s,p,i,score=0;
  bool sb[100001];
  char t[100001];
  scanf("%lld%lld%lld%lld%lld%s",&n,&k,&r,&s,&p,t);
  for(i=0;i<strlen(t);i++){
    if(i>=k&&t[i]==t[i-k]&&sb[i-k]){
      continue;
    }
    sb[i]=true;
    switch (t[i])
    {
    case 'r':
      score+=p;
      break;
    case 's':
      score+=r;
      break;
    case 'p':
      score+=s;
      break;
    }
  }
  printf("%lld",score);
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;
map<string,int> dic;
map<string,bool> isp;
map< string, vector<string> > gm;

int solve(string s){
    int r = dic[s];
    int t = 0;
    if(gm[s].size()){
	REP(i,gm[s].size()){
	    t += solve(gm[s][i]);
	}
    }else{
	return dic[s];
    }
    r = min(r,t);
    return r;
}

int main(){
    while(true){
	int n;
	cin >> n;
	if(n==0) break;
	REP(i,n){
	    string s;
	    int p;
	    cin >> s >> p;
	    dic[s] = p;
	    isp[s] = false;
	    gm[s] = vector<string>(0);
	}
	cin >> n;
	REP(i,n){
	    string s;
	    int m;
	    cin >> s >> m;
	    REP(j,m){
		string temp;
		cin >> temp;
		isp[temp] = true;
		gm[s].PB(temp);
	    }
	}
	string s;
	cin >> s;
	cout << solve(s) << endl;
    }
    return 0;
}

Measured memory_bytes: 1244
def calc_payment(p):
        max_p = 0
        sum_p = 0
        for p_v in p:
                max_p = max(max_p, p_v)
                sum_p += p_v
        return sum_p - (max_p // 2)


N = int(input())
p = [int(input()) for _ in range(N)]
print(calc_payment(p))

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
	}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int ans=min(b,d)-max(a,c);
	cout << (ans<0?0:ans) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	int M, D;
	cin >> M >> D;
	int count = 0;
	int num1, num2, tmp;
	for (int i = 2; i <= M; i++) {
		for (int j = 10; j <= D; j++) {
			tmp = j;
			num1 = tmp % 10;
			tmp /= 10;
			num2 = tmp % 10;
			if (num1 >= 2 && num2 >= 2 && num1 * num2 == i) count++;
		}
	}
	cout << count;
}

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

int main() {
  int N;
  cin >> N;
  vector<char> s(N);
  rep(i,N) cin >> s.at(i);
  char temp = s.at(0);
  int count = 1;
  rep(i,N) {
    if(temp!=s.at(i)) {
      count++;
      temp = s.at(i);
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <queue>
#include <algorithm>
#define X_MAX 500
#define Y_MAX 500
#define N_MAX 100000
#define V_MAX ((X_MAX + 1) * (Y_MAX + 1))
#define lld "%lld"
typedef long long lnt;
typedef bool bnt;
typedef void vnt;
const lnt LNF = 0x3F3F3F3F3F3F3FLL;
const int dx[] = {-1, 0, +1, 0}, dy[] = {0, -1, 0, +1};
int X, Y, N, i, k, x, y, u, v, sx, sy, tx, ty, Ql = -1, Qr = -1, Q[V_MAX * 2];
lnt A, B, C, dir[X_MAX + 1][Y_MAX + 1], dis[X_MAX + 1][Y_MAX + 1][3];
inline bnt chk(int x, int y) { return x >= 0 && x <= X && y >= 0 && y <= Y; }
struct dat
{
	int k, x, y; lnt d;
	bnt operator < (const dat & p) const { return d > p.d; }
} p;
std::priority_queue<dat> P;
int main()
{
	scanf("%d %d" lld lld lld "%d", &X, &Y, &A, &B, &C, &N);
	for (x = 0; x <= X; ++x)
		for (y = 0; y <= Y; ++y)
			dir[x][y] = -1;
	scanf("%d %d", &sx, &sy), dir[sx][sy] = 0;
	for (i = 2; i < N; ++i)
		scanf("%d %d", &x, &y), dir[x][y] = 0;
	scanf("%d %d", &tx, &ty), dir[tx][ty] = 0;
	for (x = 0; x <= X; ++x)
		for (y = 0; y <= Y; ++y)
			if (!dir[x][y])
				Q[++Qr] = x, Q[++Qr] = y;
	while (Ql < Qr)
	{
		x = Q[++Ql], y = Q[++Ql];
		for (k = 0; k < 4; ++k)
			if (chk(u = x + dx[k], v = y + dy[k]) && !~dir[u][v])
				dir[u][v] = dir[x][y] + C, Q[++Qr] = u, Q[++Qr] = v;
	}
	for (k = 0; k < 3; ++k)
		for (x = 0; x <= X; ++x)
			for (y = 0; y <= Y; ++y)
				dis[x][y][k] = LNF;
	P.push((dat) {2, sx, sy, 0});
	while (true)
	{
		p = P.top(), P.pop();
		if (dis[p.x][p.y][p.k] < LNF)
			continue;
		if (p.x == tx && p.y == ty)
			break;
		dis[p.x][p.y][p.k] = p.d;
		switch (p.k)
		{
		case 2:
			for (k = 0; k < 2; ++k)
				if (dis[p.x][p.y][k] == LNF)
					P.push((dat) {k, p.x, p.y, p.d + B});
			for (k = 0; k < 4; ++k)
				if (chk(u = p.x + dx[k], v = p.y + dy[k]) && dis[u][v][2] == LNF)
					P.push((dat) {p.k, u, v, p.d + C});
			break;
		default:
			if (dis[p.x][p.y][2] == LNF)
				P.push((dat) {2, p.x, p.y, p.d + dir[p.x][p.y]});
			for (k = p.k; k < 4; k += 2)
				if (chk(u = p.x + dx[k], v = p.y + dy[k]) && dis[u][v][p.k] == LNF)
					P.push((dat) {p.k, u, v, p.d + A});
		}
	}
	printf(lld "\n", p.d);
	return 0;
}

Measured memory_bytes: 24476
# Author: cr4zjh0bp
# Created: Sun Mar 22 22:02:37 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

x, a, b = na()
c, d = abs(x - a), abs(x - b)

if c < d:
    print("A")
else:
    print("B")

Measured memory_bytes: 3064
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

const int INF{1001001001};
const lint LINF{1001001001001001001ll};
const int MOD{(int)1e9 + 7};
const double EPS{1e-9};
const double PI{acos(-1)};
const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

signed main() {
  int n = in();
  vi a(n);
  rep(i, n) cin >> a[i];

  int cnt = 0;
  rep(i, n) {
    if (a[i] % 2 == 1) cnt++;
  }

  if (cnt % 2 == 0) {
    print("YES");
  } else {
    print("NO");
  }
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main() {
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < H; ++ i) {
		for (int j = 0; j < W; ++ j) {
			string s;
			cin >> s;
			if (s == "snuke") {
				cout << (char)(j+'A') << (i+1) << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
int main()
{
	int a,b;
	cin>>a>>b;
	bool f=true;
	for(int i=1;i<=100000;i++)
	{
		int x=floor(i*0.08);
		int y=floor(i*0.1);
		if(x==a&&y==b)
		{
			f=false;
			cout<<i;
			break;
		}
	}
	if(f)
	cout<<-1;	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vll vector<ll>
#define vvll vecror<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll fact(ll n){ll s=1; for(ll i=1;i<=n;i++)s*=i; return s;}
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
 
 


void solve()
{
    ll A,B,C;
    cin>>A>>B>>C;
    cout<<C<<" "<<A<<" "<<B;
    return;
}

int main()
{
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <string>
#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;
using namespace std;

int main(){
    string x;
    cin >> x;
    vector<int> ss(x.size(), 0);
    ll ans = 0;

    rep(i, ss.size()){
        ss[i] = ss[i - 1];
        if(ss[i] > 0 && x[i] == 'T'){
            ss[i] --;
        }
        ss[i] += x[i] == 'S';
    }
    ans = ss[ss.size() - 1] * 2;
    cout << ans << endl;
    return 0;
}


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

int GCD( const int A, const int B )
{
int x;
int y;

	x = A;
	y = B;
	while( true )
	{
		x %= y;
		if( x == 0 ) return y;

		y %= x;
		if( y == 0 ) return x;
	}

	return - 1;
}

int main( int argc, char *argv[] )
{
int A;
int B;
int C;

	cin >> A;
	cin >> B;
	cin >> C;
	if( C % GCD( A, B ) == 0 )
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}



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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string s;
    int cnt = 0;
    cin >> s;

    for(int i=0; i<3; i++){
        if(s[i]=='o') cnt++;
    }
    cout << 700+100*cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int N;
  cin >>N;
  vector<int>vec(N);
  rep(i,N) {
cin >>vec.at(i);
  }
  int count=0;
  repl(i,1,N-1) {
if(((vec.at(i)>vec.at(i-1)) && (vec.at(i+1)>vec.at(i))) 
   || ((vec.at(i)>vec.at(i+1)) && (vec.at(i-1)>vec.at(i))))
     {
  count++;
}
    }
cout << count<< endl;
    }
  

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i, j, n, minJ, tmp, cnt=0;
  int A[100];

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

  for(i=0; i<n; i++){
    minJ = i;
    for(j=i+1; j<n; j++){
      if(A[j] < A[minJ]){
	minJ = j;
      }
    }
    if(minJ != i){
      tmp = A[i];
      A[i] = A[minJ];
      A[minJ] = tmp;
      cnt++;
    }
  }

  for(i=0; i<n-1; i++){
    printf("%d ", A[i]);
  } printf("%d\n", A[i]);
  printf("%d\n", cnt);
}



Measured memory_bytes: 2140
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = sc.nextIntArray(n);
        int[] dp = new int[n];
        Arrays.fill(dp,Integer.MAX_VALUE);
        dp[0] = 0;
        for(int i = 0; i < n; i++){
            for(int j = 1; j <= k; j++){
                if(i+j >= n) break;
                dp[i+j] = Math.min(dp[i+j],dp[i]+Math.abs(a[i+j]-a[i]));
            }
        }
        pw.println(dp[n-1]);
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 39612
import sys

for s in sys.stdin:
    c1,c2,c3 = map(int,s.split())
    county=countn=0
    for i in xrange(1,10) :
        if i in [c1,c2,c3] :continue
        if c1+c2+i <= 20: county += 1
        else : countn += 1
    if county/float(countn+county) >= 0.5 : print "YES"
    else: print "NO"

Measured memory_bytes: 4228
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define eps 1e-8
//#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int mod= 998244353;
ld PI = acosl(-1);
const ll infl = 5e18+100;
const int inf = 2e9;
const int nmax = 1e6+10;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

int fact[nmax];

int ncr(int n, int r){
    if(n<r or n<0 or r<0) return 0;
    if(fact[n] - fact[r] - fact[n-r] > 0) return 0;
    return 1;
}

int work(vector<int>arr){
    int n = arr.size(), ret = 0;
    for(int i=0; i<n; i++){
        int x = arr[i];
        ret ^= (ncr(n-1, i) * x )%2;
    }
    return ret;
}

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

    for(int i=2; i<nmax; i++){
        int k = i;
        while(k) fact[i] += k/2, k/=2;
    }

    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<int>arr(n);
    for(int i=0; i<n; i++) arr[i] = int(s[i]-'1');
    bool ekase = false;
    for(int x : arr) if(x==1) ekase = true;
    vector<int>arr2 = arr;
    for(int &x : arr2) if(x==2) x=1;
    for(int &x : arr) if(x==2) x=0;

    int ans = work(arr);
    int ans2 = work(arr2);

    if(ans) cout<<'1';
    else if(ekase) cout<<'0';
    else if(ans2) cout<<'2';
    else cout<<'0';
}


Measured memory_bytes: 17052
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <tuple>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

signed main() {
	int h, a;
	cin >> h >> a;
	cout << (h + a - 1) / a << endl;
	return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  l=[0]+l+[0]
  n+=2

  sm=0
  for i in range(n-1):
    sm+=abs(l[i+1]-l[i])

  # print(sm)

  for i in range(1,n-1):
    _sm=sm
    _sm+=abs(l[i+1]-l[i-1])
    _sm-=abs(l[i]-l[i-1])
    _sm-=abs(l[i+1]-l[i])
    print(_sm)

main()
# print(main())


Measured memory_bytes: 16612
from sys import stdin
import numpy as np

h,w = [int(x) for x in stdin.readline().rstrip().split()]
li = [["." for i in range(w+2)]for j in range(h+2)]

for i in range(h):
    s = stdin.readline().rstrip()
    for j in range(w):
        li[i+1][j+1] = s[j]

for i in range(1,h-1):
    for j in range(1,w-1):
        if li[i][j-1] == "." and li[i][j] == "#" and li[i][j+1] != "#":
            if li[i+1][j] != "#" and li[i-1][j] != "#":
                print("No")
                exit()
print("Yes")

Measured memory_bytes: 12432
#include <stdio.h>

int main() {
  int n, m, x, ans = 1e9+7, i, j, k, a[20][20], b[20], c[20], s;
  scanf("%d %d %d",&n, &m, &x);
  
  for(i = 0; i < n; i++) {
      scanf("%d",&c[i]);
      for(j = 0; j < m; j++)
      scanf("%d",&a[i][j]);
    }
    for(i = 0; i < (1 << n); i++) {
        for(j = 0; j < n; j++)
        b[j] = 0;
        for(j = s = 0; j < n; j++) {
            if((i & (1 << j)) == 0)
            continue;
            s += c[j];
            for(k = 0; k < m; k++)
            b[k] += a[j][k];
        }
        for(j = 0; j < m; j++) {
            if(b[j] < x)
            goto NEXT;
        }
        if(ans > s)
        ans=s;
        NEXT:;
    }
    printf("%d\n",ans>1e9?-1:ans);
    return 0;
}


Measured memory_bytes: 1736
import bisect
N = int(input())
#ソートしておく
L = sorted(list(map(int, input().split())))
ans = 0
 
#短い2辺を総当たりで選択
for i in range(N - 2):
  for j in range(i + 1, N - 1):
    #小さい順に並べた時の成立条件
    # l1 + l2 > l3
    l12 = L[i] + L[j]
    #l2の隣から　l12以下のところまで全部が対象、成立しない場合
    #ans += max(bisect.bisect_left(L, l12) - j - 1, 0)
    ans += bisect.bisect_left(L, l12) - j - 1
print(ans)

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

int main (){
   vector<int> x(3);
   cin >> x.at(0) >> x.at(1) >> x.at(2);
   sort(x.begin(), x.end());
   cout << x.at(1) - x.at(0) + x.at(2) - x.at(1) << endl;
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<char> S(n);
    copy_n(istream_iterator<char>(cin), n, S.begin());
    sort(S.begin(), S.end());
    if (unique(S.begin(), S.end()) - S.begin() == 3)
        puts("Three");
    else
        puts("Four");
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
const int NIL = -1;
struct Node { int p, l, r; };
const int MAX = 10000;
Node T[MAX];
int n, D[MAX], H[MAX];
void setDepth(int u, int d) {
	if (u == NIL)return;
	D[u] = d;
	setDepth(T[u].l, d + 1);
	setDepth(T[u].r, d + 1);
}
int setHeight(int u) {
	int h1(0), h2(0);
	if (T[u].l != NIL)h1 = setHeight(T[u].l) + 1;
	if (T[u].r != NIL)h2 = setHeight(T[u].r) + 1;
	return H[u] = max(h1, h2);
}
int getSibling(int u) {
	if (T[u].p == NIL)return NIL;
	if (T[T[u].p].l != u && T[T[u].p].l != NIL)return T[T[u].p].l;
	if (T[T[u].p].r != u && T[T[u].p].r != NIL)return T[T[u].p].r;
	return NIL;
}
void print(int u) {
	printf("node %d: ", u);
	printf("parent = %d, ", T[u].p);
	printf("sibling = %d, ", getSibling(u));
	int deg = 0;
	if (T[u].l != NIL)deg++;
	if (T[u].r != NIL)deg++;
	printf("degree = %d, ", deg);
	printf("depth = %d, ", D[u]);
	printf("height = %d, ", H[u]);
	if (T[u].p == NIL)printf("root\n");
	else if (T[u].l == NIL&&T[u].r == NIL)printf("leaf\n");
	else printf("internal node\n");
}
signed main() {
	int v, l, r, root = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)T[i].p = NIL;
	for (int i = 0; i < n; i++) {
		scanf("%d%d%d", &v, &l, &r);
		T[v].l = l;
		T[v].r = r;
		if (l != NIL)T[l].p = v;
		if (r != NIL)T[r].p = v;
	}
	for (int i = 0; i < n; i++)if (T[i].p == NIL)root = i;
	setDepth(root, 0);
	setHeight(root);
	for (int i = 0; i < n; i++)print(i);
	return 0;
}

Measured memory_bytes: 3164
def ind(S):
  L4=list()
  for i in range(len(S)):
    if S[len(S)-i-1]=="1":
      L4.append(i)
  return set(L4)
N=int(input())
L=list(map(int,input().split()))
L=[ind(bin(i)[2:]) for i in L]
ans=0
n=0
i=0
T=set()
while True:
  if i==N and n==N:
    break
  elif i==N:
    ans+=i-n
    n+=1
    continue
  if T&L[i]==set():
    T=T|L[i]
    ans+=1
    i+=1
  else:
    T=T-L[n]
    n+=1
    ans+=i-n
  if i==N and n!=N:
    n+=1
print(ans)

Measured memory_bytes: 176448
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a = Array.fill(n)(sc.nextInt)
  val sorted = a.sorted
  val last1 = sorted(n-1)
  val last2 = sorted(n-2)
  // printlnからPrintWriter利用に変えてみただけ
  val pw = new java.io.PrintWriter(System.out)
  a.foreach(i => pw.println(calc(i)))
  pw.flush()
  
  def calc(i: Int): Int = if (i == last1) last2 else last1
}

Measured memory_bytes: 61344
import copy
n=int(input())
p=[]
ps=[]
cnt=0
p = list(map(int, input().split()))
pn=copy.deepcopy(p)
ps=p
ps.sort()
for i in range(n):
    if ps[i]!=pn[i]:
        cnt=cnt+1
        if cnt==3:
            break
if cnt==0 or cnt==1 or cnt==2:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3444
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int n,s;
  vector<int> ss;
  while(1){
    cin>>n;
    //    cout<<"::"<<n<<endl;
    if(n==0)break;
    ss.clear();
    int i,j,k;
    for(i=0;i<n;i++){
      cin>>s;
      ss.push_back(s);
    }
    sort(ss.begin(),ss.end());
    int re=0;
    for(i=1;i<ss.size()-1;i++)
      re+=ss[i];
    re/=ss.size()-2;
    cout<<re<<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,m,a[100000],mi,dec[100000] = {},add[100000] = {},ans = 0;
	cin >> n >> m;
	for(int i = 0;i < n;i++){
		cin >> a[i];a[i]--;
		if(i){
			ans += min((a[i] + m - a[i - 1]) % m,1 + a[i] % m);
			dec[a[i - 1] + 1]++;
			dec[a[i] + 1]--;
			add[a[i] + 1] += (a[i] + m - a[i - 1]) % m;
			if(a[i] < a[i - 1]) dec[0]++;
		}
	}
	for(int i = 1;i < m;i++) dec[i] += dec[i - 1];
	mi = ans;
	for(int i = 1;i < m;i++){
		ans -= dec[i - 1];
		ans += add[i];
		mi = min(mi,ans);
	}
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <queue>
#define rep(i, n) for (int i = 0;i < (n); i++)
using namespace std;


int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> q;
    rep(i, n) {
        int a;
        cin >> a;
        q.push(a);
    }    
    rep(i, m) {
        int a = q.top(); q.pop();
        q.push(a/2);
    }
    long long ans = 0;
    rep(i, n) {
        ans += q.top(); q.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	for (int i=1;n>i;i++){
		string s;
		cin>>s;
		if (s=="Y"){
			cout<<"Four"<<endl;
			break;
			}
		if (n==i+1 && s!="Y"){
			cout<<"Three"<<endl;
			}
		}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a;
    int b;
    cin >> a;
    cin >> b;

    if(a==0){
        if(b==100){
            cout << 101 << endl;
        }else{
        cout << 1 * b << endl;
        }
    }else if(a==1){
        if(b==100){
            cout << 10100 << endl;
        }else {
            cout << 100 * b << endl;
        }
    }else if(a==2){
        if(b==100){
            cout << 1010000 << endl;
        }else {
            cout << 10000 * b << endl;
        }
    }

        return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

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

	private static void solve() {
		Scanner scn = new Scanner(System.in);
		PrintWriter pr = new PrintWriter(System.out);
		int N = scn.nextInt();
		int x,y;
		int maxx,maxy;
		for(int k=0;k<N;k++){
			maxx=0;
			maxy=0;
			x=0;
			y=0;
			while(true){
				int tmpx=scn.nextInt();
				int tmpy=scn.nextInt();
				if(tmpx==0&&tmpy==0){
					break;
				}
				x+=tmpx;
				y+=tmpy;
				if(maxx*maxx+maxy*maxy<x*x+y*y||(maxx*maxx+maxy*maxy==x*x+y*y&&maxx<x)){
					maxx=x;
					maxy=y;
				}
			}
			pr.println(maxx+" "+maxy);
		}
		pr.flush();
		scn.close();
	}

}

Measured memory_bytes: 33384
#include<iostream>

using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  char m[H][W];
  int dp[H][W];
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> m[i][j];
      dp[i][j] = 0;
    }
  }

  if(m[0][0]=='#'){
    dp[0][0] = 1;
  }

  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      int w=100000, h=100000;
      if(i==0 && j==0){
        continue;
      }

      if(0 < j){
        if(m[i][j]==m[i][j-1]){
          w = dp[i][j-1];
        }else{
          w = dp[i][j-1] + 1;
        }
      }
      
      if(0 < i){
        if(m[i][j]==m[i-1][j]){
          h = dp[i-1][j];
        }else{
          h = dp[i-1][j] + 1;
        }
      }

      dp[i][j] = min(h,w);
    }
  }

  if(m[H-1][W-1]=='#'){
    dp[H-1][W-1] += 1;
  }

  printf("%d\n", dp[H-1][W-1] / 2);
}


Measured memory_bytes: 3660
#include "bits/stdc++.h"

#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define ffor(i,a,b) for(ll i=(a);i<(ll)(b);++i)
#define rep(i, n) ffor(i,0,n)
#define All(obj) (obj).begin(),(obj).end()
#define INF ((ll)1e9+7)
#define c(a) cout<<a<<"\n";
using namespace std;
const int N = 100005;

int main() {
	speed;
	int n, m;
	cin >> n >> m;
	vector<int>ok(n + 1, true);
	rep(i, n) {
		int a;
		cin >> a;
		ok[a] = false;
		//true なら踏める段
	}
	vector<ll>dp(n + 1);
	dp.at(0) = 1;
	rep(now, n) {
		ffor(next, now + 1, min(n, (int)now + 2) + 1) {
			if (ok[next]) {
				dp[next] += dp[now];
				dp[next] %= INF;
			}
		}
	}
	c(dp[n]);
	ed;
	return 0; 
}



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

int main() {
    string s;
    cin >> s;
    int64_t ans = 0;
    int64_t cnt_white = 0;
    for (int i = (int)s.size() - 1; i >= 0; i--) {
        if (s.at(i) == 'W') cnt_white++;
        else ans += cnt_white;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
from __future__ import print_function

import sys
input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


# import re
# import array
# import copy
# import functools
# import operator

# import math
# import string
# import fractions
# from fractions import Fraction
from fractions import gcd

# import collections
# import itertools
# import bisect

# import heapq
# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace
# from queue import PriorityQueue as pq
from queue import Queue

# from itertools import accumulate

# from collections import deque
# from collections import Counter

# from operator import mul
# from functools import reduce

# def lcm(n,m):
#     return int(n*m/gcd(n,m))

# def reduce(p, q):
#     common = fractions.gcd(p, q)
#     return (p//common , q//common )

# def combinations_count(n, r):
#     r = min(r, n - r)
#     numer = reduce(mul, range(n, n - r, -1), 1)
#     denom = reduce(mul, range(1, r + 1), 1)
#     return numer // denom


# import random
# import time
def crange(a, b, i):
    return range(a, b + 1, i)


def main():
    n, m = map(int, input().strip().split())
    a = [input().strip() for _ in range(n)]
    b = [input().strip() for _ in range(m)]
    n, m = (lambda x, y: (x - 1, y - 1))(n, m)
    eprint("n,m ", end=": ")
    eprint(n,m)
    # success_flag = 0
    ii, jj, colx, rowx = 0, 0, 0, 0
    for i in crange(0, n - m, 1):
        for j in crange(0, n - m, 1):
            failure_flag = 0
            for col in crange(0, m, 1):
                for row in crange(0, m, 1):
                    if a[i+col][j+row] != b[col][row]:
                        failure_flag = 1
                        ii, jj, colx, rowx = i, j, col, row
            if failure_flag == 0:
                print("Yes")
                eprint("ii,jj,colx,rowx ", end=": ")
                eprint(ii, jj, colx, rowx)
                return
    print("No")
    eprint("ii,jj,colx,rowx ", end=": ")
    eprint(ii, jj, colx, rowx)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 67948
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <iomanip>
#include <deque>
#include <cassert>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <chrono>
#include <ctime>
#include <random>
#include <stack>
using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
#define INF 2001001001
#define MOD 1000000007

int H,W,A,B;
int used[1001];
int ans[1001][1001];

int main()
{
  //ios_base::sync_with_stdio(0);cin.tie(0);
  //freopen (".in","r",stdin);
  //freopen (".out","w",stdout);
  cin>>H>>W>>A>>B;
  for (int i=0;i<=H;i++){ //number of rows with A
    int ones=i*A+(H-i)*(W-A);
    for (int j=0;j<=W;j++){
      if ((ones-B*j)==(W-j)*(H-B)){
	//answer found
	for (int k=0;k<W;k++)
	  if (k<j)
	    used[k]=B;
	  else
	    used[k]=H-B;
	for (int k=0;k<H;k++){
	  vector<pair<int,int>>v;
	  for (int l=0;l<W;l++)
	    v.push_back({-used[l],l});
	  sort(v.begin(),v.end());
	  int temp=A;
	  if (k>=i) temp=W-A;
	  for (int l=0;l<temp;l++){
	    ans[k][v[l].second]=1;
	    used[v[l].second]--;
	  }
	}
	for (int i=0;i<W;i++){
	  int cnt=0;
	  for (int j=0;j<H;j++)
	    if (ans[j][i]==1)
	      cnt++;
	  if (min(cnt,H-cnt)!=B){
	    assert(0);
	    return 0;
	  }
	}
	for (int i=0;i<H;i++){
	  for (int j=0;j<W;j++)
	    cout<<ans[i][j];
	  cout<<endl;
	}
	return 0;
      }
    }
  }
  cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 5120
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    n = NI()
    m = n.bit_length()+1
    root = [[-1] * n for _ in range(m)]
    rev = [0] * n
    depth = [0] * n
    for i in range(n):
        x = LI()
        for a in x[1:]:
            root[0][a] = i
            depth[a] = depth[i] + 1
    for k in range(1,m):
        for i in range(n):
            root[k][i] = root[k-1][root[k-1][i]]

    q = NI()
    for _ in range(q):
        u,v = LI()
        if depth[u] < depth[v] : u,v = v, u
        d = depth[u] - depth[v]
        bit = 1
        for i in range(d.bit_length()):
            if d & bit: u = root[i][u]
            bit <<= 1

        j = depth[u].bit_length() - 1
        while j >= 0:
            if root[j][u] != root[j][v]:
                u = root[j][u]
                v = root[j][v]
            j -= 1
        if u == v:
            print(u)
        else:
            print(root[0][u])

if __name__ == '__main__':
    main()


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

const int MAX_N = 1e5+2;
int N, M;
int a[MAX_N], b[MAX_N];

struct inter{
	int st, ed;
	inter(int s, int t) : st(s), ed(t) {}
	bool operator < (const inter& other) const
	{
		return (ed != other.ed) ? ed < other.ed : st < other.st;
	}
};

void solve()
{
	vector<inter> A;
	for(int i=0;i<M;++i) A.emplace_back(a[i], b[i]);
	sort(A.begin(), A.end());
	int ans = 1;
	int cut = A[0].ed;
	for(int i=1;i<(int)A.size();++i){
		if(A[i].st < cut) continue;
		else{
			ans++;
			cut = A[i].ed;
		}
	}
	cout << ans << '\n';
}

int main()
{
	cin >> N >> M;
	for(int i=0;i<M;++i) cin >> a[i] >> b[i];
	solve();
	return 0;
}

Measured memory_bytes: 5068
# -*- coding: utf-8 -*-
"""
Created on Sat Mar  9 22:21:07 2019

@author: yuta
"""

NM = list(map(int,input().split()))
N = NM[0]
M = NM[1]
AB = [list(map(int,input().split())) for _ in range(N)]

def main(n,m,ab):
    ab.sort(key=lambda x:x[0])
    count = 0
    price = 0
    for i in range(n):
        for j in range(ab[i][1]):
            if count == m:
                break
            else:
                price += ab[i][0]
                count += 1
    print(price)
main(N,M,AB)

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

using namespace std;

typedef long long int ll;

const ll inf = 1e9;

ll n, m, q;
vector < ll > a, b, c, d, v;
ll ans = LLONG_MIN;

void solve(ll idx, ll prev){
  if(idx == n + 1){
    ll sum = 0;
    for(int i = 0; i < q; i++){
      if(v[b[i]] - v[a[i]] == c[i]) sum += d[i];
    }
    ans = max(ans, sum);
    return;
  }

  for(int i = prev; i <= m; i++){
    v[idx] = i;
    solve(idx + 1, i);
  }
}

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

  cin >> n >> m >> q;
  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);
  v.resize(n + 1);
  for(int i = 0; i < q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];

  solve(1, 1);

  cout << ans << endl;
}


Measured memory_bytes: 3632
// #include<bits/stdc++.h>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<deque>
#include<cmath>
#include<cstdio>
#include<bitset>
#include<string>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

typedef long long ll;
typedef pair<int ,int> P;

const int INF  = 0x3f3f3f3f;
const int MAXN = 1e6+7;


int main(){
        // freopen("../in.txt","r",stdin);
        // freopen("../out.txt","w",stdout);
        ios::sync_with_stdio(0);
        cin.tie(0);
        int a,b;
        cin>>a>>b;
        cout<<max(max(a+b,a-b),a*b)<<endl;

        return 0;
}


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

int main(){
  int N = 0, M = 0, c = 0, a = 0, ans;
  cin >> N >> M;
  rep(i, M){
    cin >> a;
    c += a;
  }
  if(N < c) ans = -1;
  else{
    ans = N-c;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char in[120];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%s",in);printf("%s\n%s\n",in,in);
	}
}

Measured memory_bytes: 128