akhauriyash/Code-Regression huggingface dataset:
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let L = cin.getInt();
    let l = L, dl = 0;
    let ce = 0;
    let te = new Array(20).fill(false);
    while (l) {
        if (l & 1) {
            te[dl] = true;
            ce++;
        }
        l >>= 1;
        dl++;
    }
    console.log(`${dl} ${(dl - 1) * 2 + ce - 1}`);
    l = L;
    let t = 1;
    for (let i = 1; i < dl; i++) {
        console.log(`${i} ${i + 1} ${0}`);
        console.log(`${i} ${i + 1} ${t}`);
        if (te[i - 1]) {
            console.log(`${i} ${dl} ${l - t}`);
            l -= t;
        }
        t <<= 1;
    }
}
class Inputer{constructor(t){this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    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 { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int r; cin >> r;
    cout << fixed << setprecision(20) << 2 * r * M_PI << endl;
    return 0;
}


Measured memory_bytes: 3768
#include <iostream>
#include <algorithm>
#define MAX_V 10000
#define MAX_E 100000

using namespace std;

struct edge{
  int from,to,cost;
  edge(int f = -1,int t = -1,int c = -1) : from(f) ,to(t) ,cost(c) {}
};

int V,E;
int par[MAX_V],rank[MAX_V];
edge es[MAX_E];

bool cmp(const edge &e1,const edge &e2){
  return e1.cost < e2.cost;
}

void init(int n){
  for(int i = 0 ; i < n ; i++){
    par[i] = i;
    rank[i] = 0;
  }
}

int find(int x){
  if(par[x] == x){
    return x;
  }
  return par[x] = find(par[x]);
}

void unite(int x,int y){
  x = find(x);
  y = find(y);

  if(x == y) return;
  if(rank[x] < rank[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rank[x] == rank[y]) rank[x]++;
  }
}

bool same(int x,int y){
  return find(x) == find(y);
}

int kruskal(){
  sort(es, es+E, cmp);
  init(V);

  int res = 0;
  for(int i = 0 ; i < E ; i++){
    edge e = es[i];
    if(!same(e.from,e.to)){
      unite(e.from,e.to);
      res += e.cost;
    }
  }

  return res;
}

int main(){
  cin >> V >> E;
  for(int i = 0 ; i < E ; i++){
    cin >> es[i].from >> es[i].to >> es[i].cost;
  }
  cout << kruskal() << endl;

  return 0;
}

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


int main (){
  int a=0;
  string S,T;
  cin>>S>>T;
  rep(i,S.length()){
    if(S[i]!=T[i]) a++;
  }
  if(a==0){
    cout<<"Yes";
    return 0;
  }
  else{
    cout<<"No";
    return 0;
  }
}

Measured memory_bytes: 3624
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  double n,m,d;cin>>n>>m>>d;
  if(d==0)cout<<fixed<<setprecision(10)<<(m-1)/n<<endl;
  else cout<<fixed<<setprecision(10)<<2*(n-d)*(m-1)/(n*n)<<endl;
}

Measured memory_bytes: 256
/**
  * Array - Official House
  */
object Main {
  def main(args: Array[String]): Unit = {
    val n = io.StdIn.readInt()
    val operations = Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).take(n).map(_.split(" ").map(_.toInt))
      .map { case Array(b, f, r, v) => (b, f, r, v) }
      .toSeq
    val initialHouse = OfficialHouse((1 to 4).map(Building(_, (1 to 3).map(Floor(_, (1 to 10).map(Room(_, 0)))))))
    val currentHouse = operations.foldLeft(initialHouse) {
      (house, operation) => {
        operation match {
          case (b, f, r, v) =>
            house.inout(b, f, r, v)
        }
      }
    }
    print(currentHouse)
  }

  case class Room(roomNumber: Int, residents: Int) {
    override def toString: String = s" $residents"

    def inout(inoutResidents: Int): Room = {
      Room(roomNumber, residents + inoutResidents)
    }
  }

  case class Floor(floorNumber: Int, rooms: Seq[Room]) {
    override def toString: String = rooms.foldLeft("")(_ + _)

    def inout(roomNumber: Int, inoutResidents: Int): Floor = {
      Floor(floorNumber, rooms.updated(roomNumber - 1, rooms(roomNumber - 1).inout(inoutResidents)))
    }
  }

