akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Globalization;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        SetOut(sw);
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;

    int W, H, N;
    void solve()
    {
        W = cin.nextint;
        H = cin.nextint;
        N = cin.nextint;

        int WW = 0, HH = 0;
        for (int i = 0; i < N; i++)
        {
            var t = cin.scanint;
            if (t[2] == 1) WW = Math.Max(WW, t[0]);
            else if (t[2] == 2) W = Math.Min(W, t[0]);
            else if (t[2] == 3) HH = Math.Max(HH, t[1]);
            else if (t[2] == 4) H = Math.Min(H, t[1]);
        }
        if (W - WW <= 0 || H - HH <= 0 )
        {
            WriteLine(0);
        }
        else
        {
            WriteLine((W - WW) * (H - HH));
        }

    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 2776
def main():
    N = int(input())
    permutation = list(map(int, input().split()))
    answer = 0
    for i in range(N):
        if permutation[i] == i + 1:
            if permutation[i] == N:
                permutation[i], permutation[i - 1] = permutation[i - 1], permutation[i]
            else:
                permutation[i], permutation[i + 1] = permutation[i + 1], permutation[i]
            answer += 1
    print(answer)


if __name__ == '__main__':
    main()

Measured memory_bytes: 14008
import static java.lang.Math.max;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Scanner;

public class Main {

	final static int INF = Integer.MAX_VALUE;
	static boolean[] visited;
	static List<Integer>[] lst;
	static List<Integer> ordered;

	public static void main(String[] args) {
		Locale.setDefault(Locale.ENGLISH);
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		solve(in, System.out);
		in.close();
	}

	protected static void solve(Scanner in, PrintStream out) {
		int n = in.nextInt();
		int m = in.nextInt();
		lst = new ArrayList[n + 1];
		ordered = new ArrayList<>();
		for (int i = 1; i <= n; i++)
			lst[i] = new ArrayList<>();
		for (int j = 0; j < m; j++)
			lst[in.nextInt()].add(in.nextInt());
		int ret = solveLine(n, m);
		out.printf(Locale.ENGLISH, "%s%n", ret);
	}

	private static int solveLine(int n, int m) {
		int ans = 0;
		visited = new boolean[n + 1];
		for (int i = 1; i <= n; i++) {
			if (!visited[i]) topoVisit(i);
		}
		int[] dp = new int[n + 1];
		for (int i = n - 1; i >= 0; i--) {
			int val = ordered.get(i);
			for (int a : lst[val]) {
				dp[a] = i == n - 1 ? 1 : max(dp[a], dp[val] + 1);
				ans = max(ans, dp[a]);
			}
		}
		return ans;
	}

	private static void topoVisit(int pos) {
		visited[pos] = true;
		for (int a : lst[pos]) {
			if (!visited[a]) {
				topoVisit(a);
			}
		}
		ordered.add(pos);
	}

}

Measured memory_bytes: 107736
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  long count = 0;
  for (long i = 1; i <= N; i++) {
    long p;
    cin >> p;
    if (i != p) count++;
  }
  if (count <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
S = input()
T = input()

sts = set(S)
stt = set(T)

for i in range(26):
  c = chr(ord('a')+i)
  idx1 = [i for i, x in enumerate(T) if x == c]
  st1 = set([])
  idx2 = [i for i, x in enumerate(S) if x == c]
  st2 = set([])
  
  for j in idx1:
    if S[j] not in st1 and len(st1) > 0:
      print('No')
      exit()
    elif len(st1) == 0:
      st1.add(S[j])
  for j in idx2:
    if T[j] not in st2 and len(st2) > 0:
      print('No')
      exit()
    elif len(st2) == 0:
      st2.add(T[j])
      
print('Yes')

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

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 6;
  ans -= a;
  ans -= b;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	vector<vector<ll>> f(3, vector<ll>(24 * 60));
	vi bs;
	rep(i, n){
		vi v;
		int h, m;		
		rep(j, 6){ cin >> h >> m; v.pb(h * 60 + m); }
		rep(j, 3) for(int k = v[2 * j]; k <= v[2 * j + 1]; k++) f[j][k] |= 1ll << i;
		bs.insert(bs.end(), all(v));
	}
	sort(all(bs)); bs.erase(unique(all(bs)), bs.end());
	int ans = 0;
	for(int i : bs) for(int j : bs) for(int k : bs){
		if(!(i < j && j < k)) continue;
		ll X = f[0][i], Y = f[1][j], Z = f[2][k];
		ans = max(ans, __builtin_popcountll(X & Y & Z));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3268
#include <iostream>

int main() {
	int code;
	std::cin >> code;
	int status = 0;

	if (code >= 65 && code <= 90) {
		status = 1;
	}
	else if (code >= 97 && code <= 122) {
		status = 2;
	}

	std::cout << status << std::endl;

	return 0;
}


Measured memory_bytes: 3112
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

const long long MOD = 998244353;
// const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  ll n,q;
  std::cin>>n>>q;

  using kozi=std::tuple<ll,ll,ll>;

  std::multiset<ll> set;
  std::vector<kozi> event;

  rep(i,0,n){
    ll s,t,x;
    std::cin>>s>>t>>x;
    event.emplace_back(s-x,1,x);
    event.emplace_back(t-x,-1,x);
  }  

  std::sort(all(event));

  ll now=0;

  rep(i,0,q){
    ll d;
    std::cin>>d;
    while(now<2*n&&std::get<0>(event[now])<=d){
      if(std::get<1>(event[now])==1){
        set.insert(std::get<2>(event[now]));
      }else{
        auto itr=set.lower_bound(std::get<2>(event[now]));
        set.erase(itr);
      }
      now++;
    }
    if(set.empty())std::cout<<-1<<"\n";
    else std::cout<<*set.begin()<<"\n";
  }

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  int O=N;
  int f=0;

  for(int i=0;i<9;i++){
    f+=O%10;
    O=O/10;
  }
  
  if(N%f==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define inf 1000000000000000000
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  string s;
  cin >> s;
  ll n = s.size(), ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n + 1; j++) {
      ll res = j - i;
      for (int k = i; k < j; k++) {
        if (s[k] != 'A' && s[k] != 'C' && s[k] != 'G' && s[k] != 'T') res = 0;
      }
      chmax(ans, res);
    }
  }
  cout << ans << endl;
}

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

using namespace std;

#define int long long

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef unordered_map<int,int> mii;
typedef unordered_map<char,int> mci;
typedef unordered_map<string,int> msi;

#define pb push_back
#define f first
#define s second 
 

void solve() {
    int n;
    cin>>n;
    vi h(n);
    for(int i=0;i<n;i++) {
        cin>>h[i];
    }
    vi dp(n);
    dp[n-1] = 0;
    dp[n-2] = abs(h[n-1]-h[n-2]);
    for(int i=n-3;i>=0;i--) {
        dp[i] = min(dp[i+1]+abs(h[i]-h[i+1]),dp[i+2]+abs(h[i]-h[i+2]));
    }
    cout<<dp[0]<<endl;
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //#ifdef ONLINEJUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    //#endif

    int tc; tc=1;
    for (int t = 1; t <= tc; t++) {
        //cout << "Case #" << t  << ": ";
        solve();
    }
}

Measured memory_bytes: 4756
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    string left = "qwertasdfgzxcvb";
    sort(all(left));
    while(1){
        string s; cin >> s;
        if(s == "#") break;
        ll n = s.size();
        vb v(n);
        rep(i,n){
            v[i] = binary_search(all(left),s[i]);
        }
        ll ans = 0;
        rep(i,n-1){
            if(v[i] != v[i+1]) ans++;
        }
        cout << ans << endl;
    }
}


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

