akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N;
	std::cin >> N;
	std::vector<int64_t> A(N);
	for (int64_t i = 0; i < N; i++)
	{
		std::cin >> A[i];
	}

	std::sort(A.begin(), A.end());
	A.erase(std::unique(A.begin(), A.end()), A.end());

	if (A.size() == N)
	{
		std::cout << "YES" << std::endl;
	}
	else
	{
		std::cout << "NO" << std::endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


Measured memory_bytes: 4644
import java.util.*;
import java.util.stream.*;

public class Main {
    static final int MAX_V = 50;
    static final int MAX_S = MAX_V * 50 + 5;

    @SuppressWarnings("unchecked")
    static List<Edge>[] g = new ArrayList[MAX_V];
    static long[][] dist = new long[MAX_V][MAX_S + 5];

    static {
        for (int i = 0; i < MAX_V; i++) {
            g[i] = new ArrayList<>();
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int cities = sc.nextInt();
        int lines = sc.nextInt();
        int silvers = sc.nextInt();
        for (int i = 0; i < lines; i++) {
            int u = sc.nextInt();
            int v = sc.nextInt();
            int fare = sc.nextInt();
            int minutes = sc.nextInt();
            --u; --v;
            g[u].add(new Edge(v, fare, minutes));
            g[v].add(new Edge(u, fare, minutes));
        }
        List<Integer> c = new ArrayList<>(cities), d = new ArrayList<>(cities);
        for (int i = 0; i < cities; i++) {
            c.add(sc.nextInt());
            d.add(sc.nextInt());
        }
        for (int i = 0; i < cities; i++) {
            for (int j = 0; j < MAX_S + 5; j++) {
                dist[i][j] = Long.MAX_VALUE;
            }
        }
        silvers = Integer.min(silvers, MAX_S);

        PriorityQueue<Data> q = new PriorityQueue<>((a, b) -> {
            long diff = a.x - b.x;
            if (diff > 0) return 1;
            if (diff < 0) return -1;
            return 0;
        });
        TriConsumer<Integer, Integer, Long> push = (v, s, x) -> {
            if (s < 0) return;
            if (dist[v][s] <= x) return;
            dist[v][s] = x;
            q.add(new Data(v, s, x));
        };
        push.accept(0, silvers, 0L);
        while (!q.isEmpty()) {
            Data top = q.poll();
            int v = top.v, s = top.s;
            long x = top.x;
            if (dist[v][s] != x) continue;
            {
                int ns = Integer.min(s + c.get(v), MAX_S);
                push.accept(v, ns, x + d.get(v));
            }
            for (Edge e : g[v]) {
                push.accept(e.to, s - e.a, x + e.b);
            }
        }
        for (int i = 1; i < cities; i++) {
            long ans = Long.MAX_VALUE;
            for (int j = 0; j < MAX_S + 5; j++) {
                ans = Long.min(ans, dist[i][j]);
            }
            System.out.println(ans);
        }
    }

    private static class Edge {
        int to, a, b;
        Edge(int to, int a, int b) {
            this.to = to;
            this.a = a;
            this.b = b;
        }
    }

    private static class Data {
        int v, s;
        long x;
        Data(int v, int s, long x) {
            this.v = v;
            this.s = s;
            this.x = x;
        }
    }
}

interface TriConsumer<T, U, V> {
    void accept(T t, U u, V v);
}


Measured memory_bytes: 64936
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (size_t i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (size_t k = 1; k < v.size(); k++)
	{
		for (size_t j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int r, d, x;
	cin >> r >> d >> x;
	rep(i, 10)
	{
		x = r * x - d;
		cout << x << endl;
	}
	return 0;
}

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

#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;
int main() {
	fast
		string a;
	cin >> a;
	for (int i = 0; i < a.size(); i++) {
		cout << 'x';
	}
}

 

Measured memory_bytes: 256
import java.util.*;

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

    String s = sc.next();
    int ans = 0;

    for(int i = 0; i < (s.length() / 2); i++){
      if(s.charAt(i) != s.charAt(s.length() - 1 - i)){
        ans += 1;
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 23124
package main

import "fmt"

type data struct {
	graph [][]bool
}

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)

	graph := make([][]bool, n)
	for i := range graph {
		graph[i] = make([]bool, n)
	}

	for i := 0; i < m; i++ {
		var a, b int
		fmt.Scanf("%d %d", &a, &b)
		graph[a-1][b-1], graph[b-1][a-1] = true, true
	}

	d := data{graph: graph}

	visited := make([]bool, n)
	visited[0] = true

	fmt.Println(d.dfs(0, n, visited))
}

func (d data) dfs(v, n int, visited []bool) int {
	allVisited := true
	for i := 0; i < n; i++ {
		if !visited[i] {
			allVisited = false
		}
	}

	if allVisited {
		return 1
	}

	var ret int
	for i := 0; i < n; i++ {
		if !d.graph[v][i] {
			continue
		}

		if visited[i] {
			continue
		}

		visited[i] = true
		ret += d.dfs(i, n, visited)
		visited[i] = false
	}

	return ret
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	//入力
	int N;
	cin >> N;
	vector<int> d(N);
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}
	int count = 0;
	sort(d.begin(), d.end());
	for (int i = 1; i < N; i++) {
		if (d[i] == d[i - 1]) {
			count++;
		}
	}

	cout << N - count;
	return 0;
}

Measured memory_bytes: 256
//
//  BambooBlossoms.cpp
//  ProgrammingContest
//
//  Created by 王叶 on 2018/04/13.
//  Copyright © 2018年 王叶. All rights reserved.
//

#include <stdio.h>
#include <vector>
#include <iostream>
using namespace std;

int main(){
    int maxsize=7368792;
    int m,n=0;
    vector<int> result;
    while(true){

        cin>> m >>n;
        if(m==0&&n==0){
            break;
        }

        vector<bool>dataSet(maxsize);
        for(int i=m;i<=maxsize;i++){
            if(dataSet[i]==false){
                n--;
                for(int j=i;j<maxsize;j=j+i){
                    dataSet[j]=true;
                }
            }
            if(n==0){
                break;
            }
        }
        for(int i=m;i<maxsize;i++){
            if(dataSet[i]==false){
                result.push_back(i);
                break;
            }
        }


    }
    for (int i=0; i<result.size(); i++) {
        cout<<result[i]<<endl;
    }
}



Measured memory_bytes: 4040
#include <stdio.h>
#include <string.h>

int main()
{
    char str[21];
    int i, n;
    
    scanf("%s", str);
    n = strlen(str);
    
    for (i = n - 1; i >= 0; i--)
        printf("%c", str[i]);
    
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 0
// 　　＿＿
// 　／　<＠ﾌ
//  ｜(ﾉﾉハ))
//  ﾉ从ﾟヮﾟ从
// 　ﾉ｜ｿﾉГ|つ author:hotarunx
// 〈_ﾉ^^^ヽ|
// 　~~tｧtｧ~
#include <algorithm>
#include <array>
#include <atcoder/dsu>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
using namespace atcoder;
#define int long long

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);

    int n, m;
    cin >> n >> m;

    dsu d(n);

    vector<int> a(m), b(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;

        d.merge(a[i], b[i]);
    }

    const int ans = d.groups().size() - 1;
    cout << ans << "\n";
}


Measured memory_bytes: 9272
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }

    #[allow(dead_code)]
    pub fn get2<T: FromStr, U: FromStr>() -> (T, U)
    where
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }

    #[allow(dead_code)]
    pub fn get3<S: FromStr, T: FromStr, U: FromStr>() -> (S, T, U)
    where
        <S as FromStr>::Err: Debug,
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
}

