akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;scanf("%d",&N);
    int P[N],Q[N];
    for(int i=0;i<N;i++)scanf("%d",&P[i]);
    for(int i=0;i<N;i++)scanf("%d",&Q[i]);
    int a[N];
    for(int i=0;i<N;i++)a[i]=i+1;
    int cnt=0,p=0,q=0;
    do{
        cnt++;
        int nowp=0,nowq=0;
        for(int i=0;i<N;i++){
            if(a[i]==P[i])nowp++;
            if(a[i]==Q[i])nowq++;
        }
        if(nowp==N)p=cnt;
        if(nowq==N)q=cnt;
    }while(next_permutation(a,a+N));
    printf("%d\n",abs(p-q));
    return 0;
}

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
    int array[5],k;
    rep(i,5) cin >> array[i];
    cin >> k;

    if(array[4]-array[0] > k){
        cout << ":(" << endl;
        return 0;
    }
    cout << "Yay!" << endl;
    return 0;
}


Measured memory_bytes: 256
/* ***********************************************
Author        :yang12138
Created Time  :2017年04月18日 星期二 18时52分08秒
File Name     :A.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)

const int N=1e5+10;
int a[N*3];

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
	int n;
	scanf("%d",&n);
	for(int i=1;i<=3*n;i++) scanf("%d",a+i);
	sort(a+1,a+3*n+1);

   	ll ans=0; 
	for(int i=3*n-1;i>=n+1;i-=2) ans+=a[i];

	printf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 1408
#!/usr/bin/env python3

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    q = int(input())
    for i in range(q):
        print(wc())

def wc():
    a, b = map(int, input().split())
    if a == b:
        return 2 * (a - 1)
    if b > a:
        a, b = b, a
    sqt = (a * b) ** 0.5
    area1 = math.ceil(sqt) - 1
    area2 = math.ceil(sqt) - 1 - b
    area3 = b - 1
    adj = -1 if (math.ceil(sqt) - 1) * math.ceil(sqt) >= a * b else 0
    return area1 + area2 + area3 + adj

main()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair < int, int > pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 524290;
const int mod = 1e9 + 7;

int f[2][MAXN], n, m, k, a[25][25], cur;

inline void Inc(int &x, int y) { x += y; if (x >= mod) x -= mod; }
inline int Lowbit(int x) { return x & -x; }

inline int Trans(int x, int y, int z)
{
	if (x >> y & 1)
		return !z ? -1 : x;
	return !z ? x : ((x >> y) - Lowbit(x >> y) + 1) << y | (x & (1 << y) - 1);
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read() - 1, m = Read(), k = Read();
	mset(a, -1);

	for (int i = 1, x, y; i <= k; i ++)
		x = Read(), y = Read() - 1, a[x][y] = Read();
	f[0][0] = cur = 1;
	for (int i = 1; i <= m; i ++)
		for (int j = 0; j < n; j ++, cur ^= 1)
		{
			mset(f[cur], 0);
			for (int k = 0; k < (1 << n); k ++)
				if (f[cur ^ 1][k])
				{
					if (a[i][j] != 1 && ~Trans(k, j, 0))
						Inc(f[cur][Trans(k, j, 0)], f[cur ^ 1][k]);
					if (a[i][j] != 0 && ~Trans(k, j, 1))
						Inc(f[cur][Trans(k, j, 1)], f[cur ^ 1][k]);
				}
		}
	int ans = 0;
	for (int i = 0; i < (1 << n); i ++)
		Inc(ans, f[cur ^ 1][i]);
	return printf("%d\n", ans), 0;
}


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

using namespace __gnu_pbds;
using namespace std;

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

const int infI=1e9+5;
const long long infL=1e16;
const int MOD=1e9+7;
const int MAX=2e5+5;

#define mp make_pair
#define in &
#define pb push_back
#define ii pair<int,int>
#define iii pair<ii,int>
#define ll long long
#define pll pair<ll,ll>
#define vvl vector<vector<ll> >
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define eb emplace_back
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define popb pop_back()
#define se second
#define fi first
#define test(t) int t;cin>>t;while(t--)
#define debug(x) cerr<<"=>"<<#x<<" = "<<x<<endl

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

//only use if mod is prime
ll mod_inv(ll a,ll mod){
    a%=mod;
    return power(a,mod-2);
}

void extended_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return;
    }
    ll x1,y1;
    extended_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-((a/b)*y1);
    return;
}

//TLE can also occur if vectors are not passed by reference
//priority_queue implements max heap by default

vector<vector<ii> > adj;
vi col;

void dfs(int u,int p){
    for(auto x:adj[u]){
        int v =x.fi;
        int w = x.se;
        if(v == p){
            continue;
        }
        if(w%2){
            col[v]=1-col[u];
        }
        else{
            col[v] = col[u];
        }
        dfs(v,u);
    }
}

int main(){
    fastio;
    int n;
    cin>>n;
    adj.resize(n+1);
    forn(i,0,n-1){
        int s,d,w;
        cin>>s>>d>>w;
        adj[s].pb(mp(d,w));
        adj[d].pb(mp(s,w));
    }
    col.resize(n+1,0);
    dfs(1,-1);
    forn(i,1,n+1){
        cout<<col[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 8960
s = gets.chomp
ans = 0
cnt = 0
(0..s.size-1).each do |i|
  if s[i] == "A" || s[i] == "G" || s[i] == "C" || s[i] == "T"
    cnt += 1
  else
    ans = cnt if ans < cnt
    cnt = 0
  end
end
ans = cnt if ans < cnt

puts ans

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
using namespace std;
using Int = long long int;

int main(void) {
    const static Int MAX_XI_VALUE = 50;
    Int n, a;
    cin >> n >> a;

    vector<vector<vector<Int>> > dp(n + 1, vector<vector<Int> >(n + 1, vector<Int>(n * MAX_XI_VALUE + 1)));

    Int now;
    cin >> now;
    dp[1][1][now] = 1;

    for (Int i = 2; i <= n; ++i) {
        cin >> now;
        dp[i][1][now] = 1;
        for (Int j = 1; j <= i; ++j) {
            for (Int k = 1; k < n * MAX_XI_VALUE + 1; ++k) {
                dp[i][j][k] += dp[i - 1][j][k];
                if (k >= now) {
                    dp[i][j][k] += dp[i - 1][j - 1][k - now];
                }
            }
        }
    }

    Int result = 0;
    for (Int j = 1; j <= n; ++j) {
        result += dp[n][j][a * j];
    }
    cout << result << endl;

    return 0;
}


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

int vis[123456];

ll mod = 1e9+7;

ll gcd(ll a,ll b){
	if(b==0)return a;return gcd(b,a%b);
}
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){
        if(pow&1==1){ans = ans*base;}
        base *= base;pow/=2;}return ans;
}
ll inv(ll x){return expo(x,mod-2);}


int main() {
    ll q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    ll n1 = n-n%2;
    ll ans1, ans2, ans3, ans4;
     ans1 = (n1/2)*d+min((n-n1)*s, min(2*(n-n1)*h, 4*(n-n1)*q));
     ans2 = n*s;
     ans3 = 2*n*h;
     ans4 = 4*n*q;
    if(ans1 > ans2)
    ans1 = ans2;
    if(ans3 > ans4)
    ans3 = ans4;
    if(ans1 < ans3) cout << ans1;
    else cout << ans3;
}


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

using namespace std;

template <typename T, class F = function<T(const T&, const T&)>>
class SparseTable {
public:
  int n;
  vector<vector<T>> mat;
  F func;
  
  SparseTable(const vector<T>& a, const F& f) : func(f) {
    n = static_cast<int>(a.size());
    int max_log = 32 - __builtin_clz(n);
    mat.resize(max_log);
    mat[0] = a;
    for (int j = 1; j < max_log; j++) {
      mat[j].resize(n - (1 << j) + 1);
      for (int i = 0; i <= n - (1 << j); i++) {
        mat[j][i] = func(mat[j - 1][i], mat[j - 1][i + (1 << (j - 1))]);
      }
    }
  }
  
  T get(int from, int to) const {
    assert(0 <= from && from <= to && to <= n - 1);
    int lg = 32 - __builtin_clz(to - from + 1) - 1;
    return func(mat[lg][from], mat[lg][to - (1 << lg) + 1]);
  }
};

int main() {
  ios::sync_with_stdio(false); cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  SparseTable<int> stmin(a, [&](int x, int y) { return min(x, y); });
  SparseTable<int> stmax(a, [&](int x, int y) { return max(x, y); });
  vector<int> mark(n);
  for (int i = 0; i < n; ) {
    mark[i] = i;
    int j;
    for (j = i + 1; j < n && a[j] > a[j - 1]; j++) {
      mark[j] = i;
    }
    i = j;
  }
  int ans = 1;
  bool flag = false;
  if (mark[0] == mark[k - 1]) flag = true;
  for (int i = 1; i + k <= n; i++) {
    if (stmin.get(i - 1, i + k - 1) != a[i - 1] || stmax.get(i - 1, i + k - 1) != a[i + k - 1]) {
      if (mark[i] == mark[i + k - 1]) {
        if (!flag) {
          flag = 1;
          ++ans;
        }
      } else ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 28032
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
	double x,h;
	while(1){
		cin >> x;
		cin >> h;
		if(x == 0 && h == 0) break;
		double ans = x * x;
		double tmp = x / 2;
		double a = tmp*tmp+h*h;
		double b = sqrt(a);
		double c = x * b / 2;
		double d = c * 4;
		ans += d;
		printf("%.6f\n",ans);
	}
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

int main() {
  int n, x, y;
  cin >> n >> x >> y;

  V<int> ans(n);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      int c = j - i;
      int fi = min(abs(x - i), abs(y - i));
      int fj = min(abs(y - j), abs(y - j));
      c = min(c, fi + fj + 1);
      ans[c]++;
    }

  for (int k = 1; k < n; k++) {
    printf("%d\n", ans[k]);
  }
}


Measured memory_bytes: 3704
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>  // std::unique
#include <cmath>
using namespace std;

// 素数判定
template <typename T>
bool IsPrimeNumber(T value) {

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


int main(void) {
	long long money = 100;
	long long targetAmount;

	cin >> targetAmount;

	long long elapsedYear = 0;

	while (money < targetAmount) {
		money = floor(money * 1.01);
		elapsedYear++;
	}

	auto output = elapsedYear;
	cout << output;
}


Measured memory_bytes: 3744
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int res = 0;
        for(int i = 0;i < n;i++){
            int h = sc.nextInt();
            if(h >= k){res++;}
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 46880
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let x = v[0];
	let y = v[1];
	println!("{}", x + y/2);
}

Measured memory_bytes: 4352
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-04 20:21:34
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int64 n, k; cin >> n >> k;
  //int64 g = __gcd(n, k);

  if (n < k) {
    cout << min(n, abs(n - k)) << endl; return 0;
  }

  if (n % k == 0) {
    cout << 0 << endl; return 0;
  }

  n %= k;

  cout << min(n, abs(n - k)) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int count=0;
    for(int i=0;i<4;i++)
    {
      if(s.at(i)=='+')
      count++;
      else
      count--;
    }
    cout << count << endl;
}

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

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out,false);
        int n = scanner.nextInt();
        String[] arr = new String[n];
        for(int i =0; i < n; i++) {
            char[] str = scanner.next().toCharArray();
            Arrays.sort(str);
            arr[i] = new StringBuilder().append(str).toString();
        }
        Arrays.sort(arr);
        long amt = 0;
        for(int i = 0; i < n; ) {
            int j = i + 1;
            for(; j < n; j++) {
                if (!arr[i].equals(arr[j])) break;
            }
            amt += ((long)(j - i-1)*(j - i))/ 2; 
            i = j;
        }
        out.println(amt);
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 46292
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  ll A[N];
  for(int i=0;i<N;++i) cin>>A[i];
  ll two[64], two1[64];
  for(ll i=0;i<64;++i) {
    two[i] = 0;
    two1[i] = 0;
    for(int j=0;j<N;++j) {
      if((A[j]&(1ull<<i))==0) two[i] += (1ull<<i);
      two[i] %= mod;
      two1[i] += (1ull<<i)&A[j];
      two1[i] %= mod;
    }
  }
  ll ans = 0;
  for(int i=0;i<N;++i) {
    for(ll j=0;j<64;++j) {
      if((A[i]&(1ull<<j))!=0) ans += two[j];
      else ans += two1[j];
      ans %= mod;
    }
  }
  ll h=mod-2;
  ll twotwo;
  ll tmp;
  while(h>0) {
    twotwo = 1;
    tmp = 2;
    while(2*twotwo<h) {
      twotwo *= 2;
      tmp *= tmp;
      tmp %= mod;
    }
    h -= twotwo;
    ans *= tmp;
    ans %= mod;
  }
  cout<<ans<<endl;
}



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

int main(){
  while(1){
    int n;
    cin >> n;
    if(n==0) break;
    int a[n];
    int sum=0;
    for(int i=0; i<n; i++){
      cin >> a[i];
      sum += a[i];
    }
    int c=0;
    for(int i=0; i<n; i++){
      if(sum/n>=a[i])
      c++;
    }
    cout << c << endl;
  }
  return 0;
}



Measured memory_bytes: 3160
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
      Scanner sc = new Scanner(System.in);
      int x,y;
      x = 1;
      y = 1;
      while(x != 0 || y != 0){
    	x = sc.nextInt();
    	y = sc.nextInt();
    	if((x!=0 || y != 0) && x >= y){
    		System.out.println(y+" "+x);}
    	else if((x!=0 || y != 0) && x < y){
        	System.out.println(x+" "+y);
    	}
      }
	}

}

Measured memory_bytes: 36728
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


/* キューのデータ */
typedef struct DATA {
  long long int data;
  struct DATA *next;
} DATA_T;

