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

/*
問題文
今日の曜日を表す文字列 S が与えられます。
S は SUN,MON,TUE,WED,THU,FRI,SAT のいずれかであり、
それぞれ日曜日、月曜日、火曜日、水曜日、木曜日、金曜日、土曜日を表します。

次の日曜日 (あす以降) が何日後か求めてください。

制約
S は SUN,MON,TUE,WED,THU,FRI,SAT のいずれか

*/

public class Main {
    public static void main(String[] args){

        // Mapの格好いい初期値の設定の仕方is何
        HashMap<String, Integer> map = new HashMap<String, Integer>();
        map.put("SUN", 7);
        map.put("MON", 6);
        map.put("TUE", 5);
        map.put("WED", 4);
        map.put("THU", 3);
        map.put("FRI", 2);
        map.put("SAT", 1);

        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        System.out.println(map.get(s));
    }
}

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

int main(){
  int n,p[11],max=100,sum=0;
    cin>>n;
  
  for(int i=0;i<n;i++){
    cin>>p[i];
    if(p[i]>=max) max=p[i];
  }

  for(int i=0;i<n;i++){
    sum+=p[i];
  }
  cout<<sum-max/2<<endl;



  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define emp emplace

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 100010;
int MOD;
vector<int> g[N];

int mul(ll a, ll b)
{
	return (a*b)%MOD;
}


int pd[N];
int pd2[N];

int solve(int u, int last)
{
	pd[u] = 1;
	for (int v : g[u])
	{
		if (v == last) continue;
		pd[u] = mul(pd[u], 1 + solve(v, u));
	}
	return pd[u];
}

void solve2(int u, int last, int up)
{
	pd2[u] = mul(pd[u], up + 1);

	vector<int> pref;
	pref.pb(1);
	for (int i = 0; i < g[u].size(); i++)
	{
		int v = g[u][i];
		int val = v == last ? 1 : pd[v] + 1;
		pref.pb(mul(pref.back(), val));
	}
	int suf = 1;
	for (int i = (int)g[u].size()-1; i >= 0; i--)
	{
		int v = g[u][i];
		if (v == last) continue;
		
		solve2(v, u, mul(mul(up+1, pref[i]), suf));
		suf = mul(suf,  pd[v] + 1);
	}
}

int main()
{
	int n;
	scanf("%d %d", &n, &MOD);
	for (int i = 0; i < n-1; i++)
	{
		int u, v;
		scanf("%d %d", &u, &v);
		g[u].pb(v);
		g[v].pb(u);
	}
	solve(1, 0);
	solve2(1, 0, 0);
	for (int i = 1; i <= n; i++)
		printf("%d\n", pd2[i]);
	return 0;
}

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

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

  int ans = 1;
  int a = 0, b = 0;
  for(int i = 0; i < n; i++){
    a = ans * 2;
    b = ans + k;
    if(a <= b)
      ans = a;
    else
      ans = b;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
n=int(input())
s=input()
R=[]
G={}
B=[]
for i in range(n):
  if s[i]=='R':
    R.append(i+1)
  elif s[i]=='G':
    G[i+1]=G.get(i+1,0)+1
  else:
    B.append(i+1)
res=len(R)*len(G)*len(B)
for i in R:
  for j in B:
    if ((i+j)%2==0 and G.get((i+j)//2,0)==1):
      res-=1
    if G.get(2*max(i,j)-min(i,j),0)==1:
      res-=1
    if G.get(2*min(i,j)-max(i,j),0)==1:
      res-=1
print(res)

Measured memory_bytes: 74612
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

using Weight=int;
using DArray=vector<Weight>;
using DMatrix=vector<DArray>;

static const Weight INF=1<<29;

struct Edge {
    size_t src, dst;
    Weight weight;
    Edge() {}
    Edge(size_t src, size_t dst, Weight weight=1):
        src(src), dst(dst), weight(weight)
    {}
};

bool operator<(const Edge &e, const Edge &f) {
    if (e.weight != f.weight) {
        return e.weight > f.weight;
    } else {
        return e.src!=f.src? e.src<f.src : e.dst<f.dst;
    }
}

using Edges=vector<Edge>;
using Vertex=vector<Edge>;
using Graph=vector<Vertex>;

void join(Graph &g, size_t s, size_t d, Weight w=1) {
    // non-directed
    g[s].push_back(Edge(s, d, w));
    g[d].push_back(Edge(d, s, w));
}

void connect(Graph &g, size_t s, size_t d, Weight w=1) {
    // directed
    g[s].push_back(Edge(s, d, w));
}

template <class T>
using lp_queue=priority_queue<T, deque<T>, greater<T>>;

vector<Weight> shortest_distance(const Graph &g, size_t s) {
    /* Dijkstra */
    size_t V=g.size();
    vector<Weight> d(V, INF); d[s]=0;

    lp_queue<pair<Weight, size_t>> q; q.push(make_pair(0, s));
    while (!q.empty()) {
        pair<Weight, size_t> p=q.top(); q.pop();
        size_t v=p.second;
        if (d[v] < p.first) continue;

        for (const Edge &e: g[v])
            if (d[e.dst] > d[v] + e.weight) {
                d[e.dst] = d[v] + e.weight;
                q.push(make_pair(d[e.dst], e.dst));
            }
    }
    return d;
}

int main() {
    size_t n;
    scanf("%zu", &n);

    Graph g(n);
    for (size_t i=0; i<n; ++i) {
        size_t u, k;
        scanf("%zu %zu", &u, &k);

        for (size_t j=0; j<k; ++j) {
            size_t c;
            Weight v;
            scanf("%zu %d", &c, &v);

            connect(g, u, c, v);
        }
    }

    vector<Weight> d=shortest_distance(g, 0);
    for (size_t i=0; i<n; ++i)
        printf("%zu %d\n", i, d[i]);

    return 0;
}

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

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	int d=3;
	if(a==b){
		d--;
	}
	if(a==c){
		d--;
	}
	if(b==c){
		d--;
	}
	if(a==b&&b==c){
		d++;
	}
	cout<<d<<endl;
}


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

int main() {
  int n;
  cin >> n;
  
  long long ans = 0;
  for ( int i = 1; i <= n; i++ ) {
    ans += ( i%3 == 0 || i%5 == 0 ) ? 0 : i;
  }

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


Measured memory_bytes: 3632
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

pair<int,int> a[100010];

int main()
{
    #ifdef waltz
        freopen("input.txt","r",stdin);
    #endif
    int n;scanf("%d",&n);
    for (int i=1;i<=n;i++) {scanf("%d",&a[i].first);a[i].second=i;}
    sort(a+1,a+n+1);
    int ans=0;
    for (int i=1;i<=n;i++) ans+=(abs(a[i].second-i)&1);
    printf("%d\n",ans>>1);
    return 0;
}


Measured memory_bytes: 896
a = []
for i in range(5):
    a.append(int(input()))
k = int(input())
ans = 0

for i in range(5):
    for j in range(5):
        if i == j: continue
        if abs(a[i] - a[j]) > k:
            ans += 1
print(':(' if ans > 0 else 'Yay!')

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

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

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

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

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

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

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

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




void solve() {
    int n; cin >> n;
    cout << n*2*pi << endl;
}

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


Measured memory_bytes: 7904
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;

int main(){
	cin>>n;
	double S=0;
	for(int i=0;i<n;i++){
		double x;
		cin>>x;
		S+=1.0/x;
	}
	cout<<syosu(9)<<1.0/S<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();
	
	ll A; cin >> A;
	string a; cin >> a;
	ll b = 0;
	rep(i, 0, a.size()) {
		if (a[i] == '.')continue;
		b *= 10;
		b += a[i] - '0';
	}
	ll ans = A * b;
	ans /= 100;
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define fi first
#define se second
#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)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;


int main() {
    ll n;
    cin>>n;
    vector<int> d(n);
    int k=0;


    rep(i,n){
        cin>>d[i];
    }

    sort(d.begin(),d.end());
    k=d[d.size()/2]-d[d.size()/2-1];

    cout<<k<<endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#pragma GCC optimize("O2")
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline char CH()
{
  static char buf[100000],*ptr1=buf,*ptr2=buf;
  return ptr1==ptr2&&(ptr2=(ptr1=buf)+fread(buf,1,100000,stdin),ptr1==ptr2)?EOF:*ptr1++;
}
static inline int IN(void)
{
  int x=0,f=0,c=CH();while(c<48||c>57){f^=c==45,c=CH();}
  while(c>47&&c<58){x=x*10+c-48,c=CH();}return f?-x:x;
}
static inline void OUT(long x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
static inline void Radix32(int A[],const int sz)
{
  static int temp[200001];const int bit=8;
  rep(k,4)
  {
    int u[256]={},v[256]={};
    rep(i,sz)u[A[i]>>bit*k&((1<<bit)-1)]++;
    rep(i,(1<<bit)-1)u[i+1]+=u[i];
    rep(i,sz){temp[--u[A[sz-1-i]>>bit*k&((1<<bit)-1)]]=A[sz-1-i];}k++;
    rep(i,sz)v[temp[i]>>bit*k&((1<<bit)-1)]++;
    rep(i,(1<<bit)-1)v[i+1]+=v[i];
    rep(i,sz)A[--v[temp[sz-1-i]>>bit*k&((1<<bit)-1)]]=temp[sz-1-i];
  }
}
int main(void)
{
  int N=IN(),c=CH(),p=0,m=0,z=0,A[200000];
  long K=0,count=0,l=-2e18,r=-l,mid,x;while(c>47&&c<58){K=K*10+c-48,c=CH();}
  rep(i,N){x=IN();if(x>0)A[m+p++]=x;else if(x<0)A[p+m++]=x;else z++;}
  Radix32(A,m+p);
  if((K>1l*m*p)&&(2*K<=2l*m*p+1l*z*(N-1)))return puts("0"),0;
  if(K<=1l*m*p)r=1l;else l=-1l;x=1l*z*(p+m)+1l*z*(z-1)/2+1l*p*m;
  while(l<=r)
  {
    mid=(l+r)/2;count=0;
    if(mid>=0)
    {
      int plus=p-1,minus=m-1;count+=x;if(count>=K){r=mid-1l;continue;}
      rep(i,p){while(i<plus&&(1l*A[i]*A[plus]>mid)){plus--;}if(i==plus){break;}count+=1l*plus-i;}if(count>=K){r=mid-1l;continue;}
      rep(i,m){while(i<minus&&(1l*A[m+p-1-i]*A[m+p-1-minus]>mid)){minus--;}if(i==minus){break;}count+=1l*minus-i;}
    }
    else{int low=0;rep(i,m){while(1l*A[low]*A[p+i]>mid&&low<p){low++;}count+=1l*p-low;}}
    if(count>=K)r=mid-1l;else l=mid+1l;
  }
  return OUT(l),0;
}

Measured memory_bytes: 3004
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n;
	cin>>n;
	vector<int> a(n),b(n),c(n);
	FOR(i,0,n){
		cin>>a[i]>>b[i]>>c[i];
	}
	int dp[101010][3]={};
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];

	FOR(i,1,n){
		dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
		dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
		dp[i][2]=max(dp[i-1][1]+c[i],dp[i-1][0]+c[i]);
	}
	cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
    return 0;
}


Measured memory_bytes: 2560
while True:
    n,x= map(int,raw_input().split())

    if n == x == 0:
        break

    count = 0
    for i in range(1,n-1):
        for j in range(i+1,n):
            for k in range(j+1,n+1):
                s = i + j + k
                if s == x:
                     count = count + 1
                     break
                elif s > x:
                     break
    print count

Measured memory_bytes: 6452
#include <bits/stdc++.h> 
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 1e5+10;
const int N = 1e6+10;
const int E = 1e6+10;  
ll n,m;
ll a[maxn];
int main(){
	cin>>n>>m;
	double sum = 0;
	F(i,1,n){
		cin>>a[i];
		sum+=a[i];
	}
	sum = sum/(4.0*m);
	int pc = 0;
	F(i,1,n){
		if(a[i]>=sum) pc++;
	}
	if(pc>=m){
		printf("Yes\n");
	}
	else printf("No\n");
}

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

const int mod = 1000000007;

int dp[2010];

int dfs(int n) {
	if (n == 0) return 1;
	if (~dp[n]) return dp[n];
	int &res = dp[n] = 0;
	for (int i = 3; i <= n; i++) {
		res += dfs(n - i);
		res %= mod;
	}
	return res;
}

int main () {
	memset(dp, -1, sizeof(dp));
	int n; cin >> n;
	cout << dfs(n) << endl;
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k, x, a, b, c0 = 0, c1 = 0, c2 = 0, ans;
	cin >> n >> a >> b;
	while (n--) {
		cin >> x;
		if (x <= a) c0++;
		else if (x <= b) c1++;
		else c2++;
	}
	ans = min(c0, min(c1, c2));
	cout << ans << "\n";

	return 0;
}


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

using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;i++)
#define IREP(i,n) for(ll i=1;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define DEBUG(x) cerr << x << "\n"

int main(){
    string s;
    cin >> s;
    cout << count(s.begin(),s.end(),'1');
    return 0;
}

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

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

using namespace std;

int main(){
	int n; cin>>n;
	map<string,int> f;
	rep(i,n){
		string s; cin>>s;
		++f[s];
	}
	for(string s:{"AC","WA","TLE","RE"}) cout<<s<<" x "<<f[s]<<'\n';
	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
ll mypow(ll x, ll n, ll m) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		return mypow(x*x%m, n / 2, m);
	}
	else {
		return x * mypow(x, n - 1, m) % m;
	}
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

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] % INF) % INF;
}
///////////////////////////////////////


int main() {
	bool ok[3][3];
	int key[3][3];
	REP(i, 3) {
		REP(j, 3) {
			int a; cin >> a;
			key[i][j] = a;
			ok[i][j] = false;
		}
	}
	int n; cin >> n;
	REP(i, n) {
		int b; cin >> b;
		REP(j, 3) {
			REP(k, 3) {
				if (key[j][k] == b) {
					ok[j][k] = true;
				}
			}
		}
	}
	bool ans = false;
	REP(i, 3) {
		if (ok[i][0] && ok[i][1] && ok[i][2])ans = true;
		if (ok[0][i] && ok[1][i] && ok[2][i])ans = true;
	}
	if (ok[0][0] && ok[1][1] && ok[2][2])ans = true;
	if (ok[2][0] && ok[1][1] && ok[0][2])ans = true;
	if (ans)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

int main(){
  string s;
  cin >> s;
  int num=-1;
  string alp="abcdefghijklmnopqrstuvwxyz";
  bool conti=false;
  for(int i=0; i<26; i++){
    conti=false;
    for(int j=0; j<s.size(); j++){
      if(s.at(j)==alp.at(i)){
        conti=true;
        continue;
      }
    }
    if(conti)
      continue;
    else{
      num=i;
      break;
    }
  }
  if(num==-1)
    cout << "None" << endl;
  else
    cout << alp.at(num) << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<queue>
#include<map>
using namespace std;
#define N 8
int main()
{
  map<string,int>m;
  queue<string>q;
  string now,next;

  string s;
  char c;

  now="01234567";
  m[now]=0;
  q.push(now);
  while(!q.empty()){
    now=q.front();
    q.pop();
    for(int i=0;i<N;i++){
      if(now[i]!='0')continue;
      next=now;
      if(i!=0 && i!=4){
	swap(next[i],next[i-1]);
	if(!m.count(next)){
	  m[next]=m[now]+1;
	  q.push(next);
	}
      }
      next=now;
      if(i!=3 && i!=7){
	swap(next[i],next[i+1]);
	if(!m.count(next)){
	  m[next]=m[now]+1;
	  q.push(next);
	}
      }
      next=now;
      if(i<4){
	swap(next[i],next[i+4]);
	if(!m.count(next)){
	  m[next]=m[now]+1;
	  q.push(next);
	}
      }
      next=now;
      if(i>=4){
	swap(next[i],next[i-4]);
	if(!m.count(next)){
	  m[next]=m[now]+1;
	  q.push(next);
	}
      }
      break;
    }
  }


  while(cin>>c){
    s=c;
    for(int i=1;i<N;i++){
      cin>>c;
      s+=c;
    }
    cout<<m[s]<<endl;
  }
}

Measured memory_bytes: 2188
import java.util.Scanner;

public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		long[] dp = new long[2001];
		for(int i=0;i<=1000;i++)for(int j=0;j<=1000;j++)dp[i+j]++;
		while(sc.hasNext()){
			int N = sc.nextInt();
			long res = 0;
			for(int s=0;s<=2000;s++)if(0 <= N-s && N-s <= 2000)res+=dp[s]*dp[N-s];
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 20100
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
   	long x=long.Parse(Console.ReadLine());
      long zandaka=100;
      int ans=0;

      while(zandaka<x){
        
        zandaka+=(zandaka/100);
  		ans=ans+1;
      
    }

      Console.WriteLine(ans);
  }
  }

}

Measured memory_bytes: 27540
#include <bits/stdc++.h>
//#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
 
 
int main(){
   
  int64_t n,k,sum=0;
  cin>>n>>k;
  
  vector<int64_t> h(n);
  rep(i,n){
      cin>>h.at(i);
      //sum+=a.at(i);
  }
  sort(h.begin(), h.end());
  reverse(h.begin(), h.end());
  for(int i=k;i<n;i++){
      sum+=h.at(i);
  }
 
  
  cout<<sum<<endl;
      
  
  
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int n, q;
int seg[100000*4];

int query(int k, int a, int b, int l, int r) {
  if (r <= a || b <= l) return 0;
  if (l <= a && b <= r) return seg[k];
  int ret = query(2*k+1, a, (a+b)/2, l, r);
  ret += query(2*k+2, (a+b)/2, b, l, r);
  return ret;
}

void add(int k, int a, int b, int p, int x) {
  if (p < a || b <= p) return;
  if (b-a == 1) seg[k] += x;
  else {
    add(2*k+1, a, (a+b)/2, p, x);
    add(2*k+2, (a+b)/2, b, p, x);
    seg[k] = seg[2*k+1] + seg[2*k+2];
  }
}

int main(int argc, char *argv[])
{
  cin >> n >> q;
  
  for (int i = 0; i < q; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == 0) {
      add(0, 0, n, b-1, c);
    } else {
      cout << query(0, 0, n, b-1, c) << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 4116
target = raw_input()

command = []
for _ in range(int(raw_input())):
    command += [raw_input()]

for c in command:
    cmd = c.split()
    if 'replace' == cmd[0]:
        #print   target[0:int(cmd[1])] + cmd[3] + target[int(cmd[2])+1:len(target)]
        target = target[0:int(cmd[1])] + cmd[3] + target[int(cmd[2])+1:len(target)]
    if 'reverse' == cmd[0]:
        #print target[int(cmd[1]):int(cmd[2])+1]
        target = target[0:int(cmd[1])] + target[int(cmd[1]):int(cmd[2])+1][::-1] + target[int(cmd[2])+1:len(target)]
    if 'print' == cmd[0]:
       print target[int(cmd[1]):int(cmd[2])+1]

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

using namespace std;

#define LIMIT 100
typedef int64_t ll;
typedef pair<ll, ll> ii;
int gcd(ll a, ll b) { return (b==0)?a:gcd(b, a%b); }
int lcm(ll a, ll b) { ll i=(a/gcd(a,b))*b; assert(i>0); return i; }

//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);
  cin.tie(NULL);

  int n, y; cin >> n >> y;
  y /= 1000;

  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n-i; ++j) {
      int k = n-i-j;
      if(i*10 + j*5 +k == y){
        printf("%d %d %d\n", i, j, k);
        return 0;
      }

    }
  }

  printf("%d %d %d\n", -1, -1, -1);

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 	int d,n; cin>>d>>n;
  	if(d==0 && n!=100){
      cout<<n<<endl;
    }else if(d==0 && n==100){
      cout<<n+1<<endl;
    }
  
  	if(d==1 && n!=100){
      cout<<n*100<<endl;
    }else if(d==1 && n==100){
      cout<<(n+1)*100<<endl;
    }
  
  	if(d==2 && n!=100){
      cout<<n*10000<<endl;
    }else if(d==2 && n==100){
      cout<<(n+1)*10000<<endl;
    }
  	
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    int ans = 1e8;
    for (int i = 1; i <= 100; ++i) {
        int sum = 0;
        rep(j, n) {
            sum += (x[j] - i) * (x[j] - i); 
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
# -*- coding: utf-8 -*-
 
N = int(input())
P = list(map(int, input().split()))

ans = 0
min_val = P[0]
for i in range(N):
    if P[i] <= min(min_val, P[i]):
        ans += 1
        min_val = min(min_val, P[i])
print(ans)

Measured memory_bytes: 24872
#include<cstdio>
#include<iostream>
#include<map>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
typedef long long LL;
const LL mod = 1e9+7;
int main(){
	LL a,ans=1;
	cin >> a;
	for(int i = 1;i <= a;i++){
		ans*=i;
		ans%=mod;
		}
	cout << ans << endl;
	return 0;
	}


Measured memory_bytes: 256
#include<stdio.h>
int main ()
{  int n;
   scanf("%d",&n);
   int h;
   do
   {   h=n%10;
       if(h==7)
        { printf("Yes");return 0;}
        n=n/10;
   }while(n!=0);
   printf("No");
   return 0;
}

Measured memory_bytes: 1736
import java.io.*;
import java.util.Scanner;
 
class Main {
  public static void main(String args[]) {
	Scanner scanner = new Scanner(System.in);
    int input1 = scanner.nextInt();
    int input2 = input1 / 1000;
    int n1 = input1 % 1000;
    if(n1==0){
      input2 = input2 -1;
    }
    input2 = input2 + 1;
    input2 = input2 * 1000;
    input1 = input2 - input1;
    
    System.out.println(input1);
  };
};

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

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll le[n+2],ri[n+2];
    memset(le, 0, sizeof(le)); 
    memset(ri, 0, sizeof(ri)); 
    for(int i=1;i<=n;i++){
    	cin >> le[i];
    	ri[i] = le[i];
    }
    for(int i=0;i<=n;i++){
    	le[i+1] ^= le[i];

    }
    for(int i=n+1;i>0;i--){
    	ri[i-1] ^= ri[i];
    }
    for(int i=1;i<=n;i++){
    	cout <<( le[i-1] ^ ri[i+1]) << " ";
    }
    cout << endl;
    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for (auto &x: h) {
    cin >> x;
  }
  sort(begin(h),end(h));
  transform(begin(h)+K-1,end(h),begin(h),begin(h),
            [](int x, int y){return x - y;});
  cout << *min_element(begin(h),end(h)-K+1) << endl;
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
const int MOD = 1000000009;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, d;
  int x[15][15];
  int cnt = 0;

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

  for(int i = 0;i < n;i++){
    for(int j = i + 1;j < n;j++){
      int temp = 0;

      for(int k = 0;k < d;k++){
	int diff = abs(x[i][k] - x[j][k]);
	diff *= diff;
	temp += diff;
      }
      for(int ans = 0;ans * ans <= temp;ans++){
	if(ans * ans == temp){
	  cnt ++;
	  break;
	}
      }
    }
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                while(sc.hasNext()){
                        double v = sc.nextDouble();
                        int n = 1;
                        while(Math.pow(2*9.8*5*(n-1),0.5) < v){
                                n++;
                        }
                        System.out.println(n);
                }
                sc.close();
        }
}

Measured memory_bytes: 12000
import bisect

mod = 1000000007

def main():
    n = int(input())
    s = input()
    if n%2!=0:
        print("No")
        return
    for i in range(n//2):
        if s[i]!=s[i+n//2]:
            print("No")
            return
    print("Yes")
    return


if __name__=='__main__':
    main()

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

int main() {
  string S;
  cin >> S;

  bool ans = true;

  if (S[0] != 'A') ans = false;
  if (isupper(S[1]) || isupper(S.back())) ans = false;

  int cnt = 0;
  for (int i = 2; i <= S.size() - 2; i++) {
    if (S[i] == 'C') cnt++;
    else if (isupper(S[i])) {
      ans = false;
      break;
    }
  }

  if (cnt != 1) ans = false;

  cout << (ans ? "AC" : "WA") << endl;
}

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n;
	cin >> n;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		if(a % 2){
			cout << "first" << endl;
			return 0;
		}
	}
	cout << "second" << endl;
}

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


int main() {
    vector<int> a = {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 k;
    cin >> k;
    cout << a[k-1] << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int ans = 0;
    for(int i = 1; i <= N; i+=2){
      int count = 0;
      for(int j = 1; j <= i; j++){
        if(i%j==0){
          count++;
        }
      }
      if(count == 8){
        ans++;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23252
#include <iostream>

using namespace std;

typedef long long ll;

const int MOD = 998244353; // change if needed

struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}

  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }

  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }

  Modint operator- () const {
    return Modint(MOD - val);
  }

  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }

  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }

  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }

  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }

  bool operator== (Modint other) const {
    return val == other.val;
  }

  bool operator!= (Modint other) const {
    return val != other.val;
  }
};

Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}

