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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin>>s;
    llong ans=0,cur=0;
    rep(i,(int)s.size()-1) {
        if(s[i]=='A')++cur;
        else if(s[i]=='B'&&s[i+1]=='C')ans+=cur,++i;
        else cur=0;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 720
//一个数组 两两相乘 n*(n-1)/2种方式 求乘积第k小
//可拓展为两个数组
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 100;
ll a[maxn];
int n;
ll k;
bool check(ll x){
	ll cnt = 0;
	for (int i = 0; i < n; i++){
		if (a[i] == 0){
			if (x >= 0)
				cnt += n - 1;
			continue;
		}
		else if (a[i] < 0){
			ll tmp;
			if (x >= 0) tmp = x / a[i];
			else{
				if (x%a[i] == 0)
					tmp = x / a[i];
				else
					tmp = x / a[i] + 1;
			}
			cnt += n - (lower_bound(a, a + n, tmp) - a);
		}
		else{
			ll tmp;
			if (x >= 0)
				tmp = x / a[i];
			else{
				if (x%a[i] == 0)
					tmp = x / a[i];
				else
					tmp = x / a[i] - 1;
			}
			cnt += upper_bound(a, a + n, tmp) - a;
		}
		if (a[i] * a[i] <= x)
			cnt--;
	}
	return cnt / 2 >= k;
}
int main(){

	cin >> n >> k;
	for (int i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	sort(a, a + n);
	ll L = -1e18, R = 1e18;
	ll ans = 0;
	while (L <= R){
		ll mid = (L + R) >> 1;
		if (check(mid))
			ans = mid, R = mid - 1;
		else
			L = mid + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

string modi(string arg){
	string ret="", tmps;
	int n=arg.size(),times=1;
	char tmp=arg[0];
	for(int i=1;i<n;i++){
		if(arg[i] == tmp){
			times++;
		}else{
			stringstream ss;
			ss << times;
			ss >> tmps;
			ret += tmps;
			ret += tmp;
			tmp = arg[i];
			times = 1;
		}
	}
	stringstream ss;
	ss << times;
	ss >> tmps;
	ret += tmps;
	ret += tmp;
	return ret;
}

int main(void){
	string str;
	int n;
	while(cin >> n && n){
		cin >> str;
		for(int i=0;i<n;i++){
			str = modi(str);
		}
		cout << str << endl;
	}
}

Measured memory_bytes: 1064
N = int(input())

max_cnt = 0
res = 1
for i in reversed(range(1, N+1)):
    tmp = i
    cnt = 0
    while i % 2 == 0:
        i /= 2
        cnt += 1
    if cnt > max_cnt:
        max_cnt = cnt
        res = tmp
print(res)

Measured memory_bytes: 3060
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void) {
	//350pot ploblem
	llint n,x,i,ans=0;cin>>n;
	vector<llint>A(n);
	for(i=0;i<n;i++){cin>>A[i];ans+=A[i];cin>>x;A[i]+=x;ans-=x;}

	SO(A);REV(A);
	for(i=0;i<n;i++){
		if(i%2==0){ans+=A[i];}else{ans-=A[i];}
	}
	cout<<ans/2<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.Map.Entry;

public class Main {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map odds = new TreeMap<Integer, Integer>();
        Map evens = new TreeMap<Integer, Integer>();
        for (int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            if (i % 2 == 0) {
                odds.put(tmp, (Integer) odds.getOrDefault(tmp, 0) + 1);
            } else {
                evens.put(tmp, (Integer) evens.getOrDefault(tmp, 0) + 1);
            }
        }

        List<Entry<Integer, Integer>> oddsEList = new ArrayList<Entry<Integer, Integer>>(odds.entrySet());
        Collections.sort(oddsEList, new Comparator<Entry<Integer, Integer>>() {
            public int compare(Entry<Integer, Integer> obj1, Entry<Integer, Integer> obj2) {
                return obj2.getValue().compareTo(obj1.getValue());
            }
        });

        List<Entry<Integer, Integer>> evensEList = new ArrayList<Entry<Integer, Integer>>(evens.entrySet());
        Collections.sort(evensEList, new Comparator<Entry<Integer, Integer>>() {
            public int compare(Entry<Integer, Integer> obj1, Entry<Integer, Integer> obj2) {
                return obj2.getValue().compareTo(obj1.getValue());
            }
        });

        if (!oddsEList.get(0).getKey().equals(evensEList.get(0).getKey())) {
            System.out.println(n - oddsEList.get(0).getValue() - evensEList.get(0).getValue());
        } else {
            if (oddsEList.size() == 1 && evensEList.size() == 1) {
                System.out.println(n / 2);
            } else if (oddsEList.size() == 1) {
                System.out.println(n - oddsEList.get(0).getValue() - evensEList.get(1).getValue());
            } else if (evensEList.size() == 1) {
                System.out.println(n - oddsEList.get(1).getValue() - evensEList.get(0).getValue());
            } else {
                if (oddsEList.get(0).getValue() + evensEList.get(1).getValue() > oddsEList.get(1).getValue()
                        + evensEList.get(0).getValue()) {
                    System.out.println(n - oddsEList.get(0).getValue() - evensEList.get(1).getValue());
                } else {
                    System.out.println(n - oddsEList.get(1).getValue() - evensEList.get(0).getValue());
                }
            }
        }
    }
}

Measured memory_bytes: 66484
import sys
sys.setrecursionlimit(10**7)

class Node:
    def __init__(self, parent, left, right):
        self.parent = parent
        self.left = left  
        self.right = right

def get_height(T, H, u):
    h1, h2 = 0, 0
    if T[u].right is not None:
        h1 = get_height(T, H, T[u].right) + 1
    if T[u].left is not None:
        h2 = get_height(T, H, T[u].left) + 1
    h = max(h1, h2)
    H[u] = h
    return h


def get_depth(T, D, u, d):
    D[u] = d
    if T[u].right is not None:
        get_depth(T, D, T[u].right, d+1) 
    if T[u].left is not None:
        get_depth(T, D, T[u].left, d+1) 

def ret_sibling(T, u):
    parent = T[u].parent
    if parent is None:
        return -1
    if T[parent].left != u:
        ret = T[parent].left
    else:
        ret = T[parent].right
    if ret is None:
        return -1
    return ret

def ret_degree(T, u):
    ret = 2
    if T[u].left is None:
        ret -= 1
    if T[u].right is None:
        ret -= 1
    return ret

n = int(input())
T = {k: Node(None, None, None) for k in range(n)}  
for _ in range(n):
    tmp = list(map(int, input().split()))
    if tmp[1] != -1:
        T[tmp[0]].left = tmp[1]  
        T[tmp[1]].parent = tmp[0]  
    if tmp[2] != -1:
        T[tmp[0]].right = tmp[2]  
        T[tmp[2]].parent = tmp[0]

for k, v in T.items():
    if v.parent is None:
        ROOT = k
        break

D = {}
get_depth(T, D, ROOT, 0)
H = {}
get_height(T, H, ROOT)


def print_for_a_node(u):
    if T[u].parent is None:
        parent = -1
    else:
        parent = T[u].parent

    sib = ret_sibling(T, u)
    deg = ret_degree(T, u)
    node_type = 'internal node' if deg != 0 else 'leaf'
    if parent == -1:
        node_type = 'root'

    print(f'node {u}: parent = {parent}, sibling = {sib}, degree = {deg}, depth = {D[u]}, height = {H[u]}, {node_type}')


for node in range(n):
    print_for_a_node(node)


Measured memory_bytes: 5636
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final long MOD = 1000000007;
	public static void main(String[] args) {
		int i=0,j=0,k=0;
		Scanner sc = new Scanner(in);
		long n = parseLong(sc.next());
		sc.close();
		HashMap<Integer,Long> pri = new HashMap<>();
		for(i=2;i<=n;i++) {
			int tmp=i;
			j=2;
			while(tmp%j==0) {
				tmp/=j;
				if(pri.get(j)==null) {
					pri.put(j, 1L);
				} else {
					pri.put(j,pri.get(j)+1L);
				}
			}
			for(j=3;j*j<=i;j+=2) {
				while(tmp%j==0) {
					tmp/=j;
					if(pri.get(j)==null) {
						pri.put(j, 1L);
					} else {
						pri.put(j,pri.get(j)+1L);
					}
				}
			}
			if(tmp!=1) {
				if(pri.get(tmp)==null) {
					pri.put(tmp, 1L);
				} else {
					pri.put(tmp,pri.get(tmp)+1L);
				}
			}
		}
		long ans=1;
		for (Integer ii: pri.keySet()) {
//			out.printf("%d:%d%n",ii,pri.get(ii));
			ans *= (pri.get(ii)+1L);
			if(ans>=MOD)ans%=MOD;
		}
		out.println(ans);
	}
}


Measured memory_bytes: 21204
#include <iostream>
#include<string.h>
#include<math.h>
#include<algorithm>


using namespace std;

int main() {
	int N, A[200000],B[200000],MAX;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		B[i] = A[i];
	}
	sort(B, B + N);
	MAX = B[N - 1];
	for (int i = 0; i < N; i++) {
		if (A[i] == MAX) {
			cout << B[N - 2] << endl;
		}
		else cout << MAX << endl;
	}
	return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >>a >> b;
    int sum = 0;
    if(a>=b){
        sum += a;
        a--;
    }
    else{
        sum += b;
        b--;
    }
    sum += max(a, b);
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int n=S.size();
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
    string bubun = S.substr(i,j-i+1);
    int m = bubun.size();
    
    bool flag = true;
    for(int k=0;k<m;k++){
      char c = bubun[k];
      if(c!='A'&&c!='C'&&c!='G'&&c!='T'){
        flag=false;
        break;
      }
    }
    if(flag){
      ans=max(ans,m);
    }
  }
  }
  cout<< ans<< endl;
}


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

