akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        String s = in.next();
        String t = in.next();
        int m = s.length();
        int n = t.length();
        int[][] L = new int[m + 1][n + 1];
        for (int i = 0; i <= m; i++) {
            for (int j = 0; j <= n; j++) {
                if (i == 0 || j == 0) {
                    L[i][j] = 0;
                } else if (s.charAt(i - 1) == t.charAt(j - 1)) {
                    L[i][j] = L[i - 1][j - 1] + 1;
                } else {
                    L[i][j] = Math.max(L[i - 1][j], L[i][j - 1]);
                }
            }
        }
        int index = L[m][n];
        int temp = index;
        char[] lcs = new char[index + 1];
        lcs[index] = Character.MIN_VALUE;
        int i = m, j = n;
        while (i > 0 && j > 0) {
            if (s.charAt(i - 1) == t.charAt(j - 1)) {
                lcs[index - 1] = s.charAt(i - 1);
                i--;
                j--;
                index--;
            } else if (L[i - 1][j] > L[i][j - 1]) {
                i--;
            } else {
                j--;
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int k = 0; k <= temp - 1; k++) {
            sb.append(lcs[k]);
        }
        out.println(sb.toString());
        out.close();
    }

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

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

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

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

    }
}


Measured memory_bytes: 80936
from itertools import accumulate
n,x = (int(i) for i in input().split())
l = [int(i) for i in input().split()]
ruiseki = list(accumulate(l))
ruiseki.insert(0,0)
i = 0
#print(ruiseki)
while i < len(ruiseki) and ruiseki[i] <= x:
    i += 1
print(i)


Measured memory_bytes: 3060
import sys
from itertools import combinations_with_replacement, product
import numpy as np
def input(): return sys.stdin.readline().rstrip()


def main():
    n, m, x = map(int, input().split())
    data = np.zeros((n,m+1),int)
    ans=10**10
    for i in range(n):
        data[i]=np.array(list(map(int, input().split())))
    for bit in list(product([0,1],repeat=n)):
        calc=np.dot(np.array(bit), data)
        if all(calc[1:]>=x):
            ans=min(ans,calc[0])
    
    if ans==10**10:
        print(-1)
    else:
        print(ans)




if __name__ == '__main__':
    main()

Measured memory_bytes: 27612
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

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;}

const ll mod = 1000000007;
const int INF = 1<<29;

int main(){
  int A, B; cin >> A >> B;

  int res = 0;
  for (int i = 1; i <= 1000; ++i){
    if ((i * 8) / 100 == A && (i * 10) / 100 == B) {res = i;  break;}
  }
  if (res == 0) res = -1;
  cout << res << endl;
}


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

class Main{
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st  = new StringTokenizer(br.readLine());

        int n = Integer.parseInt(st.nextToken());
        int q = Integer.parseInt(st.nextToken());
        st  = new StringTokenizer(br.readLine());

        int[] arr = new int[n];
        for (int i=0; i<n; i++) {
            arr[i] = Integer.parseInt(st.nextToken());
        }

        Query[] queries = new Query[q];
        ArrayList<Query>[] queriesAt = new ArrayList[n];
        for (int i=0; i<n; i++) queriesAt[i]=new ArrayList<>();

        for (int i=0; i<q; i++) {
            st  = new StringTokenizer(br.readLine());
            int l=Integer.parseInt(st.nextToken())-1;
            int r=Integer.parseInt(st.nextToken())-1;
            queries[i] = new Query(l,r,i);
            queriesAt[r].add(queries[i]);
        }

        int[] lastseen = new int[500001];
        Arrays.fill(lastseen, -1);

        SegTree segTree = new SegTree(0,n-1);

        for (int i=0; i<n; i++) {
            if (lastseen[arr[i]]!=-1) {
                segTree.update(lastseen[arr[i]],0);
            }
            lastseen[arr[i]] = i;
            segTree.update(lastseen[arr[i]],1);
            for (Query qq: queriesAt[i]){
                qq.ans = segTree.query(qq.l,qq.r);
            }
        }

        for (int i=0; i<q; i++) {
            out.println(queries[i].ans);
        }
        out.close();
    }

    static class SegTree{
        int leftmost,rightmost,sum;
        SegTree lchild, rchild;
        SegTree(int l, int r){
            leftmost=l;
            rightmost=r;
            if (leftmost==rightmost) {
                sum=0;
            }
            else {
                int mid = l+(r-l)/2;
                lchild = new SegTree(l, mid);
                rchild = new SegTree(mid+1, r);
            }
        }
        public void recalc() {
            if (leftmost!=rightmost) {
                sum = lchild.sum+rchild.sum;
            }
        }
        public void update(int idx, int val){
            if (leftmost==rightmost) {
                this.sum=val;
            }
            else if (idx<=lchild.rightmost) {
                lchild.update(idx, val);
            }
            else{
                rchild.update(idx, val);
            }
            recalc();
        }
        public int query(int l, int r){
            if (l>rightmost || r<leftmost) {
                return 0;
            }
            else if (l<=leftmost && r>=rightmost)
                return sum;
            else
                return lchild.query(l,r)+rchild.query(l,r);
        }
    }
    static class Query{
        int l,r,ans,idx;
        Query(int a, int b, int c){
            l=a;
            r=b;
            idx=c;
        }
    }




}

