akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;
typedef pair<int, int> pp;       // int aa = pp.first;
typedef tuple<int, int, int> tp; // int aa = get<0>(tp);

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

int all[100100];

class BIT {
public:
  vector<int> bit;
  int M;

  BIT(int M) : bit(vector<int>(M + 1, 0)), M(M) {}

  int get(int i) const {
    if (!i)
      return 0;
    return bit[i] + get(i - (i & -i));
  }

  void add(int i, int x) {
    if (i > M)
      return;
    bit[i] += x;
    add(i + (i & -i), x);
  }
};

void solve(long long N, long long M, vector<long long> l, vector<long long> r) {
  BIT bit(100010);

  vector<tp> vtp;
  REP(i, N) { vtp.push_back(tp(r[i] - l[i] + 1, l[i], r[i])); }
  sort(ALL(vtp));

  int pc = 0;
  FOR(m, 1, M + 1) {
    ll ans = 0;

    while (pc < N && get<0>(vtp[pc]) < m) {
      bit.add(get<1>(vtp[pc]), 1);
      bit.add(get<2>(vtp[pc]) + 1, -1);
      pc++;
    }

    ans += N - pc;

    for (int v = m; v <= M; v += m) {
      ans += bit.get(v);
    }

    cout << ans << endl;
  }
}

int main() {
  ios::sync_with_stdio(false);
  long long N;
  long long M;
  cin >> N;
  vector<long long> r(N - 1 + 1);
  vector<long long> l(N - 1 + 1);
  cin >> M;
  for (int i = 0; i <= N - 1; i++) {
    cin >> l[i];
    cin >> r[i];
  }
  solve(N, M, l, r);
  return 0;
}


Measured memory_bytes: 16368
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll read()
{
    char ch=getchar();
    ll x=0,f=1;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
priority_queue<ll,vector<ll>,greater<ll> > qa,qb;
priority_queue<ll> qo,t;
int main()
{
    ll xx,y,a,b,c;
    ll x,ans=0;
    cin>>xx>>y>>a>>b>>c;

    while(!t.empty())
        t.pop();
    for(int i=0;i<a;i++)
    {
        x=read();
        t.push(x);
    }
    for(int i=0;i<xx;i++)
    {
        x=t.top();
        t.pop();
        qa.push(x);
    }

    while(!t.empty())
        t.pop();
    for(int i=0;i<b;i++)
    {
        x=read();
        t.push(x);
    }
    for(int i=0;i<y;i++)
    {
        x=t.top();
        t.pop();
        qb.push(x);
    }
	for(int i=0;i<c;i++)
    {
        x=read();
        qo.push(x);
    }
    for(int i=0;i<xx;i++)
    {
        x=qa.top();
        qa.pop();
        qo.push(x);
    }
    for(int i=0;i<y;i++)
    {
        x=qb.top();
        qb.pop();
        qo.push(x);
    }
    for(int i=0;i<xx+y;i++)
    {
        x=qo.top();
        ans+=x;
        qo.pop();
    }
    cout<<ans<<endl;
	return 0;
}
/*
20 5
0 5 10 17 19
*/


Measured memory_bytes: 8560
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 97;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

// OrderedSet
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template < typename T > using ordered_set = tree < T, null_type, greater < T >, rb_tree_tag, tree_order_statistics_node_update >;

//typedef uint64_t hash_t;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int HASH_COUNT = 2;
//const hash_t HASH_P = (uint32_t)-13337;
//uniform_int_distribution<hash_t> MULT_DIST(0.25 * HASH_P, 0.75 * HASH_P);
//const hash_t HASH_MULT[HASH_COUNT] = {MULT_DIST(rng), MULT_DIST(rng)};

int n;
int seen[1234];
int play[1234];

vector < int > V[1234];

int main(){
  fastScan(n);
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n - 1; j++){
      int x;
      fastScan(x);
      V[i].pb(x);
    }
  }
  int ans = 0, ok = n;
  while(ok > 0){
    int match = 0;
    ans++;
    for(int i = 1; i <= n; i++){
      if(play[i] == n-1) continue;
      if(play[i] < (n - 1) && seen[i] != ans){
        int x = V[i][play[i]];
        if(play[x] < (n - 1) && seen[x] != ans && V[x][play[x]] == i){
          match++;
          seen[i] = ans; seen[x] = ans;
          play[i]++; play[x]++;
          if(play[i] == n - 1) ok--;
          if(play[x] == n - 1) ok--;
        }
      }
    }
    if(match == 0){
      break;
    }
  }
  for(int i = 1; i <= n; i++){
    if(play[i] != n - 1){
      ans = -1;
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 6400
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int n;

int main(){
	cin >> n;
	vl a(n), b(n);
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];
	reverse(all(b));
	int p = -1;
	int l = 0, r = n;
	rep(i,n){
		if(a[i] == b[i]){
			if(p == -1){
				p = a[i];
				l = i;
			}
		}else{
			if(p != -1){
				if(r == n) r = i;
			}
		}
	}
	if(p == -1){
		cout << "Yes" << "\n";
		print(b);
		return 0;
	}
	int id = 0;
	for(int i=l; i<r; i++){
		while(id < n && (a[id] == p || b[id] == p)) id++;
		if(id == n){
			rep(j,n){
				if(a[j] == b[j]){
					cout << "No" << "\n";
					return 0;
				}
			}
			cout << "Yes" << "\n";
			print(b);
			return 0;
		}
		swap(b[id], b[i]);
		id++;
	}
	cout << "Yes" << "\n";
	print(b);
}

Measured memory_bytes: 6420
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	int maxP = -1;
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		int p;
		cin >> p;
		
		ans += p;
		maxP = max(maxP, p / 2);
	}
	
	ans -= maxP;
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<string>
#include<numeric>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using vi = vector<int>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using vpii = vector<pii>;

