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

using namespace std;
using ll = long long;


const int MOD = 998244353;

class Edge{
public:
    ll from,to, value;
    Edge(int f,int t, int c){
        from = f;
        to = t;
        value = c;
    }
};
class SegTreeRMQ{
public:
    SegTreeRMQ(int N){
        init(N);
    }
    void init(int N){
        int s = 1;
        while(s < N){
            s*=2;
        }
        dat = std::vector<ll>(s * 2, 1e18);
        n = s;
    }
    void update(int i,ll x){
        i += n - 1;
        dat[i]= x;
        while(i > 0){
            i = (i-1) / 2;
            dat[i] = min(dat[i * 2 + 1],dat[i * 2 + 2]);
        }
    }
    //使う時は変数名.query(a,b,k,l,変数名getSize())
    //区間の左端(b)に注意+1しよう
    ll query(int a,int b,int k,int l,int r){
      //  cout<<k<<endl;
        if(r <= a || b<= l)return 1e18;
        if(a <= l && r <= b)return dat[k];
        else{
            ll vl = query(a,b,k * 2 + 1,l,(l+r)/2);
            ll vr = query(a,b,k * 2 + 2,(l+r)/2,r);
            return min(vl,vr);
        }
    }
    int getSize(){
        return n;
    }
    void show(){
        for(int a = 0;a < n;a++){
            cout<<dat[a]<<" ";
        }
        cout<<endl;
        return;
    }
private:
    int n;
    std::vector<ll> dat;
};


int main(){
    int N,M;cin >> N >> M;
    vector<pair<pair<int, int>, int>> vec;
    for(int i = 0;i < M;i++){
        int a,b,c;cin >> a >> b >> c;
        a--,b--;
        vec.push_back(make_pair(make_pair(b,a), c));
    }
    sort(vec.begin(),vec.end());
    SegTreeRMQ Seg(N);
    Seg.update(0, 0);
    for(int i = 0;i < M;i++){
        int a,b,c;
        a = vec.at(i).first.second;
        b = vec.at(i).first.first;
        c = vec.at(i).second;
        ll usi = Seg.query(a,b+1,0,0,Seg.getSize());
        ll now = Seg.query(b,b+1,0,0,Seg.getSize());
        Seg.update(b, min(now, usi + c));
    }
    if(Seg.query(N-1, N,0,0,Seg.getSize()) == 1e18){
        cout<<-1<<endl;
        return 0;
    }
    cout<<Seg.query(N-1, N,0,0,Seg.getSize())<<endl;
    /*
    vector<int> A,B;
    for(int  i = 0;i < N;i++){
        int a;cin >> a;
        A.push_back(a);
    }
    for(int i = 0;i < N;i++){
        int b;cin >> b;
        B.push_back(b);
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    for(int i = 0;i < N;i++){
        if(A[i] > B[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    */

}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++)
    cin >> A[i];
  vector<int> B(N);
  for(int i = 0; i < N; i++)
    B[A[i] - 1] = i + 1;
  for(int i = 0; i < N; i++)
    cout << B[i] << " ";
  return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  VL xs(N+2);
  REP(i,N)
	cin >> xs[1+i];

  LL ans = 0;
  REP(i,N+1) ans += abs(xs[i+1] - xs[i]);

  FOR(i,1,N+1){
	cout << ans + abs(xs[i-1] - xs[i+1]) - abs(xs[i-1] - xs[i])
	  - abs(xs[i] - xs[i+1]) << endl;;
  }

  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD2 = 1e9 + 7;
const ll MOD = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second

ll FACT[301100] = { 0 }, IFACT[301100] = { 0 };

ll extgcd(ll a, ll b, ll &x, ll &y) {
	ll g = a;
	x = 1;
	y = 0;
	if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
	return g;
}
ll invMod(ll a, ll m) {
	ll x, y;
	if (extgcd(a, m, x, y) == 1) return (x + m) % m;
	else                         return 0;
}
ll mod_pow(ll x, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%MOD;
		x = x*x%MOD;
		n >>= 1;
	}
	return res;
}
void inverse(ll N) {
	FACT[0] = 1;
	IFACT[0] = 1;
	for (int i = 1;i <= N;i++) {
		FACT[i] = FACT[i - 1] * i % MOD;
		IFACT[i] = invMod(FACT[i], MOD);
	}
}
ll combi(ll n, ll r) {
	if (n < 0 || r < 0 || r > n)return 0;
	if (r > n / 2)r = n - r;
	return FACT[n] * IFACT[n - r] % MOD*IFACT[r] % MOD;
}




