akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.lang.*;

class Mod{
    static final long MOD = 1_000_003;
    static final long[] fact = makeFactorialArray(1100000);
    static final long[] factInv = makeInversedArray(fact);

    public static long add(long a, long b){
        long tmp = (a+b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long adds(long... ar){
        long ans=0;
        for(long x:ar) ans = Mod.add(ans, x);
        return ans;
    }
    public static long sub(long a, long b){
        return add(a,-b);
    }
    public static long mult(long a, long b){
        long tmp = (a*b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long mults(long... ar){
        long ans=1;
        for(long x:ar) ans = Mod.mult(ans, x);
        return ans;
    }
    public static long power(long a, long x){ //calculate a^x
        if(x<0)return 0;
        if(x==0)return 1;
        if(x%2==0) {
            long half = power(a,x/2);
            return mult(half,half);
        }
        return (a*power(a,x-1)) % MOD;
    }
    public static long inverse(long a){
        return power(a,MOD-2);
    }
    public static long div(long a, long b){
        return mult(a, inverse(b));
    }
    private static long[] makeFactorialArray(int size){
        long[] array = new long[size];
        array[0]=1;
        for(int i=1;i<size;i++){
            array[i]=mult(array[i-1],i);
        }
        return array;
    }
    private static long[] makeInversedArray(long[] original){
        long[] array = new long[original.length];
        for(int i=0;i<original.length;i++){
            array[i] = inverse(original[i]);
        }
        return array;
    }
    public static long combination(int n, int r){
        if(n<0 || r<0 || n<r) return 0;
        return mult(fact[n], mult(factInv[r],factInv[n-r]));
    }
    public static long fact(long n){
        if(n>=MOD) return 0;
        return fact[(int)n];
    }
    public static long gcd(long a, long b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        if(a%b==0) return b;
        return gcd(b,a%b);
    }
    public static long lcm(long a, long b){
        return (a/gcd(a,b))*b;
    }

}

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int Q = sc.nextInt();
        for(int q=0; q<Q; q++){
            long x = sc.nextLong();
            long d = sc.nextLong();
            long n = sc.nextLong();

            if(d==0){
                System.out.println(Mod.power(x,n));
            }else if(Mod.div(1000003-x, d)<n){//check whether the array have 0
                System.out.println(0);
            }else{
                //  Mults(x, x+d, x+2d,..., x+(n-1)d)
                //= Mults(x/d, x/d+1, ..., x/d+n-1) * d^n
                //= fact(x/d+n-1) / fact(x/d-1) * d^n
                long ans = Mod.mults(Mod.fact(Mod.add(Mod.div(x,d), n-1)),
                                     Mod.inverse(Mod.fact(Mod.sub(Mod.div(x,d),1))),
                                     Mod.power(d,n));

                System.out.println(ans);
            }
        }
    }
}

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

long inv(int a, int m) {
    long i = 1, j = 0;
    for(int b = m; a > 1; swap(i, j), swap(a, b)) {
        j = (j + b / a * (m - i)) % m;
        b %= a;
    }
    return i;
}
long f[222222] = {1}, g[222222] = {1};
int main() {
    int n, m, k, p = 998244353;
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i++)
        f[i] = f[i - 1] * i % p;
    auto c = [&](int n, int r) {
        return f[n] * inv(f[r] * f[n - r] % p, p) % p;
    };
    for(int i = 0; i < n; i++)
        g[i + 1] = g[i] * (m - 1) % p;
    long r = 0;
    for(int i = 0; i <= k; i++)
        (r += c(n - 1, i) * g[n - 1 - i]) %= p;
    cout << r * m % p << endl;
    return 0;
}


Measured memory_bytes: 6732
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
static const long long MOD_NUM = 1000000007LL;

static void A_task();

int main()
{
	A_task();
	fflush(stdout);
	return 0;
}

static void A_task()
{
	char S[4] = { 0 };
	char T[4] = { 0 };

	getstring(S);
	getstring(T);

	int ans = 0;
	for (int i = 0; i < 3; i++) {
		if (S[i] == T[i]) ans++;
	}
	printf("%d\n", ans);
}



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

using namespace std;

#define ll long long

const int INF = 1e9+5;

int main(){
    //freopen("tree.in","r",stdin);
    //freopen("tree.out","w",stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    //cin.tie(0);

    
    int n, w;
    cin >> n >> w;
    vector<ll> weight(n), value(n);

    for(int i = 0; i < n; ++i){
        cin >> weight[i] >> value[i];
    }
    int sum_value = 0;
    for(int i = 0; i < n; ++i){
        sum_value += value[i];
    }

    vector<ll> dp(sum_value+1, INF);
    dp[0] = 0;
    // dp[i] - the minimum total weight of items with total value exactly i
    for(int i = 0; i < n; ++i){
        for(int value_cal = sum_value-value[i]; value_cal >= 0; --value_cal){
            dp[value_cal+value[i]] = min(dp[value_cal+value[i]], dp[value_cal]+weight[i]);
        }
    }

    ll ans = 0;
    for(int i = 0; i <= sum_value; ++i){
        if(dp[i] <= w)
            ans = max(ans, (ll)i);
    }
    cout << ans << endl;
}

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

int main() {
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	a *= 100;
	b *= 100;
	double con = 0;
	int water = a, sugar = 0;
	double max = 1e2*e / (100 + e);
	for (int i = 0;i*a <= f;i++)
	{
		for (int j = 0;i*a + j * b <= f;j++)
		{
			if (i == 0 && j == 0)continue;
			for (int k = 0;i*a + j * b + k * c <= f;k++)
			{
				for (int l = 0;i*a + j * b + k * c + l * d <= f;l++)
				{
					double now = 1e2*(k*c + l * d) / (i*a + j * b + k * c + l * d);
					if (con < now&&now <= max)
					{
						con = now;
						water = i * a + j * b + k * c + l * d;
						sugar = k * c + l * d;
					}
				}
			}
		}
	}
	printf("%d %d\n", water, sugar);
}

Measured memory_bytes: 256
<?php
$n = intval(fgets(STDIN));
$str = trim(fgets(STDIN));
$Q = intval(fgets(STDIN));

$seg = new SegTree($n);
function op($a, $b){return $a | $b;}

for($i = 0; $i < $n; $i++){
  $seg->set($i, 1<<(ord($str[$i])-97));
}
while($Q--){
  list($q, $a, $b) = explode(" ", trim(fgets(STDIN)));
  if($q == "1"){
    $seg->set($a-1, 1<<(ord($b)-97));
  }else{
    $ret[] = popcount($seg->get($a-1, $b));
  }
}
echo implode("\n", $ret);


class SegTree{
  public $tree;
  public $bits;
  function __construct($n){
    $this->bits = max(1, ceil(log($n)/log(2)));
    for($i = 0; $i < $this->bits; ++$i){
      $this->tree[$i] = array_fill(0, 2**($this->bits-$i), 0);
    }
  }
  function set($i, $amount){
    $this->tree[0][$i] = $amount;
    for($j = 1, $J = $this->bits; $j < $J; ++$j){
      $this->tree[$j][$i>>$j] = op($this->tree[$j-1][$i>>$j<<1], $this->tree[$j-1][($i>>$j<<1) + 1]);
    }
  }
  function get($f, $t){
    $sum = 0;
    $tree = $this->tree;
    $bits = $this->bits;
    $i = 0;
    while($f!=$t){
      $treei = $tree[$i];
      if(($f >> $i) & 1 == 1){
        $sum = op($sum, $treei[$f>>$i]);
        $f+=1<<$i;
      }
      if(($t >> $i) & 1 == 1){
        $sum = op($sum, $treei[($t>>$i)-1]);
        $t-=1<<$i;
      }
      ++$i;
    }
    return $sum;
  }
}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array: ";
            echo implode(" ", addIndex($val))."\n";
        }else{
            echo "array:array\n";
            if(isCleanArray($val)){
                foreach($val as $row)echo implode(" ", addIndex($row))."\n";
            }else{
                foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row))."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}
