akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int min=1000000000,max=0;
		for(int i=0; i<n; i++) {
			int s=sc.nextInt();
			if(min>s)min=s;
			if(max<s)max=s;
		}
		System.out.println(max-min);
	}
}


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

int main()
{
	vector<int> h;
	int32_t N;
	int32_t ans = 0;
	int32_t s, e;
	bool inc_flag;

	cin >> N;

	for (int32_t i = 0; i < N; i++)
	{
		int32_t t;
		cin >> t;
		h.push_back(t);
	}

	s = 0;
	e = h.size();

	while (true)
	{
		inc_flag = false;
		for (uint32_t i = s; i < e; i++)
		{
			if (h[i] > 0)
			{
				h[i]--;
				inc_flag = true;
			}
			else
			{
				break;
			}
		}
		if (inc_flag)
		{
			ans++;
		}

		if (h[s] == 0)
		{
			s++;
		}

		if (s >= e)
		{
			break;
		}

	}

	cout << ans;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define rv(s) reverse(s.begin(),s.end());
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
 
int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n;cin>>n;
  vi h(n);
  rep(i,n)cin>>h[i];
  
  int ans=0;
  while(true){
    
    if(*max_element(h.begin(), h.end())==0) break;
    
    int i=0;
    while(i<n){
      if(h[i]==0) i++;
      else {
        ans++;
        while(h[i]>0 && i<n){
          --h[i];
          i++;
        }
      }
    }
  }
  cout(ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,x,k,y;
    cin >> n >> k >> x >> y;
    if(n > k){
        cout << k*x + (n-k)*y << endl;
    }else{
        cout << n * x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a/gcd(a,b)*b;}
// head
const int mxN = 3e3+3;
int n;
ll dp[mxN][mxN], a[mxN];
int main() {
	ios::sync_with_stdio(0); 
	cin.tie(0); cout.tie(0);
	cin >> n;
	rep(i, 0, n) cin >> a[i];
	rep(len, 1, n + 1){
		rep(l, 0, n){
			int r = l + len - 1;
			if(r >= n) break;
			if(l == r) {
				dp[l][r] = a[l];
			}
			dp[l][r] = max(a[l] - dp[l+1][r], a[r] - dp[l][r-1]);
		}
	}
	cout << dp[0][n-1] << endl;
}




Measured memory_bytes: 70016
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  double h, a;
  cin >> h >> a;
  cout << ceil(h / a) << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#define M_PI 3.1415926535897932384626433832795

int main() {
	int n;
	string s;
	cin >> n >> s;
	int count(1);
	char buffer;
	buffer = s[0];
	rep(i, n) {
		if (buffer != s[i]) {
			++count;
			buffer = s[i];
		}
	}
	cout << count;
}

Measured memory_bytes: 636
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solveA();
		// new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numA1 = 0;
		int numA2 = 0;
		int numA3 = 0;

		try {
			scanner = new Scanner(System.in);
			int[] wk = new int[3];

			for (int i = 0; i < wk.length; i++) {
				wk[i] = scanner.nextInt();
			}

			Arrays.sort(wk);
			int res = Math.abs(wk[0] - wk[1]) + Math.abs(wk[1] - wk[2]);

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

int n, m;
set<int> si;

vector<int> G[100100];

int main() {
	cin >> n >> m;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<int> ans;
	ans.push_back(1);
	si.insert(1);
	int r = 1;
	while (1) {
		bool f = 0;
		REP(i, G[r].size()) {
			int to = G[r][i];
			if (si.find(G[r][i]) == si.end()) {
				si.insert(to);
				ans.push_back(to);
				r = to;
				break;
			}
			if (i == G[r].size() - 1)f = 1;
		}
		if (f)break;
	}
	r = 1;
	reverse(ALL(ans));
	while (1) {
		bool f = 0;
		REP(i, G[r].size()) {
			int to = G[r][i];
			if (si.find(G[r][i]) == si.end()) {
				si.insert(to);
				ans.push_back(to);
				r = to;
				break;
			}
			if (i == G[r].size() - 1)f = 1;
		}
		if (f)break;
	}
	cout << ans.size() << endl;
	REP(i, ans.size()) {
		if (i == 0)cout << ans[i];
		else cout <<" " << ans[i];
	}
	cout << endl;
}



Measured memory_bytes: 11384
N  = int(input())
a = input().split()
A = [int(s) for s in a]   #strのリストをintのリストに変換

Counter = 0

while True:
	for i in range(N):
		if A[i-1] % 2 == 0:	#偶数の時,2で割る
			A[i-1] = A[i-1] / 2
		else: #奇数の時,次のelseは無視されてbreak,つまりwhileのループを抜ける
			break
	else:	#else以下はfor分が最後まで行った時実行される
		Counter += 1
		i = 0
		continue

	break	

print(Counter)

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
using namespace std;

int n, k, w[100010];

bool ok(int P){
  int x = 0, y = 1;
  for(int j=0; j<n; j++){
    if(w[j] > P){
      return 0;
    }
    else{
      if(x+w[j] <= P){
	x += w[j];
      }
      else{
	y++;
	x = w[j];
      }
    }
  }
  if(y<=k) return 1;
  else return 0;
}

int main(){
  cin >> n >> k;
  for(int i=0; i<n; i++){
    cin >> w[i];
  }

  int l = 0, h =1000100000;
  while(l+1 < h){
    int m = (l+h)/2;
    if(ok(m)){
      h = m;
    }
    else{
      l = m;
    }

  }
  printf("%d\n", h);

}

Measured memory_bytes: 1532
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, C;
    cin >> A >> B >> C;
    if (A%2 == 0 || B%2 == 0 || C%2 == 0) cout << 0 << endl;
    else cout << min(A*B, min(B*C, C*A)) << endl;
    return 0;
}


Measured memory_bytes: 384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define popcnt(x) __builtin_popcount(x)
#define popcntll(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class COneStrokePath {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N, M;
        in>>N>>M;
        vvc<int> G(N);
        REP(i, M){
            int a, b;
            in>>a>>b;
            a--, b--;
            G[a].pb(b);
            G[b].pb(a);
        }
        vc<int> P(N);
        REP(i, N) P[i] = i;
        int ans = 0;
        do{
            if(P[0]!=0) break;
            bool ok = true;
            REP(i, N-1){
                int now = P[i], nxt = P[i+1];
                bool flag = false;
                for(auto& u : G[now]){
                    if(u==nxt){
                        flag = true;
                        break;
                    }
                }
                ok &= flag;
            }
            if(ok) ++ans;
        }while(next_permutation(ALL(P)));
        out<<ans<<'\n';
    }
};