int main() {
	ll n, a, b, k, ans = 0;
	cin >> n >> a >> b >> k;
	inverse(300010);
	for (int i = 0;i <= n;i++) {
		if (k - a*i >= 0 && (k - a*i) % b == 0) {
			ans += (combi(n, i)*combi(n, (k - a*i) / b)) % MOD;
			ans %= MOD;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4992
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

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

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

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> P;

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

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

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}
int main(){
   int k, l;
   bool a,b,c;
   cin >> k;
   LL ans=0;
   FOR(x,1,k+1){
       FOR(y,1,k+1){
           FOR(z,1,k+1){
            int l = min({x,y,z});
                for(int f=l; f>0; f--){
                    a=false;
                    b=false;
                    c=false;
                    if(x%f==0) a=true;
                    if(y%f==0) b=true;
                    if(z%f==0) c=true;
                    if(a&&b&&c){
                        ans+=f;
                        break;
                    }
                    
                }
           }
       }
   }
   cout << ans << endl;
}
    




Measured memory_bytes: 3636
# ABC 131: B – Bite Eating
n, l = [int(s) for s in input().split()]

flavor_apples = [l + i - 1 for i in range(1, n + 1)]
abs_flavor_apples = [abs(i) for i in flavor_apples]
flavor_apple_pie = sum(flavor_apples)

print(flavor_apple_pie - flavor_apples[abs_flavor_apples.index(min(abs_flavor_apples))])

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

int main(){
int a,b,c;
  int t=0;
  
  cin >> a >> b >> c;
  
  if(a>b){
    t=a;
    a=b;
    b=t;
  }
  if(b>c){
    t=b;
    b=c;
    c=t;
  }
  if(a>b){
    t=a;
    a=b;
    b=t;
  }
  
  if(a==5&&b==5&&c==7){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
    return 0;
    
  }
}

Measured memory_bytes: 256
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}

	long N;
	std::cin >> N;

	if (N % 2 == 1) {
		std::cout << "0\n";
		return 0;
	}
	
	long result = 0;
	long x = 10;
	while (true) {
		result += N / x;
		if (x > std::numeric_limits<long>::max() / 5)
			break;
		x *= 5;
	}
	std::cout << result << "\n";
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cstdlib>
#include <utility>
#include <cmath>
#include <queue>
#include <stack>
#include <cstring>

using namespace std;

#define ll long long

#ifndef ONLINE_JUDGE
#define debug(format, ...) fprintf(stderr, \
    "%s:%d: " format "\n", __func__, __LINE__,##__VA_ARGS__)
#else
#define debug(format, ...)
#define NDEBUG
#endif

int n;
int a[200005];

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    sort(a + 1, a + n + 1);
    reverse(a + 1, a + n + 1);
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        ans += a[(i + 2) / 2];
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 2512
#include <cstring>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <climits>
#include <cctype>
#include <bitset>
using namespace std;

#define PI 3.14159265359
#define all(v) v.begin(),v.end()
#define sortva(v) sort(all(v))
#define sortvd(v) sort(v.rbegin(),v.rend())
#define sortaa(a,n) sort(a,a+n)
#define sortad(a,n) sort(a,a+n),reverse(a,a+n)
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define sfstr(v) scanf("%s", v);
#define sz(v) (int)v.size()
#define ndl puts("")
#define SS stringstream
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}


int main() {
	//PLAY();

	int x;
	cin >> x;
	cout << 24 + (24 - x) << endl;

	return 0;
}

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

