akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
typedef long long ll;

const int NUMS[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    rep(i, M) cin >> A[i];
    sort(A.begin(), A.end());

    bool dp[N/2+1][N+50] = {false};
    dp[0][0] = true;

    rep(i, N/2) {
        rep(j, N+1) {
            if(!dp[i][j]) continue;
            rep(k, M) {
                dp[i+1][j+NUMS[A[k]]] = true;
            }
        }
    }

    int len = 0;
    rep(i, N/2+1) {
        if(dp[i][N]) len = max(len, i);
    }

    string res = "";
    for(int i=len; i>0; i--) {
        int a = 0;
        rep(j, M) {
            
            if(N-NUMS[A[j]] >= 0 && dp[i-1][N-NUMS[A[j]]]) a = max(a, A[j]);
        }
        res += (a + '0');
        N -= NUMS[a];
    }

    cout << res << endl;
    return 0;


}

Measured memory_bytes: 49280
def solve():
  while True:
    h,w,n = map(int,input().split())
    if not h: break
    sss = [[1 if s == "1" else 0 for s in input().split()] for i in range(h)]
    dp = [[0 for i in range(w + 1)] for j in range(h + 1)]
    dp[0][0] = n - 1
    for x in range(h):
      for y in range(w):
        a = dp[x][y]
        b = sss[x][y]
        if b:
          if a % 2:
            dp[x + 1][y] += a // 2
            dp[x][y + 1] += a // 2 + 1
          else:
            dp[x + 1][y] += a // 2
            dp[x][y + 1] += a // 2
        else:
          if a % 2:
            dp[x + 1][y] += a // 2 + 1
            dp[x][y + 1] += a // 2
          else:
            dp[x + 1][y] += a // 2
            dp[x][y + 1] += a // 2
        sss[x][y] = (a + b) % 2
  
  #  print(sss)
  #  print(dp)
    x = y = 0
    while x < h and y < w:
      if sss[x][y]:
        y += 1
      else:
        x += 1
    print(x + 1,y + 1)
  #  print(sss)
solve()


Measured memory_bytes: 30336
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	string a="";
	for(int i=0;i<s.length();i++)
	{
	    if(s[i]=='0'||s[i]=='1') a=a+s[i];
	    int x=a.length()-1;
	    if(s[i]=='B') a=a.substr(0,max(0,x));
	}
	cout<<a;
	return 0;
}

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

int main(){
  int N,i,j,A[100],minj,temp,count=0;

  scanf("%d",&N);
  //constraint
  if(N<1 || N>100){
    exit(1);
  }

  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
    //constraint
    if(A[i]<0 || A[i]>100){
      exit(8);
    }
  }
 
  //selection sort
  for(i=0;i<=N-2;i++){
    minj=i;

    for(j=i;j<=N-1;j++){
      if(A[j]<A[minj]){
	minj=j;
      }
    }

    temp=A[i];
    A[i]=A[minj];
    A[minj]=temp;

    if(i!=minj){
      count++;
    }
  }
  
  for(i=0;i<N-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[N-1]);

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

Measured memory_bytes: 600
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main(){
	int N,A,i;
	int even=0,odd=0,evsla,odsla,evan=0,odan=0;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&A);
		if(A%2==0) even++;
		else odd++;
	}
	while(even>1 || odd>1){
		if(odd>=2){
			odd-=2;
			even++;
		}
		if(even>=2){
			even--;
		}
	}
	//printf("%d %d",even,odd);
	if((even+odd)%2==1) printf("YES\n");
	else printf("NO\n");
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
	char ch=getchar();int f=0;
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9')
	{f=(f<<1)+(f<<3)+ch-'0';
	ch=getchar();}
	return f;
}
int a[1000002],head=500000,tail=500000;
int main()
{
	int n=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
	}
	if(n%2==0)
	{
		for(int i=n;i>=1;i-=2)
		printf("%d ",a[i]);
		for(int i=1;i<=n;i+=2)
		printf("%d ",a[i]);
	}
	else
	{
		for(int i=n;i>=1;i-=2)
		printf("%d ",a[i]);
		for(int i=2;i<=n;i+=2)
		printf("%d ",a[i]);
	}
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int n, cnt[110],maxi;
void no() {
	puts("Impossible");
	exit(0);
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		maxi = max(maxi, x);
		cnt[x]++;
	}
	int m = maxi + 1;
	if (m == 2) {
		if (cnt[1] != 2) no();
	}
	else {
		int mini = m / 2;
		for (int i = 1; i < mini; i++) if (cnt[i]) no();
		if (m & 1) {
			if (cnt[mini] != 1) no();
		}
		else if (cnt[mini] != 2) no();
		for (int i = mini + 1; i <= maxi; i++) if (cnt[i] < 2) no();
	}
	puts("Possible");
	return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    N = int(input())
    DIC = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
    for _ in range(N):
        S = input()
        DIC[S] += 1

    for k, v in DIC.items():
        print(f'{k} x {v}')