int main() {
	COneStrokePath solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <queue>

using namespace std;

vector<vector<int> > road;
vector<vector<int> > railway;
map<int, int> ufroad;
map<int, int> ufrail;

map<pair<int, int>, int> ans;
int N, K, L;

void bfs(int i, map<int, int>& uf, vector<vector<int> >& g)
{
    queue<int> q;
    q.push(i);
    while (q.empty() == false)
    {
        int p = q.front();
        q.pop();
        if (uf.find(p) == uf.end())
        {
            uf.insert(make_pair(p, i));
            int n = g[p].size();
            for (int j = 0; j < n;j++)
            {
                q.push(g[p].at(j));
            }
        }
    }
}

int main()
{
    cin >> N >> K >> L;
    road.resize(2 * 100000);
    railway.resize(2 * 100000);

    for (int i = 0; i < K;i++)
    {
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        road[A].push_back(B);
        road[B].push_back(A);
    }
    for (int i = 0; i < L; i++)
    {
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        railway[A].push_back(B);
        railway[B].push_back(A);
    }

    for (int i = 0; i < N; i++)
    {
        bfs(i, ufroad, road);
        bfs(i, ufrail, railway);
    }

    for (int i = 0; i < N;i++)
    {
        pair<int, int> key = make_pair(ufroad[i], ufrail[i]);
        //cout << "first = " << key.first << " second = " << key.second << endl;
        if (ans.find(key) == ans.end())
        {
            ans.insert(make_pair(key, 1));
        }
        else
        {
            ans[key]++;
        }
    }

    for (int i = 0; i < N; i++)
    {
        pair<int, int> key = make_pair(ufroad[i], ufrail[i]);
        cout << ans[key];
        if(i != N - 1)
        {
            cout << ' ';
        }
    }

    return 0;
}

Measured memory_bytes: 42240
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define mp unordered_map
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    ll n,i,j;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    ll suff[n];
    ll sum=0;

    for(i=n-1;i>=0;i--)
    {
        sum = (sum%mod + arr[i]%mod)%mod;
        suff[i] = sum;
    }

    ll ans=0;

    for(i=0;i<n-1;i++)
    {
        ll x = (arr[i]%mod * suff[i+1]%mod)%mod;
        ans = (ans%mod + x%mod)%mod;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 6716
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int MOD = 1000000007;

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

    long long ans = 1;
    for(int i=1; i<=n; ++i){
        ans *= i;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int N, L;
    cin >> N >> L;
    
    int flavor[N + 1];
    
    for(int i = 1; i <= N; i++){
        flavor[i] = L + i - 1;
    }
    
    // int total = 0;
    // for(int i = 1; i <= N; i++){
    //     total += flavor[i];
    // }
    
    int smallest = 1000000;
    int smallestIndex = 0;
    
    for(int i = 1; i <= N; i++){
        if(abs(flavor[i]) < abs(smallest)){
            smallest = abs(flavor[i]);
            smallestIndex = i;
        }
    }
    
    int ans = 0;

    
    for(int i = 1; i <= N; i++){
        if(i == smallestIndex){
            continue;
        } else {
        ans += flavor[i];

        }
    }
    cout << ans << endl;
    
    
}


Measured memory_bytes: 256
def solve():
    N, M, X = map(int, input().split())
    A = [int(a) for a in input().split()]
    left = 0
    right = 0
    for i, a in enumerate(A):
        if a < X: left += 1
        else: right += 1
    print(min(left, right))

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3060
h,w,m=map(int,input().split())
hs=[0 for _ in range(h)]
ws=[0 for _ in range(w)]
B=set()
for _ in range(m):
  a,b=map(int,input().split())
  a-=1
  hs[a]+=1
  b-=1
  ws[b]+=1
  B.add((a,b))
hmax=-1
wmax=-1
for i in range(h):
  hmax=max(hmax,hs[i])
for j in range(w):
  wmax=max(wmax,ws[j])
mh=[]
mw=[]
for i in range(h):
  if hs[i]==hmax:
    mh.append(i)
for j in range(w):
  if ws[j]==wmax:
    mw.append(j)

ans=hmax+wmax
cnt=0
for i in mh:
  for j in mw:
    if (i,j) in B:
      continue
    print(ans)
    exit()
print(ans-1)

    

Measured memory_bytes: 176848
n , k = map(int, input().split())
ans = 0
MOD = int(1e9+7)
for i in range(k, n + 2):
    r = (2*n-i+1) * i // 2
    l = (i - 1) * i // 2
    ans += r - l + 1
print(ans % MOD)


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

int main(void){
    
    ll n, y;
    
    cin >> n >> y;
    
    for(ll i=0; i<=n; i++){
        
        for(ll j=0; j<=n-i; j++){
            
            if(y==i*10000+j*5000+(n-i-j)*1000){
                
                cout << i << " " << j << " " << n-i-j << endl;
                return 0;
                
            }
            
        }
        
    }
    
    cout << "-1 -1 -1" << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const ll INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

int main(){
	int n;
	cin >> n;
	multiset<int> s;
	s.insert(-1);
	rep(i, n){
		int d;
		cin >> d;
		auto p = s.lower_bound(d);
		--p;
		if(*p==-1)s.insert(d);
		else{
			s.erase(s.find(*p));
			s.insert(d);
		}
	}

	cout << s.size()-1 << endl;

	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

int gcd(int a, int b) {//最大公約数
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {//最小公倍数
	int g = gcd(a, b);
	return a / g * b;
}

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

	int A, B;
	cin >> A >> B;

	cout << lcm(A, B) << endl;
	return 0;
}



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

using namespace std;

constexpr int inf = 0x7fff;

struct point{
    int x,y;
};

int main(void){
    int h,w,vcnt;

    cin >> h >> w;

    vector<vector<int>> g(h+2,vector<int>(w+2,-1));
    vector<point> pt(h*w);

    vcnt=0;
    for(int y=0; y<h; y++){
        for(int x=0; x<w; x++){
            char c;
            cin >> c;
            if(c == '.'){
                pt[vcnt].x=x;
                pt[vcnt].y=y;
                g[y+1][x+1] = vcnt;
                vcnt++;
            }
            //cout << g[y+1][x+1] << " ";
        }
        //cout << endl;
    }

    vector<vector<int>> v(vcnt,vector<int>(vcnt,inf));
    for(int i=0; i<vcnt; i++){
        int x=pt[i].x;
        int y=pt[i].y;

        int x_t[] = { 0,-1,1,0};
        int y_t[] = {-1, 0,0,1};
        for(int j=0; j<4; j++){
            int ii, jj;
            ii = y_t[j];
            jj = x_t[j];
            int p=g[y+ii+1][x+jj+1];
            if(p >= 0){
                v[p][i] = 1;
                v[i][p] = 1;
            }
            v[i][i] = 0;
        }
    }

    for(int k=0; k<vcnt; k++){
        for(int i=0; i<vcnt; i++){
            for(int j=0; j<vcnt; j++){
                v[i][j] = min(v[i][k] + v[k][j], v[i][j]);
            }
        }
    }

    int max_dist = 0;
    for(int i=0; i<vcnt; i++){
        for(int j=0; j<vcnt; j++){
            max_dist = max(v[i][j], max_dist);
            //cout << v[i][j] << " " << max_dist << endl;
        }
    }

    cout << max_dist << endl;

    return 0;
}

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

template <class T> T combi(T n, T r)
{
    if (n < 0 || n < r || r < 0)
        return 0;

    r = min(r, n - r);
    if (r == 0)
        return 1;

    vector<T> numer(r);
    vector<T> denom(r);

    iota(all(numer), n - r + 1);
    iota(all(denom), 1);

    for (T i = 1; i < r; i++) {
        T divisor = denom[i];
        if (divisor > 1) {
            T offset = (n - r) % (i + 1);
            for (T j = i; j < r; j += i + 1) {
                numer[j - offset] /= divisor;
                denom[j] /= divisor;
            }
        }
    }
    
    T p = 1;
    for(T i = 0; i < r; i++)
        p *= numer[i];

    return p;
}


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

    ll N, A, B; cin >>N>>A>>B;

    if (B - A < 0 || N <= 0 || (N==1 && A != B)) {
        cout << 0 << endl;
    } else {
        cout << B*(N-2) - A*(N-2) + 1 << endl;
    }
}


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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

#define fi first
#define se second
#define all(A) A.begin(),A.end()

using namespace std;

/////////////////////////////////////////////////////

ll N, X, M;
ll mk[101010];
ll mk2[101010];
ll i, j, k;

int main(){
    scanf("%lld%lld%lld", &N, &X, &M);
    i = 1;
    j = X;
    while(mk[j]==0){
        mk[j] = i;
        mk2[i-1] = j;
        ++i;
        j = j * j % M;
    }
    
    
    ll a = mk[j]-1;
    ll b = i-1;

    //rep(i,0,b+2){
    //    printf("%lld,", mk2[i]);
    //}
    //printf("%lld,%lld\n", a, b);

    ll ans = 0;
    if(N<a){
        rep(i,0,N){
            ans += mk2[i];
        }
    }else{
        rep(i,0,a){
            ans += mk2[i];
            //printf(" %lld:%lld,", mk2[i],ans);
        }
        ll ansp=0;
        rep(i,a,b){
            ansp += mk2[i];
        }
        N -= a;
        ll d = N / (b - a);
        ll m = N % (b - a);
        //printf("\n%lld,%lld,%lld,%lld\n",N, d, m,ansp);
        ans += d * ansp;
        rep(i,0,m){
            ans += mk2[i + a];
            //printf(" %lld:%lld,", mk2[i + a],ans);
        }
    }
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 4884
#include<bits/stdc++.h>
#define N 200005
using namespace std;
int t[N];
char s[N];
int len;
int used[N];
vector<int> g[30];
void add(int x,int y){
	for (;x<=len;x+=x&(-x)) t[x]+=y;
}
int ask(int x){
	int s=0;
	for (;x;x-=x&(-x)) s+=t[x];
	return s;
}
int main(){
	scanf("%s",s+1);
	len=strlen(s+1);
	for (int i=1;i<=len;i++)
		g[s[i]-'a'].push_back(i);
	int tmp=0;
	for (int i=0;i<26;i++)
		tmp+=(g[i].size())&1;
	if (tmp>1){
		puts("-1");
		return 0;
	}
	for (int i=1;i<=len;i++)
		add(i,1);
	long long ans=0;
	memset(used,0,sizeof(used));
	for (int i=1;i<=len;i++)
		if (!used[i]){
			int ch=s[i]-'a';
			int sz=g[ch].size();
			int u=g[ch][sz-1];
			if (i==u)
				ans+=(ask(len)-ask(i))/2;
			else
				ans+=ask(len)-ask(u);
			add(u,-1);
			add(i,-1);
			used[i]=used[u]=1;
			g[ch].erase(g[ch].end()-1);
		}
	cout<<ans;
}

Measured memory_bytes: 3064
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: u32 = read();
    let mut vec: Vec<u64> = vec![];
    for i in 0..N {
        let v = read();
        if (i == 0 && v != 0) || (i != 0 && v == 0) {
            println!("0");
            return;
        }
        vec.push(v);
    }
    vec.sort();
    // (v, count)
    let mut v2: Vec<(u64, u64)> = vec![];
    for v in vec {
        if v2.is_empty() {
            v2.push((v, 1));
        } else if v2[v2.len() - 1].0 != v {
            if v - v2[v2.len() - 1].0 != 1 {
                println!("0");
                return;
            }
            v2.push((v, 1));
        } else {
            let (last_v, last_count) = v2.pop().unwrap();
            v2.push((last_v, last_count + 1));
        }
    }
    let mut before = 1u64;
    let mut ans = 1;
    for (_, count) in v2 {
        ans *= mod_pow(before, count);
        ans %= 998_244_353;
        before = count;
    }
    println!("{}", ans);
}

fn mod_pow(base: u64, exp: u64) -> u64 {
    let mut ans = 1;
    for _ in 0..exp {
        ans *= base;
        ans %= 998_244_353;
    }
    ans
}


Measured memory_bytes: 8444
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)

typedef long long  ll;
const int maxn = 105;
const ll mod = 998244353;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;

int n,m;
int a[maxn];
char s[maxn];

int main()
{
    while(~scanf("%d",&n))
    {
        int x,y;
        int ans=0;
        for(int i=1;i<=n;i++)
        {
            scanf("%d%d",&x,&y);
            ans+=(y-x+1);
        }
        printf("%d\n",ans);
    }
}


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

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	int ans = 0;
	x -= z;
	while (x >= y + z) {
		ans++;
		x -= y + z;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;


#include <random>

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

    int D;
    cin>>D;
    int c[26];
    int q[D];
    rep(i,26){
        cin>>c[i];
    }
    int s[D][26];
    rep(i,D){
        rep(j,26){
            cin>>s[i][j];
        }
    }
    int ans=0;
    int l[26]{};
    int y=0;
    rep(i,D){

        int an=-INF;
        int x=0;
        rep(k,26){
            int a=ans;
            int la[26];
            rep(_,26){
                la[_]=l[_];
            }
            a+=s[i][k];
            rep(j,26){
                if(j==k){
                    la[k]=0;
                }else{
                    la[j]++;
                    a-=la[j]*c[j];
                }
            }
            if(an<a){
                x=k;
                an=a;
            }
        }
        y=x;
        ans+=s[i][y];
        rep(j,26){
            if(j==y){
                l[y]=0;
            }else{
                l[j]++;
                ans-=l[j]*c[j];
            }
        }
        y++;
        q[i]=y;
    }

    int tr=0;
    std::random_device rnd; 
    while(tr<=140000){
        int g=rnd()%26;
        int h=rnd()%26;
        tr++;
        int ansm=0;
        int r[D];
        rep(i,D){
            if(i==g){
                if(h!=q[i]){
                    r[i]=h;
                }else{
                    r[i]=rnd()%26;
                }

            }else{
                r[i]=q[i];
            }
        }
        int lx[26]{};
        rep(i,D){
            ansm+=s[i][r[i]];
            rep(j,26){
                if(j==r[i]){
                    lx[r[i]]=0;
                }else{
                    lx[j]++;
                    ansm-=lx[j]*c[j];
                }
            }
        }
        if(ansm>ans){
            rep(i,D){
                q[i]=r[i];
            }
            ans=ansm;
        }
    }
    rep(i,D){
        cout << q[i] << endl;
    }

    



}


Measured memory_bytes: 3728
import java.util.Scanner;

public class Main {
    static public void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H1 = sc.nextInt();
        int M1 = sc.nextInt();
        int H2 = sc.nextInt();
        int M2 = sc.nextInt();
        int K = sc.nextInt();
        
        int after = H2*60+M2;
        int before = H1*60+M1;
        System.out.println(after-K-before);
    }
}

Measured memory_bytes: 35788
#include<iostream>
#include<string>

using namespace std;
int N,x,y=0,z=0,L[100010];
long long H[100010];

int main(){
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>H[i];
    L[i]=0;
  }
  for(int i=1;i<N;i++){
    if(H[i]<=H[i-1]){
      y=y+1;
    }else{

      L[i]=y;
      y=0;
    }
  }
  L[N-1]=y;
  for(int i=0;i<N;i++){
    z=max(z,L[i]);
  }

  cout<<z;

 return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define sz(x) (int)(x).size()
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(), x.end()
using ll = long long;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin>>n>>m;
    vector<string> grid(n);
    rep(i,0,n) cin>>grid[i];
    const int INF=1e9;
    vector<vector<int>> dp(n,vector<int>(m,INF));
    dp[0][0]=grid[0][0]=='#'?1:0;
    rep(i,0,n) rep(j,0,m) {
        if(j>0) {
            int c = dp[i][j-1];
            if(grid[i][j]=='#' && grid[i][j-1]=='.') ++c;
            dp[i][j]=min(dp[i][j],c);
        }
        if(i>0) {
            int c = dp[i-1][j];
            if(grid[i][j]=='#' && grid[i-1][j]=='.') ++c;
            dp[i][j]=min(dp[i][j],c);
        }
    }
    cout<<dp[n-1][m-1]<<"\n";
}