#[allow(unused_macros)]
macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn main() {
    let s = util::line().chars().collect::<Vec<_>>();

    if s.first() == s.last() {
        if s.len() % 2 == 0 {
            println!("First");
        } else {
            println!("Second");
        }
    } else {
        if s.len() % 2 == 0 {
            println!("Second");
        } else {
            println!("First");
        }
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9
 
typedef long long ll;
 
using namespace std;
 
const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 2e5+5;
//int a[N];

int main()
 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 	
 	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif

    int d, t, s;

    cin >> d >> t >> s;

    if (((d+s-1)/s) > t) cout << "No";
    else cout << "Yes";

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<int> minus;
    vector<int> plus;
    int zeroCnt = 0;

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

        if(A == 0){
            zeroCnt++;
        }
        else if(A > 0){
            plus.push_back(A);
        }
        else{
            minus.push_back(A);
        }
    }

    sort(plus.begin(), plus.end());
    sort(minus.begin(), minus.end(), greater<int>());

    int mSize = (int)minus.size();
    int pSize = (int)plus.size();
    if(zeroCnt == N){
        cout << 0 << endl;
        for(int i = 0; i < N - 1; i++){
            cout << 0 << " " << 0 << endl;
        }
    }
    else{

        if(zeroCnt != 0){
            if(mSize == 0){
                minus.push_back(0);
                mSize++;
                zeroCnt--;
            }
            else if(pSize == 0){
                plus.push_back(0);
                pSize++;
                zeroCnt--;
            }
        }

        if(mSize == 0){
            int ans = accumulate(plus.begin() + 1, plus.end(), 0) - plus[0];
            cout << ans << endl;

            int sum = plus[0];
            for(int i = 1; i <= pSize - 2; i++){
                cout << sum << " " << plus[i] << endl;
                sum -= plus[i];
            }
            cout << plus[pSize - 1] << " " << sum << endl;;
            sum = plus[pSize - 1] - sum;
            for(int i = 0; i < zeroCnt; i++){
                cout << sum << " " << 0 << endl;
            }
        }
        else if(pSize == 0){
            int ans = minus[0] - accumulate(minus.begin() + 1, minus.end(), 0);
            cout << ans << endl;

            int sum = minus[0];
            for(int i = 1; i <= mSize - 1; i++){
                cout << sum << " " << minus[i] << endl;
                sum -= minus[i];
            }
            for(int i = 0; i < zeroCnt; i++){
                cout << sum << " " << 0 << endl;
            }
        }
        else{
            int plusSum = accumulate(plus.begin(), plus.end(), 0);
            int minusSum = accumulate(minus.begin(), minus.end(), 0);

            int ans = plusSum - minusSum;
            cout << ans << endl;

            int pSum = plus[0];
            for(int i = 1; i < mSize; i++){
                cout << pSum << " " << minus[i] << endl;
                pSum -= minus[i];
            } 

            int mSum = minus[0];
            for(int i = 1; i < pSize; i++){
                cout << mSum << " " << plus[i] << endl;
                mSum -= plus[i];
            }

            cout << pSum << " " << mSum << endl;
            int tempSum = pSum - mSum;
            for(int i = 0; i < zeroCnt; i++){
                cout << tempSum << " " << 0 << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 2424
from math import gcd
from functools import reduce


class SmallestPrimeFactors:
    def __init__(self, n):
        self.spf = list(range(n + 1))
        for i in range(2, int(n ** 0.5) + 1):
            if self.spf[i] == i:
                for j in range(i * i, n + 1, i):
                    if self.spf[j] == j:
                        self.spf[j] = i

    def factor(self, x):
        if self.spf[x] == x:
            return [x]
        nxt = x // self.spf[x]
        return self.factor(nxt) + [self.spf[x]]


def is_PC():
    spf = SmallestPrimeFactors(1_000_000)
    primes = set()
    for a in A:
        if a == 1:
            continue
        new_primes = set(spf.factor(a))
        if primes & new_primes:
            return False
        primes |= new_primes
    return True


def is_SC():
    return reduce(gcd, A) == 1


N, *A = map(int, open(0).read().split())
if not is_SC():
    print("not coprime")
elif is_PC():
    print("pairwise coprime")
else:
    print("setwise coprime")


Measured memory_bytes: 121900
def isPrime(x):
    if x < 2:
        return False
    if x == 2:
        return True
    if x % 2 == 0:
        return False
    cur = 3
    while True:
        if cur * cur > x:
            break
        if x % cur == 0:
            return False
        cur += 2
    return True


Q = int(input())
num = [0] * 100010
for i in range(3,100001,2):
    if isPrime(i) and isPrime((i+1)//2):
        num[i] += 1
for i in range(0,100001):
    num[i+1] += num[i]


for _ in range(Q):
    l,r = map(int, input().split())
    print(num[r] - num[l-1])


Measured memory_bytes: 6388
#include<iostream>
#include<algorithm>
using namespace std;
bool dp[100010];
int main(){
	int n,s;
	cin>>n;
	for(int i=0;i<10010;i++)dp[i]=false;
	dp[0]=true;
	int ans=0;
	for(int i=0;i<n;i++){
		cin>>s;
		for(int j=10010;j>=0;j--){
			if(dp[j]==true)
			{
			if(j+s<10010){
				dp[j+s]=true;
				if((j+s)%10>0){
					ans=max(ans,j+s);
				}
			}
			
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#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;
    vector<int> A(N);
    vector<int> B(N);
    ll ans = 0;
    rep(i, N){
        cin >> A[i];
        B[i] = A[i]%2;
        ans += A[i]/2;
    }
    rep(i, N-1){
        if(B[i] == 0){
            continue;
        } else {
            if(B[i+1] == 1){
                ans++;
                B[i+1] = 0;
            } else if(A[i+1] > 1){
                B[i+1] = 1;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1152
import java.util.*;
import java.io.*;

public class Main {
    static int[] weight;
    static int[] value;
    static long[][] dp;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //BufferedReader br = new BufferedReader(new FileWriter("knapsack1.in");
        //StringTokenizer st = new StringTokenizer(br.readLine());
        //PrintWriter pw = new PrintWriter("knapsack1.out");
        //HashMap<Integer, Integer> map = new HashMap<>();
        int n = sc.nextInt();
        int weightMax = sc.nextInt();

        weight = new int[n+1];
        value = new int[n+1];
        dp = new long[n+1][weightMax+1];
        for(int x = 0; x<n+1; x++){
            Arrays.fill(dp[x], -1);
        }
        for(int x = 1; x<n+1; x++){
            int w = sc.nextInt();
            int v = sc.nextInt();
            weight[x] = w;
            value[x] = v;
        }

        System.out.println(max(n, weightMax));



    }

    public static long max(int i, int w){
        if(dp[i][w] != -1)
            return dp[i][w];
        if(i == 0)
            return dp[i][w] = 0;
        if(w == 0)
            return dp[i][w] = 0;
        if(weight[i] <= w)
            return dp[i][w] = Math.max(value[i] + max(i-1, w - weight[i]), max(i-1, w));
        return dp[i][w] = max(i-1, w);
    }
}


Measured memory_bytes: 127104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[1000005];
ll tp[1000005];
ll l[1000005];
ll h[1000005];
vector<ll> e[1000005];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    n = n % 10;
    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
    {
        cout << "hon\n";
    }
    if(n == 0 || n == 1 || n == 6 || n == 8)
    {
        cout << "pon\n";
    }
    if(n == 3)
    {
        cout << "bon\n";
    }
    return 0;
}


Measured memory_bytes: 27040
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define N (ll)(1e6+3)
#define INF (ll)(1e18+3)

#define ll long long
#define rep(i,a,n) for(ll i = a; i < n; i++)
#define per(i,a,n) for(ll i = n-1; i >= a; i--)

//using namespace __gnu_pbds;
using namespace std;
 
// typedef
// tree<
//     pair<ll,ll>,
//     null_type,
//     less<pair<ll,ll>>,
//     rb_tree_tag,
//     tree_order_statistics_node_update>
// ordered_set;

void fail() {
    cout << "No" << endl;
    exit(0);
}

ll M = 1000000;

void solve() {
    ll H, W, h, w;
    cin >> H >> W >> h >> w;

    if (H%h == 0 && W%w == 0) fail();

    cout << "Yes" << endl;
    if (H%h) {
        rep(i,0,H) {
            rep(j,0,W) {
                if (i%h == 0) cout << M << " ";
                else if (i%h == h-1) cout << -M-1 << " ";
                else cout << 0 << " ";
            }
            cout << endl;
        }
    }
    else if (W%w) {
        rep(i,0,H) {
            rep(j,0,W) {
                if (j%w == 0) cout << M << " ";
                else if (j%w == w-1) cout << -M-1 << " ";
                else cout << 0 << " ";
            }
            cout << endl;
        }
    }



}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long


signed main(){
  int n;
  string s;
  int a[300050];
  int cnt=0;
  int ans=BIG;
  cin>>n>>s;
  a[0]=0;
  repi(i,1,n+1){
    if(s[i-1]=='W') a[i]=a[i-1]+1;
    else a[i]=a[i-1];
  }
  int wsum=a[n];
  repi(i,1,n+1){
    ans=min(ans,(a[i-1]+(n-i)-(wsum-a[i])) );
  }
  cout<<ans<<endl;
  
    

  return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  string s;
  cin >> s;
  
  int answer = 0;
  int i = 0;
    
  while(i <= s.size() - answer){
    if(s.at(i) == 'A'){
      for(int j = i + 1; j < s.size(); j++){
        if(s.at(j) == 'Z'){
          answer = max(j - i + 1, answer);
        }
      }
    }
    i++;
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include<string>
#include<sstream>
#define CAPACITY 9


namespace jisaku{//stoi?????¨?????????????????????????????????????????§??£?¨???????

	int stoi(std::string str){
		int ret;
		std::stringstream ss;
		ss << str;
		ss >> ret;
		return ret;
	}

     std::string to_string(int i){
		 std::string text;
		std::stringstream textline;
		textline<< i;
		textline >> text;
		return text;
	}

}




class OverDigit{

public:

	int num_a[CAPACITY];
	int num_b[CAPACITY];
	OverDigit(std::string str_a, std::string str_b);
	void ChangeDigit(std::string str, int num[]);
	void Add();
};

OverDigit::OverDigit(std::string str_a, std::string str_b){

	ChangeDigit(str_a, num_a);
	ChangeDigit(str_b, num_b);

}

void OverDigit::ChangeDigit(std::string str, int num[]){

	std::vector <int> num_str(CAPACITY, 0);
	int loc = CAPACITY, k = 8;
	int  str_rest,str_Max;

	str_rest = str.length() % CAPACITY;
	str_Max = str.length() / 9;

	for (int j = str.length() - CAPACITY; str_Max > 0; j = j - CAPACITY){
		num_str[k] = jisaku::stoi(str.substr(j, CAPACITY));
		loc = k;
		k--;
		str_Max--;

	}
	//?????????????????????????????????????????\??????

	if (str_rest != 0)num_str[loc - 1] = jisaku::stoi(str.substr(0, str_rest));

	for (int j = 0; j < CAPACITY; j++){
		num[j] = num_str[j];
	}
}
//80????????§????¶???????
void OverDigit::Add(){

	int num_ans[CAPACITY] = {};
	int fat, overflow = 0, count = 0;
	std::string text,t;


	for (int j = CAPACITY - 1; j >0; j--){
		if (num_a[j] + num_b[j] <= 999999999){
			num_ans[j] = num_a[j] + num_b[j];
		}
		else if (num_a[j] + num_b[j] > 999999999){
			fat = (num_a[j] + num_b[j]) - 1000000000;
			num_ans[j] = fat;
			num_a[j - 1]++;
		}

	}

	if (num_a[0] + num_b[0] > 99999999){
		overflow = 1;
	}
	else{
		num_ans[0] = num_a[0] + num_b[0];


	}

	if (overflow == 1){
		std::cout << "overflow" << std::endl;
	}
	else {
		for (int j = 0; j < CAPACITY; j++){
			
          if (num_ans[j] != 0){
				count++;
				t = jisaku::to_string(num_ans[j]);
				if (t.length() != 9){
					for (int l = 0; l < (9 - t.length()); l++){
						text += "0";
					}
				}
				text += t;


			}
			else if (num_ans[j] == 0 && count >= 1){
					text+="000000000";
						}

		}

		int count = 0;
		for (int l = 0; l < text.length(); l++){
			if (count == 0 && text[l] == '0'){
			}
			else {
				std::cout << text[l];
				count++;
			}
		}std::cout << std::endl;
	}

};


int main(){

	
	//vector???????????¨??????80???????¨????
	int N;
	std::string str_a, str_b;

	std::cin >> N;
	std::cin.ignore();

	for (int i = 0; i < N; i++){
		getline(std::cin, str_a);
		getline(std::cin, str_b);
		if (str_a == "0" && str_b == "0"){std::cout << '0' << std::endl;
		}
		else if (str_a.length() >= 81 || str_b.length() >= 81){
		
			std::cout << "overflow" << std::endl;
		}
		else{

			OverDigit OverDigit_a(str_a, str_b);//???????????§??????
			OverDigit_a.Add();
		}
	}
	return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h> 
using namespace std;
int main()
{
	long long int n,w;
	cin>>n>>w;
	long long int a[n],b[n];
	long long int c[w+1]={0};
	int i,j;
	for(i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
	}
	for(i=0;i<n;i++)
	{
		for(j=w-a[i];j>=0;j--)
		{
			if(c[j+a[i]]<c[j]+b[i]) 
			{
				c[j + a[i]] = c[j] + b[i];
			}
		}
	}
	cout<<c[w]<<endl;
	return 0;
}

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

long long MOD = 1e9+7;
vector<vector<long long> > comb(int n) {
  vector<vector<long long> > v(n + 1, vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]) % MOD;
    }
  }
  return v;
}

int main() 
{
    int N, K; cin >> N >> K;
    vector<vector<long long> > v = comb(N);
    for (int i=1; i<=K; i++)
    {
        cout << ((v[N-K+1][i] % MOD)*(v[K-1][i-1]) % MOD) % MOD  << endl;
    }
    return 0;
}



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

int main() {
  int N,M,count,countMax = 0;
  cin >> N;
  vector<string> blue(N);
  
  for(int i = 0;i < N;i++) 
    cin >> blue.at(i);
  
  cin >> M;
  vector<string> red(M);
  
  for(int i = 0;i < M;i++) 
    cin >> red.at(i);
  
  for(int i = 0;i < N;i++) {
    count = 0;
    for(int j = 0;j < N;j++) {
      if (blue.at(i) == blue.at(j)) 
        count++;
    }
    for(int j = 0;j < M;j++) {
      if (blue.at(i) == red.at(j))
        count--;
    }
    countMax = max(count, countMax);
  }
  cout << countMax << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int x = 1;
  
  for (int i = 0; i < N; i++) {
    if (x <= K) {
      x *= 2;
    }
    else {
      x += K;
    }
  }
  
  cout << x << endl;
  
}

Measured memory_bytes: 3616
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

#リストをソート
a = sorted(a)
b = sorted(b)
c = sorted(c)

# x以上のイテレータを
def lower_bound(arr , x):
    l = 0
    r = len(c)
    for j in range(30):
        mid = (l + r) // 2
        # print(l , r , mid)
        if x <= arr[mid]:
            r = mid
        else:
            l = mid
    return r


count = 0
for i in range(n):
    a_count = lower_bound(a , b[i])
    c_count = len(c) - lower_bound(c , b[i] + 1)
    count += a_count * c_count

print(count)


Measured memory_bytes: 29440
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define N 3001
double f[N][N] = {1}, p[N];
int n;
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%lf", &p[i]);
        f[i][0] = f[i - 1][0] * (1 - p[i]);
        for (int j = 1; j <= i; j++)
            f[i][j] = f[i - 1][j - 1] * p[i] + f[i - 1][j] * (1 - p[i]);
    }
    double ans = 0;
    for (int i = n / 2 + 1; i <= n; i++) ans += f[n][i];
    printf("%.10lf\n", ans);
    return 0;
}

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

int main (void){
	int n;
	cin >> n;
	vector<int> v(n);
	for(int i = 0; i < n; ++i){
		cin >> v[i];
	}
	sort(v.begin(),v.end());
	long long sum = 0;
	if(n % 2 == 0){
		for(int i = 0; i < n/2; ++i){
			sum -= 2 * v[i];
		}
		for(int i = n/2; i < n; ++i){
			sum += 2 * v[i];
		}
		sum += v[n/2-1];
		sum -= v[n/2];
	}else{
		long long sum2 = 0;
		for(int i = 0; i < n/2; ++i){
			sum -= 2 * v[i];
		}
		for(int i = n/2; i < n; ++i){
			sum += 2 * v[i];
		}
		for(int i = 0; i < n/2+1; ++i){
			sum2 -= 2 * v[i];
		}
		for(int i = n/2+1; i < n; ++i){
			sum2 += 2 * v[i];
		}
		sum -= v[n/2]; sum -= v[n/2+1];
		sum2 +=v[n/2]; sum2 += v[n/2-1];
		sum = max(sum, sum2);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1272
#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++)
typedef long long int ll;
typedef unsigned long long int ull;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c,n,ans=0;
  string s,t;
  cin >>n;
  rep(i,n) {
    int x;
    cin >>x;
    if(i%2==0&&x%2==1)ans++;
  }
  cout <<ans;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int H, W, A[80][80], B;
bool DP[80][80][28000];

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> B;
			A[i][j] -= B;
		}
	}
	DP[0][0][14000 + A[0][0]] = true;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			for (int k = 0; k < 28000; k++) {
				if (!DP[i][j][k])continue;
				if (i != H - 1) {
					DP[i + 1][j][k + A[i + 1][j]] = true;
					DP[i + 1][j][k - A[i + 1][j]] = true;
				}
				if (j != W - 1) {
					DP[i][j + 1][k + A[i][j + 1]] = true;
					DP[i][j + 1][k - A[i][j + 1]] = true;
				}
			}
		}
	}
	int res = 0xE869120;
	for (int i = 0; i < 28000; i++) {
		if (DP[H - 1][W - 1][i]) {
			res = min(res, abs(i - 14000));
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 173952
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// How to use 「map」
/*
  - 宣言
    map<{key_type}, {value_type}> salary;
  - 要素の挿入
    salary["Alice"] = 1000;
  - 要素の取得 O(logn)
    salary.at("Alice");
  - 要素の削除
    salary.erase("Alice");
  - キー検索
    salary.find("Alice"); -> true
    salary.find("Bob");   -> false
  - イテレーション
    for(auto& [key, value] : salary) {...}
 */
// -------------------------------------


// How to use 「lower_bound」, 「upper_bound」
/*
  vector<int> a = {1, 2, 3, 4, 5};
  auto iter1 = lower_bound(all(a), 3);  <- 第二引数「以上」の最小イテレータが返る
  auto iter2 = upper_bound(all(a), 3);  <- 第二引数「より大きい」最小のイテレータが返る
 */
// -------------------------------------


// How to use 「struct sort」
/*
  struct Person {
    string name;
    int age;

    Person(string _name, int _age) {
      name = _name;
      age = _age;
    }

    bool operator<(const Person &another) const {
      return age < another.age;
    }
  };

  vector<Person> people;
  people.pb(Person("Alice", 20));
  people.pb(Person("Bob", 19));
  people.pb(Person("John", 40));
  people.pb(Person("Chris", 30));
  sort(all(people));
 */
 // -------------------------------------

// -------------------------------------------------------------------------------------



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

  if ((a == b && b == c) || (a != b && b != c && a != c)) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,q,S[10000]={},T[10000]={},karicount=0,X[1000000]={},count=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>S[i];
    }
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>T[i];
    }
    for(int i=0;i<q;i++){
        for(int j=0;j<n;j++){
            if(T[i]==S[j]){
                count+=1;
                break;
            }   
        }
    }
    cout<<count<<endl;
    
}


Measured memory_bytes: 3172
function main()
	N=parse(Int,readline())
	ans=0
	T=Int[]
	for _=1:N
		a,b=map(x->parse(Int,x),split(readline()))
		ans+=a
		push!(T,a+b)
	end
	sort!(T)
	reverse!(T)
	for i=2:2:N
		ans-=T[i]
	end
	println(ans)
end
main()


Measured memory_bytes: 155020
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;

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

  ll n, m;
  cin >> n >> m;

  if(n == 1 && m == 1){
    cout << 1 << endl;
  }
  else if(n == 1){
    cout << (m - 2) << endl;
  }
  else if(m == 1){
    cout << (n - 2) << endl;
  }
  else{
    cout << ((n - 2) * (m - 2)) << endl;
  }

  return 0;
}


Measured memory_bytes: 888
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn solve(h: u64) -> u64 {
    if h == 1 {
        1
    } else {
        1 + 2 * solve(h / 2)
    }
}

fn main() {
    let mut sc = Scanner::new();
    let h: u64 = sc.cin();
    put!(solve(h));
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
import sys
while True:
    height, width = map(int, raw_input().split())
    if height == 0 and width == 0:
        break
    for i in range(height):
        for j in range(width):
            if j % 2 == 0 and i % 2 == 0: #even n, even n
                sys.stdout.write("#")
            elif j % 2 != 0 and i % 2 == 0: #even n, odd n
                sys.stdout.write(".")
            elif j % 2 == 0 and i % 2 != 0: #odd n, even n
                sys.stdout.write(".")
            elif j % 2 != 0 and i % 2 != 0: #odd n, odd n
                sys.stdout.write("#")
        print
    print

Measured memory_bytes: 6448
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(18);
}
signed main(){
  init_io();
  ll n,ans=0;
  cin >> n;
  ll a[n][n],ca[n][n];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin >> a[i][j];
      ca[i][j] = a[i][j];
    }
  }
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        ca[i][j] = min(ca[i][j],ca[i][k]+ca[k][j]);
      }
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(a[i][j]!=ca[i][j]){
        cout <<"-1\n";
        return 0;
      }
    }
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      bool is_mi = true;
      for(int k=0;k<n;k++){
        if(i==k||k==j) continue;
        if(ca[i][j]==ca[i][k]+ca[k][j]){
          is_mi=false;
          break;
        }
      }
      if(is_mi){
        ans += ca[i][j];
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1664
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << min(a,b) + min(c,d) << endl;
}

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

int main(){
  int n,v[1000],w[1000],W,casenum = 0;
  int dp[1001][1001];
  const int INF = 100000000;
  
  while(scanf("%d",&W),W){
    casenum++;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d,%d",&v[i],&w[i]);
    
    for(int i=0;i<=W;i++)dp[0][i] = 0;

    int ansv = 0, answ = 0;
    for(int i=0;i<n;i++){
      for(int j=0;j<=W;j++){
	dp[i+1][j] = dp[i][j];
	if(j>=w[i] && dp[i+1][j] < dp[i][j-w[i]] + v[i]){
	  dp[i+1][j] = dp[i][j-w[i]] + v[i];
	  if( ansv < dp[i+1][j] || (ansv == dp[i+1][j] && answ > j) ){
	    ansv = dp[i+1][j]; answ = j;
	  }
	}
      }
    }
    
    printf("Case %d:\n",casenum);
    printf("%d\n%d\n",ansv,answ);
  }
}

Measured memory_bytes: 4948
#include <bits/stdc++.h>
using namespace std ;
 
const long long mod = 1e9 + 7 ;
 
int a[312345];
int n, m, dp[312345], par[312345], bad[312345];
pair <int, int> t[312345 * 4];

void upd(int v, int tl, int tr, int pos, int val) {
	if(tl == tr) {
		t[v].first=val;
		t[v].second=pos;

	} else {
		int tm = (tl + tr) / 2;
		if(pos <= tm)
			upd(v + v, tl, tm, pos, val);
		else upd(v + v + 1, tm + 1, tr, pos, val);
		if(t[v + v].second) {
			t[v] = t[v + v];
			if(t[v + v + 1].second){
				t[v] = min(t[v + v], t[v + v + 1]);
			}
		}
		else t[v] = t[v + v + 1];

	}
}

pair <int, int>get(int v, int tl, int tr, int l, int r) {
	if(l > r) return {(int)1e9,0};

	if(tl == l && tr == r) {
		return t[v];
	}
	int tm =(tl+tr)/2;

	return min(get(v + v, tl, tm, l, min(tm, r)),
				get(v +v +1,tm + 1, tr, max(l, tm + 1), r));
}

int main ( ) {

	cin >> n >> m;
	for(int i =1; i<= n + 1; i++) {
		char c;
		cin >> c;
		if(c=='1') bad[i]=1;
	}
	for(int i = 0; i < 312345 * 4; i++)
		t[i].first=1e9+7,t[i].second=0;
	memset(par,-1,sizeof(par));
	memset(dp,-1,sizeof(dp));
	dp[n+1]=0;
	upd(1, 1, n + 1, n + 1, 0);

	bool gg = 0;
	for(int i = n; i >= 1; i--) {
		if(bad[i])continue;

		pair <int, int> tmp = get(1, 1, n + 1, i + 1, min(n + 1, i + m));
		if(tmp.second==0) {
			gg=1;
			continue;
		}
		par[i] = tmp.second;
		dp[i] = tmp.first+1;
		upd(1, 1, n + 1, i, dp[i]);
	}
	//cout<<dp[1];

	if(dp[1]!=-1&&gg==0){
		int f = 1;
		while(par[f]!=-1) {
			cout<<par[f]-f<<endl;
			f=par[f];
		}
	}else cout << -1;
	return 0;
}

Measured memory_bytes: 14720
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
def LILI(n): return [LI() for _ in range(n)]
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    H, W = LI()
    maze = [SI() for _ in range(H)]

    ans = [[0 for _ in range(W+1)] for _ in range(H+1)]  # 1つ加えることで番兵とする。Python の場合、[-1] == [N-1] なので、上下左右に加えなくても、右と下に加えるだけでいい（ナナメ移動があるときは注意）。
    ans[0][0] = 1

    for j in range(W):
        for i in range(H):
            if (i, j) == (0, 0): continue
            if maze[i][j] == '#':
                continue
            else:
                ans[i][j] = (ans[i-1][j] + ans[i][j-1])%MOD

    print(ans[H-1][W-1])

main()

Measured memory_bytes: 44632
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

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

    static class TaskA {
        public void solve(int testNumber, FasterScanner in, PrintWriter out) {
            int n = in.nextInt();
            out.println(in.nextInt() >= n ? n : n - 1);
        }

    }

    static class FasterScanner {
        private InputStream in;
        private byte[] buffer;
        private int bufPointer;
        private int bufLength;

        public FasterScanner(InputStream in) {
            this.in = in;
            buffer = new byte[1024];
        }

        private boolean hasNextByte() {
            if (bufPointer < bufLength) return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        }

        private int readByte() {
            if (hasNextByte()) return buffer[bufPointer++];
            return -1;
        }

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

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++;
            return hasNextByte();
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9') throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 22484
from sys import exit
A,B = map(int,input().split())

satA = []
i = 0
while True:
    if int(i * 0.08) == A:
        satA.append(i)
        i += 1
    else:
        if len(satA) != 0:
            break
        else:
            i += 1

for i in satA:
    if int(i * 0.1) == B:
        print(i)
        exit(0)

print(-1)

Measured memory_bytes: 9092
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	boolean check(boolean[] sw, int m) { //スイッチの状態がswのとき、m番目の電球がつくか
		int c = 0;
		
		for(int i=0;i<k[m];i++) {
			if(sw[s[m][i]-1])c++;
		}
		
		return c%2 == p[m];
	}
	
	boolean checkAll(boolean[] sw) {
		
		for(int i=0;i<M;i++) {
			if(!check(sw,i)) {
				return false;
			}
		}
		return true;
	}
	
	int[] p;
	int N,M;
	int[][] s;
	int[] k;
	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		N = sc.nextInt();
		M = sc.nextInt();
		
		
		k = new int[M];
		s = new int[M][N];
		
		for(int i=0;i<M;i++) {
			k[i] = sc.nextInt();
			for(int j=0;j<k[i];j++) {
				s[i][j] = sc.nextInt();
			}
		}
		
		p = new int[M];
		for(int i=0;i<M;i++) {
			p[i] = sc.nextInt();
		}
		
		int ans = 0;
		System.err.println("--");
		for(int i=0;i<Math.pow(2, N);i++) {
			boolean[] sw = new boolean[N];
			for(int j=0;j<N;j++) {
				sw[j] = ((i>>j) & 0x01) == 1;
			}
			System.err.println(Arrays.toString(sw));
			
			if(checkAll(sw)) {
				ans++;
			}
		}
		
		out.println(ans);
		
		
		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  cout << (a+b+1)/2 << endl;

  return 0;
}


Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll a,b;cin>>a>>b;
    string ans;
    if(a==0||b==0)ans="Zero";
    else if(a>0&&b>0)ans="Positive";
    else if(a<0&&b>0)ans="Zero";
    else if(a>0&&b<0)ans="Zero";
    else{
        if((b-a)%2==0)ans="Negative";
        else ans="Positive";
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 256