function addIndex($val){
    if(!isCleanArray($val)){
        $val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);
    }
    return $val;
}
function isCleanArray($array){
    $clean = true;
    $i = 0;
    foreach($array as $k => $v){
        if($k != $i++)$clean = false;
    }
    return $clean;
}
//ビットカウント-1の数を数える
function popcount($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}


Measured memory_bytes: 39544
#include<stdio.h>

/* ?§??????????struct?????£?¨? */
typedef struct{
	int d0;
	int d1;
	int d2;
	int d3;
	int d4;
	int d5;
}DICE;

/* DiseRoll??¢??°?????£?¨? */
int DiceRoll(DICE[], int);
/* Dise??¢??°?????£?¨? */
void Dice(char p, DICE[], int);
/* Count??¢??°?????£?¨? */
int Count(DICE[], int);

int main(void){

	DICE d[100];
	int i = 0, flg = 0, n;
	char str[2][4] = { "Yes" ,"No" };

	scanf("%d", &n);
		for(i = 0; i < n; i++)
			scanf("%d%d%d%d%d%d", &d[i].d0, &d[i].d1, &d[i].d2, &d[i].d3, &d[i].d4, &d[i].d5);
		for(i = 1; flg == 0&&i < n; i++) flg = DiceRoll(d, i);
			if(flg) { printf("No\n"); return 0;
		}
	printf("Yes\n");

	return 0;
}





