akhauriyash/Code-Regression huggingface dataset:
// template {{{

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

#define loop(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) loop(i, 0, n)
#define rloop(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define rrep(i, n) rloop(i, 0, n)
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define mp std::make_pair
#define mt std::make_tuple
#define fi first
#define se second

using ll = long long;
using ull = unsigned long long;

template<typename T, size_t H, size_t W>
using matrix = std::array<std::array<T, W>, H>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 10;
const ll LLINF = 1e18 + 10;

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

template<typename T>
inline T sq(T x){ return x * x; }

template<typename T, typename U>
inline void chmax(T &x, U y){ x = std::max<T>(x, y); }

template<typename T, typename U>
inline void chmin(T &x, U y){ x = std::min<T>(x, y); }

template<typename T>
inline void sort(T &c){ std::sort(std::begin(c), std::end(c)); }

template<typename T>
inline void reverse(T &c){ std::reverse(std::begin(c), std::end(c)); }

template<typename T>
inline void unique(T &c){ std::sort(c); c.erase(std::unique(std::begin(c), std::end(c))); }

// }}}

string toString(ll x){
	stringstream ss;
	ss << x;
	return ss.str();
}

ll pow_10[20];

ll calc(ll a, ll b)
{
	assert(toString(a).size() == toString(b).size());
	ll n = toString(a).size();
	ll fz = b / 3 - (a - 1) / 3;
	ll bz = b / 5 - (a - 1) / 5;
	ll fb = b / 15 - (a - 1) / 15;
	return n * ((b - a + 1) - (fz + bz - fb)) + 4 * (fz + bz);
}

ll calc2(ll x)
{
	ll len = 0;
	for (int i = 0;; i++){
		ll a = pow_10[i], b = min(pow_10[i + 1] - 1, x);
		if (a > x) break;
		len += calc(a, b);
	}
	return len;
}

int main()
{
	pow_10[0] = 1;
	rep(i, 19) pow_10[i + 1] = pow_10[i] * 10;
	
	ll s;
	cin >> s, s--;

	ll lb = 0, ub = 5e17;
	while (ub - lb > 1){
		ll md = (lb + ub) / 2;
		(calc2(md) <= s ? lb : ub) = md;
	}

	ll len = calc2(lb);

	string res;
	rep(i, 20){
		ll x = ub + i;
		if (x % 3 == 0) res += "Fizz";
		if (x % 5 == 0) res += "Buzz";
		if (x % 3 != 0 && x % 5 != 0) res += toString(x);
	}
	
	rep(i, 20){
		cout << res[s - len + i];
	}
	cout << endl;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  int n,c;
  string s;
  cin >> n >> s;
  c = n;
  for(int i = 1;i<n;i++)
  {
      if(s[i-1] == s[i])
      {
          c--;
          s[i-1] = 0;
      }
  }
  cout << c << endl;
  return 0;
}



Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<utility>

using namespace std;

int n;

bool judge(int num)
{
	int cnt = 0;

	for (int i = 2; i < num;i++)
	{
		if (num%i==0)
		{
			cnt = 1;

			return false;
		}
	}

	return true;


}

int main(void)
{
	while (cin >> n, n)
	{
		for (int i = n; i > 2;i--)
		{
			if (judge(i)&&judge(i-2))
			{
				cout << i - 2 << " " << i << endl;
				break;
			}
		}

	}


	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
struct cmp1
{
    bool operator () (int &a, int &b)
    {
        return a > b ;
    }
};
int main()
{
    char a[10];
    cin>>a;
    for(int i=0;i<sizeof(a);i++)
    {
        if(a[i]=='A'&&a[i+1]=='C')
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var line = consoleReader.SplitInt();
            var A = line[0];
            var P = line[1];
            var p = 3 * A + P;
            return p / 2;
        }

        public const int mod = 1000000007;
        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc()); static string MultiLine<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

    public class ConsoleReader { public virtual string String() => Console.ReadLine(); public int Int() => int.Parse(String()); public long Long() => long.Parse(String()); public ulong ULong() => ulong.Parse(String()); public double Double() => double.Parse(String()); public string[] Split() => String().Split().ToArray(); public int[] SplitInt() => String().Split().Select(int.Parse).ToArray(); public long[] SplitLong() => String().Split().Select(long.Parse).ToArray(); public ulong[] SplitULong() => String().Split().Select(ulong.Parse).ToArray(); public double[] SplitDouble() => String().Split().Select(double.Parse).ToArray(); public IEnumerable<string> Repeat(int count) { for (int i = 0; i < count; i++) yield return String(); } public IEnumerable<int> RepeatInt(int count) { for (int i = 0; i < count; i++) yield return Int(); } public IEnumerable<long> RepeatLong(int count) { for (int i = 0; i < count; i++) yield return Long(); } public IEnumerable<string[]> RepeatSplit(int count) { for (int i = 0; i < count; i++) yield return Split(); } public IEnumerable<int[]> RepeatSplitInt(int count) { for (int i = 0; i < count; i++) yield return SplitInt(); } }
}