int main(){
  while(true){
    int ans;
    if(!(cin >> ans)) break;

    while(true){
      char op;
      cin >> op;

      if(op == '=') break;

      int val;
      cin >> val;

      switch(op){
        case '+': ans += val; break;
        case '-': ans -= val; break;
        case '/': ans /= val; break;
        case '*': ans *= val; break;
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
	int n;
	int s[1000];
	while(cin >> n && n>0){
		for(int i=0; i<n; i++){
			cin >> s[i];
		}
		sort(s, s+n);
		int sum = 0;
		for(int i=1; i<n-1; i++){
			sum += s[i];
		}
		cout << sum/(n-2) << endl;
	}
        return 0;
}

Measured memory_bytes: 1176
#pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <limits>

using namespace std;

typedef int64_t i64;
typedef pair<i64, i64> P;

static const i64 MOD = 1000000007;

//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
    i64 from, to, cost;
    edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
    edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

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

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

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

#pragma endregion

int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };

int main() {
    i64 n, m;
    cin >> n >> m;
    vector<i64> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    vector<P> v;
    for (int i = 0; i < m; ++i) {
        i64 b, c;
        cin >> b >> c;
        v.push_back(P(c, b));
    }
    sort(v.begin(), v.end(), greater<P>());
    vector<i64> op;
    i64 cnt = 0;
    for (int i = 0; i < m; ++i) {
        if (n - cnt < v[i].second) {
            for(int j = 0; j < n - cnt; ++j) op.push_back(v[i].first);
            cnt = n;
            break;
        }
        else {
            for (int j = 0; j < v[i].second; ++j) op.push_back(v[i].first);
            cnt += v[i].second;
        }
    }
    i64 ans = 0;
    for (int i = 0; i < cnt; ++i) {
        if(op[i] > a[i]) a[i] = op[i];
    }
    for (int i = 0; i < n; ++i) {
        ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4464
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;
import java.util.concurrent.LinkedBlockingDeque;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        Room rooms[] = new Room[n];
        for (int i = 0; i < n; i++) {
            rooms[i] = new Room(i);
        }

        for (int i = 0; i < m; i++) {
            int a = in.nextInt() - 1;
            int b = in.nextInt() - 1;
            rooms[a].adjacent.add(rooms[b]);
            rooms[b].adjacent.add(rooms[a]);
        }

        Queue<Room> search = new LinkedBlockingDeque<>();
        search.add(rooms[0]);
        while (search.size() > 0) {
            Room r = search.poll();
            for (Room room : r.adjacent) {
                if (room.from == -1) {
                    room.from = r.num;
                    search.add(room);
                }
            }
        }

        System.out.println("Yes");
        for (int i = 1; i < n; i++) {
            System.out.println(rooms[i].from + 1);
        }
    }
}

class Room {
    int num = -1;
    int from = -1;
    List<Room> adjacent = new ArrayList<>();

    public Room(int num) {
        this.num = num;
    }
}

Measured memory_bytes: 73800
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 200005;

int n, i, a, b, maxx[N], res[N];
VI graf[N];
map<int, int> mapa[N];

void dfs1(int w, int o) {
	if (o != -1) maxx[w] = max(maxx[o], o);
	for (auto &w2 : graf[w]) if (w2 != o) dfs1(w2, w);
}

int dfs2(int w, int o, int m) {
	if (mapa[w].find(m) != mapa[w].end()) return mapa[w][m];
	int res = 0;
	for (auto &w2 : graf[w]) if (w2 != o && w2 < m) res += (1 + dfs2(w2, w, m));
	mapa[w][m] = res;
	return res;
}

void dfs3(int w, int o) {
	for (auto &w2 : graf[w]) if (w2 != o) dfs3(w2, w);
	if (w == 0) return;
	res[w] = 1 + dfs2(w, o, maxx[w]);
	if (w < maxx[o]) res[w] -= (1 + dfs2(w, o, maxx[o]));
}

void dfs4(int w, int o) {
	if (w != 0) res[w] += res[o];
	for (auto &w2 : graf[w]) if (w2 != o) dfs4(w2, w);
}

int main() {
scanf("%d", &n);
for (i=0;i<n;i++) {
	graf[i].clear();
	maxx[i] = -1;
	res[i] = 0;
	mapa[i].clear();
}
for (i=1;i<n;i++) {
	scanf("%d %d", &a, &b);
	a--;
	b--;
	graf[a].pb(b);
	graf[b].pb(a);
}
dfs1(0, -1);
dfs3(0, -1);
dfs4(0, -1);
for (i=1;i<n;i++) printf("%d ", res[i]);
printf("\n");
return 0;
}



Measured memory_bytes: 44032
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	int ans = (1 << 30);
	for (int i = 0; i <= max(X, Y); ++i) {
		int reqA = max(X - i, 0);
		int reqB = max(Y - i, 0);
		int cost = A * reqA + B * reqB + C * i * 2;
		ans = min(ans, cost);
	}
	cout << ans << endl;
	return 0;
}

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


int main() {
    int N,D;
    int ans = 0;
    cin >> N >> D;
    vector<vector<int>> vec(N,vector<int> (D));
    for(int i=0;i<N;++i){
      for(int j=0;j<D;++j){
        cin >> vec.at(i).at(j);
      }
    }

    for(int i=0;i<N-1;++i){
      for(int j=i+1;j<N;++j){
        int sum = 0;
        for(int k=0;k<D;++k){
          sum += pow(vec.at(i).at(k) - vec.at(j).at(k),2);
        }
        int t = 0;
        while(pow(t,2) <= sum){
          if(pow(t,2) == sum) ans++;
          t++;
        }
      }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>
 
int main()
{
  int a, b, i;
  int sum = 0;
  
  scanf("%d %d", &a, &b);
  
  for(i = 0; i < 2; i++){
    if(a >= b){
     sum += a;
     a--;
   }else{
     sum += b;
     b--;
   }
  }
  
  printf("%d", sum);
  
  return 0;
}

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

using namespace std;

const int N = 1e5 + 10;
long long dp[N];

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

  fill(dp, dp + N, 1e18);
  dp[0] = 0;
  int n, W;
  cin >> n >> W;
  for (int i = 0; i < n; ++i) {
    int w, v;
    cin >> w >> v;
    for (int j = N - 1 - v; j >= 0; --j) {
      dp[j + v] = min(dp[j + v], dp[j] + w);
    }
  }
  for (int i = N - 1; ; --i) {
    if (dp[i] <= W) {
      cout << i;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 1024
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    let a: i32 = read!();
    let b: i32 = read!();
    println!("{}",(b+b/100)*100_i32.pow(a as u32));
}

Measured memory_bytes: 2136
s = input()
list_s = list(set(s))
ans = ''
if len(set(s)) == 4:
    ans = 'Yes'
elif len(list_s) == 2 and list_s.count('E') == list_s.count('W'):
    ans = 'Yes'
elif len(list_s) == 2 and list_s.count('N') == list_s.count('S'):
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n; cin>>n;
  int a[n],b[n],sum=0; for(int i=0;i<n-1;i++) cin>>b[i];
  a[0]=b[0];
  for(int i=1;i<n-1;i++){
    a[i]=min(b[i-1],b[i]);
  }
  a[n-1]=b[n-2];
  for(int i=0;i<n;i++){
    sum+=a[i];
  }
  cout<<sum;
}

Measured memory_bytes: 3620
n = int(input())
activities = [list(map(int, input().split())) for _ in range(n)]

pre_a = 0
pre_b = 0
pre_c = 0
res = 0
for a, b, c in activities:
    tmp_a = max(pre_b, pre_c) + a
    tmp_b = max(pre_a, pre_c) + b
    tmp_c = max(pre_b, pre_a) + c
    pre_a = tmp_a
    pre_b = tmp_b
    pre_c = tmp_c
print(max(pre_a, pre_b, pre_c))



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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()
auto& errStream=cerr;
#ifdef LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%"  SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

signed main(){
	int n=read(),k=read();
	vi a(n);
	REP(i,n)
		a[i]=read();
	vi x;
	REP(i,n){
		int s=0;
		FOR(j,i,n){
			s+=a[j];
			x.PB(s);
		}
	}
	cerr<<x<<endl;
	int ans=0;
	for(int t=40;t>=0;t--){
		vi y;
		for(auto v:x){
			if((v&(int(1)<<t)))
				y.PB(v);
		}
		if(int(y.size())>=k){
			x=y;
			ans+=(int(1)<<t);
		}
	}
	print(ans);
}


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

using namespace std;
int main(){
	string s;
	cin >> s;
	int a,b;
	a = (s[0] - '0')*10 + (s[1] - '0');
	b = (s[2] - '0')*10 + (s[3] - '0');
	if(a==0 || b==0){
		if(a==0 && b==0){
			cout << "NA" << endl;
		}else if(a==0 && b<=12){
			cout << "YYMM" << endl;
		}else if(a<=12 && b==0){
			cout << "MMYY" << endl;
		}else{
			cout << "NA" << endl;
		}
		return 0;
	}
	if(a<=12 && b<=12){
		cout << "AMBIGUOUS" << endl;
	}
	if(a<=12 && b>12){
		cout << "MMYY" << endl;
	}
	if(a>12 && b<=12){
		cout << "YYMM" << endl;
	}
	if(a>12 && b>12){
		cout << "NA" << endl;
	}
}
		

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    int N;
    cin >> N;
    vector<pair<ll, int>> A(N);
    for (int i = 0; i < N; i++) cin >> A[i].first, A[i].second = i;
    sort(A.begin(), A.end(), greater<pair<ll, ll>>());

    vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, 0));
    auto dl = [&](ll x, ll p) { return abs(p - x); };
    auto dr = [&](ll y, ll p) { return abs(N - 1 - p - y); };
    for (int x = 0; x <= N; x++) {
        for (int y = 0; x + y <= N; y++) {
            int i = x + y - 1;

            if (x) dp[x][y] = max(dp[x][y], dp[x - 1][y] + dl(x - 1, A[i].second) * A[i].first);
            if (y) dp[x][y] = max(dp[x][y], dp[x][y - 1] + dr(y - 1, A[i].second) * A[i].first);
        }
    }
    ll ans = 0;
    for (int x = 0; x <= N; x++) ans = max(ans, dp[x][N - x]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 34664
from collections import defaultdict
from itertools import accumulate
from operator import xor


def solve(acc):
    MOD = 10 ** 9 + 7
    cnt0 = 0
    dp0 = defaultdict(lambda: 1)
    dp1 = defaultdict(lambda: 0)
    last_0 = defaultdict(lambda: 0)
    for a in acc:
        if a == 0:
            cnt0 += 1
        else:
            if a not in dp1:
                dp1[a] = 1
                last_0[a] = cnt0
            else:
                bw0 = cnt0 - last_0[a]
                if bw0 > 0:
                    dp0[a] = (dp0[a] + dp1[a] * bw0) % MOD
                    last_0[a] = cnt0
                dp1[a] = (dp1[a] + dp0[a]) % MOD

    if acc[-1] == 0:
        return (pow(2, cnt0 - 1, MOD) + sum(dp1.values())) % MOD
    else:
        return dp0[acc[-1]]


n = int(input())
aaa = list(map(int, input().split()))
acc = list(accumulate(aaa, func=xor))
print(solve(acc))


Measured memory_bytes: 80416
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
char s[1007];
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n; cin >> n;
	int ans=0, mx=0;
	for(int i=0; i<n; i++) {
		int a,b; cin >> a >> b;
		if(a==b) {ans++; mx=max(mx,ans);}
		else ans=0;
	}
	cout << ((mx>=3)?"Yes\n":"No\n");
}


Measured memory_bytes: 3644
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner as = new Scanner(System.in);
		int n = Integer.parseInt(as.next());
		int s = Integer.parseInt(as.next());
		/*
		int a,b;
		int t = 0;
		int x = 0;
		String l = "NO";
		for(int i=0;i<n;i++){
			a = Integer.parseInt(as.next());
			b = Integer.parseInt(as.next());
			try{
				if((b-x)*1.0/(a-t) > s){
					l = "YES";
					break;
				}
			}catch(ArithmeticException e){
			}
			t = a;
			x = b;
		}*/
		System.out.println(n*(n-1)/2+s*(s-1)/2);
	}
}

