akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n, v) rep(i, n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1, 0, -1, 0}, y_pos[4] = {0, 1, 0, -1};
int ctoi(char c)
{
	if (c >= '0' && c <= '9')
	{
		return c - '0';
	}
	return 0;
}

char upper(char c)
{
	return c - 0x20;
}

char lower(char c)
{
	return c + 0x20;
}

void unique_vector(vector<int> &v)
{
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
	std::fill((T *)array, (T *)(array + N), val);
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y)
{
	if (y == 0)
		return x;
	return gcd(y, x % y);
}

//最小公倍数
ll lcm(ll x, ll y)
{
	ll g = gcd(x, y);
	return x / g * y;
}

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

//素因数分解
map<ll, ll> prime_factor(ll n)
{
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++)
	{
		while (n % i == 0)
		{
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1)
		ret[n] = 1;
	return ret;
}

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	cout << c << " " << a << " " << b << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;


int main(){
    int N, M;
    cin >> N >> M;
    Graph g(N, vector<int>());
    rep(i, M){
        int a, b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> dist(N, -1);
    queue<int> que;
    vector<int> ans(N, -1);
    dist[0] = 0;
    ans[0] = 0;
    que.push(0);
    while(!que.empty()){
        int v = que.front(); que.pop();
        for(auto x: g[v]){
            if(dist[x] != -1){
                continue;
            }
            ans[x] = v + 1;
            dist[x] = dist[v] + 1;
            que.push(x);
        }
    }
    //-1になるときだ…いつ？？？
    cout << "Yes" << endl;
    for(int i = 1;i < N; i++) cout << ans[i] <<endl;
}

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



#define ll int
#define pb push_back
#define all(n) n.begin(),n.end()
#define eb emplace_back
#define endl "\n"
#define pll pair<ll,ll>
#define YES cout <<"YES"<<endl;
#define NO cout <<"NO"<<endl;
#define ff first
#define ss second
//do not use "\n" in interactive problem
//#define ((x|y)-y) (x&(~y))
//#define __gcd(fibo(x),fibo(y)=fibo(__gcd(x,y))
using namespace std;
const ll maxn=5e5+50;

const ll mod=1000000007;
const ll mod1=998244353;
ll a[maxn];

struct tk
{
    ll lf, rt;
    ll id;
};
ll p=890;
ll cur=0;
bool lf1(tk a,tk b)
{
    return (a.lf/p<b.lf/p||(a.lf/p==b.lf/p&&a.rt<b.rt));
}
ll cnt[maxn];
tk b[maxn];

void add(ll id)
{

    cnt[a[id]]++;
    if(cnt[a[id]]==1) cur++;
}
void ers(ll id)
{
    cnt[a[id]]--;
    if(cnt[a[id]]==0) cur--;
}
ll ans[maxn];
int main()
{
    //freopen("test.txt","r",stdin);
    // freopen("CHEMIST.OUT","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,t;
    cin>>n>>t;
    for (int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for (int i=1;i<=t;i++)
    {
        cin>>b[i].lf>>b[i].rt;
        b[i].id=i;
    }
    sort(b+1,b+t+1,lf1);
    for (int i=b[1].lf;i<=b[1].rt;i++)
    {
        add(i);
    }
    ans[b[1].id]=cur;
    ll lnw=b[1].lf;
    ll rnw=b[1].rt;
    for (int i=2;i<=t;i++)
    {
        while (lnw<b[i].lf)
        {
            ers(lnw);
            lnw++;
        }
        while (rnw<b[i].rt)
        {
            rnw++;
            add(rnw);
        }
        while (lnw>b[i].lf)
        {

            lnw--;
            add(lnw);
        }
        while (rnw>b[i].rt)
        {
            ers(rnw);
            rnw--;
        }
        ans[b[i].id]=cur;
    }
    for (int i=1;i<=t;i++)
    {
        cout <<ans[i]<<endl;
    }

}


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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    int q;
    cin >> q;
    
    vector <int> is_prime(101010, 1);
    is_prime[0] = is_prime[1] = 0;

    for (int i = 2; i < 101010; i++) {
        if (!is_prime[i]) continue;
        for (int j = i*2; j < 101010; j+=i) is_prime[j] = 0;
    }

    vector <int> tmp(101010, 0), sum(101011, 0);

    for (int i = 0; i < 101010; i++) {
        if (i%2 == 0) continue;
        if (is_prime[i] and is_prime[(i+1)/2]) tmp[i] = 1;
    }

    for (int i = 0; i < 101010; i++) sum[i+1] = sum[i] + tmp[i];
    
    vector<int> l(q), r(q);
    for (int i = 0; i < q; i++) {
        cin >> l[i] >> r[i];
    }
    for (int i = 0; i < q; i++) {
        cout << sum[r[i]+1] - sum[l[i]] << endl;
    }
    return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const ll MOD2=998244353;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

ll choose(ll n,ll k){
  ll x=n,y=1,ans=1;
  rep(i,k){
    ans=ans*x/y;
    x--;
    y++;
  }
  return ans;
}

int main() {
  ll n,p;
  cin >> n >> p;
  vl a(n);
  ll Z=0,O=0;
  rep(i,n){
    cin >> a[i];
    if(a[i]%2==0){
      Z++;
    }
    else{
      O++;
    }
  }
  ll X=0;
  ll i=0;
  while(i<=O){
    if(i%2==0){
      X+=choose(O,i);
    }
    i++;
  }
  if(p==0){
    cout << (ll)pow(2,Z)*X << endl;
  }
  else{
    cout << (ll)pow(2,Z)*((ll)pow(2,O)-X) << endl;
  }
}


Measured memory_bytes: 256
#n=int(input())
a,b=map(str,input().split())
#t=int(input())
#al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

a=int(a)
b=int(b[0]+b[2]+b[3])

print((a*b)//100)


Measured memory_bytes: 9040
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>
#include <cmath>

using namespace std;

int main() {
	double a, b, h, m;
	cin >> a >> b >> h >> m;

	double h_t = (h * 60 + m) / 2; // 12 * 60 / 360
	double m_t = m * 6; // 360 / 60

	h_t *= M_PI / 180;
	m_t *= M_PI / 180;

	double h_x = a * sin(h_t);
	double h_y = a * cos(h_t);
	double m_x = b * sin(m_t);
	double m_y = b * cos(m_t);

	double dx = h_x - m_x;
	double dy = h_y - m_y;
	double ans = sqrt(dx*dx + dy*dy);

	printf("%.12f\n", ans);
	return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl;
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T,class U>
ostream& operator << (ostream& os,pair<T,U>& p){
	os << p.fi << ',' << p.sec; return os;
}
template<class T,class U>
istream& operator >> (istream& is,pair<T,U>& p){
	is >> p.fi >> p.sec; return is;
}
template<class T>
ostream& operator << (ostream &os,const vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		os << vec[i];
		if(i+1<vec.size())os << ' ';
	}
	return os;
}
template<class T>
istream& operator >> (istream &is,vector<T>& vec){
	for(int i=0;i<vec.size();i++)is >> vec[i];
	return is;
}
void fastio(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
}
ll MOD = 1000000007ll;
string s;
ll M;
ll a[10];
int main(){
  cin >> M;
  cin >> s;
  ll dig = 1ll;
  for(int i=s.size()-1;i>=0;i--){
    int d = (int)(s[i]-'0');
    a[d] = (a[d]+dig)%MOD;
    dig = (dig*10ll)%MOD;
  }
  // for(int i=0;i<10;i++)cout << a[i] << endl;
  vector<int> vec;
  for(int i=0;i<10;i++)vec.pb(i);
  do{
    ll sum = 0ll;
    int fd = (int)(s[0]-'0');
    // cout << vec << endl;
    if(s.size()==1||vec[fd]!=0){
      for(int i=0;i<10;i++){
        sum = (sum+a[i]*vec[i])%MOD;
      }
      if(sum==M){
        for(int i=0;i<s.size();i++){
          int d = (int)(s[i]-'0');
          cout << vec[d];
        }
        cout << endl;
        // cout << sum << endl;
        return 0;
      }
    }
  }while(next_permutation(all(vec)));
  cout << -1 << endl;
	return 0;
}



Measured memory_bytes: 3336
N=int(input())
p=input().split()
for i in range(0,N):
    p[i]=int(p[i])
t=0
for i in range(0,N):
    if i+1!=p[i]:
        t+=1
if t==2 or t==0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
main(){int s[9000],n,m,t,f,i;while(scanf("%d%d",&n,&m),n)for(i=t=f=1;i<=n+m;i++){scanf("%d",&s[i]);if(i>n)if(t+=s[t+=s[i]],t>=n&f==1)printf("%d\n",i-n,f=0);}}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/05/02  Problem: AOJ 1302 / Link: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1302  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----

分割統治(昨日やった)

----解説ここまで---- */

map<VI, int>Map;
int N, M;

int f(VI& a) {
	if (SZ(a) < 2)return 0;
	int &ret = Map[a];
	if (ret > 0)return ret;
	ret = M;
	FOR(i, 0, M) {
		VI a1, a0;
		FOR(j, 0, SZ(a)) {
			if (a[j] & (1 << i)) {
				a1.push_back(a[j]);
			}
			else {
				a0.push_back(a[j]);
			}
		}
		if (a1.empty() || a0.empty())continue;
		ret = min(ret, 1 + max(f(a1), f(a0)));
	}

	return ret;
}

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

	while (cin >> M >> N, N | M) {
		VI v;
		Map.clear();
		FOR(i, 0, N) {
			string s; cin >> s;
			v.push_back(stoi(s, 0, 2));
		}
		LL ans = f(v);
		cout << ans << "\n";
	}


	return 0;
}



Measured memory_bytes: 5396
#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 <stack>
#include <numeric>
#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>

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

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;

using Bint = mp::cpp_int;


int main(void){
  int N; cin>>N;
  vector<int> h(N+2);
  FORQ(id,1,N)
    cin>>h[id];
  h[0] = 0; h[N+1] = 0;

  int left=0, right=0;
  int cnt_operationConducted=0;
  int minx=0;
  bool flag_thereIsPositiveNumber=false;
    
  while(1){
    for(left=0;left<=N;left++)
      if(h[left]==0 && h[left+1]!=0) {left=left+1;break;}
    for(right=0;right<=N;right++)
      if(h[right]!=0 && h[right+1]==0){flag_thereIsPositiveNumber=true; break;}
    if(flag_thereIsPositiveNumber == false) break;
    
    minx = *min_element(h.begin()+left, h.begin()+right+1);
    FORQ(i,left,right){
      h[i]-=minx;
    }
    cnt_operationConducted +=minx;
    flag_thereIsPositiveNumber=false;
  }
  cout<<cnt_operationConducted<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>

int main() {
	int r, g, b;
	std::cin >> r >> g >> b;
	
	int c = 100 * r + 10 * g + b;
	
	if (c % 4 == 0) std::cout << "YES" << std::endl;
	else std::cout << "NO" << std::endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<string.h>
#define ll long long
#define Start ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define fr first
#define sc second
#define M_PI           3.14159265358979323846
using namespace std;
int n,m;
int Dp[100100][3];
int A[100100],B[100100],C[100100];
int Solve(int i,int k)
{
    if(i==n)
        return 0;
    if(Dp[i][k]!=-1)
        return Dp[i][k];
    if(k==0)
        Dp[i][k]=max(Solve(i+1,1)+A[i],Solve(i+1,2)+A[i]);
    if(k==1)
        Dp[i][k]=max(Solve(i+1,0)+B[i],Solve(i+1,2)+B[i]);
    if(k==2)
        Dp[i][k]=max(Solve(i+1,0)+C[i],Solve(i+1,1)+C[i]);
    return Dp[i][k];
}
int main()
{
    Start;

    cin>>n;
    for(int i=0; i<n; i++)
        cin>>A[i]>>B[i]>>C[i];
    memset(Dp,-1,sizeof(Dp));
    int Ans=0;
    for(int i=0;i<3;i++)
        Ans=max(Ans,Solve(0,i));
    cout<<Ans;


}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
#define yn(x) puts((x ? "Yes" : "No"))
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vector<pii> vp;

void input() {
  cin>>N;
  vp.resize(N);
  rep(i,0,N-1){
    cin>>vp[i].first;
    vp[i].second = i; // index
  }

}
int dp[5555][5555];
void solve() {
  sort(all(vp));
  reverse(all(vp));

  // dp[l][r] : vp[l+r-1] をつかう
  rep(i,0,N-1){
    //i:wa

    // l + r = i
    // l = i-r
    int ak = vp[i].first;
    int k = vp[i].second; // 大きいやつのindex. 1 ~ N tigau
    rep(l,0,i){ //i: 0~n-1
      int r = i-l;

      // 
      chmax(dp[l+1][r], dp[l][r] + ak * abs(k-l));
      chmax(dp[l][r+1], dp[l][r] + ak * abs(N-r-k-1));
    }
  }

  int ans = 0;
  rep(i,0,N){
    chmax(ans, dp[i][N-i]);
  }
  cout<<ans<<endl;

  ;
  ;
}
signed main() {
  cout << setprecision(12);
  input();
  solve();
  return 0;
}

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

typedef long long int ll;
typedef long double ld;
const ll MAX=1e4+5;
const ll MAX1=1e2+5;
const ll INF=1e15+2;
const ll MOD=1e9+7;

#define pb push_back
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define pi pair<ll,ll>
#define map1 unordered_map

string k;
ll d,sz;
ll dp[2][MAX][MAX1];

ll solve(ll pos,ll sum,int flag)
{
    if(pos==sz)
        return sum==0;
        
    if(dp[flag][pos][sum]!=-1)
        return dp[flag][pos][sum];
    ll ans=0;
    
    for(int i=0;i<10;i++)
    {
        if(flag)
            ans=(ans+solve(pos+1,(sum+i)%d,flag))%MOD;
        else
        {
            if(i<k[pos]-'0')
                ans=(ans+solve(pos+1,(sum+i)%d,1))%MOD;
            else if(i==k[pos]-'0')    
                ans=(ans+solve(pos+1,(sum+i)%d,0))%MOD;
        }
    }
    return dp[flag][pos][sum]=ans;
}    
int main()
{
    memset(dp,-1,sizeof(dp));
    faster;
    cin>>k;
    cin>>d;
    sz=k.length();
    cout<<(solve(0,0,0)-1+MOD)%MOD;
    
}

Measured memory_bytes: 17408
#include<stdio.h>

int main()
{
	int n, k;
	char s[128];

	scanf("%d", &n);
	scanf("%s", s);
	scanf("%d", &k);

	for(int i = 0; i < n; i++){
		if(s[i] != s[k - 1]){
			s[i] = '*';
		}
	}

	printf("%s\n", s);

	return 0;
}


Measured memory_bytes: 128
N = int(input())
ab = [list(map(int, input().split())) for i in range(N)]
cd = [list(map(int, input().split())) for i in range(N)]

from operator import itemgetter
cnt = 0
while True:
    if len(cd) <= 0:
        break
    K = -1
    ab = sorted(ab, key = itemgetter(1))
    cd = sorted(cd, key = itemgetter(0))
    for i in range(len(ab) - 1, -1, -1):
        if ab[i][0] < cd[0][0] and ab[i][1] < cd[0][1]:
            cnt += 1
            del ab[i]
            K = 1
            break
    del cd[0]

print(cnt)
    


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
constexpr ll MOD = 1000000007;
int main(void){
  int n;
  cin >> n;
  vector<int> a(n); vector<vector<pair<int,int>>> xy(n);
  RPT(i,0,n){
    cin >> a[i];
    xy[i] = vector<pair<int,int>>(a[i]);
    RPT(j,0,a[i]) {cin >> xy[i][j].first >> xy[i][j].second; xy[i][j].first--;}
  }
  int ans = 0;
  FOR(i,1,1<<n){
    if(__builtin_popcount(i)<=ans) continue;
    vector<int> trppl;
    FOR(j,0,n) if( ((i>>j)&1)== 1) trppl.push_back(j);
    bool updt_ = true;
    for(auto x: trppl){
      FOR(j,0,a[x]){
        if( ((i>>xy[x][j].first)&1)!=xy[x][j].second){
          updt_ = false;
          break;
        }
      }
      if(!updt_) break;
    }
    if(updt_)ans = __builtin_popcount(i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
words = "abcdefghijklmnopqrstuvwxyz"
def make_palindrome(instr):
    chara_list = [ 0 for i in range(26) ]
    outstr = []
    for i in instr:
        chara_list[words.index(i)] += 1

    chara_list_2 = [ i % 2 for i in chara_list ]
    if len(instr) % 2 == 1:
        if chara_list_2.count(1) > 1:
            outstr = "NG"
        else:
            m = chara_list_2.index(1)
            for j, v in enumerate(chara_list):
                if j != m and v != 0:
                    outstr.append(words[j]*(v//2))
            outstr.append(words[m])
            outstr +=  outstr[:len(outstr)-1][::-1]

    else:
        if chara_list_2.count(1) > 0:
            outstr = "NG"
        else:
            for j, v in enumerate(chara_list):
                if v != 0:
                    outstr.append(words[j]*(v//2))
            outstr +=  outstr[::-1]
    outstr = "".join(outstr)
    return outstr

h, w = [ int(v) for v in input().split() ]
words_list = [0 for i in range(26)]
ans = "No"
if h == 1:
    if make_palindrome(input()) != "NG":
        ans = "Yes"
elif w == 1:
    tate = [ input() for i in range(h) ]
    if make_palindrome(tate) != "NG":
        ans = "Yes"
else:
    for i in range(h):
        for j in input():
            words_list[words.index(j)] += 1

    if h % 2 == 0 and w % 2 == 0:
        if all([ i % 4 == 0 for i in words_list ]):
            ans = "Yes"
    elif h % 2 == 1 and w % 2 == 0:
        if all([ i % 2 == 0 for i in words_list ]):
            if [ i % 2 == 0 and i % 4 != 0 for i in words_list ].count(True) <= w//2:
                ans = "Yes"
    elif h % 2 == 0 and w % 2 == 1:
        if all([ i % 2 == 0 for i in words_list ]):
            if [ i % 2 == 0 and i % 4 != 0 for i in words_list ].count(True) <= h//2:
                ans = "Yes"
    elif h % 2 == 1 and w % 2 == 1:
        if [ i % 2 for i in words_list ].count(1) == 1:
            words_list = [ i // 2 * 2 for i in words_list ]
            if [ i % 2 == 0 and i % 4 != 0 for i in words_list ].count(True) <= h//2 + w//2:
                ans = "Yes"

print(ans)

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

using namespace std;
typedef long long int ll;
int main() 
{
long double a,b,c;
cin>>a>>b>>c;
long double d= a+b+ 2*sqrt(a)*sqrt(b) ;

long double e=c ; 

if(d<e)
{
    cout<<"Yes";
}
else
{
    cout<<"No";
}


return 0;    
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll a, b, q;
    cin >> a >> b >> q;
    vl s(a), t(b), x(q);
    for (int i = 0; i < a; ++i) {
        cin >> s[i];
    }
    for (int i = 0; i < b; ++i) {
        cin >> t[i];
    }
    for (int i = 0; i < q; ++i) {
        cin >> x[i];
    }
    for (int i = 0; i < q; ++i) {
        ll ret  = INF;
        auto sr = lower_bound(s.begin(), s.end(), x[i]);
        auto tr = lower_bound(t.begin(), t.end(), x[i]);
        if (sr != s.end() && tr != t.end())
            chmin(ret, max(*sr - x[i], *tr - x[i]));
        if (sr != s.end() && tr != t.begin()) {
            auto tl = prev(tr);
            chmin(ret, *sr - *tl + min(*sr - x[i], x[i] - *tl));
        }
        if (sr != s.begin() && tr != t.end()) {
            auto sl = prev(sr);
            chmin(ret, *tr - *sl + min(*tr - x[i], x[i] - *sl));
        }
        if (sr != s.begin() && tr != t.begin()) {
            auto tl = prev(tr);
            auto sl = prev(sr);
            chmin(ret, max(x[i] - *sl, x[i] - *tl));
        }
        cout << ret << "\n";
    }
    return 0;
}

Measured memory_bytes: 3712
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


H, W = inpl()

X = [list(input()) for _ in range(H)]

A = [['.' for _ in range(W)] for _ in range(H)]
B = [['.' for _ in range(W)] for _ in range(H)]
tmp = ['#' for _ in range(W - 1)]
for i in range(H):
    if i % 2 == 0:
        A[i][:-1] = tmp
        B[i][-1] = '#'
    else:
        B[i][1:] = tmp
        A[i][0] = '#'

for h in range(H):
    for w in range(W):
        if X[h][w] == '#':
            A[h][w] = '#'
            B[h][w] = '#'

for a in A:
    print(''.join(a))
print('')
for b in B:
    print(''.join(b))


Measured memory_bytes: 10100
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
  fio;
  long long a,b,c,d;
  cin>>a>>b>>c>>d;
  long long p1,p2,p3,p4;
  p1=a*c;
  p2=a*d;
  p3=b*d;
  p4=b*c;
  long long z;
  z=max(p1,p2);
  z=max(z,p3);
  z=max(z,p4);
  cout<<z<<endl;
  return 0;
}

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

const ll MOD = 998244353;

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

int main() {
  ll n; cin >> n;
  vll d(n), e(n);
  rep(i, n) cin >> d[i];
  rep(i, n) e[d[i]]++;
  if (d[0] != 0) {
    cout << 0 << endl;
    return 0;
  }
  if (e[0] != 1) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 1;
  for (ll i = 1; i <= n-1; i++) {
    if (e[i - 1] == 0 && e[i] != 0) {
      cout << 0 << endl;
      return 0;
    }
    ans = ans % MOD * modpow(e[i - 1], e[i], MOD) % MOD;
  }
  cout << (ans % MOD) << endl;
  return 0;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

const int MAX_N = 112345;
int N, K, X[MAX_N];

void solve() {
    cin >> N >> K;
    rep(i, N)cin >> X[i];

    int re = INT_MAX;
    for (int i = 0; i + K <= N; ++i) {
        int j = i + K - 1, va = -1;
        if (X[i] < 0 && X[j]>0) {
            va = max(-X[i], X[j]) + min(-X[i], X[j]) * 2;
        } else {
            va = max(abs(X[i]), abs(X[j]));
        }
        smin(re, va);
    }
    cout << re << endl;
}

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

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define M 1046527
#define NIL -1
#define L 14


  char moji[M][L];



int In(char *);
int Find(char*);
int getint(char);
long long getkey(char *);
int h1(int);
int h2(int);

int main(){
  int n,i,h;
  char str[L],mei[10];

  for(i=0;i<M;i++)  moji[i][0]='\0';

  scanf("%d",&n);


  for(i=0;i<n;i++){
    scanf("%s%s",mei,str);
    if(mei[0]=='i'){
      In(str);
    }
   else if(mei[0]=='f'){
        if(Find(str)==1){
          printf("yes\n");
        }else{
          printf("no\n");
        }
   }
  }

   return 0;
}


int In(char *str){
  long long i,h,key;

   key=getkey(str);
   for(i=0; ;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(str,moji[h])==0) return 1;
    else if(strlen(moji[h])==0){
      strcpy(moji[h],str);
      return 0;
    }
   }
    return 0;
}



int Find(char *str){
  long long i,h,key;

   key=getkey(str);

  for(i=0; ;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(str,moji[h])==0){
      return 1;
    }else if(strlen(moji[h])==0){
      return 0;
    }
  }
 return 0;
}


int h1(int x){
  return x%M;
}

int h2(int x){
  return 1+(x%(M-1));
}

long long getkey(char *str){
  int sum=0,p=1,i;
  for(i=0;i<strlen(str);i++){
    sum+=p*(getint(str[i]));
    p*=5;
  }
  return sum;
}

int getint(char str){
  if(str=='A') return 1;
  else if(str=='C') return 2;
  else if(str=='G') return 3;
  else if(str=='T') return 4;
  else return 0;
}


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

#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef long double ld;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

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

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





int main(){

    bool flag=false;
    ll ans=0,sum=0;

    ll n;
    cin>>n;
    --n;

    string nam = "";

    while(n >= 0){
        int d = (n)%26;
        char addc = 'a'+d;
        nam = addc + nam;

        if(n==0)break;

        n /= 26;
        --n;
    }


    cout<<nam<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  ll N;
  cin>>N;
  vector<P> vec(N);
  ll x;
  FOR(i,0,N){
    cin>>x;
    vec[i]=make_pair(x,i);
  }
  sort(vec.begin(),vec.end());
  ll res=0;
  ll pre=0;
  ll max=0;
  FOR(i,0,N){
    if(pre<=vec[i].second){
      res++;
    }
    else{
      if(max<=res){
        max=res;
      }
      res=1;
    }
    pre=vec[i].second;
  }
  if(max<=res)max=res;
  cout<<N-max<<endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pll pair<ll,ll>
#define pb push_back
#define F first
#define S second
#define I insert
#define vll vector<ll>
#define vbl vector<bool>
#define vvll vector<vll>
#define vld vector<ld>
#define vb vector<bool>
#define vc vector<char>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()

template<class T> ostream& operator<<(ostream &os, vector<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T> ostream& operator<<(ostream &os, set<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, map<T , R> V){
	os << "[ ";
	for(auto v  : V) os << "(" << v.first << ":" << v.second << ")";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, pair<T , R> V){
	return os << "(" << V.first << "," << V.second << ")";
}

#define cerr cout
#define TRACE
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1<<" | ";
        __f(comma+1, args...);
    }
    clock_t clk=clock();
    #define checktime() cout<<"\nTime Elapsed : "<<float(clock()-clk)/CLOCKS_PER_SEC<<endl
#else
    #define trace(...);
    #define checktime();
#endif

const ll Mod = 1e9 + 7;
// const ll Mod = 998244353;
const ll MAXN = 1e6;

void solve(){
    ll k;string s;cin>>k>>s;
    ll n=s.size();
    cout<<s.substr(0,min(n,k));
    if(n>k) cout<<"...";
    cout<<"\n";
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<fixed<<setprecision(25);

    ll t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <iostream>

using namespace std;

int n, a, b;
int p[10], q[10];

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> q[i];
  }
  
  while(next_permutation(p, p+n)) {
    a++;
  }
  while(next_permutation(q, q+n)) {
    b++;
  }
  
  cout << abs(a-b) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,k,n) for(int i = k; i < n; i++)  
#define repp(i,k,n) for(int i = k; i <= n; i++) 
#define per(i,k,n) for(int i = k; i >= n; i--)

#define int long long
#define all(a) a.begin(),a.end()       

#define pb push_back
typedef long long ll; 
typedef pair<int, int> ii;
typedef pair<int,ii > iii; 
typedef vector<ii> vii;
typedef vector<char> vchar;
typedef vector<int> vi;
#define ff first
#define ss second

#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));

#define INF 1000000000
#define mod 998244353
//#define mod 1000000007
#define endl "\n"


   //=\/=\/=\/=\/=\/=\/=\/=\/=\/=\        Jai Hind Dosto        /=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\\
  //=\/=\/=\/=\       RETARDED     ̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\з= ( ▀ ͜͞ʖ▀) =ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿      NISHAN                 /=\/=\/=\/=\\
 //=\/=\/=\/=\         APE                                           SINGH                   /=\/=\/=\/=\\
//=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\\


int modPow(int a, int b);
void solve(){

    int a;
    double b;
    cin >> a >>b;
    cout << (int)((double)a*b)<<endl;









}






signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed;
    //cout <<setprecision(2);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
   // int test=1; cin >> test;
   // while(test--)
    solve();
}


int modPow(int a, int b){
    if(b==0)return 1;
    if(b%2==0){
        int x = a*a;
        x%=mod;
        return modPow(x,b/2);
    }
    return (a*modPow(a,b-1))%mod;
}


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

public class Main {
  public static void main (String[] args) {
    Scanner input = new Scanner(System.in);
    
    while (input.hasNext()) {
      int N = input.nextInt();
      int K = input.nextInt();
      int[] h = new int[N];
      
      for (int i = 0; i < h.length; ++i) {
        h[i] = input.nextInt();
      }
      
      int[] cost = new int[N];
      Arrays.fill(cost, Integer.MAX_VALUE);
      cost[0] = 0;
      for (int i = 0; i < h.length; ++i) {
        final int END = Math.min(h.length, i + K + 1);
        
        for (int j = i + 1; j < END; ++j) {
          cost[j] = Math.min(cost[j], cost[i] + Math.abs(h[j] - h[i]));
        }
      }
      
      System.out.println(cost[cost.length - 1]);
    }
  }
}

Measured memory_bytes: 49724
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define endl "\n"
#define what_is(x) cout<<#x<<" is "<<x<<endl;
#define F(i,a,b) for(int i = a; i < b; i++)
#define MAX(a,b,c) max(a,max(b,c))
#define MIN(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define inf 1e18
const double pi = 3.141592653589793238460;
#define debug false
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define mod 1000000007 

int ncr(int n,int r)
{
    if(n<2)
        return 0;
    int ans = 1;
    r = min(r,n-r);
    for(int i=0;i<r;i++)
    {
        ans = ans*(n-i)/(i+1);
    }
    return ans;
}
void solve()
{
    int n,m;
    cin>>n>>m;
    int ans = ncr(n,2)+ncr(m,2);
    cout<<ans<<"\n";  
}

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        // freopen("Test.txt","r",stdin);
        // freopen("Output.txt","w",stdout);
    #endif
    
     // if(debug){watch_is();}
    solve();   
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

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

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

    //cout << fixed << setprecision(15);

    string s;
    cin >> s;

    ll ans = 0;

    int n = s.size();
    for (int bit = 0; bit < (1 << (n - 1)); ++bit)
    {
        vector<int> v;
        for (int i = 0; i < n - 1; ++i)
        {
            if ((1 & (bit >> i)) == 1)
                v.push_back(1);
            else
                v.push_back(0);
        }

        ll sum = 0;

        ll t = s[0] - '0';
        ll vidx = 0;
        ll sidx = 1;
        while (sidx < n)
        {
            if (v[vidx] == 1)
            {
                t *= 10;
                t += s[sidx] - '0';
            }
            else
            {
                sum += t;
                t = s[sidx] - '0';
            }
            vidx++;
            sidx++;
        }
        if (t)
            sum += t;
        ans += sum;
    }
    cout << ans << endl;
    return 0;
}


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[] a = new int[N];
        //ArrayList<Integer> A = new ArrayList<>();
       
        for(int i = 0; i < N; i++){
          a[i] = sc.nextInt();
        }
        
       Arrays.sort(a);
       for(int i = 1; i < N; i++){
         if(a[i] == a[i-1]){
           System.out.println("NO");
           return;
         }else{

         }
       }
       
       System.out.println("YES");
      
	}

}





Measured memory_bytes: 62104
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

const i64 MAXN = 300005;

i64 n;
i64 a[MAXN];

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    string s;
    cin >> n >> s;

    bool f = n % 2 == 0;
    for (i64 i = 0; i < n / 2; i++) {
        if (s[i] != s[i + n / 2]) {
            f = 0;
            break;
        }
    }

    if (f) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

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

  long count = 0;
  bool flag_e2s = false;
  long output = 0;
  bool flag_same = true;
  
  int head_num = 1;
  
  for (int i = 0 ; i < S.size()-1 ; i++){
    if( S.at(i) == S.at(i+1)){
      head_num += 1;
    }
    else{
      break;
    }
  }
  
//  cout << "S.size():" << S.size() << endl;
  for (int i = 0 ; i < S.size() ; i++){
//  	cout << "i:" << i << endl;    
	if(S.size() == 1){
    	break; 
    }
    if(i == S.size() -1){ //最後の１つ
      if(S.at(0) == S.at(i)){
        if( head_num%2 == 0){
        //先頭の被りが偶数なら最後の１つは変更不要なのでカウントしない
        }
        else {        //先頭の被りが奇数なら最後の１つは変更要なのでカウントする
	      	count += 1;
 	     	flag_e2s = true;
        }
      }
      else{
        flag_same = false;
      }
    }
    else if(S.at(i) == S.at(i+1)){
    	  count += 1;
          i += 1;
    	}
    else {
      flag_same = false;
    }
  }

  if(S.size() ==1){
    output = K / 2;
  }
  else if (flag_same == true){
      output = ((S.size() )* K) /2 ;
  }
  else if(flag_e2s == false) {
    output = count * K;
//    cout << "false" << endl;
  }
  else{
    output = (count * K) -1;
//    cout << "true" << endl;
  } 
  cout << output << endl;
    
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
 
// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
 
using namespace std;
using namespace __gnu_pbds;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
 
const int INF = 2e9;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 998244353;

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

int solve(int x)
{
    if(x == n)
        return 0;
    if(dp[x] != -1)
        return dp[x];
    int &res = dp[x];
    res = solve(x + 1) + abs(h[x+1] - h[x]);
    if(x + 2 <= n)
        res = min(res, solve(x + 2) + abs(h[x+2] - h[x]));
    return res;
}

int32_t main()
{
    IOS;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> h[i];
    memset(dp, -1, sizeof(dp));
    cout << solve(1) << endl;
    return 0;
}

Measured memory_bytes: 16768
from collections import defaultdict 
import sys
input = sys.stdin.readline
from math import gcd

MOD = 1000000007

dic1 = defaultdict(int)

All_zero = 0

S = set()
N = int(input())
ans = 0 #仲が悪い数を数える
for i in range(N):
    a, b = map(int, input().split())
    if a == 0 and b == 0: #なんでもOK
        All_zero += 1
    elif a == 0:
        S.add((0, 1))
        dic1[(0, 1)] += 1
    elif b == 0:
        S.add((1, 0))
        dic1[(1, 0)] += 1
    else:
        GCD = gcd(a, b)
        a //= GCD
        b //= GCD
        if a < 0: #aを必ず正にする
            a *= -1
            b *= -1
        S.add((a, b))
        dic1[(a, b)] += 1
        
lst = []
for a, b in S:
    tmp11 = dic1[(a, b)]
    A = a
    B = b
    if B <= 0:
        B *= -1
        A *= -1
    tmp2 = dic1[(B, -A)]
    # print (a, b, A, B)
    dic1[(B, -A)] = 0
    if tmp11 > 0:
        lst.append((tmp11, tmp2))

# print (lst)

ans = 1
for a, b in lst:
    tmp = (pow(2, a, MOD) - 1) + (pow(2, b, MOD) - 1) + 1 #左側を入れる、右側を入れる、両方入れない
    ans *= tmp
    ans %= MOD

ans = (ans - 1 + All_zero) % MOD
print (ans % MOD)

# print (S)

Measured memory_bytes: 118992
#include<stdio.h>

#define MAX 100000

int a[MAX];
int n;

int partition(int,int);

int main()
{
  int i,q;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++)
    {
      scanf("%d",&a[i]);
    }

  q = partition(0,n - 1);

  for(i = 0 ; i < n ; i++)
    {
      if(i)printf(" ");

      if(i == q)printf("[");
      printf("%d",a[i]);
      if(i == q)printf("]");
    }
  printf("\n");

  return 0;
  
}

int partition(int p,int r)
{
  int x,i,j,t;

  x = a[r];
  i = p - 1;
  for(j = p ; j < r ; j++)
    {
      if(a[j] <= x)
	{
	  i++;
	  t = a[i];
	  a[i] = a[j];
	  a[j] = t;
	}
    }

  t = a[i + 1];
  a[i + 1] = a[r];
  a[r] = t;

  return i + 1;
}



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

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	bool e = true;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		e &= a[i] == b[i];
	}
	if (e) {
		cout << 0 << endl;
	} else {
		ll s = 0;
		int m = INT_MAX;
		for (int i = 0; i < n; i++) {
			s += a[i];
			if (a[i] > b[i]) {
				m = min(m, b[i]);
			}
		}
		cout << s - m << endl;
	}
	return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {

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

		int H = in.nextInt();
		int W = in.nextInt();
		
		int[][] map = new int[10][10];
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				map[i][j] = in.nextInt();
			}
		}
	
		for (int k = 0; k < 10; k++) {
			for (int i = 0; i < 10; i++) {
				for (int j = 0; j < 10; j++) {
					map[i][j] = Math.min(map[i][j], map[i][k] + map[k][j]);
				}
			}
		}
		
		long answer = 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				int n = in.nextInt();
				if (n != -1) {
					answer += map[n][1];
				}
			}
		}
		System.out.println(answer);
	}
}