int main() {
    ll n; cin >> n;
    vector<ll> a(n+1);
    for(int i = 0; i < n+1; ++i) {
        cin >> a[i];
    }

    ll node = 1;
    bool f = false;
    vector<ll> ans(n+1);
    for(int i = 0; i <= n; ++i){
        ans[i] = node;
        if( node - a[i] < 0){
            f = true;
            break;
        }
        node = node- a[i];
        if(node < (2LL << 60)) node *= 2LL;
    }
    if(f){
        cout << -1 << endl;
        return 0;
    }
    ll now = 0;
    for(int i = n; i >= 0; --i){
        now += a[i];
        if(ans[i] - now > 0){
            ans[i] = now;
        }
        else{
            break;
        }
    }

    ll sum = 0;
    for(int i = 0; i <= n; ++i){
        sum += ans[i];
    }
    cout << sum << endl;
    return 0;
}


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

// int main(){
//   string S;
//   cin >> S;
//   int count_max = 0, count_tmp = 0;
//   for(int i = 0; i < S.length(); i++){
//     if((S[i] == 'A') || (S[i] == 'G') || (S[i] == 'C') || (S[i] == 'T')){
//     }else if(){
//       j++;
//     }
//   }
//   cout << count_max << endl;
//   return 0;
// }
//
bool hasOnlyACGT(string s) {
    for(int i=0;i<s.size();i++){
        if(s[i] != 'A' && s[i] != 'C' && s[i] != 'G' && s[i] != 'T')
            return false;
    }
    return true;
}

