akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll n;
  cin >> n;
  char arr[n];
  ll black = 0, white = 0;
  fi(0, n) {
    cin >> arr[i];
    if(arr[i] == '.')
      black++;
  }
  ll ans = black;
  fi(0, n) {
    if(arr[i] == '#') {
      white++;
    }
    else {
      black--;
    }
    chmin(ans, white + black);
  }
  
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 384
#include <stdio.h>
#define N 2001

void calc(int, int);

char A[N];
int n,q,elems[20];

int main(){
    int i,tmp;
    for(i=0; i<N; i++){
        A[i]='n';
    }
    scanf("%d",&n);
    for(i=0; i<n; i++) scanf("%d",&elems[i]);
    calc(0,0);
    scanf("%d",&q);
    for(i=0; i<q; i++){
        scanf("%d",&tmp);
        if(A[tmp] == 'y')printf("yes\n");
        else printf("no\n");
    }
}

void calc(int sum, int a){
    if(a == n){
        if(sum >= 1 && sum <= 2000){
            A[sum] = 'y';
        }
    }
    else{
        calc(sum+elems[a],a+1);
        calc(sum,a+1);
    }
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> v(m);
  vector<vector<int>> r(n+1);
  rep(i, m){
    cin >> v[i].first >> v[i].second;
    r[v[i].first].push_back(v[i].second);
  }
  rep(i, n+1) sort(r[i].begin(), r[i].end());
  rep(i, m){
    string a = "";
    int b, c;
    b = v[i].first;
    c = lower_bound(r[v[i].first].begin(), r[v[i].first].end(), v[i].second) - r[v[i].first].begin() + 1;
    rep(j, 6){
      a = to_string(c%10) + a;
      c /= 10;
    }
    rep(j, 6){
      a = to_string(b%10) + a;
      b /= 10;
    }
    cout << a << endl;
  }
  return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define pb push_back
#define ff first
#define ss second
#define long int64_t
using namespace std;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, INF<<1);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args)
{ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma+1, args...); }

const int N = 301;
const int mod = 998244353;

int a[N], dp[2][N * N], au[2][N * N];