/* キューの情報を構造体 */
typedef struct QUEUE {
  /* キューの先頭を指すポインタ */
  DATA_T *head;
  /* キューの最後尾を指すポインタ */
  DATA_T *tail;
} QUEUE_T;

void initQueue(QUEUE_T*);
void finishQueue(QUEUE_T*);
void enqueue(QUEUE_T*, long long int);
long long int dequeue(QUEUE_T*);

/* キューを初期化する関数 */
void initQueue(QUEUE_T *queue){

  queue->head = NULL;
  queue->tail = NULL;
}

/* キューの終了処理をする関数 */
void finishQueue(QUEUE_T *queue){
  DATA_T *p, *next;
  p = queue->head;
  while(p != NULL){
    next = p->next;
    free(p);
    p = next;
  }
}

/* エンキューする関数 */
void enqueue(QUEUE_T *queue, long long int input){

  DATA_T *add;

  /* エンキューするデータを保持するメモリを確保 */
  add = (DATA_T*)malloc(sizeof(DATA_T));

  /* メモリが足りなければ何もせず関数終了 */
  if(add == NULL){
    printf("メモリが取得ないためエンキューできません\n");
    return ;
  }

  add->data = input;
  add->next = NULL;

  /* キューが空の場合は先頭に追加するのみ */
  if(queue->head == NULL){
    queue->head = add;
    queue->tail = add;
    return ;
  }

  /* キューの最後尾に追加したデータを追加 */
  /* キューの最後尾のデータのnextを追加データのアドレスにセット */
  queue->tail->next = add;

  /* キューの最後尾を指すtailを追加したデータのアドレスにセット */
  queue->tail = add;
}