int main(){
    string s;
    cin >> s;
    int count_max = 0;
    for(int l = 0;l<s.size();l++){
        for(int r = l; r<s.size();r++){
            if(hasOnlyACGT(s.substr(l,r-l+1))){
                if(count_max < r-l+1)
                    count_max = r-l+1;
            }
        }
    }
    cout << count_max << endl;
}


Measured memory_bytes: 256
n=int(input())

def eratosthenes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

l=eratosthenes(55555)
ans=[]
for li in l:
    if li%5==1:
        ans.append(li)
print(*ans[:n])


Measured memory_bytes: 9840
const main = (input) => {
  const args = input.trim().split(" ");
  const first = BigInt(parseInt(args[0], 10));
  const second = BigInt(args[1].replace(".", ""));
  const answer = (first * second).toString();

  console.log(answer.length > 2 ? answer.slice(0, -2) : 0);
};

main(require('fs').readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29616
use std::io;

fn read_ints() -> std::vec::Vec<i64> {
    let mut str = String::new();
    io::stdin().read_line(&mut str);

    let mut vec: Vec<i64> = Vec::new();
    for element in str.split_whitespace() {
        vec.push(element.parse().unwrap());
    }
    return vec;
}

fn main() {
    let x = read_ints();
    for i in 0..5 {
        if x[i] == 0 {
            println!("{}", i + 1);
            return;
        }
    }
}


Measured memory_bytes: 2156
//Author - Rahil Malhotra
#include "bits/stdc++.h"
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int mod=998244353;
int n,k;
int arr[15][2];
int dp[200005];
int tree[1000005];
int lazy[1000005];
void propogate(int i,int l,int r)
{
    tree[i]+=(r-l+1)*lazy[i];
    if(l!=r)
    {
        lazy[i*2]+=lazy[i],lazy[i*2+1]+=lazy[i];
        lazy[i*2]%=mod,lazy[i*2+1]%=mod;
    }
    lazy[i]=0;
}
void update(int i,int l,int r,int l1,int r1,int val)
{
    if(lazy[i])
        propogate(i,l,r);
    if(l1>r1 || l>r1 || l1>r)
        return;
    if(l1<=l && r<=r1)
    {
        tree[i]+=(r-l+1)*val;
        tree[i]%=mod;
        if(l!=r)
        {
            lazy[i*2]+=val,lazy[i*2+1]+=val;
            lazy[i*2]%=mod,lazy[i*2+1]%=mod;
        }
        return;
    }
    int mid=(l+r)/2;
    update(i*2,l,mid,l1,r1,val);
    update(i*2+1,mid+1,r,l1,r1,val);
    tree[i]=(tree[i*2]+tree[i*2+1])%mod;
}
int query(int i,int l,int r,int l1,int r1)
{
    if(l1>r1 || l>r1 || l1>r)
        return 0;
    if(lazy[i])
        propogate(i,l,r);
    if(l1<=l && r<=r1)
        return tree[i];
    int mid=(l+r)/2;
    return (query(i*2,l,mid,l1,r1)+query(i*2+1,mid+1,r,l1,r1))%mod;
}
int32_t main()
{
    IOS;
    cin>>n>>k;
    for(int i=0;i<k;i++)
        cin>>arr[i][0]>>arr[i][1];
    update(1,1,n+5,1,1,1);
    for(int i=1;i<=n;i++)
    {
        dp[i]=query(1,1,n+5,i,i);
        for(int j=0;j<k;j++)
            update(1,1,n+5,min(n+1,i+arr[j][0]),min(n+1,i+arr[j][1]),dp[i]);
    }
    print(dp[n]%mod);
}   


Measured memory_bytes: 13404
import java.util.*;

public class Main {
	static char[] ORG = "CODEFESTIVAL2016".toCharArray();
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int count = 0;
		for (int i = 0; i < ORG.length; i++) {
			if (ORG[i] != arr[i]) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int) (v).size()

#define rep(i,a,b) for(int (i) = (a); (i) < (b); ++(i))
#define trav(a, x) for(auto& a : x)

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define shandom_ruffle random_shuffle
#define funoredered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using funordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

constexpr int INF = 0x3f3f3f3f;
constexpr int NINF = 0xc0c0c0c0;
constexpr double EPS = 1e-8;
constexpr ll MOD = 1000000007LL;

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

inline ll modPow( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

inline int cmp_double( double x, double y, double tol = EPS) {
    return (x <= y + tol) ? ( x + tol < y) ? -1 : 0 : 1;
}

constexpr int ms = 3003;
int DP[ms][ms];

int main()
{
	ios::sync_with_stdio(0); cin.tie(NULL);
    string a, b;
    cin >> a >> b;
    for(int i = 1; i <= sz(a); ++i) {
        for(int j = 1; j <= sz(b); ++j) {
            int posA = i - 1;
            int posB = j - 1;
            DP[i][j] = max( DP[i - 1][j], DP[i][j - 1] );
            if( a[posA] == b[posB] ) DP[i][j] = max(DP[i][j], DP[i - 1][j - 1] + 1);
        }
    }
    
    string ans;
    
    int curX = sz(a), curY = sz(b);
    
    while(curX > 0 && curY > 0) {
        if( DP[curX][curY] == DP[curX - 1][curY - 1] + 1 && a[curX - 1] == b[curY - 1] ) {
            ans += a[curX - 1];
            --curX; --curY;
        }
        else if( DP[curX][curY] == DP[curX - 1][curY] ) --curX;
        else --curY;
    }
    
    /*for(int i = 0; i <= sz(a); ++i) {
        for(int j = 0; j <= sz(b); ++j) {
            cout << DP[i][j] << " ";
        }
        cout << endl;
    }*/
    reverse( all(ans) );
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 35456
using System;

namespace Ferris_Whrrl
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] S = Console.ReadLine().Split(' ');
            int A = int.Parse(S[0]);
            int B = int.Parse(S[1]);

            if (A >= 13)
            {
                Console.WriteLine(B);
            }
            else if (A >=6)
            {
                Console.WriteLine(B / 2);
            }
            else
            {
                Console.WriteLine("0");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

ll A[100100];
int main(){
    ll N,L;
    cin >> N >> L;
    REP(i,N){
        ll a;
        cin >> a;
        A[i] = a;
    }

    //queue<ll> q;
    ll last = A[0];
    int pivot = -1;
    for(int i = 1; i < N; i++){
        ll a = A[i];
        if(last + a >= L){
            pivot = i-1;
            break;
        }
        last = a;
    }

    if(pivot < 0){
        cout << "Impossible" << endl;
        return 0;
    }

    cout << "Possible" << endl;
    for(int i = 0; i < pivot; i++){
        cout << i+1 << endl;
    }
    for(int i = N-2; i >= pivot; i--){
        cout << i+1 << endl;
    }
    return 0;
}


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

int main(){
    double l;
    cin >> l;
    printf("%.20lf\n", pow(l/3, 3));
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int i,make,a;
char s[15];
int main(void){
    scanf("%s",s);
    a = strlen(s);
    for(i=0;i<a;i++){
        if(s[i] == 'x'){
            make += 1;
        }
    }
    if(make < 8){
        printf("YES");
    }else{
        printf("NO");
    }
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val (n, k) = readLine()?.split(" ")?.map { it.toInt() } ?: return
    val aMap: Map<Int, Int> = readLine()
        ?.split(" ")
        ?.asSequence()
        ?.map { it.toInt() }
        ?.groupBy { it }
        ?.mapValues { it.value.size }
        ?: return
    if (aMap.size <= k) {
        println(0)
        return
    }
    val result = aMap.values.sorted().take(aMap.size - k).sum()
    println(result)
}

Measured memory_bytes: 127752
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N, D, X;
  cin >> N >> D >> X;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  for(int i = 0; i < D; ++i){
    for(int j = 0; j < N; ++j)
      if(!(i%A[j])) ++X;
  }
  cout << X << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int pwmd(int a, int n)
{
	if (!n)
		return 1;
	int pt = pwmd(a, n / 2);
	pt *= pt, pt %= mod;
	if (n & 1)
		pt *= a, pt %= mod;
	return pt;
}
int pow(int a,int b)
{
	int ans=1;
	while(b>0)
	{
		if(b&1)
			ans*=a;
		a*=a;
		b=b>>1;
	}
	return ans;
}
vector<pair<int,int>> vec;
bool compare(pair<int,int> v1,pair<int,int> v2)
{
	return v1.ss<v2.ss;
}
int32_t main()
{       
    FIO;
    int n,m;
    cin>>n>>m;

    int a[m];
    memset(a,0,sizeof(a));
    int sum=0;

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

    if(sum>n)
    	cout<<"-1"<<endl;
    else
    	cout<<(n-sum)<<endl;


    return 0;
}

Measured memory_bytes: 3696
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T = ll> constexpr T TEN(int n) {return (n==0)?1:10*TEN<T>(n-1);}

int main() {
    string s;
    cin >> s;
    int n = int(s.size());
    ll sm = 0;
    for (int p = 0; p < n; p++) {
        for (int d = 0; d < n-p; d++) {
            int l = p;
            int r = max(0, n-2-(p+d));
            ll base = 1;
            for (int i = 0; i < l+r; i++) {
                base *= 2;
            }
            for (int i = 0; i < d; i++) {
                base *= 10;
            }
            sm += base * (s[p]-'0');
        }
    }
    cout << sm << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

ll n, ans = 0;

int chk(ll x){
  map<int, int> mp;
  while(x){
    mp[x%10]++;
    x /= 10;
  }
  int res = 0;
  if(mp.size() == 3) res++;
  return res;
}

void dfs(ll x){
  if(x > n) return;
  ans += chk(x);
  for(int i = 3; i <= 7; i += 2){
    x *= 10;
    x += i;
    dfs(x);
    x /= 10;
  }
}

int main(){
  cin >> n;
  dfs(0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
import java.util.Map.Entry;
import java.util.*;
import java.math.*;
import org.w3c.dom.css.Counter;
  
public class Main{
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        //モンスターの体力
        int H = Integer.valueOf(s.next());
        //魔法の種類
        int N = Integer.valueOf(s.next());
        //体力減少
        int[] HPdown = new int[N+1];
        //魔法減少
        int[] MPcost = new int[N+1];
        //未到達の値
        int noRoot = 100000001;
		for(int i = 0; i < N; i++) {
			HPdown[i] = Integer.valueOf(s.next());
			MPcost[i] = Integer.valueOf(s.next());
        }
    
		//動的
        long[] dp = new long[20000];
        //整頓
        Arrays.fill(dp, noRoot);
        //初期値(0)設定
		dp[0] = 0;
        //魔法の種類だけくり返す
		for(int i = 0; i < N; i++) {
            //i=0
            //十分な数繰り返す
			for(int j = 0; j < 10000; j++) {
                    //あるHP値への到達方法に対して
                    //既存の方法と、新しい方法、より低コストな方を選択
                    dp[j+HPdown[i]] =
                    Long.min(dp[j+HPdown[i]], dp[j] + MPcost[i]);
			}
        }
        //目標値以上の到達方法のなかから、最小のものを選択
		for(int i = 10001; i >= 0; i--) {
			dp[i] = Long.min(dp[i], dp[i+1]);
		}
		System.out.println(dp[H]);
    }
}
    


    

Measured memory_bytes: 39408
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
ll A[1000010];
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main(){
    cin>>N;
    for(ll i=0;i<N;i++) cin>>A[i];
    sort(A,A+N);
    bool pairwise=true;
    bool isPrime[1000010];
    for(ll i=1;i<=A[N-1];i++)isPrime[i]=true;
    for(ll i=0;i<N;i++){
        if(!isPrime[A[i]]){
            pairwise=false;
            break;
        }
        vector<ll> v;
        ll a=A[i];
        for(ll j=2;j*j<=a;j++){
            if(a%j==0)v.push_back(j);
            while(a%j==0) a/=j;
        }
        if(a!=1)v.push_back(a);
        for(auto x:v){
            for(ll j=x;j<=A[N-1];j+=x){
                isPrime[j]=false;
            }
        }
    }
    if(pairwise){
        cout<<"pairwise coprime"<<endl;
        return 0;
    }
    ll _gcd=A[0];
    for(ll i=1;i<N;i++){
        _gcd=gcd(_gcd,A[i]);
    }
    if(_gcd==1){
        cout<<"setwise coprime"<<endl;
        return 0;
    }
    cout<<"not coprime"<<endl;
    return 0;
}

Measured memory_bytes: 12368
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    double a, b, x;
    cin >> a >> b >> x;
    cout << fixed << setprecision(8);
    double res;
    double h = x/(a*a);
    if(h >= b/2.0) {
        double g = (b-h)/(a/2.0);
        res = atan(g);
        
    } else {
        double y = 2*x/(a*b);
        double g = b/y;
        res = atan(g);
    }

    
    cout << res*180/3.141592653589 << endl;


    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		List<Boolean> blue = new ArrayList<>();
		
		String str = sc.next();
		
		for (int i = 0; i < str.length(); i++) {
			blue.add(false);
			if (str.charAt(i) == '1') {
				blue.set(i, true);
			}
		}
		
		int count = 0;
		
		while (true) {
			int index1 = -1;
			int index2 = -1;
			
			int n = blue.size() / 2;
			
			for (int i = n; i < blue.size() - 1; i++) {
				if (blue.get(i) != blue.get(i + 1)) {
					index1 = i;
					break;
				}
			}
			
			for (int i = n - 1; i >= 0; i--) {
				if (blue.get(i) != blue.get(i + 1)) {
					index2 = i;
					break;
				}
			}
			
			int index = -1;
			
			if (index1 < 0){
				index = index2;
			} else if (index2 < 0) {
				index = index1;
			} else {
				if (index1 - n < n - index2) {
					index = index1;
				} else {
					index = index2;
				}
			}
			
			if (index < 0) {
				break;
			} else {
				for (int i = 0; i < 2; i++) {
					blue.remove(index);
				}
			}
			
			count += 2;
		}
		
		System.out.println(count);
	}
}


Measured memory_bytes: 27860
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);

        int k = scn.nextInt();
        int n = scn.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = scn.nextInt();
        }
        int max = array[0] + k - array[n - 1];

        for (int i = 1; i < n; i++) {
            max = Math.max(max, array[i] - array[i - 1]);
        }

        System.out.println(k - max);

    }
}

Measured memory_bytes: 79008
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder cards = new StringBuilder();
        int count;
        int i;
        int h;
        while (!cards.append(br.readLine()).toString().equals("-")) {
            count = Integer.parseInt(br.readLine());
            for (i = 0; i < count; i++) {
                h = Integer.parseInt(br.readLine());
                String subStr = cards.substring(0, h);
                cards.delete(0, h);
                cards.append(subStr);
            }
            System.out.println(cards);
            cards.delete(0, cards.length());
        }
    }
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

