akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:102400000,102400000")
#include<iostream>  
#include<cstdio>  
#include<fstream>  
#include<iomanip>
#include<algorithm>  
#include<cmath>  
#include<deque>  
#include<vector>  
#include<assert.h>
#include<bitset>
#include<queue>  
#include<string>  
#include<cstring>  
#include<map>  
#include<stack>  
#include<set>
#include<functional>
#define pii pair<int, int>
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define eps 0.00000001
#define mst(a,i) memset(a,i,sizeof(a))
#define all(n) n.begin(),n.end()
#define lson(x) ((x<<1))  
#define rson(x) ((x<<1)|1) 
#define inf 0x3f3f3f3f
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int maxn = 1e4 + 5;
pii a[maxn];
int dp[maxn][2];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int i, j, k, m, n, T;
	cin >> k >> m >> n;
	int sum = k * 100 + m * 10 + n;
	if (sum % 4 == 0)
		cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

int main(){
    int k,x;
    cin >> k >> x;
    for(int i = x-k+1; i < x+k;i++) cout << i << " ";
    cout << endl;
    return 0;
}

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

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int lis = 0;
  int res = 1;
  int n;

  scanf ( "%d", &n );
  while ( n-- )
  {
    char ch;
    int c;

    scanf ( " %c %d", &ch, &c );
    if ( ch == '(' )
      lis += c;
    else
      lis -= c;

    res = res && ( lis >= 0 );
  }
  
  puts ( res && lis == 0 ? "YES" : "NO" );

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}
 
#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;

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

	int n, t;
	cin >> n >> t;
	vector<vector<int>> pref(n, vector<int>(t + 1));
	auto suff = pref;
	vector<PII> items(n);
	REP(i, n) cin >> items[i].ST >> items[i].ND;
	REP(i, n) {
		if(i) pref[i] = pref[i - 1];
		for(int j = t; j >= items[i].ST; j--)
			pref[i][j] = max(pref[i][j], pref[i][j - items[i].ST] + items[i].ND);
	}
	for(int i = n - 1; i >= 0; i--) {
		if(i != n - 1) suff[i] = suff[i + 1];
		for(int j = t; j >= items[i].ST; j--)
			suff[i][j] = max(suff[i][j], suff[i][j - items[i].ST] + items[i].ND);
	}

	int ans = pref[n - 1][t];
	REP(i, n) {
		if(i == 0) ans = max(ans, items[i].ND + suff[1][t - 1]);	
		else if(i == n - 1) ans = max(ans, items[i].ND + pref[n - 2][t - 1]);
		else {
			FOR(j, 0, t - 1)
				ans = max(ans, items[i].ND + pref[i - 1][j] + suff[i + 1][t - 1 - j]);
		}
	}

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


Measured memory_bytes: 70784
N, T = [int(x) for x in input().split()]
t = [int(x) for x in input().split()]
sum = 0
current = 0

for tt in t:
  if current <= tt:
    current = tt+T
    sum += T
  else:
    diff = current - tt
    current = tt+T
    sum += T - diff
print(sum)


Measured memory_bytes: 25196
from scipy.sparse import*
(n,m,s,*D),*t=[map(int,t.split())for t in open(0)]
R,C=[],[]
for u,v,a,b in t[:m]:
    for i in range(2501-a):
        R+=(i+a)*51+u,(i+a)*51+v
        C+=i*51+v,i*51+u
        D+=b,b
for i,(c,d)in enumerate(t[m:],1):
    for j in range(2501-c):
        R+=j*51+i,
        C+=(j+c)*51+i,
        D+=d,
d=csgraph.dijkstra(csr_matrix((D,(R,C)),[8**6]*2),1,min(2500,s)*51+1)
for i in range(2,n+1):print(int(min(d[i::51])))

Measured memory_bytes: 122848
gcd(a,b){return b?gcd(b,a%b):a;}
main()
{
	int K;
	scanf("%*d%d",&K);
	int M=0,G=0,A;
	for(;~scanf("%d",&A);G=gcd(G,A))if(M<A)M=A;
	puts(M<K||K%G?"IMPOSSIBLE":"POSSIBLE");
}


Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			string s = cin.Next();
			int m = s.Length;
			char[] ss = new char[m];
			for (int i = 0; i < m; i++) {
				int temp = s[i] - 'A';
				temp = (temp + n) % 26;
				ss[i] = (char)(temp + 'A');
			}

			Console.WriteLine(new string(ss));
		}
	}


	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

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

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

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

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 11192
b = list(reversed(list(input())))

MOD = 10 ** 9 + 7

n = len(b)

if n == 1:
    print(3)
    exit()

dp = [0] * n

dp[n-1] = 2
for i in range(n-2, -1, -1):
    if b[i] == '1':
        dp[i] = ( dp[i+1] * 2 ) % MOD
    else:
        dp[i] = dp[i+1]

dp.append(1)

#print(dp)

