akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class CTogether {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int counter[] = new int[1000002];
            for (int i = 0; i < n; i++) {
                int x = in.nextInt();
                counter[x]++;
                counter[x + 1]++;
                counter[x + 2]++;

            }
            int count = 0;
            for (int i = 0; i < counter.length; i++) count = Math.max(count, counter[i]);
            out.print(count);

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 44436
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using lli = long long int;

int main(){
  lli n, k;
  std::cin >> n >> k;
  std::vector<lli> h(n);
  for (int i = 0; i < n; i++) {
    std::cin >> h[i];
  }
  std::sort(h.begin(), h.end());
  lli ans = 0;
  for (int i = 0; i < n - k; i++) {
    ans += h[i];
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 1792
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto S = RD!string;
	auto T = RD!string;

	long ans;
	foreach (i; 0..3)
	{
		if (S[i] == T[i])
			++ans;
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

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

#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0);
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define pii pair<int,int>
#define UMP(x,y) unordered_map<x,y>
#define MP(x,y) map<x,y>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define inf 1e18
#define endl "\n"
#define coutd(n) cout << fixed << setprecision(n)
#define watch(x) cout<<#x<<" = "<<x<<endl;
typedef double db;
typedef long double ld;	
const int mod = 1000000007;

using namespace std;

int32_t main(){
    fast
    	
    //int t;
	//cin>>t;
	//rep(_,0,t){
		
	//}
	int amount;
	cin>>amount;
	int i=0,p=100;
	while(p < amount){
		p += (p/100);
		i++;
	}
	cout<<i; 
    return 0;
}


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

int minimum(int min[],int k,int n,int arr[],int i)
{
    int range;
    vector<int> a;
    if(i+k>n-1)
    {
        range=n-1;
    }
    else
    {

        range=i+k;
    }
    for(int j=range;j>i;j--)
    {
        a.push_back(abs(arr[j]-arr[i])+min[j]);
    }
    return *min_element(a.begin(),a.end());
}
int findmin(int n,int k,int arr[])
{
    int min[n];

    min[n-1]=0;
    min[n-2]=abs(arr[n-1]-arr[n-2]);

    for(int i=n-3;i>=0;i--)
    {
        min[i]=minimum(min,k,n,arr,i);
    }
    return min[0];
}
int main()
{
    int n;
    cin>>n;
    int k;
    cin>>k;
    int arr[n];
    {
        for(int i=0;i<n;i++)
        {
            cin>>arr[i];
        }
    }
    int ans;
    ans=findmin(n,k,arr);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
import math
import collections

def main():
  N = int(input())
  S = list()
  S = [input() for _ in range(N)]
  
  s = collections.Counter(S)
  
  MaxCount = max(s.values())
  
  ans = []
  
  for key, value in s.items():
    if value == MaxCount:
      ans.append(key)
                 
  ans.sort()
  
  for i in ans:
    print(i)
  
  
  
  
main()

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

using namespace std;

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

    int w[n], v[n];
    int mxv = 0;

    for(int i = 0; i < n; i++)
    {
        cin >> w[i] >> v[i];
        mxv += v[i];
    }

    long long dp[2][mxv + 1];
    int mxtn = 0;

    for(int i = 0; i <= mxv; i++)
    {
        dp[0][i] = INT_MAX;
        dp[1][i] = INT_MAX;
    }

    dp[0][0] = 0;

    int t;

    for(int i = 1; i <= n; i++)
    {
        t = i % 2;
        mxtn += v[i - 1];
        for(int j = 0; j <= mxtn; j++)
        {
            dp[t][j] = min(dp[t][j], dp[!t][j]);
            if(j >= v[i - 1]) dp[t][j] = min(dp[t][j], dp[!t][j - v[i - 1]] + w[i - 1]);
        }
    }

    int ans = 0;

    for(int i = 0; i <= mxv; i++)
    {
        if(dp[t][i] <= c)
            ans = max(ans, i);
    }

    /*for(int i = 0; i < 2; i++)
        for(int j = 0; j <= mxv; j++)
            cout << i << " : " << j << " : " << dp[i][j] << endl;*/

    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 1792
import math
D,G = map(int,input().split())
L = []
for i in range(D):
  L.append(list(map(int,input().split())))
n = 2
ans = float('inf')
def Base_10_to_n(X, n):
  if (int(X/n)):
      return Base_10_to_n(int(X/n),n)+str(X%n)
  return str(X%n)
for i in range(2**D):
  K = Base_10_to_n(i, n).zfill(D)
  S = 0
  sub = 0
  for j in range(D):
    if K[j] == '1':
      S += L[j][0]*100*(j+1)+L[j][1]
      sub += L[j][0]
  if S >= G:
    if sub <= ans:
      ans = sub
  else:
    cnt = 0
    for l in range(D):
      if cnt == 0:  
        if K[D-l-1] == '0':
          cnt = 1
          if G-S <= L[D-l-1][0]*100*(D-l)+L[D-l-1][1]:
            if G-S > L[D-l-1][0]*100*(D-l):
              if ans >= sub+L[D-l-1][0]:
                ans = sub+L[D-l-1][0]
            else:
              if ans >= sub+math.ceil((G-S)/(100*(D-l))):
                ans = sub+math.ceil((G-S)/(100*(D-l)))
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <string>


using namespace std;
int main() {
    int V[6] =  {1, 5, 10, 50, 100, 500};
    int C[6];  //枚数
    int A;  //合計金額
    int t = 0;

    while(1) {
        cin >> A;
        if(A == 0){
            break;
        }
        A = 1000 - A;
        int ans = 0;
        for(int i = 5; i >= 0; i--){ //Vは500円から使う
            t = A / V[i]; //コインを使う枚数
            A -= t * V[i]; //A(合計金額)から支払われた分だけ引く
            ans += t;
            }
        cout << ans << '\n';
        }
    return 0;
    }


Measured memory_bytes: 3080
s = input()
invs = s[::-1]
s = s


i=0
j=0
ans = 0 #sへのｘの挿入をカウント
while i<len(s) and j<len(s):
  if s[i]==invs[j]:
    i+=1
    j+=1
  elif s[i]=='x':
    i+=1
  elif invs[j]=='x':
    # sにxを挿入する想定
    j+=1
    ans+=1
  else:
    print(-1)
    break
else:
  if i==j:
    print(ans)
  elif i>j and all([c=='x' for c in invs[j:]]):
    print(ans+i-j)
  elif i<j and all([c=='x' for c in s[i:]]):
    print(ans)
  else:
    print(-1)

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  ll a, b, c, k;
  cin >> a >> b >> c >> k;

  if(a >= k) cout << k << endl;
  else if(a + b >= k) cout << a << endl;
  else cout << a - (k - (a + b)) << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main() {
	int e;

	while (cin >> e && e > 0) {
		int min = 100000000;

		for (int z = 0; z <= 100; z++) {
			if (z * z * z > e) {
				break;
			}
			for (int y = 0; y <= 1000; y++) {
				if ((z * z * z) + (y * y) > e) {
					break;
				}
				else {
					if (min > z + y + (e - ((z * z * z) + (y * y)))) {
						min = z + y + (e - ((z * z * z) + (y * y)));
					}
				}
			}
		}

		cout << min << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  if (n % 1110 <= 9) {
    cout << "Yes";
  }
  else if (n % 1000 % 111 == 0) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

bit = [0] * 60
for a in A:
    i = 0
    while a > 0:
        bit[i] += a & 1
        i += 1
        a >>= 1

ans = 0
for i, x in enumerate(bit):
    x = x*(n-x)
    for _ in range(i):
        x *= 2
        x %= mod
    ans += x
    ans %= mod
print(ans)


Measured memory_bytes: 122808
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] a = new int[n][2];
		for (int i = 0; i < n; i++) {
			a[i][0] = i + 1;
			a[i][1] = sc.nextInt();
		}
		Arrays.sort(a, Comparator.comparingInt(x -> x[1]));
		for (int i = 0; i < n; i++) {
			System.out.print(a[i][0]);
			System.out.print(" ");
		}
		System.out.println();
	}
}


Measured memory_bytes: 67116
#include<stdio.h>

#include<string.h>
#include<stdlib.h>
#include<math.h>
#define MOD 1000000007
long long plzh(long long a)

{
	long long i,t=1;
	for(i=1;i<=a;i++)
	{
		t=i*t%MOD;
	}
	return t;
}

int main()

{

	long long x,m,n;

	while(scanf("%lld %lld",&m,&n)!=EOF)

	{
		if(n==m)
		{
			m=plzh(m);
			n=plzh(n);
			x=(m*n*2)%MOD;
		}
		else if( abs(m-n)==1)
		{
			m=plzh(m);
			n=plzh(n);
			x=m*n%MOD;
		}
		else
		{
			x=0;
		} 
		printf("%lld\n",x);
	}

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.14159265359
#define all(v) v.begin(),v.end()
#define vil vector<long int>
#define vi vector<int> 
#define pb(x) push_back(x)
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ub upper_bound
#define lb lower_bound
#define INF 1000000007 
#define MOD 998244353
void solve(ll T){
int n,w;
cin>>n>>w;
vil a(n),b(n);
for(int i=0;i<n;i++){
    cin>>b[i]>>a[i];
}
ll dp[n+1][w+1];
for(int i=0;i<=n;i++){
    for(int j=0;j<=w;j++){
        if(i==0||j==0){
            dp[i][j]=0;
        }
       else if(j>=b[i-1]){
     dp[i][j]=max(dp[i-1][j],dp[i-1][j-b[i-1]]+a[i-1]);
        }
        else{
            dp[i][j]=dp[i-1][j];
        }
    }
}
cout<<dp[n][w]<<endl;

}
int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
ll T;
T=1;
//cin>>T;
while(T--){
   solve(T);
return 0;
}
}

Measured memory_bytes: 82444
n=int(input())
p=list(map(float,input().split()))
dp=[[0]*(n+1) for _ in range(n+1)]
dp[0][0]=1
for i in range(1,n+1):
    for j in range(i+1):
        if j>0:
            dp[i][j]+=dp[i-1][j-1]*p[i-1]
        dp[i][j]+=dp[i-1][j]*(1-p[i-1])
print(sum(dp[n][n//2+1:]))

Measured memory_bytes: 203392
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>

using namespace std;

int main(int argc, const char * argv[]) {
    
    int n, m, ans = 0;

    cin >> n >> m;
    
    if(n >= 2)
    {
        ans += n * (n - 1) / 2;
    }
    
    if(m >= 2)
    {
        ans += m * (m - 1) / 2;
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>

const int mod = 1000000007;

int dfs(std::map<int, std::vector<int>>& t_dict, int K, int current, int parent, int n_pp){
  long long int ans = K-n_pp-1;
  int n_parent_count = 1;
  if(parent == -1){
    ans = K;
    n_parent_count = 0;
  }
  for(const auto& node: t_dict[current]){
    if(node == parent) continue;
    ans *= dfs(t_dict, K, node, current, n_parent_count);
    ans = ans % mod;
    n_parent_count += 1;
  }
  return static_cast<int>(ans);
}


int main(){
  int N,K;
  std::cin >> N >> K;
  std::map<int, std::vector<int>> t_dict;
  for(int i = 0; i < N; i++){
    t_dict[i] = std::vector<int>();
  }
  for(int i = 0; i < N-1; i++){
    int a,b;
    std::cin >> a >> b;
    a--; b--;
    t_dict[a].push_back(b);
    t_dict[b].push_back(a);
  }

  std::cout << dfs(t_dict, K, 1, -1, 0) << std::endl;

  return 0;
}


Measured memory_bytes: 17792
#include <iostream> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <algorithm> 
using namespace std; 
typedef long long LL; 
const LL INF = 1e16; 
const int MAX_N = 55; 
const int MAX_V = 2e5 + 5; 
struct Graph { int to, next; } e[MAX_N << 1]; 
int fir[MAX_N], e_cnt; 
void clearGraph() { memset(fir, -1, sizeof(fir)); e_cnt = 0; } 
void Add_Edge(int u, int v) { e[e_cnt] = (Graph){v, fir[u]}, fir[u] = e_cnt++; } 

struct node { LL val, wei; bool op; } a[MAX_N]; 
bool operator < (const node &l, const node &r) 
    { return 1ll * l.val * r.wei > 1ll * l.wei * r.val; } 
int N, X, D; 
void dfs(int x) { 
	for (int i = fir[x]; ~i; i = e[i].next) { 
		int v = e[i].to; 
		dfs(v); 
		a[x].val += a[v].val; 
		a[x].wei += a[v].wei; 
	} 
} 
int V, lim;
LL f[MAX_V]; 
void ins(LL w, LL v) { 
	for (int i = V; i >= v; i--) 
        f[i] = min(f[i], f[i - v] + w); 
} 
void add(node p) { 
	int t = lim; 
	for (int i = 0; 1 << i <= t; i++) 
		ins(p.wei * (1 << i), p.val * (1 << i)), t -= 1 << i; 
	if (t) ins(p.wei * t, p.val * t); 
} 
int main () { 
	clearGraph(); 
	scanf("%d %d %d", &N, &X, &D); 
	scanf("%lld", &a[1].wei), a[1].val = 1, a[1].op = 1; 
	for (int i = 2; i <= N; i++) { 
		int w, fa; scanf("%d %d", &w, &fa); 
		a[i].wei = w, a[i].val = 1, Add_Edge(fa, i); 
	} 
	dfs(1); 
	lim = min(N, D); 
	V = N * N * N; 
	for (int i = 0; i <= V; i++) f[i] = INF; 
	f[0] = 0; 
	for (int i = 1; i <= N; i++) add(a[i]); 
	sort(&a[1], &a[N + 1]); 
	while (!a[N].op) --N; 
	LL ans = 0; 
	for (int i = 0; i <= V; i++) { 
		if (f[i] > X) continue; 
		LL val = i, wei = f[i]; 
		for (int j = 1; j < N; j++) { 
			LL cnt = min(1ll * D - lim, (X - wei) / a[j].wei); 
			val += cnt * a[j].val, wei += cnt * a[j].wei; 
		} 
		LL cnt = (X - wei) / a[N].wei; 
		ans = max(ans, val + cnt * a[N].val); 
	} 
	printf("%lld\n", ans); 
    return 0; 
} 

Measured memory_bytes: 1408
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	
	N := ScanInt(scanner)
	A := make([]int, N)
	for i := 0; i < N; i++ {
	    A[i] = ScanInt(scanner)
	}
	A = append([]int{0}, A...)
	A = append(A, 0)
	
	sum := 0
	for i := 0; i < N + 1; i++ {
	    sum += Abs(A[i+1] - A[i])
	}
	
	for i := 0; i < N; i++ {
	    // a <= b <= c
	    if A[i] <= A[i+1] && A[i+1] <= A[i+2] {
	        fmt.Println(sum)
        // a <= c <= b
	    } else if A[i] <= A[i+2] && A[i+2] <= A[i+1] {
	        fmt.Println(sum - 2 * Abs(A[i+1] - A[i+2]))
	    // b <= a <= c
	    } else if A[i+1] <= A[i] && A[i] <= A[i+2] {
	        fmt.Println(sum - 2 * Abs(A[i] - A[i+1]))
	    // b <= c <= a
	    } else if A[i+1] <= A[i+2] && A[i+2] <= A[i] {
	        fmt.Println(sum - 2 * Abs(A[i+2] - A[i+1]))
	    // c <= a <= b
	    } else if A[i+2] <= A[i] && A[i] <= A[i+1] {
	        fmt.Println(sum - 2 * Abs(A[i+1] - A[i]))
	    // c <= b <= a
	    } else if A[i+2] <= A[i+1] && A[i+1] <= A[i] {
	        fmt.Println(sum)
	    }
	}
}

func ScanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func ScanFloat64(scanner *bufio.Scanner) float64 {
	scanner.Scan()
	f, e := strconv.ParseFloat(scanner.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func ScanText(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

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

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

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

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
}

Measured memory_bytes: 256
N = int(input())
C = list(input())

Rcnt = C.count("R")
Ccnt = N - Rcnt
swapcnt = 0
for i in range(N):
    if i < Rcnt and C[i] == "W":
        swapcnt += 1

print(min(swapcnt, min(Rcnt, Ccnt)))


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
 
  int a,b;
  int c[1001][1001],i,j;
  int l,m,n,x1,y1,x2,y2,o,p,max;
   
  while(1){
   
    scanf("%d %d",&a,&b);
 
    if(a==0&&b==0){
      break;
    }
 
    for(i=0;i<a;i++){
      for(j=0;j<b;j++){
    scanf("%d",&c[i][j]);
      }
    }
 
    max=0;
 
    for(x2=2;x2<a;x2++){
      for(y2=2;y2<b;y2++){
    for(x1=0;x1<x2-1;x1++){
      for(y1=0;y1<y2-1;y1++){
 
        l=c[x1][y1];
 
        for(j=y1;j<y2+1;j++){
          if(c[x1][j]<l){
        l=c[x1][j];
          }
        }
 
        for(i=x1;i<x2+1;i++){
          if(c[i][y1]<l){
        l=c[i][y1];
          }
        }
 
        for(j=y1;j<y2+1;j++){
          if(c[x2][j]<l){
        l=c[x2][j];
          }
        }
 
        for(i=x1;i<x2+1;i++){
          if(c[i][y2]<l){
        l=c[i][y2];
          }
        }
 
        n=0;
        for(o=x1+1;o<x2;o++){
          for(p=y1+1;p<y2;p++){
 
        m=l-c[o][p];
        n=n+m;
     
          }
        }
 
        for(o=x1+1;o<x2;o++){
          for(p=y1+1;p<y2;p++){
        if(c[o][p]>=l){
          n=0;
        }
          }
        }
 
        if(max<n){
          max=n;
        }
  
      }
    }
      }
    }
 
    printf("%d\n",max);
 
  }
   
  return 0;
}



Measured memory_bytes: 2032
#include<bits/stdc++.h>
using namespace std;
int main(){
	const int INF=1e9+5;
	int n;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
int dp[n];
for(int i=0;i<n;i++)
 dp[i]=INF;
dp[0]=0;
	for(int i=0;i<n;i++){
		
			if(i+1<n)
			dp[i+1]=min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
				if(i+2<n)
			dp[i+2]=min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long l;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SONI ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
const int maxn=5e5+15;
const int maxm=5000+15;
const int mod=1e9+9;
const int inf=0x3f3f3f3f;
const int MOD=1000000007;

void max_self(ll& a,ll b)
{
    a=max(a,b);
}

int main()
{
    SONI;
    int n,W;
    cin>>n>>W;
    vector<ll> dp(1+W);
    for(int item=0;item<n;item++)
    {
        int weight,value;
        cin>>weight>>value;
        for(int w_already = W-weight;w_already>=0;w_already--)
        {
            max_self(dp[w_already+weight],dp[w_already]+value);
        }
    }
    
    ll answer=0;
    for(int i=0;i<=W;i++)
    {
        max_self(answer,dp[i]);
    }
    cout<<answer;
    return 0;
}

Measured memory_bytes: 1024
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] hen = ReadStringSplit();
        int a = int.Parse(hen[0]);
        int b = int.Parse(hen[1]);
        int c = int.Parse(hen[2]);

        if(a == b && b == c)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }

    //読み取り用
    static String Read()
    {
        return Console.ReadLine();
    }

    static int ReadInt()
    {
        return int.Parse(Console.ReadLine());
    }

    static char[] ReadChar()
    {
        return Console.ReadLine().ToCharArray();
    }

    static string[] ReadStringSplit()
    {
        return Console.ReadLine().Split(' ');
    }
}

Measured memory_bytes: 13140
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int ans = a < b ? a : b;
  int len = a < b ? b : a;
  for(int i=0;i<len;i++){
    cout<<ans;
  }
  cout << endl;
  /*
  char sta[b],stb[a];
  for(int i=0;i<b;i++){
    sta[i] = a+'0';
  }

  for(int i=0;i<a;i++){
    stb[i] = b+'0';
  }
  if(sta > stb) cout << sta << endl;
  else cout << stb << endl;
  */
}


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

using namespace std;

int main() {
	int n, sum = 0;
	cin >> n;
	vector <int> a(n), b(n), c(n - 1);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	a.push_back(0);
	for (int i = 0; i < n; ++i) {
		cin >> b[i];
	}
	for (int i = 0; i < n - 1; ++i) {
		cin >> c[i];
	}
	for (int i = 0; i < n; ++i) {
		sum += b[a[i] - 1];
		if ( a[i] == a[i + 1] - 1) {
			sum += c[a[i] - 1];
		}
	}
	cout << sum;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
row = list(map(int,input().split()))
p = 10000000000000000
i = 0
j = 1
while i + k <= n:
  if(row[i]*row[i+k-1] < 0):
    l = abs(row[i])
    r = abs(row[i+k-1])
    ma = max(l,r)
    mi = min(l,r)
    t = mi*2 + ma

    if(t < p):
      p = t
  elif(row[i] < 0):
    t = abs(row[i])
    if(t < p):
      p = t
  else:
    t = row[i+k-1]
    if(t < p):
      p = t
  i += 1
print(p)

Measured memory_bytes: 14660
#include<iostream>
using namespace std;
int main(){
	int x,y,dp[18][300];
	for(int i=0;i<18;i++)for(int j=0;j<300;j++)dp[i][j]=0;
	for(int i=1;i<=300;i++){
		dp[1][i]=1;
	}
	for(int i=2;i<=17;i++){
		x=i*i;
		
		for(int j=1;j<=300;j++){
			if(j<x)dp[i][j]=dp[i-1][j];
			else if(j==x)dp[i][j]=dp[i-1][j]+1;
			else dp[i][j]=dp[i-1][j]+dp[i][j-x];
		}
	}
	while(cin>>y&&y>0){
		cout<<dp[17][y]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1180
#include <stdio.h>

int main(void){
        int a, b, c, temp, i;
        scanf("%d %d %d", &a, &b, &c);
        if((a>=1 && a<=10000) && (b>=1 && b<=10000) && (c>=1 && c<=10000)){
                for(i=0;i<2;i++){
                        if(a>b){
                                temp=a;
                                a=b;
                                b=temp;
                        }
                        if(b>c){
                                temp=b;
                                b=c;
                                c=temp;
                        }
                }
                printf("%d %d %d\n", a, b, c);
        }
        return 0;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define X first
#define Y second
#define pb push_back
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define int long long

const LL mod = 1e9 + 7;


template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }

template<class T, class U>
istream& operator >> (istream& in, pair<T, U> & v){ in >> v.X >> v.Y;return in; }

template<class T, class U>
ostream& operator << (ostream& out, pair<T, U> & v){ out << v.X << " " << v.Y;return out; }

void chkmax(int &a, int b) {
    a = max(a, b);
    return;
}

void chkmin(int &a, int b) {
    a = min(a, b);
    return;
}

LL ppow (LL x, LL s) {
    if (!s) return 1;
    if (!(s - 1)) return x % mod;
    if (s % 2) return (x * ppow (x, s - 1)) % mod;
    LL b = ppow (x, s / 2);
    return (b * b) % mod;
}

vector<vector<int> > gr;
vector<int> used, dp;

int get(int u) {
    if (used[u]) {
        return dp[u];
    }
    used[u] = 1;
    for (auto x : gr[u]) {
        chkmax(dp[u], get(x) + 1);
    }
    return dp[u];
}

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("ILUXA.in", "r", stdin);
    int n, m;
    cin >> n >> m;
    gr.resize(n);
    used.resize(n, 0);
    dp.resize(n, 0);
    while (m--) {
        int x, y;
        cin >> x >> y;
        gr[--y].pb(--x);
    }
    int ans = 0;
    for (int i = 0;i < n;i++) {
        chkmax(ans, get(i));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 11776
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}



int main() {
	int x; cin >> x;
	int y = x;
	int sum=0;

	while (x) {
		sum += x % 10;
		x /= 10;
	}
	
	if (y % sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	/////////////input////////////
	int N, Q;
	string S;
	cin >> N >> Q;
	cin >> S;

	std::vector<int> l(Q);
	std::vector<int> r(Q);

	for (int i = 0; i < Q; ++i)
	{
		cin >> l[i] >> r[i];
	}
	///////////compute////////////
	int count = 0;
	std::vector<int> RF(N);

	for (int i = 0; i < N; ++i)
	{
		if (S[i] == 'A' && S[i + 1] == 'C')
		{
			count++;
			RF[i + 1] += count;
		}else{
			RF[i + 1] += count;
		}
	}

	for (int i = 0; i < Q; ++i)
	{
		cout << RF[r[i] - 1] - RF[l[i] - 1] << endl;
	}
}

Measured memory_bytes: 2176
def resolve():
    l1, l2, r1, r2 = map(int, input().split())
    lw = l1 + l2
    rw = r1 + r2
    
    ans = ""
    if lw < rw:
        ans = "Right"
    elif lw > rw:
        ans = "Left"
    else:
        ans = "Balanced"
    print(ans)
resolve()

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

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

    if(N%(2*D+1)) cout << N/(2*D+1) + 1 << endl;
    else cout << N/(2*D+1);

    return 0;
}

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

using namespace std;
   
int main(void){

	string inp;
	string suu("0123456789");
	int num,b;

	num=0;
	while(cin>>inp){
		b=1;
		for(int i=inp.length()-1;i>=0;i--){
			if(suu.find(inp[i])!=-1){
				num+=suu.find(inp[i])*b;
				b*=10;
			}
			else b=1;
		}
	}

	cout<<num<<endl;

    return 0;
}

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

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

    int total = 0;
    for(int i = 0; i < m; i++) {
        int tmp;
        cin >> tmp;
        total += tmp;
    }

    int asobu;
    asobu  = n - total;
    if( asobu < -1 ) asobu = -1;

    cout << asobu << endl;
}

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

int main(){
  int N;
  int C[500],S[500],F[500];
  int cnt;

  cin >> N;
  for(int i = 1; i < N; i++){
    cin >> C[i] >> S[i] >> F[i];
  }

  for(int i = 1; i < N; i++){
    cnt = 0;
    cnt += S[i] + C[i];

    for(int j = i; j < N-1; j++){
      for(;;){
        if(cnt%F[j+1] == 0 and cnt >= S[j+1]){
          cnt += C[j+1];
          //cout << cnt << endl;
          break;
        }
        else cnt++;
        //cout << cnt << endl;
      }
    }

    cout << cnt << endl;
  }
  cout << 0 << endl;
  return 0;
}

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  string s;
  cin >> s;
  vector<bool> v(3, false);
  rep(i,3){
    if(s[i]=='a'){
      v[0] = true;
    }
    if(s[i]=='b'){
      v[1] = true;
    }
    if(s[i]=='c'){
      v[2] = true;
    }
  }
  if(v[0]&&v[1]&&v[2]) cout <<  "Yes" << endl;
  else cout <<  "No" << endl;
}      
       

Measured memory_bytes: 3572
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())

As = [a-i for i, a in enumerate(As, 1)]
As.sort()
middle = As[N//2]
print(sum([abs(a-middle) for a in As]))

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

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

        String s = sc.next();

        int len = s.length();
        StringBuilder ans = new StringBuilder();
        for (int i = 0; i<len; i++){
            if (i%2 == 0){
                ans.append(s.charAt(i));
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 38992
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
#define inf 0x7fffffff
#define llinf 0x7fffffffffffffffll
using namespace std;
map<int,int> mp;
int main()
{
	int i,j,k,n,m,x;
	ll sum,ans;
	scanf("%d%d",&n,&m);
	ans=0;
	sum=0;
	mp[0]++;
	for(i=0;i<n;i++)
	{
		scanf("%d",&x);
		sum+=x;
		mp[sum%m]++;
	
	}
	for(__typeof(mp.begin()) it=mp.begin();it!=mp.end();it++)
	{
		k=(*it).second;
	//	printf("%d ",k);
		ans=ans+k*1ll*(k-1)/2;
	//	printf("%d\n",ans);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3200
import sys
from collections import Counter

N = int(sys.stdin.readline().rstrip())

S = []
for _ in range(N):
    S.append(sys.stdin.readline().rstrip())

c = Counter(S)

print(f"AC x {c['AC']}")
print(f"WA x {c['WA']}")
print(f"TLE x {c['TLE']}")
print(f"RE x {c['RE']}")

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

typedef long long ll;
ll a[100100], A, B;
int n;

bool jud(ll x)
{
    ll rest = x;
    for (int i = n; i; i--)
    {
        if ((a[i] - B * (x - rest) + A - 1) / A > rest) return 0;
        ll tmp = a[i] - B * x;
        if (tmp > 0) rest -= (tmp + A - B - 1) / (A - B);
    }
    return 1;
}

int main()
{
    int i;
    scanf("%d%lld%lld", &n, &A, &B);
    for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
    sort(a + 1, a + n + 1);
    ll l = 0, r = (ll)n * (a[n] + A - 1) / A;
    while (l < r)
    {
        ll mid = (l + r) >> 1;
        if (jud(mid)) r = mid;
                else l = mid+1;
    }
    cout<<l<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include<cmath>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int cnt=0,w,x,y,z;
    for(int i=a;i<=b;i++)
    {
        w=i/10000;
        x=(i/1000)%10;
        y=(i/10)%10;
        z=i%10;
        if(w==z&&x==y)cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
let content = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', buf => {
  content += buf;
});

process.stdin.on('end', () => {
  const [nums, sums] = content
    .trim()
    .split('\n')
    .filter((line, i) => i % 2 === 1)
    .map(nums => nums.split(' ').map(n => +n));

  for (const sum of sums) {
    const result = solve(sum, nums, 0);
    console.log(result ? 'yes' : 'no');
  }
});

const memoize = fn => {
  const memo = {};
  return (...args) => {
    const key = JSON.stringify(args);
    if (!(key in memo)) {
      memo[key] = fn(...args);
    }

    return memo[key];
  };
};

const solve = memoize((sum, nums, offset) => {
  if (sum === 0) {
    return true;
  } else if (offset >= nums.length) {
    return false;
  }

  return (
    solve(sum, nums, offset + 1) || solve(sum - nums[offset], nums, offset + 1)
  );
});


Measured memory_bytes: 25336
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
 
typedef long long ll;
#define INF 1e9
 
 
int main(){
  int n;
  cin >> n;
  vector<int> a(n/2), b(n/2);
  REP(i, n){
     if(i % 2){
        cin >> b[i/2];
     }
     else{
        cin >> a[i/2];
     }
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  vector<pair<int, int>> ac, bc;
  int cnt = 0, pre = -1;
  int ansa = 0, ansb = 0;
  REP(i, n/2){
     if(pre != a[i]){
        pre = a[i];
        cnt = 1;
         ac.push_back(make_pair(cnt, pre));
     }
     else{
        cnt++;
        ac[ac.size()-1].first++;
     }
      ansa = max(ansa, cnt);
  }
  cnt = 0;
  pre = -1;
  REP(i, n/2){
     if(pre != b[i]){
        pre = b[i];
        cnt = 1;
        bc.push_back(make_pair(cnt, pre));
     }
     else{
        cnt++;
        bc[bc.size()-1].first++;
     }
     ansb = max(ansb, cnt);
  }
  int ans;
   sort(ac.begin(), ac.end());
   sort(bc.begin(), bc.end());
   if(ac[ac.size()-1].second == bc[bc.size()-1].second){
      if(ac.size()==1 || bc.size()==1){
         if(ac.size()==1 && bc.size() == 1){
            ans = max(ac[ac.size()-1].first, bc[bc.size()-1].first);
            //cout << ac[ac.size()-1].first << " " << bc[bc.size()-1].first << " " << ans << endl;
         }
         else if(ac.size() == 1){
            ansa = ac[ac.size()-1].first;
            ansb = bc[bc.size()-2].first;
            ans = ansa+ansb;
         }
         else{
            ansb = ac[ac.size()-2].first;
            ansb = bc[bc.size()-1].first;
            ans = ansa+ansb;
         }
         
      }
      else{
         ans = max(ac[ac.size()-1].first+bc[bc.size()-2].first, ac[ac.size()-2].first+bc[bc.size()-1].first);
      }
   }
   else{
      ans = ac[ac.size()-1].first+bc[bc.size()-1].first;
   }
   //cout << n << " " << ans << endl;
   cout << n-ans << endl;

  return 0;
}


Measured memory_bytes: 1784
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    long long int x,t;
    cin >> x >> t;
    if((x-t) < 0 ) cout << 0 << endl;
    else cout << x-t << endl;
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int n, x;
	while (true) {
		cin >> n >> x;
		if (n == 0 && x == 0) break;
		int count = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				for (int k = 1; k <= n; k++) {
					if (i + j + k == x) {
						if (!(i == j || i == k || j == k || i == j == k)) {
							count++;
							//cout << i << " " << j << " " << k << "\n";
						}
					}
				}
			}
		}
		cout << count/6 << "\n";
	}
}

Measured memory_bytes: 1160
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;

int main(){
	int a = 0, s = 0, n = 0,b,c;
	while (scanf("%d,%d", &b, &c) + 1){
		s += (b*c);
		a += c;
		++n;
	}
	a = round((double)a / n);
	cout << s << endl << a << endl;
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair

using namespace std;

int main(){
  int N;
  string s;
  cin>>N;
  cin>>s;
  int R,B;
  R = B = 0;
  for(int i = 0;i < N;i++){
    if(s[i] == 'R')R++; else B++;
  }
  bool isR = true;
  
  if(R <= B)isR = false;
  
  if(isR){
  	cout<<"Yes";
  }else{
  	cout<<"No";
  }
  return 0;
}


Measured memory_bytes: 256
from collections import deque
n = int(input())
#a, b, c = map(int, input().split())
al = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

q = deque([])

for i in range(1, n+1):
    if i % 2 == 0:
        q.appendleft(al[i-1])
    else:
        q.append(al[i-1])

ansl = list(q)
ansl = ansl[::-1] if n % 2 != 0 else ansl

print(*ansl, sep=" ")


Measured memory_bytes: 32344
from bisect import bisect_right
from itertools import accumulate
import sys
input = sys.stdin.readline

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A = list(accumulate(A))
B = list(accumulate(B))
ans = bisect_right(B, K)
for i in range(N):
    if A[i] > K:
        break
    j = bisect_right(B, K - A[i])
    ans = max(ans, i + j + 1)
print(ans)


Measured memory_bytes: 124052
#include<bits/stdc++.h>
#include<map>
using namespace std;
int main(){
  int h,w,k;
  cin>>h>>w>>k;
  vector<string> v(h);
  for(int i=0;i<h;i++)cin>>v[i];
  int count=0;
	for(int r=0;r<1<<h;r++)
		for(int c=0;c<1<<w;c++){
			int ans=0;
			for(int i=0;i<h;i++)
				for(int j=0;j<w;j++)
					if(((r>>i)&1)==0&&((c>>j)&1)==0&&v[i][j]=='#')ans++;
		if(ans==k)count++;
		}
	cout<<count;
	return 0;
}

Measured memory_bytes: 3624
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    N = int(inputs[0])
    for i in reversed(range(N+1)):
        flg = True
        count = i
        while count > 1:
            if count % 2 != 0:
                flg = False
                break
            count = count // 2
        if flg:
            return i


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


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

int main(int argc, const char * argv[]) {
    int N, Y;
    
    cin >> N >> Y;
    
    for (int i = 0; i <= N; i++) {
        for (int j = 0; i + j <= N; j++) {
            int k = N - i - j;
            int total = (i * 10000) + (j * 5000) + (k * 1000);
            if (((i + j + k) == N) && (total == Y)) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    
    return 0;
}

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

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

    int ans; 

    if (S == "SUN")
        ans = 7; 
    else if (S == "MON")
        ans = 6; 
    else if (S == "TUE") 
        ans = 5; 
    else if (S == "WED")
        ans = 4; 
    else if (S == "THU")
        ans = 3;  
    else if (S == "FRI")
        ans = 2; 
    else if (S == "SAT")
        ans = 1; 
    
    cout << ans; 
    return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, x, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> x;
		if ((i & 1) && (x & 1))ans++;
	}
	cout << ans;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll INF=1e9;
const int Bmax=2e5;





int main(){
  int n;
  cin>>n;
  vector<int> a(n),ap(n),am(n);
  bitset<Bmax> x;
  cin>>x;
  int p=x.count();

  int now=1;
  int nowp=1;
  int nowm=1;
  int rem=0;
  int remp=0;
  int remm=0;

  rep(i,n){
    if(p>0){
      a[i]=now%p;
      if(x.test(i)) rem=(rem+now)%p;
      now=(now*2)%p;
    }

    ap[i]=nowp%(p+1);
    if(x.test(i)) remp=(remp+nowp)%(p+1);
    nowp=(nowp*2)%(p+1);

    if(p>1) {
      am[i]=nowm%(p-1);
      if(x.test(i)) remm=(remm+nowm)%(p-1);
      nowm=(nowm*2)%(p-1);
    }
  }


  rep(i,n){
    int remi;
    if(x.test(n-1-i)){
      if(p<=1){
        cout<<0<<endl;
        continue;
      }else{
        remi=(remm+(p-1)-am[n-1-i])%(p-1);
      }
    }else{
      remi=(remp+ap[n-1-i])%(p+1);
    }
    int ans=1;

    while(remi!=0){
      ans++;
      int xi=remi;
      bitset<32> t=bitset<32>(xi);
      int pi=t.count();
      remi=xi%pi;
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 5844
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    int rem = a-b;
    int ans = c - min(rem, c);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
 
using namespace std;

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

signed main(){
    io();
    int n; cin >> n;
    vector<int> a(n), b;
    int difs = 0;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        b.push_back(i + 1);
        if(b[i] != a[i]){
            ++difs;
        }
    }
    puts(difs > 2 ? "NO\n" : "YES\n");
    return 0;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;

	int max3(int a, int b, int c) {
		int max = ((a < b) ? b : a);
		return (max < c)? c : max;
	}
	
	void doIt() {
		int n = sc.nextInt();
		int w[] = new int[n + 1];
		w[0] = 0;
		for(int i = 1; i <= n; i++) {
			w[i] = w[i - 1];
			w[i] += sc.nextInt();
		}
		int min = MAX;
		for(int i = 0; i <= n; i++) {
			int val = Math.abs(w[n] - w[i] * 2); 
			min = (min > val) ? val : min;
		}
		System.out.println(min);
	}
	
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
#define MOD 1000000007

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N; cin >> N;
	vector<ll> a(N);
	int r[9] = { 0 };
	int col = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		int R = a[i] / 400;
		if (R >= 8) {
			r[8]++;
		}
		else {
			if (r[R] == 0) {
				col++;
			}
			r[R]++;
		}
	}
	if (col != 0) {
		cout << col << " " << col + r[8] << endl;
	}
	else {
		cout << 1 << " " << r[8] << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
const int M = 2e5+5;
char s[M];

struct Node{
	int swp,ch[3],ed;
}t[2000010];
int cnt=1;

inline void ins(int sum){
	int fir=1;
	int s=sum;
	for(int i=0;i<n;i++){
		int q=sum%3;
		sum/=3;
		if(!t[fir].ch[q])t[fir].ch[q]=++cnt;
		fir=t[fir].ch[q];
	}
	t[fir].ed=s;
}

void add(){
	int fir=1;
	for(int i=0;i<n;i++){
		if(t[fir].swp){
			swap(t[fir].ch[1],t[fir].ch[2]);
			for(int j=0;j<3;j++)t[t[fir].ch[j]].swp^=1;
			t[fir].swp=0;
		}
		int q=t[fir].ch[2];t[fir].ch[2]=t[fir].ch[1],t[fir].ch[1]=t[fir].ch[0];
		t[fir].ch[0]=q;
		fir=q;
	}
}
int ans[2000010];
void dfs(int fir,int d,int quan,int s){
	if(t[fir].swp){
		swap(t[fir].ch[1],t[fir].ch[2]);
		for(int j=0;j<3;j++)t[t[fir].ch[j]].swp^=1;
		t[fir].swp=0;
	}
	if(d==n){
		ans[t[fir].ed]=s;return;
	}
	for(int j=0;j<3;j++){
		dfs(t[fir].ch[j],d+1,quan*3,s+quan*j);
	}
}
int tot=0;
int main()
{
	cin >> n;
	tot=1;for(int i=1;i<=n;i++)tot*=3;
	scanf("%s",s+1);
	m=strlen(s+1);
	for(int i=0;i<tot;i++){
		ins(i);
	}
	// cerr << "?" << endl;
	for(int j=1;j<=m;j++){
		if(s[j]=='S')t[1].swp^=1;
		else add();
		// dfs(1,0,1,0);
		// for(int i=0;i<tot;i++)printf("%d ",ans[i]);puts("");
	}
	dfs(1,0,1,0);
	for(int i=0;i<tot;i++)printf("%d ",ans[i]);puts("");
}

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

#define EPS (1e-10)
typedef complex<double> Po;

double cross(Po x,Po y){return x.real()*y.imag() - x.imag()*y.real();}

double area(Po a,Po b,Po c){
  return abs(cross(b-a,c-a)/2);
}

bool inter(Po a,Po b,Po c,Po x){
  if( area(a,b,x) + area(b,c,x) + area(c,a,x) > area(a,b,c) + EPS)return false;
  else return true;
}

int main(){
  int n;
  Po p1,p2,p3,pk,ps;

  cin >> n;

  for(int i=0;i<n;i++){
    cin >> p1.real() >> p1.imag();
    cin >> p2.real() >> p2.imag();
    cin >> p3.real() >> p3.imag();
    cin >> pk.real() >> pk.imag();
    cin >> ps.real() >> ps.imag();

    if(inter(p1,p2,p3,pk) != inter(p1,p2,p3,ps) )cout << "OK" << endl;
    else cout << "NG" << endl;
  }
  
}

Measured memory_bytes: 952