  case class Building(buildingNumber: Int, floors: Seq[Floor]) {
    override def toString: String = floors.foldLeft("")(_ + _ + "\n")

    def inout(floorNumber: Int, roomNumber: Int, inoutResidents: Int): Building = {
      Building(buildingNumber, floors.updated(floorNumber - 1, floors(floorNumber - 1).inout(roomNumber, inoutResidents)))
    }
  }

  case class OfficialHouse(buildings: Seq[Building]) {
    override def toString: String = buildings.mkString("#" * 20 + "\n")

    def inout(buildingNumber: Int, floorNumber: Int, roomNumber: Int, inoutResidents: Int): OfficialHouse = {
      OfficialHouse(buildings.updated(buildingNumber - 1, buildings(buildingNumber - 1).inout(floorNumber, roomNumber, inoutResidents)))
    }
  }

}

Measured memory_bytes: 46228
function Main(input) {
  input = input.split('\n');

  var n = parseInt(input[0], 10);
  var a = input[1].split(' ').map(i => parseInt(i, 10));

  var ans = 0;
  for (var i = 0; i < n; i++) {
    while (a[i] % 2 == 0) {
      ans++;
      a[i] /= 2;
    }
  }

  console.log(ans);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x1;
  int x2;
  int x3;
  int x4;
  int x5;
  cin >> x1;
  cin >> x2;
  cin >> x3;
  cin >> x4;
  cin >> x5;
  if (x1==0){
    cout <<1;
  }
  if (x2==0){
    cout <<2;
  }
   if (x3==0){
    cout <<3;
  }
   if (x4==0){
    cout <<4;
  }
   if (x5==0){
    cout <<5;
  }
}

Measured memory_bytes: 3672
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <map>
#include <algorithm>


using namespace std;

struct rest{
    string name;
    int score, num;

};
bool cmp(const rest &a,const rest &b){
    if(a.name == b.name){
        return a.score > b.score;
    }
    return a.name < b.name;
}


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

    vector<rest> rests;
    for(int i = 0; i < n; i++){
        string tmp;
        int p;
        cin >>tmp >>p;
        rest r;
        r.name = tmp;
        r.score = p;
        r.num = i+1;
        rests.push_back(r);
    }

    sort(rests.begin(), rests.end(), cmp);


    for(int i = 0; i < n; i++){
        printf("%d\n", rests[i].num);
    }

    //sort(rest.begin(), rest.end());


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int mod=1e9+7;
const int N=1e5+5;

ll n,k;
ll ans;
ll f[N];
ll po(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%mod;
		b>>=1;
		a=a*a%mod;
	}
	return ans;
}

int main()
{
	// freopen("test.in","r",stdin);
	// scanf("%d",&T);
	// while(T--)
	// {
	scanf("%lld%lld",&n,&k);
	ll ans=0;
	for(ll i=k;i;i--)
	{
		f[i]=po(k/i,n);
		for(ll j=i+i;j<=k;j+=i)
			f[i]-=f[j];
		f[i]%=mod;
		f[i]+=mod;
		f[i]%=mod;
		ans+=f[i]*i%mod;
		ans%=mod;
	}
	printf("%lld\n",ans);
	// }
	return 0;
}


Measured memory_bytes: 4560
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

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

    rep(c, r)
    {
        int n, k;
        cin >> n >> k;
        vector<int> houses(n), distances(n - 1);
        rep(i, n)
        {
            cin >> houses.at(i);
        }
        if (k >= n)
        {
            cout << 0 << endl;
            continue;
        }
        rep(i, n - 1)
        {
            distances.at(i) = houses.at(i + 1) - houses.at(i);
        }
        sort(distances.begin(), distances.end());
        rep(i, k - 1)
        {
            distances.pop_back();
        }
        int ans = 0;
        rep(i, distances.size())
        {
            ans += distances.at(i);
        }
        cout << ans << endl;
    }
}


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

using namespace std;