ans = dp[0]
x = 1

for i in range(n):
    if b[i] == '1':
        ans += x * dp[i+1]
        ans %= MOD
    x = (x * 3) % MOD

print(ans)



Measured memory_bytes: 50416
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int amari=0;
  long long ans=0;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    ans+=(a+amari)/2;
    if(a==0)
      amari=0;
    else
      amari=(a+amari)%2;
    //cout<<ans<<" "<<amari<<endl;
  }
  cout<<ans<<endl;
  return 0;
}


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

string s, t, u;

int main(void)
{
	int a, b;

	cin >> s >> t >> a >> b >> u;

	if (s == u)
		cout << a - 1 << " " << b;
	else
		cout << a << " " << b - 1;
	return 0;
}

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

const int K = 10000;

void counting_sort(int n, int A[], int B[]) {
  int i, accum;
  int C[K+1] = {};

  for (i = 1; i < n+1; i++) C[A[i]]++;
  accum = 0;
  for (i = 0; i < K+1; i++) {
    accum += C[i];
    C[i] = accum;
  }

  for (i = n; i > 0; i--) {
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }
}  

int main() {
  int i, n;
  int *A, *B;
  // int A[N+1], B[N+1];
  
  cin >> n;
  A = new int[n+1];
  B = new int[n+1];

  for (i = 1; i < n+1; i++) cin >> A[i];

  counting_sort(n, A, B);

  for (i = 1; i <= n ; i++) {
    if (i > 1) cout << " ";
    cout << B[i];
  }
  cout << endl;

  delete[] A;
  delete[] B;

  return 0;
}


Measured memory_bytes: 18340
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <list>
#include <cmath>
#include <stack>
#include <queue>

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

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int main()
{
	string s, t;
	cin >> s >> t;
	cout << t << s;
}


Measured memory_bytes: 31488
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto N = readln.chomp.to!int;
    int c;
    foreach (i, a; readln.split.to!(int[])) if (i%2 == 0 && a%2 == 1) ++c;
    writeln(c);
}

Measured memory_bytes: 2688
import math
import numpy as np


def main():
    N = int(input())

    M = [N // 10 ** i for i in range(5 + 1)]

    mat = [[0 for _ in range(10)] for _ in range(10)]

    for i in range(1, 10):
        for j in range(1, 10):

            for k in range(6 + 1):
                if k == 0:  # 1
                    if i == j and N >= i:
                        mat[i][j] += 1

                else:  # 1x2 max=192 min=102
                    max_ = (i + 1) * 10 ** k - 10 + j
                    min_ = i * 10 ** k + j

                    if N >= max_:
                        mat[i][j] += 10 ** (k - 1)
                        continue
                    elif N < min_:
                        continue
                    else:
                        mat[i][j] += (N - min_) // 10 + 1
                        continue

    # print(np.array(mat))

    ans = 0

    for i in range(1, 10):
        for j in range(1, 10):
            ans += mat[i][j] * mat[j][i]

    print(ans)


if __name__ == '__main__':
    main()


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

int d1[550], d2[550];
int main() {
	int n, m;
	while (scanf("%d%d", &n, &m), n) {
		map<string, int>mp;
		vector<P>E[550];
		string s, p, g; cin >> s >> p >> g;
		mp[s] = 0; mp[p] = 1; mp[g] = 2;
		rep(i, m) {
			string a, b; int d, t; cin >> a >> b >> d >> t;
			if (mp.find(a) == mp.end())mp[a] = mp.size();
			if (mp.find(b) == mp.end())mp[b] = mp.size();
			E[mp[a]].push_back(P(d / 40 + t, mp[b]));
			E[mp[b]].push_back(P(d / 40 + t, mp[a]));
		}
		priority_queue<P, vector<P>, greater<P>>que;
		memset(d1, 0x3f, sizeof(d1));
		d1[0] = 0; que.push(P(0, 0));
		while (!que.empty()) {
			P p = que.top(); que.pop();
			if (d1[p.second] != p.first)continue;
			for (P u : E[p.second]) {
				if (d1[u.second] > p.first + u.first) {
					d1[u.second] = p.first + u.first;
					que.push(P(d1[u.second], u.second));
				}
			}
		}
		memset(d2, 0x3f, sizeof(d2));
		d2[1] = 0; que.push(P(0, 1));
		while (!que.empty()) {
			P p = que.top(); que.pop();
			if (d2[p.second] != p.first)continue;
			for (P u : E[p.second]) {
				if (d2[u.second] > p.first + u.first) {
					d2[u.second] = p.first + u.first;
					que.push(P(d2[u.second], u.second));
				}
			}
		}
		printf("%d\n", d1[1] + d2[2]);
	}
}

Measured memory_bytes: 3400
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;

#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define itn int
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

#define NMAX 2000001
#define VMAX 10000
ll A[NMAX], C[VMAX + 1], B[NMAX];

signed main() {
	int n;
	cin >> n;
	int i;
	rep(i, VMAX) C[i] = 0;
	rep(i, n) {
		cin >> A[i + 1];
		C[A[i+1]]++;
	}
	rep(i, VMAX) C[i + 1] = C[i + 1] + C[i];
	FOR(i, 1, n + 1) {
		B[C[A[i]]] = A[i];
		C[A[i]]--;
	}
	rep(i, n) {
		if (i) cout << " ";
		cout << B[i + 1];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 34440
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
    int a,b;
    cin >> a >> b;
    if(a+b == 15){
        P("+");
    }else if(a*b == 15){
        P("*");
    }else{
        P("x");
    }
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,h,m;
  cin>>a>>b>>h>>m;
  double S=30*h+0.5*m;
  double L=6*m;
  double ran1=abs(S-L);
  double ran2=360-ran1;
  double degree=min(ran1,ran2);
  double pi, unit;
  pi     = 2.0 * asin(1.0);
  unit   = pi / 180.0;
  double radian = degree*unit;
  double c=cos(radian);
  double ans=sqrt(a*a+b*b-2*a*b*c);
  cout << fixed << setprecision(15) << ans << endl;
  return 0;
}

Measured memory_bytes: 4224
#include <stdio.h>

int main(){
	
	int n;
	int i=0;
	int flag=0;
	int counter=0;
	int A[200];
	
	scanf("%d", &n);
	
    for( i=0 ; i<n ; i++ ){
		scanf("%d", &A[i]);
	}
	
	while(1){
		
		for( i=0 ; i<n ; i++ ){
			
			if( (A[i] % 2) == 1 ){
				flag++;
				break;
			}
			
			A[i] = A[i] / 2;
			
		}
		
		if( flag == 1 ){
			break;
		}
		
		counter++;
		
	}
	
	printf("%d", counter);
		
	return 0;
	
}

Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>
#include<math.h>
  
using namespace std;
   
void Solution()
{
    int n, m;
    int a[100][100] = {{0}};
    int b[100] = {0};
    int sum = 0;
    
    cin>>n>>m;
    
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            cin>>a[i][j];
        }

    }
    
    for(int i = 0; i < m; i++)
    {
        cin>>b[i];
    }
    
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
             sum += b[j] * a[i][j];
        }
        
        cout<<sum<<endl;
        sum = 0;
        
    }
        
}
  