vl res;
vector<vector<pll>> adj;

void dfs(ll i, ll p, ll pc) {
	ll c = 1;
	for (auto e: adj[i]) {
		ll j, k;
		tie(j,k) = e;
		if (j == p) continue;
		if (c == pc) c++;
		res[k] = c;
		dfs(j,i,c);
		c++;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	adj.resize(n);
	FOR(i,1,n) {
		ll a, b;
		cin >> a >> b;
		a--, b--;
		adj[a].eb(b,i-1);
		adj[b].eb(a,i-1);
	}
	
	ll col = 0;
	FOR(i,0,n) col = max(col,sz(adj[i]));
	res.resize(n-1);
	dfs(0,-1,-1);
	
	cout << col << endl;
	FOR(i,0,n-1) cout << res[i] << endl;
}



Measured memory_bytes: 10752
import math
def get_prime(n):
    if n <= 1:
        return[]
    prime = [2]
    limit = int(math.sqrt(n))

    data = [i+1 for i in range(2,n,2)]
    while limit > data[0]:
        prime.append(data[0])
        data = [j for j in data if j% data[0] != 0]
    return prime + data
prime_num = get_prime(100003)

x = int(input())
for i in prime_num:
    if x <= i:
        print(i)
        exit()

Measured memory_bytes: 5272
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

const ll MOD=1e9+7;
ll ad(ll x,ll y=0){
  return (x+y)%MOD;
}

int main(){
  string k;
  ll d,n,dp[10010][100]={},ans=0,s=0;
  cin>>k>>d;
  n=k.length();
  dp[0][0]=1;
  Fr(i,n) fr(j,d) for(int l=0;l<10;l++) dp[i][j]=ad(dp[i][j],dp[i-1][((j-l)%d+d)%d]);
  fr(i,n){
    for(int j=0;j<k[i]-'0';j++){
      ans=ad(ans,dp[n-1-i][(d-(s+j)%d)%d]);
    }
    s=(s+k[i]-'0')%d;
  }
  if(s==0) ans++;
  cout<<(ans+MOD-1)%MOD<<endl;
}

Measured memory_bytes: 8064
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define VAR(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

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


    VAR(string, s);
    print(s.substr(0, 4) , s.substr(4, 8));

    return 0;
}


Measured memory_bytes: 256
-- C Exception handling

import Control.Monad
import Data.List

main :: IO()
main = do
  l <- getLine
  let n = read l :: Int
  a_orig <- replicateM n getLine
  let a_list = map read a_orig :: [Int]

  let biggest: second: _ = sortBy (\x y -> compare y x)  a_list

  forM_ a_list $ \i -> do
    if i == biggest then
      putStrLn(show second)
      else
      putStrLn(show biggest)



Measured memory_bytes: 97660
#!/usr/bin/env python3
import sys
import collections as cl


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    n, x, y = MI()
    ans = [0] * (n)

    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            dis = min(j - i, abs(i - x) + abs(j - y) + 1)
            ans[dis] += 1

    for i in range(1, n):
        print(ans[i])


main()


Measured memory_bytes: 75164
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 10????????? cout << setprecision(10) << double;
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (???test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// ??\??????push_back(d)???array[d]???????????????1?????§?????????
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// ?????§??¬?´???°???Greatest Common Divisor???
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// ????°???¬?????°???Least Common Multiple???
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y??´??????????????´?????????
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//??????????????????????????????.
	int n;
	cin >> n;
	FOR(i, 0, n) {
		int x, y, b, p;
		int ans_hutuu = 0;
		int ans_matome = 9999999;
		cin >> x >> y >> b >> p;

		ans_hutuu = x*b + y*p;
		// ???????????¨??§??????
		if (b < 5)	b = 5;
		if (p < 2)p = 2;
		ans_matome = x*b*0.8 + y*p*0.8;


		cout << min(ans_hutuu, ans_matome) << endl;
	}

	return 0;
}

Measured memory_bytes: 1200
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner (System.in);
		long takahasi=0,nakahasi=0,hikuhasi=0;
		long kaisu=0;
		long sum=0;
		sc=new Scanner(System.in);

		takahasi=sc.nextLong();
		nakahasi=sc.nextLong();
		hikuhasi=sc.nextLong();
		kaisu=sc.nextLong();
		sum=takahasi+nakahasi+hikuhasi;

		if(takahasi==nakahasi && nakahasi==hikuhasi) {
			System.out.println("0");
			System.exit(0);
		}
		else {
			/*for(int i=0; i<kaisu; i++) {
				takahasi=sum-takahasi;
				nakahasi=sum-nakahasi;
				hikuhasi=sum-hikuhasi;
				sum*=2;
			}*/

			if(kaisu%2==0) {		//偶数階処理の時
				//そのまま
			}

			else if(kaisu%2==1) {		//偶数階処理の時
				takahasi=sum-takahasi;
				nakahasi=sum-nakahasi;
			}
		}
		if(Math.abs(takahasi-nakahasi)>1000000000000000000l) {
			System.out.println("Unfair");
		}
		else {
			System.out.println(takahasi-nakahasi);
		}
	}
}

