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

using namespace std;

typedef long long       ll;

#define all(x)            (x).begin(),(x).end()
#define Sort(x)            sort(all(x))
#define A               first
#define B               second
#define sep             ' '
#define fast_io         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random     mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count())

const ll XN = 5e2+7,
         Md = 1e9+7;

ll n, ans;
string s, str;

void Solve(){
	ll jav = 0;
	for (int i = 0; i < str.size(); ++i){
		jav = (jav*10)+(str[i]-'0');
	}
	ans += jav;
}

int main(){
	fast_io;
	cin >> s;
	n = s.size()-1;
	for (int i = 0; i < (1 << n); ++i){
		str = "";
		str += s[0];
		for (int j = 0; j < n; ++j){
			if ((i & (1 << j))){
				Solve();
				str = s[j+1];
			}
			else{
				str = str + s[j+1];
			}
		}
		Solve();
	}
	cout << ans << '\n';
    return 0;
}
/*             now or never                 */


Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>

int main()
{
 char s[6]={};
  
  scanf("%s",s);
  
  if(s[2]==s[3]&&s[4]==s[5])
  {
    printf("Yes\n");
  }
  else
  {
    printf("No\n");
  }
  return 0;
}

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

bool then(bool p, bool q) { return !p || q; }

int main() {
    lint T;
    cin >> T;

    while(T--) {
        lint A, B, C, D;
        cin >> A >> B >> C >> D;

        bool c1 = A >= B;
        bool c2 = B <= D;

        bool c31 = C < B;
        lint g = __gcd(B, D);
        // C < (A+kD)%B < B なるkが存在 <=> C-A%B < k'g < B-A%B なるk'が存在
        bool c32 = (B-A%B-1)-(B-A%B-1)%g > C-A%B;
        bool c3 = then(c31, !c32);
        cout << (c1&c2&c3 ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.range;
import std.algorithm;
import std.math;
import std.regex;

void main() {
	auto s = readln.chomp.map!(a => a.to!int).array;
	auto t = s.sort().uniq.array;
	if(s.length != t.length) "no".writeln;
	else "yes".writeln;
}

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

const int N = 15;
typedef pair<int,int> ii;

int h, w;
int cnt_h;
ii row[N];
ii col[N];
string a[N];
bool can[N][N];

void yes() {
	printf("YES\n"); exit(0);
}

bool check_col(int i, int j) {
	for (int k = 1; k <= cnt_h; ++k) {
		if (a[row[k].first][i] != a[row[k].second][j] || a[row[k].first][j] != a[row[k].second][i]) {
			return false;
		}
	}
	return true;
}

void brute_col(int pos, int mask) {
	if (pos == w) {
		if (w % 2 == 0 && mask == 0) {
			yes();
		}
		if (w % 2 == 1 && __builtin_popcount(mask) == 1) {
			for (int c = 0; c < w; ++c) {
				if (mask >> c & 1) {
					if (check_col(c, c)) yes();
				}
			}
		}
		return;
	}

	brute_col(pos + 1, mask | (1 << pos));

	for (int c = 0; c < w; ++c) {
		if (mask >> c & 1) {
			if (check_col(c, pos)) {
				brute_col(pos + 1, mask ^ (1 << c));
			}
		}
	}
}

void brute_row(int pos, int mask) { 
	// {mask} is the set of currently unmatched rows
	if (pos == h) {
		if (h % 2 == 0 && mask == 0) {
			brute_col(0, 0);
		}
		if (h % 2 == 1 && __builtin_popcount(mask) == 1) {
			for (int r = 0; r < h; ++r) {
				if (mask >> r & 1) {
					row[++cnt_h] = ii(r, r);
					brute_col(0, 0);
					--cnt_h;
					break;
				}
			}
		} 
		return;
	}

	brute_row(pos + 1, mask | (1 << pos));

	for (int r = 0; r < h; ++r) {
		if (mask >> r & 1) {
			if (can[pos][r]) {
				row[++cnt_h] = ii(pos, r);
				brute_row(pos + 1, mask ^ (1 << r));
				--cnt_h;
			}
		}
	}
}

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

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

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < h; ++j) {
			if (i == j) continue;
			string s = a[i];
			string t = a[j];
			sort(s.begin(), s.end());
			sort(t.begin(), t.end());
			can[i][j] = s == t;
		}
	}

	brute_row(0, 0);
	printf("NO\n");
}