int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1208
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	int N; cin >> N;
	int data[N]; 
	F0R(i, N) cin >> data[i];
	
	int start = 0;
	
	int ans = 0;
	FOR(i, 1, N) {
		if (data[i] > data[i-1]) start = i;
		ans = max(ans, i-start);
	}
	cout << ans << endl;
	
	return 0;
}
 



Measured memory_bytes: 640
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> v;
	int a, b;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		v.emplace_back(a, b);
	}
	bool ans = false;
	bool point[200001] = { false };
	for (int i = 0; i < 200001; i++) {
		point[i] = false;
	}
	for (int i = 0; i < m; i++) {
		if (v[i].first == 1)point[v[i].second] = true;
	}
	for (int i = 0; i < m; i++) {
		if (v[i].second == n) {
			if (point[v[i].first])ans = true;
		}
	}
	cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

Measured memory_bytes: 2420
import copy
def main():
    n, a, b, c, d = map(int, input().split())
    step = list(input())

    sn = a - 1
    fn = b - 1

    sn_goal = False
    fn_goal = False
    jump = -1
    
    while True:
        if d < c:
            if (step[fn - 1] == ".") and (step[fn + 1] == "."):
                jump = copy.deepcopy(fn)

        if fn == d - 1:
            fn_goal = True
            break

        if step[fn + 1] == ".":
            fn += 1
        elif step[fn + 2] == ".":
            fn += 2
        else:
            break

    if d < c:
        if jump == -1:
            print("No")
            exit()

        step[jump] = "#"

    while True:
        if sn == c - 1:
            sn_goal = True
            break

        if step[sn + 1] == ".":
            sn += 1
        elif step[sn + 2] == ".":
            sn += 2
        else:
            break
    
    if sn_goal and fn_goal:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 10848
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
const ll mod = (ll)1e9 + 7;
    
int main(){
    speed;
    long double n; cin >> n;
    int k = ceil((-1 + sqrt(1 + (8 * n))) / 2.0 );
    cout << k;
    return 0;
}

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

int judge(int num)
{
    int fx = 0;
    while(num > 0)
    {
        fx += num % 10;
        num /= 10;
    }
    return fx;
}

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

    int fx = judge(N);
    if(N % fx == 0) cout << "Yes";
    else cout << "No";
}

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

abs_max = abs_max_v = idx = 0

a.each_with_index do |i, j|
  
  if abs_max <= i.abs
    abs_max = i.abs
    abs_max_v = i
    idx = j
  end
  
end

puts 2 * N - 1

N.times{ |i| puts "#{idx+1} #{i+1}" }
a.map!{ |j| j + abs_max }