int main(){
  int N, K;
  cin >> N >> K;
  int cnt = 0;
  int tmp;
  rep(i, N){
    cin >> tmp;

    if(tmp >= K)
      cnt++;
  }

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

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int mod = 1000000007;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
ll x, y;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> x >> y;
    ll ans = 0;
    while (y >= x)
    {
        x = x * 2;
        ans++;
    }
    cout << ans << "\n";
}

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

int main() {
	ll n;
	cin >> n;
	vector<pair<ll, ll>> v;
	for (ll i = 0; i < n; ++i) {
		ll a, b;
		cin >> a >> b;
		v.push_back({ b,a });
	}
	sort(v.begin(), v.end());
	ll now = 0;
	for (auto p : v) {
		now += p.second;
		if (now > p.first) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 6384
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in(gcu());}
_sc(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename H,typename... T> _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
template <typename T>
_vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for (char c: s) pcu(c);}
template <typename H,typename... T> _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename T> _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
_vl(){out('\n');}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

typedef vector<int> v;

v read() {
	v a(in());
	for (int &x : a)
		x = in();
	return move(a);
}

int main() {
	v a = read(), b = read();
	outl((int)(a < b));
}


Measured memory_bytes: 2632
# AGC006A - Prefix and Suffix
def main():
    n = int(input())
    S, T = tuple(input().rstrip() for _ in range(2))
    for i in range(n):
        if S[i:] == T[: n - i]:  # check duplicates
            print(n + i)
            break
    else:
        print(n * 2)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
//#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define int long long
#define ll long long
#define str string
#define db double
#define ac() cout<<"Yes"<<endl;
#define wa() cout<<"No"<<endl;
#define ddd cout<<"---debug---"<<endl;
#define ff(a,b) for(signed (a)=1;(a)<=(b);(a)++)
#define fff(a,b) for(signed (a)=0;(a)<(b);(a)++)
#define re readdd()
#define pr(a) printtt(a)
#define pee puts("");
#define eee putchar(' ');
#define pss(a) push_back(a)
#define ps(a) push(a)
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}//
int ppow(int a,int b,int mod){a%=mod;//
int ans=1%mod;while(b){if(b&1)ans=(long long)ans*a%mod;
a=(long long)a*a%mod;b>>=1;}return ans;}
int readdd(){int x=0,f=1;char c=getchar();//
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')f=-1,c=getchar();
while(isdigit(c))x=x*10+c-'0',c=getchar();
return f*x;}
void printtt(int x){if(x<0)putchar('-'),x=-x;
if(x>=10)printtt(x/10);putchar(x%10+'0');}
bool addd(int a,int b){return a>b;};
//
const int maxm=3e3+5;
const int mod=998244353;
int d[maxm];
int a[maxm];
signed main(){
    int n,s;
    cin>>n>>s;
    for(int i=1;i<=n;i++)cin>>a[i];
    int ans=0;
    for(int i=1;i<=n;i++){
        if(s>a[i]){
            ans=(ans+d[s-a[i]]*(n-i+1)%mod)%mod;
        }else if(s==a[i]){
            ans=(ans+i*(n-i+1)%mod)%mod;
        }
        for(int j=s;j>=a[i];j--){
            d[j]=(d[j]+d[j-a[i]])%mod;
        }
        d[a[i]]=(d[a[i]]+i)%mod;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <vector>
#define pb push_back
std::vector<int> adj[200005];
int sz[200005], mx[200005], sec[200005], low[200005];
char col[200005];
long long ans;
void dfs(int u, int fa = -1)
{
	sz[u] = col[u] - '0';
	low[u] = col[u] == '1' ? 0 : 1e9;
	for (int v : adj[u])
	{
		if (v == fa)
			continue;
		dfs(v, u);
		if (mx[v] + 1 > mx[u])
		{
			sec[u] = mx[u];
			mx[u] = mx[v] + 1;
		}
		else
			sec[u] = std::max(sec[u], mx[v] + 1);
		sz[u] += sz[v];
		if (sz[v])
			low[u] = std::min(low[u], mx[v] + 1);
	}
}
void work(int u, int fa = -1)
{
	if (u)
	{
		int x = mx[fa] == mx[u] + 1 ? sec[fa] : mx[fa];
		if (x + 1 > mx[u])
		{
			sec[u] = mx[u];
			mx[u] = x + 1;
		}
		else
			sec[u] = std::max(sec[u], x + 1);
		if (sz[0] - sz[u])
			low[u] = std::min(low[u], x + 1);
	}
	ans += std::max(0, std::min(sec[u] + 1, mx[u] - 1) - low[u] + 1);
	for (int v : adj[u])
	{
		if (v != fa)
			work(v, u);
	}
}
int main()
{
	// freopen("AGC008-F.in", "r", stdin);
	int n;
	scanf("%d", &n);
	for (int i = 1; i < n; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		adj[--u].pb(--v);
		adj[v].pb(u);
	}
	scanf("%s", col);
	dfs(0);
	work(0);
	printf("%lld\n", ans + 1);
	return 0;
}


Measured memory_bytes: 24064
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g,c;}E;
typedef struct graph{
	int vcnt,ecnt;
	E  e[200010];//適宜変える
}G;

int csort(const void*a,const void*b){
	ll p=(*(E*)a).c,q=(*(E*)b).c;
	return p<q?-1:p>q?1:0;
}

G g;
void readgraph(){
	//適宜変える
	ll n,m;
	scanf("%lld%lld",&n,&m);
	rep(i,0,m){
		ll x,y,c;
		scanf("%lld%lld%lld",&x,&y,&c);
		g.e[2*i].s=x;
		g.e[2*i].g=y;
		g.e[2*i].c=c;
		g.e[2*i+1].s=y;
		g.e[2*i+1].g=x;
		g.e[2*i+1].c=c;
	}
	g.vcnt=n;
	g.ecnt=2*m;
	qsort(g.e,g.ecnt,sizeof(E),csort);

}

//union-find
#define UFLIMIT (1<<17)
int unicnt[UFLIMIT+10];//正ならcnt、非正なら根のindex
void ufinit(int n){rep(i,0,n)unicnt[i]=1;}
int ufroot(int x){return unicnt[x]<=0?-(unicnt[x]=-ufroot(-unicnt[x])):x;}
int ufsame(int x,int y){return ufroot(x)==ufroot(y);}
void uni(int x,int y){if((x=ufroot(x))==(y=ufroot(y)))return;if(unicnt[x]<unicnt[y]){int t=x;x=y;y=t;}unicnt[x]+=unicnt[y];unicnt[y]=-x;}
#undef UFLIMIT


//クラスカル法
//最小全域木を構成する辺とそのコストの合計を求める
//union findが必要、事前にコストでソートが必要
//O(ElogE)
//*
//ll saishou[100010];
ll kurasukaru(){
	ll ans=0;
	ufinit(g.vcnt);
	rep(i,0,g.ecnt){
		if(!ufsame(g.e[i].s,g.e[i].g)){
			uni(g.e[i].s,g.e[i].g);
//			saishou[i]=1;
			ans+=g.e[i].c;
		}
	}
	return ans;
}
//*/

int main(){
	readgraph();
	printf("%lld\n",kurasukaru());
}



Measured memory_bytes: 10908
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int SumDigits(int x){
  int sum =0;
  while(x>0){
    sum+=x%10;
    x/=10;
  }
  return sum;
}

int main() {
  int n;
  cin>>n;
  if(n%SumDigits(n)==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  ll n, k, s;
  cin >> n >> k >> s;
  vector<ll> ret(n, 1);
  if (s == 1e9) {
    for (int i = 0; i < k; i++) {
      ret[i] = s;
    }
  } else {
    for (int i = 0; i < n; i++) ret[i] = 1e9;
    for (int i = 0; i < k; i++) {
      ret[i] = s;
    }
  }
  printv(ret);
}


Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {
	
	static int N;
	static int[][] info;
	
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			N = in.nextInt();
			if(N==0) break;
			info = new int[N][N+1];
			for(int i=0;i<N;i++){
				for(int j=0;j<N+1;j++){
					info[i][j] = in.nextInt();
				}
			}
			int size = 1<<(N);
			int[] dp = new int[size];
			for(int i=0;i<size;i++){
				dp[i] = Integer.MAX_VALUE;
			}
			dp[0] = 0;
			for(int k=0;k<N;k++){
				int com = (1<<k)-1;
				while(com < 1<<N){
					for(int l=0;l<N;l++){
						if((com>>l & 1)==0){
							int cand = dp[com] + time(l,com);
							dp[com | 1<<l] = Math.min(dp[com|1<<l], cand);
						}
					}
					int x = com & -com;
					int y = com + x;
					if(x==0) com = 1;
					else com = ((com & ~y)/x >> 1) | y;
				}
			}
			System.out.println(dp[size-1]);
			
			System.gc();
		}
	}
	
	public static int time(int trg,int wepon){
		int time = info[trg][0];
		for(int i=0;i<N;i++){
			if((wepon>>i&1)==1){
				time = Math.min(time,info[trg][i+1]);
			}
		}
		return time;
	}
	
}

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

