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

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	int N;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int H,W;
		H = nextInt();
		W = nextInt();
		N = nextInt();

		int sum = 0;
		int res = 0;
		for(int i=Math.max(H,W);sum<N;sum+=i,res++) {
		}
		out.println(res);
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}

	long lcm(long m, long n) {
	        return m * n / gcd(m, n);
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
int main()
{
    int a,b,n,count=0;
    scanf("%d%d",&a,&b);
    if(b<2)
       printf("%d",count);
    else
    {
    n=a;
    while(n<b)
    {
        n+=a-1;
        count++;
    }
    printf("%d",++count);
    }

}

Measured memory_bytes: 128
// Date: 2020-02-26

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

LL ans[N], fac[20];
int sz;

int get(LL x) {
    int ans = 0;
    while(x) ans += x % 10, x /= 10;
    return ans;
}

void init() {
    fac[0] = 1;
    rep(i, 1, 15) fac[i] = fac[i-1] * 10;
    ans[++sz] = fac[15]-1;
    while(1) {
        LL tp = ans[sz];
        LL mx = 0;
        rep(i, 0, 15) rep(j, 1, 9) {
            if(tp > fac[i] * j) {
                LL tp2 = tp - fac[i] * j;
                if(tp2 * get(tp) <= tp * get(tp2)) {
                    mx = max(mx, tp2);
                }
            }
        }
        if(mx == 0) break;
        ans[++sz] = mx;
    }
}

int main() {
    init();
    int k; scanf("%d", &k);
    while(k--) printf("%lld\n", ans[sz--]);

    return 0;
}

Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define pf push_front
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main(){
  string s;
  cin>>s;
  s.erase(s.size()-1);
  int ans=0;
  for(;;){
    int mid=s.size()/2;
    rep(i,mid){
      if(s[i]!=s[mid+i]){
        s.erase(s.size()-1);
        ans++;
        break;
      }
      if(i==mid-1){
        cout<<s.size()-1<<endl;
        goto at;
      }
    }
  }
 at: ;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PI acos(-1.0)
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

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

  int ans = 100000;

  rep(i,s.size() - t.size()+1){
    int dif = 0;
    rep(j,t.size()){
      if(s[i+j] != t[j]){
        dif++;
      }
    }
    chmin(ans, dif);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
string a;
bool flag=false;
int main()
{
	cin>>a;
	for(int i=0; i<a.size(); i++)
	{
		if(a[i]=='C')
			flag=true;  
		if(a[i]=='F' && flag)  
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;  
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;

int main () {
    int a, b, c, z;
    cin >> a >> b >> c;
    z = a + b + c;
    if (z >= 22) cout << "bust" << endl;
    else if (z <= 21) cout << "win" << endl;
    return 0;
}

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

int main(){
    int N, K;
    vector<int> D(10,0);
    cin >> N >> K;
    int d;
    for(int i=0; i<K; i++){
        cin >> d;
        D[d] = 1;
    }
    for(int i=N; i<100000; i++){
        bool flag = true;
        int tmp = i;
        while(tmp!=0){
            if(D[tmp%10] == 1){
                flag = false;
                break;
            }
            tmp /= 10;
        }
    
        if(flag){
            cout << i << endl;
            break;
        }
    }
    return 0;
}

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

int main()
{
    long long a,b,c;
    cin>>a>>b>>c;
    int cnt=0;
    if(a==b&&b==c&&a%2==0){cout<<"-1"<<endl;return 0;}
    while(!(a%2||b%2||c%2))
    {
        long long t1= a/2 + b/2;
        long long t2= b/2+ c/2;
        long long t3 = a/2 + c/2;
        a= t2; b= t3; c= t1;
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    int cnt1 = 0;
    int cnt2 = 0;
    int cnt4 = 0;
    for(int i=0; i<N; ++i) {
        int a;
        cin >> a;
        if(a % 4 == 0) ++cnt4;
        else if(a % 2 == 0) ++cnt2;
        else ++cnt1;
    }

    if(cnt2 == 0) {
        if(cnt1 <= cnt4 + 1) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else {
        if(cnt1 <= cnt4) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC137C
{
    class Program
    {
        static void Main(string[] args)
        {
            long ans = 0;
            var n = int.Parse(Console.ReadLine());
            var stringList = new List<string>();
            for(int i = 0; i < n; i++)
            {
                stringList.Add(Console.ReadLine());
            }

            var memo = new Dictionary<string, long>();
            for(int i = 0; i < stringList.Count; i++)
            {
                var s = string.Join("", stringList[i].OrderBy(c => c));
                if(memo.ContainsKey(s))
                {
                    memo[s] += 1;
                    ans += memo[s];
                }
                else
                {
                    memo[s] = 0;
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 34212
def f():
    return int(raw_input())
def f2():
    return map(int, raw_input().split())

def merge(left, mid, right):
    L = S[left:mid]
    R = S[mid:right]
    lp, rp, xp = 0, 0, 0
    a, b = L[0], R[0]
    c = right - left
    x = [0] * c
    flg = True

    def f(A,xp):
        for e in A:
            x[xp] = e
            xp += 1
        return False
    
    while flg:
        while flg and a <= b:
            x[xp] = a
            lp += 1
            xp += 1
            try:
                a = L[lp]
            except:
                flg = f(R[rp:], xp)
        while flg and a >= b:
            x[xp] = b
            rp += 1
            xp += 1
            try:
                b = R[rp]
            except:
                flg = f(L[lp:],xp)
    S[left:right] = x
    return c

def mergesort(left, right):
    c = 0
    if left + 1 < right:
        mid = (left + right)/2
        c += mergesort(left, mid)
        c += mergesort(mid, right)
        c += merge(left, mid, right)
    return c

global S
n = f()
S = f2()

c = mergesort(0, n)
print " ".join(map(str,S))
print c

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

#define ll long long
#define pii pair<int, int>
#define pll pair<long, long>
#define pdd pair<double, double>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define umap unordered_map
#define uset unordered_set

using namespace std;

vector<bool> prime;

ll modex(ll x,ll n)
{
	if(!n) return 1;
    if(n&1) return (x*modex((x*x)%mod,(n-1)/2))%mod;
    else return modex((x*x)%mod,n/2);
}
ll modinv(ll n) 
{ 
	return modex(n,mod-2); 
}
void sieve(ll n) {
	prime.resize(n+1, true);
	for(ll p=2;p<=n;p++) {
		if(prime[p]) {
			for(int i=p;i*i<=n;i+=p) prime[i] = false;
		}
	}
}

void solve() {
	// type code here
	double n; cin>>n;
	double m = ceil(n*100.0/108.0);
	// cout << m << " " << m*1.08;
	if(floor(m*1.08) == n)
		cout << floor(m) << endl;
	else
		cout << ":(" <<endl;
}

int main(void) {
	fastio;
	solve();
	// int t; cin>>t;
	// while(t--)
	// 	solve();
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		String b = sc.next();
		if (b.equals("A")) {
			System.out.println("T");
		} else if (b.equals("C")) {
			System.out.println("G");
		} else if (b.equals("G")) {
			System.out.println("C");
		} else {
			System.out.println("A");
		}

	}

}

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

int main(){
    ll X,Y; cin >> X >> Y;
    ll cnt=0;
    while(X<=Y){
        X*=2;
        cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC049_C
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            Console.WriteLine(CheckEnd(s) ? "YES" : "NO");
        }

        readonly static string[] strs = new string[4] { "dream", "dreamer", "erase", "eraser" };

        static int[] _stringCheckPtr = new int[strs.Length];
        static int _wrongCount = 0;

        static void Init()
        {
            for (int i = 0; i < strs.Length; ++i)
            {
                _stringCheckPtr[i] = strs[i].Length - 1;
            }
            _wrongCount = 0;
        }

        static bool CheckEnd(string str)
        {
            bool[] flags = new bool[4];

            Init();

            bool flag = false;

            int j = str.Length - 1;
            for (; j >= 0; --j)
            {
                for (int i = 0; i < strs.Length; ++i)
                {
                    if (_stringCheckPtr[i] == -1) { continue; }
                    if (strs[i][_stringCheckPtr[i]] == str[j])
                    {
                        if (_stringCheckPtr[i] == 0)
                        {
                            if (j == 0)
                            {
                                flag = true;
                                break;
                            }

                            Init();
                            break;
                        }
                        else
                        {
                            --_stringCheckPtr[i];
                        }
                    }
                    else
                    {
                        _stringCheckPtr[i] = -1;
                        ++_wrongCount;
                        if (_wrongCount == strs.Length) { break; }
                    }

                }
            }

            return flag;
        }
    }

    public static class Extensions
    {
        public static string Reverse(this string str)
        {
            char[] arr = str.ToCharArray();

            arr.Reverse();

            return new string(arr);
        }
    }
}


Measured memory_bytes: 13140
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int MOD = 1000000007;
        
        
        if ((x + y) % 3 != 0) { 
            System.out.println(0);
            return;
        }
        
        int tmp = 0;
        if (x < y) {
            tmp = x;
            x = y;
            y = tmp;
        }
        
        if (y * 2 < x) {
            System.out.println(0);
            return;
        }
        
        int xstart = (x + y) / 3 * 2;
        int ystart = (x + y) / 3;
        
        int n = xstart - x;
        
        int ans1 = xstart / 2;
        int ans2 = n;
        
        
        System.out.println(nCkMOD(ans1, ans2, MOD));
    }
    
    public static long nCkMOD(long n, long k, long mod) {
        if (k > n - k) return nCkMOD(n, n - k, mod);
        
        long res = 1;
        for (int i = 0; i < k; i++) {
            res = (res * (n - i)) % mod;
        }
        for (int i = 1; i <= k; i++) {
            res = (res * inverse(i, mod)) % mod;
        }
            
        return res % mod;
    }
 
    private static long inverse(long a, long mod) {
        return modpow(a, mod - 2, mod);
    }
 
    private static long modpow(long a, long n, long mod) {
        long res = 1;
        
        while (n > 0) {
            if (n % 2 == 1) res = (res * a) % mod;
            a = (a * a) % mod;
            n >>= 1;
        }
        
        return res % mod;
    }
}

Measured memory_bytes: 23124
#include <stdio.h>

int main(void) {
  long long n, sum = 0, i;

  scanf("%lld", &n);

  for (i = 1; i <= 1000000000; i *= 10) {
    sum += (n / i) % 10;
  }

  if (n % sum == 0) {
    printf("Yes\n");
  }else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }
        static List<long>[] graph;
        static long ans;
        static bool[] used;
        static void Solve()
        {
            (long N, long M) = Slice2<long>();
            graph = Enumerable.Repeat(0, (int)N).Select(_ => new List<long>()).ToArray();
            for(var i=0;i<M;++i)
            {
                (long a, long b) = Slice2<long>();
                --a;--b;
                graph[a].Add(b);
                graph[b].Add(a);
            }
            ans = 0;
            used = new bool[N];
            DFS(0, -1);
            WriteLine(ans);
        }
        static void DFS(long root, long parent)
        {
            used[root] = true;
            foreach (var g in graph[root])
            {
                if (g == parent) continue;
                if (used[g]) continue;
                DFS(g, root);
            }
            if (used.All(u => u))
                ++ans;
            used[root] = false;
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28492
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

#define N_MAX 100000

void solv()
{
	int N; scanf("%d", &N);
	int d[N_MAX];
	for (int i = 0; i < N; i++){
		scanf("%d", d + i);
	}



	sort(d, d + N);


	printf("%d", d[N / 2] - d[N / 2 - 1]);
	
	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 512
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

N, M = list(map(int, sys.stdin.readline().split()))
ABC = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]

D = np.full((N, N), IINF)
for a, b, c in ABC:
    D[a - 1][b - 1] = c
    D[b - 1][a - 1] = c

# warshall floyd
for via in range(N):
    D = np.minimum(D, sum(np.meshgrid(D[via], D[via], sparse=True)))

ans = 0
for a, b, c in ABC:
    if D[a - 1][b - 1] < c:
        ans += 1
print(ans)


Measured memory_bytes: 12748
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    a = II()
    b = II()
    if a > b: print('GREATER')
    elif a < b: print('LESS')
    else: print('EQUAL')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
using P=pair<int,int>;
int main(){
  int n; cin>>n;
  vector<P> c(n),tr(n);
  vector<vector<int>> tree(n);
  for(int i=0;i<n;i++){
    c[i]=P(0,i);
  }
  for(int i=0;i<n-1;i++){
    int a,b; cin>>a>>b;
    a--; b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
    tr[i]=P(a,b);
    c[a].first++; c[b].first++;
  }
  sort(c.rbegin(),c.rend());
  vector<int> weight(n),m(n);
  for(int i=0;i<n;i++){
    cin>>m[i];
  }sort(m.rbegin(),m.rend());
  queue<int> que;
  que.push(c[0].second);
  vector<bool> vis(n,false);
  int j=1; weight[c[0].second]=m[0];
  while(!que.empty()){
    int z=que.front(); que.pop();
    vis[z]=true;
    for(int i=0;i<tree[z].size();i++){
      if(vis[tree[z][i]]) continue;
      que.push(tree[z][i]);
      vis[tree[z][i]]=true;
      weight[tree[z][i]]=m[j];
      j++;
    }
  }
  long long sum=0;
  for(int i=0;i<n-1;i++){
    int x=tr[i].first,y=tr[i].second;
    sum+=min(weight[x],weight[y]);
  }cout<<sum<<endl;
  for(int i=0;i<n-1;i++){
    cout<<weight[i]<<' ';
  }cout<<weight[n-1]<<endl;
}

Measured memory_bytes: 1152
// Copyright lzt
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
#include<ctime>
using namespace std;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef std::pair<long long, long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i, j, k)  for (register int i = (int)(j); i <= (int)(k); i++)
#define rrep(i, j, k) for (register int i = (int)(j); i >= (int)(k); i--)
#define Debug(...) fprintf(stderr, __VA_ARGS__)

inline ll read() {
  ll x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}

const int mod = 1e9 + 7;
const int maxn = 1010;
int n, m;
char c[maxn][maxn];
int f[maxn][maxn];

void work() {
  n = read(), m = read();
  f[0][1] = 1;
  rep(i, 1, n) rep(j, 1, m) {
    c[i][j] = getchar();
    while (c[i][j] != '.' && c[i][j] != '#') c[i][j] = getchar();
    if (c[i][j] == '.') f[i][j] = (f[i - 1][j] + f[i][j - 1]) % mod;
  }
  cout<<f[n][m]<<endl;
}

int main() {
  #ifdef LZT
    freopen("in", "r", stdin);
  #endif

  work();

  #ifdef LZT
    Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
  #endif
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#include <ext/rope>
using namespace std;
using namespace __gnu_cxx;

using ci = const int;
using ld = long double;
using llint = long long;
using ullint = unsigned long long;
using pii = pair <int,int>;
using pcc = pair <char,char>;
using pll = pair <llint,llint>;
using pss = pair <string,string>;
using vi = vector <int>;
using vb = vector <bool>;
using vll = vector <llint>;
using vii = vi::iterator;

#define INF (1<<30)
#define MOD 1000000007
#define mt make_tuple
#define all(c) c.begin(), c.end()
#define ms(name,val) memset(name, val, sizeof name)
#define np nullptr
// inline functions



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

    int n;
    cin >> n;
    map <string,vector <pii>> M; // (city, score,index)

    for (int t1 = 1; t1 <= n; ++t1)
    {
        int x;
        string s;
        cin >> s >> x;
        M[s].push_back({x, t1});
    }

    for (auto it: M)
    {
        sort(all(it.second));
        reverse(all(it.second));

        for (auto jt: it.second)
            cout << jt.second << '\n';
    }







































    return 0;
}

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



int solve()
{
    int a,b;
    cin>>a>>b;
    long int ans=b;
    
    for(int i=1;i<a;i++) 
    ans*=b-1;
	cout<<ans;

}
    
int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int risi(int a){
	if(a==0){
		return 100000;
	}else{
		double b=(double)risi(a-1)*1.05;
		if(((int)b%1000)!=0){
			b-=(int)b%1000;
			b+=1000;
		}
		return (int)b;
	}
}

int main(){
	int a;
	scanf("%d",&a);
	printf("%d\n",risi(a));
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for( int i = a; i < b ; i++ ) 
#define af(i,a,b) for( int i = a; i >= b ; i--)
#define rep(i,a,b,k) for(int i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( int i = a; i >= b ; i-= k)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)

typedef long double ld;
typedef long long int ll;
typedef vector<int> vi ;
typedef pair<int,int> ii ;
typedef vector<ii> vii ;

const int MAX= 1001;
int ha[100010][3];
int dp[100010][3];
int main(){
	fastio;	
	int n,ans=0;
	cin>>n;
	f(i,0,n)
		f(j,0,3) cin>>ha[i][j];
	f(i,0,3) dp[0][i]=ha[0][i];
	f(i,1,n)
		f(j,0,3) dp[i][j]=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+ha[i][j];
	f(i,0,3) ans=max(ans,dp[n-1][i]);
	cout<<ans;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll MOD = 1e9+7;
const static ll INF = 1e14;


vector<vector<ll>> mul(vector<vector<ll>> &a, vector<vector<ll>> &b) {
    ll N = a.size();
    vector<vector<ll>> res(N, vector<long long>(N, 0));
    for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++)
            for(int k = 0; k < N; k++)
                (res[i][j] += a[i][k] * b[k][j]) %= MOD;
    return res;
}

vector<vector<ll>> matpow(vector<vector<ll>> m, ll k) {
    ll N = m.size();
    vector<vector<ll>> res(N, vector<ll>(N, 0));
    for(int i = 0; i < N; i++)
        res[i][i] = 1; // 単位行列にする

    while(k > 0) {
        if(k & 1) res = mul(res, m);
        m = mul(m, m);
        k >>= 1;
    }
    return res;
}

int main() {
    ll N, K; cin >> N >> K;
    vector<vector<ll>> A(N, vector<ll>(N));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++) cin >> A[i][j];
    }
    vector<vector<ll>> M = matpow(A, K);

    ll ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++) { ans += M[i][j]%MOD; ans %= MOD;}
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class FXorShift {

    // return A[i]: The length of the longest substring starting from S[i]
    // which is also a prefix of S. Obviously, A[0] = S.size();
    void Zalgorithm(vector<int>& A, vector<int>& S) {
      A[0] = S.size();
      int i = 1, j = 0;
      while (i < S.size()) {
        while (i+j < S.size() && S[j] == S[i+j]) ++j;
        A[i] = j;
        if (j == 0) { ++i; continue;}
        int k = 1;
        while (i+k < S.size() && k+A[k] < j) A[i+k] = A[k], ++k;
        i += k; j -= k;
      }
    }

public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<int> a(n);
      vector<int> b(n);
      rep(i, n) {
        cin >> a[i];
      }
      rep(i, n) {
        cin >> b[i];
      }
      vector<int> c(n), d(n);
      rep(i, n-1) {
        c[i] = a[i] ^ a[i+1];
        d[i] = b[i] ^ b[i+1];
      }
      c[n-1] = a[0] ^ a[n-1];
      d[n-1] = b[0] ^ b[n-1];

      vector<int> e(3*n);
      rep(i, n) {
        e[i] = c[i];
        e[n+i] = d[i];
        e[2*n+i] = d[i];
      }

      vector<int> f(3*n);
      Zalgorithm(f, e);

      vector<P> ans;

      rep(i, n) {
        if (f[n+i] >= n) {
          int x = a[0] ^ b[i];
          ans.emplace_back((n-i)%n, x);
        }
      }

      sort(all(ans));

      for(auto e : ans) {
        cout << e.first << ' ' << e.second << '\n';
      }
    }
};

signed main() {
  FXorShift solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 14572
import java.util.*;

public class Main{
	public static final int[] dx = {1, 0, -1,  0};
	public static final int[] dy = {0, 1,  0, -1};

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Deque<Integer[]> deque = new ArrayDeque<Integer[]>();
		Deque<Integer[]> wall_data = new ArrayDeque<Integer[]>();
		Integer[] wall = new Integer[18];
		int w, h;
		int reach_x = 0, reach_y = 0, min = 0;

		while(true){
			deque.clear();
			wall_data.clear();
			w = sc.nextInt();
			h = sc.nextInt();
			if(w+h==0) break;

			int[][] field = new int[h+2][w+2];
			for(int i=1; i<h+1; i++){
				for(int j=1; j<w+1; j++){
					field[i][j] = sc.nextInt();
					if(field[i][j]==2){
						Integer[] p = {j, i, 0};
						deque.addLast(p);
						field[i][j] = 0;
						reach_x = j;
						reach_y = i;
					}
				}
			}
			wall_data.addLast(wall);

			while(!deque.isEmpty()){
				Integer[] ball = deque.pollFirst();
				Integer[] punished_wall = wall_data.pollFirst();

				for(int i=0; i<ball[2]; i++){
					field[punished_wall[i*2+1]][punished_wall[i*2]] = 0;
				}

				for(int i=0; i<4; i++){
					int x = ball[0];
					int y = ball[1];
					int count = ball[2];

					if(field[y+dy[i]][x+dx[i]]!=1){
						while(x>0&&x<w+1&&y>0&&y<h+1&&field[y+dy[i]][x+dx[i]]==0){
							y += dy[i];
							x += dx[i];
						}
						reach_x = x;
						reach_y = y;
						if(x!=0&&x!=w+1&&y!=0&&y!=h+1){
							if(field[y+dy[i]][x+dx[i]]==3){
								reach_x = x + dx[i];
								reach_y = y + dy[i];
								break;
							}
							if(count<9){
								Integer[] new_punished_wall = Arrays.copyOf(punished_wall, punished_wall.length);
								new_punished_wall[count*2] = x+dx[i];
								new_punished_wall[count*2+1] = y+dy[i];
								count++;
								Integer[] q = {x, y, count};
								deque.addLast(q);
								wall_data.addLast(new_punished_wall);
							}
						}
					}
				}
				for(int i=0; i<ball[2]; i++){
					field[punished_wall[i*2+1]][punished_wall[i*2]] = 1;
				}
				min = ball[2] + 1;
				if(field[reach_y][reach_x]==3) break;
			}
			if(field[reach_y][reach_x]==3){
				System.out.println(min);
			}else{
				System.out.println("-1");
			}
		}
	}
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N; cin >> N;
  // ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  vector<ll> a(N); rep(i, N) cin >> a[i];
  
  ll ans = 0;
  rep(i, N) {
    for(ll j = i + 1; j < N; j++) {
      ans += a[i] * a[j];
    }
  }

  cout << ans << endl;
 }


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<vector<int>> q(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> q.at(i).at(j);
    }
  }
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  for(int i = 0; i < 3; i++) {
    for(int j = 0; j < 3; j++) {
      for(int o = 0; o < N; o++) {
        if(q.at(i).at(j) == vec.at(o)) {
          q.at(i).at(j) = 0;
        }
      }
    }
  }
  int y = 1;
  if(q.at(0).at(0) == 0 && q.at(0).at(1) == 0) {
    if(q.at(0).at(2) == 0) {
      y = 0;
    }
  }
  if(q.at(1).at(0) == 0 && q.at(1).at(1) == 0) {
    if(q.at(1).at(2) == 0) {
      y = 0;
    }
  }
  if(q.at(2).at(0) == 0 && q.at(2).at(1) == 0) {
    if(q.at(2).at(2) == 0) {
      y = 0;
    }
  }
  if(q.at(0).at(0) == 0 && q.at(1).at(0) == 0) {
    if(q.at(2).at(0) == 0) {
      y = 0;
    }
  }
  if(q.at(0).at(1) == 0 && q.at(1).at(1) == 0) {
    if(q.at(2).at(1) == 0) {
      y = 0;
    }
  }
  if(q.at(0).at(2) == 0 && q.at(1).at(2) == 0) {
    if(q.at(2).at(2) == 0) {
      y = 0;
    }
  }
  if(q.at(0).at(0) == 0 && q.at(1).at(1) == 0) {
    if(q.at(2).at(2) == 0) {
      y = 0;
    }
  }
  if(q.at(2).at(0) == 0 && q.at(1).at(1) == 0) {
    if(q.at(0).at(2) == 0) {
      y = 0;
    }
  }
  if(y == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int x, n;
	cin >> x >> n;
	vector<int> p(n);
	rep (i, n) cin >> p[i];
	if (n == 0) {
	  cout << x << endl;
	  return 0;
	}
	int diff = Inf, res;
	rep (i, 102) {
	  bool exist = false;
	  rep (j, n) if (i == p[j]) exist = true;
	  if (exist) continue;
	  if (diff > abs(i - x)) {
		diff = abs(i - x);
		res = i;
	  }
	}
	cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 3640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	in := IOInitialize()
	n := Int(in)
	var a [2][]int
	a[0] = IntArray(in, n)
	a[1] = IntArray(in, n)

	max := -9999
	for i := range a[0] {
		tmp := 0
		index := 0
		for jj := range a[0] {
			tmp += a[index][jj]
			if i == jj {
				index = 1
				tmp += a[index][jj]
			}
		}
		if max < tmp {
			max = tmp
		}
	}

	fmt.Println(max)
}

//////////
//
//

func IOInitialize() *bufio.Scanner {
	t := bufio.NewScanner(os.Stdin)
	t.Split(bufio.ScanWords)
	return t
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("\t\tThere is a FALSE not to want.")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("\t\tError:Failed to convert text to int,")
	}
	return value
}

func IntArray(s *bufio.Scanner, size int) []int {
	deepArray := make([]int, size)
	for i := range deepArray {
		deepArray[i] = Int(s)
	}
	return deepArray
}

func GraphSetByEdge(s *bufio.Scanner, v int) [][]int {
	g := make([][]int, v)
	for i := range g {
		g[i] = make([]int, 0)
	}
	for xxNonUsedInLoopI := 0; xxNonUsedInLoopI < v-1; xxNonUsedInLoopI++ {
		a, b := Int(s)-1, Int(s)-1
		g[a] = append(g[a], b)
		g[b] = append(g[b], a)
	}

	return g
}


Measured memory_bytes: 640
q = int(input())

p = [True] * 100010
s = [0] * 100010
p[0] = False
p[1] = False
i = 2
while i <= 100005:
    if p[i]:
        j = i * 2
        while j <= 100005:
            p[j] = False
            j += i
    i += 1


for i in range(100005):
    if i & 1 and p[i] and p[(i + 1) // 2]:
        s[i] += 1
for i in range(100005):
    s[i + 1] += s[i]

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


Measured memory_bytes: 12584
#include<cstdio>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
#define INF (1LL << 60)
pair<int, int> points[1000000] ;

long long int dist(int a, int b){
  long long int x = points[a].first - points[b].first;
  long long int y = points[a].second - points[b].second;
  return x * x + y * y;
}

long long int sq(int x){
  return x * x;
}

void sort_in_y(int l, int mid, int r){
  pair<int, int> tmp[r - l];
  int lps = l, rps = mid, ps = 0;
  while(lps < mid || rps < r){
    if(lps == mid || rps != r && points[lps].second > points[rps].second)
      tmp[ps++] = points[rps++];
    else
      tmp[ps++] = points[lps++];
  }
  for(int i = l;i < r;i++){
    points[i] = tmp[i - l];
  }
}

long long int solve(int l, int r){
  if(r - l <= 1)return INF;
  int mid = (l + r) / 2;
  int center = points[mid].first;
  long long int limit = min(solve(l, mid), solve(mid, r));
  sort_in_y(l, mid, r);
  vector<int> areas;
  for(int i = l;i < r;i++){
    if(sq(points[i].first - center) >= limit)continue;
    for(int j = areas.size() - 1;j >= 0;j--){
      if(sq(points[areas[j]].second - points[i].second) >= limit)break;
      limit = min(limit, dist(i, areas[j]));
    }
    areas.push_back(i);
  }
  return limit;
}

int main(){
  int n;
  scanf("%d", &n);
  for(int i = 0;i < n;i++){
    scanf("%d%d", &points[i].first, &points[i].second);
  }
  sort(points, points + n);
  printf("%lld\n", solve(0, n));
  return 0;
}

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

template <class Abel> struct BIT {
    const Abel UNITY_SUM = 0;                       // to be set
    vector<Abel> dat;
    
    /* [1, n] */
    BIT(int n) : dat(n + 1, UNITY_SUM) { }
    void init(int n) { dat.assign(n + 1, UNITY_SUM); }
    
    /* a is 1-indexed */
    inline void add(int a, Abel x) {
        for (int i = a; i < (int)dat.size(); i += i & -i)
            dat[i] = dat[i] + x;
    }
    
    /* [1, a], a is 1-indexed */
    inline Abel sum(int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i)
            res = res + dat[i];
        return res;
    }
    
    /* [a, b), a and b are 1-indexed */
    inline Abel sum(int a, int b) {
        return sum(b - 1) - sum(a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat.size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	int cnt[30]={};
	for (int i = 0; i < s.size(); ++i)
	{
		++cnt[s[i]-'a'];
	}
	int f=1;
	char c;
	for (int i = 0; i < 30; ++i)
	{
		if (cnt[i]%2==1)
		{
			--f;
			c='a'+i;
		}
		if (f<0)
		{
			cout<<"-1\n";
			return 0;
		}
	}
	string l,r;
	int memo[30]={};
	for (int i = 0; i < s.size(); ++i)
	{
		if (memo[s[i]-'a']<cnt[s[i]-'a']/2)
		{
			l.push_back(s[i]);
			r.push_back(s[i]);
			++memo[s[i]-'a'];
		}
	}
	reverse(r.begin(), r.end());
	if (f==0)
	{
		l.push_back(c);
	}
	l+=r;
    queue<long long> sidx[30];
    for (long long i = 0; i < s.size(); ++i)
    {
    	sidx[s[i]-'a'].push(i+1);
    }
   	long long idx[s.size()];
    for (long long i = 0; i < s.size(); ++i)
    {
    	idx[i]=sidx[l[i]-'a'].front();
    	sidx[l[i]-'a'].pop();
    }
    BIT<long long> bit(s.size());
    long long ans=0LL;
    for (int i = 0; i < s.size(); ++i)
    {
    	ans+=i-bit.sum(idx[i]);
    	bit.add(idx[i],1LL);
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5576
#include<cstring>
#include<cstdio>
#include<cstdlib>

int top, S[1000];

void push(int x){
	S[++top]=x;
}

int pop(){
	top--;
	return S[top+1];
	}
	
int main(){
	int a, b;
	top = 0;
	char s[100];
	while(scanf("%s",s) != EOF){
		if(s[0] == '+'){
			a = pop();
			b = pop();
			push(a+b);
		}else if(s[0] == '-'){
			b = pop();
			a = pop();
			push(a-b);
		}else if(s[0] == '*'){
			b = pop();
			a = pop();
			push(a*b);
		}else{
			push(atoi(s));
		}
	}
	printf("%d\n",pop());
	return 0;
}

Measured memory_bytes: 984
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef		vector<ll>      vll;
#define		pb              push_back
#define         O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		PB              pop_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)



int main()
{
    ll x,y;
    cin>>x>>y;
    
    if(x*500<y)
        cout<<"No"<<nn;
    else cout<<"Yes"<<nn;






    return 0;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	x := make([]float64, n)
	y := make([]float64, n)
	for i:=0;i<len(x); i++{
		fmt.Scan(&x[i], &y[i])
	}

	sum := 0.0
	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			dx := x[i] - x[j]
			dy := y[i] - y[j]
			sum += math.Sqrt(dx*dx + dy*dy)
		}
	}
	fmt.Println(sum / float64(n) * 2.0)
}

Measured memory_bytes: 1844
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int arr[n];
	int dp[n];
	for(int i=0; i<n; i++) cin >> arr[i];
	dp[0] = 0;
	dp[1] = abs(arr[1]-arr[0]);
	for(int i=2; i<n; i++){
		dp[i] = min(dp[i-1] + abs(arr[i]-arr[i-1]),dp[i-2] + abs(arr[i]-arr[i-2]));
	}
	cout << dp[n-1];
	return 0;
}

Measured memory_bytes: 4392
MOD=10**9+7
class Fp(int):
    def __new__(self,x=0):return super().__new__(self,x%MOD)
    def inv(self):return self.__class__(super().__pow__(MOD-2,MOD))
    def __add__(self,value):return self.__class__(super().__add__(value))
    def __sub__(self,value):return self.__class__(super().__sub__(value))
    def __mul__(self,value):return self.__class__(super().__mul__(value))
    def __floordiv__(self,value):return self.__class__(self*self.__class__(value).inv())
    def __pow__(self,value):return self.__class__(super().__pow__(value%(MOD-1), MOD))
    __radd__=__add__
    __rmul__=__mul__
    def __rsub__(self,value):return self.__class__(-super().__sub__(value))
    def __rfloordiv__(self,value):return self.__class__(self.inv()*value)
    def __iadd__(self,value):self=self+value;return self
    def __isub__(self,value):self=self-value;return self
    def __imul__(self,value):self=self*value;return self
    def __ifloordiv__(self,value):self=self //value;return self
    def __ipow__(self,value):self=self**value;return self
    def __neg__(self):return self.__class__(super().__neg__())

def main():
    N,*A=map(int, open(0).read().split())
    C=[0]*(N+1)
    C[-1]=3
    ans=Fp(1)
    for a in A:
        ans*=C[a-1]
        C[a-1]-=1
        C[a]+=1
    print(ans)

if __name__ == "__main__":
    main()

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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

int n,k,a[110];
bool dp[100010];

void input(){
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	return;
}

void solve(){
	for(int i=1;i<=k;i++){
		for(int j=0;j<n;j++){
			if(i-a[j]<0)continue;
			if(dp[i-a[j]])continue;
			dp[i]=true;
		}
	}
	if(dp[k])cout<<"First"<<endl;
	else cout<<"Second"<<endl;
	return;
}

int main(){
	input();
	solve();
	return 0;
}

Measured memory_bytes: 384
s = input()
x, y = map(int, input().split())

s = s.split("T")
s_x = []
s_y = []
for i in range(0,len(s),2):
    s_x.append(s[i])
for i in range(1,len(s),2):
    s_y.append(s[i])
x_count = []
y_count = []
for i in range(len(s_x)):
    x_count.append(s_x[i].count("F"))
for j in range(len(s_y)):
    y_count.append(s_y[j].count("F"))

if sum(x_count) < abs(x) or sum(y_count) <abs(y):
    print("No")
    exit()

x = x - x_count[0]
x_list = set([0])
for i in range(len(x_count)-1,0,-1):
    new_xlist = set()
    for j in range(len(x_list)):
        k = x_list.pop()
        new_xlist.add(k + x_count[i])
        new_xlist.add(k - x_count[i])
    x_list = new_xlist

y_list = set([0])
for i in range(len(y_count)-1,-1,-1):
    new_ylist = set([])
    for j in range(len(y_list)):
        l = y_list.pop()
        new_ylist.add(l + y_count[i])
        new_ylist.add(l - y_count[i])
    y_list = new_ylist

if x in x_list and y in y_list:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
   int n, d;
   cin>>n>>d;
   
   int xy[n][2];
   
   for(int i=0;i<n;i++){
       cin>>xy[i][0]>>xy[i][1];
   }
   
   int ct=0;
   for(int i=0;i<n;i++){
       double ns = pow(xy[i][0],2)+pow(xy[i][1],2);
       double ans = sqrt(ns);
       if(ans<=d){
           ct++;
       }
   }
   
   cout<<ct<<endl;

}


Measured memory_bytes: 5184
def L():
	return list(map(int, input().split()))

N = int(input())
A = L()
B = L()
C = L()
O = 0

for i in range(N):
	ai = A[i] - 1
	O += B[ai]
	if i > 0 and A[i] == A[i - 1] + 1:
		O += C[ai - 1]

print(O)

Measured memory_bytes: 9184
import sys
from fractions import gcd
sys.setrecursionlimit(1000000)

def main():

    def cul(n,x):
        l=len(x)
        b=[x[i] for i in range(l)]
        b.pop(n)
        tmp=b[0]
        for i in range(1,l-1):
            tmp=gcd(tmp,b[i])
        return tmp

    ans=0
    for i in range(p):
        s=cul(i,a[:p])
        if s>ans: ans=s
    print(ans)

if __name__=='__main__':
    N, *a = map(int, sys.stdin.read().split())
    p=50
    if p>N: p=N
    main()

Measured memory_bytes: 16144