Modint inv (Modint a) {
  return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}

const int MAX_N = 1e6 + 5;

int arr [MAX_N];
ll divs [MAX_N];

int factor [MAX_N];
int mobius [MAX_N];

int calc_mob (int x) {
  int ans = 1, last = -1;
  while (x != 1) {
    if (factor[x] == last) return 0;
    ans *= -1;
    last = factor[x];
    x /= factor[x];
  }
  return ans;
}

int main () {
  ios::sync_with_stdio(false);

  for (int i = 2; i < MAX_N; i++) {
    if (factor[i] == 0) {
      for (int j = i; j < MAX_N; j += i) {
        factor[j] = i;
      }
    }
  }

  for (int i = 1; i < MAX_N; i++) {
    mobius[i] = calc_mob(i);
  }
  
  int n;
  cin >> n;
  
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    for (int k = 1; k * k <= arr[i]; k++) {
      if (arr[i] % k == 0) {
        divs[k] += arr[i];
        if (k * k != arr[i]) {
          divs[arr[i] / k] += arr[i];
        }
      }
    }
  }

  Modint ans (0);
  for (int i = 1; i < MAX_N; i++) {
    divs[i] %= MOD;
    divs[i] *= divs[i];
    divs[i] %= MOD;

    /*
    ll cur_ans = 0;
    for (int d = 1; d * d <= i; d++) {
      if (i % d == 0) {
        cur_ans += mobius[d] * divs[i / d];
        if (d * d != i) {
          cur_ans += mobius[i / d] * divs[d];
        }
      }
    }
    cur_ans %= MOD;
    cout << i << " " << cur_ans << endl;

    ans += Modint(cur_ans) * inv(Modint(i));
    */
  }

  for (int i = 1; i < MAX_N; i++) {
    ll cur_ans = 0;
    for (int k = 1; k * i < MAX_N; k++) {
      cur_ans += mobius[k] * divs[i * k];
    }
    
    Modint ca = Modint(cur_ans);
    if (ca.val < 0) ca.val += MOD;
    ans += ca * inv(Modint(i));
  }

  for (int i = 0; i < n; i++) {
    ans -= Modint(arr[i]);
  }
  ans *= inv(2);

  cout << ans << endl;
}


