akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int r,g,b,n;
int abs(double x)
{
	return x>0?x:-x;
}
int main ()
{
	scanf("%d%d%d%d",&r,&g,&b,&n);
	int ans=0;
	int x,y;
	double z=0;
	for(x=0;x<=n/r;x++)	
		for(y=0;y<=n/g;y++)
		{
			//cout<<n-r*x-g*y<<" ";
			z=(double)(n-r*x-g*y)/b;
			//cout<<z<<" ";
			//cout<<(int)z<<" ";
			if(z==(int)z&&z==abs(z)) ans++;
			else 
			{
				z=0;
				continue; 
			}
			//cout<<ans<<endl;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define deb(x) cout << #x << "=" << x << endl

int main() {
	// your code goes here
	ll t;
    t=1;
	while(t--)
	{
	  ll n;
	  cin>>n;
	  ll A[n];
	  for(ll i=0;i<n;i++)
	  {
	      cin>>A[i];
	  }
	  ll dp[n+1];
	  dp[0]=0;
	  dp[1]=abs(A[1]-A[0]);
	  for(ll i=2;i<n+1;i++)
	  {
	      dp[i]=min(abs(A[i]-A[i-1])+dp[i-1],abs(A[i]-A[i-2])+dp[i-2]);
	  }
	  cout<<dp[n-1];
	}
	return 0;
}


Measured memory_bytes: 5196
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
 		System.out.println((a % 1000) == 0 ? 0 : 1000 - (a % 1000));
	}
}

Measured memory_bytes: 35684
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
#include<array>
#include<algorithm>
#include<queue>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
#include<bitset>
#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

//long nCr(int n, int r) {
//	long ans = 1;
//	for (int i = n; i > n - r; i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; i++) {
//		ans = ans / i;
//	}
//	return ans;
//}
//long nHr(int n, int r) {
//	n = n + r - 1;
//	return nCr(n, r);
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI N, D;
	cin >> N >> D;
	D = D * 2 + 1;
	if (N % D == 0) {
		cout << N / D << endl;
	}
	else {
		cout << N / D + 1 << endl;
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            string X = string.Empty;
            string Y = string.Empty;
            int ret = 0;
            for (int i = 0; i < N; i++)
            {
                int tmpRet = 0;
                X += S[i];
                Y = string.Empty;
                for (int j =i + 1; j < N; j++)
                {
                    Y += S[j];
                }

                var XList = X.Distinct().ToList();
                foreach (var x in XList)
                {
                    var tmp = Y.IndexOf(x);
                    if (tmp != -1)
                    {
                        tmpRet++;
                    }
                }

                if (ret < tmpRet)
                {
                    ret = tmpRet;
                }
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 13280
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a <= b)
  cout << a << endl;
  else
  cout << a - 1 << endl;
}


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

using ll = long long;

