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

using namespace std;

#define MAX_N 15
#define MAX 2200
#define OFFSET 1100
typedef pair<int, int> pii;

class Dice {
  private:
    void roll(int a, int b, int c, int d)
    {
        swap(v[a], v[b]);
        swap(v[b], v[d]);
        swap(v[c], v[d]);
    }
    
  public:
    int v[6], x, y;
    string order;
    void roll_B() { roll(0, 1, 4, 5); }
    void roll_R() { roll(0, 3, 2, 5); }
    void roll_F() { roll(0, 4, 1, 5); }
    void roll_L() { roll(0, 2, 3, 5); }
};

int bit[MAX][MAX];

void rot(int x, Dice &d)
{
    bit[d.y][d.x] |= (1<<x);
    for (auto &c: d.order) {
        if (c == 'L') {
            c = 'R';
            d.roll_L();
            d.x--;
        } else if (c == 'F') {
            c = 'B';
            d.roll_F();
            d.y--;
        } else if (c == 'R') {
            c = 'L';
            d.roll_R();
            d.x++;
        } else {
            c = 'F';
            d.roll_B();
            d.y++;
        }
        bit[d.y][d.x] |= (1<<x);
    }
    reverse(d.order.begin(), d.order.end());
}

int get_cost(int S, Dice d)
{
    int res = 0;
    set<pii> used;
    if ((bit[d.y][d.x] & S) == 0) {
        used.insert(pii(d.y, d.x));
        res += d.v[5];
    }
        
    for (auto c: d.order) {
        if (c == 'L') {
            d.x--;
            d.roll_L();
        } else if (c == 'F') {
            d.y--;
            d.roll_F();
        } else if (c == 'R') {
            d.x++;
            d.roll_R();
        } else {
            d.y++;
            d.roll_B();
        }
        
        if (used.count(pii(d.y, d.x)) == 0 && (bit[d.y][d.x] & S) == 0) {
            used.insert(pii(d.y, d.x));
            res += d.v[5];
        }
    }
    return res;
}

int main()
{
    int N;
    while (cin >> N, N) {
        vector<Dice> d(N);
        for (int i = 0; i < N; i++) {
            cin >> d[i].x >> d[i].y;
            d[i].x += OFFSET; d[i].y += OFFSET;
            cin >> d[i].v[3] >> d[i].v[2] >> d[i].v[1];
            cin >> d[i].v[4] >> d[i].v[5] >> d[i].v[0];
            cin >> d[i].order;
        }

        memset(bit, 0, sizeof(bit));
        
        for (int i = 0; i < N; i++) {
            rot(i, d[i]);
        }        
        
        int dp[1<<MAX_N];
        memset(dp, -1, sizeof(dp));

        dp[0] = 0;
        for (int i = 0; i < (1<<N); i++) {
            if (dp[i] == -1) continue;                        
            for (int j = 0; j < N; j++) {
                if (i >> j & 1) continue;
                int ni = i | (1<<j);                
                dp[ni] = max(dp[ni], dp[i] + get_cost(i, d[j]));
            }
        }
        cout << dp[(1<<N)-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 22188
n = int(input())
p = str(input()).split(' ')
p = [int(i) for i in p]
counter = 0

for index in range(2, len(p)):
    if p[index - 2] < p[index - 1] and p[index - 1] < p[index]:
        counter = counter + 1
    elif p[index - 2] > p[index - 1] and p[index - 1] > p[index]:
        counter = counter + 1

print(counter)

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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF 1e9

int W, H;
int start_x, start_y, goal_x, goal_y;
int *ices[12][12];
char maze[12][12];
bool G[12][12];
int depth;
int next_depth;

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

void dfs_count(int *ice, int x, int y) {
    (*ice)++;
    ices[y][x] = ice;
    maze[y][x] = '?'; // used

    REP(i, 4) {
        int sx = x + dx[i], sy = y + dy[i];
        if (0 <= sx && sx < W && 0 <= sy && sy < H) {
            if (maze[sy][sx] == 'X') {
                dfs_count(ice, sx, sy);
            }
        }
    }
}

bool iddfs(int x, int y, int step) {
    if (x == goal_x && y == goal_y) return true;
    int dist = abs(x - goal_x) + abs(y - goal_y);
    if (step + dist > depth) {
        next_depth = min(next_depth, step + dist);
        return false;
    }
    REP(i, 4) {
        int sx = x + dx[i], sy = y + dy[i];
        if (0 <= sx && sx < W && 0 <= sy && sy < H) {
            if (*ices[sy][sx] > 0 && !G[sy][sx]) {
                (*ices[sy][sx])--;
                G[sy][sx] = true;
                if (iddfs(sx, sy, step+1)) return true;
                G[sy][sx] = false;
                (*ices[sy][sx])++;
            }
        }
    }
    return false;
}

int main() {
    while (cin >> W >> H, W|H) {
        REP(y, H) REP(x, W) cin >> maze[y][x];

        int empty = 100000;
        int wall = 0;

        int ice[12][12] = {};

        REP(y, H) REP(x, W) {
            switch (maze[y][x]) {
            case '.':
                ices[y][x] = &empty;
                break;
            case '#':
                ices[y][x] = &wall;
                break;
            case 'S':
                start_x = x;
                start_y = y;
                ices[y][x] = &empty;
                break;
            case 'G':
                goal_x = x;
                goal_y = y;
                ices[y][x] = &empty;
                break;
            case 'X': {
                dfs_count(&ice[y][x], x, y);
                ice[y][x] /= 2;
                ices[y][x] = &ice[y][x];
                break;
            }
            }
            maze[y][x] = '?'; // used
        }

        fill_n((bool *)G, 12*12, false);
        depth = abs(start_x - goal_x) + abs(start_y - goal_y);
        while (!iddfs(start_x, start_y, 0)) {
            depth = next_depth;
            next_depth = INF;
        }
        cout << depth << endl;
    }
}

Measured memory_bytes: 1164
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            var n = int.Parse(ReadLine());

            int[] d = ReadLine().Split(' ').Select(int.Parse).ToArray();

            Array.Sort(d);

            int tmp = Abs(d[n / 2 - 1] - d[n / 2]);

            WriteLine(tmp);

        }
    }
}