int main()
{
	fio;
	int n, p = 0, a0 = 1;
	cin >> n;
	for(int i=1; i<=n; i++)
	{
		cin >> a[i];
		p += a[i];
		a0 = (a0 * 3ll) % mod;
	}
	dp[0][0] = au[0][0] = 1;
	int id = 0;
	for(int i=1; i<=n; i++)
	{
		for(int j=0; j<a[i]; j++)
		{
			dp[id ^ 1][j] = (dp[id][j] << 1) % mod;
			au[id ^ 1][j] = au[id][j];
		}
		for(int j=a[i]; j<=p; j++)
		{
			dp[id ^ 1][j] = (dp[id][j] * 2ll + dp[id][j - a[i]]) % mod;
			au[id ^ 1][j] = (au[id][j] + au[id][j - a[i]]) % mod;
		}
		id ^= 1;
	}
	int a1 = 0;
	for(int i=(p+1 >> 1); i<=p; i++)
		a1 = (a1 + dp[id][i]) % mod;
	a1 = (a1 * 3ll) % mod;
	if((p & 1) == 0)
		a1 = ((a1 - au[id][p >> 1] * 3ll) % mod + mod) % mod;
	int ans = (a0 - a1 + mod) % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1664
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 200000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	ll cost;
	edge(int _t, ll _cost) : t(_t)
		, cost(_cost) {
	}
};
bool isPrime(int n) {

	if (n == 1) return false;
	for (ll i = 2; i * i <= n; i++)
	{
		if (n % i == 0) return false;
	}
	return true;
}
void Solve() {
	int n;
	cin >> n;
	int a[100010];
	for (size_t i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	int res = 0;
	for (size_t i = 1; i <= n; i++)
	{
		res += a[a[i]] == i;
	}
	cout << (res / 2) << endl;
}
int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define mod		1000000007
#define inf     1000000000000000000
#define MX1		100005
#define MX2		10000004
#define pi		acos(-1)
#define pb      push_back
#define vlli    vector<lli>
#define plli    vector<pair<lli,lli> >
#define mp      make_pair
#define all(v)  v.begin(),v.end()
#define test    int t;cin>>t;
lli gcd(lli a, lli b){return b?gcd(b,a%b):a;}
lli power(lli a,lli b){lli ans=1;while(b){if(b&1){ans=(ans*a)%mod;}a=(a*a)%mod;b>>=1;}return ans;}
int main()
{
	opt;
	lli n;
	cin>>n;
	lli min=10000000,max=-1,i,j;
	for(i=0;i<n;i++)
	{
		cin>>j;
		if(j<min)
		min=j;
		if(j>max)
		max=j;
	}
	cout<<max-min<<"\n";

	return 0;
}


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

#define pow(n) (n)*(n)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using namespace std;


int main (void) 
{

  /* Variable_Proclamation */
  int N;    // input
  int K;    // input

  int i;    // subscript
  int comp; // comparison
  int dif;
  int rewrite; // output


  /* Input, Array_Proclamation */
  cin >> N >> K;
  vector<int> A(N);

  vector< pair<int, int> > kinds;


  for(i=0; i<N; i++)
  {
    cin >> A.at(i);
  }


  /* Initialize */
  comp  = 0;
  dif   = 0;
  rewrite = 0;


  /* Calculation */

  sort( all(A) );

  for(i=0; i<N; i++)
  {
    if( comp != A.at(i) )
    {
      comp  = A.at(i);
      kinds.push_back( make_pair(1, comp) );
    }
    else
    {
      kinds.at( kinds.size() -1 ).first++;
    }
  }

  sort   ( all(kinds) );
  reverse( all(kinds) );

  dif = kinds.size() - K;

  while(dif > 0)
  {

    rewrite += kinds.at( kinds.size() -1 ).first;
    dif--;
    
    kinds.pop_back();

  }
  

  /* Output */
  cout << rewrite << endl;


  return 0;

}


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

int main(){
 long long H,c=0,d=1,co=0;
  cin >> H;
  c=divine(H);

  rep(i,c){
   d*=2;
    co+=d;
  }
 
  cout << co+1 <<endl;
}

long long divine(long long H){
  
  if(H==1){
return 0;
  }
  long long c= divine(H/2);
  c++;
  return c;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var count1 = 0;
            var count2 = 0;
            var count3 = 0;
            var count4 = 0;

            for (int i = 0; i < 3; i++)
            {
                var a = ReadInts();
                for (int i1 = 0; i1 < 2; i1++)
                {
                    var x = a[i1];
                    switch (x)
                    {
                        case 1:
                            count1++;
                            break;
                        case 2:
                            count2++;
                            break;
                        case 3:
                            count3++;
                            break;
                        case 4:
                            count4++;
                            break;
                        default:
                            break;
                    }
                }
            }
            if (count1 == 3 || count2 == 3 || count3 == 3 || count4 == 3)
            {
                WriteLine("NO");
            }
            else
            {
                WriteLine("YES");
            }
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

    }
}


Measured memory_bytes: 13140
#include <stdio.h>
#include <math.h>
 
int main()
{
  int a,b,c;
  double S,L;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  S=a*b*sin(c*M_PI/180)/2;
  L=sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(c*M_PI/180))+a+b;
  printf("%lf\n",S);
  printf("%lf\n",L);
  printf("%lf\n",2*S/a);
  return 0;
}


Measured memory_bytes: 2112
#include<iostream>
using namespace std;
int main() {
	char a;
	cin >> a;
	if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u') {
		cout << "vowel" << endl;
	}
	else cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define MAX_N 200
using namespace std;

int main() {
  int n, ans=100;
  int dig;
  long long tmp;

  scanf("%d", &n);
  for(int i=0;i<n;i++){
    scanf("%lld", &tmp);
    dig=0;
    while((tmp&(1<<dig))==0) dig++;
    if(ans>dig) ans=dig;
  }

  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int N,A,B;
    std::cin>>N>>A>>B;
    if(N*A<=B){
        std::cout<<N*A<<std::endl;
    } else if(N*A>B){
        std::cout<<B<<std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cctype>
#include <complex>

using namespace std;

int main()
{
    int a,b;
    string s;
    cin >> a >> b >> s;
    
    const bool ispc = s[a] == '-' &&
        any_of(&s[0], &s[a], [](char x){ return isdigit(x) != 0; }) && 
        any_of(&s[a+1], &s[a+b+1], [](char x){ return isdigit(x) != 0; });
    
    cout << (ispc ? "Yes" : "No") << '\n';
    
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define AC cout << "AC" << endl;
#define WA cout << "WA" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long

const unsigned int BIT_FLAG_0 = (1 << 0);  // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1);  // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2);  // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3);  // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4);  // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5);  // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6);  // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7);  // 0000 0000 1000 0000

const double PI = 3.14159265358979323846;

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

#define H_MAX 500
#define W_MAX 500
#define INF 1e9 + 7

int main() {
    string S;
    int flag, cnt = 0, vmax = 0;
    cin >> S;
    rep(i, S.size()) {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
            cnt++;
        } else {
            cnt = 0;
        }
        vmax = max(vmax, cnt);
    }
    cout << vmax << endl;
}


Measured memory_bytes: 3624
import java.io.ByteArrayInputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	String INPUT = "";
	
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes()));
		PrintWriter out = new PrintWriter(System.out);
		
		solve(sc, out);
		out.flush();
	}
	
	void solve(Scanner sc, PrintWriter out) {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int arr[] = {a,b,c};
		Arrays.sort(arr);
		
		System.out.println(arr[0] + " " + arr[1] + " " + arr[2]);
	}
}



