akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
	int k = 0 , ans = 0;
	string X;
	cin >>X;
	for( int i = 0 ; i < X.size() ; i++){
		if(X[i] == 'A'||X[i] == 'T'||X[i] == 'C'||X[i] == 'G'){
		    k++;
		    if(i == X.size() - 1){
		    	if(ans < k) ans = k;
		    }
		}
		else{
			if(ans < k){
				ans = k;
			}
			k = 0;
		}
	}
    cout << ans <<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x1 = Integer.parseInt(sc.next());
        int y1 = Integer.parseInt(sc.next());
        int x2 = Integer.parseInt(sc.next());
        int y2 = Integer.parseInt(sc.next());

        int vx = x2 - x1;
        int vy = y2 - y1;

        int x3 = 0, y3 = 0, x4 = 0, y4 = 0;
        x3 = x2 - vy;
        y3 = y2 + vx;
        x4 = x1 - vy;
        y4 = y1 + vx;

        System.out.printf("%d %d %d %d\n", x3, y3, x4, y4); 
    }
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    int a, b, c;
    cin>>a>>b>>c;

    cout<<max(0, c - (a - b))<<endl;
}

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

using namespace std;

#define int long long

bool codejam = 0;

typedef long long li;
typedef long double ld;

void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1;
	// int t; 
	// cin >> t;
	int tt = t;
	while (t--) { 
		if (codejam) cout << "Case #" << tt - t << ": ";
		solve();
	}
	return 0;
}
const int N = 2e5, M = 1e9 + 7;
int dp[N];
set<int> lol;
void solve() {
	int n;
	cin >> n;
	int m;
	cin >> m;
	for (int i = 1; i <= m; ++i) {
		int ha;
		cin >> ha;
		lol.insert(ha);
	}
	memset(dp, 0, sizeof dp);
	dp[0] = 1;
	for (int i = 1; i <= n; ++i) {
		if (lol.count(i)) continue;
		if (i >= 1) dp[i] += dp[i - 1];
		if (i >= 2) dp[i] += dp[i - 2];

		dp[i] %= M;
	}
	cout << dp[n];
}	
 	

Measured memory_bytes: 6528
//Triangle
#include<math.h>
#include<iostream>
using namespace std;
int main()
{
	long long S, x1 = 1000000000, x2 = 1, y1, y2, z1 = 0, z2 = 0, q, r;
	cin >> S;
	if(S == pow(10, 18)) {
		y2 = pow(10, 9);
		y1 = 0;
	}
	else {
	r = S % x1;
	q = S / x1;
	y2 = q + 1;
	y1 = x1 - r;
	}
	cout << x1 << " " << x2 << " " <<  y1 << " " << y2 << " " << z1 << " " << z2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>
#include <iomanip>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  priority_queue<double, vector<double>, greater<double>> v;
  REP(i,0,n) {
    double x;
    cin >> x;
    v.push(x);
  }
  while (v.size() >= 2) {
    double x = v.top();
    v.pop();
    double y = v.top();
    v.pop();
    v.push((x + y) / 2);
  }
  cout << setprecision(15) << v.top() << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int l[n];
    for(int i=0;i<n;i++)cin>>l[i];
    sort(l,l+n);
    int x=0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            x+=lower_bound(l+j+1,l+n,l[i]+l[j])-upper_bound(l+j+1,l+n,l[j]-l[i]);
        }
    }
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<utility>
#include<tuple>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<queue>
#include<deque>
#include<bitset>
#include<cmath>
#include<map>
#include<iomanip>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a; i < b; i++)

