akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;

string s;
int n;
VVi dp;
Vi memo;

void init()
{
	cin >> s;
	reverse(ALL(s));

	n = SZ(s);
	dp.resize(n + 1, Vi(13, 0));
	dp[0][0] = 1;

	memo.resize(n);
	memo[0] = 1;
	REP1O(i, n)
	{
		memo[i] = memo[i - 1] * 10 % 13;
		if (memo[i] == 0)
			memo[i] = 13;
	}
}

inline int summod(int a, int b) { a += b; return (a > MOD) ? a - MOD : a; }

int main()
{
	init();

	REP(i, n)
	{
		if (s[i] != '?')
		{
			int d = (s[i] - '0');
			int r = d * memo[i] % 13;
			REP(j, 13)
				dp[i + 1][(j + r) % 13] = summod(dp[i + 1][(j + r) % 13], dp[i][j]);
		}
		else
			REP(d, 10)
		{
			int r = d * memo[i] % 13;
			REP(j, 13)
				dp[i + 1][(j + r) % 13] = summod(dp[i + 1][(j + r) % 13], dp[i][j]);
		}
	}

	cout << dp[n][5] << endl;
}


Measured memory_bytes: 9344
//...START BY DOING WHAT IS NECESSARY, THEN WHAT IS POSSIBLE AND SUDDENLY YOU ARE DOING THE IMPOSSIBLE... 
// ................. WORK UNTILL YOUR IDOLS BECOME YOUR RIVALS................................

#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define pb emplace_back
#define f first
#define s second
#define delrep(a)  (a).erase(unique((a).begin(),(a).end()),(a).end());
#define all(a)  (a).begin(),(a).end()
#define sz(x)   (int)x.size()
const int N=4e5+5;
using namespace std;
int get_second( pair<int, int> i ){ return i.second; }  
int trail_zero(int n){while (n % 10 == 0) n /= 10 ; return n;}
typedef long long ll;
map<ll,ll> m11;
set<int> s1;
map<int,pair<int,int>> m1;
vector<pair<int,int>>v1;
vector<int>v9[26];
char s111[N];
ll p2[N],p3[N];
ll hash1[N];
int n,m;
bool check(int a,int b) { if(a>=0 || a<n) return true; if(b>=0 || b<m) return true; else return false;}
int dx[]={0,-1,0,1};
int dy[]={1,0,-1,0};
char s[500][500]; 
 vector<long long int> v[26];
 set<string> st; 
int main()
{
   string s; cin>>s; int k,y=0; cin>>k;
   for(int i=0;i<s.size();i++)
     for(int j=1;j<=5 && s.size();j++)
     {
      string x=s.substr(i,j); st.insert(x);
     }
    auto i=st.begin(); while(i!=st.end()) { if(y==k-1) return cout<<*i<<endl,0; i++; y++;   }
return 0;
}








Measured memory_bytes: 1664
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>
#include <tuple>
#include <complex>


#define FOR(i, a, b)		for(int i = (int)(a); i < (int)(b); ++i)
#define FORE(i, a, b)		for(int i = (int)(a); i <= (int)(b); ++i)
#define REP(i, n)			FOR(i, 0, n)
#define REPE(i, n)			FORE(i, 0, n)
#define ALL(x)				(x).begin(),(x).end()
#define DEBUG_DC(x)			cout << #x << ": " << x << endl
#define VEC_TYPE			int
#define INF					1e9+1

