akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

pair<int, int> GetMaxElement(const unordered_map<int, int>& m) {
  pair<int, int> res {0, 0};
  for (const auto& e : m) {
    if (e.second > res.second) res = e;
  }
  return res;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n;
  cin >> n;
  unordered_map<int, int> odd;
  unordered_map<int, int> even;
  rep(i, n) {
    int num;
    cin >> num;
    if (i % 2 == 0) {
      odd[num]++;
    } else {
      even[num]++;
    }
  }

  pair<int, int> odd_max = GetMaxElement(odd);
  pair<int, int> even_max = GetMaxElement(even);
  if (odd_max.first != even_max.first) {
    cout << n - odd_max.second - even_max.second << endl;
  } else {
    odd.erase(odd_max.first);
    even.erase(even_max.first);
    pair<int, int> odd_2nd = GetMaxElement(odd);
    pair<int, int> even_2nd = GetMaxElement(even);
    int num_erase = max(odd_max.second + even_2nd.second,
                        even_max.second + odd_2nd.second);    
    cout << n - num_erase << endl;
  }
  return 0;
}


Measured memory_bytes: 4376
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		string s="hi";
		map<string,ll int> ma;
		for(ll int i=1;i<=100;i++) 
		{
			ma[s]++;
			s+="hi";
		}
		string t;
		cin>>t;
		if(ma[t]==1) cout<<"Yes";
		else cout<<"No"<<endl;
	}
	return 0;
}

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

typedef vector<int> vi;

int N, M;
vi dp;
vector<vi> G;

void input_init(void) {
	cin >> N >> M;
	G.resize(N + 1);
	for (int i = 1; i <= M; ++i) {
		int x, y;
		cin >> x >> y;
		G[x].push_back(y);
	}
	dp.resize(N + 1, -1);
}

int rec(int n) {
	if (dp[n] != -1)
		return dp[n];
	int d = 0;
	for (int i = 0; i < (int)G[n].size(); ++i) {
		int to = G[n][i];
		d = max(d, rec(to) + 1);
	}
	return dp[n] = d;
}

int solve(void) {
	int val = 0;
	for (int i = 1; i <= N; ++i)
		val = max(val, rec(i));
	return val;
}

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

	input_init();
	int ans = solve();

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 8192
# coding: utf-8
N = int(input())
S = input()
R, G, B = S.count("R"), S.count("G"), S.count("B")
ans = R * G * B
for i in range(N):
    for d in range(N):
        j = i + d
        k = j + d
        if k >= N:
            continue
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            ans -= 1
print(ans)

Measured memory_bytes: 68156
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;


int main() {
int H,W;
cin >> H >> W;
vector<vector<char>> vec(H+2,vector<char>(W+2));
bool ans = true;
for (int i = 1;i < H+1;i++) {
    for (int j = 1;j < W+1;j++) {
        cin >> vec.at(i).at(j);
    }
}
for (int i = 1;i < H;i++) {
    for (int j = 1;j < W;j++) {
        if (vec.at(i).at(j) == '#') {
            if (vec.at(i).at(j+1) == '#' || vec.at(i).at(j-1) == '#' || vec.at(i+1).at(j) == '#' || vec.at(i-1).at(j) == '#'){
                continue;
            } else {
                ans = false;
            }
        }

    }
}
if (ans == true) cout << "Yes" << endl;
else cout << "No" << endl;


return 0;
}


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

int N, K;
int deg[101010];
int ans[101010];

struct edge {
    int from, to;
    int id;
    edge(int a=0, int b=0, int id=-1) :from(a), to(b), id(id) {}
};

vector<edge> G[101010];
void solve(int v, int col) {
    int c = 1;
    //cout << "A: " << v << ", " << col << endl;
    for (auto e : G[v]) {
        if (ans[e.id] != 0) {
            continue;
        }
        while (true) {
            if (c == col) {
                c++;
                continue;
            }
            //cout << e.id << ", " << c << endl;
            ans[e.id] = c;
            solve(e.to, c);
            c++;
            break;
        }
    }
}

int main() {
    cin >> N;
    rep(i, N-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        edge e1(a, b, i);
        edge e2(b, a, i);
        deg[a]++; deg[b]++;
        G[a].push_back(e1);
        G[b].push_back(e2);
    }

    rep(i, N) K = max(deg[i], K);
    cout << K << endl;
    solve(0, 0);
    rep(i, N-1) {
        cout << ans[i] << endl;
    }

}