Measured memory_bytes: 44860
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb(a) push_back(a)
#define pi pair<int,int>
#define f first
#define s second
#define endl "\n"
void solve()
{
    int x;
    cin>>x;
    int k=1;
    int p=360;
    while(p%x)
    {
        p+=360;
    }
    cout<<p/x<<endl;
}
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    solve();
} 

Measured memory_bytes: 3648
#define FNAME ""

#include <bits/stdc++.h>

#define hash padjf9srpi
#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forn(i, n) for (int i = 0; i < (n); i++)
#define fornr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define forab(i, a, b) for (int i = (a); i < (b); i++)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
 
#ifdef _WIN32
    #define I64 "%I64d"
#else
    #define I64 "%lld"
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;                                                                                                                                                                                      
typedef vector <int> vi;

template <class T> T sqr(const T &a) {return a * a;}

int n, a[200000];

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

#ifdef LOCAL
    freopen(FNAME".in", "r", stdin);
    freopen(FNAME".out", "w", stdout);
#endif

    scanf("%d", &n);
    forn(i, n) scanf("%d", &a[i]);
    sort(a, a + n);
    LL need = a[n - 1];
    LL sum = 0;
    forn(i, n - 1) sum += a[i];
    int ans = 1;
    fornr(i, n - 1) {
        if (2 * sum >= need) ans++;
        sum -= a[i];
        need = max(need - 2 * a[i], (LL) a[i]);
    }
    printf("%d\n", ans);
}




Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> bool chmax(T &a, U b) { if (a < b) a = b; return true; }
template<class T, class U> bool chmin(T &a, U b) { if (a > b) a = b; return true; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  int n, m; cin >> n >> m;
  vi a(n);

  rep(i, n) cin >> a[i];
  int sum = accumulate(all(a),0);

  int ans = 0;
  rep(i, n) if (4 * m * a[i] >= sum) ++ans;

  if (ans >= m) cout << "Yes\n";
  else cout << "No\n";

  return (0);
}


Measured memory_bytes: 3624