akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
    int n, m, a[5], b[5];
    cin >> n >> m;
    for (int in = 0; in < m; in++)
    {
        cin >> a[in] >> b[in];
    }

    for (int i = 0; i < 1000; i++)
    {
        string s = to_string(i);
        if (s.length() == n)
        {
            int j;
            for (j = 0; j < m; j++)
            {
                if (s[a[j] - 1] != b[j] + '0')
                {
                    break;
                }
            }

            if (j == m)
            {
                cout << s << endl;
                return 0;
            }
        }
    }

    cout << -1 << endl;

    /*
    if (!m)
    {
        cout << -1 << endl;
        return 0;
    }

    string s = "";
    for (int asdf = 0; asdf < n; asdf++)
    {
        s += '?';
    }

    for (int i = 0; i < m; i++)
    {
        int x;
        char y;
        cin >> x >> y;

        if (s[x - 1] == '?' || s[x - 1] == y)
        {
            s[x - 1] = y;
        }
        else
        {
            cout << -1 << endl;
            return 0;
        }
        
    }

    if (n != 1 && s[0] == '0')
    {
        cout << -1 << endl;
        return 0;
    }

    if (s[0] ==  '?') s[0] = 1;
    for (int i = 1; i < n; i++)
    {
        if (s[i] == '?')
        {
            s[i] = '0';
        }
    }
 
    cout << s << endl;
    */
}

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

int main()
{
  int map[30][32];
  int x,y;
  int w,n;
  int tmp;

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

  for(int i=1;i<=n;i++){
    scanf("%d,%d ",&x,&y);
    map[x-1][i] = y-1;
    map[y-1][i] = x-1;
  }

  for(int i=0;i<w;i++){
    tmp=i;
    for(int j=1;j<=n;j++)tmp = map[tmp][j];
    map[tmp][n+1] = i;
  }

  for(int i=0;i<w;i++)cout << map[i][n+1]+1 << endl;

  return 0;
}

Measured memory_bytes: 0
#include"iostream"
 
using namespace std;
int judge[2];
int main(){
 string s;
  cin>>s;
  for(int i=0;i<3;i++)
     judge[s[i]-'A']=1;
  bool ans=true;
  for(int i=0;i<2;i++)
     if(judge[i]==0)
         ans=false;
  if(ans)  cout<<"Yes"<<endl;
  else   cout<<"No"<<endl;
  
  return 0;
}

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

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] input = br.readLine().split(" ");
        int a = Integer.parseInt(input[0]);
        int b = Integer.parseInt(input[1]);
        int c = Integer.parseInt(input[2]);
        int d = Integer.parseInt(input[3]);
        int ans = 0;
        
        if(a <= c && c <= b && b <= d){
            ans = b - c;
        }else if(c <= a && a <= d && d <= b){
            ans = d - a;
        }else if(a <= c && d <= b){
            ans = d - c;
        }else if(c <= a && b <= d){
            ans = b - a;
        }else{
            ans = 0;
        }
        
        out.println(ans);
        out.close();
        
    }
}

Measured memory_bytes: 32872
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    string s; cin >> s;
    int len = s.length();
    VI n(len);
    FOR(i, 0, len)n[i] = s[i] - '0';

    vector<bool> z(len+1);
    z[len] = true;
    rFOR(i, 0, len) {
        if (s[i] == '0')z[i] = true;
        else break;
    }
    auto dp = defvec<int>(INF, len + 1, 2);
    dp[0][0] = 0;
    dp[0][1] = 1;
    FOR(i, 0, len) {
        if (z[i + 1])chmin(dp[i + 1][0], dp[i][1] + 10 - n[i]);
        else {
            chmin(dp[i + 1][1], dp[i][1] + 9 - n[i]);
            chmin(dp[i + 1][0], dp[i][1] + 10 - n[i]);
        }
        chmin(dp[i + 1][1], dp[i][0] + n[i] + 1);
        chmin(dp[i + 1][0], dp[i][0] + n[i]);
    }
    cout << min(dp[len][1], dp[len][0]) << "\n";
}

Measured memory_bytes: 60060
# -*- coding: utf-8 -*-
"""
Created on Wed Mar  6 14:59:59 2019

@author: Yamazaki Kenichi
"""

N,M = map(int,input().split())
bb = [list(map(int,(input().split()))) for i in range(M)]

def comb2(N):
    return N*(N-1)//2
ans = [int(comb2(N))]
bb.reverse()

T = [[-1,1] for i in range(N+1)]
def p(u):
    return T[u][0]
def findset(u):
    if p(u) == -1:
        return u
    else:
        T[u][0] = findset(p(u))
        return T[u][0]
def unite(u,v):
    if findset(u) == findset(v):
        return    
    if T[findset(u)][1] >= T[findset(v)][1]:
        T[findset(u)][1] += T[findset(v)][1]
        T[findset(v)][0] = findset(u)
    else:
        T[findset(v)][1] += T[findset(u)][1]
        T[findset(u)][0] = findset(v)
        