Measured memory_bytes: 21844
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
//#define pop pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846 
vector< ll > tree[N];

int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    //   freopen ("INPUT.txt" , "r" , stdin);
    //   freopen ("OUTPUT.txt", "w" , stdout);
    // #endif 
    ll n,x,y;
    cin>>n>>x>>y;
    ll ans[n];
    ll xx=1;
    for(int i=n-1;i>=1;i--,xx++)
      ans[i]=xx;
    // for(int i=1;i<=n-1;i++)
    //   cout<<ans[i]<<'\n';
    // cout<<'\n';
    for(int i=1;i<=x;i++)
    {
      for(int j=y;j<=n;j++)
      {
        ans[j-i]--;
        ans[x-i+1+j-y]++;
      }
    }
    for(int i=1;i<=x;i++)
    {
      for(int j=x+1;j<y;j++)
      {
        ll prev=j-i;
        ll ne=x-i+1+y-j;
        if(ne<prev)
        {
          ans[ne]++;
          ans[prev]--;
        }
      }
    }
    for(int i=x+1;i<y;i++)
    {
    	for(int j=i+1;j<y;j++)
    	{
    		ll prev=j-i;
    		ll ne=i-x+1+y-j;
    		if(ne<prev)
    		{
    			ans[ne]++;
    			ans[prev]--;
    		}
    	}
    }
    for(int i=x+1;i<y;i++)
    {
      for(int j=y;j<=n;j++)
      {
        ll prev=j-i;
        ll ne=i-x+1+j-y;
        if(ne<prev)
        {
          ans[ne]++;
          ans[prev]--;
        }
      }
    }
    for(int i=1;i<=n-1;i++)
      cout<<ans[i]<<'\n';
}


