akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

class Bipartite_Matching {
protected:
    vector<vector<int>> G;
    vector<int> used, alive;
    int t;
    int l, r;
public:
    vector<int> match;
    explicit Bipartite_Matching(int l, int r): l(l), r(r), t(0), G(l+r), used(l+r, 0), alive(l+r, -1), match(l+r, -1) {};

    void add_edge(int a, int b){
        G[a].emplace_back(b+l);
        G[b+l].emplace_back(a);
    }

    bool dfs(int x){
        used[x] = t;
        for (auto &&i : G[x]) {
            int w = match[i];
            if(alive[i] == 0) continue;
            if(w == -1 || (used[w] != t && dfs(w))){
                match[x] = i;
                match[i] = x;
                return true;
            }
        }
        return false;
    }

    int matching() {
        int ans = 0;
        for (int i = 0; i < G.size(); ++i) {
            if(alive[i] == 0) continue;
            if(match[i] == -1) {
                ++t;
                ans += dfs(i);
            }
        }
        return ans;
    }
};

class Bipartite_Matching_LexMin : public Bipartite_Matching {
public:
    using Bipartite_Matching::Bipartite_Matching;

    int solve_LexMin() {
        int res = matching();
        for (int i = 0; i < l; ++i) {
            if(!~match[i]) continue;
            match[match[i]] = -1;
            match[i] = -1;
            ++t;
            dfs(i);
            alive[match[i]] = 0;
            alive[i] = 0;
        }
        return res;
    }
};

int main() {
    int n;
    scanf("%d", &n); n--;
    Bipartite_Matching_LexMin G(n, n);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            int x;
            scanf("%d", &x);
            if(x){
                G.add_edge(j, i);
            }
        }
    }
    auto matching = G.solve_LexMin();
    if(matching != n) {
        puts("no");
        return 0;
    }
    puts("yes");
    for (int i = 0; i < n; ++i) {
        printf("%d\n", G.match[i]-n+1);
    }
    return 0;
}


Measured memory_bytes: 3388
#include<stdio.h>
#include<string.h>
int Partition(int *,int *,char *,int,int);
void QSort(int *,int *,char *,int,int);
int main()
{
  int i,n,s=0;
  int A[200000],B[200000];
  char ch,C[100000];
    
  scanf("%d%c",&n,&ch);
  for(i=0;i<n;i++){
    scanf("%c%c%d%c",&C[i],&ch,&A[i],&ch);
    B[i]=i;
  }
 
  QSort(A,B,C,0,n-1);
  for(i=0;i<n;i++){
    if(B[i]>B[i+1] && A[i]==A[i+1]){
      s=1;
      break;
    }
  }
  if(s==0)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",C[i],A[i]);
  }
  return 0;
}
 
void QSort(int *A,int *B,char *C,int p,int r)
{
  int q;
  if(p<r){
    q=Partition(A,B,C,p,r);
    QSort(A,B,C,p,q-1);
    QSort(A,B,C,q+1,r);
  } 
}
 
 
int Partition(int *A,int *B,char *C,int p,int r)
{
  int x,i,j,temp;
  char ch;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      temp=A[i];
      A[i]=A[j];
      A[j]=temp;
      temp=B[i];
      B[i]=B[j];
      B[j]=temp;
      ch=C[i];
      C[i]=C[j];
      C[j]=ch;
    }
     
  }
  temp=A[i+1];
  A[i+1]=A[r];
  A[r]=temp; 
  temp=B[i+1];
  B[i+1]=B[r];
  B[r]=temp;
  ch=C[i+1];
  C[i+1]=C[r];
  C[r]=ch;
  return i+1;
}  


Measured memory_bytes: 2612
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for i in range(m)]

yen=0
for i in set(s):
    num=s.count(i)
    num2=t.count(i)
    yen=max(yen,num-num2)
print(yen)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = Integer.parseInt(scan.next());
		int b = Integer.parseInt(scan.next());
		
		if (a >= 1 && b <= 100) {
			System.out.println((a * b) + " " + (2 * a + 2 * b));
		}
	}
}