Measured memory_bytes: 18688
/*
  バブルソート（数列 A を読み込み、バブルソートで昇順に並び変え出力するプログラム）
  2018/04/10
*/

#include<stdio.h>

#define MAX 100

void swap(int *a,int i,int j)
{
  int temp;
  temp = a[i];
  a[i] = a[j];
  a[j] = temp;
}

int bubbleSort(int *a,int n)
{
  int i;
  int count=0;//要素の交換回数
  int flag;//逆の隣接要素が存在する
  
  flag = 1;
  while(flag){
    flag = 0;
    for(i=n-1;0<i;i--)
      if(a[i]<a[i-1]){
	swap(a,i,(i-1));
	count+=1;
	flag = 1;
      }
  }
  return count;
}

int main(void)
{
  int a[MAX];/*数列A*/
  int n;/*数列Aの要素数*/
  int count = 0;//要素の交換回数
  int i;
  
  //数列の要素数を読み込む
  fscanf(stdin,"%d",&n);

  //数列を読み込む
  for(i=0;i<n;i++)
    fscanf(stdin,"%d",&a[i]);

  count = bubbleSort(a,n);

  for(i=0;i<n-1;i++)
    printf("%d ",a[i]);
  printf("%d\n%d\n",a[i],count);

  return 0;
}


