akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <iomanip>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,m,a,i;
	std::cin >> m >> n;
	for(i=0; i<n; ++i){
		std::cin >> a;
		m -= a;
	}
	std::cout << std::max(m,-1) << std::endl;
	return 0;
}


Measured memory_bytes: 3624
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int C = Integer.parseInt(sc.next());
        
        for(int i=A; i<=A*B; i+=A){
            if(i % B == C){
                System.out.println("YES");
                return;
            }
        }
        
        System.out.println("NO");
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>
#include <boost/dynamic_bitset.hpp>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
  // INFILE();
	ll x;
	cin >> x;

	ll d = x / 11;
	ll m = x % 11;

	cout << (d * 2) + ((m == 0) ? 0 : (m > 6) ? 2 : 1) << "\n";

  return 0;
}

template <class T> static void scan(vector<T> &v) {
  map<type_index, const char *const> m = {{typeid(int), "%d"},
                                          {typeid(ll), "%lld"},
                                          {typeid(double), "%lf"},
                                          {typeid(char), "%c"}};

  auto tFormat = m[typeid(T)];

  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
	if (isWord) {
		for (auto &n : v) {
			cin >> n;
		}
		return;
	}

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
	string s;
	getline(cin, s);

	if (s.size() == 0) {
		getline(cin, s);
	}

	for_each(begin(s), end(s), [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
	return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


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

class Main{

    static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    static StringBuilder sb = new StringBuilder("");
    static StringTokenizer stk = new StringTokenizer("");

    public static void main(String arg[]){
        try{
            stk = new StringTokenizer(bf.readLine());
            int N = Integer.parseInt(stk.nextToken());
            int K = Integer.parseInt(stk.nextToken());
            stk = new StringTokenizer(bf.readLine());
            int arr[] =  new int[N];
            for(int i=0;i<N;i++){
                arr[i] = Integer.parseInt(stk.nextToken());
            }
            System.out.println(solver(N,K,arr));
        }catch(Exception e){
            e.printStackTrace();
        }
    }

    public static int solver(int N,int K,int[] arr){
        int[] dp  = new int[N];
        dp[0] = 0;
        for(int i=1;i<N;i++){
            dp[i] = Integer.MAX_VALUE;
        }

        for(int i=1;i<N;i++){
            for(int j=1;j<=K;j++){
                dp[i] = Math.min(dp[i],(i-j >= 0) ? dp[i-j] + Math.abs(arr[i-j] - arr[i]) : Integer.MAX_VALUE);
            }
        }
        return dp[N-1];
    }
}

Measured memory_bytes: 33992
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef long double ld;
#define res register
const int INF=0x3f3f3f3f;
template<typename T> inline T read(){
	char ch=getchar();T s=0;int f=1;
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=(s<<1)+(s<<3)+(ch^48);ch=getchar();}
	return s*f;
}
int main(){
	string s,t;
	cin>>s>>t;
	string tmp,ans="";
	if(s.size()<t.size()){
		cout<<"UNRESTORABLE"<<endl;
		return 0;
	}
	for(res int i=0;i<=s.size()-t.size();++i){
		tmp=s;
		res int j;
		for(j=i;j<t.size()+i;++j){
			if(tmp[j]=='?')tmp[j]=t[j-i];
			if(tmp[j]!=t[j-i])break;
		}
		j-=i;
		if(j==t.size()){
			for(res int k=0;k<tmp.size();k++)if(tmp[k]=='?')tmp[k]='a';
			ans=tmp;
		}
	}
	if(ans!=""){
		cout<<ans<<endl;
	}
	else cout<<"UNRESTORABLE"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> inv(n);
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p;
    p--;
    inv[p] = i;
  }
  int maxv = 0;
  int tmp = 0;
  for (int i = 1; i < n; i++) {
    if (inv[i - 1] < inv[i]) {
      tmp++;
    } else {
      maxv = max(maxv, tmp);
      tmp = 0;
    }
  }
  maxv = max(maxv, tmp);
  int ans = n - maxv - 1;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cstring>
#include <climits>
using namespace std;

int room[2][500][500];

struct NODE{
	int x,y,cst;
	NODE(int x,int y,int cst) : x(x) , y(y) , cst(cst) {}
};
bool operator < (const NODE &a,const NODE &b){
	return a.cst > b.cst;
}
bool flag[500][500];
int main(){
	int R;
	while(cin >> R && R){
		int W[2],H[2],sx[2],sy[2];
		map<int,int> result[2];
		result[0][0] = 0;
		result[1][0] = 0;
		
		for(int i = 0 ; i < 2 ; i++){
			cin >> W[i] >> H[i] >> sx[i] >> sy[i];
			sx[i]--,sy[i]--;
			for(int y = 0 ; y < H[i] ; y++)
				for(int x = 0 ; x < W[i] ; x++)
					cin >> room[i][y][x];
			priority_queue<NODE> Q;
			Q.push(NODE(sx[i],sy[i],room[i][sy[i]][sx[i]]));
			memset(flag,0,sizeof(flag));
			while(Q.size()){
				NODE q = Q.top(); Q.pop();
				if(flag[q.y][q.x]) continue;
				else flag[q.y][q.x] = true;
				result[i][q.cst]++;
				int dx[] = {-1,0,1,0} , dy[] = {0,-1,0,1};
				for(int d = 0 ; d < 4 ; d++){
					int tx = q.x + dx[d] , ty = q.y + dy[d];
					if(tx >= 0 && ty >= 0 && tx < W[i] && ty < H[i] && !flag[ty][tx]) Q.push(NODE(tx,ty,max(q.cst,room[i][ty][tx])));
				}
			}
		}
		map<int,int> from;
		vector<int> u;
		int prev = 0;
		for(map<int,int>::iterator it = result[1].begin() ; it != result[1].end() ; ++it){
			from[u.size()] = it->first;
			u.push_back(it->second + prev);
			prev = u.back();
		}
		int ans = INT_MAX;
		u.push_back(INT_MAX);
		int prev2 = 0;
		for(map<int,int>::iterator it = result[0].begin() ; it != result[0].end() ; ++it){
			int thisLevel = it->first;
			int thisCount = it->second + prev2;
			int anotherCount = *lower_bound(u.begin(),u.end(),R-thisCount);
			if(anotherCount != INT_MAX){
				int anotherLevel = from[ lower_bound(u.begin(),u.end(),R-thisCount) - u.begin() ] ;
				ans = min(ans,thisLevel+anotherLevel);
			}
			prev2 += it->second;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <fstream>
#include <math.h>
#include <string>

using namespace std;

int main(){

  int N, M, tmp=0;
  cin >> N >> M;

  double A[N], sum=0.0;
  for(int a=0; a<N; a++){
    cin >> A[a];
    sum += A[a];
  }

  double criterion = sum/4/M;
  for(int i=0; i<N; i++){
    if(A[i] >= criterion) tmp++;
  }

  //cout << sum <<" "<<;


  if(tmp >=M) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}


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

x = list(map(int, input().split()))

#print(N)
#print(x)

def hantei(x):
    count_1 = 0
    x_sort = sorted(x)
    number_1 = range(len(x))
    list_2 = [(x_sort[i],x_sort[j],x_sort[k]) for i in number_1 for j in number_1 for k in number_1 if i < j < k]
    for a in list_2:
        if a[0] + a[1] > a[2] and a[0] != a[1] and a[1] != a[2]:
            count_1 += 1
    return count_1

print(hantei(x))



Measured memory_bytes: 20492
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
	ll a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	int  fun=0;
	if(a+b>2*c)
		fun=1;
	else 
		fun=2;
	ll ans=0;
	if(fun==1)
	{
		ll ans1=0;
		if(x>=y){
			ans=y*2*c+(x-y)*a;
			ans1=x*2*c;
			ans=min(ans1,ans);
		}
		else{
			ans=x*2*c+(y-x)*b;
			ans1=y*2*c;
			ans=min(ans1,ans);
		} 
	}
	else
	{
		ans=x*a+y*b;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    func count() -> Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
}
extension Array where Element: Comparable {
    func max() -> Element! {
        return self.maxElement()
    }
    func min() -> Element! {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let i = readIntSplit(by: " ")
print(i[0]==i[1] ?i[0]*2:i.max()*2-1)


Measured memory_bytes: 7908
//=================================
// Created on: 2018/07/03 05:02:40
//=================================
#include <bits/stdc++.h>
using namespace std;
struct CostGraph
{
    CostGraph(const int v) : V{v}, edge(v) {}
    struct Edge
    {
        Edge(const int from, const int to, const int cost) : from{from}, to{to}, cost{cost} {}
        const int from, to, cost;
    };
    void addEdge(const int from, const int to, const int cost) { edge[from].push_back(Edge{from, to, cost}); }
    const int V;
    vector<vector<Edge>> edge;
};
vector<int> Dijkstra(const CostGraph& g, const int s)
{
    using P = pair<int, int>;
    priority_queue<P, vector<P>, greater<P>> q;
    constexpr int INF = 1 << 30;
    vector<int> d(g.V, INF);
    d[s] = 0, q.push({0, s});
    while (not q.empty()) {
        const int c = q.top().first, v = q.top().second;
        q.pop();
        if (d[v] < c) { continue; }
        for (const auto& e : g.edge[v]) {
            if (d[e.to] <= d[v] + e.cost) { continue; }
            d[e.to] = d[v] + e.cost, q.push({d[e.to], e.to});
        }
    }
    return d;
}
int main()
{
    for (int N;;) {
        cin >> N;
        if (N == 0) { break; }
        vector<vector<int>> t(N, vector<int>(N + 1));
        for (int i = 0; i < N; i++) {
            for (int j = 0; j <= N; j++) { cin >> t[i][j]; }
        }
        const int maximum = 1 << N;
        CostGraph g(maximum);
        for (int i = 0; i < maximum; i++) {
            for (int j = 0; j < N; j++) {
                if (i & (1 << j)) {
                    const int sub = i - (1 << j);
                    int mini = t[j][0];
                    for (int k = 0; k < N; k++) {
                        if (sub & (1 << k)) { mini = min(mini, t[j][k + 1]); }
                    }
                    g.addEdge(sub, i, mini);
                }
            }
        }
        const auto ans = Dijkstra(g, 0);
        cout << ans[maximum - 1] << endl;
    }
    return 0;
}



Measured memory_bytes: 15136
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long ll;
#define INF 100000000
#define MOD 1000000007

int main()
{
	const int N = 100000;
	int n;
	ll k;
	ll num = 0;
	//int a[N];
	vector<int> a;
	ll count[N] = {0};
	
	cin >> n >> k;
	a.resize(n);
	for (int i = 0; i < n; i++) {
		ll b;
		cin >> a[i];
		cin >> b;
		count[a[i] - 1] += b;
	}
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()), a.end());
	/*for (int i = 0; i < a.size(); i++) {
		cout << a[i] << endl;
	}*/
	for (int i = 0; i < a.size(); i++) {
		//cout << count[a[i] - 1] << endl;
		num += count[a[i] - 1];
		//cout << num << endl;
		if (num >= k) {
			cout << a[i] << endl;
			break;
		}
	}

	return (0);
}

Measured memory_bytes: 1408
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

for i in range(h):
  for j in range(w):
    if j > 0 and a[i][j-1] != "." and a[i][j] == "#":
      a[i][j] = "*"
    elif j < w - 1 and a[i][j+1] != "." and a[i][j] == "#":
      a[i][j] = "*"
    elif i > 0 and a[i-1][j] != "." and a[i][j] == "#":
      a[i][j] = "*"
    elif i < h - 1 and a[i+1][j] != "." and a[i][j] == "#":
      a[i][j] = "*"

print("No" if sum([row.count("#") for row in a]) else "Yes")


Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long yoko = sc.nextInt();
        long tate = sc.nextInt();
        long can = (yoko*tate+1)/2;
        if(yoko == 1){
            System.out.println(1);
        }
        else if(tate == 1){
            System.out.println(1);
        }else{
            System.out.println(can);

        }
    }
}


Measured memory_bytes: 21844
a = int(input())
b = 0
for i in range(a):
    cnt = 0
    if (i+1)%2 != 0:
        for j in range(i+1):
            if (i+1)%(j+1) == 0:
                cnt +=1
        if cnt == 8:
            b +=1
print(b)

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

int main() {
	int N;
	cin >> N;
	vector<string> test (N);
	for(int i = 0;i < N;i++){
		cin >> test.at(i);
	}
	sort(test.begin(),test.end());
	vector<string> vec (N);
	vector<int> count (N);
	vec.at(0) = test.at(0);
	count.at(0) = 1;
	int testnum = 1;
	for(int i = 1;i < N;i++){
		if(test.at(i) != test.at(i-1)){
			vec.at(testnum) = test.at(i);
			count.at(testnum) = 1;
			testnum++;
		}
		else{
			count.at(testnum-1)++;
		}
	}
	int M;
	cin >> M;
	vector<string> second (M);
	for(int i = 0;i < M;i++){
		cin >> second.at(i);
	}
	int maxcount = 0;
	for(int i = 0;i < testnum;i++){
		int testcount = count.at(i);
		for(int j = 0;j < M;j++){
			if(vec.at(i) == second.at(j)){
				testcount--;
			}
		}
		maxcount = max(maxcount,testcount);
	}
	cout << maxcount << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        x: [i32; n],
    } 
    println!("{}", (1..101).map(|a| x.iter().map(|b| b - a).map(|b| b * b).sum::<i32>()).min().unwrap())
}

Measured memory_bytes: 4352
import java.util.Scanner;
public class Main{
    public static void calc(double x1, double y1, double x2, double y2, double px, double py){
        if(y1 == y2)
            System.out.println(px + " " + y1);
        else if(x1 == x2)
            System.out.println(x1 + " " + py);
        else{
            double katamuki1 = (y2 - y1)/(x2 - x1);
            double seppen1 = -katamuki1 * x1 + y1;
            double katamuki2 = -1.0 / katamuki1;
            double seppen2 = -katamuki2 * px + py;
            double ansx = (seppen2 - seppen1)/(katamuki1 - katamuki2);
            double ansy = ansx * katamuki1 + seppen1;
            System.out.println(ansx + " " + ansy);
        }
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        int y1 = sc.nextInt();
        int x2 = sc.nextInt();
        int y2 = sc.nextInt();
        int q = sc.nextInt();
        for(int i = 0 ; i < q ; i++){
            int px = sc.nextInt();
            int py = sc.nextInt();
            calc((double)x1,(double)y1,(double)x2,(double)y2,(double)px,(double)py);
        }
    }
}


Measured memory_bytes: 34872
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
const int N = 1e5 + 5;


int32_t main()
{
   IOS;
   string s,t;
   cin >> s >> t;

   int n= s.length();
   int cnt=0;

   for(int i=0; i<n; i++)
   {
   		if(s[i]!=t[i])
   			cnt++;
   }

   cout << cnt << endl;
   


   return 0;
}
 

Measured memory_bytes: 3748
char s[1+6*8];
main(f){
	int n,d,i,j;
	for(;~scanf("%d",&n);){
		memset(s,'\n',1+6*8-1);
		memset(s+1+2*6,'=',5);
		for(i=5;i--;){
			d=n%10;
			n/=10;
			s[1+0*6+i]=d/5?' ':'*';
			s[1+1*6+i]=d/5?'*':' ';
			for(j=5;j--;)
				s[1+(3+j)*6+i]=d%5==j?' ':'*';
		}
		puts(s+f);
		f=0;
	}
}

Measured memory_bytes: 0
if __FILE__ == $0
  i = 1
  while line = STDIN.gets
    tokens = line.chomp!.split.map!(&:to_i)
    x, y, seed = tokens[0], tokens[1], tokens[2]
    ans = 0
    while x <= y
      v = x
      ans += 1 if seed % v == 0
      x += 1
    end
    puts ans
  end
end

Measured memory_bytes: 8612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct edge{ll to, cost;};
typedef pair<ll, ll> P;
vector<edge> G_yen[100010], G_snuuke[100010];
vector<ll> dist_yen, dist_snuuke;
const ll INF = 1e16;

void dij_yen(int start){
  priority_queue<P, vector<P>, greater<P> > que;
  for(int i = 0; i < dist_yen.size(); i++) dist_yen[i] = INF;
  dist_yen[start] = 0;
  que.push(P(0, start));
  while(!que.empty()){
    P p = que.top(); que.pop();
    ll next = p.second;
    if(dist_yen[next] < p.first) continue;
    for(int i = 0; i < G_yen[next].size(); i++){
      edge e = G_yen[next][i];
      if(e.cost + dist_yen[next] < dist_yen[e.to]){
        dist_yen[e.to] = dist_yen[next] + e.cost;
        que.push(P(dist_yen[e.to], e.to));
      }
    }
  }
}

void dij_snuuke(int start){
  priority_queue<P, vector<P>, greater<P> > que;
  for(int i = 0; i < dist_snuuke.size(); i++) dist_snuuke[i] = INF;
  dist_snuuke[start] = 0;
  que.push(P(0, start));
  while(!que.empty()){
    P p = que.top(); que.pop();
    ll next = p.second;
    if(dist_snuuke[next] < p.first) continue;
    for(int i = 0; i < G_snuuke[next].size(); i++){
      edge e = G_snuuke[next][i];
      if(e.cost + dist_snuuke[next] < dist_snuuke[e.to]){
        dist_snuuke[e.to] = dist_snuuke[next] + e.cost;
        que.push(P(dist_snuuke[e.to], e.to));
      }
    }
  }
}

int main(){
  ll N, M, s, t; cin >> N >> M >> s >> t;
  --s;--t;
  dist_yen.assign(N, INF);
  dist_snuuke.assign(N, INF);
  for(int i = 0; i < M; i++){
    int u, v, a, b; cin >> u >> v >> a >> b;
    --u;--v;
    edge e = {u, a}, e1 = {v, a}, e2 = {u, b}, e3 = {v, b};
    G_yen[u].push_back(e1);G_yen[v].push_back(e);
    G_snuuke[u].push_back(e3); G_snuuke[v].push_back(e2);
  }
  dij_yen(s);
  dij_snuuke(t);
  ll ans = 1e18;
  vector<ll> sum(N);
  for(int i = 0; i < N; i++){
    sum[i] = dist_yen[i] + dist_snuuke[i];
  }
  vector<ll> min_money(N);
  min_money[N - 1] = sum[N -1];
  for(int i = N - 2; i >= 0; i--){
    min_money[i] = min(sum[i], min_money[i + 1]);
  }
  for(int i = 0; i < N; i++){
    cout << 1000000000000000 - min_money[i] << endl;
  }
}

Measured memory_bytes: 19908
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll n; cin>>n;
  ll ans = 0;
  for(int i=1; i<n; i++){
    // x*y = i
    for(int j=1; j*j<=i; j++){
      if(i%j==0){
        if(i/j!=j)
          ans += 2;
        else
          ans++;
      }
    }
  }
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
string s[200005],ss[200005];
int main(){
	int n,i,ans=1,sum=1,mx=1;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>s[i];
	}
	sort(s+1,s+n+1);
	ss[1]=s[1];
	for(i=2;i<=n;i++){
		if(s[i-1]!=s[i]){
			sum=1;
			if(mx==1){
				ans++;
				ss[ans]=s[i];
			}
		}else{
			sum++;
			if(mx==sum){
				ans++;
				ss[ans]=s[i];
			}
			if(mx<sum){
				mx=sum;
				ans=1;
				ss[1]=s[i];
			}
		}
	}
	for(i=1;i<=ans;i++){
		cout<<ss[i];
		if(i!=ans) cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int tmp = N;
  int sum = 0;
  
  for(int i; i<9; i++){
    if (tmp<0) break;
    sum += (tmp%10);
    tmp = tmp / 10;
  }
  // cout << N << ':' << sum << endl;
  if (N%sum==0){
  	cout << "Yes" << endl;
  }
  else{
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
function Main(input) {

    input = input.split("\n");

    tmp0 = input[0].split(' ');
    tmp1 = input[1].split(' ');

    var N = parseInt(tmp0[0], 10);
    var M = parseInt(tmp0[1], 10);
    var C = parseInt(tmp0[2], 10);

    for (var i = 0; i < M; i++) {
        tmp1[i] = parseInt(tmp1[i], 10);
    }

    var count = 0

    var value = 0


    for (var i = 0; i < N; i++) {
        var sum = 0

        tmp = input[i + 2].split(" ");

        for (var j = 0; j < M; j++) {
            tmp[j] = parseInt(tmp[j], 10);
        }

        for (var k = 0; k < M; k++) {
            value = tmp[k] * tmp1[k];
            sum += value;
        }

        if (sum + C > 0) {
            count++;
        }
    }

    console.log(count);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21192
import heapq
import math

n,m=map(int,input().split())
a = map(int,input().split())
a = list(map(lambda x:x*-1,a))

heapq.heapify(a)

for _ in range(m):
	l = heapq.heappop(a)
	l = math.ceil(l/2)
	heapq.heappush(a,l)

print(abs(sum(list(a))))

Measured memory_bytes: 14532
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		long h = sc.nextLong();
		long w = sc.nextLong();

		// 計算
		long result = 0;
		if(h > 1 && w > 1){
		    result = ((h+1)/2)*((w+1)/2) + (h/2)*(w/2);
		}else{
		    result = 1;
		}
		
		// 出力
		System.out.println(result);
	}
}





Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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


	int N;
	cin >> N;
	int F[N][10], P[N][11];
	rep(i, 0, N) rep(j, 0, 10) cin >> F[i][j];
	rep(i, 0, N) rep(j, 0, 11) cin >> P[i][j];

	int rsl = -1e9;

	for(int mask = 1; mask < 1 << 10; mask++) {
		int count[N];
		memset(count, 0, sizeof(count));
		rep(i, 0, 10) {
			if(mask & 1 << i) {
				rep(j, 0, N) {
					if(F[j][i] == 1) count[j]++;
				}
			}
		}
		int tmp = 0;
		rep(i, 0, N) tmp += P[i][count[i]];

		rsl = max(rsl, tmp);

	}

	cout << rsl << endl;


}


Measured memory_bytes: 256
# ret = []
N = int(input())
newL = [[0]]
# ret.append(L.copy())

for _ in range(N - 1):
    L = newL.copy()
    newL = []
    for s in L:
        for i in range(max(s) + 2):
            newL.append(s.copy() + [i])
#     ret.append(newL.copy())
    
di = {i: chr(ord('a') + i) for i in range(10)}
print('\n'.join([''.join(list(map(lambda x: di[x], newL[i]))) for i in range(len(newL))]))

Measured memory_bytes: 34960
N,K = map(int,input().split())
x = [int(i) for i in input().split()]
ans = 1e10

for i in range(N-K+1):
    l,r = x[i],x[i+K-1]
    if l < 0 and r <= 0: temp = -l
    elif l >= 0 and r > 0:   temp = r
    else:
        if -l < r:    temp = 2*(-l) + r
        else:    temp = -l + 2*r  
    
    if ans > temp:  ans = temp

print(ans)
        

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define fup(i,a,b) for(int i=a;i<=b;++i)
#define fdw(i,a,b) for(int i=a;i>=b;--i)
#define sync ios::sync_with_stdio(false);cin.tie(0)
#define cl(a) memset(a,0,sizeof(a))
#define gcd __gcd
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
//ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//ll ksm(ll a,ll b,ll mod){ll ans=1;a%=mod;for(;b;b>>=1){if(b&1) ans=ans*a%mod;a=a*a%mod;}return ans;}
//ll oula(ll n){ ll res=n;for(ll i=2;i*i<=n;i++){if(n%i==0){ res=res-res/i;while(n%i==0) n/=i;}}if(n>1) res=res-res/n;return res;}
//bool MRT(ll x){if(x==2)return true;fup(i,1,30){ll now=rand()%(x-2)+2;if(ksm(now,x-1,x)!=1)return false;}return true;}
//void shai(int n)fup(i,2,n){if(isprime[i]){v.push_back(i);for(int j=2*i;j<=10000;j+=i)isprime[j]=0;}}//"埃氏筛筛选素数"
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const int N = 1e5 + 10 ;

int main()
{
    sync;
    string s;
    cin>>s;
    fup(i,1,s.size())
    {
        cout<<"x";
    }
    cout<<endl;
    return 0;
}


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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    for (int i=1;i<=9;i++){
        for (int j=1;j<=9;j++){
            if (i*j == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}

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

typedef long long ll;
ll MOD = 1000000007;

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

    vector <int> a(n+1, 0), b(n+1, 0), ans;
    for (int i = 0; i < n; i++) cin >> a[i+1];

    for (int i = n; i >= 1; i--) {
        int sum = 0;
        for (int j = i*2; j <= n; j+=i) {
            sum += b[j];
        }
        if (sum % 2 != a[i]) {
            ans.push_back(i);
            b[i] = 1;
            //cout << i << endl;
        }
    }
    
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3064
n,c=map(int,input().split())
xv=[]
for _ in range(n):

    xv.append(tuple(map(int,input().split())))

a=[0]*n
a[0]=xv[0][1]-xv[0][0]
for i in range(1,n):
    a[i]=a[i-1]+xv[i][1]-xv[i][0]+xv[i-1][0]


b=[0]*n
b[n-1]=xv[n-1][1]-(c-xv[n-1][0])
for i in range(n-2,-1,-1):
    b[i]=b[i+1]+xv[i][1]-(c-xv[i][0])+(c-xv[i+1][0])

amax=[0]*n
bmax=[0]*n
amax[0],bmax[n-1]=max(0,a[0]),max(0,b[n-1])
for i in range(1,n):
    amax[i]=max(a[i],amax[i-1])
for i in range(n-2,-1,-1):
    bmax[i]=max(b[i],bmax[i+1])

ans=0
for i in range(n):
    if i==n-1:
        ans=max(ans,amax[i])
    else:
        ans=max(ans,amax[i]+bmax[i+1]-xv[i][0])

for i in range(n-1,-1,-1):
    if i==0:
        ans=max(ans,bmax[i])
    else:
        ans=max(ans,amax[i-1]+bmax[i]-(c-xv[i][0]))
print(ans)


Measured memory_bytes: 27632
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
char str[1000001];
pair<char,int> Q[1000000];
int main(){
	scanf("%s",str);
	int len=strlen(str);
	int ret=0;
	int now=0;
	int val=1;
	char last=str[0];
	for(int i=1;i<len;i++){
		if(last==str[i]){
			val++;
		}else{
			Q[now++]=make_pair(last,val);
			val=1;
			last=str[i];
		}
	}
	Q[now++]=make_pair(last,val);
	for(int i=1;i<now-1;i++){
		if(Q[i-1].first=='J'&&Q[i].first=='O'&&Q[i+1].first=='I'){
			if(Q[i-1].second>=Q[i].second&&Q[i+1].second>=Q[i].second)ret=max(ret,Q[i].second);
		}
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 0
/*input
8 10
*/
macro_rules! input_vec {
    () => {
        input!()
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };
    ($delimiter:expr) => {
        input!()
            .split($delimiter)
            .map(|x| x.parse().unwrap())
            .collect()
    };
}

macro_rules! input {
    () => {{
        let mut return_ = String::new();
        std::io::stdin().read_line(&mut return_).ok();
        return_.pop();
        return_
    }};
}

fn main() {
    let n: Vec<u32> = input_vec!();
    print!(
        "{:032b}\n{:032b}\n{:032b}\n",
        n[0] & n[1],
        n[0] | n[1],
        n[0] ^ n[1]
    );
}



Measured memory_bytes: 5020
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

#define int long long

#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=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}
constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

int N, M, Q;
int arr[14];
int a[55], b[55], c[55], d[55];

int mx = 0;

void dfs(int len, int cur)
{
	if (len == N) {
		int s = 0;
		rep(i, Q) {
			if (arr[b[i]] - arr[a[i]] == c[i]) {
				s += d[i];
			}
		}
		chmax(mx, s);
		return;
	}
	for (int i = cur; i <= M; ++i) {
		arr[len] = i;
		dfs(len + 1, i);
	}
}

signed main()
{
	cin>>N>>M>>Q;
	rep(i, Q) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		--a[i], --b[i];
	}
	dfs(0, 1);
	cout << mx << endl;
}



Measured memory_bytes: 3592
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

int calc(int pre_row,int pre_col,int current_row,int current_col){

	int diff_SAYUU,diff_JYOUGE;
	if(pre_row == current_row){
		return abs(pre_col - current_col);
	}else if(pre_col == current_col){
		return abs(pre_row - current_row);
	}else{
		diff_JYOUGE = abs(pre_row-current_row);
		diff_SAYUU = abs(pre_col-current_col);

		if(pre_row > current_row){ 
			if(pre_col > current_col){

				if(diff_JYOUGE > diff_SAYUU){
					return diff_SAYUU + abs((pre_row-diff_SAYUU)-current_row);
				}else{
					return diff_JYOUGE + abs((pre_col-diff_JYOUGE)-current_col);
				}

			}else{ //pre_col < current_col
				return diff_JYOUGE+diff_SAYUU;
			}
		}else{ //pre_row < current_row
			if(pre_col > current_col){
				return diff_JYOUGE+diff_SAYUU;
			}else{ //pre_col < current_col
				if(diff_JYOUGE > diff_SAYUU){
					return diff_SAYUU + abs(current_row-(pre_row+diff_SAYUU));
				}else{
					return diff_JYOUGE + abs(current_col-(pre_col+diff_JYOUGE));
				}
			}
		}
	}
}

int main(){

	int W,H,N,pre_row,pre_col,current_row,current_col,sum = 0;

	scanf("%d %d %d",&W,&H,&N);

	scanf("%d %d",&pre_col,&pre_row);

	for(int i = 1; i < N; i++){
		scanf("%d %d",&current_col,&current_row);

		sum += calc(pre_row,pre_col,current_row,current_col);

		pre_row = current_row;
		pre_col = current_col;
	}

	printf("%d\n",sum);

	return 0;
}

Measured memory_bytes: 2712
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<vector<double>> v;
  rep(i,N){
    double x, y;
    cin >> x >> y;
    v.push_back({x,y});
  }

  vector<int> w;
  rep(i,N) w.push_back(i);

  int M = 0;
  double sum = 0;
  do {
    double tmp = 0;
    rep(i,N-1){
      int ii = w[i];
      double x1 = v[w[i]][0];
      double y1 = v[w[i]][1];
      double x2 = v[w[i+1]][0];
      double y2 = v[w[i+1]][1];
      tmp += sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
    }
    sum += tmp;
    M++;
  }while(next_permutation(ALLOF(w)));

  printf("%.12lf\n", sum / M);
  
  return 0;
}


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

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int m = Integer.parseInt(sc.next());
    int[] an = new int[n];
    for (int i = 0; i < n; i++) {
      an[i] = Integer.parseInt(sc.next());
    }
    while (m > 0) {
      Arrays.sort(an);
      int a = an[n - 1];
      int halfA = a / 2;
      an[n - 1] = halfA;
      m--;
      if (m == 0) {
        break;
      }
      for (int i = n - 2; i >= 0 && an[i] > halfA; i--) {
        an[i] /= 2;
        m--;
        if (m == 0) {
          break;
        }
      }
    }
    pw.println(Arrays.stream(an).mapToLong(i -> i).sum());
  }
}


Measured memory_bytes: 48928
#include <bits/stdc++.h>
using namespace std;
int n,sol,x;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        cin>>x;
        if(x%2) sol=1;
    }
    if(sol) cout<<"first";
    else cout<<"second";
//    for(int i=1;i<=n;++i)
//    {
//        cin>>t1[i];
//        cin>>t2[i];
//    }
//    v1[n]=0;
//    for(int i=n-1;i>=1;--i)
//    {
//        nr=n-i;
//        while(v[i]>v[i+1])
//        {
//            v[i]
//        }
//    }
    return 0;
}


