akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
	"sort"
)

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = sc.NextInt()
	}
	sort.Ints(arr)
	l := 0
	r := n - 1
	for l < r {
		l++
		r--
	}
	/*
		if arr[l] == arr[r] {
			fmt.Printf("0\n") // output for debug
			return
		}
	*/
	fmt.Printf("%v\n", arr[l]-arr[r]) // output for debug

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 6912
// https://atcoder.jp/contests/abc081/tasks/arc086_a

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main()
{
  int N, K, A, m[200000] = {0}, r = 0, i;

  cin >> N >> K;

  REP(i, N)
  {
    cin >> A;
    m[A - 1]++;
  }
  sort(m, m + 200000, greater<int>());

  i = K;
  while (i < 200000 && m[i] != 0)
    r += m[i++];

  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int p(long long n) {
	int pos = sqrt(n);
	for (; pos >= 1; pos--) {
		if (n % pos == 0)return pos;
	}


}
int main()
{
	long long a;
	cin >> a;
	long long g1 = p(a);
	long long g2 = a / g1;
	long long ans = g1 + g2 - 2;
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<typename T> T minimum(T head, T tail) { return std::min(head, tail); }
template<typename Head, typename... Tail> Head minimum(Head head, Tail... tail) {
  return std::min(head, minimum(tail...));
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v){os << " [" << i++ << "]" << x; if (i % 5 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 5 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll R, G;
  std::cin >> R >> G;

  print((G - R) + G);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
	using namespace std;
	#define int long long int
	#define pb push_back
	const int mod=1e9+7;
	#define all(x) x.begin(),x.end()
	#define endl '\n'
	#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
	
	int32_t main(){
		IOS;
		string s,t;
		cin>>s>>t;
		int ans=INT_MAX;
		for(int i=0;i<=s.size()-t.size();i++){
			int cnt=0;
			for(int j=0;j<t.size();j++){
				if(s[i+j]!=t[j])cnt++;
			}
			ans=min(ans,cnt);
		}
		cout<<ans<<endl;
		return 0;
	}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++) cin >> h[i];
	int ans = 0;
	int l = 0;
	for (int i = 1; i < n; i++){
		if (h[i-1] >= h[i]) l++;
		else{
			ans = max(ans, l);
			l = 0;
		}
	}
	ans = max(ans, l);
	cout << ans << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define llinf 1e17
#define nllinf -4e18
 
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll,ll> 
#define vpll vector<pair<ll,ll > >
 
#define repup(a,b,i) for(i=a;i<=b;i++)
#define repdown(a,b,i) for(i=b; i>=a; i--)
#define repupx(a,b,i,x) for(i=a;i<=b;i+=x)
	
#define repit(v,it) for(it=v.begin(); it!=v.end(); it++)
#define itall(v) v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define fr first
#define sc second
 
#define err(n) cout<<n<<" ";
#define t1 cout<<",";
 
ll MOD= 1e9 +7;

int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll i,j,k1;

ll n,k;cin>>n>>k;
ll a[n];
bool p[k+1]={0};// 0-> player 2 wins;
//repup(0,k,i)err(p[i])cout<<'\n';
repup(0,n-1,i)cin>>a[i];
p[0]=0;

repup(0,k,i){
	repup(0,n-1,j){
		if(a[j]>i)continue;
		if(!p[i- a[j]])p[i]=1;
		if(p[i])break;
	}

}
//repup(0,k,i)err(p[i])cout<<'\n';
if(p[k])cout<<"First";
else cout<<"Second";
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		int[] arg =new int[100];
        int i=0,sum=0,num=0;
        boolean[] card=null;
        int[][] result=null;
        boolean first=true;

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
            	if(line.equals("0")){
            		break;
            	}else{
            		sum=0;
            		int mon=1000-Integer.parseInt(line);
            		while(mon!=0){
            			if(mon>=500){
            				mon-=500;
            			}else if(mon>=100){
            				mon-=100;
            			}else if(mon>=50){
            				mon-=50;
            			}else if(mon>=10){
            				mon-=10;
            			}else if(mon>=5){
            				mon-=5;
            			}else if(mon>=1){
            				mon-=1;
            			}
            			sum++;
            		}
            		System.out.println(sum);
            	}
            }
         }
	}
}

Measured memory_bytes: 24292
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

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

	for(int i=0; i<19; i++){
		if(s.at(i) == ',') cout << " ";
		else cout << s.at(i);
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }

const LL MOD = 1000000007;

int main(){
    LL n;
    cin >> n;
    string s;
    cin >> s;
    map<char,LL> cnt;
    for(char c: s){
        cnt[c] += 1;
    }
    LL ans = 1;
    for(auto p: cnt){
        ans = (ans * (p.second+1)) % MOD;
    }
    cout << (ans+MOD-1)%MOD << endl;
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

struct arrow{
    int pair,weight;
};

bool ans = true;

void solve(vector<pii> &Node, vector<vector<arrow>> &tree, int num){
    if(Node[num].second == 0){
        Node[num].first == 0;
        Node[num].second++;
    }

    for( arrow k : tree[num] ){
        if( Node[k.pair].second == 0 ){
            Node[k.pair].first = k.weight + Node[num].first;
            Node[k.pair].second++;
            solve(Node,tree,k.pair);
        } else {
            if( Node[k.pair].first != Node[num].first + k.weight){
                ans = false;
            }
        }
    }
    Node[num].second++;
}

void allsolve(vector<pii> &Node, vector<vector<arrow>> &tree){
    for( int i = 0; i < Node.size(); i++ ){
        if(Node[i].second != 2){
            solve(Node,tree,i);
        }
    }
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int N, M; cin >> N >> M;
    vector<vector<arrow>> tree(N);

    int l, r, d;
    while(cin >> l >> r >> d){
        arrow key,backkey;
        key.pair = r-1; backkey.pair = l-1; key.weight = d; backkey.weight = -d;
        tree[l-1].push_back(key);
        tree[r-1].push_back(backkey);
    }

    vector<pii> Node(N,make_pair(0,0));
    allsolve(Node,tree);

    if(ans) cout << "Yes" << endl;
    else  cout << "No" << endl;
}

Measured memory_bytes: 12416
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {
  long long int x, y; cin >> x >> y;
  cout << (abs(x-y) <= 1 ? "Brown":"Alice") << endl;

  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())

a = [[] for i in range(n)]
for i in range(n):
    a[i] = list(map(int, input().split()))

b = [0] * m
for i in range(m):
    b[i] = int(input())

for ai in a:
    cnt = 0
    for j, bj in enumerate(b):
        cnt += ai[j] * bj
    print(cnt)


Measured memory_bytes: 6020
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
char s[101010];
int d[101010],dn;
int main()
{
	int n,rt,nn;
	scanf("%s",s+1);
	n=strlen(s+1);
	if(s[1]=='0'||s[n]=='1')
	{
		printf("-1");
		return 0;
	}
	for(int i=1;i<n;i++)
		if(s[i]!=s[n-i])
		{
			printf("-1");
			return 0;
		}
	rt=1;
	dn=0;
	for(int i=1;i<=n;i++)
		if(s[i]=='1')
			d[++dn]=i;
	nn=1;
	d[++dn]=n;
	for(int i=dn;i>1;i--)
	{
		for(int j=1;j<=d[i]-d[i-1];j++)
		{
			++nn;
			printf("%d %d\n",rt,nn);
		}
		rt=nn;
	}
	return 0;
}

Measured memory_bytes: 1920
#include<iostream>
#include<vector>
#include<string>
#include<set>

using ll = long long;
const ll MOD = 1000000007;

// ref : https://note.com/kltl/n/nb476be9d4bd6

ll pow(ll n){
    if(n == 0) return 1;
    if(n == 1) return 2;
    if(n % 2 == 0){
        ll tmp = pow(n / 2);
        return (tmp * tmp) % MOD;
    }else{
        ll tmp = pow((n - 1) / 2);
        return (2 * ((tmp * tmp) % MOD)) % MOD;
    }
}

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

    // 正しく並ぶことができるかどうか確かめる
    bool ok = true;
    for(int i = (n + 1) % 2; i < n; i += 2){
        if(i == 0){
            if(num[i] != 1){
                ok = false;
                break;
            }
        }else{
            if(num[i] != 2){
                ok = false;
                break;
            }
        }
    }
    if(!ok){
        std::cout << 0 << std::endl;
        return 0;
    }

    // 答えは2^(N / 2)
    std::cout << pow(n / 2) << std::endl;

    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int a,b,c,d,e;
  int N=5;
  cin >> a >> b >> c >> d >> e;
  vector<int> time={a,b,c,d,e};
  vector<int> index={0,1,2,3,4};
  int besttime = 100000;
  
  do {
    int nowtime = 0;
    for (int i=0; i<N; i++) {
      while(nowtime%10 != 0) nowtime++;
      nowtime += time[index[i]];
    }
    besttime = min(nowtime,besttime);
  }while (next_permutation(index.begin(),index.end()));
  
  cout << besttime << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

bool ok(int i, int x, int y, int z) {
    return x * x + y * y + z * z + x * y + y * z + z * x <= i;
}

int main() {
    int N;
    cin >> N;
    FOR(i, 1, N + 1) {
        int ans = 0;
        FOR(x, 1, 101) {
            if (x * x > i) break;
            FOR(y, 1, 101) {
                if (x * x + y * y > i) break;

                int l = 1, r = 101;
                while (l + 1 < r) {
                    int mid = (l + r) / 2;
                    if (ok(i, x, y, mid)) l = mid;
                    else r = mid;
                }
                if (x * x + y * y + l * l + x * y + y * l + l * x == i) ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main()
{
  int h, w;
  cin >> h >> w;
  int a[h][w];
  rep(i, h) {
    rep(j, w) {
      cin >> a[i][j];
    }
  }
  
  int ans[h*w][4];
  int cnt = 0;
  rep(i, h) {
    rep(j, w) {
      if (a[i][j] != 0) {
        if (i != 0 && a[i-1][j] % 2 == 1) {
          --a[i][j];
          ans[cnt][0] = i+1;
          ans[cnt][1] = j+1;
          ans[cnt][2] = i;
          ans[cnt][3] = j+1;
          ++cnt;
        }
        else if (j != 0 && a[i][j-1] % 2 == 1) {
          --a[i][j]; ++a[i][j-1];
          ans[cnt][0] = i+1;
          ans[cnt][1] = j+1;
          ans[cnt][2] = i+1;
          ans[cnt][3] = j;
          ++cnt;
        } 
        else if (j != w-1 && a[i][j] % 2 == 1) {
          --a[i][j]; ++a[i][j+1];
          ans[cnt][0] = i+1;
          ans[cnt][1] = j+1;
          ans[cnt][2] = i+1;
          ans[cnt][3] = j+2;
          ++cnt;
        }
        else if (i != h-1 && a[i][j] % 2 == 1) {
          --a[i][j]; ++a[i+1][j];
          ans[cnt][0] = i+1;
          ans[cnt][1] = j+1;
          ans[cnt][2] = i+2;
          ans[cnt][3] = j+1;
          ++cnt;
        }
      }
    }
  }
  
  cout << cnt << endl;
  rep(i, cnt) printf("%d %d %d %d\n", ans[i][0], ans[i][1], ans[i][2], ans[i][3]);
  return 0;
}

Measured memory_bytes: 6912
import java.util.Scanner;

/*

*/

public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();

        String[] TEMP = T.split("");
        String[] TEMP_S = S.split("");

        int count = 0;
        for (int i = 0; i < TEMP_S.length - TEMP.length +1; i++) {
    		int temp = 0;
        	for (int j = 0; j < TEMP.length; j++) {
        		if (TEMP_S[i + j].equals(TEMP[j])) {
        			temp++;
        		}
        	}
    		if (temp > count) {
    			count = temp;
    		}
        }

        System.out.println(T.length() -count);
    }
}

Measured memory_bytes: 35720
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int X; cin>>X;
    for(int i=1;;i++){
	X-=i;
	if(X<=0){
	    cout<<i<<endl;
	    return 0;
	}
    }
}


Measured memory_bytes: 256
i=input
n=int(i())
a=eval('[list(map(int,i().split()))for _ in"_"*int(i())],'*n)
print(max(all(y==i>>x-1&1for j,t in enumerate(a)if i>>j&1for x,y in t)*bin(i).count('1')for i in range(2**n)))

Measured memory_bytes: 3060
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


mod=1000000007
def combinations_count_mod(n, r):
    r = min(r, n - r)
    numer = reduce(lambda x,y: x*y%mod, range(n, n - r, -1), 1)
    denom = pow( reduce(lambda x,y: x*y%mod, range(1, r + 1), 1) , mod-2, mod)
    return numer * denom % mod



def main():
    n,d = map(int,input().strip().split())
    cnt=0
    for i in range(n):
        x,y = map(int,input().strip().split())
        if x**2 + y**2 <= d**2:
            cnt+=1
    print(cnt)


if __name__ == '__main__':
    main()

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

using namespace std;

#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>

typedef long long ll;

int main() {
  int N, ans = 0;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    if (i % 2 == 1) {
      int cnt = 0;
      for (int j = 1; j <= N; j++) {
        if (i % j == 0) {
          cnt++;
        }
      }
      if (cnt == 8) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;

int main()
{
    
 string n,m;
 cin>>n>>m;

 if((n[0]==m[2])&&(n[1]==m[1])&&(n[2]==m[0]))
cout<<"YES"<<endl;
 else
 cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
    public static void main (String[] args) throws java.lang.Exception
	{
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		String a=s.next();
		String b=s.next();
		for(int i=0;i<n;i++)
		{System.out.print(a.charAt(i)+""+b.charAt(i));
	}}}

Measured memory_bytes: 22100
// Anve$hi $hukla
#include <bits/stdc++.h>
using namespace std;
struct ${$(){ios_base::sync_with_stdio(false);cin.tie(NULL);}}$;

typedef long long LL;
const long long Maxn = 200005;

long long get(vector <long long> v) {
    if(v[2] % 2 == 0 || v[1] % 2 == 0 || v[0] % 2 == 0)
        return 0;
    else
        return v[0] * v[1];
}

const long long inf = 2e18;

int main() {
    vector <long long> v(3);
    for(long long i = 0; i < 3; i++) {
        cin >> v[i];
    }       
    sort(v.begin(), v.end());
    long long ans = inf;

    do {
        long long t = get(v);
        ans = min(ans, t);
    } while(next_permutation(v.begin(), v.end()));
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define fastio cin.tie(NULL);cout.tie(NULL);ios_base::sync_with_stdio(0);
#define debug(x) cout << x << endl;
#define endl '\n'
#define MAXN 1000005
#define INF 0x3f3f3f3f
#define LOG 20
#define pb push_back

typedef long long ll;
typedef pair <ll, ll> pii;
typedef vector <int> vi;
typedef vector <pii> vii;

bool prime[MAXN];

int crivo(int v){
    memset(prime, true, sizeof(prime));
    for(int i = 2; i < MAXN; i++){
        if(!prime[i]) continue;
        if(i >= v) return i;
        for(int j = 2 * i; j < MAXN; j += i) prime[j] = 0;
    }
    return v;
}

int32_t main(){
    fastio
    int x;
    cin >> x;
    cout << crivo(x) << endl;

    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int K;
	cin >> K;

	int A, B;
	cin >> A >> B;

	for (int i = A; i <= B; i++)
	{
		if (i % K == 0)
		{
			cout << "OK";
			return 0;
		}
	}

	cout << "NG";

	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <climits>

using ll = long long;
using namespace std;

int main(){
  int H, N;

  cin >> H >> N;

  vector<int> A(N), B(N);

  for(int i = 0; i < N; ++i){
    cin >> A[i] >> B[i];
  }

  vector<int> mp(H+1, 100000001);

  mp[0] = 0;

  for(int i = 0; i < N; ++i){
    if(1 <= A[i]) {
      mp[1] = min(mp[1], B[i]);
    }
  }

  for(int i = 2; i <= H; ++i){
    for(int j = 1; j <= i/2; ++j){
      mp[i] = min(mp[i], mp[j] + mp[i-j]);
    }

    for(int j = 0; j < N; ++j){
      if(i <= A[j]) {
        mp[i] = min(mp[i], B[j]);
      }
    }
  }

  cout << mp[H] << endl;

  return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,k = LI()
    a = LI()
    l = [math.log(ai) for ai in a]
    s = sum(l[:k])
    for i in range(k,n):
        p = s
        s += l[i]-l[i-k]
        if p < s:
            print("Yes")
        else:
            print("No")

    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 112460
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

struct edge{int from, to, cost;};

edge es[2010];
int d[1010];
int V, E, r;
const int INF=1e9;

bool shortest_path(int s) {
    for(int i=0;i<V;i++) d[i]=INF;
    d[s]=0;
    for(int i=0;i<V;i++){
        bool update=false;
        for (int j=0;j<E;j++){
            edge e=es[j];
            if(d[e.from]!=INF && d[e.to]>d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;
                update=true;
            }
        }
        if (!update) break;
        if (i==V-1) return false;
    }
       return true;
}

int main(void){
	int i;

	cin >> V >> E >> r;
	for(i=0;i<E;i++) cin >> es[i].from >> es[i].to >> es[i].cost;

	if(shortest_path(r)){
		for(i=0;i<V;i++){
			if(d[i]==INF) cout << "INF" << endl;
			else cout << d[i] << endl;
		}
	}else{
		cout << "NEGATIVE CYCLE" << endl;
	}
	   return 0;
}

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

void trace(int a[], int N) {
  for (int i = 0; i < N; i++) {
    printf("%d", a[i]);
    if (i < N - 1) printf(" ");
  }
  printf("\n");
  return;
}

int bubblesort(int a[], int N) {
  int cnt = 0;
  bool flag = 1; //どこかが逆順であるか否か
  for (int i = 0; flag; i++) {
    flag = 0;
    for (int j = N - 1; j > i; j--) {
      if (a[j] < a[j - 1]) {
        swap(a[j], a[j - 1]);
        flag = 1;
        cnt++;
      }
    }
  }
  return cnt;
}

int main() {
  int N; scanf("%d", &N);
  int a[N];
  for (int i = 0; i < N; i++) {
    scanf("%d", &a[i]);
  }
  int cnt = bubblesort(a, N);
  trace(a, N);
  cout << cnt << endl;
  return 0;
}


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

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

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	ll M, K;
	cin >> M >> K;

	ll len = 1;
	REP(i, M)len *= 2;
	vector<ll> res;

	if (K == 0) {
		REP(i, len)cout << i << " ";
		REP(i, len)cout << len - i - 1 << " ";
		cout << endl;
	}
	else {
		if (K < len) {
			ll tmp = 0;
			REP(i, len) if (i != K)tmp ^= i;
			if (tmp == K) {
				REP(i, len)if (i != K)cout << i << " ";
				cout << K << " ";
				for (int i = len - 1; i >= 0; i--)
					if (i != K)cout << i << " ";
				cout << K << endl;
				return 0;
			}
		}
		cout << -1 << endl;
	}
	return 0;
}


Measured memory_bytes: 1792
/* ANTHOR KUMAR DAS
KUET ECE 2K18*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sc(a) scanf("%d",&a)
#define sc1(n) scanf("%lld",&n)
#define sc2(b,c) scanf("%lld%lld",&b,&c)
#define f(a,b) for(a=0;a<b;a++)
#define pb(a) push_back(a)
#define br break
int main()
{
    int n,k,f,i,j;
    cin>>n;
    char s[n];
    scanf("%s",&s);
    if(n%2!=0)
    {
        cout<<"No"<<endl;
    }
    else{
        k=n/2;
        f=0;
        for(i=0,j=k;i<k;i++)
        {
            if(s[i]!=s[j])
            {
                f=1;
                break;
            }
            j++;
        }
        if(f==1)
        {
            cout<<"No"<<endl;
        }
        else{
            cout<<"Yes"<<endl;
        }

    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct _IO{_IO(){ios::sync_with_stdio(0);cin.tie(0);}}_io;

typedef long long ll;
typedef long double db;
typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vii;
typedef pair<int, int> pi;
typedef map<int, int> mi;
#define fi first
#define se second
#define be begin()
#define ed end()
#define sz size()
#define cl clear()
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define lb(v, x) lower_bound(v.begin(), v.end(), x)
#define lbi(v, x) (lb(v, x) - v.begin())
#define tp(x, y) int x, y; tie(x, y)
#define mp make_pair
#define mt make_tuple
#define fc(x) for(int x = 1, _end = ri(); x <= _end; x++)
void uni(vi &v) { sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); }

db rd() { db x; cin >> x; return x; }
ll ri() { ll x; cin >> x; return x; }
string rs() { string s; cin >> s; return s; }
pi rpi() { pi x; cin >> x.fi >> x.se; return x; }
vi rvi(int n, int f = 0) { vi v(n + f); for (int i = f; i < v.size(); i++) cin >> v[i]; return v; }
vii rvii(int n, int m, int f = 0) { vii v(n + f, vi(n + f)); for (int i = f; i < v.size(); i++) for (int j = f; j < v[0].size(); j++) cin >> v[i][j]; return v; }
void pr() {}; template <class T, class ...U> void pr(T x, U ...y) { cout << x << ' ', pr(y...); }
void prl() { cout << '\n'; }; template <class T, class ...U> void prl(T x, U ...y) { cout << x << ' ', prl(y...); }
void pr(const vi &v, int f = 0) { for (int i = f; i < v.size(); i++) cout << v[i] << ' '; }
void prl(const vi &v, int f = 0) { pr(v, f); cout << '\n'; }
void pr(const pi &x) { cout << x.fi << ' ' << x.se; };
void prl(const pi &x) { pr(x); cout << '\n'; }

const int N = 2e5 + 5, M = 1e9 + 7;

int main() {
  int n = ri(), m = ri();
  auto v = rvi(n);
  ll ans = 0;
  if (v[0] > m) ans = v[0] - m, v[0] = m;
  for (int i = 1; i < v.sz; i++) {
    if (v[i] + v[i-1] >= m) ans += v[i] + v[i-1] - m, v[i] -= v[i] + v[i-1] - m;
  }
  pr(ans);
}


Measured memory_bytes: 3736
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Linq.Enumerable;
using static System.Math;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var D = Range(0, N).Select(i => ReadLine().Split(' ').Select(int.Parse).ToArray()).ToArray();

        static bool Same(int[] d) => d[0] == d[1];

        var ans = "No";
        for (int i = 0; i < N - 2; i++)
        {
            if (Same(D[i]) && Same(D[i + 1]) && Same(D[i + 2]))
            {
                ans = "Yes";
                break;
            }
        }

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 28384
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

#define MAXNUM 12005
bool prime[MAXNUM];

void eratosthenes()
{
	prime[0]=prime[1]=false;

	for(int i=2; i<MAXNUM; i++)
	{
		prime[i]=true;
	}
	
	for(int i=2; i*i<MAXNUM; i++)
	{
		if(prime[i])
		{
			for(int j=i*i; j<MAXNUM; j+=i)
			{
				prime[j]=false;
			}
		}
	}
}

int solve(int N, vector<int>& primes)
{
	int res = 0, sum = 0;
	queue<int> q;
	for(int i=0; i<primes.size(); i++) {
		sum += primes[i];
		q.push(primes[i]);

		while(sum > N) {
			if(q.empty()) break;
			sum -= q.front(); q.pop();
		}

		if(sum == N) res++;
	}

	return res;
}

int main()
{
	eratosthenes();
	vector<int> primes;
	for(int i=2; i<MAXNUM; i++)
		if(prime[i]) primes.push_back(i);

	int N;
	while(cin >> N, N) {
		cout << solve(N, primes) << endl;
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e5+5;
int n, l, a[N], p;
int main()
{
    n = read(), l = read(); 
    for(int i = 1; i <= n; ++i) a[i] = read();
    for(p = 1; p < n&&a[p]+a[p+1] < l; ++p);
    if(p == n) puts("Impossible");
    else
    {
        puts("Possible");
        for(int i = 1; i < p; ++i) printf("%d\n", i);
        for(int i = n-1; i >= p; --i) printf("%d\n", i);
    }
    return 0;
}

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

int main()
{
	int k,x,min,max;

   cin >> k >> x;

   min = x - k + 1;
   max = x + k - 1;

   for(int i=min; i<max; i++){
     cout << i << " ";
   }
     cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
import math
from typing import List, Any


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


def solve() -> Any:
    N = read_int()
    B = read_ints()
    answer = [0]*N
    for j in range(N-1, -1, -1):
        last_valid = -1
        for i in range(len(B)):
            if B[i] == i+1:
                last_valid = i
        if last_valid == -1:
            print(-1)
            return
        answer[j] = B.pop(last_valid)
    for a in answer:
        print(a)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 75244
from collections import deque
H,W,K=map(int,input().split())
A=[list(input())for _ in range(H)]
for i,a in enumerate(A):
	if"S"in a:y,x=(i,a.index("S"))
d=1e9
Q=deque([(0,y,x)])
while Q:
	c,i,j=Q.popleft()
	d=min(d,i,j,H-i-1,W-j-1)
	if c>=K:continue
	for ni,nj in((i+1,j),(i,j+1),(i-1,j),(i,j-1)):
		if 0<=ni<H and 0<=nj<W and A[ni][nj]==".":
			A[ni][nj]="#"
			Q+=[(c+1,ni,nj)]
print(-(-d//K)+1)

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

using namespace std;

int N, M;
string ans;

void resolve()
{
    cin >> N >> M;

    ans = (M == N) ? "Yes" : "No";
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N, A, B;
    cin >> N >> A >> B;

    vector<ll> X(N);
    FOR(i, 0, N){
        cin >> X[i];
    }

    ll cost_sum = 0;
    FOR(i, 0, N-1){
        ll cost = min(B, A * (X[i+1] - X[i]));
        cost_sum += cost;
    }

    p(cost_sum);
    
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<int, null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
int main()
{
    fastIO;
    ll n;
    cin>>n;
    string str,str1;
    cin>>str>>str1;
    string ans;
    for(int i=0;i<n;i++)
    {
        ans+=str[i];
        ans+=str1[i];
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

using Data = pair<pii, int>;

int N, _, W;
int dp[2][2005];
vi a;

int DP(int p, int i)
{
	if (dp[p][i] != -1) return dp[p][i];

	int &res = dp[p][i];

	res = abs(a[i] - a[N]);

	if (p == 0) {
		for (int j = i + 1; j < N; ++j) {
			chmax(res, DP(!p, j));
		}
	} else {
		for (int j = i + 1; j < N; ++j) {
			chmin(res, DP(!p, j));
		}
	}

	return res;
}

signed main()
{
	cin >> N >> _ >> W;
	a.resize(N+1);
	a[0] = W;
	rep1(i, N) cin >> a[i];

	memset(dp, -1, sizeof(dp));
	cout << DP(0, 0) << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main() {
    int n;int k;
    cin >> n >> k;
    double ans = 0;
    for(int i = 1;i<=n;i++){
        lli y = i;
        double p = 1.0;
        while(true){
            if(y < k ){
                p *= 0.5;
                y *=2;
            }else {
                break;
            }
        }
        ans += p;

    }
    ans /= (double)n;
    printf("%.12f\n", ans);
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
 
 
n,q = na()
g = [[] for i in range(n)]
c = [0]*n
 
for i in range(n-1):
    a,b = na()
    g[a-1].append(b-1)
    g[b-1].append(a-1)
for i in range(q):
    p,x = na()
    c[p-1] += x
 
def f(b,a,r):
    r += c[a]
    c[a] = r
    for i in g[a]:
        if i != b:
            f(a,i,r)
 
f(-1,0,0)
print(' '.join([str(s) for s in c]))

Measured memory_bytes: 238672
#include <bits/stdc++.h>
 using namespace std;
#define FIO                     ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod                     1000000007
#define eps                     1e-9
#define setbits                 __builtin_popcount
#define gcd                     __gcd
#define rep(i,a,b)              for(int i=a;i<=b;i++)
#define repr(i,b,a)             for(int i=b;i>=a;i--)
#define forn(i,n)               for(int i=0;i<n;i++)
#define all(a)                  a.begin(), a.end()
#define pb                      push_back
#define endl                    "\n"
#define ff                      first
#define ss                      second
#define asort(c)                sort(all(c)) 
#define lbpos(x,v)              (int)(lower_bound(all(v),x)-v.begin())//=v.size()==>No LB 
#define ubpos(x,v)              (int)(upper_bound(all(v),x)-v.begin())//=v.size()==>No UB
#define PI                      3.14159265358979323846
#define int                     long long
#define show(a)                 cout<<endl;for(auto i: a) cout<<i<<' '; cout<<endl;
typedef  vector<int>                 vi;
typedef  pair<int, int>              ii;
typedef  vector<ii>                 vii;
typedef  long double                 ld;
#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
  const char* comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " = " << arg1;
  ZZ(comma, args...);
}
clock_t time_p=clock();
void timer()
{
    time_p=clock()-time_p;
    cerr<<"Execution Time: "<<(double)(time_p)/CLOCKS_PER_SEC<<"\n";
}


int32_t main()
{
  FIO;
 
  
  int a,b,c,s,t;
  cin>>a>>b>>c;
  int ans=0;
  t=min(b,c);
  ans+=2*t;
  c-=t;
  b-=t;
  s=min(a,c);
  ans+=s;
  c-=s;
  if(c)
    ans+=1;
  if(b)
    ans+=b;
  cout<<ans;
  timer();
  return 0; 
}   

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 998244353;
const double EPS = 1e-10;

const int mod = 998244353;
struct mint {
    long long x;
    mint(long long x = 0) : x((x % mod + mod) % mod) {}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
int main() {
    int N;
    cin >> N;
    vector<int> D(N, 0);
    int maxDist = -1;
    rep(i, N) {
        cin >> D[i];
        maxDist = max(maxDist, D[i]);
    }
    if (not(D[0] == 0)) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> cntOfDist(100000 + 1, 0);
    rep(i, N) { cntOfDist[D[i]]++; }
    if (not(cntOfDist[0] == 1)) {
        cout << 0 << endl;
        return 0;
    }

    mint ans = 1;
    for (int dist = 1; dist <= maxDist; dist++) {
        mint cntPrev = cntOfDist[dist - 1];
        mint cntCur  = cntOfDist[dist];
        ans *= cntPrev.pow(cntCur.x);
    }
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int gcd(int a, int b){
    if(a == 0)return b;
    if(b == 0)return a;
    if(a < b){
        int tmp = a;
        a = b;
        b = tmp;
    }
    int r = a % b;
    if(r == 0)return b;
    return gcd(b, r);
}

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

    int A[N];
    for(int i = 0; i < N; i++)cin >> A[i];

    int max_gcd = 1;
    int L[N+1], R[N+1];
    L[0] = R[N] = 0;
    for(int i = 1; i <= N; i++){
        L[i] = gcd(L[i-1], A[i-1]);

        R[N-i] = gcd(R[N-i+1], A[N-i]);
    }
    int ans = 1;
    for(int i = 0; i < N; i++){
        if(gcd(L[i], R[i+1]) > ans)ans = gcd(L[i], R[i+1]);
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 1408
import java.util.*;
import java.io.PrintWriter;
public class Main{
	static int[] ans;
	static ArrayList<Integer>[] map;
	static int[] dis;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int x=sc.nextInt()-1;
		int y=sc.nextInt()-1;
		map=new ArrayList[n];
		ans=new int[n+1];
		for(int i=0; i<n; i++){
			map[i]=new ArrayList<>();
		}
		for(int i=0; i<n-1; i++){
			map[i].add(i+1);
			map[i+1].add(i);
		}
		map[x].add(y);
		map[y].add(x);
		for(int i=0; i<n; i++){
			PriorityQueue<St> q=new PriorityQueue<>((t,r)->(t.dis-r.dis));
			dis=new int[n];
			Arrays.fill(dis,-1);
			q.add(new St(0,i));
			while(!q.isEmpty()){
				St p=q.poll();
				if(dis[p.now]!=-1){
					continue;
				}
				dis[p.now]=p.dis;
				if(i<p.now){
					ans[dis[p.now]]++;
				}
				for(int j:map[p.now]){
					if(dis[j]==-1){
						q.add(new St(p.dis+1,j));
					}
				}
			}
		}
		for(int i=1; i<=n-1; i++){
			System.out.println(ans[i]);
		}
	}
	static class St{
		int now,dis;
		St(int dis,int now){
			this.dis=dis;
			this.now=now;
		}
	}
}


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

int main() {
  ll n, W;
  cin >> n >> W;
  vector<ll> w(n), v(n);
  for (int i = 0; i < n; i++)
    cin >> w[i] >> v[i];

  vector<vector<ll>> dp(n + 1, vector<ll>(100000));

  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 100000; j++) {
      if (j >= w[i]) {
        dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j]);
      } else {
        dp[i + 1][j] = dp[i][j];
      }
    }
  }
  cout << dp[n][W] << endl;
}

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

using namespace std;

typedef long long ll;
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
const double pi=acos(-1);
const int maxn=1e5;
const int mod=1e9+7;
int a[3]= {0};
int main()
{
    int n;
    cin>>n;
    ll ans=1;
    for(int i=0; i<n; i++)
    {
        int x;
        sint(x);
        int flag=1;
        int sum=0;
        for(int i=0; i<3; i++)
        {
            if(a[i]==x)
            {
                if(flag)
                {
                    flag=0;
                    a[i]++;
                    sum++;
                }
                else
                    sum++;
            }
        }
        ans=ans*sum%mod;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n,c,k;
    cin >> n >> c >> k;
    
    vector<int> t(n);
    for(int i = 0; i < n; i++){
        cin >> t[i];
    }
    
    sort(t.begin(), t.end());
    
    int cnt = 0;
    
    for(int i = 0; i < n; i++){
        int maxt = t[i] + k;
        int j;
        for(j = 0; j < c; j++){
            if(i + j > n - 1) break;
            if(t[i+j] <= maxt);
            else break;
        }
        cnt++;
        if(i + j > n - 1) break;
        i+=j-1;
    }
    
    cout << cnt << endl;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
int main(void)
{
    string str;
    cin>>str;
    for (int i = 0;i + 1 < str.length();++i)
        if (str[i] == 'A' && str[i + 1] == 'C')
            return puts("Yes") * 0;
    puts("No");
    return 0;
}


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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


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

    if( x < 1200 ) cout << "ABC" << endl;
    else cout << "ARC" << endl;
}


Measured memory_bytes: 256