for c in bb:
    if findset(c[0]) != findset(c[1]):
        res1 = T[findset(c[0])][1]
        res2 = T[findset(c[1])][1]
        unite(c[0],c[1])
        ans.append(ans[-1]-res1*res2)
    else:
        ans.append(ans[-1])
for i in range(M):
    print(ans[-i-2])


Measured memory_bytes: 39788
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N;
ll K;
P a[100100];
int main(){
	cin >> N >> K;
	for(int i=0;i<N;i++){
		cin >> a[i].fi >> a[i].sec;
	}
	sort(a,a+N);
	for(int i=0;i<N;i++){
		K -= a[i].sec;
		if(K<=0){
			cout << a[i].fi << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        int maxVal = (int)(Math.Pow(10,9) + 7);
        int[] arr = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        int n = arr[0];
        int a = arr[1];
        int b = arr[2];
        var ans = ModInt.Pow(2, n) - 1 - nCr(n, a) - nCr(n, b);
        Console.WriteLine(ans);

    }

    static ModInt nCr(int n, int r)
    {
        ModInt ans = 1;
        // 分子
        for (int i = 0; i < r; i++)
        {
            ans *= n - i;
        }
        // 分母
        for (int i = 1; i <= r; i++)
        {
            ans /= i;
        }
        return ans;
    }

    public struct ModInt
    {
        public const long Mod = (int)1e9 + 7;
        public long num;
        public ModInt(long n) { num = n; }
        public override string ToString() { return num.ToString(); }
        public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }
        public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }
        public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }
        public static ModInt operator /(ModInt l, ModInt r) { return l * Inverse(r); }
        public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }
        public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }
        public static ModInt Pow(long v, long k)
        {
            long ret = 1;
            for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)
                if ((k & 1) == 1) ret = ret * v % Mod;
            return new ModInt(ret);
        }
        public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
        private static List<ModInt> Facs = new List<ModInt> { 1 };
        public static ModInt Fac(int n)
        {
            for (int i = Facs.Count; i <= n; i++)
            {
                Facs.Add(i * Facs[i - 1]);
            }
            return Facs[n];
        }
        public static ModInt nCr(int n, int r)
        {
            if (n < r) return 0;
            if (n == r) return 1;
            return Fac(n) / (Fac(r) * Fac(n - r));
        }
    }



}




Measured memory_bytes: 13396
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    let mut m = n + 1;
    let mut ans = 0;
    for &x in &v {
        if x < m {
            ans += 1;
            m = x;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;


int main() {
	int N, W;
	cin >> N >> W;
    vector<int> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    vector<vector<ll>> dp(110, vector<ll>(101010));
    int maxV = N*1000;
    rep(i, N+1) rep(j, maxV+1) dp[i][j] = LINF;
    dp[0][0] = 0;

    rep(i, N) rep(j, maxV+1) {
        dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]], dp[i][j]+w[i]);
    }

    ll ans = 0;
    rep(j, maxV+1) {
        if (dp[N][j] <= W) ans = j;
    }
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 89448
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

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

    std::vector<int> l(n);
    for (int i = 0; i < n; i++) {
        std::cin >> l[i];
    }

    auto dfs = [&](auto f, int num, int a_len, int b_len, int c_len) -> int {
        if (num == n) {
            if (std::min({ a_len, b_len, c_len }) > 0) {
                return std::abs(a - a_len) + std::abs(b - b_len) + std::abs(c - c_len) - 30;
            } else {
                return 1e9;
            }
        }

        int no_extentions = f(f, num + 1, a_len, b_len, c_len);
        int extends_a = f(f, num + 1, a_len + l[num], b_len, c_len) + 10;
        int extends_b = f(f, num + 1, a_len, b_len + l[num], c_len) + 10;
        int extends_c = f(f, num + 1, a_len, b_len, c_len + l[num]) + 10;
        return std::min({ no_extentions, extends_a, extends_b, extends_c });
    };

    std::cout << dfs(dfs, 0, 0, 0, 0);
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        k: usize,
        a: [i64; n],
    }

    let mut sums = vec![];
    for i in 0..n {
        let mut sum = 0;
        for j in i..n {
            sum += a[j];
            sums.push(sum);
        }
    }

    let mut valid = vec![true; sums.len()];
    let mut ans: i64 = 0;

    for b in (0..50).rev() {
        let mut cnt = 0;
        for i in 0..sums.len() {
            if valid[i] && sums[i] & (1 << b) != 0 {
                cnt += 1;
            }
        }

        if cnt >= k {
            ans += 1 << b;
            for i in 0..sums.len() {
                if valid[i] && sums[i] & (1 << b) == 0 {
                    valid[i] = false;
                }
            }
        }
    }

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


Measured memory_bytes: 9976
n = int(input())
arr = [int(j) for j in input().split()]

