akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;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 COM(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 gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	string S=in<string>();
  	int N;N=SZ(S);
  	int p[4]={0};
  	REP(i,N){
    	if(S[i]=='N'){
        	p[0]++;
        }else if(S[i]=='S'){
        	p[1]++;
        }else if(S[i]=='E'){
        	p[2]++;
        }else{
        	p[3]++;
        }
    }
  	if((p[0]==0&&p[1]==0)||p[0]&&p[1]){
    	if((p[2]==0&&p[3]==0)||p[2]&&p[3]){
    		print("Yes");
  			return 0;
        }
    }
  	print("No");
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  bool ans = 1;
  for(int i = 0; i < s.size(); i++) {
    if(i % 2 == 0) {
      if(s[i] == 'L') {
        ans = 0;
        break;
      }
    }
    if(i % 2 == 1) {
      if(s[i] == 'R') {
        ans = 0;
        break;
      }
    }
  }
  if(ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
typedef long long LL;
const int mo=1e9+7;
LL n,k,a[2005];
LL ans,sum1[2005],sum2[2005];
int main()
{
	scanf("%lld %lld",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(a[i]>a[j])
			{
				if(i>j)
					sum1[i]++;
				if(i<j)
					sum2[i]++;
			}
	for(int i=1;i<=n;i++)
	{
		LL tmp=(k*(k+1)/2)%mo;
		tmp=(tmp*sum2[i])%mo;
		ans=(ans+tmp)%mo;
		tmp=(k*(k-1)/2)%mo;
		tmp=(tmp*sum1[i])%mo;
		ans=(ans+tmp)%mo;
	}
	printf("%lld",ans);
	return 0;
} 
//2 1 2 1

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

		final int n = sc.nextInt();
		final int m = sc.nextInt();
		final int l = sc.nextInt();
		
		int[][] mat1 = new int[n][m];
		int[][] mat2 = new int[m][l];
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				mat1[i][j] = sc.nextInt();
			}
		}
		
		for(int i = 0; i < m; i++){
			for(int j = 0; j < l; j++){
				mat2[i][j] = sc.nextInt();
			}
		}
		
		for(int i = 0; i < n; i++){
			for(int k = 0; k < l; k++){
				long sum = 0;
				
				for(int j = 0; j < m; j++){
					sum += mat1[i][j] * mat2[j][k];
				}
				
				System.out.print((k == 0 ? "" : " ") + sum);
			}
			System.out.println();
		}
	}

}

Measured memory_bytes: 44820
# include <bits/stdc++.h>
using namespace std;
namespace Base{
	# define mr make_pair
	typedef long long ll;
	typedef double db;
	const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
	const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
	template<typename T> void read(T &x){
    	x = 0; int fh = 1; double num = 1.0; char ch = getchar();
		while (!isdigit(ch)){ if (ch == '-') fh = -1; ch = getchar(); }
		while (isdigit(ch)){ x = x * 10 + ch - '0'; ch = getchar(); }
	    if (ch == '.'){
	    	ch = getchar();
	    	while (isdigit(ch)){num /= 10; x = x + num * (ch - '0'); ch = getchar();}
		}
		x = x * fh;
	}
	template<typename T> void chmax(T &x, T y){x = x < y ? y : x;}
	template<typename T> void chmin(T &x, T y){x = x > y ? y : x;}
}
using namespace Base;