using namespace std;
using ll = long long;

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

int main() {
  int n, k;
  cin >> n >> k;
  int v[n];
  rep(i, n) cin >> v[i];

  int ans = 0;

  for (int a = 0; a <= min(n, k); ++a) {
    for (int b = 0; b <= min(n, k) - a; ++b) {
      vector<int> g;
      int now = 0;
      rep(i, a) {
        g.push_back(v[i]);
        now += v[i];
      }
      rep(i, b) {
        g.push_back(v[n - i - 1]);
        now += v[n - i - 1];
      }
      sort(g.begin(), g.end());

      int res = k - (a + b);
      int m = g.size();
      rep(i, min(res, m)) {
        if (g[i] > 0) break;
        now -= g[i];
      }

      ans = max(ans, now);
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int x, y;
  while (1) {
    cin >> x >> y;
    if ((x == 0) && (y == 0)) {
      break;
    }
    if (x < y) {
      cout << x << ' ' << y << endl;
    } else {
      cout << y << ' ' << x << endl;
    }
    
  }
}

Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1; return;}
#define yes {cout << "Yes"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

const int N = 1e5 + 7;

int p[N];

void solve() {
    int n, m;
    string s;
    cin >> n >> m >> s;
    deque <pi> q;
    q.pb({ 0, 0 });
    loop1(i, n) {
        if (q.empty())
            no;
        if (s[i] == '0') {
            p[i] = q.front().S;
            pi newp = { q.front().F + 1, i };
            while (q.back().F > newp.F)
                q.pop_back();
            q.pb(newp);
        }
        if (q.front().S == i - m)
            q.pop_front();
    }
    vector <int> ans;
    for (int i = n; i; i = p[i])
        ans.pb(i - p[i]);
    reverse(all(ans));
    for (int x : ans)
        cout << x << " ";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 5252
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>


template<typename T, typename U>
std::enable_if_t<std::rank<T>::value == 0> fill_all(T& arr, const U& v) {
    arr = v;
}
template<typename ARR, typename U>
std::enable_if_t<std::rank<ARR>::value != 0> fill_all(ARR& arr, const U& v) {
    for (auto& i : arr) {
        fill_all(i, v);
    }
}

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t D;
int32_t C[30];
int32_t S[400][30];

int32_t res[400];
void greedy1()
{
    int32_t last[40] = {};
    fill_all(last, -1);
    for (int32_t d = 0; d < D; d++)
    {
        int32_t max = S[d][0];
        int32_t max_index = 0;
        for (int32_t i = 0; i < 26; i++)
        {
            auto ss = S[d][i] + C[i]*(d - last[i]);
            if (max < ss) {
                max = ss;
                max_index = i;
            }
        }
        res[d] = max_index;
        last[max_index] = d;
    }
}

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> D;
    for (size_t i = 0; i < 26; i++)
    {
        in >> C[i];
    }
    for (size_t d = 0; d < D; d++)
    {
        for (size_t i = 0; i < 26; i++)
        {
            in >> S[d][i];
        }
    }
    greedy1();

    for (size_t d = 0; d < D; d++)
    {
        out << res[d]+1 << '\n';
    }
    //for (size_t d = 0; d < D; d++)
    //{
    //    out << (d%26) + 1 << '\n';
    //}

    return 0;
}
#endif


Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
int INF = 100000;
vector<int> dy = {1, 0, -1, 0};
vector<int> dx = {0, 1, 0, -1};
int dfs(vector<vector<int>> &A, int y, int x, int c){
  if (c >= 10){
    return INF;
  }
  int ans = INF;
  for (int i = 0; i < 4; i++){
    int y2 = y;
    int x2 = x;
    if (A[y2 + dy[i]][x2 + dx[i]] != 1){
      while (1){
        if (A[y2 + dy[i]][x2 + dx[i]] != 0){
          break;
        }
        y2 += dy[i];
        x2 += dx[i];
      }
      int next = A[y2 + dy[i]][x2 + dx[i]];
      if (next == 1){
        A[y2 + dy[i]][x2 + dx[i]] = 0;
        ans = min(ans, dfs(A, y2, x2, c + 1));
        A[y2 + dy[i]][x2 + dx[i]] = 1;
      }
      if (next == 3){
        ans = c + 1;
        break;
      }
    }
  }
  return ans;
}
int main(){
  while (1){
    int w, h;
    cin >> w >> h;
    if (w == 0 && h == 0){
      break;
    }
    vector<vector<int>> A(h + 2, vector<int>(w + 2, -1));
    for (int i = 1; i <= h; i++){
      for (int j = 1; j <= w; j++){
        cin >> A[i][j];
      }
    }
    int sy, sx;
    for (int i = 1; i <= h; i++){
      for (int j = 1; j <= w; j++){
        if (A[i][j] == 2){
          sy = i;
          sx = j;
        }
      }
    }
    A[sy][sx] = 0;
    int ans = dfs(A, sy, sx, 0);
    if (ans == INF){
      cout << -1 << endl;
    } else {
      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 2992
#include<string>
#include<vector>
#include<iomanip>
#ifndef _WIN32
#include<iostream>
#endif
#include<algorithm>
using namespace std;
#define FOR(i,bg,ed) for(int i =(bg); i< (ed);i++)
#define REP(i,n) FOR(i,0,n) 

int main(){
	cout << fixed;
	cout << setprecision(10);
	int R,N;
	while (cin >> R >> N, R){
		vector<double> A(40, 0);
		vector<double> B(40, 0);
		REP(i, N){
			int lb, ub;
			double h;
			cin >> lb >> ub >> h;
			FOR(j, 1, 40)if (lb <= j - 1 && j <= ub)A[j] = max(A[j], h);
			FOR(j, 1, 40)if (lb <= -j && -j + 1 <= ub)B[j] = max(B[j], h);

		}
		double ans = 114514;
		FOR(i,1, R+1){
			double a = i - 1;
			double b = i;
			ans = min(ans, A[i] - sqrt(R*R - a*a) + R);
			ans = min(ans, A[i] - sqrt(R*R - b*b) + R);
			ans = min(ans, B[i] - sqrt(R*R - a*a) + R);
			ans = min(ans, B[i] - sqrt(R*R - b*b) + R);
			//cout << " " << ans << endl;

		}
		cout << ans << endl;
	}



}

Measured memory_bytes: 3228
#include<iostream>
#include<queue>
#include<string.h>
using namespace std;

int n,m,p,a,b;
int t[8];

struct edge{
	int x,y,cost;
};

struct state{
	int x,nt;
	double ncost;
};

bool operator < (state a,state b){
	return a.ncost>b.ncost;
}

void solve(){
	double ans=1000000;
	for(int i=0;i<n;i++){
		scanf("%d",&t[i]);
	}

	edge e[1000];

	for(int i=0;i<p;i++){
		scanf("%d%d%d",&e[i].x,&e[i].y,&e[i].cost);
		e[i+p].x=e[i].y;
		e[i+p].y=e[i].x;
		e[i+p].cost=e[i].cost;
	}
	priority_queue<state> Q;
	double total[1<<8][31];
	bool c[1<<8][31];
	memset(total,-1,sizeof(total));
	memset(c,0,sizeof(c));
	state now;
	now.ncost=0.0;
	now.x=a;
	now.nt=(1<<n)-1;
	Q.push(now);

	while(!Q.empty()){
		state now;
		now=Q.top();
		Q.pop();
		if(c[now.nt][now.x]==true)
			continue;
		c[now.nt][now.x]=true;
		if(now.x==b)
			ans=min(ans,now.ncost);
		for(int i=0;i<p*2;i++){
			if(e[i].x==now.x){
				for(int j=0;j<n;j++){
					if((now.nt>>j & 1) == 1){
						state next;
						next.x=e[i].y;
						next.nt=(~(1<<j)) & now.nt;
						next.ncost=now.ncost+(double)e[i].cost/(double)t[j];
						total[next.nt][next.x]=next.ncost;
						Q.push(next);
					}
				}
			}
		}
	}
	if(ans>100000)
		cout<<"Impossible\n";
	else	
		cout<<ans<<"\n";
}


int main()
{
	scanf("%d%d%d%d%d",&n,&m,&p,&a,&b);
	while(n!=0){
		solve();
	scanf("%d%d%d%d%d",&n,&m,&p,&a,&b);
	}
	return 0;
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

ll solve(ll x){
    dump(x);
    ll ans = 0;
    ans += x / 11 * 2;
    x %= 11;
    dump(x);
    if(x){
        ans++;
        x = max(0ll, x - 6);
    }
    if(x){
        ans++;
        x = max(0ll, x - 5);
    }
    dump(x);
    dump(ans);
    return ans;
}

int main(){
    ll x;

    rep(i,20) solve(i);
    
    while(cin >> x){
        cout << solve(x) << endl;
    }
}


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

int main(){
    int_fast64_t N, A(0), B(0), C(0), D(0);
    scanf("%lld", &N);
    for(int i = 0; i < N; ++i){
        scanf("%lld%lld", &A, &B);
        if(A > C){
            C = A;
            D = B;
        }
    }
    printf("%lld\n", C + D);
    return 0;
}


Measured memory_bytes: 256
s = list(input())
a = s[0]
b = s[1]
c = s[2]
d = s[3]
e = int(a)+int(b)+int(c)+int(d)
f = e - 7
if e == 7:
  print(a+'+'+b+'+'+c+'+'+d+'=7')
else:
  if int(b)*2 == f:
    print(a+'-'+b+'+'+c+'+'+d+'=7')
  elif int(c)*2 == f:
    print(a+'+'+b+'-'+c+'+'+d+'=7')
  elif int(d)*2 == f:
    print(a+'+'+b+'+'+c+'-'+d+'=7')
  elif (int(b)+int(c))*2 == f:
    print(a+'-'+b+'-'+c+'+'+d+'=7')
  elif (int(b)+int(d))*2 == f:
    print(a+'-'+b+'+'+c+'-'+d+'=7')
  elif (int(c)+int(d))*2 == f:
    print(a+'+'+b+'-'+c+'-'+d+'=7')
  elif (int(b)+int(c)+int(d))*2 == f:
    print(a+'-'+b+'-'+c+'-'+d+'=7')

Measured memory_bytes: 3192
#include <stdio.h>

int main(void)
{
	int n,d,t[100]={0},s=0,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&d);
		t[d-1]++;
	}
	for(i=0;i<100;i++)if(t[i]>0)s++;
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  cin >> n;
  REP(i, n) {
    int a;
    cin >> a;
    if (a % 2 == 0) {
      if (a % 3 != 0 && a % 5 != 0) {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}


Measured memory_bytes: 256
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

INF = float("inf")

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

# Dinic's algorithm
from collections import deque
class Dinic:
    def __init__(self, N):
        self.N = N
        self.G = [[] for i in range(N)]

    def add_edge(self, fr, to, cap):
        forward = [to, cap, None]
        forward[2] = backward = [fr, 0, forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)

#無向グラフ？
#    def add_multi_edge(self, v1, v2, cap1, cap2):
#        edge1 = [v2, cap1, None]
#        edge1[2] = edge2 = [v1, cap2, edge1]
#        self.G[v1].append(edge1)
#        self.G[v2].append(edge2)

    def bfs(self, s, t):
        self.level = level = [None]*self.N
        deq = deque([s])
        level[s] = 0
        G = self.G
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in G[v]:
                if cap and level[w] is None:
                    level[w] = lv
                    deq.append(w)
        return level[t] is not None

    def dfs(self, v, t, f):
        if v == t:
            return f
        level = self.level
        for e in self.it[v]:
            w, cap, rev = e
            if cap and level[v] < level[w]:
                d = self.dfs(w, t, min(f, cap))
                if d:
                    e[1] -= d
                    rev[1] += d
                    return d
        return 0

    def flow(self, s, t):
        flow = 0
        INF = 10**9 + 7
        G = self.G
        while self.bfs(s, t):
            *self.it, = map(iter, self.G)
            f = INF
            while f:
                f = self.dfs(s, t, INF)
                flow += f
        return flow

#処理内容
def main():
	N = int(input())
	A = []
	B = []
	for i in range(N):
		a, b = getlist()
		A.append([a, b])
	for i in range(N):
		c, d = getlist()
		B.append([c, d])

	G = Dinic(2 * N + 2)
	for i in range(N):
		G.add_edge(0, i + 1, 1)
		G.add_edge(N + 1 + i, 2 * N + 1, 1)
	for i in range(N):
		for j in range(N):
			if A[i][0] < B[j][0] and A[i][1] < B[j][1]:
				G.add_edge(i + 1, N + 1 + j, 1)
	print(G.flow(0, 2 * N + 1))


if __name__ == '__main__':
	main()

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()
#define chor(x,y) x = (x||y);

const int INF = 1001001001;

int main(){
	int h ,w; cin >> h >> w;
	vector<vi>a, b, c; a = b = c = vector<vi>(h, vi(w));
	rep(i,h) rep(j,w) cin >> a[i][j];
	rep(i,h) rep(j,w) cin >> b[i][j];
	rep(i,h) rep(j,w) c[i][j] =  a[i][j] - b[i][j];
	int bias = 7000;
	vector<vector<vector<bool>>> dp(h,vector<vector<bool>>(w,vector<bool>(14000, false)));
	dp[0][0][bias+c[0][0]] = true;
	rep(i,h)rep(j,w)rep(k, 14000){
		int d = c[i][j];
		if(i>0 && (k-d>0 && k-d<14000)) chor(dp[i][j][k], dp[i-1][j][k-d]);
		if(i>0 && (k+d>0 && k+d<14000)) chor(dp[i][j][k], dp[i-1][j][k+d]);
		if(j>0 && (k-d>0 && k-d<14000)) chor(dp[i][j][k], dp[i][j-1][k-d]);
		if(j>0 && (k+d>0 && k+d<14000)) chor(dp[i][j][k], dp[i][j-1][k+d]);
		
		// if(dp[i][j][k]) cout << i << " " << j <<" " <<k<<endl; 
	}
	int ans = INF;
	rep(i,14000){
		if(dp[h-1][w-1][i]) ans = min(ans, abs(i-bias));
	}
	// rep(i, 14000){
	// 	if(dp[h-1][w-1][i])cout <<i<< endl;
	// }
	cout << ans <<endl;
}

Measured memory_bytes: 13824
#include<stdio.h>

int main(void){

	int n, d[100][2];
	int i, k;

	scanf("%d", &n);
	for (k = 0; k <= n - 1;k++) {
		scanf("%d %d", &d[k][0], &d[k][1]);
	}

	for (i = 0;i <= n - 3;i++) {
		if (d[i][0] == d[i][1] && d[i + 1][0] == d[i + 1][1] && d[i + 2][0] == d[i + 2][1]) {
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 1728
#!/usr/bin/perl
use POSIX qw(floor);

my $s = scalar(<STDIN>);
my $t = scalar(<STDIN>);

$s =~ s/[\x00-\x20]+$//ios;
$t =~ s/[\x00-\x20]+$//ios;

my $sl = length($s);
my $tl = length($t);

my $mn = 10**9;
for(my $i=0;$i<=$sl-$tl;$i++){
  my $c = 0;
  for(my $j=0;$j<$tl;$j++){
    $c++ if( substr($s,$i+$j,1) ne substr($t,$j,1) );
  }
  $mn = $c if $c < $mn;
}
print "$mn\n";



Measured memory_bytes: 6652
X, N = map(int, input().split(' '))
if N == 0:
    print(X)
else:
    P_ls = list(map(int, input().split(' ')))
    diff, rst = -1, 0
    for i in range(101, -1, -1):
        if i not in P_ls:
            if diff == -1:
                diff = abs(X - i)
                rst = i
            else:
                diff = min(diff, abs(X - i))
                if diff == abs(X - i):
                    rst = i
    print(rst)

Measured memory_bytes: 9120
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int q;
  cin >> q;
  rep(i, q) {
    ll a, b;
    cin >> a >> b;
    if (a == b) {
      cout << a*2-2 << endl;
      continue;
    }
    ll l = 0, r = 1LL<<31; //最大マッチングをする数列の長さ
    while (r-l > 1) {
      ll mid = (l+r)/2;
      ll c1 = (mid+1)/2, c2 = (mid+1)-c1; //長さmidの数列の中央値
      if (c1*c2 < a*b)
        l = mid;
      else
        r = mid;
    }
    cout << l-1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(long long)(n); i++)
#define REP(i, k, n) for(long long i=(long long)(k); i<(long long)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const int INF = INT_MAX;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x, ll y){ if(x>y) swap(x, y);while(x!=0){ y%=x; swap(x, y); }return y; }
ll mpow(ll x, ll r){if(r==0) return 1;if(r%2==1){ return x*mpow(x, r-1)%mod; }else{ ll aa = mpow(x, r/2); return aa*aa%mod; }}

int main(){
	ll a, b, c, k; cin >> a >> b >> c >> k;
	if(a >= k){
		cout << k << endl;
	}else if(a+b>=k){
		cout << a << endl;
	}else{
		cout << a-(k-a-b) << endl;
	}
	return 0;
}


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(N, A);
  OK(N % 500 <= A);

  return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

double d(int x1, int y1, int x2, int y2) {
    int dx = x2 - x1;
    int dy = y2 - y1;
    return sqrt(dx * dx + dy * dy);
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int x[8], y[8];
    rep(i, N) cin >> x[i] >> y[i];
    double sum = 0;
    int order[8];
    int cnt = 0;
    rep(i, 8) order[i] = i;
    do {
        rep(i, N - 1) {
            sum += d(x[order[i]], y[order[i]], x[order[i + 1]], y[order[i + 1]]);
        }
        cnt++;
    }while(next_permutation(order, order + N));
    cout << fixed << setprecision(12) << sum / cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define loop int a[n]; for(i=0;i<n;i++)
#define lloop ll a[n]; for(i=0;i<n;i++)
#define tcase int t; cin>>t; while(t--)
#define max(a,b) (a>b?a:b)
#define check(a,b) for(i=0;i<b;i++) cout<<a[i]<<' '; cout<<endl;
#define pb push_back
#define min(a,b) (a<b?a:b)
#define g(a) (a*(a-1))/2
#define fi first
#define se second
#define M 1000000007
#define pi 3.14159265
using namespace std;

int t[100005];
int x[100005];
int y[100005];
int main()
{
  ios::sync_with_stdio(false);
  //freopen("output.txt","r",stdin);
  int n,m;
  cin>>n;
  for(int i=1;i<=n;i++)
    cin>>t[i]>>x[i]>>y[i];
  for(int i=1;i<=n;i++)
  {
    m=x[i]-x[i-1]+y[i]-y[i-1];
    m=t[i]-t[i-1]-m;
    if(m<0||m%2)
    {
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
  return 0;
}

Measured memory_bytes: 1408
S = [input().split() for _ in range(3)]
count1 = 0
count2 = 0
count3 = 0
count4 = 0
for i in range(3):
    count1 += S[i].count('1')
    count2 += S[i].count('2')
    count3 += S[i].count('3')
    count4 += S[i].count('4')
set = {count1,count2,count3,count4}
if set == {1,1,2,2}:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return float(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

from collections import deque

def main():
	mod=10**9+7
	n,k=MI()
	G=[[] for _ in range(n+1)]

	for _ in range(n-1):
		a,b=MI()
		G[a].append(b)
		G[b].append(a)
	#print(G)

	ans=k

	for i in range(len(G[1])):
		ans*=k-i-1
		ans%=mod
	#print(ans)

	Q=deque(G[1])
	#print(Q)

	sumi=set([1]+G[1])
	#print(sumi)


	while Q:
		now=Q.popleft()
		kk=k-2
		for i in G[now]:
			if i not in sumi:
				ans*=kk
				ans%=mod
				kk-=1
				sumi.add(i)
				Q.append(i)

	print(ans%mod)


























if __name__ == "__main__":
	main()


Measured memory_bytes: 104128
#include<bits/stdc++.h>
using namespace std;
#define int long long

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

  vector<int> L(N+1),R(N+1);
  for(int i=0;i<N;i++){
    L[i+1]=max(L[i],a[i]);
  }
  for(int i=N-1;i>=0;i--){
    R[i]=max(R[i+1],a[i]);
  }

  for(int i=0;i<N;i++){
    cout<<max(L[i],R[i+1])<<endl;
  }

  return 0;
}

Measured memory_bytes: 6272
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
    
    long long N,L;
  	cin >> N >> L;
    long long S = N*(2*L+N-1)/2;
    if(L<=0 && N+L-1>=0){
      cout <<S;
      return 0;
    }
    if(N+L-1 < 0){
      cout<< S -(N+L-1);
      return 0;
    }
  cout << S-L;
  return 0;
}

Measured memory_bytes: 256
n, x, m = map(int, input().split())
ans = 0
prev_set = set()
prev_list = list()
ans_hist = list()
r = x

for i in range(n):
    if i == 0:
        pass
    else:
        r = (r * r) % m
    
    if r == 0:
        break
    
    if r in prev_set:
        index = prev_list.index(r)
        period = i - index
        count = (n - index) // period
        rest = (n - index) % period

        # ans = sum(prev_list[:index])
        # ans += sum(prev_list[index:i]) * count
        if index == 0:
            ans += ans * (count - 1)
        else:
            ans += (ans - ans_hist[index - 1]) * (count - 1)

        ans += sum(prev_list[index:index+rest])
        # ans += (ans_hist[index + rest - 1] - ans_hist[index - 1])
        break
    else:
        ans += r
        prev_set.add(r)
        prev_list.append(r)
        ans_hist.append(ans)
print(ans)


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

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

const int Maxn = 100005;
const int Maxs = 524288;
const ll Inf = 1000000000000000000ll;

int n, m;
ll st[Maxs];
vector <ii> neigh[Maxn];

void Create(int v, int l, int r)
{
    st[v] = Inf;
    if (l < r) {
        int m = l + r >> 1;
        Create(2 * v, l, m);
        Create(2 * v + 1, m + 1, r);
    }
}

void Update(int v, int l, int r, int a, int b, ll val)
{
    if (l == a && r == b) st[v] = min(st[v], val);
    else {
        int m = l + r >> 1;
        if (a <= m) Update(2 * v, l, m, a, min(m, b), val);
        if (m + 1 <= b) Update(2 * v + 1, m + 1, r, max(m + 1, a), b, val);
    }
}

ll Get(int v, int l, int r, int x)
{
    ll res = st[v];
    if (l < r) {
        int m = l + r >> 1;
        if (x <= m) res = min(res, Get(2 * v, l, m, x));
        else res = min(res, Get(2 * v + 1, m + 1, r, x));
    }
    return res;
}

int main()
{
    scanf("%d %d", &n, &m);
    Create(1, 1, n);
    Update(1, 1, n, 1, 1, 0);
    for (int i = 0; i < m; i++) {
        int l, r, c; scanf("%d %d %d", &l, &r, &c);
        neigh[l].push_back(ii(r, c));
    }
    ll g;
    for (int i = 1; i <= n; i++) {
        g = Get(1, 1, n, i);
        if (g >= Inf) { printf("-1\n"); return 0; }
        for (int j = 0; j < neigh[i].size(); j++)
            Update(1, 1, n, i + 1, neigh[i][j].first, g + ll(neigh[i][j].second));
    }
    printf("%lld\n", g);
    return 0;
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int n;
	cin >> n;

	ll ans = 0;

	cout << 800*n - 200*(n/15) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vi = vector<int>;
using vs = vector<string>;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repp(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define repd(i, n) for(ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

ll k, l, m, n;
const ll M = 1e9 + 7;



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

    int n;
    cin >> n;

    vl a(n);
    rep(i, n) cin >> a[i];

    sort(all(a), [](ll a, ll b) {return a > b;});

    cout << a[0] << " ";

    int idx = 0;
    while(2 * a[idx] > a[0]) idx++;

    if(abs(2 * a[idx - 1] - a[0]) < abs(2 * a[idx] - a[0])) cout << a[idx - 1] << endl;
    else cout << a[idx] << endl;
}

Measured memory_bytes: 3988
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n=sc.nextInt();
			int[] a=new int[n];
			int count=0;
			a[0]=sc.nextInt();
			for(int i=1; i<n; i++) {
				a[i]=sc.nextInt();
				if(a[i]==a[i-1]) {
					count++;
					a[i]=1000;
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 21972
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int hp = sc.nextInt();
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            hp -= sc.nextInt();
            if(hp <= 0)
                break;
        }
        System.out.println(hp <= 0 ? "Yes" : "No");
    }
}

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

int main() {
  string s, t;
    
  cin >> s;
  cin >> t;
  
  int minCount = t.size();
  
  for(unsigned int i = 0; i < s.size()-t.size()+1; i++){
    int count = 0;
    for(unsigned int j = 0; j < t.size(); j++){
      if(s.at(i+j) != t.at(j)){
      	count++;
      }
    }
    if(count < minCount){
      minCount = count;
    }
  }

  cout << minCount << endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


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

	ll n;
	cin >> n;

	vector<mp::cpp_int> a(n);

	rep(i, n)
	{
		cin >> a[i];
	}
	mp::cpp_int ans = 1;
	sort(a.begin(), a.end());
	rep(i, n)
	{
		ans *= a[i];
		if (ans > 1000000000000000000)
		{
			cout << -1 << endl;
			ret;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6472
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

set<int> edge[100000];
int ans[100000];
map<pint,int> num;

void DFS(int X,int painted){
    int color=1;
    while(!edge[X].empty()){
        int Y=*edge[X].begin();
        edge[X].erase(Y);
        edge[Y].erase(X);
        if(painted!=color){
            int x=X,y=Y;
            if(x>y) swap(x,y);
            ans[num[pint(x,y)]]=color;
            DFS(Y,color);
            color++;
        }
        else{
            color++;
            int x=X,y=Y;
            if(x>y) swap(x,y);
            ans[num[pint(x,y)]]=color;
            DFS(Y,color);
            color++;
        }
    }
}

int main(void){
    int N;
    cin >> N;
    int maxi[N]={};  
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        a--,b--;
        num[pint(a,b)]=i;
        edge[a].insert(b);
        edge[b].insert(a);
        maxi[a]++,maxi[b]++;
    }
    cout << *max_element(maxi,maxi+N) << endl;
    DFS(0,0);
    rep(i,N-1) cout << ans[i] << endl;
}

Measured memory_bytes: 21504
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    int ns = 1 << n;
    vl s(ns);
    multiset<int> allslimes;
    for (int i = 0; i < ns; ++i) {
        cin >> s[i];
        allslimes.insert(s[i]);
    }
    sort(s.begin(), s.end());
    multiset<int> slimes;
    slimes.insert(s[ns - 1]);
    allslimes.erase(prev(allslimes.end())); // largest
    for (int i = 0; i < n; ++i) {
        vi temp;
        for (auto it = slimes.rbegin(); it != slimes.rend(); it = next(it)) {
            auto ita = allslimes.lower_bound(*it);
            if (ita == allslimes.begin()) {
                cout << "No"
                     << "\n";
                return 0;
            }
            ita = prev(ita);
            temp.push_back(*ita);
            allslimes.erase(ita);
        }
        for (auto &t : temp) {
            slimes.insert(t);
        }
    }
    cout << "Yes"
         << "\n";
    return 0;
}

Measured memory_bytes: 15352
import numpy as np
n, m = map(int, input().split())
A = [list(input()) for _ in range(n)]
B = [list(input()) for _ in range(m)]

A, B = np.array(A), np.array(B)

for i in range(n-m+1):
    for j in range(n-m+1):
        tmp = A[i:i+m, j:j+m]
        # 普通にtmp == Bで比較すると要素ごとの一致不一致が返るので,
        # 全体の一致を判定するall()を利用する
        if (tmp == B).all():
            print("Yes")
            exit()
else:
    print("No")

Measured memory_bytes: 26948
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(ll i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(ll j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

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

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


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

    int N, T;
    cin >> N >> T;

    int c, t;
    vector<int> costs;
    REPinit(i, 0, N) {
        cin >> c >> t;
        if (t <= T) {
            costs.push_back(c);
        }
    }

    if (costs.empty()) {
        cout << "TLE" << endl;
    }
    else {
        sort(CONTAINER_ALL(costs));
        cout << costs.front() << endl;
    }

    
    return 0;
}


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

int main(void){
    string s;
    while(true) {
        cin >> s;
        if (s == "0"){
            break;
        }
        int sum = 0;
        for(int i = 0; i < s.size(); i++){
            int n = s[i] - 48;
            sum += n;
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 3212
import java.util.*;
class Main {
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  int[] array =  new int[3];
  for( int i = 0; i < 3; i++) {
   array[i] = sc.nextInt();
  }
  Arrays.sort(array);
  System.out.println( array[0] + " " + array[1] + " " + array[2] );
 }
}


Measured memory_bytes: 26340
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<vector<pair<int, int>>> syogen(N);
  for(int i = 0; i < N; i++){
    int A;
    cin >> A;
    for(int j = 0; j < A; j++){
      int x, y;
      cin >> x >> y;
      syogen.at(i).push_back(make_pair(x, y));
    }
  }
  
  int max = 0;
  for(int i = 0; i < (1 << N); i++){
    bitset<15> bit(i);
    bool flag = true;    
    for(int j = 0; j < N; j++){
      if(!bit.test(j)){
        continue;
      }
      for(auto temp : syogen.at(j)){
        int num = temp.first - 1;
        int kind = temp.second;
        if(bit.test(num) != (kind == 1)){
          flag = false;
        }
      }
    }
    if(flag == true && bit.count() > max){
      max = bit.count();      
    }
  }
  cout << max << endl;
}

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

#define int long long
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}

signed main(){
  int n,k;cin>>n>>k;
  int ans=n;
  n%=k;
  chmin(ans,abs(n));
  n-=k;
  chmin(ans,abs(n));
  for(int i=0;i<100000;i++){
    n*=-1;
    n-=k;
    chmin(ans,abs(n));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        int ans = (x % y == 0) ? -1 : x;
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 21972