Measured memory_bytes: 7808
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
//////////////
//最大公約数
LL gcd(LL a, LL b) {
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}

//最小公倍数
LL lcm(LL a, LL b) {
	return a / gcd(a, b) * b;
}
void solve() {
	LL A, B, C, D;
	cin >> A >> B >> C >> D;
	LL AC = (A-1) / C;
	LL AD = (A-1) / D;
	
	LL BC = B / C;
	LL BD = B / D;

	LL CD = lcm(C, D);
	LL ACD = (A-1) / CD;
	LL BCD = B / CD;
	
	LL ans = B - A + 1;
	ans = ans - (BC - AC) - (BD - AD) + (BCD - ACD);
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define ROF(i, a, b) for (int i = a; i >= (b); i--)

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    int h, w, n; cin >> h >> w >> n;
    cout << (n - 1) / max(h, w) + 1 << endl;
}

Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

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

		long N = sc.nextLong();
		String anser = "";
		while (true) {
			N--;
			anser = (char)(N % 26 + 'a') + anser;
			N = N / 26;
			if (N == 0) {
				break;
			}
		}
		System.out.println(anser);
	}

	private static class FastScanner {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;

		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

//		public int nextInt() {
//			return Integer.parseInt(next());
//		}

		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}

Measured memory_bytes: 37088
import math


def main():
    A, B, H, M = map(int, input().split())
    H += M / 60
    H, M = H / 12 * 2 * math.pi, M / 60 * 2 * math.pi
    theta = H - M if H > M else M - H
    theta = 2 * math.pi - theta if theta > math.pi else theta
    ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62556
! 2020.2.9
!
      program answer
      implicit none
      integer :: n,i
      character(len=100) :: S
      character(len=100) :: S_x
!
      read(*,*) S
      n = len_trim(S)
      do i=1,n
        S_x(i:i) = 'x'
      end do
!
      write(*,*) S_x(1:n)