if abs_max_v > 0
  
  (N-1).times{ |i| puts "#{i+1} #{i+2}" }
  
else
  
  (N-1).times{ |i| puts "#{N-i} #{N-1-i}" }
  
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    string T;
    cin>>T;
    rep(i,T.size()){
        if(T[i]=='?'){
            cout << 'D';
        }
        else{
            cout << T[i];
        }
    }
    cout << endl;
    



}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
int main()
  {
  int n;
  int x, y;
  cin >> n;
  int ar1[9];
  int ar2[9];
  for(int i=0;i<=n-1;i++)
  {
      scanf("%d",&ar1[i]);
  }
  for(int i=0;i<=n-1;i++)
  {
      scanf("%d",&ar2[i]);
  }
  int res=0;
  res=res+ar1[n-1];
  int mul=10;
  for(int i=n-2;i>=0;i--)
  {
      res=res+mul*ar1[i];
      mul=mul*10;
  }
  int res2=0;
  res2=res2+ar2[n-1];
  int mul2=10;
  for(int i=n-2;i>=0;i--)
  {
      res2=res2+mul2*ar2[i];
      mul2=mul2*10;
  }

  x=min(res,res2);
  y=max(res,res2);
  bool ar[n+1];
  int r;
  int cnt =0;
  bool flag;
  for(int i=x; i<=y;i++)
    {
    flag=true;
    memset(ar,0,sizeof(ar));
     r=i;
    while(r>0)
      {
      ar[r%10]=1;
      r=r/10;
      }
    for(int j=1;j<=n;j++){
      if(ar[j]==false)
        { flag= false;
          break;
         }
      }
    if(flag ==true)
      cnt++;

  }
 cout << cnt-1 << endl;
return 0;
}


Measured memory_bytes: 256
open System

[<EntryPoint>]
let main argv =
    let N=stdin.ReadLine()|>int
    [for i in [0..N-1] do yield (stdin.ReadLine()|>int64)]
    |>List.sortDescending
    |>fun c -> ((List.sum c) - (c.[0]/2L))
    |>stdout.WriteLine
    0


Measured memory_bytes: 14432
#include <stdio.h>
int main(void){
    int N,L,i,j,count;
    int box[256];
    int max = -999;
    int min = 999;
    int mode = 0;
    count = 0;
    scanf("%d %d",&N,&L);
    for(i = 0; i < N; i++){
        box[i] = L + i;
        if (box[i] > max){
            max = box[i];
        }
        if (box[i] < min){
            min = box[i];
        }
        if (box[i] == 0){
            mode = 1;
        }
    }
        
    for (i = 0; i < N; i++){
     
    }
    if (mode == 0){
         for (i = 0; i < N; i++){
                count = count + box[i];
        }
        if (min > 0){
            count = count - min;
        }else{
            count = count - max;
        }

    }else if (mode == 1){
        for (i = 0; i < N; i++){
                count = count + box[i];
        }
    }
    printf("%d",count);
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Long> list = new ArrayList<>();
    //final List<Long> list2 = new ArrayList<>();

    int a = sc.nextInt();
    int b = sc.nextInt();

    int sum = 0;
    if(a >= b){
        sum += a;
        a--;
    }else{
        sum += b;
        b--;
    }

    if(a >= b){
        sum += a;
    }else{
        sum += b;
    }

    System.out.println(sum);





}
}

Measured memory_bytes: 35888
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool seive[300001];
vector<int> matuzakiList;

void init(){
  for(int i = 0; i <= 300000; i++) seive[i] = true;
  seive[0] = seive[1] = false;
  for(int i = 2; i * i <= 300000; i++){
    for(int j = i * i; j <= 300000; j = j + i) seive[j] = false;
  }
}

int matuzakiNumber(int N, int P){
  int prime[30] = {0}, cnt = 0;
  for(int i = N + 1; cnt != 30; i++){
    if(seive[i]) prime[cnt++] = i;
  }
  for(int i = 0; i < 30; i++){
    for(int j = i; j < 30; j++){
      int ml = prime[i] + prime[j];
      matuzakiList.push_back(ml);
    }
  }
  sort(matuzakiList.begin(), matuzakiList.end());
  return matuzakiList[P-1];
}

int main(void){
  init();
  int N, P;
  while(cin >> N >> P && N != -1 && P != -1){
    matuzakiList.clear();
    cout << matuzakiNumber(N, P) << endl;
  }
  return 0;
}

Measured memory_bytes: 1516
using System;
using System.Linq;
class Test{
  public static void Main(){ 
    var NXY =  Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToList();
    var N = NXY[0];
    var X = NXY[1];
    var Y = NXY[2];
    int[] count = new int[N+1];
    for(int i =1; i<N; i++){
      for(int j =i+1; j<=N; j++){
        int a = j-i;
        int b = Math.Abs(X-i)+1+Math.Abs(Y-j);
        int len = Math.Min(a,b);
        count[len]++;
      }
    }
    for(int x=1;x<N;x++){
      Console.WriteLine(count[x]);
    }
  }
}