Measured memory_bytes: 18016
import itertools

N,M,R = map(int,(input().split()))
r = list(map(lambda x:int(x)-1,(input().split())))

dist = [[float("inf")]*N for _ in range(N)]

for i in range(M):
    a,b,c = map(int,(input().split()))
    dist[a-1][b-1] = c
    dist[b-1][a-1] = c
for i in range(N):
    dist[i][i] = 0

def warshall_floyd(d):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j],d[i][k]+d[k][j])
    return d

dist = warshall_floyd(dist)

min_ans = float("inf")
for perm in itertools.permutations(r):
    ans = 0
    for i in range(len(r)-1):
        ans += dist[perm[i]][perm[i+1]]
    min_ans = min(ans,min_ans)

print(min_ans)

Measured memory_bytes: 59480
def b(M,x,y,n=1):
 M[x][y]=0;t=[]
 if M[x-1][y]:t+=[b(M,x-1,y,n+1)]
 if M[x][y-1]:t+=[b(M,x,y-1,n+1)]
 if M[x+1][y]:t+=[b(M,x+1,y,n+1)]
 if M[x][y+1]:t+=[b(M,x,y+1,n+1)]
 M[x][y]=1
 return max([n]+t)
for e in iter(input,'0'):
 n,m=int(e),int(input())
 P=[[0]*(n+2)for _ in[0]*(m+2)]
 for i in range(m):P[i+1][1:-1]=map(int,input().split())
 print(max(b(P,i,j)for i in range(1,m+1)for j in range(1,n+1)if P[i][j]))


Measured memory_bytes: 5732
#include <bits/stdc++.h>
using namespace std;
#define forn(i,a,b) for(int i=a; i<b; ++i)
typedef long long int ll;
    
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n, a[105];
    cin >> n;
    
    for (int i = 0; i<  n; i++) cin >> a[i];
    sort(a,a+n);
    
    cout << a[n-1] - a[0] << endl;
    
    return 0;
}

Measured memory_bytes: 256
lines = STDIN.read.split("\n")
lines.each do |line|
  h, w = line.split(" ").map(&:to_i)
  break if h == 0 && w == 0
  puts "#" * w
  (h - 2).times do |i|
    puts ["#", "." * (w - 2), "#"].join('')
  end
  puts "#" * w
  print "\n"
end

Measured memory_bytes: 8872
#include<stdio.h>
#include<math.h>
int main(void){
    int X, Y;
    double d, a, x, y, k, n = 1;
    x = y = 0;
    k = 90;
    scanf("%lf,%lf", &d, &a);
    while ( n ) {
        x -= d * cos(k * 3.1415926535 / 180.0 );
        y += d * sin(k * 3.1415926535 / 180.0 );
        k += a;
        /*printf("x:%lf y:%lf\n", -x, y);*/
        scanf("%lf,%lf", &d, &a);
        if ( d == 0 && a == 0 ) n = 0;
    }
    X = x; Y = y;
    printf("%d\n%d\n", X, Y);
    return 0;
}

Measured memory_bytes: 2004
#include <stdio.h>
int main(void){
      int a[1000],i,n;
      scanf("%d", &n);
      for(i=0; i<n; i++) {
          scanf("%d", &a[i]);
      }
      for(i =n-1; i>=1; i--) {
          printf("%d ", a[i]);
      }
      printf("%d\n",a[0]); 
      return 0;
}



Measured memory_bytes: 2144
import itertools
N = int(input())
num = [i for i in range(1,N+1)]
num_list = list(itertools.permutations(num))
ser_A = tuple(map(int,input().split()))
ser_B = tuple(map(int,input().split()))
A = 0
B = 0
for i in range(len(num_list)):
	if(num_list[i] == ser_A ):
		A = i+1
	if(num_list[i] == ser_B ):
		B = i+1
print(abs(A-B))

Measured memory_bytes: 8052
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()
	c := nextInt()

	a5 := 0
	a7 := 0
	if a == 5 {
		a5++
	} else if a == 7 {
		a7++
	}

	if b == 5 {
		a5++
	} else if b == 7 {
		a7++
	}

	if c == 5 {
		a5++
	} else if c == 7 {
		a7++
	}

	if (a5 == 2) && (a7 == 1) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;

int main(){
  int h,w;
  cin >> h >> w;
  string c[h];
  rep(i,h){
    cin >> c[i];
    cout << c[i] << endl;
    cout << c[i] << endl;
  }
  
  return 0;
}

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

using namespace std;