Measured memory_bytes: 20820
n = [int(x) for x in input()]
op_cnt = len(n)-1 #隙間の数
for i in range(2**op_cnt):
  op = ["-"] * op_cnt
  for j in range(op_cnt):
    if ((i>>j)&1):
      op[op_cnt-1-j] = "+"
  
  ans = ""
  for x, y in zip(n, op+[""]): #opの数はnよりひとつ少ないので数合わせしておく
    ans += str(x)+y
  if eval(ans)==7:
    print(ans+"=7")
    break

Measured memory_bytes: 3064
X = int(input())

for b in range(-10**6, 10**6):
    a5 = abs(b**5 + X)
    a = int(pow(a5, 1 / 5))

    if a5 < 0:
        a = -a

    if a**5 - b**5 == X:
        print(a, b)
        exit()


Measured memory_bytes: 9560
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int INF = 10e8;
const int maxN = 200010;
const int maxM = 100010;
const int N = 5000; 
const int MOD = 1000000007;

int a[maxN];
int n;
ll _min(ll a,ll b)
{
	if(a > b)
		return b;
	else
		return a;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		a[i] = a[i] - i;
	}
	sort(a+1,a+1+n);
	ll ans = 0;
	ll maxn = -INF;
	int pov = 0;
	int m = -1;
	int m1 = -1;
	if(n%2 == 1)
	{
		m = (n+1)/2;
	}
	else
	{
		m = n/2;
		m1 = n/2 + 1;	
	}
	pov = a[m];
	for(int i=1;i<=n;i++)
	{
		ans += (ll)abs(a[i] - pov);
	}
	maxn = ans;
	if(m1 != -1)
	{
		ans = 0;
		for(int i=1;i<=n;i++)
		{
			ans += (ll)abs(a[i] - a[m1]);
		}
	}
	maxn = _min(ans,maxn);
	printf("%lld\n",maxn);
	return 0;
}  