Measured memory_bytes: 2096
#include <bits/stdc++.h>
    #define MOD 1000000007LL
    using namespace std;
    typedef long long ll;
    typedef pair<int,int> P;
     
    int n,k;
    ll a[200005];
    vector<ll> b[2];
     
    int main(void){
    	scanf("%d%d",&n,&k);
    	for(int i=0;i<n;i++){
    		scanf("%lld",&a[i]);
    		if(a[i]>=0){
    			b[0].push_back(a[i]);
    		}else{
    			b[1].push_back(-a[i]);
    		}
    	}
    	sort(b[0].begin(),b[0].end());
    	sort(b[1].begin(),b[1].end());
    	ll ans=1;
    	if(n==k){
    		for(int i=0;i<b[0].size();i++){
    			ans=ans*b[0][i]%MOD;
    		}
    		for(int i=0;i<b[1].size();i++){
    			ans=ans*b[1][i]%MOD;
    		}
    		if(b[1].size()%2==1){
    			ans=MOD-ans;
    			ans%=MOD;
    		}
    	}else if(b[0].size()==0){
    		if(k%2==1){
    			for(int i=0;i<k;i++){
    				ans=ans*b[1][i]%MOD;
    			}
    			ans=MOD-ans;
    			ans%=MOD;
    		}else{
    			for(int i=b[1].size()-k;i<b[1].size();i++){
    				ans=ans*b[1][i]%MOD;
    			}
    		}
    	}else{
    		int pos0=(int)b[0].size()-1;
    		int pos1=(int)b[1].size()-1;
    		if(k%2==1){
    			ans=ans*b[0][pos0--]%MOD;
    			k--;
    		}
    		for(int i=0;i<k/2;i++){
    			bool flag=false;
    			if(pos0-1>=0 && pos1-1>=0){
    				ll v0=b[0][pos0]*b[0][pos0-1];
    				ll v1=b[1][pos1]*b[1][pos1-1];
    				if(v0<v1){
    					flag=true;
    				}
    			}else if(pos0-1<0){
    				flag=true;
    			}
    			if(!flag){
    				ll val=b[0][pos0]*b[0][pos0-1]%MOD;
    				ans=ans*val%MOD;
    				pos0-=2;
    			}else{
    				ll val=b[1][pos1]*b[1][pos1-1]%MOD;
    				ans=ans*val%MOD;
    				pos1-=2;
    			}
    		}
    	}
    	printf("%lld\n",ans);
    	return 0;
    }

