akhauriyash/Code-Regression huggingface dataset:
def partition(A, p, r):
    x = A[r-1]
    i = p-1

    for j in range(p,r-1):
        if A[j] <= x:
            i = i + 1
            A[i],A[j] = A[j],A[i]

    A[i+1],A[r-1] = A[r-1],A[i+1]

    print("{0} [{1}] {2}".format(" ".join(map(str,A[:i+1])),str(A[i+1])," ".join(map(str,A[i+2:]))))

    return



if __name__ == '__main__':
    cnt = int(input())
    A = list(map(int,input().split()))
    p = 0
    r = len(A)
    partition(A,p,r)

Measured memory_bytes: 19032
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t x){
	if(was_output)cout << " ";
	was_output = true;
	cout << x;
}

void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
	int a, b;
	cin >> a >> b;
	cout << max(0, a-b*2) << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;
int N,K;
int V[51];
int ans=0;
int ma=-1000000000;
int main(){
	cin >> N >> K;
	for(int i=1;i<=N;i++)cin >> V[i];
	int R = min(N,K);
	for(int i=0;i<=R;i++){
		for(int j=0;i+j<=R;j++){
			ans=0;
			priority_queue<int> q;
			for(int k=0;k<i;k++)q.push(-1*V[k+1]);
			for(int k=0;k<j;k++)q.push(-1*V[N-k]);
			int x=K-i-j;
			while(!q.empty()){
				if(x<=0 || q.top()<=0)break;
				x--;
				q.pop();
			}
			while(!q.empty()){
				ans=ans+(-1)*q.top();
				q.pop();
			}
			//printf("%d %d %d\n",i,j,ans);
			ma=max(ma,ans);
		}
	}
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
int main() {
  int N; cin>>N;
  int K; cin>>K;
  char S[N];
    for(int x=0; x<N ; x++){
      char a; cin>>a;
      S[x]= a;
    }
  S[K-1]+=32;
  for(int b=0; b<N ;b++){
    cout<< S[b];
  }
  return 0;
}

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

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    int nx = x2;
    int ny = y2;
    int dx = x2 - x1;
    int dy = y2 - y1;
    for(int i=0; i<2; i++){
        swap(dx, dy);
        dx = -dx;
        nx += dx;
        ny += dy;
        if(i == 0) cout << nx << " " << ny << " ";
        else cout << nx << " " << ny << endl;
    }
    return 0;
}

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

#define int long long
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
using namespace std;

const unsigned int M = 1e9 + 7;

int32_t main() {
	fastio;

	int n;
	cin >> n;
	vector<int> a(n);
	int mn = INT_MAX, mx = INT_MIN;
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		mn = min(mn, a[i]);
		mx = max(mx, a[i]);
	}
	int ans = INT_MAX;
	for(int i = mn; i <= mx; ++i) {
		int curr = 0;
		for(int j = 0; j < n; ++j) curr += (a[j] - i) * (a[j] - i);
		ans = min(ans, curr);
	}
	cout << ans;

	return 0;
}

/*
The point of meeting can only lie somewhere in between the houses of the attendees.
* So, we calculate the stamina spent for every point in the range and report the minimum stamina spent.
*/