su1 = 0
su2 = sum(arr)
abc = []
for i in range(n):
	su1 += arr[i]
	su2 -= arr[i]
	abc += [abs(su1-su2)]

print(min(abc))

# print(abc)

Measured memory_bytes: 26224
#include <bits/stdc++.h>
using namespace std;
int n;
int a[1444][1444];
int p[1444][1444];
int getres(int l,int r,int u,int d){return p[d][r]-p[u-1][r]-p[d][l-1]+p[u-1][l-1];}
int main(){
	cin.tie(0);
	int n,m;cin>>n>>m;
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)cin>>a[i][j];
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)
	p[i][j]=p[i-1][j]+p[i][j-1]-p[i-1][j-1]+a[i][j];
	int res=0;
	for(int s=1-m;s<=n-1;s++){
		int i1,j1;
		if(s<=0)i1=1,j1=1-s;
		else j1=1,i1=s+1;
		for(int i=i1,j=j1;i<=n&&j<=m;){
			if(getres(j1,j,i1,i)==0){
				res=max(res,(j-j1+1)*(i-i1+1));// 其实这俩数字相等啦…… 
				i++,j++;
			}else{
				i1++,j1++;
			}
		}
	}
	cout<<res<<endl;
	return 0;
}



Measured memory_bytes: 18856
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

const int MaxN = 1e6;
int n, m, i, j, t, k, p, q, sum, flag;
int a, b, c[MaxN];

int main()
{
	while(cin >> a >> b >> k)
	{
		flag = 0;
		if((b - a + 1) / 2 >= k)
		{
			for(i = a;; i++) 
			{
				flag++;
				printf("%d\n", i);
				if(flag == k)  break;
			}
			flag = 0;
			for(i = b;; i--)
			{
				flag++;
				c[flag] = i;
				if(flag == k) break;
			}
			for(i = flag; i > 0; i--)  printf("%d\n", c[i]);
		}
		else
			for(i = a; i <= b; i++)  printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static int[][] dp;
    public static ArrayList<Integer>[] al;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        al = new ArrayList[n];
        for(int i = 0; i<n; i++){
            al[i] = new ArrayList<Integer>();
            al[i].add(i);
        }

        for(int i=0; i<m; i++){
            int ma = sc.nextInt() - 1;
            int mb = sc.nextInt() - 1;
            al[ma].add(mb);
            al[mb].add(ma);
        }

        int q = sc.nextInt();
        int[][] p = new int[q][3];

        for(int i=0; i<q; i++){
            p[i][0] = sc.nextInt() - 1;
            p[i][1] = sc.nextInt();
            p[i][2] = sc.nextInt();
        }
        sc.close();

        dp = new int[n][11];
        for(int i=0; i<n; i++){
            for(int j=0; j<11; j++){
                dp[i][j] = -1;
            }
            
        }

        for(int i=0; i<q; i++){
            paint(p[q-i-1][0], p[q-i-1][1], q-i-1);
        }

        for(int i=0; i<n; i++){
            if(dp[i][0] == -1){
                System.out.println("0");
            }else{
                System.out.println(p[dp[i][0]][2]);
            }
        }
    }

    public static void paint(int v, int d, int t){
        if(dp[v][d] != -1) return;

        dp[v][d] = t;
        if(d == 0) return;
        for(int i=0; i<al[v].size(); i++){
            paint(al[v].get(i), d-1, t);
        }
    }
}

Measured memory_bytes: 177928
#include<bits/stdc++.h>
using namespace std;
#define int long long int
signed main()
{
   int k,s=0;
   cin>>k;
   for(int i=1;i<=k;i++)
   {
       for(int j=1;j<=k;j++)
       {
           for(int l=1;l<=k;l++)
           {
               int a=__gcd(i,j);
               int b=__gcd(a,l);
               s+=b;
           }
       }
   }
   cout<<s<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N,M;
    cin>>N>>M;
    vector<bool> A(N);
    vector<int> B(N,0);
    REP(i,M){
        int p;
        string s;
        cin>>p>>s;
        p--;
        if(s=="AC") A[p]=true;
        else if(!A[p]) B[p]++;
    }
    int a=0,b=0;
    REP(i,N) if(A[i]){
        a++;
        b+=B[i];
    }
    cout<<a<<" "<<b<<endl;
}

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

using Graph = vector<vector<int>>;

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

  Graph g(n);
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    g[a - 1].push_back(b - 1);
    g[b - 1].push_back(a - 1);
  }

  vector<int> dist(n, -1);
  vector<int> nex(n, -1);
  queue<int> que;

  dist[0] = 0;
  nex[0] = 0;
  que.push(0);

  while(!que.empty()){
    int v = que.front();
    que.pop();

    for(int nv : g[v]){
      if(dist[nv] != -1) continue;

      dist[nv] = dist[v] + 1;
      nex[nv] = v;
      que.push(nv);
    }
  }

  for(int i = 0; i < n; i++){
    if(dist[i] == -1){
      cout << "No" << endl;
      return 0;
    }
  }


  cout << "Yes" << endl;
  for(int i = 1; i < n; i++){
    cout << nex[i] + 1 << endl;
  }

  return 0; 
}