Measured memory_bytes: 26220
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

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

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, M;
std::map<ll, ll> mp, mod, dup;
ll ans;

int main()
{
  std::cin >> N >> M;

  rep( i, N )
  {
    ll X;
    std::cin >> X;

    ++mp[X];
    ++mod[X%M];
  }

  itr( it, mp )
  {
    if( it->second >= 2 )
    {
      dup[it->first%M] += it->second/2;
    }
  }

  ans += mod[0]/2;

  if( !(M&1) )
    ans += mod[M/2]/2;
  
  repi( i, 1, (M+1)/2 )
  {
    ans += std::min( mod[i], mod[M-i] );

    if( mod[i] > mod[M-i] )
      ans += std::min( (mod[i]-mod[M-i])/2, dup[i] );
    
    if( mod[i] < mod[M-i] )
      ans += std::min( (mod[M-i]-mod[i])/2, dup[M-i] );
  }
  
  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 12928
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N;
    cin >> N;
    vector<int> C(N),S(N),F(N);
    rep(i,0,N-1){
        cin >> C[i] >> S[i] >>F[i];
    }
    rep(i,0,N){
        int t = 0;
        for(int j = i; j < N-1; j++){
            if(t < S[j]){
                t = S[j];
            }
            if(t % F[j] != 0){
                t += (F[j] - t % F[j]);
            }
            t += C[j];
        }
        cout << t << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n,a,b,c;
	scanf("%d",&n);
	a=n/10;
	b=a/10;
	c=b/10;
	if(((n%10==a%10)&&(a%10==b%10))||((a%10==b%10)&&(b%10==c%10))){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

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

int main(){
	int n;
	double x, y;
	double angle;
	while (cin >> n) {
		if (n == -1) {
			break;
		}
		x = 1;
		y = 0;
		angle = M_PI_2;
		n--;
		for (int i = 0; i < n; i++) {
			x += cos(angle);
			y += sin(angle);
			angle = atan2(y, x) + M_PI_2;
		}
		cout << x << endl;
		cout << y << endl;
	}
	return 0;
}

Measured memory_bytes: 0
//wxlcoder
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <numeric>
#include <utility>
#include <queue>
#include <memory>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cstdlib>
#include <list>
#include <limits.h>
#include <utility>
#include <functional>
#include <iterator>
#include <deque>
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MAXN 10010
#define MAXM
using namespace std;
/*********default*********/

int main()
{
	long long n, m, ans = 0x3f3f3f3f3f3f3f3f;
	long long a[3];
	
	scanf("%lld%lld", &n, &m);
	long long x;
	
	for (int i = 1; i < n; i++) {
		a[0] = i * m;
		x = (n - i) / 2;
		a[1] = x * m;
		a[2] = (n - i - x) * m;
		sort(a, a + 3);
		ans = min(ans, a[2] - a[0]);
		a[0] = i * m;
		x = m / 2;
		a[1] = x * (n - i);
		a[2] = (m - x) * (n - i);
		sort(a, a + 3);
		ans = min(ans, a[2] - a[0]);/*
		if (i == 2) {
			printf("%d\n", ans);
		}*/
	}
	swap(n, m);
	for (int i = 1; i < n; i++) {
		a[0] = i * m;
		x = (n - i) / 2;
		a[1] = x * m;
		a[2] = (n - i - x) * m;
		sort(a, a + 3);
		ans = min(ans, a[2] - a[0]);
		a[0] = i * m;
		x = m / 2;
		a[1] = x * (n - i);
		a[2] = (m - x) * (n - i);
		sort(a, a + 3);
		ans = min(ans, a[2] - a[0]);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#define ll long long
#define MAXN 2000005
using namespace std;
ll a[MAXN], X, x, mn = (1ll << 62);
int main() {
	ll n;
	scanf("%lld", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		X += a[i];
	}
	for(int i = 1; i < n; i++) {
		x += a[i];
		mn = min(abs(X-x-x), mn);
	}
		
	printf("%lld\n", mn);
	return 0;
}

Measured memory_bytes: 1664
n,k=map(int,input().split())
array=[]
for i in range(n):
    array.append(list(map(int,input().split())))
array.sort(key=lambda x:x[0])
q=True
count=0
i=0
while q:
    count +=array[i][1]
    if k<=count:
        print(array[i][0])
        exit()
    else:
        i +=1

Measured memory_bytes: 29144
S=input()
K=int(input())
x=0
l=[]
for i in range(len(S)):
    if S[i-1]==S[i]:
        x+=1
    else:
        l.append(x)
        x=0
l.append(x)
if len(l)==1:
    print(-(-len(S)*K)//2)
elif S[-1]!=S[0]:
    print(sum([-(-e//2) for e in l])*K)
elif S[-2]==S[-1]:
    print(-(-(l[0]-1)//2)+sum([-(-e//2) for e in l[1:-1]])*K-((-l[0]-l[-1])//2)*(K-1)-((-l[-1])//2))
else:
    print(-(-(l[0]-1)//2)+sum([-(-e//2) for e in l[1:]])*K-(-l[0]//2)*(K-1))

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

using namespace std;

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

	vector<int> a(n+1), b(n+1), c(n);

	for (int i=1; i<n+1; i++) cin >> a[i];
	for (int i=1; i<n+1; i++) cin >> b[i];
	for (int i=1; i<n; i++) cin >> c[i];

	int s = b[a[1]];

	for (int i=2; i<n+1; i++) {
		s += b[a[i]];
		if (a[i] != 1 && a[i-1]+1==a[i])
			s += c[a[i-1]];
	}

	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
//#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ld n;
    cin >> n;
    cout << fixed;
    cout << setprecision(numeric_limits<double>::digits10 + 1);
    if((int) n % 2 == 0) cout << 0.5;
    else cout << ceil(n / 2) / n;

    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return int64(a)
}

func scanFloat() float64 {
	sc.Scan()
	a, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func scanTextSlice(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = scanText()
	}
	return a
}

func scanSlice(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanFloatSlice(n int) []float64 {
	a := make([]float64, n)
	for i := 0; i < n; i++ {
		a[i] = scanFloat()
	}
	return a
}

func scanInt64Slice(n int64) []int64 {
	a := make([]int64, n)
	for i := int64(0); i < n; i++ {
		a[i] = scanInt64()
	}
	return a
}

// var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt64()

	// input := scanSlice(2)
	// n := input[0]
	// k := input[1]

	// arr := scanSlice(n)
	// sort.Ints(arr)

	temp := int64(math.Log2(float64(n)))
	// if temp <= 1 {
	// 	temp++
	// }
	// fmt.Println("TEMP : ", temp)

	temp++
	temp = int64(math.Pow(2, float64(temp)))
	temp--
	ans := temp

	fmt.Println(ans)

}

func calc() int {

	return 0

}

type position struct {
	x        int
	y        int
	distanse int
}

func binarySearch(arr []int, number int) int {

	l := -1
	r := len(arr)
	index := 0
	for {
		mid := l + (r-l)/2
		tmp := arr[mid]

		if r-l <= 1 || tmp == number {
			index = mid
			break
		} else if tmp < number {
			l = mid
		} else {
			r = mid
		}
	}
	return index
}

func factorial(n int) int64 {
	sum := int64(1)
	for i := 2; i <= n; i++ {
		sum *= int64(i)
	}
	return sum
}

func deleteNumOfArray(arr []int, position int) []int {
	left := arr[:position]
	r := arr[position+1:]
	appendArr := append(left, r...)
	return appendArr
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  	int k,x;
  	cin>>k>>x;
  	if(x==(-1000000)){
        for(int i=x;i<x+k;i++){
            cout<<i<<" ";
        }
  	}
  	else if(x==(1000000)){
        for(int i=x-k+1;i<x+1;i++){
            cout<<i<<" ";
        }
  	}
  	else{
        for(int i=x-k+1;i<x+k;i++){
            cout<<i<<" ";
        }
  	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
olle = s.count("E")
cw,ce,p=0,0,10**6
for i in s:
    if i == "E":
        ce += 1
        p = min(p,cw+olle-ce)
    else:
        cw += 1
        p = min(p,cw-1+olle-ce)
print(max(p,0))

Measured memory_bytes: 3672
#include<stdio.h>

int main()
{
  int n;
  
  scanf("%d",&n);
  
  int l[n],r[n];
  int i;
  int ans=0;
  
  for(i=0;i<n;i++)
  {
    scanf("%d%d",&l[i],&r[i]);
    ans+=r[i]-l[i]+1;
  }
  
  printf("%d\n",ans);
  
  return 0;
}

Measured memory_bytes: 128
//Asif 
//CSE 18
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if((a>b && b!=1) || (a<b && a==1))
    {
        cout<<"Alice\n";
    }
    else if((b>a && a!=1) || (b<a && b==1))
    {
        cout<<"Bob\n";
    }
    else {
        cout<<"Draw\n";
    }
    return 0;
}



Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        long ln = long.Parse(Console.ReadLine());
        double n = (double)ln;
        for (int i = 1; i <= 3500; i++)
        {
            for (int j = 1; j <= 3500; j++)
            {
                var k = 1 / (4 / n - (1.0 / i + 1.0 / j));
                var floor = (int)Floor(k);
                var ceil = (int)Ceiling(k);

                if (floor > 0 && Judge(ln, i, j, floor))
                {
                    Console.WriteLine($"{i} {j} {floor}");
                    return;
                }
                if (ceil > 0 && Judge(ln, i, j, ceil))
                {
                    Console.WriteLine($"{i} {j} {ceil}");
                    return;
                }
            }
        }
    }
    static bool Judge(long N, long h, long n, long w) => 4 * h * n * w == N * (h * n + n * w + w * h);
}


Measured memory_bytes: 13268
import sys


def main():
    N = int(input())
    A = [list(map(int, input().split())) for i in range(N)]
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            dij = A[i][j]
            res = True
            for k in range(N):
                if k in [i, j]:
                    continue
                dikj = A[i][k] + A[k][j]
                if dij > dikj:
                    print(-1)
                    sys.exit()
                elif dij == dikj:
                    res = False
            if res:
                ans += dij
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 42460
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
a b c d 100
 */
int a[4];

int main(){
  REP(i,4)
    cin>>a[i];

  cout<< max(0, min(a[1],a[3])-max(a[0],a[2])) << endl;

  return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())

S = []
for i in range(M) :
    L = list(map(int,input().split()))[1:]
    for j in range(len(L)) :
        L[j] -= 1
    S.append(L)

P = list(map(int,input().split()))

ans = 0

for bit in range(1 << N) :
    A = []
    for k in range(N) :
        if bit & (1 << k) :
            A.append(k)
    for i in range(len(S)) :
        cnt = 0
        for s in S[i] :
            if s in A :
                cnt += 1
        if (cnt % 2) != P[i] :
            break
    else :
        ans += 1
print(ans)


Measured memory_bytes: 3064
from itertools import product
N, M = list(map(int, input().split()))
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]
flag = False

for _i, _j in product(range(N - M + 1), range(N - M + 1)):
    if A[_i][_j] == B[0][0] and [_A[_j:_j+M] for _A in A[_i:_i+M]] == B:
        flag = True
        break
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

bool check(string &s, string &t) {
    int cnt[128] = {0};
    for (auto &c : s) {
        cnt[c]++;
    }
    for (auto &c : t) {
        if (cnt[c] <= 0) {
            return false;
        }
    }
    return true;
}

ll calc(int a, int b, int n) {
    if (a < b) {
        return b - a;
    } else {
        return (n - a + b);
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    if (!check(s, t)) {
        cout << -1 << endl;
        return 0;
    }
    s += s;
    auto dp = make_v(s.size(), 128, -1);
    auto cnt = make_v(128, -1);
    for (int i = s.size() - 1; i >= 0; i--) {
        dp[i] = cnt;
        cnt[s[i]] = i;
    }
    ll ans = cnt[t[0]];
    int index = ans;
    int n = t.size();
    int m = s.size() / 2;
    ll prev = ans;

    REP(i, 1, n) {
        ans += calc(prev, dp[index][t[i]] % m, m);
        prev = dp[index][t[i]] % m;
        index = prev;
    }
    cout << ans + 1 << endl;

    return 0;
}


Measured memory_bytes: 108396
#include <iostream>
#include <cmath>
#include <algorithm>

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

using namespace std;
/*
const int mod=1000000000+7;
const ll inf=10000000000;
*/
int main() {
    int N;
    cin>>N;
    
    ll a[N+1][3];
    for(int i=1;i<=N;++i) cin>>a[i][0]>>a[i][1]>>a[i][2];
    
    ll d[N+1][3];
    rep(i,3)d[0][i]=0;

    
    for(int i=1;i<=N;++i){
        for(int j=0;j<3;++j){
            ll m=0;
            for(int k=0;k<3;++k){
                if(k!=j){
                    m=max(d[i-1][k]+a[i][j],m);
                }
            }
            d[i][j]=m;
        }
    }
    
    cout<<max(d[N][0],max(d[N][1],d[N][2]))<<endl;
    
}



Measured memory_bytes: 8264
//Zory-2019
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<deque>
// #include<unordered_map>
using namespace std;
int bin[40],lg[1<<21];
namespace mine
{
	typedef long long ll;
	#define double long double
	const int INF=0x3f3f3f3f;
	const ll LLINF=0x3f3f3f3f3f3f3f3fll;
	ll qread()
	{
		ll ans=0;char c=getchar();int f=1;
		while(c<'0' or c>'9') {if(c=='-') f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num)
	{
		if(num<0) {num=-num;putchar('-');}
		if(num>9) write(num/10);
		putchar('0'+num%10);
	}
	void writeln(int num){write(num);puts("");}
	#define FR first
	#define SE second
	#define MP make_pair
	#define pr pair<int,int>
	#define PB push_back
	#define vc vector
	void chmax(int &x,const int y) {x=x>y?x:y;}
	void chmin(int &x,const int y) {x=x<y?x:y;}
	const int MAX_N=5e5+10;
	const int MOD=1e9+7;
	void add(int &x,int y) {x+=y;if(x>=MOD) x-=MOD;if(x<0) x+=MOD;}

	struct SegmentTree
	{
		#define lc 2*x
		#define rc 2*x+1
		#define mid ((l+r)>>1)
		pr mx[MAX_N*4];
		void change(int x,int l,int r,int p,int c)
		{
			mx[x]=max(mx[x],MP(c,p));
			if(l==r) return;
			if(p<=mid) change(lc,l,mid,p,c);
			else change(rc,mid+1,r,p,c);
		}
		pr ask(int x,int l,int r,int fl,int fr)
		{
			if(fl>fr) return MP(0,0);
			if(l==fl and r==fr) return mx[x];
			if(fr<=mid) return ask(lc,l,mid,fl,fr);
			if(fl>mid) return ask(rc,mid+1,r,fl,fr);
			return max(ask(lc,l,mid,fl,mid),ask(rc,mid+1,r,mid+1,fr));
		}
	}sgt;

	int a[MAX_N],ans[MAX_N];
	int ru[MAX_N];vector<int> to[MAX_N];
	void ins(int x,int y) {ru[y]++;to[x].PB(y);}
	priority_queue< int,vector<int>,greater<int> > q;
	void main()
	{
		int n=qread(),K=qread();
		for(int i=1;i<=n;i++) a[qread()]=i;
		for(int i=1;i<=n;i++)
		{
			int num=a[i];sgt.change(1,1,n,num,i);
			pr a=sgt.ask(1,1,n,max(1,num-K+1),num-1);if(a.FR>0) ins(a.SE,num);
			pr b=sgt.ask(1,1,n,num+1,min(num+K-1,n));if(b.FR>0) ins(b.SE,num);
		}
		for(int i=1;i<=n;i++) if(ru[i]==0) q.push(i);
		for(int now=1;now<=n;now++)
		{
			int x=q.top();q.pop();ans[x]=now;
			for(int t=0;t<(int)to[x].size();t++)
			{
				int y=to[x][t];ru[y]--;
				if(ru[y]==0) q.push(y);
			}
		}
		for(int i=1;i<=n;i++) writeln(ans[i]);
	}
};
int main()
{
	srand(time(0));
	bin[0]=1;for(int i=1;i<=30;i++) bin[i]=bin[i-1]<<1;
	lg[1]=0;for(int i=2;i<(1<<21);i++) lg[i]=lg[i>>1]+1;
	mine::main();
}


Measured memory_bytes: 61184
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;


#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;


void Main(){
   int N;
   cin >> N;
  vector<int> L(2*N);
  rep(i,2*N) cin >> L[i];
  
  sort(L.begin(), L.end());
  int sum = 0;
  rep(i,N){
  sum += L[2*i];
  }
  cout << sum << endl;
 return;
 }
  
int main(){
 cin.tie(nullptr);
 ios_base::sync_with_stdio(false);
 cout << fixed << setprecision(15);
 Main();
 return 0;
 }

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

#define LL                      long long
#define Ulong                   unsigned long long
#define REP(i,n)                for(long long i=0; i < n ; i++ )
#define mp                      make_pair
#define pb                      push_back
#define all(x)                  (x).begin(),(x).end()
#define PI                      acos(-1.0)
#define EPS                     1e-14
#define F                       first
#define S                       second
#define di(x)                   int x; input(x)
#define in(x)                   input(x)
#define in2(x,y)                in(x),in(y)
#define in3(x,y,z)              in(x),in2(y,z)
#define lc                      ((n)<<1)
#define rc                      ((n)<<1|1)
#define db(x)                   cout << #x << " -> " << x << endl
#define nl                      cout<<endl
#define ms(ara_name,value)      memset(ara_name,value,sizeof(ara_name))
#define IO                      ios_base::sync_with_stdio(0);cin.tie(0)
#define READ                    freopen("/home/matrixcode/Desktop/in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
template<class T> inline void input(T &x) {
  register char c = getchar();x = 0;
  int neg = 0;
  for(; ((c<48 || c>57) && c != '-'); c = getchar());
  if(c=='-'){neg = 1;c = getchar();}
  for(; c>47 && c<58 ; c = getchar()){x = (x<<1) + (x<<3) + c - 48;}
  if(neg) x = -x;
}
inline long long bigmod(long long p,long long e,long long M){
  long long ret = 1;
  for(; e > 0; e >>= 1){
    if(e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  } return ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/***************************** END OF TEMPLATE *******************************/

const int N = 3e5+5;
int h[N];
int dp[N];
int main()
{
  int n,k;
  in2(n,k);
  dp[0] = 0;
  in(h[0]);
  for(int i = 1; i < n; i ++) {
    in(h[i]);
    dp[i] = INT_MAX;
    for(int j = 1; j <= k && i - j >= 0; j ++) {
      dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i-j]));
    }
  }
  cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#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 n;
  cin >> n;
  vector<int> a(n);
  int m = 1000000000, M = 0;
  rep(i, n) {
    cin >> a[i];
    m = min(m, a[i]);
    M = max(M, a[i]);
  }

  cout << M - m << endl;
  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<n;i++)
int main(void){
  int num;
  int a[2][100];
  int i,j,k;
  int sumMax;
  int sum[100] = {0};
  
  cin >> num;
  
  rep0(i,num) cin >> a[0][i];
  rep0(i,num) cin >> a[1][i];
   
  /*for(i=0;i<num;i++){      
    for(j=0;j<num;j++){*/
  rep0(i,num){
    rep0(j,num){
       if(i <= j){
         sum[i] += a[1][j]; 
         if(i==j){
           sum[i] += a[0][j];
         }
       }
       else {
         sum[i] += a[0][j]; 
       }     
     }
  }
  
  sumMax = sum[0]; 
  rep1(k,num){
    if(sumMax < sum[k]){
       sumMax = sum[k]; 
    }
  }
  
  cout << sumMax << endl;
  
  return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    if(count(a.begin(),a.end(),0)!=0){
        cout<<0<<endl;
        return 0;
    }
    ll ans=1;
    ll mx=1e18;
    rep(i,n){
        if(a[i]<=mx/ans){
            ans*=a[i];
        }
        else{cout<<-1<<endl; return 0;}
    }
    cout<<ans<<endl;
    return 0;
}


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

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

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

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

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

  int n, q; cin >> n >> q;
  vector<pair<int, P>> vec(n);
  rep(i, n) {
    int s, t, x; cin >> s >> t >> x;
    vec[i] = make_pair(x, P(s, t));
  }
  sort(vec.begin(), vec.end());

  set<int> st;
  unordered_map<int, int> mp;
  vector<int> ans(q, -1);

  rep(i, q) {
    int d; cin >> d;
    st.insert(d);
    mp[d] = i;
  }

  rep(i, n) {
    int x = vec[i].first;
    int s = vec[i].second.first;
    int t = vec[i].second.second;
    auto it = st.lower_bound(s-x);
    while(it != st.end()) {
      if (*it < t-x) {
        auto d = *it;
        ans[mp[d]] = x;
        it = st.erase(it);
      } else {
        break;
      }
    }
  }
  rep(i, q) {
    cout << ans[i] << '\n';
  }
}

Measured memory_bytes: 25032
//B.cpp
#include <iostream>
#include <string>
using namespace std;

int chk;

int main(){
  int H,W;
  cin >> H >> W;
  string S[H];
  for(int i = 0; i < H; i++){
    cin >> S[i];
  }

  bool flag;
  int l = 0;
  chk = W;

  while(l<W){
    flag = true;
    for(int j = 0; j < H; j++){
      if(S[j][l]!='.'){
        flag = false;
        break;
      }
    }
    if(flag){
      for(int k = 0; k < H; k++){
        S[k].erase(S[k].begin()+l);
      }
      --chk;
    }else{
      ++l;
    }
  }

  for(int i = 0; i < H; i++){
    if(S[i]==string(chk,'.')){
      S[i] = "";
    }
  }

  for(int i = 0; i < H; i++){
    if(S[i]!="") cout << S[i] << endl;
    else cout << S[i];
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    int N = sz(s);

    rep(i,N){
        cout << 'x';
    }
}

Measured memory_bytes: 256
from operator import itemgetter

H, W = map(int, input().split())

A = []
Hnew = 0
for i in range(H):
    temp = input()
    if temp == '.' * W:
        pass
    else:
        A.append(temp)
        Hnew += 1

FlagA = [0] * W

for i in range(W):
    for j in range(Hnew):
        if A[j][i] == '#':
            FlagA[i] = 1
            break

for i in range(Hnew):
    for j in range(W):
        if FlagA[j] == 1:
            print(A[i][j], end="")
    print()


Measured memory_bytes: 4468
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace test
{
    class Program
    {


        static void Main(string[] args)
        {
            List<List<decimal>> resultList = new List<List<decimal>>();

            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string[] inputArray = Console.ReadLine().Split(' ');

                resultList.Add(GetAnswer(inputArray));

            }

            foreach (List<decimal> list in resultList)
            {
                Console.WriteLine("{0:f3} {1:f3} {2:f3}", list[0], list[1], list[2]);
            }

            //Console.ReadKey();

        }

        static List<decimal> GetAnswer(string[] inputArray)
        {
            List<decimal> answer = new List<decimal>();

            decimal x1 = decimal.Parse(inputArray[0]);
            decimal y1 = decimal.Parse(inputArray[1]);
            decimal x2 = decimal.Parse(inputArray[2]);
            decimal y2 = decimal.Parse(inputArray[3]);
            decimal x3 = decimal.Parse(inputArray[4]);
            decimal y3 = decimal.Parse(inputArray[5]);

            decimal a, b, c, l, m, n;

            a = x2 * x2 + y2 * y2 - x1 * x1 - y1 * y1;
            b = x3 * x3 + y3 * y3 - x2 * x2 - y2 * y2;

            if (y2 != y3)
            {
                c = (y1 - y2) / (y2 - y3);

                l = (a - c * b) / (x1 - x2 - c * (x2 - x3));
                m = (b - l * (x2 - x3)) / (y2 - y3);
            }
            else
            {
                l = -x2 - x3;
                m = (a - (x1 - x2) * l) / (y1 - y2);
            }

            n = -x1 * l - y1 * m - x1 * x1 - y1 * y1;

            //Console.WriteLine("{0:f3} {1:f3} {2:f3}", l,m,n);

            decimal x = -l / 2;
            decimal y = -m / 2;
            decimal r = (decimal)Math.Sqrt((double)x * (double)x + (double)y * (double)y - (double)n);

            answer.Add(x);
            answer.Add(y);
            answer.Add(r);

            return answer;
        }

    }
}

Measured memory_bytes: 6004
import sys
import math
import functools

def resolve(in_):
    N = int(next(in_))
    A = tuple(map(int, next(in_).split()))

    max_a = max(A)
    temp = [0] * (max_a + 1)
    temp[1] = 1

    for i in range(2, max_a + 1):
        if temp[i]:
            continue

        j = i
        while j < max_a + 1:
            if not temp[j]:
                temp[j] = i
            j += i

    B = set()
    for a in A:
        s = set()
        while a > 1:
            s.add(temp[a])
            a = a // temp[a]
        for v in s:
            if v in B:
                if functools.reduce(math.gcd, A) == 1:
                    return 'setwise coprime'
                else:
                    return 'not coprime'
            B.add(v)
    
    return 'pairwise coprime'
    

def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 110580