/* DiseRoll??¢??°?????????????????????????????? */
int DiceRoll(DICE d[], int i)
{
	int j, l, iSum, jSum;

		for(j = 0; j < i; j++){
			iSum = d[i].d0 + d[i].d1 + d[i].d2 + d[i].d3 + d[i].d4 + d[i].d5;
			jSum = d[j].d0 + d[j].d1 + d[j].d2 + d[j].d3 + d[j].d4 + d[j].d5;
				if (jSum == iSum) {
				if (d[j].d5 == d[i].d0) Dice('N', d, j), Dice('N', d, j);
					else if(d[j].d1 == d[i].d0) Dice('N', d, j);
					else if(d[j].d4 == d[i].d0) Dice('S', d, j);
					else if(d[j].d2 == d[i].d0) Dice('W', d, j);
					else if(d[j].d3 == d[i].d0) Dice('E', d, j);
						if(d[j].d0 == d[i].d0) {
							for(l = 0; l < 4; l++) {
								if (d[j].d1 == d[i].d1)
								if (d[i].d2 == d[j].d2&&d[i].d3 == d[j].d3&&d[i].d4&&d[j].d4&&d[i].d5 == d[j].d5) 
							return 1;
						Dice('L', d, j);
					}
				}
			if(Count(d, i) >= 10 && Count(d, j) >= 10) return 1;
		}
	}
	return 0;
}



/* Dise??¢??°???????????????????????????????????? */
void Dice(char p, DICE d[], int n){
	int tmp;
		if(p == 'S') { tmp = d[n].d0; d[n].d0 = d[n].d4; d[n].d4 = d[n].d5; d[n].d5 = d[n].d1; d[n].d1 = tmp; }
		if(p == 'W') { tmp = d[n].d0; d[n].d0 = d[n].d2; d[n].d2 = d[n].d5; d[n].d5 = d[n].d3; d[n].d3 = tmp; }
		if(p == 'E') { tmp = d[n].d0; d[n].d0 = d[n].d3; d[n].d3 = d[n].d5; d[n].d5 = d[n].d2; d[n].d2 = tmp; }
		if(p == 'N') { tmp = d[n].d0; d[n].d0 = d[n].d1; d[n].d1 = d[n].d5; d[n].d5 = d[n].d4; d[n].d4 = tmp; }
		if(p == 'L') { tmp = d[n].d1; d[n].d1 = d[n].d3; d[n].d3 = d[n].d4; d[n].d4 = d[n].d2; d[n].d2 = tmp; }
}



/* Count??¢??°??????????????°???????????? */
int Count(DICE d[], int n){
	int cnt = 0;
		if(d[n].d0 == d[n].d1)++cnt;
		if(d[n].d0 == d[n].d2)++cnt;
		if(d[n].d0 == d[n].d3)++cnt;
		if(d[n].d0 == d[n].d4)++cnt;
		if(d[n].d0 == d[n].d5)++cnt;
		if(d[n].d1 == d[n].d2)++cnt;
		if(d[n].d1 == d[n].d3)++cnt;
		if(d[n].d1 == d[n].d4)++cnt;
		if(d[n].d1 == d[n].d5)++cnt;
		if(d[n].d2 == d[n].d3)++cnt;
		if(d[n].d2 == d[n].d4)++cnt;
		if(d[n].d2 == d[n].d5)++cnt;
		if(d[n].d3 == d[n].d4)++cnt;
		if(d[n].d3 == d[n].d5)++cnt;
		if(d[n].d4 == d[n].d5)++cnt;

	return cnt;
}

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

class program{
    public static void Main(){
        var ab = Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToList();
        var a = ab[0];
        var b = ab[1];
        
        if(a * b % 2 == 1){
            Console.WriteLine("Odd");
        }else{
            Console.WriteLine("Even");
        }
    }
}