Measured memory_bytes: 11348
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    S = input_raw[0]
    input_raw = read_func().strip().split()
    [K] = [int(input_raw[0])]
    s = S[K - 1]
    new_S = ""
    for i in range(N):
        if S[i] != s:
            new_S += "*"
        else:
            new_S += S[i]
    print new_S


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N; cin >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    vector<vector<int>> G(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b; cin >> a >> b; a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    auto dfs = [&](auto& dfs, int node, int pre) -> int {
        int ans = -1;
        for (int nxt : G[node]) if (nxt != pre && A[nxt] < A[node]) {
            ans = max(ans, -dfs(dfs, nxt, node));
        }
        return ans;
    };
    vector<int> ans(N);
    for (int root = 0; root < N; root++) {
        int res = dfs(dfs, root, -1);
        if (res > 0) ans[root] = 1;
    }
    for (int i = 0; i < N; i++) if (ans[i]) cout << i + 1 << ' ';
    cout << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

int h, w;
string s[20];

int bfs(int p, int q);

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

	int mx = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '.') {
				mx = max(mx, bfs(i, j));
			}
		}
	}
	cout << mx << endl;

	return 0;
}

int bfs(int p, int q)
{
	int map[20][20];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			map[i][j] = -1;
		}
	}

	queue<pair<pair<int, int>, int>> que;
	que.push(make_pair(make_pair(p, q), 0));
	while (!que.empty()) {
		int x = que.front().first.first;
		int y = que.front().first.second;
		int dist = que.front().second;
		que.pop();

		if (map[x][y] != -1) {
			continue;
		}
		map[x][y] = dist;

		int dx[] = { 0, -1, 0, 1 };
		int dy[] = { -1, 0, 1, 0 };
		for (int i = 0; i < 4; i++) {
			if (x + dx[i] >= 0 && x + dx[i] < h &&
				y + dy[i] >= 0 && y + dy[i] < w &&
				s[x + dx[i]][y + dy[i]] == '.') {
				que.push(make_pair(make_pair(x + dx[i], y + dy[i]), dist + 1));
			}
		}
	}
	
	int mx = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			mx = max(mx, map[i][j]);
		}
	}
	return mx;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;
ll N;
ll num[105000];
atcoder::modint998244353 beki[105000];
atcoder::modint998244353 Factorial[105000];
using mint = atcoder::modint998244353;
struct A {
    vector<mint> v;
};

bool operator<(A a, A b) {
    return a.v.size() > b.v.size();
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    beki[0] = 1;
    Factorial[0] = 1;
    for(int i = 1; i <= 100000; i++) {
        beki[i] = beki[i-1] * 2;
        Factorial[i] = Factorial[i-1] * i;
    }
    for(int i = 0; i < 2 * N; i++) {
        ll a;
        cin >> a;
        num[a]++;
    }
    priority_queue<A> que;
    que.push({{1}});
    for(int i = 0; i <= 100000; i++) {
        if(num[i] <= 1) continue;
        vector<atcoder::modint998244353> v;
        atcoder::modint998244353 now = 1;
        v.push_back(1);
        for(int j = 1; j * 2 <= num[i]; j++) {
            now *= num[i] - j * 2 + 2;
            now *= num[i] - j * 2 + 1;
            now /= 2;
            now /= j;
            v.push_back(now);
            //cerr << i << " " << num[i] << " " << j << " " << now.val() << endl;
        }
        que.push({v});
    }
    while(que.size() >= 2) {
        auto v = que.top();
        que.pop();
        auto w = que.top();
        que.pop();
        auto u = atcoder::convolution(v.v, w.v);
        que.push({u});
    }
    auto v = que.top().v;
    mint ans = 0;
    for(int i = 0; i < v.size(); i++) {
        mint tmp = v[i];
        ll rest = 2 * N - i * 2;
        tmp *= Factorial[rest];
        tmp /= beki[rest/2];
        tmp /= Factorial[rest/2];
        //cerr << i << " " << tmp.val() << endl;
        if(i % 2 == 0) ans += tmp;
        else ans -= tmp;
    }
    cout << ans.val() << endl;
    return 0;
}

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

using namespace std;


int main() { 
    string s;
    while (cin >> s) {
        int n = s.length();
        int cnt = 0;
        for (int i = 1; i < n; ++i) {
            if (s[i] != s[i-1]) ++cnt;
        }
        cout << cnt << "\n";
    }

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> c(n - 1), s(n - 1), f(n - 1);
    for (int i = 0; i < n - 1; i++) {
        cin >> c[i] >> s[i] >> f[i];
    }

    for (int i = 0; i < n - 1; i++) {
        int cur = s[i] + c[i];
        for (int j = i + 1; j < n - 1; j++) {
            if (s[j] <= cur) {
                if ((cur - s[j]) % f[j] == 0) {
                    cur += c[j];
                } else {
                    cur += f[j] - ((cur - s[j]) % f[j]) + c[j];
                }
            } else {
                cur = s[j] + c[j];
            }
        }

        cout << cur << endl;
    }

    cout << "0" << endl;
}


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