/*
C - Rally / 
Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 
300
 points

Problem Statement
There are 
N
 people living on a number line.

The 
i
-th person lives at coordinate 
X
i
.

You are going to hold a meeting that all 
N
 people have to attend.

The meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate 
P
, the 
i
-th person will spend 
(
X
i
−
P
)
2
 points of stamina to attend the meeting.

Find the minimum total points of stamina the 
N
 people have to spend.

Constraints
All values in input are integers.
1
≤
N
≤
100
1
≤
X
i
≤
100
Input
Input is given from Standard Input in the following format:

N

X
1
 
X
2
 
.
.
.
 
X
N

Output
Print the minimum total stamina the 
N
 people have to spend.

Sample Input 1 
Copy
2
1 4
Sample Output 1 
Copy
5
Assume the meeting is held at coordinate 
2
. In this case, the first person will spend 
(
1
−
2
)
2
 points of stamina, and the second person will spend 
(
4
−
2
)
2
=
4
 points of stamina, for a total of 
5
 points of stamina. This is the minimum total stamina that the 
2
 people have to spend.

Note that you can hold the meeting only at an integer coordinate.

Sample Input 2 
Copy
7
14 14 2 13 56 2 37
Sample Output 2 
Copy
2354
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 2000005
using namespace std;
long long sz;
long long heap[MAX];

void init()
{
	sz = 0;
	memset(heap, 0, sizeof(heap));
}

void push(long long x)
{
	heap[++sz] = x;
	int i = sz;
	while (i > 1 && heap[i / 2] < heap[i]) {
		swap(heap[i / 2], heap[i]);
		i /= 2;
	}
}

long long pop()
{
	long long ret = heap[1];
	heap[1] = heap[sz--];
	int i = 1;
	while (1) {
		int a = 2 * i;
		int b = 2 * i + 1;
		int l = i;
		if (a <= sz && heap[a] > heap[l])
			l = a;
		if (b <= sz && heap[b] > heap[l])
			l = b;
		if (l == i) break;
		swap(heap[i], heap[l]);
		i = l;
	}
	return ret;
}

int main()
{
	string com;
	init();
	while (cin >> com && com != "end") {
		if (com[0] == 'i') {
			long long v;
			cin >> v;
			push(v);
		}
		else
			cout << pop() << endl;
	}
	return 0;
}


Measured memory_bytes: 18808
# include <iostream>

using namespace std;

void print_dir(int times, char direction){
  for (int i = 0; i < times; i++){
    cout << direction;
  }
}

int main(){
  int sx, sy, tx, ty;

  cin >> sx >> sy >> tx >> ty;

  // firt go R -> D
  print_dir(tx-sx, 'R');
  print_dir(ty-sy, 'U');

  // first come U <- L
  print_dir(tx-sx, 'L');
  print_dir(ty-sy, 'D');

  // second go D -> R
  cout << 'D';
  print_dir(tx-sx+1, 'R');
  print_dir(ty-sy+1, 'U');
  cout << 'L';

  // second come L <- U
  cout << 'U';
  print_dir(tx-sx+1, 'L');
  print_dir(ty-sy+1, 'D');
  cout << "R" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define rep (i, n) for (int i = 1; i <= n; i++)

using namespace std;

int main() {
	int a, b, k;
	cin >> k >> a >> b;
	
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			cout << "OK\n";
			return 0;
		}
	}
	
	cout << "NG\n";
	
	return 0;
}

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

using namespace std;

int main() {
	char c;	cin >> c;
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		cout << "vowel" << endl;
		return 0;
	}
	cout << "consonant" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int m1,m2,d1,d2;
  scanf("%d %d %d %d",&m1,&d1,&m2,&d2);
  
  if(m1!=m2){
    printf("%d",1);
  }else{
    printf("%d",0);
  }
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
typedef long long ll;

ll solve(ll N)
{
    if (N % 2 == 1)
        return 0;
    ll ans = 0;
    N /= 2;

    while (N)
    {
        ans += N / 5;
        N /= 5;
    }
    return ans;
}

int main()
{

    ll N;
    cin >> N;

    ll ans = solve(N);

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1

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

Node T[MAX];

void preorder(int u){
  if(u == NIL){
    return;
  }
  printf(" %d",u);
  preorder(T[u].l);
  preorder(T[u].r);
}

void inorder(int u){
  if(u == NIL){
    return;
  }
  inorder(T[u].l);
  printf(" %d",u);
  inorder(T[u].r);
}

void postorder(int u){
  if(u == NIL){
    return;
  }
  postorder(T[u].l);
  postorder(T[u].r);
  printf(" %d",u);
}

int main(){
  int n,l,r,id,root,i;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].p = T[i].r = T[i].l = NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d %d %d",&id,&l,&r);
    T[id].l = l;
    T[id].r = r;
    if(l != NIL)T[l].p = id;
    if(r != NIL)T[r].p = id;
  }

  for(i=0;i<n;i++){
    if(T[i].p == NIL){
      root = i;
    }
  }

  printf("Preorder\n");
  preorder(root);
  printf("\nInorder\n");
  inorder(root);
  printf("\nPostorder\n");
  postorder(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2052
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


S = input()
S = S[:-1]

while len(S) > 1:
    if len(S) % 2 == 1:
        S = S[:-1]
        continue

    if S[:len(S) // 2] == S[len(S) // 2:]:
        print(len(S))
        break
    else:
        S = S[:-1]


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,ans=100;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
int input;
scanf("%d",&input);
int u=0;
while(input%2==0&&input>1){
u++;
input/=2;
}
ans=min(ans,u);
}
printf("%d\n",ans);
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define test ll t; cin>>t; while(t--)
typedef long long int ll;
int main() {
    FIO;
    //test
    {
        ll n,i,n1,j=0,ans=0,x,y;
        cin>>n;
        n1=n;
        for(i=2;i<=sqrt(n1);i++){
            j=0;
            while(n%i==0){
                j++;
                n/=i;
            }
            x=1;
            while(j>0){
               j-=x;
               if(j>=0){
                   ans++;
               }
               x++;
            }
        }
        //cout<<n<<endl;
        if(n>1){
            ans++;
        }
        cout<<ans<<endl;
    }
	return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(int i = (int)(b); i < (int)(e); ++i)
#define RFOR(i, b, e) for(int i = (int)(e-1); i >= 0; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPP(x,y,c) for(const auto& [x,y]:(c))
#define VS vector<string>
#define VI vector<int>
#define VVI vector<vector<int>>
#define ALL(x) (x).begin(),(x).end()
#define PAIR pair<int,int>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;

using namespace std;

int main() {
	string str;
	cin >> str;

	int count = 0;
	REPC(c, str) {
		if (c == 'p') { ++count; }
	}
	cout << str.size()/2 - count << endl;

}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	int n;
	cin >> n;
	bool flag = true;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a % 2 == 0 && a % 3 != 0 && a % 5 != 0) {
			flag = false;
			break;
		}
	}
	if (flag) cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
	return 0;
}

Measured memory_bytes: 3568
n = int(input())
h = list(map(int,input().split()))

cnt = 0
grow = True
while grow:
    inc = False
    grow = False
    for i in range(n):
        if h[i] == 0:
            inc = False
        else:
            h[i] -= 1
            if not inc:
                inc = True
                grow = True
                cnt += 1
print(cnt)



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

int main() {
  string s;
  cin >>s;
  
  if(s[0]==s[1] && s[1]==s[2] && s[2]==s[3])
    cout << "No" << endl;
  else if(s[0]==s[2] && s[1]==s[3])
    cout << "Yes" << endl;
  else if(s[0]==s[3] && s[1]==s[2])
    cout << "Yes" << endl;
  else if(s[0]==s[1] && s[2]==s[3])
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  string s;
  
  string t;
  cin >> s >> t;
  int f = 0;
  for(int i = s.size()-1;i >= 0;i--){
    for(int j = 0;j <= t.size()-1;j++){
      if(s[i-t.size()+1+j] == t[j] || s[i-t.size()+1+j] == '?'){
	//cout << i-t.size()+1+j << endl;
      }
      else{
	
	break;
      }
      if(j == t.size()-1){
	f = 1;
	REP(k,t.size()){
	  s[i-t.size()+1+k] = t[k];
	}
	break;
      }
    }
    if(f == 1)
      break;
    
  }
  //cout << s << endl;
  if(f == 1){
    REP(i,s.size()){
      if(s[i] == '?'){
	s[i] = 'a';
      }
    }
    cout << s << endl;
  }
  else
    cout << "UNRESTORABLE" << endl;
  
  return 0;
}


Measured memory_bytes: 256
S = input()
weather_l = ['Sunny', 'Cloudy', 'Rainy']
for i, weather in enumerate(weather_l):
    next_i = 0
    if S == weather:
        if i == 2:
            next_i = 0
        else:
            next_i = i + 1
        print(weather_l[next_i])


Measured memory_bytes: 2940
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <bitset>

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

using namespace std;

int main() {
	int N, count = 1;
	scanf("%d", &N);
	vector<int> d(N);
	rep(i, N) scanf("%d", &d[i]);
	sort(d.begin(), d.end(), greater<int>());
	for (int i = 1; i < N; i++) {
		if (d[i - 1] > d[i]) {
			count++;
		}
	}
	printf("%d\n", count);
}




Measured memory_bytes: 3768
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long int
#define pair <ll, ll> pi
#define vector <ll> vi
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define SQ(a) (a) * (a)
#define ordered_set tree<ll, null_type, greater_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> //greater_equal<ll> or less<ll>
// find_by_key()   order_of_key()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}*/

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen('input.txt', 'r', stdin);
    //freopen('output.txt', 'w', stdout);
    ll i, j, k, n, m, b, d, t, ans = 0,x,y;
    cin>>n;
    ll a[n];
    ll dp[n]={0};
    cin>>a[0];
    dp[0]=a[0];
    rep(i,1,n-1){
        cin>>a[i];
        dp[i]=dp[i-1]+a[i];
    }
    ll sum=dp[n-1];
    ll max1=INT_MAX;
    rep(i,0,n-2){
        y=sum-dp[i];
       
        if(abs(dp[i]-y)<max1){
            max1=abs(dp[i]-y);
        }
    }
    cout<<max1<<endl;
    return 0;
}