Measured memory_bytes: 11220
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, k = sc.nextInt()
  val as = List.fill(n)(sc.nextInt()-1)

  val count = Array.fill(n)(0)

  for (a <- as) {
    count(a) += 1
  }

  val ans = count.sorted.reverse.drop(k).sum
  println(ans)
}


Measured memory_bytes: 68624
import java.util.*;
import java.security.*;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
    
    
public class Main {
	public static void main(String[] args) throws NoSuchAlgorithmException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		ArrayList<String> listA = new ArrayList<String>();
		ArrayList<Integer> listB = new ArrayList<Integer>();
		sc.next();
		sc.next();
		for(int i = 0; i < n-1; i++) {
			String[] tt = sc.next().split(":");
			int time1 = Integer.parseInt(tt[0]) * 60 + Integer.parseInt(tt[1]);
			String name1 = sc.next();
			tt = sc.next().split(":");
			int time2 = Integer.parseInt(tt[0]) * 60 + Integer.parseInt(tt[1]);
			String name2 = sc.next();
			if(time2 - time1 >= t) {
				listA.add(name1);
				listB.add(time2 - time1);
			}
		}
		sc.next();
		sc.next();
		System.out.println(listA.size());
		for(int i = 0; i < listA.size(); i++) {
			System.out.println(listA.get(i) + " " + listB.get(i));
		}
	}
	
}

Measured memory_bytes: 26340
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> count(1e5+1);
	long long sum = 0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
		count[a[i]]++;
	}
	int q;
	cin >> q;
	vector<vector<long long>> b(1e5+1, vector<long long>(2));
	rep(i, q)
		cin >> b[i][0] >> b[i][1];

	rep(i,q){
		count[b[i][1]] += count[b[i][0]];
		sum = sum - count[b[i][0]] * b[i][0] + count[b[i][0]] * b[i][1];
		//cout << count[b[i][0]] <<"x"<< b[i][0] << " " << count[b[i][0]] << "x" << b[i][1] << endl;
		count[b[i][0]] = 0;
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 9504
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<par<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int a,p;
    cin>>a>>p;
    cout<<(a*3+p)/2<<endl;
}

Measured memory_bytes: 256
using System;

namespace ABC074C
{
    class Program
    {
        static void Main(string[] args)
        {
            var target = Console.ReadLine().Split(' ');
            int A = int.Parse(target[0]);
            int B = int.Parse(target[1]);
            int C = int.Parse(target[2]);
            int D = int.Parse(target[3]);
            int E = int.Parse(target[4]);
            int F = int.Parse(target[5]);

            int weight = A*100;
            int w_sugar = 0;
            double max_ratio = 0.0;
            double e_ratio = (double)E/(100+E)*100.0;
            for(int i=0;i<=F/100+1;i++){
                for(int j=0;j<=F/100+1;j++){
                    int water = 100*(i*A+j*B); 
                    if(water > F) continue;
                    for(int k=0; k <= F/C+1; k++){
                        for(int p=0; p<= F/D+1; p++ ){
                            int sugar = C*k+D*p; 
                            if(water + sugar <= F && water > 0){
                                double ratio = (double)sugar/(water+sugar)*100.0;
                                if( ratio  == e_ratio ){
                                    Console.WriteLine("{0} {1}", sugar+water, sugar);
                                    return;
                                }
                                if( ratio  > max_ratio && ratio < e_ratio ) {
                                  max_ratio = ratio;      
                                  w_sugar = sugar; weight = sugar + water;
                                }
                            }
                        }
                    }                    
                }
            }
            Console.WriteLine("{0} {1}", weight, w_sugar);
        }
    }
}


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

using namespace std;

//20 - 25 (wrong solution)
//30

int main() {
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	int ok = 0;
	for (int back = 0; back < n; ++back) {
		long long left = c*1ll*(n-1-back) - d*1ll*back;
		long long right = d*1ll*(n-1-back) - c*1ll*back;
		if(left <= b-a && b-a <= right) {
			ok = 1;
		}
	}
	if(ok) puts("YES");
	else puts("NO");
}

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

 int main()
{
    long long int N,S;
    cin >> N ;
    S = 0;
    for(int i=1;i<=N;i++){
        if(i%3!=0){
        if(i%5!=0){
            S += i;
        }
    }
        }cout << S << endl;
        }