Measured memory_bytes: 6616
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    vector<string> split(string s) {
        string tmp;
        vector<string> ret;
        for (int i = 0; i < s.size(); ++i) {
            if (i + 1 == s.size()) {
                if (s[i] == '\"') {
                    ret.push_back(tmp);
                    tmp = "";
                } else {
                    tmp += s[i];
                    ret.push_back(tmp);
                }
            }
            if (s[i] == '\"') {
                ret.push_back(tmp);
                tmp = "";
            } else {
                tmp += s[i];
            }
        }
        return ret;
    }

    bool solve() {
        string s1, s2;
        cin >> s1;
        if (s1 == ".") return false;
        cin >> s2;
        if (s1 == s2) {
            cout << "IDENTICAL" << endl;
            return true;
        }

        auto ss1 = split(s1);
        auto ss2 = split(s2);
        if (ss1.size() != ss2.size()) {
            cout << "DIFFERENT" << endl;
            return true;
        }

        int cnt = 0;
        for (int i = 0; i < ss1.size(); ++i) {
            if (i % 2 == 0) {
                if (ss1[i] != ss2[i]) {
                    cout << "DIFFERENT" << endl;
                    return true;
                }
            } else {
                if (ss1[i] != ss2[i]) {
                    cnt++;
                }
            }
        }
        if (cnt > 1) {
            cout << "DIFFERENT" << endl;
            return true;
        } else {
            cout << "CLOSE" << endl;
            return true;
        }


        return true;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    while (Solve().solve());

    return 0;
}