string s, t;

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

    int mx = 0;
    for (int i = 0; i <= s.size() - t.size(); i++) {
        int count = 0;
        for (int j = 0; j < t.size(); j++) {
            if (s[i + j] == t[j]) count++;
        }
        mx = max(mx, count);
    }

    cout << t.size() - mx << endl;

    return 0;
}

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

int main(){

    int n,k;
    cin >> n >> k;

    vector<int> a(n);

    rep(i,n) cin >> a[i];
    ll ans=1e+18;
    for(int i=0;i+k<=n;i++){
        ll t=min(abs(a[i+k-1]),abs(a[i]))+abs(a[i]-a[i+k-1]);        
        ans=min(ans,t);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};

int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,k;
    cin>>k>>n;
    vector<int>v;
    v.push_back(n);
    k--;
    for(int i=n+1;i<=n+k;i++)
        v.push_back(i);
    for(int i=n-1;i>=n-k;i--)
        v.push_back(i);
    sort(all(v));
    for(auto i:v)
        cout<<i<<" ";

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  string s;
  cin >> s;
  int n = s.size();
  rep(i,n-1){
    if(s.at(i) == s.at(i+1)){
      cout << i+1 << " " << i+2 << endl;
      return 0;
    }
  }
  rep(i,n-2){
    char a = s.at(i);
    char c = s.at(i+2);
    if(a == c){
      cout << i+1 << " " << i+3 << endl;
      return 0;
    }
  }
  cout << "-1 -1" << endl;
}