Measured memory_bytes: 384
N, K = map(int, input().split())

treats = [False] * N
for _ in range(K):
	d = int(input())
	As = map(int, input().split())
	for A in As:
		treats[A - 1] = True

count = 0
for t in treats:
	if not t:
		count += 1

print(count)


Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
//#define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define drep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define Maxe(x) *max_element(all(x))
#define Mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
#define Fi first
#define Se second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    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;
    }

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo
//mint,dijkstra,gyakugen

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n;
        string s;
        cin>>n>>s;
        ll res=0;
        rep(i,n){
            map<char,ll> F;//前半
            map<char,ll> S;//後半
            ll x=0;
            rep(j,i+1){
                F[s[j]]++;
            }
            rep2(j,i+1,n){
                S[s[j]]++;
            }
            for(auto p:F){
                if(S[p.first]>0)x++;
            }
            res=max(res,x);
        }
        cout<<res<<endl;
    }

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

using P = pair<int, int>;

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

    int h, w, n;
    cin >> h >> w >> n;

    map<P, int> m;
    rep (i, n)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        rep (j, 3)
        {
            rep (k, 3)
            {
                int y = a - j;
                int x = b - k;
                if (IN(0, h - 2, y) && IN(0, w - 2, x))
                {
                    ++m[P{x, y}];
                }
            }
        }
    }

    vs32 ans(10, 0);
    for (auto& item : m)
    {
        ++ans[item.second];
    }
    s64 zero = (s64)(h - 2) * (w - 2);
    rep (i, 10) zero -= ans[i];

    cout << zero << "\n";
    for (int i = 1; i < 10; ++i)
    {
        cout << ans[i] << "\n";
    }

    return 0;
}