Measured memory_bytes: 3632
unittest
{
	assert( [ "xyz", "4" ].parse.expand.solve == "aya" );
	assert( [ "a", "25" ].parse.expand.solve == "z" );
	assert( [ "codefestival", "100" ].parse.expand.solve == "aaaafeaaivap" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	input.popFront;
	auto k = input.front.to!( long );
	return tuple( s, k );
}

auto solve( dchar[] s, long k )
{
	foreach( ref c; s )
	{
		auto i = ( 'z' - c + 1 ) % 26;
		if( k < i ) continue;
		c = 'a';
		k -= i;
	}
	auto i = ( 'z' - s[ $ - 1 ] + 1 ) % 26;
	if( k < i ) s[ $ - 1 ] += k;
	else        s[ $ - 1 ]  = 'a' + ( k - i ) % 26;
	return s;
}


Measured memory_bytes: 3096
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BIrohaLovesStringsABCEdition {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n, l;
	    in >> n >> l;
	    vector<string> v(n);
	    for(int i=0; i<n; i++){
	        in >> v[i];
	    }
	    sort(v.begin(), v.end());
	    for(auto const& e : v){
	        out << e;
	    }
	    out << endl;
	}
};


int main() {
	BIrohaLovesStringsABCEdition solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var N = IO.RInt;
            var a = IO.RSInt;

            var cum = new long[N + 1];

            for (int i = 0; i < N; i++)
            {
                cum[i + 1] = cum[i] + a[i];
            }

            long ans = long.MaxValue;
            for (int i = 1; i < N; i++)
            {
                var x = cum[i];
                var y = cum[N] - x;

                ans = Min(ans, Abs(x - y));
            }
            WriteLine(ans);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

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

using namespace std;

int main(void)
{
    string S;
    int n, i, ans=0, count=0;

    cin >> S;

    n = S.size();

    for(i=0; i<n; i++){
        if(S[i]!='A' && S[i]!='C' && S[i]!='G' && S[i]!='T'){
            if(count > ans){
                ans = count;
            }

            count = 0;
        }

        else{
            count++;
        }
    }

    if(count > ans){
        ans = count;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int _x1, _y1, _x2, _y2, _x3, _y3, _x4, _y4;

int main() {
    cin >> _x1 >> _y1 >> _x2 >> _y2;
    int x = _x2 - _x1;
    int y = _y2 - _y1;
    _x3 = _x2 - y ;
    _y3 = _y2 + x;
    _x4 = _x3 - x;
    _y4 = _y3 - y;
    cout << _x3 << ' ' << _y3 << ' ' << _x4 << ' ' << _y4 << endl;
    return 0;
}


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

int n;
vector<P> points;
double res;

double score(P p) {
    double ans = 0;
    rep(i, n) {
        double xdiff = p.first - points[i].first;
        double ydiff = p.second - points[i].second;
        double dist = sqrt(xdiff * xdiff + ydiff * ydiff);
        ans = max(ans, dist);
    }
    return res = ans;
}

double solvey(double x) {
    double l = 0, r = 1000;
    rep(i, 100) {
        double ly = (l * 2 + r) / 3;
        double ry = (l + r * 2) / 3;
        if (score(P(x, ly)) > score(P(x, ry))) {
            l = ly;
        } else {
            r = ry;
        }
    }
    return l;
}

int main() {
    cin >> n;
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        points.emplace_back(x, y);
    }
    double l = 0, r = 1000;
    rep(i, 100) {
        double lx = (l * 2 + r) / 3;
        double rx = (l + r * 2) / 3;
        double ly = solvey(lx);
        double ry = solvey(rx);
        if (score(P(lx, ly)) > score(P(rx, ry))) {
            l = lx;
        } else {
            r = rx;
        }
    }
    printf("%.9f\n", res);
}

Measured memory_bytes: 3660
// header {{{
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <utility>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <list>
#include <stack>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;

#define ALPHABET    26
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)
#define INF         1000000005

typedef long long ll;
typedef unsigned long long ull;
// }}}

int main() {
    string s;cin >> s;
    int p = 0;
    for(auto c : s){
        if(c == 'p') p++;
    }
    cout << s.size()/2 - p << endl;
    return 0;
}


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

int gcd(int a,int b){if(b==0) return a ; return gcd(b,a%b) ;}
string yorn(bool a){if(a) return "YES" ; return "NO" ;}

int main(){
	int a,b,c ;
	cin >> a >> b >> c ;
	cout << yorn(c%gcd(a,b)==0) << endl ;
}


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


Measured memory_bytes: 256
use std::cmp;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, k: usize, mut td: [(usize, usize); n]);
    td.sort_by_key(|x| x.1);
    td.reverse();
    let mut used = vec![false; n + 1];
    let mut dups = vec![];
    let mut ret = 0;
    let mut memo = 0;
    let mut m = 0;
    for &(t, d) in &td[..k] {
        if used[t] {
            dups.push(d);
        } else {
            m += 1;
            used[t] = true;
        }
        ret += d;
    }
    ret += m * m;
    memo = ret;
    for &(t, d) in &td[k..] {
        if used[t] {
            continue;
        }
        if let Some(min) = dups.pop() {
            used[t] = true;
            memo = memo - min + d - m * m + (m + 1) * (m + 1);
            ret = cmp::max(ret, memo);
            m = m + 1;
        }
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 8444
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		VI X(N), Y(N), I(N);
		REP(i, N) cin>>X[i]>>Y[i];
		REP(i, N) I[i]=i;
		double ans = 0;
		ll cnt = 0;
		do {
			double lans = 0;
			REP(j, N-1) {
				ll i0 = I[j];
				ll i1 = I[j+1];
				lans += sqrt((double)(X[i0]-X[i1])*(X[i0]-X[i1])+(Y[i0]-Y[i1])*(Y[i0]-Y[i1]));
			}
			ans += lans;
			cnt++;
		} while(next_permutation(ALL(I)));
		ans /= cnt;
//		DD(cnt);
		cout<<setprecision(20)<<ans<<endl;
	}
	
	return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++)
        cin >> h[i];
    int ret = 1, high = h[0];
    for (int i = 1; i < n; i++)
    {
        if (h[i] >= high)
            ret++;
        high = max(high, h[i]);
    }
    cout << ret << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007 //998244353