int main(){
    int n,count = 0;
    cin >> n;
    vector<int>v(n);

    for(int i = 0;i < n;i++)
        cin >> v[i];
    
    for(int i = 0;i < n;i++){
        bool flag = true;
        for(int j = 0;j < i;j++){
            if(v[j] > v[i])flag = false;
        }
        if(flag)count++;
    }
        

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

	public void exec(Scanner sc) {
		String s = "575";
		s = s.replaceFirst(sc.next(), "");
		s = s.replaceFirst(sc.next(), "");
		s = s.replaceFirst(sc.next(), "");
		System.out.println(s.length() == 0 ? "YES" : "NO");
	}
}


Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int h,w;
    cin >> h >> w;
    int n;
    cin >> n;
    int ans;
    if(n/h <= n/w){
        ans = n/h;
        if(n%h != 0) ans++;
    }else{
        ans = n/w;
        if(n%w != 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3556
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
 
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	ll g=gcd(a,b);
	return a/g*b;
}
int main(){
	ll n,k;
	cin>>n>>k;
	ll a[200100]={0};
	rep(i,0,n){
		ll x;
		cin>>x;
		a[x]++;
	}
	vector<ll> v;
	ll kind=0;
	rep(i,0,n+1){
		if(a[i]>0){
			v.push_back(a[i]);
			kind++;
		}
	}
	sort(v.begin(),v.end());
	ll ans=0;
	rep(i,0,kind-k){
		ans+=v[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3956
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func main() {
  sc.Split(bufio.ScanWords)
  for i := 1; ; i++ {
    a := nextInt()
    b := nextInt()
    if a == 0 && b == 0 {
      break
    }
    if a < b {
      fmt.Printf("%d %d\n", a, b)
    } else {
      fmt.Printf("%d %d\n", b, a)
    }

  }
}


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

using namespace std;

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

const int dy[] = {0, -1, 0, 1}, dx[] = {-1, 0, 1, 0};
int n, m;
string in[100];
bool v[50][50];

void rec(int y, int x){
	v[y][x] = 1;
	rep(d, 4){
		int ny = y + dy[d], nx = x + dx[d];
		if(ny < 0 || nx < 0 || ny >= n || nx >= m) continue;
		if(v[ny][nx] || in[ny][nx] == '#') continue;
		rec(ny, nx);
	}
}
bool con_check(){
	memset(v, 0, sizeof(v));
	rec(0, 0);
	return v[0][m - 1] && v[n - 1][0] && v[n - 1][m - 1];
}
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	while(cin >> n >> m, n){
		rep(i, n) cin >> in[i];
		
		bool found = 0;
		if(!con_check()){
			found = 1;
			goto END;
		}
		rep(y, n) rep(x, m) if(in[y][x] == '.'){
			if(y==0 && x==0 || y==0 && x==m-1 || y==n-1 && x==0 || y==n-1 && x==m-1) continue;
			in[y][x] = '#';
			if(!con_check()){ found = 1; goto END; }
			in[y][x] = '.';
		}
		END:
		cout << (found ? "NO" : "YES") << endl;
	}
	return 0;
}

Measured memory_bytes: 3364
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


string solve(){
    string res;
    string S,T; cin >> S >> T;
    sort(S.begin(),S.end());
    sort(T.begin(),T.end());
    
    vector<int> cS(26),cT(26);
    for(auto c:S) cS[c-'a']++;
    for(auto c:T) cT[c-'a']++;
    sort(cS.begin(),cS.end());
    sort(cT.begin(),cT.end());
    for(char c = 0; c < 26; c++){
        if(cS[c] != cT[c]) return "No";
    }
    return "Yes";
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 916
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    vector<string> g;
    for (int i=0; i<h; i++){
        string s;
        cin >>s;
        g.push_back(s);
    }
    
    int a[h];
    int b[w];
    string h_blank="";
    string w_blank="";
    for (int i=0; i<h; i++){
        h_blank+='.';
        a[i]=0;
    }
    for (int i=0; i<w; i++){
        w_blank+='.';
        b[i]=0;
    }
    for (int i=0; i<h; i++){
        if (g[i]==w_blank){
            a[i]=1;
        }
    }
    
    for (int j=0; j<w; j++){
        string t="";
        for (int i=0; i<h; i++){
            t+=g[i][j];
        }
        if (t==h_blank){
            b[j]=1;
        }
    }

    for (int i=0; i<h; i++){
        for (int j=0; j<w; j++){
            if ( a[i]==0 && b[j]==0){
                cout << g[i][j];
            }
        }
        if (g[i]!=w_blank){
            cout <<endl;
        }
    }
}

Measured memory_bytes: 384
A, B, C, D, E, F = map(int, input().split())

max_density = 0
ans_water = 0
ans_sugar = 0
for na in range(F // (A * 100) + 1):
    for nb in range(F // (B * 100) + 1):
        water = (A * na + B * nb) * 100
        if water == 0 or water > F:
            break

        for nc in range(F // C + 1):
            for nd in range(F // D + 1):
                sugar = C * nc + D * nd
                if water + sugar > F:
                    break

                density = sugar / (water + sugar)
                if density > E / (100 + E):
                    break

                if density >= max_density:
                    max_density = density
                    ans_water = water
                    ans_sugar = sugar

print(ans_water + ans_sugar, ans_sugar)


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

nxt = X
lst = []
dic = {}

for i in range(M + 1):
    if nxt in dic:
        loop_st = dic[nxt]
        loop_ed = i - 1
        break

    lst.append(nxt)
    dic[nxt] = i

    nxt = (nxt ** 2) % M


v = N - loop_st
q, r = divmod(v, loop_ed - loop_st + 1)

pre_sum = sum(lst[:loop_st])
loop_sum = q * sum(lst[loop_st:])
post_sum = sum(lst[loop_st:loop_st + r])
print(pre_sum + loop_sum + post_sum)


Measured memory_bytes: 15728
n = int(input())
P = [int(input()) for _ in range(n)]
Q = [0]*(n+1)
for i, j in enumerate(P):
  Q[j-1] = i+1
count = 0
m = 0
for i in range(n):
  count += 1
  if Q[i] > Q[i+1]:
    m = max(m, count)
    count = 0
print(n-m)

Measured memory_bytes: 18892
import java.util.Scanner;

public class Main{

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] data = new int[n];
    int count = 0;

    int max = 0;

    for(int i = 0;i < n;i++){
      data[i] = sc.nextInt();
    }



    for(int i = 0;i < n-1;i++){
      if(data[i] >= data[i+1]){
        count++;
      }else{
        count = 0;
      }

      if(max < count){
        max = count;
      }
    }

    System.out.println(max);

  }

}


Measured memory_bytes: 50956
#!/usr/bin/env python3
import sys
from collections import Counter
INF = float("inf")


def solve(N: int, S: "List[str]"):
    c = Counter()
    for s in S:
        c[s] += 1

    m = -1
    for key in c:
        if c[key] > m:
            m = c[key]
    ans = []
    for key in c:
        if c[key] == m:
            ans.append(key)
    ans.sort()
    for line in ans:
        print(line)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)


if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
    long long N;
    cin >> N;
    vector<long long> A(N);
    for(long long i = 0; i < N; i++){
        long long tmp = 0;
        cin >> tmp;
        tmp = tmp - (i + 1);
        A[i] = tmp;
    }
    sort(A.begin(),A.end());
    for(int i = 0; i < N; i++){
        //cout << A[i] << ", ";
    }
    //cout << endl;
    long long mid = 0;
    long long sumA = 0;
    long long sumB = 0;
    if(N % 2 == 1){
        mid = (N - 1)/2;
        for(int i = 0; i < N; i++){
            sumA += abs(A[i] - A[mid]);
        }
        cout << sumA << endl;
    }else{
        mid = (A[N / 2] + A[N / 2 - 1]) / 2;
        for(int i = 0; i < N; i++){
            sumA += abs(A[i] - mid);
        }
        cout << sumA << endl;
    }

}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
    int n;
    int tmp;
    int hoge=0;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<a.size();i++){
        cin>>a[i];
    }
    for(int j=0;j<n;j++){
        for(int k=j+1;k<n;k++){
            tmp = abs(a[j]-a[k]);
            if(tmp > hoge) hoge = tmp;
        }
    }
    printf("%d\n",hoge);
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  int tmp = 0;
  for(char c: s) {
    tmp += (c=='+' ? 1 : -1);
  }
  cout << tmp << endk;
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	string s, l, m;
	map<string, int> map;
	int mxl = 0;
	int tmp = 0;
	while(cin >> s){
		map[s]++;
		if(map[s] > tmp){
			m = s;
			tmp = map[s];
		}
		int tmp_s = s.size();
		if(s.size() > mxl){
			mxl = max(mxl,tmp_s);
			l = s;
		}
	}
	cout << m << " " << l << endl;
	return 0;
}

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

int main(){
	int K, N;
	cin >> K >> N;
	int A[N];
	int sa[N];
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	for(int i=0;i<N-1;i++){
		sa[i] = A[i+1] - A[i];
	}
	sa[N-1] = A[0] + K - A[N-1];
	int MA = 0;
	for(int i=0;i<N;i++){
		MA = max(MA, sa[i]);
	}
	cout << K - MA << endl;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

signed main(void)
{
  string s, t = "";
  getline(cin, s);

  REP(i, s.size()-4) {
    string tmp = s.substr(i, 5);
    if(tmp == "peach") {
      s[i] = 'a'; s[i+1] = 'p'; s[i+2] = 'p'; s[i+3] = 'l'; s[i+4] = 'e';
    } else if(tmp == "apple") {
      s[i] = 'p'; s[i+1] = 'e'; s[i+2] = 'a'; s[i+3] = 'c'; s[i+4] = 'h';
    }
    //cout << tmp << endl;
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  string s;
  cin >> s;
  vector<int> ans(s.size(),0);
  s.push_back('R');
  int o,e = 0;
  int memo = 0;
  rep(i,s.size()) {
    if(i%2==0) e++;
    else o++;
    if(s[i] == 'R'&& s[i+1] == 'L') memo = i;
    else if(s[i] == 'L' && s[i+1] == 'R') {
      if(memo % 2 == 0) {
        ans[memo] = e;
        ans[memo+1] = o;
      }else {
        ans[memo] = o;
        ans[memo+1] = e;
      }
      o = 0;e = 0;
    }
  }
  rep(i,s.size()-1) {
    if(i != s.size()-2) cout << ans[i] << ' ';
    else cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e17;
// Int MOD = 998244353;

Int dp[3010][3010];

int main() {
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    
    for (Int i = 0; i < (Int)s.size(); i++) {
        for (Int j = 0; j < (Int)t.size(); j++) {
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]);
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1]);
            if (s[i] == t[j]) {
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
            }
        }
    }
    string res = "";
    Int i = (Int)s.size();
    Int j = (Int)t.size();
    while (i > 0 && j > 0) {
        if (dp[i][j] == dp[i - 1][j]) {
            i--;
        }
        else if (dp[i][j] == dp[i][j - 1]) {
            j--;
        }
        else {
            i--;
            j--;
            res = s[i] + res;
        }
    }
    dump(res);
    return 0;  
} 

Measured memory_bytes: 70784
#include <stdio.h>
int main(void){
 
int n, k;
int sum = 0;
scanf("%d %d",&n,&k);
 
for(int i = 1; i <= n; i++){
if(i %2 ==1)
sum += 1;
}
 
if(sum >= k)
printf("YES");
 
else
printf("NO");
 
return 0;
 
}

Measured memory_bytes: 128
s = input()
N = 0
S = 0
W = 0
E = 0
for i in range(len(s)) :
    str = s[i]
    if str == 'N' :
        N = 1
    elif str == 'S':
        S = 1
    elif str == 'W':
        W = 1
    elif str == 'E':
        E = 1
if (N-S)==0 and (W-E)==0 :
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=200005;

int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n,i;
    scanf("%d%d",&n,&i);
    if(n<10)i+=100*(10-n);
	printf("%d",i);
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
c = [int(i) for i in input().split()]
lr = [[int(i) - 1 for i in input().split()] for _ in range(Q)]

class BinaryIndexedTree() :
  def __init__(self, n) :
    self.n = n
    self.tree = [0] * (n + 1)
      
  def sum(self, i) :
    s = 0
    while i > 0 :
      s += self.tree[i]
      i -= i & -i
    return s
      
  def add(self, i, x) :
    while i <= self.n :
      self.tree[i] += x
      i += i & -i

BIT = BinaryIndexedTree(N + 5)
sch = [[i, l, r] for i, (l, r) in enumerate(lr)]
sch.sort(key=lambda x: x[2])
ret = [0] * Q
last = [-1] * (N + 1)

cur = 0
for i, l, r in sch :
  while cur <= r :
    BIT.add(cur + 1, 1)
    pos = last[c[cur]]
    if pos != -1 :
      BIT.add(pos + 1, -1)
    last[c[cur]] = cur
    cur += 1
  ret[i] = BIT.sum(r + 1) - BIT.sum(l)
for r in ret :
  print(r)

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

int main(){
  int n; cin >> n;
  vector<tuple<string, int, int>> data(n);
  for(int i = 0; i < n; i++){
    string s; int a;
    cin >> s >> a;
    data.at(i) = make_tuple(s, -1*a, i + 1);
  }
  sort(data.begin(), data.end());
  for(int i = 0; i < n; i++){
    int ans;
    tie(ignore, ignore, ans) = data.at(i);
    cout << ans << endl;
  }
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = int(1e9) + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 a, b, x;
  cin >> a >> b >> x;
  if (!a && x == 1) cout << b + 1 << "\n";
  else {
    i64 ans = b / x - (a - 1) / x;
    cout << (!a ? ans + 1 : ans) << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9+7
#define LINF (long long)4e18



int main(){
    int N; cin >> N;
    vector<long long> a(N);
    long long ans = 0;
    rep(i,N){
        cin >> a[i];
        ans += a[i] - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
using namespace std;
string S; 
bool check(int i, int j, int k){
    bool ok = true; 
    for(int p = 0; p < k; p++){
        if(S.at(i+p) != S.at(j+p)){
            ok = false; break; 
        }
    }
    return ok; 
}
int main(){
	int N; cin >> N >> S; 
	vector<int> C[26] = {}; 
	for(int i = 0; i < N; i++){
		C[S.at(i) - 'a'].push_back(i); 
	}
	int mx = 0; 
	for(int i = 0; i < 26; i++){
		mx = max(mx, (int) C[i].size()); 
	}
	if(mx == 1){
		cout << 0 << endl; return 0; 
	}
	int ok = 0; int ng = N / 2 + 1; 
	while(ng - ok > 1){
		int mid = (ok + ng) / 2; 
		bool possible = false; 
		map<string, int> M1; 
		map<string, int> M2; 
		for(int i = 0; i <= N - mid; i++){
			M1[S.substr(i, mid)] = i; 
		}
		for(int i = N - mid; i >= 0; i--){
			M2[S.substr(i, mid)] = i; 
		}
		for(int i = N - mid; i >= 0; i--){
			if(abs(M1[S.substr(i, mid)] - M2[S.substr(i, mid)]) >= mid){
				possible = true; break; 
			} 
		}
		if(possible) ok = mid; 
		else ng = mid; 
	}
	cout << ok << endl; 
}

Measured memory_bytes: 13464
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if(a + b >= c){
      System.out.println(b + c);
    }else{
      System.out.println(a + 2 * b + 1);
    }
  }
}

Measured memory_bytes: 22484
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            String s = in.next();

            StringBuilder sb = new StringBuilder();
            sb.append(s);

            while (sb.length() > 0) {
                if (sb.length() >= 5 && sb.substring(sb.length() - 5, sb.length()).equals("dream")) {
                    sb.delete(sb.length() - 5, sb.length());
                    continue;
                }
                if (sb.length() >= 7 && sb.substring(sb.length() - 7, sb.length()).equals("dreamer")) {
                    sb.delete(sb.length() - 7, sb.length());
                    continue;
                }
                if (sb.length() >= 5 && sb.substring(sb.length() - 5, sb.length()).equals("erase")) {
                    sb.delete(sb.length() - 5, sb.length());
                    continue;
                }
                if (sb.length() >= 6 && sb.substring(sb.length() - 6, sb.length()).equals("eraser")) {
                    sb.delete(sb.length() - 6, sb.length());
                    continue;
                }
                out.println("NO");
                return;
            }
            out.println("YES");
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isPrintableChar(int c) {
            return c >= 33 && c <= 126;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();

            int b = readByte();
            while (!isPrintableChar(b))
                b = readByte();

            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }

            return sb.toString();
        }

    }
}