Measured memory_bytes: 256
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    d = collections.defaultdict(list)
    d[1] += [0]
    d[3] += [0]
    d[5] += [0]
    d[7] += [0]
    d[8] += [0]
    d[10] += [0]
    d[12] += [0]
    d[4] += [1]
    d[6] += [1]
    d[9] += [1]
    d[11] += [1]
    d[2] += [2]
    x, y = list(map(int, input().rstrip('\n').split()))
    print("Yes" if d[x] == d[y] else "No")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX/2e5

ll mpow(ll a, ll b){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}

vv64 gr;
vp64 ans;
v64 vis,num;

void dfs(ll v, ll val){
	vis[v]=val;
	forn(i,(ll)gr[v].size()){
		if(vis[gr[v][i]]){
			if(vis[gr[v][i]]<val) continue;
			ans.pb(mp(v,gr[v][i]));
			num[v]++;
		}
		else{
			dfs(gr[v][i],val+1);
			if(num[gr[v][i]]%2){
				ans.pb(mp(gr[v][i],v));
				num[gr[v][i]]++;
			}
			else{
				ans.pb(mp(v,gr[v][i]));
				num[v]++;
			}
		}
	}
}

void solve(ll index){
	ll n,m;
	cin >> n >> m;
	gr.resize(n+5);
	vis.resize(n+5,0);
	num.resize(n+5,0);
	forn(i,m){
		ll t1,t2;
		cin >> t1 >> t2;
		gr[t1].pb(t2);
		gr[t2].pb(t1);
	}
	dfs(1,1);
	forsn(i,1,n+1){
		if(num[i]%2){
			cout << -1 << ln;
			return;
		}
	}
	forn(i,(ll)ans.size()){
		cout << ans[i].fi << " " << ans[i].se << ln;
	} 
}