int main() {
    int n, m; cin >> n >> m;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vector<ll> plus, minus;
    ll ans = 0;
    for(int i = 0; i < n; ++i) {
        if(a[i] < i) {
            plus.push_back(i);
            minus.push_back(a[i]);
        } else {
            plus.push_back(a[i]);
            minus.push_back(i);
        }
        ans += abs(a[i] - i);
    }
    sort(begin(plus), end(plus));
    sort(rbegin(minus), rend(minus));

    for(int i = 0; i < m; ++i) {
        if(plus[i] > minus[i]) break;
        ans += 2 * (minus[i] - plus[i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 5556
#include<iostream>
#include<map>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
main(){
  map<char,int> kioku;
  kioku['I']=1;
  kioku['V']=5;
  kioku['X']=10;
  kioku['L']=50;
  kioku['C']=100;
  kioku['D']=500;
  kioku['M']=1000;
  char tmp[1000];
  char c;
  int num=0;
  int before=0;
  while(cin>>tmp){
    for(int i=0;i<strlen(tmp);i++){
      if(i!=strlen(tmp)-1){
	if(kioku[tmp[i+1]]>kioku[tmp[i]]){
	  num+=abs(kioku[tmp[i]]-kioku[tmp[i+1]]);
	  i++;
	}
	else{
	  num+=kioku[tmp[i]];
	}
      }
      else{
	num+=kioku[tmp[i]];
      }
    }
    cout<<num<<endl;
    num=0;
  }
}

Measured memory_bytes: 1176
from sys import setrecursionlimit
setrecursionlimit(10**8)

def main():
    n = int(input())
    a = list(map(int, input().split()))

    dp = [[[-1] * (n+1) for _ in range(n+1)] for _ in range(n+1)]
    dp[0][0][0] = 0.0

    def search(i, j, k):
        num = n
        if i > 0:
            if dp[i-1][j][k] == -1:
                num += search(i-1, j, k) * i
            else:
                num += dp[i-1][j][k] * i
        if j > 0:
            if dp[i+1][j-1][k] == -1:
                num += search(i+1, j-1, k) * j
            else:
                num += dp[i+1][j-1][k] * j
        if k > 0:
            if dp[i][j+1][k-1] == -1:
                num += search(i, j+1, k-1) * k
            else:
                num += dp[i][j+1][k-1] * k
        num /= i + j + k

        dp[i][j][k] = num
        return num

    print(search(a.count(1), a.count(2), a.count(3)))

main()

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

using namespace std;

int solve(vector<bool> switches, vector<vector<int>>& lights, vector<int>& p,
          int s_idx) {
    if (s_idx >= switches.size()) {
        for (int i = 0; i < lights.size(); ++i) {
            int count = 0;
            for (int j = 0; j < lights[i].size(); ++j) {
                if (switches[lights[i][j]])
                    ++count;
            }
            if (count % 2 != p[i])
                return 0;
        }
        return 1;
    }

    int c1 = solve(switches, lights, p, s_idx + 1);
    switches[s_idx] = true;
    int c2 = solve(switches, lights, p, s_idx + 1);
    return c1 + c2;
}

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

    vector<vector<int>> v(m);
    for (int i = 0; i < m; ++i) {
        int k;
        cin >> k;
        v[i].resize(k);
        for (int j = 0; j < k; ++j)
            cin >> v[i][j];
    }

    vector<int> p(m);
    for (int i = 0; i < m; ++i)
        cin >> p[i];

    vector<bool> s(n + 1, false);
    int count = solve(s, v, p, 1);
    cout << count << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)

signed main(){
    int x;
    cin >> x;
    if(x < 600) cout << '8';
    else if(x < 800) cout << '7';
    else if(x < 1000) cout << '6';
    else if(x < 1200) cout << '5';
    else if(x < 1400) cout << '4';
    else if(x < 1600) cout << '3';
    else if(x < 1800) cout << '2';
    else cout << '1';
    cout << endl;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template

int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

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

    ll n,k;
    cin>>k>>n;
    if(k*500 >= n) cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX(x,y) x>y?x:y
typedef long long int ll;

ll N,C,x[100002],v[100002];

ll Solve(){
	ll lg=0,tem=0;
        ll max[100001];
        max[0]=0;
	for(ll i=0;i<N;i++)
	{
		lg+=v[i+1]+x[i]-x[i+1];
		max[i+1]=MAX(max[i],lg);
	}
	ll ans=max[N];
	for(ll i=N;i>1;i--)
	{
		tem+=v[i]+x[i]-x[i+1];
		ans=MAX(tem+x[i]-C+max[i-1],ans);
	}
	return ans;
}

void swap(ll* v1,ll* v2){
        ll sw = *v1;
        *v1=*v2;
        *v2=sw;
}
       
int main(){
	scanf("%lld %lld",&N,&C);
	for(ll i=0;i<N;i++) scanf("%lld %lld",&x[i+1],&v[i+1]);
	x[N+1]=C;
        x[0]=0;
	ll Ans1=Solve();
        for(ll i=1;i<=N/2;i++) {
            x[i]=C-x[i];
            x[N+1-i]=C-x[N+1-i];
            swap(&x[i],&x[N+1-i]);
            swap(&v[i],&v[N+1-i]);
        }
	ll Ans2=Solve();
	printf("%lld",MAX(Ans1,Ans2));
	return 0;
}


Measured memory_bytes: 2560
N = int(input())
from itertools import product
ans = 0
for i in range(3,len(str(N))+1):
    for ptn in product('753',repeat=i):
        s = ''.join(ptn)
        for c in '753':
            if c not in s:
                break
        else:
            if int(''.join(ptn)) <= N:
                ans += 1
print(ans)

Measured memory_bytes: 9104
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_vec() -> Vec<i64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let n: usize = input();
    let a_vec = input_vec();
    let mut ans = 0;
    for i in 0..n {
        for j in 0..n {
            if (a_vec[i] - a_vec[j]).abs() > ans {
                ans = (a_vec[i] - a_vec[j]).abs();
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2116
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<stdio.h>
using namespace std;

int main() {
	char N[4];
	char C[4];
	cin >> N;
	cin >> C;

	if (
		(N[0] == C[2])
		&& (N[1] == C[1])
		&& (N[2] == C[0])
		) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int k;
	cin >> k;
	cout << a[k - 1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
   string s1, s2, s3;
   cin >> s1 >> s2 >> s3;
   cout << "A" << s2[0] << "C" << endl;

   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
#define szxb 100010
using namespace std;
int n,a[szxb];
inline bool cmp(int x,int y){return (x>y);}
signed main()
{
	scanf("%d",&n);int n1(0),n2(0);
	for(register int i(1);i^(n+1);i++){scanf("%d",&a[i]);}sort(a+1,a+n+1,cmp);while(a[n1+1]>=(n1+1)){n1++;}while(a[n1+n2]>=n1){n2++;}
	puts(((((a[n1]-n1+1)&1)&&(n2&1))?("Second"):("First")));
	return 0;
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
    a105(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a105(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    val (num, people) = args[0].split(" ").map { it.toInt() }
    println(if (num % people == 0) 0 else 1)
}


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

int main() {
  int N;
  cin>>N;
  vector<int> v(N);
  rep(i,N) cin>>v[i];
  sort(v.begin(),v.end());
  int ans = v[N-1]-v[0];
  
  cout << ans << endl;
  return 0;  
    

}


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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<char>a(n);
    vector<char>b(n);
    rep(i,n){
        if(i % 2 == 0){
            a[i] = '0';
            b[i] = '1';
        }else{
            a[i] = '1';
            b[i] = '0';
        }
    }
    int acnt = 0,bcnt = 0;
    rep(i,n){
        if(s[i] != a[i])acnt++;
        if(s[i] != b[i])bcnt++;
    }
    cout << min(acnt,bcnt) << endl;
    return 0;
}

Measured memory_bytes: 512
/*
AizuOnline A0075
Title BMI
*/
#include <stdio.h>
#include <float.h>

int gno;
double height;
double weight;
//
main()
{
  int cnt=0;

  while(EOF!=scanf("%d,%lf,%lf",&gno,&weight,&height))
    {

      if(weight/height/height >= 25.0)
	{
	  printf("%d\n",gno);
	  cnt++;
	}
    }
    if(cnt==0)
      printf("該当なし\n");
return(0);
}

Measured memory_bytes: 628
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}

int main(){
  int n,x,t;
  cin>>n>>x>>t;
  if(n%x==0)cout<<n*t/x<<endl;
  else cout<<(n/x+1)*t<<endl;
    
    
  return 0;
}


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

class LazySegmentTree
{
    int n;
    using T1 = long long;
    using T2 = long long;
    T1 id1 = 0;
    T2 id2 = -INT_MAX;
    std::vector<T1> node; // sum
    std::vector<T2> lazy; // update

    // 遅延評価
    void eval(int k, int l, int r)
    {
        // 遅延配列が空なら終了
        if (lazy[k] == id2)
            return;
        // 遅延配列を適用
        node[k] = lazy[k];
        if (r - l > 1)
        {
            lazy[2 * k + 1] = lazy[k] / 2;
            lazy[2 * k + 2] = lazy[k] / 2;
        }
        // 遅延配列初期化
        lazy[k] = id2;
    }

  public:
    LazySegmentTree(int _n)
    {
        int sz = _n;
        n = 1;
        while (n < sz)
            n *= 2;
        // 配列初期化
        node.resize(2 * n - 1, id1);
        lazy.resize(2 * n - 1, id2);
    }
    // 半開区間 [a, b) に対して値 val を反映させる
    void update(int a, int b, T2 val, int l = 0, int r = -1, int k = 0)
    {
        if (r < 0)
            r = n;
        // ノード k で遅延評価
        eval(k, l, r);
        if (b <= l || r <= a)
            return;
        // 区間が被覆されている場合
        if (a <= l && r <= b)
        {
            // 遅延配列更新, 評価
            lazy[k] = (r - l) * val;
            eval(k, l, r);
        }
        else
        {
            // 子ノードの値を評価し, 更新
            int mid = (l + r) / 2;
            update(a, b, val, l, mid, 2 * k + 1);
            update(a, b, val, mid, r, 2 * k + 2);
            node[k] = node[2 * k + 1] + node[2 * k + 2];
        }
    }

    // 半開区間 [a, b) に対してクエリを投げる
    T1 query(int a, int b, int l = 0, int r = -1, int k = 0)
    {
        if (r < 0)
            r = n;
        eval(k, l, r);
        // 範囲外なら単位元返す
        if (b <= l || r <= a)
            return id1;
        if (a <= l && r <= b)
            return node[k];
        int mid = (l + r) / 2;
        T1 vl = query(a, b, l, mid, 2 * k + 1);
        T1 vr = query(a, b, mid, r, 2 * k + 2);
        return vl + vr;
    }
};

using namespace std;

void solve_dsl_2_i()
{
    int n, q;
    cin >> n >> q;
    LazySegmentTree lst(n);
    while (q--)
    {
        int type;
        cin >> type;
        if (type == 0)
        {
            int s, t, x;
            cin >> s >> t >> x;
            t++;
            lst.update(s, t, x);
        }
        else
        {
            int s, t;
            cin >> s >> t;
            t++;
            cout << lst.query(s, t) << endl;
        }
    }
}

int main()
{
    solve_dsl_2_i();
}



Measured memory_bytes: 7076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  cout << N/3 << endl;
  return 0;
    

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
 
int main() {
	int a, b;
  	cin >> a >> b;
  	cout << max({a+b, a-b, a*b}) << endl;
    return 0;
}

Measured memory_bytes: 256
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

import sys
d = abs(b - a)
if d == 0:
    print('YES')
    sys.exit()
vv = v - w 
if vv <= 0:
    print('NO')
    sys.exit()

tt = d/vv
if tt <= t:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9124
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#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>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pi;
typedef long long ll;
typedef unsigned long long ull;
const int IINF = 1<<28;
const ll MOD = 1000000007;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

map<vs, int> m2;

int dfs(vs &v, int m, int mask) {
	if(v.size() < 2)
		return v.size()-1;
	if(m2.count(v))
		return m2[v];
	int ans = IINF;
	REP(i, m) {
		vs a, b;
		int mask2 = mask;
		if(!(mask2 >> i & 1)) {
			mask2 |= 1 << i;
			REP(j, v.size()) {
				if(v[j][v[j].size()-1-i] == '1')
					a.pb(v[j]);
				else
					b.pb(v[j]);
			}
			int res = max(dfs(b, m, mask2), dfs(a, m, mask2))+1;
			ans = min(ans, res);
		}
	}
	m2[v] = ans;
	return ans;
}

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

	int m, n;
	while(cin >> m >> n, m|n) {
		m2.clear();
		vs v(n);
		REP(i, n)
			cin >> v[i];
		cout << dfs(v, m, 0) << endl;
	}
	return 0;
}

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

int main() {
  ll H1 = 0,M1 = 0,H2 = 0, M2 = 0,K = 0,H = 0;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  if(M1 <= M2){
    cout << (H2 - H1) * 60 + (M2 - M1) - K;
  }
  else{
    cout << (H2 - H1 - 1) * 60 + (60 - (M1 - M2)) - K;
  }
}

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

inline int sqr(int x) {
	return x*x;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	cin >> n;

	vector<pair<int, int>> xs(n);
	for (auto& x : xs) {
		cin >> x.first >> x.second;
	}

	double dist[8][8] = {};
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			dist[i][j] = sqrt(
				sqr(xs[i].first - xs[j].first) +
				sqr(xs[i].second - xs[j].second));
		}
	}

	double tot = 0;
	int cnt = 0;

	vector<int> p(n);
	iota(p.begin(), p.end(), 0);
	do {
		for (int i = 1; i < n; i++) {
			tot += dist[p[i-1]][p[i]];
		}
		cnt++;
	} while (next_permutation(p.begin(), p.end()));

	cout << fixed << setprecision(15) << tot/cnt << endl;

	return 0;
}



Measured memory_bytes: 256
module ArrayL = ArrayLabels
module ListL = ListLabels

let dbg = Printf.printf "[debug]%s"

let max_num = 100_000_000_000

let id = fun x -> x
let tuple2 x y = (x,y)
let tuple3 x y z = (x,y,z)
let succ x = x + 1
let pred x = x - 1

let (++) n m =
  let rec aux i =
    if i = m then [m]
    else i :: aux (i+1) in
  if n > m then [] else aux n

let (++^) n m = n ++ (m-1)

let scan fmt f = Scanf.sscanf (read_line ()) fmt f

let scan_lines n fmt f =
  List.map (fun _ -> scan fmt f) (0++^n)

let scan_matrix n m e conv =
  let arr = Array.make_matrix n m e in
  Array.iteri (fun i line ->
      let s = Scanf.Scanning.from_string @@ read_line () in
      Array.iteri (fun j _ ->
          arr.(i).(j) <- Scanf.bscanf s " %s" conv;
        ) line) arr; arr

let between n x m = n <= x && x < m

let string_to_list s =
  List.map (String.get s) (0 ++^ String.length s)

let () =
  let rec aux ()=
    let (n, x) = scan "%d %d" tuple2 in
    if n = 0 && x = 0 then ()
    else
      (ListL.map (1++n) ~f:(fun i ->
           ListL.map (i+1++n) ~f:(fun j ->
               ListL.map (j+1++n) ~f:(fun k ->
                   if i + j + k = x then true
                   else false
                 )
             )
         ) |> List.concat |> List.concat |> List.filter ((=) true)
       |> List.length
       |> Printf.printf "%d\n";
       aux ())
  in aux ()



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

int N;

int main()
{
    scanf("%d",&N);
    int now = 1,ans = 0;
    while(now <= N)
    {
        ans = now;
        now *= 2;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 10000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	ll n, k, q;
	cin >> n >> k >> q;
	vector<int> point(n, k-q);
	rep(i, q){
		int a;
		cin >> a;
		a--;
		point[a]++;
	}
	rep(i, n){
		if(0 < point[i]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 1024
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))


ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


int main()
{
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n + 1), b(m + 1);
    a[0] = b[0] = 0;
    rrepp(i, 1, n) {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    rrepp(i, 1, m) {
        cin >> b[i];
        b[i] += b[i - 1];
    }
    ll result = 0;
    repp(i, n) {
        ll limit = k - a[i];
        if (limit < 0) {
            break;
        }
        ll index = upper_bound(b.begin(), b.end(), limit) - b.begin();
        result = max(result, i + index - 1);
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 6044
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
using Graph=vector<vector<int>>;

int main()
{
  ll x;cin>>x;
  ll a,b;
  for (ll a=0;a<1000;a++)
  {
    for (ll b=0;b<1000;b++)
    {
      //cout<<"==="<<endl;
      if (pow(a,5)-pow(b,5)==x)
      {
        cout<<a<<" "<<b<<endl; 
        return (0);
      }
      else if (pow(a,5)+pow(b,5)==x)
      {
        cout<<a<<" "<<b*(-1)<<endl; 
        return (0);
      }
    }
  }
}


Measured memory_bytes: 4072
import re
K,W = map(int,input().split())
#N = str(input())
#K = int(input())
A = list(map(int,input().split()))
a=[K-A[-1]+A[0]]
for i in range(W-1):
    l = abs(A[i]-A[i+1])
    a.append(l)

a.remove(max(a))
print(sum(a))


Measured memory_bytes: 26356
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
using ll = long long;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
int main(){
    int a,b;
    cin>>a>>b;
    cout<<b/GCD(a,b)*a<<endl;
}

Measured memory_bytes: 256
while True:
	a,b = map(int, raw_input().split())
	if a + b == 0: break
	for i in range(a):
		if i % 2 == 0:
			tmp = '#.' * (b / 2) 
			tmp += '#' if b % 2 == 1 else ""
		else:
			tmp = '.#' * (b / 2)
			tmp += '.' if b % 2 == 1 else ""
		print tmp
	print 

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

int main() {
  int n;
  cin>>n;
  int k=100005;
  int v,u,x[k]={},y[k]={};
  for(int i=0;i<n/2;i++){
    cin>>v>>u;
    x[u]++;
    y[v]++;
  }
  int ans,c1,c2,max1=0,max2=0,next1,next2;
  
  for(int i=1;i<k;i++){
    if(max1<=x[i]){
      next1=max1;
      max1=x[i];
      c1=i;
    }
    if(max2<=y[i]){
      next2=max2;
      max2=y[i];
      c2=i;
    }
    
    if(max1>x[i] && x[i]>next1)
      next1=x[i];
    if(max2>y[i] && y[i]>next2)
      next2=y[i];
  }
  
  if(c1!=c2)
    ans=n-max1-max2;
  else ans=n-max(max1+next2 , max2+next1);
  
  cout<<ans<<endl;
  return 0;
    
  
  
  
  
}

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

using namespace std;

int main(){
    int N;
    while(cin >> N){
        vector<long long> a(N);
        for(auto& t : a) cin >> t;
        long long res = 0;
        vector<long long> m(N);
        while(true){
            long long add = 0;
            for(int i=0;i<N;i++){
                m[i] = a[i]/N;
                a[i] -= m[i] * N;
                add += m[i];
            }
            for(int i=0;i<N;i++) a[i] += (add - m[i]);
            if(add == 0) break;
            res += add;
        }
        cout << res << endl;
    }
}

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

int main(){
    
   long double m;
   int n;
   cin>>n>>m;
   int ar[n];

   long long sum =0;

   for(int i=0;i<n;i++){
      cin>>ar[i];
      sum+=ar[i];
   }

   long double val = (1.0 / (4.0 * m))* (long double) sum;
   int cnt =0;

   for(int i=0;i<n;i++){
   	 if(val <= (long double)ar[i]){
         cnt++;
   	 }
   }

   if(cnt >= m){
   	cout<<"Yes"<<endl;
   }else{
   	cout<<"No"<<endl;
   }
 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	int n,k;
	cin>>n>>k;
	vector<int>v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	int dp[n];
	for(int i=0;i<n;i++){
		dp[i]=INT_MAX;
	}
	dp[n-1]=0;
	dp[n-2]=abs(v[n-1]-v[n-2]);
	for(int i=n-1;i>=n-k;i--){
		for(int j=i;j<n;j++){
			dp[i]=min(dp[i],min(dp[i+1]+abs(v[i]-v[i+1]),abs(v[i]-v[n-1])));
		}
	}
	for(int i=n-k-1;i>=0;i--){
		for(int j=1;j<=k;j++){
			int abs1=abs(v[i]-v[i+j]);
			dp[i]=min(dp[i],abs1+dp[i+j]);
		}
	}
	// for(int i=0;i<n;i++){
	// 	cout<<dp[i]<<" ";
	// }
	// cout<<endl;
	cout<<dp[0]<<endl;
}

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

int main() {
  int n;cin>>n;
  vector<tuple<string,int,int>> vec(n+1);
  for(int i=1;i<=n;i++){
    string s;cin>>s;
    int p;cin>>p;
    p=-p;
    vec[i]=make_tuple(s,p,i);
  }
  sort(all(vec));
  for(int i=1;i<=n;i++){
    string s;
    int p;
    int a;
    tie(s,p,a)=vec[i];
    cout<<a<<endl;
  }
}
    

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  Solver(LL n) : n(n){};

  void solve() {
    for (int i = 0; i < n - 1; ++i) {
      for (int j = i + 1; j < n; ++j) {
        int l = 0;
        while (((i >> l) & 1) == ((j >> l) & 1)) l++;
        cout << l + 1 << ' ';
      }
      cout << endl;
    }
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <complex>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << "\n"
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[300][300];
char field[200][200];

int main(){
  clr(d,0);
  cin >> n >> m >> l;
  rep(i,0,m){
    int a;
    cin >> a;
    d[a] = 1;
  }
  ll ans = INF;
  m = 0;
  pel(i,l-1,1)if(d[i] != 0)m++;
  ans = min(ans,m);
  m = 0;
  rep(i,l+1,n)if(d[i] != 0)m++;
  ans = min(ans,m);
  print(ans);
  return 0;
}

Measured memory_bytes: 1792
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int a,b;
	std::cin >> a >> b;
	a--;b--;
	std::vector<std::vector<char> > gridw(50,std::vector<char>(100,'#'));
	std::vector<std::vector<char> > gridb(50,std::vector<char>(100,'.'));

	for(int i=1;i<49;i+=2) {
		for(int j=0;j<100;j+=2) {
			if(a==0) goto endw;
			gridw[i][j] = '.';
			a--;
			if(a==0) goto endw;
		}
	}
endw:
	for(int i=1;i<49;i+=2) {
		for(int j=0;j<100;j+=2) {
			if(b==0) goto endb;
			gridb[i][j] = '#';
			b--;
			if(b==0) goto endb;
		}
	}
endb:
	print("100 100");
	for(auto i:gridw) {
		for(auto j:i) std::cout << j;
		std::cout << ENDL;
	}
	for(auto i:gridb) {
		for(auto j:i) std::cout << j;
		std::cout << ENDL;
	}

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n,m) for(int i=(n);i<(m);i++)
int main(){
  string S;
  cin>>S;
  int N=S.size();
  ll ans=0;
  rep(i,0,1<<N){
    ll x=0;
    rep(j,0,N){
      if(i&1<<j) x=x*10+S[j]-'0';
      else{
        ans+=x;
        x=0;
      }
    }
    ans+=x;
  }
  cout<<ans<<endl;
}

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

#define ll long long
#define ld long double

using namespace std;

vector <ll> a,f;

bool check(ll mx, ll k)
{
    for(int i = 0; i < a.size(); i++)
    {
        if(a[i] * f[i] > mx)
        {
            ll dif = (a[i] * f[i] - mx) / f[i];
            if((a[i] * f[i] - mx) % f[i]) dif++;
            if(dif > k) return false;
            k -= dif;
        }
    }
    return true;
}

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,k,x;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    {
        cin >> x;
        a.push_back(x);
    }
    for(int i = 0; i < n; i++)
    {
        cin >> x;
        f.push_back(x);
    }
    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());
    ll l = 0, r = 1e12;
    ll mid;
    while(l < r)
    {
        mid = (l + r) >> 1;
        if(!check(mid, k))
        {
            l = mid + 1;
        } else
            {
                r = mid;
            }
    }
    cout << l;
}


Measured memory_bytes: 5616
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <memory>
#include <numeric>
#include <type_traits>

using namespace std;

#define rep(i,n) for (int (i)=0;(i)<(n);i++)
typedef long long ll;
const int MAXV = 1e9;



int main(){
  int X, N; cin >> X >> N;
  int p[N];
  bool res[102];
  rep(i,102){
    res[i] = true;
  }
  rep(i,N){
    cin >> p[i];
    res[p[i]] = false;
  }
  int ans;
  rep(i,102){
    if(res[i] == false) continue;
    else{
      if(abs(X-i) < abs(X-ans)){
        ans = i;
      }
      if(abs(X-i) == abs(X-ans) && i < ans){
        ans = i;
      }
    }
  }
  cout << ans;


  return 0;
}

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

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    unsigned long a, b, c;
    cin >> a >> b >> c;
    if(c % 2 == 0 || a % 2 == 0 || b % 2 == 0) {
        cout << 0 << endl;
        return 0;
    } 

    vector<unsigned long> row = {a,b,c};
    sort(row.begin(),row.end());
    cout << row[0] * row[1] <<endl;
}

Measured memory_bytes: 3588
import java.util.*;
import java.util.stream.*;
import java.io.*;
class Main {
  public static void main(String[] args) {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    br.lines()
      .skip(1)
      .parallel()
      .map(line -> Stream.of(line.split(" "))
                    .mapToInt(Integer::parseInt)
                    .map(n -> n * n)
                    .sorted()
                    .toArray())
      .map(ar -> (ar[0] + ar[1] == ar[2]) ? "YES" : "NO")
      .sequential()
      .forEach(System.out::println);
  }
}

Measured memory_bytes: 32336
/*-------------------------------*
| Name: Ayush Kumar              |
| Site: CSES                     |
| Email: ayushkr667@gmail.com    |
*-------------------------------*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define INF (ll) 1e18
const double PI = 3.141592653589793238460;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

char arr[1001][1001];
ll dp[1001][1001]; 

int main()
{
    int h, w;
    cin >> h >> w;
    string a[h];
    for(int i=0; i<h; i++)
        cin >> a[i];

    dp[1][1]=1;
    for(int i=1; i<=h; i++)
    {
        for(int j=1; j<=w; j++)
        {
            if(a[i-1][j-1] == '.')
                dp[i][j] = max(dp[i][j], dp[i-1][j] + dp[i][j-1]) % mod;
            else
                dp[i][j] = 0;
        }
    }
    cout << dp[h][w] << endl;
    return 0;
}


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


namespace ABC127_1
{
    class D
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var N = a[0];
            var M = a[1];
            var A = Console.ReadLine().Split().Select(long.Parse).OrderBy(x => x).ToArray();
            var BC = Enumerable.Repeat(0, (int)M).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).OrderByDescending(x => x[1]).ToArray();

            var index = 0;
            for (long i = 0; i < N;)
            {
                var count = 0;
                while (index < M && i < N && count < BC[index][0])
                {
                    if (A[i] < BC[index][1]) A[i] = BC[index][1];
                    else break;
                    i++;
                    count++;
                }
                index++;
                if (M <= index) break;
            }
            //Console.WriteLine(string.Join(",", A));

            Console.WriteLine(A.Sum());
        }
    }
}



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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n; cin >> n;
    vector<ll> lis(3*n);
    ll ans = 0;
    REP(i, 0, 3*n){cin >> lis[i];}
    sort(ALL(lis), greater<>());
    for(int i = 1; i < 2*n; i += 2){
        ans += lis[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
import itertools

N=int(input())
testimony=[]
for i in range(N):
    a=int(input())
    l=[]
    for j in range(a):
        l2=[int(k) for k in input().split()]
        l.append(l2)
    testimony.append(l)

nums=[0,1]
kind=itertools.product(nums,repeat=N)

def is_corect_kind(k,testimony,N):
    for i in range(N):
        if k[i]==1:
            for t in testimony[i]:
                if k[t[0]-1]!=t[1]:
                    return False
    return True

answer=0
for k in kind:
    if is_corect_kind(k,testimony,N):
        answer=max(answer,sum(k))
print(answer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MD=int(1e9)+7;

int madd(int x,int y) {
	if (x+y<MD) return x+y; else return x+y-MD;
}
int mmul(int x,int y) {
	return int(ll(x)*y % MD);
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int N,K;
	cin>>N>>K;
	
	set<int> s;
	for (int i=1; i*i<=N; ++i) {
		s.insert(i);
		s.insert(N/i);
	}

	vector<int> xs(s.begin(),s.end());
	
	int m=sz(xs);
	vector<int> cnt(m);
	map<int,int> pos;
	rep(i,0,m) {
		cnt[i]=xs[i]-(i==0 ? 0 : xs[i-1]);
		pos[xs[i]]=i;
	}
	
	vector<int> to(m);
	rep(i,0,m) to[i]=pos[N/xs[i]];
	
	vector<int> f(m);
	rep(i,0,m) f[i]=cnt[i];
	
	rep(i,0,K-1) {
		vector<int> nf(m);
		rep(j,0,m) nf[to[j]]=madd(nf[to[j]],f[j]);
		per(j,0,m-1) nf[j]=madd(nf[j],nf[j+1]);
		rep(j,0,m) nf[j]=mmul(nf[j],cnt[j]);
		f=nf;
	}
	
	int res=0;
	rep(i,0,m) res=madd(res,f[i]);
	cout<<res<<"\n";
}


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

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

    vector<int> l(0);
    for (int i = 0; i < N; i++) {
        int li;
        cin >> li;
        l.push_back(li);
    }
    sort(l.begin(), l.end());

    int last_idx = l.size() - 1;
    int max_len = 0;
    for (int i = last_idx; i > last_idx - K; i--) {
        max_len += l[i];
    }
    cout << max_len << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <unordered_map>
#include <unordered_set>

using namespace std;

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

const ll INF = 1e17;

int main() {
    ios_base::sync_with_stdio(false);
    map<ll, ll> cnt;
    ll n, x;
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> x;
        ++cnt[x];
    }
    ll ans = 0;
    for(ll k = (ll(1) << 60); k > 0; k >>= 1) {
        for(auto d : cnt) {
            ll res = k - d.first;
            if(res > 0 && cnt.find(res) != cnt.end()) {
                ll op;
                if(res == d.first) {
                    op = d.second / 2;
                    cnt[d.first] = d.second % 2;
                    ans += op;
                }
                else {
                    op = min(d.second, cnt[res]);
                    cnt[d.first] -= op;
                    cnt[res] -= op;
                    ans += op;
                }
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;


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

    bool ans = true;
    rep(i, 3){
        if (s[i] == s[i+1]){
            ans = false;            
        }
    }
    if (ans){
        cout << "Good" << endl;
    } else {
        cout << "Bad" << endl;
    }
}



Measured memory_bytes: 256
def bubble_sort(a, n)
  flag = true
  count = 0

  while flag
    flag = false

    (N - 1).downto(1) do |i|
      if a[i] < a[i - 1]
        a[i], a[i - 1] = a[i - 1], a[i]
        count += 1
        flag = true
      end
    end
  end

  puts a.join(' ')
  puts count
end

N = gets.to_i
A = gets.split.map(&:to_i)

bubble_sort(A, N)

Measured memory_bytes: 8716
#include<iostream>
using namespace std;
int main(){
  int n;cin >> n;int x=n;
  cout << n << ":";
  for(int i=2;i*i<=x;i++){
    while(n%i==0) {
      cout << " " << i;
      n/=i;
    }
  }
  if(n!=1)
    cout << " " << n;
  cout << endl;
  return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <string>
#include <limits.h>
#include <numeric>
using namespace std;


int main() {
	int n, s, x[100010], d[100010], ans;
	cin >> n >> s;
	for (int i = 1; i<= n; i++) {
	    cin >> x[i];
	    if (i == 1) d[1] = abs(x[1] - s);
	    else d[i] = abs(x[i] - x[i - 1]);
	}
	ans = d[1];
	for (int i = 1; i < n; i++) {
	    int a = ans, b = d[i + 1];
	    if (a < b) {
	        int tmp = a;
	        a = b;
	        b = tmp;
	    }
	    int r = a % b;
        while (r != 0) {
            a = b;
            b = r;
            r = a % b;
        }
        ans = b;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int n,x=0,max=0,i;
	char s[100];
	scanf("%d %s", &n, s);
	for(i=0; i<n; i++)
	{
		if(s[i]=='I')
		x++;
		else
		x--;
		if(max<x)
		max=x;
	}
	printf("%d\n", max);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, m; cin >> n >> m;
    typedef pair<int, int> P;
    vector<P> war(m);
    rep(i,m) {
        int a, b; cin >> a >> b;
        war[i] = P(b, a);
    }
    sort(war.begin(), war.end());
    int ans = 0, mx = 0;
    rep(i,m) {
        // cout << i << ' ' << war[i].second << ' ' << war[i].first << endl;
        if (war[i].second < mx) continue;
        mx = war[i].first;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024