/* デキューする関数 */
long long int dequeue(QUEUE_T *queue){
  //int i = 0;
  long long int ret = 0;
  DATA_T *tmpNext;

  /* キューが空なら何もせずに関数終了 */
  if(queue->head == NULL){
    printf("キューが空です\n");
    return -1;
  }

  /* デキューする数（先頭データ）を取得 */
  ret = queue->head->data;

  /* デキューするデータのnextポインタの指すアドレスを退避 */
  tmpNext = queue->head->next;

  /* デキューしたデータ（先頭データ）を削除 */
  free(queue->head);

  /* 先頭を指すheadポインタを先頭の次のデータのアドレス（退避したアドレス）にセット */
  queue->head = tmpNext;

  return ret;
}



int main(void){

  int m,k;
  long long int input,i;
  long long int output;
  QUEUE_T queue;

  
  initQueue(&queue);
  for(i=1;i<=9;i++){
      enqueue(&queue,i);
  }
  scanf("%d",&k);
  for(i=1;i<k;i++){
    output=dequeue(&queue);
    if(output%10!=0){
        input=10*output+(output%10)-1;
        enqueue(&queue,input);
    }
    input=10*output+(output%10);
    enqueue(&queue,input);
    if(output%10!=9){
        input=10*output+(output%10)+1;
        enqueue(&queue,input);
    }
  }  
  output=dequeue(&queue);
  printf("%lld\n",output);   
  finishQueue(&queue);
  return 0;
}