Measured memory_bytes: 9136
/**
 *      ABC 46 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-20 07:20:30
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, c; cin >> a >> b >> c;
    if (a == b && b == c){
        cout << 1 << endl;
    }
    else if ((a == b || b == c) || c == a){
        cout << 2 << endl;
    }
    else {
        cout << 3 << endl;
    }
    return 0;
}


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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

//#define _USE_MATH_DEFINES
//#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef int long long i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 1000000007; // 10000000000000007ll;

const double eps = 1e-8;

const i64 MAXN = 1'000'000 + 6;

i64 n;
i64 a[MAXN] = { 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 };

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n;
    cout << a[n - 1] << endl;

    return 0;
}

Measured memory_bytes: 256
//😄😄😄😄😄😄😄😄😄😄😄😄😄
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define For(i,a,b) for(int i=a;i<b;i++)
#define debug(x) cout<<"DEBUG------> "<<x<<endl
#define endl "\n"

int main() {
	int arr[5];
	For(i, 0, 5) {
		cin >> arr[i];
	}
	For(i, 0, 5) {
		if (arr[i] == 0) {
			cout << i + 1 << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, x, y;
    cin >> n >> x >> y;
    --x, --y;
    vector <int> ans(n);
    for (int i = 0; i < n; i++) {
        vector <int> d(n, INF);
        queue<int> q;
        d[i] = 0;
        q.push(i);
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            vector <int> to;
            if (v + 1 < n) to.pb(v + 1);
            if (v) to.pb(v - 1);
            if (v == x) to.pb(y);
            if (v == y) to.pb(x);
            for (int V : to) {
                if (d[V] == INF) {
                    d[V] = d[v] + 1;
                    q.push(V);
                }
            }
        }
        for (auto &i : d) ++ans[i];
    }
    for (int i = 1; i < n; i++) {
        cout << ans[i] / 2 << '\n';
    }
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
int main(){
    int n;
    ll ans=0;
    cin>>n;
    vector<int> a(n),b(n),c(n);
    rep(i,n)cin>>a[i];
    rep(j,n)cin>>b[j];
    rep(k,n)cin>>c[k];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    rep(j,n){
        auto itra=lower_bound(a.begin(),a.end(),b[j]);
        auto itrc=upper_bound(c.begin(),c.end(),b[j]);
        ans+=(itra-a.begin())*(c.end()-itrc);
    }
    cout<<ans<<endl;
    }

Measured memory_bytes: 4580
/**
 *      ABC 80 C    //bit 全探索
 *      author  : kyomukyomupurin
 *      created : 2018-09-26 08:47:06
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    int F[N][10] = {};
    for (auto i = 0; i < N; ++i) {
        for (auto j = 0; j < 10; ++j) {
            cin >> F[i][j];
        }
    }

    int P[N][11] = {};
    for (auto i = 0; i < N; ++i) {
        for (auto j = 0; j < 11; ++j) {
            cin >> P[i][j];
        }
    }

    int answer = -(1<<30);

    for (auto bit = 1; bit < (1<<10); ++bit) {
        int cost = 0;
        for (auto i = 0; i < N; ++i) {
            int c = 0;
            for (auto j = 0; j < 10; ++j) {
                if ((bit >> j & 1) && F[i][j]){
                    ++c;
                }
            }
            cost += P[i][c];
        }
        if (cost > answer){
            answer = cost;
        }
    }

    cout << answer << '\n';
    return 0;
}



Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]

from fractions import gcd

L = [0] * (N + 1)
for i in range(N):
    L[i + 1] = gcd(L[i], A[i])

R = [0] * (N + 1)
for i in range(N - 1, -1, -1):
    R[i] = gcd(R[i + 1], A[i])

print(max(gcd(l, r) for l, r in zip(L[:N], R[1:])))


Measured memory_bytes: 14056
n = gets(chomp:true).to_i
a = gets.split.map(&:to_i)
gets
m = gets.split.map(&:to_i)

def solve(i, n, a, m)

  # 返り値処理
  # 組み合わせてmから引いた答えが0ならばtrue
  if m == 0
    return true
  end

  # 再帰回数がa配列のサイズn以上になったらfalse
  if i >= n
    return false
  end
  # 返り値処理

  # dig処理
  # 左値を引かなかった場合、右値を引いた場合
  # orになっているので1回でもtrueが返ればtrue
  res = solve(i + 1, n, a, m) || solve(i + 1, n, a, m-a[i])
  return res
  # dig処理
end

m.each{|value| puts solve(0, n, a, value) ? "yes" : "no"}


Measured memory_bytes: 8896
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll K;
  cin >> K;
  ll all = K / 50;
  vector<ll> ans(50);
  for (ll i = 0; i < K % 50; ++i) {
    ans.at(i) = 50 - (K % 50) + i + 1 ;
  }
  ll cnt = 0;
  for (ll i = K % 50; i < 50; ++i) {
    ans.at(i) = cnt;
    cnt += 1;
  }
  for (ll i = 0; i < 50; ++i) {
    ans.at(i) += all;
  }
  cout << 50 << "\n";
  for (ll i = 0; i < 50; ++i) {
    cout << ans.at(i) << " ";
  }
  cout << "\n";
}


Measured memory_bytes: 256
#include<cstdio>
int main(){
	int h,w;
	scanf("%d%d",&h,&w);
	int a[h+2][w+2]={};
	for(int i=0;i<h;i++){
		char s[w+1];
		scanf("%s",s);
		for(int j=0;j<w;j++){
			if(s[j]=='#')a[i+1][j+1]=1;
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(a[i][j]==1){
				printf("#");
			}else{
				printf("%d",a[i-1][j-1]+a[i-1][j]+a[i-1][j+1]+a[i][j-1]+a[i][j+1]+a[i+1][j-1]+a[i+1][j]+a[i+1][j+1]);
			}
		}
		printf("\n");
	}
	return 0;
}
			 

Measured memory_bytes: 128
ans = []
word = []
shuffle = []
while True:
  s = input()
  if s == "-":
    break
  word.append(s)
  m = int(input())
  shuffle.append([int(input()) for i in range(m)])
for i, j in zip(word, shuffle):
  for k in j:
    i = i[k:] + i[:k]
  ans.append(i)
for out in ans:
  print(out)


Measured memory_bytes: 5604
#include <stdio.h>
int n, arr[200001];
int main(void) {
	int i, num;
	scanf("%d", &n);
	for(i=1; i<n; i++){
		scanf("%d", &num);
		arr[num]++;
	}
	for(i=1; i<=n; i++)	
		printf("%d\n", arr[i]);
	return 0;
}

Measured memory_bytes: 2464
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int A[101] = {0};

int main()
{
	int N = 0, i = 0;
	double ans = 0.0;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	for (i = 0; i < N; i++) {
		ans += 1.0/(double)A[i];
	}
	printf("%f\n", 1.0/ans);
    return 0;
}


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

int main() {
	
	int n , m[12] = {} ;
	
	while( cin >> n ){
		if( cin.eof() ) break ;
		if( n==0 ){
			for( int i=11 ; i>=0 ; i-- ){
				if( m[i] != 0 ){
					cout << m[i] << endl ;
					m[i] = 0 ;
					break ;
				}
			}
		}
		else {
			for( int i=0 ; i<12 ; i++ ){
				if( m[i] == 0 ){
					m[i] = n ;
					break ;
				}
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 1e2+5;

bool judge(int n,string s){
	for(int i = 0;i < n/2;++i){
		if(s[i] != s[i+n/2]) return 0;
	}
	return 1;
}

int main()
{
    int n;
    string s;
    scanf("%d",&n);
    cin >> s;
    if((n&1) || !judge(n,s)) printf("No\n");
    else printf("Yes");
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);

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

  int n;
  cin >> n;

  int a = 0, w = 0, t = 0, r = 0;
  rep(i, n) {
    string s;
    cin >> s;
    if (s == "AC") a++;
    else if (s == "WA") w++;
    else if (s == "TLE") t++;
    else if (s == "RE") r++;
    else throw 1;
  }

  printf("AC x %d\n", a);
  printf("WA x %d\n", w);
  printf("TLE x %d\n", t);
  printf("RE x %d\n", r);

  return 0;
}


Measured memory_bytes: 3748
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;
const int MOD = 1000000007;

int main() {
	int n;
	int c[] = {5, 7, 5, 7, 7};
	while (cin >> n, n) {
		vs w(n);
		REP(i, n) {
			cin >> w[i];
		}
		int ans = -1;
		REP(i, n) {
			int p = 0, t = 0;
			FOR(j, i, n - 1) {
				t += w[j].size();
				if (t == c[p]) {
					if (p == 4) {
						ans = i+1;
						break;
					}
					else {
						p++;
						t = 0;
					}
				}
				else if (t > c[p]) {
					break;
				}
			}
			if (ans != -1) {
				break;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3136
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;

	void solve() {
		int n = readNum();
		int[] ia = new int[n];
		for (int i = 0; i < n; i++) {
			ia[i] = readNum();
		}
		int ans = 0;
		int cur = 1;
		while (cur != 2) {
			int next = ia[cur - 1];
			if (next == 0) {
				pln(-1);
				return;
			}
			ans++;
			ia[cur - 1] = 0;
			cur = next;
		}
		pln(ans);
	}

	// -----------------------------------------------------
	// 2018/04/25 r1
	// -----------------------------------------------------
	int abs(int a) {
		return (a >= 0) ? a : -a;
	}

	long abs(long a) {
		return (a >= 0) ? a : -a;
	}

	int max(int a, int b) {
		return (a > b) ? a : b;
	}

	long max(long a, long b) {
		return (a > b) ? a : b;
	}

	int min(int a, int b) {
		return (a < b) ? a : b;
	}

	long min(long a, long b) {
		return (a < b) ? a : b;
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	long readLong() {
		String line = readLine();
		return plong(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++)
			nums[i] = pint(flds[i]);
		return nums;
	}

	long[] readLongs() {
		String[] flds = readFlds();
		long[] nums = new long[flds.length];
		for (int i = 0; i < flds.length; i++)
			nums[i] = plong(flds[i]);
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;
	static boolean _bElapsed = false;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (_bElapsed)
			System.err.println((end - start) + "ms");
	}
}


Measured memory_bytes: 33964
from sys import stdin
import math
import fractions
from collections import deque

INF = 10 ** 10

N = int(stdin.readline().rstrip())


ans = 0
for k in range(1, int(math.sqrt(N+1))):
    if N % k == 0:
        # N = k(m+1) で表すことができる ...よってkはNの約数で、N^0.5以下のもの
        # m = N/k-1
        ans += ((N//k)-1)

print(ans)


Measured memory_bytes: 66156
#include<bits/stdc++.h>
using namespace std;
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define mod		1000000007
#define inf     1000000000000000000
#define MX1		100005
#define MX2		10000004
#define pi		acos(-1)
#define pb      push_back
#define vlli    vector<lli>
#define plli    vector<pair<lli,lli> >
#define mp      make_pair
#define all(v)  v.begin(),v.end()
#define setbits(n) __builtin_popcount(n)
#define test    int t;cin>>t;
lli gcd(lli a, lli b){return b?gcd(b,a%b):a;}
lli power(lli a,lli b){lli ans=1;while(b){if(b&1){ans=(ans*a)%mod;}a=(a*a)%mod;b>>=1;}return ans;}
int main()
{
	opt;
	lli i,j,k,l;
	lli n;
	cin>>n;
	vlli v;
	lli ar[100005]={0};
	for(i=0;i<n;i++)
	{
		cin>>j;
		ar[j]++;
	}
	k=0;
	for(i=0;i<100000;i++)
	{
		k=max(k,ar[i]+ar[i+1]+ar[i+2]);
	}	
	cout<<k<<"\n";
	return 0;
}


Measured memory_bytes: 1024
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

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

const int N=100000+10;

int n; char s[N];

int main() {
	scanf("%s",s+1); n=strlen(s+1);
	if (s[1]==s[n]) {
		if (n&1) puts("Second");
		else puts("First");
	} else {
		if (n&1) puts("First");
		else puts("Second");
	}
	return 0;
}

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

#define MAX_DATA_NUM      100

static void Exchange_Void(int *pSortBuff, int insert, int key );

int main(void)
{
    int data_num;			/* Data Num */
	int cd;					/* Count Data */
	int key = 0;			/* Compare Num */
	int pSortBuff[MAX_DATA_NUM];
	int insert;
	int loop;
 //	int pSortBuff[6] = {5, 2, 4, 6, 1, 3};
   
 //   pSortBuff = (int *)malloc(sizeof(int) * MAX_DATA_NUM);
    /* get "Data Num" */
    scanf("%d", &data_num);
     
    /* get Name & time */
    while((scanf("%d", &(pSortBuff[cd])) != EOF) && cd < MAX_DATA_NUM)
    {
        cd++;
    }
    
	
    /* get Data Num equal process num */
    if( data_num == cd )
    {
         while(key < data_num)
        {
        	if(key>0)
        	{
        		insert = -1;
	        	for(loop=key-1; loop>=0; loop--)
	        	{
	        		if(pSortBuff[loop] > pSortBuff[key])
	        		{
	        			insert = loop;
	        		}
	        	}
        		if(insert != -1)
        		{
        			Exchange_Void(pSortBuff, insert, key);
        		}
        	}
        	// print
			for(loop=0; loop<data_num-1; loop++)
			{
				printf("%d ", pSortBuff[loop]);
			}
        	printf("%d\n", pSortBuff[data_num-1]);
			key++;
        }
    }
    else
    {
        /* error input */
    }