Measured memory_bytes: 3224
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

def dist(x,y):
    return min(abs(x-y), abs(24-abs(x-y)))

n = readint()
d = readints()

d.sort()

a = [0]*24
a[0]=1
for i in range(n):
    if d[i]==0:
        a[0]+=1
        continue
    if d[i]==12:
        a[12]+=1
        continue
    x = d[i]
    y = 24-d[i]
    ansx = 100
    ansy = 100
    for j in range(24):
        if a[j]:
            ansx = min(ansx, dist(x,j))
            ansy = min(ansy,dist(y,j))
    if ansx >= ansy:
        a[x]+=1
    else:
        a[y]+=1

ans = 100
for x in a:
    if x>1:
        ans = 0

if ans:
    b = []
    for i,x in enumerate(a):
        if x:
            b.append(i)
    for i in range(len(b)):
        ans = min(ans,dist(b[i],b[i-1]))
print(ans)

    








Measured memory_bytes: 63680
#include <stdio.h>

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

int W, N, v[1001], w[1001], dp[1001][1001];

int main(void){
    int n_case = 1;
    while(1){
        int x, y;
        scanf("%d", &W);
        if(W == 0) break;
        scanf("%d", &N);
        for(x = 1; x <= N; x++){
            scanf("%d,%d", &v[x], &w[x]);
        }
        for(x = 0; x <= W; x++){
            dp[0][x] = 0;
        }
        for(x = 1; x <= N; x++){
            for(y = 0; y <= W; y++){
                if(y < w[x]) dp[x][y] = dp[x-1][y];
                else dp[x][y] = max(dp[x-1][y],
                                    dp[x-1][y-w[x]] + v[x]);
            }
        }
        int max_v = 0, weight;
        for(x = 0; x <= W; x++){
            if(dp[N][x] > max_v){
                max_v = dp[N][x];
                weight = x;
            }
        }
        printf("Case %d:\n%d\n%d\n", n_case, max_v, weight);
        n_case++;
    }
    return 0;
}