int main(void) {
  int N, M, K;
  cin >> N >> M >> K;
  vector<long long> A, B;

  long long n;
  A.push_back(0);
  for (int i = 0; i < N; i++) {
    cin >> n;
    A.push_back(n + A[i]);
  }

  B.push_back(0);
  for (int i = 0; i < M; i++) {
    cin >> n;
    B.push_back(n + B[i]);
  }

  int al = 0, ar = N, bl = 0, br = N, ai;
  if (A[al] > K) {
    ai = al;
  } else if (A[ar] <= K) {
    ai = ar;
  } else {

    while (ar - al != 1) {
      if (A[(al + ar) / 2] <= K) {
        al = (al + ar) / 2;
      } else {
        ar = (al + ar) / 2;
      }
    }
    ai = al;
  }
  int ans = 0, bi = 0;
  for (int i = ai; i >= 0; --i) {

    while (bi != M && B[bi+1] + A[i] <= K) bi++;
    ans = max(bi + i, ans);
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7992
#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; cin >> N;
    string S; cin >> S;

    int ans = 1;

    for (int i = 1; i < N; i++){
        if(S[i] != S[i-1])ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
S = input()

odd = True
yes = True

for s in S:
    if odd:
        if s == "L":
            yes = False
            break
        odd = False
    else:
        if s == "R":
            yes = False
            break
        odd = True

# print(S)

if yes:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

int main(){
  int i,j,n;
  unsigned int ans,x;

  while(1){
    map<unsigned int,int> a;
    cin >> n;
    if(n == 0) break;
    ans = 0;
    for(i=0;i<n;i++){
      cin >> x;
      a[x]++;
      if(a[x] > n/2) ans = x;
    }

    if(ans == 0) cout << "NO COLOR" << endl;
    else cout << ans << endl;
    

  }
  return 0;
}

Measured memory_bytes: 1944
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
int main() {
    int A, B, K;
    cin >> A >> B >> K;
    set<int> ans;
    for (int i = A; i < A + K && i <= B; i++) ans.insert(i);
    for (int i = max(A, B - K + 1); i <= B; i++) ans.insert(i);
    for (auto i : ans) cout << i << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int i;
	cin >> i;
	i = 1 - i;
	cout << i << endl;

	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
 int main(){
 int N, X, m[101];
 cin >> N >> X;
 int S = 0, M = 1001001001;
 for(int i = 0; i < N; ++i){
 cin >> m[i];
 S += m[i];
 if(m[i] < M){
 M = m[i];
 }
 }
 int ans = N + (X - S) / M;
 cout << ans << endl;
 }


Measured memory_bytes: 256
import java.io.InputStreamReader;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.*;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.InputStream;
import static java.lang.Math.*;

public class Main {

    public static void main(String[] args) {
        final String[] tasks = new String[]{"D","C","B","A"};
        for(final String task:tasks) {
            try {
                Class ca = Main.class.getClassLoader().loadClass(task);
                if (ca.getField("on").getInt(null) == 1) {
                    Object aTask = ca.newInstance();
                    Method m = ca.getMethod("S", null);
                    m.invoke(aTask, null);
                }
            } catch (Exception ex) { }
        }
    }

}

class A {
    public static int on = 1;

    public void run(){
        int n = ni();
        int a = ni();
        int sy = n%500;
        if(a>=sy){
            pl("Yes");
        }else{
            pl("No");
        }




    }
    private InputReader in =  new InputReader(System.in);
    private PrintWriter out = new PrintWriter(System.out);
    public void S(){run();out.close(); }
    public int ni(){return Integer.parseInt(in.ns());}
    public long nl(){return Long.parseLong(in.ns());}
    public String ns(){return in.ns();}
    public void p(Object obj){out.print(obj);}
    public void ps(Object obj){p(obj);p(" ");}
    public void pl(Object obj){out.println(obj);}
    public int gcd(int a,int b){ while( b != 0 ) { int t = a % b;a = b;b = t; } return a; }
}

class B {
    public static int on = 0;

    public void run(){

    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String ns() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

}





Measured memory_bytes: 20692
import Data.List

main::IO()
main = do
    n <- readLn::IO Int
    xs <-map read . words <$> getLine::IO [Integer] 
    print $ (query . group . sort) xs


query::[[Integer]] -> Integer
query[] = 0
query (x:xs) = if x!!0 == fromIntegral(length x) then (0 + query xs) else (addOrSub x + query xs)  

addOrSub::[Integer] -> Integer
addOrSub x = case fromIntegral(length x) <= x!!0 of
                  -- eg.7 7 7 7 7
                 True -> fromIntegral (length x)
                 False -> fromIntegral(length x) - (x!!0)


Measured memory_bytes: 43388
#include <stdio.h>

#define house 4
#define floor 3
#define room 10

int main()
{
  short people[house][floor][room] = {0};
  short n;

  fscanf(stdin, "%hd", &n);

  short i, b, f, r, v;
  for (i = 0; i < n; i++) {
    fscanf(stdin, "%hd %hd %hd %hd", &b, &f, &r, &v);
    people[b - 1][f - 1][r - 1] += v;
  }
    
  short j, k;
  for (i = 0; i < house; i++) {
    for (j = 0; j < floor; j++) {
      for (k = 0; k < room; k++) {
	if (k < room) {
	  putchar(' ');
	}
	fprintf(stdout, "%hd", people[i][j][k]);
      }
      putchar('\n');
    }
    if (i < house - 1) {
      fprintf(stdout, "####################\n");
    }
  }
    
  return 0;
}

Measured memory_bytes: 616
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=1e5+10;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> void chkmax(T &a,T b) { a<b?a=b:0; };
template<typename T> void chkmin(T &a,T b) { a>b?a=b:0; };
int n,a[N];
map<int,int> cnt0,cnt1;
vector<pii> v0,v1;
int main() {
    cin>>n;
    for(int i=1;i<=n;i++) a[i]=gi();
    for(int i=1;i<=n;i+=2) cnt1[a[i]]++;
    for(int i=2;i<=n;i+=2) cnt0[a[i]]++;
    for(pii x:cnt0) v0.pb(mp(x.se,x.fi));
    for(pii x:cnt1) v1.pb(mp(x.se,x.fi));
    sort(v0.begin(),v0.end(),greater<pii>());
    sort(v1.begin(),v1.end(),greater<pii>());
    if(v0[0].se!=v1[0].se) printf("%d\n",n-v0[0].fi-v1[0].fi);
    else {
        int ans=0;
        if(sz(v0)>1) ans=max(ans,v0[1].fi+v1[0].fi);
        if(sz(v1)>1) ans=max(ans,v0[0].fi+v1[1].fi);
        if(sz(v0)==1&&sz(v1)==1) ans=max(ans,n>>1);
        printf("%d\n",n-ans);
    }
    return 0;
}


Measured memory_bytes: 6520
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int x = sc.nextInt();
        double ans = t * 1.0 / x;
        System.out.println(ans);
    }
}

Measured memory_bytes: 25300
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int p, q, r;

    cin >> p >> q >> r;

    cout << p + q + r - max({p, q, r}) << endl;
}

Measured memory_bytes: 256
n=int(input())
s=list(input())

def Z_algorithm(s):
  N=len(s)
  Z_alg=[0]*N
  Z_alg[0]=N
  i=1
  j=0
  while i<N:
    while i+j<N and s[j]==s[i+j]:
      j+=1
    Z_alg[i]=j
    if j==0:
      i+=1
      continue
    k=1
    while i+k<N and k+Z_alg[k]<j:
      Z_alg[i+k]=Z_alg[k]
      k+=1
    i+=k
    j-=k
  return Z_alg

ans=[0]
for i in range(n):
  S=s[i:n]
  z=Z_algorithm(S)
  for j in range(len(z)):
    if z[j]<=j:
      ans.append(z[j])
print(max(ans))

Measured memory_bytes: 234996
n=int(input())
a_list=list(map(int,input().split()))
S=sum(a_list)
x=0
ans=10**20
for i in range(n-1):
    x+=a_list[i]
    y=S-x
    temp=abs(x-y)
    ans=min(ans,temp)
print(ans)


Measured memory_bytes: 76880
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

int main() {
	int h, a;
	cin >> h >> a;
	int ans = h / a + 1;
	if(h % a == 0) ans--;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    int A, B, C, res;
    std::cin >> A >> B >> C;
    if ( A == B ) {
        res = C;
    } else if ( B == C ) {
        res = A;
    } else {
        res = B;
    }

    std::cout << res << std::endl;
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

vector<bool> isPrime;

void Eratosthenes(int N){
  isPrime.assign(N+1, true);
  isPrime[0] = isPrime[1] = false;

  for(int i=2; i*i<=N; i++)
    if(isPrime[i])
      for(int j=i; i*j<=N; j++)
        isPrime[i*j] = false;
}

int dp[15][1121] = {};

bool solve() {
  int N, K;

  scanf("%d%d", &N, &K);

  if (N == 0) return false;

  memset(dp, 0, sizeof(dp));

  dp[0][0] = 1;

  for(int i=0; i<=N; i++) {
    if (!isPrime[i]) continue;

    for(int k=K-1; k>=0; k--) {
      for(int j=0; j+i<=N; j++) {
        dp[k+1][j+i] += dp[k][j];
      }
    }
  }

  printf("%d\n", dp[K][N]);

  return true;
}

int main(){

  Eratosthenes(1120);

  while(solve());

  return 0;
}



Measured memory_bytes: 3160
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

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

template <class T>
void read(T &x)
{
	char ch;
	for (ch=getchar();(ch<'0'||ch>'9')&&ch!='-';) ch=getchar();
	x=0;int t=1;if (ch=='-') {ch=getchar();t=-1;}
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	x*=t;
}

char a[100010],b[100010];
int c[100010];

int main()
{
	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	scanf("%s",a+1);int n=strlen(a+1);
	int s=0,m=0;
	for (int i=1;i<=n;i++)
		if (a[i]!='x')
		{
			b[++m]=a[i];c[m]=s;s=0;
		}
		else
			s++;
	c[m+1]=s;
	for (int i=1;i<=m/2;i++) if (b[i]!=b[m+1-i]) {puts("-1");return 0;}
	int ans=0;
	for (int i=1;i<=(m+1)/2;i++) ans+=max(c[i],c[m+2-i])-min(c[i],c[m+2-i]);
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 768
n = int(input())
a = list(map(int,input().split()))
sum = 0
for i in range(n):
   a[i] = a[i] -(i+1)
a.sort()
if n % 2 ==1:
    b = a[(n//2)]
else:
    b = (a[n//2]+a[n//2-1]) //2
for i in range(n):
    sum += abs(a[i]-b)
print(sum)

Measured memory_bytes: 86740
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

a,b = mi()

for i in range(1,1010,1):
    if math.floor(i*0.08) == a and math.floor(i*0.10) == b:
        print(i)
        exit()
print(-1)


Measured memory_bytes: 9180
#include<stdio.h>
int N,M,S[105],G[105],i,j,t,c;
int main()
{
	scanf("%d%d",&N,&M);
	for(i=0;i<M;i++)scanf("%d",G+i);
	for(i=0;i<M;i++)
	{
		for(j=1,c=0;j<=N;j++)
		{
			scanf("%d",&t);
			if(t==G[i])
				S[j]++;
			else
				c++;
		}
		S[G[i]]+=c;
	}
	for(i=1;i<=N;i++)
		printf("%d\n",S[i]);
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <map>

using namespace std;
typedef long long LL;

const int maxn = 550005;
int x[maxn],l[maxn][19],r[maxn][19],n,V;
int dpl[maxn],dpr[maxn],pos[maxn];
bool upd(int &x,int y) {x>y?x=y:0;}
int main()
{
	#ifdef Amberframe
		freopen("agc012e.in","r",stdin);
		freopen("agc012e.out","w",stdout);
	#endif
	scanf("%d %d",&n,&V);
	int k=0;while (V>>k) ++k;++k;
	for (int i=1;i<=n;i++) scanf("%d",&x[i]);
	for (int i=1;i<=n;i++)
	for (int j=0;j<k;j++) {
		if (i==1||x[i]-x[i-1]>(V>>j)) l[i][j]=i;
		else l[i][j]=l[i-1][j];
	}
	for (int i=n;i>=1;i--)
	for (int j=0;j<k;j++) {
		if (i==n||x[i+1]-x[i]>(V>>j)) r[i][j]=i;
		else r[i][j]=r[i+1][j];
	}
	
	int S=((1<<k)-1)^1;
	for (int i=1;i<(1<<k);i+=2) {
		dpl[i]=0;dpr[i]=n+1;
		for (int j=1;j<k;j++)
		if (i>>j&1) {
			dpl[i]=max(dpl[i],r[dpl[i^(1<<j)]+1][j]);
			dpr[i]=min(dpr[i],l[dpr[i^(1<<j)]-1][j]);
		}
	}
	for (int i=1;i<=n+1;i++) pos[i]=n+1;
	for (int i=1;i<(1<<k);i+=2)
		upd(pos[dpl[i]+1],dpr[S^i]-1);
	for (int i=n;i>=1;i--) upd(pos[i],pos[i+1]);
	
	for (int i=1;i<=n;i++)
		printf("%s\n",pos[l[i][0]]<=r[i][0]?"Possible":"Impossible");
	return 0;
}

Measured memory_bytes: 42112
tcd = raw_input()
score = 0
for k, c in enumerate(tcd):
    if k % 2 == 1:
        if c == 'g':
            score += 1
            #print(k, 'plus')
    if k % 2 == 0:
        if c == 'p':
            score += -1
            #print(k, 'minu')
print(score)


Measured memory_bytes: 2692
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;

int main(){

    long long int n,k;

    cin >> n >> k;

    if(n<k)cout << min(n,k-n) << endl;
    else{
        n = n-(n/k)*k;
        cout << min(n,k-n);
    }

}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

void ReadInput(int *inputA, int *inputB, int *inputC, int *inputK)
{
    scanf("%d %d %d %d", inputA, inputB, inputC, inputK);
}

void CountA(int * inputA, int * inputK , int * outputVal)
{
    while(1)
    {
        if(*inputA == 0)
        {
            break;
        }
        else if (*inputK == 0)
        {
            break;
        }
        *inputA = *inputA - 1;
        *inputK = *inputK - 1;
        *outputVal = *outputVal + 1;
        
    }
}

void CountB(int *inputB, int * inputK, int *outputVal)
{
    while(1)
    {
        if(*inputB == 0)
        {
            break;
        }
        else if (*inputK == 0)
        {
            break;
        }
        
        *inputB = *inputB - 1;
        *inputK = *inputK - 1;
        *outputVal = *outputVal + 0;
        
    }
}

void CountC(int *inputC, int * inputK, int *outputVal)
{
    while(1)
    {
        if(*inputC == 0)
        {
            break;
        }
        else if (*inputK == 0)
        {
            break;
        }
        *inputC = *inputC - 1;
        *inputK = *inputK - 1;
        *outputVal = *outputVal + (-1);
        
    }
}

int main(int argc, const char * argv[])
{
    int * inputA = malloc(10*sizeof(int));
    int *inputB = malloc(10*sizeof(int));
    int *inputC = malloc(10*sizeof(int));
    int *inputK = malloc(10*sizeof(int));
    int outputVal = 0;
    int * outputValP = &outputVal;
    
    ReadInput(inputA, inputB, inputC, inputK);
    CountA(inputA,inputK, outputValP);
    CountB(inputB,inputK, outputValP);
    CountC(inputC,inputK, outputValP);
    
    printf("%d \n",outputVal);
    
    return 0;
}


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

int main() {
	int N, ans = 0;
	cin >> N;
	vector<vector<int>> a(10, vector<int>(10));
	for (int i = 1; i <= N; i++) {
		string b = to_string(i);
		a[b.front() - '0'][b.back() - '0']++;
	}
	for (int i = 1; i <= N; i++) {
		string b = to_string(i);
		ans += a[b.back() - '0'][b.front() - '0'];
	}
	cout << ans;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;  
using ll = long long;
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define Rep(i, a, b) for(ll i = a; i <= b; i++)
#define repr(i, a, b) for(ll i = b-1; i >= a; i--)
// #define _GLIBCXX_DEBUG
template <class T> using V = vector<T>;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define sz(v) ((ll)(v).size())
const double pi = acos(-1.0);
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
// #define fi first
// #define se second
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
const int dy2[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dx2[] = {1, 1, 0, -1, -1, -1, 0, 1};
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
 
/*--------------------------------------------------------------------------------
--------------------------------------------------------------------------------*/


const ll max_n = 1 << 23;
const ll ll_max = 2147483647;

ll n, dat[2*max_n - 1];

void init(int n_){
    n = 1;
    while(n < n_) n *= 2;
    for(ll i = 0; i < 2*n - 1; i++) dat[i] = ll_max;
}

void update(ll k, ll a){
    k += n-1;
    dat[k] = a;
    while(k > 0){
        k = (k-1) / 2;
        dat[k] = min(dat[k*2 + 1], dat[k*2 + 2]);
    }
}

ll query(ll a, ll b, ll k, ll l, ll r){
    // cout << "k: " << k << ", l: " << l << ", r: " << r << endl;
    if(r <= a || b <= l) return ll_max;
    if(a <= l && r <= b) return dat[k];
    else{
        ll vl = query(a, b, k*2 + 1, l, (l+r)/2);
        ll vr = query(a, b, k*2 + 2, (l+r)/2, r);
        return min(vl, vr);
    }
}

int main() {
	n = 300500;
    ll n_ = 1;
    while(n_ < n) n_ *= 2;
    n = n_;
    init(n);

    // while(q--){
    //     ll c, x, y; cin >> c >> x >> y;
    //     if(c){
    //         ll ans = query(x, y+1, 0, 0, n);
    //         cout << ans << endl;
    //     }else{
    //         update(x, y);
    //     }
    //     for(int i = 0; i < 10; i++) cout << query(i, i+1, 0, 0, n) << " \n"[i==9];
    // }

	ll N, k;
	cin >> N >> k;
	V<ll> a(N);
	rep(i, 0, N) cin >> a[i];
	ll ans = INF;
	rep(i, 0, N){
		ll dp = query(max(a[i]-k, 0LL), min(a[i]+k+1, n), 0, 0, n); // min
		chmin(dp, 0LL);
		update(a[i], dp-1);
		// for(int i = 0; i < 10; i++) cout << query(i, i+1, 0, 0, n) << " \n"[i==9];
	}
	Rep(i, 0, 300000) chmin(ans, query(i, i+1, 0, 0, n));
	cout << -ans << endl;

    return 0;
}
 

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

int main() {
    int n, k;
    cin >> n >> k;
    vector <int> p(n, -1);
    rep (i, k) {
        int a, b;
        cin >> a >> b;
        p[--a] = --b;
    }
    vector <vector <vector <int>>> dp(n, vector <vector <int>> (3, vector <int> (3, 0)));
    rep (i, 3) rep (j, 3) {
        dp[0][p[0] == -1 ? i : p[0]][p[1] == -1 ? j : p[1]] = 1;
    }

    range (i, 1, n) {
        if (p[i + 1] != -1) {
            rep (j, 3) rep (k, 3) if (p[i + 1] != j || j != k) {
                (dp[i][j][p[i + 1]] += dp[i - 1][k][j]) %= 10000;
            }
        }
        else {
            rep (j, 3) rep (k, 3) rep (l, 3) if (j != k || k != l) {
                (dp[i][j][k] += dp[i - 1][l][j]) %= 10000;
            }
        }
    }

    int cnt = 0;
    rep (i, 3) rep (j, 3) (cnt += dp[n - 2][i][j]) %= 10000;
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3172
n,k=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n-1)]
connection=[[] for i in range(n)]
for i in range(n-1):
  connection[l[i][0]-1].append(l[i][1]-1)
  connection[l[i][1]-1].append(l[i][0]-1)
mod=10**9+7

def bfs(v):
  child=[0]*n
  next=[v]
  next2=set()
  visited=[-1]*n
  visitct=0
  while len(next)!=0 and visitct!=n:
    for i in range(len(next)):
      if visited[next[i]]==-1:
        visited[next[i]]=1
        visitct+=1
        for j in range(len(connection[next[i]])):
          if visited[connection[next[i]][j]]==-1:
            child[next[i]]+=1
            next2.add(connection[next[i]][j])
    next=list(next2)
    next2=set()
  return child

child=bfs(0)
ans=k
for i in range(n):
  if i==0:
    for j in range(k-1,k-1-child[i],-1):
      ans*=j
      ans%=mod
  else:
    for j in range(k-2,k-2-child[i],-1): 
      ans*=j
      ans%=mod
print(ans%mod)

Measured memory_bytes: 49512
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
 
const ll MOD=1e9+7;
const ll INF=1e18;
 
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

bool ans[7369000];

int main(){
    int m,n;
    while(true){
        cin >> m >> n;
        if(m + n == 0) break;
        for(int i = 0;i < 7369000;i++){
            ans[i] = false;
        }
        int year = m;
        for(int i = 0;i < n;i++){
            while(true){
                if(ans[year] == false)break;
                year++;
            }
            for(int j = 1;j*year < 7369000;j++){
                ans[j*year] = true;
            }
        }
        for(;year < 7369000;year++){
            if(ans[year] == false){
                cout << year << endl;
                break;
            }
        }
    }
}


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

int main() {
	long long N, Z, W, buf;
	vector<long long> a;
	cin >> N >> Z >> W;
	while (cin >> buf) {
		a.push_back(buf);
	}
	long long answer;
	if (N > 1)
		{answer = max(abs(a[N - 2] - a[N - 1]), abs(a[N - 1] - W));}
	else
		{answer = abs(a[0] - W);}
	cout << answer << endl;
}

Measured memory_bytes: 256
words = lambda t : list(map(t, input().split()))

n,a,b = words(int)
if (a - b) % 2 == 0:
    print(abs(a-b) // 2)
else:
    print(min((a+b-1)//2, ((n-a) + (n-b) + 1)//2))


Measured memory_bytes: 38384
K = int(input())
sevens = 7
if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    i = 1
    while True:
        if sevens % K == 0:
            print(i)
            break
        sevens = (sevens % K)*10+7
        i += 1


Measured memory_bytes: 9028
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (ll i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (ll i = ((ll)(n)-1); i >= 0; --i)
#define rreps(i, n) for (ll i = ((ll)(n)); i > 0; --i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repc2(i, s, n) for (ll i = (s); i <= (ll)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;

template <typename T>
struct BIT {
    int n;
    vector<T> data;
    BIT(int n) : n(n + 1), data(n + 1, 0) {}
    void add(int i, T x) {
        for (int j = i; j < n; j += (j & -j)) {
            data[j] += x;
        }
    }
    T sum(int i) {
        T s(0);
        for (int j = i; j > 0; j -= (j & -j)) {
            s += data[j];
        }
        return s;
    }
    T sum(int l, int r) { return sum(r) - sum(l - 1); }
};

int n, q;

int main() {
    scanf("%d%d", &n, &q);
    BIT<ll> bit(n);
    reps(i, n) {
        ll a;
        scanf("%lld", &a);
        bit.add(i, a);
    }
    rep(i, q) {
        int c, a, b;
        scanf("%d%d%d", &c, &a, &b);
        if (c == 0) {
            bit.add(a + 1, b);
        } else {
            printf("%lld\n", bit.sum(a + 1, b));
        }
    }
    return 0;
}

Measured memory_bytes: 8212
n,m = map(int,input().split())
x=[]

for i in range(n):
	a,b = map(int,input().split())
	x.append((a,b))
x.sort()

ans = 0

for j,k in x:
	if k<m:
		ans += j*k
		m -= k
	else:
		ans += j*m
		break
print(ans)

Measured memory_bytes: 16892
from functools import reduce

def comb(n, k, p):
  a = reduce(lambda x,y: x*y%p, range(n,n-k,-1))
  b = reduce(lambda x,y: x*y%p, range(1,k+1))
  return (a*pow(b, p-2, p))%p
      
n, a, b = map(int, input().split())
MOD = 10**9 + 7
     
print((pow(2,n,MOD) - 1 - comb(n, a, MOD) - comb(n, b, MOD))%MOD)

Measured memory_bytes: 39280
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let s = stdin.lock().lines().next().unwrap().unwrap();
    let ans = if s
        .chars()
        .enumerate()
        .all(|(i, c)| (i + 1) % 2 == 1 && c != 'L' || (i + 1) % 2 == 0 && c != 'R')
    {
        "Yes"
    } else {
        "No"
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.Scanner;

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

		Long X = sc.nextLong();
		for(Long i = X; i<1000000000; i++) {
			int count = 0;
			//1～iの間繰り返す i以下の素数を探す。
			for(int num = 1; num<i; num++) {
				if(i%num==0) {
					count++;
				}
			}

			if(count < 3) {
				System.out.println(i);
				break;
			}
		}
	}
}


Measured memory_bytes: 21844
#include <stdio.h>
int main(void) {
	int n;
	scanf("%d", &n);

	int a[n],i;
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

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

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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll i,j,k,b=-2,n,t;
	bool q=false;
	cin>>n;
	if (n==0){
		q=true;
	}
	vector<ll> g;
	while (n!=0){
		if (n>0){
			t=-(n/abs(b));
			g.push_back(n-t*b);
			n=t;
		}
		else {
			t=(ll)(abs(n)+1)/abs(b);
			g.push_back(n-t*b);
			n=t;
		}
	}
	if (q==true){
		cout<<"0";
	}
	else {
	    for (i=g.size()-1;i>=0;i--){
	    	cout<<g[i];
    	}
    }
	return 0;
}

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

using namespace std;


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

	int x = 700;

	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'o') {
			x += 100;
		}
	}
	cout << x << endl;
}

Measured memory_bytes: 3580
/**
 *    author:  tourist
 *    created: 21.03.2020 15:13:15       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> a(n - 1);
  for (int i = 0; i < n - 1; i++) {
    a[i] = (int) abs(s[i] - s[i + 1]);
  }
  n--;
  vector<int> cnt(3, 0);
  for (int x : a) {
    cnt[x] += 1;
  }
  int coeff = 1;
  if (cnt[1] == 0) {
    coeff *= 2;
    for (int& x : a) {
      x >>= 1;
    }
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (((n - 1) & i) == i) {
      res ^= a[i];
    }
  }
  cout << (res & 1) * coeff << '\n';
  return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - White Cells
            var line = ReadLine();
            int H = line[0];
            int W = line[1];

            line = ReadLine();
            int h = line[0];
            int w = line[1];

            var cells = new bool[H, W];

            //横方向に黒く塗りつぶす
            for(int i = 0; i < h; i++)
            {
                for(int j = 0; j < W; j++)
                {
                    cells[i, j] = true;
                }
            }

            //縦方向に黒く塗りつぶす
            for (int i = 0; i < w; i++)
            {
                for (int j = 0; j < H; j++)
                {
                    cells[j, i] = true;
                }
            }

            int count = 0;

            for(int i = 0; i < H; i++)
            {
                for(int j = 0; j < W; j++)
                {
                    if (cells[i, j] == false)
                    {
                        count++;
                    }
                }
            }

            Console.WriteLine(count);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine().TrimEnd();
            var array = line.Split(' ');
            var numbers = new List<int>();

            foreach (var s in array)
            {
                int num = int.Parse(s);
                numbers.Add(num);
            }

            return numbers;
        }
    }
}

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


typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
/*--------------------------------------------*/


int main(){
 //cout.precision(10);
 cin.tie(0);
 ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  string s;
  cin >> s;
  
  rep(i,s.size()){
    if(s[i]-'A'+N<26){
    	cout << (char)(s[i]+N);
    }else{
		cout << (char)(s[i]+N-26);
    }
  }
  

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll a[100010];
ll maxroot[100010] = {0};

int main(){
    int n;
    cin >> n;
    // vll a(n+1);
    // vll maxroot(n+1, 0);
    rep(i,n+1){
        cin >> a[i];
        if(i == 0){
            maxroot[i] = 1 - a[i];
        }else{
            maxroot[i] = maxroot[i-1]*2 - a[i];
        }
        if(maxroot[i] > inf){
            maxroot[i] = inf;
        }
        if(maxroot[i] < 0){
            cout << -1 << endl;
            return 0;
        }
        // cout << maxroot[i] << endl;
    }
    ll ans = 0;
    ll tmp = 0;
    for(int i=n; i>=0; i--){
        if(tmp > maxroot[i]){
            tmp = maxroot[i];
        }
        tmp += a[i];
        ans += tmp;
        // cout << tmp << endl;
    }
    cout << ans << endl;

}



Measured memory_bytes: 5192
N, M = list(map(int, input().split()))
if N > M:
    N, M = M, N
res = 0
if M == 1:
    res = 1
elif N == 2 or M == 2:
    res = 0
elif N == 1:
    res = M - 2
else:
    res = (N - 2) * (M - 2)
print(res)


Measured memory_bytes: 9108
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int n, m, a, b, root, par[100010], num[100010];
vector<int> frd[100010], S;
const ll mod =1000000007;

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

int main(void)
{
	cin >> n >> m;
	for (int i = 1; i < n + m; i++)
	{
		cin >> a >> b;
		frd[a].push_back(b);
		num[b]++;
	}
	for (int i = 1; i <= n; i++)
	{
		if (num[i] == 0)
		{
			root = i;
		}
	}
	S.push_back(root);
	while (S.size())
	{
		int node = S.back();
		S.pop_back();
		for (int i = 0; i < frd[node].size(); i++)
		{
			if (num[frd[node][i]] == 1)
			{
				par[frd[node][i]] = node;
				S.push_back(frd[node][i]);
			}
			num[frd[node][i]]--;
		}
	}
	for (int i = 1; i <= n; i++)
	{
		cout << par[i] << endl;
	}
	int www;
	cin >> www;
}


Measured memory_bytes: 7040
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        N: usize,
        tmpDs: [i64; N],
    }

    let mut Ds: Vec<i64> = tmpDs.into_iter().collect();
    Ds.sort();

    if Ds[N / 2 - 1] == Ds[N / 2] {
        println!("0");
        return;
    }

    // Ds[N/2-1] 以上、Ds[N/2]未満の数は何個あるか?
    let ans = Ds[N / 2] - Ds[N / 2 - 1];

    println!("{}", ans);
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD=1000000007;
ll comb(ll a,ll b){
    ll com=1;
    while(a>0){
        com*=a;
        com%=MOD;
        a--;
    }
    while(b>0){
        com*=b;
        com%=MOD;
        b--;
    }
    return com;
}
int main() {
    ll N,M; cin>>N>>M;
    if(abs(N-M)>1){
        cout<<0;
        return 0;
    }
    ll ans=0;
    if(N==M){
        ans=comb(N,M)*2;
        ans%=MOD;
    }
    else{
        ans=comb(N,M);
        ans%=MOD;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

int solve(){
    int n,m; cin>>n>>m;
    for (int i = 0; i < m; ++i)
    {
        int t; cin>>t;
        n-=t;
    }
    cout<<max(-1ll,n);
    return 0;
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] h = new int[N];
        for(int i = 0; i < N; i++) h[i] = sc.nextInt();
        int ans = 0;
        boolean con = true;
        while(con){
            con = false;
            int min = Integer.MAX_VALUE;
            int s = 0;
            for(int i = 0; i < N; i++){
                if(h[i] == 0 ){
                    if(s < i){
                        for(int j = s; j < i; j++) h[j] -= min;
                        ans += min;
                        min = Integer.MAX_VALUE;
                    }
                    s = i +1;
                }else if(h[i] < min){
                    min = h[i];
                    con = true;
                }
            }
            if(s < N){
                for(int j = s; j < N; j++) h[j] -= min;
                ans += min;
                min = Integer.MAX_VALUE;
            }
        }

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

}


Measured memory_bytes: 23764