Measured memory_bytes: 10656
#include <bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(int i = a;i < b;i++)
#define Rep(i,n) For(i,0,n)
#define All(a) a.begin(),a.end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9

typedef long long ll;
const ll MOD = 1000000007;

ll gcd(ll a,ll b){
  if(a < b){
    ll temp = a+b;
    a = temp - a;
    b = temp - b;
  }
  ll c = 1;
  if(b == 0)return a;
  while(c != 0){
    c = a%b;
    if(c == 0)return b;
    a = b;
    b = c;
  }
}

ll N;

int main(){
  cin >> N;
  vector<ll> A(N);
  vector<ll> B(N);
  map<pair<ll,ll>,pair<ll,ll>> m;
  vector<pair<ll,ll>> key;
  vector<ll> pow_2(N+10);
  pow_2[0] = 1;
  Rep(i,N+5){
    pow_2[i+1] = 2*pow_2[i];
    pow_2[i+1] %= MOD;
  }
  ll zero = 0;
  Rep(i,N){
    cin >> A[i] >> B[i];
    if(A[i] == 0 && B[i] == 0){
        zero++;
        continue;
    }
    else if(A[i] == 0)B[i] = -1;
    else if(B[i] == 0)A[i] = 1;
    else{
      ll GCD = gcd(abs(A[i]),abs(B[i]));
      A[i] /= GCD;
      B[i] /= GCD;
      if(A[i] < 0){
        A[i] *= (ll)-1;
        B[i] *= (ll)-1;
      }
    }
    pair<ll,ll> p;
    pair<ll,ll> num;
    if(B[i] >= 0)p = make_pair(A[i],B[i]);
    else p = make_pair(-B[i],A[i]);
    if(m.count(p) == 1){
      num = m[p];
      if(B[i] >= 0)num.first++;
      else num.second++;
      m[p] = num;
    }else{
      if(B[i] >= 0)num = make_pair((ll)1,(ll)0);
      else num = make_pair((ll)0,(ll)1);
      m.emplace(p,num);
      key.push_back(p);
    }
  }
  
  ll n = key.size();
  //cout << n << endl;
  ll ans = 1;
  Rep(i,n){
    auto p = m[key[i]];
    ll t = pow_2[p.first]+pow_2[p.second]-1;
    t %= MOD;
    ans *= t;
    ans %= MOD;
  }
  ans %= MOD;
  cout << (ans+MOD-1+zero)%MOD << endl;
  //cin >> n;
}

Measured memory_bytes: 26644
# include <iostream>
# include <string.h>
using namespace std;
const int N=31;
int a[N];
string b;
int n,s;
void work (void)
{
	int i,j,k,t;
	for (i=0;i<=n-2;i++)
	{
		j=0;
		t=0;
		memset (a,0,sizeof (a));
		while (j<=i)
		{
			k=b[j]-96;
			a[k]=1;
			j++;
		}
		while (j<n)
		{
			k=b[j]-96;
			if (a[k]==1)
			a[k]=2;
	        j++;
		}
		for (j=1;j<=26;j++)
		if (a[j]==2)
		t++;
		if (t>s)
		s=t;
	}
	cout<<s;
}
int main (void)
{
	cin>>n;
	cin>>b;
	work ();
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        long x = in.nextLong();
        long y = in.nextLong();

        int c = 0;
        while (x <= y) {
            c++;
            x *= 2;
        }

        out.println(c);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}


Measured memory_bytes: 20948
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int point1 = 0, point2 = 0;
		String animal1, animal2;
		for (int i = 0; i < n; i++) {
			animal1 = sc.next();
			animal2 = sc.next();
			char[] array1 = animal1.toCharArray();
			char[] array2 = animal2.toCharArray();
			int arrayLength = Math.min(array1.length, array2.length);
			for (int j = 0; j < arrayLength; j++) {
				if (array1[j] > array2[j]) {
					point1 += 3;
					break;
				} else if (array1[j] < array2[j]) {
					point2 += 3;
					break;
				} else if (j == arrayLength - 1) {
					if (array1.length == array2.length) {
						point1 += 1;
						point2 += 1;
						break;
					} else if (array1.length > array2.length) {
						point1 += 3;
						break;
					} else {
						point2 += 3;
						break;
					}
				}
			}
		}
		System.out.println(point1 + " " + point2);
		sc.close();
	}
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  int a = 0;
  for (int j = 0; j < N; j++) {
    if (j % 2 == 1) {
      continue;
    }
    else if (vec.at(j) % 2 == 0) {
      continue;
    }
    else {
      a++;
    }
  }
  
  cout << a << endl;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (b - a == c - b) {
    cout << "YES" << endl;
    return 0;
  } else {
    cout << "NO" << endl;
    return 0;
  }
}