Measured memory_bytes: 141104
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

#if __has_include("debug.hpp")
#include "debug.hpp"
#else
template<typename T>
void debug(T& obj) {}
#endif

template<typename T>
T in(){
	T val;
	cin >> val;
	return val;
}

template<typename T>
vector<T> inv(ll num) {
	vector<T> val(num);
	rep(i,num) cin >> val[i];
	return val;
}

//----------------------------------------------------------------------
void solve() {

	int n,m;
	cin >> n >> m;
	vector<int> vec(n, -1);
	bool flag = true;
	rep(i, m) {
		int s, c;
		cin >> s >> c;
		if (vec[s-1] == -1) vec[s-1] = c;
		else if (vec[s-1] != c) {
			flag = false;
			break;
		}
	}

	if (flag == false) {
		cout << -1;
	} else {
		if (vec[0] == 0 && n != 1) cout << -1;
		else {
			rep(i,n) {
				if (vec[i] != -1) cout << vec[i];
				else if (i==0 && n!=1) cout << 1;
				else if (i==0 && n==1) cout << 0;
				else cout << 0;
			}
		}
	}

}
//----------------------------------------------------------------------

int main(int argc, char* argv[]) {
	solve();
	return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<map>
#include<cstring>
using namespace std;

bool comp(const int&a,const int&b)
{
	return a>b;
}

int main()
{
	map<long long,int> m;
	int n;
	scanf("%d",&n);
	long long a[n];
	for(int i=0;i<n;i++)
	{
		scanf("%ld",&a[i]);
	}
	sort(a,a+n,comp);
	long long max1=0,max2=0;
	for(int i=0;i<n;i++)
	{
		m[a[i]]++;
		if(m[a[i]]==4)
		{
			printf("%ld\n",a[i]*a[i]);
			return 0;
		}
		if(m[a[i]]==2&&max1==0) {max1=a[i];continue;}
		if(m[a[i]]==2&&max2==0) {max2=a[i];break;}
	}
	if(!max2) cout<<0<<endl;
	else
	{
		printf("%ld\n",max1*max2);
	}
	return 0;
}








Measured memory_bytes: 6272
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define de(x) cout<<#x<<"="<<x<<endl;
using namespace std;
set<string> s;
int main(void)
{
	s.clear();
	string x,y;
	cin>>x>>y;
	bool flag=false;
	bool flag2=false;
	rep(i,0,x.length())
	{
		flag=true;
		rep(j,0,y.length())
		{
			if(x[i+j]!='?'&&x[i+j]!=y[j])
			{
				flag=false;
				break;
			}
		}
		if(flag==true)
		{
			flag2=true;
			string s1=x;
			rep(j,0,y.length()) s1[i+j]=y[j];
			rep(j,0,s1.length()) if(s1[j]=='?')s1[j]='a';
			//cout<<x<<"  "<<s1<<endl;;
			s.insert(s1);
		}
	}
	if(flag2)cout<<*s.begin();
	else printf("UNRESTORABLE");
	return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> a(H);
  
  for (int i = 0; i < H; i++) {
    cin >> a.at(i);
  }
  //cout << a.at(0) << endl;
  
  
  vector<string> hash(W+2);
  for (int i = 0; i < W+2; i++) {
    hash.at(i) = '#';
    cout << hash.at(i);
  }
  cout << endl;
  
  for (int i =0; i < H; i++) {
    cout << '#' << a.at(i) << '#' << endl;
  }
  
  for (int i = 0; i < W+2; i++) {
    cout << hash.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 256
from collections import Counter
N, K = map(int, input().split())
a = []
for i in range(1, N+1):
    a.append(i%K)
b = Counter(a)
ans = 0
for x in b:
    if x == 0:
        ans += b[x]**3
        continue
    if K%2 == 0 and x == K//2:
        ans += b[K//2]**3
print(ans)

Measured memory_bytes: 16620
l = [int(i) for i in list(input())]
a=l[0]
b=l[1]
c=l[2]
d=l[3]
a_=str(a)
b_=str(b)
c_=str(c)
d_=str(d)
if a+b+c+d == 7:
    print(a_+'+'+b_+'+'+c_+'+'+d_+'=7')
elif a+b+c-d == 7:
    print(a_+'+'+b_+'+'+c_+'-'+d_+'=7')
elif a+b-c+d == 7:
    print(a_+'+'+b_+'-'+c_+'+'+d_+'=7')
elif a+b-c-d == 7:
    print(a_+'+'+b_+'-'+c_+'-'+d_+'=7')
elif a-b+c+d == 7:
    print(a_+'-'+b_+'+'+c_+'+'+d_+'=7')
elif a-b-c+d == 7:
    print(a_+'-'+b_+'-'+c_+'+'+d_+'=7')
elif a-b+c-d == 7:
    print(a_+'-'+b_+'+'+c_+'-'+d_+'=7')
elif a-b-c-d == 7:
    print(a_+'-'+b_+'-'+c_+'-'+d_+'=7')

Measured memory_bytes: 38256
#pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;

typedef int64_t i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
    i64 from, to, cost;
    edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
    edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

// 多重vectorを可変引数テンプレートで http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e : t) fill_v(e, v);
}
//

#pragma endregion

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

int main() {
    i64 n;
    cin >> n;
    vector<i64> t(n), a(n);
    for(int i = 0; i < n; ++i) cin >> t[i];
    for(int i = 0; i < n; ++i) cin >> a[i];
    vector<bool> x(n, false), y(n, false);
    x[0] = y[n - 1] = true;
    for (int i = 1; i < n; ++i) {
        if (t[i] != t[i - 1]) {
            x[i] = true;
        }
    }
    for (int i = n - 2; i >= 0; --i) {
        if (a[i] != a[i + 1]) {
            y[i] = true;
        }
    }
    i64 ans = 1;
    for (int i = 0; i < n; ++i) {
        if (x[i] && y[i]) {
            if (t[i] != a[i]) {
                ans = 0;
            }
        }
        else if (x[i]){
            if(t[i] > a[i]) ans = 0;
        }
        else if (y[i]) {
            if(a[i] > t[i]) ans = 0;
        }
        else {
            ans = ans * min(t[i], a[i]) % MOD;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }


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

	int N, M; cin >> N >> M;
	string S; cin >> S;
	reverse(all(S));

	vector<int> mini(N + 1);
	rep(i, 0, N + 1) {
		if (S[i] == '0')mini[i] = i;
		else mini[i] = mini[i - 1];
	}
	dump(mini);

	vector<int> ans;

	int s = 0;
	bool ok = true;
	while (s != N) {
		dump(s);
		int ns = mini[min(N, s + M)];
		dump(ns);
		if (s == ns) {
			ok = false;
			break;
		}
		ans.push_back(ns - s);
		s = ns;
	}
	reverse(all(ans));

	if (ok) {
		cout << ans[0]; rep(i, 1, ans.size()) { cout << " " << ans[i]; } cout << endl;
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 2248
import sys
import math
sys.setrecursionlimit(1000000)
mod=1000000007
class Node:
    def __init__(self):
        self.next=[]
    def get_data(self,new_next,weight=1):
        self.next.append(new_next)
def BFS(i,depth,K):  
    depth+=1
    tmp=i
    seki=1
    num=len(tmp)
    if depth==1:
        calc=K-1
        loop=range(calc,calc-num,-1)
        for i in loop:
            seki*=i%1000000007

        
    else:
        calc=K-2
        num-=1
        if calc>=num:
            seki=cache[num]
        else:
            print(0)
            exit()

            
            
    for each in tmp:
        if not check_node[each]:
            check_node[each]=True
            seki*=BFS(node[each].next,depth,K)%mod
    return seki


N,K=list(map(int,input().split()))

if K>2:
    cache=[0 for i in range(K-2)]
    cache[0]=1
    for i in range(1,K-2):
        cache[i]=cache[i-1]*(K-1-i)%mod
    cache.append(cache[-1])
else:
    cache=[1,1]
node=[Node() for _ in range(N)]
check_node=[False for _ in range(N)]
check_node[0]=True
for i in range(N-1):
    p,n=list(map(int,input().split()))
    node[n-1].get_data(p-1)
    node[p-1].get_data(n-1)
start=0
d=0

com=K*BFS(node[0].next,d,K)
print(int(com)%mod)

Measured memory_bytes: 112748
#include<iostream>
#include<queue>
using namespace std;
#define P pair<int,int>

deque<P> q;
bool did[100010];

int main(){
  int k;

  cin>>k;

  q.push_front(P(1,1));

  while(1){
    P p = q.front(); q.pop_front();
    if(did[p.first]) continue;
    did[p.first] = true;
    if(p.first==0){
      cout<<p.second<<endl;
      break;
    }
    q.push_back(P((p.first+1)%k,p.second+1));
    q.push_front(P((p.first*10%k),p.second));
  }

  return 0;
}




Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int  n, m, sum;
  cin >> n >> m;
  vector<int> a(n);
  string ans;
  ans = "No";
  sum = 0;
  for(int i=0; i < n; i++){
    cin >> a[i];
    sum += a[i];
  }
  sort(a.begin(), a.end());
  if(sum <= a[n-m]*4*m){
    ans = "Yes";
  }

  cout << ans <<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		int INF = 100000000;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] dp = new int[n+1];
		int [] a = new int[m];
		for(int i = 0; i < m; i++) {
			a[i] = sc.nextInt();
		}
		int[] cost = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
		Arrays.sort(a);
		Arrays.fill(dp, -INF);
		dp[0] = 0;
		for(int i = 1; i <= n; i++) {
			for(int j = m-1; j >= 0; j--) {
				if(i - cost[a[j]] < 0) continue;
				else
					dp[i] = Math.max(dp[i],dp[i-cost[a[j]]] + 1);
			}
		}
		StringBuilder ans = new StringBuilder();
		while(n != 0) {
			for(int j = m-1; j >= 0; j--) {
				if(cost[a[j]] > n)
					continue;
				if(dp[n-cost[a[j]]] == dp[n]-1) {
					ans.append(a[j]);
					n -= cost[a[j]];
					break;
				}
			}
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 23764
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	int sx, sy, tx, ty;
	int X, Y;

	cin >> sx >> sy >> tx >> ty;

	X = abs(tx - sx);
	Y = abs(ty - sy);

	int i;
	// 1
	for (i = 0;i < X;i++)
		cout << "R";

	for (i = 0;i < Y;i++)
		cout << "U";

	// 2
	for (i = 0;i < X;i++)
		cout << "L";

	for (i = 0;i < Y;i++)
		cout << "D";

	// 3
	cout << "D";

	for (i = 0;i < X + 1;i++)
		cout << "R";

	for (i = 0;i < Y + 1;i++)
		cout << "U";

	cout << "L";

	// 4
	cout << "U";

	for (i = 0;i < X + 1;i++)
		cout << "L";

	for (i = 0;i < Y + 1;i++)
		cout << "D";

	cout << "R" << endl;

	return 0;
}


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

int main()
{
    int N;
    long long dai = 0;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
        if(i>0 && A.at(i-1)>A.at(i))
        {
            dai += A.at(i - 1) - A.at(i);
            A.at(i) += A.at(i-1)-A.at(i);
        }
    }
    cout << dai << endl;

}


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

#define vi vector<int>
#define all(v) v.begin(),v.end()
#define ll long long int
#define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll MOD=1e9+7;

void solve(){
   int n;
   cin >> n;
   vector<int>v(n);
   ll sum=0;
   for(int i=0;i<n;i++)cin >> v[i],sum+=v[i];
   int m;
   cin >> m;
   for(int i=0;i<m;i++){
     int a,b;
     cin >> a >> b;
      cout << sum-v[a-1]+b<<'\n';
   }
}


int main(){
  IOS
     solve();
}
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]"):
    from itertools import accumulate
    s = sum(a)
    return min(abs(s-2*aa) for aa in accumulate(a[:-1]))

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, a))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 32268
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
#define int long long
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
int x=read(),cur=100,cnt=0;
signed main(){
	while(cur<x){
		cur=(int)(1.01*cur);
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3468
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std ;
#define ll long long 
#define MXN 100005

int main(){
	int n;
	cin>>n;
	ll h[MXN];
	for(int i=0;i<n;i++) cin>>h[i];
	
	int cnt=0,m=0;
	for(int i=1;i<n;i++){
		if(h[i-1]<h[i]){
			cnt=max(cnt,m);
			m=0;
		}
		else
			m++;
	//	cout<<m<<"　";
	}
	cnt=max(cnt,m);
	cout<<cnt<<'\n';
	return 0;
}



Measured memory_bytes: 1024
n, k = map(int, input().split())
lst = list(map(int, input().split()))
idx = lst.index(1)
k -= 1
a = (len(lst[:idx]) + k - 1) // k
b = (len(lst[idx + 1:]) + k - 1) // k
c = ((n - 1) + k - 1) // k
print(min(c, a + b))

Measured memory_bytes: 20328
import sys
input=sys.stdin.buffer.readline
H,N = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(N)]
dp = [10000000000]*(H+1)
dp[0] = 0
for i in range(1,H+1):
    for j in range(N):
        A = ab[j][0]
        B = ab[j][1]
        if i - A < 0:
            dp[i] = min(dp[i],dp[0]+B)
        else:
            dp[i] = min(dp[i],dp[i-A]+B)
print(dp[H])

Measured memory_bytes: 42092
#include <bits/stdc++.h>
#define repeat(i, n) for(int (i) = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
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; }

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

	bool is_hitachi = true;
	for(int i = 0; i < S.length(); i += 2) {
		string s = S.substr(i, 2);
		if (s != "hi") {
			is_hitachi = false;
		}
	}

	cout << ( (is_hitachi) ? "Yes" : "No" ) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define ll long long 
#define f(i, a, b) for(ll i=a;i<b;i++)
#define fi(i, a, b) for(ll i=b-1;i>=a;i--)
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define ml map<ll,ll> 

vi arr[100010];
vi garr[100010];
bool visi[100010];
ll M  = (ll)(1e9+7);
ll ans[100010];
void bfs(int i)
{
   visi[i] = true;
   ll b=1;
   ll w=1;
   for(auto it: arr[i])
   {
      if(!visi[it])
      {
         bfs(it);
         w*=ans[it];
         w%=M;
         for(auto g:arr[it])
         {
            if(g!=i)
            {
               b*=ans[g];
               b%=M; 
            } 
         }
      }
   }
   ans[i] = b+w;
   ans[i]%=M;
   // cout<<i<<" "<<ans[i]<<"\n";
}

void solve()
{
   ll n;
   cin>>n;
   ll x,y;
   if(n==1)
   {
      cout<<"2\n";
      return;
   }
   f(i,0,n-1)
   {
      cin>>x>>y;
      arr[x].pb(y);
      arr[y].pb(x);
   }
   f(i,1,n+1)
   {
      visi[i] = false;
   }
   bfs(x);
   cout<<ans[x]<<"\n";

}

int main()
{
   ll t;
   t=1;
//    cin>>t;
   while (t--)
   {
       solve();
   }  
}

Measured memory_bytes: 16128
import java.util.*;

public class Main { //クラス名はMain
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
      	double b = sc.nextDouble();
        int o=0;
        o=(int)Math.ceil((b-1)/(a-1));
        System.out.println(o);
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define sz(x) (int)((x).size())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i, a, n, step) for (int (i) = (a); (i) < (int)(n); (i) += (step))
#define ROF(i, a, n, step) for (int (i) = (a); (i) >= (int)(n); (i) += (step))
#define FOREACH(it, v) for (auto (it) : (v))

using namespace std;

typedef unsigned long long ull;
typedef long long ll ;
typedef long double ld;
typedef pair <int, int> pii;

template <class T>
const bool is_impar(const T &x) {return (bool) (x & 1);}

int a, b, c;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> a >> b >> c;
    if (a > b)
        swap(a, b);
    if (a > c)
        swap(a, c);
    if (b > c)
        swap(b, c);
    cout << b - a + c - b;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int m,nmin,nmax;
string s;

int main() {
	cout << fixed << setprecision(18);
	cin>>m>>nmin>>nmax;
	while(0!=m){
		
		long long int p[210],res,gap=0;
		for(int i=1;i<=m;i++){
			cin>>p[i];
		}
		sort(p+1,p+m+1);
		for(int i=m-nmax+1;i<=m-nmin+1;i++){
			if(gap<p[i]-p[i-1]){
				gap=p[i]-p[i-1];
				res=m-i+1;
			}
		}
		cout<<res<<endl;
		cin>>m>>nmin>>nmax;
	}
	
} 


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a[N];
  int b[N];
  for(int i = 0;i<N;i++){
    cin>>a[i];
    if(i == 0){
      b[0] = a[0];
    }
    if(i>0){
      b[i] = b[i-1]+a[i];
    }
  }
  int ans = 1000000;
  for(int i = 0;i<N;i++){
    ans = min(ans,abs(b[N-1]-2*b[i]));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;


template<class T> struct PrimalDual {
  struct Edge {
    int to, rev;
    T cap, cost;
  };
  const int n;
  const T inf = numeric_limits<T>::max();
  VV<Edge> g;
  V<T> pot, dist;
  V<> pv, pe;
  PrimalDual(int n) : n(n), g(n), pot(n), dist(n), pv(n), pe(n) {}
  void add_edge(int from, int to, T cap, T cost) {
    assert(from != to);
    assert(cap >= 0);
    assert(cost >= 0);
    g[from].emplace_back(Edge{to, (int) g[to].size(), cap, cost});
    g[to].emplace_back(Edge{from, (int) g[from].size() - 1, 0, -cost});
  }
  void dijkstra(int s) {
    using P = pair<T, int>;
    priority_queue< P, V<P>, greater<P> > pque;
    fill(begin(dist), end(dist), inf);
    pque.emplace(dist[s] = 0, s);
    while (!pque.empty()) {
      T d; int v;
      tie(d, v) = pque.top(); pque.pop();
      if (d > dist[v]) continue;
      for (int i = 0; i < g[v].size(); ++i) {
        const Edge& e = g[v][i];
        if (e.cap <= 0 or dist[e.to] <= dist[v] + e.cost - (pot[e.to] - pot[v])) continue;
        pv[e.to] = v;
        pe[e.to] = i;
        pque.emplace(dist[e.to] = dist[v] + e.cost - (pot[e.to] - pot[v]), e.to);
      }
    }
  }
  T min_cost_flow(int s, int t, T f) {
    assert(s != t);
    assert(f >= 0);
    T res = 0;
    fill(begin(pot), end(pot), 0);
    while (f > 0) {
      dijkstra(s);
      if (dist[t] == inf) return -1;
      for (int v = 0; v < n; ++v) pot[v] += dist[v];
      T d = f;
      for (int v = t; v != s; v = pv[v]) {
        d = min(d, g[pv[v]][pe[v]].cap);
      }
      f -= d;
      res += d * pot[t];
      for (int v = t; v != s; v = pv[v]) {
        Edge& e = g[pv[v]][pe[v]];
        e.cap -= d;
        g[v][e.rev].cap += d;
      }
    }
    return res;
  }
};
template<class T> struct NegCost {
  const int n;
  V<T> b;
  PrimalDual<T> pd;
  T diff;
  NegCost(int n) : n(n), b(n), pd(n + 2), diff(0) {}
  void add_edge(int from, int to, T cap, T cost) {
    assert(cap >= 0);
    if (cost < 0) {
      b[from] -= cap, b[to] += cap;
      diff += cap * cost;
      pd.add_edge(to, from, cap, -cost);
    } else {
      pd.add_edge(from, to, cap, cost);
    }
  }
  T min_cost_flow(int s, int t, T f) {
    assert(f >= 0);
    b[s] += f, b[t] -= f;
    T F = 0, _F = 0;
    for (int v = 0; v < n; ++v) {
      if (b[v] > 0) {
        pd.add_edge(n, v, b[v], 0);
        F += b[v];
      }
      if (b[v] < 0) {
        pd.add_edge(v, n + 1, -b[v], 0);
        _F += b[v];
      }
    }
    assert(F + _F == 0);
    T res = pd.min_cost_flow(n, n + 1, F);
    return res != -1 ? res + diff : -1;
  }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m, f; cin >> n >> m >> f;
  NegCost<int> g(n);
  for (int i = 0; i < m; ++i) {
    int u, v, cap, cost; cin >> u >> v >> cap >> cost;
    g.add_edge(u, v, cap, cost);
  }
  cout << g.min_cost_flow(0, n - 1, f) << '\n';
}


Measured memory_bytes: 3252
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <numeric>
#include <complex>
#include <iomanip>

using namespace std;

#define bitcount(n) __builtin_popcount(n)

#define debug(n) cout << n << endl;

#define PREC(n) setprecision(n)
#define DOTPREC(n) fixed << setprecision(n)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define omajinai ios::sync_with_stdio(false); cin.tie(0)

template<typename T> bool chmax(T&a,T b) { if(a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T&a,T b) { if(a > b) {a = b; return true;} return false;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

const ll MOD = 1000000007;

int main(void)
{
    int N;
    cin >> N;

    vector<ll> A;

    int negative = 0;
    rep(i, N) {
        ll tmp;
        cin >> tmp;
        A.push_back(abs(tmp));

        negative += tmp < 0 ? 1 : 0;
    }


    ll sum = accumulate(all(A), (ll)0);
    ll min = *min_element(all(A));

    cout << (negative % 2 == 0 ? sum : sum - 2 * min) << endl;

    return 0;
}


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    ll x,y;
    cin >> x >> y;
    set<ll> st1,st2;
    st1.insert(1);
    st1.insert(3);
    st1.insert(5);
    st1.insert(7);
    st1.insert(8);
    st1.insert(10);
    st1.insert(12);
    st2.insert(4);
    st2.insert(6);
    st2.insert(9);
    st2.insert(11);
    if((st1.count(x)==1 && st1.count(y)==1) || (st2.count(x)==1 && st2.count(y)==1)){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;



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

	if (b-a < 2*k){
		for (int i = a; i <= b; i++){
			cout << i << endl;
		}
	}else{
		for (int i = a; i < a + k; i++){
			cout << i << endl;
		}
		for (int i = b-k+1; i <= b; i++){
			cout << i << endl;
		}
	}
	return  0;
}

Measured memory_bytes: 3548
#include <stdio.h>
#include <string>
#include <iostream>
#include <set>
#include <utility>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, ans = 0;
  scanf("%lld", &n);
  char s[n * 2 +10];
  scanf("%s", s);
  set< pair< pair<string, string>, ll> > se1, se2;
  set< pair< pair<string, string>, ll> >::iterator it2;
  for(i = 0; i < (1 << n); ++i) {
    string s1, s2;
    for(j = 0; j < n; ++j) {
      if(i >> j & 1) s1.push_back(s[j]);
      else s2.push_back(s[j]);
    }
    pair<string, string> p1 = make_pair(s1, s2);
    pair< pair<string, string>, ll> p2 = make_pair(p1, 0);
    it2 = se1.lower_bound(p2);
    if(it2 != se1.end() && (*(it2)).first.first == s1 && (*(it2)).first.second == s2) {
      ll tmp = (*(it2)).second;
      se1.erase(it2);
      p2.second = tmp + 1;
      se1.insert(p2);
    } else {
     p2.second = 1;
     se1.insert(p2);
    }
  }
  for(i = 0; i < (1 << n); ++i) {
    string s1, s2;
    for(j = 0; j < n; ++j) {
      if(i >> j & 1) s1.push_back(s[2 * n - 1 - j]);
      else s2.push_back(s[2 * n - 1 - j]);
    }
    pair<string, string> p1 = make_pair(s1, s2);
    pair< pair<string, string>, ll> p2 = make_pair(p1, 0);
    it2 = se2.lower_bound(p2);
    if(it2 != se2.end() && (*(it2)).first.first == s1 && (*(it2)).first.second == s2) {
      ll tmp = (*(it2)).second;
      se2.erase(it2);
      p2.second = tmp + 1;
      se2.insert(p2);
    } else {
     p2.second = 1;
     se2.insert(p2);
    }
  }
  //printf("%lld %lld\n", se1.size(), se2.size());
  set< pair< pair<string, string>, ll> >::iterator it;
  /*for(it = se1.begin(); it != se1.end(); ++it) {
    cout << (*it).first.first << " " << (*it).first.second << endl;
  }
  printf("\n");
  for(it = se2.begin(); it != se2.end(); ++it) {
    cout << (*it).first.first << " " << (*it).first.second << endl;
  }*/
  for(it = se1.begin(); it != se1.end(); ++it) {
    pair< pair<string, string>, ll> stmp = *it;
    stmp.second = 0;
    it2 = se2.lower_bound(stmp);
    if(it2 != se2.end() && (*(it2)).first.first == stmp.first.first && (*(it2)).first.second == stmp.first.second) ans += (*(it)).second * (*(it2)).second;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 91904
import java.math.BigDecimal;
import java.util.*;

public class Main {
    public static void main(String[] args){
        ABC160C();
    }
    private static void ABC160C() {
        // no comment, no error check
        final int INPUT_LINES_CNT = 2;
        final String DATA_SPLIT_SPACE = " ";

        ArrayList<String> inputLines = getStdInMultiLines(INPUT_LINES_CNT);

        if (inputLines.size() == 0) {
            System.out.println(0);
            return;
        }

        String outputStr = "0";
        try {
            List<String> inputLineList= 
            Arrays.asList((inputLines.get(0)).split(DATA_SPLIT_SPACE));

            int distance = Integer.valueOf(Arrays.asList((inputLines.get(0)).split(DATA_SPLIT_SPACE)).get(0));
            int houseNum = Integer.valueOf(Arrays.asList((inputLines.get(0)).split(DATA_SPLIT_SPACE)).get(1));
            List<String> individualDistance = Arrays.asList((inputLines.get(1)).split(DATA_SPLIT_SPACE));
            int min = Integer.valueOf(individualDistance.get(houseNum - 1)) - Integer.valueOf(individualDistance.get(0));

            for (int i = 1; i < houseNum; i++){
                int temp = 0;
                temp = Integer.valueOf(individualDistance.get(i - 1)) + distance - Integer.valueOf(individualDistance.get(i));
                min = temp < min ? temp : min;
                outputStr = String.valueOf(min); 
            }
        }
        catch (Exception ex) {
            outputStr = "0";
        }

        System.out.println(outputStr);
        return;
    }

    private static int getStdInNum() {
        String line1 = getStdInSingleLine();
        if (isNumber(line1)) {
            return Integer.parseInt(line1);
        }
        return 0;
    }

    private static ArrayList<String> getStdInMultiLines() {
        int cnt = 0; 
        int max = 0;

        Scanner cin = new Scanner(System.in);
        ArrayList<String> list = new ArrayList<String>();
        for (;cin.hasNext();) {
            list.add(cin.nextLine());
            if (cnt++ == 0) {
                max = Integer.parseInt((list.get(0)).split(" ")[0]);
            }
            else if (cnt == max + 1) {
                break;
            }
        }
        cin.close();
        return list;
    }
    private static ArrayList<String> getStdInMultiLines(int inputLinesCnt) {
        int cnt = 0; 

        Scanner cin = new Scanner(System.in);
        ArrayList<String> list = new ArrayList<String>();
        for (;cin.hasNext();) {
            list.add(cin.nextLine());
            if (++cnt == inputLinesCnt) {
                break;
            }
        }
        cin.close();
        return list;
    }

    private static String getStdInSingleLine() {
        Scanner cin = new Scanner(System.in);

        for (;cin.hasNext();) {
            cin.close();
            return cin.nextLine();
        }

        cin.close();
        return "";
    }

    private static boolean isNumber(String val) {
        try {
            Integer.parseInt(val);
            return true;
        }
        catch (NumberFormatException nfex) {
            return false;
        }
    }

}


Measured memory_bytes: 62804
import Control.Monad

getNumber :: String -> [Int]
getNumber xs = (read (fst h) :: Int) : case snd h of
                                         [] -> []
                                         (_:xs') -> getNumber xs'
  where h = break (== ' ') xs

getTaple :: String -> (Int,Int)
getTaple xs = (read $ fst h :: Int,(read.(\(_:xs) -> xs)) $ snd h)
  where h = break (== ' ') xs

replace :: [Int] -> (Int,Int) -> [Int]
replace xs (1,m) = m : (tail xs)
replace (x:xs) (n,m) = x : replace xs ((n - 1),m)

printTaples :: [Int] -> [(Int,Int)] -> IO ()
printTaples _ [] = return ()
printTaples xs (y:ys) = do
                      let p = sum $ replace xs y
                      putStrLn $ show p
                      printTaples xs ys

main :: IO ()
main = do
  num_ <- getLine
  nums <- fmap getNumber getLine :: IO [Int]
  drinks <- fmap read getLine :: IO Int
  numPares <- replicateM drinks $ do
                numP <- fmap getTaple getLine
                return numP
  printTaples nums numPares

Measured memory_bytes: 1020
'use strict'
function main(input) {
  input = input
    .trim()
    .split(/\s|\n/)
    .map(v => ~~v)
  const n = input.slice(0, 1)[0]
  const nums = input.slice(1)
  if (n === 1) {
    console.log('Yes')
    return
  }
  for (let i = 0; i < n - 1; i++) {
    const sub = nums[i + 1] - nums[i]
    if (sub >= 1) {
      nums[i + 1] -= 1
    } else if (sub === 0) {
      //
    } else {
      console.log('No')
      return
    }
  }
  console.log('Yes')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

double dp[3001][3001];

int main()
{

    int i,j,k,l,m,n;
    cin >> n ;

    double ar[n+10],res=0.0;

    for(i=1; i<=n; i++)
        cin >> ar[i];

    dp[1][1] = ar[1];
    dp[1][0] = 1.00-ar[1];

    for(i=2;i<=n;i++)dp[i][0] = dp[i-1][0] * (1.00-ar[i]);

    for(i=2; i<=n; i++)
    {
        for(j=1; j<=i; j++)
        {
                dp[i][j] = (dp[i-1][j]*(1.00-ar[i])) + (dp[i-1][j-1]*ar[i]);
        }
    }

    for(i=n/2+(n%2); i<=n; i++)
        res += dp[n][i];

    cout <<std ::  setprecision(12) << res << endl;

}


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

#define Omar45 ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define pb push_back
#define endl '\n'
#define mod 1000000007
const int inf=0x3f3f3f3f;
const int maxN=1000;

int main() {
	Omar45
    int H, W;  cin >> H >> W;
    char arr[H][W];
    int   dp[H][W]={};
    for (int i=0; i<H; i++)
        for (int j=0; j<W; j++) {
            cin >> arr[i][j];
            if (arr[i][j]=='#')  dp[i][j]=0;
        }
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            if (i==0 && j==0) {
                dp[i][j] = 1;
                continue;
            }
            if (arr[i][j] == '.') {
                if (i>0) dp[i][j] += dp[i-1][j];
                if (j>0) dp[i][j] += dp[i][j-1];
            }
            dp[i][j]%=mod;
        }
    }
    cout << dp[H-1][W-1];
}


Measured memory_bytes: 5120
#include<stdio.h>
int main()
{
    int i,j,a[15],t;
    for(i=0;i<10;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<10;i++)
    {
        for(j=0;j<9-i;j++)
        {
            if(a[j]>a[j+1])
            {
                t=a[j];
                a[j]=a[j+1];
                a[j+1]=t;
            }
        }
    }
    for(i=9;i>6;i--)
    {
        printf("%d\n",a[i]);
    }
    return 0;
}

Measured memory_bytes: 1808
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int i;
	char ans[3];
	char sn[3][3]; 
	for(i=0;i<3;i++)
	{
		cin >> sn[i];
		//ans[i]=sn[i][i];
	} 
	
	cout << sn[0][0] << sn[1][1] << sn[2][2] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    map<int, bool> mp[2]; mp[0][0] = true; mp[1][0] = true;
    while(1) {
        int n = mp[0].size();
        for(auto it=mp[0].begin(); it!=mp[0].end(); it++) {
            if(it->first+100*A > F) continue;
            mp[0][it->first+100*A] = true;
            if(it->first+100*B > F) continue;
            mp[0][it->first+100*B] = true;
        }
        if(n == mp[0].size()) break;
    }
    while(1) {
        int n = mp[1].size();
        for(auto it=mp[1].begin(); it!=mp[1].end(); it++) {
            if(it->first+C > 30*E) continue;
            mp[1][it->first+C] = true;
            if(it->first+D > 30*E) continue;
            mp[1][it->first+D] = true;
        }
        if(n == mp[1].size()) break;
    }
    double mol = 0.0;
    int x=0, y=0;
    for(auto w=mp[0].begin(); w!=mp[0].end(); w++) {
        for(auto s=mp[1].begin(); s!=mp[1].end(); s++) {
            int ww = w->first;
            int ss = s->first;
            if(ww*E/100.0 >= ss&& ww+ss <= F) {
                if(mol <= (100.0*ss)/(double)(ww+ss)) {
                    mol = (100.0*ss)/(double)(ww+ss);
                    x = ww+ss; y = ss;
                }
            }
        }
    }
    printf("%d %d\n", x, y);
}

Measured memory_bytes: 384
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    String s = sc.next();
    String ss = s;
    ss=ss.substring(a,a+1);
    if(ss.equals("-")){
      s = s.replace("-","");
      int slen = s.length();
      if(slen == a + b){
          System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 22996
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int x=sc.nextInt();
    int t=sc.nextInt();
    if (x-t<0) {
      System.out.println(0);
    }else{
      System.out.println(x-t);
    }
  }
}


Measured memory_bytes: 21716
/*
 * main.c
 *
 *  Created on: 2019/06/09
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int P = 0, Q = 0, R = 0;
	int ans = 0;
	scanf("%d %d %d", &P, &Q, &R);

	if(P > Q) {
		if(P > R) {
			ans = Q + R;
		} else {
			ans = Q + P;
		}
	} else {
		// P < Q
		if(Q > R) {
			ans = P + R;
		} else {
			ans = P + Q;
		}
	}
	printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
n = int(input())
t = [list(map(int, input().split())) for _ in range(n)]
d = 0
for i in range(n - 1):
    for j in range(i, n):
        d += (((t[i][0] - t[j][0]) ** 2 + (t[i][1] - t[j][1]) ** 2)
              ** 0.5)

print(d*2/n)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll K;
    cin >> K;
    vl A(K);
    rep(i, K) cin >> A[i];
    reverse(all(A));

    ll m = 2, M = 2;
    rep(i,K){
        m = (m + A[i] - 1) / A[i] * A[i];
        if(m>M){
            cout << -1 << endl;
            return 0;
        }
        M = M / A[i] * A[i] + A[i] - 1;
    }

    cout << m << " " << M << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

int main(void){
   int N,M;
   cin>>N>>M;
   vector<vector<int>> graph(N);
   vector<int> A(M),B(M);
   for(int i=0;i<M;i++){
      cin>>A[i]>>B[i];
      A[i]--;
      B[i]--;
   }
   for(int i=0;i<M;i++){
      graph[A[i]].push_back(B[i]);
      graph[B[i]].push_back(A[i]);
   }
   vector<int> ans(N,-1);
   vector<int> dist(N,-1);
   queue<int> que;
   dist[0]=0;
   ans[0]=0;
   que.push(0);
   while(!que.empty()){
      int v=que.front();
      que.pop();
      for(int nv:graph[v]){
         if(dist[nv]!=-1) continue;
         dist[nv]=dist[v]+1;
         ans[nv]=v;
         que.push(nv);
      }
   }
   for(int i=0;i<N;i++){
      if(dist[i]==-1){
         cout<<"No"<<endl;
         return 0;
      }
   }
   cout<<"Yes"<<endl;
   for(int i=1;i<N;i++){
      cout<<ans[i]+1<<endl;
   } 
   return 0;
}

Measured memory_bytes: 12324