akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>

#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0) return a + b;
  if (b > a) return gcd(b, a);
  return gcd(b, a % b);
}

 

int main(void) {

  int n, m, h[200100], a[200100], b[200100];
  int c[200100] = {};
  cin >> n >> m;
  rep(i, n) cin >> h[i];
  rep(i, m) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    if (h[a[i]] <= h[b[i]]) c[a[i]]++;
    if (h[b[i]] <= h[a[i]]) c[b[i]]++;
  }

  int ans = 0;
  rep(i, n) {
    if (c[i] == 0) ans++;
  }
  cout << ans << endl;
}

  


Measured memory_bytes: 5556
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  ll ans=0,x=1;
  rep(i,n) {
    ll y=(a[i]-1)/x;
    if(y) {
      y--;
      ans+=y;
      a[i]-=y*x;
    }
    ll z=a[i]-1;
    if(z>=x) {
      a[i]-=z;
      ans++;
    }
    x=max(x,a[i]+1);
  }
  pr(ans);
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  Main();return 0;
}


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

int main(){
  int i = 0;
  int j = 0;
  int k = 200;
  int N;
  cin>>N;
  while(j<N){
    int A;
    cin>>A;
    while( i<k ){
      if( A != A/2*2)
        break;
      A /= 2;
      i++;
    }
    k = i;
    j++;
    i = 0;
  }
  
  cout<<k<<endl;
  
}

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