Measured memory_bytes: 256
"""
scc の計算自体は 300～400ms程度。
あとは import と出力"""

import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8, i8[:, :], i8[:], i8[:], i8[:], i8[:], i8[:], i8, i8, i8, i8),
      cache=True)
def scc_dfs(N, G, idx, low, ord, ids, visited, now_ord, group_num, vis_i, v):
    low[v] = ord[v] = now_ord
    now_ord += 1
    visited[vis_i], vis_i = v, vis_i + 1
    for e in range(idx[v], idx[v + 1]):
        to = G[e, 1]
        if ord[to] == -1:
            now_ord, group_num, vis_i = \
                scc_dfs(N, G, idx, low, ord, ids,
                        visited, now_ord, group_num,
                        vis_i, to)
            low[v] = min(low[v], low[to])
        else:
            low[v] = min(low[v], ord[to])
    if low[v] == ord[v]:
        while True:
            u, vis_i = visited[vis_i - 1], vis_i - 1
            ord[u] = N
            ids[u] = group_num
            if u == v:
                break
        group_num += 1
    return now_ord, group_num, vis_i


@njit((i8, i8[:, :]), cache=True)
def scc(N, G):
    idx = np.searchsorted(G[:, 0], np.arange(N + 1))
    low = np.zeros(N, np.int64)
    ord = np.zeros(N, np.int64) - 1
    now_ord = 0
    group_num = 0
    visited, vis_i = np.empty(N, np.int64), 0
    ids = np.zeros(N, np.int64)
    for v in range(N):
        if ord[v] == -1:
            now_ord, group_num, vis_i = \
                scc_dfs(N, G, idx, low, ord, ids,
                        visited, now_ord, group_num,
                        vis_i, v)
    return group_num, group_num - ids - 1

@njit((i8, i8[:, :]), cache=True)
def main(N, G):
    n_comp, comp = scc(N, G)
    ans = np.empty((N, 2), np.int64)
    ans[:, 0] = np.arange(N)
    ans[:, 1] = comp
    ans = ans[np.argsort(ans[:, 1])]
    idx = np.searchsorted(ans[:, 1], np.arange(n_comp + 1))
    print(n_comp)
    for c in range(n_comp):
        V = ans[idx[c]:idx[c + 1], 0]
        print(len(V))
        for v in V:
            print(v)

N, M = map(int, readline().split())
AB = np.array(read().split(), np.int64).reshape(-1, 2)

AB = AB[np.argsort(AB[:, 0])]

main(N, AB)

Measured memory_bytes: 178576
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int N, M;
int X[100000];
vector<int> md[100000];
vector<pair<int, int>> md2[100000];