Measured memory_bytes: 27988
// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);
//#define _GLIBCXX_DEBUG//only for debugging
/*BISMILLAH UR RAHMAN*/ 
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<fixed<<setprecision(10);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) int(x.size())
#define INF INT_MAX;
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> ii;
ii arr[int(1e2+10)];
ll cnt[int(1e5+10)][110];ll n;
ll dp(ll weight,ll index)
{
  if(weight<=0||index<=0)return 0;
  if(cnt[weight][index]!=-1) return cnt[weight][index];
  ll ans=0;
  if(arr[index-1].first<=weight)
   {
    ans=max(arr[index-1].second+dp(weight-arr[index-1].first,index-1),dp(weight,index-1));}
  else
    {ans=dp(weight,index-1);}
  return cnt[weight][index]=ans;
}
int main()
{  
  fast
  cin>>n;
  ll w;cin>>w;
  memset(cnt,-1,sizeof(cnt));
  for(ll i=0;i<n;++i)
  cin>>arr[i].first>>arr[i].second;
  cout<<dp(w,n)<<endl;
}


Measured memory_bytes: 86272
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 1e5 + 10;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b,ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a,ll b){ if(a==0){return b;}else{ return gcd(b%a,a);}}

int n;
int val[maxn];
void solve()
{
	sa(n);
	repp(i,1,n)
	{
		sa(val[i]);
	}
	ll res = val[1]-1;
	int maxx=2;
	repp(i,2,n)
	{
		if(val[i]>maxx)
		{
			int k=val[i]/maxx-(val[i]%maxx==0);
			res+=k;
			maxx=max(val[i]%maxx,maxx);
		}
		else if(val[i]==maxx)
		{
			maxx++;
		}
	}
	cout<<res<<endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
int N, M, C = 0;cin >> N >> M;
vector<vector<int>> A(M, vector<int>(N));

for(int i = 0; i < M; i++){

int k;cin >> k;

for(int j = 0; j < N; j++){

if(j < k){
cin >> A.at(i).at(j);}

else A.at(i).at(j) = 0;

}

}

vector<int> P(M);

for(int i = 0; i < M; i++)cin >> P.at(i);



for(int bit = 0; bit < (1 << N); bit++){
bitset<10> S(bit);
bool X = 1;

for(int m = 0; m < M; m++){
int count = 0;

for(int i = 0; i < N; i++){    

if(S.test(i)){
for(int j = 0; j < N; j++){
if(A.at(m).at(j) == (i + 1))count++;}
}

}

if(count%2 != P.at(m)){
  X = 0;break;}

}

if(X)C++;

}

  cout << C;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(void)
{
  int H, W;
  cin >> H >> W;
  while (!(0 == H && 0 == W)) {
    REP(i,H) {
      for (int j = 0; j < W; j++) {
        if (0 == j || j == W -1 || 0 == i || i == H - 1) {
          cout << '#';
        }
        else cout << '.';
      }
      cout << '\n';
    }
    cout << '\n';
    cin >> H >> W;
  }
}



Measured memory_bytes: 3016
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 998244353;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

ll modpow(ll a, ll t) {
    ll ret = 1LL;
    while(t){
        if(t & 1LL){
            ret *= a;
            ret %= MOD;
        }
        a *= a;
        a %= MOD;
        t >>= 1;
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, a;
    cin >> n;
    vector<ll> cnt(n, 0);
    cin >> a;
    if(a != 0) {
        cout << 0 << endl;
        return 0;
    }
    cnt[0] = 1;
    int max_d = 0;
    for(int i=1;i<n;++i){
        cin >> a;
        ++cnt[a];
        max_d = max(max_d, a);
    }

    if(cnt[0] != 1) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1LL;
    for(int i=2;i<=max_d;++i) {
        if(cnt[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
        ans *= modpow(cnt[i-1], cnt[i]);
        ans %= MOD;
    }

    cout << ans << endl;
}


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

int main()
{
	char s[10];
	cin >> s;
	sort(s, s + 4);
	if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3])
		cout << "Yes\n";
	else
		cout << "No\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, i;
	long num = 1;
	
	while (scanf("%d", &n) != EOF){
		for (i = 1; i <= n; i++){
			num *= i;
		}
		printf("%ld\n", num);
	}
	
	return 0;
}

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

using namespace std;

int main(){
	int n, w;
	scanf("%d %d", &n, &w);

	vector<pair<int, int> > data(n+1);
	for(int i=0;i<n;i++)
		scanf("%d %d", &data[i].first, &data[i].second);
	
	vector<vector<long long int> > dp(n, vector<long long int> (w+1, 0));
	for(int i=0; i<=w; i++){
		if(i<data[0].first) dp[0][i] = 0;
		else dp[0][i] = data[0].second;
	}

	for(int i=1; i<n;i++){
		for(int j = 0; j<=w; j++){
			if(j<data[i].first) dp[i][j] = dp[i-1][j];
			else dp[i][j] = max(dp[i-1][j], dp[i-1][j-data[i].first] + data[i].second);
		}
	}
	/*for(int i=0; i<n;i++){
		for(int j = 0; j<=w; j++)
			printf("%lld ", dp[i][j]);
		printf("\n");
	}*/
	printf("%lld\n", dp[n-1][w]);
}

Measured memory_bytes: 79488
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t,l;
    cin>>n;
    vl<pair<ll,ll>> job;
    for(i=0;i<n;i++)
    {
        cin>>a>>b;
        job.pb({b,a});
    }
    sort(job.begin(),job.end());
    //for(i=0;i<n;i++) cout<<job[i].ff<<" "<<job[i].ss<<endl;
    ll tim=0;
    for(i=0;i<n;i++)
    {
        if(tim+job[i].ss<=job[i].ff) 
        {
            tim+=job[i].ss;
            //cout<<tim<<endl;
        }
        else
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

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

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

int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	printf("%d\n",gcd(a,b));
	return 0;
}

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

int main(void) {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d) {
    cout << "Left" << endl;
  }
  else if (a + b == c + d) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
#define ll long long
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int main(){
	fastio();
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++) cout<<"x";	
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<list>
#include<map>
#include<iomanip>
#include<iostream>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
#include<memory.h>
using namespace std;
int main(){
	string n;
	cin>>n;
	if(n[0]==n[2])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

ans = 'APPROVED'
for i in range(N):
    if A[i] % 2 == 1:
        continue
    if A[i] % 3 != 0 and A[i] % 5 != 0:
        ans = 'DENIED'
        break

print(ans)


Measured memory_bytes: 2940
a, b, k = map(int,input().split())

if b-a+1 < k*2:
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,a+k):
        print(i)
    for i in range(b+1-k,b+1):
        print(i)

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

int main(){
    int n;
    cin >> n;
    vector<pair<int, pair<int,int>>> clue;
    for(int i=0;i<n;i++){
        int x, y, h;
        cin >> x >> y >> h;
        clue.push_back({h, {x, y}});
    }
    sort(clue.rbegin(), clue.rend());

    for(int cx=0;cx<=100;cx++){
        for(int cy=0;cy<=100;cy++){
            int h = clue[0].first + abs(clue[0].second.first-cx) + abs(clue[0].second.second-cy);
            for(int i=1;i<n;i++){
                int x, y;
                tie(x, y) = clue[i].second;
                if(clue[i].first != max(0, h-abs(x-cx)-abs(y-cy))){
                    goto ng;
                }
            }
            cout << cx << " " << cy << " " << h << endl;
            return 0;
            ng:;
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 256
import * as fs from 'fs';

//in
// 2 16
//out
// 9
const main = (inp: string) => {
    const [a, b]: number[] = inp.split(' ').map(Number);
    let cap: number = 0;

    if ((a + b) % 2 == 1) {
        console.log('IMPOSSIBLE');
    } else {
        console.log((a + b) / 2);
    }
};

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


Measured memory_bytes: 7372