Measured memory_bytes: 4520
import java.util.Scanner;

public class Main
{

  public static void main(String[] args)
  {
    try (Scanner sc = new Scanner(System.in))
    {
      String[] tmp = sc.nextLine().split(" ");
      final int A = Integer.parseInt(tmp[0]);
      final int B = Integer.parseInt(tmp[1]);
      final int X = Integer.parseInt(tmp[2]);

      System.out.println(solve(A, B, X));
    }
  }

  private static int solve(int a, int b, int x)
  {
    int ret = 0;

    if (a >= (b * 2))
    {
      ret = (x / 500) * b;
      if (x % 500 > 0)
      {
        ret += b;
      }

      return ret;
    }

    ret = x / 1000 * a;

    if (a < b)
    {
      if (x % 1000 > 0)
      {
        ret += a;
      }
      return ret;
    }

    if (x % 1000 > 500)
    {
      ret += a;
    }
    else if (x % 1000 > 0)
    {
      ret += b;
    }

    return ret;

  }
}



Measured memory_bytes: 26304
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define pi 3.141592653589
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)
using namespace std;

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



int main() {

	int a, b, c, d, e, f;
	vector<int>suger, water;
	bool w[3000] = {}, s[3000] = {};
	int answ = 0, anss = 0;
	double M = 0;

	cin >> a >> b >> c >> d >> e >> f;
	if (100 * a <= f) {
		water.push_back(100 * a); 
		w[100 * a] = true;
	}
	if (100 * b <= f) {
		water.push_back(100 * b); 
		w[100 * b] = true;
	}
	suger.push_back(c); s[c] = true;
	suger.push_back(d); s[d] = true;
	rep(i, 0, water.size()) {
		if (water[i] + 100 * a <= f) {
			if (!w[water[i] + 100 * a]) {
				water.push_back(water[i] + 100 * a);
				w[water[i] + 100 * a] = true;
			}
		}
		if (water[i] + 100 * b <= f) {
			if (!w[water[i] + 100 * b]) {
				water.push_back(water[i] + 100 * b);
				w[water[i] + 100 * b] = true;
			}
		}
	}
	rep(i, 0, suger.size()) {
		if (suger[i] + c <= f) {
			if (!s[suger[i] + c]) {
				suger.push_back(suger[i] + c);
				s[suger[i] + c] = true;
			}
		}
		if (suger[i] + d <= f) {
			if (!s[suger[i] + d]) {
				suger.push_back(suger[i] + d);
				s[suger[i] + d] = true;
			}
		}
	}
	sort(suger.begin(), suger.end());
	sort(water.begin(), water.end());
	rep(i, 0, water.size()) {
		rep(j, 0, suger.size()) {
			if ((water[i] + suger[j] <= f) && (water[i] * e / 100 >= suger[j])) {
				if ((double)suger[j] * 100 / (water[i] + suger[j]) > M) {
					M = (double)suger[j] * 100 / (water[i] + suger[j]);
					answ = water[i] + suger[j];
					anss = suger[j];
				}
			}
			else break;
		}
	}
	if(anss==0&&answ==0)cout << water[water.size()-1] << " " << anss << endl;
	else cout << answ << " " << anss << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
class Main{
    public static void main(String[] a) throws Exception{
    	ArrayList<String> lst = new ArrayList<String>();
    	
    	Scanner scan = new Scanner(System.in);
    	
    	StringBuffer a1 = new StringBuffer(scan.next());
        System.out.println(a1.reverse());
    }
}

Measured memory_bytes: 25948
#include <stdio.h>

int main () {
    int N, K, A = 1;
    scanf("%d %d", &N, &K);
    
    for (int i = 1; i <= N; i++) {
        if (A * 2 < A + K) {
            A *= 2;
        }
        else {
            A += K;
        }
    }
    printf("%d", A);
}

Measured memory_bytes: 1732
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=1e5+5;
int a[maxn],b[maxn],c[maxn],maxx[5][maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
    for(int i=1;i<=n;i++)
    {
        maxx[1][i]=max(maxx[2][i-1],maxx[3][i-1])+a[i];
        maxx[2][i]=max(maxx[1][i-1],maxx[3][i-1])+b[i];
        maxx[3][i]=max(maxx[1][i-1],maxx[2][i-1])+c[i];
    }
    int ans=max({maxx[1][n],maxx[2][n],maxx[3][n]});
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 4076
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x7f
#define MAX_INF_VAL 0x7f7f7f7f
#define pi 3.141592653589
#define eps 1e-10
//#define p 2173412051LL
#define sz 2

using namespace std;

int main() {
	int n, m;
	scanf( "%d%d", &n, &m );
	if( n == m )
		printf( "Yes" );
	else
		printf( "No" );
	return 0;
}

Measured memory_bytes: 256
import numpy as np

N, K = map(int, input().split())
S = input()

nums = np.array([len(s) for s in S.replace('10', '1,0').replace('01', '0,1').split(',')])

if S[0] == '0':
    nums = np.insert(nums, 0, 0)

if len(nums) % 2 == 0:
    nums = np.insert(nums, len(nums), 0)

csm = np.insert(nums.cumsum(), 0, 0)

res = 0
for i in range(0, len(nums), 2):
    left = i
    right = min(2*K+1 + i, len(nums))
    res = max(res, csm[right] - csm[left])
print(res)

Measured memory_bytes: 15832