Measured memory_bytes: 58496
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
typedef long long ll;

const int N = 2e5 + 5;

template <typename T>
class segmentTree {
  typedef function<T(const T& a, const T& b)> MergeFunc;
  int n;
  vector<T> st;
  MergeFunc merge;
  T emptySegmentValue;
  inline int L(int cur) { return 2 * cur + 1; }
  inline int R(int cur) { return 2 * cur + 2; }
  void update(int cur, int s, int e, int index, T newValue) {
    if(s > index || e < index) return;
    if(s == e) return void(st[cur] = newValue);
    int mid = (s + e) / 2;
    update(L(cur), s, mid, index, newValue);
    update(R(cur), mid + 1, e, index, newValue);
    st[cur] = merge(st[L(cur)], st[R(cur)]);
  }
  T query(int cur, int s, int e, int i, int j) {
    if(s > j || e < i) return emptySegmentValue;
    if(s >= i && e <= j) return st[cur];
    int mid = (s + e) / 2;
    auto left = query(L(cur), s, mid, i, j);
    auto right = query(R(cur), mid + 1, e, i, j);
    return merge(left, right);
  }
public:
  segmentTree(int n, T emptySegmentValue, MergeFunc merge) :
    n(n), emptySegmentValue(emptySegmentValue), merge(merge) { st.resize(n << 2, T()); }
  segmentTree(int n, T emptySegmentValue, T defaultValue, MergeFunc merge) :
    n(n), emptySegmentValue(emptySegmentValue), merge(merge) { st.resize(n << 2, defaultValue); }
  void update(int index, T newValue) { update(0, 0, n - 1, index, newValue); }
  T query(int l, int r) { return query(0, 0, n - 1, l, r); }
};

