akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

void reader(int &a) { scanf("%d", &a); }
void reader(double &a) { scanf("%lf", &a); }
void reader(char a[]) { scanf("%s", a); }
void reader(char &a) { scanf(" %c", &a); }
void reader(ll &a) { scanf("%lld", &a); }
void reader(ull &a) { scanf("%llu", &a); }
// void reader(string& a){cin >> a;};
template<class T, class U> void reader(T& t, U& u) { reader(t); reader(u); }
template<class T, class U, class V> void reader(T& t, U& u, V& v) { reader(t); reader(u); reader(v); }

void writer(const int a, char c) { printf("%d", a); putchar(c); }
void writer(const ll a, char c) { printf("%lld", a); putchar(c); }
void writer(const ull a, char c) { printf("%llu", a); putchar(c); }
void writer(const double a, char c) { printf("%.20lf", a); putchar(c); }
void writer(const char a[]) { printf("%s", a); };
void writer(const char a[], char c) { printf("%s", a); putchar(c); };
void writer(const char a, char c) { putchar(a); putchar(c); };
template<class T> void writerLn(T t) { writer(t, '\n'); }
template<class T, class U> void writerLn(T t, U u) { writer(t, ' '); writer(u, '\n'); }
template<class T, class U, class V> void writerLn(T t, U u, V v) { writer(t, ' '); writer(u, ' '); writer(v, '\n'); }
template<class T> void writerArr(T x[], int n) { int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }
template<class T> void writerVec(vector<T> x) { int n = x.size(); int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }

vector<string> split(const string &str, char sep) { vector<string> v; stringstream ss(str); string buffer; while (getline(ss, buffer, sep)) { v.push_back(buffer); }return v; }
// #define int ll
bool test = 1;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define MAX 300000
//.....................
ull mod = (int)1e9 + 7;

ull N;
int H, W;