typedef vector<ll> vl;
typedef vector<vl> matrix;//A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
typedef vector<bool> vb;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Sortup(V) sort(V.begin(), V.end())
#define Sortdown(V) sort(V.rbegin(), V.rend())
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
void CumuSum(vl &A){rep(i,A.size())if(i)A[i]+=A[i-1];}
ll llpow(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;}return res;}
ll llpowMOD(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;res%=MOD;e%=MOD;}return res;}
bool bit(ll subset, ll Rsift){ return ((subset)>>(Rsift))&1; }

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

    // solution comes here

    ll N;
    cin >> N;
    set<ll> A;
    rep(i, N) {
        ll a;
        cin >> a;
        if(A.count(a)) A.erase(a);
        else A.insert(a);
    }

    cout << A.size() << nl;
}

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

int main() {
	int N;
	cin >> N;
	string S;
	cin>> S;
	int now = 0;
	int ans = now;
	for (int i = 0;i<S.size();++i) {
		if ('I'==S[i]) {
			now++;
		}
		else {
			now--;
		}
		ans = max(ans, now);
	}
	cout << ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

int main() {
	ll N, M;
	cin >> N >> M;
	ll l = 0, r = 1e12;
	while(l <= r) {
		ll m = (l + r) / 2;
		if(M < 2 * m || (M - 2 * m) / 2 + N < m)
			r = m - 1;
		else
			l = m + 1;
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 256
//Leonidas
#pragma GCC optimize("Ofast")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container'.',hpp>
//#include <ext/pb_ds/tree_policy'.',hpp>
//typedef tree < int , null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> TREE;
#define ll long long
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define pld pair<long double,long double >
#define ld long double
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
#define pll pair<ll,ll>
#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define M_PI 3.14159265358979323846
//#define int long long
const int mod=1000000007;
//const int mod=1009;
//const int mod=998244353;
const int inf=1000000009;
const long long INF=1000000000000000009;
const long long big=1000000000000000;
const long double eps=0.000000000000000000001;
using namespace std;
int T[200005],Z[1000005];
int32_t main()
{
    speed
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>T[i];
    sort(T+1,T+n+1);
    int ile=0;
    for(int i=1;i<=n;i++)
    {
        if(T[i]!=T[i+1]&&!Z[T[i]])
            ile++;
        if(T[i]!=T[i-1])
        {
            for(int j=T[i];j<=1000000;j+=T[i])
                Z[j]=1;
        }
    }
    cout<<ile;
    return 0;
}


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

int main() {
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    for (auto& e : s) cin >> e;
    sort(begin(s), end(s));
    cout << accumulate(begin(s), end(s), ""s) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <string>

using namespace std;

const int maxn = 2005;

array<array<int, maxn>, maxn> l, r, u, d;
array<string, maxn> s;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int h, w;
  cin >> h >> w;
  for (int i = 0; i < h; ++i) {
    cin >> s[i];
    for (int j = 0; j < w; ++j) {
      r[i][j] = w;
      d[i][j] = h;
      if (s[i][j] == '.') {
      	l[i][j] = j;
        u[i][j] = i;
        if (j > 0 && s[i][j-1] == '.') l[i][j] = l[i][j-1];
        if (i > 0 && s[i-1][j] == '.') u[i][j] = u[i-1][j];
      }
    }
  }
  int ans = 0;
  for (int i = h - 1; i >= 0; --i)
    for (int j = w - 1; j >= 0; --j) {
      if (s[i][j] == '#') {
        r[i][j] = j;
        d[i][j] = i;
      } else {
        if (j < w - 1) r[i][j] = r[i][j+1];
        if (i < h - 1) d[i][j] = d[i+1][j];
        ans = max(ans, r[i][j] - l[i][j] + d[i][j] - u[i][j] - 1);
      }
    }
  cout << ans << '\n';
}

Measured memory_bytes: 67328
/* **********************************JAI SAI RAM ************************************* */
//HELP IN CODEFORCES ROUND 641
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll P=1000000007;
ll MAX=1e15;
ll MIN=-1*(1e15);
ll a[200001];
void  answer()
{
    ll n,i,j,k,l,m,o,q,r,t;
    ll ans=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    ans+=a[n-1];
    j=n-2;
    for(i=n-3;i>=0;)
    {
      if(i>=0)
      {
      ans+=a[j];
      i--;
      }
      if(i>=0)
      {
      ans+=a[j];
      i--;
      }
      j--;
    }
    cout<<ans<<endl;
}
int main()
{
    ll t;
    t=1;
    while(t--)
    {
        answer();
    }
    return 0;
}


Measured memory_bytes: 5136
#include <cstddef>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
namespace loquat {
using vertex_t = size_t;
}
namespace loquat {
namespace edge_param {
struct to_ {
	vertex_t to;
	explicit to_(vertex_t t = 0)
		: to(t)
	{ }
};
}
namespace detail {
template <typename T, typename... Params>
struct edge_param_wrapper : public T, edge_param_wrapper<Params...> {
};
template <typename T>
struct edge_param_wrapper<T> : public T {
	template <typename U>
	explicit edge_param_wrapper(U&& x)
		: T(std::forward<U>(x))
	{ }
};
}
template <typename... Params>
struct edge : public detail::edge_param_wrapper<edge_param::to_, Params...> {
	template <typename... Args>
	explicit edge(Args&&... args)
		: detail::edge_param_wrapper<edge_param::to_, Params...>(
			std::forward<Args>(args)...)
	{ }
};
}
namespace loquat {
template <typename EdgeType>
class adjacency_list {
public:
	using edge_type = EdgeType;
	using edge_list = std::vector<edge_type>;
private:
	std::vector<std::vector<EdgeType>> m_edges;
public:
	explicit adjacency_list(size_t n)
		: m_edges(n)
	{ }
	const edge_list& operator[](vertex_t u) const {
		return m_edges[u];
	}
	template <typename... Args>
	void add_edge(vertex_t from, Args&&... args){
		m_edges[from].emplace_back(std::forward<Args>(args)...);
	}
};
}
using namespace std;
using edge = loquat::edge<>;
void dfs(
	int u,
	vector<int>& path,
	vector<bool>& used,
	const loquat::adjacency_list<edge>& g)
{
	used[u] = true;
	path.push_back(u);
	for(const auto& e : g[u]){
		if(used[e.to]){ continue; }
		dfs(e.to, path, used, g);
		break;
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	loquat::adjacency_list<edge> g(n);
	int x = -1, y = -1;
	for(int i = 0; i < m; ++i){
		int a, b;
		cin >> a >> b;
		--a; --b;
		g.add_edge(a, b);
		g.add_edge(b, a);
		if(x < 0){
			x = a;
			y = b;
		}
	}
	vector<bool> used(n, false);
	vector<int> forward, backward;
	used[y] = true;
	dfs(x, forward, used, g);
	dfs(y, backward, used, g);
	reverse(backward.begin(), backward.end());
	cout << forward.size() + backward.size() << endl;
	for(const auto v : backward){ cout << v + 1 << " "; }
	for(const auto v : forward){ cout << v + 1 << " "; }
	cout << endl;
	return 0;
}


Measured memory_bytes: 10744
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import static java.lang.Math.max;
import static java.lang.Math.min;



public class Main {
    public static void main(String[] args) {
        FastScanner fsc = new FastScanner();
        int w=fsc.nextInt();
        int h=fsc.nextInt();
        int n=fsc.nextInt();
        int l=0, r=w, b=0, t=h;
        for(int i=0;i<n;i++){
            int x=fsc.nextInt();
            int y=fsc.nextInt();
            int a=fsc.nextInt();
            if(a==1){
                l=max(l, x);
            } else if(a==2){
                r=min(r, x);
            } else if(a==3){
                b=max(b, y);
            } else{
                t=min(t, y);
            }
        }
        System.out.println(l<=r && b<=t?(r-l)*(t-b):0);
    }
}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 22612
#include <iostream>
#include <string>

using namespace std;

long long f[300030][3][3],ans,mod=1000000007;

string s;

int main()
{
  f[0][0][0]=1;
  cin>>s;
  s="0"+s;
  for(int i=0;i<(int)s.size()-1;i++)
  {
    for(int x=0;x<=2;x++)
    {
      for(int y=0;y<=2;y++)
      {
        if(s[i+1]!='0')
        {
          if(y) f[i+1][x][y-1]+=f[i][x][y];
          else f[i+1][min(x+1,2)][y]+=f[i][x][y];
          f[i+1][x][y-1]%=mod;
          f[i+1][min(x+1,2)][y]%=mod;
        }
        if(s[i+1]!='1')
        {
          if(y==2) f[i+1][x][1]+=f[i][x][y];
          else f[i+1][x][y+1]+=f[i][x][y];
          f[i+1][x][1]%=mod;
          f[i+1][x][y+1]%=mod;
        }
      }
    }
  }
  for(int i=0;i<3;i++)
  {
    for(int j=0;j<=i;j++)
    {
      ans+=f[s.size()-1][i][j];
      ans%=mod;
    }
  }
  printf("%lld\n",ans);
}


Measured memory_bytes: 21724
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>

using namespace std;

#define MOD 1000000007
#define INT_MAX

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

	long long res = 1;
	
	for (long long i = 1; i <= n; i++) {
		res = (i * res) % MOD;
	}

	cout << res << endl;

	return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>
#include <unordered_set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))
#define MAX(x,y) ((x)<(y)?(y):(x))

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

#define INF 1000000000

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

ll twoRow(ll a, ll b, ll mod)
{
	ll ret = 1;
	for(ll i = 1 ;i <= a+b;++i)
	{
		ret *= i;
		ret %= mod;
	}
	for(ll i = 1 ;i <= a;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	for(ll i = 1 ;i <= b;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	return ret;
}

struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return (ret);
}
/*
小数の桁数を指定する
	cout << setprecision(8)<< mp[0]-mx << endl;
*/
ll mp[1000100] = {0};
int main()
{
	//ll mod = (10e8)+7;
	ll mod = 1000000007;
	ll i,j,k,a,b;//,ans=0;
	char c;
	ll endi;
	ll N,M,T, X,Y;
	ll tm[100010] = {0};
	ll tm2[100010] = {0};
	cin >> N;
	for(i=0;i<N;++i)
	{
		cin >> tm[i];
		tm2[i] = tm[i];
	}
	for(i=0;i<N;++i)
	{
		for(j=2;j*j<=tm[i];++j)
		{
			if(tm[i]%j == 0)
			{
				k = 0;
				while(tm[i]%j == 0)
				{
					++k;
					tm[i] /= j;
				}
				if(mp[j] < k)
					mp[j] = k;
			}
		}
		if(mp[tm[i]] == 0)
			mp[tm[i]] = 1;
	}
	a = 1;
	for(i=2;i<1000005;++i)
	{
		while(mp[i] > 0)
		{
			a *= i;
			a %= mod;
			--mp[i];
		}
	}
	ll ans = 0;
	for(i=0;i<N;++i)
	{
		ans += a * div2mul(tm2[i], mod);
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}




















Measured memory_bytes: 8192