Measured memory_bytes: 256
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair

typedef long long ll;
typedef long double ld;

void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int res = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            for(int k = j + 1; k < n; k++){
                int x = a[i], y = a[j], z = a[k];
                if(x + y > z && y + z > x && x + z > y && x != y && y != z && z != x){
                    res++;
                }
            }
        }
    }
    cout << res << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,X,Y; cin>>n>>m>>X>>Y;
    vi x(n),y(m);
    rep(i,n) cin>>x[i];
    rep(i,m) cin>>y[i];
    FOR(i,X+1,Y){
        bool ok = true;
        rep(j,n){
            if (x[j]>=i){
                ok = false;
                break;
            }
        }
        rep(j,m){
            if (y[j]<i){
                ok = false;
                break;
            }
        }
        if (ok){
            cout<<"No War\n";
            return 0;
        }
    }
    cout<<"War\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

long long int gcd(long long int a, long long int b) {
    while (a % b != 0 && b % a != 0) {
        if (a > b) {
            a %= b;
        } else {
            b %= a;
        }
    }
    return min(a, b);
}

long long int f(long long int a, long long int b, long long int c) {
    return a - a / b - a / c + a / (b * c / gcd(b, c));
}

int main() {
    long long int a, b, c, d;
    cin >> a >> b >> c >> d;
    long long int res = f(b, c, d) - f(a - 1, c, d);
    cout << res << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define mp make_pair
#define pb push_back
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }

int main() {
    int N;  cin >> N;
    vector<int> X(N); rep(i, N) cin >> X[i];

    vector<pair<int, int>> v;
    rep(i, N) v.pb(mp(X[i], i));
    sort(all(v));
    int back = v[N/2].first;
    int front = v[N/2-1].first;
    vector<pair<int, int>> ans;
    rep(i, N) {
        if (i < N/2) ans.pb(mp(v[i].second, back));
        else ans.pb(mp(v[i].second, front));
    }
    sort(all(ans));
    rep(i, N) print(ans[i].second);

    return 0;
}


Measured memory_bytes: 6256
# coding: utf-8
# Here your code !
import sys
import math

def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1????´???°??§?????????

    # ??¨??????????????????????????????
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]
    
prime_list = primes(1000000)

for line in sys.stdin:
    n = int(line)
    count = 0
    for p in prime_list:
        if p > n:
            break
        count += 1
    print(count)

Measured memory_bytes: 47592
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	int a,b,h;
	cin >> a >> b >> h;
	
  	cout << (a+b)*h/2 << endl;
	return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<int> h(N);
  vector<int> j(N);
  for(int i = 0; i<N; i++){
    cin >> h.at(i);
  }
  
  for(int i = 0; i<N; i++){
    j.at(h.at(i)-1) = (i+1);
  }
  
  for(int i=0; i<N; i++){
    if(i == N - 1){
      cout << j.at(i) << endl;
    }else{
    cout << j.at(i) << " ";
    }
  }
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  while(true){
    c-=b;
    if(c<=0){
      cout << "Yes" << endl;
      break;
    }
    a-=d;
    if(a<=0){
      cout << "No" << endl;
      break;
    }
  }
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll i) {
	ll sum = 1;
	for (ll j = 2; j <= i; j++)
		sum = (sum* j) % Mod;
	return sum;
}//階乗(正）
//#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
int b[100001];
bool c[100001];
bool d[100001];
signed main() {
	int q;
	cin >> q;
	fill(d + 2, d + 100001, true);
	for (int i = 0; i < 100001; i++) {
		if (d[i]) {
			int t = i * 2;
			while (t < 100001) {
				d[t] = 0;
				t += i;
			}
		}
	}
	for (int i = 0; i < 100001; i++) {
		if (i % 2 == 1) {
			if (d[i] && d[(i + 1) / 2])
				c[i] = 1;
		}
	}
	for (int i = 1; i < 100001; i++)
		b[i] = b[i - 1] + c[i];
	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		cout << b[r] - b[l - 1] << endl;
	}
	getchar(); getchar();
}