int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    // cin >> t;
    forn(i,t) solve(i+1);
    return 0;
}

Measured memory_bytes: 19568
n,m = map(int,input().split())
mod = 10**9+7
def fact(x):
    a = 1
    for i in range(1,x+1):
        a = (a*i)%mod
    return a
if n >m+1 or m>n+1:
    print(0)
  

elif n == m+1:
    p = (fact(m)**2)%mod
    print(p*(m+1)%mod)

elif m == n+1:
    p = (fact(n)**2)%mod
    print(p*(n+1)%mod)
elif m == n:
    p = fact(n)**2%mod
    print(p*2%mod)

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

signed main() {
  int n;
  cin >> n;

  vector<int> s(n);
  for ( int i = 0; i < n; i++ ) cin >> s[i];

  int q;
  cin >> q;
  
  vector<int> t(n);
  for ( int i = 0; i < q; i++ ) cin >> t[i];
  
  int cnt = 0;
  for ( int i = 0; i < q; i++ ) {
    if ( binary_search(s.begin(), s.end(), t[i]) ) cnt++;
  }

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



Measured memory_bytes: 3584
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-9
#define MOD 1000000007
#define int long long
using namespace __gnu_pbds;
using namespace std;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ost;


int32_t main(){
	int h, w;
	cin >> h >> w;
	char a[h][w];
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++)
			cin >> a[i][j];
	}
	vector<vector<int>> dp(h+1,vector<int>(w+1,0));
	dp[1][1] = 1;
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			if(a[i-1][j-1] == '#')
				continue;
			dp[i][j] += (i > 1 && a[i-2][j-1] == '.' ? dp[i-1][j] : 0);
			dp[i][j] %= MOD;
			dp[i][j] += (j > 1 && a[i-1][j-2] == '.' ? dp[i][j-1] : 0);
			dp[i][j] %= MOD;
		}
	}
	cout << dp[h][w] << "\n";

	return 0;
}