int main(){
	int n;
	read(n);
	cout << 360 / __gcd(n, 360) << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(){
    
    ios::sync_with_stdio(false), cin.tie(0);
	int n, k, q;
    cin >> n >> k >> q;
    vector<int> v(n+1,0);
    for(int i=0; i<q; ++i){
        int a; cin >> a;
        ++v[a];
    }
    for(int i=1; i<=n; ++i){
        cout << (k-(q-v[i])>0 ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 1024
a,b,c,x,y = map(int, input().split())
ans=10**10
for i in range(0,max(x,y)*2+1,2):
    sm=c*i
    if x-i/2>0:
        sm+=a*(x-i/2)
    if y-i/2>0:
        sm+=b*(y-i/2)
    ans=min(ans,sm)

print(int(ans))


Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
static const long long INF = 1LL<<59;
static const long long MOD = (ll)1e9+7;

#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i, n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)((v).size())
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).begin(), (v).end())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}

ll dp[55][55][110];

void solve() {
    ll N, K;
    cin >> N >> K;
    vll V(N);
    for(auto &v:V) cin >> v;
    for(ll ln = 1; ln <= N; ln++) {
        for(int l = 0; l < N - ln + 1; l++) {
            ll r = l + ln;
            for(int k = 1; k <= K; k++) {
                ll m = max(
                    dp[l+1][r][k-1] + V[l],
                    dp[l][r-1][k-1] + V[r-1]
                );
                if(k>=2) {
                    dp[l][r][k] = max(
                        m,
                        max(
                            dp[l+1][r][k-2],
                            dp[l][r-1][k-2]
                        )
                    );
                }else {
                    dp[l][r][k] = m;
                }
            }
        }
    }
    ll ans = -INF;
    REP(k, K+1) {
        ans = max(ans, dp[0][N][k]);
    }
    out(ans);
}

int main() {
    fast_io;
    cout << setprecision(20) << fixed;
    solve();
    return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const int64 infll = (1LL << 61) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

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

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

int main() {
  int N, K;
  cin >> N;
  UnWeightedGraph g(N);
  for(int i = 1; i < N; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    g[x].emplace_back(y);
    g[y].emplace_back(x);
  }
  cin >> K;
  vector< int > A(N, inf);
  priority_queue< pair< int, int > > que;
  for(int i = 0; i < K; i++) {
    int v, k;
    cin >> v >> k;
    --v;
    A[v] = k;
    que.emplace(k, v);
  }
  while(que.size()) {
    auto p = que.top();
    que.pop();
    for(auto to : g[p.second]) {
      if(A[to] == inf) {
        A[to] = A[p.second] - 1;
        que.emplace(A[to], to);
      } else if(abs(A[to] - A[p.second]) != 1) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  for(auto &p : A) cout << p << endl;

}


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

long floor_sqrt(long n){
    long s = floor(sqrt(n));
    if(s*s>n){
        s--;
    }
    if((s+1)*(s+1)<=n){
        s++;
    }
    return s;
}

long calc(long a, long b){
    long s = floor_sqrt(a*b-1);
    long ans = 2*s;
    if(min(a, b)<=s){
        ans--;
    }
    if(s*(s+1)>a*b-1){
        ans--;
    }
    return ans;
}

int main(void){
    long a, b, q;
    scanf("%ld", &q);
    for(long i=0; i<q; i++){
        scanf("%ld %ld", &a, &b);
        printf("%ld\n", calc(a, b));
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;

    string a = s.substr(0, 5);
    string b = s.substr(6, 7);
    string c = s.substr(14, 5);

    cout << a << " " << b << " " << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


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

    int N, D;
    cin >> N >> D;

    int X[200000], Y[200000];
    rep(i, N) {cin >> X[i] >> Y[i];}

    int ans = 0;
    rep(i, N) {if (pow(pow(X[i], 2) + pow(Y[i], 2), 0.5) <= D) ans++;}

    cout << ans << endl;
}

Measured memory_bytes: 5424
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int N, K;
	cin >> N >> K;

	vector<int> a;
	for (int i = 0; i < N; i++) {
		int ai;
		cin >> ai;
		if (ai >= K) continue;
		a.push_back(ai);
	}

	sort(begin(a), end(a));

	int ans = 0;
	for (int i = 0; i < a.size(); i++) {
		int discard = a[i];
		int sum = 0;
		for (int j = a.size() - 1; j >= 0; j--) {
			if (i == j) continue;
			if (sum + a[j] >= K) continue;
			sum += a[j];
		}
		if (sum + discard < K) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int y(x) {
    return x*x;
}

int area (int d) {
    int s=0, i;

    for (i=0;i<600;i+=d) {
        s+=y(i)*d;
    }
    return s;
}

int main (void) {
    int d, s;

    while (scanf("%d", &d)!=EOF) {
        s=area (d);
        printf("%d\n", s);
    }

    return 0;
}


Measured memory_bytes: 2056
#include<cstdio>
#include<iostream>
#include <string>
#include<algorithm>
using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    
    int c = ((a+b) % 2)*10;
    int d = (a+b) / 2;
    
    if(c>=5)
    {
        d = d + 1;
    }
    
    cout << d;
}




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

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b)
{
	int res = 1;

	while (b)
	{
		if (b & 1) res = (res * a);

		a = (a * a); 
		b >>= 1;
	}
	return res;
}

int gcd(int a, int b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

#define N 1000010
#define MOD 1000000007

char str[N];
int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);

	string s;
	cin >> s;

	int i = 200000;
	int j = 0;
	while (j < s.size())
	{
		str[i] = s[j];
		j++, i++;
	}

	i = 200000 - 1;
	j = i + s.size() + 1;
	int q;
	cin >> q;
	int r = 0;
	while (q--)
	{
		int f;
		cin >> f;

		if (f == 1)
		{
			r = (r + 1) % 2;
		}
		else
		{
			int b; char ch;
			cin >> b >> ch;
			if (b == 1)
			{
				if (r)
					str[j++] = ch;
				else
					str[i--] = ch;
			} 
			else
			{

				if (r)
					str[i--] = ch;	
				else
					str[j++] = ch;
			}
		}
	}
	i++;
	string ans;
	while (i < j)
	{
		ans += str[i];
		i++;
	}

	if (r)
		reverse(ans.begin(), ans.end());

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1364
import collections
xy_list = list(map(int, input().split()))

score = 0

xy_count = collections.Counter(xy_list)
if xy_count.get(1):
  score += xy_count.get(1) * 300000
  if xy_count.get(1) == 2:
    score += 400000
if xy_count.get(2):
  score += xy_count.get(2) * 200000
if xy_count.get(3):
  score += xy_count.get(3) * 100000

print(score)

Measured memory_bytes: 3436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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

vector<string> fi;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

    int H, W; cin >> H >> W;
    fi.resize(H);
    rep(i, H) cin >> fi[i];

    vector<vector<int>> dist(H, vector<int>(W, -1));
    queue<pi> que;
    rep(i, H) rep(j, W) {
        if(fi[i][j] == '#'){
            dist[i][j] = 0;
            que.push(make_pair(i, j));
        }
    }

    while(!que.empty()) {
        auto cur = que.front();
        que.pop();
        for(int dir = 0; dir < 4; dir++) {
            int nx = cur.first + dx[dir];
            int ny = cur.second + dy[dir];
            if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if(dist[nx][ny] == -1) {
                dist[nx][ny] = dist[cur.first][cur.second] + 1;
                que.push(make_pair(nx, ny));
            }
        }
    }
    int res = 0;
    rep(i, H) rep(j, W) {
        res = max(res, dist[i][j]);
    }
    COUT(res);
}

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

int main(void){
    int c;
    cin >> c;
    if(c >= 30)cout << "Yes";
    else cout << "No";
    
    
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
 
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

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

  vector<int> x(m);
  REP(i,m) cin >> x[i];

  sort(x.begin(), x.end());
  
  vec a(m - 1);
  REP(i, a.size()){
    a[i] = x[i + 1] - x[i];
  }

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

  int ans = 0;
  REP(i, a.size() - n + 1) ans += a[i];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;

int main() {
    cout.precision(20);
    double a, b;
    cin >> a >> b;
    double c, d;
    cin >> c >> d;
    int m = c * 60 + d;
    double da = m / 2.0;
    double db = (m * 6) % 360;
    if(da == db){
        cout << abs(a - b) << endl;
        return 0;
    }

    double di = db - da;

    if(abs(di) == 180){
        cout << a + b << endl;
        return 0;
    }

    double ans = 0;

    if(di > 0){
        if(di < 180){
            ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(di * M_PI / 180.0));
        } else {
            ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos((360 - di) * M_PI / 180.0));
        }
    }
    else {
        di = da - db;
        if(di < 180){
            ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(di * M_PI / 180.0));
        } else {
            ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos((360 - di) * M_PI / 180.0));
        }
    }
    cout << ans << endl;
}


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