Measured memory_bytes: 13380
import numpy as np
import bisect
n,m,k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]+list(np.cumsum(A))
b = [0]+list(np.cumsum(B))
ans = 0
for i in range(len(a)):
    x = k-a[i]
    if x < 0: break
    I = bisect.bisect_left(b, x)
    if I >= len(b): I -= 1
    if b[I] > x:
        if I != 0: I -= 1
        else: continue
    ans = max(ans, i+I)
print(ans)

Measured memory_bytes: 60876
n, m = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for i in range(m)]


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


u = UnionFind(n)
for x, y in xy:
    u.union(x-1, y-1)

cnt = 0
for i, v in enumerate(p):
    if u.same(v-1, i):
        cnt += 1

print(cnt)

Measured memory_bytes: 100332
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, n) for (int i = 0; i < n; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

typedef struct list
{
  int node;
  struct list *next;
} list;

list *graph[MAX];

void initGraph(void)
{
  for (int i = 0; i < MAX; i++)
    graph[i] = NULL;
}

void addEdge(int node1, int node2)
{
  list *new1 = (list *)malloc(sizeof(list *));
  new1->node = node2;
  new1->next = graph[node1];
  graph[node1] = new1;
}

typedef struct
{
  int front;
  int rear;
  int data[MAX][2];
} queue;

void initQueue(queue *p)
{
  p->front = p->rear = 0;
}

bool emptyQueue(queue *p)
{
  return p->front == p->rear;
}

bool fullQueue(queue *p)
{
  return (p->front - 1 == p->rear) || (p->front == 0 && p->rear == MAX - 1);
}

void queuePop(queue *p)
{
  if (emptyQueue(p))
  {
    printf("UnderFlow\n");
    exit(1);
  }
  else
  {
    p->front++;
    if (p->front == MAX)
      p->front = 0;
  }
}

void queuePush(queue *p, int node, int dist)
{
  if (fullQueue(p))
  {
    printf("OverFlow\n");
    exit(1);
  }
  else
  {
    p->data[p->rear][0] = node;
    p->data[p->rear][1] = dist;
    p->rear++;
    if (p->rear == MAX)
      p->rear = 0;
  }
}

int main(void)
{
  int n, m;
  scanf("%d %d", &n, &m);

  initGraph();

  int u, v;
  rep(i, m)
  {
    scanf("%d %d", &u, &v);
    addEdge(u, v);
  }
  int s, t;
  scanf("%d %d", &s, &t);

  queue que;
  int dist[MAX][3];

  rep(i, MAX) rep(j, 3) dist[i][j] = -1;
  dist[s][0] = 0;

  initQueue(&que);
  queuePush(&que, s, 0);

  while (!emptyQueue(&que))
  {
    int p = que.data[que.front][0];
    int d = que.data[que.front][1];
    queuePop(&que);
    for (list *n = graph[p]; n != NULL; n = n->next)
    {
      int nd = (d + 1) % 3;
      if (dist[n->node][nd] != -1)
        continue;
      dist[n->node][nd] = dist[p][d] + 1;
      queuePush(&que, n->node, nd);
    }
  }
  int ans = dist[t][0] == -1 ? -1 : dist[t][0] / 3;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 6016
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#define REP(i, N) for(int i=0; i<N; i++)
using namespace std;
 
//#include "atcoder.hpp"
 
long long gcd(long long a, long long b) {
    if (a>b) swap(a,b);
    
    auto r = b % a;
    
    return (r ? gcd(r, a) : a);
}
 
int main() {
    long long X, Y, Z, K;
    
    cin >> X >> Y >> Z >> K;
    long long A[1000], B[1000], C[1000];
    
    REP(i,X)
        cin >> A[i];
    REP(i,Y)
    cin >> B[i];
    REP(i,Z)
    cin >> C[i];
    
    priority_queue<long long> XY;
    
    REP(i,X) REP(j,Y) {
        long long tmp = A[i] + B[j];
        XY.push(tmp);
    }
    
    priority_queue<long long> XYZ;
    int cnt = 3000;
    while (cnt-- && !XY.empty()) {
      auto value = XY.top();
    REP(i,Z) {
        XYZ.push(value + C[i]);
    }
      XY.pop();
    }
    
    while (K--) {
    cout << XYZ.top() << endl;
        XYZ.pop();
    }
    
    return 0;
}

Measured memory_bytes: 43236
#include <stdio.h>

#define MAX 1000000000000000000

int main(void){
  int n, i;
  long long value[100010], result = 1, temp;

  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ ){
    scanf("%lld",&value[i]);
    if( value[i] == 0 ){
      printf("0\n");
      return 0;
    }
  }

  for( i = 0 ; i < n ; i++ ){
    temp = result * value[i];
    if( ( result <=  0 ) || ( value[i] > ( MAX / result )  ) ){
      printf("-1\n");
      return 0;
    }
    result = temp;
  }

  if( result > MAX )
    printf("-1\n");
  else
    printf("%lld\n",result);

  return 0;
}


Measured memory_bytes: 2492
import java.io.*;
// import java.math.*;
// import java.util.*;
// import java.util.Map.*;
// import java.util.stream.*;

public class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader reader =
            new BufferedReader (new InputStreamReader (System.in));
        int a = Integer.parseInt (reader.readLine());
        String s = reader.readLine();
        System.out.println (3200 <= a ? s : "red");
        return;
    }
}