Measured memory_bytes: 25864
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int a,b,n;
	cin>>n>>a>>b;
	if((b-a-1)%2==1)
	{
		cout<<"Alice"<<endl;
	}
	else
	{
		cout<<"Borys"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
// C++ program to find LCM of 2 numbers 
// without using GCD 
#include <bits/stdc++.h> 
using namespace std; 

// Function to return LCM of two numbers 
long long int findLCM(long long int a,long long int b) 
{ 
	long long int lar = max(a, b); 
	long long int small = min(a, b); 
	for (long long int i = lar; ; i += lar) { 
		if (i % small == 0) 
			return i; 
	} 
} 

// Driver program to test above function 
int main() 
{ 
	long long int a,b;
	cin >> a>>b;
	cout  << findLCM(a, b); 
	return 0; 
} 


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

int main()
{
    string a, b; cin>>a>>b;
    int n=a.size(), m=b.size();

    cout<<(n>m ? "GREATER" : n<m ? "LESS" : a>b ? "GREATER" : a<b ? "LESS" : "EQUAL")<<endl;
}


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

#define INF 1e9
#define PI 3.141592653589793238
#define N 1000000010
#define mod 1000000007
#define REP(inc, bgn, end) for(int inc=bgn; inc<end; inc++)
typedef long long ll;

int main() {
    ll n; cin>>n;
    ll ans=0;
    for(ll i=1; i<=n/2; i++){
        for(ll j=i; j<n; j++){
            if(i*j>=n) break;
            if(i==j) ans++;
            else ans += 2;
        }
    }
    
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

const int maxn = 2000+5;
const int INF = 0x3f3f3f3f;
int h,w;
char g[maxn][maxn];

int dx[4];
int dy[4];

struct node{
	int ed[4];
	bool vis[4];
	node(){
		ed[0] = ed[1] = ed[2] = ed[3] = 0;
		vis[0] = vis[1] = vis[2] = vis[3] = false;
	}
}res[maxn][maxn];

void dfs(int i,int j,int dir) {
	if (g[i][j] == '#') {
		return;
	}
	if (i < 1 || i > h || j < 1 || j > w) {
		return;
	}
	if (res[i][j].vis[dir]) {
		return;
	}
	res[i][j].vis[dir] = true;
	dfs(i+dx[dir],j+dy[dir],dir);
	res[i][j].ed[dir] = res[i+dx[dir]][j+dy[dir]].ed[dir]+1;;
}

void solve() {
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			dfs(i,j,0);
			dfs(i,j,1);
			dfs(i,j,2);
			dfs(i,j,3);
		}
	}
}