struct Mod {
    static const int P = 998244353;
    long long k;

    Mod() = default;
    Mod(const long long k) : k(k%P) {}
};

Mod operator+(const Mod a, const Mod b) {
    return a.k + b.k;
}

Mod operator+=(Mod& a, const Mod b) {
    return a = a + b;
}

Mod operator*(const Mod a, const Mod b) {
    return a.k * b.k;
}

Mod operator*=(Mod& a, const Mod b) {
    return a = a * b;
}

Mod power(const Mod a, const int k) {
    if (k == 0) {
        return 1;
    } else if (k % 2 == 0) {
        return power(a*a, k/2);
    } else {
        return a * power(a*a, k/2);
    }
}

Mod inverse(const Mod a) {
    return power(a, Mod::P-2);
}

int main() {
    int N, A, B; long long K;
    cin >> N >> A >> B >> K;

    auto factorials = vector<Mod>(N+1);
    factorials[0] = 1;
    for (int i = 1; i <= N; i++) {
        factorials[i] = factorials[i-1] * i;
    }

    auto inverse_factorials = vector<Mod>(N+1);
    inverse_factorials[N] = inverse(factorials[N]);
    for (int i = N; i >= 1; i--) {
        inverse_factorials[i-1] = i * inverse_factorials[i];
    }

    auto binomial = [&](const int n, const int k) {
        return factorials[n] * inverse_factorials[k] * inverse_factorials[n-k];
    };

    Mod result = 0;
    for (int x = 0; x <= N; x++) {
        const long long L = K - x * A;
        if (L % B != 0) {
            continue;
        }
        const long long y = L / B;

        if (0 <= y && y <= N) {
            result += binomial(N, x) * binomial(N, int(y));
        }
    }

    cout << result.k << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
using namespace std;

int main(){
  int N, ans = 1,  num = 1 ;
  cin >> N  ;
  N %= 10 ;
  if(N == 3){
    cout << "bon" << endl ;
  }  
  else if((N == 0) || (N == 1) || (N == 6) || (N == 8) ){
    cout << "pon" << endl ;
  } 
  else{
    cout << "hon" << endl ;
  }
  return 0 ;
}  

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

int main(){
    int K, S, count=0;
    cin >> K >> S;
    for(int x=0; x<=K; x++){
        if(min(2*K-(S-x)+1, S-x+1)>0) count += min(2*K-(S-x)+1, S-x+1);
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll _pow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}


ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    ll P;
    cin >> N >> P;
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    ll ans = 0;
    if (P == 5 || P == 2) {
        rep(i, N) {
            if ((ll(S[i]) - 0x30) % P == 0) {
                ans += ll(N) - ll(i);
            }
        }
        cout << ans << endl;
        return 0;
    }
    
    vll mod10(N + 1);
    ll t = 1;
    mod10[0] = 1;
    REP(i, 1, N + 1) {
        mod10[i] = (mod10[i - 1] * 10) % P;
    }


    vll Smods(N + 1);

    map<ll, ll> Smod_map;
    Smod_map[0]++;


    REP(i, 1, N + 1) {
        Smods[i] = (Smods[i - 1] + ((ll(S[i - 1]) - 0x30) * mod10[i - 1]) % P) % P;
        Smod_map[Smods[i]]++;
    }
    

    for (auto& S : Smod_map) {
        ans += (S.second * (S.second - 1))/2;
    }

    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4244
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int k,x; cin >> k >> x;
    
    for(int i=x-k+1; i<x+k;i++) cout << i << " ";
    cout << ln;
    
    return 0;
}

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

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

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

  cout << min(a*n, b);
}