int n;
int a[N], h[N];

int main()
{
  scanf("%d", &n);
  for(int i = 0; i < n; i++)
    scanf("%d", &h[i]), h[i]--;
  for(int i = 0; i < n; i++)
    scanf("%d", &a[i]);
  segmentTree<long long> st(n, 0, [](const ll& a, const ll& b) { return max(a, b); });
  long long best = 0;
  for(int i = 0; i < n; i++) {
    long long cur = a[i] + st.query(0, h[i]);
    best = max(best, cur);
    st.update(h[i], cur);
  }
  cout << best << endl;
  return 0;
}


Measured memory_bytes: 8064
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N;
  string S;
  while (cin >> N >> S) {
    vector<int> W(N + 1, 0);
    W[0] = 0;
    for (int i = 0; i < N; i++) {
      W[i + 1] = W[i] + (S[i] == 'W');
    }
    int res = 1 << 29;
    for (int i = 0; i < N; i++) {
      int tmp = W[i] + ((N - i - 1) - (W[N] - W[i + 1]));
      res = min(res, tmp);
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 1796
from collections import Counter
# N=7
# S=["beat","vet","beet","bed","vet","bet","beet"]
N=int(input())
S=[]
for i in range(N):
    S.append(input())

SC=Counter(S)
values, counts = zip(*SC.most_common())
# １番目の回数がもっとも多く投票された数
most_counts=list(counts)[0]
# 多く投票された数と同じ票数のものは何個ある確認
most_counts_len=len([i for i in list(counts) if i ==most_counts])
# 出力は辞書順にする
output_values=values[:most_counts_len]
output_values=sorted(output_values)
for i in output_values:
    print(i)

Measured memory_bytes: 125228
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

int main() {
    string s;
    while(cin >> s, s != "0"){
        auto dp = make_v(s.size()+1, 11, 0LL);
        ll ans = 0;
        for (int i = 0; i < s.size(); ++i) {
            if(s[i] != '0') dp[i+1][s[i]-'0']++;
            for (int j = 0; j < 11; ++j) {
                dp[i+1][(j*10+s[i]-'0')%11] += dp[i][j];
            }
            ans += dp[i+1][0];
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 12360
#include <stdio.h>
#include <stdlib.h>
#define FALSE 0
#define TRUE 1
#define N 2000
int *A, *m;
int n,q;
int solve(int,int);
int main(){
  int i;
  scanf("%d",&n);
  if(n > 20)
    exit(1);
  A = (int*)malloc(sizeof(int) * n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
    if(A[i] > N)
      exit(1);
  }
  
  scanf("%d",&q);
  if(q > 200)
    exit(1);
  m = (int*)malloc(sizeof(int) * q);
  for(i = 0; i < q; i++){
    scanf("%d",&m[i]);
    if(m[i] > N)
      exit(1);
  }
  
  for(i = 0; i < q; i++){
    if(solve(0,m[i]))
      printf("yes\n");
    else
      printf("no\n");
  }
  
  return 0;
  }

int solve(i,m){
  if(m == 0)
    return TRUE;
  if(i >= n)
    return FALSE;
  int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int maxn=1e5+5;
const int maxm=5e2+5;
const int maxq=55;
const int INF=0x3f3f3f3f;
int main()
{
    int n,i;
    while(~scanf("%d%d",&n,&i))
    {
        int ans=n-i+1;
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 256
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, M = list(map(int, sys.stdin.readline().split()))
ans =set( list(range(M+1)))
for i in range(N):
    _, *A = list(map(int, sys.stdin.readline().split()))
    ans &= set(A)
print(len(ans))



Measured memory_bytes: 13652
#include <stdio.h>
int main(void){
    int i , j, W, H;
    while(1){
        scanf("%d %d", &W, &H);
        if(W == 0 && H == 0){
            break;
        }
        for(i = 0; i < W; i++){
            for(j = 0; j < H; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2048
import numpy as np

h, w, k = map(int, input().split())

grid = []
for _ in range(h):
    grid.append(list(map(str, input().rstrip())))
grid = (np.array(grid)).reshape(h, -1)

x, y = np.where(grid == "#")

arr = np.zeros((h, w), dtype=int)
arr[x, y] = np.arange(1, k+1)

np.maximum.accumulate(arr, axis=1, out=arr)

for w in range(w - 2, -1, -1):
    arr[:, w] += arr[:, w+1] * (arr[:, w] == 0)

for i in range(1, h):
    if arr[i, -1] == 0:
        arr[i] += arr[i - 1]

for j in range(h - 1, -1, -1):
    if arr[j, -1] == 0:
        arr[j] += arr[j+1]

for i in range(h):
    print(*arr[i])

Measured memory_bytes: 16348
#include<bits/stdc++.h>
using namespace std;
 
/*
*****************code written By**********************
..................Marajul islam.......................
...................BSMRSTU,CSE........................
*/ 
 
int sc1() {int x; scanf("%d", &x); return x;}
 
long long sc2() {long long x; scanf("%lld", &x); return x;}
 
 
 
#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>
 
 
const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;
 
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll)a * b % mod;}
 

 
 
int solve() {
 
	string s;
	cin>>s;
	if(s[0]==s[1] && s[1]==s[2]) puts("No");
	else puts("Yes");

 
	return 0;
}
 
 
 
 
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 
	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
 
	return 0;
 
 
 
 
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 50009
using namespace std;
const int MOD=1e9+7;
int n,m;
vector<int>G;
long long f[maxn],g[maxn];
void div(int n){
	for(int i=1;i*i<=n;i++){
		if(n%i)
			continue;
		G.push_back(i);
		if(i*i!=n)
			G.push_back(n/i);
	}
	sort(G.begin(),G.end());
}
long long mgml(long long a,int b){
	long long res=1;
	while(b){
		if(b&1)
			res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}
int main(){
	cin>>n>>m;
	div(n);
	int sz=G.size();
	for(int i=0;i<sz;i++){
		f[i]=mgml(m,(G[i]+1)/2);
	}
	for(int i=0;i<sz;i++){
		g[i]=f[i];
		for(int j=0;j<i;j++){
			if(G[i]%G[j]==0){
				g[i]-=g[j];
				g[i]%=MOD;
				g[i]+=MOD;
				g[i]%=MOD;
			}
		}
	}
	long long ans=0;

		for(int i=0;i<sz;i++){
			if(G[i]%2==0){
				g[i]=g[i]*mgml(2,MOD-2)%MOD;
			}
			ans=(ans+g[i]*G[i])%MOD;
		}
	
	cout<<ans<<endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
use proconio::input;

#[allow(unused_variables)]
fn main() {
    input! {
        aaa: [[usize; 3]; 3],
        n: usize,
        ba: [usize; n]
    };

    let bingo = aaa
        .into_iter()
        .map(|x| {
            x.iter()
                .map(|y| if ba.contains(y) { true } else { false })
                .collect::<Vec<bool>>()
        })
        .collect::<Vec<Vec<bool>>>();

    let mut ans = "No";

    for i in 0..3 {
        // 縦
        if bingo[0][i] && bingo[1][i] && bingo[2][i] {
            ans = "Yes"
        }

        // 横
        if bingo[i][0] && bingo[i][1] && bingo[i][2] {
            ans = "Yes"
        }
    }

    // 斜め
    if bingo[0][0] && bingo[1][1] && bingo[2][2] {
        ans = "Yes"
    }

    if bingo[0][2] && bingo[1][1] && bingo[2][0] {
        ans = "Yes"
    }

    println!("{}", ans);
}


Measured memory_bytes: 2136
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
  int i, N, tmp, count;
  vector<int> p;
  cin >> N;
  
  for(i = 0; i < N; i++) {
    cin >> tmp;
    p.push_back(tmp);
  }
  count = 0;
  for(i = 1; i < N - 1; i++) {
    if(p[i - 1] < p[i] && p[i] < p[i + 1]) count++;
    else if(p[i - 1] > p[i] && p[i] > p[i + 1]) count++;
  }
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256