Measured memory_bytes: 9088
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>

#define MOD 1000000007
#define DEBUG 0


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

long long int gcd(long long int a, long long int b) {
	long long int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int a, long long int b) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}

bool isPrime(int n) {
	if (n == 1)return false;
	if (n == 2)return true;

	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}

	return true;
}


int main()
{

	int n;
	cin >> n;

	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	long long int ans = 0;

	if (a[0] == 0 && a.size() % 2 == 1) {

		ans = 1;
		for (int i = 1; i < a.size(); i += 2) {
			if (a[i] != i+1) {
				ans = 0;
				break;
			}
			if (a[i + 1] != i + 1) {
				ans = 0;
				break;
			}

			ans *= 2;
			ans %= MOD;
		}

	}
	else if (a[0] == 1 && a.size() % 2 == 0) {

		ans = 1;
		for (int i = 0; i < a.size(); i += 2) {
			if (a[i] != i + 1) {
				ans = 0;
				break;
			}
			if (a[i + 1] != i + 1) {
				ans = 0;
				break;
			}

			ans *= 2;
			ans %= MOD;

		}


	}


	cout << ans << endl;


	return 0;

}



Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

ll power(ll x, ll m){
    if(m == 0) return 1;
    if(m == 1) return x;
    if(m % 2 == 0){
        return power(x*x,m/2);
    }else{
        return power(x*x,m/2)*x;
    }
}

