akhauriyash/Code-Regression huggingface dataset:
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;

signed main() {
  int H1,H2,M1,M2,K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  H2 = H2 - H1 ;
  M2 = M2 -M1 ;
  M2 = M2 + 60*H2 -K;
  answer(M2);

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double n;
    cin>>n;
    double m=n;
    int unko=int(m);

    for(double i=0.0;i<=n;i+=1){
        double maki=i;

        if(int(maki*1.08)==unko){
            cout << int(i)<<endl;
            return 0;
        }
    }
    cout<< ":("<<endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        if(s[0] == 'A') {
            int count = 0;
            for (int i = 2; i < s.length - 1; i++) {
                if(s[i] == 'C') {
                    count++;
                }
            }
            if(count == 1) {
                count = 0;
                for (int i = 0; i < s.length; i++) {
                    if(Character.isUpperCase(s[i])) {
                        count++;
                    }
                }
                if(count == 2) {
                    System.out.println("AC");
                    return;
                }
            }
        }
        System.out.println("WA");
    }
}

Measured memory_bytes: 35772
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
	int k, s;
	cin >> k >> s;

	int ans = 0;
	REP(x, k + 1) {
		REP(y, k + 1) {
			int z = s - x - y;
			if (z >= 0 && z <= k) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}

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

int main(){
	int a,b;
	cin >> a >> b;
	string ans;
	if(a >= b){
		for(int i = 0; i < a; i++){
			ans.push_back('0'+b);
		}
	}
	else{
		for(int i = 0; i < b; i++){
			ans.push_back('0'+a);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
from bisect import bisect
N, K = map( int, input().split())
X = list( map( int, input().split()))
I = bisect(X, -1)
Xmin = X[:I]
Xmin = [ -x for x in Xmin[::-1]]
Xplu = X[I:]
H = [10**9]*(10**5)
Xmin += H
Xplu += H
ans = 10**9
for i in range( min(I, K)):
    if i == K-1:
        ans = min(ans, Xmin[i])
    else:
        ans = min(ans, Xmin[i]*2 + Xplu[K-i-2])
for i in range( min(N-I, K)):
    if i == K-1:
        ans = min(ans, Xplu[i])
    else:
        ans = min(ans, Xplu[i]*2 + Xmin[K-i-2])
print(ans)

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

using namespace std;

int D[10];

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int N, K, x;
	cin >> N >> K;
	for (int i = 0; i < K; ++i) {
		cin >> x;
		D[x] = 1;
	}
	bool change = false;
	for (char c : to_string(N)) {
		int d = c - '0';
		if (D[d] == 1) {
			change = true;
			break;
		}
	}
	if (!change) cout << N << '\n';
	else {
		bool possible;
		for (int i = N + 1; ; ++i) {
			possible = true;
			for (char c : to_string(i)) {
				int d = c - '0';
				if (D[d] == 1) {
					possible = false;
					break;
				}
			}
			if (possible) {
				cout << i << '\n';
				break;
			}
		}
	}
	return 0;
}

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

int gcd(int a, int b)
{
    if (a < b)
    {
        swap(a, b);
    }
    while (b > 0)
    {
        int r = a % b;
        a = b;
        b = r;
    }
    return a;
}

int main()
{
    int n, k;
    cin >> n >> k;

    vector<int> a(n);
    int mx = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
        mx = max(mx, a.at(i));
    }

    int g = a.at(0);
    for (int i = 1; i < n; i++)
    {
        g = gcd(g, a.at(i));
    }

    if (k <= mx && k % g == 0)
    {
        cout << "POSSIBLE" << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define N 505
#define ll long long
#define debug(x) cerr<<#x<<" : "<<x<<endl
#define CM cerr<<(&MOP1-&MOP2)/1024.0/1024.0<<endl
using namespace std;
template <class T> inline T Min(T x, T y){
    return x<y?x:y;
}
template <class T> inline T Max(T x, T y){
    return x>y?x:y;
}
bool MOP1;
int A[N],W[N],sum,n,k;
int ans;
bool MOP2;
bool check(int now){
	ll res=0;
	for(int i=1;i<=n;i++)W[i]=A[i]%now,res+=W[i];
	sort(W+1,W+1+n);
	ll tot=0;
	for(int i=0;i<=n;i++){
		tot+=W[i];
		if(1LL*(n-i)*now-res+tot==tot)break;
	}
	return tot<=k;
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]),sum+=A[i];
	for(int i=1;i*i<=sum;i++){
		if(sum%i)continue;
		if(check(i))ans=Max(ans,i);
		if(i*i==sum)break;
		if(check(sum/i))ans=Max(ans,sum/i);
	}
	printf("%d\n",ans);
	return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  string s;
  cin>>s;
  int mi = MOD;
  rep(i, s.size() - 2) {
    int h = s[i] - '0';
    int j = s[i + 1] - '0';
    int z = s[i + 2] - '0';
    int tmp = h * 100 + j * 10 + z;
    mi = min(mi, abs(753 - tmp)); 
  }
  cout << mi << endl;

  return 0;
}


Measured memory_bytes: 256
o = gets()
e = gets()
n_o = o.length
n_e = e.length
o_a = o.split("")
e_a = e.split("")

if(n_o == n_e)
	n = 2*n_o
	i = 0
	while i < n
		print(o_a[i])
		print(e_a[i])
		i = i + 1
	end
else
	n = 2*n_o - 1
	i = 0
	while i < n
		print(o_a[i])
		print(e_a[i])
		i = i + 1
	end
end

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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define pi 3.141592653589
#define MOD 1000000007
#define to() int t; cin>>t; while(t--)
#define pb push_back
#define in insert
#define mp make_pair
#define ff first
#define ss second
#define si(s) s.size()
#define fori(it,v) for(it=v.begin();it!=v.end(); it++) 
#define for1(low,high,k) for(int i=low;i<high;i+=k)
#define for11(low,high,k) for(int j=low;j<high;j+=k)
#define for2(low,high,k) for(int i=low;i<=high;i+=k)
#define rev(high,low,k)  for(int i=high;i>=low ;i-=k)
#define all(x) x.begin(), x.end()
#define fil(x,i) memset(x,i,sizeof(x));
#define setbits(x) __builtin_popcount(x)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout) 
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;

vector<vector<int>>g;
int vis[200005];

int dfs(int i){
	vis[i]=1;
	int cnt=1;
	for(int j:g[i]){
		if(!vis[j]) cnt+=dfs(j);
	}
	return cnt;
}

int main()
{
	boost;
	int n,m; cin>>n>>m;
	g.resize(n+1);
	for1(0,m,1){
		int a,b; cin>>a>>b;
		g[a].pb(b); g[b].pb(a);
	}
	
	int ans=0;
	
	for(int i=1;i<=n;i++){
		if(vis[i]) continue;
		int temp=dfs(i);
		ans=max(ans,temp);
	}
	cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 24256
import std;

long calc(long a, long b, long c, long k) {
    long x = min(a, k);
    long y = min(b, k - x);
    long z = min(c, k - x - y);
    return x - z;
}

void main() {
    long a, b, c, k; scan(a, b, c, k);
    writeln(calc(a, b, c, k));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;


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

using namespace std;

#define __START__ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define popb pop_back
#define pf push_front
#define popf pop_front
#define nl "\n"
#define sp " "
#define hashset unordered_set
#define tostr to_string
#define ins insert
#define ct count
#define __END__ return 0;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef set<int> si;
typedef set<char> sc;
typedef string str;
typedef deque<int> di;

signed main(){
    __START__
    int n, d; cin >> n >> d;
    int arr[n][2];
    for (int i = 0; i < n; i++){
        for (int j = 0; j < 2; j++){
            cin >> arr[i][j];
        }
    }
    int counter = 0;
    for (int i = 0; i < n; i++){
        if ((db)sqrt((db)arr[i][0]*(db)arr[i][0] + (db)arr[i][1]*(db)arr[i][1]) <= d){
            counter++;
        }
    }
    cout << counter;
    __END__
}


Measured memory_bytes: 5228
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()
#define pb push_back

#define error(x) cout << #x << " = " << x << endl

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

const int N = 1e5 + 20;
int n, m, deg[N];

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

	cin >> n >> m;

	for (int i = 0, u, v; i < m; i++)
	{
		cin >> u >> v;
		u--, v--;

		deg[u]++, deg[v]++;
	}

	for (int i = 0; i < n; i++)
	{
		if (deg[i] & 1) return cout << "NO\n", 0;
	}

	cout << "YES\n";
}


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

int main(void) {
  int a, b, mod;
  cin >> a >> b;
  
  if(a < b) {
    int tmp = a;
    a = b;
    b = tmp;
  }
  while(true) {
    mod = a % b;
    if(mod == 0) {
      break;
    }
    a = b;
    b = mod;
  }

  cout << b << endl;
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#define LOWX 0
#define LOWY 0
int main(void){
	int W,H;
	int x,y,r;
	scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
	if((LOWX<=x-r)&&(x+r<=W)&&(LOWY<=y-r)&&(y+r<=H)){
		printf("Yes\n");
	}
	else	printf("No\n");
	return 0;
}

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

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

    int n,m;
    cin >> n >> m;

    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 892
/*ABC152-D*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;


int main(){
    int N;
    cin>>N;
    int c[11][11];
    rep(i,10)rep(j,10){
       c[i][j]=0; 
    }
    rep(i,N+1){
        string si = to_string(i);
        if(i%10!=0){
            c[(int)(si[0]-'0')][i%10]+=1;
        }
    }
    int sum=0;    
    rep(i,10)rep(j,10){
        sum+=c[i][j]*c[j][i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
key_data_list = []
for _ in range(K):
    value, op = map(int, input().split())
    open_boxes = map(int, input().split())
    box_value = 0
    for opb in open_boxes:
      box_value += 2**(opb-1)
    key_data_list.append([value, box_value])

max_tresure_state = 2**N
max_key_price = 2**30
dp_table = [[max_key_price] * (max_tresure_state) for i in range(K+1)]

dp_table[0][0] = 0

for key_index in range(K):
    for tresure_state in range(max_tresure_state):
        key_value = key_data_list[key_index][0]
        key_state = key_data_list[key_index][1]

        if dp_table[key_index+1][tresure_state] > dp_table[key_index][tresure_state]:
            dp_table[key_index+1][tresure_state] = dp_table[key_index][tresure_state]

        buying_state = key_state | tresure_state
        dp_table[key_index+1][buying_state] = min(dp_table[key_index][buying_state],
                                                  dp_table[key_index+1][buying_state],
                                                  dp_table[key_index][tresure_state] + key_value)


result_value = dp_table[K][max_tresure_state-1]
if result_value == max_key_price:
    print(-1)
else:
    print(int(result_value))


Measured memory_bytes: 79960
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    string s; cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main(){
    cin>>N>>H;
    vp attack(N*2);
    rep(i,N*2){
        cin>>A;
        attack[i] = mp(A,(i+1)%2);
    }
    sort(attack.begin(), attack.end());
    reverse(attack.begin(), attack.end());
    ll ans = 0;
    rep(i,N*2){
        P p = attack[i];
        if(p.se == 0){
            ++ans;
            H -= p.fi;
            if(H <= 0) break;
        }else{
            ans += (H - 1) / p.fi + 1;
            break;
        }
        //cout<<i<<' '<<H<<endl;
    }
    cout<<ans<<endl;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

ll calc(ll a, ll b, ll x){
	return (a*x / b) - a* (x/b);
}

int main()
{
	ll a,b,n;
	cin>>a>>b>>n;

	if(b > n){
		cout<<calc(a,b,n)<<endl;
	}else{
		cout<<calc(a,b,(n/b)*b-1)<<endl;
	}
	return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int numRow1 = sc.nextInt();
        int numCol1Row2 = sc.nextInt();
        int numCol2 = sc.nextInt();

        int[][] mat1 = new int[numRow1][numCol1Row2];
        int[][] mat2 = new int[numCol1Row2][numCol2];
        long[][] matOut = new long[numRow1][numCol2];
        int i, j, k;
        for (i = 0; i < numRow1; i++) {
            for (j = 0; j < numCol1Row2; j++) {
                mat1[i][j] = sc.nextInt();
            }
        }
        for (i = 0; i < numCol1Row2; i++) {
            for (j = 0; j < numCol2; j++) {
                mat2[i][j] = sc.nextInt();
            }
        }
        for (i = 0; i < numRow1; i++) {
            for (j = 0; j < numCol2; j++) {
                for (k = 0; k < numCol1Row2; k++) {
                    matOut[i][j] += mat1[i][k] * mat2[k][j];
                }
                if (j != 0) System.out.print(" ");
                System.out.print(matOut[i][j]);
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 54460
#include<iostream>
#include<string>
#include<queue>
#include<map>
using namespace std;
int dx[8]={0,1,0,-1,1,1,-1,-1};
int dy[8]={1,0,-1,0,1,-1,1,-1};
main()
{
	map<string,int>M;
	queue<string>P;
	string start="";
	for(int i=0;i<19;i++)
	{
		string s;cin>>s;
		start+=s;
	}
	M[start]=0;
	P.push(start);
	while(!P.empty())
	{
		string now=P.front();P.pop();
		int cost=M[now];
		int nx,ny;
		for(int i=0;i<now.size();i++)
		{
			if(now[i]=='O')
			{
				nx=i/15;
				ny=i%15;
				break;
			}
		}
		for(int r=0;r<8;r++)
		{
			int tx=nx+dx[r],ty=ny+dy[r];
			if(tx<0||ty<0||tx>=19||ty>=15||now[tx*15+ty]!='X')continue;
			string nxt=now;
			while(0<=tx&&tx<19&&0<=ty&&ty<15&&nxt[tx*15+ty]=='X')
			{
				nxt[tx*15+ty]='.';
				tx+=dx[r];
				ty+=dy[r];
			}
			if(tx>=19||tx==18&&0<=ty&&ty<15)
			{
				cout<<cost+1<<endl;
				return 0;
			}
			else if(0<=tx&&tx<19&&0<=ty&&ty<15)
			{
				nxt[nx*15+ny]='.';
				nxt[tx*15+ty]='O';
				if(M.find(nxt)==M.end())
				{
					M[nxt]=cost+1;
					P.push(nxt);
				}
			}
		}
	}
	cout<<-1<<endl;
}



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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int a,b,c;
    cin >> a >> b >>c;
    cout << min(min(a+b, b+c), c+a) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    int n;
    cin >> n;
    vector<int> c(n, 0), v(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (v[i] - c[i] > 0)
            ans += v[i] - c[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//datatypes
	#define int long long
	#define vi vector<int>
	#define si set<int>
	#define vii vector<ii>
	#define ii pair<int,int>
	#define mii map<int,int>
	#define M 1000000007
	#define pi 3.141592653589793
	#define in(x) int x; cin>>x;
	#define sz(x) (int)x.size()
	#define fr first
	#define sc second
	#define pb push_back
	#define mkp make_pair
	#define inputFile \
	    freopen("input.txt", "r", stdin); 
	#define outputFile \
	    freopen("output.txt", "w", stdout)
	#define rep(i,a,b) for(int i=a; i<b; i++)
	#define trav(a) for(auto &x:a)
	#define test cout<<"hello\n";
	#define all(x) (x).begin(),(x).end()
	#define mem0(x) memset(x, 0, sizeof(x))
	#define mem1(x) memset(x, -1, sizeof(x))
	#define sa(x) std::sort(all(x))
	#define sd(x) std::sort(all(x),greater<int>())

signed solve()
{
	int n, k;
	cin>>n>>k;
	int a[n];
	for(int i=0; i<n; ++i)
		cin>>a[i];

	int dp[n];
	for(int i=0; i<n; ++i)
		dp[i]=INT_MAX;

	dp[0]=0;
	//dp[1]=dp[0]+abs(a[0]-a[1]);

	for(int i=1; i<n; ++i)
	{
		for(int j=1; j<=k && (i-j)>=0; ++j)
		{
			//cout<<i<<" "<<dp[i]<<" "<<dp[i-j]+abs(a[i]-a[i-j])<<endl;
			dp[i]=min(dp[i], dp[i-j]+abs(a[i]-a[i-j]) );
		}
		//cout<<"i"<<i<<" "<<dp[i]<<endl;
	}

	cout<<dp[n-1];
	return 0;
}

signed main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--) solve();
	//cout << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
   int N;
   cin >> N;
   int count =0;
   
   for(int i = 0;i < 30;i++){
       for(int j =0;j< 20;j++){
           if(( i*4 + j*7)==N){
               count++; 
           }
       }
   }
   
   if(count >=1) cout << "Yes" << endl;
   else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
 
const int mod=1e9+7;
const int Max=100005;
int n,m,s;
int sum[Max];
 
inline int ksm(int a,int b)
{
	int ans=1;
	while(b)
	{
	  if(b&1) ans=(ans*a)%mod;
	  b>>=1;
	  a=(a*a)%mod;
	}
	return ans;
}
 
signed main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&m),sum[m]++;
	for(int i=0;i<n;i++) if(sum[i]>=3) {cout<<"0";return 0;}
	if((n&1&&sum[0]!=1)||(!(n%2)&&sum[0])) {cout<<"0";return 0;}
	cout<<ksm(2,n/2);
	return 0;
}

Measured memory_bytes: 1024
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"

using namespace std;
typedef long long ll;

int n;
int h[100100];
int dp[100100];

int main()
{
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  dp[n - 1] = 0;
  dp[n - 2] = abs(h[n - 1] - h[n - 2]);
  for (int i = n - 3; i >= 0; i--)
  {
    int a1 = dp[i + 1] + abs(h[i] - h[i + 1]);
    int a2 = dp[i + 2] + abs(h[i] - h[i + 2]);
    dp[i] = min(a1, a2);
  }
  cout << dp[0] << "\n";
}

Measured memory_bytes: 1024
def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    a_copy = sorted(a)
    a_max = a_copy[-1]
    a_second = a_copy[-2]
    for i in range(n):
        if a[i] == a_max:
            print(a_second)
        else:
            print(a_max)


main()

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

using namespace std;
int n,h,tic = 0,p[1<<20];
const int mod = 1000000007;
long long ans,tick[1<<20],val[1<<20];
inline void AddTag(int now,long long bas) {
	bas *= now;
	bas %= mod;
	if (now >= (1<<h)) {
		now = p[now-(1<<h)+1]+(1<<h)-1;
		while (now > 1) {
			if (tick[now>>1] < tic)
				val[now>>1] = 0,tick[now>>1] = tic;
			bas *= now;
			bas %= mod;
			(val[now>>1] += bas) %= mod;
			now >>= 1;
		//	cout << now << " " << val[now] << endl;
		}
		return ;
	}
	AddTag(now<<1,bas);
	AddTag((now<<1)+1,bas);
}
inline void calcAns(int now,long long bas) {
	bas *= now;
	bas %= mod;
	if (now >= (1<<h)) {
		now = p[now-(1<<h)+1]+(1<<h)-1;
		long long tmp = bas*now%mod,caled = 0;
		while (now > 1) {
			//caled *= now;
			//caled %= mod;
			caled *= now;
			caled %= mod;
			now >>= 1;
			tmp *= now;
			tmp %= mod;
			if (tick[now] == tic) {
				//cout << now << " " << tmp << " " << val[now] << " " <<caled << endl;
				(ans += tmp*(val[now]-caled)) %= mod;
				caled = val[now];
			}
		}
		return ;
	}
	calcAns((now<<1),bas);
	calcAns((now<<1)+1,bas);
}
inline void dfs(int now) {
	if (now >= (1<<h))
		return ;
	tic++;
	AddTag(now<<1,now);
	calcAns((now<<1)+1,1);
	//cout << ans << endl;
	dfs(now<<1);
	dfs((now<<1)+1);
}
int main() {
	scanf("%d",&h);
	h--;
	int n = 1<<h;
	for (int i = 1;i <= n; i++)
		scanf("%d",&p[i]);
	dfs(1);
	ans += mod;
	ans %= mod;
	printf("%lld\n",ans);
	return 0;
}
/*
5
6 14 15 7 12 16 5 4 11 9 3 10 8 2 13 1
4
1 2 3 4 5 6 7 8
*/

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


int main()
{
    string s;
    cin >> s;
    int a_i, z_i;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'Z') z_i = i;
    }
    for (int i = s.size() - 1; i >= 0 ; i--)
    {
        if (s[i] == 'A') a_i = i;
    }
    cout << z_i - a_i + 1 << endl;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


ll dp1[1000005];
ll dp2[1000005];

void solve() {
    rep(i, 1000005) dp1[i] = dp2[i] = INF;
    dp1[0] = dp2[0] = 0;
    rep1(i, 1000004){
        rep1(j, 300){
            ll tmp = j*(j+1)*(j+2)/6;
            if(i - tmp >= 0){
                dp1[i] = min(dp1[i], dp1[i-tmp]+1);
                if(tmp%2) dp2[i] = min(dp2[i], dp2[i-tmp]+1);
            }
            // dp1[i] = min(dp1[i], dp1[i-1]+1);
            // dp2[i] = min(dp2[i], dp2[i-1]+1);
        }
    }
    int a;
    while(cin >> a, a){
        cout << dp1[a] << " " << dp2[a] << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}



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

int main() {
  int a,b;
  cin >> a >> b;
  
  if(b==1){
    cout << 0 << endl;
  }
  else if(b>=a){
    int c = (b-a)/(a-1);
  
    if((b-a)%(a-1)!=0){
      c += 1;
    }
    
    cout << c + 1 << endl;
  }
  else{
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
import sys
m=166666;s=[1]*m;t=[1]*m
for i in range(m):
 if s[i]:
  k=6*i+5
  s[i+k::k]=[0]*len(s[i+k::k])
  t[-2-i+k::k]=[0]*len(t[-2-i+k::k])
 if t[i]:
  k=6*i+7
  s[-2-i+k::k]=[0]*len(s[-2-i+k::k])
  t[i+k::k]=[0]*len(t[i+k::k])
for e in sys.stdin:
 e=int(e)
 print([e-1,sum(s[:(e+1)//6])+sum(t[:(e-1)//6])+2][e>3])


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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ld long double
#define forn(low,high,i) for(i = low; i < high; i++)
#define forrev(high,low,i) for(i = high; i >= low; i--)
#define all(v) v.begin(),v.end()
#define decimal_digits cout << fixed << setprecision(15);

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#define GOOGLE 0
#define MULTIPLE_TC 0

const int inf = 1e9;
const long long INF = 1e18;
const int mod = 1e9 + 7;
const int bit32 = log2(inf) + 3;
const int bit64 = log2(INF) + 3;

inline int add(long long a, long long b){a += b; if(a >= mod) a -= mod; return a;}
inline int sub(long long a, long long b){a -= b; if(a < 0) a += mod; return a;}
inline int mul(long long a, long long b){a %= mod; b %= mod; return (int)((long long) a * b % mod);}
inline int modexpo(long long a, long long b){int res = 1; while(b > 0){ if(b & 1) res = mul(res, a); a = mul(a, a); b /= 2;} return res;}
inline int divide(long long a, long long b){return mul(a, modexpo(b, mod - 2));}
inline int inv(long long a){return modexpo(a, mod - 2);}

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

void pre(){ // Reset each global variable (esp. for graphs)
  
}

void solve(){
  string s, t;
  cin >> s >> t;
  t.pop_back();
  cout << (s == t ? "Yes\n" : "No\n");
}

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL); 

  pre();

  int t = 1, T;

  if(MULTIPLE_TC)
    cin >> t;

  for(T = 1; T <= t; T++){
    if(GOOGLE)
      cout << "Case #" << T << ": ";
    solve();
  }

  ktj();
}


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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }			//最小公倍数(Least Common Multiple)

long long comb(long long m) {
	return (m * (m - 1)) / 2;
}


int main() {
	int k;
	string s;
	cin >> k;
	cin >> s;
	
	if (s.size() <= k)
		cout << s << endl;
	else {
		while (s.size() != k) {
			s.pop_back();
		}
		rep(i,3)	s.push_back('.');
		cout << s << endl;
	}
	


}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  int n; cin >>n;
  vector<ll> a(n); rep(i, n) cin >>a[i];
  rep(i, n) a[i] -= i+1;
  sort(all(a));
  ll b = a[n/2];
  ll res = 0;
  rep(i, n){
    res += abs(b - a[i]);
  }
  cout <<res <<endl;
}

Measured memory_bytes: 1792
n = int(input())
s = list(input())
rw = s.count(".")
rb = n - rw
ans = rw
lw = 0
lb = 0
for i in s:
    if i == ".":
        lw += 1
        rw -= 1
    else:
        lb += 1
        rb -= 1
    ans = min(ans, lb + rw)
print(ans)

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 998244353;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < SIZE; ++i) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

// 組み合わせ（重複無し）
LL comb(int n, int k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

// 二項係数
LL Bin(LL n, LL k) {
    if(k < 0 || n < k) {
        return 0;

    }
    LL ret = 1;
    for(LL i = 1; i <= k; ++i) {
        ret *= n--;
        ret /= i;

    }
    return ret;
}

// 重複組み合わせ
LL comb_rep(int x, int y) {
    return comb(x + y - 1, x - 1);

}

/*
 * 繰り返し自乗法
 */
//typedef long long LL;
LL power( LL x, LL n ) {
    LL res = 1;
    if( n > 0 ) {
        res = power( x, n / 2 );
        if( n % 2 == 0 ) res = ( res * res ) % MOD;
        else res = ( ( ( res * res ) % MOD ) * x ) % MOD;

    }
    return res;

}

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

    LL N, M, K;
    cin >> N >> M >> K;
    combInit();

    LL res = 0;
    for(int i = 0; i <= K; ++i) {
        LL a = M * power(M - 1, N - i - 1) % MOD;
        LL b = comb(N - 1, i);
        res = (res + (a * b) % MOD) % MOD;

    }
    cout << res << endl;
    return 0;
}



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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 998244353
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"
#define int ll

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

  int N,K;
  cin>>N>>K;
  vector<int>L(K),R(K);
  for(int i=0;i<K;i++)cin>>L[i]>>R[i];
  vector<int>ans(N);
  ans[0]=1;
  ans[1]=-1;
  ll sum=0;
  for(int i=0;i<N;i++){
    sum=(sum+ans[i])%MOD;
    for(int j=0;j<K;j++){
      if(i+L[j]<N)ans[i+L[j]]=(ans[i+L[j]]+sum)%MOD;
      if(i+R[j]+1<N)ans[i+R[j]+1]=((ans[i+R[j]+1]-sum)%MOD+MOD)%MOD;
    }
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 4772
<?php
list($n,$m)=explode(" ",trim(fgets(STDIN)));
$i=0;
while($i<$n){
  list($a[],$b[])=explode(" ",trim(fgets(STDIN)));
  ++$i;
}
asort($a);
$ans=(int)0;
foreach($a as $k => $v){
  if($m==0){
    break;
  }else{
    $c=min($m,$b[$k]);
    $ans+=$v*$c;
    $m-=$c;
  }
}
echo $ans;

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

#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define FORV(a, A) for (auto &a : A)

using namespace std;

using ll = long long;

void Main() {
  int N, K;
  cin >> N >> K;
  int ans = 0, a;
  REP(i, 0, N - 1) {
    cin >> a;
    if (a >= K) ans++;
  }
  cout << ans;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX = 100000;
const int INF = (1 << 30);

int main()
{
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; i++)
  {
    cin >> A.at(i);
  }
  vector<int> dp(MAX, INF);
  int length = 1;
  dp.at(0) = A.at(0);
  for (int i = 1; i < n; i++)
  {
    if (dp.at(length - 1) < A.at(i))
    {
      dp.at(length) = A.at(i);
      length++;
    }
    else
    {
      *lower_bound(dp.begin(), dp.end(), A.at(i)) = A.at(i);
    }
  }
  cout << length << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(a,b,c) for(int a=b;a<c;a++)
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    int n;
    cin>>n;
    int h[n+1];
    f(i,0,n) cin>>h[i+1];
    ll dp[n+1];
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    f(i,3,n+1)
    {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n];

}














/* cd Desktop/templates */

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

int main(){
	int a, v, n, maxv, mina;
	cin>>n;
	cin>>a>>v;
	maxv=v;
	mina=a;
	for(int i=1;i<n;i++){
		cin>>a>>v;
		if(maxv<v){
			maxv=v;
			mina=a;
		}else if(maxv==v){
			if(mina>a){
				mina=a;
			}
		}
	}
	cout<<mina<<" "<<maxv<<endl;
	return 0;
}

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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define all(c) begin(c),end(c)

template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

const int INF = 1 << 29;

auto solve() {
    int N;
    ll X;
    cin >> N >> X;
    vll lens(51, 0), ps(51, 0);
    lens[0] = ps[0] = 1;
    FOR(i, 1, 51) {
        lens[i] = lens[i - 1] * 2 + 3;
        ps[i] = ps[i - 1] * 2 + 1;
    }
    function<ll(ll, int)> rec = [&](ll v, int depth) {
        ll half = lens[depth] / 2;
        if(depth==0) {
            return 1ll;
        } else if (v == 0) {
            return 0ll;
        } else if (v == lens[depth] - 1) {
            return ps[depth - 1] * 2 + 1;
        } else if (v == half) {
            return ps[depth - 1] + 1;
        } else if (v < half) {
            return rec(v - 1, depth - 1);
        } else {
            return ps[depth - 1] + 1 + rec(v - half - 1, depth - 1);
        }
    };

    return rec(X - 1, N);
}


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

    cout << solve() << endl;
//    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cstdio>

using namespace std;

int main(){
	int n;
	string s;
	map< string, vector<int> > m;
	while(cin >> s >> n){
		m[s].push_back(n);
	}
	
	map< string, vector<int> >::iterator it;
	for(it = m.begin(); it != m.end(); it++){
		cout << it->first << endl;
		sort(it->second.begin(), it->second.end());
		for(int i = 0; i < it->second.size(); i++){
			if(i){
				cout << ' ';
			}
			cout << it->second[i];
		}
		cout << endl;
	}
	
	return 0;
}

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

sumsW = [0]
sumsE = [0]

cnt = 0
for i in range(N):
    if S[i] == 'W':
        cnt += 1
    sumsW.append(cnt)

cnt = 0
for j in range(N-1, -1, -1):
    if S[j] == 'E':
        cnt += 1
    sumsE.append(cnt)
sumsE.reverse()

ans = 3 * 10**5
for i in range(N+1):
    ans = min(sumsW[i] + sumsE[i], ans)
    
print(ans)


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

char matrix[70][70];
string dp[70][70];

bool big(const string &s1, const string &s2){
	if(s1.size() != s2.size()){
		return s1.size() < s2.size();
	}else{
		for(int i = 0; i < s1.size(); i++){
			if(s1[i] != s2[i])
				return s1[i] < s2[i];
		}
	}
	return true;
}

int main(){
	int w, h;
	while(cin >> w >> h && (w || h)){
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++){
				cin >> matrix[i][j];
				dp[i][j].clear();
			}
		}
		string max;
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++){
				if(isdigit(matrix[i][j])){
					if(dp[i-1][j].empty() && dp[i][j-1].empty()){
						if(matrix[i][j] != '0'){
							dp[i][j].push_back(matrix[i][j]);
						}
					}else{
						if(big(dp[i][j-1], dp[i-1][j])){
							dp[i][j] = dp[i-1][j];
							dp[i][j].push_back(matrix[i][j]);
						}else{
							dp[i][j] = dp[i][j-1];
							dp[i][j].push_back(matrix[i][j]);
						}
					}
					if(!big(dp[i][j], max)) max = dp[i][j];
				}
			}
		}
		cout << max << endl;
	}
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
typedef long long ll;


int main() {
    int n,m,ans = 0;
    cin >> n >> m;
    int k[15], s[15][15], p[15];
    rep(i, m){
        cin >> k[i];
        rep(j, k[i]){
            cin >> s[i][j];
        }
    }
    rep(i, m) cin >> p[i];
    
    for(int bits = 0; bits < (1 << n); bits++){
        bool ok = true;
        rep(i, m){
            int on = 0;
            rep(j, k[i]){
                if(bits & (1 << s[i][j]-1)) on++;
            }
            if(on % 2 != p[i]) ok = false;
        }
        if(ok) ans++;
    }
    cout << ans << endl;
}



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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> from1;
  unordered_set<int> toN;
  for (int i = 1; i <= M; ++i) {
    int a, b;
    cin >> a >> b;
    if (a == 1) from1.push_back(b);
    if (b == N) toN.insert(a);
  }
  string s = "IMPOSSIBLE";
  for (const auto& x : from1) {
    if (toN.find(x) != toN.end()) {
      s = "POSSIBLE";
      break;
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 4764
#include <iostream>
#include <cstdio>
#include <set>
using namespace std;




int main(){
  ios::sync_with_stdio(false);
  int n; cin >> n;
  set<string> s;
  for(int i=0; i<n; i++){
    string s1,s2;
    cin >> s1 >> s2;
    if(s1[0] == 'i') s.insert(s2);
    else{
      if(s.find(s2) == s.end()) printf("no\n");
      else printf("yes\n");
    }
  }

}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
inline int ri() {
	int r; cin >> r; return r;
}


int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> sn(n);
	for(int i = 0; i < k; i++) {
		int d; cin >> d;
		for(int j = 0; j < d; j++) {
			int a; cin >> a; a--;
			sn[a]++;
		}
	}
	cout << count(sn.begin(), sn.end(), 0) << endl;
}

Measured memory_bytes: 3640
def solve():
    n, a, b = list(map(int, input().split()))
    MOD = 10 ** 9 + 7
    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]
    
    for i in range(2, max(a, b)+1):
        fact.append((fact[-1] * i) % MOD)
        inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
        factinv.append((factinv[-1] * inv[-1]) % MOD)
    
    def ncr(n, r):
        ret = factinv[r]
        for i in range(n, n-r, -1):
            ret = ret * i % MOD
        return ret
        
    ans = pow(2, n, MOD)
    ans = (ans-ncr(n, a)-ncr(n, b)-1) % MOD
    return ans


print(solve())


Measured memory_bytes: 80880
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>

#include <numeric>
#include <memory>
#include <cassert>

#include <map>
#include <vector>
#include <queue>


using namespace std;

typedef long long LL;



int main() {
    int c = 0;
    char f[20];
    scanf("%s", f);
    for (int i = 0; f[i]; ++i) if (f[i] == '2') ++c;
    cout << c << endl;
}

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

#define ll long long
#define int long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf (int)(1e18)
#define ps(x, y) fixed << setprecision(y) << x
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(p) p.begin(), p.end()
#define ub(a, b) upper_bound(all(a), b)
#define lb(a, b) lower_bound(all(a), b)
#define PI 3.14159265
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void run()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int32_t main()
{
    run();
    int n;
    cin >> n;
    int ans = (n % 1000);
    ans = 1000 - ans;
    ans %= 1000;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner

object Main extends App {
  val sc=new java.util.Scanner(System.in)
  val n,m = sc.nextInt()
  val A = (0 until n) map (_ => sc.nextInt())
  
  def solve(n : Int, m : Int, A : Seq[Int]) : String = {
    var sum = 0.0
    for(i <- 0 until n){
      sum += A(i)
    }
    var cnt = 0
    val fourm = m * 4.0
    for(i <- 0 until n){
      if(A(i) >= sum / fourm )cnt+=1
    }
    if(cnt >= m)"Yes"
    else "No"
  }

  println(solve(n,m,A))
}

Measured memory_bytes: 27424
#include <iostream>
#include <set>
#include <string>

using namespace std;

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

    string cmd, word;
    set<string> S;
    for (int i = 0; i < N; ++i) {
        cin >> cmd >> word;

        if (cmd == "insert") {
            S.insert(word);
        } else if (cmd == "find") {
            cout << (S.find(word) == S.end() ? "no" : "yes") << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 32640