Measured memory_bytes: 23680
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")*/

using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
#define mp make_pair
 
typedef long double DOUBLE;
typedef complex<DOUBLE> COMPLEX;
typedef vector<DOUBLE> VD;
typedef vector<COMPLEX> VC;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

 
void print(auto &a)
{
    for (auto s: a) cout<<s<<' ';
    cout<<endl;
}
 
void get(vector<auto> &a)
{
    for (int i = 0; i<(int)a.size(); i++) cin>>a[i];
}
 
const int p = 998244353;
 
 
int mul(int a, int b) {
    return (1LL * a%p * b%p) % p;
}
 
int add(int a, int b) {
    int s = (a+b);
    s = s%p;
    if (s<0) s+=p; 
    return s;
}
 
int sub(int a, int b) {
    int s = (a-b);
    s = s%p;
    if (s<0) s+=p; 
    return s;
}
 
int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}
 
int inv(int n)
{
    return po(n, p-2);
}
 
vector<int> Z(vector<int> s)
{
int n = s.size();
vector<int> z(n);
int L = 0, R = 0;
for (int i = 1; i < n; i++) {
  if (i > R) {
    L = R = i;
    while (R < n && s[R-L] == s[R]) R++;
    z[i] = R-L; R--;
  } else {
    int k = i-L;
    if (z[k] < R-i+1) z[i] = z[k];
    else {
      L = i;
      while (R < n && s[R-L] == s[R]) R++;
      z[i] = R-L; R--;
    }
  }
}
return z;
}

mt19937 rnd(time(0));

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

    string s;
    cin>>s;
    int n = s.length();
    string res;
    for (int i = 0; i<n; i++)
    {
        if (s[i]=='A') {res+='A'; continue;}
        if (s[i]=='C') {res+='X'; continue;}
        if (i==n-1||s[i+1]!='C') {res+='X'; continue;}
        res+='B'; i++; continue;
    }
    ///cout<<s<<endl<<res<<endl;
    
    ll total = 0;
    int cur = 0;
    for (int i = 0; i<res.length(); i++)
    {
        if (res[i]=='X') {cur = 0; continue;}
        if (res[i]=='A') cur++;
        else total+=cur;
    }
    cout<<total;
    

}