Measured memory_bytes: 1152
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main(){
    int i,A,B,K;
    bool ans=false;
    cin>>K;
    cin>>A>>B;
    for(i=1;K*i<=B;i++){
        if(K*i>=A&&K*i<=B){
        ans=true;
        break;
        }
        if(K*i>B)break;
    }

    if(ans==true)cout<<"OK";
    else cout<<"NG";

return 0;
}

Measured memory_bytes: 3124
package main

import (
	"fmt"
	"math"
)

func main() {

	var S string

	fmt.Scan(&S)

	cnt:=1
	var result string

	for len(S) > cnt {

		s := S[0:len(S)-cnt]

		half := int(math.Ceil(float64(len(s))/2.0))

		if s[0:half] == s[half:]{

			result = s
			break
		}

		cnt++

	}


	fmt.Println(len(result))
}

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


int main(){
    long long a, b, n;

    cin >> a >> b >> n;

    long long minv = min(b - 1, n);


    
    printf("%lld\n", a*minv/b - a*(minv/b));

    return 0;
    
}

Measured memory_bytes: 3752
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

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

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
X ceil(X v, X d)
{
	return (v+d-1)/d;
}


struct l_t
{
	int id;
	ll a;
	ll l;
	ll d;
};


struct solve
{
	solve(){}
	ll operator()(int n, ll k, vll&a) {
		ll a_sum=0, a_max=0;
		for(auto&m:a)
		{
			a_sum+=m;
			max_u(a_max, m);
		}
		ll a_min=a_sum/(n+k);

		ll s=max(1LL, a_min);
		ll e=a_max;
		ll ans=e;
		while(s<=e)
		{
			ll c=(s+e)/2;
			ll cut_sum=0;
			for(auto m:a)
			{
				ll cut=(m-1)/c;
				cut_sum+=cut;
			}
//cout << "s=" << s << " e=" << e << " c=" << c << " cut_sum=" << cut_sum << "\n";

			if(cut_sum<=k)
			{
				e=c-1;
				min_u(ans, c);
			}
			else
			{
				s=c+1;
			}
		}
		return ans;
	}
};

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

	for(;;)
	{
		int n;
		ll k;
		cin >> n >> k;
		if(cin.fail()) break;
		vll a(n);
		for(auto&m:a) cin >> m;

		cout << solve()(n, k, a) << "\n";
		cout.flush();
	}
	return 0;
}