Measured memory_bytes: 256
n = int(input())
ans = []
for i in range(n):
    a, b, c = map(int, (input()).split(" "))
    if 2*max(a, b, c)**2 == a**2+b**2+c**2:
        ans.append("YES")
    else:
        ans.append("NO")
for i in ans:
    print(i)


Measured memory_bytes: 5716
package main

import (
  "fmt"
)

func main() {
  var n int
  var s string
  var k int
  fmt.Scan(&n)
  fmt.Scan(&s)
  fmt.Scan(&k)
  k--
  ck := rune(s[k])
  for _, c := range s {
    if ck == c {
      fmt.Printf("%c", c)
    } else {
      fmt.Printf("*")
    }
  }
  fmt.Printf("\n")
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pq priority_queue
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define elif else if

using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using pll=pair<ll,ll>;
using pss=pair<string,string>;
using pdd=pair<ld,ld>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ex[8]={1,1,0,-1,-1,-1,0,1};
const int ey[8]={0,1,1,1,0,-1,-1,-1};
const ld E=1e-9;

template<class T> void chmin(T &a, T b){a=min(a, b);}
template<class T> void chmax(T &a, T b){a=max(a, b);}

ll abs1(ll a){if(a>=0)return a;else return -a;}
ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1)ret*=a;
    a*=a;
    if(a>=p)a%=p;if(ret>=p)ret%=p;
    b=b>>1;
  }
  return ret;
}
int digit(ll a,ll b=10){int i=0;while(a!=0){a/=b;i++;}return i;}
ll gcd1(ll a,ll b){
  if(a==0 || b==0)return 0;
  ll n;while(a%b!=0){n=a%b;a=b;b=n;}return b;
}
ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];a[0]=n;b[0]=m;int i=1;
  while(b[i-1]!=0){a[i]=b[i-1];b[i]=a[i-1]%b[i-1];i++;}
  n=i;if(c%a[n-1]!=0)return 0;
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){ll cnt=x;x=y;y=cnt-(a[n-i-1]/b[n-i-1])*y;}
  return x;
}
ll modRev(ll a,ll p=MOD){
  a%=p;ll n=solveLinear(a,p,1);
  n%=p;if(n<0)return n+p;
  return n;
}
ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  ll ret=1;
  for(int i=1;i<=n;i++){ret=ret*i;if(ret>=p)ret%=p;}
  return ret;
}
ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  ll ret=1;
  rep(i,k){ret=ret*(n-i);if(ret>=p)ret%=p;}
  return ret;
}
ll binom(ll n,ll k,ll p=MOD){
  return (perm(n,k,p)*modRev(fact(k)))%p;
}
int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