int main(){
    ll n; cin >> n;
    vl a(n);
    rep(i,n){
        cin >> a[i];
    }
    ll ans = 0;
    rep(i,n){
        while(a[i]>0){
            if(a[i]%2 == 0){
                ans++;
                a[i] /= 2;
            }else{
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define X first
#define Y second
#define for0 for(int i=0;i<n;i++)
int main(){
    long long a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k<=a) cout<<k;
  else if(k>a&&k<=a+b) cout<<a;
  else if(k>a+b&&k<=a+b+c) cout<<a-(k-a-b);
   
    
}


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

using namespace std;

int main() {

    int N, M, C;
    cin >> N >> M >> C;

    int ans = 0;

    int B[M + 1];
    for (int m = 1; m <= M; m++) {
        cin >> B[m];
    }

    int A[N + 1][M + 1];
    for (int n = 1; n <= N; n++) {
        for (int m = 1; m <= M; m++) {
            cin >> A[n][m];
        }
    }

    for (int n = 1; n <= N; n++) {

        vector<int> members;

        for (int m = 1; m <= M; m++) {
            int x = A[n][m] * B[m];
            members.push_back(x);
        }

        int sum = accumulate(members.begin(), members.end(), 0LL) + C;
        if (sum > 0) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> c(n);

	for(int i=0; i<n; i++) cin >> v[i];
	for(int i=0; i<n; i++) cin >> c[i];

	int ans = 0;
	for(int i=0; i<n; i++){
		int a = v[i]-c[i];
		ans += max(0,a);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(){
   int n;
   cin>>n;
   for(int i=1;i<n+1;i++){
      int ans=0;
      int x=1;
      float g1;
      g1 = sqrt(n/6.00);
      while(x<=g1){
         int y=x;
         //cout<<x<<endl;
         float g2 ;
         g2 = (sqrt(3.00*i-2.00*x*x)-x)/3.00;
         while(y<=g2){
            int z;
            z = (sqrt(4*i-3*x*x-3*y*y-2*x*y)-x-y)/2;
            int g4;
            g4 = x*x+y*y+z*z+x*y+y*z+z*x;
            //cout<<x<<y<<z<<endl;
            if(g4==i){
               if(x==y && y==z) ans+=1;
               else if(x==y || y==z || z==x) ans+=3;
               else ans+=6;
            }
            y+=1;
         }
         x+=1;
      }
      cout<<ans<<endl;
   }
   return 0;
}

Measured memory_bytes: 3704
#include <stdio.h>
int main(void)
{
  int i;
  
  int n; 
  scanf("%d",&n);
  int S[n];
  for(i=0;i<n;i++) {
    scanf("%d",&S[i]);
  }

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

  int count=0;

  for(i=0;i<q;i++) {
    int left=0,right=n-1;
    while(left<=right) {
      int mid=(left+right)/2;
      if(T[i]==S[mid]) {
	count++;
	break;
      }
      else if(T[i]>S[mid])
	left=mid+1;
      else
	right=mid-1;
    }
  }

  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 2292
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LL long long int
const LL MOD=1e9+7;
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//            When something is important enough, you do it even if the odds are not in your favor.

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // code goes here
    LL t=1;//cin>>t;
    while(t--){
      string s;cin>>s;
      LL sum=0;
      for(auto x:s) sum+=x-'0';
        if(sum%9) cout<<"No";
      else cout<<"Yes";
    }
    return 0;
}

Measured memory_bytes: 3780