int main() {

	int k, a, b;
	cin >> k >> a >> b;

	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}

	cout << "NG" << endl;

	return 0;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int a,b,c,d;
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		d = sc.nextInt();
		if(juge(a,c,d)) {
			System.out.println("Yes");
		}else if(juge(a,b,d)&&juge(b,c,d)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

	private static boolean juge(int a1, int a2, int d) {
		if(java.lang.Math.abs(a1-a2)<=d) {
			return true;
		}else {
			return false;
		}
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>

using namespace std;

int main(){
    int n;
    string s,ans = "Yes";

    cin >> n >> s;

    if(n % 2 != 0) ans = "No";
    else{
        for(int i = 0;i < n/2;i++){
            if(s[i] != s[i+(n/2)])
                ans = "No";
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

void main(){
    while(true) {
        auto n = readInt();
        if(n == 0) {
            return;
        }
        int ans;
        foreach(i; iota(n)) {
            int x, y, h, w;
            readlnTo(x, y, h, w);
            auto l = x+y+h;
            if(l <= 60 && w <= 2) {
                ans += 600;
                continue;
            }
            if(l <= 80 && w <= 5) {
                ans += 800;
                continue;
            }
            if(l <= 100 && w <= 10) {
                ans += 1000;
                continue;
            }
            if(l <= 120 && w <= 15) {
                ans += 1200;
                continue;
            }
            if(l <= 140 && w <= 20) {
                ans += 1400;
                continue;
            }
            if(l <= 160 && w <= 25) {
                ans += 1600;
                continue;
            }
        }
        writeln(ans);
    }
}

Measured memory_bytes: 3144
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <string>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    long long n,k; cin >> n >> k;
    long long ans = k;
    ans *= pow(k-1L,n-1L);
    cout << ans << endl; return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N; cin >> N; int a[N]; int mi=inf, ma=-inf, mii, mai;
  cout << 2*N- 2 << endl;
  rep(i, N){
    cin >> a[i];
    if(mi>a[i]){
      mi=a[i]; mii=i+1;
    }
    if(ma<a[i]){
      ma=a[i]; mai=i+1;
    }
  }
  bool plus = false;
  if(ma>0 && abs(ma)>abs(mi)) plus = true;
  if(plus){
    rep(i, N){
      if(i+1==mai) continue;
      cout << mai << " " << i+1 << endl;
    }
    rep(i, N-1){
      cout << i+1 << " " << i+2 << endl;
    }
    return 0;
  }
  rep(i, N){
    if(i+1==mii) continue;
    cout << mii << " " << i+1 << endl;
  }  
  for(int i=N; i>=2; i--){
    cout << i << " " << i-1 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
      
  
  
  
  
 
 
int main(){
  ll i, j;
  string s;
  cin >> s;
  ll n = s.size();
  vector<ll> a(n + 1),ab(n + 1), abc(n + 1),x(n+1);
  x[0]=1;
  for(i = 1; i < n + 1;i++){
    x[i]=x[i-1];
    a[i] = a[i - 1];
    ab[i] = ab[i - 1];
    abc[i] = abc[i - 1];
    switch(s[i - 1]){
      case 'A':
        a[i] += x[i];
        break;
      case 'B':
        ab[i] += a[i - 1];
        break;
      case 'C':
        abc[i] += ab[i - 1];
        break;
      case '?':
        abc[i] = 3 * abc[i - 1] + ab[i - 1];
        ab[i] = 3 * ab[i - 1] + a[i - 1];
        //cout << "tsts" << endl;
        a[i] = 3 * a[i - 1] + x[i-1];
        x[i]=x[i-1]*3;
        
        break;
    }
    //cout << a[i] spa ab[i] spa abc[i] << endl;
    a[i] %= MOD;
    ab[i] %= MOD;
    abc[i] %= MOD;
    x[i]%=MOD;
  }
  cout << abc[n] << endl;
    
        
  return 0;
}

Measured memory_bytes: 3584
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<set>
#include<fstream>
#include<map>
#include<string>
#include <stdio.h>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<stack>
#include<climits>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll>vl;
typedef vector<int>vi;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef vector<char>vc;
typedef vector<string>vs;
#define MP make_pair
#define all(v) v.begin(),v.end()
const ll mod = 1000000007;
const ll OO = (ll)1e18;
const int dx[] = { 0, 1, -1, 0 };
const int dy[] = { 1, 0, 0, -1 };
ll gcd(ll a, ll b){ if (b == 0){ return a; }return gcd(b, a % b); }
ll fast_power(ll base, ll power){
	if (power == 1) return base;
	if (power % 2 == 0) return fast_power((base*base), power / 2);
	else return(base*fast_power((base*base), power / 2));
}
//#pragma warning (disable : 4996)
void Qalbaz()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(2);
	
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, mn = 1e8, c;
	ll x;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		c = 0;
		cin >> x;
		while (x % 2 == 0)
		{
			x /= 2;
			c++;
		}
		mn = min(mn, c);
	}
	cout << mn;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#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 forn(i,n,m) for(int (i)=(n);i<=(int)(m);(i)++)
#define pb push_back
#define mp make_pair
#define re return
#define first fi
#define second se
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF=1e9;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef queue <int> qi;
int n; 
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	cout<<pow(n,3);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

vector<int> Eratosthenes(const int N)
{
    vector<bool> is_prime(N + 1);
    for (int i = 0; i <= N; i++)
    {
        is_prime[i] = true;
    }
    vector<int> P;
    for (int i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (int j = 2 * i; j <= N; j += i)
            {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}
int calc(int x)
{
    int cur = 1;
    while (((cur + 1) * cur) / 2 <= x)
    {
        cur++;
    }
    cur--;
    return cur;
}
int main()
{
    ll n;
    cin >> n;
    int ans = 0;
    ll x = 2;
    cerr << "done" << endl;
    while (x * x <= n)
    {
        if (n % x == 0)
        {
            int cnt = 0;
            while (n % x == 0)
            {
                cnt++;
                n /= x;
            }
            // cerr << cnt << " " << calc(cnt) << endl;
            ans += calc(cnt);
        }
        x++;
    }
    if (n != 1)
    {
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define LL long long int 
#define LD long double
#define PI 3.14159265358979323846
#define MOD ((LL)1e9+7)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const LL N=1e5+10;
vector<LL>A(N),dp(N),f(N);
LL n;
/*
LL make_dp(LL I)
{
	if(f[I])return dp[I];
	if(I==1)dp[I]=0;
	else if(I==2)dp[I]=abs(A[1]-A[2]);
	else
	{
		dp[I]=min(dp[I-1]+abs(A[I-1]-A[I]),dp[I-2]+abs(A[I]-A[I-2]));
	}
	f[I]++;
	return dp[I];
	
}*/
int main()
{
	IOS
	cin>>n;
	for(LL i=1;i<=n;i++)cin>>A[i];
	
	dp[1]=0;
	dp[2]=abs(A[1]-A[2]);
	for(LL i=3;i<=n;i++)
	{
		dp[i]=min(dp[i-1]+abs(A[i]-A[i-1]),dp[i-2]+abs(A[i]-A[i-2]));
	}
	cout<<dp[n]<<endl;	
}
			
				
			
	
	
	
			
		



Measured memory_bytes: 2560
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1 << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	cin >> N;
	string S;
	string T;
	cin >> S >> T;
	string ans;
	rep(i, 2 * N) {
		if (i & 1) {
			ans.push_back(T[i / 2]);
		} else {
			ans.push_back(S[i / 2]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
const int inf = INT_MAX;
const double eps = 0.0000001;
const double PI = acos(-1.0);
const int MOD = 1e9+7;
const int N  = 1e5+5;

int a[N][3], dp[N][3];

int solve(int i, int j) {
	if (i == 0) return 0;
	if (dp[i][j]) return dp[i][j];
	int ans = 0;
	for (auto k: {0, 1, 2}) {
		if (j == k) continue;
		ans = max (ans, a[i][k] + solve(i-1, k));
	}
	dp[i][j] = ans;
	return ans;
}

signed main(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif  
    IOS;

    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    	cin >> a[i][0] >> a[i][1] >> a[i][2];
    cout << max({solve(n, 0), solve(n, 1), solve(n, 2)});
    return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans=0;
cin >> n;
int v[n],c[n],r[n];
rep(i,n) cin >> v[i];
rep(i,n) cin >> c[i];
rep(i,n) {
r[i] = v[i] - c[i];
if (r[i]>0){
ans += r[i];
}
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
program rectangle_cutting
  implicit none
  real(8) :: w, h, x, y
  integer :: m
  character(64) :: s
  read(*,*) w, h, x, y
  write(s,'(f40.16)') 0.5d0*w*h
  m = 0
  if ((x.eq.0.5d0*w).and.(y.eq.0.5d0*h)) m = 1
  write(*,'(a,x,i0)') trim(adjustl(s)), m
  stop
end program rectangle_cutting

Measured memory_bytes: 640
#include <stdio.h>

void insertionSort(int A[], int N)
{
  int i, j, k;
  int v;
    
  for (i = 1; i < N; i++) {
    v = A[i];
    j = i - 1;

    while (j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
    }

    A[j + 1] = v;

    for (k = 0; k < N; k++) {
      if (k != N -1) {
	printf("%d ", A[k]);
      } else {
	printf("%d\n", A[k]);
      }
    }
  }
}

int main()
{
  int i;
  int N;
  int A[1000];

  scanf("%d", &N);

  for (i = 0; i < N; i++) {
    char c;
    int ret;
    ret = scanf("%d%c", &A[i], &c);
    if (ret == 1) break;
  }

  for(i = 0; i < N; i++) {
    if (i != N -1) {
      printf("%d ", A[i]);
    } else {
      printf("%d\n", A[i]);
    }
  }
  
  insertionSort(A, N);

  return 0;
}



Measured memory_bytes: 2044
#include <stdio.h>

void swap(int *X, int *Y)
{
    int Temp = *X;
    *X = *Y;
    *Y = Temp;
}

int main()
{
    for(int i = 0; i < 3000; ++i){
        int X, Y;
        scanf("%d%d", &X, &Y);
        if(X == 0 && Y == 0) return 0;
        if(X > Y) swap(&X, &Y);
        printf("%d %d\n", X, Y);
    }
    return 0;
}


Measured memory_bytes: 2660
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <tuple>

using namespace std;

int main()
{
    int N, m=0;
    string S;
    cin >> N >> S;
    for (int j=0; j < N-1; ++j) {
        int tmp=0;
        array<bool, 27> x={false};
        for (int k=0; k < j; ++k) {
            int c = S[k] - 'a';
            x[c] = true;
        }
        for (int k=j; k < N; ++k) {
            int c = S[k] - 'a';
            if (x[c]) tmp+=1;
            x[c] = false;
        }
        m = max(m, tmp);
    }
    cout << m << endl;
}

Measured memory_bytes: 256
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define int long long
#define inf 1000000007
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
int v;
vector<int> G[205];
int match[205];
bool used[205];

void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
}

bool dfs(int v){
    used[v]=true;
    for(int i=0; i<G[v].size();i++){
        int u=G[v][i],w=match[u];
        if(w<0||(!used[w]&&dfs(w))){
            match[v]=u;
            match[u]=v;
            return true;
        }
    }
    return false;
}
int bipartite_matching(){
    int res=0;
    memset(match,-1,sizeof(match));
    rep(i,0,v){
        if(match[i]<0){
            memset(used,0,sizeof(used));
            if(dfs(i))res++;
        }
    }
    return res;
}

signed main() {
    cin>>v;
    P red[105],blue[105];
    rep(i,0,v){
        cin>>red[i].first>>red[i].second;
    }
    rep(i,0,v){
        cin>>blue[i].first>>blue[i].second;
    }
    rep(i,0,v){
        rep(j,0,v){
            if(red[i].first<blue[j].first&&red[i].second<blue[j].second){
                add_edge(i,v+j);
            }
        }
    }
    v*=2;
    cout<<bipartite_matching()<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;

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

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100100];

int main() {
  int N, K; cin >> N >> K;
  for (int i = 0; i < N; ++i) cin >> h[i];

  // 初期化 (最小化問題なので INF に初期化)
  for (int i = 0; i < 100100; ++i) dp[i] = INF;

  // 初期条件
  dp[0] = 0;

  // ループ
  for (int i = 0; i < N; ++i) {
    for (int j = 1; j <= K; ++j) {
      chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    }
  }

  // 答え
  cout << dp[N-1] << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
#include <sstream>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main() {
    ll ans = 0;

    ll n, m;
    
    cin >> n >> m;
    
    vector<ll> k;
    vector<ll> *s = new vector<ll> [m];
    vector<ll> p;

    for (int i = 0; i < m; i++) {
        ll temp;
        cin >> temp;
        k.push_back(temp);
        for (int j = 0; j < temp; j++) {
            ll temps;
            cin >> temps;
            s[i].push_back(temps);
        }
    }

    for (int i = 0; i < m; i++) {
        int temp;
        cin >> temp;
        p.push_back (temp);
    }

    for (int bit = 0; bit < (1<<n); bit++) {
        bool ok = true;
        for (int i = 0; i < m; i++) {
            ll ct = 0;
            for (int j = 0; j < k[i]; j++) {
                if (bit & (1<<s[i][j]-1)) ct++;
            }
            if (ct % 2 != p[i]) ok = false; 
        }
        if (ok) ans++;
    }

    cout << ans << endl;

}

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

const int mod = 1000000007;
int dp[100020][13];

int main(){
  string s;
  cin >> s;
  int n = s.size();
  // memset(dp,0,sizeof(dp));
  if(s[0]=='?')rep(i,10)dp[0][i]=1;
  else dp[0][s[0]-'0']=1;
  for(int i=1;i<n;i++){
    if(s[i]=='?'){
      for(int j=0;j<13;j++){
        for(int l=0;l<10;l++){
          (dp[i][(j*10+l)%13]+=dp[i-1][j])%=mod;
        }
      }
    }else{
      int c = s[i]-'0';
      for(int j=0;j<13;j++){
        (dp[i][(j*10+c)%13]+=dp[i-1][j])%=mod;
      }
    }
    for(int j=0;j<13;j++)dp[i][j]%=mod;
  }
  // rep(i,n){
  //   rep(j,13){
  //     cout << dp[i][j] << ' ';
  //   }
  //   cout << endl;
  // }
  cout << dp[n-1][5] << endl;
  return 0;
}


Measured memory_bytes: 5504
#include <iostream>
#include <vector>
#include <algorithm>

#define pb push_back
#define mp make_pair

using namespace std;

int main(void)
{
	int n,m;
	int h,r;
	int i1,i2;
	int maxx;

	while(1){
		cin>>n;
		if(n==0) break;

		vector<pair<int,int> > doll;

		for(i1=0;i1<n;i1++){
			cin>>h>>r;
			doll.pb(mp(h,r));
		}
		cin>>m;
		for(i1=0;i1<m;i1++){
			cin>>h>>r;
			doll.pb(mp(h,r));
		}

		sort(doll.begin(), doll.end());
		vector<int> dp(doll.size(),1);
		maxx=0;
		
		for(i1=0;i1<doll.size();i1++){
			for(i2=0;i2<i1;i2++){
				if(doll[i1].first>doll[i2].first && doll[i1].second>doll[i2].second) {
					dp[i1]=max(dp[i1],dp[i2]+1);
				}
			}
			maxx=max(maxx,dp[i1]);
		}
		cout<<maxx<<endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#include <iostream>

using namespace std;

#define MAX 100005
#define NIL -1

struct Node{
    int p, l, r;
};

Node T[MAX];
int n, D[MAX], H[MAX];

int max(int a, int b){
    if(a > b){
        return a;
    }
    else return b;
}

int getSibling(int u){
    if(T[u].p == NIL)return NIL;
    if(T[T[u].p].l != u && T[T[u].p].l != NIL){
        return T[T[u].p].l;
    }
    if(T[T[u].p].r != u && T[T[u].p].r != NIL){
        return T[T[u].p].r;
    }
    return NIL;
}

void print(int u){
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "sibling = " << getSibling(u) << ", ";
    int deg = 0;
    if(T[u].l != NIL)deg++;
    if(T[u].r != NIL)deg++;
    cout << "degree = " << deg << ", ";
    cout << "depth = " << D[u] << ", ";
    cout << "height = " << H[u] << ", ";
    
    if( T[u].p == NIL){
        cout << "root" << endl; 
    }
    else if(T[u].l == NIL && T[u].r == NIL){
        cout << "leaf" << endl;
    }
    else cout << "internal node" << endl;
}
void rec(int u, int p){
    D[u] = p;
    if(T[u].r != NIL)rec(T[u].r, p + 1);
    if(T[u].l != NIL)rec(T[u].l, p + 1);
}

int high(int u){
    int h1, h2;
    h1 = h2 = 0;
    if(T[u].r != NIL){
        h1 = high(T[u].r) + 1;
    }
    if(T[u].l != NIL){
        h2 = high(T[u].l) + 1;   
    }
    return H[u] = max(h1, h2);
}

int main(void){
    // Your code here!
    int i, v, l, r, root = 0;
    cin >> n;
    for(i = 0; i < n; i++)T[i].p = T[i].l = T[i].r = NIL;
    
    for(i = 0; i < n; i++){
        cin >> v >> l >> r;
        T[v].l = l;
        T[v].r = r;
        if(l != NIL)T[l].p = v;
        if(r != NIL)T[r].p = v;
    }   
    for(i = 0; i < n; i++){
        if(T[i].p == NIL){
            root = i;
        }
    }
    
    rec(root, 0);
    high(root);
    
    for(i = 0; i < n; i++){
        print(i);
    }
    
    return 0;
}


Measured memory_bytes: 3148
#include<stdio.h>

int main(void)
{



        double a = 0, b = 0, c = 0, d = 0, e = 0, f = 0;
        double x = 0.0, y = 0.0;


        while(scanf("%lf %lf %lf %lf %lf %lf", &a, &b , &c , &d , &e , &f) != EOF)
        {
                y = ((d * c) - (a * f)) / ((d * b) - (a * e));
                x = (c - (b * y)) / a;

                printf("%0.3f %0.3f\n", x, y);
        }

        return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;

char str[100003]; int N;

int main(){
	scanf("%s" , str + 1); N = strlen(str + 1);
	if(str[1] == '0' || str[N] == '1'){puts("-1"); return 0;}
	for(int i = 1 ; i < N ; ++i) if(str[i] != str[N - i]){puts("-1"); return 0;}
	int pre = 1;
	for(int i = 2 ; 2 * i <= N ; ++i){
		if(str[i] == '1') while(pre < i) cout << pre++ << ' ' << i << endl;
	}
	while(pre < N) cout << pre++ << ' ' << N << endl;
    return 0;
}

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

/*
const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  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;
  }
};

// Paskal's triangle => Combination
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for ( int i = 0; i <= 4000; i++) {
    for ( int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}

mint comb(int n, int k) {
  return c[n][k];
}

mint f2(int n, int k) {
  return comb(n+k-1,k-1);
}

mint f(int n, int k) {
  if (n < k) return 0;
  if (n == 0 && k == 0) return 1;
  if (k < 1) return 0;
  return f2(n-k,k);
}

int main() {
  init();
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    mint blue = f(k,i); // f2(k-i,i) -> comb(k-i+i-1,i-1) = comb(k-1,i-1)
    // mint red = f2(n-k-(i-1),i+1) -> comb(n-k-(i-1)+i+1-1,i+1-1) = comb(n-k+1,i)
    mint red = 0;
    {
      red += f(n-k,i-1);
      red += f(n-k,i);
      red += f(n-k,i);
      red += f(n-k,i+1);
    }
    mint ans = blue * red;
    printf("%lld\n", ans.x);
  }
  return 0;
}
*/
// chiba original ↓

long long c[4005][4005];
void init() {
  c[0][0] = 1;
  for ( int i = 0; i <= 4000; i++) {
    for ( int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j] % MOD; // c[1][0] = 1  c[2][0] = 1 c[2][1] += 1 => 2
      c[i+1][j+1] += c[i][j] % MOD; // c[1][1] = 1 c[2][1] = 1 c[2][2] = 1
    }
  }
}


long long combination(int n, int k) {
  return c[n][k];
}

int main(){
  init();
  int N, K;
  cin >> N >> K;

  if ( N == K ) { // only Blue
    for (int i = 0; i < N; i++) {
      if(i==0) cout << 1 << endl;
      else cout << 0 << endl;
    }
    return 0;
  }

  for ( int i = 1; i <= K; i++ ) { // K = 1000
    // K-1Ci-1 * N-K+1Ci
    // 多分これでもいけるが、場合分けを除外しないといけない
    long long blue = combination(K-1, i-1); // blue i >= 572 でなぜか0
    long long red  = combination(N-K+1, i); // red

    // mint blue = comb(K-1, i-1);
    // mint red  = comb(N-K+1, i);
    // mint ans = blue * red;
    cout << blue * red % MOD << endl;
    // cout << ans.x << endl;

  }
  return 0;
}

/*
// 後半半分がMODした分減少してしまい、ゼロになる
long long combination(int n, int r) {
  // if ( n < r ) return 0;
  if ( n == 0 && r == 0 ) return 1;
  long long num = 1;
  // r == 0以下の時はfor文を迂回してnum = 1を返す。
  for ( int i = 1; i <= r; i++ ) {
    num = num * ( n - i + 1 ) / i; // 1/2が0になるので、右辺が num * () / iとする
    // cout << n << " " << r << " " << i << " " << num << endl;
  }
  return num % MOD;
}
*/


Measured memory_bytes: 123648
#include <iostream>
using namespace std;


int main(){
    int N;
    int p[50];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> p[i];
    }

    int count = 0;

    for(int j=0; j<N; j++){
        if(p[j] != j+1){
            count++;
        }
    }

    if(count == 0 || count == 2){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
class Dice{
public:
    int f[6];
    void move(int i,int j,int k,int l){
        int t=f[i];f[i]=f[j];f[j]=f[k];f[k]=f[l];f[l]=t;
    }
    void roll(char c){
        if(c=='E'){
            move(0,3,5,2);
        }
        if(c=='W'){
            move(0,2,5,3);
        }
        if(c=='N'){
            move(0,1,5,4);
        }
        if(c=='S'){
            move(0,4,5,1);
        }
        if(c=='R'){
            move(1,2,4,3);
        }
    }
    int top() {
        return f[0];
    }
    int right(){
        return f[2];
    }
    int left(){
        return f[3];
    }
    int front(){
        return f[1];
    }
};
bool eq(Dice a,Dice b){
    for(int i=0;i<6;i++) if(a.f[i]!=b.f[i]) return false;
    return true;
}
int main(){
    Dice d[2];
    for(int j=0;j<2;j++)
        for(int i=0;i<6;i++)
            cin >> d[j].f[i];
    bool f=false;
    
    
    for(int i=0;i<4;i++){
        d[1].roll('R');
        for(int j=0;j<4;j++){
            d[1].roll('N');
            if(eq(d[0],d[1])) f=true;
        }
    }
    d[1].roll('E');
    for(int j=0;j<4;j++){
        d[1].roll('N');
        if(eq(d[0],d[1])) f=true;
    }
    
    d[1].roll('W');
    d[1].roll('W');
    for(int j=0;j<4;j++){
        d[1].roll('N');
        if(eq(d[0],d[1])) f=true;
    }
    
    cout << (f?"Yes":"No") << endl;
    return 0;
}




Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 7;
const int MOD = 1e9 + 7;

int dp[N];
int ps[N+1];

int main()
{
	ios::sync_with_stdio(false);

	dp[0] = 1;
	ps[1] = 1;
	for (int i=1; i<N; i++)
	{
		dp[i] = (dp[i-1] + ps[max(0, i-2)]) % MOD;
		ps[i+1] = (ps[i] + dp[i]) % MOD;
	}
	int n;
	cin >> n;
	ll res = n;
	for (int i=1; i<n; i++)
	{
		res = (res + 1LL * dp[i-1] * (n-1) % MOD * (n-1)) % MOD;
		res = (res + 1LL * dp[i] * (n-1)) % MOD;
	}
	cout << res << "\n";


	return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  int sum = 0;
  rep(i, s.size()) {
    sum += s[i] - '0';
  }
  if(sum % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3748
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_157
{
    class C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            int n = nm[0];
            int m = nm[1];
            int?[] nums = new int?[n];
            int[][] scs = new int[m][];
            for(int i = 0; i < m; i++)
            {
                scs[i] = ReadInts();
            }

            for(int i = 0; i < m; i++)
            {
                int s = scs[i][0] - 1;
                int c = scs[i][1];
                if (nums[s] == null)
                {
                    nums[s] = c;
                }
                else if(nums[s]!=c)
                {
                    WriteLine(-1);
                    return;
                }
            }
            if (n > 1 & nums[0] == 0)
            {
                WriteLine(-1);
                return;
            }

            if (n==1)
            {
                Write(nums[0] ?? 0);
            }
            else
            {
                Write(nums[0] ?? 1);
            }

            for(int i = 1; i < n; i++)
            {
                Write(nums[i] ?? 0);
            }
            WriteLine();
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a.at(i);
  }
  int count = 0;
  bool finished = false;
  rep(i, 1000000000) {
    rep(j, n) {
      if (a.at(j) % 2 != 0) {
        finished = true;
        break;
      } 
      a.at(j)  /= 2;
    }
    if (finished) {
      break;
    }
    count++;
  }
  cout << count << endl;
    
  
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (A*B < C*D)
	{
		cout << C*D << endl;
	}
	else if (A*B > C*D)
	{
		cout << A*B << endl;
	}
	else
	{
		cout << A*B << endl;
	}
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  ll n;
  cin >> n;
  string res = "";
  while (n != 0) {
    n--;
    res.push_back(n % 26 + 'a');
    n /= 26;
  }
  reverse(res.begin(), res.end());
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3608
import sys
input = sys.stdin.readline

if __name__ == '__main__':
  n=int(input())
  ans=0
  d=[0]*(n+1)
  for i in range(1,n+1):
    for j in range(i,n+1,i):
      d[j]+=1
  for i in range(1,n+1):
    ans+=i*d[i]
  print(ans)

Measured memory_bytes: 151792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.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))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll N, B[101], A[101], ans=0;
    scanf("%lld", &N);
    rep(i, 0, N-1) scanf("%lld", B+i);
    A[0]=B[0];
    A[N-1]=B[N-2];
    rep(i, 1, N-1){
        A[i] = min(B[i-1], B[i]);
    }
    rep(i, 0, N) ans += A[i];
    printf("%lld\n", ans);
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)

int N;
lint MOD;

lint power(lint x, lint n, lint MOD=MOD)
{
    lint ans = 1;
    while (n>0)
    {
        if (n & 1) (ans *= x) %= MOD;
        (x *= x) %= MOD;
        n >>= 1;
    }
    return ans;
}

vector<lint> fac, facInv, inv;
void facInit(int nmax)
{
    fac = facInv = inv = vector<lint>(nmax + 1, 1);
    for (int i = 2; i <= nmax; i++)
    {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        facInv[i] = facInv[i-1] * inv[i] % MOD;
    }
}

lint nCr(int n, int r)
{
    if (n<r || r<0) return 0;
    return (fac[n] * facInv[r] % MOD) * facInv[n-r] % MOD;
}


int main()
{
    cin >> N >> MOD;
    facInit(N);


    vector<vector<lint> > dp(N+1, vector<lint>(N+1)); // dp[i][j] : 品1~iの一部をj杯に分割する総数
    REP(i, N+1) dp[i][0] = 1;
    FOR(i, 1, N+1) FOR(j, 1, N+1) {
        dp[i][j] = (dp[i-1][j] * (j + 1) + dp[i-1][j-1]) % MOD;
    }

    vector<lint> part(N + 1);
    REP(n, N+1) {
        lint pattern = power(2, N - n);
        lint pattern_p = power(2, N - n, MOD - 1);
        lint tmp = 1;
        part[n] = 1;
        FOR(j, 1, n+1)
        {
            (tmp *= pattern) %= MOD;
            (part[n] += dp[n][j] * tmp) %= MOD;
        }
        (part[n] *= power(2, pattern_p)) %= MOD;
    }

    lint ans = 0;
    REP(n, N+1) (ans += ((MOD + 1 - n%2*2) * nCr(N, n) % MOD) * part[n]) %= MOD;
    cout << ans << endl;
}


Measured memory_bytes: 70784
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Read();
            Console.WriteLine(s.Replace(","," "));
        }

        private static readonly Func<string> Read = () => Console.ReadLine();
        private static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split();
        private static readonly Func<int> ReadInt = () => int.Parse(Console.ReadLine());
        private static readonly Func<long> ReadLong = () => long.Parse(Console.ReadLine());
        private static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
        private static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
        private static readonly Action<string> Cw = str => Console.WriteLine(str);
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  int n; cin >> n;
  deque<int> que;
  rep(i, n) {
    int a; cin >> a;
    que.push_back(a);
  }
  sort(que.begin(), que.end());

  deque<int> que2 = que;

  int before = -1;
  long ans1 = 0;
  int first;
  rep(i, n) {
    int now;
    if (i%2 == 0) {
      now = que.front(); que.pop_front();
    } else {
      now = que.back(); que.pop_back();
    }
    if (i == 0) {
      first = now;
    } else if (i < n-1) {
      ans1 += abs(now - before);
    } else {
      ans1 += max(abs(now-before), abs(now-first));
    }
    before = now;
  }

  before = -1;
  long ans2 = 0;
  rep(i, n) {
    int now;
    if (i%2 != 0) {
      now = que2.front(); que2.pop_front();
    } else {
      now = que2.back(); que2.pop_back();
    }
    if (i == 0) {
      first = now;
    } else if (i < n-1) {
      ans2 += abs(now - before);
    } else {
      ans2 += max(abs(now-before), abs(now-first));
    }
    before = now;
  }
  cout << max(ans1, ans2) << endl;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;
  for (int i = 1; i <= 9; i++) {
    if (N / i < 10 && N % i == 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 2019;
int N[MOD];
int R[MOD];
int main()
{
  	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string S;
	cin >> S;
	int nb = 0;
	for (int i = 0 ; i < S.size() ; i++)
	{
		for (int j = 0 ; j < MOD ; j++) R[(j * 10 + (S[i] - '0')) % MOD] += N[j];
		for (int j = 0 ; j < MOD ; j++)
		{
			N[j] = R[j];
			R[j] = 0;
		}
		N[S[i] - '0']++;
		nb += N[0];
	}
	cout<<nb<<endl;
}

Measured memory_bytes: 3740
#include <iostream>
using namespace std;

int main() {
long long i,o,t,j,l,s,z,c=0,k=0;
cin>>i>>o>>t>>j>>l>>s>>z;
if(i>0&&j>0&&l>0){
if(i%2==1)k++;
if(j%2==1)k++;
if(l%2==1)k++;
if(k==3)c=3;
if(k==2)c=1;
}
c+=(i/2)*2+o+(j/2)*2+(l/2)*2;
cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

ll func(ll a,ll b,ll c){
    return b/c-(a-1)/c;
}

template<typename T>
T gcd(T u, T v) {
    if(u==0)return v;
    if(v==0)return u;
    T r;
    while (v) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    put(b-a-(func(a,b,c)+func(a,b,d)-func(a,b,c*d/gcd(c,d)))+1);
    return 0;
}


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

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
const ll MOD = 998244353LL;
ll add(ll &a, ll b) {return a=(a+b)%MOD;}
ll mul(ll &a, ll b) {return a=(a*b)%MOD;}

const int SIZE = 300000+10;

ll fact[SIZE];

ll inv(ll a, ll p) {
  return ( a == 1LL ? 1LL : (1LL - p*inv(p%a, a)) / a + p );
}

ll solve(ll N, ll A, ll B, ll K) {
  ll ans = 0;
  for(ll a = 0; a <= N; a++) {
    if(a*A > K) break;
    ll b = (K-(a*A))/B;
    if(a*A+b*B != K) continue;
    if(b > N) continue;
    ll tmp = 1LL;
    mul(tmp, fact[N]);
    mul(tmp, inv(fact[a], MOD));
    mul(tmp, inv(fact[N-a], MOD));
    mul(tmp, fact[N]);
    mul(tmp, inv(fact[b], MOD));
    mul(tmp, inv(fact[N-b], MOD));
    add(ans, tmp);
  }
  return ans;
}

int main() {
  fact[0] = 1; fact[1] = 1;
  for(int i = 2; i < SIZE; i++) {
    fact[i] = (ll)i;
    mul(fact[i],fact[i-1]);
    //    cout << i << " " << fact[i] << endl;                                         \
                                                                                        
  }
  ll N;
  ll A, B;
  ll K;
  cin>>N>>A>>B>>K;
  if(A>B) swap(A,B);
  ll ans = solve(N, A, B, K);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():

    N,M=MAP()
    S=LIST()
    T=LIST()

    # dp1[i][j], dp2[i][j] := Sをi文字目、Tをj文字目まで考えた時、dp1はi方向、dp2はj方向に遷移させる
    dp1=list2d(N+2, M+2, 0)
    dp2=list2d(N+2, M+2, 0)
    dp1[0][0]=1
    for i in range(N+1):
        for j in range(M+1):
            dp1[i][j]%=MOD
            # 数え上げをi方向とj方向で重複がないように遷移させる
            dp1[i+1][j]+=dp1[i][j]
            dp2[i][j]+=dp1[i][j]
            dp2[i][j+1]+=dp2[i][j]
            # 今回増やす数値が一致するなら
            if i<N and j<M and S[i]==T[j]:
                # 斜めに遷移させる(1→0)
                dp1[i+1][j+1]+=dp2[i][j]
    print((dp2[N][M])%MOD)

if __name__ == '__main__':
    main()


Measured memory_bytes: 105052
#include <iostream>

using namespace std;
typedef unsigned long long ull;
int main() {
    ull a=1, b,n;
    cin >> n;
    for(ull d=2;d*d<=n;d++){
        if(n%d==0){
           a=d; 
        }
    }
    b=n/a;
    cout<<a+b-2;
    return 0;
}

Measured memory_bytes: 256