Measured memory_bytes: 1024
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>

using namespace std;


int main(int argc, const char * argv[]) {
    
    int h, n, sum = 0;
    string ans = "No";
    
    cin >> h >> n;
    
    int a[n];
    
    for(int i=0; i<n; i++)
    {
        cin >> a[i];
        
        sum += a[i];
        
        if(sum >= h)
        {
            ans = "Yes";
            break;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		int[]input = new int[n];
		for(int i=0;i<n;i++) {
			input[i]= sc.nextInt();
		}
		Arrays.sort(input);
		String res = "YES";
		for(int i=0;i<n-1;i++) {
			if(input[i]==input[i+1]) {
				res ="NO";
				break;
			}
		}
		System.out.println(res);


	}

}


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

int main() {
    int n, m; cin >> n >> m;
    int sum = 0;
    double A[n + 1];
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        sum += A[i];
    }
    double t = sum*1.0 / (4.0 * m);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (A[i] >= t) ans++;
    }
    if (ans >= m) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <utility>
#include <vector>

#define MAX_NODE 10000
#define INF 1000000000

using namespace std;

int d[MAX_NODE];
vector<int> adj[MAX_NODE];

int bfs(int n, int start){
	queue<int> que;
	for(int i=0;i<n;i++){
		d[i]=(i==start)?0:-1;
	}
	que.push(start);
	while(que.empty()==0){
		int from=que.front();
		que.pop();
		for(int i=0;i<adj[from].size();i++){
			int to=adj[from][i];
			if(d[to]==-1){
				d[to]=d[from]+1;
				que.push(to);
			}
		}
	}
}	

int main(){
	int n,u,k,v;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>u>>k;
		for(int j=0;j<k;j++){
			cin>>v;
			v--;
			adj[u-1].push_back(v);
		}
	}
	bfs(n,0);
	for(int i=0;i<n;i++){
		cout<<i+1<<" "<<d[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1460