Measured memory_bytes: 916
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    x=INT()
    if x==3 or x==5 or x==7:
        print('YES')
    else:
        print('NO')
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
)

var in = bufio.NewReader(os.Stdin)

func main() {
	var n, h, w int
	fmt.Fscanf(in, "%d %d %d\n", &n, &h, &w)

	a := make([]int, n+1) //h
	b := make([]int, n+1) //w
	var count int
	for i := 1; i <= n; i++ {
		fmt.Fscanf(in, "%d %d\n", &a[i], &b[i])
		if a[i] >= h && b[i] >= w {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String c1 = sc.next();
			StringBuilder c2 = new StringBuilder(sc.next());

			if (c1.equals(c2.reverse().toString())) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}

		}
	}
}


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

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int sei(int a){
  return a>0 ? a : 0;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int n[3][3]={{0,0,0},{0,0,0},{0,0,0}},flag=0;
  int minx[3]={200,200,200};
  int miny[3]={200,200,200};
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      scanf("%d ",&n[i][j]);
    }
  }
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      minx[i]=min(n[i][j],minx[i]);
    }
  }

  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      miny[i]=min(n[j][i],miny[i]);
    }
  }
  //debug
  //for(int i=0;i<3;i++)printf("%d\n",minx[i]);
  //for(int i=0;i<3;i++)printf("%d\n",miny[i]);
for(int a=0;a<=minx[0];a++){
  for(int b=0;b<=minx[1];b++){
    for(int c=0;c<=minx[2];c++){
      for(int d=0;d<=miny[0];d++){
        for(int e=0;e<=miny[1];e++){
          for(int f=0;f<=miny[2];f++){
            if(n[0][0]==a+d && n[0][1]==a+e && n[0][2]==a+f && n[1][0]==b+d && n[1][1]==b+e && n[1][2]==b+f && n[2][0]==c+d && n[2][1]==c+e && n[2][2]==c+f){
              printf("Yes");
              return 0;
            }
          }
        }
      }
    }
  }
}
printf("No");
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#define LEN 1000000

typedef struct pp{
  char name[100];
  int t;
}P;

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

void enqueue(P x){
  strcpy(Q[tail].name,x.name);
  Q[tail].t = x.t;
  if( tail + 1 == LEN )tail = 0;
  else tail++;

}

P dequeue(){
  if( head + 1 == LEN )head = 0;
  else head++;
  return Q[head];
}


int main(){
  int elaps = 0, ans=0;
  int i, q, c=0, p_count=0;
  P u;

  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    if( strlen(Q[i].name) > 10 ){
      printf("%s\n", Q[i].name);
      p_count++;
      break;
    }
    scanf("%d", &Q[i].t);
    enqueue(Q[i]);
  }
  
  while(1){
    c++;
    if( n == p_count )break;
    if( Q[c].t - q > 0 ){
      ans += q;
      Q[c].t -= q;
      enqueue(Q[c]);
    }    
    else{
      ans += Q[c].t;
      printf("%s %d\n", Q[c].name, ans);
      p_count++;
      Q[c] = dequeue();
    }
  }

  return 0;
}

Measured memory_bytes: 21088
#include <iostream>