Measured memory_bytes: 512
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>
 
// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std
 
Jehian Norman Saviero;
 
// MACROS TYPE
typedef long l;
typedef unsigned long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
 
// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")
 
// MACROS FOR ATTRIBUTE
#define fi first
#define se second
 
// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))
 
// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

const int sz = 2e5+5;
set<pi> blockships;

vi pset;
int group[sz];

void initSet(int N) {
	pset.resize(N+1);
	for (int i = 0; i < pset.size(); ++i) {
		pset[i] = i;
	}
}

int findSet(int p) {
	return pset[p] == p ? p : pset[p] = findSet(pset[p]);
}

void joinSet(int u, int v) {
	pset[findSet(u)] = findSet(v);
}

bool isSameSet(int u, int v) {
	return findSet(u) == findSet(v);
}

int main() {
	int N, M, K;
	sci(N), sci(M), sci(K);
	initSet(N);
	vi sub;
	sub.resize(N+1, 0);
	for (int i = 0; i < M; ++i) {
		int u, v;
		sci(u), sci(v);
		++sub[u], ++sub[v];
		joinSet(u, v);
	}
	RESET(group);
	vi deg(N+1);
	for (int i = 1; i <= N; ++i) {
		++group[findSet(i)];
	}
	for (int i = 1; i <= N; ++i) {
		deg[i] = group[findSet(i)]-1;
	}
	for (int i = 0; i < K; ++i) {
		int u, v;
		sci(u), sci(v);
		if (isSameSet(u,v)) {
			--deg[u], --deg[v];
		}
	}
	for (int i = 0; i < N; ++i) {
		if (i) printf(" ");
		printf("%d", deg[i+1]-sub[i+1]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 205000;
const int INF = 1e9;

class SegmentTree {
private: 
  long long tree[4 * MAXN];
  int num;
public:
  void init(int n) {
    num = 1;
    while (num < n) {
      num *= 2;
    }
    for (int i = 1; i < 2 * num; i++) {
      tree[i] = INF;
    }
  }

  long long getMin(int l, int r) {
    l = num + l; r = num + r;
    long long res = INF;
    
    while (l <= r) {
      if (l & 1) {
        res = min(res, tree[l]);
        l++;
      }
      if (r % 2 == 0) {
        res = min(res, tree[r]);
        r--;
      }
      l /= 2; r /= 2;
    }

    return res;
  }

  void update(int pos, long long val) {
    pos = num + pos;
    tree[pos] = val;
    pos /= 2;
    while (pos >= 1) {
      tree[pos] = min(tree[pos * 2], tree[pos * 2 + 1]);
      pos /= 2;
    }
  }
};

int n;
int p[MAXN];
int pos[MAXN];
int ans = -1;
SegmentTree t;

int main() { 

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

  t.init(n);

  int mnInv = -1;
  for (int i = n; i >= 0; i--) {
    int cur = i;
    if (mnInv != -1) {
      cur += (n - mnInv + 1);
    }
    if (ans == -1 || cur < ans) {
      ans = cur;
    }

    int curMn = t.getMin(0, pos[i] - 1);
    if (curMn != INF && (mnInv == -1 || curMn < mnInv)) {
      mnInv = curMn;
    }
    t.update(pos[i], i);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8064
#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;

double h[55];
int main(){
    double r;
    int n;
    while(cin>>r>>n,(int)r|n){
        int xl,xr;
        double hi;
        memset(h,0,sizeof(h));
        rep(i,n){
            cin>>xl>>xr>>hi;
            xl+=25,xr+=25;
            FOR(j,xl,xr) h[j]=max(hi,h[j]);
        }
        double mn=1000100010;
        FOR(i,25-r,25+r){
            double dx=min(abs(i-25),abs(i-24));
            mn=min(mn,h[i]-sqrt(r*r-dx*dx)+r);
        }
        cout<<fixed<<setprecision(12)<<mn<<endl;
    }
    return 0;
}


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

int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int k; string s;
cin>>k>>s;
int size = s.size();
if(size <= k){
    cout<<s;
}else{
    for(int i =0; i<k; i++){
        cout<<s[i];
    }cout<<"...";
}

    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define int long long

int my_gcd(int n, int m){
    if(n < m) swap(n, m);
    if(m == 0) return n;
    return my_gcd(m, n%m);
}

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n;
    cin >> n;
    vector<int> a(n);
    int maxa = 0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        maxa = max(maxa, a[i]);
    }

    vector<int> primes;
    vector<int> min_prime_factor(maxa+1, 0);
    
    primes.push_back(2);
    for(int j=2; j<=maxa; j+=2){
        min_prime_factor[j] = 2;
    }
    
    int i;
    for(i=3; i*i<=maxa; i+=2){
        if(min_prime_factor[i] != 0) continue;
        primes.push_back(i);
        for(int j=i; j<=maxa; j+=i){
            if(min_prime_factor[j] == 0){
                min_prime_factor[j] = i;
            }
        }
    }
    
    for(; i<=maxa; i+=2){
        if(min_prime_factor[i] == 0){
            primes.push_back(i);
            min_prime_factor[i] = i;
        }
    }

    int ggcd = a[0];
    for(int i=1; i<n; i++){
        ggcd = my_gcd(a[i], ggcd);
        if(ggcd == 1) break;
    }

    if(ggcd != 1){
        cout << "not coprime" << endl;
        return 0;
    }

    map<int, int> mp_prime;
    for(int j=0; j<primes.size(); j++){
        mp_prime[primes[j]] = j;
    }

    vector<bool> c(primes.size(), false);
    for(int i=0; i<n; i++){
        while(a[i] != 1){
            int p = min_prime_factor[a[i]];
            if(c[mp_prime[p]] != false){
                cout << "setwise coprime" << endl;
                return 0;
            }
            c[mp_prime[p]] = true;
            a[i] /= p;
            while(a[i] % p == 0) a[i] /= p;
        }
    }
    cout << "pairwise coprime" << endl;

    return 0;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, k;
  std::cin >> n >> k;

  constexpr int64_t mod = 1000000007;

  const auto pow_n = [=](const int64_t i) {
    int64_t data = 1;
    int64_t current = i;
    int64_t count = 1;
    while (count <= n) {
      if ((count & n) != 0) {
        data *= current;
        data %= mod;
      }
      current = current * current;
      current %= mod;
      count <<= 1;
    }
    return data;
  };

  std::vector<int64_t> val(k + 1, 0);

  for (int64_t i = k; 1 <= i; i--) {
    val[i] = pow_n(k / i);
    for (int64_t j = 2; i * j <= k; j++) {
      val[i] -= val[i * j];
      if (val[i] < 0) {
        val[i] += mod;
      }
    }
  }

  int64_t ans = 0;

  for (int64_t i = 1; i <= k; i++) {
    ans += (i * val[i]) % mod;
    ans %= mod;
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 3972
#include<bits/stdc++.h>
using namespace std;
int main() {
	string a;
	cin>>a;
	string b=string(a.rbegin(),a.rend());
	for(int i=0; i<b.length(); i++) {
		if(b[i]=='b')
			b[i]='d';
		else if(b[i]=='d')
			b[i]='b';
		else if(b[i]=='p')
			b[i]='q';
		else if(b[i]=='q')
			b[i]='p';
	}
	if(b==a)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=a,i##_len=(b);i<i##_len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;
typedef long long ll;

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

int main() {
    vector<int> v{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int s;
    cin >> s;

    cout << v[s - 1] << '\n';

    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define FOR(i,m,n) for(int i=m;i<(n);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
const ll inf = INT_MAX;
const double eps = 1e-8;
const double pi = acos(-1.0);

// aにするのに必要な操作回数
int alpha_distance (char const al) {
  return (int)(('a' - al + 26) % 26);
}

// 操作をする
char roll (char const al, int num) {
  return (al + num - 'a') % 26 + 'a';
}

int main(void){
  string s;
  cin >> s;
  int k;
  cin >> k;
  REP (i, s.size()) {
    if (i == (int)s.size() - 1)
      cout << roll(s[i], k);
    else if (k >= alpha_distance(s[i])) {
      cout << 'a';
      k -= alpha_distance(s[i]);
    } else {
      cout << s[i];
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
string K;
ll n;
ll D;
ll dp[10004][102][2];
ll solve(ll pos,ll d,int tight)
{
    if(dp[pos][d][tight]!=-1)
    return dp[pos][d][tight];
    ll up = (tight)?K[pos]-'0':9;
    if(pos==n-1)
    {
        ll ans=0;
        for(int x=0;x<=up;x++)
        {
            if(x%D==d)
            ans++;
        }
        return ans;
    }
    ll ans=0;
    for(int x=0;x<=up;x++)
    {
        ans = (ans%mod+solve(pos+1,(D+d-x%D)%D,(tight&&(x==up))?1:0)%mod)%mod;
    }
    return dp[pos][d][tight]=ans;
}
int main() {
    cin>>K;
    cin.ignore();
    cin>>D;
    n = K.length();
    memset(dp,-1,sizeof dp);
    cout<<(mod+solve(0,0,1)-1)%mod;
}


Measured memory_bytes: 20300
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){

long double A, B, H, M, hk, mk, k, ans;
cin >> A >> B >> H >> M;
//なんにも考えずに全部doubleで定義して入力
//hkは分針の角度,mkは時針の角度,kはその差で,ansが答え出力用

mk = M * 6;
hk = (H * 60 + M)* 0.5;
k = fabs(hk - mk);
//ここまでで時計の針の角度を算出

k = k*(2*M_PI/360);
//角度をラジアンに変換
ans = 2 * A * B * cos(k);
A = A * A;
B = B * B;
ans = A + B - ans;
//ここまで余弦定理(c^2=a^2+b^2-2ab cos(a))
ans = sqrt(ans);
//平方根が答え

 printf("%.10Lf\n", ans);

}

Measured memory_bytes: 4180
module Main(main) where
import Data.List

comb n y = filter (\(a,b,c) -> y == (a*10) + (b*5) + c) $ [0 .. n] >>= (\y -> map (\a -> (a,y,n-y-a)) [0 .. n-y])
  
ans [] = "-1 -1 -1"
ans ((a,b,c):_) = (show (floor a)) ++ " " ++ (show (floor b)) ++ " " ++ (show (floor c))

main :: IO ()
main = do
  [n,y] <- map read . words <$> getLine :: IO [Double]
  putStrLn $ ans $ comb n (y / 1000)



Measured memory_bytes: 1020
#include<iostream>
using namespace std;
int main() {
	string str;
	cin >> str;
	if (str.length() > 5) {
		if (str[2] == str[3] && str[4] == str[5]) {
			cout << "Yes" << endl;
		}
		else
			cout << "No" << endl;
	}
	else
		cout << "No" << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

const int MAX = 1e5+10;

int N;
ll P[MAX];
set<int> idx;

ll solve() {
    ll ans = 0;
    vii pos;
    REP (i, N) pos.PB(MP(P[i], i));
    sort(rALL(pos));
    REP (n, N) {
        int p = pos[n].first;
        int i = pos[n].second;
        ll ll = MAX, l = MAX, r = MAX, rr = MAX;
        idx.insert(i);
        auto it = idx.lower_bound(i);
        if (it == idx.begin()) {
            ll = l = -1;
        }
        else {
            l = *(--it);
            it = idx.lower_bound(l);
            if (it == idx.begin()) {
                ll = -1;
            }
            else {
                ll = *(--it);
            }
        }

        it = idx.upper_bound(i);
        if (it == idx.end()) {
            rr = r = N;
        } else {
            r = *it;
            it = idx.upper_bound(r);
            if (it == idx.end()) {
                rr = N;
            } else {
                rr = *it;
            }
        }
        ans += p * ((r-rr) * (l-i) + (ll-l) * (i-r));
    }
    return ans;
    /*
    REP (i, N) {
        ll ll = MAX, l = MAX, r = MAX, rr = MAX;
        int count = 0, j = i-1;
        while (j >= 0) {
            if (P[j] > P[i]) {
                if (count == 0) l = j;
                else ll = j;
                count++;
            }
            if (count == 2) break;
            j--;
        }
        if (count == 0) ll = l = -1;
        if (count == 1) ll = -1;
        count = 0, j = i+1;
        while (j < N) {
            if (P[j] > P[i]) {
                if (count == 0) r = j;
                else rr = j;
                count++;
            }
            if (count == 2) break;
            j++;
        }
        if (count == 0) rr = r = N;
        if (count == 1) rr = N;
        ans += P[i] * ((r-rr) * (l-i) + (ll-l) * (i-r));
    }
    return ans;
    */
}

int main() {
    cin >> N;
    REP (i, N) cin >> P[i];
    cout << solve() << endl;
}

Measured memory_bytes: 7280
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_SIZE_MAX		100000									// 最大サイズ
#define D_MOD			1000000007								// 除数

// 内部変数
static int siH;													// 高さ
static int siW;													// 幅
static int siNgH;												// 移動不可 - 高さ
static int siNgW;												// 移動不可 - 幅
static long long sl1Fact[D_SIZE_MAX * 2 + 5];					// 階乗
static long long sl1PtnL[D_SIZE_MAX + 5];						// 高さ別パターン数 - 左側
static long long sl1PtnR[D_SIZE_MAX + 5];						// 高さ別パターン数 - 右側

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 階乗セット
int
fSetFact(
)
{
	int i;

	sl1Fact[0] = 1;
	sl1Fact[1] = 1;
	for (i = 2; i < siH + siW; i++) {
		sl1Fact[i] = sl1Fact[i - 1] * (long long)i % (long long)D_MOD;
	}

	return 0;
}

// べき乗 - 取得
long long
fGetModPower(
	long long plBase			// <I> 基数
	, int piIdx					// <I> 指数
)
{
	// 平方リスト - 作成
	long long ll1Val[100];
	ll1Val[0] = plBase;
	int liCnt = 1;
	int liIdx = 1;
	while (piIdx > liIdx) {
		ll1Val[liCnt] = ll1Val[liCnt - 1] * ll1Val[liCnt - 1] % (long long)D_MOD;
		liCnt++;
		liIdx += liIdx;
	}

	// べき乗 - 取得
	long long llVal = 1;
	while (piIdx > 0) {
		if (piIdx >= liIdx) {
			piIdx -= liIdx;
			llVal = llVal * ll1Val[liCnt - 1] % (long long)D_MOD;
		}
		liCnt--;
		liIdx /= 2;
	}

	return llVal;
}

// 高さ別パターン数セット
int
fSetPtn(
	int piW						// <I> 長さ(幅)
	, long long *plpTo			// <O> セット先
)
{
	int i;

	plpTo[1] = 1;

	// nCr = n! / r! / (n-r)!
	for (i = 2; i <= siH; i++) {

		// n!
		int liN = piW + i - 2;
		plpTo[i] = sl1Fact[liN];

		// r!
		int liR = i - 1;
		long long llRev = fGetModPower(sl1Fact[liR], D_MOD - 2);
		plpTo[i] = plpTo[i] * llRev % (long long)D_MOD;

		// (n-r)!
		llRev = fGetModPower(sl1Fact[liN - liR], D_MOD - 2);
		plpTo[i] = plpTo[i] * llRev % (long long)D_MOD;
	}

	return 0;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 高さ・幅・移動不可を取得
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d%d%d%d", &siH, &siW, &siNgH, &siNgW);

	// 階乗セット
	fSetFact();

	// 高さ別パターン数セット
	fSetPtn(siNgW, sl1PtnL);									// 左側
	fSetPtn(siW - siNgW, sl1PtnR);								// 右側

	// 全パターン算出
	long long llSum = 0;
	for (i = 1; i <= siH - siNgH; i++) {
		llSum += sl1PtnL[i] * sl1PtnR[siH - i + 1];
		llSum %= (long long)D_MOD;
	}

	// 結果セット
	sprintf(lc1Out, "%lld\n", llSum);

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables ***************/
LL n;
/**********************************************/
// gcd: 最大公約数, lcm: 最小公倍数
LL euclidean(LL a, LL b){
    if(a < b) swap(a, b);
    LL r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
LL gcd(LL a, LL b){
    return euclidean(a, b);
}
LL lcm(LL a, LL b){
    LL g = gcd(a, b);
    return a / g * b;
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    
    for(LL x = 1; x <= 3500; x++){
        for(LL y = 1; y <= 3500; y++){
            LL g = (x*y)*4 - n*y - n*x;
            if(g > 0 && (n*x*y) % g == 0){
                cout << x << " " << y << " " << (n*x*y) / g << endl;
                return 0;
            }
        }
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

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

int main(){
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long lcd = (c * d) / gcd(c, d);

  long long ans1 = (long long)(b / lcd) - (long long)((a-1) / lcd);
  long long ans2 = (long long)(b / c) - (long long)((a-1) / c);
  long long ans3 = (long long)(b / d) - (long long)((a-1) / d);

  cout << (b - a + 1) - (ans2 + ans3 - ans1) << "\n";
}


Measured memory_bytes: 256
n=int(input())
a= list(input())
b= list(input())
c= list(input())

alphabet = [chr(i) for i in range(97, 97+26)]

ans = 0
for i in range(n):
    cnt = 200
    for j in range(26):
        cnt_tmp = 0
        if (a[i] != alphabet[j]):
            cnt_tmp += 1
        if (b[i] != alphabet[j]):
            cnt_tmp += 1
        if (c[i] != alphabet[j]):
            cnt_tmp += 1
        cnt = min(cnt, cnt_tmp)
    ans += cnt

print(ans)
    
        
        

'''
west
east
wait
'''





Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define MOD 1000000007

using namespace std;
typedef long long int ll;

int main(void){
	// #ifndef ONLINE_JUDGE
	// freopen("in.txt", "r", stdin);
	// #endif
	fast;
	string s, t;
	cin >> s >> t;
	s = s + s;
	for (int i = 0; i < int(s.size()); ++i){
		string a = s.substr(i, s.size()/2);
		if (a == t){
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int 	cnt = parseNum();
		int[]	frq = new int[6];

		while (cnt-- > 0) {
			frq[parseRank()]++;
		}

		for (int i = 0; i < frq.length; i++) {
			String	out = (i+1) + ":";

			while(frq[i] > 0) {
				out += "*";
				frq[i]--;
			}

			System.out.println(out);
		}
	}
 
	private static int parseRank() {
		int		rank = 5;
		double	data = Double.parseDouble(parseStdin());

		if (data < 165.0) {
			rank = 0;
		}
		else if (data < 170.0) {
			rank = 1;
		}
		else if (data < 175.0) {
			rank = 2;
		}
		else if (data < 180.0) {
			rank = 3;
		}
		else if (data < 185.0) {
			rank = 4;
		}

		return rank;
	}
 
	private static int parseNum() {
		int     num = 0;
		String  str = null;

		if ((str = parseStdin()) != null) {
			num = Integer.parseInt(str);
		}

		return num;
	}
 
	private static String parseStdin() {
        String  stdin = null;
        
        try {
        	String  tmp = br.readLine();
        	if (tmp != null) {
            	if (!tmp.isEmpty()) stdin = tmp;
        	}
        }
        catch (IOException e) {}
 
        return stdin;
	}
}

Measured memory_bytes: 16924
#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set> 
typedef  long long ll;
const int  maxn = 2110;
const int mod = 1000000007;
using namespace std;
ll n, m,ans;
string a;
map<string, ll>ma;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a;
		sort(a.begin(), a.end());
		ans += ma[a];
		ma[a]++;
	}
	printf("%lld", ans);
}


Measured memory_bytes: 11136
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e2 + 10;
int x[N];
int y[N];
double d[N][N];
double dis(int i, int j)
{
	double dx = x[i] - x[j];
	double dy = y[i] - y[j];
	return sqrt(dx * dx + dy * dy);
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) scanf("%d%d", &x[i], &y[i]);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			d[i][j] = dis(i, j);
		}
	}
	vector<int> v;
	for (int i = 0; i < n; i++) v.push_back(i);
	double sum = 0;
	int cnt = 0;
	do
	{
		cnt++;
		for (int i = 0; i + 1 < v.size(); i++)
		{
			sum += d[v[i]][v[i + 1]];
		}
	} while (next_permutation(v.begin(), v.end()));
	printf("%.14f\n", sum / cnt);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define NINTH_POWER_OF_TEN 1000000000
#define int long long

typedef long long ll;
typedef pair<int, int> Pair;

const int kMaxN = 100000;

int N, K;
int A[kMaxN];

int ans = NINTH_POWER_OF_TEN;

signed main() {
  cin >> N >> K;
  REP(i, N) { cin >> A[i]; }

  REP(i, N-K+1) {
    int a = A[i];
    int b = A[i+K-1];
    if (a <= 0 && b <= 0) {
      ans = MIN(ans, -a);
    } else if (a <= 0 && b >= 0) {
      a = ABS(a);
      if (a <= b) {
        ans = MIN(ans, a*2 + b);
      } else {
        ans = MIN(ans, b*2 + a);
      }
    } else {
      ans = MIN(ans, b);
    }
  }

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define MOD 1000000007
#define mod 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2*1e9

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

Measured memory_bytes: 256