Measured memory_bytes: 32480
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{

    class Program
    {
        static void Main(string[] args)
        {

            int r = int.Parse(Console.ReadLine());
            Console.WriteLine(3 * r * r);
        }
    }
}

Measured memory_bytes: 11092
let () =
    let split s =
        let rec loop i cur flag acc =
            if i = String.length s then (
                if flag then cur :: acc else acc
            ) else (
                match flag, s.[i] with
                | true,  ' ' -> loop (i + 1) 0 false (cur :: acc)
                | false, ' ' -> loop (i + 1) 0 false acc
                | true,  v   -> loop (i + 1) (cur * 10 + int_of_char v - 48) true acc
                | false, v   -> loop (i + 1) (cur * 10 + int_of_char v - 48) true acc
            )
        in
        List.rev (loop 0 0 false [])
    in
    let main () =
        let n, m = Scanf.sscanf (read_line ()) "%d %d" (fun n k -> n, k) in
        let arrs = Array.of_list (split (read_line ())) in
        let arrt = Array.of_list (split (read_line ())) in
        let mat = Array.make_matrix (n + 1) (m + 1) 1 in
        let mm = 1000000000 + 7 in
        for y = 1 to n do
            for x = 1 to m do
                mat.(y).(x) <- (mat.(y - 1).(x) + mat.(y).(x - 1) +
                    if arrs.(y - 1) = arrt.(x - 1) then 0 else -mat.(y - 1).(x - 1) + mm) mod mm
            done
        done;
        Printf.printf "%d\n" mat.(n).(m)
    in
    main ()

Measured memory_bytes: 34684
#include<bits/stdc++.h>
using namespace std;
int main(){
	char S[12];
	scanf("%s", S);
	if(S[0] != 'A') printf("WA");
	else{
		int cnt = 0;
		for(int i = 2; i < strlen(S) - 1; i += 1) if(S[i] == 'C') cnt += 1;
		if(cnt != 1) printf("WA");
		else{
			for(int i = 1; i < strlen(S); i += 1) if(S[i] <= 'Z') cnt += 1;
			if(cnt != 2) printf("WA");
			else printf("AC");
		}
	}
}

Measured memory_bytes: 256
from collections import deque
h, w = map(int, input().split())
maze = [list(input()) for _ in range(h)]
INF = 1000000
def bfs(sx, sy):
    reached = [[INF for _ in range(w)] for _ in range(h)]
    dx = [-1, 0, 1, 0]
    dy = [0, 1, 0, -1]
    d = deque()
    d.append([sx, sy])
    reached[sx][sy] = 0
    while d:
        x, y = d.popleft()
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if nx < 0 or nx > h - 1 or ny < 0 or ny > w - 1 or maze[nx][ny] =="#" or reached[nx][ny] != INF:
                continue
            d.append([nx, ny])
            reached[nx][ny] = reached[x][y] + 1
    
    gl = 0
    for i in range(h):
        for j in range(w):
            if reached[i][j] != INF:
                gl = max(gl, reached[i][j])
    return gl

ans = 0
for i in range(h):
    for j in range(w):
        if maze[i][j] != "#":
            ans = max(ans, bfs(i, j))
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
using ll=long long;
const ll MOD=1e9+7;
const int INF=1<<30;

int H,W;
const int dy[8]={0,0,1,1,1,-1,-1,-1};
const int dx[8]={1,-1,0,1,-1,0,1,-1};
vector<string> G;

void dfs(int y,int x){
  int cnt=0;
  for(int dir=0;dir<8;dir++){
    int ny=y+dy[dir];
    int nx=x+dx[dir];
    if(ny<0||nx<0||ny>=H||nx>=W) continue;
    if(G[ny][nx]=='#') cnt++;
  }
  G[y][x]='0'+cnt;
}

int main(){
  cin >> H >> W;
  G.resize(H);
  rep(i,H){
    cin >> G[i];
  }
  rep(i,H){
    rep(j,W){
      if(G[i][j]=='.') {dfs(i,j);}
      cout << G[i][j];
      if(j==W-1) cout << endl;
    }
  }
  
}

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

int main(){
    int a, b;
    char op;
    while(1){
        cin >> a >> op >> b;
        if(op == '?')      break;
        else if(op == '+') cout << a+b << endl;
        else if(op == '-') cout << a-b << endl;
        else if(op == '*') cout << a*b << endl;
        else               cout << a/b << endl;
    }  
}