char field[20][20];
int cnt = 0;
void grid_dfs(int y, int x) {
	int i, j;
	if (y == H - 1 && x == W - 1) cnt++;
	rep(i, 2) {
		int nx = x + dx[i];
		int ny = y + dy[i];
		if (nx < 0 || W <= nx) continue;
		if (ny < 0 || H <= ny) continue;
		if (field[ny][nx] == '#') continue;
		grid_dfs(ny, nx);
	}
}
signed main(void)
{
	while (cin >> W >> H) {
		cnt = 0;
		if (H == 0 && W == 0) break;
		cin >> N;
		rep(i, N) {
			int x, y;
			cin >> x >> y;
			x--; y--;
			field[y][x] = '#';
		}
		grid_dfs(0, 0);
		cout << cnt << endl;
		rep(i, H) rep(j, W) {
			field[i][j] = 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3032
use proconio::input;

fn main() {
    input! {
        n: usize,
        b: [usize; n],
    };
    let mut ans = std::collections::VecDeque::new();
    let mut bd = b.into_iter().collect::<std::collections::VecDeque<_>>();
    for _ in 0..n {
        let mut found = None;
        for (j, &b_i) in bd.iter().enumerate().rev() {
            if j + 1 == b_i {
                found = Some(j);
                ans.push_front(b_i);
                break;
            }
        }
        match found {
            Some(j) => {
                bd.remove(j);
            }
            None => {
                println!("-1");
                return;
            }
        }
    }
    for &a_i in ans.iter() {
        println!("{}", a_i);
    }
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef map<int, int> mii;
typedef map<int, string> mis;
typedef map<string, int> msi;
typedef set<int> si;
typedef set<ll> sl;
typedef map<ll, ll> mll;
typedef queue<int> qi;
typedef queue<ii> qii;
typedef vector<string> vs;
typedef pair<ll, ll> iil;
typedef vector<iil> viil;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int, ii> iii;
typedef vector<pair<pair<int,int>,int>> viii;
typedef vector<pair<pair<ll,ll>,ll>> viiil;

#define pb push_back
#define mp make_pair
#define rep(i, n) for (int i = 0 ; i < n ; i++)
#define INF 1000000000
#define MOD 1000000007;

void solve() {
    ll n, d;
    cin >> n >> d;
    int ct = 0;
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        ll sq = x * x + y * y;
        if (sq <= d * d) {
            ct++;
        }
    }
    cout << ct << endl;
}

void querySolve() {
    int n;
    cin >> n;
    while (n--) {
        solve();
    }
}

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

}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,S=0;
	cin>>N;
	int n=N;
	while(N!=0){
		S=S+N%10;
		N=N/10;
	}
	if(n%S==0) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
s=input()
if s[0]==s[1]:
  if s[1]!=s[2] and s[2]==s[3]:
    print("Yes")
  else:
    print("No")
  exit()
if s[0]==s[2]:
  if s[0]!=s[1] and s[1]==s[3]:
    print("Yes")
  else:
    print("No")
  exit()
if s[0]==s[3]:
  if s[0]!=s[1] and s[1]==s[2]:
    print("Yes")
  else:
    print("No")
  exit()
  
print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int n,k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> cum(n+1,0);
    rep(i,n) cum[i+1]=a[i];
    rep(i,n) cum[i+1]+=cum[i];
    vector<ll> b;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=n;j++){
            b.push_back(cum[j]-cum[i]);
        }
    }
    vector<bool> unuse((int)b.size(),false);

    for(int bit=43;bit>=0;bit--){
        int c = 0;
        rep(i,b.size()){
            if(unuse[i]) continue;
            if(b[i]>>bit&1) ++c;
        }
        if(c>=k){
            rep(i,b.size()){
                if(unuse[i]) continue;
                if(!(b[i]>>bit&1)) unuse[i]=true;
            }
        }
    }

    int c = 0;
    ll ans = 0;
    rep(i,b.size()){
        if(unuse[i]) continue;
        else{
            if(c==0){
                ans = b[i];
                ++c;
            }else{
                ans = ans & b[i];
                ++c;
                if(c==k) break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7444
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
	int n;
	scanf("%d", &n);
	LL ans = 0;
	int rem = 0;
	for(int i=0;i<n;i++){
		int a;
		scanf("%d", &a);
		if(rem == 1 && a != 0) a--, ans++;
		ans += a/2;
		rem = a%2;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


int main(){
	fio; cout<<fixed<<setprecision(25);	
	int k , a , b; cin >> k >> a >> b;
	for(int i =a ; i <= b ; ++i){
		if(i%k == 0){
			cout << "OK" << endl;
			return 0;
		}
	}
	cout<< "NG" << endl;



	return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>


int parent(int p) {
  if( p != 1 ) {
    return (int)p/2;
  }else {
    return -1;
  }
}


int left(int p, int n) {
  if( p*2 <= n ) {
    return p*2;
  }else {
    return -1;
  }
}


int right(int p, int n) {
  if( p*2+1 <= n ) {
    return p*2+1;
  }else {
    return -1;
  }
}


void swap(int* a, int* b) {
  int tmp;

  tmp = *a;
  *a = *b;
  *b = tmp;

}


void maxHeapify(int* h, int p, int n) {

  int l, r;
  int largest;

  l = left(p, n);
  r = right(p, n);

  //左、右、自身のうち最大のノード
  if( l != -1 && h[l] > h[p] ) {
    largest = l;
  }
  else {
    largest = p;
  }
  if( r != -1 && h[r] > h[largest] ) {
    largest = r;
  }


  if( largest != p ) {
    swap(&h[p], &h[largest]);
    maxHeapify(h, largest, n);
  }

}


void buildMaxHeap(int* h, int n) {
  int i;
  
  for( i=(int)n/2; i>=1; i-- ) {
    maxHeapify(h, i, n);
  }

}


void printHeap(int* h, int n) {
  int i;

  for( i=1; i<=n; i++) {
    printf(" %d", h[i]);
  }
  printf("\n");

}


int main() {

  int n; //heapSize
  int* h; //heapPointer

  int i;

  scanf("%d", &n);

  h = (int*)malloc( sizeof(int) * (n + 1) );

  //Heapは1から始まる
  for( i=1; i<=n; i++) {
    scanf("%d", &h[i]);
  }

  buildMaxHeap(h, n);

  printHeap(h, n);

  return 0;

}

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

int main()
{
    char s[4];
    int i,j;
    for(i=0;i<4;i++){
        cin >> s[i];
        for(j=3;i<j;j++){}
    }
    
    char temp;
    int same=0;
    int els=0;

    for(i=0;i<3;i++){
        for(j=3;i<j;j--){
            if(s[i]>s[j]){
                temp=s[i];
                s[i]=s[j];
                s[j]=temp;
            }
        }
    }

    if(s[0]==s[1]){
        same++;
    }
    if(s[2]==s[3]){
        same++;
    }
    if(s[1]!=s[2]){
        els++;
    }

    //cout << same << els <<endl;
    
    if(same==2 && els==1){
        puts("Yes");
    }else{
        puts("No");
    }
}

Measured memory_bytes: 256
/**
 *     author: qodjf
 *     created: 04.24.2020 01:10:04
 */
#include <bits/stdc++.h>
using namespace std;

string to_string(string s) { return '"' + s + '"'; }

string to_string(const char *s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

#define mst(x, a) memset(x, a, sizeof(x))

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
constexpr ll MOD = 1e9 + 7;

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

ll inversePairs(vector<ll> &a, int l, int r) {
  if (l + 1 >= r) return 0;
  int m = (l + r) / 2;

  ll cnt = 0;
  cnt += inversePairs(a, l, m);
  cnt += inversePairs(a, m, r);

  vector<ll> tmp(a.begin() + l, a.begin() + m);
  int lsize = m - l;
  int i = 0, j = m;
  int tail = l;
  while (i < lsize && j < r) {
    if (tmp[i] > a[j]) {
      cnt += lsize - i;
      a[tail++] = a[j++];
    } else {
      a[tail++] = tmp[i++];
    }
  }
  while (i < lsize) {
    a[tail++] = tmp[i++];
  }

  return cnt;
}

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

  ll N, K;
  cin >> N >> K;
  vector<ll> sum(N + 1);
  sum[0] = 0;
  for (int i = 1; i <= N; i++) {
    int a;
    cin >> a;
    sum[i] = sum[i - 1] + a;
  }
  for (int i = N - 1; i >= 0; i--) {
    sum[i] += (N - i) * K;
  }

  cout << N * (N + 1) / 2 - inversePairs(sum, 0, N + 1) << endl;
}


Measured memory_bytes: 2996
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k,i,ans;
  ans=0;
  cin >> n >> k;
  vector<int> p(n);
  for(i=0;i<n;++i) {cin >> p.at(i);}

sort(p.begin(),p.end());
for(i=0;i<k;i++)
{
ans=ans+p.at(i);
}
  cout << ans;
  
return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n  = sc.nextInt
  val al = Vector.fill(n)(sc.nextInt)

  val acc = comulativeSum(al)
  val sum = acc.last

  val a = acc.dropRight(1)

  val res =
    a.foldLeft(Long.MaxValue){case (min, x) =>
      Math.min( min, Math.abs(x - (sum - x)) )
    }

  println(res)

  def comulativeSum(intVector: Vector[Int]): Vector[Long] ={
    intVector.foldLeft(Vector.empty[Long]){
      case (list, ac) =>
        if(list.isEmpty) Vector(ac)
        else list :+ (list.last + ac)
    }
  }
}

Measured memory_bytes: 90468
S = input()
N = len(S)

s = S[0]
cnt = 0
i = 0

while i < N-1:
    if s == S[i+1]:
        s = s + S[i+1]
        cnt += 1
        i += 2
    else:
        s = S[i+1]
        i += 1

print(N-cnt)


Measured memory_bytes: 3500
class dice:
    def __init__(self, li):
        self.men = [0] + li
    def move0(self, a, b, c, d):
        self.men[a], self.men[b], self.men[c], self.men[d] = self.men[b], self.men[c], self.men[d], self.men[a]
    def move(self, h):
        if h == "N":
            self.move0(1, 2, 6, 5)
        elif h == "S":
            self.move0(1, 5, 6, 2)
        elif h == "W":
            self.move0(1, 3, 6, 4)
        elif h == "E":
            self.move0(1, 4, 6, 3)
        elif h == "O":
            self.men[1], self.men[6], self.men[2], self.men[5] = self.men[6], self.men[1], self.men[5], self.men[2]
        elif h == "L":
            self.move0(2, 3, 5, 4)
        elif h == "R":
            self.move0(2, 4, 5, 3)
        elif h == "B":
            self.men[3], self.men[4], self.men[2], self.men[5] = self.men[4], self.men[3], self.men[5], self.men[2]
    def move2(self, a, b):
        if self.men[1] != a:
            for i, s in [(2, "N"), (3, "W"), (4, "E"), (5, "S"), (6, "O")]:
                if self.men[i] == a:
                    self.move(s)
                    break
        if self.men[2] != b:
            if b == self.men[3]:
                self.move("L")
            elif b == self.men[4]:
                self.move("R")
            else:
                self.move("B")
saikoro = dice(list(map(int, input().split())))
for _ in range(int(input())):
    saikoro.move2(*map(int, input().split()))
    print(saikoro.men[3])



Measured memory_bytes: 5608
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  as <- map unsafeTextToRational . T.words <$> T.getLine :: IO [Rational]
  let
    s = fromRational . recip . sum . map recip $ as :: Double
  print s

unsafeTextToRational :: T.Text -> Rational
unsafeTextToRational s = case T.rational s of
  Right (x, _) -> x
{-# INLINE unsafeTextToRational #-}

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


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

// https://atcoder.jp/contests/abc081/tasks/abc081_a

int getOneCounter(string inputString){
    int counter = 0;
    if(inputString[0] - '0' == 1)counter = counter+1;
    if(inputString[1] - '0' == 1)counter = counter+1;
    if(inputString[2] - '0' == 1)counter = counter+1;
    return counter;
}

int main(void){
    string squareBoard;
    int ans;
    cin >> squareBoard;
    ans = getOneCounter(squareBoard);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    int q;cin>>q;
    V<ll>a;
    for(ll i=0;i<q;i++){
        int x;cin>>x;
        if(x==0){
            ll b;cin>>b;
            a.pb(b);
        }
        else if(x==1){
            ll b;cin>>b;
            cout<<a[b]<<endl;
        }
        else a.erase(a.begin()+a.size()-1);
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------













































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

const int MAX_N = 100005;
int N, M;
std::vector<int> adj[MAX_N];
bool seen[MAX_N];

void dfs(int i) {
  seen[i] = true;
  for (int next : adj[i]) {
    if (seen[next]) continue;
    dfs(next);
  }
}

int main() {
  scanf("%d %d", &N, &M);
  for (int i = 0; i < M; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--; b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  int count = 0;
  for (int i = 0; i < N; ++i) {
    if (seen[i]) continue;
    count++;
    dfs(i);
  }
  printf("%d\n", count-1);
}


Measured memory_bytes: 9872
#include <bits/stdc++.h>
using namespace std;
bool grid[100][100] = {};
int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main() {
    int A,B;
    cin >> A >> B;

    for(int i=0; i<50; ++i) {
        for(int j=0; j<100; ++j) grid[i][j] = true;
    }

    for(int i=0; i<49; ++i) {
        if(A == 1) break;
        for(int j=0; j<100; ++j) {
            if(A == 1) break;
            bool flag = true;
            for(int k=0; k<8; ++k) {
                int nx = i + dx[k];
                int ny = j + dy[k];
                if(nx < 0 || nx > 99 || ny < 0 || ny > 99) continue;
                if(grid[nx][ny] == false) flag = false;
            }
            if(flag) {
                grid[i][j] = false;
                --A;
            }
        }
    }

    for(int i=51; i<100; ++i) {
        if(B == 1) break;
        for(int j=0; j<100; ++j) {
            if(B == 1) break;
            bool flag = true;
            for(int k=0; k<8; ++k) {
                int nx = i + dx[k];
                int ny = j + dy[k];
                if(nx < 0 || nx > 99 || ny < 0 || ny > 99) continue;
                if(grid[nx][ny] == true) flag = false;
            }
            if(flag) {
                grid[i][j] = true;
                --B;
            }
        }
    }

    cout << "100 100" << endl;
    for(int i=0; i<100; ++i) {
        for(int j=0; j<100; ++j) cout << (grid[i][j] ? '#' : '.');
        cout << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        List<Integer> a = new ArrayList<>();
        int n = sc.nextInt();
        int k = sc.nextInt();
        for(int i = 0;i < n;i++){
            a.add(sc.nextInt());
        }
        Collections.sort(a);
        int cnt = 0;
        for(Integer it : a){
            if(it == 1){
                continue;
            }
            it = 1;
            cnt++;
        }

        int ans = 0;
        if(cnt % (k-1) == 0){
            ans = cnt / (k-1);
        }
        else{
            ans = cnt / (k-1) + 1;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 58892
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int add(int a, int b, int mod = MOD) {
    return (a + b) % mod;
}
int mul(int a, int b, int mod = MOD) {
    return 1LL * a * b % mod;
}

int fmod(int a, int mod = MOD) {
    a %= mod;
    if (a < 0) return a + mod;
    return a;
}
int n, dp[2][13];
char s[100005];
int main() {
    scanf(" %s", s);
    n = strlen(s);
    dp[0][0] = 1;
    int pw = 1;
    for (int i = 1; i <= n; ++i) {
        memset(dp[i & 1], 0, sizeof(int) * 13);
        if (s[n - i] != '?') {
            int d = s[n - i] - '0';
            for (int k = 0; k < 13; ++k)
                dp[i & 1][k] = dp[~i & 1][fmod(k - pw * d, 13)];
        } else {
            for (int k = 0; k < 13; ++k)
                for (int j = 0; j < 10; ++j) dp[i & 1][k] = add(dp[i & 1][k], dp[~i & 1][fmod(k - pw * j, 13)]);
        }
        pw = mul(pw, 10, 13);
    }
    if (dp[n & 1][5] < 0) dp[n & 1][5] += MOD;
    printf("%d\n", dp[n & 1][5]);
}

Measured memory_bytes: 384
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.next()
    val b = sc.next()
    println(problem059b(a, b))
}

fun problem059b(a: String, b: String): String {
    when {
        a.length > b.length -> return "GREATER"
        a.length < b.length -> return "LESS"
    }
    for (i in 0 until a.length) {
        return if (a[i].toInt() > b[i].toInt()) {
            "GREATER"
        } else if (a[i].toInt() < b[i].toInt()) {
            "LESS"
        } else {
            continue
        }
    }
    return "EQUAL"
}

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

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

	int min = 1001;

	int c[100], t[100];
	for(int i = 0; i < n; i++){
		cin >> c[i] >> t[i];

		if(t[i] <= u && min > c[i]) min = c[i];
	}

	if(!(min <= 1000)) cout << "TLE" << endl;
	else cout << min << endl;
}

Measured memory_bytes: 256
N,X,Y=map(int, input().split())
d = [0]+list(range(N-1, 0, -1))
X,Y=min(X,Y),max(X,Y)

for i in range(1,N):
  for j in range(i+1,N+1):
    if i<= X:
      if j>= Y:
        d[j-i] -=1
        d[j-Y+X-i+1] += 1
      else:
        if j > (X+Y)/2:
          d[j-i] -=1
          d[X-i+1+Y-j] += 1
    else:
      if i-X+abs(j-Y)+1 < j-i:
        d[j-i] -= 1
        d[i-X+abs(j-Y)+1] += 1

for i in range(1,N):
  print(d[i])

Measured memory_bytes: 9376
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

int main(){
    long n, t;
    scanf("%ld%ld", &n, &t);
    std::vector<long> a(n);
    long cnt = 0, min = LINF, dif = 0;
    for(int i = 0; i < n; i++){
        scanf("%ld", &a[i]);
        min = std::min(min, a[i]);
        if(a[i] - min == dif){
            cnt++;
        }else if(a[i] - min > dif){
            dif = a[i] - min;
            cnt = 1;
        }
    }
    printf("%ld\n", cnt);
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
    int n,k;
    int d[110],a[110][110];
    bool s[110]={};
    cin>>n>>k;
    fori(k){
        cin>>d[i];
        forj(d[i]){
            cin>>a[i][j];
            s[a[i][j]-1]=true;
        }
    }

    int c=0;
    fori(n){
        if(s[i]==false){
            ++c;
        }
    }
    cout<<c;
}

Measured memory_bytes: 3668
// Code by H~$~C
#include <bits/stdc++.h>
using namespace std;

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

int n, m;
char grid[22][22];
int dis[405][405];
inline int getid(int x, int y) {
  return (x - 1) * m + y;
}

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i)
    scanf("%s", grid[i] + 1);
  memset(dis, 63, sizeof(dis));
  for (int i = 1; i <= n * m; ++i)
    dis[i][i] = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      if (grid[i][j] != '.') continue;
      for (int f = 0; f < 4; ++f) {
        int ni = i + dx[f], nj = j + dy[f];
        if (ni < 1 || ni > n || nj < 1 || nj > m) continue;
        if (grid[ni][nj] != '.') continue;
        dis[getid(i, j)][getid(ni, nj)] = 1;
        dis[getid(ni, nj)][getid(i, j)] = 1;
      }
    }
  for (int k = 1; k <= n * m; ++k)
    for (int i = 1; i <= n * m; ++i)
      for (int j = 1; j <= n * m; ++j)
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
  int mx = 0;
  for (int i = 1; i <= n * m; ++i)
    for (int j = 1; j <= n * m; ++j)
      if (dis[i][j] < 1e9) mx = max(mx, dis[i][j]);
  printf("%d\n", mx);
  return 0;
}


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

constexpr int MOD = 1e9 + 7;

int main() {
    int N; cin >> N;
    string S; cin >> S;
    map<char, ll> memo;
    for (int i = 0; i < N; i++) memo[S[i]]++;
    ll ans = 1;
    for (auto x : memo) ans = (ans * (x.second + 1)) % MOD;
    cout << (MOD + ans - 1) % MOD << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
//
int main(){
  int N;
  pair<int,char> A[100],B[100];
  cin>>N;
  FOR(i,0,N){
    char c;
    int num;
    cin>>c>>num;
    A[i]=MA(num,c);
    B[i]=MA(num,c);
  }
  bool F=true;;
  while(F){
    F=false;
    FOR(i,1,N){
      if(A[i].FI<A[i-1].FI){
        swap(A[i],A[i-1]);
        F=true;
      }
    }
  }
  FOR(i,0,N){
    int minj=i;
    FOR(j,i,N){
      if(B[j].FI<B[minj].FI){
        minj=j;
      }
    }
    if(i!=minj){
      swap(B[i],B[minj]);
    }
  }
  FOR(i,0,N){
    if(i!=0){
      cout<<" ";
    }
    cout<<A[i].SE<<A[i].FI;
  }
  cout<<endl;
  cout<<"Stable"<<endl;
  bool D=true;
  FOR(i,0,N){
    if(i!=0){
      cout<<" ";
    }
    cout<<B[i].SE<<B[i].FI;
    if(A[i].FI!=B[i].FI||A[i].SE!=B[i].SE){
      D=false;
    }
  }
  cout<<endl;
  if(D){
    cout<<"Stable"<<endl;
  }else{
    cout<<"Not stable"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
bool check_A( string &S )
{
    auto sz = S.size();
    //size ??? 6 ??\?????????????????? false
    if( sz < 6 )
    {
        return 0;
    }
    //?????????[>'=], ????°????[~]?????????????????´?????? false
    if( S[ 0 ] != '>' || S[ 1 ] != '\'' || S[ 2 ] != '=' || S[ sz - 1 ] != '~' )
    {
        return 0;
    }
    //??????[>']??¨????°?[~]???????????????
    string R = S.substr( 2, sz - 3 );
    sz = R.size();
    //R ???[#,=]??\???????????????????????????????????? false
    if( R.find_first_not_of( "#=", 0 ) != string::npos )
    {
        return 0;
    }
    if( sz % 2 == 0 )
    {
        return 0;
    }
    //R ?????????????????????????????£???[#]???????????\??????[#]????????£?????? false
    auto pos = R.find( "#" );
    if( R.find( "#", pos + 1 ) != string::npos )
    {
        return 0;
    }
    // S ???????????????[#]???????????£?????? false
    if( R[ sz / 2 ] != '#' )
    {
        return 0;
    }
    return 1;
}
bool check_B( string &S )
{
    auto sz = S.size();
    //size ??? 6 ??\?????????????????? false
    if( sz < 6 )
    {
        return 0;
    }
    //?????????[>^], ????°????[~~]?????????????????´?????? false
    if( S[ 0 ] != '>' || S[ 1 ] != '^' || S[ sz - 1 ] != '~' || S[ sz - 2 ] != '~' )
    {
        return 0;
    }
    string R = S.substr( 2, sz - 4 );
    sz = R.size();
    // S ???size????\???°?????£?????? false
    if( sz % 2 != 0 )
    {
        return 0;
    }
    for( int i = 0; i < sz; i += 2 )
    {
        //[Q=]?????£?¶???§????????£?????? false
        if( R[ i ] != 'Q' || R[ i + 1 ] != '=' )
        {
            return 0;
        }
    }
    return 1;
}
int main()
{
    int N;
    cin >> N;
    
    REP( i, N )
    {
        string S;
        cin >> S;
        
        string res{ "NA" };
        if( check_A( S ) )
        {
            res = "A";
        }
        else if( check_B( S ) )
        {
            res = "B";
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Max(a, b) (a > b ? a : b)
#define Min(a, b) (a < b ? a : b)
#define ii pair<int, int>
#define fi first
#define se second
const int MAX = 200000; //2 * 10^5
const int MOD = 1000000007; //10^9 + 7
const int OO = 0x3f3f3f3f; // 0x3f3f3f3f;

int32_t main()
{
	int n;
	cin >> n;
	vector<int> pot(13, 1);
	for(int i = 1; i < 13; i++)
		pot[i] = pot[i - 1] * 26;

	int d = 1, s = 0;
	for(int i = 1; i <= 12; i++)
	{
		s += pot[i - 1];
		if(n >= s)
			d = i;
		else 
			break;
	}
	for(int i = 0; i < d; i++)
		n -= pot[i];
	
	string ans(d, '.');

	for(int i = 0; i < d; i++)
	{
		int k = 0;
		for(int j = 0; j < 26; j++)
			if(pot[d - i - 1] * j <= n)
				k = j;
		ans[i] = char('a' + k);
		n -= pot[d - i - 1] * k;
	}

	cout << ans << '\n';

	return 0;

	// int l = 1, maxi = 26, ant = 0;
	// while(maxi < n)
	// {
	// 	l++;
	// 	ant = maxi;
	// 	maxi *= 26;
	// }

	// n -= ant;

	// cout << l << '\n';
	
	
	// // << maxi << ' ' << ant << ' ' << n << '\n';
	
	// return 0;

	// string s;

	// while(n > 26)
	// {
	// 	int q = n / 26;
	// 	cout << n << ' ' << q << ' ' << n - 26 * q << '\n'; 
	// 	s.push_back(char('a' + n - 26 * q - 1));
	// 	n = q;
	// }
	// if(n > 0) s.push_back(char('a' + n - 1));
	// reverse(s.begin(), s.end());
	// cout << s << '\n';

	return 0;
}


Measured memory_bytes: 3624
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;


int n, m;
string s;
int p[100005];


int main(int argc, const char * argv[]) {
//    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    cin >> s;
    s = "#" + s;
    for (int i = 2; i <= n; ++i) {
        p[i] = p[i - 1];
        if (s[i] == 'C' && s[i - 1] == 'A') ++p[i];
    }
    while (m--) {
        int l, r;
        cin >> l >> r;
        cout << p[r] - p[l] << '\n';
    }
}



Measured memory_bytes: 1388
import java.util.*;

class Main {
	Scanner sc;
	int X, Y, A, B, C;
	int[][] a;
	
	void calc() {
		sc = new Scanner(System.in);
		X = sc.nextInt();
		Y = sc.nextInt();
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();
		
		a = new int[A+B+C][2];
		for (int i = 0; i < A; i++) {
			a[i][0] = sc.nextInt();
			a[i][1] = 0;
		}
		for (int i = A; i < A+B; i++) {
			a[i][0] = sc.nextInt();
			a[i][1] = 1;
		}
		for (int i = A+B; i < A+B+C; i++) {
			a[i][0] = sc.nextInt();
			a[i][1] = 2;
		}
		Arrays.sort( a, Comparator.comparingInt( (int[] app) -> app[0] ).reversed());
		int[] c = new int[3];
		long s = 0;
		int counted = 0;
		for (int i = 0; i < A+B+C; i++) {
			if (c[0] == X && a[i][1] == 0) continue;
			if (c[1] == Y && a[i][1] == 1) continue;
			s += a[i][0];
			c[a[i][1]]++;
			counted++;
			if (counted == X+Y) break;
		}
		System.out.println(s);
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}


Measured memory_bytes: 69012
#include <algorithm>
#include <cstdio>
#include <climits>
#include <vector>
using namespace std;

int main() {
    while(true) {
        int d; scanf("%d", &d);
        if(d==0) break;
        int n,m; scanf("%d%d", &n, &m);
        int cw[100001], ccw[100001];
        cw[0] = ccw[0] = 0;
        cw[1] = ccw[1] = d;
        for(int i = 0; i < n-1; i++) {
            int x; scanf("%d", &x);
            cw[i+2] = x;
            ccw[i+2] = d-x;
        }
        sort(cw, cw+n+1);
        sort(ccw, ccw+n+1);
        int valsum = 0;
        for(int i = 0; i < m; i++) {
            int qr; scanf("%d", &qr);
            int qr2 = d-qr; if(qr==0) qr2=0;
            valsum += min(*lower_bound(cw, cw+n+1, qr)-qr, *lower_bound(ccw, ccw+n+1, qr2)-qr2);
        }
        printf("%d\n", valsum);
    }
    return 0;
}

Measured memory_bytes: 1544
#include <stdio.h>
#include <stdlib.h>


typedef struct Node {
  int val;
  struct Node *next;  
} node_t;

node_t *G[100000];
int connected[100000];
int color;

node_t* add_node(node_t *node, int val)
{
    node_t *n = (node_t*)malloc(sizeof(node_t));
    n->val = val;
    n->next = node;
    return n;     
}

void add(int u, int v)
{
    G[u] = add_node(G[u], v);
    G[v] = add_node(G[v], u);
}

void dfs(int v)
{
    node_t *p;
    if (connected[v]) return;
    connected[v] = color;
    for (p = G[v]; p != NULL; p = p->next) {
        dfs(p->val);
    }
}

int main()
{
    int i;    
    int n, m;
    int s, t;
    scanf("%d %d", &n, &m);
    
    for (i = 0; i < m; i++) {
        scanf("%d %d", &s, &t);
        add(s, t);        
    }
    
    for (i = 0; i < n; i++) {
        color = i + 1;
        dfs(i);
    }
    
    int q;
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d %d", &s, &t);
        if (connected[s] == connected[t]) puts("yes");
        else puts("no");
    }
    
    return 0;
}

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

int main(){
	int A,B,C;
	cin>>A>>B>>C;
	int X=max(max(A,B),C);
	int ans;
	if(((X-A)+(X-B)+(X-C))%2==0) ans=((X-A)+(X-B)+(X-C))/2;
	else ans=((X-A)+(X-B)+(X-C)+3)/2;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

def main():
    a, b, c, d = map(int, input().split())

    if c == 1 or d == 1:
        print(0)
        return
    g = lcm(c,d)
    cmod = b//c - (a-1)//c
    dmod = b//d - (a-1)//d
    cdmod = b//g - (a-1)//g
    print(b-a+1-cmod-dmod+cdmod)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 64620
<?php
$str = "0".trim(fgets(STDIN));
$l = strlen($str);
$dp0 = array_fill(0, $l+1, 0);//超えてないやつ
$dp1 = array_fill(0, $l+1, 0);//超えたやつ
$numArray = array_map("intval", str_split($str));
for($i = 0; $i < $l; ++$i){
  $d = intval($str[$i]);
  $dp0[$i+1] = min($dp0[$i]+$d, $dp1[$i]+10-$d);
  $dp1[$i+1] = min($dp0[$i]+$d+1, $dp1[$i]+9-$d);
}
echo $dp0[$i],"\n";


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

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

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

// order statistics tree
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
             tree_order_statistics_node_update> indexed_set;

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define rrep(i, b, a) for(int i = b; i >= a; --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

const int N = 1e5+10;
int n;
int d[N];
int main() {
  cin.tie(0); cin.exceptions(cin.failbit);
  scanf("%d", &n);
  rep(i, 0, n) scanf("%d", d+i);
  sort(d, d+n);
  printf("%d\n", d[n/2] - d[n/2-1]);
}


Measured memory_bytes: 640
N, M = map(int, input().split())
edges = [None]*M
INF = 10**18

for i in range(M):
    a, b, c = map(int, input().split())
    edges[i] = (a-1, b-1, -c)
    
def bellman(n, edges, r):
    d = [INF] * n
    d[r] = 0
    
    for i in range(n):
        for (u, v, c) in edges:
            if(d[u] != INF and d[u]+c < d[v]):
                d[v] = d[u] + c
                if(i == n-1 and v == n-1):
                    return "inf"
                
    return -d[-1]
    
ans = bellman(N, edges, 0)
print(ans)

Measured memory_bytes: 9356
# -*- coding: utf-8 -*-
blue = int(input())
bluelist = []
redlist = []
for i in range(blue):
    bluelist.append(input())
red = int(input())
for i in range(red):
    redlist.append(input())
maxyen = 0
for x in bluelist:
    yen = bluelist.count(x) - redlist.count(x)
    if yen > maxyen:
        maxyen = yen
print(maxyen)

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    ll n, m; cin >> n >> m;
    vector<ll> a(m), b(m);
    rep(i, m){
        cin >> a.at(i) >> b.at(i);
        --a.at(i), --b.at(i);
    }

    struct UnionFind UF(n);
    ll cur = n*(n-1)/2;
    vector<ll> res;

    for(int i=0; i<m; i++){
        res.push_back(cur);

        int A = a.at(m-1-i), B = b.at(m-1-i);
        if(UF.issame(A, B)) continue;

        ll sa = UF.size(A), sb = UF.size(B);
        dump(sa);
        dump(sb);
        cur -= sa * sb;
        UF.merge(A, B); 

    }

    reverse(res.begin(), res.end());
    rep(i, res.size()){
        cout << res.at(i) << endl;
    }


    return 0;
}


Measured memory_bytes: 4212
#include<stdio.h>
double abs(double A){
	return A<0.0?-A:A;
}
int main(){
	int a;
	while(scanf("%d",&a),~a){
		double p=(double)a/2.0;
		while(1){
			p=p-((p*p*p)-(double)a)/(3.0*p*p);
			if(abs(p*p*p-(double)a)<(double)a*0.00001)break;
			//printf("%.6lf\n",p);
		}
		printf("%.6lf\n",p);
	}
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 100009;
int n, k;

int sm(int i) {
    if(i%2) {
        return (i+1)/2*i;
    } else {
        return i/2*(i+1);
    }
}

int32_t main() {

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

    cin >> n >> k;
    int smsmall = sm(k+2*n-1) - sm(k-1), smbig = sm(k+3*n-1) - sm(k+2*n-1);

    if(smsmall > smbig) {
        cout << -1 << endl;
        return 0;
    }

    vector<pair<int, int>> vp;

    int r = k + 2*n - n/2 - 1;
    for(int i = 0; i < n; ++i) {
        int l = k+i;
        vp.emplace_back(l+r, l);
        r++;
        if(r == k+2*n) r = k + n;
    }

    sort(vp.begin(), vp.end());

    for(int i = 0; i < n; ++i) {
        cout << vp[i].second << ' ' << vp[i].first - vp[i].second << ' ' << k + 2*n + i <<'\n';
    }
    
    return 0;
}


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

using ll=long long;
using int64=int64_t;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
    int n=in(),a[n],b[n],c[n],i,ans;
    forin(a,n);
    forin(b,n);
    forin(c,n-1);
    c[n-1]=0;
    ans=b[a[0]-1];
    for (i=1;i<n;i++){
        ans+=b[a[i]-1];
        if (a[i-1]+1==a[i]) {
            ans+=c[a[i-1]-1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while((line = br.readLine()) != null){
            String[] input = line.split(" ");
            int max = Integer.valueOf(input[0]);
            int goal = Integer.valueOf(input[1]);
            if(max == 0 && goal == 0) break;
            int count = 0;

            for(int i = 1; i <= max; i++){
                for(int j = 1; j <= max; j++){
                    if(i == j) continue;
                    for(int k = 1; k <= max; k++){
                        if(i == k || j == k) continue;
                        if((i+j+k) == goal) count++;
                    }
                }
            }

            System.out.println(count/6);
        }
    }
}

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

int main() {
	string x, y;
	cin >> x >> y;
	if (x.compare(y) > 0) {
		cout << ">" << endl;
	} else if (x.compare(y) == 0) {
		cout << "=" << endl;
	} else {
		cout << "<" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <strstream>
#include <string>
#include <deque>
#include <vector>
#include <algorithm>
typedef unsigned int UINT;
using namespace std;

bool checkABC(string &S)
{
    string clect = "abc";
    for (auto c : clect) {
        bool isnot = true;
        for (auto s : S) {
            if (s == c) {
                isnot = false;
                break;
            }
        }
        if (isnot)
            return false;
    }
    return true;
}


int main(void) {
    string S;
    cin >> S;
    if (checkABC(S))
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
        int int1 = Integer.parseInt(scan.next());
        int int2 = Integer.parseInt(scan.next());
//        int int3 = Integer.parseInt(scan.next());
//        String temp_str1 = "";
//        String temp_str2 = "";
        int temp_int1 = 0;
//        String str1 = scan.next();
        int ans_int = 0;
        String ans = "";
//        double ans_dob = 0;
        ans_int = int1-int2;
        if(ans_int<0){
            ans_int = 0;
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(ans_int);
        out.flush();
        scan.close();
    }
}


Measured memory_bytes: 21844
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int MX = 310;
int n, k;
ll MOD;

ll cnk[MX][MX];
ll dp[MX][MX];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n >> k >> MOD;
	for (int i = 0; i < MX; ++i)
		for (int j = 0; j < MX; ++j) {
			if (i == j || j == 0)
				cnk[i][j] = 1;
			else if (j > i)
				cnk[i][j] = 0;
			else
				cnk[i][j] = (cnk[i - 1][j] + cnk[i - 1][j - 1]) % MOD;
		}
	for (int i = 0; i <= k; ++i)
		dp[0][i] = 1;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= k; ++j) {
			dp[i][j] = dp[i][j - 1];
			for (int l = 0; l < i; ++l) {
				dp[i][j] = (dp[i][j] + cnk[i][l] * dp[l][j - 1] % MOD * dp[i - 1 - l][j]) % MOD;
			}
		}
	cout << dp[n][k] << "\n";
	return 0;
}




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


int main(){
  int N; vi W(110);
  cin >> N;
  for(int i=0; i<N; i++) cin >> W[i];

  vi sum(110,0); sum[0] = W[0];
  for(int i=1; i<N; i++) sum[i] = sum[i-1] + W[i];

  int ans = 9999999;
  for(int i=0; i<N;i++){
    ans = min(ans, abs(sum[i]-(sum[N-1]-sum[i])));
  }
    
  cout << ans << endl;

  
}

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

#define ll long long

using namespace std;


int main(){
    int a,b;
    cin>>a>>b;
    string s="",t="";
    for(int i=0; i<b; i++){
        s+= char('0' + a);
    }
    for(int i=0; i<a; i++){
        t+=char('0'+ b);
    }
    if(a>b){
        cout<<t<<endl;
    }
    else{
        cout<<s<<endl;
    }
}



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

using namespace std;

const long long INF = LONG_LONG_MAX;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, weight;
    cin >> n >> weight;
    vector<int> c(n), w(n);
    vector<vector<long long> > dp(n + 1);
    for (int i = 0; i <= n; i++) {
        dp[i].resize(weight + 1);
    }
    for (int i = 0; i < n; ++i) {
        cin >> w[i] >> c[i];
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= weight; ++j) {
            dp[i][j] = dp[i - 1][j];
            if (j >= w[i-1]) dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + c[i - 1]);
        }
    }
    long long ans = -1;
    for (int i = 0; i <= n; ++i) {
        ans = max(ans, dp[i][weight]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 79488
#include<bits/stdc++.h>
using namespace std;
int main()
{
    std::ios_base::sync_with_stdio(false);
    //std::cin.tie(nullptr);
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256