//	free(pSortBuff);
    return 0;
}

static void Exchange_Void(int *pSortBuff, int insert, int key )
{
	int swap;
	int loop;
	
	swap = pSortBuff[key];
	
	for(loop=key; loop>insert; loop--)
	{
		pSortBuff[loop] = pSortBuff[loop-1];
	}
	pSortBuff[insert] = swap;
}

Measured memory_bytes: 1812
import java.io.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int[] p = new int[N];
        for (int i = 0; i < N; i++) {
            p[i] = scan.nextInt();
        }
        int count = 0;
        for (int i = 0; i < N; i++) {
            if (p[i] != i + 1) {
                count++;
            }
        }
        if (count <= 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
        scan.close();
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rp1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define rp0(i,n) for ((i)=0;(i)<(n);(i)++)
using namespace std;
const int mod=998244353;
int n,q,f[800005],tag[800005],s[800005],lst=1;
void build(int x,int l,int r){
	tag[x]=0;if(l==r){
		f[x]=s[x]=lst;lst=10ll*lst%mod;
		return;
	}
	int mid=(l+r)/2;build(x+x+1,mid+1,r);build(x+x,l,mid);
	s[x]=f[x]=(f[x+x]+f[x+x+1])%mod;
}
void update(int x,int l,int r,int ll,int rr,int c){
	if(ll<=l&&r<=rr){
		tag[x]=c;s[x]=1ll*f[x]*c%mod;
		return;
	}
	if(tag[x]){
		tag[x+x]=tag[x+x+1]=tag[x];
		s[x+x]=1ll*f[x+x]*tag[x]%mod;
		s[x+x+1]=1ll*f[x+x+1]*tag[x]%mod;
		tag[x]=0;
	}
	int mid=(l+r)/2;
	if(ll<=mid)update(x+x,l,mid,ll,rr,c);
	if(rr>mid) update(x+x+1,mid+1,r,ll,rr,c);
	s[x]=(s[x+x]+s[x+x+1])%mod; 
}
int main(){
	cin>>n>>q;int i;
	build(1,1,n);
	rp0(i,q){
		int l,r,d;
		cin>>l>>r>>d;update(1,1,n,l,r,d);
		cout<<s[1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 9684
/**
    __author__ : srv_twry
**/

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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}

bool ge(const ll& a, const ll& b) { return a >= b; }
bool le(const ll& a, const ll& b) { return a <= b; }
bool eq(const ll& a, const ll& b) { return a == b; }
bool gt(const ll& a, const ll& b) { return a > b; }
bool lt(const ll& a, const ll& b) { return a < b; }
int sgn(const ll& x) { return le(x, 0) ? eq(x, 0) ? 0 : -1 : 1; }
/*----------------------------------------------------------------------*/

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
	int n; cin>>n; cout<<n*n*n;

    return 0;
}

Measured memory_bytes: 892
fun main(args : Array<String>) {
    val x = readLine()!!.toInt()

    if (x < 100) {
        println(0)
        return
    }

    val d2 = x.toString().takeLast(2).toInt()
    val cnt = (x - d2) / 100

    val items = d2 / 5 + (if (d2 % 5 == 0) 0 else 1)

    println(if (cnt >= items) 1 else 0)
}

Measured memory_bytes: 33808
#include <bits/stdc++.h>
#define sz(x) (int((x).size()))
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
template<typename T> bool domax(T &a, T b) { return (b > a ? (a = b, true) : false); }
template<typename T> bool domin(T &a, T b) { return (b < a ? (a = b, true) : false); }
typedef long long ll;

const int maxn = 100*1000+5;

ll n, ans[maxn], bns[maxn];
int q;
std::vector<ll> v;
std::map<ll,ll> mult;

int main() {
    scanf("%lld%d", &n, &q);
    v.pb(n);
    for (int i = 0; i < q; i++) {
        ll x; scanf("%lld", &x);
        while (!v.empty() && v.back() >= x) v.pop_back();
        v.pb(x);
    }
    std::set<ll> todo;
    todo.insert(v.back());
    mult[v.back()]++;
    int k = sz(v) - 1;
    while (!todo.empty()) {
        ll x = *todo.rbegin(), y = mult[x];
        todo.erase(x);
        if (x <= v[0]) ans[x] += y;
        else {
            while (v[k] >= x) k--;
            if (v[k] == x) k--;
            ll z = x / v[k];
            todo.insert(v[k]);
            mult[v[k]] += y*z;
            todo.insert(x % v[k]);
            mult[x % v[k]] += y;
        }
    }
    ll sum = 0;
    for (int i = n; i >= 1; i--) {
        sum += ans[i];
        bns[i] = sum;
    }
    for (int i = 1; i <= n; i++) printf("%lld\n", bns[i]);
}


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

int main(){
  int n;
  cin >> n;
  
  int ans = 0;
  for (int i=1 ; i<=n ; i++){
    if (i/10 == 0)
      ans++;
    else if (i/100 != 0 && i/1000 == 0)
      ans++;
    else if (i/10000 != 0 && i/100000 == 0)
      ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int main(){
  long ii,jj,kk;
  vector<int> ret;
  deque<int> deq;

  int q,c,d,x;
  cin >> q;

  for(ii=0;ii<q;ii++){
    cin >> c;

    if(c==0){
      cin >> d >> x;
      if(d==0){
        //deq.insert(deq.begin(),x);
        deq.push_front(x);
      }
      else{
        deq.push_back(x);
      }
    }
    else if(c==1){
      cin >> d;
      cout << deq[d] << endl;
    }
    else{
      cin >> d;
      if(d==0){
        deq.pop_front();
      }
      else{
        deq.pop_back();
      }
    }
  }
  
  return 0;
}



Measured memory_bytes: 4680
N = int(input())
n = len(str(N))
 
if n==1:
	print(N)
else:
	M = [9,0]*(n//2)			#list[9,0]がn//2個繋がっている
	M.pop()						#pop()でlistの最後尾を削除
	M = map(str,M)				#joinの際には文字列しか使えないのでstrを使用
	M = int(''.join(M))			#join(M)=90909みたいな。それを数字化
	if n%2==0:
		print(M)
	else:
		M = M + N - 10**(n-1) + 1
		print(M)

Measured memory_bytes: 3060
n = int(input())
p = list(map(float,input().split()))
dp = [[0 for x in range(n+1)] for x in range(n+1)]
dp[0][0] = 1
for y in range(n):
    for x in range(n):
        dp[y+1][x] += dp[y][x]*(1-p[y])
        dp[y+1][x+1] += dp[y][x]*p[y]
print(sum(dp[n][n//2+1:n+1]))


Measured memory_bytes: 257672
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF   = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

void solve()
{
    LL N, A, B;
    cin >> N >> A >> B;

    LL div = N / (A + B);
    LL mod = N % (A + B);

    cout << div * A + min(mod, A) << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		TreeMap<Long, Integer> map = new TreeMap<>();
			for(int i = 0 ; i < N ; i++){
				long cost = sc.nextLong();
				int num = sc.nextInt();
				//map.put(cost,num);
				//map.put(cost,map.containsKey(cost)?num+map.get(cost):num);

				if(map.containsKey(cost)){
					map.put(cost,num + map.get(cost));
				}else{
					map.put(cost,num);
				}


				//map.compute(cost, (k,v) -> v==null? num : num+v);
			}
			sc.close();


			long totalcost = 0;
			int bought = 0;

			for(Map.Entry<Long,Integer> kv : map.entrySet()){
				long cost = kv.getKey();
				int maxnum = kv.getValue();

				int buycount = Math.min(maxnum, M-bought);
				totalcost += buycount * cost;
				bought += buycount;

				if(bought > M){
					break;
				}
			}
			System.out.println(totalcost);
	}

}

Measured memory_bytes: 97620
N=int(input())
S=input()

#print(S)
#print(S[1:])
list1=[]

ST=S[1:].count("E")
list1.append(ST)
#print(list1)

for i in range(1,N):
    if S[i]=="E":
        ST=ST-1
    if S[i-1]=="W":
        ST=ST+1
    list1.append(ST)
#print(list1)
print(min(list1))

Measured memory_bytes: 15564
#include <bits/stdc++.h>
using namespace std;
bool to(int x){
  int i,j;
  bool k=false;
  for(i=1;i<10;i++){
    for(j=1;j<10;j++){
      if(x==i*j){
       k=true;
      }
    }
  }
return k;  
}

int main() {
  int a;
  cin >> a; 
  if(to(a)==true){
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
}

Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int a, b;
    String c;

    for(;;){
      a = sc.nextInt();
      c = sc.next();
      b = sc.nextInt();
      if("+".equals(c)){
        System.out.println(a + b);
      }else if("-".equals(c)){
        System.out.println(a - b);
      }else if("*".equals(c)){
        System.out.println(a * b);
      }else if("/".equals(c)){
        System.out.println(a / b);
      }else if("?".equals(c)){
          break;
      }
    }
/*fin*/
    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 18048
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>



int main() {
	int n; std::cin >> n;
	std::vector<int> score(n); for (auto& s : score) std::cin >> s;
	std::vector<bool> sum_score(10001, false); sum_score[0] = true;
	int max = 0;
	for (const auto s : score) {
		for (int i = 10000 - s; i >= 0; --i) if (sum_score[i]) {
			sum_score[i + s] = true;
			if ((i + s) % 10 != 0 && max < (i + s)) {
				max = i + s;
			}
		}
	}
	std::cout << max << std::endl;
}


Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    n = f.read_int()
    a = f.read_int_list()
    b = f.read_int_list()
    c = f.read_int_list()

    ans = sum(b)
    for i in xrange(n-1):
        if a[i]+1 == a[i+1]:
            ans += c[a[i]-1]
    return ans


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


Measured memory_bytes: 5020
import java.util.*;

public class Main {

    public static void main(String[] args) {
//        long startTime = System.currentTimeMillis();
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();

        String S = scanner.next();
        scanner.close();

        StringBuilder sb = new StringBuilder(S);
        StringBuilder sb2 = new StringBuilder(S.toLowerCase());

        sb.setCharAt(K-1,sb2.charAt(K-1));

        System.out.println(sb.toString());

//        System.out.println(System.currentTimeMillis() - startTime);
    }
}


Measured memory_bytes: 21844
package main

import (
	"fmt"
)

func main() {
	INF := 100000 * 10000
	var N, K int
	fmt.Scan(&N)
	fmt.Scan(&K)
	H := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&(H[i]))
	}

	dp := make([]int, N)
	for i := 0; i < N; i++ {
		dp[i] = INF
	}
	dp[0] = 0

	for i := 1; i < N; i++ {
		//dp[i] = (1..K).map{|k| i-k < 0 ? INF : dp[i-k] + (H[i] - H[i-k]).abs }.min
		value := INF
		for k := 1; k <= K; k++ {
			var tmp int
			if i-k < 0 {
				tmp = INF
			} else {
				tmp2 := H[i] - H[i-k]
				if tmp2 < 0 {
					tmp2 = tmp2 * -1
				}
				tmp = dp[i-k] + tmp2
			}

			if tmp < value {
				value = tmp
			}
		}
		dp[i] = value
	}

	fmt.Println(dp[N-1])
}


Measured memory_bytes: 5504
r,c=gets.split(" ").map(&:to_i)
h = Array.new(r+1).map{Array.new(c+1,0)} 

for i in 1..r  # 変数 i を1からrまで増やして繰り返し処理する。

a= gets.split.map(&:to_i)
    for j in 1..c
    h[i-1][j-1] = a[j-1]
    h[i-1][c] += a[j-1]
    h[r][j-1] += a[j-1]
    h[r][c] += a[j-1]
    end
end
for i in 0..r
    for j in 0..c
      print " " unless j == 0
      print h[i][j]
    end
    print "\n"
  end



Measured memory_bytes: 7032
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >>n;
    int count[4][3][10]={0};
    for(int i=0;i<n;i++){
        int x,y,z,w;
        cin >>x>>y>>z>>w;
        count[x-1][y-1][z-1]+=w;
    }
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                cout<<' '<<count[i][j][k];
            }
            cout<<endl;
        }
        if(i!=3) cout<<"####################"<<endl;
    }
}


Measured memory_bytes: 3104
#include <bits/stdtr1c++.h>

using namespace std;

#define INP "solve"
#define OUT "solve"

const int QQ = 3e5 + 10;
const int maxN = 5e5;
const int maxM = 3e5 + 10;
const int oo = 2e9;
const int module = 1e9 + 7;
const long double du = 1e-9;

void doc() {
    freopen(INP ".inp","r",stdin);
    freopen(OUT ".out","w",stdout);
}

void solve() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    int b[n];
    for (int i = 0; i < n; i++) cin >> b[i];
    int c[n];
    for (int i = 0; i < n; i++) cin >> c[i];
    int Res = b[a[0] - 1];
    for (int i = 1; i < n; i++) {
        if (a[i] - a[i - 1] == 1) Res += c[a[i - 1] - 1];
        Res += b[a[i] - 1];
        //cout << Res << '\n';
    }
    cout << Res;
}
int main(int argc,char *argv[]) {
    //srand(time(nullptr));
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //doc();
    solve();
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n, p[210000], a, res, ans;
int main(void){
    // Your code here!
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a;
        p[a] = i;
    }
    ans = 1;
    for (int i = 1; i < n; i++) {
        if (p[i] < p[i + 1]) {
            ans++;
        } else {
            res = max(res, ans);
            ans = 1;
        }
    }
    cout << n - max(res, ans) << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

const int maxm = 100000;
const int maxn = 1E5 + 10;

int n, A[maxn], B[maxn], C[maxn], v[maxn];

int main()
{
	#ifdef vv
		freopen("vv.txt", "r", stdin);
	#endif

	cin >> n;
	for (int i = 1; i <= n; i++)
		scanf("%d", &v[i]);
	for (int i = 1; i <= n; i++)
		if (i & 1) ++B[v[i]], ++C[v[i]]; else ++A[v[i]];
	for (int i = 1; i <= maxm; i++)
		B[i] = max(B[i], B[i - 1]);
	for (int i = maxm; i; i--)
		C[i] = max(C[i], C[i + 1]);

	int Ans = n;
	for (int i = 1; i <= maxm; i++)
	{
		int x = A[i] + max(B[i - 1], C[i + 1]);
		Ans = min(Ans, n - x);
	}
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;


int main() {
    int a, b;
    cin >> a >> b;
    if (b == 1){
        cout << 0 << endl;
        return 0;
    }
    cout << a - b;
}

Measured memory_bytes: 256
// Problem : B - Multiple of 9
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define ll long long 
#define ull unsigned long long
const int INF = 1e9 + 5;
#define pb push_back
#define eb emplace_back
#define vll vector<long long int>
#define loop(i, a, b) for(long long int i = a; i < b; i++)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pii pair<ll, ll>
#define vpair vector<pii>
#define vbool vector<bool>
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<<a[i]<<' ';}cout<<'\n'
#define sec second
#define fir first
#define br '\n'
#define permute next_permutation
#define pqua priority_queue<ll>
#define pqud priority_queue<ll, vector<ll>, greater<ll> >
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define maxi *max_element
#define pi acos(-1)
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(10)

vector<long long int> sieve(long long int n){
 	vector<long long int> primes;
 	bool isPrime[n+1] = {false};
 	isPrime[1] = isPrime[0] = false;
 	for(long long int i = 2;i<=n;i++)
 	{
 		isPrime[i] = true;
 	}
 	for(long long int i = 2;i*i<=n;i++)
 	{
 		if(isPrime[i])
 		{
 			for(long long int j = i*i;j<=n;j+=i)
 			{
 				isPrime[j] = false;
 			}
 		}
 	}
 	for(long long int i = 2;i<=n;i++)
 	{
 		if(isPrime[i])
 		{
 			primes.push_back(i);
 		}
 	}
 	return primes;
}

void print_vector2(vector<vector<ll> >v) {
    for(ll i=0;i<v.size();i++){
        for(ll j=0;j< v[i].size();j++){
            cout<<v[i][j]<<" ";
        }cout<<"\n";
    }
}

void print_vector1(vector<ll> v) {
    for(ll i=0; i<v.size();i++){
        cout<<v[i]<<" ";
    }cout<<"\n";
}

ll gcd(ll a, ll b) {
    return __gcd(a, b);
}

// v.back()
// v.erase(v.begin(), v.brgin + k)
// v.insert(at which place v.bigin() + 1 implines at i = 1, no. of times, value)
// v.insert(position, copy.begin(), copy.end())
// v1.swap(v2)
// v.clear() to clear v.empty() to check empty
// map assending order and set descending order 
// stringstream ss(str) Used for breaking words

int main(){
    FastIO;
    PRECISION;

    string s;
    cin>>s;
    ll ans = 0;
    for(int i = 0; i < s.size(); i++){
    	ans = ans + s[i] - 48;
    }
    if(ans % 9 == 0){
    	cout<<"Yes";
    }
    else{
    	cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3772
#include <cstdio>

int mat[14][25];

int main()
{
  for (int i = 0; i < 14; ++i)
  {
    for (int j = 0; j < 25; ++j)
    {
      mat[i][j] = 7 * i + 4 * j;
    }
  }

  int n;
  scanf("%d", &n);

  for (int i = 0; i < 14; ++i)
  {
    for (int j = 0; j < 25; ++j)
    {
      if (n == mat[i][j])
      {
        printf("Yes\n");
        return 0;
      }
    }
  }

  printf("No\n");
  return 0;
}

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

int main() {
    vector<int> m(11);
    for (int i = 0; i < 3; i++) {
        int in;
        cin >> in;
        m[in]++;
    }
    if (m[5] == 2 && m[7] == 1) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    return 0;
}

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

int dx[] = {-1,0,0,1};
int dy[] = {0,1,-1,0};
// 行けることをまず判定
// 行けるルート以外のマスは全部塗りつぶしていい
// 答えは, 現在の.の個数 - 最短経路
// bfsだなあ
int main() {
	int h, w;
	cin >> h >> w;
	int sum = 0;
	vector<vector<bool>> n(h,vector<bool>(w));
	for(int i=0;i<h;i++) {
		string s;
		cin >> s;
		for(int j=0;j<w;j++) {
			if(s[j]=='.') {
				sum++;
				n[i][j] = true;
			}else n[i][j] = false;
		}
	}
	vector<vector<bool> > done(h,vector<bool>(w,false));
	// bfsやる
	queue<pair<int,pair<int,int>>> q;
	q.push({1,{0,0}});
	done[0][0] = true;
	int length = -1;
	while(!q.empty()) {
		auto tmp = q.front();
		int now = tmp.first;
		//cout << tmp.second.first << " " << tmp.second.second << endl;
		q.pop();
		if(tmp.second.first == h-1 && tmp.second.second == w-1) {
			length = tmp.first;
			break;
		}
		for(int i=0;i<4;i++) {
			int ny = tmp.second.first + dy[i];
			int nx = tmp.second.second + dx[i];
			if(0<=ny && ny<h && 0<=nx && nx<w && done[ny][nx] == false && n[ny][nx]) {
				done[ny][nx] = true;
				q.push({now+1,{ny,nx}});
			}
		}
	}
	//cout << "sum :" << sum << endl;
	//cout << "length: " <<  length << endl;
	if(length == -1) {
		cout << -1 << endl;
	}else {
		cout << sum - length << endl;
	}
}

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

int main() {
    int n, x, y; cin >> n >> x >> y;
    int ans[n];
    for (int i = 1; i < n; i++){
        ans[i] = 0;
    }
    
    for (int i = 1; i < n+1; i++){
        for (int j = i+1; j < n+1; j++){
            int r = min(
                abs(j - i),
                min(abs(x-i) + 1 + abs(y-j),
                abs(y-i) + 1 + abs(x-j))
                );
            ans[r] ++;
        }
    }
    for (int i = 1; i < n; i++){
        cout << ans[i] << endl;
    }

}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int i,a,b,n,s;

	while(scanf("%d %d %d",&a,&b,&n) != EOF){
		a %= b;
		s = 0;
		for(i = 0;i < n;i++){
			a *= 10;
			s += a/b;
			a %= b;
			if(a == 0){
				break;
			}
		}
		printf("%d\n",s);
	}

	return 0;
}

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


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

  string w[n];
  r(i,n){
    cin>>w[i];
  }

  bool flag=1;
  int cnt=0;

  r(i,n-1){
    int x=w[i].size();
    if(w[i][x-1]!=w[i+1][0]){flag=0;}


  }
  
  if(flag==1){
  r(i,n){
    cnt=0;
    r(j,n){
      if(w[i]==w[j])cnt++;
    }
    if(cnt!=1)flag=0;
  }
}

if(flag)cout<<"Yes"<<endl;
else cout<<"No"<<endl;





return 0;}


Measured memory_bytes: 256
A,B,K=map(int,input().split())
li=[]  
for i in range(A,A+K):
  li.append(i)
for j in range(B-K+1,B+1):
  li.append(j)
ans=sorted(set(li))
for l in ans:
  if A<=l<=B:
    print(l)

Measured memory_bytes: 3060
N=int(input())
h=list(map(int, input().split()))


dp=[0]+[float("inf")]*(N-1)


for i in range(N-1):
    #１進む
    dp[i+1]=min(abs(h[i+1]-h[i])+dp[i],dp[i+1])
    
    #2進む
    if not i+2>N-1:
        dp[i+2]=min(abs(h[i+2]-h[i])+dp[i],dp[i+2])

print(dp[-1])


Measured memory_bytes: 13980
//quming
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=1005;
int a[N],n,ans,m;
int main(){
	scanf("%d",&n);
	fp(i,1,9)fp(j,1,9)if(i*j==n)return puts("Yes"),0;
	puts("No");
	return 0;
}

Measured memory_bytes: 256