Measured memory_bytes: 6684
#include <stdio.h>

int main() {
	int n, j, ans;
	int a[16666670*2] = {};
	long int k;

	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		scanf("%ld", &k);
		long int s = k / 30, t = k % 30;
		if ((a[s] & (0b1 << t)) == 0)
		{
			a[s] = a[s] | (0b1 << t);
			ans++;
		}
		else
		{
			a[s] = a[s] & ~(0b1 << t);
			ans--;
		}
	}

	printf("%d", ans);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ff(i,a,b) for(int i = a; i < b; i++)
#define fb(i,a,b) for(int i = a; i > b; i--)
#define MOD 1000000007


ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}


void solve(){
	int n;
	cin>>n;
	if(n>=400&&n<=599) cout<<8;
	if(n>=600&&n<=799) cout<<7;
	if(n>=800&&n<=999) cout<<6;
	if(n>=1000&&n<=1199) cout<<5;
	if(n>=1200&&n<=1399) cout<<4;
	if(n>=1400&&n<=1599) cout<<3;
	if(n>=1600&&n<=1799) cout<<2;
	if(n>=1800&&n<=1999) cout<<1;
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif

	//int t;
    //cin>>t;
	//while(t--)
		solve();
	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 3804
let s = readLine()!
let t = readLine()!

let sCount = s.count
let tCount = t.count

var answer = Int.max
var sIndex = s.startIndex
var tIndex = t.startIndex
var i = 0

while i < sCount-tCount+1 {
    var changeNeeded = 0
    var newSIndex = sIndex
    var newTIndex = tIndex
    var j = 0
    while j < tCount {
        if s[newSIndex] != t[newTIndex] {
            changeNeeded += 1
            if changeNeeded == answer {
                break
            }
        }
        j += 1
        newSIndex = s.index(after: newSIndex)
        newTIndex = t.index(after: newTIndex)
    }
    answer = min(answer, changeNeeded)
    i += 1
    sIndex = s.index(after: sIndex)
}
print(answer)


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

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if(a * c >= a * d && a * c >= b * c && a * c >= b * d ) {
    cout << a * c << endl;
  }
  else if(a * d >= a * c && a * d >= b * c && a * d >= b * d ) {
    cout << a * d << endl;
  }
  else if(b * c >= a * c && b * c >= a * c && b * c >= b * d ) {
    cout << b * c << endl;
  }
  else if(b * d >= a * c && b * d >= b * c && b * d >= a * d ) {
    cout << b * d << endl;
  }
  
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<string>
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<list>
using namespace std;

int main(){
	string s;
	cin >> s;
	for (int i = 0;i < s.size();i++) {
		if ((i + 1) % 2 == 1)cout << s[i];
	}
	cout << endl;
}


Measured memory_bytes: 512
n = gets.to_i

if n < 10
    puts (1000 - n.to_s.split("")[-1].to_i)
elsif n < 100
    puts (1000 - n.to_s.split("")[-2..-1].join("").to_i)
elsif n.to_s.split("")[-3..-1].join("").to_i == 0
    puts 0
else
  puts (1000 - n.to_s.split("")[-3..-1].join("").to_i)
end



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

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

    cin >> K;

    for (int i = 0; i < K; i++)
    {
        if (B <= A)
        {
            B = B * 2;
        }
        else if (C <= B)
        {
            C = C * 2;
        }
        else
        {
            break;
        }
    }

    if (C > B && B > A)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
    int l, r;
    cin >> l >> r;
    int a[2019] = {0};

    int tot = 0;
    for (int i=l; i<=r; i++) {
        if (tot == 2019) break;
        a[tot] = i % 2019;
        tot++;
    }

    int ans = 2020;
    for(int i=0; i<tot-1; i++) {
        for (int j=i+1; j<tot; j++) {
            ans = min(ans, (a[i]*a[j])%2019);
        }
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


ll n,a,b,c,d;
int main()
{
  finp;
  cin>>n>>a>>b>>c>>d;

  if(d == 0)
  {
  	if(a == b)
  	{
  		cout<<"YES";
  	}
  	else cout<<"NO";
  	return 0;
  }
  
  ll avl = n-2;//available moves to reach [b+c,b+d] or [b-d,b-c]
  bool f = false;
  afor(cmoves,-avl,avl)//net moves of c
  {
  	ll rem = avl - llabs(cmoves);//can use atmost this many d moves
  	ll curr = a + cmoves*c;

  	//case 1: [b+c,b+d]
  	if(curr < (b+c))
  	{
  		ll no = (b + c - curr)/d;
  		if((b + c - curr)%d)no++;

  		ll curr2 = curr + no*d;
  		if(no<=rem && (rem-no)%2==0 && curr2>=(b+c) && curr2<=(b+d))
  		{
  			f = true;
  			break;
  		}
  	}
  	else if(curr > (b+d))
  	{
  		ll no = (curr - (b + d))/d;
  		if((curr - (b + d))%d)no++;

  		ll curr2 = curr - no*d;
  		if(no<=rem && (rem-no)%2==0 && curr2>=(b+c) && curr2<=(b+d))
  		{
  			f = true;
  			break;
  		}
  	}
  	else if(rem%2==0)
  	{
  		f = true;
  		break;
  	}

  	//case 2: [b-d,b-c]

  	if(curr < (b-d))
  	{
  		ll no = (b - d - curr)/d;
  		if((b - d - curr)%d)no++;

  		ll curr2 = curr + no*d;
  		if(no<=rem && (rem-no)%2==0 && curr2>=(b-d) && curr2<=(b-c))
  		{
  			f = true;
  			break;
  		}
  	}
  	else if(curr > (b-c))
  	{
  		ll no = (curr - (b - c))/d;
  		if((curr - (b - c))%d)no++;

  		ll curr2 = curr - no*d;
  		if(no<=rem && (rem-no)%2==0 && curr2>=(b-d) && curr2<=(b-c))
  		{
  			f = true;
  			break;
  		}
  	}
  	else if(rem%2==0)
  	{
  		f = true;
  		break;
  	}

  }
  
  if(!f)cout<<"NO";
  else cout<<"YES";
return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <cstdio>
using namespace std;
typedef long long ll;

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

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

int main(){
    ll a,b,c,d,e,k,l,m,n,o=0,p,q,r,x,y,z,max1=0,ans=0;
    string s,t,u;
    cin>>n;
    
    for(ll i=1;i<10;i++){
     if(n%i==0&&n/i<10&&n/i>0)o++;   
    }
    if(o==0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    
}






Measured memory_bytes: 256
n= int(input())
l= list(map(int,input().split()))
a=0
b=0
ans=float("Inf")
for i in range(n+1):
   a=sum(l[:i])
   b=sum(l[i:])
   ans=min(ans,max(a,b)-min(a,b))
print(ans)

Measured memory_bytes: 3064
N,M = map(int,input().split())
list = []
count = 0
ans = 0
for i in range(N):
    A,B=input().split()
    list.append((int(A), int(B)))
list.sort()
#print(list)
#while(count <=  M ):
for i in range(N):
    count+=list[i][1]
    if count <= M:
        ans += list[i][0] * list[i][1]
    else:
        ans += list[i][0] * (M - (count -list[i][1]))
        break
print(ans)

Measured memory_bytes: 16984
k = int(input())

if k==0:
    print(2)
    print("0 0")

elif k ==1:
    print(2)
    print("2 0")

elif k <=50:
    print(k)
    print((str(k)+" ")*(k-1)+str(k))
    
else:
    l = k // 50
    m = k % 50
    print(50)
    print((str(50+l)+" ")*m+(str(49+l-m)+" ")*(49-m)+str(49+l-m))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int r;
int main () {
	cin >> r;
	if (0 <= r && r < 1200) {
		cout << "ABC";
	} else if (1200 <= r && r < 2800) {
		cout << "ARC";
	} else {
		cout << "AGC";
	}

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int a,b;
		cin>>a>>b;
		for(int i =1;i<=100000;i++){
			int x = floor(0.08*(double)(i));
			int y = floor(0.1*(double)(i));
			if(x==a && y==b){
				return cout << i,0;
			}
		}
		cout <<"-1";
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <utility>
#include <queue>
#include <string>

using namespace std;

int main(){
    for (; ;) {
        int N ,M;
        cin >> N >> M;
        if (N==0 && M==0) break;
        vector<pair<int,int> > E(N);
        int ans=0;
        for (int i=0; i<N; i++) {
            int D,P;
            cin >> D >> P;
            E[i].first =P;
            E[i].second = D;
            ans+=D*P;
        }
        sort(E.begin(),E.end());
        for (int i=0;i<N;i++) {
            if (M>E[N-i-1].second) {
                ans -= E[N-i-1].first*E[N-i-1].second;
                M-=E[N-i-1].second;
            }else{
                ans -= M*E[N-i-1].first;
                break;
            }
        }
        cout << ans << endl;
    }
}

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

const int mnx = 3e5 + 9;
const int mod = 1e9 + 7;

map<ll, ll> q;
ll sum[mnx];
ll ans, n, a;

int main() {

cin >> n;

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

ans += q[0];

for(int i=1; i<=n; i++) {
    int tmp = q[sum[i]] - 1;
    if(tmp >= 0) {
        ans += tmp;
        q[sum[i]]--;
    }
}

cout << ans << '\n';


return 0;

}


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

int main() {

  int N, K, X;
  cin >> N >> K;
  X = K;
  
  long long ans = 0;
  
  for(int i = 0; i < N; i++) {    
    ans++;
    if(N < X) {
      cout << ans << endl;
      break;
    }
    else X = X * K;
  }
  
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;


long long P[51];
long long S[51];


long long func( long long l, long long k ) {
    if ( l == 0 ) { return 1; }
    if ( k <= 1 ) { return 0; }

    long long s = S[l];
    long long p = P[l];
    
    if ( s == k ) { return p; }

    if ( (s+1)/2 == k ) { return P[l-1]+1; }
    else if ( (s+1)/2 > k ) { return func(l-1, k-1); }
    else if ( (s+1)/2 < k ) { return P[l-1]+1+func(l-1,k-(2+S[l-1]) ); }
}


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

    P[0] = S[0] = 1;
    for ( int i = 1; i <= 50; i++ ) {
        P[i] = P[i-1]*2+1;
        S[i] = S[i-1]*2+3;
    }
    
    cout << func( N, X ) << endl;

    return 0;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_vec::<usize>()[0];
    let mut a = read_as_vec::<u64>();
    a.dedup();
    let n = a.len();

    if n < 3{
        println!("1");
        return;
    }

    let mut i:usize = 0;
    let mut ans = 0;

    while i < n-1{
        let tmp = i;
        while i < n-1 && a[i] < a[i+1]{
            i += 1;
        }
        if tmp < i{
            ans += 1;
            i += 1;
        }
        let tmp = i;
        if i == n - 1 && a[n-2] > a[n-1]{
            ans += 1;
        }
        while i < n-1 && a[i] > a[i+1]{
            i += 1;
        }
        if tmp < i{
            ans += 1;
            i += 1;
        }
        if i == n - 1 && a[n-2] < a[n-1]{
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll n; cin >> n;
    vector<ll> d(200000);
    for(ll i=0; i<n; i++) cin >> d[i];
    map<ll, ll> mp;
    ll m; cin >> m;
    vector<ll> t(200000);
    for(ll i=0; i<m; i++){
        cin >> t[i];
        if(mp.count(t[i])){
            mp[t[i]]++;
        }else{
            mp[t[i]] = 1;
        }
    }
    for(ll i=0; i<n; i++){
        if(mp.count(d[i])){
            mp[d[i]]--;
            if(mp[d[i]]==0){
                mp.erase(d[i]);
            }
        }
    }
    if(mp.size()==0) cout << "YES" << endl;
    else             cout << "NO"  << endl;
    return 0;
}

Measured memory_bytes: 18736
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    ll n ; cin >> n;
    vector<ll> a(n,0);
    rep(i,n){
        rep(j,10){
            bool x ; cin >> x;
            if(x) a.at(i) += pow(2,j);            
        }
    }
    vector<vector<ll>> rev(n,vector<ll>(11));
    rep(i,n) rep(j,11) cin >> rev.at(i).at(j);
    ll ans = -INF;
    for(int i=1;i<(1<<10);i++){
        ll anskouho = 0;
        for(int j=0;j<n;j++){
            ll z = (i&a.at(j));
            bitset<10> bz(z);
            ll cnt = bz.count();
            anskouho += rev.at(j).at(cnt);
        }                        
        ans = max(ans,anskouho);
      //cout << ans << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n= input().split()
x = [input().split() for i in range(2)]
sum = 0
for i in range(int(n[0])):
    if int(x[0][i]) > int(x[1][i]):
        a = (int(x[0][i]) - int(x[1][i]))
        sum += a
print(sum)

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

const int mxN = 1e5 + 2;
int n, m;
long long dp[mxN], ans[mxN], coef[mxN];
vector<int> adj[mxN], children[mxN];
vector<long long> prefix[mxN], suffix[mxN];
//map<int, int> mp1, mp2;

void dfs(int node, int p)
{
    long long ways = 1;

    vector<int> vals;
    for (auto& v : adj[node])
    {
        if (v == p)
            continue;
        dfs(v, node);

        children[node].push_back(v);

        ways *= (1 + dp[v]);
        vals.push_back(1 + dp[v]);
        ways %= m;
    }
    prefix[node].resize(vals.size() + 1);
    suffix[node].resize(vals.size() + 1);
    prefix[node][0] = suffix[node][0] = 1;
    for (int i = 1; i < prefix[node].size(); i++)
    {
        prefix[node][i] = prefix[node][i - 1] * vals[i - 1];
        prefix[node][i] %= m;
    }
    // cout << "node: " << node << ". prefix" << endl;
    // for (auto& num : prefix[node])
    // {
    //     cout << num << " ";
    // }
    // cout << endl;
    for (int i = 1; i < suffix[node].size(); i++)
    {
        suffix[node][i] = suffix[node][i - 1] * vals[vals.size() - i];
        suffix[node][i] %= m;
    }
    // cout << "node: " << node << ". suffix" << endl;
    // for (auto& num : suffix[node])
    // {
    //     cout << num << " ";
    // }
    // cout << endl;

    dp[node] = ways;
    // cout << "node: " << node << ". dp: " << ways << endl;
}

void dfs2(int node, int p, int index)
{
    ans[node] = dp[node];

    coef[node] = 1;
    if (p != -1)
    {
        coef[node] = coef[p];
        // for (auto& ch : children[p])
        // {
        //     if (ch == node)
        //         continue;
        //     coef[node] *= (dp[ch] + 1);
        //     coef[node] %= m;
        // }
        // cout << "node: " << node << ". mp1: " << mp1[node] << ". mp2: " << mp2[node] << endl;

        coef[node] *= prefix[p][index];
        coef[node] %= m;
        coef[node] *= suffix[p][children[p].size() - index - 1];
        coef[node] %= m;

        coef[node] += 1;
        coef[node] %= m;
    }
    // cout << "node: " << node << ". coef: " << coef[node] << endl;
    ans[node] *= coef[node];
    ans[node] %= m;

    int i = 0;
    for (auto& v : adj[node])
    {
        if (v == p)
            continue;
        dfs2(v, node, i);
        i++;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for (int i = 0; i < n - 1; i++)
    {
        int x, y;
        cin >> x >> y;
        x--; y--;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    dfs(0, -1);
    dfs2(0, -1, 0);
    for (int i = 0; i < n; i++)
        cout << ans[i] << endl;
}

Measured memory_bytes: 37440
import java.lang.ArithmeticException

fun main() {
    val n = readLine()!!.toInt()
    val an = readLine()!!.split(" ").map(String::toLong)

    if (an.contains(0L)) {
        println(0)
        return
    }

    var result = 1L
    for (a in an) {
        try {
            result = Math.multiplyExact(result, a)

            if(1000000000000000000 < result){
                println(-1)
                return
            }
        } catch (e: ArithmeticException) {
            println(-1)
            return
        }

    }
    println(result)
}





Measured memory_bytes: 63196
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	string ss;
	cin >> ss;
	cin >> ss;
	cout << 'A' << ss[0] << 'C' << endl;
	return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=502;
int n,ar[N][N],lis[1006],dx[]={0,0,-1,1},dy[]={-1,1,0,0},ar1[N][N];
bool check(int x,int y){
  if(x>0&&x<=n){
    if(y>0&&y<=n){
      return true;
    }
  }
  return false;
}
bool check1(int x){
    int i;
    for(i=2;i*i<=x;i++){
     if(x%i==0){
         return false;
     }
    }
    return true;
}
int LCM(int x,int y){
  return (x/__gcd(x,y)) * y;
}
signed main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int i,j,k,l,num=0,hichic=0;
  cin>>n;
  if(n==2){
    cout<<"4 7\n23 10";
    return 0;
  }
  for(i=2;i<=10000;i++){
    //cout<<i<<endl;
        if(check1(i)){
        num++;
         lis[num]=i;
      //cout<<num<<' '<<i<<endl;
          if(num==1002){
        //cout<<num<<' '<<"cac"<<endl;
                break;
            }
        }
    }
    //cout<<num<<endl;
    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
        if(!((i+j)&1)){
          continue;
        }
        if(i-1&&j-1){
          ar[i][j]=ar[i-1][j-1];
        }
        else{
          hichic++;
          ar[i][j]=lis[hichic];
        }
      }
    }
    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
        if(!((i+j)&1)){
          continue;
        }
        if(i-1&&j+1<=n){
    		ar1[i][j]=ar1[i-1][j+1];
          	ar[i][j]*=ar1[i][j];
        }
        else{
          hichic++;
          ar[i][j]*=lis[hichic];
          ar1[i][j]=lis[hichic];
        }
      }
    }
    //cout<<"cac"<<endl;
    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
        if(!((i+j)&1)){
          ar[i][j]=1;
          for(l=0;l<4;l++){
            if(check(i+dx[l],j+dy[l])){
              ar[i][j]=LCM(ar[i][j],ar[i+dx[l]][j+dy[l]]);
            }
          }
          cout<<ar[i][j]+1<<' ';
        }
        else{
            cout<<ar[i][j]<<' ';
        }
      }
      cout<<'\n';
    }
}

Measured memory_bytes: 7040
#include <stdio.h>

void find3(int n);
 
int main(void) {
    int n;
     
    scanf("%d",&n);
    find3(n);
    
    printf("\n");
    return 0;
}

void find3(int n){
	int i;
	
	for(i=1;i<=n;i++){
        if(i % 3 == 0)
        	printf(" %d",i);
        else if (i % 10 == 3)
        	printf(" %d",i);
        else if (i % 100 == 3)
        	printf(" %d",i);
        else if (i % 1000 == 3)
        	printf(" %d",i);
        else if (i / 10 == 3)
        	printf(" %d",i);
        else if (i / 100 == 3)
        	printf(" %d",i);
        else if (i / 1000 == 3)
        	printf(" %d",i);
        else if (i % 1000 / 100 == 3)
        	printf(" %d",i);
        else if (i % 1000 % 100 / 10 == 3)
        	printf(" %d",i);
        else{}
        
    }
}

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

int main() {
  int n,k,t,a;
  cin >> n >> t >> a;
  vector<int> h(n),H(n);
  for(int i=0;i<n;i++){
    cin >> h.at(i);
    k = t*1000 - h.at(i)*6;
    h.at(i) = max(a*1000 -k,k- a*1000);
    H.at(i) = h.at(i);
  }
  sort(h.begin(),h.end());
  
  for(int i=0;i<n;i++){
    if(h.at(0) == H.at(i)){
      cout << i+1 << endl;
      break;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
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 (b<a) { a=b; return 1; } return 0; }

int main(){
  int n,k;
  cin >> n >> k;
  int r,s,p;
  cin >> r >> s >> p;
  char t[n];
  rep(i,n)cin >> t[i];
  ll ans = 0;
  int r_time =0;
  int s_time =0;
  int p_time = 0;
  vector<bool> v(n,'0');
  rep(i,n){
    if(i-k>=0){
      if(t[i-k]==t[i])v[i]=1-v[i-k];
      if(v[i]==0)continue;
      else{
        if(t[i]=='r')ans += p;
        else if(t[i]=='s') ans+=r;
        else ans += s;
      }
    }else{
      if(t[i]=='r')ans += p;
      else if(t[i]=='s') ans+=r;
      else ans += s;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

typedef long long int ll;
#define inf 0x3f3f3f3f
#define endl '\n'
// #define case(i) "Case #" << i << ": "

int dp[100001][4];
int a[100001][4];
int n;

int solve(int i, int f) {
    if(i == n) return 0;
    else if(i == 0) {
        int mx = -inf;
        for(int j = 0; j < 3; ++j) {
            mx = max(a[i][j] + solve(i+1, j), mx);
        }
        return mx;
    }
    else {
        if(dp[i][f] != -1) return dp[i][f];
        int mx = -inf;
        for(int j = 0; j < 3; ++j) {
            if(j != f) mx = max(a[i][j] + solve(i+1, j), mx);
        }
        dp[i][f] = mx;
        return mx;
    }
}


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

    cin >> n;
    memset(dp, -1, sizeof(dp));
    
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < 3; ++j) {
            cin >> a[i][j];
        }
    }

    cout << solve(0, -1) << endl;    
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pll pair<long long, long long>
#define f first
#define s second
#define debug cout<<"here\n" 
#define MOD 1000000009

const int MAXN = 2e5 +15;
 
using namespace std;

ll A[MAXN];

void solve(){    
    int n; cin>>n;
    for(int i=0; i<n; i++) cin>>A[i];
    ll s=0;
    for(int i=1; i<n; i++){
        if(A[i] <A[i-1]){
            s += A[i-1] -A[i];
            A[i] = A[i-1];
        }
    }
    cout<<s;
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cout.tie(0); cin.tie(0);    
    cout<<fixed<<setprecision(12);

    int t =1; //cin>>t;
    for(int i=1; i<= t; i++){
        solve();
        cout<<"\n";
    }
    
    return 0;
}       

Measured memory_bytes: 5188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define vpli vector<pair<long long,int>>
#define deb(x) cout<<x<<endl;
#define all(x) x.begin(),x.end()
ll MOD = 1e9+7;


void solve()
{
    int a,b;
    cin>>a>>b;
    if(b>=2*a && b<=4*a && b%2==0)
        cout<<"Yes";
    else
        cout<<"No";
    
}

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

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(ll i=1;i<=n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 1000000007
#define mod 998244353
#define sec setprecision
#define Pair pair<ll,ll>
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using namespace std;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow((x * x)%mod , n / 2)%mod);
	else
		return (x * pow(x, n - 1))%mod;
}
int main() {
	rip(i, 365) {
		if (i % 26 == 0)cout << 26 << endl;
		else cout << i % 26 << endl;
	}
}

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


int main()
{
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif

	ll x;
	cin>>x;

	cout<<((x/500)*1000 + ((x%500)/5)*5);

	return 0;
} 

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

std::string c1, c2, c3;

int main()
{
	in >> c1 >> c2 >> c3;
	out << c1[0] << c2[1] << c3[2] << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define mod 1000000007LL
#define eps 0.0001

#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------

    int w,a,b;
    cin >> w >> a >> b ;
    int a2 = a + w;
    int b2 = b + w;

    if (a > b && a < b2 ){
        pri(0) ;
    return 0;
    }
    if (a2 > b && a2 < b2 ){
        pri(0) ;
    return 0;
    }
    pri(min(min(abs(a-b),abs(a-b2)) ,min(abs(a2-b),abs(a2-b2))));

    return 0;
}



Measured memory_bytes: 256
import sys
import math
N,M,X,Y=map(int,input().split())
V=list(map(int,input().split()))
W=list(map(int,input().split()))
V.sort()
W.sort()
ju=V[N-1]
ans=W[0]
if(ju<ans):
  if(X<ju and ju<ans and ans<=Y):
    print('No War')
  else:
    print('War')
else:
  print('War')

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

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 1e5 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e9 + 7;
const ll infll = 1e18 + 7;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int x; cin >> x;
    int t = 100, ans = 0;
    while (t < x){
        ans++;
        t += t / 100;
    }
    cout << ans;
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 3652