akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;

    cin >> s >> t;
    bool ok = true;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) ok = false;
    }

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



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

int n, a, x[50];
int dp[51][51][2501];

signed main() {
	int i, j, k;
	
	cin >> n >> a; rep(i, n) cin >> x[i];
	
	dp[0][0][0] = 1;
	rep(i, n) {
		rep(j, i + 1) {
			rep(k, 50 * i + 1) {
				dp[i + 1][j][k] += dp[i][j][k];
				dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
			}
		}
	}
	
	int ans = 0;
	rep(i, n + 1) if (i > 0) ans += dp[n][i][a * i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 49024
#include <stdio.h>

int main(){
	int D,T,S;
	double sum;
	
	scanf("%d",&D);
	scanf("%d",&T);
	scanf("%d",&S);
	
	sum = (double)D / (double)S;
	
	if(sum <= T){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 1640
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
  while(true){
    int n, m, i, j, k;
    int p[100];
    for(i = 0; i < 100; i++)
      p[i] = -1;
    cin >> n >> m;
    if(!n)
      break;
    for(i = 0; i < n; i++){
      for(j = 0; j < m; j ++){
	      int input;
	      cin >> input;
	      p[j] += input;
      }
    }
    k = 1;
    for(i = 1000; i >= 0; i--){
      for(j = 0; j < m; j++){
	      if(p[j] == i){
	        printf("%d", j + 1);
	        if(k < m) printf(" ");
		else printf("\n");
		k++;
	      }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
const ll mod=1e9+7;
template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
 
const ll N=1e6+8;
const ll INF=1e18;
ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

vector<ll> v[N];
ll dp[N][2];
ll my_name(ll x,ll y,ll p){
  if(dp[x][p]!=-1)
  return dp[x][p];
  ll res=1;
  if(p==1){
    for(auto it:v[x]){
      if(it==y)
      continue;
      res=mul(res,my_name(it,x,0));
    }
  }
  else{
   ll res1=1,res2=1;
    for(auto it:v[x]){
      if(it==y)
      continue;
      res1=mul(res1,my_name(it,x,1));
      res2=mul(res2,my_name(it,x,0));
    }
    res=add(res1,res2);
  }
  return dp[x][p]=res;
}
int main (){
  IOS;
 ll n;
 cin>>n;
 ll a,b;
 for(ll i=1;i<=n-1;i++){
   cin>>a>>b;
   v[a].pb(b);
   v[b].pb(a);
 }
 memset(dp,-1,sizeof(dp));
 cout<<my_name(1,0,0);
}

Measured memory_bytes: 49408
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int n,k;
  cin >> n >> k;
  vi list(n+1,0);
  int tmp;
  rep(i,n){
    cin >> tmp;
    list.at(tmp)++;
  }
  sort(list.begin(),list.end());
  int sp = n;
  int answer = 0;
  for(int i=1;i<=n;i++){
    if(list.at(i) == 0){
      sp--;
      continue;
    }
    if(sp <= k){
      cout << answer;
      return 0;
    }
    answer += list.at(i);
    sp--;
  }
  cout << answer;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    char pre;
    char now;
    int ans = 1;
    cin >> pre;
    for (int i = 1; i < n; i++) {
        cin >> now;
        if (pre != now) {
            ans++;
        }
        pre = now;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, m, l = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]
B = [list(map(int, input().split())) for i in range(m)]
for ARow in A:
    result = []
    for BCol in zip(*B):
        result.append(sum([a * b for (a,b) in zip(ARow, BCol)]))
    print(*result)

Measured memory_bytes: 8588
import math
import itertools
N, D = map(int, input().split())
X = [0]*N
for i in range(N):
    X[i] = list(map(int, input().split()))

cnt = 0
for i in list(itertools.combinations(X, 2)):
    ans = 0
    for j in range(D):
        ans += abs((i[0][j] - i[1][j])**2)
    if math.sqrt(ans).is_integer():
        cnt += 1
print(cnt)

Measured memory_bytes: 9132
num = input().split()
A = int(num[0]) #1
B = int(num[1])  #0
C = int(num[2]) #-1
K = int(num[3]) #選ぶ個数

count = 0
kai = 0
if K < A:
    print(K)
if K == A:
    print(K)
if K > A:
    
    kai = A
    count = A
    
    if count < K:
        if K == A+B:
            print(A)
        elif K > A+B:
            kai = A
            count = A+B
            
            if count < K:
               kai = A + (K - count)*(-1)
               print(kai)

Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;


int Main(int N, VI &A, VI &B, VI &C)
{
    int ans = B[A[0]-1];
    REP2(i, 1, N) {
        ans += B[A[i]-1];
        if(A[i-1]+1 == A[i]) ans += C[A[i]-2];
    }
    return ans;
}

int main(void){
    int N;
    cin >> N;
    VI A(N), B(N), C(N-1);
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> B[i];
    REP(i, N-1) cin >> C[i];
    cout << Main(N, A, B, C) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n, ans=0, i, j, temp=0;
  scanf("%d", &n);
  for(i=1;i<=n;i+=2){
    for(j=1;j<=i;j++){
      if(i%j==0){
        temp++;
      }
    }
    if(temp==8){
      ans++;
    }
    temp=0;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ll long long
#define MOD 1000000007
#define MAX 1000010
#define test(a,n) REP(i,n) cout << a[i] << " ";
using namespace std;

int main(){
  int a[9];
  REP(i,9) cin >> a[i];
  int n;
  cin >> n;
  int b[n];
  REP(i,n) cin >> b[i];
  int ans[9] = {0};
  
  REP(j,9){
    REP(i,n){
      if(b[i] == a[j]) ans[j]++;
    }
  }
  
  if(ans[0] > 0 && ans[1] > 0 && ans[2] > 0) cout << "Yes";
  else if(ans[0] > 0 && ans[4] > 0 && ans[8] > 0) cout << "Yes";
  else if(ans[3] > 0 && ans[4] > 0 && ans[5] > 0) cout << "Yes";
  else if(ans[6] > 0 && ans[7] > 0 && ans[8] > 0) cout << "Yes";
  else if(ans[0] > 0 && ans[3] > 0 && ans[6] > 0) cout << "Yes";
  else if(ans[1] > 0 && ans[4] > 0 && ans[7] > 0) cout << "Yes";
  else if(ans[2] > 0 && ans[5] > 0 && ans[8] > 0) cout << "Yes";
  else if(ans[2] > 0 && ans[4] > 0 && ans[6] > 0) cout << "Yes";
  else cout << "No";
  return 0;
}

Measured memory_bytes: 256
///******* In the name of Allah *******///

#include <bits/stdc++.h>
using namespace std;

long int ar[10013];
//long int gcd(long int a, long int b)
//{
//    if(b==0)
//        return a;
//    return gcd(b,a%b);
//}
//void sieve()
//{
//    long long int i,j,k = 0;
//    memset(ar,0,sizeof(ar));+
//    ar[1] = 1;
//    for(i=2; i<=713; i++)
//    {
//        if(ar[i]==0)
//        {
//            for(j=i+i; j<=713; j+=i)
//            {
//                ar[j] = 1;
//            }
//        }
//    }
//}

long int a[10000013];
void Ok()
{
    long int b,c,d,e,f,g,h,t,i,j,k,l,m,n,Min,Max;
    long int ans_1,ans_2,ans_3,cnt_1,cnt_2,cnt_3,flag_1,flag_2,flag_3,temp,sum;
    double aa,bb,cc,dd,ee,ff,gg;
    char aaa[113],bbb[113],ccc[113],ddd;
    string spc,in,store;

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

    cin>>aaa;
    cnt_1 = 0;
    Max = 0;
    aaa[3] = 'S';
    for(i=0;i<=3;i++)
    {
        if(aaa[i]=='R')
            cnt_1++;
        else
            Max = max(cnt_1,Max), cnt_1 = 0;

    }
    cout<<Max<<endl;


    return;
}

int main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    Ok();

    return 0;
}


Measured memory_bytes: 3608
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Map<Long, Long> map = new TreeMap<>(Comparator.reverseOrder());
        for (int i = 0; i < n; i++) {
            long a = Long.parseLong(sc.next());
            map.merge(a, 1L, Long::sum);
        }
        List<Long> list2 = new ArrayList<>();
        List<Long> list4 = new ArrayList<>();
        for (Map.Entry<Long, Long> m : map.entrySet()) {
            if (m.getValue() >= 4) {
                list4.add(m.getKey());
            }
            if (m.getValue() >= 2) {
                list2.add(m.getKey());
                if (list2.size() == 2) {
                    break;
                }
            }
        }
        if (list4.size() != 0 && list4.get(0) >= list2.get(0)) {
            System.out.println(list4.get(0) * list4.get(0));
        } else if (list2.size() < 2) {
            System.out.println(0);
        } else {
            System.out.println(list2.get(0) * list2.get(1));
        }
    }
}

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

long long _max(long long a, long long b) {
    return a > b ? a : b;
}

int main(void) {
    long long N, M;
    cin >> N >> M;


    long long center = _max(M - 2, 0) * _max(N - 2, 0);

    if (N == 1) center = _max(M - 2, 1);
    if (M == 1) center = _max(N - 2, 1);

    cout << center << endl;

    return 0;
}


Measured memory_bytes: 256
class BinaryTree {
  constructor() {
    this.root = null;
    BinaryTree.Node = BinaryTree.Node || BinaryTree._createNodeClass();
  }

  static _createNodeClass() {
    return class BinaryTreeNode {
      constructor(key, parent = null, left = null, right = null) {
        this.key = key;
        this.parent = parent;
        this.left = left;
        this.right = right;
      }

      getChildrenNumber() {return Number(this.left !== null) + Number(this.right !== null);}

      isLeftChild() {return this.parent ? this.parent.left === this : null;}

      getLeftOrRight() {return this.isLeftChild() ? 'left' : 'right';}

      getSuccessor() {
        let n;
        if (this.right !== null) {
          n = this.right;
          while (n.left !== null) n = n.left;
        } else {
          n = this.parent;
          while (!n.isLeftChild && n.parent != null) n = n.parent;
        }
        return n;
      }
    };
  }

  insert(key) {
    if (this.root === null) {
      this.root = new BinaryTree.Node(key);
      return;
    }
    let x = this.root, y;
    let newNode = new BinaryTree.Node(key);
    while (x !== null) {
      y = x;
      x = x[key < x.key ? 'left' : 'right'];
    }
    newNode.parent = y;
    y[key < y.key ? 'left' : 'right'] = newNode;
  }

  find(key, n = this.root) {
    if (n === null || n.key === key) return n;
    return this.find(key, n[key < n.key ? 'left' : 'right']);
  }

  delete(key) {
    const n = this.find(key);
    const leftOrRight = n.getLeftOrRight();
    switch (n.getChildrenNumber()) {
    case 0:
      n.parent[leftOrRight] = null;
      break;
    case 1:
      n.parent[leftOrRight] = n.left || n.right;
      n.parent[leftOrRight].parent = n.parent;
      break;
    default:
      const skey = n.getSuccessor().key;
      this.delete(skey);
      n.key = skey;
    }
  }

  printByIneorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      innerFunc(n.left);
      str += ` ${n.key}`;
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  printByPreorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      str += ` ${n.key}`;
      innerFunc(n.left);
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  print() {
    this.printByIneorder();
    this.printByPreorder();
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  const tree = new BinaryTree();
  lines.forEach(function(cmd) {
    switch (cmd.charAt(0)) {
    case 'i': tree.insert(Number(cmd.split(' ')[1])); break;
    case 'f': console.log(tree.find(Number(cmd.split(' ')[1])) ? 'yes' : 'no'); break;
    case 'd': tree.delete(Number(cmd.split(' ')[1])); break;
    default: tree.print();
    }
  });
})();



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

const int64_t INF=1e9+7;

int main(){
  int64_t N,D,A;
  cin>>N>>D>>A;
  vector<pair<int64_t,int64_t>> p(N);
  for(int i=0;i<N;++i){
    cin>>p[i].first>>p[i].second;
  }
  sort(p.begin(),p.end());

  vector<int64_t> dam(N+1,0);
  int64_t ans=0;

  for(int i=0;i<N;++i){
    if(dam[i]<p[i].second){
    int j=upper_bound(p.begin(),p.end(),make_pair(p[i].first+2*D,INF))-p.begin();
    int64_t need=(p[i].second-dam[i]+(A-1))/A;
    dam[i] += need*A;
    dam[j] -= need*A;
    ans += need;
  }
  dam[i+1] += dam[i];
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long modexp(long long a, long long n)
{
    if(n==1)
        return a;
    long long res = modexp(a,n/2)%mod;
    if(n%2==0)
        return (res%mod*res%mod)%mod;
    else
        return (a%mod*res%mod*res%mod)%mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n,a,b;
    cin>>n>>a>>b;
    long long k = n, nca=1, ncb=1;
    for(long long i = 1; i<=a; i++)
    {
        nca = (nca%mod * (k+1-i)%mod *(modexp(i,mod-2)%mod))%mod;
    }
    for(long long i = 1; i<=b; i++)
    {
        ncb = (ncb%mod * (k+1-i)%mod * (modexp(i,mod-2)%mod))%mod;
    }
    long long ans = (modexp(2,n)%mod - 1 - nca%mod - ncb%mod + 2*mod)%mod;
    cout<<ans;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>

char s[10];

int main()
{
	int i;
	bool ans=false;
	scanf("%s",s);
	for(i=0;i<strlen(s)-1;i++) if(s[i]=='A'&&s[i+1]=='C') {ans=true;break;}
	if(ans) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<string>
#include<sstream>
#include<cstdlib>

using namespace std;

int main ()
{

	stack<int> operands;
	int operand1,operand2;

	string line;

	getline ( cin, line ); 

	istringstream iss ( line );

	string symbol;

	while ( iss >> symbol )
	{
		switch ( symbol[0] )
		{
			case '+':
				operand2 = operands.top();
				operands.pop();
				operand1 = operands.top();
				operands.pop();
				operands.push ( operand1 + operand2 );
				break;
			case '-':
				operand2 = operands.top();
				operands.pop();
				operand1 = operands.top();
				operands.pop();
				operands.push ( operand1 - operand2 );
				break;
			case '*':
				operand2 = operands.top();
				operands.pop();
				operand1 = operands.top();
				operands.pop();
				operands.push ( operand1 * operand2 );
				break;
			case '/':
				operand2 = operands.top();
				operands.pop();
				operand1 = operands.top();
				operands.pop();
				operands.push ( operand1 / operand2 );
				break;
			default :
				operands.push ( atoi(symbol.c_str()) );
				break;
		}
	}

	cout << operands.top() << endl;

return 0;
}



Measured memory_bytes: 3220
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE BangPatterns #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Data.Bits
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Monoid
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM

main :: IO ()
main = do
    [n, q] <- map read.words <$> getLine :: IO [Int]
    queries <- U.unfoldrN q (readInt3.B.dropWhile isSpace) <$> B.getContents
    putStr.unlines.map show $ solve n queries

solve :: Int -> U.Vector (Int, Int, Int) -> [Int]
solve n queries = ($[]) $ runST $ do
    bit <- newBinaryIndexedTree n
    U.foldM' `flip` id `flip` queries $ \acc (com, x, y) ->
        if com == 0
        then updateKey (x-1) y bit >> return acc
        else (acc.).(:) <$> queryRange (x-1) (y-1) bit

instance Monoid Int where
    mempty = 0
    mappend = (+)
    {-# INLINE mempty #-}
    {-# INLINE mappend #-}

instance Group Int where
    invert = negate
    {-# INLINE invert #-}

-------------------------------------------------------------------------------

readInt3 :: B.ByteString -> Maybe ((Int,Int,Int), B.ByteString)
readInt3 bs = Just ((x,y,z),bsz)
  where
    Just (x, bsx) = B.readInt bs
    Just (y, bsy) = B.readInt $ B.unsafeTail bsx
    Just (z, bsz) = B.readInt $ B.unsafeTail bsy

class Monoid g => Group g where
    invert :: g -> g

newtype BinaryIndexedTree m g = BIT (UM.MVector m g)

newBinaryIndexedTree :: (PrimMonad m, U.Unbox g, Group g)
                     => Int
                     -> m (BinaryIndexedTree (PrimState m) g)
newBinaryIndexedTree n = BIT `liftM` UM.replicate n mempty

queryKey :: (PrimMonad m, U.Unbox g, Group g)
         => Int
         -> BinaryIndexedTree (PrimState m) g
         -> m g
queryKey key (BIT bit) = go key mempty
  where
    go !i !res
      | i >= 0 = UM.unsafeRead bit i >>= go ((i .&. (i + 1)) - 1) . (<> res)
      | otherwise = return res
{-# INLINE queryKey #-}

queryRange :: (PrimMonad m, U.Unbox g, Group g)
           => Int
           -> Int
           -> BinaryIndexedTree (PrimState m) g
           -> m g
queryRange 0 r bit = queryKey r bit
queryRange l r bit = (mappend.invert) `liftM` queryKey (l - 1) bit `ap` queryKey r bit
{-# INLINE queryRange #-}

updateKey :: (PrimMonad m, U.Unbox g, Group g)
          => Int
          -> g
          -> BinaryIndexedTree (PrimState m) g
          -> m ()
updateKey key !x (BIT bit) = go key
  where
    !n = UM.length bit
    go !i = when (i < n) $ do
      UM.unsafeRead bit i >>= UM.unsafeWrite bit i . (<> x)
      go $ i .|. (i + 1)
{-# INLINE updateKey #-}

Measured memory_bytes: 16332
import java.util.Scanner;

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

        Scanner s = new Scanner(System.in);
        int a = s.nextInt(), b = s.nextInt();

        if ((a * b) % 2 == 0) {
          System.out.println("Even");
        } else {
          System.out.println("Odd");
        }
    }
}


Measured memory_bytes: 21844
using System;

namespace abc045_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            string b = Console.ReadLine();
            string c = Console.ReadLine();
            bool A = true;
            bool B = true;
            bool C = true;
            char now = 'a';
            while (A && B && C)
            {
                switch (now)
                {
                    case ('a'):
                        {
                            if (a.Length <= 0)
                            {
                                A = false;
                                break;
                            }
                            now = a[0];
                            a = a.Substring(1, a.Length - 1);
                            break;
                        }
                    case ('b'):
                        {
                            if (b.Length <= 0)
                            {
                                B = false;
                                break;
                            }
                            now = b[0];
                            b = b.Substring(1, b.Length - 1);
                            break;
                        }
                    case ('c'):
                        {
                            if (c.Length <= 0)
                            {
                                C = false;
                                break;
                            }
                            now = c[0];
                            c = c.Substring(1, c.Length - 1);
                            break;
                        }
                }
            }
            if (!B)
            {
                Console.WriteLine("B");
            }
            else if (!C)
            {
                Console.WriteLine("C");
            }
            else
            {
                Console.WriteLine("A");
            }
        }
    }
}

Measured memory_bytes: 2648
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(H, W):
    if min(H, W) == 1:
        return 1
    return -(-(H*W)//2)


def main():
    H, W = read_int_n()
    print(slv(H, W))


if __name__ == '__main__':
    main()


Measured memory_bytes: 7868
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define EB emplace_back
#define MP make_pair
#define all(o) (o).begin(), (o).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define fr(i,n) for(lli i=0;i<n;++i)
#define rep(i,a,b) for(lli i=a;i<=b;++i)
#define per(i,a,b) for(lli i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b))) 
#define sz(x) (lli)(x).size()
#define endl '\n'
typedef long long lli;        typedef long double ld;
typedef pair<lli,lli> ii;     typedef vector<lli> vi;
typedef vector<ii> vii;       typedef vector<vi> graph;
long long MOD=1000000007;     long double EPS=1e-9;
#define debarr(a,n) cout<<#a<<" : ";for(int i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debmat(mat,row,col) cout<<#mat<<" :\n";for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const unordered_set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const unordered_map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
lli binpow(lli b,lli p,lli mod){lli ans=1;b%=mod;for(;p;p>>=1){if(p&1)ans=ans*b%mod;b=b*b%mod;}return ans;}

void pre(){

}

void solve(){
	lli n,k;
	cin>>n>>k;
	lli arr[n+k+1];
	fr(i,n)cin>>arr[i];
	lli dp[n+k+1];
	fr(i,n+1)dp[i]=MOD*MOD;
	dp[0]=0;
	rep(i,0,n-1){
		rep(j,1,k){
			remin(dp[i+j],dp[i]+abs(arr[i]-arr[i+j]));
		}
	}
	cout<<dp[n-1]<<endl;
}

signed main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("in.txt","r",stdin);//freopen("out.txt","w",stdout);
	pre();lli t=1;//cin>>t;
	for(lli i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}


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

int main(){
    string S;
    string text = "";
    cin >> S;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == 'B' && text.size() != 0){
            // text.size()-1 番目以降の文字を1文字削除
            text.erase(text.size()-1,1);
        } else if(S[i] != 'B'){
            text += S[i];
        }
    }
    cout << text << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
char str[12];
int main()
{
	scanf("%s",&str);
	int n=strlen(str);
	ll ret=0;
	for(int S=0;S<1<<(n-1);S++)
	{
		ll now=0;
		ll sum=0;
		for(int i=0;i<n;i++)
		{
			now*=10LL;
			now+=str[i]-'0';
			if(i<n-1&&(S>>i&1))
			{
				sum+=now;
				now=0;
			}
		}
		sum+=now;
		ret+=sum;
	}
	printf("%lld\n",ret);
	return 0;
}


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

#define _USE_MATH_DEFINES
#define pb  push_back

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

const ll INF = 999999999;
const ll atcoder = 1000000007;
const int dx[4] = { 1 , 0 , -1 ,0 };
const int dy[4] = { 0 , 1 , 0 , -1 };

int main() {

	int n;
	cin >> n;
	ll a, b;
	ll ans = 0;
	ll maxa = 0;

	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		if (a > maxa) {
			ans = a + b;
			maxa = a;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	int n, m, l, r;
	scanf("%d %d", &n, &m);
	int e[n + 1], cur = 0, ans = 0;
	fill(e, e + n + 1, 0);
	for (int i = 0; i < m; i++){
		scanf("%d %d", &l, &r);
		e[l - 1]++;
		e[r]--;
	}
	for (int i = 0; i <= n; i++){
		cur += e[i];
		if (cur == m) ans++;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e3+100;
const int inf=0x3f3f3f3f;
typedef pair<ll,int>P;

ll dp[maxn][maxn];
ll num[maxn];
ll dist(int x,int y){
    if(x<y)
        return dp[x][y];
    return dp[y][x];
}
int main(){
    int n,x,y;
    scanf("%d%d%d",&n,&x,&y);
    for(int i=1;i<=n;i++){
        for(int j=i;j<=n;j++)
            dp[i][j]=j-i;
    }
    if(y<x)
        swap(x,y);
    dp[x][y]=1;
    for(int i=1;i<=n;i++){
        for(int j=i;j<=n;j++)
            {
                dp[i][j]=min(dp[i][j],dist(i,x)+1+dist(y,j));
                num[dp[i][j]]++;
            }
    }
    for(int i=1;i<n;i++)
        printf("%lld\n",num[i]);

}


Measured memory_bytes: 33024
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int INF = 2000000000;


void solve(){

	//  éðóÔÅà¯éÅ¬Ô
	int n;
	while(cin >> n && n != 0){
		int dp[1 << 16];
		int scores[17][17];
	
		for(int i = 0; i < n; i++){
			for(int j = 0; j <= n; j++){
				cin >> scores[i][j];
			}
		}

		fill(dp,dp+(1<<16),INF);

		// ÅÉ_WðUª·éê
		for(int i = 0; i < n; i++){
			dp[1 << i] = scores[i][0];
		}
		
		// ªóÔ©çSÌóÔðvZiQ»®ðpj
		for(int s = 3; s < (1 << n); s++){
			// jrbgÚªtrueÈçAvZ
			for(int j = 0; j < n; j++){
				if((s >> j) & 1){
					int sc = scores[j][0];
					for(int i = 0; i < n; i++){
						if(((s >> i) & 1) && i != j){
							sc = min(sc,scores[j][i+1]);
						}
					}
					// JÚµÄ­é±ÆªÅ«é©Ç¤©
					if(dp[(s & ~(1 << j))] != INF){
						dp[s] = min(dp[s],dp[(s & ~(1 << j))] + sc);
					}
				}
			}
		}
		cout << dp[(1 << n) - 1] << endl;
	}
}

int main(){
	
	solve();

	return 0;
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

typedef struct {
	vector <int> to;
	int cost;
	bool is_visited;
} edge;
int main( void ){
	int N, A, B;
	cin >> N >> A>> B;
	int lim = A+B;
	int cnt = 0, b_cnt = 0;
	string S; cin >> S;
	rep(i,0,N){
		if (S[i] == 'a'){
			if (cnt < lim){
				cnt++;
				cout << "Yes\n";
				continue;
			}
		}
		else if (S[i] == 'b'){
			if (cnt < lim && b_cnt < B){
				cnt++;b_cnt++;
				cout << "Yes\n";
				continue;
			}
		}
		cout << "No\n";
	}
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 896
package main

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

func main() {
	A := nextInt64()
	B := nextFloat64()
	b := int64(B*100 + 0.001)
	fmt.Println((A * b) / 100)
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextFloat64() float64 {
	v, _ := strconv.ParseFloat(nextReader(), 64)
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func Max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Min(s, v)
	}
	return s
}

func MaxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Max(s, v)
	}
	return s
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


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

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> a(q);
  for(int i=0; i<q; i++)
    cin >> a.at(i);
  
  vector<int> s(n);
  for(int i=0; i<q; i++) {
    s.at(a.at(i)-1) ++;
  }
  
  for(int i=0; i<n; i++) {
    if(s.at(i) + k - q > 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 200005;

int n, v1, v2, x, q, A[MAXN];
vector<vector<int>> G;

void dfs_traversal(int v, int p, int cur) {
    for (int c : G[v]) {
        if (c != p) {
            dfs_traversal(c, v, cur + A[v]);
        }
    }

    A[v] += cur;
}

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

    G.resize(n);

    for (int i = 0; i < n - 1; i++) {
        scanf("%d%d", &v1, &v2);
        G[v1 - 1].push_back(v2 - 1);
        G[v2 - 1].push_back(v1 - 1);
    }

    while (q--) {
        scanf("%d%d", &v1, &x);
        A[v1 - 1] += x;
    }

    dfs_traversal(0, -1, 0);

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

    printf("\n");

    return 0;
}


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

int main(){
    int n, ans = 0;
    cin >> n;

    for(int i = 1; i <= n; ++i){
      string s = to_string(i);
      if(s.size() % 2 == 1)  ++ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
using namespace std;
int main(){
	int d,n,i,i2,i3,dp[200][200],t[200],a[200],b[200],c[200],tk[200][200],max=0;
	cin>>d>>n;
	for(i=0;i<200;i++){
		for(i2=0;i2<200;i2++){
			dp[i][i2]=0;
			tk[i][i2]=0;
		}
	}
	for(i=0;i<d;i++){
		cin>>t[i];
	}
	for(i=0;i<n;i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	for(i=0;i<d;i++){
		for(i2=0;i2<n;i2++){
			if(a[i2]<=t[i]&&t[i]<=b[i2]){
				tk[i][i2]=1;
			}
		}
	}
	for(i=0;i<d-1;i++){
		for(i2=0;i2<n;i2++){
			if(tk[i][i2]==1){
				for(i3=0;i3<n;i3++){
					if(tk[i+1][i3]==1){
						if(dp[i+1][i3]<dp[i][i2]+abs(c[i2]-c[i3])){
							dp[i+1][i3]=dp[i][i2]+abs(c[i2]-c[i3]);
						}
					}
				}
			}
		}
	}
	for(i=0;i<n;i++){
		if(max<dp[d-1][i]){
			max=dp[d-1][i];
		}
	}
	/*
	for(i=0;i<d;i++){
		for(i2=0;i2<n;i2++){
			cout<<dp[i][i2]<<' ';
			if(dp[i][i2]<10){
				cout<<' ';
			}
		}
		cout<<endl;
	}*/
	cout<<max<<endl;
}

Measured memory_bytes: 3384
// Template
#pragma region r1
#include "bits/stdc++.h"
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003LL;
template <typename T>
inline bool chmin(T &x, const T &y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}
template <typename T> 
inline bool chmax(T &x, const T &y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}
struct IOSET {
    IOSET() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(10);
    }
} ioset;
#pragma endregion

// Main Code
int main() {
    int h, w, n, sr, sc;
    cin >> h >> w >> n >> sr >> sc;
    --sr; --sc;
    string s, t;
    cin >> s >> t;

    int a = 0, b = h, c = 0, d = w;
    per(i, n) {
        if (t[i] == 'L') d = min(d + 1, w);
        if (t[i] == 'R') c = max(c - 1, 0);
        if (t[i] == 'U') b = min(b + 1, h);
        if (t[i] == 'D') a = max(a - 1, 0);
        if (s[i] == 'L') c = min(c + 1, w);
        if (s[i] == 'R') d = max(d - 1, 0);
        if (s[i] == 'U') a = min(a + 1, h);
        if (s[i] == 'D') b = max(b - 1, 0);
        if (a == b || c == d) {
            cout << "NO\n";
            return 0;
        }
    }
    if (a <= sr && sr < b && c <= sc && sc < d) cout << "YES\n";
    else cout << "NO\n";
}

Measured memory_bytes: 4012
#include<stdio.h>
#include<stdlib.h>
int main(void){
  int i,*arr,num,min,max;
  scanf("%d",&num);
  arr = (int*)malloc(sizeof(int)*num);
  for(i=0;i<num;i++) scanf("%d",&arr[i]);
  max = arr[1]-arr[0];
  min = arr[0];
  for(i=1;i<num;i++){
    if(arr[i]-min > max) max = arr[i]-min;
    if(min > arr[i]) min = arr[i];
  }
  
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 1380
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=1000000007;
ll MOD=998244353;
int inf=1000001000;
ll INF=100000000000000000;

#define Int long long
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;}
 
 
template <typename E>
struct SegmentTree{
  using H = function<E(E,E)>;
  Int n,height;
  H h;
  E ei;
  vector<E> laz;
 
  SegmentTree(H h,E ei):h(h),ei(ei){}
 
  void init(Int n_){
    n=1;height=0;
    while(n<n_) n<<=1,height++;
    laz.assign(2*n,ei);
  }
 
  inline void propagate(Int k){
    if(laz[k]==ei) return;
    laz[(k<<1)|0]=h(laz[(k<<1)|0],laz[k]);
    laz[(k<<1)|1]=h(laz[(k<<1)|1],laz[k]);
    laz[k]=ei;
  }
 
  inline void thrust(Int k){
    for(Int i=height;i;i--) propagate(k>>i);
  }
 
  void update(Int a,Int b,E x){
    thrust(a+=n);
    thrust(b+=n-1);
    for(Int l=a,r=b+1;l<r;l>>=1,r>>=1){
      if(l&1) laz[l]=h(laz[l],x),l++;
      if(r&1) --r,laz[r]=h(laz[r],x);
    }
  }
 
  E get_val(Int a){
    thrust(a+=n);
    return laz[a];
  }
 
  void set_val(Int a,E x){
    thrust(a+=n);
    laz[a]=x;
  }
};
 
//INSERT ABOVE HERE

int main() {
    ll n,m;
    cin >> n >> m;
    auto h=[&](ll x,ll y){return min(x,y);};
  const ll INF = 1e18;
  SegmentTree<ll> seg(h,INF);
  seg.init(n);
  seg.set_val(0,0);
  vector<ll> l(m),r(m),c(m);
  vector<vector<ll>> G(n+1,vector<ll>(0)); 
  rep(i,m){
      cin >> l[i] >> r[i] >> c[i];
      G[--l[i]].push_back(i);
  }
  rep(i,n){
      ll d=seg.get_val(i);
      for (ll j:G[i]) seg.update(l[j],r[j],d+c[j]);
  }
  ll ans=seg.get_val(n-1);
  if (ans>=INF) ans=-1;
  cout << ans << endl;
}


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

int main()
{
    int a,b,c,d,area,area2;
    cin>>a>>b>>c>>d;
    area= a * b ;
    area2= c * d ;
    if(area>area2)
    printf("%d",area);
    else
    printf("%d",area2);
    
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

constexpr ll INF = 1e16;
constexpr ll INM = 114514;
constexpr ll MOD = 1e9 + 7;
constexpr ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n;
	cin >> n;
	dump(n * n * n);
	return 0;
}


Measured memory_bytes: 256
// 2012/10/25 Tazoe

#include <iostream>
using namespace std;

char F[102][102];

void dfs(int Y, int X, char C)
{
	if(F[Y][X]!=C)
		return;

	F[Y][X] = 0;

	dfs(Y-1, X, C);
	dfs(Y, X+1, C);
	dfs(Y+1, X, C);
	dfs(Y, X-1, C);
}

int main()
{
	while(true){
		int H, W;
		cin >> H >> W;

		if(H==0&&W==0)
			break;

		for(int y=1; y<=H; y++){
			for(int x=1; x<=W; x++){
				cin >> F[y][x];
			}
		}

		int cnt = 0;
		for(int y=1; y<=H; y++){
			for(int x=1; x<=W; x++){
				if(F[y][x]!=0){
					cnt++;
					dfs(y, x, F[y][x]);
				}
			}
		}

		cout << cnt << endl;
	}

	return 0;
}

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

long long a, b, mn = 1e9;
int main() {
	long long i, j;
	cin>>a>>b;
	for(i=a; i<=min(a+2019, b); i++) for(j=i+1; j<=min(a+2019, b); j++) {
		mn = min(mn, i * j % 2019);
	}
	cout<<mn;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>
 
using namespace std;

const int nmax = 8;

bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]){

    bool all_visited = true;

    for(int i = 0; i < N; i++){
        if(visited[i] == false){
            all_visited = false;
        }
    }

    if(all_visited){
        return 1;
    }

    int ret = 0;

    for(int i = 0; i < N; i++){
        if(graph[v][i] == false) continue;
        if(visited[i]) continue;

        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }

    return ret;
}

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

    for(int i = 0; i < M; i++){
        int A, B;
        cin >> A >> B;
        graph[A-1][B-1] = graph[B-1][A-1] = true;
    }

    bool visited[nmax];
    for(int i = 0; i < N; i++){
        visited[i] = false;
    }

    visited[0] = true;

    cout << dfs(0, N, visited) << endl;

    return 0;
}

Measured memory_bytes: 256
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var mod = 1e9+7;
function mul(){for(var a=arguments,r=a[0],i=a.length;--i;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i])%mod;return r;}

console.log(main());
function main(){
  var n = o.a();
  var a = o.l();
  var ans = 1;
  var id = xArray(0,n+1);
  id[0] = 3;
  for(var i = 0; i < n; i++){
    if(id[a[i]] === 0)return 0;
    ans = mul(ans,id[a[i]]);
    id[a[i]]--, id[a[i]+1]++;
  }
  return ans;
}

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

void fillField(char *s,int line,int pos){
	if(line<0||line>=12||pos<0||pos>=12) return;
	if(*(s+line*13+pos)!='1') return;
	*(s+line*13+pos)='2';
	fillField(s,line+1,pos);
	fillField(s,line-1,pos);
	fillField(s,line,pos+1);
	fillField(s,line,pos-1);
}

int main(void){
	char *field = malloc(12*13*sizeof(char));
	do{
		int i,j;
		for(i=0;i<12;++i){
			scanf("%s%*c",field+13*i);
		}
		int islands = 0;
		for(i=0;i<12;++i){
			for(j=0;j<12;++j){
				if(*(field+13*i+j)=='1'){
					++islands;
					fillField(field,i,j);
				}
			}
		}
		printf("%d\n",islands);
	}while(scanf("%*c")!=EOF);
	free(field);
	return 0;
}

Measured memory_bytes: 588
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: f64, m: f64, d: usize,
    }

    let ans = if d == 0 {
        (m - 1.0) / n
    } else {
        (m - 1.0) * 2.0 * (n - d as f64) / (n * n)
    };
    println!("{}", ans);
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define mp make_pair
#define ld long double
#define ull unsigned long long int
#define mod 1000000007
ll n,a[100009],b[100009],c[100009],dp[100009][5];
ll recurs(ll pos,ll last)
{
	if(dp[pos][last]!=-1) return dp[pos][last];
	if(pos>n) return 0;
	ll max1=-1;
	for (int i = 1; i <=3; ++i)
	{
		if(i==last) continue;
		if(i==1)
		max1=max((a[pos]+recurs(pos+1,1)),max1);
		if(i==2)
		max1=max((b[pos]+recurs(pos+1,2)),max1);
		if(i==3)
		max1=max((c[pos]+recurs(pos+1,3)),max1);
	}
	dp[pos][last]=max1;
	return max1;
}
int main()
{
    ios_base::sync_with_stdio(false);//this works only
    cin.tie(NULL);// when first all inputs are from user
    cout.tie(NULL);//you will see all outputs afterwards
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for (int i = 1; i <=n; ++i)
    {
    	cin>>a[i]>>b[i]>>c[i];
    }
    ll ans=recurs(1,-1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 14336
#include<stdio.h>
int main()
{
    int x,a,b;
    scanf("%d%d%d",&x,&a,&b);
    if(b<=a)
		printf("delicious\n");
	else if(b<=(a+x))
		printf("safe\n");
	else if(b>(x+a))
		printf("dangerous\n");
    return 0;
}

Measured memory_bytes: 1644
function main(S) {
    var S = S.trim();
    var squares = Array(S.length).fill(0);
    var rightIndex = 0;
    var leftIndex = 0;
    for (var i = 0; S.length > i; i++) {
        var j = i;
        var count = 0;

        if (S[j] === "R") {
            if (j < rightIndex) {
                j = rightIndex;
                count = j - i;
            }
        } else {
            if (j > leftIndex) {
                j = leftIndex;
                count = i - j;
            }
        }

        while (S[j] + S[j+1] !== "RL") {
            if (S[j] === "R") {
                j++;
            } else {
                j--;
            }

            count++;
        }

        if (j >= i) rightIndex = j;
        if (i >= j) leftIndex = j;

        var point = (count % 2) === 0 ? j : j + 1;
        squares[point] += 1;
    }

    console.log(squares.join(" "));
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15308