!
      end program answer

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main()
{
    int a,b,i;
    cin>>a>>b;

    int p,sum = 0;

    for(i=1; i<=b; i++)
    {
        cin>>p;
        sum = sum+p;
    }

    if(sum >= a)
        {
            cout<<"Yes"<<endl;
        }
    else
        {
            cout<<"No"<<endl;
        }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int main() {
    int N; string s;
    cin>>N>>s;
    char prev=s[0];
    int ans=1;
    for (int i = 1; i < N; ++i) {
        if(s[i]!=prev){
            ans++;
            prev=s[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
def digit_sum(n):
    n_lst = list( str(n) )
    n_sum = 0
    for i in range( len(n_lst) ):
        n_sum += int( n_lst[i] )
    return n_sum
 
n1 = input()
if digit_sum(n1)%9==0 : print("Yes")
else: print("No")

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

using namespace std;

#define ll  long long
#define s   first
#define c   second

const int   N   = 3e5 + 5;
const ll    inf = 1e17;

typedef pair<int,ll>    ii;

ii  CHT[N];
int tot;

ll  val(ii  d,int x)    {
    return  1ll * d.s * x + d.c;
}
int bad(ii  a,ii  b,ii  c)  {
    return  (c.c - a.c) * (b.s - a.s) >= (b.c - a.c) * (c.s - a.s);
}
int add(int s,ll  c)    {
    ii  d(s,c);
    for(; tot > 1 && bad(d,CHT[tot],CHT[tot - 1]) ; --tot);
    CHT[++tot] = d;
}
ll  get(int x)  {
    for(; tot > 1 && val(CHT[tot],x) <= val(CHT[tot - 1],x) ; --tot);
    return  val(CHT[tot],x);
}

int n, m;
int t[N];

int calc(ll *f,ll *s)   {
    CHT[tot = 1] = ii(0,0);

    for(int i = 1 ; i <= n ; ++i)   {
        s[i] = s[i - 1] + t[i];
        f[i] = max(get(i) - s[i] + 1ll * i * (i + 1) / 2,f[i - 1]);
        add(-i,f[i] + s[i] + 1ll * i * (i - 1) / 2);
    }
    return  1;
}

ll  f[2][N];
ll  s[2][N];
ll  h[N];

int work(int l,int r,int o) {
    if (l >  r) return  0;

    int m = (l + r + o) / 2;
    work(l,m - 1,o);
    work(m + 1,r,o);

    tot = 0;

    for(int i = l - 1 ; i < m ; ++i)
        add(-i,f[o][i] + s[o][i] + 1ll * i * (i - 1) / 2);

    vector<ll>  v;

    for(int i = m ; i <= r ; ++i)
        v.push_back(get(i) - s[o][i] + 1ll * i * (i + 1) / 2 + f[o ^ 1][n - i]);

    reverse(v.begin(),v.end());

    ll  las = -inf;

    for(ll  x : v)
        las  = max(las,x),
        h[r] = max(las,h[r]),
        --r;

    return  1;
}

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

    cin >> n;

    for(int i = 1 ; i <= n ; ++i)
        cin >> t[i],
        h[i] = -inf;

    calc(f[0],s[0]);    reverse(t + 1,t + 1 + n);
    calc(f[1],s[1]);    reverse(t + 1,t + 1 + n);

    work(1,n,0);    reverse(h + 1,h + 1 + n);
    work(1,n,1);    reverse(h + 1,h + 1 + n);

    cin >> m;

    while (m--) {
        int x;  cin >> x;
        int y;  cin >> y;
        cout << max(f[0][x - 1] + f[1][n - x],h[x] + t[x] - y) << "\n";
    }
}

Measured memory_bytes: 18740
import heapq as pq

N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]

day_to_reward = {}
for a, b in AB:
    if day_to_reward.get(a) is None:
        day_to_reward[a] = [b]
    else:
        day_to_reward[a].append(b)

ans = 0
candidate = []
for i in range(1, M+1):
    for reward in day_to_reward.get(i, []):
        pq.heappush(candidate, - reward)
    if candidate:
        work_reward = - pq.heappop(candidate)
        ans += work_reward


print(ans)


Measured memory_bytes: 33860
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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 <bits/stdc++.h>
#include<queue>
#include <numeric>
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;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
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(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}


int main(){
    int N;
    cin >> N;
    long long A[N];
    for(int i=0;i<N;++i) cin >> A[i];
    map<long long,long long>mp;
    for(int i=0;i<N;++i){
        ++mp[A[i]];
    }
    bool exist=true;
    for(int i=0;i<N;++i){
        if(mp[A[i]]>=2){
            exist=false;
            break;
        }
    }
    if(exist){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/
signed main(){
  string s;
  cin>>s;
  if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]) cout<<"Bad"<<endl;
  else cout<<"Good"<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

const int MAX_PRIME = 1000006;
vector<int> primes;
bool isPrime[MAX_PRIME+1];
// sieve of Erastosthenes
void prime_list(){
  const int sz = MAX_PRIME;
  fill(isPrime, isPrime+sz+1, true);
  isPrime[0]=isPrime[1]=false;
  for(int i=4;i<=sz;i+=2) isPrime[i]=false;
  primes.pb(2);
  for(int i=3; i<=sz; i+=2){
    if(isPrime[i]){
      primes.pb(i);
      for(long j=(long)i*i; j<=sz; j+=i) isPrime[j]=false;
    }
  }
}

int main(){
  prime_list();
  long n,p;
  cin>>n>>p;

  if(n==1){
    cout << p << endl;
    return 0;
  }

  long ans = 1;
  for(auto &pr : primes){
    int cnt = 0;
    while(p%pr==0){
      cnt++;
      p /= pr;
    }
    if(cnt/n >= 1){
      rep(_, cnt/n) ans *= pr;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define ll long long int
#define pb push_back
#define endl "\n"
ll input;
int main() {
    int t=1;
    // cin>>t;
    while(t--)
    {
        ll x,y;
        cin>>x>>y;
        for(int i=0;i<=x;i++)
        if((i*2+(x-i)*4)==y)
        {
            cout<<"Yes\n";
            return 0;
        }
        cout<<"No\n";
    }
}


Measured memory_bytes: 3640
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const ll INF=10000000000000000LL;
typedef pair<int,int>P;
vector<int> v[100001];
int c[100001],d[100001];
int main() {
	int n,a,b;
	cin>>n;
	for(int i=0;i<n-1;++i){
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	priority_queue<P,vector<P>,greater<P> >que;
	for(int i=0;i<=n;++i)c[i]=100005;
	que.push(P(0,1));
	while(!que.empty()){
		P p=que.top();que.pop();
		int n1=p.second,c1=p.first;
		if(c[n1]<=c1)continue;
		c[n1]=c1;
		for(int i=0;i<v[n1].size();++i){
			que.push(P(c1+1,v[n1][i]));
		}
	}
	for(int i=1;i<=n;++i)d[i]=100005;
	que.push(P(0,n));
	while(!que.empty()){
		P p=que.top();que.pop();
		int n1=p.second,d1=p.first;
		if(d[n1]<=d1)continue;
		d[n1]=d1;
		for(int i=0;i<v[n1].size();++i){
			que.push(P(d1+1,v[n1][i]));
		}
	}
	int mad=0;
	int mac=0;
	for(int i=1;i<=n;++i){
		if(c[i]<=d[i])mac++;
		if(c[i]>d[i])mad++;
	}
	if(mad>=mac)cout<<"Snuke"<<endl;
	else cout<<"Fennec"<<endl;
	return 0;
}


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

typedef long long ll;

const int Maxn = 2000005;
const int mod = 1000000007;

int n, h, d;
int fac, sum;
int dp[Maxn];

int main()
{
    scanf("%d %d %d", &n, &h, &d);
    fac = sum = 1;
    for (int i = 2; i <= n; i++) {
        fac = ll(fac) * i % mod;
        sum = (sum + fac) % mod;
    }
    int cur = 0;
    dp[1] = fac; dp[d + 1] = (mod - fac) % mod;
    for (int i = 1; i <= h; i++) {
        cur = (cur + dp[i]) % mod;
        if (i == h) { printf("%d\n", cur); return 0; }
        int ways = ll(cur) * sum % mod;
        dp[i + 1] = (dp[i + 1] + ways) % mod;
        dp[i + d + 1] = (dp[i + d + 1] - ways + mod) % mod;
    }
    return 0;
}


Measured memory_bytes: 8064
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
	int i, j, k, x, N;
	cin >> N;
	int a[N];
	for(i=1; i<=N; i++)
	{
		cin >> a[i];
	}
	for(k=1; k<N; k++)
	{
		cout << a[k] << " ";
	}
	cout << a[N] << endl;
	for(i=2; i<=N; i++)
	{
		for(j=i-1; j>=1; j--)
		{
			if(a[j]>a[j+1])
			{
				x=a[j+1];
				a[j+1]=a[j];
				a[j]=x;
			}
			else{}
		}
		for(k=1; k<N; k++)
		{
			cout << a[k] << " ";
		}
		cout << a[N] << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

int main()
{
	int n;
	map<string, int> m;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		if (m.find(s) != m.end())
			m[s]++;
		else
			m[s] = 1;
	}

	int ma = 0;
	
	for (auto itr : m)
		if (itr.second > ma)
			ma = itr.second;

	for (auto itr = m.begin(); itr != m.end(); itr++)
		if (itr->second == ma)
			cout << itr->first << endl;

	return 0;
}


Measured memory_bytes: 17664
def Palindrome(string):
	return string == string[::-1]

def strongPalindrome(string):
	n = len(string)
	if not Palindrome(string):
		return 'No'
	if not Palindrome(string[:(n - 1) // 2]):
		return 'No'
	if not Palindrome(string[(n + 3) // 2 - 1:]):
		return 'No'
	return 'Yes'

string = input()
print(strongPalindrome(string))

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

using namespace std;


int main(){

    string s;
    cin >> s;
    int c = 0;
    for(int i = 0;i < s.size() - 1;i++)
    {
        if(s[i] != s[i+1]) c++;
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
typedef long long ll;
const int MAX = 100010;
ll inv[MAX],fact[MAX],fi[MAX];
constexpr ll mod = 1000000007;
void inverse(){
	int i;
	inv[1] = 1;
	for(i=2;i<MAX;i++){
		inv[i] = mod - (mod/i)*inv[mod%i]%mod;
	}
	fact[0] = fi[0] = 1;
	for(i=1;i<MAX;i++){
		fact[i] = fact[i-1]*i%mod;
		fi[i] = (fi[i-1]*inv[i])%mod;
	}
}

ll comb(int n,int k){
	if(n<0 || k<0 || n<k){
		return 0;
	}else{
		return fact[n]%mod*fi[k]%mod*fi[n-k]%mod;
	}
}

ll a[1010],dp[2][1010];
int main(){
	ll i,j,n,k,l;
	cin >> n >> k;
	for(i=0;i<k;i++){
		cin >> a[i];
	}
	inverse();
	dp[0][0] = 1;
	for(i=k - 1;i>=0;i--){
		for(j=0;j<=n;j++){
			ll s = 0;
			for(l=0;l<=j;l++){
				(s += dp[0][j - l]*comb(j,l)%mod*comb(n - l,a[i] - l)%mod) %= mod;
			}
			(dp[1][j] += s) %= mod;
		}
		for(j=0;j<=n;j++){
			dp[0][j] = dp[1][j];
			dp[1][j] = 0;
		}
	}
	cout << dp[0][n] << endl;
}

Measured memory_bytes: 2688
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U> bool chmax(T &a, U b) { if (a <= b) {a = b; return 1;} return 0; }
template <class T, class U>  bool chmin(T &a, U b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T>  ostream &operator<<(ostream &os, vector<T> &v) { os << "{"; rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); } os << "}"; return os; }

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
    ll z=0,n,h,m,ans=0,sum=0,k,w,Max=-1,Min=1e9+1;
    bool ok = true;
    string s,t,u;
    cin >> w >> h >> n;
    VI a(n), x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i] >> a[i];
    ll nh=0, nw=0;

    rep(i,n){
      if(a[i] == 1){
        if(nw < x[i]) 
          nw = x[i];
      }
      if(a[i] == 2){
        if(w > x[i])
          w = x[i];
      }
      if(a[i] == 3){
        if(nh < y[i])
          nh = y[i];
      }
      if(a[i] == 4){
        if(h > y[i])
          h = y[i];
      }
    }

    if ((w < nw) ||  (h < nh))
      pri(0);
    else
      pri((w-nw)*(h-nh));

    return 0;
}


Measured memory_bytes: 256
li = [int(x) for x in input().split()]
li.sort()
tmp = li[2] * 3
buf = sum(li)

if buf%2 != tmp%2:
    ans = ((li[2] + 1) * 3 - buf) //2
else:
    ans = (li[2] * 3 - buf) // 2

print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(void)
{
    char S[5];
    int i,j,t;

    scanf("%s",S);
    j=0;
    for (i=0;i<4;i++) {
        if (S[i]=='+') j++;
        else          j--;
    }
    printf("%d",j);
    return 0;
}

Measured memory_bytes: 128
import java.util.*

fun main() {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        var max = 0
        var n = 0
        repeat(N) {
            val D = Array(2) { sc.next().toInt() }
            if (D[0] == D[1]) {
                n++
            } else {
                n = 0
            }
            if (max < n) max = n
        }
        pw.println(if (max >= 3) "Yes" else "No")
    }
}


Measured memory_bytes: 36572
import heapq
N, M = map(int, input().split())
A = list(map(lambda x: -int(x), input().split()))
heapq.heapify(A)

ans = 0
for i in range(M):
    most_expensive = -heapq.heappop(A)
    most_expensive //= 2
    heapq.heappush(A, -most_expensive)

print(-sum(A))


Measured memory_bytes: 14180
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        for(int i=1;i<=n;i++){
            if(i%3==0||i%10==3){
                System.out.print(" "+i);
            }else{
                int x=i;
                while(x>=10){
                    x/=10;
                    if(x%10==3){
                        System.out.print(" "+i);
                        break;
                    }
                }
            }
        }
        System.out.println();
    }

}



Measured memory_bytes: 28500
#include<stdio.h>
#include<string.h>
#include<math.h>
long n,x,i,nokori;
long sum=0;
long min=1000;
long s[101]={0};
int main(){
scanf("%ld",&n);
scanf("%ld",&x);
for(i=1;i<=n;i++){
scanf("%ld",&s[i]);
if(min>s[i])min=s[i];
sum+=s[i];
}
nokori=x-sum;
n+=nokori/min;
printf("%ld",n);
}

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

int main()
{
  int n,p;
  cin >> n;
  int found=0;
  for(int i=0;i<n;++i){
    cin >> p;
    if(p!=i+1){
      found+=1;
      if(found==3){
        cout << "NO";
        return 0;
      }
    }
  }
  
  cout << "YES";
  return 0;
}

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

class Program
{
	static void Main(string[] args)
	{
		var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
		var a = input[0];
		var b = input[1];

		if (a < b)
		{
			System.Console.WriteLine("a < b");
		}
		else if (a > b)
		{
			System.Console.WriteLine("a > b");
		}
		else
		{
			System.Console.WriteLine("a == b");
		}
	}
}


Measured memory_bytes: 18208
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion

int main()
{
	double n; cin >> n;
	cout << ceil(n / 2) << endl;
}

Measured memory_bytes: 256
M=10**9+7
#リストに入力（文字列）
text=input()
lst=list(text)
lst.reverse()
digit=len(lst)
six=[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]]
for i in range(digit):
  if(lst[i]=="?"):
    six[i%6][1]=six[i%6][1]+1
  else:
    six[i%6][0]=(six[i%6][0]+int(lst[i]))%13
rem=-(six[0][0]+10*six[1][0]+9*six[2][0]+12*six[3][0]+3*six[4][0]+4*six[5][0]-5)%13
######(?のいじったもの)+rem=0(mod13)
######(?*1+?*10+?*9+?*12+?*3+?*4)+rem=0
modulos=[1,0,0,0,0,0,0,0,0,0,0,0,0]
def mat1(ls):
  val_ls=[0]*13
  for i in range(13):
    val_ls[i]=(ls[i]+ls[(i-1)%13]+ls[(i-2)%13]+ls[(i-3)%13]+ls[(i-4)%13]+ls[(i-5)%13]+ls[(i-6)%13]+ls[(i-7)%13]+ls[(i-8)%13]+ls[(i-9)%13])%M
  return val_ls
def mat10(ls):
  val_ls=[0]*13
  for i in range(13):
    val_ls[i]=(ls[i]+ls[(i-10)%13]+ls[(i-20)%13]+ls[(i-30)%13]+ls[(i-40)%13]+ls[(i-50)%13]+ls[(i-60)%13]+ls[(i-70)%13]+ls[(i-80)%13]+ls[(i-90)%13])%M
  return val_ls
def mat100(ls):
  val_ls=[0]*13
  for i in range(13):
    val_ls[i]=(ls[i]+ls[(i-9)%13]+ls[(i-18)%13]+ls[(i-27)%13]+ls[(i-36)%13]+ls[(i-45)%13]+ls[(i-54)%13]+ls[(i-63)%13]+ls[(i-72)%13]+ls[(i-81)%13])%M
  return val_ls
def mat1000(ls):
  val_ls=[0]*13
  for i in range(13):
    val_ls[i]=(ls[i]+ls[(i+1)%13]+ls[(i+2)%13]+ls[(i+3)%13]+ls[(i+4)%13]+ls[(i+5)%13]+ls[(i+6)%13]+ls[(i+7)%13]+ls[(i+8)%13]+ls[(i+9)%13])%M
  return val_ls
def mat10000(ls):
  val_ls=[0]*13
  for i in range(13):
    val_ls[i]=(ls[i]+ls[(i-3)%13]+ls[(i-6)%13]+ls[(i-9)%13]+ls[(i-12)%13]+ls[(i-15)%13]+ls[(i-18)%13]+ls[(i-21)%13]+ls[(i-24)%13]+ls[(i-27)%13])%M
  return val_ls
def mat100000(ls):
  val_ls=[0]*13
  for i in range(13):
    val_ls[i]=(ls[i]+ls[(i-4)%13]+ls[(i-8)%13]+ls[(i-12)%13]+ls[(i-16)%13]+ls[(i-20)%13]+ls[(i-24)%13]+ls[(i-28)%13]+ls[(i-32)%13]+ls[(i-36)%13])%M
  return val_ls
for j in range(six[0][1]):
  modulos=mat1(modulos)
for j in range(six[1][1]):
  modulos=mat10(modulos)
for j in range(six[2][1]):
  modulos=mat100(modulos)
for j in range(six[3][1]):
  modulos=mat1000(modulos)
for j in range(six[4][1]):
  modulos=mat10000(modulos)
for j in range(six[5][1]):
  modulos=mat100000(modulos)
print(modulos[rem])

Measured memory_bytes: 4228
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    double h = sc.nextDouble();
    double m = sc.nextDouble();
    double rad = Math.toRadians(h * 30 - m * 5.5);
    double ans2 = a * a + b * b - 2 * a * b * Math.cos(rad);
    double ans = Math.sqrt(ans2);
    System.out.println(ans);

  }
}


Measured memory_bytes: 37532
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
  int N, M;
  scanf("%d %d", &N, &M);
  int X[M];
  for (int i=0; i<M; i++) {
    scanf("%d", &X[i]);
  }
  if (M <= N) {
    printf("0\n");
    return 0;
  }

  sort(X, X+M);
  int diff[M-1];
  for (int i=0; i<M-1; i++) {
    diff[i] = X[i+1] - X[i];
  }
  sort(diff, diff+(M-1));
  int ans = 0;
  for (int i=0; i<(M-N); i++){
    ans += diff[i];
  }
  printf("%d\n", ans);

}


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

#define INF 1001001001
#define MAX 1e18

int main() {
  int n, m;
  cin >> n >> m;
  vector<string> s(n);
  rep(i,n) cin >> s[i];

  mf_graph<int> g(n*m+2);
  int dx[4] = {1, 0, -1,  0};
  int dy[4] = {0, 1,  0, -1};
  rep(x,n)rep(y,m) {
    if (s[x][y]=='#') continue;
    if ((x+y)%2==0) {
      g.add_edge(n*m,x*m+y,1);
      rep(i,4) {
        int nx = x+dx[i];
        int ny = y+dy[i];
        if (nx < 0 || nx >= n || ny < 0 || ny >= m || s[nx][ny]=='#') continue;
        g.add_edge(x*m+y,nx*m+ny,1);
      }
    }
    else g.add_edge(x*m+y,n*m+1,1);
  }
  int f = g.flow(n*m,n*m+1);
  for (auto e : g.edges()) {
    if (!e.flow||e.from==n*m||e.to==n*m+1) continue;
    int sx = e.from/m, sy = e.from%m;
    int tx = e.to/m, ty = e.to%m;
    if (tx==sx+1) s[sx][sy]='v', s[tx][ty]='^';
    if (tx==sx-1) s[sx][sy]='^', s[tx][ty]='v';
    if (ty==sy+1) s[sx][sy]='>', s[tx][ty]='<';
    if (ty==sy-1) s[sx][sy]='<', s[tx][ty]='>';
  }
  cout << f << endl;
  rep(i,n) cout << s[i] << endl;

  return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int edge[50][50];

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

  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edge[a][b]++;
    edge[b][a]++;
  }

  rep(i, n) {
    int cnt = 0;
    rep(j, n) cnt += edge[i][j];
    cout << cnt << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<set>
#include<math.h>
using namespace std;

int main(){
    int N;
    int d[110];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> d[i];
    }
    
    set<int> V;
    for(int i=0; i<N; i++){
        V.insert(d[i]);
    }
    
    
    cout << V.size() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include<string>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9 + 7);

string s, t;
vector<vector<int>> dp;

int main(void) {
	cin >> s >> t;
	if (s.size() < t.size())
		swap(s, t);
	dp = vector<vector<int>>(s.size() + 1, vector<int>(t.size() + 1, 0));

	for (int i = 1; i < s.size() + 1; i++) {
		for (int j = 1; j < t.size() + 1; j++) {
			if (s[i - 1] == t[j - 1])
				dp[i][j] = dp[i - 1][j - 1] + 1;
			else
				dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
		}
	}
	int ret_size = dp[s.size()][t.size()];
	string ret(ret_size, ' ');
	int i = s.size();
	int j = t.size();
	while (ret_size > 0) {
		if (s[i - 1] == t[j - 1]) {
			ret[ret_size-1] = s[i - 1];
			i--;
			j--;
			ret_size--;
		}
		else if (dp[i - 1][j] == dp[i][j])
			i--;
		else
			j--;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 38548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;

int main() {
    int x,y,z; cin >> x >> y >> z;
    x-=z;
    cout << x/(y+z);
}




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

using namespace std;

int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    if (m1 < m2) {
        h2--;
        m2 += 60;
    }
    int up = (h2 - h1) * 60 + (m2 - m1);
    cout << up - k << endl;
    return 0;
}


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

using namespace std;

int read()
{
	int a = 0,x = 1;
	char ch = getchar();
	while(ch > '9' || ch < '0'){
		if(ch == '-') x = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9'){
		a = a*10 + ch-'0';
		ch = getchar();
	}
	return a*x;
}
const int N=1007;
char s[N];
int main()
{
	scanf("%s",s);
	if(s[strlen(s)-1] == 's') {
		printf("%ses",s);
	} else printf("%ss",s);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint func(ll n, ll x){
	mint val = 1;
	mint a = n;
	mint b = x;

	rep(i,x){
		val *= a;
		a -= 1;
	}
	rep(i,x){
		val /= b;
		b -= 1;
	}

	return val;
}

void solve_156() {
	ll n, a, b;
	ll ans = 0;

	cin >> n >> a >> b;

	mint x = 2;
	mint val = x.pow(n);

	mint sum;
	sum = func(n, a) + func(n, b);

	ans = val.x - 1 - sum.x;
	while ( ans < 0){
		ans += MOD; 
	}

	cout << ans << "\n";
}

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

	solve_156();

	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
    
    int d, n;
    int ans;
    
    scanf("%d%d", &d, &n);
    
    if (n<100) {
        ans = n*pow(100, d);
    } else {
        ans = 101*pow(100, d);
    }
    
    printf("%d", ans);
    
    return 0;
}


Measured memory_bytes: 2276
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int a[100100];
vector<int> v;
int main()
{
	int n;
	cin>>n;
	rep(i,n) cin>>a[i];
	sort(a,a+n);
	lint out=0;
	if(n%2==0){
		rep(i,n/2-1) out-=a[i]*2;out-=a[n/2-1];out+=a[n/2];
		REP(i,n/2+1,n) out+=a[i]*2;
	}
	else{
		rep(i,n/2-1) out-=a[i]*2;
		REP(i,n/2+2,n) out+=a[i]*2;
		out+=max(a[n/2+1]+a[n/2]-a[n/2-1]*2,a[n/2+1]*2-a[n/2]-a[n/2-1]);
	}
	cout<<out<<endl;
}


Measured memory_bytes: 888
#define _GLIBCXX_DEBUG
#include"bits/stdc++.h"

using namespace std;

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define ZeroToN(i,n) for(int i=0;i<(ll)(n+1);i++)
#define AToB(i,a,b) for(int i=a;i<(ll)(b+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back


#define remove_unique(v) v.erase(unique(ALL(v)), v.end())

//pair
#define fir first
#define sec second

//types
#define ll long long
#define vec vector
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(char a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T = int>
void print(vec<T> v){ cout << "["; for (T item: v) { cout << item << ", "; } cout << "]" << endl; }

template <class T = int>
void print2dVec(vec<vec<T>> v2d){for(vec<T> v: v2d) {print(v);}}

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"YES":"NO"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__
#define next next__
#define prev prev__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

void Main() {
    //code here
    int n = gi;
    string s = gs;
    int res = 0;
    AToB(i, 0, 999) {
        vec<int> digits = {i/100, i/10%10, i%10};
        int f = 0;
//print(digits);
        for(char c: s) {
            if (digits[f] + '0' == c) {
                f++;
            }
            ///print(f);
            if (f == 3) {
                break;
            }
        }
        if (f == 3) {
            res += 1;
        }
    }
    print(res);
}

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

Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<int> Slist() { return new List<int>(ReadLine().Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var XY = Sarray();
            var X = XY[0];
            var Y = XY[1];
            var cnt = 0;
            long tmp = X;
            while(tmp<=Y)
            {
                tmp *= 2;
                cnt++;
            }
            WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 18980
#include <cstdio>
#include <cstring>
#include <vector>
#include <utility>
#include <functional>
#include <algorithm>

using namespace std;

int dp[512][10005];
int N,M;
int P[10005],C[512],E[512];

int dfs(int n, int m){
  if(n>=N) return P[min(m,M)];
  int &res = dp[n][m];
  if(res >= 0) return res;
  return res = max(dfs(n+1,m), dfs(n+1,min(m+C[n],M))-E[n]);
}

int main(){
  scanf("%d%d",&M,&N);
  memset(dp, -1, sizeof dp);
  for(int i=1;i<=M;i++) scanf("%d",&P[i]);
  sort(P+1, P+M+1, greater<int>());
  for(int i=1;i<M;i++) P[i+1] += P[i];
  for(int i=0;i<N;i++) scanf("%d%d", &C[i], &E[i]);

  printf("%d\n", dfs(0, 0));
  return 0;
}

Measured memory_bytes: 21116
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int N, M;
    cin >> N >> M;
    VVI S(M);
    REP(i, M) {
        int k;
        cin >> k;
        REP(j, k) {
            int foo;
            cin >> foo;
            S[i].EB(foo - 1);
        }
    }
    VI p(M);
    REP(i, M) {
        cin >> p[i];
    }

    int ans = 0;
    REP(i, (1 << N)) {
        bool ok = true;
        REP(j, M) {

            int cnt = 0;
            FORE(e, S[j]) {
                if (i & (1 << e)) {
                    cnt++;
                }
            }
            if (cnt % 2 != p[j]) {
                ok = false;
            }
        }
        if (ok) {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N = ri()
A = np.array(rl())
c = np.bincount(A)
if len(c) == 1:
    answer = c[0]
else:
    answer = c[0] + c[1]

for i in range(1, len(c)-1):
    result = c[i-1] + c[i] + c[i+1]
    if result > answer:
        answer = result

print(answer)


Measured memory_bytes: 23436
#include <bits/stdc++.h>
using namespace std;
int a,b,fr[110];
int main()
{
    for(int i=1;i<=9;i++)
        for(int j=1;j<=9;j++)
            fr[i*j]=1;
    cin>>a;
    if(fr[a]==1)
        cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256