int main(int argc, char **argv) {
	cin >> N >> M;
	REP(i, N) {
		cin >> X[i];
		md[X[i] % M].push_back(X[i]);
	}
	REP(i, M) {
		sort(ALL(md[i]));
		int p = -1, cnt = 0;
		REP(j, md[i].size()) {
			if (md[i][j] != p) {
				if (cnt != 0) {
					md2[i].push_back(MP(p, cnt));
				}
				p = md[i][j];
				cnt = 0;
			}
			++cnt;
		}
		if (cnt != 0) md2[i].push_back(MP(md[i][md[i].size() - 1], cnt));
	}
	int res = md[0].size() / 2;
	FOR(i, 1, (M - 1) / 2 + 1) {
		int a = 0, b = 0;
		while (true) {
			while (a < md2[i].size() && md2[i][a].second % 2 == 0) ++a;
			while (b < md2[M - i].size() && md2[M - i][b].second % 2 == 0) ++b;
			if (a >= md2[i].size()) {
				int k = 0;
				while (b < md2[M - i].size()) {
					while (k < md2[i].size() && md2[i][k].second == 0) ++k;
					if (k == md2[i].size()) break;
					--md2[i][k].second; --md2[M - i][b].second;
					++res;
					while (b < md2[M - i].size() && md2[M - i][b].second % 2 == 0) ++b;
				}
				break;
			}
			if (b >= md2[M - i].size()) {
				int k = 0;
				while (a < md2[i].size()) {
					while (k < md2[M - i].size() && md2[M - i][k].second == 0) ++k;
					if (k == md2[M - i].size()) break;
					--md2[i][a].second; --md2[M - i][k].second;
					++res;
					while (a < md2[i].size() && md2[i][a].second % 2 == 0) ++a;
				}
				break;
			}
			--md2[i][a].second; --md2[M - i][b].second;
			++res;
		}
		REP(j, md2[i].size()) res += md2[i][j].second / 2;
		REP(j, md2[M - i].size()) res += md2[M - i][j].second / 2;
	}
	if (M % 2 == 0) {
		int a = 0, b = 0;
		while (true) {
			while (a < md2[M / 2].size() && md2[M / 2][a].second % 2 == 0) ++a;
			b = a + 1;
			while (b < md2[M / 2].size() && md2[M / 2][b].second % 2 == 0) ++b;
			if (b >= md2[M / 2].size()) break;
			--md2[M / 2][a].second; --md2[M / 2][b].second;
			++res;
		}
		REP(j, md2[M / 2].size()) res += md2[M / 2][j].second / 2;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define forn(i,n) for(ll (i) = 0 ; (i) < (n) ; ++(i))
#define for1(i,n) for(ll (i) = 1 ; (i) <= (n) ; ++(i))
#define vll vector<ll>
#define pll pair<ll ,ll >
#define vpll vector< pll >
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
#define endl "\n"
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

ll extended_GCD(ll a , ll b , ll &x , ll &y){
    if(a == 0){
        x = 0;
        y = 1;
        return b;
    }
    ll x1 , y1;
    ll gcd = extended_GCD(b%a , a , x1 , y1);
    x = y1 - (b/a)*x1; 
    y = x1;
    return gcd;
}
ll modinv(ll a , ll mod = MOD){
    ll x , y;
    extended_GCD(a , mod , x , y);
    if(x < 0) x += mod;
    return x;
}
ll power(ll a, ll b, ll m = MOD) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll binomialCoeff(ll n,ll k) 
{ 
    ll res = 1; 
    if ( k > n - k ) 
        k = n - k; 

    for (  ll i = 0; i < k; ++i) 
    { 
        res = (res* (n - i))%MOD; 
        res = (res* modinv(i + 1))%MOD; 
    } 
    return res; 
} 

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    ll t=1;
    //cin>>t;
    while(t--){
        ll n,x,ans=0,c=0,sum=0;
        ll m,y;
        cin>>n>>m;
        bool vis[n+1]={0};
        vll id(n+1,0);
        vll v[n+1];
        ll a[n+1]={0};
        forn(i,m){
            cin>>x>>y;
            v[x].pb(y);
            a[y]=1;
            id[y]++;
        }
        vll idx;
        for1(i,n){
            if(a[i]==0){
                idx.pb(i);
                // break;
            }
        }
        vll d(n+1,0);
        for (auto &&it : idx)
        {       
            queue<ll>q;
            if(id[it]==0 && !vis[it])
                q.push(it);
            while(!q.empty()){
                ll tmp=q.front();
                q.pop();
                vis[tmp]=1;
                for (auto &&i : v[tmp])
                {
                    id[i]--;
                    d[i]=max(d[i],d[tmp]+1);
                    if(id[i]==0 && !vis[i])
                        q.push(i);
                }
            }
        }
        ans=*max_element(all(d));
        cout<<ans<<endl;
    }
    // #ifndef ONLINE_JUDGE
    //     cout<<endl<<"Time Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec"<<endl;
    // #endif
}

Measured memory_bytes: 8192
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  long long N, A, B, C, D, E;
  long long minval = 10000000000000000;
  scanf("%lld",&N);
  scanf("%lld",&A);
  scanf("%lld",&B);
  scanf("%lld",&C);
  scanf("%lld",&D);
  scanf("%lld",&E);
  minval = std::min(minval, A);
  minval = std::min(minval, B);
  minval = std::min(minval, C);
  minval = std::min(minval, D);
  minval = std::min(minval, E);
  long long ans = (N+minval-1)/minval;
  printf("%lld\n",5+ans-1);
  return 0;
}


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

#define LL long long
#define MOD 1000000007
#define rep(i,n) for(int i = 0;i < (n);i++)

using namespace std;

LL gcd(LL C, LL D) {
	if (C < D) gcd(D, C);

	if (C%D == 0)return D;
	else gcd(D, C%D);
}



int main() {
	string s, t;
	int ans = 0;

	cin >> s >> t;
	for (int i = 0; i < s.length()-t.length()+1; i++) {
		int cnt = 0;
		rep(j, t.length()) {
			if (s[i+j] == t[j]) {
				cnt++;
			}
		}
		ans = max(ans, cnt);
	}

	cout<< t.length()-ans << endl;
  return 0;
}






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

int main(){
    int S, h, m, s;
    cin >> S;
    
    h = S / 3600;
    m = S % 3600 / 60;
    s = S % 3600 % 60;
    
    printf("%d:%d:%d\n",h,m,s);
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
 
#define 	pi 				3.14159265358979
#define 	mod 			1000000007
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(ll i = a ; i < b ; i++)
#define     repn(i, a, b)   for(ll i = a ; i > b ; i--)
#define 	mod1 			1000003
#define     mod2            998244353
#define     inf             2e18
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define     sz              size()
#define     len             length()
#define 	ff 				first
#define 	ss 				second
#define 	PB 				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define     pll             pair<ll, ll>
#define     vll             vector<ll>
#define     vpll            vector<pll>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define     sqr(a)          ((a)*(a))
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	print3(a) 		for(auto i : a)cout<<i<<nl;
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

// ostringstream str1;
// str1 << n;
// string tmp = str1.str();
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }
 