using namespace std;
typedef long long ll;
typedef vector<VEC_TYPE> vdef;
typedef vector<vdef> vvdef;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmaxE(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; }
template<class T> inline bool chminE(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
template<typename T> inline T mygcd(T a, T b) { return b ? mygcd(b, a%b) : a; }
template<typename T> inline T mylcm(T a, T b) { return a * b / mygcd(a, b); }

int main()
{
	int ans = 0;
	int m, d;
	cin >> m >> d;
	for (int i = 1; i <= m; ++i)
	{
		for (int j = 22; j <= d; ++j)
		{
			int d10 = std::floor((double)j / 10.0);
			int d1 = j - 10 * d10;
			if (i == d10*d1 && d10 > 1 && d1 > 1)
			{
				++ans;
			}
		}
	}

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

Measured memory_bytes: 256
#include<stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))

int d[40][100010];
int main(){
	int n;
	scanf("%d%*d",&n);
	rep(nnn,0,n){
		int s,t,c;
		scanf("%d%d%d",&s,&t,&c);
		d[c][s-1]++;
		d[c][t]--;
	}
	rep(c,1,31)rep(i,0,100005){
		if(i)d[c][i]+=d[c][i-1];
		if(d[c][i]>0)d[35][i]++;
	}
	int ans=0;
	rep(i,0,100005)ans=max(ans,d[35][i]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 14080
#include <stdio.h>

int main(void){

  long n;
  scanf("%ld", &n);
  long number = n;
  long s_n = 0;
  while (number > 0) {
    s_n += number%10;
    number /= 10;
  }
  if (n%s_n == 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<sstream>
using namespace std;
#define ll long long
#define ld long double
 
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>=b;i--)
 
#define mp make_pair
#define pb push_back
 
#define ft first
#define sd second
 
 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V> 
 
const ll N = 100005;
const ll M = 1000000007;
 
int main(){
  ll h;
  cin>>h;
  ll res=1;
  ll cnt=0;
  while(res<=h){
  	res=res*2;
  	cnt++;
  }
  	ll ans=0;
	f(i,0,cnt){
		ans+=(ll)pow(2,i);
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n,m;
	string str;
	cout << fixed << setprecision(10);
	cin>>n>>m;
	cout<<max({n-m,n+m,n*m});


	cout<<endl;
} 


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

/*
http://acm-icpc.aitea.net/index.php?plugin=attach&refer=2014%2FPractice%2F%E6%A8%A1%E6%93%AC%E5%9B%BD%E5%86%85%E4%BA%88%E9%81%B8%2F%E8%AC%9B%E8%A9%95&openfile=D.pdf
*/

const int inf=1e9;

int main(){
  ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m,h,k;
	while(cin>>n>>m>>h>>k,n){
		vector<tuple<int,int,int,int> > v[101];
		for(int i=0;i<m;i++){
			int a,b,c,d,e;cin>>a>>b>>c>>d>>e;
			a--;b--;e--;
			v[a].push_back(make_tuple(b,c,d,e));
			v[b].push_back(make_tuple(a,c,d,e));
		}
		int s,t;cin>>s>>t;
		s--;t--;
		int p;cin>>p;
		int a[500],b[500];
		for(int i=0;i<p;i++){
			int l,d;cin>>l>>d;
			int now=0;
			for(int j=0;j<l;j++){
				int tmp;cin>>tmp;
				tmp--;
				now|=(1<<tmp);
			}
			a[i]=d;
			b[i]=now;
		}
		int dp[300][300];
		for(int i=0;i<300;i++)for(int j=0;j<300;j++)dp[i][j]=inf;
		dp[0][0]=0;
		for(int i=0;i<p;i++){
			for(int j=0;j<(1<<k);j++){
				dp[i+1][j|b[i]]=min(dp[i+1][j|b[i]],dp[i][j]+a[i]);
				dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
			}
		}
		int ans=inf;
		for(int i=0;i<(1<<k);i++){
			if(dp[p][i]==inf)continue;
			int d[101][25];
			for(int j=0;j<n;j++)for(int k=0;k<=h;k++)d[j][k]=inf;
			d[s][0]=0;
			priority_queue<tuple<int,int,int> > q;
			q.push(make_tuple(0,s,0));
			while(!q.empty()){
				int now=get<1>(q.top());
				int nowcost=-get<0>(q.top());
				int nowh=get<2>(q.top());
				q.pop();
				if(nowcost>d[now][nowh])continue;
				for(int j=0;j<(int)v[now].size();j++){
					int next=get<0>(v[now][j]);
					int next_h=get<2>(v[now][j]);
					int next_cost=get<1>(v[now][j]);
					int cop=get<3>(v[now][j]);
					if(i&(1<<cop))next_cost=0;
					if(nowh+next_h<=h && d[next][nowh+next_h]>d[now][nowh]+next_cost){
						d[next][nowh+next_h]=d[now][nowh]+next_cost;
						q.push(make_tuple(-d[next][nowh+next_h],next,nowh+next_h));
					}
				}
			}
			int res=inf;
			for(int j=0;j<=h;j++)res=min(res,d[t][j]);
			ans=min(res+dp[p][i],ans);
		}
		if(ans==inf)cout<<-1<<endl;
		else cout<<ans<<endl;
	}
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include<time.h>
#include<cmath>
#include<vector>
using namespace std;

int main(void)
{
	int k, s;
	cin >> k >> s;

	int count = 0;

	for (int i = 0; i <= k; i++) {
		for (int j = 0; j <= k; j++) {
			int p = s - i - j;
			if (p >= 0 && p <= k)
				count++;
		}
	}
	cout << count;
	cout << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool check(int a,int b,int c,int d,string s)
{
    for(int i=a;i<c;++i)
    {
        if(s[i]=='#'&&s[i+1]=='#')
            return false;
    }
    for(int i=b;i<d;++i)
    {
        if(s[i]=='#'&&s[i+1]=='#')
            return false;
    }
    if(c < d)
    {
        return true;
    }
    for(int i=b;i<=d;++i)
    {
        if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.')
        {
            return true;
        }
    }
    return false;
}
int main()
{
    int n,a,b,c,d;
    string s;
    cin>>n>>a>>b>>c>>d>>s;
    s="#"+s;
    if(check(a,b,c,d,s))
    {
        puts("Yes");
    }else
    {
        puts("No");
    }
}

Measured memory_bytes: 772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
using vs = vector<string> ;
#define all(v) v.begin(),v.end()

#define MAX_V 10
#define INF 1e9

struct edge { int to;int cost;};

vector<edge> G[MAX_V];
using P = pair<int, int>;
int V,ans;

int bfs(int v){
  ll ans=0;
  deque<vector<int>> qv;
  vector<int> d;d.push_back(v);
  qv.push_back(d);
  while(!qv.empty()){
    vector<int> d_tmp = qv.back();
    qv.pop_back();
    int nowv = d_tmp[d_tmp.size()-1];
    //ここで別々のd_tmpにしないと
    for(int i=0;i<G[nowv].size();++i){
      if(find(all(d_tmp),G[nowv][i].to)==d_tmp.end()){
        d_tmp.push_back(G[nowv][i].to);
        if(d_tmp.size()==V) ans++;
        else{
          qv.push_back(d_tmp);
          d_tmp.erase(d_tmp.end()-1);
        }
        //rep(h,d_tmp.size()) cout<<d_tmp[h];
      }
    }
    //cout<<endl;
  }
  return ans;
}


int main(){
  cin >> V;
  int E;cin>>E;
  rep(i,E){
    int a,b;cin>>a>>b;a--,b--;
    edge e1={a, 1},e2={b, 1};
    G[a].push_back(e2);
    G[b].push_back(e1);
  }
  cout << bfs(0) << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 
    static Scanner in = new Scanner(System.in);
    void solve() {
        String s = in.nextLine(), t = in.nextLine();
        if(s.charAt(0) == t.charAt(2) && s.charAt(1) == t.charAt(1) && s.charAt(2) == t.charAt(0)){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
 
    public static void main(String[] args) {
        new Main().solve();
    }
}

Measured memory_bytes: 23124
#include<iostream>
using namespace std;
int main(){
	int w,a,b;
	int atob,btoa;
	cin >> w >> a >> b;
	int starta = a;
	int startb = b;
	int enda = a+w;
	int endb = b+w;

	if(enda<startb){
		atob = startb-enda;
		cout << atob;
	}
	else if(endb<starta){
		btoa = starta-endb;
		cout << btoa;
	}
	else cout << 0;

	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
yesno = 'Yes'
p=0
for i in range(N-1):
    if H[i] < H[i+1]:
        p=0
    elif H[i] == H[i+1]:
        p=p
    elif H[i] - 1 == H[i+1]:
        p += 1
        if p == 2 :
            yesno = 'No'
            break
    else:
        yesno = 'No'
        break
print(yesno)

Measured memory_bytes: 14396
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

bool solve() {
    int n;
    cin >> n;
    ll a[n];
    ll sm = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sm += a[i];
    }
    ll er = (1LL+n)*(n)/2;
    if (sm % er) return false;
    ll k = sm/er;
    ll b[n];
    for (int i = 0; i < n; i++) {
        ll di = a[i] - a[(i+n-1)%n];
        di -= k;
        if (0 < di) return false;
        if (di % n) return false;
        b[i] = (-di) / n;
    }
    ll co = 0;
    for (int i = 0; i < n; i++) {
        co += b[i];
    }
    if (co != k) return false;
    return true;
}

int main() {
    if (solve()) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    priority_queue<ll> que;
    ll N,M;
    cin >> N >> M;
    vector<ll> A(N);
    vector<pair<ll,ll>> pa(M);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    for(int i=0;i<M;i++){
        ll a,b;
        cin >> a >> b;
        pa[i]=make_pair(b,a);
    }
    sort(A.rbegin(),A.rend());
    sort(pa.rbegin(),pa.rend());
    ll ct=0;
    int adx=0,bdx=0;
    vector<ll> ansv;
    while(ct < N){
        if(A[adx]>=pa[bdx].first){
            ansv.push_back(A[adx]);
            adx++;
            ct++;
        }
        else{
            for(int i=0;i<pa[bdx].second;i++){
                if(ct==N) break;
                ansv.push_back(pa[bdx].first);
                ct++;
            }
            bdx++;
        }
    }
    ll ans=0;
    for(int i=0;i<N;i++){
        //cout << ansv[i] << endl;
        ans+=ansv[i];
    }
    //cout << pa[1].first << endl;
    cout << ans << endl;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define MAX (ll)(1e5 + 4)
#define MOD (ll)(1e9 + 7)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false), cin.tie (nullptr);

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

ll fact[MAX];

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

ll ad (ll a, ll b) {
	b += MOD;
	b %= MOD;
	return (a  + b) % MOD;
}

ll pw (ll a, ll b)  {
	ll res = 1;
	while (b) {
		if (b & 1) {
			res = mult (res, a);
		}
		b >>=  1;
		a = mult (a, a);
	}
	return res;
}

ll cc (int n, int k) {
	return mult (fact[n], pw (mult (fact[n - k], fact[k]), MOD - 2));
}

int main () { 
	IO;
	int n, k;
	cin >> n >> k;
	fact[0] = 1;
	for (int i = 1; i <= MAX; i++) {
		fact[i] = mult (i , fact[i - 1]);
	}
	int ar[n];
	for (int i = 0; i< n; i++) {
		cin >> ar[i];
	}
	sort (ar, ar + n);
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		if (i >= k - 1) {
			ans = ad (ans, mult (cc (i, k - 1), ar[i]));
		}
		if (n - 1 - i  >= k - 1) {
			ans = ad (ans , -1 * mult (ar[i], cc (n - 1 - i, k - 1)));
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<map>
#include<string>
#include<string.h>
#include<utility>
#include<algorithm>
#include<vector>
#include<queue>
#include<iostream>
#include<math.h>
#include<stack>
#include<set>
#define INF 2147483647
#define loop(i, a, b) for(int i=a; i<=b; i++)
#define mem(arr) memset(arr, 0, sizeof(arr));
using namespace std;
typedef long long lli;
typedef double llf;
typedef pair<int, int> P;
typedef vector<int> vec;
typedef priority_queue<int, vector<int>, greater<int> > pQ;
typedef queue<int> Q;
typedef set<int> S;
struct edge{
	int to, value;
};
void solve();
int main()
{
	int times = 1;
//	cin >> times;
	loop(i, 1, times)
	{
		solve();
		cout << '\n';
	}
	return 0;
}
const int n = 2e5;
vector<edge> tree[n + 50];
lli a, b, c, d, e, f;
lli arr[n + 50], arr1[n + 50], arr2[n + 50];
string str, str1, str2;

void solve()
{
	cin >> a;
	loop(i, 0, a - 1)
		cin >> arr[i];
	sort(arr, arr + a);
	lli cnt = a * (a - 1) * (a - 2) / 6;
	loop(i, 0, a - 1)
	{
		loop(j, i + 1, a - 1)
		{
			int he = lower_bound(arr, arr + a, arr[i] + arr[j]) - arr;
			cnt -= (lli)a - he;
		}
	}
	cout << cnt << '\n';
}

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

vector<vector<int>> G(200010);
vector<bool> B(200010);

void dfs(int cur, int prev) {
  B.at(cur) = true;
  for (auto nx : G.at(cur)) {
    if (B.at(nx)) continue;
    dfs(nx, cur);
  }
}

int main() {
  int N, M; cin >> N >> M;
  for (int i = 0; i < N; i++) {
    int k; cin >> k;
    for (int j = 0; j < k; j++) {
      int l; cin >> l;
      l += 100000;
      G.at(i).push_back(l);
      G.at(l).push_back(i);
    }
  }
  dfs(0, -1);
  bool ok = true;
  for (int i = 0; i < N; i++) {
    if (!B.at(i)) ok = false;
  }
  if (ok) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 11644
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

// MOD逆元 非再帰拡張ユークリッド
long modinv(long a){long M=MOD,b=M,u=1,v=0;while(b)u-=a/b*v,swap(u,v),a%=b,swap(a,b);return (u%M+M)%M;}

int main(void) {
  long N, M;
  cin >> N >> M;

  unordered_map<long, long> yakusu;
  while (M % 2 == 0) {
    yakusu[2]++;
    M /= 2;
  }
  for (long i = 3; i * i <= M; i+=2) {
    while (M % i == 0) {
      yakusu[i]++;
      M /= i;
    }
  }
  if (M != 1) yakusu[M]++;

  for (auto it: yakusu) {
    cerr << it.first << ": " << it.second << endl;
  }

  unordered_map<long, long> foo;
  unordered_map<long, long> invs;

  for (auto it: yakusu) {
    if (foo[it.second] != 0) continue;
    long a = it.second;
    long b = a + N - 1;
    long tmp = 1;
    rep (i, a) tmp = (tmp * (b - i)) % MOD;
    rep (i, a) {
      long inv = invs[i+1];
      if (inv == 0) {
        inv = modinv(i+1);
        invs[i+1] = inv;
      }
      tmp = (tmp * inv) % MOD;
    }
    foo[it.second] = tmp;
  }

  long result = 1;
  for (auto it: yakusu) {
    result = (result * foo[it.second]) % MOD;
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

int MOD = 998244353;
// int MOD = 1000000007;
// int m[1001][1001] = {0};
//----------------------------------------------------------------
signed main(){

	ll n;
	string s;
	cin >> n >> s;

	ll ans = 0;

	for(int l = 0;l < n-1;l++){
		vll A(n-l);
		ll i = 1,j = 0;
		A[0] = n-l;
		while(i < n-l){
			while(i+j < n-l && s[j+l] == s[i+j+l])j++;
			A[i] = j;
			if(j == 0){i++;continue;}
			ll k = 1;
			while(i+k < n-l && k+A[k] < j){
				A[i+k] = A[k];
				k++;
			}
			i += k;
			j -= k;
		}
		rep(m,n-l)ans = max(ans,min(m,A[m]));
	}

	cout << ans << endl;

	return 0;
}

//----------------------------------------------------------------

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2017-final.contest.atcoder.jp/tasks/ddcc2017_final_b
// rm -r -f test;oj dl https://agc038.contest.atcoder.jp/tasks/agc038_a

Measured memory_bytes: 384
/*
        |___Arshit Mangukiya___|
        |___DA-IICT____|
        |___201801173____|
*/
        //__WRITE  YOUR  CODE  HERE___//
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;            
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppl;
typedef vector<pll> vpl;
#define ff first
#define ss second
#define pi acos(-1)
#define mr_ad_0501 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define all(a)      a.begin(),a.end()
#define f(i,a,n) for(ll i=a;i<n;i++)
#define MOD 1000000007
#define MAX 200007
#define LM LLONG_MAX
#define sz size()
#define p(x)        cout<< x << " ";
#define pe(x)       cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
const int N=1e5+5;

/*  bool fun(pair<int,int>a , pair<int,int>b)
            {
                if(a.ff == b.ff)    return a.ss < b.ss;
                else            return a.ff < b.ff;
            }*/
           
 /*void bfs(ll x)
 {
    queue<ll> q;
    q.push(x);
    while(!q.empty())
    {
        ll k=q.front();
        q.pop();
        for(auto X:v[k])
        {
            if(!vis[X])
            {
                l[X]=l[k]+1;
                vis[X]=1;
                q.push(X);
            }
        }
    }
 }*/
//ll i,j;
/*void dfs(ll v) {
    visited[v] = true;
    for (auto u : adj[v]) {
        if (!visited[u])
            dfs(u);
    }
}*/

ll getSetBitsFromOneToN(ll N)
{
    ll two = 2, ans = 0;
    ll n = N;
 
    while (n) {
        ans += (N / two) * (two >> 1);
 
        if ((N & (two - 1)) > (two >> 1) - 1)
            ans += (N & (two - 1)) - (two >> 1) + 1;
 
        two <<= 1;
        n >>= 1;
    }
    return ans;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll mod_pow(ll a,ll b,ll m)
{
    ll res = 1;
    while(b)
    {
        if(b&1)
        {
        res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}
 
ll mod_inverse(ll a)
{
	return mod_pow(a , MOD-2 , MOD);
}

void solve()
{
	string s;
	cin>>s;
	ll n=s.sz;
	ll c=0;
	ll ans=INT_MIN;
	f(i,0,n)
	{
		if(s[i]=='R')c++;
		else
		{
			ans=max(ans,c);
			c=0;
		}
	}
	ans=max(ans,c);
	cout<<ans;
//	else cout<<-1;
}
   
int32_t main(){
    mr_ad_0501;
    ll t=1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
}

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

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    priority_queue<pair<int, int>> dt_que;
    for (int i = 0; i < N; i++) {
        int t, d;
        cin >> t >> d;
        dt_que.push({d, t});
    }
    priority_queue<int> removable;
    set<int> used_t;
    long long sum = 0;
    for (int i = 0; i < K; i++) {
        int d = dt_que.top().first;
        int t = dt_que.top().second;
        dt_que.pop();
        sum += d;
        if (used_t.count(t) > 0) {
            removable.push(-d);
        } else {
            used_t.insert(t);
        }
    }
    vector<long long> max_by_type(N + 1);
    long long x = used_t.size();
    long long ans = sum + x * x;
    max_by_type.at(x) = ans;
    while (!dt_que.empty() and !removable.empty()) {
        int d = dt_que.top().first;
        int t = dt_que.top().second;
        dt_que.pop();
        if (used_t.count(t) > 0) {
            continue;
        }
        used_t.insert(t);
        long long x = used_t.size();
        long long diff = d + removable.top() + x * x - (x - 1) * (x - 1);
        removable.pop();

        max_by_type.at(x) = max_by_type.at(x - 1) + diff;
        if (max_by_type.at(x) > ans) {
            ans = max_by_type.at(x);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4980
def main():
    s = list(map(int, list(input())))

    c0 = 0
    c1 = 0

    for x in s:
        if x == 1:
            c1 += 1
        else:
            c0 += 1

    print(2*min(c0, c1))

if __name__ == '__main__':
    main()

Measured memory_bytes: 10368
#include<stdio.h>
/*long long int lcm(long long int a,long long int b){
    long long int max=(a>b)?a:b;
    while(1){
        if(max%a==0 && max%b==0){
            break;
        }
        max++;
    }
    return max;
}*/
long long int gcd(long long int a, long long int b) 
{ 
	if (a == 0) 
		return b; 
	return gcd(b % a, a); 
} 

// Function to return LCM of two numbers 
long long int lcm(long long int a, long long int b) 
{ 
	return (a*b)/gcd(a, b); 
} 
int main(){
	long long int a,b,c,d;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    long long int p,count=b-a+1;
    count-=(a%c==0)?(b/c-a/c+1):(b/c-a/c);
   // printf("%lld\n",count);
    count-=(a%d==0)?(b/d-a/d+1):(b/d-a/d);
   // printf("%lld\n",count);
    p=lcm(c,d);
   // printf("%lld",p);
    count+=(a%p==0)?(b/p-a/p+1):(b/p-a/p);
    
    
	printf("%lld\n",count);
}

Measured memory_bytes: 1700
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
 import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        ArrayList<Long> array = new ArrayList<Long>();
        
       
        for(int i=0;i<n;i++){
            array.add(toLong(scan.nextInt()));
        }
        
        long min=1000001;
        long max=-1000001;
        long sum = 0;
        
        for(long i : array){
            if(min > i) min = i;
            if(max < i) max = i;
            sum += i;
        }
        
        System.out.println(min + " " + max + " " + sum);
        scan.close();
    }
    
    public static long toLong(Number number){
        return number.longValue();
    }
}

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

int main(){
    int x,y;
    cin >> x >> y;
    bool flag = true;
    if(y%2 != 0){
        flag = false;
    }else if(y/2 < x){
        flag = false;
    }else{
        if(y%4 == 0){
            if(y/4 > x){
                flag = false;
            }
        }else{
            if(y/4 > x-1){
                flag = false;
            }
        }
        
    }
    if(flag){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
/*
ll GCD(ll A,ll B){
  return (B==0)?(A):(GCD(B,A%B));
}
ll LCM(ll A,ll B){
  return A/GCD(A,B)*B;
}
*/
int main(){
	int A,B;
	cin>>A>>B;
	if(A<=8&&B<=8){
		cout<<"Yay!"<<endl;
	}else{
		cout<<":("<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
a, b, k = map(int,input().split())
#n = int(input())
#b = list(map(int,input().split()))
#ls = [list(map(int,input().split())) for i in range(n)]
#s = input()
ls = []
for i in range(1,min([a,b])+1):
  if a%i == 0 and b%i == 0:
    ls.append(i)
print(ls[-k])

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

int main() {
  int D, T, S;
  cin >> D >> T >> S;

  if (S * T >= D) {
    cout << "Yes" << endl;
  }
  else if (S * T < D) {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3632
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

template<typename T> int ContinuousLCS(const T &a, const T &b) {
  const int n = a.size(), m = b.size();
  vvi dp(n + 1, vi(m + 1));
  int maxi = 0;
  rep(i, n) rep(j, m) {
    if (a[i] == b[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
    cmax(maxi, dp[i + 1][j + 1]);
  }
  return maxi;
}

main {
  string s, t;
  while (cin >> s >> t) cout << ContinuousLCS(s, t) << endl;
}

Measured memory_bytes: 127952
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn dfs(links: &Vec<Vec<usize>>, cur: usize, visited: &mut HashSet<usize>, nodes: usize) -> bool {
    visited.insert(cur);

    //    debug!(&visited, cur, nodes);

    if visited.len() == nodes {
        return true;
    }

    let nexts = &links[cur];
    let tmp_visited = visited.clone();
    for &n in nexts.iter().filter(|&x| !tmp_visited.contains(x)) {
        if dfs(links, n, visited, nodes) {
            return true;
        }
    }

    return false;
}

fn is_linked(links: &Vec<Vec<usize>>, nodes: usize) -> bool {
    let mut visited = HashSet::new();
    return dfs(links, 0, &mut visited, nodes);
}

fn main() {
    let (n, m) = read!(usize, usize);
    let edges: Vec<(usize, usize)> = read![usize,usize; m];
    let edges: Vec<(usize, usize)> = edges.into_iter().map(|(x, y)| (x - 1, y - 1)).collect();

    let mut link_count = 0;

    for i in 0..(edges.len()) {
        let mut links = vec![vec![]; n];

        for (from, to) in edges
            .iter()
            .enumerate()
            .filter(|&x| x.0 != i)
            .map(|(_, &x)| x)
        {
            links[from].push(to);
            links[to].push(from);
        }

        // この隣接状態(i本目を切断)でもグラフが連結かどうかを判定する
        if is_linked(&links, n) {
            link_count += 1;
        }
    }

    println!("{}", edges.len() - link_count);
}


Measured memory_bytes: 4352
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]

card = []
for Ai in A:
    card.extend(Ai)

for bi in b:
    try :
        index = card.index(bi)
        card[index] = True
    except ValueError:
        pass

answer = 'No'
if (card[0] is True and card[1] is True and card[2] is True) or \
    (card[3] is True and card[4] is True and card[5] is True) or \
    (card[6] is True and card[7] is True and card[8] is True) or \
    (card[0] is True and card[3] is True and card[6] is True) or \
    (card[1] is True and card[4] is True and card[7] is True) or \
    (card[2] is True and card[5] is True and card[8] is True) or \
    (card[0] is True and card[4] is True and card[8] is True) or \
    (card[2] is True and card[4] is True and card[6] is True):
    answer = 'Yes'

print(answer)


Measured memory_bytes: 3064
n,s,*a=map(int,open(0).read().split())
ans=0
mod=998244353
dp=[0]*(s+1)
for i in range(n):
	dp[0]+=1
	if a[i]>s:
		continue
	ans+=dp[s-a[i]]*(n-i)
	ans%=mod
	for j in range(s,a[i]-1,-1):
		dp[j]+=dp[j-a[i]]
		dp[j]%=mod
print(ans)



Measured memory_bytes: 42220
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct Edge{
	int to;
};

void BFS(vector<vector<Edge>>& G)
{
	queue<int> Q;
	vector<int> depth(G.size(), -1);
	int dep = 0;
	
	depth[0] = dep;
	for(auto i : G[0])
		Q.push(i.to);
	while(!Q.empty()){
		dep++;
		int size = Q.size();

		for(int i = 0; i < size; i++){
			int v = Q.front();
			Q.pop();
			if(depth[v-1] == -1){
				depth[v-1] = dep;
				for(auto i : G[v-1])
					Q.push(i.to);
			}
		}
	}

	for(int i = 0; i < G.size(); i++){
		cout << i + 1 << " " << depth[i] << endl;
	}
}

int main(void)
{
	int num;
	cin >> num;

	vector<vector<Edge>> AdjList(num);
	for(int i = 0; i < num; i++){
		int u, k;
		cin >> u >> k;
		for(int j = 0; j < k; j++){
			int v;
			cin >> v;
			AdjList[i].push_back(Edge{v});
		}
	}

	BFS(AdjList);
	return 0;
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int N;

int main(void) {

    cin >> N;

    int negCnt = 0;
    ll sum = 0;
    ll min = 1000000000;
    rep(i, N) {
        ll a;
        cin >> a;
        ll a_abs = abs(a);
        if (a < 0) negCnt++;
        sum += a_abs;

        if (min > a_abs) {
            min = a_abs;
        }

    }

    // 負数が奇数個
    if (negCnt % 2 == 1) {
        sum -= (min * 2);
    }

    cout << sum << endl;


    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

public static class P {
    public static void Main() {
        long n=long.Parse(Console.ReadLine());
        long[]a=new long[5];
        for(int i=0;i<5;i++){
            a[i]=long.Parse(Console.ReadLine());
        }
        long max=0;
        for(int i=0;i<5;i++){
            max=Math.Max(max,(n+a[i]-1)/a[i]);
        }
        Console.WriteLine(max+4);
    }
}


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

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

  vector<int> ans(N);

  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    ans.at(a - 1)++, ans.at(b - 1)++;
  }

  for (int i = 0; i < N; i++) {
    cout << ans.at(i) << "\n";
  }
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
x, y, a, b, c = nm()
p = nl()
q = nl()
r = nl()
p.sort()
q.sort()
l = p[-x:] + q[-y:]
l.sort()
r.sort()
for i in range(c):
    if l[i] < r[-1]:
        l[i] = r.pop()
    else:
        break
print(sum(l))


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

int cal(long long a){
  int i=0;
  while(a>0){
    i++;
    a/=10;
  }
  return i;
}

int main(){
  long long n;
  cin >> n;
  int ans=cal(n);
  long long a,b;
  int mi;
  for(a=1;a*a<=n;++a){
    if(n%a!=0) continue;
    b=n/a;
    mi=max(cal(a),cal(b));
    if(ans>mi){
      ans=mi;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define RFOR(i, begin, end) for(int i=(end)-1, i##_begin_=(begin);i>=i##_begin_;i--)
#define rep(i, N) FOR(i, 0, N)
#define rrep(i, N) RFOR(i, 0, N)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long int;
using V = vector<ll>;
using P = pair<ll, ll>;
using VP = vector<P>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
constexpr int inf = 1e9;
constexpr int mod = 1e9+7;
ll gcd(ll a, ll b) { return b? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}


int main() {
    ll n, k;
    cin >> n >> k;
    
    V h(n);
    rep(i, n) cin >> h[i];

    sort(all(h));

    ll ret = inf;
    rep(i, n-k+1) {
        ret = min(ret, h[i+k-1] - h[i]);
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<ll,ll>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    cs
    ld a,b,h,m,t;
    cin>>a>>b>>h>>m;
    t=abs(h*30+30*m/60-m*6);
    if(t==180) bye(a+b)
    else if(t>180) t=360-t;
    cout<<fixed<<setprecision(12)<<sqrt(a*a+b*b-2*a*b*cos(t*pi/180));

}

Measured memory_bytes: 4144
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const double INF = 1e12;



int num[31];
int main(){
	int w,n;
	while(cin>>w){
		cin>>n;
		REP(i,w+1)num[i]=i;
		REP(i,n){
			int a,b;char c;
			cin>>a>>c>>b;
			swap(num[a],num[b]);
		}
		REP(i,w)cout<<num[i+1]<<endl;
	}
	return 0;
}

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

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  string S;
  cin >> S;
  int all = 0;
  int passB = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'c') {
      cout << "No" <<endl;
    }
    else if (S.at(i) == 'b') {
      if (all < A+B && passB < B) {
        cout << "Yes" <<endl;
        all++;
        passB++;
      }
      else {
        cout << "No" <<endl;
      }
    }
    else if (all < A+B) {
      cout << "Yes" <<endl;
      all++;
    }
    else {
      cout << "No" <<endl;
    }
  }
}


Measured memory_bytes: 896
import java.util.*;
import java.math.*;
import java.io.*;

class Main
{
	public static void main(String[] args)
	{
		new Main().run();
	}
	
	void run(){
		Scanner sc=new Scanner(System.in);
		int M=sc.nextInt();
		long K=sc.nextLong();
		//00,
		//11,10,00,01,00,10,11,01
		if(M==0){
			if(K==0){
				System.out.println("0 0");
			}else{
				System.out.println(-1);
			}
		}else if(M==1){
			if(K==0){
				System.out.println("0 0 1 1");	
			}else{
				System.out.println(-1);
			}
		}else if((1<<M)-1>=K){
			PrintWriter pw=new PrintWriter(System.out);
			ArrayList<Long> a=new ArrayList<>();
			for(long i=0;i<(1<<M);++i){
				if(i!=K)a.add(i);
			}
			a.add(K);
			for(long i=(1<<M)-1;i>=0;--i){
				if(i!=K)a.add(i);
			}
			a.add(K);
			for(int i=0;i<a.size();++i){
				pw.print(a.get(i)+(i==a.size()-1?"\n":" "));
			}
			pw.close();
		}else{
			System.out.println("-1");
		}
		
	}
	
	
	void tr(Object...objects){
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 63352
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        HashMap<Integer,Long> factor=new HashMap<>();
        for (int i = 1; i <= n; i++) {
            int temp=i;
            int s=(int)sqrt(i)+1;
            for (int j = 2; j <= s; j++) {
                while (temp%j==0){
                    factor.put(j,factor.getOrDefault(j,0l)+1);
                    temp/=j;
                }
            }
            if(temp!=1)factor.put(temp,factor.getOrDefault(temp,0l)+1);
        }
        long ans=1;
        for (Integer k:factor.keySet()){
            ans=(ans*(factor.get(k)+1))%(long)(1e9+7);
        }
        out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int a,b,c,d,e;
 	cin >> a>>b>>c;
 	int x[b];
 	for (int i = 0; i < b; i++) {
 		cin >> x[i];
 		if(x[i]<c){
 			d++;
 		}else{
 			e++;
 		}
 	}
 	if(d<e){
 		cout << d << endl;
 	}else{
 		cout << e << endl;
 	}
 }

Measured memory_bytes: 256
<?php
$s = str_split(trim(fgets(STDIN)));
$n = str_split("CODEFESTIVAL2016");

$ans = 0;
$i = 0;
while($i < 16){
if($s[$i] != $n[$i]){
++$ans;
}
++$i;
}

echo $ans . PHP_EOL;
?>

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

int n;
string s,t;

int main(){
	cin>>n>>s>>t;
	for(int i=0;i<n;i++) cout<<s[i]<<t[i];
	cout<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python

def count(a, b):
    ans = 0
    for i, j in zip(a, b):
        if i != j:
            ans += 1
    return ans

s = input()
t = input()

ans = len(s)

for i in range(0, len(s)-len(t)+1):
    a = s[i:i+len(t)+1]
    ans = min(ans, count(a, t))

print(ans)


Measured memory_bytes: 73064
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];puts("");}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

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

	int a,b,c;
	cin>>a>>b>>c;
	cout<<min(c,b/a)<<endl;
}


Measured memory_bytes: 256
def main():

    n = int(input())
    ok = 0
    for i in range(1, 10):
        if n % i == 0 and 1 <= n / i <= 9:
            ok += 1
    if ok != 0:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

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

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

  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  
  if(K == 0){
    cout << A - B << endl;
  }else if(K%2==1){
    cout << (B-A) << endl;
  }else{
    cout << (A-B)  << endl;
  }

  return 0;
}


Measured memory_bytes: 256