Measured memory_bytes: 6144
import decimal,math
from collections import Counter,defaultdict
from fractions import gcd
from bisect import bisect_right,bisect_left
decimal.getcontext().prec = 10
N=int(raw_input())

arr=map(int,raw_input().split())
ans=1
for i in arr:
	ans=ans*i
ans1=0
for i in arr:
	ans1=ans1+(ans)/float(i)
print ans/float(ans1)		

Measured memory_bytes: 34792
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX



 
void solve()
{
  int n;
  cin >> n;
  string arr[n];
  inp(arr, n);
  rep(i,0,n-1)
    sort(arr[i].begin(), arr[i].end());
  map<string, int> q;
  rep(i,0,n-1)
    q[arr[i]]++;
  int ans = 0;
  loop(q)
    ans += ((it.sc)*(it.sc-1))/2;
  cout << ans << endl;
 
}


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

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n, m;
  cin >> n >> m;
  ll count_ac = 0;
  ll count_wa = 0;
  vi p(m);
  vector<string> M(m);
  vector<bool> a(n, true);
  vi b(n, 0);
  rep(i, m){
    cin >> p[i] >> M[i];
    p[i]--;
  }
  rep(i,m){
    if(a[p[i]]==true&&M[i]=="WA"){
      b[p[i]]++;
    }
    else if(a[p[i]]==true&&M[i]=="AC"){
      a[p[i]] = false;
      count_ac++;
      count_wa += b[p[i]];
    }
  }
  cout << count_ac << " " << count_wa << endl;
}

