akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;


int main(){
  string s; cin >> s;
  // s = string(5000,'a');
  int K; cin >> K;
  int n = s.size();
  set<string> d;
  for (int i=0;i<n;i++){
    for (int k=1;k<=5;k++){
      if (i+k<=n) d.insert(s.substr(i,k));
    }
  }
  int cnt = 0;
  for (auto p : d) {
    cnt++;
    if (cnt==K) {
      cout << p << endl;
      break;
    }
  }
  

  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 4724
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	int n;
	cin>>n;
	vector<int>a(n);
	int cnt=0;
	rep(i,n){
		cin>>a[i];
		if(a[i]%2==1 and i%2==0){
			cnt++;
		}
	}
	cout<<cnt<<endl;
}

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


Measured memory_bytes: 3612
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#define n printf("consonant")
#define y printf("vowel")
#define b break
using namespace std;
char a;
int main(){
	cin>>a;
	switch(a){
		case 'a':y;b;
		case 'e':y;b;
		case 'i':y;b;
		case 'o':y;b;
		case 'u':y;b;
		default:n;b;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>



using namespace std;



int main(){

  long N;
  cin >> N;

  long min;
  for(int i = 0; i < 5; i++){
    long tmp;
    cin >> tmp;
    if(i == 0) min = tmp;
    if(tmp < min) min = tmp;
  }

  long groups = N / min;
  if(N % min != 0) groups++;
  //printf("groups : %l\n", groups);

  cout << groups+4 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<map>
#include<algorithm>
#include<cctype>
using namespace std;
const int N=1e5+5;
int num,sum;
int a[N],b[N],f[N],g[N];
bool bz[N];
map<int,int>mp;
inline int read()
{
	int X=0,w=0; char ch=0;
	while(!isdigit(ch)) w|=ch=='-',ch=getchar();
	while(isdigit(ch)) X=(X<<1)+(X<<3)+(ch^48),ch=getchar();
	return w?-X:X;
}
int get(int x)
{
	return f[x]==x?x:f[x]=get(f[x]);
}
int main()
{
	int n=read();
	for(int i=1;i<=n;i++)
	{
		int x=read();
		sum^=x;
		if(!mp.count(x)) a[i]=mp[x]=++num; else a[i]=mp[x];
		f[i]=a[i];
	}
	if(!mp.count(sum)) a[n+1]=mp[sum]=++num; else a[n+1]=mp[sum];
	f[n+1]=a[n+1];
	for(int i=1;i<=n;i++)
	{
		int x=read();
		if(!mp.count(x)) b[i]=mp[x]=++num; else b[i]=mp[x];
		g[i]=b[i];
	}
	sort(f+1,f+1+n+1);
	sort(g+1,g+1+n);
	for(int i=1,j=0;i<=n+1;i++)
	{
		if(j<n && g[j+1]==f[i]) j++;
		if(i==n+1 && j<n) return 0&puts("-1");
	}
	for(int i=1;i<=num;i++) f[i]=i;
	sum=0;
	for(int i=1;i<=n;i++)
		if(a[i]^b[i])
		{
			sum++;
			int x=get(a[i]),y=get(b[i]);
			if(x^y) f[y]=x;
		}
	for(int i=1;i<=n;i++)
		if(a[i]^b[i] && !bz[get(a[i])]) sum++,bz[get(a[i])]=true;
	if(!bz[get(a[n+1])]) sum++;
	printf("%d",sum-1);
	/*for(int i=1;i<=num;i++) f[i]=g[i]=0;
	for(int i=1;i<=n;i++)
		if(a[i]^b[i])
		{
			g[f[a[i]]=a[i]]=1;
			g[f[b[i]]=b[i]]=1;
		}
	g[f[a[n+1]]=a[n+1]]=1;
	for(int i=1;i<=n;i++)
		if(a[i]^b[i])
		{
			int x=get(a[i]),y=get(b[i]);
			if(x^y)
			{
				f[y]=x;
				g[x]+=g[y];
				g[y]=0;
			}
		}
	if(g[get(a[n+1])]>1) sum=-2; else sum=g[get(a[n+1])]=0;
	for(int i=1;i<=num;i++)
		if(g[i]) sum+=g[i]+1;
	printf("%d",sum);*/
	return 0;
}

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

long long h, w, k;
vector<string> s, t;

long long solve();

int main() {
  cin >> h >> w >> k;
  s.resize(h);
  for (int i = 0; i < h; ++i) cin >> s[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0;
  for (int i = 0; i < (1 << (h + w)); ++i) {
    t = s;
    for (int j = 0; j < h; ++j)
      if (i >> j & 1)
        for (int l = 0; l < w; ++l) t[j][l] = 'x';
    for (int j = 0; j < w; ++j)
      if (i >> (j + h) & 1)
        for (int l = 0; l < h; ++l) t[l][j] = 'x';
    int cnt = 0;
    for (int j = 0; j < h; ++j)
      for (int l = 0; l < w; ++l)
        if (t[j][l] == '#') ++cnt;
    if (cnt == k) ++res;
  }
  return res;
}

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

int main() {
  int n;
  cin >> n;
  vector<tuple<int, string, int>> shops;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int p;
    cin >> p;

    tuple<int, string, int> t = make_tuple(i + 1, s, p);
    shops.push_back(t);
  }

  stable_sort(shops.begin(), shops.end(),
              [](tuple<int, string, int> a, tuple<int, string, int> b) -> int {
                return (get<2>(a) > get<2>(b));
              });

  stable_sort(shops.begin(), shops.end(),
              [](tuple<int, string, int> a, tuple<int, string, int> b) -> int {
                return (get<1>(a) < get<1>(b));
              });

  for (int i = 0; i < n; i++) {
    cout << get<0>(shops[i]) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n,k;
int main(){
	cin>>n>>k;
	if(n>10)
	{
		cout<<k;
		return 0;
	}
	cout<<k+100*(10-n);
	return 0;
}

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 pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

ll a[200001];
int main(){
    ll n,q,s,t;
    cin>>n>>q>>s>>t;
    ll ans=0;
    int ai,pre;
    cin>>pre;
    FOR(i,1,n+1){
        cin>>ai;
        a[i]=ai-pre;
        if(a[i]>0) ans-=s*a[i];
        else ans-=t*a[i];
        pre=ai;
    }
    ll l,r,x;
    rep(i,q){
        cin>>l>>r>>x;
        if(l>0){
            if(a[l]>0) ans+=s*a[l];
            else ans+=t*a[l];
            a[l]+=x;
            if(a[l]>0) ans-=s*a[l];
            else ans-=t*a[l];
        }
        if(r<n){
            if(a[r+1]>0) ans+=s*a[r+1];
            else ans+=t*a[r+1];
            a[r+1]-=x;
            if(a[r+1]>0) ans-=s*a[r+1];
            else ans-=t*a[r+1];
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 4692
import math


def distance(p1, p2):
    """returns the distance between p1 and p2

    >>> d = distance((0, 0), (1, 1))
    >>> print("{0:.5f}".format(d))
    1.41421
    """
    (x1, y1) = p1
    (x2, y2) = p2
    return math.sqrt((x2-x1)**2 + (y2-y1)**2)


def run():
    x1, y1, x2, y2 = [float(i) for i in input().split()]

    print(distance((x1, y1), (x2, y2)))


if __name__ == '__main__':
    run()



Measured memory_bytes: 5672
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {
    ll n, h, cnt = 0;
    cin >> n >> h;
    vll a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    for (int i = 1; i <= n; i++) {
        if (b[n-i] >= a[n-1]) {
            h -= b[n-i];
            cnt++;
            if (h <= 0) {
                cout << cnt << endl;
                return 0;
            }
        }
    }
    cout << (h+a[n-1]-1)/a[n-1]+cnt << endl;
    return 0;
}


Measured memory_bytes: 1792
#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 pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;
using namespace std;

ll inf=1000000000000000*40;
pair<ll,ll> pl[1<<20];
ll v[40],w[40];
int main(){
    int n;
    ll ww;
    cin>>n>>ww;
    rep(i,n) cin>>v[i]>>w[i];
    //half split
    int n2=n/2;
    rep(i,1<<n2){
        ll sw=0,sv=0;
        rep(j,n2){
            if(i>>j&1){
                sw+=w[j];sv+=v[j];
            }
        }
        pl[i]=mp(sw,sv);
    }
    sort(pl,pl+(1<<n2));
    int m=1;
    rep(i,1<<n2){
        if(pl[m-1].second<pl[i].second) pl[m++]=pl[i];
    }
    ll ans=0;
    rep(i,1<<(n-n2)){
        ll sw=0,sv=0;
        rep(j,n-n2){
            if(i>>j&1){
                sw+=w[n2+j];sv+=v[n2+j];
            }
        }
        if(sw<=ww){
            ll tv=(lower_bound(pl,pl+m,mp(ww-sw,inf))-1)->second;
            ans=max(ans,sv+tv);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 19484
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits.h>
#include <climits>
#include <map>
#include <unordered_map>
#include <cmath>
#include <set>
#include <unordered_set>
#include <iterator>
#include <deque>
#include <assert.h>
#include <cstdlib>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
ull min(ull x, ull y){ if (x<y) return x; return y;}
ull max(ull x, ull y){ if (x<y) return y; return x;}
ll min(ll x, ll y){ if (x<y) return x; return y;}
ll max(ll x, ll y){ if (x<y) return y; return x;}
double min(double x, double y){ if (x<y) return x; return y;}
double max(double x, double y){ if (x<y) return y; return x;}
ull gcd(ull x, ull y){
    if (!x) return y;
    if (!y) return x;
    if (x>y) swap(x,y);
    return gcd(x, y%x);
}
ull inv(ull a, ull c){ // a,c are coprime and a<c
    if (a==1){
        return 1;
    }
    return ((c-(c/a))*inv(c%a,c))%c;
}


int main(){
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int a,b,c,k,sum = 0;
    cin>>a>>b>>c>>k;
    sum += min(a,k);
    k -= min(a,k);
    k -= min(b,k);
    sum -= min(c,k);
    cout<<sum<<"\n";

    return 0;
}





Measured memory_bytes: 3168
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		for(int i = 0; i < S.length(); i++) {
			for(int j = i + 1; j < S.length(); j++) {
				if(S.charAt(i) == S.charAt(j)) {
					System.out.println("no");
					return;
				}
			}
		}
		System.out.println("yes");

	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    string S,T; cin >> S >> T;
    int N = S.size();
    REP(i,N) {
        string A = "";
        A += S[N-1];
        REP(j,N-1) {
            A += S[j];
        }
        //cout << A << endl;
        if(A == T) {
            cout << "Yes" << endl;
            return 0;
        }
        S = A;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
const int MAX_N =1e9 - 1;
int main()
{
	string s;
	cin>>s;
	int count = 0, ans = 0;
	for(int i = 0; i < 3; i++)
	{
		if(s[i] == 'R')
		{
			count++;
		}
		else if(count > 0)
		{
			ans = count;
			count = 0;
		}
	}
	cout << max(ans,count) << endl;
	return 0;
}


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

int main(){
    ios::sync_with_stdio(0);
    ll n, k;
    cin >> n >> k;
    ll m = pow(2, n);
    if(k==0){
        cout << "0 0";
        for(int i=1; i<m; ++i){
            cout << " " << i << " " << i;
        }
        cout << endl;
        return 0;
    }
    if(n==1 or k>m-1){
        cout << -1 << endl;
    }
    else{
        cout << "0 " << k << " 0";
        for(int i=1; i<m; ++i){
            if(i==k) continue;
            cout << " " << i;
        }
        cout << " " << k;
        for(int i=m-1; i>0; --i){
            if(i==k) continue;
            cout << " " << i;
        }
        cout << endl;
    }
}   


Measured memory_bytes: 1792
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;

//#[proconio::fastout]
fn main() {
    input! {
        x: usize,
        y: usize,
        z: usize,
    }

    println!("{} {} {}", z, x, y);
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i_len=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

int main()
{
    ll N;
    cin >> N;
    vec A(N+1), B(N);
    REP(i,0,N+1) cin >> A[i];
    REP(i,0,N) cin >> B[i];

    ll sum = 0;
    REP(i,0,N) {
        if(A[i] <= B[i]) {
            sum += A[i];
            B[i] -= A[i];
            A[i] = 0;
            if(A[i+1] <= B[i]) {
                sum += A[i+1];
                A[i+1] = 0;
            }
            else {
                sum += B[i];
                A[i+1] -= B[i];
            }
        }
        else {
            sum += B[i];
            A[i] -= B[i];
        }
    }
    PR(sum);

    return 0;
}

/*



*/

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long hxtype;
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=200005;
int q[N],p[N],a[N],f[N],e[N];
int main(){
	int n,i,s,x=1,m;ll k;
	scanf("%d%lld",&n,&k);p[m=n+1]=1;
	for(i=1;i<=n;++i)scanf("%d",&a[i]);
	for(i=n;i   ;--i)f[a[i]]=i;
	for(i=N;i   ;--i)e[i]=m;
	for(i=n;i   ;--i){
		if(e[a[i]]==m)p[i]=f[a[i]]+1;
		else p[i]=p[e[a[i]]+1];
		e[a[i]]=i;
	}
//	for(i=1;i<=m;++i)printf("%d ",p[i]);printf("\n");
	--k;
	while(k){
		if(k&1ll)x=p[x];
		k>>=1;
		for(i=1;i<=m;++i)q[i]=p[p[i]];
		for(i=1;i<=m;++i)p[i]=  q[i] ;
	}
//	printf("x=%d\n",x);
	s=0;
	for(i=N;i   ;--i)e[i]=0;
	for(i=x;i<=n;++i){
		if(e[a[i]]){
			do e[x=f[s--]]=0;while(x!=a[i]);
		}else{
			e[f[++s]=a[i]]=1;
		}
	}
	for(i=1;i<=s;++i)printf("%d ",f[i]);
	return 0;
}

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

void solve(int N, int M, vector<int> A, vector<int> B)
{
    vector<vector<int>> w(M);
    for (int i = 0; i < N; i++)
    {
        if (A.at(i) > M)
            continue;
        w.at(A.at(i) - 1).push_back(B.at(i));
    }

    int res = 0;
    priority_queue<int> q;
    for (int i = 0; i < M; i++)
    {
        for (auto r : w.at(i))
            q.push(r);

        if (q.empty())
            continue;
        res += q.top();
        q.pop();
    }
    cout << res << endl;
}

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i) >> B.at(i);
    }
    solve(N, M, move(A), move(B));
    return 0;
}


Measured memory_bytes: 6400
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

constexpr int64_t kNum = static_cast<int64_t>('z' - 'a' + 1);

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  int64_t index = N;
  int64_t length = 1;
  int64_t beki = 1;
  while (true) {
    beki = beki * kNum;
    if (index <= beki) {
      string result;
      int64_t temp = index - 1;
      while (static_cast<int64_t>(result.length()) < length) {
        string aaaa;
        aaaa.push_back('a' + (temp % kNum));
        result = aaaa + result;
        temp /= kNum;
      }
      cout << result << endl;
      break;
    }
    index -= beki;
    ++length;
  }
  return 0;
}


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

int main(){
  int n;
  bool bl=true;
  char s[100];
  cin>>n>>s;
  if(n%2==1){
    cout<<"No";
    return 0;
  }
  for(int i=0;i<n/2;i++){
    if(s[i]!=s[i+(n/2)])bl=false;
    //cout<<s[i]<<endl<<s[i+(n/2)]<<endl;
  }
  bl?cout<<"Yes":cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <string>
#include <cstdio>
using namespace std;
int main(){
	int i , n ;
	string str ;
	getline(cin,str) ;
	for( i=0 ; i<str.size() ; i++ ){
		if( !islower(str[i]) )
			printf( "%c", tolower(str[i]) ) ;
		else if( !isupper( str[i] ) )
			printf( "%c" , toupper( str[i] ) ) ;
		else 
			printf( "%c" , str[i] ) ;
	}
	cout << endl ;
}

Measured memory_bytes: 1176
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    string S;
    cin >> S;
    map<char, int> m;
    for (int i = 0; i < 3; i++) {
        if (m.count(S[i]) == 0) {
            m[S[i]] = 1;
        } else {
            m[S[i]] += 1;
        }
    }
    for (auto& kv : m) {
        if (kv.second != 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	string s;
	cin >> s;
	if ( n%2 == 1) {
		cout << "No" ; 
		return 0;
	}
	bool check = true;
	for0(i,n/2){
		if(s[i] != s[i+n/2]){
			check = false;
		}
	}
	if(check == true){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
int gcd(int a,int b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}

int main (){
  int N,X;
  cin>>N>>X;
  vector<int>xxx(N);
  rep(i,N){
    int x;
    cin>>x;
    xxx[i]=abs(X-x);
  }
  int ah;
  ah=xxx[0];
  rep(i,N){
    ah=gcd(ah,xxx[i]);
  }
  cout<<ah;
}


Measured memory_bytes: 640
#include <iostream>                                                                                   
using namespace std;                                                                                  
                                                                                                      
int main() {                                                                                          
  int n, m;                                                                                           
  cin >> n >> m;                                                                                      
  int a[n];                                                                                           
  int sum = 0;                                                                                        
  for (int i=0; i<n; i++) {                                                                           
    cin >> a[i];                                                                                      
    sum += a[i];                                                                                      
  }                                                                                                   
  int canChoose = 0;                                                                                  
  for (int i=0; i<n; i++) {                                                                           
    if ((float)a[i] >= sum / (4.0 * m)) {                                                              
      canChoose++;                                                                                    
    }                                                                                                 
  }                                                                                                   
  if (canChoose >= m) {                                                                               
    cout << "Yes" << endl;                                                                            
  } else {                                                                                            
    cout << "No" << endl;                                                                             
  }                                                                                                   
                                                                                                      
  return 0;                                                                                           
} 

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

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

int main() {
    int a,b;
    cin >> a >> b;
    int A = a;
    int B = b;
    rep(i,a-1){
        B = B*10 + b;
    }
    rep(i,b-1){
        A = A*10 + a;
    }
    string ans1 = to_string(A);
    string ans2 = to_string(B);
    if(ans1 <= ans2) cout << ans1 << endl;
    else cout << ans2 << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double



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


////////////////////////////////////////////////////////////////////
int n;vector<int> a, b;

signed main(){
  cin>>n;int cnt = 0;
  rep(i,n){
    int aa;cin>>aa;
    a.push_back(aa);
    b.push_back(aa);
  }
  sort(b.begin(), b.end());
  rep(i,n){
    a[i] = distance(b.begin(), lower_bound(b.begin(), b.end(), a[i]));
    if(i%2 == 0 && a[i]%2 == 1)cnt++;
  }
  
  cout << cnt << endl;
}


Measured memory_bytes: 2036
K, S = map(int, input().split())
res = 0
for x in range(K+1):
    y_z = S - x
    if y_z < 0:
        continue
    
    y_min = max(y_z-K,0)
    y_max = min(y_z,K)
    res += max(y_max-y_min+1,0)

print(res)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
//#define coutyn(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n, m; cin >> n >> m;
    Graph g(n + 1);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    queue<int> q;
    vector<int> dist(n + 1, -1);
    vector<int> pre(n + 1, -1);
    dist[1] = 0;
    q.push(1);
    while(!q.empty())
    {
        int v = q.front();q.pop();
        for(auto it : g[v])
        {
            if (dist[it] != -1) continue;
            dist[it] = dist[v] + 1;
            pre[it] = v;
            q.push(it);
        }
    }

    cout << "Yes" << endl;
    Rep(i, 2, n + 1)
    {
        int ans = pre[i];
        cout << ans << endl;
    }
}



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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    cout << fixed << setprecision(10);

    //入力
    ll n, k; cin >> n >> k;
    vll a(n), f(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> f[i];

    //sort
    sort(all(a));
    sort(f.rbegin(), f.rend());

    //にぶたん
    ll r = infll;
    ll l = -1; //null
    ll mid;

    while(r-l > 1) {  //条件を満たす中で最適化  //今回は最大値の'最小化'
        mid = (r+l)/2;

        //条件判定をラムダ式で実装
        bool check = [&]{
            ll cnt = 0;
            for(int i = 0; i < n; i++) {
                cnt += max(0LL, a[i] - mid/f[i]);  //a[i]->a'[i]への変更に必要な修行数
            }
            return (cnt <= k); //ここに満たしたい条件式を入れてboolを返してる
        }();

        if(check) r = mid; else l = mid;  //更新
    }

    //出力
    cout << r << '\n';
}

Measured memory_bytes: 3328
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M;
int A[100000], B[100000];
vector<int> G[100000];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M;
  rep(i, M) {
    cin >> A[i] >> B[i];
    A[i]--, B[i]--;
    G[B[i]].pb(i);
  }
  int ctr = 0, lp = -1;
  rep(x, N) {
    bool f = false;
    for (int i : G[x]) {
      if (A[i] < lp) continue;
      f = true;
    }
    if (f) ctr++, lp = x;
  }
  cout << ctr << "\n";
  return 0;
}


Measured memory_bytes: 5632
h, w = map(int, input().split())
a = []
c = []
for i in range(10):
    c.append(list(map(int, input().split())))
for i in range(h):
    a.append(list(map(int, input().split())))


for k in range(10):
    for i in range(10):
        for j in range(10):
            if c[i][j] > c[i][k] + c[k][j]:
                c[i][j] = c[i][k] + c[k][j]
ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j] >= 0:
            ans += c[a[i][j]][1]

print(ans)

Measured memory_bytes: 9564
#include <iostream>

using namespace std;

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

    char a = ' ', b = ' ';
    int aCnt = 0, bCnt =0;
    string ans = "Yes";

    for(char c: s){
        if(a == c){
            aCnt++;
        }else if(b == c){
            bCnt++;
        }else if(a == ' '){
            a = c;
            aCnt++;
        }else if(b == ' '){
            b = c;
            bCnt++;
        }else{
            ans = "No";
            break;
        }

        if(aCnt > 2 || bCnt > 2){
            ans = "No";
            break;
        }
    }

    cout << ans << endl;
}

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

int main(){
  int N,M,cunt=0,max_b=0,flag=0;
  cin>>N>>M;
  vector<int> a(M+1),b(M+1);
  for(int i=1;i<=M;i++){
    cin>>a[i]>>b[i];
  }

  int i=1;
  while(i<=N){
    max_b= -1;
    for(int j=1;j<=M;j++){
      if(a[j]<=i && i<=b[j])
        max_b=max(max_b,b[j]);
    }
    if(max_b== -1){
      cout<<"Impossible"<<endl;
      return 0;
    }
    i=max_b+1;
    ++cunt;
  }

  cout<<cunt<<endl;

  return 0;
}


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

typedef long long ll;
typedef long double ld;

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

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    string s1, s2, s3;

    cin >> s1 >> s2 >> s3;

    cout << (char)(s1[0] - 32) << (char)(s2[0] - 32) << (char)(s3[0] - 32) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FILL(Itr,n) fill((Itr).begin(),(Itr).end(),n)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int N,T;
int a[100010];

int main(){
    
    for(int i=0;i<100010;i++)a[i]=0;
    
    cin >> N >> T;
    for(int i=0;i<N;i++){
        int l,r; cin>>l>>r;
        a[l]++; a[r]--;
    }
    
    for(int i=1;i<100010;i++)a[i] = a[i] + a[i-1];
    
    int ans = 0;
    for(int i=0;i<=T;i++)ans = max(ans,a[i]);
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3476
#include <bits/stdc++.h> 
using namespace std; 
typedef long long l;
l f1(l* arr, l n) 
{ 
    l dp[n][n]; 
    for (l u = 0; u < n; ++u) { 
        for (l i = 0, j = u; j < n; ++i, ++j) { 
            l x = ((i + 2) <= j) ? dp[i + 2][j] : 0; 
            l y = ((i + 1) <= (j - 1)) ? dp[i + 1][j - 1] : 0; 
            l z = (i <= (j - 2)) ? dp[i][j - 2] : 0; 
            dp[i][j] = max(arr[i] + min(x, y), arr[j] + min(y, z)); 
        } 
    } 
    return dp[0][n - 1]; 
} 

int main() 
{ 
    l n;
    cin>>n;
    l arr[n];
    l sum = 0;
    for(l i = 0 ; i <n ; i++)
    {
    cin>>arr[i];
    sum+=arr[i];
    }
    l temp = f1(arr,n);
    cout<<(2*temp - sum);
    return 0; 
} 

Measured memory_bytes: 70528
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m;
int mat[82][82];
int dp[82][82][18000];
int fun(int i,int j,int s)
{
	
	if(i==n && j==m)
	{
		return s;
	}
	if(dp[i][j][s] != -1)
	{
		return dp[i][j][s];
	}
		int a = INT_MAX,b = INT_MAX,c = INT_MAX,d = INT_MAX;
		if(i<n)
		{
			a = fun(i+1,j,abs(s-mat[i+1][j]));
			b = fun(i+1,j,abs(s+mat[i+1][j]));
		}
		if(j<m)
		{
			c = fun(i,j+1,abs(s-mat[i][j+1]));
			d = fun(i,j+1,abs(s+mat[i][j+1]));
		}
		dp[i][j][s] = min(min(a,b),min(c,d));
		return min(min(a,b),min(c,d));
}
main()
{
	//freopen("input.txt","rt",stdin);
	memset(dp,-1,sizeof(dp));
	cin>>n>>m;
	int A[n][m];
	int B[n][m];
	for(int i=0;i<n;i++)
	{
	 for(int j=0;j<m;j++)
	 {
	 	cin>>A[i][j];
	 }
	}
	for(int i=0;i<n;i++)
	{
	 for(int j=0;j<m;j++)
	 {
	 	cin>>B[i][j];
	 }
	}
	for(int i=0;i<n;i++)
	{
	 for(int j=0;j<m;j++)
	 {
	 	mat[i+1][j+1] = abs(A[i][j]-B[i][j]);
	 }
	}
	int p = fun(1,1,mat[1][1]);
	cout<<p<<endl;
}

Measured memory_bytes: 946048
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define bit(n,m)(((n)>>(m))&1)

int a[200010];
int flag[200010];
int ans[200010];
ll temp[200010];
typedef struct edge{ll s,g;}E;
E e[200010];
int id[200010];

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}

int mex(ll s){
	int ans=0;
	while(bit(s,ans))ans++;
	return ans;
}

int f(int k){
	ll s=0;
	rep(i,id[k],id[k+1])s|=1LL<<f(e[i].g);
	return ans[k]=mex(s);
}

void check(int t){
	int s=t;
	while(a[s]!=t){
		ans[a[s]]=mex(temp[a[s]]|(1LL<<ans[s]));
		s=a[s];
	}
	if(ans[t]==mex(temp[t]|(1LL<<ans[s]))){
		puts("POSSIBLE");
//		rep(i,0,6)printf("%d",ans[i]);
		exit(0);
	}
}

int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n){
		ll t;
		scanf("%lld",&t);
		t--;
		a[i]=t;
		e[i].s=t;
		e[i].g=i;
	}
		
	qsort(e,n,sizeof(E),esort);
	{
		int p=0;
		rep(i,0,n){
			while(p<n&&e[p].s<i)p++;
			id[i]=p;
		}
		id[n]=n;//一応番兵
	}
	
	//サイクル検出　サイクル上は2、それ以外は0
	for(int i=0;flag[i]!=2;i=a[i])flag[i]++;
	rep(i,0,n)flag[i]&=2;
	
	//サイクル以外の割り当て
	rep(i,0,n)if(!flag[i]&&flag[a[i]]==2)temp[a[i]]|=1LL<<f(i);
	
	//サイクルの割り当て
	int t=0;
	while(!flag[t])t++;
	//tをmexにする
	ans[t]=mex(temp[t]);
	check(t);
	ans[t]=mex(temp[t]|(1LL<<ans[t]));
	check(t);
	
	puts("IMPOSSIBLE");
}

Measured memory_bytes: 7940
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

int maxtime(int x) {
    return (x+9)/10 * 10;
}

int remtime(int x){
    return maxtime(x) - x;
}
int main()
{
    int a, b, c , d ,e;
    cin >> a >> b >> c  >> d >> e;
    int sum = maxtime(a) + maxtime(b) + maxtime(c) + maxtime(d) + maxtime(e);
    sum -= max({ remtime(a), remtime(b), remtime(c), remtime(d), remtime(e)});
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
typedef struct{
    pii num,sc;
}hoge;
int main(){
    ll a,b,c,d; ll ans=-INF;
    rep(i,2){cin>>a>>b>>c>>d;ans=max(ans,a+b+c+d);}
    cout<<ans<<endl;
}

Measured memory_bytes: 3088
(n,),a,*z=$<.map{_1.split.map &:to_i}
g=(d=[2e9]*-~n).map{[]}
z.map{g[_1]<<_2;g[_2]<<_1}
f=->u,q,r{x=d[k=d.bsearch_index{_1>=a[u-1]}]
d[k]=a[u-1]
$*[u]=r=[r,k+1].max
g[u].map{_1!=q&&f[_1,u,r]}
d[k]=x}
f[1,0,0]
puts$*

Measured memory_bytes: 283008
il = input().split()
a = il[0]
b = il[1]

if b[-1] == 2 or b[-1] == 3 or b[-1] == 7 or b[-1] == 8 :
    print("No")
else:
    import math
    N = int(a+b)
    N_2 = math.floor(math.sqrt(N))
    if(N_2 ** 2 == N):
        print("Yes")
    else:
        print("No")
        

Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
	int n; scanf("%d",&n);
	int l[n]; scanf("%d",&l[0]);
	for (int i = 1; i < n; ++i)
	{
		scanf("%d",&l[i]);
		if(l[i]<l[i-1]){
			int tmp=l[i];
			l[i]=l[i-1];
			l[i-1]=tmp;
		}
	}
	int total=0;
	for (int i = 0; i < n-1; ++i) total+=l[i];
	if(l[n-1]<total) printf("Yes");
	else printf("No");
	return 0;
}


Measured memory_bytes: 128
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=505;
char s[N][N];int fa[N],sz[N],bin[N],n,m,res;
inline int find(R int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
void ck(){
	if(n&1){
		R int c=(n+1)>>1,fl=1;
		fp(j,1,m)if(s[c][j]!=s[c][m-j+1]){fl=0;break;}
		if(!fl)res*=2;
	}
	if(m&1){
		R int r=(m+1)>>1,fl=1;
		fp(i,1,n)if(s[i][r]!=s[n-i+1][r]){fl=0;break;}
		if(!fl)res*=2;
	}
}
int fac[15],st[15],top;
bool ck(R int i,R int j){
	top=0;
	st[++top]=s[i][j];
	st[++top]=s[n-i+1][j];
	st[++top]=s[i][m-j+1];
	st[++top]=s[n-i+1][m-j+1];
	sort(st+1,st+1+top);
	R int sum=1;
	for(R int l=1,r=1;l<=top;l=r){
		while(r<=top&&st[r]==st[l])++r;
		sum*=fac[r-l];
	}
	sum=24/sum,res=mul(res,sum==24?12:sum);
	return sum==24;
}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d%d",&n,&m),res=1;
	fp(i,1,n)scanf("%s",s[i]+1);
	ck();
	fp(i,1,(n>>1)+(m>>1))fa[i]=i,sz[i]=1;
	bin[0]=1;fp(i,1,(n>>1)+(m>>1))bin[i]=mul(bin[i-1],2);
	fac[0]=1;fp(i,1,4)fac[i]=fac[i-1]*i;
	fp(i,1,n>>1)fp(j,1,m>>1)
		if(ck(i,j)){
			R int u=find(i),v=find((n>>1)+j);
			if(u!=v)fa[u]=v,sz[v]+=sz[u];
		}
	fp(i,1,(n>>1)+(m>>1))if(find(i)==i)res=mul(res,bin[sz[i]-1]);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) fixed << setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  vl A;
  string S;
  cin >> S;
  if (S == "RRR")
    cout << 3 << endl;
  else if (S[0] == 'R' && S[1] == 'R')
    cout << 2 << endl;
  else if (S[1] == 'R' && S[2] == 'R')
    cout << 2 << endl;
  else if (S[0] == 'R' || S[1] == 'R' || S[2] == 'R')
    cout << 1 << endl;
  else
    cout << 0 << endl;

  return 0;
}


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

using namespace std;

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

const double PI=3.14159265358979323846;

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

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

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

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

s64 mygcd(s64 x, s64 y)
{
    if (y == 0) return x;
    return mygcd(y, x % y);
}

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

    // - 12:23
    // 16:12 -

    int n;
    cin >> n;

    vs64 a(n);
    rep (i, n) cin >> a[i];

    bool ans1 = true, ans2 = true;

    // check pairwise
    vector< bool > found(1000001, false);
    rep (i, n)
    {
        s64 x = a[i];
        for (s64 j = 2; j * j <= x; ++j)
        {
            if (x % j == 0)
            {
                if (found[j])
                {
                    ans1 = false;
                    break;
                }
                found[j] = true;
                while (x % j == 0)
                {
                    x /= j;
                }
            }
        }
        if (x != 1)
        {
            if (found[x]) ans1 = false;
            found[x] = true;
        }
        if (!ans1) break;
    }

    s64 g = 0;
    rep (i, n)
    {
        g = mygcd(g, a[i]);
    }
    ans2 = g == 1;

    if (ans1)
    {
        cout << "pairwise coprime" << "\n";
    }
    else if (ans2)
    {
        cout << "setwise coprime" << "\n";
    }
    else
    {
        cout << "not coprime" << "\n";
    }

    return 0;
}



Measured memory_bytes: 11344
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr);
#endif
#define ff first
#define ss second
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
   int a,b;
   cin>>a>>b;
   cout<<((a*b)&1?"Odd":"Even")<<endl;
}
int32_t main(){
  IOS;
  solve();
  //debug();
 #ifdef LOCAL_DEFINE
 cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
 #endif	
}


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

namespace AOJ1_10_C
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());//人数
                if (n == 0) break;
                string[] scrstring = Console.ReadLine().Split(' ');
                int[] scr = new int[scrstring.Length];
                string Answer;
                double arpha2 = new int();//分散
                double m = 0;//平均点
                double arpha = new double();

                
                for (int i = 0; i < scr.Length; i++)
                {
                    scr[i] = int.Parse(scrstring[i]);
                    m += scr[i];
                }
                m = m / n;//平均点を得る
                for (int i = 0; i < n; i++)//mを使うため、上と一緒にできない
                {
                    arpha2 += (scr[i] - m) * (scr[i] - m);
                }
                arpha2 = arpha2 / n;//分散を得る
                arpha = Math.Sqrt(arpha2);
                Answer = Math.Abs(arpha).ToString("F8");

                Console.WriteLine(Answer);
            }
        }
    }
}




Measured memory_bytes: 15888
import itertools
n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]
pat = list(itertools.product([0, 1, 2, 3], repeat=n))
ans = 10**10
for p in pat:
    aa, bb, cc = 0, 0, 0
    mp = -30
    for i in range(n):
        if p[i] == 0:
            pass
        elif p[i] == 1:
            aa += l[i]
            mp += 10
        elif p[i] == 2:
            bb += l[i]
            mp += 10
        else:
            cc += l[i]
            mp += 10
    if aa == 0 or bb == 0 or cc == 0:
        continue
    abc = [aa, bb, cc]
    pat2 = list(itertools.permutations([0, 1, 2]))
    for q in pat2:
        mp2 = 0
        mp2 += abs(a - abc[q[0]])
        mp2 += abs(b - abc[q[1]])
        mp2 += abs(c - abc[q[2]])
        ans = min(ans, mp + mp2)
print(ans)

Measured memory_bytes: 84188