akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  int N, P;
  vector<int> A;
  vector<int> U;
  map<int, int> memo;
  ll res{};

  Tmp(int N, int P)
  : N(N)
  , P(P)
  , A(N)
  , U(N+1)
  {}

  ll operator()() {
    pre();
    return res;
  }

  void pre() {
    U[N] = 0;
    ++memo[0];
    ll kisuu = 1;
    for (int i = N-1; i >= 0; --i) {
      auto a = A[i] * kisuu + U[i+1];
      kisuu *= 10;
      kisuu %= P;
      a %= P;
      U[i] = a;
      res += memo[a];
      ++memo[a];
    }
  }
};

void solve(void)
{
  int N, P; cin >> N >> P;
  Tmp t(N, P);
  for (int i = 0; i < N; ++i) {
    char c; cin >> c;
    t.A[i] = c - '0';
  }

  ll ans{};
  if (P == 2 || P == 5) {
    // 10とPが互いに素ではない
    for (int i = 0; i < N; ++i) {
      if (t.A[i] % P == 0) {
        // 0 % P == 0もOKなので
        ans += i+1;
      }
    }
  }
  else {
    // 10とPが互いに素なので後ろから見る
    ans = t();
  }
  cout << ans << CRLF;

  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
ll mod=1000000007;
//ll mod=67280421310721;
//ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		string s;
		cin>>s;
		FOR(i,0,s.size())
		{
			if(s[i]=='P')
			cout<<'P';
			else
			cout<<'D';
		}
	}
	return 0;
}


Measured memory_bytes: 3732
import java.util.*;
public class Main{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
     long n=sc.nextLong();
      ArrayList<Long> a1=new ArrayList<Long>();
      HashMap<Long,Long>  map=new HashMap<Long,Long>();
	long a[]=new long[(int)n];
	long s=0;
       for(int i=0;i<n;i++)
      {
	    a[i]=sc.nextLong();
	    s=s+a[i];
               if(map.containsKey(a[i]))
	                 map.put(a[i],map.get(a[i])+1);
              else
  	                map.put(a[i],1l);
      }
       int q=sc.nextInt();
    Long sum=s;
      for(int i=0;i<q;i++)
      {
	long x1=sc.nextLong();
	long x2=sc.nextLong();
                 if(map.containsKey(x1))
                {
	                  sum=sum+((x2-x1)*map.get(x1));
	                  if(map.containsKey(x2))
	                         map.put(x2,map.get(x2)+map.get(x1));
                          else
	                  {
		                  map.put(x2,map.get(x1));
	                  }
                          map.remove(x1);
	           }
                   a1.add(sum);
    }     
   for(int t=0;t<a1.size();t++)
	     System.out.println(a1.get(t));
  }
}

Measured memory_bytes: 71588
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d",&a);
  b=a/3600;
  a=a-b*3600;
  c=a/60;
  a=a-c*60;
  printf("%d:%d:%d\n",b,c,a);
  return(0);
}

Measured memory_bytes: 2764
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0;i < n;i++)
using namespace std;
typedef long long ll;
 