Measured memory_bytes: 3088
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = list(range(n + 1))
        self.ranks = [0 for _ in range(n + 1)]

    def get_root(self, x):
        if self.parents[x] == x:
            return x
        self.parents[x] = self.get_root(self.parents[x])
        return self.parents[x]

    def merge(self, x, y):
        x = self.get_root(x)
        y = self.get_root(y)
        if x != y:
            if self.ranks[x] < self.ranks[y]:
                self.parents[x] = y
            else:
                self.parents[y] = x
                if self.ranks[x] == self.ranks[y]:
                    self.ranks[x] += 1


n, m = map(int, input().split())
ls = [list(map(int, input().split())) for _ in range(m)]

count = 0
for i in range(m):
    uf = UnionFind(n)
    for j in range(m):
        if j == i:
            continue
        uf.merge(*ls[j])
    for i in range(n + 1):
        uf.get_root(i)
    if len(set(uf.parents[1:])) > 1:
        count += 1
print(count)

Measured memory_bytes: 3064
#include<cstdio>
#include<vector>
#include<algorithm>
#include<iostream>
#include<cassert>
#include<cstring>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<string>
#include<climits>
using namespace std;
typedef pair<int,int>pint;
typedef vector<int>vint;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

const int INF=1001001001;

int D,K,L;
int c[8][8];

int M,N,P;
int r[200];
int t[200];
int dp[1<<16];
void dping(){
    fill_n(dp,1<<16,INF);

    dp[0]=0;

    rep(i,D)rep(latte,L){
        for(int j=(1<<(2*K))-1;j>=0;j--){
            rep(k,K){
                if((j>>(2*k)&3)>=2)continue;
                chmin(dp[j+(1<<(2*k))],dp[j]+c[i][k]);
            }
        }
    }
}

struct edge{
    int to,cap,cost,rev;
    edge(int to,int cap,int cost,int rev):to(to),cap(cap),cost(cost),rev(rev){}
};

const int MAX_V=500;
int S=MAX_V-2,T=MAX_V-1;
int V;
vector<edge>G[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];

void add_edge(int from,int to,int cap,int cost){
    G[from].pb(edge(to,cap,cost,G[to].size()));
    G[to].pb(edge(from,0,-cost,G[from].size()-1));
}

int min_cost_flow(int s,int t,int f){
    int res=0;
    while(f>0){
        fill_n(dist,MAX_V,INF);
        dist[s]=0;
        bool update=true;
        while(update){
            update=false;
            rep(v,MAX_V){
                if(dist[v]==INF)continue;
                rep(i,G[v].size()){
                    edge &e=G[v][i];
                    if(e.cap>0&&dist[e.to]>dist[v]+e.cost){
                        dist[e.to]=dist[v]+e.cost;
                        prevv[e.to]=v;
                        preve[e.to]=i;
                        update=true;
                    }
                }
            }
        }

        if(dist[t]==INF)return -1;

        int d=f;
        for(int v=t;v!=s;v=prevv[v]){
            chmin(d,G[prevv[v]][preve[v]].cap);
        }

        f-=d;
        res+=d*dist[t];
        for(int v=t;v!=s;v=prevv[v]){
            edge &e=G[prevv[v]][preve[v]];
            e.cap-=d;
            G[v][e.rev].cap+=d;
        }
    }

    return res;
}

int main(){
    while(cin>>D>>K>>L,D||K||L){
        memset(r,0,sizeof(r));memset(t,0,sizeof(t));
        rep(i,MAX_V)G[i].clear();

        rep(i,D)rep(j,K)cin>>c[i][j];

        cin>>M>>N>>P;

        rep(i,M){
            rep(j,K){
                int a;cin>>a;
                r[i]|=a<<(j*2);
            }
        }

        rep(i,P){
            rep(j,K){
                int a;cin>>a;
                t[i]|=a<<(j*2);
            }
        }

        dping();

        rep(i,M){
            add_edge(S,i,1,0);
            if(r[i]!=INF)add_edge(i,T,1,dp[r[i]]);
        }
        rep(i,P){
            add_edge(M+i,T,1,0);
        }
        rep(i,M){
            rep(j,P){
                bool ok=true;
                rep(k,K)if((r[i]>>(2*k)&3)<(t[j]>>(2*k)&3))ok=false;
                if(ok)add_edge(i,M+j,1,dp[r[i]-t[j]]);

            }
        }
        cout<<min_cost_flow(S,T,N)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3140
def main():
    N, A, B = list(map(int, input().split(' ')))
    X = list(map(int, input().split(' ')))
    ans = sum([min(B, A * (X[i + 1] - X[i])) for i in range(N - 1)])
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 15020
#include <cstdio>
#include <cstdlib>
#include <algorithm>

typedef long long i64;

const int N = 500000 + 10;

int n, m, d[N];

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &d[i]);
  static int a[N], b[N];
  a[0] = m;
  for (int i = 1; i <= n; ++i) a[i] = std::min(a[i - 1], abs(a[i - 1] - d[i]));
  b[n + 1] = 0;
  for (int i = n; i > 0; --i) b[i] = b[i + 1] + (b[i + 1] >= d[i] / 2 ? d[i] : 0);
  int q;
  for (scanf("%d", &q); q--;) {
    int x;
    scanf("%d", &x);
    puts(a[x - 1] <= b[x + 1] ? "NO" : "YES");
  }
  return 0;
}