int f(int p,int q){
  if(p>q)swap(p,q);
  int n=q/p+1,r=q%p;
  return n*p+r-1;
}

int main(){
  int i,j,k,cnt=0;
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int p=abs1(c-a),q=abs1(d-b);
  int g=gcd1(p,q);
  cout<<g*f(p/g,q/g)<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
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; }

void solve(long long N, std::string S){
    set<ll> setR, setG, setB;
    REP(i, N) {
        if(S[i]=='R') setR.insert(i);
        else if(S[i]=='G') setG.insert(i);
        else if(S[i]=='B') setB.insert(i);
    }
    ll ans = setR.size()*setG.size()*setB.size();
    for(auto x: setR){
        for(ll i=1; i<= 2000; i++){
            if(setG.count(x+i) && setB.count(x+2*i)) ans--;
            if(setB.count(x+i) && setG.count(x+2*i)) ans--;
        }
    }
    for(auto x: setG){
        for(ll i=1; i<= 2000; i++){
            if(setR.count(x+i) && setB.count(x+2*i)) ans--;
            if(setB.count(x+i) && setR.count(x+2*i)) ans--;
        }
    }
    for(auto x: setB){
        for(ll i=1; i<= 2000; i++){
            if(setG.count(x+i) && setR.count(x+2*i)) ans--;
            if(setR.count(x+i) && setG.count(x+2*i)) ans--;
        }
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 3428
N, M = map(int, input().split())
Llist=[]
Rlist=[]
for _ in range(M):
    L, R = map(int, input().split())
    Llist.append(L)
    Rlist.append(R)
ans = min(Rlist) - max(Llist) + 1
print(max(0, ans))


Measured memory_bytes: 10996
use proconio::{input, fastout};
#[fastout]
fn main() {
    input!{
        n: usize,
        m: usize,
    }
    let mut kind: Vec<usize> = vec![0;m];
    for _i in 0..n {
        input!{
            k: usize,
        }
        input!{
            mut a: [usize;k],
        }
        for j in 0..k {
            a[j] -= 1;
            kind[a[j]] += 1;
        }
    }
    let mut cnt = 0;
    for i in 0..m {
        if kind[i]==n {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i=0; i<n; i++)
	{
		cin >> a[i];
	}
	int ans[n];
	ans[0]= 0;
	ans[1]= abs(a[1]-a[0]) ;
	for(int i=2; i<n; i++)
	{
		ans[i]=min(ans[i-1]+abs(a[i]-a[i-1]),ans[i-2]+abs(a[i-2]-a[i]));
	}
	
	cout << ans[n-1];
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i,n,init) for(ll i=init;i<(n);i++)
#define repd(i,n,init) for(ll i=(n);i>=init;i--)
#define repm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define repb(bit,n,init) for(ll bit=init;bit<(1<<n);++bit)

int main()
{
    int n;
    cin >> n;
    vector<int> A(n,0);
    repi(i,n-1,0){
        int a;
        cin >> a;
        A[a-1]++;
    }
    repi(i,n,0){
        cout << A[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int A,B,C,D;
  
  cin>>A>>B>>C>>D;
  
  int sw=0;
  int sw1=0;
  
  if(A%D==0){
    sw=A/D;
  }else{
    sw=A/D+1;
  }
  
  if(C%B==0){
    sw1=C/B;
  }else{
    sw1=C/B+1;
  }
  
  if(sw<sw1){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
  
}



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

int main(void){
    int N,cnt=1;
    cin>>N;

    int d[N];
    for(int i=0;i<N;i++)
        cin>>d[i];

    sort(d,d+N);

    for(int i=1;i<N;i++){
        if(d[i]!=d[i-1])
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;
const ll inf = 1e18;


int n, m;
ll s;

int u[maxn], v[maxn];
ll a[maxn], b[maxn]; //(silver coin, time)
ll c[maxn], d[maxn]; //(silver coin, time)


vector<int> g[maxn];



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

    cin>>n>>m>>s;
    const ll MX = 50*50 + 10;

    for (int i=0; i<m; i++) {
	cin>>u[i]>>v[i]>>a[i]>>b[i];
	--u[i]; --v[i];
	g[u[i]].push_back(i);
	g[v[i]].push_back(i);
    }

    for (int i=0; i<n; i++) {
	cin>>c[i]>>d[i];
    }

    s = min(s, MX);

    vector<vector<ll>> dp(n, vector<ll>(MX+1, inf));
    dp[0][s] = 0;


    set<pair<ll,pair<int,ll>>> st;
    st.insert({0, {0, s}});


    auto add = [&](int at, ll coin, ll time) {
	if (coin<0) return;
	if (time >= dp[at][coin]) return;
	auto key = make_pair(time, make_pair(at, coin));
	if (st.count(key)) {
	    st.erase(key);
	}
	dp[at][coin] = time;
	key.first = time;
	st.insert(key);
    };


    while (!st.empty()) {
	auto cur = *st.begin();
	st.erase(st.begin());
	ll time = cur.first;
	int at = cur.second.first;
	ll coin = cur.second.second;

	// stay here
	add(at, min(MX, coin+c[at]), time+d[at]);

	// take edge
	for (int eId: g[at]) {
	    add(at^u[eId]^v[eId], coin-a[eId], time+b[eId]);
	}
    }


    for (int i=1; i<n; i++) {
	ll time = *min_element(dp[i].begin(), dp[i].end());
	cout<<time<<"\n";
    }
    
    
    return 0;
}


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

int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  
  L = A + B;
  R = C + D;
  
  if (L > R)
    cout << "Left" << endl;
  else if (L == R)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            string x = Console.ReadLine();
            char c = x[0];
            int n = (int)c;/* int.Parse(x);*/
            n += 1;
            char ans = (char)n;
            Console.Write(ans);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>

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

static const ull Money = 1e15;

struct Edge
{
    int to;
    int cost[2];

    Edge(int to_, int cost_y_, int cost_s_) :
        to{ to_ }
    {
        cost[0] = cost_y_;
        cost[1] = cost_s_;
    }

};

using Edges = vector<vector<Edge>>;


void dijkstra(int s, int flag, vector<ull>& d, Edges& edges)
{
    priority_queue<P, vector<P>, greater<P>> que;

    d[s] = 0;
    que.emplace(0, s);

    while(!que.empty()) {
        P p = que.top();
        que.pop();

        int v = p.second;

        if(d[v] < p.first) {
            continue;
        }

        for(int i = 0; i < edges[v].size(); ++i) {
            Edge e = edges[v][i];
            if(d[e.to] > d[v] + e.cost[flag]) {
                d[e.to] = d[v] + e.cost[flag];
                que.emplace(d[e.to], e.to);
            }
        }
    }
}

int main()
{
    int n, m, s, t;
    cin >> n >> m >> s >> t;

    s--;
    t--;

    Edges edges(n);

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

        u--;
        v--;

        edges[u].emplace_back(v, a, b);
        edges[v].emplace_back(u, a, b);
    }

    vector<ull> ds(n, numeric_limits<ull>::max());
    vector<ull> dt(n, numeric_limits<ull>::max());

    dijkstra(s, 0, ds, edges);
    dijkstra(t, 1, dt, edges);

    vector<ull> costs(n);

    ull c = numeric_limits<ull>::max();
    for(int i = 0; i < n; ++i) {
        c = min(c, ds[n-i-1] + dt[n-i-1]);
        costs[i] = c;
    }

    reverse(begin(costs), end(costs));

    for(int i = 0; i < n; ++i) {
        cout << Money - costs[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 10692
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {

    struct T
    {
        bool b = false;
        int w = 0;
    }t;

    int n, m;
    int p;
    int corr = 0;
    int pen = 0;
    int temp =0;
    string s;

    cin >> n >> m;
    vector<T> a (n+1);
    for(int i = 0; i < m; i++){
        cin >> p >> s;
        if(a[p].b == false){
            if(s == "AC") {
                corr++;
                a[p].b = true;
            }
            else{
                a[p].w++;
            }
        }
    }
    for(int i = 1; i < a.size(); i++){
        if(a[i].b){
            pen += a[i].w;
        }
    }
    cout<< corr << " " << pen;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define SIZE 402
using namespace std;

typedef pair<int, int> P;
const int di[] = {0, 0, -1, 1};
const int dj[] = {-1, 1, 0, 0};
char s[SIZE][SIZE];
bool t[SIZE][SIZE];

int main(){
  int h, w;
  cin >> h >> w;
  long long result = 0;
  queue<P> q;
  
  int im = h+1, jm = w+1;
  for(int i=0; i<=im; i++) t[i][0] = t[i][jm] = true;
  for(int j=0; j<=jm; j++) t[0][j] = t[im][j] = true;
  for(int i=1; i<=h; i++) scanf("%s", s[i] + 1);
  
  for(int i=1; i<=h; i++)
    for(int j=1; j<=w; j++){
      int bl = 0, wh = 0;
      if ( !t[i][j] ){
        q.push(P(i, j));
        t[i][j] = true;
      }
      while( !q.empty() ){
        P p = q.front();
        q.pop();
        if(s[p.first][p.second] == '#')bl++; else wh++;
        for(int a=0; a<4; a++){
          int k = p.first + di[a];
          int l = p.second+ dj[a];
          if(
            !t[k][l] && s[p.first][p.second] != s[k][l]
          ){
            q.push(P(k,l));
            t[k][l] = true;
          }
        }
      }
      result += (long long)bl * (long long)wh;
    }
  cout << result << endl;
}

Measured memory_bytes: 512
#include <iostream>
int main()
{
  int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int i;
  std::cin >> i;
  std::cout << arr[i-1];
  return 0;
}

Measured memory_bytes: 3152
#include <stdio.h>

int s[100000]={0};
char l[1000000]={0};

int main(){
	int n, i,st,lt;
	st=0;lt=2;
	for(i=2;i<=999999;i++)l[i]=1;
	
	while(lt<1000){
		s[st++]=lt;
		l[lt]=0;
		for(i=lt;i<999999;i++){
			if(l[i]&&i%lt==0)l[i]=0;
		}
		while(l[lt]==0 && lt < 1000000)lt++;
	}
	for(i=lt;i<999999;i++){
		if(l[i])s[st++]=i;
	}
	//i=0;
	//while(s[i])printf("%d ",s[i++]);
	while(scanf("%d",&n)>0){
		i=0;
		while(s[i]&&n>=s[i])i++;
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean[] exist = new boolean [32];

		int total = 0;

		for (int i=0;i<n;i++) {
			int tmp = sc.nextInt();
			total ^= tmp;
			exist[Integer.numberOfTrailingZeros(tmp)] = true;
		}

		System.out.println(calc(total,exist));
	}

	static int calc (int total, boolean[] exist) {
		int count = 0;
		while (total > 0) {
			int top = 31-Integer.numberOfLeadingZeros(total);
			if(exist[top]) {
				total ^= ((1 << (top+1))-1);
				count++;
			} else {
				return -1;
			}
		}
		return count;
	}

}


Measured memory_bytes: 48768
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,m,a=0,b=100000,l,r;
  cin >> n >> m;
  for(int i=0; i<m; i++) {
    cin >> l >> r;
    if(l>a) {
      a=l;
    }
    if(r<b) {
      b=r;
    }
  }
  if(a<=b) {
    cout << b-a+1 << endl;
  }
  else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
h,w,k = map(int,input().split())
ss = []
for i in range(h):
    s = list(input())
    ss.append(s)
ans = 0
for i in range(2**h):
    for j in range(2**w):
        count = 0
        for x in range(h):
            for y in range(w):
                if i>>x&1 == 1 or j>>y&1 == 1:continue
                if ss[x][y] == "#" : 
                    count += 1 
        if count == k:
            ans += 1
print(ans)


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

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int a[] = new int[n];
        int b[] = new int[n];
        int c;
        for(int i = 0; i < n; i++){
        	c = sc.nextInt();
        	a[i] = c;
        	b[i] = c;
        }
        for(int i = 0; i < n; i++){
        	a[i] = b[n - i - 1];
        	System.out.print(a[i]);
        	if(i != n - 1){
        		System.out.print(" ");
        	}
        }
        System.out.println();
    }
}


Measured memory_bytes: 26284
#include <string.h>
#include <iostream>
#include <queue>
#include <complex>
#include <functional>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

typedef complex<double> P;
#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define EQV(a,b) ( EQ( a.real(), b.real() ) && EQ( a.imag(), b.imag() ) )

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

//---------------------------------------------------------------------
struct Point {
	int x, y;
};
struct Oridir {
	char o;
	int d;
};
int n, m;
bool check[20];

vector<Point> juel(20);
vector<Oridir> mov(30);

int main() {
	while (cin >> n, n) {
		memset(check, false, sizeof(check));
		rep(i, n) cin >> juel[i].x >> juel[i].y;
		cin >> m;
		rep(i, m) cin >> mov[i].o >> mov[i].d;
		//????????????

		int x = 10, y = 10;
		rep(i, m) {
			while (mov[i].d--) {
				switch (mov[i].o) {
				case 'N': y++; break;
				case 'S': y--; break;
				case 'E': x++; break;
				case 'W': x--; break;
				default: break;
				}
				rep(j, n) {
					if (check[j]) continue;
					if (x == juel[j].x && y == juel[j].y) check[j] = true;
				}
			}
		}

		int suc = true;
		rep(j, n) {
			if (!check[j]) {
				suc = false;
				cout << "No" << endl;
				break;
			}
		}
		if (suc) cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <numeric>
#include <set>
#include <utility>
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T> &v) {
  int n = v.size();
  for (int i = 0; i < n; ++i) {
    if (i > 0) cout << ' ';
    cout << v[i];
  }
  cout << '\n';
}

int main() {

  ll n, x, m;
  cin >> n >> x >> m;
  ll a = x;
  ll r = a;
  if (n < m) {
    for (ll i = 2; i <= n; ++i) {
      a = a * a % m;
      r += a;
    }
    cout << r << '\n';
    return 0;
  }

  vector<ll> exist(m + 2, false);
  vector<ll> mod;
  mod.push_back(x);
  exist[x] = true;
  ll loop_val = -1;
  for (ll i = 2; i <= m + 1; ++i) {
    a = a * a % m;
    if (!exist[a]) {
      exist[a] = true;
      mod.push_back(a);
    } else {
      loop_val = a;
      break;
    }
  }
  ll loop_id = find(mod.begin(), mod.end(), loop_val) - mod.begin();
  ll sz = mod.size() - loop_id;
  ll loop_sum = accumulate(mod.begin() + loop_id, mod.end(), 0ll);
  ll ans = accumulate(mod.begin(), mod.begin() + loop_id, 0ll);
  ll re = n - loop_id;
  ans += re / sz * loop_sum + accumulate(mod.begin() + loop_id, mod.begin() + loop_id + re % sz, 0ll);
  cout << ans << '\n';
  return 0;
}


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

int main() {
  char c;
  cin >> c;
  if(
      c == 'a' ||
      c == 'i' ||
      c == 'u' ||
      c == 'e' ||
      c == 'o')
    cout << "vowel" << std::endl;
  else cout << "consonant" << std::endl;
}

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

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)

int main()  
{ 
    FAST_INP;
    int n;
    cin >> n;
    unordered_map<int,int> ans(n);
	for(int x=1;x<=105;x++){
		for(int y=1;y<=105;y++){
			for(int z=1;z<=105;z++){
				int k = (x*x)+(y*y)+(z*z)+(x*y)+(y*z)+(z*x);
				if( k < 10005 ) {
					ans[k]++;
				} 
			}
		}
	}
    for(int i=1;i<=n;i++){
		cout << ans[i] << "\n";
	}
    return 0;
} 

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	ll N, K;
	cin >> N >> K;
	
	int B[41] = {};
	rep(i, N) {
		ll A;
		cin >> A;
		rep(j, 41) {
			B[j] += A & 1ll;
			A /= 2;
		}
	}

	int K2[41] = {};
	rep(i, 41) {
		K2[i] = K & 1ll;
		K /= 2;
	}

	int OK = 0;
	int kotae[41] = {};
	for (int i = 40; i >= 0; i--) {
		int kari = N - B[i];
		if (OK) kotae[i] = max(B[i], kari);
		else if (K2[i]) {
			if (B[i] >= kari) {
				OK = 1;
				kotae[i] = B[i];
			}
			else {
				kotae[i] = kari;
			}
		}
		else {
			kotae[i] = B[i];
		}
	}

	ll hontou = 0;
	rep(i, 41) {
		hontou += (1ll << i) * kotae[i];
	}

	co(hontou);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec p(N); cin >> p;
    vec ans;
    while(1){
        if(p[0] == 0){
            bool f = true;
            FOR(i, 1, N) if(p[i] != i){
                f = false;
                break;
            }
            if(f) break;
        }
        if(p[0] != 0 && p[N - 1] != 0 && p[0] < p[N - 1]){
            ans.pb(N - 1);
            swap(p[0], p[N - 1]);
        }
        ans.pb(1);
        FOR(i, 1, N) swap(p[i], p[i - 1]);
        //vdebug(p);
    }
    Out(SZ(ans));
    Out(ans);

    return 0;
}


Measured memory_bytes: 1528