int main() 
{
    ll a, b, c, d;
    bool ans;
    cin >> a >> b;

    if(b >= a)
        cout << "unsafe" << endl;
    else
        cout << "safe" << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair <int,ll> pii;
int n,i=0,j=0;

int main(void)
{
  cin >> n;
  int a[2][n];
  int max=-1,tmp;
  bool turn =false;
  rep(j,2)
    {
      rep(i,n)
	{
	  cin >> a[j][i];
	}
    }
  for(int i=0;i<n;i++)
    {
      tmp=0;
      turn=false;
      for(int j=0;j<n;j++)
	{
	  if(turn==true)
	    {
	      tmp+=a[1][j];
	    }
	  else
	    {
	      tmp+=a[0][j];
	    }
	  if(j==i) 
	    {
	      turn=true;
	      tmp+=a[1][j];
	    }
	}
      if(tmp>=max)
	{
	  max=tmp;
	}
    }
  cout << max << endl;
  return 0;
}


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

#define int long long
#define double long double

using namespace std;

#define REP(i, a, b) for (int(i) = (a); i < (b); (i)++)
#define rep(i, n) REP(i, 0, n)
#define PER(i, a, b) for (int(i) = (a - 1); i >= (b); (i)--)
#define per(i, n) PER(i, n, 0)
#define each(i, n) for (auto &i : n)
#define clr(a) memset((a), 0, sizeof(a))
#define mclr(a) memset((a), -1, sizeof(a))
#define all(a) (a).begin(), (a).end()
#define dum(val) cerr << #val " = " << val << " ";
#define dump(val) cerr << #val " = " << val << endl;
#define FILL(a, v) fill(a, a + sizeof(a) / sizeof(*a), v)

typedef pair<int, int> P;
typedef tuple<int, int, int> T;

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

signed main() {
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;

	return 0;
}


Measured memory_bytes: 764
from bisect import bisect_left

s = input()
t = input()

l = len(s)

ss = s * 2
let = [[] for _ in range(26)]
for i, e in enumerate(ss, 1):
    idx = ord(e) - ord("a")
    let[idx].append(i)

for e in t:
    idx = ord(e) - ord("a")
    if not let[idx]:
        print(-1)
        exit()

i = 1
times = 0
for e in t:
    j = ord(e) - ord("a")
    choose = bisect_left(let[j], i)
    q, r = divmod(let[j][choose], l)
    times += q
    i = r + 1

ans = times * l + i - 1
print(ans)


Measured memory_bytes: 12020
function main(input) {
  var ary = input.split("\n");
  var nums = ary[0].split(" ");
  var n = parseInt(nums[0], 10);
  var k = parseInt(nums[1], 10);
  var x = ary[1].split(" ").map(i => parseInt(i, 10));
  var minTime = null;

  for (var i = 0; i < n - k + 1; i++) {
    var time = calcMinTime(i, i + k - 1, x);
    if (minTime === null || time < minTime) {
      minTime = time;
    }
  }
  console.log(minTime);
}

function calcMinTime(i, j, x) {
  var a = Math.abs(x[i]) + Math.abs(x[j] - x[i]);
  var b = Math.abs(x[j]) + Math.abs(x[j] - x[i]);
  return Math.min(a, b);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 17484
#include <vector>
#include <iostream>
#include <string>
#include <math.h>

using namespace std;



int main(void){

  vector<int> a;

  int N;

  cin >> N ;

  for(int i = 0; i<N;i++){
    int tmp;
    cin >> tmp;
    a.push_back(tmp);

  }

  int count = 0;

  for(int i = 0; i<N;i++){
    if((i+1) != a.at(i) ) {
      count++;
    }
  }

  if(count <= 2){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}




Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
#include<list>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//int型0~9を文字0~9に変換
char int_to_char(int c) {
	if (c == 0) return '0';
	if (c == 1) return '1';
	if (c == 2) return '2';
	if (c == 3) return '3';
	if (c == 4) return '4';
	if (c == 5) return '5';
	if (c == 6) return '6';
	if (c == 7) return '7';
	if (c == 8) return '8';
	if (c == 9) return '9';
	else return'x';
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}
//xとyのビットごとの排他的論理和
template<class T> T XOR(T x, T y)
{
	T n = 0;
	while (max(x, y) > pow(2, n)) n++;
	T ans=0;
	for (int i = 0; i <= n; i++)
	{
		T x1 = (x % (T)pow(2, i + 1)) / (T)pow(2, i);
		T y1 = (y % (T)pow(2, i + 1)) / (T)pow(2, i);
		if (x1 != y1) ans += (T)pow(2, i);
	}
	return ans;
}

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	long long N, X[100];
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> X[i];
	}

	int ans, t;
	for (int i = 1; i < 100; i++)
	{
		t = 0;
		for (int j = 0; j < N; j++)
		{
			t += (X[j] - i)*(X[j] - i);
		}

		if (i == 1) ans = t;
		else ans = min(ans, t);
	}

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

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

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

using pii = pair<int, int>;

double kyori(pii x, pii y) {
  return sqrt(pow(x.first - y.first, 2) + pow(x.second - y.second, 2));
}

inline void Main() {
  // code
  int n;
  double r = 0;
  pii xy[8];
  cin >> n;
  rep(i, n) cin >> xy[i].first >> xy[i].second;

  rep(i, n) {
    rep(j, n) {
      r += kyori(xy[i], xy[j]);
    }
  }

  cout << r/n << endl;
}

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


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

int A[ 100 ];

int main()
{
int N;
int i;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

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

	sort( A, A + N );

	cout << A[ N - 1 ] - A[ 0 ] << endl;

	return 0;
}





Measured memory_bytes: 256
s = input()

for i in range(len(s)-2):
    c1, c2, c3 = s[i], s[i + 1], s[i + 2]
    if c1 == c2 or c1 == c3 or c2 == c3:
        print(i+1, i+3)
        break
else:
    if len(s) == 2 and s[0] == s[1]:
        print(1, 2)
    else:
        print(-1, -1)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long UL;
typedef pair<int, int> P;
typedef pair<int, P> PPI;
typedef pair<LL, LL> PL;
typedef long long LL;
// LLONG_MIN, INT_MIN
#define xx first
#define yy second
const LL INF = 1000000000;

struct edge
{
    LL to, cost;
    edge(int a, int b):to(a), cost(b){}
};

int sm[11009][11009];
int n,m,k;

int cal(vector<int>& cut){
  int re = 0;
  vector<int> now(cut.size()), total(cut.size());
  for(int i=1;i<=m;i++){
    int idx=1;
    fill(now.begin(), now.end(), 0);
    for(int j=1;j<=n;j++)
      if(sm[j][i]==1){
        while(j>cut[idx])idx++;
        now[idx]++;
        if(now[idx]>k)return n*m*m;
      }
    int big=0;
    for(int i=0;i<cut.size();i++)
      if(total[i]+now[i]>k)big=1;
      else total[i] += now[i];
    if(big){re++;copy(now.begin(), now.end(), total.begin());}
  }
  return re;
}
int main()
{
  //freopen("input", "r", stdin);
  //freopen("output", "w", stdout);
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  cin>>n>>m>>k;
  for(int i=1;i<=n;i++){
    string ts;
    cin>>ts;
    for(int j=1;j<=m;j++)
      sm[i][j] = ts[j-1]- '0';
  }
  int ans = n*m*m;
  for(int st=0;st<(1<<(n-1));st++){
    vector<int> cut(1);
    int tmp= __builtin_popcount(st);
    for(int j=0;j<n-1;j++){
      if((st>>j)&1){
        cut.push_back(j+1);
      }
    }
    cut.push_back(n);
    tmp += cal(cut);
    // cout<<st<<" "<<tmp<<endl;
    ans = min(ans, tmp);
  }
  cout<<ans<<endl;
}


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

int main(int argc, char const *argv[])
{
	int n,k,q,right;
	while(~scanf("%d %d %d",&n,&k,&q)){
		int a[n+5];
		for (int i = 1; i <= n; ++i)
		{
			a[i]=0;
		}
		for (int i = 0; i < q; ++i)
		{
			scanf("%d",&right);
			a[right]++;
			k--;
		}
		for (int i = 1; i <= n ; ++i)
		{
			a[i]+=k;
			if (a[i]>0)
			{
				printf("Yes\n");
			}
			else{
				printf("No\n");
			}
		}

	}
	return 0;
}

Measured memory_bytes: 1024
S = input().rstrip()

while len(S) >= 5:
    if S[-5:] in ['dream', 'erase']:
        S = S[:-5]
        continue
    if S[-6:] == 'eraser':
        S = S[:-6]
        continue
    if S[-7:] == 'dreamer':
        S = S[:-7]
        continue
    print('NO')
    exit()

if len(S):
    print('NO')
else:
    print('YES')


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll l,r;
int belong(ll l,ll r){//检验[l,r-1]中是否存在r的子集
	return l<=r-(r&-r);
}
map<pair<ll,ll>,ll> M;
ll calc(ll l,ll r){//从[l,r]中选若干个，求or表示出的集合大小(不含0)
	if (l==r) return 1;
	pair<ll,ll> now(l,r);
	if (M.count(now)) return M[now];
	//按最低位取值分治
	ll ans=0;
	if (!(l&1)) ans=2*calc(l>>1,r>>1);
		else ans=calc(l>>1,r>>1)+calc((l+1)>>1,r>>1);
	if (!(r&1)) ans-=1-belong(l>>1,r>>1);
	return M[now]=ans;
}
int main()
{
	cin>>l>>r;
	cout<<calc(l,r)<<endl;
	return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> p;

  for (int i = 0; i < n; ++i) {
    int a = 0;
    cin >> a;
    p.push_back(a);
  }

  int c = 0;
  for (int i = 0; i < n; ++i) {
    if (p[i] != i + 1) {
      c++;
    }
  }

  if (c == 0 || c == 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
// #define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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

long long  func(long long  n, long long  k) {
	if (n == 0) return 0;
	if (n >= k) {
		return func(n % k, k);
	}
	else return min(n, k - n);
}

int  main() {

	long long  n, k; cin >> n >> k;
	cout << func(n, k);

	return 0;
}

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

const int MAX = 2000000;
const int MOD = 1000000007;

ll fac[MAX],finv[MAX],inv[MAX];

void COMinit() {
  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;
}

int main() {
  int x,y; cin>>x>>y;
  int p=2*y-x;
  int q=2*x-y;
  bool ok=true;
  if (p%3!=0||q%3!=0||p<0||q<0) ok=false;
  COMinit();
  ll res;
  if (ok) res=COM((p+q)/3, q/3);
  else res=0;
  cout<<res<<endl;
}


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

using namespace std;

int main() {
    int N, T, A, H[1000];
    cin >> N >> T >> A;
    for (int i = 0; i < N; ++i) {
        cin >> H[i];
    }
    double diff_min = 1.0e9;
    int tmp;
    for (int i = 0; i < N; ++i) {
        if(diff_min > abs(T - H[i]*0.006 - A)){
            tmp = i;
            diff_min = abs(T - H[i]*0.006 - A);
//            cout << diff_min << endl;
        }
    }
    cout << tmp+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define bw(i,r,l) for (int i=r-1;i>=l;i--)
#define fw(i,l,r) for (int i=l;i<r;i++)
using namespace std;
int n,k,MOD,dp[305][305],psum[305][305],c[305][305];
signed main() {
	//freopen("aome.inp","r",stdin);
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n>>k>>MOD;
	/*
	In the sequence, in an insert operation, we can insert the value x before y if:
	- x > y
	- x = y and the first integer on its right that differs from x is smaller than x
	Second case don't have to be considered since we can just insert x to the left of the other number,
	and it will just be the first case.
	So now, consider that we are inserting our next number before the number k. Then, k obviously
	must be smaller than the inserted one. Now, call:
	DP[i][j]: The number of ways to create a subtree with i verticles with the value of the root as j
	(j = K + 1 means it will be the end of the sequence, and we can insert whatever we want).
	Passing states, consider inserting a number v and have its subtree's size as p.
	Then DP[i][j] = DP[p][v] * DP[i - p][j] with v running from 1 to j, p running from 1 to i.
	This can be calculated optimally if we pre - calculate the sum of all DP[p][v] for a fixed p,
	then just multiply it up.
	Time complexity: O(NK ^ 2)
	Final answer: DP[N + 1][K + 1]
	Base case: i = 1, answer is j - 1
	*/
	fw (i,0,n+1) {
		c[i][0]=1;
		fw (j,1,i+1) c[i][j]=(c[i-1][j-1]+c[i-1][j])%MOD;
	}
	memset(dp,0,sizeof(dp)); memset(psum,0,sizeof(psum));
	fw (i,1,n+2) {
		fw (j,1,k+2) {
			if (i==1) {dp[i][j]=1; psum[i][j]=psum[i][j-1]+dp[i][j]; continue;}
			fw (p,1,i) {
				dp[i][j]+=(psum[p][j-1]*dp[i-p][j]%MOD*c[i-2][p-1])%MOD;
				dp[i][j]%=MOD;
			}
			psum[i][j]=psum[i][j-1]+dp[i][j];
			psum[i][j]%=MOD;
		}
	}
	cout<<dp[n+1][k+1];
}

Measured memory_bytes: 2432
import math
n, d = map(int,input().split())
x = [list(map(int, input().split())) for i in range(n)]

dis = 0
count = 0
for i in range(n-1):
  for j in range(i+1, n):
    val = [x-y for (x, y) in zip(x[i], x[j])]
    dis = math.sqrt(sum(map(lambda x:x**2, val)))
    if dis%1==0:
      count += 1
      
print(count)

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

map <int,int> m;

int prime(int x){
	int i;
	if(x%2 == 0){
		m[2]++;
		if(m[2] > 1){
			return 1;
		}
	}
	while(x%2==0){
		x/=2;
	}
	for(i=3;i*i<=x;i+=2){
		if(x%i==0){
			m[i]++;
			if(m[i] > 1){
				return 1;
			}
		}
		while(x%i==0){
			x/=i;
		}
	}
	if(x > 2){
		m[x]++;
		if(m[x] > 1){
			return 1;
		}
	}
return 0;
}



int gcd(int x,int y){
	if(y==0){
		return x;
	}
	return gcd(y,x%y);
}

int main()
{

	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif

    int n,i,j,g,x;
    vector <int> v;
    cin>>n;
    for(i=0;i<n;++i){
    	cin>>x;
    	v.push_back(x);
    }
    g = v[0];
    for(i=1;i<n;++i){
    	g = gcd(g,v[i]);
    }
    if(g!=1){
    	cout<<"not coprime";
    	return 0;
    }

    for(i=0;i<n;++i){
    	if(prime(v[i])){
    		cout<<"setwise coprime";
    		return 0;
    	}
    }
    cout<<"pairwise coprime";

}

Measured memory_bytes: 7368
#include<bits/stdc++.h>
using namespace std;
int main(){
	int b[3][3]={};
	int a,n;
	bool ans=false;
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>b[i][j];
		}
	}
	cin>>n;
	for(int k=0;k<n;k++){
		cin>>a;
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(a==b[i][j]){
					b[i][j]=0;
				}
			}
		}
	}
	for(int i=0;i<3;i++){//よこ
		bool t=true;
		for(int j=0;j<3;j++){
			if(b[i][j]!=0){
				t=false;
			}
		}
		if(t){
			ans=true;
		}
	}
	for(int i=0;i<3;i++){//よこ
		bool t=true;
		for(int j=0;j<3;j++){
			if(b[j][i]!=0){
				t=false;
			}
		}
		if(t){
			ans=true;
		}
	}
	if(b[0][0]==0&&b[1][1]==0&&b[2][2]==0||b[0][2]==0&&b[1][1]==0&&b[2][0]==0){
		ans=true;
	}
	if(ans){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0

for i in range(n):
    if a[i] >= b[i]:
        ans += b[i]
    else:
        x = min(b[i], a[i]+a[i+1])
        a[i+1] = a[i+1]-x+a[i]
        ans += x

print(ans)

Measured memory_bytes: 18304
#include <stdio.h>

int main(void){
	int R,G,B,N;
	int count=0;
	scanf("%d %d %d %d",&R,&G,&B,&N);

	for(int r=0; r*R<=N; r++){
		for(int g=0; r*R+g*G<=N; g++){
			if((N-r*R-g*G) % B==0){ count++;}
		}
	}
	printf("%d\n",count );
}

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

using namespace std;
using ll = long long;

int main()
{
    ll N, M;
    cin >> N >> M;

    ll A, B;
    vector<vector<ll>> V(M);
    for(ll i=0; i<N; ++i){
        cin >> A >> B;
        if(A > M) continue;
        V[M-A].push_back(B);
    }

    ll s = 0;
    priority_queue<ll> Q;
    for(ll i=M-1; i>=0; --i){
        for(auto b: V[i]) Q.push(b);
        if(!Q.empty()){
            s += Q.top();
            Q.pop();
        }
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>

using namespace std;

#define PI 3.14159265358979323846
#define INF 1e+9
#define DIV_NUM (1000000007)



int main() {

	string S, T;
	cin >> S >> T;
	int A, B;
	cin >> A >> B;
	string U;
	cin >> U;
	if (U == S) A--;
	if (U == T) B--;


	long long int N = 10000000000000;
	long long ans = 0;
	for (long long i = 0; i < N; i++) {
		ans += 1;
	}

	cout << A << " " << B << endl;

	return 0;
}


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

using namespace std;


long long f(int n) {
    if (n < 2) return 1;
    return n * f(n - 2);
}

long long d(long long n) {
    if (n % 10) {
        return 0;
    }
    return 1 + d(n / 10);
}

long long g(long long n) {
    if (n % 2 == 1) return 0;
    n /= 2;
    long long ans = 0;
    while (n > 0) {
        ans += n / 5;
        n /= 5;
    }
    return ans;
}

int main() {
    long long n;
    cin >> n;
    cout << g(n) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>

#define REP(i, N) for(int i = 0; i < N; ++i)
#define FOR(i, M, N) for(int i = M; i < N; ++i)

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	if (N % 2 == 0) {
		N = N / 2;
	}
	else if (N % 2 == 1) {
		N = (N + 1) / 2;
	}
	
	if (N >= K)cout << "YES" << endl;
	else cout << "NO" << endl;

	system("pause");
	return 0;
}

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

template<typename T, char start='a', int C=26>
struct Trie{
    struct Node{
        vector<int> ch, dp;
        T val;
        Node(){
            val = 0;
            ch.assign(C, -1);
            dp.assign(C, 0);
        }
    };

    vector<Node> nodes;
    int64_t ans = 0;

    Trie(){ nodes.push_back(Node()); }

    int add(int nd, int d, const string& S, vector<int>& num){
        if(int(S.size()) == d){
            nodes[nd].val = 1;
            return nd;
        }else{
            for(int j=0; j<26; j++) if(num[j]){
                int c = nodes[nd].ch[j];
                if(c != -1 && nodes[c].val) ans++;
            }
            int c = S[d] - start;
            num[c]--;
            if(nodes[nd].ch[c] == -1){
                nodes[nd].ch[c] = nodes.size();
                nodes.push_back(Node());
            }
            return add(nodes[nd].ch[c], d+1, S, num);
        }
    }
    int add(const string& S){
        vector<int> num(C);
        for(char c : S) num[c-'a']++;
        return add(0, 0, S, num);
    }
};

int main(){
    int N;
    cin >> N;
    vector<pair<int, string>> S(N);
    for(int i=0; i<N; i++){
        string s;
        cin >> s;
        reverse(s.begin(), s.end());
        S[i] = {int(s.size()), s};
    }
    sort(S.begin(), S.end());
    Trie<int> tr;
    for(auto& [sz, s] : S) tr.add(s);
    cout << tr.ans << endl;
    return 0;
}


Measured memory_bytes: 425580
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;

#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define fastio ios_base::sync_with_stdio(0)

int cot ;
void permute(int index , int &n)
{
	if(index == 3)
	{
		++cot ; return ;
	}
	for(int i = 1 ; i <= n ; ++i)
	{
		permute(index + 1 , n);
	}	
	return ; 
}

int main()
{
	 #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif
	fastio;cin.tie(0);cout.tie(0);
	int n ; 
	cin >> n ; 
	bool visited[n + 1] = {0};
	cot  = 0;
	permute(0 , n);
	cout << cot ;

	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
#define mp make_pair
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

ll n;
st s;
vc a;
bool b;

void srch(ll z,ll f){
  if(z==0){
    a[0]='S';
  }
  else{
    a[0]='W';
  }
  if(f==0){
    a[1]='S';
  }
  else{
    a[1]='W';
  }
  FOR(i,1,n-1){
    if((a[i]=='S'&&s[i]=='o')||(a[i]=='W'&&s[i]=='x')){
      a[i+1]=a[i-1];
    }
    else{
      if(a[i-1]=='W'){
        a[i+1]='S';
      }
      else{
        a[i+1]='W';
      }
    }
  }
  b=true;
  rep(i,2){
    ll cnt=0;
    if(a[(n-1+i)%n]=='W'){
      cnt++;
    }
    if(s[(n-1+i)%n]=='x'){
      cnt++;
    }
    if(a[(n-2+i)%n]!=a[i%n]){
      cnt++;
    }
    if(cnt%2==1){
      b=false;
    }
  }
}
int main(){
  cin >> n >> s;
  a.resize(n);
  b=false;
  srch(0,0);
  if(b){
    rep(i,n){
      cout << a[i];
    }
    return 0;
  }
  srch(0,1);
  if(b){
    rep(i,n){
      cout << a[i];
    }
    return 0;
  }
  srch(1,0);
  if(b){
    rep(i,n){
      cout << a[i];
    }
    return 0;
  }
  srch(1,1);
  if(b){
    rep(i,n){
      cout << a[i];
    }
    return 0;
  }
  cout << -1 << endl;
}

Measured memory_bytes: 3860
#include<bits/stdc++.h>
using namespace std;
         
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007  
const int N = 100001; 

// bool sortbysec(const pair<int,int> &a, const pair<int,int> &b){ 
//     return (a.second < b.second);}
 
// int fexp(int a, int b,int m){int ans = 1;while(b){if(b&1)ans=ans*a%m; b/=2;a=a*a%m;}return ans;}
// int inverse(int a, int p){return fexp(a, p-2,mod);} 

// int fac[2000001];

// int nCrModPFermat(int n, int r,int p) { 
//     if (r==0) return 1; 
//     return (fac[n]*inverse(fac[r],p)%p*inverse(fac[n-r],p)%p)%p; 
// }
 
void solve(){
	int h,w,k;cin>>h>>w>>k;
	vector<vector<char>> v(h+1,vector<char>(w+1,'.'));
	// vi r(h+1);
	// vi c(w+1);
	int ans=0,B=0;
	rep(i,0,h){
		rep(j,0,w){
			cin>>v[i][j];
			if(v[i][j]=='#'){B++;}

		}
	}
	rep(i,0,1<<h){
		// int sum=0;
		vi r(h+1);
		int num=i,k0=0;
		while(num>0){
			if(num%2)r[k0]=1;
			num=num/2;k0++;
		}
		rep(j,0,1<<w){	
			int num1=j,k1=0;
			int sum=0;
			vi c(w+1);
			while(num1>0){
				if(num1%2)c[k1]=1;
				num1=num1/2;k1++;
			}
			rep(ii,0,h){
				rep(jj,0,w){
					if((r[ii]==1||c[jj]==1)&&v[ii][jj]=='#')sum++;
				}
			}
			if(sum==B-k){
				ans++;
				// cout<<i<<" "<<j<<endl;
			}
		}
	}
	cout<<ans;
    return ;
}
         
signed main(){
        IOS;    
 

        int t=1;
        // cin>>t;
        // fac[0] = 1; 
        // for (int i=1 ; i<=2000001; i++) fac[i] = fac[i-1]*i%mod; 
        rep(i,0,t){
            solve();
            cout<<"\n";
        //   cout<<" * "<<t<<"\n";
        }
    //    return 0;
}

Measured memory_bytes: 3656
#!ruby -na
f=->n,m,a,b{a/m*n*~-n/2+(x=b%m-m*y=(b%m+n*a%=m)/m
y>0?f[y,a,m,x%a]+y*=n+x/a:0)}
p f[*$F.map(&:to_i)]if$.>1

Measured memory_bytes: 14364
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  char key1[]={'w',' ','k','s','t','n','h','m','y','r'};
  char key2[]={'a','i','u','e','o'};
	    
  string str;
  
  cin >>str;
  
  for(int i=0 ; i < (int)str.size() ; i+=2){
    if(str[i]=='0' && str[i+1]=='U'){
      cout <<"nn";
    }else{
      int num=str[i]-'0';
      if(key1[num] != ' '){
	cout <<key1[num];
      }
      if(str[i+1] == 'T'){
	cout <<key2[0];
      }else if(str[i+1] == 'L'){
	cout <<key2[1];
      }else if(str[i+1] == 'U'){
	cout <<key2[2];
      }else if(str[i+1] == 'R'){
	cout <<key2[3];
      }else{
	cout <<key2[4];
      }
    }    
  }
  cout <<endl;

  return 0;
}

Measured memory_bytes: 1176
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c,d;
	while( ~scanf("%d %d %d %d",&a,&b,&c,&d) ){
		int sum1, sum2;
		sum1 = a + b;
		sum2 = c + d;
		if( sum1 > sum2 )
			printf("Left\n");
		else if( sum1 == sum2 )
			printf("Balanced\n");
		else if( sum1 < sum2 )
			printf("Right\n");
	}
}

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

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

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

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

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

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

    int H, W;
    cin >> H >> W;
    int N;
    cin >> N;
    vector<int> v(N + 1);
    for(int i = 1; i <= N; ++i) {
        cin >> v[i];

    }

    int mp[105][105];
    int x, y;
    x = 1, y = 1;
    int p = 1;
    bool f = true;
    int c = H * W;
    while(c > 0) {
        mp[y][x] = p;
        v[p]--;
        if(v[p] == 0) ++p;

        if(f) {
            if(x == W) {
                f = false;
                y++;

            } else {
                x++;

            }
        } else {
            if(x == 1) {
                f = true;
                y++;

            } else {
                x--;

            }
        }
        --c;
    }

    for(int i = 1; i <= H; ++i) {
        for(int j = 1; j <= W; ++j) {
            cout << mp[i][j] << " ";

        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;

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

int main() {
  int n;
  cin >> n;
  rep (iii, n) {
    cout << "Case " << iii + 1 << ":" << endl;
    int k;
    cin >> k;
    rep (i, 10) {
      k = k * k % 1000000 / 100;
      cout << k << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
int main()
{
  int n,a[1000],i,min=1000000,j;

  while(1){
   
    scanf("%d",&n);
    min=1000000;
    if(n==0) break;
      
    for(i=0; i<n; i++){
      scanf("%d",&a[i]);
    }

    for(j=0; j<n; j++){
      for(i=0; i<n; i++){
	if(i!=j){
	  int sa=a[i]-a[j];

	  if(sa<0){
	    sa=-sa;

	  }
	  if(min>sa){
	    min=sa;
	  }
	  
	}
      }
    }
    printf("%d\n",min);
  }
  return 0;
}

	

Measured memory_bytes: 600
#include<stdio.h>

int main(){
	int p=1<<30,j=1<<30;
	int a;
	int i;
	for(i=0;i<3;i++){
		scanf("%d",&a);
		if(p>a)p=a;
	}
	for(i=0;i<2;i++){
		scanf("%d",&a);
		if(j>a)j=a;
	}
	printf("%d\n",p+j-50);
	return 0;
}

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

void Main()
{
  int N;
  cin >> N;
  ll happy = 0;
  while (N >= 5) {
    if (N >= 500) {N-=500; happy+=1000;}
    else if (N>=5) {N-=5; happy+=5;}
  }
  cout << happy << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <bits/extc++.h>
#define lowbit(x) ((x) & -(x))
using namespace std;

int lg[1000010];

int main() {
	int L; scanf("%d", &L);
	for (int i = 2; i <= 1000000; ++i)
		lg[i] = lg[i >> 1] + 1;
	int m = 0;
	for (int i = L; i != 0; i -= 1 << lg[i])
		++m;
	printf("%d %d\n", lg[L] + 1, m - 1 + (lg[L] << 1));
	for (int i = 0; i < lg[L]; ++i)
		printf("%d %d %d\n%d %d %d\n", i + 1, i + 2, 1 << i, i + 1, i + 2, 0);
	for (int i = L; i != 1 << lg[i]; i -= lowbit(i))
		printf("%d %d %d\n", lg[lowbit(i)] + 1, lg[i] + 1, i - lowbit(i));
	return 0;
}



Measured memory_bytes: 7720
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  int A, B;
  cin >> A >> B;
  if (A > 8 || B > 8) {
    cout << ":(\n";
  } else {
    cout << "Yay!\n";
  }
}


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


int main(void)
{
	int n,k;
	
	scanf("%d %d",&n,&k);
	
	char s[n-1];
	
	scanf("%s",s);
	
	s[k-1] = s[k-1] + 32;
	
	printf("%s\n",s);
	
	return 0;
}
	
	
	
	

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

int main()
{
    int N, L;
    vector<string> S;
    cin >> N >> L;
    string ans = "";
    for (int i = 0; i < N; ++i)
    {
        string s;
        cin >> s;
        S.push_back(s);
    }
    sort(S.begin(), S.end());
    for (int i = 0; i < N; ++i)
    {
        ans += S[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
import java.io.*;
import java.util.*;
public class Main{
  public static void main(String[] args)  throws IOException{
    Scan sc = new Scan();
    int N = sc.scanInt();
    int A[] = new int[N];
    for(int i=0;i<N;i++){
      A[i] = sc.scanInt();
    }
    int cnt = 1;
    int min = A[0];
    for(int i=1;i<N;i++){
      if(min >= A[i]){
        cnt++;
        min = A[i];
      }
    }

    System.out.println(cnt);

  }
}
class Scan
{
    private byte[] buf=new byte[1024];
    private int index;
    private InputStream in;
    private int total;
    public Scan()
    {
        in=System.in;
    }
    public int scan()throws IOException
    {
        if(total<0)
        throw new InputMismatchException();
        if(index>=total)
        {
            index=0;
            total=in.read(buf);
            if(total<=0)
            return -1;
        }
        return buf[index++];
    }
    public int scanInt()throws IOException
    {
        int integer=0;
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        int neg=1;
        if(n=='-')
        {
            neg=-1;
            n=scan();
        }
        while(!isWhiteSpace(n))
        {
            if(n>='0'&&n<='9')
            {
                integer*=10;
                integer+=n-'0';
                n=scan();
            }
            else throw new InputMismatchException();
        }
        return neg*integer;
    }
    public double scanDouble()throws IOException
    {
        double doub=0;
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        int neg=1;
        if(n=='-')
        {
            neg=-1;
            n=scan();
        }
        while(!isWhiteSpace(n)&&n!='.')
        {
            if(n>='0'&&n<='9')
            {
                doub*=10;
                doub+=n-'0';
                n=scan();
            }
            else throw new InputMismatchException();
        }
        if(n=='.')
        {
            n=scan();
            double temp=1;
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    temp/=10;
                    doub+=(n-'0')*temp;
                    n=scan();
                }
                else throw new InputMismatchException();
            }
        }
        return doub*neg;
    }
    public String scanString()throws IOException
    {
        StringBuilder sb=new StringBuilder();
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        while(!isWhiteSpace(n))
        {
            sb.append((char)n);
            n=scan();
        }
        return sb.toString();
    }
    private boolean isWhiteSpace(int n)
    {
        if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
        return true;
        return false;
    }
}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
typedef pair <string, string> pss;

#define int long long

const int N = 18 + 1;
int n, ans;
string s1, s2, s;
map <pss, int> mp;

pss solve(int msk) {
	string tmp1, tmp2;
	for (int i = 0; i < n; i++)
		if (msk & (1LL << i))
			tmp1 += s[n + i];
		else
			tmp2 += s[n + i];
	
	reverse(tmp1.begin(), tmp1.end());
	reverse(tmp2.begin(), tmp2.end());
	return pss(tmp1, tmp2);
}

pss solve2(int msk) {
	string tmp1, tmp2;
	for (int i = 0; i < n; i++)
		if (msk & (1LL << i))
			tmp1 += s[i];
		else
			tmp2 += s[i];
	
	return pss(tmp1, tmp2);
}

int32_t main() {
	cin >> n >> s;
	for (int i = 0; i < n; i++)
		s1 += s[i];
	for (int i = n; i < n; i++)
		s2 += s[i];
	
	for (int msk = 0; msk < (1LL << n); msk++) {
		pss p = solve(msk);
//		cout << p.first << " " << p.second << endl;
		mp[p]++;
	}
	
	for (int msk = 0; msk < (1LL << n); msk++) {
		pss p = solve2(msk);
		ans += mp[p];
	}
	cout << ans;
}

Measured memory_bytes: 87040
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N;
  cin >> N ;
  int i = 0 ;
 while(i<N){
   string S;
   cin >> S;
   if(S != "Y"){
     i++;
     if(i==N-1 && S != "Y"){
     cout << "Three" << endl;
       break;
     }
     }
   else if(S == "Y"){
     cout << "Four" << endl;
     break;
   }
 }
}

Measured memory_bytes: 256
#include<stdio.h>

/*箱の中に入っているボールに書かれた数の最大値をM、最大公約数を m とおく。
このとき、m, 2m, ..., M=(M/m)mを作ることができる。
*/

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

int main(void){
	int N,K,A[100000],i, M,m;

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

	M=0;
	for(i=0;i<N;i++){
		if(M<A[i]){M = A[i];}
	}
	
	m = A[0];
	for(i=0;i<N;i++){
		m = gcd(m,A[i]);
	}

	if(K <= M && K%m == 0){
		printf("POSSIBLE\n");
	}else{
		printf("IMPOSSIBLE\n");
	}
	return 0;
}

Measured memory_bytes: 512
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define pb     push_back
#define inf     2e18
#define low     -2e18
#define PI        acos(-1.0)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
const int sz = 2e5+9;
ll a[sz];
ll sum[sz];
ll N = 1e9+7;
ll mulMod(ll a,ll b,ll n)
{
    ll res = 0;
    a = a%n;
    while(b>0)
    {
        if(b%2==1)
        {
            res = (res+a)%n;
        }
        a = (a*2)%n;
        b/= 2;
    }
    return res;
}
int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    FAST
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
        if(i==0)
            sum[i]  = a[i];
        else sum[i]  = a[i]+sum[i-1];
    }
    ll ans = 0;
    for(i=0;i<n-1;i++)
    {
        x = mulMod(a[i],(sum[n-1]-sum[i]),N);
        ans = (ans+x)%N;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 6724
#include<stdio.h>
int main(){
  int n,a,b,i,j,k,m=0;
  scanf("%d %d %d",&n,&a,&b);
  for(i=n;i>=1;i--)
  {
    k=i;
    for(j=0;k!=0;){
      j+=k%10;
      k/=10;
    }
    if(j>=a && j<=b){
      m+=i;
    }
  }
  printf("%d",m);
}

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

namespace ABC042
{
    class Program
    {
        static void Main(string[] args)
        {
            a();
            //b();
            //c();
        }

        public static void a()
        {
            int[] abc = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            Array.Sort(abc);
            if (abc[0] == 5 && abc[1] == 5 && abc[2] == 7)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }

        public static void b()
        {
            int[] nl = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
            string[] s = new string[nl[0]];
            for (int i = 0; i < nl[0]; i++)
            {
                s[i] = Console.ReadLine();
            }
            Array.Sort(s);
            foreach (var x in s)
            { Console.Write(x); }
            Console.WriteLine();
        }

        public static void c()
        {
            int[] nk = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
            int[] d = Console.ReadLine().Split(' ').Select(b => int.Parse(b)).ToArray();
            int ans = nk[0];
            bool flg = false;
            while(flg == false)
            {
                string s = ans.ToString();
                foreach (var x in d)
                {
                    if(s.Contains(x.ToString()))
                    {
                        ans++;
                        break;
                    }
                    else
                    {
                        flg = true;
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = 1e9+7; typedef vector<ll> VL;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	string s;
	cin >>n >>s;
	
	VI sl(n+1), sr(n+1);
	rep(i, n) sl[i+1] = sl[i] + (s[i]=='W');
	repr(i,n-1,0) sr[i] = sr[i+1] + (s[i]=='E');
	
	int ans = n;
	rep(i, n){
		int w = sl[i] + sr[i+1];
		//dbg(i, sl[i], sr[i+1]);
		ans =min(ans, w);
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 2948
/**Bismillahir Rahmanir Rahim.**/
#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long int            ll;
typedef long double              ld;
#define Faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi                 acos(-1);
#define test        int t; cin>>t; while(t--)
//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());
//cin.getline(array,size);
int main()
{
    int s=0;
    string a,b;
    cin>>a>>b;
    for(int i=0;i<a.size();i++)
    {
        if(a[i]!=b[i])
            s++;
    }
    cout<<s<<endl;
}


Measured memory_bytes: 3916
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF 1e9
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int,int> p;

char m[21][21];
int n,w,h,gx[11],gy[11],d[21][21],dx[]={1,0,-1,0},dy[]={0,1,0,-1},D[11][11],dp[1<<11][11];

void bfs(int N){
	queue<p> q;
	rep(i,h)rep(j,w)d[i][j]=INF;
	q.push(p(gx[N],gy[N]));
	d[gy[N]][gx[N]]=0;
	while(!q.empty()){
		p c=q.front();q.pop();
		rep(i,n)if(c.first==gx[i]&&c.second==gy[i]){D[N][i]=d[gy[i]][gx[i]];}
		rep(i,4){
			int nx=c.first+dx[i],ny=c.second+dy[i];
			if(nx>=0&&nx<w&&ny>=0&&ny<h&&m[ny][nx]!='x'&&d[ny][nx]==INF){
				q.push(p(nx,ny));
				d[ny][nx]=d[c.second][c.first]+1;
			}
		}
	}
}

int main(){
	while(cin>>w>>h&&w){
		n=1;
		rep(i,11)fill(D[i],D[i]+11,INF);
		rep(i,h)rep(j,w){
			cin>>m[i][j];
			if(m[i][j]=='o'){gx[0]=j;gy[0]=i;}
			if(m[i][j]=='*'){gx[n]=j;gy[n++]=i;}
		}
		rep(i,n)bfs(i);
		rep(s,1<<n)fill(dp[s],dp[s]+n,INF);
		rep(i,n)dp[(1<<n)-2][i]=0;
		for(int s=(1<<n)-2;s>=0;s--)rep(v,n)rep(u,n)if(!(s>>u&1))dp[s][v]=min(dp[s][v],dp[s|1<<u][u]+D[v][u]);
		cout<<(dp[0][0]!=INF?dp[0][0]:-1)<<endl;
	}
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1000000000;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    int p[n];
    for(int i=0;i<n;i++) cin >> p[i];
    int maxp = 0;
    int sum = 0;
    for(int i=0;i<n;i++){
        sum += p[i];
        maxp = max(maxp, p[i]);
    }
    cout << sum - maxp / 2 << endl;
}

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

int main() {
  string s;
  cin >> s;
  
  int count = 0;
  
  if(s.size()%2==0){
    for(int i = 0; i < s.size()/2; i++){
      if(s.at(i)!=s.at(s.size()-1-i)){
        count++;
      }
    }
  }
  else{
    for(int i = 0; i < (s.size()-1)/2; i++){
       if(s.at(i)!=s.at(s.size()-1-i)){
        count++;
       }
    }
  }
    cout << count << endl;
      
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;

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

    cout << N*800 - (N/15)*200 << endl;
}



Measured memory_bytes: 256