using namespace std;

int n;
map<string, int> ans;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    while (n--) {
        string s;
        cin >> s;
        ++ans[s];
    }
    vector<string> v{"AC", "WA", "TLE", "RE"};
    for (string s : v) {
        cout << s << " x " << ans[s] << endl;
    }
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i, m, n) for(int i = (int)m; i < (int)n; i++)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int a; cin >> a;
    double aa = a;
    cout << (a%2 == 0 ? 0.5 : (aa+1)/(2*aa))  <<'\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    P a[n];

    rep(i, n) cin >> a[i].first;
    rep(i, n) cin >> a[i].second;
    int f[n];
    rep(i, n) f[i] = a[i].first - a[i].second;
    //rep(i, n) cout << f[i] << endl;
    int g = 0;
    rep(i, n) if(f[i] > 0) {
        g += f[i];
        //cout << g << endl;
    }
    cout << g << endl;



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int count = 0,max = 0;
    for(int i = 0;i < s.size();i++)
    {
        if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C')
        {
            count++;
        }
        else
        {
            count = 0;
        }
        if(count > max)
        {
            max = count;
        }
    }
    cout << max;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int,int> P;
const int INF=1e9;
int main(){
    int h,w,ans=0;
    cin>>h>>w;
    vector<vector<char>> a(h,vector<char>(w));
    vector<vector<int>> dist(h,vector<int>(w,INF));
    queue<P> que;
    rep(i,h) rep(j,w){
        cin>>a[i][j];
        if(a[i][j]=='#'){
            que.push(P(i,j));
            dist[i][j]=0;
        }
    }
    const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
    while(que.size()){
        P p=que.front();que.pop();
        rep(i,4){
            int nx=p.first+dx[i],ny=p.second+dy[i];
            if(0<=nx&&nx<h&&0<=ny&&ny<w&&dist[nx][ny]==INF){
                que.push(P(nx,ny));
                dist[nx][ny]=dist[p.first][p.second]+1;
                ans=dist[nx][ny];
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 16168
#include <iostream>
using namespace std;
int main(void){
    int N,Y;
    cin >> N >> Y;
    for(int ichiman = 0; ichiman < N+1; ichiman++)
    {
        for(int gosen = 0; gosen < N+1; gosen++)
        {
            int sen = N - ichiman - gosen;
            if((10000*ichiman+5000*gosen+1000*sen)==Y && sen >= 0)
            {
                cout << ichiman << " " << gosen << " " << sen << endl;
                exit(0);
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
//おまじない
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn=100000;

int n;
string s;

int main(){
    
    cin >> s;
    int size = s.size();
    if(size%2==0){
        if(s[0]==s[size-1]){
            cout << "First"<<endl;
        }else{
            cout << "Second"<<endl;
        }
    }else{
        if(s[0]==s[size-1]){
            cout <<"Second"<<endl;
        }else{
            cout <<"First"<<endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 512
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String args[]) {
        int n = sc.nextInt();
        int d = sc.nextInt();

        double d2 = 2*d+1;
        double ans = n/d2;

        pw.println((int)Math.ceil(ans));
        pw.flush();
    }

    static FastScanner sc = new FastScanner();
    static PrintWriter pw = new PrintWriter(System.out);
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


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

typedef long long ll;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 999999999
#define DEBUG(s) cout << s << endl

using namespace std;

int hogenum = 0;
long long nums[100000];
void make(int i, string s, bool three, bool five, bool seven) {
    if (i == 10) {
        if (!three || !five || !seven)
            return;
        nums[hogenum] = stoll(s);
        hogenum++;
        return;
    }

    make(i + 1, "3" + s, true, five, seven);
    make(i + 1, "5" + s, three, true, seven);
    make(i + 1, "7" + s, three, five, true);
    if (i > 0)
        make(10, s, three, five, seven);
}

int main() {
    long long n;
    cin >> n;
    make(0, "", false, false, false);
    int ans = 0;
    for (int i = 0; i < hogenum; i++) {
        if (nums[i] <= n)
            ans++;
    }
    cout << ans;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main(){
  int arr[5];
  for(int i=0;i<5;i++){
    cin>>arr[i];
  }
  for(int i=0;i<5;i++){
    if(arr[i]==0)cout<<i+1<<endl;
  }
  return 0;
}

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

int main (void) {
    char    s[101];
    int     s_len;
    int     i;
    char    *ans = "Yes";

    scanf("%s", s);
    s_len = strlen(s);

    for ( i=0; i<s_len; i++ ) {
        if ( (i%2 == 1 && s[i] == 'R') ||
             (i%2 == 0 && s[i] == 'L') )
            ans = "No";
    }

    printf("%s\n", ans);
    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
	long long x;
	cin >> x;
	long long ans=x/11*2;
	if(x-(ans*11/2)>6){
		ans+=2;
	}else if(x-(ans*11/2)>0){
		ans+=1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    vector<int> v(5);
    for(int i=0; i<5; ++i)
        cin >> v[i];

    int k;
    cin >> k;
    if(v[4] - v[0] > k)
        cout << ":(" << endl;
    else
        cout << "Yay!" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+7 , mz = 1e9+7;
int p[N];
int f[N];
int n,m;

int finds(int x){return f[x]==x?x:f[x]=finds(f[x]);}

int main(){
    cin>>n>>m;
    int x,y;
    for(int i = 1 ; i <= n ; i++)   scanf("%d",&x) , f[i] = i ,  p[x] = i;
    for(int j = 1 ; j <= m ; j++){
        scanf("%d%d",&x,&y);
        x = finds(x);
        y = finds(y);
        if( x != y ){
            f[x] = y;
        }
    }
    y = 0;
    for(int i = 1 ; i <= n ; i++){
        if( finds(p[i]) == finds(i) ){
            y++;
        }
    }
    cout<<y<<endl;
    return 0;
}


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

using namespace std;

int N;
vector<int> a;
vector<int> memoX, memoY;
int fY(int X);

int fX(int Y)
{
    if (memoX[Y] >= 0)
        return memoX[Y];

    int ans = 0;
    for (int i=Y+1; i<N+1; i++)
        ans = max(ans, fY(i));
    ans = max(ans, abs(a[N+1] - a[Y]));
    //cout<<"fX "<<Y<<" "<<ans<<endl;
    return memoX[Y] = ans;
}

int fY(int X)
{
    if (memoY[X] >= 0)
        return memoY[X];

    int ans = 1000000000;
    for (int i=X+1; i<N+1; i++)
        ans = min(ans, fY(i));
    ans = min(ans, abs(a[N+1] - a[X]));
    //cout<<"fY "<<X<<" "<<ans<<endl;
    return memoY[X] = ans;
}

int main()
{
    cin>>N;
    a = vector<int>(N+2);
    cin>>a[0]>>a[1];
    for (int i=0; i<N; i++)
        cin>>a[i+2];

    memoX = vector<int>(N+2, -1);
    memoY = vector<int>(N+2, -1);

    cout<<fX(1)<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef pair<ut,ut> prs;
const int SIZE=2*1e5;
const LL p=7+1e9;
LL A[SIZE];
VI edges[SIZE];
inline void IN(ut &x){cin >> x;}
inline void INA(ut n,ut x[]){REP(i,n) cin >> x[i];}
inline void INE(ut m,VI edges[]){
	ut a,b;
	REP(i,m){
		cin >> a >> b;
		edges[a].PB(b);
		edges[b].PB(a);
	}
}
inline void INEC(ut m,Vpr edges[]){
	ut a,b,c;
	REP(i,m){
		cin >> a >> b >> c;
		edges[a].PB(pr(c,b));
		edges[b].PB(pr(c,a));
	}
}
bool reached[SIZE];
VI path[2];
void dfs(int now,int ind){
	queue<int> qu;
	reached[now]=true;
	qu.push(now);
	while(!qu.empty()){
		int now=qu.front();
		path[ind].PB(now);

		qu.pop();	
		REP(i,edges[now].size()){
			int next=edges[now][i];
			if(!reached[next]){
				reached[next]=true;
				qu.push(next);
				break;
			}
		}

	}
}
int main(){
	LL N,M;
	cin >> N >> M;
	INE(M,edges);
	int times=0;
	path[0].PB(1);
	reached[1]=true;
	REP(i,edges[1].size()){
		int next=edges[1][i];
		if(!reached[next]){
			dfs(next,times);
			times++;
		}
		if(times==2) break;
	}
	cout << path[0].size()+path[1].size() << endl;
	REP(i,path[0].size()){
		int next=path[0][path[0].size()-1-i];
		if(i) cout << " ";
		cout << next;
	} 
	REP(i,path[1].size()){
		cout << " " << path[1][i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 10868
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(){
char A[1300];
  int i;
  
   fgets(A, sizeof(A), stdin);
  //scanf("%s",A);
  //printf("%d\n",strlen(A));
  for(i=0;i<strlen(A);i++){
  	if(isalpha(A[i])){
      if(islower(A[i])){
      	printf("%c",toupper(A[i]));
      }
      else if(isupper(A[i])){
      	printf("%c",tolower(A[i]));
      }
    }
    else{
      printf("%c",A[i]);
    }
  }
 
  return 0;
  
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

/*
ll Lucas(int N){
  if (N == 0) return 2;
  else if (N == 1) return 1;
  else return Lucas(N - 1) + Lucas(N - 2);
}
*/

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

  vector <ll> L(87);
  L.at(0) = 2;
  L.at(1) = 1;
  if (N == 1) cout << L.at(1) << endl;
  else{
    for (int i = 2; i <= N; i++){
      L.at(i) = L.at(i - 2) + L.at(i - 1);
    }
    cout << L.at(N) << endl;
  }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
long long n,k,w[105],v[105],dp[105][100005];
long long f(long long idx, long long wg){
    if(wg>k)return -1e18;
    if(idx>n)return 0;
    
    if(dp[idx][wg]!=-1)return dp[idx][wg];
    return dp[idx][wg] = max( v[idx]+f(idx+1,wg+w[idx]),f(idx+1,wg));
}
int main(){
    cin>>n>>k;
    for(long long i =1;i<=n;i++)cin>>w[i]>>v[i];
    memset(dp,-1,sizeof(dp));
    cout<<f(1,0)<<endl;
}

Measured memory_bytes: 82304
// parameter "input" gets all data
function Main(input) {
  var r = parseInt(input, 10);
  var result = 'AGC';

  if (r < 1200) {
    result = 'ABC';
  } else if (r < 2800) {
    result = 'ARC'
  }

  console.log(result);
}
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define INF 1000000007
#define ll long long
#define F first
#define S second
#define pii pair<ll int,ll int>
#define pb push_back
#define ppb pop_back
#define vi vector<ll int>
#define f(a, b) for(auto i = a;i < b;i++)


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string str;
	cin >> str;
	ll q;
	cin >> q;

	vector < char > front, back;
	ll flag = 0;
	f(0, q)
	{
		ll a, cnt = 0;
		cin >> a;
		if(a == 1)
		{
			flag ++;
		}
		else
		{
			ll b;
			char c;
			cin >> b >> c;
			if(b == 1)
			{
				if(flag%2 == 0)
					front.push_back(c);
				else
					back.push_back(c);
			}
			else
			{
				if(flag%2 == 0)
					back.push_back(c);
				else
					front.push_back(c);
			}
		}
	}
	if(flag % 2 == 0)
		reverse(front.begin(), front.end());
	else
	{
		reverse(str.begin(), str.end());
		reverse(back.begin(), back.end());
	}

	if(flag % 2 == 0)
	{
		f(0, front.size())
			cout << front[i];
		cout << str;
		f(0, back.size())
			cout << back[i];
		cout << "\n";
	}
	else
	{
		f(0, back.size())
			cout << back[i];
		cout << str;
		f(0, front.size())
			cout << front[i];
		cout << "\n";
	}

	return 0;
}


Measured memory_bytes: 976
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
using namespace std;

#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        string s;
        cin>>s;
        if(s[0]==s[1]||s[2]==s[1]||s[3]==s[2])
        {
        	cout<<"Bad";
        }
        else
        	cout<<"Good";
    }
    return 0;
}

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

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

    for(int i=1;i<n;i++) if(a[i]+a[i+1]>=l){
        printf("Possible\n");
        for(int j=n-1;j>i;j--) printf("%d\n",j);
        for(int j=1;j<i;j++) printf("%d\n",j);
        printf("%d",i);
        return 0;
    }

    printf("Impossible");
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
 
vector<pair<int, ll> > path[100005];
int par[100005];
int dep[100005];
int siz[100005];
ll cst[100005];
int hev[100005];
void dfs(int a){
	siz[a]=1;
	for(int i=0; i<path[a].size(); i++){
		int d=path[a][i].first;
		if(d==par[a]) continue;
		par[d]=a;
		dep[d]=dep[a]+1;
		cst[d]=path[a][i].second;
		dfs(d);
		siz[a]+=siz[d];
		if(!hev[a] || siz[hev[a]]<siz[d])
			hev[a]=d;
	}
}
 
ll k;
ll add[100005];
ll edgecost(int a){
	ll ret=add[a]+add[par[a]]+cst[a];
	return ret%k?ret:0;
}
 
int pos[100005];
int hl_par[100005];
 
ll bit[100005];
ll sum(int i){
	ll ret=0;
	while(i){
		ret+=bit[i];
		i-=i&-i;
	}
	return ret;
}
void set(int i, ll x){
	// printf("set %d %lld\n", i, x);
	x-=sum(i+1)-sum(i);
	i++;
	while(i<100005){
		bit[i]+=x;
		i+=i&-i;
	}
}
 
int lca(int a, int b){
	int p=hl_par[a], q=hl_par[b];
	if(p==q) return dep[a]<dep[b]?a:b;
	if(dep[p]<dep[q]) return lca(a, par[q]);
	else return lca(par[p], b);
}
ll cost(int a){
	ll ret=0;
	while(a){
		int p=hl_par[a];
		ret+=sum(pos[a])-sum(pos[p]);
		if(p) ret+=edgecost(p);
		// printf("%d->%d:%lld %d->%d:%lld\n", a, p, sum(pos[a])-sum(pos[p]), p, par[p], edgecost(p));
		a=par[p];
	}
	return ret;
}
 
int main(){
	int n;
	cin >> n >> k;
	for(int i=0; i<n-1; i++){
		int a, b;
		ll c;
		cin >> a >> b >> c;
		path[a].push_back(make_pair(b, c));
		path[b].push_back(make_pair(a, c));
	}
	for(int i=0; i<n; i++) hev[i]=0;
	par[0]=dep[0]=cst[0]=0;
	dfs(0);
 
	for(int i=0; i<n; i++) add[i]=0;
 
	int cnt=0;
	for(int i=0; i<n; i++) pos[i]=-1;
	for(int i=0; i<n; i++){
		if(i && hev[par[i]]==i) continue;
		int j=i;
		do{
			// printf("%d ", j);
			pos[j]=cnt++;
			hl_par[j]=i;
		}while(j=hev[j]);
	}
	// printf("\n");

	for(int i=0; i<100005; i++) bit[i]=0;
	for(int i=0; i<n; i++)
		set(pos[i], edgecost(hev[i]));
	 
	int q;
	cin >> q;
	for(int i=0; i<q; i++){
		string s;
		ll a, b;
		cin >> s >> a >> b;
		if(s[0]=='a'){
			add[a]+=b;
			// for(int i=0; i<10; i++) printf("%lld ", sum(i)); printf("\n");
			set(pos[a], edgecost(hev[a]));
			if(a) set(pos[a]-1, edgecost(a));
			// for(int i=0; i<10; i++) printf("%lld ", sum(i)); printf("\n");
		}else{
			cout << (cost(a)+cost(b)-2*cost(lca(a, b))) << endl;
		}
	}
}

Measured memory_bytes: 20920
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++) {
        cin >> a[i];
    }

    int tmp = 0;
    for(auto e: a) {
        tmp ^= e;
    }

    for(auto e: a) {
        cout << (e ^ tmp) << endl;
    }
    return 0;
}


Measured memory_bytes: 4056
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int n;
    cin>>n;
  vector<int>v;
    for(int i=111;i<=999;i=i+111)
    {
        v.push_back(i);
    }
    if(n<=v.front())
    {
        cout<<v.front()<<endl;
        return 0;
    }
    for(int i=0;i<9;i++)
    {
        if(n>v[0]&&n<=v[1]){
            cout<<"222"<<endl;
            break;
        }
        else if(n>v[1]&&n<=v[2]){
            cout<<"333"<<endl;
            break;
        }
        else if(n>v[2]&&n<=v[3]){
            cout<<"444"<<endl;
            break;
        }
            else if(n>v[3]&&n<=v[4]){
            cout<<"555"<<endl;
            break;
            }
            else if(n>v[4]&&n<=v[5]){
            cout<<"666"<<endl;
            break;
            }
            else if(n>v[5]&&n<=v[6]){
            cout<<"777"<<endl;
            break;
            }
            else if(n>v[6]&&n<=v[7]){
            cout<<"888"<<endl;
            break;
            }
            else if(n>v[7]&&n<=v[8]){
            cout<<"999"<<endl;
            break;
        }
    }
return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<map>
#include<set>
using namespace std;
#define LL long long 
int n,t[200000],a[200000],b[200000];
int main()
{
	while(cin>>n)
	{
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d%d",&t[i],&a[i],&b[i]);
		}
		int x=0,s=0,v=0;
		for(int i=1;i<=n;i++)
		{
			s=t[i]-t[i-1];
			x=abs(a[i]-a[i-1])+abs(b[i]-b[i-1]);
			if(x>s||(x<s&&(s-x)%2==1)){v=1;break;}
		}
		if(v)printf("No\n");
		else printf("Yes\n");
	}
	return 0;
}


Measured memory_bytes: 1408
solve :: Int -> Int -> Int -> Int -> String
solve s1 s2 s3 s4 = case (b1, b2) of
  (True, True)   -> "AMBIGUOUS"
  (True, False)  -> "MMYY"
  (False, True)  -> "YYMM"
  (False, False) -> "NA"
  where isMonth d1 d2 = d1 * 10 + d2 `elem` [1..12]
        b1 = isMonth s1 s2
        b2 = isMonth s3 s4

main :: IO ()
main = do
  [s1, s2, s3, s4] <- map (read . (:[])) <$> getLine
  putStrLn $ solve s1 s2 s3 s4

Measured memory_bytes: 508
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

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

    vector<long long> a(N);
    rep(i,N) cin >> a[i];
    long long ans = 0;
    rep(i,N-1) {
        long long diff = a[i] + a[i + 1] - x;
        if (diff <= 0) continue;
        else if (diff <= a[i + 1]) {
            ans += diff;
            a[i + 1] -= diff;
        } else {
            ans += diff;
            a[i] = diff - a[i + 1];
            a[i + 1] = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

type bufReader struct {
	r   *bufio.Reader
	buf []byte
	i   int
}

var reader = &bufReader{
	bufio.NewReader(os.Stdin),
	make([]byte, 0),
	0,
}

func (r *bufReader) readLine() {
	if r.i < len(r.buf) {
		return
	}
	r.buf = make([]byte, 0)
	r.i = 0
	for {
		line, isPrefix, err := r.r.ReadLine()
		if err != nil {
			panic(err)
		}
		r.buf = append(r.buf, line...)
		if !isPrefix {
			break
		}
	}
}

func (r *bufReader) next() string {
	r.readLine()
	from := r.i
	for ; r.i < len(r.buf); r.i++ {
		if r.buf[r.i] == ' ' {
			break
		}
	}
	s := string(r.buf[from:r.i])
	r.i++
	return s
}

func (r *bufReader) nextLine() string {
	r.readLine()
	s := string(r.buf[r.i:])
	r.i = len(r.buf)
	return s
}

var writer = bufio.NewWriter(os.Stdout)

func next() string {
	return reader.next()
}

func nextInt64() int64 {
	i, err := strconv.ParseInt(reader.next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextInt() int {
	return int(nextInt64())
}

func nextLine() string {
	return reader.nextLine()
}

func out(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	return int(max64(int64(x), int64(y)))
}

func min64(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func min(x, y int) int {
	return int(min64(int64(x), int64(y)))
}

func abs64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func abs(x int) int {
	return int(abs64(int64(x)))
}

func joinInt64s(a []int64, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.FormatInt(v, 10)
	}
	return strings.Join(b, sep)
}

func joinInts(a []int, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.Itoa(v)
	}
	return strings.Join(b, sep)
}

func divUp64(x, y int64) int64 {
	return (x + y - 1) / y
}

func divUp(x, y int) int {
	return int(divUp64(int64(x), int64(y)))
}

func gcd64(x, y int64) int64 {
	if x < y {
		x, y = y, x
	}
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func gcd(x, y int) int {
	return int(gcd64(int64(x), int64(y)))
}

func lcm64(x, y int64) int64 {
	return x * y / gcd64(x, y)
}

func lcm(x, y int) int {
	return int(lcm64(int64(x), int64(y)))
}

func pow64(x, y int64) int64 {
	return int64(math.Pow(float64(x), float64(y)))
}

func pow(x, y int) int {
	return int(pow64(int64(x), int64(y)))
}

func main() {
	solve()
	writer.Flush()
}

type pair struct {
	i, j int
}

func solve() {
	out("A" + string(strings.Split(nextLine(), " ")[1][0]) + "C")
}


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

typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ar array
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll mod = 1e9 + 7;
const ll inf = 2e15 + 5;
double PI = 3.14159265358979323846;

void solve() {

    int n, w;
    cin >> n >> w;
    vl wt(n), val(n);
    ll V = 0;
    for (int i = 0; i < n; i++) {
        cin >> wt[i] >> val[i];
        V += val[i];
    }

    vvl dp(n + 1, vl(V + 1, inf));

    dp[0][0] = 0;

    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= V; j++) {
            if(j == 0){
                dp[i][j] = 0;
                continue;
            }

            if (val[i - 1] <= j) {
                dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - val[i - 1]] + wt[i - 1]);
            } else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }

    ll ans = 0;

    for (int value = V; value >= 0; value--) {
        if (dp[n][value] <= w and dp[n][value] != inf) {
            ans = value;
            break;
        }
    }

    cout << ans << endl;

}

int32_t main()
{
    IOS
    // int T; cin >> T; while (T--)
    solve();
    return 0;
}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    string a, b;
    cin>> a>> b;

    string s= a, t= b;

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());


    if(a!= b)
    {
        cout<<  "No\n";
        return 0;
    }

    int n= a.size();
    for(int i=0; i<n; i++)
    {
        if(s==t)
        {
            cout<<  "Yes\n";
            return 0;
        }
        s=s[n-1]+ s;
        s.pop_back();

    }
    cout<<  "No\n";

    return 0;
}




Measured memory_bytes: 3652
h1, m1, h2, m2, k = map(int,input().split())
h_diff = h2 - h1
m_diff = m2 - m1
if m_diff < 0:
  t = (h_diff - 1) * 60 + (60 + m_diff)
else:
  t = h_diff * 60 + m_diff
result = t - k
print(result)

Measured memory_bytes: 9176
#include<iostream>
#include<vector>
using namespace std;
 
int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> c(n);
    for(int i = 0; i < n; i++){
        cin >> c[i];
        for(int j = 0; j < m; j++)cin >> a[i][j];
    }
    int ans = 12345678;
    int all = 1<<n;
    for(int mask = 0; mask < all; mask++){
        vector<int> level(m);
        int cost = 0;
        for(int i = 0; i < n; i++){
            if((mask>>(n-i-1))&1){
                cost += c[i];
                for(int j = 0; j < m; j++){
                    level[j] += a[i][j];
                }
            }
        }
        bool ok = true;
        for(int j = 0; j < m; j++){
            if(level[j] < x) ok = false;
        }
        if(ok) ans = min(ans,cost);
    }
    if(ans == 12345678) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define MAXN 100010
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const int mod = 1e9 + 7;

int main (){
    ll l, r;
    cin >> l >> r;

    if (l/2019LL != r/2019LL || l%2019LL == 0){
        cout << "0" << endl;
    }
    else {
        ll menor = 30000;
        for (ll i=l; i<r; i++){
            for (ll j = l+1; j<=r; j++){
                menor = min(menor, (i*j)%2019);
            }
        }
        cout << menor << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(){
  int n, a, b;

  scanf("%d%d%d", &n, &a, &b);

  if(n*a < b){
    printf("%d\n", n*a);
  }else{
    printf("%d\n", b);
  }
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
signed main(){
	string S;
	cin >> S;
	int count = 0;

	if(S == "SSS"){
		count = 0;
	}else if(S[1] == 'S' || S == "SRS"){
		count = 1;
	}else if(S == "RRR"){
		count = 3;
	}else{
		count = 2;
	}

	cout << count << endl;
 
	return 0;
}

Measured memory_bytes: 3636
N,a,b,c,d = map(int,input().split())

fact = [0]*(N+1)
ifact = [0]*(N+1)
inv = [0]*(N+1)
p=10**9+7

def combination(n):
    fact[0] = 1
    fact[1] = 1
    ifact[0] = 1
    ifact[1] = 1
    inv[1] = 1
    for i in range(2,n+1):
        fact[i] = (fact[i-1]*i)%p
        inv[i] = p - inv[p%i]*(p//i)%p
        ifact[i] = (ifact[i-1]*inv[i])%p
def op(n,k):
    if k<0 or k>n or n<0:
        return 0
    return (fact[n]*ifact[k]*ifact[n-k])%p

combination(N)

dp = [[0]*(N+1) for _ in range(b-a+2)]
dp[0][0] = 1
for i in range(b-a+1):
    step = i+a
    fa = fact[step]
    inv_Af = pow(fact[step],p-2,p)
    for j in range(N+1):
        val = dp[i][j]%p
        if val==0:
            continue
        dp[i+1][j] = (dp[i+1][j] + val)%p
        if j+c*step > N:
            continue
        tmp = pow(fa,(c-1)*(p-2), p)
        for k in range(c,d+1):
            idx = k*step
            if j+idx > N:
                break
            val2 = (op(N-j,idx) * fact[idx])%p
            tmp *= inv_Af
            tmp %= p
            val3 = (val2 * ifact[k]*tmp)%p
            dp[i+1][j+idx] += val*val3
print(dp[-1][-1]%p)


Measured memory_bytes: 132188
#include "bits/stdc++.h"
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T & a, const T & b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7;

lint N, A, B, ind = 0;
lint arr[10000];
lint val[10000];
vector<lint> to[10000];

void dfs(lint curr, lint prev) {
	val[curr] = arr[ind];
	ind++;
	REP(i, to[curr].size()) {
		lint next = to[curr][i];
		if (next == prev) continue;
		dfs(next, curr);
	}
}

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	fill((long long*)val, (long long*)val + sizeof(val) / sizeof(long long), 0);
	REP(i, N - 1) {
		cin >> A >> B; A--; B--;
		to[A].push_back(B);
		to[B].push_back(A);
	}
	REP(i, N) {
		cin >> arr[i];
	}
	sort(arr, arr + N, greater<lint>());
	lint sum = 0;
	REP(i, N - 1) {
		sum += arr[i + 1];
	}
	val[0] = arr[ind];
	ind++;
	REP(i, to[0].size()) {
		dfs(to[0][i], 0);
	}
	cout << sum << endl;
	REP(i, N) {
		cout << val[i] << " ";
	}
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
const int INF = 1001001001;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    ll ans = 1;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    if(n%2){
        rep(i, n){
            if(i%2){
                if(a[i] != i+1){
                    cout << 0 << endl;
                    return 0;
                }
            }else{
                if(a[i] != i){
                    cout << 0 << endl;
                    return 0;
                }
            }

        }
    }else{
        rep(i, n){
            if(i%2){
                if(a[i] != i){
                    cout << 0 << endl;
                    return 0;
                }
            }else{
                if(a[i] != i+1){
                    cout << 0 << endl;
                    return 0;
                }
            }
        }
    }

    rep(j, n/2) ans = (ans*2)%MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int f(int curr,string&a){
	if(curr>=a.length()-2) return 0;
	if(a[curr]!='A') return f(curr+1,a);
	if(a[curr+1]=='B' && a[curr+2]=='C') return 1+f(curr+3,a);
	return f(curr+1,a);
}
int main(){
	int n;
	string s;
	cin>>n>>s;
	cout<<f(0,s);
}

Measured memory_bytes: 3572
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Char
import Data.Int
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> Int -> B.ByteString -> B.ByteString
solve !n !k !s =
  let ch = B.index s k
  in  B.take k s `B.append` B.singleton (toLower ch) `B.append` B.drop (k + 1) s

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  (n, k) <-
    (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine
  s <- B.getLine
  B.putStrLn $ solve n (k - 1) s


Measured memory_bytes: 380
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		BigInteger ba = BigInteger.valueOf(a);
		BigInteger bb = BigInteger.valueOf(b);
		BigInteger gcd = ba.gcd(bb);
		System.out.println(ba.multiply(bb).divide(gcd).toString());
	}
}


Measured memory_bytes: 21844