Measured memory_bytes: 7680
"use strict";
const Main = (input) => {
	let xs = input.trim().split(' ').map(v=>parseInt(v,10));
    let ans = '';
    if(xs[0] + xs[1] < 10){
    	ans = xs[0] + xs[1];
    }else if(xs[0] + xs[1] >= 10){
        ans = "error";
    }
    console.log(ans);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int n;
    cin >> n;
    int ans = 0;
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        if(i % 2 == 0 && a % 2 != 0)    ++ans;
    }
    cout << ans << endl;
}

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

int main(){
  int minP = INT_MAX;
  for(int i = 0; i < 3; i++){
    int x;
    cin >> x;
    minP = min(minP, x);
  }

  int minJ = INT_MAX;
  for(int i = 0; i < 2; i++){
    int x;
    cin >> x;
    minJ = min(minJ, x);
  }

  cout << minP + minJ - 50 << endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}
 

int main(){
   fastIO();
   int n;
   cin>>n;
   cout<<n*n<<endl;
}  
//VERIFICAR LONG VS INT
  

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

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    int k;
    cin>>k;
    string s;
    cin>>s;
    if(s.length() <= k) cout<<s<<endl;
    else{
        for(int i=0;i<k;i++) cout<<s[i];
        cout<<"..."<<endl;
    }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int a = str.size();
    
  if (str.at(a-1)=='2'||str.at(a-1)=='4'||str.at(a-1)=='5'||str.at(a-1)=='7'||str.at(a-1)=='9'){
    cout << "hon" << endl;
  }
  else if (str.at(a-1)=='0'||str.at(a-1)=='1'||str.at(a-1)=='6'||str.at(a-1)=='8'){
    cout << "pon" << endl;
  }
  else {
    cout << "bon" << endl;
  }
}

Measured memory_bytes: 3580
#include<iostream>
#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
int main()
{
	ios;
	int n,m;
	cin>>n>>m;
	n%=500;
	if(m>=n)cout<<"Yes\n";
	else cout<<"No\n";
} 

Measured memory_bytes: 3128
N = int(input())
ans = []
for i in range(1, N+1):
    if i % 3 == 0 and i % 5 == 0:
        ans.append(0)
    elif i % 3 == 0:
        ans.append(0)
    elif i % 5 == 0:
        ans.append(0)
    else:
        ans.append(i)
print(sum(ans))

Measured memory_bytes: 33916
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
#define ll long long
#define INF 9999999999999999
#define rep(i,m,n) for(ll i = m;i < n;i++)
#define rrep(i,m,n) for(ll i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define tint tuple<int, int, int>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000010
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, M;
    cin >> N >> M;
    UnionFind uf(N);
    while(M--) {
        ll A, B;
        cin >> A >> B;
        A--;
        B--;
        uf.unite(A, B);
    }
    map<int, int> mp;
    rep(i, 0, N) mp[uf.find(i)]++;
    cout << mp.size() - 1 << endl;
}

Measured memory_bytes: 7616
#include<iostream>
using namespace std;
#define ll long long
#define for(i,n) for(int i=0;i<(int)n;i++)
int main(){
int n;
  cin>>n;
  int arr[n];
  int sum = 0;
  for(i,n){cin>>arr[i];sum+= arr[i];}
  int m;
  cin>>m;
  int p,x;
  int d = sum;
  for(i,m){
    cin>>p>>x;
    sum -= arr[p-1];
    sum += x;
    cout<<sum<<endl;
    sum = d;
  }
  return 0;
}

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


int main(void){
    // Your code here!
    int N;
    cin >> N;
    int A;
    int sum = 1;
    int pw = 1;
    for(int i = 0; i <N;i++){
        cin >> A;
        if(A%2==0)sum *= 2;
        pw *= 3;
    }
    cout << pw - sum << endl;
    
    
    

}


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


int main() {
	map<int, int> cnt;
	for(int i=0;i<3;i++) {
		int a, b;
		cin >> a >> b;
		cnt[a]++;
		cnt[b]++;
	}

	int max_v = 0;
	for(auto& p : cnt) {
		max_v = max(max_v, p.second);
	}
	if(max_v == 3) {
		cout << "NO" << endl;
	}else {
		cout << "YES" << endl;
	}

	return 0;
}


Measured memory_bytes: 256