int main() {
  vector<int> a(3);
  rep(i,3) cin >> a.at(i);
  sort(a.begin(), a.end());
  cout << a.at(0) + a.at(1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define mp make_pair
#define v vector
#define inp_push(no, v) \
    ll no;              \
    cin >> no;          \
    v.push_back(no);
#define pb push_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define UN(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define N 2000006
#define mod 1000000007
#define INF INT64_MAX

//////////////////////////IMPORTANT FUNCTIONS/////////////////////////////////////////////

/* Guidlines berfore submitting solution
1. Check N value before submitting
2. Check all constant kind of values you are using. Might give WA. Think
3. Check mod value
*/

v<ll> fact(N);
v<ll> prime_check(1e7 + 2);
v<ll> primes;

long long powmod(long long x, long long y, long long m)
{
    long long res = 1LL;
    while (y)
    {
        if (y & 1)
            res = (res * x) % m;
        x = (x * x) % m;
        y /= 2;
    }
    return res;
}

void init_fact()
{
    fact[0] = 1;
    for (ll i = 1; i < N; i++)
    {
        fact[i] = (fact[i - 1] * i) % mod;
    }
}

ll C(ll n, ll r)
{
    if (n < r)
        return 0;
    ll temp = fact[n] * powmod(fact[r], mod - 2, mod) % mod;
    temp *= powmod(fact[n - r], mod - 2, mod);
    temp %= mod;
    return temp;
}

void Sieve()
{
    for (ll i = 2; i <= 1e7 + 1; i++)
    {
        if (prime_check[i])
            continue;
        primes.pb(i);
        for (ll j = 2 * i; j <= 1e7 + 1; j += i)
            prime_check[j] = i;
    }
}
ll phi(ll n)
{
    ll i, res = n;
    for (i = 2; i * i <= n; i++)
        if (n % i == 0)
        {
            while (n % i == 0)
                n /= i;
            res -= res / i;
        }
    if (n > 1)
        res -= res / n;
    return res;
}

/////////////////////////////////////START CODE HERE/////////////////////////////////////////////

ll k, n;
string s;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    init_fact();
    // Sieve();
    cin >> k >> s;
    n = s.size();
    ll ans = 0;
    for (ll i = 0; i <= k; i++)
    {
        ll temp = (C(n + k - i - 1, n - 1) * ((powmod(26, i, mod) * powmod(25, k - i, mod)) % mod));
        // cout << C(n + k - i - 1, n - 1) << " " << n + k - i - 1 << " " << n - 1;
        ans = (ans + temp) % mod;
    }
    cout << ans << "\n";
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int n;
void dfs(string s, char mx) {
    if (int(s.length()) == n) {
        cout << s.c_str() << endl;
        return;
    }
    for (char c='a'; c<=mx; c++) {
        dfs(s + c, (c==mx)?(mx+1):mx);
    }
}

int main(){
    cin >> n;
    dfs("", 'a');
    return 0;
}



Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int n; cin >> n;
    vector<T> pi(n);
    rep(i,n){
        int x,y,h; cin >> x >> y >> h;
        pi[i]=T(x,y,h);
    }

    int nowx,nowy,height;

    queue<T> q;

    rep(i,n){
        tie(nowx,nowy,height)=pi[i];
        if(height==0) continue;
        break;
    }

    rep(i,101){
        rep(j,101){
            int nowh=abs(nowx-i)+abs(nowy-j)+height;
            q.push(T(i,j,nowh));
        }
    }
    int l=q.size();
        while(l--){
            int a,b,c;
            tie(a,b,c)=q.front();
            q.pop();
            rep(i,n){
                tie(nowx,nowy,height)=pi[i];
                if(height==0){
                    if(abs(nowx-a)+abs(nowy-b)<c) break;
                }
                else{
                int nowh=abs(nowx-a)+abs(nowy-b)+height;
                if(nowh!=c) break;
                }
                if(i==n-1){
                    cout << a << ' ' << b << ' ' << c << endl;
                    return 0;
                }
            }
        }

return 0;
}


Measured memory_bytes: 3716
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int n;
	public static void main(String[] args) {
		read();
	}
	static boolean read(){
		if(!sc.hasNext())return false;
		n = sc.nextInt();
		for(int i = 0; i < n; i++){
			String[] line = new String[2];
			line = sc.next().split(":");
			solve(line);
		}
		return true;
	}
	static void solve(String[] param){
		int hour = Integer.parseInt(param[0]);
		int time = Integer.parseInt(param[1]);
		double longHand = 6*time;
		double shortHand = 30*hour + 0.5*time;
		double diff = Math.abs(longHand - shortHand);
		if(diff > 180.0)diff = 360.0 - diff;
		if(diff >= 0.0 && diff < 30.0){
			System.out.println("alert");
		}else if(diff >= 90.0 && diff <= 180.0){
			System.out.println("safe");
		}else if(diff >= 30 && diff < 90){
			System.out.println("warning");
		}
	}
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll, int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 100005;

void solve(){
	int a, b, ans = 1;
	cin >> a >> b;
	int y = (b-2*a)/2;
	if(y < 0 or ((b-2*a)%2) != 0)ans = 0;
	int x = a-y;
	if(x < 0 or x+y > a)ans = 0;
	cout << (ans?"Yes":"No") << '\n';
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 3632
fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val al = readLine()!!.split(" ").map(String::toInt).toMutableList()
    var ans = 0
    for (i in 0 until n - 1) {
        if (al[i] == al[i + 1]) {
            al[i + 1] = 0
            ans++
        }
    }
    println(ans)
}


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

using namespace std;



int main()
{
    long long n , st , dr , mij , ans = 0 , aux , c;
    cin >> n;
    st = 1;
    dr = (1LL << 60);
    while(st <= dr)
    {
        long long nrop = 0;
        mij = (st + dr) / 2;
        nrop = 0;
        aux = mij;
        while(aux > 2)
        {
            aux = (aux - 1) / 2;
            ++nrop;
        }
        if(nrop == n)
        {
            ans = mij;
            st = mij + 1;
        }
        else if(nrop > n)
            dr = mij - 1;
        else st = mij + 1;
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 384
def makePrimeChecker(n):
    isPrime = [True] * (n + 1)
    isPrime[0] = False
    isPrime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if isPrime[i]:
            for j in range(i * i, n + 1, i):
                isPrime[j] = False
    return isPrime

X = int(input())
isp = makePrimeChecker(2 * X)
ans = 0
for i in range(X, 2 * X):
	if(isp[i]):
		ans = i
		break

print(ans)

Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
int main()
{
    int h,w;
    cin>>h>>w;
    vector<string> s(h);
    int ans=0;
    for (int i=0; i<h;i++){
        cin>>s[i];
    }
    for(int i=0;i<h;i++){
        for (int j=0;j<w;j++){
            if (s[i][j]=='#') continue;
            queue<pair<int,int>> que;
            vector<vector<int>> dist(h,vector<int>(w,-1));
            int cnt_max=-1;
            que.push(make_pair(i,j));
            dist[i][j]=0;

            while(!que.empty()){
                pair<int,int> temp=que.front();
                int x=temp.first;
                int y=temp.second;
                que.pop();

                for (int dic=0;dic<4;dic++){
                    int nx=x+dx[dic];
                    int ny=y+dy[dic];
                    if (nx<0 || nx>=h || ny<0 || ny>=w) continue;
                    if (s[nx][ny]=='#') continue;

                    if (dist[nx][ny]==-1){
                        que.push(make_pair(nx,ny));
                        dist[nx][ny]=dist[x][y]+1;
                        cnt_max=max(dist[nx][ny],cnt_max);
                    }
                }
            }
            ans=max(ans,cnt_max);
        }
    }
    cout<<ans<<endl;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")
int table[365][26];
int main()
{
		int D;
	cin >> D;
	vec(C);
	vec(Las);
	fx(26) {
		vecp(C);
		Las.push_back(0);
	}

	fx(D) {
		fy(26) {
			cin >> table[x][y];
		}
	}
	ll ans = 0;
	fx(D) {
		ll sum = 0;
		ll res = -INT_MAX, index = 0;
		fy(26) {
			sum += table[x][y];
			fz(26) {
				if (y == z) { continue; }
				sum -= C[z] *(x + 1 - Las[z]);
			}
			if (sum>res) {
				res = sum;
				index = y;
			}
		}
		Las[index] = x + 1;
		ce(index+1)
	}
	
    return 0;
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1<<25
int main(){
  int n;
  cin>>n;
  char c[n+2];
  int l[n+2];
  for(int i=1;i<=n;i++) cin>>c[i]>>l[i];
  c[0]='n';l[0]=INF;
  c[n+1]='n';l[n+1]=INF;
  vector<int> no;
  for(int i=0;i<n+2;i++) if(c[i]=='n') no.push_back(i);
  int ans=0;
  bool used[n+2];
  memset(used,0,sizeof(used));
  for(int i=1;i<(int)no.size();i++){
    for(int j=0;j+i<(int)no.size();j++){
      //cout<<no[j]<<" "<<no[j+i]<<endl;
      bool ff=0;
      for(int k=no[j]+1;k<no[j+i];k++){
	if(c[k]=='y'&&!used[k]&&l[k]<=l[no[j]]&&l[k]<=l[no[j+i]]){
	  ff=1;
	  break;
	}
      }
      if(ff){
	//cout<<no[j]<<" "<<no[j+i]<<endl;
	ans++;
	for(int k=no[j]+1;k<no[j+i];k++) used[k]=1;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

int main()
{
	int n;
	
	cin >> n;
	map<string, int> m;
	while (n-- > 0){
		string s;
		int num;
		
		cin >> s >> num;
		m[s] += num;
	}
	for (int i = 1; i <= 5; i++){
		for (map<string, int>::iterator mi = m.begin(); mi != m.end(); mi++){
			if (mi->first.size() != i) continue;
			cout << mi->first << ' ' << mi->second << '\n';
		}
	}
	
	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define ggr getchar(); getchar();return 0;
#define ll long long
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}
struct edge { int to, cost; };

int n, u[114514], v[114514], w[114514];
vector<edge> g[114514];
int ans[114514];
bool x[114514];

void dfs(int a, int b) {
	if (x[a])return;
	x[a] = true;
	if (b % 2)ans[a] = 1;
	else ans[a] = 0;
	rep(i, g[a].size()) {
		dfs(g[a][i].to, b + g[a][i].cost);
	}
	return;
}

signed main() {
	cin >> n;
	rep(i, n - 1) {
		cin >> u[i] >> v[i] >> w[i];
		g[u[i] - 1].push_back({ v[i] - 1,w[i] });
		g[v[i] - 1].push_back({ u[i] - 1,w[i] });
	}
	dfs(0, 0);
	rep(i, n) {
		cout << ans[i] << endl;
	}
}

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

signed main(){
  int A,B,C;
  cin>>A>>B>>C;
  string ans="No";
  if(A+B==C)ans="Yes";
  if(A+C==B)ans="Yes";
  if(C+B==A)ans="Yes";
  cout<<ans<<endl;
  return 0;
}

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

namespace ProconTemplate
{
    class Doing
    {
        public class Record
        {
            public int RawValue { get; set; }

            public int Fraction
            {
                get
                {
                    return RawValue % 10;
                }
            }

            public int MaxTime
            {
                get
                {
                    if (Fraction == 0)
                    {
                        return RawValue;
                    }
                    else
                    {
                        return RawValue + (10 - Fraction);
                    }
                }
            }
        }


        public static void Main(string[] args)
        {
            var inList = new List<Record>();
            for (int iLoop = 0; iLoop < 5; iLoop++)
            {
                inList.Add(new Record() { RawValue = int.Parse(Console.ReadLine()) });
            }

            var max = inList.Sum(x => x.MaxTime);
            var lastList = inList.Where(x => x.Fraction != 0);
            if (!lastList.Any())
            {
                Console.WriteLine(max);
            }
            else
            {
                var last = lastList.OrderBy(x => x.Fraction).First();
                Console.WriteLine(max - last.MaxTime + last.RawValue);
            }
        }
    }
}


Measured memory_bytes: 11476
import java.util.*;
import java.io.*;

public class Main {
	private static void solve() throws Exception {
		Scanner sc = new Scanner(System.in);
		// Scanner sc = new Scanner(new FileReader("a.in"));
		PrintWriter pw = new PrintWriter(System.out, true);
		long factor = facto(sc.nextInt());

		pw.println(factor);
	}

	private static long facto(long x) {
		if(x == 0 || x == 1) return 1;
		else return x*facto(x-1);
	}

	public static void main(String[] args) throws Exception {
		new Main().solve();
	}

	static void debug (Object...a) {
		System.out.println(Arrays.deepToString(a));
	}
}

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

int main(){
	int N;
	cin >> N;
	vector<int> a(N);
	for(auto &i:a)cin >> i;
	
	int c=0;
	for(auto i:a){
		if(i==c+1)c++;
	}
	
	cout << ((c>0)?(N-c):(-1)) << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main()
{
	long n,cnt=0;
	cin >> n;
	long a[n+1];
	for(int i=0;i<n;i++){
		cin >> a[i];
		while(a[i]%2==0){
			a[i] /= 2;
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.Stack

fun main(args: Array<String>) = println(run {
    val s = readLine()!!

    val l = Stack<Char>()
    s.forEach {
        when(it) {
            'B' -> if(l.isNotEmpty()) l.pop()
            else -> l.push(it)
        }
    }
    l.joinToString("")

})

Measured memory_bytes: 33732
a, b = map(int, input().split())
if a <= 0 <= b:
    print('Zero')
elif 0 <= a:
    if a == 0:
        print('Zero')
    else:
        print('Positive')
elif b <= 0:
    if b == 0:
        print('Zero')
    elif (b-a) % 2 == 1:
        print('Positive')
    else:
        print('Negative')


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


int main() {
	
	int N;
	cin >> N;
	vector<int> a(N);
	for(auto &i:a)cin >> i;
	int64_t sum1=0, sum2=0;
	int64_t cnt1=0, cnt2=0;
	int sign1=1,sign2=-1;
		
	for(int i=0; i<N; i++){
		sum1 += a.at(i);
		if(sign1 * sum1 <= 0){
			cnt1 += abs(sum1) + 1;
			sum1 = sign1;
		}
		sign1 *= -1;
	}
	
	for(int i=0; i<N; i++){
		sum2 += a.at(i);
		if(sign2 * sum2 <= 0){
			cnt2 += abs(sum2) + 1;
			sum2 = sign2;
		}
		sign2 *= -1;
	}
	cout << min(cnt1, cnt2) << endl;
	
	return 0;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    A,B=(list(map(int,input())) for _ in range(2))
    n=len(A)

    # B が全て0のときだけ例外処理
    if(all(b==0 for b in B)):
        if(all(a==0 for a in A)):
            print(0)
        else:
            print(-1)
        return

    def calc():
        L=[INF]*n # L[i]: i 以下で B の bit が立っているもののうち、i-L[i] が最大となるもの
        R=[INF]*n # R[i]: i 以上で B の bit が立っているもののうち、i+R[i] が最小となるもの

        tmp=0
        for i,b in enumerate(2*B):
            if(b==1):
                tmp=i
            if(i>=n):
                L[i-n]=i-tmp

        tmp=0
        for i,b in enumerate(2*B[::-1]):
            if(b==1):
                tmp=i
            if(i>=n):
                R[i-n]=i-tmp
        R.reverse()

        res=INF
        for d in range(n): # トータルの右シフトが d 回
            LR=[]
            cnt=0 # flip する回数
            for i in range(n):
                if(A[i]==B[(i+d)%n]): continue
                cnt+=1
                if(R[i]<=d): continue
                LR.append((L[i],R[i]-d))

            if(not LR): # 左右に余分に移動する必要が無い場合
                res=min(res,cnt+d)
                continue

            LR.sort()
            k=len(LR)
            X,Y=[[None]*k for _ in range(2)]
            for i in range(k):
                X[i],Y[i]=LR[i]
            for i in range(k-1,0,-1):
                Y[i-1]=max(Y[i-1],Y[i])

            score=min(X[-1],Y[0]) # maxX, maxY
            for i in range(k-1):
                score=min(score,X[i]+Y[i+1])
            res=min(res,cnt+d+score*2)
        return res

    ans=INF
    ans=min(ans,calc())
    A.reverse()
    B.reverse()
    ans=min(ans,calc())
    print(ans)
resolve()

Measured memory_bytes: 57948
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc074_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Console.WriteLine(n * n - int.Parse(Console.ReadLine()));
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
vector<ll> sv,tv,fv,s2,t2,f2;
vector<ll> income,upwage;
const ll mod=1e9+7;
ll gcd(ll a,ll b){
  if(b==0) return a;
  return gcd(b,a%b);
}
int main(){
  ll n,m,d;
  cin>>n>>m>>d;
  income.resize(n+5,0);
  upwage.resize(n+5,0);
  for(int i=0;i<n;i++){
    ll s;
    cin>>s;
    sv.push_back(s);
    s2.push_back(s);
  }
  for(int i=0;i<n;i++){
    ll t;
    cin>>t;
    tv.push_back(t);
    t2.push_back(t);
  }
  for(int i=0;i<m;i++){
    ll f;
    cin>>f;
    fv.push_back(f);
    f2.push_back(f);
  }
  ll rte=n*m/gcd(n,m);
//  cout<<"R"<<rte<<endl;
  ll f1=0;
  for(ll i=0;i<rte;i++){
    for(int j=0;j<n;j++){
      int worker=(j+i)%n;
      f1+=(tv[j]*sv[worker])%mod;
      f1%=mod;
    }
    sv[i%n]+=fv[i%m];
  //  cout<<i%n<<" "<<i%m<<endl;
    sv[i%n]%=mod;
  }
  ll upd=0;
  for(int i=0;i<n;i++) {
    upwage[i]=sv[i]-s2[i];
    upd+=upwage[i];
    upd%=mod;
  }
  ll u2=0;
  for(int i=0;i<n;i++) {
    u2+=tv[i];
    u2%=mod;
  }
  u2*=m/gcd(n,m);
  u2%=mod;
  upd*=u2;
  upd%=mod;

  ll rp=d/rte,rp2=d%rte;
  rp%=mod;
  ll ans=rp*f1;
  ans%=mod;
  if(rp>0){
    ans+=upd*(((rp-1)*rp/2)%mod);
    ans%=mod;
  }

  //cout<<rp<<" "<<rp2<<" "<<ans<<endl;

  for(int i=0;i<n;i++) {
    s2[i]+=(upwage[i]*rp)%mod;
    s2[i]%=mod;
  }
  for(ll i=0;i<rp2;i++){
    for(int j=0;j<n;j++){
      int worker=(j+i)%n;
      ans+=(tv[j]*s2[worker])%mod;
      ans%=mod;
    }
    s2[i%n]+=fv[i%m];
    //cout<<i%n<<" "<<i%m<<endl;
    s2[i%n]%=mod;
  }

  cout<<ans<<endl;
}



Measured memory_bytes: 3152
#!/usr/bin/env python3
#ABC75 C

import copy
n,m = map(int,input().split())

graph = [[] for _ in range(n)]
edge = []
for i in range(m):
    a,b = map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
    edge.append([a,b])
def dfs(g,s):
    c[s] = True
    for i in g[s]:
        if not c[i]:
            c[i] = True
            dfs(g,i)

check = [False]*n
ans = 0
for a,b in edge:
    c = check.copy()
    g = copy.deepcopy(graph)
    g[a-1].remove(b-1)
    g[b-1].remove(a-1)
    dfs(g,0)
    if False in c:
        ans += 1
print(ans)


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
vector<string> ar;
void permute(string a, int l, int r)
{
    if (l == r)
        ar.push_back(a);
    else
    {
        for (int i = l; i <= r; i++)
        {
            swap(a[l], a[i]);
            permute(a, l+1, r);
            swap(a[l], a[i]);
        }
    }
}
int main()
{
     ll n;
     cin>>n;
        string s;
        for(int x=0;x<n;x++)
            s+=char(x+'1');
       permute(s,0,n-1);
       sort(ar.begin(),ar.end());
       ll a;
       string sa;
       for(int x=0;x<n;x++)
       {
           cin>>a;
           sa+=char(a+'0');
       }
       ll b;
       string sb;
       for(int x=0;x<n;x++)
       {
           cin>>b;
           sb+=char(b+'0');
       }
       ll da,db;
       for(int x=0;x<ar.size();x++)
       {
           if(ar[x]==sa)
            da=x;
           if(ar[x]==sb)
            db=x;
       }
       cout<<abs(da-db);
}


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

#define int long long

int32_t main(){
	int n ;
	cin >> n ;
	if(n&1) {
		cout << 0 ;
		return 0 ;
	} 
	int ans = 0 ;
	n/= 2 ; // to make even n is only even cuz
	while(n){
		ans += (n/5) ;
		n /= 5 ;
	}
	cout << ans ;
	return 0 ;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc161/abc161_a.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int X, Y, Z;
  cin >> X >> Y >> Z;

  printf("%d %d %d", Z, X, Y);
}

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

int main() {
	int k, x;
	cin >> k >> x;
	if (k * 500 >= x) puts("Yes");
	else puts("No");
	return 0;
}


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

using namespace std;

typedef long long ll;

const ll N = (ll) 2e5 + 7;

ll n;
map <ll, ll> normal;
ll cur_normal = 0;

struct Question {
        ll type;
        ll a, b;
        ll i;
};

Question q[N];



ll t_sum[N]; /// <--- Fenwick Tree for sum
ll value[N];

ll prefix_sum(ll p) {
        ll r = 0LL;
        for (ll i = p; i >= 1; i -= i & (-i)) {
                r += t_sum[i];
        }
        return r;
}

void add_sum(ll p, ll x) {
        for (ll i = p; i < N; i += i & (-i)) {
                t_sum[i] += x;
        }
}

ll t_cnt[N]; /// <--- Fenwick Tree for cnt

ll prefix_cnt(ll p) {
        ll r = 0;
        for (ll i = p; i >= 1; i -= i & (-i)) {
                r += t_cnt[i];
        }
        return r;
}

void add_cnt(ll p, ll x) {
        for (ll i = p; i < N; i += i & (-i)) {
                t_cnt[i] += x;
        }
}

ll find_k(ll k) {
        ll r = 0, pas = (1 << 17);
        while (pas > 0) {
                if (r + pas < N && prefix_cnt(r + pas) < k) {
                        r += pas;
                }
                pas >>= 1;
        }
        r++;
        return r;
}

/// Operators for Question :

bool cmp1(Question x, Question y) {
        return x.a < y.a;
}

bool cmp2(Question x, Question y) {
        return x.i < y.i;
}

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

        cin >> n;
        for (ll i = 1; i <= n; i++) {
                cin >> q[i].type;
                if (q[i].type == 1) {
                        cin >> q[i].a >> q[i].b;
                }
                q[i].i = i;
        }

        sort(q + 1, q + n + 1, cmp1);

        for (ll i = 1; i <= n; i++) {
                if (q[i].type == 1) {
                        if (normal[q[i].a] == 0) {
                                cur_normal++;
                                normal[q[i].a] = cur_normal;
                                value[cur_normal] = q[i].a;
                        }
                }
        }

        sort(q + 1, q + n + 1, cmp2);

        ll bSum = 0LL, aSum = 0LL;
        ll cate = 0;

        for (ll i = 1; i <= n; i++) {
                if (q[i].type == 1) {
                        bSum += q[i].b;
                        aSum += q[i].a;
                        ll x = normal[q[i].a];
                        add_cnt(x, 1);
                        add_sum(x, value[x]);
                        cate++;
                } else {
                        ll poz = find_k((cate + 1) / 2);
                        ll FirstHalf = (cate + 1) / 2, SecondHalf = cate - FirstHalf;
                        ll SumFirstHalf = prefix_sum(poz - 1) + (FirstHalf - prefix_cnt(poz - 1)) * value[poz], SumSecondHalf = aSum - SumFirstHalf;
                        ll total = bSum + (FirstHalf * value[poz] - SumFirstHalf) + (SumSecondHalf - value[poz] * SecondHalf);

                        cout << value[poz] << " " << total << "\n";
                }
        }

}


Measured memory_bytes: 19072
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    static long GCD(long a, long b)
    {
        return (a < b)? GCD(b, a):
               (a % b == 0)? b:
               GCD(b, a % b);
    }
    public static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split();
        long A = long.Parse(s[0]);
        long B = long.Parse(s[1]);
        Console.WriteLine(GCD(A, B));
    }
}


Measured memory_bytes: 17912
#include <cstdio>
#include <algorithm>

using namespace std;
const int Max_N(100050);

namespace io
{
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush (){fwrite (obuf, 1, oS - obuf, stdout);oS = obuf;}
	inline void putc (char x){*oS ++ = x;if (oS == oT) flush ();}
	template <class I>
	inline void gi (I &x) {for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;}
	template <class I>
	inline void print (I x){
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;while(x) qu[++ qr] = x % 10 + '0',  x /= 10;while (qr) putc (qu[qr--]);}
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io::gi;
using io::putc;
using io::print;

int N, M, A[Max_N << 1];

bool check(int x)
{
	for (int i = 2 * x + 1, j = 2 * N;i < j;++i, --j)
		if (A[i] + A[j] < M)
			return false;
	return true;
}

int main()
{
	gi(N), gi(M);
	for (int i = 1;i <= (N << 1);++i)
		gi(A[i]);
	sort(A + 1, A + 1 + (N << 1));
	int l = 0, r = N + 1, mid;
	while (l < r)
	{
		mid = l + ((r - l) >> 1);
		if (check(mid))
			r = mid;
		else
			l = mid + 1;
	}
	int Ans = 0;
	for (int i = 1, j = 2 * l;i < j;++i, --j)
		Ans = max(Ans, (A[i] + A[j]) % M);
	for (int i = 2 * l + 1, j = 2 * N;i < j;++i, --j)
		Ans = max(Ans, (A[i] + A[j]) % M);
	print(Ans);
	return 0;
}

Measured memory_bytes: 3712
/**
 *  author:   TakeruOkuyama
 *  created:  2020-04-15 11:17:28
**/
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> x(N);
    rep(i, N){
        cin >> x[i];
    }
    int ans = 0;
    rep(i, N){
        ans += min(x[i], K - x[i])*2;
    }
    cout << ans << endl;
return 0;}

/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    string s;
    cin >> s;

    rep(i, 0, s.size()){
        if(i % 2 == 0){
            if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D'){
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D'){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
inputs = STDIN.readlines.map{|line|line.strip.split()}
line = inputs.shift

n = line[0].to_i
points = []
n.times do |l_n|
    input = inputs.shift
    points.push({
        :x => input[0].to_i,
        :y => input[1].to_i,
        :h => input[2].to_i,
    })
end
points.sort! do |a, b|
    b[:h] <=> a[:h]
end
101.times do |y|
    101.times do |x|
        h = (x - points[0][:x]).abs + (y - points[0][:y]).abs + points[0][:h]
        _h = h
        points.each do |point|
            diff = (x - point[:x]).abs + (y - point[:y]).abs
            if point[:h] == 0 then
                if h - diff > 0 then
                    _h = -1
                    break
                end
            elsif point[:h] + diff != h then
                _h = -1
                break
            end
        end
        if h == _h then
            puts([x, y, h].join(' '))
        end
    end
end


Measured memory_bytes: 1788
#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--)

db dp[310][310][310]={};
bool f[310][310][310]={};
int n,a,c[3]={};

db p(int i,int j,int k){
  if(i<0||j<0||k<0) return 0;
  if(!f[i][j][k]){
    f[i][j][k]=1;
    dp[i][j][k]=(i*p(i-1,j,k)+j*p(i+1,j-1,k)+k*p(i,j+1,k-1)+n)/(i+j+k);
  }
  return dp[i][j][k];
}

int main(){
  cin>>n;fr(i,n){cin>>a;c[--a]++;}
  f[0][0][0]=1;
  printf("%.12f\n",p(c[0],c[1],c[2]));
}

Measured memory_bytes: 256256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

int tmp[100001];
signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int n;
    cin >> n;
    double border = 1000000000000000000;
    int ans = 1;
    rep(i, n)
    {
        cin >> tmp[i];
        if (tmp[i] == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    rep(i, n)
    {
        int t = tmp[i];
        if (border < t)
        {
            cout << -1 << endl;
            return 0;
        }
        ans *= t;
        border /= t;
    }
    if (ans > 1000000000000000000)
        cout << -1 << endl;
    else
        cout << ans << endl;

    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i=0; i<4; i++) {
        char c = s.at(i);

        if (c=='+') {
            ans++;
        }
        else {
            ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
struct Data
{
    int data[4];
    int num;
 
    Data () {}
    Data (int a, int b, int c, int d, int n)
    {
        data[0] = a, data[1] = b, data[2] = c, data[3] = d, num = n;
    }
 
    bool operator < (const Data d) const
    {
        for(int i = 0; i < 4; i++) {
            if(data[i] < d.data[i]) return (true);
            else if(data[i] > d.data[i]) return (false);
        }
        return (false);
    }
};
 
int N, K;
int F[50005][4];
int D, R;
bool flag[50005] = {};
int quant[50005] = {};
vector < int > G[50005];
vector < int > order;
int it = 0;
int idx = 1;
vector < int > pat[24];
priority_queue < Data > pq[24];
map < vector < int > , int > mp;
 
void process(int m);
 
int main()
{
 
 
    cin >> N >> K;
 
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < K; j++) {
            cin >> F[i][j];
        }
    }
 
    cin >> D;
    for(int i = 0; i < D; i++) {
        int A, B;
        cin >> A >> B; --A, --B;
        G[A].push_back(B);
        quant[B]++;
    }
 
    for(int i = 0; i < K; i++) {
        int val;
        cin >> val; order.push_back(val - 1);
    }
    while(order.size() < 4) order.push_back(0);
    mp[order] = 0; pat[0] = order;
    for(int i = 0; i < N; i++) {
        if(quant[i] == 0) {
            pq[0].push(Data(F[i][order[0]], F[i][order[1]], F[i][order[2]], F[i][order[3]], i));
        }
    }
    cin >> R;
    for(int i = 0; i < R; i++) {
        int m;
        cin >> m;
        process(m);
        for(int j = 0; j < K; j++) {
            cin >> order[j]; --order[j];
        }
        if(mp.count(order) == 0) {
            mp[order] = idx;
            pat[idx] = order;
            for(int j = 0; j < N; j++) {
                if(quant[j] == 0) {
                    pq[idx].push(Data(F[j][order[0]], F[j][order[1]], F[j][order[2]], F[j][order[3]], j));
                }
            }
            idx++;
        }
    }
    process(N);
 
    return (0);
}
 
void process(int m)
{
    int dat = mp[order];
    while(it < m) {
        while(!pq[dat].empty()) {
            Data d = pq[dat].top(); pq[dat].pop();
            if(flag[d.num]) continue;
            cout << d.num + 1 << endl;
            flag[d.num] = true;
            for(int i = 0; i < G[d.num].size(); i++) {
                int u = G[d.num][i];
                quant[u]--;
                if(quant[u] == 0) {
                    for(int j = 0; j < idx; j++) {
                        pq[j].push(Data(F[u][pat[j][0]], F[u][pat[j][1]], F[u][pat[j][2]], F[u][pat[j][3]], u));
                    }
                }
            }
            break;
        }
        it++;
    }
}

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

int main(){
    int n;
    std::cin >> n;
    std::vector<int> v(n);
    for(int i = 0; i < n; i++){
        std::cin >> v[i];
    }
    
    std::vector<int> evenCount(100000);
    std::vector<int> oddCount(100000);
    for(int i = 0; i < n; i++){
        if(i%2 == 0){
            evenCount[v[i]]++;
        }else{
            oddCount[v[i]]++;
        }
    }
    
    auto count = [&](std::vector<int> vec, int avoid){
        int maxIdx = 0;
        int maxValue = 0;
        for(int i = 0; i < vec.size(); i++){
            if(i == avoid){
                continue;
            }
            if(vec[i] > maxValue){
                maxValue = vec[i];
                maxIdx = i;
            }
        }
        std::pair<int, int> ans = std::make_pair(maxIdx, maxValue);
        return ans;
    };
    
    std::pair<int, int> even = count(evenCount, -1);
    std::pair<int, int> odd = count(oddCount, -1);
    
    if(even.first == odd.first){
        std::pair<int, int> even2 = count(evenCount, even.first);
        std::pair<int, int> odd2 = count(oddCount, even.first);
        if(even2.second >= odd2.second){
            even = even2;
        }else{
            odd = odd2;
        }
    }
    int ans = n - even.second - odd.second;
    
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <string>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=5+3*1e+4;
const ut INF=1<<30;
const ld eps=1e-6;
const LL p=7+1e+9;

int main(){
  int a, b;
  REP(i, 7){
    cin >> a >> b;
    cout << abs(a - b) << endl;
  }
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ll L, R;
	cin >> L >> R;

	const ll MOD = 2019;

	int cnt = 0;
	vector <ll> vec;
	for (ll ii = L; ii <= R; ++ii){
		ll tmp = ii % MOD;
		vec.push_back(tmp);
		cnt++;
		if (cnt == MOD){
			break;
		}
	}

	int minVal = 1001001001;
	for (int ii = 0; ii < vec.size() -1; ++ii){
		for (int jj = ii + 1; jj < vec.size(); ++jj){
			int tmp = (vec[ii] * vec[jj]) % MOD;
			minVal = min(minVal, tmp);
		}
	}
	
	cout << minVal << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
 
using namespace std;
int n, m;
int ans;
 
int main()
{
    scanf("%d%d",&n,&m);
    int c = m/n;
    int b = sqrt(m);
    c = min(c, b);
    for (int i = 1; i * i <= m; ++i)
    {
        if (m % i == 0) 
        {
            int i1 = i;
            int i2 = m / i;
            if (i1 <= m / n) ans = max(ans, i1); 
            if (i2 <= m / n) ans = max(ans, i2);
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i=0,a,b,temp;

	for(;;)
	{scanf("%d%d",&a,&b);
		if(a==0&&b==0)
		{break;}
	if(a>b)
	{
		temp=a;
		a=b;
		b=temp;
	}printf("%d %d\n",a,b);
}
return 0;
}



Measured memory_bytes: 1952
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

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

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll n, k; cin >> n >> k;
  vector<P> v(n);
  rep(i, n) {
    ll a, b; cin >> a >> b;
    v[i] = make_pair(a, b);
  }
  sort(v);
  ll ord = 0;
  for (ll i = 0; i < n; i++) {
    ord += v[i].second;
    if (ord >= k) {
      outl(v[i].first);
      return;
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

int main() {
  int N,M;
  string S;
  cin>>N>>M>>S;
  vector<int> p(N+1,-1);
  p.at(0)=0;
  for(int i=0;i<N;i++){
    if(p.at(i)==-1){
      continue;
    }
    else{
      for(int j=min(M,N-i);j>0;j--){
        if(p.at(j+i)==-1&&S.at(j+i)=='0'){
          p.at(j+i)=i;
        }
        else if(S.at(j+i)=='0'){
          break;
        }
      }
    }
  }
  if(p.at(N)==-1){
    cout<<"-1"<<endl;
  }
  else{
    
    vector<int> z;
    int A=N;
    while(A!=0){
      z.push_back(A-p.at(A));
      A=p.at(A);
    }
    reverse(z.begin(), z.end());
    int q=z.size();
    for(int i=0;i<q;i++){
      cout<<z.at(i);
      if(i!=q-1){
        cout<<" ";
      }
      else{
        cout<<endl;
      }
    }
  }
}

Measured memory_bytes: 1528