int main() {
	dx[0] = 1;dx[1] = -1;dx[2] = dx[3] = 0;
	dy[0] = dy[1] = 0;dy[2] = -1;dy[3] = 1;
	cin >> h >> w;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> g[i][j];
		}
	}
	solve();
	int ans = -INF;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (res[i][j].ed[0]+res[i][j].ed[1]+res[i][j].ed[2]+res[i][j].ed[3]-3 > ans){
				ans = res[i][j].ed[0]+res[i][j].ed[1]+res[i][j].ed[2]+res[i][j].ed[3]-3;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 82816
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define db cout << " HERE " << endl;
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 2000001;
int main() {
	int d , t , s;
	cin >> d >> t >> s;
	int td = t*s;
	if(td>=d)
	cout << "Yes";
	else
	cout << "No";
}
// template by benq


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define reprs(i, s, e) for(int i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    int p[n];
    rep(i, n){
        cin >> p[i];
        p[i]--;
    }

    int cnt = 0;
    rep(i, n-1){
        if(p[i] == i){
            swap(p[i], p[i+1]);
            cnt++;
        }
    }

    if(p[n-1] == n-1){
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 640
N = int(input())
S = [""] * N
P_s = [""] * N
P = [0] * N
Idx = [0] * N

for i in range(N):
    S[i],P_s[i] = map(str,input().split())
    P[i] = int(P_s[i])
    Idx[i] = i

m_i = 0
m_p = -1
for i in range(N-1):
    for j in range(i,N):
        if (m_p < P[j]):
            m_i = j
            m_p = P[j]
    tmp = P[i]
    P[i] = P[m_i]
    P[m_i] = tmp
    tmp_s = S[i]
    S[i] = S[m_i]
    S[m_i] = tmp_s
    tmp_i = Idx[i]
    Idx[i] = Idx[m_i]
    Idx[m_i] = tmp_i
    m_p = -1

for i in range(0,N-1):
    for j in range(1,N-i):
        if (S[j] < S[j-1]):
            tmp = P[j]
            P[j] = P[j-1]
            P[j-1] = tmp
            tmp_s = S[j]
            S[j] = S[j-1]
            S[j-1] = tmp_s
            tmp_i = Idx[j]
            Idx[j] = Idx[j-1]
            Idx[j-1] = tmp_i


for i in range(N):
    print(Idx[i]+1)


Measured memory_bytes: 3064
from collections import defaultdict

def main():
    N = int(input())
    X = []
    for i in range(N):
        A, B = map(int, input().split())
        X.append([A,B])
    d = defaultdict(list)
    X.sort()

    for i, x in enumerate(X):
        d[i+1].append(x[0])
    X.sort(key=lambda x: x[1])

    for i, x in enumerate(X):
        d[i+1].append(x[1])
    if N % 2 == 1:
        ans = d[(N+1)//2][1] - d[(N+1)//2][0] + 1
        print(ans)
    else:
        ans = (d[N//2][1] + d[N//2 + 1][1]) - (d[N//2][0] + d[N//2 + 1][0]) + 1
        print(ans)


    
    
    
    


if __name__ == "__main__":
    main()

Measured memory_bytes: 154176
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define oo 1000000010

int main()
{
	int a, b, j = 1;
	cin >> a >> b;

	while(1){
		int x, y;
		x = floor(j*0.08);
		y = floor(j*0.1);
		if(x == a && y == b){
			cout << j;
			break;
		}
		if(x > a || y > b){
			cout << "-1";
			break;
		}
		j++;
	}

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    int ary[n];
    rep(i,n) cin >> ary[i];

    int swapcount = 0;
    rep(i,n) {
        if (i+1 != ary[i])
        {
            swapcount ++;
        }
    }

    if (swapcount <= 2)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    
}


Measured memory_bytes: 256
h,w = map(int,input().split())
a = [list(input()) for _ in range(h)]

def printboard(board):
    for i in board:
        print(*i, sep='')

red = [['.'] * w for _ in range(h)]
blue = [['.'] * w for _ in range(h)]

for i in range(h):
    red[i][0] = '#'
    blue[i][-1] = '#'
    for j in range(1, w - 1):
        if i % 2 == 0:
            red[i][j] = '#'
        else:
            blue[i][j] = '#'

for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            red[i][j] = '#'
            blue[i][j] = '#'

printboard(red)
print()
printboard(blue)

Measured memory_bytes: 11252
#include <bits/stdc++.h>
using namespace std;
const int N = 200000;
#define LL long long
#define pI pair <LL, LL>
#define fr first
#define sc second
#define mp make_pair
int n;
LL si[N], pi[N], qi[N];
map <pI, int> M, E;
int ans, tot, prime[N], not_p[N];
int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++ i) cin >> si[i];
    for (int i = 2; i <= 2200; ++ i)
        for (int j = i + i; j <= 2200; j += i)
            not_p[j] = 1;
    for (int i = 2; i <= 2200; ++ i)
        if (!not_p[i]) prime[++ tot] = i;
    for (int i = 1; i <= n; ++ i)
    {
        pi[i] = qi[i] = 1;
        for (int j = 1; j <= tot; ++ j)
        {
            int c = 0;
            while (si[i] % prime[j] == 0) si[i] /= prime[j], c ++;
            c %= 3;
            if (c == 2) pi[i] *= prime[j]; if (c == 1) qi[i] *= prime[j];
        }
        {
            int d = sqrt(si[i]) + 1e-5;
            if (1ll * d * d == si[i]) pi[i] *= d; else qi[i] *= si[i];
        }
        if (pi[i] == 1 && qi[i] == 1) ans = 1;
        else M[mp(pi[i], qi[i])] ++, M[mp(qi[i], pi[i])] += 0;
    }
    for (auto it = M.begin(); it != M.end(); ++ it)
        if (it -> fr.fr < it -> fr.sc)
            ans += max(it -> sc, M[mp(it -> fr.sc, it -> fr.fr)]);
    cout << ans << endl;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,qq;
    cin>>n>>qq;
    string s;
    cin>>s;
    vector<int> ls(n+1);
    ls[0]=0;
    for(int i = 0; i < n-1; i++)
    {
        if(s[i]=='A'&&s[i+1]=='C')
        {
            ls[i+1]=1;
        }
        else ls[i+1]=0;
        if(i>0)
        {
            ls[i+1]+=ls[i];
        }
    }
    for(int q = 0; q < qq; q++)
    {
        int l,r;
        cin>>l>>r;
        l--;r--;
        cout<<ls[r]-ls[l]<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  long long n;
  cin >> n;
  long long ans = 0;
  for(long long i = 1; i < n; i++){
    ans += (n-1)/i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,d;
  cin>>n>>d;
  if((n%((2*d)+1)==0))
     {
       cout<<n/((2*d)+1);
     }
     else
     {
       cout<<(n/((2*d)+1))+1;
     }
     return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
// #define DEBUGGING

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(0);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

using TLL = tuple<ll, ll, ll>;

const ll INF = 5e15;
V<ll> calc(ll N, const V<PLL> &v, bool rev) {
    V<ll> ret(v.size() + 1, -INF);
    priority_queue<ll> pq;

    ll sum = 0;
    for(ll i = 0; i < N; i++) {
        ll a, b;
        tie(a, b) = v[i];
        sum += a;
        pq.push(b - a);
    }
    ret[N] = sum;
    for(ll i = N; i < v.size(); i++) {
        ll a, b;
        tie(a, b) = v[i];
        sum += a;
        pq.push(b - a);
        sum += pq.top();
        pq.pop();
        ret[i + 1] = sum;
    }

    if(rev) reverse(ALL(ret));
    return move(ret);
}

int main() {
    ll X, Y, Z;
    cin >> X >> Y >> Z;
    V<TLL> abc;
    for(ll i = 0; i < X + Y + Z; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        abc.emplace_back(a, b, c);
    }

    auto dec_ab = [](TLL t) { return get<0>(t) - get<1>(t); };
    sort(ALL(abc), [&](TLL a, TLL b) { return dec_ab(a) > dec_ab(b); });

    V<PLL> gb, sb;
    for(ll i = 0; i < X + Y + Z; i++) {
        gb.emplace_back(get<0>(abc[i]), get<2>(abc[i]));
        sb.emplace_back(get<1>(abc[i]), get<2>(abc[i]));
    }
    reverse(ALL(sb));
    auto gbc = calc(X, gb, false);
    auto sbc = calc(Y, sb, true);

    DEBUG(abc);
    DEBUG(gbc);
    DEBUG(sbc);
    ll ans = 0;
    for(ll i = 0; i <= X + Y + Z; i++) chmax(ans, gbc[i] + sbc[i]); 
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9968
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
const int mod = 998244353;

int main() {
    long long N, ans;
    cin >> N;
    long long D[N];
    map<int, int> count;
    for (int i = 0; i < N; i++) {
        cin >> D[i];
        count[D[i]]++;
    }
    if (count[0] != 1) {
        ans = 0;
    } else {
        ans = 1;
        for (int i = 1; i < N; i++) {
            ans = (ans * count[D[i] - 1]) % mod;
        }
    }

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


Measured memory_bytes: 5760
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
int n,k,mod;
int dp[303][303][303];
inline void add(int &x,int y){
	x+=y;if(x>=mod)x-=mod;
}
int main(){
	cin>>n>>k>>mod;
	dp[0][1][0]=1;
	for(int i=0;i<=n;i++){
		for(int j=1;j<=k;j++){
			for(int can=i;can>=0;can--){
				if(can)add(dp[i][j][can-1],dp[i][j][can]);
				else add(dp[i][j+1][i],dp[i][j][can]);
				add(dp[i+1][j][can],(ll)dp[i][j][can]*(can+1)%mod);
			}
		}
	}
	cout<<dp[n][k][0]<<endl;
	return 0;
}

Measured memory_bytes: 108800
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a,b;
    // スペース区切りの整数の入力
    cin >> a >> b ;
    for (int i=10*b; i<10*b+10;i++){
    //cout << i/10 << endl;
        if (int(i*0.08) == a){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define int long long

void solve()
{
    int n, x, t;
    cin >> n >> x >> t;
    int ans = ceil((double)n / x);
    cout << ans * t << endl;
}   

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

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


Measured memory_bytes: 3752
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
A = [0]*M
B = [0]*M
ans = [1]*N
for i in range(M):
  A[i], B[i] = list(map(int, input().split()))
for i in range(M):
  if H[A[i]-1]>H[B[i]-1]:
    ans[B[i]-1] = 0
  elif  H[A[i]-1] == H[B[i]-1]:
    ans[A[i]-1] = 0
    ans[B[i]-1] = 0
  else:
    ans[A[i]-1] = 0
print(ans.count(1))

    


Measured memory_bytes: 85268
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N, Z, W;
    std::cin >> N >> Z >> W;

    std::vector<int64_t> A;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        A.push_back(t);
    }

    int64_t ans = 0;

    ans = std::max(ans, abs(A[N-1] - W));
    if (N >= 2) {
        ans = std::max(ans, abs(A[N-2] - A[N-1]));
    }

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

    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::*;
use std::str::FromStr;
 
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed parsing")
}
 
use std::cmp::{min, max};
use std::num;
 
 
fn main() {
    
    let a = read::<i64>();
    let b = read::<i64>();
    
    let ans = max( max(a + b, a - b), a * b);
    
    println!("{}",ans); 
    
}

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

int main() {
	string a, b, c; cin >> a >> b >> c;

	a[0] -= 32;
	b[0] -= 32;
	c[0] -= 32;

	cout << a[0] << b[0] << c[0];
	return 0;
}

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

int main(){

	int A, B, C;
	bool judge;
	cin >> A >> B >> C;
	
	if (A==B){
		if(A==C){judge = false;}
		else{judge = true;}
	}
	else{
		if(A==C || B==C){judge = true;}
		else{judge = false;}
	}

	judge ? cout << "Yes" << endl : cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())

A_list = list(map(int, input().split()))

ans = 0

for i in range(N-1):
    if A_list[i] > A_list[i+1]:
        ans += A_list[i] - A_list[i+1]
        A_list[i+1] = A_list[i]
print(ans)

Measured memory_bytes: 32196
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        s=input()
        t=input()
        if s==t:
            return 'Yes'
        else:
            for i in range(1,len(s)+1):
                if s[i:]+s[0:i]==t:
                    return 'Yes'
        return 'No'
    print(main())
resolve()

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

#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i,a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n, m;
void solve() {
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
}

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


Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

// O(N^.5)
/// --- phi {{{ ///
ll phi(ll n) {
  ll res = n;
  for(ll i = 2; i * i <= n; i++) {
    if(n % i == 0) {
      res = res / i * (i - 1);
      while(n % i == 0) n /= i;
    }
  }
  if(n != 1) res = res / n * (n - 1);
  return res;
}
/// }}}--- ///

// WARN : use H with larger N
/// --- Modulo Factorial {{{ ///
template < int N >
struct Factorial {
  int mod;
  ll extgcd(ll a, ll b, ll &x, ll &y) {
    ll d = 0;
    return b == 0 ? (x = 1, y = 0, a) : (d = extgcd(b, a % b, y, x), y -= a / b * x, d);
  }
  ll modinv(ll a) {
    ll x = 0, y = 0;
    extgcd(a, mod, x, y);
    return (x + mod) % mod;
  }
  int arr[N + 1], inv[N + 1];
  ll operator[](int i) const { return arr[i]; }
#if !defined(DEBUG)
  constexpr
#endif
    Factorial(int mod)
    : mod(mod), arr(), inv() {
      arr[0] = 1;
      for(int i = 1; i <= N; i++) {
        arr[i] = (ll) i * arr[i - 1] % mod;
      }
      inv[N] = modinv(arr[N]);
      for(int i = N - 1; i >= 0; i--) {
        inv[i] = (ll)(i + 1) * inv[i + 1] % mod;
      }
    }
  ll C(int n, int r) const {
    if(n < 0 || r < 0 || n < r) return 0;
    return (ll) arr[n] * inv[r] % mod * inv[n - r] % mod;
  }
  ll H(int n, int r) const { return C(n + r - 1, r); }
};
/// }}}--- ///

/// --- math {{{ ///
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll d;
  return b == 0 ? (x = 1, y = 0, a) : (d = extgcd(b, a % b, y, x), y -= a / b * x, d);
}
ll modinv(ll a, ll mod) {
  ll x, y;
  extgcd(a, mod, x, y);
  if(x < 0) x += mod;
  return x;
}
ll modpow(ll a, ll b, ll mod) {
  ll r = 1;
  a %= mod;
  while(b) {
    if(b & 1) r = r * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return r;
}
/// }}}--- ///

constexpr int N = 5000 + 10;
int n, m;

// [i][j] :=
// 区別可能なi個を区別できないj個の箱に入れるか入れないかする方法
// ただしどの箱にも一個以上入っている
// ( = 第二種スターリング数的なもの )
ll S[N][N];

// 指定したi個を違反する (一個以下にしか入っていない状態) ようにする場合の数
ll w[N];

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n >> m;
  Factorial < N * 2 > fact(m);
  S[0][0] = 1;

  for(int i = 1; i <= n; i++) for(int j = 0; j <= i; j++) {
    S[i][j] = (j - 1 >= 0 ? S[i-1][j-1] : 0) + S[i-1][j] * (j + 1) % m;
    S[i][j] %= m;
  }

  ll phim = phi(m);

  for(int x = 0; x <= n; x++) {
    for(int i = 0; i <= x; i++) {
      // j 個が1個どれかに含まれるような通り数
      w[x] += S[x][i] * modpow(2, i * (n - x), m) % m;
    }
    w[x] %= m;
    w[x] = (m - 1 + w[x] * modpow(2, modpow(2, n - x, phim), m) % m) % m;
  }

  ll ans = 0;
  for(int i = 0; i <= n; i++) {
    ans += m + (i & 1 ? -1 : 1) * fact.C(n, i) % m * w[i] % m;
  }

  ans %= m;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 117376
# -*- coding: utf-8 -*-
from functools import lru_cache
import sys
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


class Bisect:
    def __init__(self, func):
        self.__func = func

    def bisect_left(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if self.__func(mid) < x:
                lo = mid+1
            else:
                hi = mid
        return lo

    def bisect_right(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if x < self.__func(mid):
                hi = mid
            else:
                lo = mid+1
        return lo


class Doubling():
    def __init__(self, N, a0):
        self.N = N
        self.nt = [[None] * N for i in range(N.bit_length())]
        for i, a in enumerate(a0):
            self.nt[0][i] = a

        for i in range(1, len(self.nt)):
            for j in range(N):
                if self.nt[i-1][j] is None:
                    self.nt[i][j] = None
                else:
                    self.nt[i][j] = self.nt[i-1][self.nt[i-1][j]]

    def apply(self, i, n):
        j = i
        for k in range(n.bit_length()):
            m = 1 << k
            if m & n:
                j = self.nt[k][j]
            if j is None:
                break
        return j



def slv(N, X, L, Q, AB):
    r = [0]
    for x in X:
        t = -1
        for j in range(r[-1], len(X)):
            if X[j] - x <= L:
                t = j
            else:
                break
        r.append(t)
    r.pop(0)

    d = Doubling(N, r)

    ans = []
    for a, b in AB:
        if a > b:
            a, b = b, a
        a -= 1
        b -= 1
        bisect = Bisect(lambda x: d.apply(a, x))
        i = bisect.bisect_left(b, 0, len(X)+1)
        ans.append(i)

    return ans


def main():
    N = read_int()
    X = read_int_n()
    L = read_int()
    Q = read_int()
    AB = [read_int_n() for _ in range(Q)]
    print(*slv(N, X, L, Q, AB), sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 96568
#include<iostream>
using namespace std;
int main() {
    while (1){
        string n;
        int ans = 0;
        cin >> n;
        if (n == "0"){
            break;
        } else {
            for (int i=0; i<n.size(); i++){
                ans += (n[i] - '0');
                //cout << ans << endl;
            }
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3168
s = int(input())
s = max(min(s, 100), 1)

f = lambda x: x * 0.5 if x % 2 == 0 else 3*x + 1
array = [s]
while s != 1:
    s = f(int(s))
    array.append(int(s))
array += [4, 2, 1]
freq = len(array)
idx = 0
for n, i in enumerate(array):
    for m, j in enumerate(array[n + 1:]):
        if i == j:
            idx = m + n + 2
            break
    if idx != 0:
        break
print(idx)

Measured memory_bytes: 39024
#include<stdio.h>

int main (void){
	
	int n,point,max,min,count,sum,ave,i;
	for(;;){
	scanf("%d",&n);
	if(n==0)break;
		count=1;
		sum=0;
		ave=0;
		
		scanf("%d",&point);
		max = point;
		min = point;
		sum = point;
		for(i=0;i<(n-1);i++){
			if(n==1) break;
			scanf("%d",&point);
			if(max<point){
				max = point;
			}else if(min>point){
				min = point;
			}
		count += 1;
		sum += point;
		}
		ave = (sum-max-min)/(count-2);
		printf("%d\n",ave);
	}
return 0;
}
		

Measured memory_bytes: 600
from sys import exit

n, m = map(int, input().split())

cnt = [0] * n
for _ in range(m):
    a, b = map(int, input().split())
    if a == 1 or a == n:
        cnt[b-1] += 1
    elif b == 1 or b == n:
        cnt[a-1] += 1

for c in cnt:
    if c == 2:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll N;
string S;
ll res[200010];

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

  cin>>S;
  N=S.size();
  for(ll i=0;i<N-1;){
    if(S[i]=='R'&&S[i+1]=='L'){
      ll l=i,r=i+1;
      ll cntR=0,cntL=0;
      while(l>=0&&S[l]=='R'){
        if((i-l)%2==0) cntR++;
        else cntL++;
        l--;
      }
      while(r<N&&S[r]=='L'){
        if((r-i-1)%2==0) cntL++;
        else cntR++;
        r++;
      }
      res[i]=cntR;
      res[i+1]=cntL;
      i=r;
    }else i++;
  }
  rep(i,N)cout<<res[i]<<" ";
  cout<<endl;

  return 0;
}


Measured memory_bytes: 1488
#include <iostream>

using namespace std;

int N;
int P[2 * 100000];
int Q[2 * 100000];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> P[i];
    }
    for (int i = 0; i < N; i++) {
        Q[P[i]-1] = i;
    }
    int cnt = 1;
    int m = 1;
    for (int i = 1; i < N; i++) {
        if (Q[i] < Q[i-1]) {
            cnt = 1;
        } else {
            cnt += 1;
        }
        if (cnt > m) {
            m = cnt;
        }
    }
    cout << N - m << endl;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

s = input()
a = s[0:2]
b = s[2:4]
a = int(a)
b = int(b)

if 0 < a <= 12 and 0 < b <= 12:
    print("AMBIGUOUS")
    exit(0)
elif 0 <= a <= 99 and 0 < b <= 12:
    print("YYMM")
    exit(0)
elif 0 < a <= 12 and 0 <= b <= 99:
    print("MMYY")
    exit(0)
else:
    print("NA")


Measured memory_bytes: 3060
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
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;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

int main() {
	ll N, Q; cin >> N >> Q;
	string S; cin >> S;
	vector<ll> l(Q), r(Q); rep(i, Q)cin >> l[i] >> r[i];

	vector<ll> ac(N);
	for (int i = 0; i < N; i++) {
		if (i == 0) ac[i] = 0;
		else {
			if (S[i - 1] == 'A' && S[i] == 'C')ac[i] = ac[i - 1] + 1;
			else ac[i] = ac[i - 1];
		}
	}

	rep(i, Q) {
		cout << ac[r[i] - 1] - ac[l[i] - 1] << endl;
	}
}

Measured memory_bytes: 3456
import java.util.Scanner;
class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int S=in.nextInt();
		int h=S/3600;
		int h1=S%3600;
		int m=h1/60;
		int m1=h1%60;
		System.out.println(h+":"+m+":"+m1);
	}
	
}



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

using namespace std;

int main(){
  int j, i, n, previous, present;
  string answer, signal[11];

  signal[0] = "0111111";
  signal[1] = "0000110";
  signal[2] = "1011011";
  signal[3] = "1001111";
  signal[4] = "1100110";
  signal[5] = "1101101";
  signal[6] = "1111101";
  signal[7] = "0100111";
  signal[8] = "1111111";
  signal[9] = "1101111";
  signal[10] = "0000000";

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

    previous = 10;
    for(i=0; i<n; ++i){
      cin >> present;

      for(j=0; j<7; ++j){
	if(signal[present][j] == signal[previous][j])
	  cout << "0";
	else
	  cout << "1";
      }
      cout << endl;
      previous = present;
    }
  }

  return 0;
}

Measured memory_bytes: 0
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from fractions import gcd
from functools import reduce

MOD = 998244353

N,*A = map(int,read().split())
A.sort()

"""
安い鳥から追加していく。(サイクルの個数 -> 美しさ)が多項式倍で遷移する。
Gaussの補題より、最大個数かけるだけ
"""

answer = reduce(lambda x,y: x*y%MOD, (gcd(i,x) for i,x in enumerate(A)))
print(answer)

Measured memory_bytes: 14512
#include <iostream>
#define _USE_MATH_DEFINES
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <math.h>
using namespace std;

int main()
{
	int S, W;
	std::cin >> S >> W;
	if (W >= S) {
		std::cout << "unsafe";
	}
	else {
		std::cout << "safe";
	}

	return 0;
}

	

Measured memory_bytes: 3636
#include <stdio.h>
#include <math.h>

int Prime(int x){
    int y=sqrt(x);
    //printf("%d\n",y);
    for(int i=2;i<=y;i++){
        if(x%i==0) return 0;
    }
    return 1;
}

int main(void){
    int n,i,m,cnt=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&m);
        cnt+=Prime(m);
    }
    printf("%d\n",cnt);
    return 0;
}



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

int counter(int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

int main() {
  int N;
  cin >> N;
  int A[N];
  vector<int> x[20];
  vector<int> y[20];

  for (int i = 0; i < N; i++) {
    cin >> A[i];
    for(int j = 0; j < A[i]; j++){
      int tmpX, tmpY;
      cin >> tmpX >> tmpY;
      x[i].push_back(tmpX);
      y[i].push_back(tmpY);
    }
  }
  
  int honestCount = 0;
  for (int i = 1; i < (1<<N); i++) {
    bool success = true;
    for (int j = 0; j < N; j++) {
      if ( !(i & ( 1 << j ) ) ) continue; //正直者でない
      for (int k = 0; k < A[j]; k++) {
        if(y[j][k]==1){
          //正直者チェック
          if( !(i & (1<<x[j][k]-1))) {success = false; break;}
        }
        if(y[j][k]==0){
          //不誠実者チェック
          if( (i & (1<<x[j][k]-1))) {success = false; break;}
        }
      }
      if (!success) break;
    }
    if (success) honestCount = max(honestCount, counter(i));
  }
  
  cout << honestCount << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define eol '\n'
using namespace std;

void printArray(vector<int> a, int n) {
  cout << a[0];
  for (int i = 1; i < n; i++) {
    cout << " " << a[i];
  }
  cout << eol;
}

void insertionSort(vector<int> a, int n) {
  printArray(a, n);
  for (int i = 1; i < n; i++) {
    int v = a[i];
    int j = i - 1;
    while (j >= 0 && a[j] > v) {
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
    
    printArray(a, n);
  }
}

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

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

  insertionSort(a, n);
  
  return 0;
}

Measured memory_bytes: 3224
n,m = map(int,input().split())

if n == 1 or n == 0 :
  n_c = 0
else :
  n_c = n * (n-1) / 2
if m == 1 or m == 0 :
  m_c = 0
else :
  m_c = m * (m-1) / 2

print(int(n_c + m_c))

Measured memory_bytes: 9116
#include <iostream>

using namespace std;

int main(){
    long long N, A, B;
    cin >> N >> A >> B;

    long long ans = 0;
    if (N == 1){
        if (A == B){
            ans = 1;
        }
    }else{
        if (A <= B){
            long long a = A * (N - 1) + B;
            long long b = A + B * (N - 1);
            ans = b - a + 1;
        }
    }
    
    cout << ans << endl;

    return 0;
}

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

int main(void) {
  ll A, B, C;
  cin >> A >> B >> C;

  ll x = max({ A, B, C });
  if (x == A) cout << "A" << endl;
  if (x == B) cout << "B" << endl;
  if (x == C) cout << "C" << endl;
}


Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
using namespace std;
#define MXN 100010
int h[MXN], dp[MXN];

int _abs(int x)
{
	return x<0? -x:x;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int N; cin>>N;
	for(int i=1; i<=N; i++) cin>>h[i];

	dp[1] = 0;
	dp[2] = _abs(h[2]-h[1]);
	for(int i=3; i<=N; i++)
		dp[i] = min(dp[i-1]+_abs(h[i]-h[i-1]), dp[i-2]+_abs(h[i]-h[i-2]));
	cout << dp[N] << '\n';
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<long> X(static_cast<unsigned long>(N)), Y(static_cast<unsigned long>(N));
    cin >> X[0] >> Y[0];
    bool check = ((X[0] + Y[0]) % 2 == 0);
    for (int i = 1; i < N; ++i) {
        cin >> X[i] >> Y[i];
        if (check != (((X[i]) + Y[i]) % 2 == 0)) {
            cout << -1 << endl;
            return 0;
        }
    }
    vector<long> d(34);
    int dLength = 33;
    if (!check) {
        cout << dLength << endl;
        for (int i = 0; i <= 32; ++i) {
            d[i] = static_cast<long>(pow(2, i));
            cout << d[i] << " ";
        }
    } else {
        dLength = 34;
        cout << dLength << endl;
        d[0] = 1;
        cout << 1 << " ";
        for (int i = 0; i <= 32; ++i) {
            d[i + 1] = static_cast<long>(pow(2, i));
            cout << d[i + 1] << " ";
        }
    }
    cout << endl;
    for (int i = 0; i < N; ++i) {
        string ans;
        for (int j = dLength - 1; j >= 0; --j) {
            long x = abs(X[i]), y = abs(Y[i]);
            if (x == max(x, y)) {
                if (X[i] < 0) {
                    ans += 'L';
                    X[i] += d[j];
                } else {
                    ans += 'R';
                    X[i] -= d[j];
                }
            } else {
                if (Y[i] < 0) {
                    ans += 'D';
                    Y[i] += d[j];
                } else {
                    ans += 'U';
                    Y[i] -= d[j];
                }
            }
        }
        reverse(ans.begin(), ans.end());
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
A, B, C, K = map(int, readline().split())

res = 0
if K <= A:
    print(K)
else:
    res += A
    K -= A
    
    if K <= B:
        print(res)
    else:
        K -= B
        res -= K
        print(res)

Measured memory_bytes: 27144
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>

#define EXIT puts("-1"),exit(0)

using namespace std;

deque<int> dq;
int n,ans;
char str1[1000001],str2[1000001];

int main(){
	scanf("%d%s%s",&n,str1+1,str2+1);
	dq.push_back(n+1);
	for(int i=n,j=n+1,d=0;i;--i){
		int t=j;
		j=min(i,j);
		while(j&&str1[j]!=str2[i])--j;
		if(j<1)EXIT;
		if(t==j){while(!dq.empty()&&dq.back()+d>=i)dq.pop_back();dq.push_back(i-d);}else{
			--d;
			if(i!=j)ans=max(ans,(int)dq.size()),dq.push_front(j-d);
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 6272
#include <algorithm>
#include <cstdio>
#include <cstring>

const int N = 1001;
const int M = 3;
const int MOD = (int)1e9 + 7;

struct Matrix
{
    Matrix(bool id = false)
    {
        memset(mat, 0, sizeof(mat));
        if (id) {
            for (int i = 0; i < M; ++ i) {
                mat[i][i] = 1;
            }
        }
    }

    void add(int x, int y, int z)
    {
        mat[x][y] += z;
        if (mat[x][y] >= MOD) {
            mat[x][y] -= MOD;
        }
    }

    int mat[M][M];
};

Matrix operator * (const Matrix& a, const Matrix& b)
{
    Matrix c;
    for (int i = 0; i < M; ++ i) {
        for (int j = 0; j < M; ++ j) {
            int& tmp = c.mat[i][j] = 0;
            for (int k = 0; k < M; ++ k) {
                tmp += 1LL * a.mat[i][k] * b.mat[k][j] % MOD;
                if (tmp >= MOD) {
                    tmp -= MOD;
                }
            }
        }
    }
    return c;
}

Matrix pow(Matrix a, long long n)
{
    Matrix result(true);
    while (n) {
        if (n & 1) {
            result = result * a;
        }
        a = a * a;
        n >>= 1;
    }
    return result;
}

int n, m;
long long k;
char s[N][N];

void flip()
{
    for (int i = 0; i < n; ++ i) {
        for (int j = 0; j < m; ++ j) {
            if (i < j || j >= n || i >= m) {
                std::swap(s[i][j], s[j][i]);
            }
        }
    }
    std::swap(n, m);
}

bool connected()
{
    for (int i = 0; i < n; ++ i) {
        if (s[i][0] == '#' && s[i][m - 1] == '#') {
            return true;
        }
    }
    return false;
}

int solve()
{
    for (int i = 0; i < n; ++ i) {
        scanf("%s", s[i]);
    }
    if (m == 0) {
        return 1;
    }
    auto ok0 = connected();
    flip();
    auto ok1 = connected();
    if (ok0 && ok1) {
        return 1;
    }
    if (!ok0 && !ok1) {
        int cnt = 0;
        for (int i = 0; i < n; ++ i) {
            for (int j = 0; j < m; ++ j) {
                cnt += (s[i][j] == '#');
            }
        }
        Matrix a;
        a.mat[0][0] = cnt;
        return pow(a, k - 1).mat[0][0];
    }
    if (ok0) {
        flip();
    }
    Matrix a0, a;
    a0.mat[0][0] = a0.mat[0][2] = 1;
    for (int i = 0; i < n; ++ i) {
        int cnt = 0, cnt2 = 0;
        for (int j = 0; j < m; ++ j) {
            if (s[i][j] == '#') {
                cnt ++;
                cnt2 += j && s[i][j - 1] == '#';
            }
        }
        int full = (s[i][0] == '#' && s[i][m - 1] == '#');
        a.add(0, 0, full);
        a.add(1, 1, cnt);
        int to = (full ? 2 : 1);
        a.add(0, to, MOD - cnt2);
        a.add(2, to, cnt);
    }
    a0 = a0 * pow(a, k - 1);
    return (a0.mat[0][1] + a0.mat[0][2]) % MOD;
}

int main()
{
    while (scanf("%d%d%lld", &n, &m, &k) == 3) {
        printf("%d\n", solve());
    }
}



Measured memory_bytes: 1152
while True:
    a, b=map(int, input().split())
    if a == b == 0:
        break
    n = int(input())
    NG = [list(map(int, input().split())) for i in range(n)]
    l1 = [[0] * (b + 1) for i in range(a + 1)]
    for i in range(1, a + 1):
        for j in range(1, b + 1):
            l1[i][j] = l1[i - 1][j] + l1[i][j - 1]
            if i == j == 1:
                l1[1][1] = 1
            if [i, j] in NG:
                l1[i][j] = 0
    print(l1[a][b])


Measured memory_bytes: 5600
<?php
    $keyword = trim(fgets(STDIN));
    $count = 0;
    
    while($sentence = trim(fgets(STDIN))) {
        if($sentence == "END_OF_TEXT") {
            echo $count."\n";
            exit;
        }
        
        $target = explode(" ",$sentence);
        
        foreach($target as $value){
            if(strtolower($value) == strtolower($keyword)) $count++;
        }
    }

Measured memory_bytes: 15232
def replace(s, r, c):
    for row in range(r - 1, r + 2):
        for column in range(c - 1, c + 2):
            if row < 0 or len(s) <= row:
                continue

            if column < 0 or len(s[row]) <= column:
                continue

            value = s[row][column]
            if value != "#":
                value += 1
                s[row][column] = value


h, w = map(int, input().split(" "))
s = []
for _ in range(h):
    row = input()
    tmp = []
    for i in range(w):
        tmp.append(row[i] if row[i] == "#" else 0)
    s.append(tmp)

for row in range(h):
    for column in range(w):
        if s[row][column] == "#":
            replace(s, row, column)

for row in range(h):
    res = ""
    for column in range(w):
        res += str(s[row][column])
    print(res)


Measured memory_bytes: 3064