int main(int argc, char *argv[]) {
	int a, b, c;
	std::cin >> a >> b >> c;
	if (a < b && b < c) {
		std::cout << "Yes" << std::endl;
	} else {
		std::cout << "No" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
  
using namespace std;
 
#define MAX 256
typedef pair<int, int> pii;
  
int n;
vector<string> e;
map<string, pii> mp;
  
int op_num(char c)
{
    switch (c) {
        case '+':
            return 0;
        case '-':
            return 1;
        case '*':
            return 2;
        case '/':
            return 3;
    }
    return -1;
}
  
int s2i(string &s)
{
    int res;
    stringstream ss(s);
    ss >> res;
    return res;
}

int calc(int a, int op, int b)
{    
    if (op == 0) {
        return (a + b) % 256;
    } else if (op == 1) {
        return (a - b + 256) % 256;
    } else if (op == 2) {
        return (a * b) % 256;
    } else {
        return (b == 0 ? MAX : (a / b) % 256);
    }
}

bool zero_division_checker()
{
    stack<vector<int>> st;
    for (int i = 0; i < n; i++) {
        if (isdigit(e[i][0])) {
            st.push({s2i(e[i])});
        } else {
            vector<int> v;
            int op = op_num(e[i][0]);            
            if (op >= 0) {
                vector<int> vb = st.top(); st.pop();
                vector<int> va = st.top(); st.pop();
                for (int j = 0; j < (int)va.size(); j++) {
                    for (int k = 0; k < (int)vb.size(); k++) {
                        int res = calc(va[j], op, vb[k]);
                        if (res == MAX) {
                            return 0;
                        }
                        v.push_back(res);
                    }
                }
                sort(v.begin(), v.end());
                v.erase(unique(v.begin(), v.end()), v.end());
                st.push(v);
            } else {
                pii p = mp[e[i]];
                for (int j = p.first; j <= p.second; j++) {
                    v.push_back(j);
                }
                st.push(v);                
            }
        }
    }
    return 1;
}
  
int main()
{
    int m;
    cin >> m;
    string name;
    int lb, ub;
    for (int i = 0; i < m; i++) {
        cin >> name >> lb >> ub;
        mp[name] = pii(lb, ub);
    }
    cin >> n;
    e.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> e[i];
    }
    cout << (zero_division_checker() ? "correct" : "error") << endl;
    return 0;
}

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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(random_device{}());
template<typename... Args> void write(Args... args) { ((cout << args << " "), ...); cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    map<int,int> cnt;
    string st;
    cin>>st;
    int res=0,base=1;
    ll ans=0;
    cnt[0]=1;
    reverse(all(st));
    for(auto ch:st){
        res=(res+(ch-'0')*base)%2019;
        base=base*10%2019;
        ans+=cnt[res];
        cnt[res]++;
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 3776
#include<iostream>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cstdio>
#include<math.h>
#include<stack>
#include<vector>
#include<map> 
#define maxn 2000005
#define INF 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int k,n,buc[maxn],arr[maxn];
ll ans;

int main()
{
	cin>>k>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i];
		if(i>1)
		{
			buc[arr[i]-arr[i-1]]++;
		}
	}
	buc[arr[1]+k-arr[n]]++;
	for(int i=k;;i--)
	{
		if(buc[i]!=0)
		{
			ans=k-i;
			cout<<ans<<endl;
			break;
		}
	}
	return 0;
}

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

const int INF = 1001001001;
vector<int> to[100005];

int main() {
    int n, m;
    cin >> n >> m;
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    } 

    queue<int> q;
    vector<int> dist(n, INF); // distance
    vector<int> pre(n, -1);
    dist[0] = 0;
    q.push(0);
    while (!q.empty()) {
        int v = q.front(); q.pop();
        for (int u : to[v]) {
            if (dist[u] != INF) continue;
            dist[u] = dist[v]+1;
            pre[u] = v;
            q.push(u);
        }
    }

    cout << "Yes" << endl;
    rep(i, n) {
        if (i == 0) continue;
        int ans = pre[i];
        ++ans;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 10728
#include<iostream>
#include<cstdio>
using namespace std;
int h,w,n,a[10010],mp[110][110];
int main()
{
	scanf("%d%d",&h,&w);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int pnt=1;	
	for(int i=1;i<=h;i++)
	{
		if(i&1)
			for(int j=1;j<=w;j++)
			{
				if(a[pnt]==0) pnt++;
				a[pnt]--;
				mp[i][j]=pnt;
			}
		else
			for(int j=w;j>=1;j--)
			{
				if(a[pnt]==0) pnt++;
				a[pnt]--;
				mp[i][j]=pnt;
			}	
	}	
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			printf("%d%c",mp[i][j],(j==w)?'\n':' ');
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <map>
using namespace std;
typedef long long i64;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 3e2+5;
int n, ans; char s[N][N];
bool valid(int A, int B)
{
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            if(s[(i+A)%n][(j+B)%n] != s[(j+A)%n][(i+B)%n]) return false;
    return true;
}
int main()
{
    n = read(); for(int i = 0; i < n; ++i) scanf("%s", s[i]);
    for(int i = 0; i < n; ++i) if(valid(i, 0)) ans += n-i;
    for(int i = 1; i < n; ++i) if(valid(0, i)) ans += n-i;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <queue>
#define int long long
#define S 1
#define T 2
#define X(x) x + 1000
#define Y(x) x + 2000
#define LX(x) 3000 + x
#define LY(x) 4000 + x

const int N = 5e3 + 35, M = 4e6 + 64, INF = 0x3f3f3f3f3f3f3f3f;
const char _[] = "UDLR";
struct edge {
	int to, next, w;
	int c;
} e[M << 1];
int head[N], cnt = 1;
void addedge(int x, int y, int z, int w) {
	e[++cnt] = (edge){y, head[x], z, w}, head[x] = cnt;
	e[++cnt] = (edge){x, head[y], 0, -w}, head[y] = cnt;
}
void ek(int s, int t, int& n, int& m) {
	std::queue<int> q;
	static int dis[N], fl[N], pre[N], vis[N];
	for (n = m = 0; (memset(dis, 0x3f, sizeof dis), fl[s] = INF, dis[s] = 0), 1; n += fl[t], m += fl[t] * dis[t]) {
		for (q.push(s); !q.empty(); q.pop())
			for (int x = q.front(), i = head[x], nx = vis[x] = 0; i; i = e[i].next)
				if (dis[nx = e[i].to] > dis[x] + e[i].c && e[i].w)
					dis[nx] = dis[x] + e[i].c, pre[nx] = i, fl[nx] = std::min(fl[x], e[i].w),
					(vis[nx] || (q.push(nx), vis[nx] = 1));
		if (dis[t] == INF) return;
		for (int i = pre[t]; i; i = pre[e[i ^ 1].to]) e[i].w -= fl[t], e[i ^ 1].w += fl[t];
	}
}

int n, m, op[N], a[N], b[N], x[N], y[N], z[N];
int check(int k) {
	static int U[N], D[N], L[N], R[N];
	for (int i = 1; i <= k; i++) L[i] = D[i] = 0, R[i] = U[i] = 100;
	for (int i = 1; i <= m; i++) {
		if (op[i] == 0) U[k - b[i]] = a[i] - 1;
		if (op[i] == 1) D[b[i] + 1] = a[i] + 1;
		if (op[i] == 2) L[b[i] + 1] = a[i] + 1;
		if (op[i] == 3) R[k - b[i]] = a[i] - 1;
	}
	for (int i = 2; i <= k; i++) L[i] = std::max(L[i], L[i - 1]), D[i] = std::max(D[i], D[i - 1]);
	for (int i = k - 1; i >= 1; i--) R[i] = std::min(R[i], R[i + 1]), U[i] = std::min(U[i], U[i + 1]);
	memset(head, 0, sizeof head), cnt = 1;
	for (int i = 1; i <= n; i++) addedge(X(x[i]), Y(y[i]), 1, -z[i]);
	for (int i = 1; i <= k; i++) {
		if (L[i] > R[i] || D[i] > U[i]) return 0;
		addedge(S, LX(i), 1, 0), addedge(LY(i), T, 1, 0);
		for (int j = L[i]; j <= R[i]; j++) addedge(LX(i), X(j), 1, 0);
		for (int j = D[i]; j <= U[i]; j++) addedge(Y(j), LY(i), 1, 0);
	}
	int n, m;
	ek(S, T, n, m);
	return n == k ? -m : 0;
}

int phead[N], pcnt;
char c[2];
int ans;
signed main() {
	scanf("%lld", &n);
	for (int i = 1; i <= n; i++) scanf("%lld%lld%lld", x + i, y + i, z + i);
	scanf("%lld", &m);
	for (int i = 1; i <= m; i++) scanf("%s%lld%lld", c, a + i, b + i), op[i] = strchr(_, *c) - _;
	for (int i = 1; i <= n; i++) ans = std::max(ans, check(i));
	printf("%lld", ans);
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    int V[25],C[25];
    for(int i=0;i<N;i++){
        cin >> V[i];
    }
    for(int i=0;i<N;i++){
        cin >> C[i];
    }
    int ans=0;
    for(int i=0;i<N;i++){
        ans+=max(0,V[i]-C[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};


int main()
{
    int A,B;
    cin >> A>>B;
    if(A <= 2 * B){
        cout <<0 << endl;
    }
    else{
        cout << A - 2 * B << endl;
    }
}


Measured memory_bytes: 3592
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		
		long mod = 1_000_000_007;
		
		long power = 1;
		for (int i = 1; i <= N; i++) {
			power *= i;
			power %= mod;
		}
		
		System.out.println(power);		
	}
}


Measured memory_bytes: 21972
import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		int cnt = 0;
		for(int n=1;n<b-a;n++){
			cnt += n;
		}
		System.out.println(cnt-a);

	}
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main () {
	int a , b , h , m , s ;
	cin >> a ;
	h = a / 3600;
	b = a % 3600;
	m = b / 60;
	s = b % 60;
	cout << h << ":" << m << ":" << s << endl;

	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define ALL(v) v.begin(),v.end()
typedef long long ll;
int main() {
  string s,t;
  cin >> s >> t;
  cout << t << s << endl;
}


Measured memory_bytes: 256
// Author: Jinhai Chen
#include <cstring>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long ll;
int c[34];
bool ok() {
	for(int i=1;i<=4;i++) {
		if(c[i]>2) return false;
	}
	return true;
}

int main() {
#ifdef CJHCJH
	freopen("data.in","r",stdin);
#endif
	ios::sync_with_stdio(false);
	int n,k,a;
	for(int i=0;i<6;i++) {
		cin>>a;
		c[a]++;
	}
	if(ok()) puts("YES");
	else puts("NO");


	return 0;
}














Measured memory_bytes: 256