akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define MODB 998244353
#define INF 9223372036854775807
signed main()
{
  int x=0,y=0,z=0,w=0,n=0,m=0,a=0,b=0;
  string s;
  std::cin >> x>>s;
if(x%2!=0){
  std::cout << "No" << '\n';
  return 0;
}
  rep(i,x/2){
    if(s[i]!=s[i+x/2])y++;
  }
  if(y!=0)std::cout << "No" << '\n';
  else std::cout << "Yes" << '\n';

}


Measured memory_bytes: 256
/*
author: Apoorv Singh
*/

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

typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " " << (x) << endl;
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
#define FORR(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"

int modulo = 1e9 + 7;

template <class X>

void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}

int fpow(int a, int n)
{
    int ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n; cin >> n;
    cout << (n-2)*180;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main()
{   long long n;
    scanf("%lld",&n);
    int cnt=0;
    for(int i=0;i<n;i++){
        int tmp1,tmp2;
        scanf("%d%d",&tmp1,&tmp2);
        if(tmp1==tmp2){
            cnt++;
        }else{
            cnt=0;
        }
        if(cnt==3){
            printf("Yes");
            return 0;
        }
    }
    
    printf("No");
    return 0;
}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin>>a>>b;
	int x=a+b;
	if(x%2) cout<<"IMPOSSIBLE\n";
	else cout<<x/2<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<functional>
using namespace std;
int n, H, W, e, p[105][105], cx = 0, cy = 0;
int main() {
	cin >> H >> W >> n;
	for (int i = 1; i <= n; i++) {
		cin >> e;
		for (int j = 0; j < e; j++) {
			p[cx][cy] = i;
			if (cx % 2 == 0 && cy == W - 1)cx++;
			else if (cx % 2 == 1 && cy == 0)cx++;
			else if (cx % 2 == 0)cy++;
			else cy--;
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (j)cout << ' '; cout << p[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		String s = stdIn.next();
		
		if ((s.contains("a")) && (s.contains("b")) && (s.contains("c"))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21588
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[100010];
    fill(A, A + 100010, 0);
    REP(i, 0, N) {
        ll a;
        cin >> a;
        A[a - 1]++;
    }
    ll one = 0;
    ll two = 0;
    REP(i, 0, 100010) {
        if (A[i] > 0) {
            if (A[i] % 2 == 1) {
                one++;
            } else {
                two++;
            }
        }
    }
    if (two % 2 == 1) {
        two--;
    }
    cout << one + two << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

int main(){
  int n; string s;
  cin >> n >> s;
  int ans = 0;
  for(int i = 0; i < 1000; i++){
    vector<int> temp;
    int now = i;
    for(int j = 0; j < 3; j++){
      temp.push_back(now%10);
      now /= 10;
    }
    reverse(temp.begin(), temp.end());
    int k = 0;
    for(int j = 0; j < n; j++){
      if(s[j] == temp[k]+'0'){
        k++;
      }
      if(k == 3) break;
    }
    if(k == 3) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

LL ans[105],k;
LL GCD(LL x, LL y)
{
	if(y == 0) return x;
	else return GCD(y, x % y);
}

LL LCM(LL x, LL y)
{
	return x / GCD(x, y) * y;
}
 int main()
{
	int n,i;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>ans[i];
	}
	k=1;
	for(i=1;i<=n;i++)
	{
		k=LCM(k,ans[i]);
	}
	cout<<k<<endl;
}

Measured memory_bytes: 256
# 2, 5, 221
n = gets.to_i
h = gets.split.map &:to_i
$count = 0
def split(arr)
  mini = arr.min
  $count += mini
  arr.map! { |a| a - mini }
  tmp = []
  t = []
  arr.each do |a|
    if a > 0
      t << a
    else
      tmp << t
      t = []
    end
  end
  tmp << t

  tmp.each do |tm|
    split(tm) unless tm.empty?
  end
end
split(h)
p $count


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


int main() {
  int N;
  cin >> N;
  vector< string > S(N);
  vector< int > T(N);
  for(int i = 0; i < N; i++) {
    cin >> S[i] >> T[i];
  }
  string X;
  cin >> X;
  for(int i = 0; i < N; i++) {
    if(X == S[i]) {
      int ret = 0;
      for(int j = i + 1; j < N; j++) {
        ret += T[j];
      }
      cout << ret << endl;
      return 0;
    }
  }
}




Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<stdio.h>
using namespace std;
struct robot
{
    int x;
    int y;
}a[100100];
int cmp(struct robot  x,struct robot  y)
{
    return x.y<y.y;
}
int main()
{
 int n,i,x,y,temp,count=1;
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
     scanf("%d%d",&x,&y);
     a[i].x=x-y;
     a[i].y=x+y;
 }
 sort(a,a+n,cmp);
 temp=a[0].y;
 for(i=1;i<n;i++)
 {
     if(temp<=a[i].x)
     {
         temp=a[i].y;
         count++;
     }
 }
 printf("%d",count);
return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

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

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


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

int main() {
	string S;
	cin >> S;
	ll N = S.size();

	ll K;
	cin >> K;

	vector<ll> v;
	
	S = S + '?';
	ll c = 1;
	rep(i,N){
		if (S[i] == S[i+1]) { c++; }
		else { v.push_back(c); c = 1; }
	}

	ll M = v.size();

	//rep(i, M) cout << v[i];

	ll ans = 0;

	if (M == 1) {
		ans = (N*K) / 2;
	}

	else if(S[0]!=S[N-1]){
		rep(i, M) {
			ans += v[i] / 2;
		}
		ans *= K;
	}

	else {
		for (ll i = 1; i < M - 1; i++) {
			ans += v[i] / 2;
		}
		ans *= K;

		ans += v[0] / 2 + v[M - 1] / 2;
		ans += (v[0] + v[M - 1]) / 2 * (K - 1);
	}

	cout << ans;

	

	system("PAUSE");

}





Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)
using ll = long long;
using pll = pair<ll,ll>;
using vvll = vector<vector<ll>>;
using vll = vector<ll>;
using vstr = vector<string>;
const ll MOD=1000000007;
vll dx{0,1,0,-1};
vll dy{1,0,-1,0};
int i,j,k,n,m,a,b,c;
ll res,ans;

template <class type> void printVector(vector<type> vec){
    stringstream ss;
    ll n=vec.size();
    for(ll i=0;i<n;i++)
    {
        ss<<vec[i]<<" ";
        if(i!=n-1)ss<<" ";
    }
    cout<<ss.str()<<endl;
}

template <class type> void inputVector(vector<type>& vec){
    for(ll i=0;i<vec.size();i++)
    {
        cin>>vec[i];
    }
}

void solve(){
    cin >> n >> k;
    if (k % 2 == 0) {
        ll a = n / k; 
        ll b = (n + (k/2)) / k;
        cout << a*a*a + b*b*b << endl;
    }
    else {
        ll a = n / k;
        cout << a*a*a << endl;
    }
}

int main(){
    solve();
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
const int N = 1e5+10;
int a[N];
 
int main()
{
    int n;
    cin>>n;
    
        for(int i=2;i<=n;i++)
        {
            int x=i;
            for(int j=2;j<=x;j++)
            {
                while(x%j==0)
                {
                    a[j]++;
                    x/=j;
                }
            }
        }
        ll ans=1;
        for(int i=1;i<=n;i++)
        {
            if(a[i]!=0) ans=(ans*(a[i]+1))%mod;
        }
        printf("%lld\n",ans);
    
    return 0;
}

  


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

#define LEN 100005
using namespace std;


typedef struct pp
{
	string name;
	int time;
} P;

P Q[LEN+1];
int head, tail;

void enqueue(P x)
{
	Q[tail] = x;
	tail = (tail+1)%LEN;
}

P dequeue()
{
	P x = Q[head];
	head = (head+1)%LEN;
	return x;
}

int main()
{
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < n; i++)
		cin >> Q[i].name >> Q[i].time;
	head = 0, tail = n;
	int elaps = 0, c;
	P temp;
	while (head != tail)
	{
		temp = dequeue();
		c = min(temp.time, q);
		temp.time -= c;
		elaps += c;
		if (temp.time)
			enqueue(temp);
		else 
			cout << temp.name << " " << elaps << endl;
	}
	return 0;
}



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

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

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N; cin >> N;
    int A[2][N]; REP(i,2)REP(j,N) cin >> A[i][j];
    int ans[2][N]; REP(i,2)REP(j,N) ans[i][j] = 0;

    REP(i,2)REP(j,N){
        ans[i][j] = A[i][j];
        if(i || j){
            if(i) chmax(ans[i][j], A[i][j] + ans[i-1][j]);
            if(j) chmax(ans[i][j], A[i][j] + ans[i][j-1]);
        }
    }
    cout << ans[1][N-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int n;
    cin>>n;
    map<int,int> mp;
    FOR(i,0,n){
        int a;
        cin>>a;
        if(mp[a]==1){
            cout<<"NO"<<endl;
            return 0;
        }
        mp[a]=1;
    }
    cout<<"YES"<<endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;
const int INF = 1e9;
const llint llINF = 1e18;

int main () {
    int a, b; cin >> a >> b;
    char x[100], y[100];
    for (int i = 0; i < b; i++) {
        x[i] = '0' + a;
    }
    x[b] = '\0';
    for (int i = 0; i < a; i++) {
        y[i] = '0' + b;
    }
    y[a] = '\0';
    if (a < b) cout << x << endl;
    else cout << y << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n; while (cin >> n)
		if (!n)return 0;
	else for (int i = 0; i < n; i++){
		int x1, x2, x3, y1, y2, y3, z1, z2, z3, w1, w2, w3;
		cin >> x1 >> y1 >> z1 >> w1 >> x2 >> y2 >> z2 >> w2;
		x3 = x1*x2 - (y1*y2) - (z1*z2) - (w1*w2);
		y3 = x1*y2 + y1*x2 + z1*w2 - (w1*z2);
		z3 = x1*z2 - (y1*w2) + z1*x2 + w1*y2;
		w3 = x1*w2 + y1*z2 - (z1*y2) + w1*x2;
		cout << x3 << ' ' << y3 << ' ' << z3 << ' ' << w3 << endl;
	}
}

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

struct SCC {
public:
    int num;

    SCC(int n) : G(n), G_rev(n), comp(n, -1), visited(n) {}

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

    void build() {
        for (int v = 0; v < G.size(); v++) dfs(v);
        reverse(order.begin(), order.end());
        num = 0;
        for (int v : order) if (comp[v] == -1) rdfs(v, num++);
    }

    int operator[](int i) const {
        return comp[i];
    }

private:
    vector<vector<int>> G, G_rev;
    vector<int> comp, order;
    vector<bool> visited;

    void dfs(int u) {
        if (visited[u]) return;
        visited[u] = true;
        for (int v : G[u]) dfs(v);
        order.push_back(u);
    }

    void rdfs(int u, int c) {
        if (comp[u] != -1) return;
        comp[u] = c;
        for (int v : G_rev[u]) rdfs(v, c);
    }
};

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

    int N, M;
    cin >> N >> M;
    SCC scc(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        scc.add_edge(a, b);
    }
    scc.build();
    cout << scc.num << "\n";
    vector<vector<int>> v(scc.num);
    for (int i = 0; i < N; i++) v[scc[i]].push_back(i);
    for (int i = 0; i < scc.num; i++) {
        cout << v[i].size();
        for (int j : v[i]) cout << " " << j;
        cout << "\n";
    }
}

Measured memory_bytes: 79552
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int a, b;

int main() {
  cin >> a >> b;
  if (b < a) {
    cout << a - 1 << endl;
  } else {
    cout << a << endl;
  }
}

Measured memory_bytes: 256
/**
 *    author:  Mohamad Milhem
**/

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define MOD ll(1000000007)
#define debug(x) cout << '[' << #x << " is: " << x << "] " <<endl;
#define decimalpoint cout << std::fixed << setprecision(5)
int h,n;
long long yes[1003], no[1003];
long long dp[20005];



long long calc(int now){
	if (now <= 0)return 0;

	if (dp[now] != -1)return dp[now];


	long long ans = 2e9;

	for (int i = 0 ; i < n ; i++){
		ans = min(ans, calc(now - yes[i]) + no[i]);
	}

	return dp[now] = ans;
}








void solve(){

	cin >> h >> n;

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

	


	for (int i = 0 ; i <= 20000 ; i++){
		dp[i] = 1e17;
	}


	dp[0] = 0;


	for (int i = 0 ; i < n ; i++){
		for (int j = 0 ; j <= h ; j++){
			dp[j+yes[i]] = min(dp[j + yes[i]] , dp[j] + no[i]);
		}

	}

	

	long long ans = 1e17;

	for (int i = h ; i <= 20000 ; i++){
		ans = min(ans, dp[i]);
	}

	cout << ans << endl;

}



int main()
{
    FAST;
    int t;
    t = 1;

    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3804
if __name__ == "__main__":
    n = int(input())
    txy = [list(map(int, input().split())) for _ in range(n)]

    time = 0
    pos = [0, 0]
    for i in range(n):
        dist = abs(txy[i][1] - pos[0]) + abs(txy[i][2]-pos[1])
        t = txy[i][0] - time
        if dist > t:
            print('No')
            exit()
        elif (t - dist) % 2 == 1:
            print('No')
            exit()
        pos = [txy[i][1], txy[i][2]]
        time = txy[i][0]

    print('Yes')


Measured memory_bytes: 27380
N, M, Q = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(Q)]


def dfs(x):
    if len(x) == N + 1:
        res = 0
        for a, b, c, d in X:
            if x[b] - x[a] == c:
                res += d
        return res

    res = 0
    last = x[-1]
    for v in range(last, M + 1):
        x.append(v)
        res = max(res, dfs(x))
        x.pop()

    return res

print(dfs([1]))


Measured memory_bytes: 78012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

ll dp[105][100005];
int N, W;
int w[105], v[105];
int main()
{
    cin >> N >> W;
    for (int i = 0; i < N; i++)
    {
        cin >> w[i] >> v[i];
    }

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (j + w[i] <= W) dp[i + 1][j + w[i]] = max(dp[i][j] + v[i], dp[i][j + w[i]]);
            dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]);
        }
    }

    cout << dp[N][W] << endl;
}

Measured memory_bytes: 79360
#include <iostream>

using namespace std;
int main()
{
	long A;
	cin >> A;
	long B;
	cin >> B;
	long C;
	cin >> C;
	long K;
	cin >> K;

	bool result = true;
	int count = 0;
	while (B <= A)
	{
		B *= 2;
		count++;
	}
	if (count > K)
	{
		result = false;
	}
	else
	{
		while (C <= B)
		{
			C *= 2;
			count++;
		}
		if (count > K)
		{
			result = false;
		}
	}

	if (result)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3616
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}
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;
}
int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<vector<int> > data(N, vector<int>(M));
    vi B(M);
    rep(i, 0, M) {
        cin >> B[i];
    }
    int count = 0;
    int sum = 0;
    rep(i, 0, N) {
        rep(i, 0, M) {
            int A;
            cin >> A;
            sum += (A * B[i]);
        }
        sum += C;
        if (sum > 0) ++count;
        sum = 0;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
a = input().split()
if (abs(int(a[0]) - int(a[1])) <= int(a[3]) and abs(int(a[1]) - int(a[2])) <= int(a[3])) or abs(int(a[0]) - int(a[2])) <= int(a[3]):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
using namespace std;
int main(void){
    int N, M, X;
    int res[2]={0};
    int toll;
    int answer;
    cin >> N >> M >> X;
    for (int i=0; i<M; i++){
        cin >> toll;
        if (toll<X){
            res[0]++;
        }
        else{
            res[1]++;
        }
    }
    if(res[0]>res[1]){
        printf("%d", res[1]);
    }
    else{
        printf("%d", res[0]);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <vector>
#include <bitset>
#include <stack>
#include <iomanip>
#include <set>
#include <queue>
#include <map>


typedef long long ll;
typedef unsigned long long ull;
#define mk make_pair
#define mkt make_tuple

using namespace std;
int const N = 200005;
ll f(ll n) {
	return n * (n + 1)/2ll;
}
int main()
{
	ll n;
	cin >> n;
	cout << f(n) - f(n / 15) * 15 - (f(n / 3) * 3 - f(n / 15)*15) - (f(n / 5)*5 - f(n / 15)*15);
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
using namespace std;
const int N=1e5+1;
const int M=1e9+7;
const double eps=1e-6;
//size() use int
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){return x?BIT[x]+sum(x-(x&-x)):0;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
//LL pw(LL a, LL b,LL M) { return b ? b & 1 ? a*pw(a, b - 1,M) % M : pw(a*a%M, b>>1,M) : 1; }
int p[2][N],f[2][N];
int main(){Accel
	int n,x;
	cin>>n;
	FOR(i,1,2)FOR(j,1,n){
		cin>>p[i][j];
		f[i][j]=max(f[i-1][j],f[i][j-1])+p[i][j];
	}
	cout<<f[2][n]<<endl;
}

Measured memory_bytes: 256
N = gets.to_i
array = gets.split.map(&:to_i)

if !array.include?(1)
    puts -1
elsif array == (1..N).to_a
    puts 0
else
    array = array.drop_while { |a| a != 1 }
    n = 2
    
    while !array.index(n).nil? do
        array = array.drop_while { |a| a != n }
        n += 1
    end
    
    puts N - n + 1
end

Measured memory_bytes: 20796
def solve(h, w, k):
    n = h + w
    MOD = 10 ** 9 + 7

    if k == 1:
        return 2 * n

    ans = 0
    # (0, 0) ... k * nPk * 1
    ans += k * n * (n - 1) % MOD
    # (i, 0) (0, j) ... sum(t for t=1..k) * (n-1)P(k-1) * (h+w)
    tmp = k * (k + 1) // 2 * (n - 1) % MOD
    ans += tmp * n % MOD
    # (i, j) ... sum((t-1)(k-t+1) for t=1..k) * (n-2)P(k-2) * 2 * h*w
    #            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ = (k-1)k(k+1)/6
    tmp = (k - 1) * k * (k + 1) // 3 % MOD
    ans += tmp * h * w % MOD

    for m in range(n - 2, n - k, -1):
        ans = ans * m % MOD
    return ans % MOD


h, w, k = map(int, input().split())
print(solve(h, w, k))


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

int main( )
{
    long long int n, s = 0, x;
    cin >> n;
    x = n;
    while (x != 0) {
        s += (x % 10);
        x /= 10;
    }
    if (n % s == 0) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000000
#define VMAX 10001
int main(){
  int n, i, *A,*B, C[VMAX];
  scanf("%d", &n);
  A = (int*)malloc(sizeof(int)*MAX);
  for(i = 1; i < n+1; i++) scanf("%d", &A[i]);
  
  for(i = 0; i < VMAX; i++) C[i]=0;
  for(i = 1; i < n+1; i++) C[A[i]]++;
  for(i = 1; i < VMAX; i++) C[i] = C[i] + C[i-1];

  B = (int*)malloc(sizeof(int)*MAX);               
  for(i = n; i > 0; i--){
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }

  for(i = 1; i < n+1; i++){
    if(i != 1) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  free(A);
  free(B);
  return 0;
}



Measured memory_bytes: 17056
//#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <numeric>

using namespace std;

typedef long long int lo;
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define inf (lo)1e9
#define N (lo)1e5 * 5
#define all(x) (x).begin(), (x).end()
#define ii pair<lo,lo>
#define iii pair<lo, pair<lo,lo> >
#define si pair<string,lo>
#define vi vector <lo> 
#define vii vector <ii> 

int main() {
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0);
    string s;
    cin >> s;
    if(s == "ABC"){
	cout << "ARC\n";
    }
    else{
	cout << "ABC\n";
    }
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< int > vi;
typedef vector< ll > lvi;
typedef vector< vi > vvi;
typedef vector< lvi > lvvi;
typedef pair< int,int > ii;
typedef pair< ll,ll > lii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define mp make_pair
#define ld long double
#define ull unsigned long long int
#define mod 998244353
ll ans=0,dp[3001][3001],n,s,a[4000];
ll recurs(int idx,int s1)
{
	if(s1==0) return (n-idx+1);
	if(idx>=n) return 0; 
	if(s1<0) return 0;
	if(dp[idx][s1]!=-1) return dp[idx][s1];
	ll val1=recurs(idx+1,s1);
	ll val2=recurs(idx+1,s1-a[idx]);
	if(s==s1)
	{
		// cout<<idx<<" "<<val2<<endl;
		ans=(ans+(val2*(idx+1))%mod)%mod;
	}
	dp[idx][s1]=(val1+val2)%mod;
	// cout<<
	return dp[idx][s1];
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
	cin>>n>>s;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	memset(dp,-1,sizeof(dp));
	recurs(0,s);
	cout<<ans<<endl;
	return 0;
}

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

template <typename tn> void read (tn & a) {
	tn x = 0, f = 1; char c = getchar();
	while (c < '0' || c > '9'){ if (c == '-') f = -1; c = getchar(); }
	while (c >= '0' && c <= '9'){ x = x * 10 + c - '0'; c = getchar(); }
	a = f == 1 ? x : -x;
}

const int MAXN = 100100;
const int Ln = 22;
const int INF = 2e9;
ll n, m;
ll a[MAXN], b[MAXN];
vector<int> g[MAXN];
ll f[MAXN], fa[MAXN], bsum[MAXN], p[MAXN];
bool vis[MAXN];

ll find (int x) { return fa[x] == 0 || fa[x] == x ? x : fa[x] = find(fa[x]); }
bool cmp (int i, int j) { return a[i] < a[j]; }

int main() {
	read(n);
	read(m);
	rep(i, 1, n) read(a[i]), read(b[i]);
	rep(i, 1, m) {
		int u, v;
		read(u);
		read(v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	rep(i, 1, n) {
		a[i] -= b[i];
		if (a[i] < 0) a[i] = 0;
		fa[i] = i;
		p[i] = i;
		vis[i] = 0;
	}
	sort(p + 1, p + 1 + n, cmp);
	rep(i, 1, n) {
		int x = p[i];
		f[x] = a[x];
		bsum[x] = b[x]; 
		vis[x] = 1;
		rep(j, 0, (int) g[x].size() - 1) {
			int v = g[x][j];
			if (vis[v]) {
				int y = find(v);
				if (x != y) {
//					cerr<<"   "<<y<<"\n";
					fa[y] = x;
					bsum[x] += bsum[y];
					f[x] = min(f[x], max(f[y], a[x] - bsum[y]) );
				}
			}
		}
//          cerr<<i<<" "<<x<<" "<<f[x]<<"\n";
	}
	cout << f[p[n]] + bsum[p[n]]<<"\n";
	return 0;
}


Measured memory_bytes: 10748
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int s, t;
  cin >> s >> t;
  if(t % s == 0) cout << s + t << "\n";
  else {
    cout << t - s << "\n";
  }
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
#include<ext/pb_ds/priority_queue.hpp>
using namespace std;

const int N = 3003;
typedef long long LL;
const LL mo = 1000000007;

int n,m,Ans;
LL f[N][N][2];

int main()
{
	#ifdef DMC
		freopen("DMC.txt","r",stdin);
	#endif
	
	cin >> n >> m; f[0][0][1] = 1;
	if (n == 1)
	{
		Ans = 2;
		for (int i = 1; i <= m; i++)
			Ans = Ans * 2 % mo;
		cout << Ans << endl; return 0;
	}
	for (int i = 1; i <= n; i++) f[0][i][0] = 1;
	for (int i = 1; i <= m; i++)
	{
		f[i][0][1] = (f[i - 1][0][1] + f[i - 1][1][0] + f[i - 1][1][1]) % mo;
		f[i][1][0] = (f[i - 1][1][0] + f[i - 1][2][0]) % mo;
		f[i][1][1] = (f[i - 1][0][1] + f[i - 1][1][0] + 2LL * f[i - 1][1][1] + f[i - 1][2][1]) % mo;
		f[i][n][0] = (f[i - 1][n - 1][0] + f[i - 1][n][0]) % mo;
		f[i][n][1] = (f[i - 1][n - 1][1] + f[i - 1][n][1]) % mo;
		for (int j = 2; j < n; j++)
		{
			f[i][j][0] = (f[i - 1][j - 1][0] + 2LL * f[i - 1][j][0] + f[i - 1][j + 1][0]) % mo;
			f[i][j][1] = (f[i - 1][j - 1][1] + 2LL * f[i - 1][j][1] + f[i - 1][j + 1][1]) % mo;
		}
	}
	for (int i = 0; i <= n; i++)
		Ans += f[m][i][1],Ans %= mo;
	cout << Ans << endl;
	return 0;
}

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

int main()
{
	int a[200],b[200],sum[200],keta[200],cnt=0,set=0;

	while( cin >> a[set] >> b[set]){
		set++;
	}

	for(int i=0;i<set;i++){
		sum[i]=a[i]+b[i];
		while(sum[i]!=0){
			sum[i]=sum[i]/10;
			cnt++;
		}
		cout << cnt << endl;
		cnt=0;
	}

	return 0;
}

Measured memory_bytes: 2996
'use strict'
const main = arg => {
	const input = arg.trim().split("\n");
	let W = Number(input[0].split(' ')[0])
	let a = Number(input[0].split(' ')[1])
	let b = Number(input[0].split(' ')[2])
	let dist = 0
	if(b <= a && b >= a + W) {
		console.log(0)
		return
	}
	if(b + W < a) {
		dist = a - (b + W)
	} else {
		dist = b - (a + W)
	}
	console.log(dist < 0 ? 0 : dist)

}   
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 22076
#include<iostream>
using namespace std;
bool center[200001];
bool flag=false;
int main(){
 int n,m;
cin>>n>>m;
	 int start,end;
	 for(int i=1;i<=m;i++){
		 
		 cin>>start>>end;
	 if(flag)
		 continue;
	 if(start==1){
		 if(center[end]){
		 flag=true;
		 }
		 else
		 center[end]=true;
	 }
	 else if(end==n){
		 if(center[start]){
		 flag=true;
		 }
		 else
			 center[start]=true;
	 }
 
	 
	 }
	 if(flag)
		 cout<<"POSSIBLE"<<endl;
	 else
		 cout<<"IMPOSSIBLE"<<endl;
	 
	 return 0;
}

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

const long long INF = 1e18;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> P(N), C(N);
	for (int i=0;i<N;i++) {
		cin >> P[i];
		P[i]--;
	}
	for (int i=0;i<N;i++) {
		cin >> C[i];
	}
	vector<int> val_len(N);
	vector<vector<long long>> val(N, vector<long long>());
	for (int i=0;i<N;i++) {
		int ind = P[i];
		long long sum_tmp = 0LL;
		long long sum_max_tmp = -INF;
		while (true) {
			sum_tmp += C[ind];
			sum_max_tmp = max(sum_max_tmp, sum_tmp);
			val[i].push_back(C[ind]);
			if (ind == i) break;
			ind = P[ind];
		}
	}

	for (int i=0;i<N;i++) {
		val_len[i] = val[i].size();
	}

	vector<vector<long long>> ruiseki_2(N, vector<long long>());
	vector<vector<long long>> ruiseki_max_2(N, vector<long long>());
	for (int i=0;i<N;i++) {
		int ind = P[i];
		long long sum_tmp = 0LL;
		long long sum_max_tmp = -INF;
		ruiseki_2[i].push_back(sum_tmp);
		ruiseki_max_2[i].push_back(sum_max_tmp);
		for (int j=0;j<2*val_len[i];j++) {
			sum_tmp += C[ind];
			sum_max_tmp = max(sum_max_tmp, sum_tmp);
			ruiseki_2[i].push_back(sum_tmp);
			ruiseki_max_2[i].push_back(sum_max_tmp);

			ind = P[ind];
		}
	}


	long long ans = -INF;
	for (int i=0;i<N;i++) {
		for (int j=1;j<=min(2*val_len[i], K);j++) {
			ans = max(ans, ruiseki_max_2[i][j]);
		}
		if (ruiseki_2[i][val_len[i]] > 0) {
			long long cnt = K/val_len[i];
			if (cnt > 0) {
				long long rui_tmp = (cnt-1)*ruiseki_2[i][val_len[i]];
				long long K_remainder = K-(cnt-1)*val_len[i];
				for (int j=0;j<=K_remainder;j++) {
					if (cnt == 1 && j == 0) continue;
					ans = max(ans, rui_tmp+ruiseki_max_2[i][j]);
				}
			}
		}
	}

	// for (int i=0;i<N;i++) {
	// 	cout << "i: " << i << endl;
	// 	for (auto v : ruiseki_max_2[i]) {
	// 		cout << v << " ";
	// 	}
	// 	cout << endl;
	// }
	cout << ans << endl;

}


Measured memory_bytes: 1019496
#include<iostream>
#include<string>
#include<set>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    set<char>a;
    cin>>s;
    for(int i=0; i<s.length(); i++)
    	a.insert(s[i]);
    (a.size()==s.length())?
    	cout<<"yes" : cout<<"no";
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 3005;
bool vis[MAX_N][MAX_N];
ll dp[MAX_N][MAX_N];
int A[MAX_N];

ll f(const int a, const int b, const int turn) {
  if (vis[a][b]) {
    return dp[a][b];
  }
  ll res = 0;
  if (a > b) {
    res = 0;
  } else if (turn == 0) { // maximize
    res = max(f(a+1, b, 1-turn) + A[a],
              f(a, b-1, 1-turn) + A[b]);
  } else { // minimize
    res = min(f(a+1, b, 1-turn) - A[a],
              f(a, b-1, 1-turn) - A[b]);
  }
  vis[a][b] = true;
  return dp[a][b] = res;
}

int main2() {
  CLR(vis, 0);
  int N = nextInt();
  REP(i, N) A[i] = nextInt();
  ll ans = f(0, N-1, 0);
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 79744
#include <stdio.h>
#include <stdlib.h>

int f(const void *a,const void *b){
  return *(int*)a-*(int*)b;
}

int main(){
  int H,N,A;
  scanf("%d %d",&H,&N);
  for(int i=1;i<=N;i++){
    scanf("%d",&A);
    H-=A;
    if(H<=0){
      printf("Yes\n");
      break;
    }  
  }
  if(H>0) printf("No\n");
  return 0;
}

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

int main(){
	int N; cin>>N;
	vector<int> A(N); rep(i, N) cin>>A[i];
	int64_t s = 0;
	int maxA = 0;
	rep(i, N) s += (maxA = max(maxA, A[i])) - A[i];
	cout<< s <<endl;
}


Measured memory_bytes: 3976
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) {
      a[i] = scanner.nextInt();
    }

    UnionFind uf = new UnionFind(N + 1);
    for (int i = 0; i < M; i++) {
      int x = scanner.nextInt();
      int y = scanner.nextInt();
      uf.union(x, y);
    }

    int count = 0;
    for (int i = 0; i < N; i++) {
      if (uf.find(i + 1) == uf.find(a[i])) count++;
    }
    System.out.println(count);
  }

  static class UnionFind {
    private final int[] table;
    private final int[] ranks;
    private final int[] sizes;

    public UnionFind(int size) {
      this.table = new int[size];
      this.ranks = new int[size];
      this.sizes = new int[size];
      for (int i = 0; i < size; i++) {
        table[i] = i;
        sizes[i] = 1;
      }
    }

    public int find(int x) {
      if (table[x] != x) {
        table[x] = find(table[x]);
      }
      return table[x];
    }

    public void union(int x, int y) {
      int xRoot = find(x);
      int yRoot = find(y);
      if (xRoot == yRoot) return;

      if (ranks[xRoot] < ranks[yRoot]) {
        int tmp = xRoot;
        xRoot = yRoot;
        yRoot = tmp;
      }

      table[yRoot] = xRoot;
      sizes[xRoot] += sizes[yRoot];
      if (ranks[xRoot] == ranks[yRoot]) ranks[xRoot]++;
    }
  }
}


Measured memory_bytes: 92000
//    .------------------------------------------------------------.
//    |   _  __   ___    ___    ___   _  _    ___     _     _  _   |
//    |  | |/ /  / _ \  |   \  |_ _| | \| |  / __|   /_\   | \| |  |
//    |  | ' <  | (_) | | |) |  | |  | .` | | (_ |  / _ \  | .` |  |
//    |  |_|\_\  \___/  |___/  |___| |_|\_|  \___| /_/ \_\ |_|\_|  |
//    |             ___    ___     _     _  _    ___               |
//    |            / _ \  | _ \   /_\   | \| |  / __|              |
//    |           | (_) | |   /  / _ \  | .` | | (_ |              |
//    |            \___/  |_|_\ /_/ \_\ |_|\_|  \___|              |
//    |                 ___   ___    ___    ___                    |
//    |                | _ ) | __|  / __|  / _ \                   |
//    |                | _ \ | _|  | (_ | | (_) |                  |
//    |                |___/ |___|  \___|  \___/                   |
//    |                                                            |
//    |------------------------------------------------------------|
//    |                      .------------.                        |
//    |                      | KerakTelor |                        |
//    |                      |------------|                        |
//    |                      | 2019-10-08 |                        |
//    |                      '------------'                        |
//    '------------------------------------------------------------'

#include <bits/stdc++.h>

#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("tune=native")

#define vec vector
#define prq priority_queue
#define fi first
#define se second

using namespace std;

using ll=long long;
using ld=long double;

//    .-----------------------------------------.
//    |        ___   _   _    ___   ___         | 
//    |       | _ ) | | | |  / __| / __|        | 
//    |       | _ \ | |_| | | (_ | \__ \        | 
//    |       |___/  \___/   \___| |___/        | 
//    |  ___   ___    ___    ___    _  _   ___  | 
//    | | _ ) | __|  / __|  / _ \  | \| | | __| |
//    | | _ \ | _|  | (_ | | (_) | | .` | | _|  | 
//    | |___/ |___|  \___|  \___/  |_|\_| |___| |
//    |                                         | 
//    '-----------------------------------------'

int main()
{
    int n;
    scanf("%d",&n);
    vec<int> x(n);
    for(auto &i:x)
        scanf("%d",&i);
    const ll inf=1e18;
    vec<ll> dp(n,inf);
    dp[0]=0;
    for(int i=1;i<n;++i)
        for(int j=1;j<3;++j)
            if(i>=j)
                dp[i]=min(dp[i],dp[i-j]+abs(x[i]-x[i-j]));
    printf("%lld\n",dp[n-1]);
}



Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
int main(){
	char S[100000];
	scanf("%s",S);

	int length = strlen(S);
	int K = strlen(S);
	
	for ( int i=0; i<length-1 ; i++ ) {
		if ( S[i+1] != S[i] ) {
			if( 2*(i+1) < length && length -(i+1) < K) {
				K = length - (i+1) ;
			} else if ( i+1<K ) {
				K = i+1;
			}
		}
	}
	printf("%d",K); 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
    int n;
	cin >> n;
	cout << n * n;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int N,M;
    cin >> N >> M;
    int a[100001] = {};
    for(int i=0;i<M;i++){
        cin >> a[i];
    }
    int dp[100001] = {1};
    
    bool broken[100001];
    for(int i=0;i<M;i++){
        broken[a[i]] = true;
    }
    
    if(broken[1] == true){
        dp[1] = 0;
    }else{
        dp[1] = 1;
    }
    for(int i=2;i<=N;i++){
        if(broken[i] == true){
            continue;
        }
        dp[i] = dp[i-1]+dp[i-2];
        dp[i] %= 1000000007;
        
    }
    
    cout << dp[N] << endl;
    return 0;
    
}


Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())
 
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll MAX=1e3+5;
 
int main(){
	int X,Y,Z,K;
	cin>>X>>Y>>Z>>K;
	vll A(X,0);
	vll B(Y,0);
	vll C(Z,0);
	
	rep(i,X)scanf("%lld",&A[i]);
	rep(i,Y)scanf("%lld",&B[i]);
	rep(i,Z)scanf("%lld",&C[i]);
	
//	sort(A.begin(),A.end(),greater<ll>);
//	sort(B.begin(),B.end(),greater<ll>);
//	sort(C.begin(),C.end(),greater<ll>);
	
	vll v1,v2;
	rep(i,X)rep(j,Y)v1.push_back(A[i]+B[j]);
	sort(v1.begin(),v1.end(),greater<ll>());
	int s=min(X*Y,K);
	rep(i,Z)rep(j,s)v2.push_back(C[i]+v1[j]);
	
	sort(v2.begin(),v2.end(),greater<ll>());
	rep(i,K)printf("%lld\n",v2[i]);
}

Measured memory_bytes: 43368