Measured memory_bytes: 7296
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    S = input()
    N = len(S)

    # n文字まで見て最後が1文字か2文字か
    dp_1 = [0] * N
    dp_2 = [0] * N
    dp_1[0] = 1
    dp_2[1] = 1
    if S[0] != S[1]:
        dp_1[1] = 2

    for i in range(2, N):
        # 2 -> 1
        dp_1[i] = max(dp_2[i - 1] + 1, dp_1[i])

        # 2 -> 2
        if S[i - 2 : i] != S[i : i + 2]:
            dp_2[i] = max(dp_2[i - 2] + 1, dp_2[i])

        # 1 -> 2
        dp_2[i] = max(dp_1[i - 2] + 1, dp_2[i])

        # 1 -> 1
        if S[i - 1] != S[i]:
            dp_1[i] = max(dp_1[i - 1] + 1, dp_1[i])

    ans = max(dp_1[-1], dp_2[-1])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 19108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;

int main(){
    ll N;
    cin>>N;
    //if(N>999)cout<<"ABD"+to_string(N-999)<<endl;
    //else cout<<"ABC"+to_string(N)<<endl;
    if(N>999)cout<<"ABD"<<endl;
    else cout<<"ABC"<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	cout<<(n==m?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int N, M;
	while (scanf("%d%d", &N, &M), N && M) {
		int A, ans = 0;
		for (int i = 0; i < N; i++) {
			scanf("%d", &A);
			if (M / N < A) ans += M / N;
			else ans += A;
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll x, y;
    cin >> x >> y;
    ll ans = abs(abs(x) - abs(y));
    if (x*y > 0) {
        if (x > y) ans += 2;
    } else if (x*y == 0) {
        if (x > y) ans += 1;
    } else {
        ans += 1;
    }
    cout << ans << endl;
}

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

int main(){

    int x, a, b;
    scanf("%d%d%d", &x, &a, &b);
    int A=abs(x-a), B=abs(x-b);
    if(A<B)
        puts("A");
    else
        puts("B");







    return 0;
}


Measured memory_bytes: 256
S = list(map(int,input().split("/")))
if S[0] < 2019:
    print("Heisei")
elif S[0] == 2019 and S[1] < 4:
    print("Heisei")
elif S[0] == 2019 and S[1] == 4 and S[2] < 31:
    print("Heisei")
else:
    print("TBD")

Measured memory_bytes: 3060
#include <iostream>
#include <string>

using namespace std;
int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;

  int count = 0;
  size_t pos = s.find("ABC");
  while (std::string::npos != pos) {
    pos = s.find("ABC", pos + 1);
    count++;
  }
  cout << count << endl;
  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 num = sc.nextLine();
        check(num);
    }

    public static void check(String num) {
        int cnt = Integer.parseInt(num);
        System.out.println(cnt*cnt*3);
    }
}

Measured memory_bytes: 22740
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<cstring>
#include<sstream>
#include<complex>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < int(Y);++(X))
#define rrep(X,Y) for (int (X) = int(Y-1);(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

class book{
public:
  string title,auther;
  ll data;
};

ll toInt(string str){
  stringstream ss(str);
  ll re=0,a;char c;
  ss>>a>>c;
  re+=a*10000;
  ss>>a>>c;
  re+=a*100;
  ss>>a>>c;
  re+=a;
  return re;
}

int main(){
  int i,j,k;
  int n,q;
  cin>>n;
  vector<book> books;
  string ti,au,dat;
  book tmp;
  rep(i,n){
    cin>>ti>>au>>dat;
    tmp.title=ti;
    tmp.auther=au;
    tmp.data=toInt(dat);
    books.pb(tmp);
  }
  cin>>q;
  string datl,datr;
  rep(i,q){
    cin>>ti>>au>>datl>>datr;
    ll datal=toInt(datl),datar=toInt(datr);
    rep(j,n){
      if(ti!="*" && books[j].title.find(ti)==string::npos)
        continue;
      if(au!="*" && books[j].auther.find(au)==string::npos)
        continue;
      if(datl!="*" && datal>books[j].data)
        continue;
      if(datr!="*" && datar<books[j].data)
        continue;
      cout<<books[j].title<<endl;
    }
    if(i<q-1)cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1256
#include<stdio.h>
int main(){
  int n, ans = 0;
  scanf("%d", &n);
  for(int i = 1; i <= 9; ++i){
    if(n % i == 0 && n / i <= 9 && n > 0) ans++;
	if(ans) break;
  }
  if(ans) puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 128
<?php

$stdin = trim(fgets(STDIN));  

$number = explode(" ", $stdin);

$a = $number[0];
$b = $number[1];
$c = $number[2];

if ($a < $b) {
    if ($b < $c) {
        echo "$a $b $c";
    } elseif ($a < $c) {
        echo "$a $c $b";
    } else {
        echo "$c $a $b";
    }
} elseif ($a > $b) {
    if ($c > $a) {
        echo "$c $a $b";
    } elseif ($c < $a) {
        if ($b >$c) {
            echo "$c $b $a";
        } else {
            echo "$b $c $a";
        }
    }
} else {
    echo "$a $b $c";
}
?>

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

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

    int n;cin >> n;
    n %= 10;
    set<int> hon{2,4,5,7,9};
    set<int> pon{0,1,6,8};
    
    if(hon.count(n))cout << "hon" << endl;
    else if(pon.count(n))cout << "pon" << endl;
    else cout << "bon" << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

int main (void)
{
    intmax_t N, A[15], x[15][14], y[15][14];
    intmax_t ans = 0;

    scanf("%jd", &N);
    for (size_t i = 0; i < N; i++) {
        scanf("%jd", &A[i]);
        for (size_t j = 0; j < A[i]; j++)
            scanf("%jd%jd", &x[i][j], &y[i][j]);
    }

    for (uint_least16_t i = 0; i <= (0x7fff >> (15 - N)); i++) {
        bool flag = true;
        for (uintmax_t j = 0; j < N; j++) {
            if (!(i & (1 << j)))
                continue;
            for (uintmax_t k = 0; k < A[j]; k++) {
                if ((i & (1 << (x[j][k] - 1))) != (y[j][k] << (x[j][k] - 1)))
                    flag = false;
            }
        }
        if (flag) {
            uintmax_t bits = 0;
            for (uint_least16_t mask = 1; mask != 0; mask <<= 1) {
                if (i & mask)
                    bits++;
            }
            if (bits > ans)
                ans = bits;
        }
    }

    printf("%jd\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long int ll;

#define rep(x, a, b) for (size_t x = a; x < b; x++)

int
main()
{
  string str;
  int k;

  cin >> str >> k;

  vector<char> c(str.size(), 0);

  rep (i, 0, str.size()) c[i] = str[i] - 'a';

  rep (i, 0, str.size()) {
    if (c[i] == 0) {
      ;
    } else if (26 - c[i] <= k) {
      k -= 26 - c[i];
      c[i] = 0;
    }
  }

  c[c.size() - 1] += k % 26;

  rep (i, 0, str.size()) {
    putchar(c[i] + 'a');
  }
  putchar('\n');
  
  return 0;
}


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

using namespace std;

int main(void) {
	int N;
	cin >> N;
	for(int i = 0; i < N; ++i) {
		int A;
		cin >> A;
		if(A % 2 == 0 && A % 3 != 0 && A % 5 != 0) {
			cout << "DENIED\n";
			return 0;
		}
	}
	cout << "APPROVED\n";
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 3000
using namespace std;
typedef pair<int,int> P;
set<P> s;

int main(){
  int n,ans;
  P p[N];
  while(1){
    ans=0;
    cin>>n;
    if(!n)break;
    for(int i=0;i<n;i++){
      cin>>p[i].first>>p[i].second;
      s.insert(p[i]);
    }
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	int x1=p[i].first,y1=p[i].second;
	int x2=p[j].first,y2=p[j].second;
	int X=x2-x1,Y=y2-y1;
	if(s.find(P(x1+Y,y1-X))!=s.end())
	  if(s.find(P(x2+Y,y2-X))!=s.end())
	    ans=max(ans,Y*Y+X*X);
	if(s.find(P(x1-Y,y1+X))!=s.end())
	  if(s.find(P(x2-Y,y2+X))!=s.end())
	    ans=max(ans,Y*Y+X*X);
      }
    }
    cout<<ans<<endl;
    s.clear();
  }
  return 0;
}

Measured memory_bytes: 1360
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  ll a;
  cin >> a;
  
 cout << (a>=30?"Yes":"No") << endl;
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3644
#include<iostream>
#include<list>
#include<string>
#include<algorithm>
int main()
{
  std::list<int> lst;
  std::string str;
  int n;
  int tmp;
  std::cin>>n;
  for(int i=0;i<n;i++){
    std::cin>>str;
    if(str=="insert"){
      std::cin>>tmp;
      lst.push_front(tmp);
    }else if(str=="deleteFirst"){
      lst.pop_front();
    }else if(str=="deleteLast"){
      lst.pop_back();
    }else{
      std::cin>>tmp;
      std::list<int>::iterator it=find(lst.begin(),lst.end(),tmp);
      if(it!=lst.end()){
	lst.erase(it);
      }
    }
  }

  for(std::list<int>::iterator it=lst.begin();it!=lst.end();++it){
    if(it!=lst.begin()){
      std::cout<<' ';
    }
    std::cout<<*it;
  }
  std::cout<<'\n';
  return 0;
}



Measured memory_bytes: 34400
#include <stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int l[n];
  int b=0;
  for(int i=0;i<n;i++){
    scanf("%d",&l[i]);
    b^=l[i];
  }
  for(int i=0;i<n;i++){
    printf("%d ",b^l[i]);
  }
  return 0;
}

Measured memory_bytes: 3180
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include <iostream>
using namespace std;

struct Node
{
	int key;
	Node *right, *left, *parent;		
};

Node *root, *NIL;

Node * find(Node *u, int k)
{
	while(u != NIL && k != u->key)
	{
		if(k < u->key)
		{
			u = u->left;
		}
		else
		{
			u = u->right;
		}
	}

	 return u;
}

void insert(int k)
{
	Node *y=NIL;
	Node *x=root;
	Node *z;

	z=(Node *)malloc(sizeof(Node));
	z->key=k;
	z->left=NIL;
	z->right=NIL;

	while(x !=  NIL)
	{
		y=x;
		if(z->key < x->key)
		{
			x= x->left;
		}
		else
		{
			x= x->right;
		}
	}

	z->parent=y;
	if(y==NIL)
	{
		root=z;
	}
	else
	{
		if(z->key < y->key)
		{
			y->left=z;
		}
		else
		{
			y->right=z;
		}
	}
}

void inorder(Node *u)
{
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}

void preorder(Node *u)
{
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}

int main()
{
	int n,i,x;
	string com;

	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		cin >> com;
		if(com == "find")
		{
			scanf("%d",&x);
			Node *t = find(root ,x);
			if(t != NIL)
			{
				printf("yes\n");
			}
			else
			{
				printf("no\n");
			}
		}
		else if(com == "insert")
		{
			scanf("%d", &x);
			insert(x);
		}
		else if(com == "print")
		{
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}


Measured memory_bytes: 22020
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

if sum(A) < sum(B):
    print(-1)
    exit()

ans = 0
minus = 0
plus_list = []
for a, b in zip(A, B):
    if a < b:
        ans += 1
        minus += b - a
    plus_list.append(a - b)

if minus == 0:
    print(0)
    exit()

plus_list_ = sorted(plus_list, reverse=True)

for p in plus_list_:
    minus -= p
    ans += 1
    if minus < 0:
        break

print(ans)
#print(minus)
#print(plus_list)

Measured memory_bytes: 18708
n = gets.to_i

s=Array.new(n)
pp=Array.new(n)
r=Array.new(n)

for i in 0...n
  s[i], pp[i] = gets.chop.split
  pp[i]=pp[i].to_i
  r[i]=[s[i],pp[i]]
end

q=r.sort{|a,b| b[1]<=>a[1]}
q.sort!{|a,b| a[0]<=>b[0]}

for i in 0...n
  puts (r.find_index(q[i])+1)
end


Measured memory_bytes: 1788
/* Simplicity and Goodness */

#include <bits/stdc++.h>
using namespace std;
#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define deb(x) cout << #x << " = " << x << ' ';
#define rep(i, a, b) for(int i=(int)(a); i<(int)(b); i++)
#define tc int tt; scn(tt); while(tt --)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


int main()
{
   int n, m;
   scn(n); scn(m);

   string s[n];
   rep(i, 0, n)
      cin >> s[i];

   vector<vector<int>> dp(n+1, vector<int>(m+1, 0));

   dp[0][0] = 1;

   rep(i, 1, m+1) {
      if(s[0][i-1] == '#') {
         break;
      } else {
         dp[1][i] = 1;
      }
   }

   rep(j, 1, n+1) {
      if(s[j-1][0] == '#') {
         break;
      } else {
         dp[j][1] = 1;
      }
   }

   rep(i, 2, n+1) {
      rep(j, 2, m+1) {
         if(s[i-1][j-1] == '#') {
            dp[i][j] = 0;
         } else {
            dp[i][j] = (1LL * dp[i-1][j] + dp[i][j-1]) % mod;
         }
      }
   }

//   rep(i, 1, n+1) {
//      rep(j, 1, m+1) {
//         cout << dp[i][j] << ' ';
//      }puts("");
//   }

   int ans = dp[n][m];
   prin(ans);
   return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

// AtCoder
#include <atcoder/all>
using namespace atcoder;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

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

vector<int> dy = {-1, 0, 1, 0, -1, 1, 1, -1},
            dx = {0, -1, 0, 1, -1, -1, 1, 1};

int encode (int i, int j, int w) { return i * w + j; }
P decode (int c, int w) { return P{c / w, c % w}; }

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    // Submit this code from the browser if using ACL!
    
    ll h, w; cin >> h >> w;
    vector<string> s(h); rep (i, h) cin >> s[i];
    mf_graph<int> graph(h * w + 2);
    rep (i, h) { rep (j, w) {
        if (s[i][j] == '#') continue;
        if ((i + j) % 2) {
            graph.add_edge(encode(i, j, w), h * w + 1, 1);
            continue;
        } else graph.add_edge(h * w, encode(i, j, w), 1);
        rep (d, 4) {
            int y = i + dy[d], x = j + dx[d];
            if (y < 0 || y >= h || x < 0 || x >= w) continue;
            if (s[y][x] == '#') continue;
            graph.add_edge(encode(i, j, w), encode(y, x, w), 1);
        }
    }}
    cout << graph.flow(h * w, h * w + 1) << "\n";
    for (auto x : graph.edges()) {
        eprintf("%d->%d %d/%d\n", x.from, x.to, x.flow, x.cap);
        if (x.from >= h * w || x.to >= h * w || x.flow == 0) continue;
        auto [y0, x0] = decode(x.from, w);
        auto [y1, x1] = decode(x.to, w);
        if (x0 > x1) swap(x0, x1);
        if (y0 > y1) swap(y0, y1);
        if (x0 != x1) {
            s[y0][x0] = '>'; s[y1][x1] = '<';
        } else {
            s[y0][x0] = 'v'; s[y1][x1] = '^';
        }
    }
    rep (i, h) cout << s[i] << "\n";
    return 0;
}

Measured memory_bytes: 5572
#include<iostream>
using namespace std;
int main(){
	int N,X;
	cin>>N>>X; 
	int *L=new int[N+1];
	int *D=new int[N+1];
	D[1]=0;
	for(int i=1;i<=N;i++){
		cin>>L[i];
	}
	for(int i=2;i<=N+1;i++){
		D[i]=D[i-1]+L[i-1];
	}
	int sum=0;
	for(int i=1;i<=N+1;i++){
		if(D[i]<=X){
			sum++;
		}
//		cout<<D[i]<<" ";
	}
	cout<<sum<<endl;
	return 0;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int Inf = (int)1e9;
		
		List<Pair>[] E = new List<Pair>[N];
		for(int i=0;i<N;i++){
			E[i] = new List<Pair>();
		}
		int[][] WF = new int[N][];
		
		for(int i=0;i<N;i++){
			WF[i] = new int[N];
			for(int j=0;j<N;j++) WF[i][j] = i == j ? 0 : Inf;
		}
		
		for(int i=0;i<M;i++){
			E[A[i]].Add(new Pair(B[i],C[i],i));
			E[B[i]].Add(new Pair(A[i],C[i],i));
			WF[A[i]][B[i]] = C[i];
			WF[B[i]][A[i]] = C[i];
		}
		
		for(int k=0;k<N;k++){
			for(int i=0;i<N;i++){
				for(int j=0;j<N;j++){
					WF[i][j] = Math.Min(WF[i][j],WF[i][k] + WF[k][j]);
				}
			}
		}
		
		bool[] used = new bool[M];
		for(int s=0;s<N;s++){
			int[] min = new int[N];
			for(int i=0;i<N;i++) min[i] = WF[s][i];
			bool[] done = new bool[N];
			for(int i=0;i<N;i++){
				int mm = Inf;
				int idx = -1;
				for(int j=0;j<N;j++){
					if(done[j])continue;
					if(mm > min[j]){
						idx = j;
						mm = min[j];
					}
				}
				
				done[idx] = true;
				foreach(var e in E[idx]){
					if(WF[s][e.To] == WF[s][idx] + e.Cost){
						used[e.Idx] = true;
					}
				}
			}
		}
		
		
		int ans = used.Count(v => v == false);
		Console.WriteLine(ans);
		
		
		
		
		
		
	}
	
	class Pair{
		public int To,Cost,Idx;
		public Pair(int t,int c,int i){
			To = t; Cost = c; Idx = i;
		}
	}
	
	
	
	int N,M;
	int[] A,B,C;
	
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		A = new int[M];
		B = new int[M];
		C = new int[M];
		for(int i=0;i<M;i++){
			d = ria();
			A[i] = d[0] - 1;
			B[i] = d[1] - 1;
			C[i] = d[2];
			
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.20f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

int main() {
	int n, k;
	cin >> n >> k;
	int p[n];
	rep (i, n) cin >> p[i];
	sort(p,p+n);

	ll sum = 0;
	rep (i, k) sum += p[i];
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
/*   -- AUTHOR -- 
  ---- cervotrex ---- 
*/
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(arr) arr.begin(),arr.end()
#define mod 1000000007
const ll INF = 1LL << 60;
const int MAX_N = 1000005;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ook order_of_key
#define fbo find_by_order
// ordered_set <int> s  ;
// auto x=s.find_by_order(k);
// s.order_of_key(val);

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
      ll a,b; cin>>a>>b;
      cout<<(a*b)<<"\n";
    }
    return 0;
}

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

int main(){ 
    lint N;
    cin >> N;
    vector<lint> A(N);
    rep( i, N ) cin >> A[i];

    vector<lint> ans(N);
    rep( i, N ) ans[0] = A[i] - ans[0];

    for( int i=1; i<N; ++i ) {
        ans[i] = 2 * A[i-1] - ans[i-1];
    }

    rep( i, N ) cout << ans[i] << "\n";
}


Measured memory_bytes: 2944