double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }
 
// vll pwx(32);
// void cal(ll x){ pwx[0] = 1; rep(i, 1, 32)pwx[i] = x*pwx[i-1]; }
 
/* ################################################################ */

#define space 200005

void solve() {
    string s;
    cin >> s;
    ll sum = 0;
    for(auto c : s) {
        sum += c-'0';
        sum %= 9;
    }

    // cout << sum << '\n';

    if(!sum) cout << "Yes\n";
    else cout << "No\n";
}

int main(){
    boost;
    // cal(3);

    // // For getting input from input.txt file 
    // freopen("alchemy_input.txt", "r", stdin); 
  
    // // Printing the Output to output.txt file 
    // freopen("output.txt", "w", stdout);

    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}


Measured memory_bytes: 3740
#include<stdio.h>
#include<math.h>

int main(){
	int n,i,j,flag;
	double xa,ya,ra,xb,rb,yb,m,p,d;
	scanf("%d",&n);
	while(n--){
		scanf("%lf %lf %lf %lf %lf %lf",&xa,&ya,&ra,&xb,&yb,&rb);
		flag=(ra>=rb?2:1);
		p=fabs(ra-rb);
		m=ra+rb;
		d=sqrt((xb-xa)*(xb-xa)+(yb-ya)*(yb-ya));
		//printf("p=%f,m=%f,d=%f,flag=%d\n",p,m,d,flag);
		if(d>m){
			printf("0\n");
		}else if(d<=m&&p<=d){
			printf("1\n");
		}else if(d<p&&flag==2){
			printf("2\n");
		}else if(d<p&&flag==1){
			printf("-2\n");
		}
	}
	return 0;
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
#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 rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
//const int MAX=;

int N;
void input(){
	cin>>N;
}

void solve(){
	string S4[4];
	S4[0] = "aacd";
	S4[1] = "bbcd";
	S4[2] = "efgg";
	S4[3] = "efhh";
	string S5[5];
	S5[0] = "aacee";
	S5[1] = "b.cff";
	S5[2] = "bdd.g";
	S5[3] = "hi..g";
	S5[4] = "hijj.";
	string S7[7];
	S7[0] = "aabc...";
	S7[1] = "d.bc...";
	S7[2] = "dee.g..";
	S7[3] = "ff..ghh";
	S7[4] = "..iijjk";
	S7[5] = "...nl.k";
	S7[6] = "...nlmm";
	if(N==2)cout<<-1;
	else if(N == 3){
		cout<<"aab"<<endl;
		cout<<"c.b"<<endl;
		cout<<"cdd"<<endl;
	}
	else if(N == 6){
		cout<<"aab..."<<endl;
		cout<<"c.b..."<<endl;
		cout<<"cdd..."<<endl;
		cout<<"...aab"<<endl;
		cout<<"...c.b"<<endl;
		cout<<"...cdd"<<endl;		
	}
	else if(N % 4 == 0){
		rep(i, N){
			int k = i/4;
			rep(p, 4*k)cout<<".";
			cout<<S4[i%4];
			rep(q,N-4*k-4)cout<<".";
			cout<<endl;
		}
	}
	else if(N % 4 == 1){
		rep(i, N-5){
			int k = i/4;
			rep(p, 4*k)cout<<".";
			cout<<S4[i%4];
			rep(q,N-4*k-4)cout<<".";
			cout<<endl;
		}
		rep(i, 5){
			rep(p, N-5)cout<<".";
			cout<<S5[i%5];
			cout<<endl;
		}
	}
	else if(N % 4 == 2){
		rep(i, N-10){
			int k = i/4;
			rep(p, 4*k)cout<<".";
			cout<<S4[i%4];
			rep(q,N-4*k-4)cout<<".";
			cout<<endl;
		}
		rep(i, 5){
			rep(p, N-10)cout<<".";
			cout<<S5[i%5];
			rep(q, 5)cout<<".";
			cout<<endl;
		}
		rep(i, 5){
			rep(p, N-5)cout<<".";
			cout<<S5[i%5];
			cout<<endl;
		}
	}
	else{
		rep(i, N-7){
			int k = i/4;
			rep(p, 4*k)cout<<".";
			cout<<S4[i%4];
			rep(q,N-4*k-4)cout<<".";
			cout<<endl;
		}
		rep(i, 7){
			rep(p, N-7)cout<<".";
			cout<<S7[i%7];
			cout<<endl;
		}
	}

}

void output(){
  
}

int main(){
  input();
  solve();
  output();
}

Measured memory_bytes: 1280
import sys
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

sys.setrecursionlimit(10**6)
# def solve():
# 	n, m = read()
# 	graph = [[] for i in range(n+1)]
# 	for _ in range(m):
# 		u, v = read()
# 		graph[u].append(v)
# 	visited = [0 for i in range(n+1)]
# 	def dfs(node):
# 		if visited[node]:
# 			return(visited[node])
# 		if not graph[node]:
# 			visited[node] = 0
# 			return(0)
# 		m = 0
# 		for i in graph[node]:
# 			m = max(m, dfs(i))
# 		visited[node] = 1 + m#ax(dfs(i) for i in graph[node])
# 		# print(node, visited[node])
# 		return(visited[node])

# 	ans = 0
# 	for i in range(1, n+1):
# 		ans = max(ans, dfs(i))
# 	# print(visited)
# 	print(ans)


def grid():
	n, m = read()
	arr = []
	for i in range(n):
		arr.append(inp().strip())
	# dic = {}
	dp = [-1]*m*n
	# print(dp, len(dp))
	def count_paths(i, j):
		# key = str(i)+"-"+str(j)
		# if key in dic:
		# 	return(dic[key])
		key = (i*m + j)
		# print(key)
		if i == n-1 and j == m-1:
			dp[key] = 1
			return(1)
		if i == n or j == m:
			return(0)
		if arr[i][j] == "#":
			dp[key] = 0
			return(0)
		if dp[key] > -1:
			return(dp[key])
		paths = (count_paths(i+1, j) + count_paths(i, j+1)) % (10**9 + 7)
		# dic[key] = paths
		dp[key] = paths
		return(paths)
	print(count_paths(0, 0))

def grid2():
	n, m = read()
	arr = []
	for i in range(n):
		arr.append(inp().strip())
	dp = {}
	# print(dp, len(dp))
	def count_paths(i, j):
		key = str(i)+"-"+str(j)
		if key in dp:
			return(dp[key])
		# key = (i*m + j)
		# print(key)
		if key in dp:
			return(dp[key])
		if i == n-1 and j == m-1:
			dp[key] = 1
			return(1)
		if i == n or j == m:
			return(0)
		if arr[i][j] == "#":
			dp[key] = 0
			return(0)
		
		paths = (count_paths(i+1, j) + count_paths(i, j+1)) % (10**9 + 7)
		# dic[key] = paths
		dp[key] = paths
		return(paths)
	print(count_paths(0, 0))

def grid3():
	MOD = pow(10,9) + 7
	H, W = read()
	 
	grid = [[0]*W for h in range(H)]
	grid[0][0] = 1
	 
	for h in range(H) :  
	  row = input()
	 
	  for w in range(W) :
	    if row[w] == '#' : continue
	    if h > 0 : grid[h][w] += grid[h-1][w]
	    if w > 0 : grid[h][w] += grid[h][w-1]
	    grid[h][w] %= MOD
	print(grid[-1][-1]% MOD)


if __name__ == "__main__":
	# solve()
	grid3()

Measured memory_bytes: 42684
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <numeric>
#include <algorithm>

using namespace std;

// r = a^n % mod
int64_t mod_pow(int64_t a, int64_t n, int64_t mod) {
  int64_t r = 1;
  while (n > 0) {
    if (n & 1) {
      r = (r * a) % mod;
    }
    a = (a * a) % mod;
    n >>= 1;
  }
  return r;
}

// a^{-1} % mod
int64_t mod_inv(int64_t a, int64_t mod) {
  return mod_pow(a, mod-2, mod);
}

const int64_t kMod = 1000000007;
const int kMax = 2000017;
std::vector<int64_t> fact(kMax), fact_inv(kMax);

void combi_init() {
  fact[0] = 1;
  for (int i = 1; i < fact.size(); ++i) {
    fact[i] = (i * fact[i-1]) % kMod;
    fact_inv[i] = mod_inv(fact[i], kMod);
  }
}

int combi(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return (((fact[n] * fact_inv[k]) % kMod) * fact_inv[n-k]) % kMod;
}

int f(int r, int c) {
  return combi(r+c, c);
}

int g(int r, int c) {
  return (f(r+1, c+1) - 1 + kMod) % kMod;
}

int S(int r1, int c1, int r2, int c2) {
  return (g(r2, c2) - g(r2, c1-1) - g(r1-1, c2) + g(c1-1, r1-1) + kMod) % kMod;
}

int main() {
  combi_init();
  int r1, c1, r2, c2;
  std::cin >> r1 >> c1 >> r2 >> c2;
  std::cout << S(r1, c1, r2, c2) << std::endl;
  return 0;
}


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

using i64 = int64_t;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b && a != c || a == c && b != a || b == c && a != b)cout << "Yes";
    else cout << "No";
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include <bits/stdc++.h>

using namespace std;

typedef pair<long long,bool> Pair;
const long long INF = 1LL<<60;

int main(){

long long N,sum = 0;

cin >> N;

for(long long i = 1;i <= N;++i){

    if(i%3 == 0 && i%5 == 0) continue;
    if(i%3 == 0) continue;
    if(i%5 == 0) continue;

    sum+=i;

}

cout << sum << endl;

return 0;

}

Measured memory_bytes: 3636