Measured memory_bytes: 4780
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x,y,z;
    int ans;
	cin >> x>> y>> z;
    ans = z-(x-y);
    if(ans<0)ans=0;
      cout << ans << endl;
}

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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    long long int n,m,x,y,i,j,a,b;
    cin>>n>>m;
    vector<long long int>A[n+1];
    queue<long long int>qt;
    bool visited[n+1]={false};
    map<long long int,long long int>result;
    for(i=0;i<m;i++){
        cin>>x>>y;
        A[x].push_back(y);
        A[y].push_back(x);
        if(x==1||y==1)
            visited[1]=true;
    }
    if(visited[1]==false)
        cout<<"No";
    else{
        qt.push(1);
        while(!qt.empty()){
            a=qt.front();
            for(i=0;i<A[a].size();i++){
                if(visited[A[a][i]]==false){
                    visited[A[a][i]]=true;
                    qt.push(A[a][i]);
                    result[A[a][i]]=a;
                }
            }
            qt.pop();
        }
        if(result.size()<n-1)
            cout<<"No";
        else{
            cout<<"Yes"<<endl;
            for(i=2;i<=n;i++){
                cout<<result[i]<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 18484
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
char s[1005][1005];
int step[1005][1005]={0};
int h,w;
int cnt;
int add[4][2]={
    0,1,
    1,0,
    -1,0,
    0,-1
};
int bound(int i,int j){
    return i>=0&&i<h&&j>=0&&j<w&&s[i][j]=='.';
}
queue<pair<int,int>>qq;
void dfs(int i,int j){
    step[i][j]=1;
    qq.push({i,j});
    if(bound(i+1,j)&&cnt<step[i+1][j])
        dfs(i+1,j);
    if(bound(i-1,j)&&cnt<step[i-1][j])
        dfs(i-1,j);
    if(bound(i,j-1)&&cnt<step[i][j-1])
        dfs(i,j-1);
    if(bound(i,j+1)&&cnt<step[i][j+1])
        dfs(i,j+1);
}
struct node{
    int i,j;
    bool operator<(const node & t)const{
        return step[i][j]>step[t.i][t.j];
    }
};
const int inf = 100000007;
int main()
{
    cin >> h >> w;
    int s1,s2;
    cin >> s1 >> s2;
    int e1,e2;
    cin >> e1 >> e2;
    for(int i=0;i<h;i++){
        cin >> s[i];
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;++j){
            step[i][j]=inf;
        }
    }
    priority_queue<node>qq;
    qq.push({s1-1,s2-1});
    step[s1-1][s2-1]=0;
    while(!qq.empty()){
        int f = qq.top().i;
        int s = qq.top().j;
        //cout << f << " " << s << " " <<step[f][s] << endl;
        qq.pop();
        for(int i=0;i<4;i++){
            int u=f+add[i][0],v=s+add[i][1];
            if(bound(u,v)&&step[u][v]>  step[f][s]){
                step[u][v]=step[f][s];
                qq.push({u,v});
            }
        }
        for(int i=-2;i<=2;i++)
        for(int j=-2;j<=2;++j){
            if(bound(f+i,s+j)&&step[f][s]+1<step[f+i][s+j]){
                step[f+i][s+j]=step[f][s]+1;
                qq.push({f+i,s+j});
            }
        }
    }
//    for(int i=0;i<h;i++){
//    for(int j=0;j<w;++j)
//        cout << step[i][j] << " \n"[j==w-1];
//    }
    if(step[e1-1][e2-1]==inf)
        cout << -1 <<endl;
    else
        cout << step[e1-1][e2-1] <<endl;
    //cout << step
    return 0;
}


Measured memory_bytes: 8528
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll inv(ll a) {
	ll ans = 1, n = mod - 2;
	while (n > 0) {
		if (n & 1) ans = ans * a%mod;
		a = a * a%mod;
		n >>= 1;
	}
	return ans;
}

int main() {
	int n, k, m;
	cin >> n >> k;
	m = max(n - k + 1, k - 1);
	vector<ll> fact(n + 2), ifact(n + 2);
	fact[0] = fact[1] = ifact[0] = ifact[1] = 1;
	for (int i = 2; i <= m; ++i) {
		fact[i] = fact[i - 1] * i%mod;
		ifact[i] = ifact[i - 1] * inv(i) % mod;
	}
	for (int i = 1; i <= k; ++i) {
		if (n - k + 1 - i >= 0)
			cout << (fact[n - k + 1] * (ifact[n - k + 1 - i] * ifact[i] % mod) % mod)
			* (fact[k - 1] * (ifact[k - i] * ifact[i - 1] % mod) % mod) % mod << endl;
		else cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int n, ptr, res;
int a[100000];

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

    sort(a, a+n);
    while(ptr < n)
    {
        int cc = a[ptr], f = 0;
        while (ptr < n && a[ptr] == cc) ++f, ++ptr;
        res += f % 2;
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 4208
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
inline int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
inline int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
inline int mul(int a, int b) {return 1ll * a * b % P;}
inline int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//----
ll x, y;
int main(){
	cin >> x >> y;
	int ans = 0;
	for(; x <= y; x = x * 2, ans++);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3688
#include <iostream>
#define rep(i,n) for(int i= 0; i<(n); i++)
using namespace std;
int main(void){
  int x,y;
  cin >> x >> y;
  
  for (int c=0; c<=x; c++){
      int t = x-c;
      if (y==2*c+4*t){
          cout << "Yes" << endl;
          return 0;
      }
  }
  
  cout << "No" << endl;
  return 0;
    
}


Measured memory_bytes: 3636
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;

    int n;
    void calc()
    {
        cin = new Scanner();
        n = cin.nextInt();
        Console.WriteLine(dfs(0, false, false, false));
    }

    int dfs(long now, bool is3, bool is5, bool is7)
    {
        if (now > n)
        {
            return 0;
        }
        int ans = 0;
        if (is3 && is5 && is7)
        {
            ans++;
        }
        ans += dfs(now * 10 + 3, true, is5, is7);
        ans += dfs(now * 10 + 5, is3, true, is7);
        ans += dfs(now * 10 + 7, is3, is5, true);
        return ans;
    }

}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <limits>
#include <string>
#include <vector>

using namespace std;

const long long INF = 1LL << 60;

//各桁の和を出力
long long Sum(long long n) {
  long long m = 0;
  while (n) {
    m += n % 10;
    n /= 10;
  }
  return m;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void Comuse() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

#define comuse Comuse()
// nCk(comuseを使え)
long long combi(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// pCk(comuseを使え)
long long perm(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] % MOD) % MOD;
}

//最小公倍数(aとbの)
long long lcm(long long a, long long b) {
  long long n;
  n = a / __gcd(a, b) * b;
  return n;
}

// auto A = div(n)
vector<long long> div(long long n) {
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) {
        ret.push_back(n / i);
      }
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

//(aのn乗をmodで割ったあまり)
long long modpow(long long a, long long n, long long mod) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) {
      ans = ans * a % mod;
    }

    a = a * a % mod;

    n >>= 1;
  }

  return ans;
}

void solve();

const int MAX_N = 131072;
// segment tree
int NN;
int seg[MAX_N * 2 - 1];
void seguse() {
  for (int i = 0; i < 2 * NN - 1; i++) {
    seg[i] = INT_MAX;
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;
  solve();
}

///////////////////////////////////////////////////////////

string S;
int Q;
bool hanten;
vector<vector<string>> query(200000, vector<string>(3));
void solve() {
  cin >> S >> Q;
  for(int i = 0; i < Q; i++){
    cin >> query.at(i).at(0);
    if(query.at(i).at(0) == "1"){
      hanten = !hanten;
    }
    if(query.at(i).at(0) == "2"){
      cin >> query.at(i).at(1) >> query.at(i).at(2);
      if(query.at(i).at(1) == "1" && hanten || query.at(i).at(1) == "2" && !hanten){
        S += query.at(i).at(2);
      } else{
        S.insert(0, query.at(i).at(2));
      }
    }
  }
  for(int i = 0; i < S.size(); i++){
    if(hanten){
      cout << S[S.size()-1-i];
    } else{
      cout << S[i];
    }
  }
}

Measured memory_bytes: 40044
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    vector<ll> a(4);
    rep(i, 4) cin >> a[i];

    ll ans = -2000000000000000000;
    chmax(ans, a[0] * a[2]);
    chmax(ans, a[0] * a[3]);
    chmax(ans, a[1] * a[2]);
    chmax(ans, a[1] * a[3]);

    if (a[0] <= 0 && 0 <= a[1] || a[2] <= 0 && 0 <= a[3]) chmax(ans, 0ll);

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

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int MX=305;

class FastIO
{
private:
	static const int MXL=200000;
	char IBF[MXL],OBF[MXL],*p1,*p2,*p3,c;
	char *const END;
	int tp,bf[22],f;
	FILE *I,*O;
	char gc(){return p1==p2?(p2=(p1=IBF)+fread(IBF,1,MXL,I)),p1==p2?EOF:*p1++:*p1++;}
	void pc(char c){if(p3==END)flush();*p3++=c;}
	void flush(){fwrite(OBF,1,p3-OBF,O),p3=OBF;}
	
public:
	FastIO(FILE *I,FILE *O):I(I),O(O),p1(IBF),p2(IBF),p3(OBF),END(OBF+MXL){}
	~FastIO(){flush();}
	template<typename T>void read(T& x)
	{
		c=gc(),x=0,f=0;
		while(!isdigit(c)){if(c=='-')f=1;c=gc();}
		while(isdigit(c))x=x*10+c-'0',c=gc();
		if(f)x=-x;
	}
	template<typename T>void write(T x)
	{
		if(x<0)putchar('-'),x=-x;
		bf[tp=1]='\n'-48;
		do bf[++tp]=x%10,x/=10;while(x);
		while(tp)pc(48+bf[tp--]);
	}
}IO(stdin,stdout);
#define read(x) IO.read(x)
#define write(x) IO.write(x)

int N,M,a[MX][MX],it[MX],ans=400,tmp,cnt[MX];
bool used[MX];

int main()
{
	read(N),read(M);
	for(int i=1;i<=N;i++)for(int j=1;j<=M;j++)read(a[i][j]);
	for(int i=1;i<=N;i++)it[i]=1;
	for(int i=1,mx;i<=M;i++)
	{
		memset(cnt+1,0,sizeof(int)*M);
		for(int j=1;j<=N;j++)
		{
			while(used[a[j][it[j]]])it[j]++;
			cnt[a[j][it[j]]]++;
		}
		mx=0;
		for(int j=1;j<=M;j++)if(cnt[j]>cnt[mx]&&!used[j])mx=j;
		ans=min(ans,cnt[mx]),used[mx]=1;
	}
	write(ans);
	return 0;
}


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

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int minbc = min(b, c);
    int ans = minbc * 2;
    b -= minbc;
    c -= minbc;
    ans += b;
    ans += min(a, c);
    c -= min(a, c);
    ans += c > 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n=int(input())
s=[Counter(list(input())) for _ in range(n)]
c=s[0]
for i in range(1,n):
  c&=s[i]
ans=''
for i in sorted(c.items(),key=lambda x:x[0]):
  ans+=i[0]*i[1]
print(ans)

Measured memory_bytes: 3316
#include <stdio.h>

int main()
{
	int r, D, x2000[11] = {};
	scanf("%d %d %d", &r, &D, &x2000[0]);
	for (int i = 1; i < 11; i++)
	{
		x2000[i] = (r * x2000[i - 1]) - D;
		printf("%d\n", x2000[i]);
	}
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b+c>=22){
    cout << "bust" << endl;
  }
  else if(a+b+c<=21){
    cout << "win" << endl;
  }
  return 0;
}

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

using namespace std;

long long a, b, q;

int main()
{
  cin >> q;
  for (int i = 1; i <= q; i++) {
    cin >> a >> b;
    if (a > b)
      swap(a, b);
    if (a == b || a + 1 == b)
      cout << 2 * a - 2 << "\n";
    else {
      long long c = sqrt(a * b);
      if (c * c == a * b)
        c--;
      if (c * (c + 1) < a * b)
        cout << 2 * c - 1 << "\n";
      else
        cout << 2 * c - 2 << "\n";
    }
  }
  return 0;
}


Measured memory_bytes: 256
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 10
typedef long long i64;

int n, k;
int b[10];

int input() {
	if (scanf("%d %d", &n, &k) < 0) return 0;
	memset(b, 0, sizeof(b));
	for (int i=0; i<k; i++) {
		int x;
		scanf("%d", &x);
		b[x] = 1;
	}
	return 1;
}

void init() {
}

int check(int n) {
	while(n) {
		if (b[n%10]) return 0;
		n /= 10;
	}
	return 1;
}

int solve() {
	while(!check(n)) n++;
	return n;
}

void output(int ans) {
	printf("%d\n", ans);
}

void cleanup() {
}

int main() {
	//precalc();
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}




Measured memory_bytes: 128
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()



def main():
	A=LI()
	A.sort()
	ans=0

	if A[0]%2 and A[1]%2 and A[2]%2:
		ans=A[0]*A[1]

	print(ans)




if __name__ == "__main__":
	main()


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

int main(void){
    long long int i, j, n, k, l, r, m, ans=0, po=0, popo;
    scanf("%lld %lld", &n, &k);
    long long int a[n];
    for(i=0; i<n; i++) scanf("%lld", &a[i]);
    l=1;
    r=1000000000;
    while(l!=r){
        po = 0;
        m = (l+r)/2;
        //printf("%lld %lld %lld\n", l, m, r);
        for(i=0; i<n; i++){
            
            if(a[i]>m) po += (a[i]-1)/m;
        }
        if(po<=k) r = m;
        else l = m+1;
    }
    printf("%lld", l);
}

Measured memory_bytes: 3244
N = gets.strip.to_i
ac = 0
wa = 0
tle = 0
re = 0


N.times do |i|
  s = gets.strip
  ac += 1 if s.eql?("AC")
  wa +=1 if s.eql?("WA")
  tle +=1 if s.eql?("TLE")
  re +=1 if s.eql?("RE")
end

puts "AC x #{ac}"
puts "WA x #{wa}"
puts "TLE x #{tle}"
puts "RE x #{re}"

Measured memory_bytes: 14332
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int H, W, K;
  while (cin >> H >> W >> K) {
    vector<string> grid(H);
    for (auto& line : grid) cin >> line;
    vec<int, 2> res = make_v(H, W, 0);
    vector<int> ys;
    for (int y = 0; y < H; y++) {
      bool found = false;
      for (int x = 0; x < W; x++) {
        if (grid[y][x] == '#') found = true;
      }
      if (found) ys.push_back(y);
    }
    int color = 1;
    int sy = 0;
    for (int i = 0; i < ys.size(); i++) {
      int y = ys[i];
      int ty = (i + 1 == ys.size() ? H : y + 1);
      vector<int> xs = {0};
      for (int x = 0; x < W; x++) {
        if (grid[y][x] == '#') xs.push_back(x + 1);
      }
      xs.pop_back();
      xs.push_back(W);
      for (int j = 0; j + 1 < xs.size(); j++) {
        for (int x = xs[j]; x < xs[j + 1]; x++) {
          for (int y = sy; y < ty; y++) { 
            res[y][x] = color;
          }
        }
        ++color;
      }
      sy = ty;
    }
    for (int y = 0; y < H; y++) {
      for (int x = 0; x < W; x++) {
        cout << res[y][x] << " ";
      }
      cout << endl;
    }
  }
  return 0;
}


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

class DP {
    static void Main(string[] args) {
        var st = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long N = st[0];
        long W = st[1];
        var w = new long[N];
        var v = new long[N];
        for (int i = 0; i < N; i++) {
            var x = Console.ReadLine().Split().Select(long.Parse).ToArray();
            w[i] = x[0];
            v[i] = x[1];
        }

        //考えうる価値の最大値
        long max_value = N * 1000 + 100;

        //少し大きめに配列を確保
        var dp = new long[N + 2, max_value + 10];

        long max_weight = 1000000000L * N + 100L;

        //値は全て大きな値で初期化する
        for (int i = 0; i < N; i++) {
            for (int j = 0; j <= max_value; j++) {
                dp[i, j] = max_weight;
            }
        }
        for (int i = 0; i < N; i++) {
            dp[i, 0] = 0;
        }
        for (int j = 1; j < max_value; j++) {
            if (j <= v[0]) {
                dp[0, j] = w[0];
            }
        }

        for (int i = 0; i < N - 1; i++) {
            for (int j = 0; j <= max_value; j++) {
                long kari = dp[i, j];
                if (j - v[i + 1] >= 0) {
                    kari = Math.Min(kari, dp[i, j - v[i + 1]] + w[i + 1]);
                }
                dp[i + 1, j] = kari;
            }
        }

        long ans = 0;
        for (int j = 0; j <= max_value; j++) {
            if (dp[N - 1, j] <= W) {
                ans = j;
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 92896
#include<bits/stdc++.h>
using namespace std;
map<pair<int,int>,int>a;
pair <int,int> hh;
int h,m,w,x,y;
long long c[10];
int main()
{
	scanf("%d%d%d",&h,&m,&w);
	c[0]=1ll*(h-2)*(m-2);
	for (int i=1;i<=w;++i)
	  {
	  	scanf("%d%d",&x,&y);
	  	for (int j=max(3,x);j<=min(x+2,h);++j) for (int k=max(3,y);k<=min(y+2,m);++k) c[a[make_pair(j,k)]]--,c[++a[make_pair(j,k)]]++;
	  }
	for (int i=0;i<=9;++i) printf("%lld\n",c[i]);
	return 0;
}

Measured memory_bytes: 56576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N,D;
    cin >> N >> D;
    cout << ceil(1.0*N/(2*D+1)) << endl;
    return 0;
}

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

using namespace std;

const vector<char> C = {'A', 'C', 'G', 'T'};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  cin >> S;
  int res = 0, len = 0;
  auto f = [](char s) {
    for (auto c : C) {
      if (s == c) return true;
    }
    return false;
  };
  for (int i = 0; i < (int)S.size(); i++) {
    if (f(S[i])) {
      len++;
    } else {
      len = 0;
    }
    res = max(res, len);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define ll  long long 
const ll INF=1LL<<60;
const ll MOD=1000000007;
const int MAX = 5000000;
long long moto[MAX], gyaku[MAX], inv[MAX];
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
void ncr_shokika() {
    moto[0] = moto[1] = 1;
    gyaku[0] = gyaku[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        moto[i] = moto[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        gyaku[i] = gyaku[i - 1] * inv[i] % MOD;
    }
}
long long ncr(int n, int r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return moto[n] * (gyaku[r] * gyaku[n - r] % MOD) % MOD;
}
int main(){
    ll a,b,c,d;cin>>a>>b>>c>>d;
    cout<<max({a*c,b*c,a*d,b*d});

}

Measured memory_bytes: 3620
#include<stdio.h>

int main(){
    int n, i;
    long min, max, result;
    long R[200000];
    
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%ld", &R[i]);
    }
    
    max = R[1]; min = R[0]; result = R[1] - R[0];
    for(i = 1; i < n; i++){
        if(max < R[i]){
            max = R[i];
        } 
        if(result < max - min){
            result = max - min;
        }
        if(min > R[i]){
            min = R[i];
            if(i != n-1){
            	max = R[i + 1];
            }
        }
    }
    printf("%ld\n", result);
    
    return 0;
}


Measured memory_bytes: 3340
N = int(input())
A = [int(input()) for _ in range(N)]

flag = 0
if A[0]:
  flag = 1
for i in range(1, N):
  if A[i] - A[i - 1] > 1:
    flag = 1
if flag:
  print(-1)
  exit()

A = [0] + A[::-1]
answer = 0
for i in range(1, len(A)):
  if A[i] and A[i] - A[i - 1] >= 0:
    answer += A[i]
print(answer)

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

int main(){
  int a, b;
  cin >> a >> b;
  int ans = -1;
  for(int i = 1; i < 1250; i++){
    if(i*8/100 == a && i*10/100 == b){
      ans = i;
      break;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

struct edge{
    int from, to;
    lint cost;
};

int n, m;
vector<edge> edges;
vector<lint> cost;

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

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

bool bellman_ford(int start, int goal){
    cost.resize(n);
    fill(cost.begin(), cost.end(), -LLINF);
    cost[start] = 0;
    for(int i = 0 ; i < n * 2 ; ++i){
        for(int j = 0 ; j < m ; ++j){
            edge now = edges[j];
            if(cost[now.from] != -LLINF && cost[now.to] < cost[now.from] + now.cost){
                cost[now.to] = cost[now.from] + now.cost;
                if(i >= n - 1 && now.to == goal){
                    return false;
                }
                if(i >= n - 1){
                    cost[now.to] = LLINF;
                }
            }
        }
    }
    return true;
}

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

    cin >> n >> m;

    rep(i, m){
        int a, b;
        lint c;
        cin >> a >> b >> c;
        edges.push_back({--a, --b, c});
    }

    if(bellman_ford(0, n - 1)){
        cout << cost[n - 1] << endl;
    }else{
        cout << "inf" << endl;
    }

    return 0;
}

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

int maxHappiness(vector<vector<int>>& tasks, int row, int col, vector<vector<int>>& mem){
    if(row >= tasks.size()) return 0;

    if(mem[row][col] != -1) return mem[row][col];

    int ans = INT_MIN;
    for(int i = 0; i < 3; i++){
        if(i == col) continue;

        ans = max(ans, tasks[row][col]+maxHappiness(tasks, row+1, i, mem));
    } 

    mem[row][col] = ans;
    return ans;
}

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

    vector<vector<int>> tasks(N, vector<int>(3));
    vector<vector<int>> mem(N, vector<int>(3, -1));
    for(int i = 0; i < N; i++){
        cin >> tasks[i][0] >> tasks[i][1] >> tasks[i][2];
    }

    int ans = INT_MIN;
    for(int i = 0; i < 3; i++){
        ans = max(ans, maxHappiness(tasks, 0, i, mem));
    }
    cout << ans << endl;
}

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

ll exp(int a, int b){

    if (b == 0) return 1;

    return a*exp(a, b-1);
}

int main(){

    ll N;
    cin >> N;
    ll buf;
    buf = N;
    int digit = 0, sum = 0;

    while(buf != 0){
        sum += buf%10;
        buf /= 10;
        digit++;
    }
//    cout << digit << " " << sum << endl;  // debug

    int l = N/(exp(10, digit-1));
    int temp = (l-1) + 9*(digit-1);
//    cout << l << " " << temp << endl;  // debug
    sum = max(sum, temp);

    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
#define alrep(i,j,n) for(int i=0;i<(n);++i)for(int j=i+1;j<(n);++j
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int MOD=1e9+7;
const long long INF = 1LL << 60;
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()



signed main(){
  int r;
  cin >> r;
  cout << r*r << endl;
  return 0;
}


Measured memory_bytes: 256