akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}

bool comp(vector<int> v1, vector<int> v2) {
    for (int i = 0; i < v1.size(); i++) {
        if (v1[i] != v2[i]) return false;
    }

    return true;
}

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

    int n;
    cin >> n;
    vector<int> p(n), q(n);

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

    int i = 0;
    while (i < n) {
        if (p[i] == q[i]) {
            i++;
            continue;
        }
        if (q[i] > p[i]) break;
        if (p[i] > q[i]) {
            swap(p, q);
            break;
        }
    }

    int ans = 0;
    do {
        if (comp(p ,q)) break;
        ans++;

    } while (next_permutation(p.begin(), p.end()));

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.ArrayDeque;
import java.util.Queue;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n%10==2||n%10==5||n%10==4||n%10==7||n%10==9) {
			System.out.println("hon");
		}
		else if(n%10==0||n%10==1||n%10==6||n%10==8) {
			System.out.println("pon");
		}
		else if(n%10==3) {
			System.out.println("bon");
		}
	 }
}

Measured memory_bytes: 35792
package main

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

func main() {
	sc := NewScanner()
	N, A, B := sc.NextInt(), sc.NextInt(), sc.NextInt()

	D := A + B - N
	if D < 0 {
		D = 0
	}
	fmt.Println(min(A, B), D)
}
func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll = long long;                    // seq 1 128 | factor   100333 ~2^16.61
using ld = long double;                  //   | grep -v ' .* '  1300111 ~2^20.31
using vl = vector<ll>;                   //                    10300777 ~2^23.30
using vvl = vector<vl>;                  //                   100400999 ~2^26.58
using pll = pair<ll,ll>;                 //                  1300400999 ~2^30.28
using vpll = vector<pll>;                //                 10200500333 ~2^33.25
using vb = vector<bool>;                 //                100200400777 ~2^36.54
using vs = vector<string>;               //               1200300700111 ~2^40.13
const ll oo = 0x3f3f3f3f3f3f3f3fLL;      //              10200300500777 ~2^43.21
const ld eps = 1e-9;                     //             100200300400777 ~2^46.51
#define sz(c) ll((c).size())             //            1200300400600999 ~2^50.09
#define all(c) begin(c),end(c)           //           10200300400600111 ~2^53.18
#define mp make_pair                     //          100200300400600333 ~2^56.48
#define mt make_tuple                    //         1200300400500800999 ~2^60.06
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

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

	ll n, k;
	cin >> n >> k;
	vl hs(n);
	FOR(i,0,n) cin >> hs[i];

	vl dp(n);
	dp[0] = 0;

	FOR(i,1,n) {
		ll res = oo;
		FOR(s,1,k+1) {
			if (i - s < 0) continue;
			res = min(res, dp[i-s] + abs(hs[i]-hs[i-s]));
		}
		dp[i] = res;
		TR(i); TR(res);
	}

	cout << dp[n-1] << "\n";

	return 0;
}


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

int main()
{

    string s;
    cin>>s;
    int ans=INT_MAX;
    for(int i=0;i<=s.size()-3;i++){
        int x=0;
        x+=s[i]-'0';
        x*=10;
        x+=s[i+1]-'0';
        x*=10;
        x+=s[i+2]-'0';
        ans=min(ans,abs(x-753));
    }
        cout<<ans;
    return 0;
}


Measured memory_bytes: 3552
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#define ll int
#define mod 100000007
#define ln printf("\n");
using namespace std;
inline void in(ll &x){x=0;char c;bool f=0;while((c=getchar())>'9'||c<'0')if(c=='-')f=!f;x=c-48;while((c=getchar())<='9'&&c>='0')x=x*10+c-48;if(f)x=-x;}
inline void out(ll x){if(x<0){putchar('-');x=-x;}if(x>9)out(x/10);putchar(x%10+48);}
inline void outn(ll x){out(x);printf("\n");}
ll x,y;
string s;
int main(){
	in(x);in(y);cin>>s;
	if(s[x]!='-'){printf("No\n");return 0;}
	for(int i=0;i<x;i++)if(s[i]>'9'||s[i]<'0'){printf("No\n");return 0;}
	for(int i=x+1;i<x+y+1;i++)if(s[i]>'9'||s[i]<'0'){printf("No\n");return 0;}
	printf("Yes\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;


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

	printf("%s", a + b + c > 21 ? "bust" : "win");

	return 0;
}



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

int main(){
  int h,w;
  int dx[] = {-1,0,1,-1,1,-1,0,1};
  int dy[] = {1,1,1,0,0,-1,-1,-1};
  while(cin >> h >> w && h && w){
    char c[11][21];
    set<string> s;
    string ans = "";

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> c[i][j];
      }
    }

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	for(int k=0;k<8;k++){
	  int x = j;
	  int y = i;

	  string str;
	  str += c[y][x];

	  while(1){
	    x += dx[k];
	    y += dy[k];

	    if(x < 0) x = w - 1;
	    else if(x >= w) x = 0;
	    if(y < 0) y = h - 1;
	    else if(y >= h) y = 0;

	    if(x == j && y == i) break;
	    else str += c[y][x];

	    
	    if(!s.empty() && s.find(str) != s.end() && str.size() > ans.size()) ans = str;
	    else if(!s.empty() && s.find(str) != s.end() && str.size() == ans.size() && str < ans) ans = str;
	    else s.insert(str);
	    
	  }

	}
      }
    }
    if(ans != "") cout << ans << endl;
    else cout << "0" << endl;
  }
  return 0;
}

Measured memory_bytes: 26000
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int P[1001],Q[1000000];
int main(){
    int n,m;

while(true){
    cin >> n >> m;
    if(n==0 && m==0) break;

    P[0]=0;
    for(int i=1;i<=n;i++) scanf("%d",&P[i]);

    int num=0;
    for(int i=0;i<=n;i++){
	for(int j=i;j<=n;j++){
	    Q[num++]=P[i]+P[j];
	}
    }

    sort(Q,Q+num);

    int key,ans=0,idx;
    int *pos;
    for(int i=0;i<num;i++){
	key=m-Q[i];
	if(key<0) break;
 	pos=upper_bound(Q,Q+num,key);
	idx=distance(Q,pos);
	
	if(Q[i]+Q[idx-1]>ans) ans=Q[i]+Q[idx-1];
    }
    
    cout << ans << endl;
}

    return 0;
}

Measured memory_bytes: 5152
import sys
N = int(input())
mod = pow(10, 9)+7
if N < 3:
    print(0)
    sys.exit()
ans = 1
for j in range(2, N//3+1):
    r = j-1
    n = N-j*3+r
    bunshi = 1
    bunbo = 1
    for i in range(r):
        bunshi = (bunshi*(n-i)) % mod
        bunbo = (bunbo*(i+1)) % mod
    ans = (ans+(bunshi*pow(bunbo, -1, mod))) % mod
print(ans)


Measured memory_bytes: 9136
#include <cstdio>
#include <utility>

#define fin stdin
#define fout stdout

char e[100009];
int s[100009];

inline std::pair <int, int> calc(char ch, int n){
    s[0]=0;
    int best = 10, poz = -1;
    for(int i = 1; i <= n; i ++){
        s[i] = s[i - 1];
        if(e[i] == ch) s[i] ++;
        else s[i] --;

        if(s[i] > best)
            return std::make_pair(poz, i);

        if(s[i - 1] < best)
            best = s[i-1], poz = i;
    }
    return std::make_pair(-1, -1);
}

int main(){
    int n = 0;
    char ch = fgetc(fin);

    while(ch != '\n'){
        e[++ n] = ch;
        ch = fgetc(fin);
    }

    bool f=1;
    for(char u = 'a'; u <= 'z' && f; u ++){
        std::pair <int, int> a = calc(u, n);
        if(a.first != -1) f=0, fprintf(fout, "%d %d\n", a.first, a.second);
    }
    if(f) fprintf(fout, "-1 -1\n");

    return 0;
}


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

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    int N;
    cin >> N;
    vector<int> h(N);
    int max = 0;
    rep(i, N){
        cin >> h[i];
        if(h[i] > max){
            max = h[i];
        }
    }
    int ans = 0;
    bool flag = false;
    rep(j, max){
        rep(i, N){    
            if(h[i] > j){
                if(flag == true){
                    //ans++;
                }else{
                    flag = true;
                    ans++;
                }
                
            }else{
                if(flag == true){
                    flag = false;
                }else{

                }
            }
            //flag = false;
        }
        flag = false;
    }
    cout << ans << endl;
return 0;}
/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        ArrayList<Integer> A = new ArrayList<>();
        for (int i=0;i<n;i++){
            A.add(scanner.nextInt());
        }
        boolean b = true;
        int count=0;
        while (b){
            for (int i:A){
                if (i%2==1){
                    b = false;
                    break;
                }
            }
            if (!b){
                break;
            }
            ArrayList<Integer> B = new ArrayList<>();
            count++;
            for (int i=0;i<A.size();i++){
                B.add(A.get(i)/2);
            }
            A.clear();
            A.addAll(B);
        }
        System.out.println(count);
    }

}

Measured memory_bytes: 21584
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
string s ; 
int give_num(int index){

} 

 
void solve()
{
	ll x ;
	cin>>x;
	ll st = 100 ;
	ll year = 0 ;
	while(st<x){
		year++;
		st = st +  (st)/100 ;
	}
	cout<<year;
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    // cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

int num[1000001];

int BubbleSort(int n)
{	
	int k = 0, ct = 0;
	bool flag = true;
	
	do {
		flag = true;
		
		for (int i = 0; i < n - 1 - k; i++){
			if (num[i] > num[i + 1]){
				flag = false;
				swap(num[i], num[i + 1]);
				ct++;
			}
		}
		k++;
	}while (!flag);
	return (ct);
}

int main()
{
	int n;
	
	while (cin >> n, n){
		for (int i = 0; i < n; i++){
			cin >> num[i];
		}
		int ct = BubbleSort(n);
		cout << ct << endl;
	}
	return (0);
}

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

typedef long long ll;
const int maxg = 10;
const int maxn = 2e3 + 3;
vector<ll> G[maxg];
int n, m;
ll dp[maxn][maxn];

int main()
{
	scanf("%d %d", &n, &m);
	for (int i = 0; i < maxg; ++i)// 为以后sum做准备
		G[i].push_back(0);
	for (int i = 0; i < n; ++i)
	{
		ll c, g;
		scanf("%lld %lld", &c, &g);
		--g;
		G[g].push_back(c);
	}
	for (int i = 0; i < maxg; ++i)
	{
		sort(G[i].begin(), G[i].end()); // 先顺排
		auto ite = G[i].begin(); ite++;
		reverse(ite, G[i].end());// 后逆排
		for (int j = 1; j < G[i].size(); ++j)
			G[i][j] += G[i][j - 1] + 2 * (j - 1);// 累加并加附加值
	}
	for (int i = 1; i < G[0].size(); ++i)// dp边界
		dp[0][i] = G[0][i];
	for (int i = 1; i < maxg; ++i)
	{
		int len = G[i].size();
		if (len == 1)	// 该类没书直接继承上次有书的
		{
			for (int j = m; j >= 1; --j)
				dp[i][j] = dp[i - 1][j];
			continue;
		}
		for (int j = 1; j <= m; ++j)
			for (int k = 1; k <= j && k < len; ++k)
				dp[i][j] = max(dp[i][j], max(dp[i - 1][j], dp[i - 1][j - k] + G[i][k]));
	}
	printf("%lld\n", dp[9][m]);
	return 0;
}


Measured memory_bytes: 3424
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

class AB {
	private Long fA;
	private int fB;

	public AB(Long a, int b) {
		fA = a;
		fB = b;
	}

	public Long getA() {
		return fA;
	}

	public int getB() {
		return fB;
	}

	public void setB(int b) {
		fB = b;
	}
}

class compAB implements Comparator<AB> {
	public int compare(AB ab1, AB ab2) {
		if (ab1.getA() < ab2.getA()) {
			return -1;
		} else if (ab1.getA() > ab2.getA()) {
			return 1;
		} else {
			return 0;
		}
	}
}

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		ArrayList<AB> ABList = new ArrayList<AB>(N);
		for (int i = 0; i < N; i++) {
			Long a = sc.nextLong();
			int b = sc.nextInt();
			ABList.add(new AB(a, b));
		}

		Collections.sort(ABList, new compAB());

		long c = 0;
		int id = 0;
		for (int j = 0; j < M; j++) {
			c += ABList.get(id).getA();
			ABList.get(id).setB(ABList.get(id).getB() - 1);
			if (ABList.get(id).getB() <= 0) {
				id++;
			}
		}

		System.out.println(c);

		sc.close();
	}
}


Measured memory_bytes: 93892
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    string s;cin>>s;
    for(char x:s){
        if(x=='7'){cout<<"Yes";return 0;}
    }
    cout<<"No";
}

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

int main(){
  ll n;
  cin >> n;
  stack<int> q;

  do{
    n--;
    int a = n%26;
    q.push(a);
    n = n/26;
  }while(n != 0);

  while(q.size() > 0){
    cout << char(q.top() + int('a'));
    q.pop();
  }
  cout << endl;
  return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

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

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)



void solve() {
	int n;
	cin>>n;
	vii a;
	int ans=0;
	for(int i=0;i<n;i++){
		int t1,t2;
		cin>>t1>>t2;
		a.push_back(make_pair(t1,t2));
	}
	for(int i=0;i<n;i++){
		if(a[i].first == a[i].second){
			ans++;
		}
		else{
			ans=0;
		}
		if(ans>=3){
		    cout<<"Yes"<<endl;
		    return;
	    }
	}
	cout<<"No"<<endl;
	
	return;

}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

   solve();
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

bool isprime(ll x) {
    for (ll i = 2; i*i <= x; i++) {
        if (x % i == 0) {
            return false;
        }
    }
    return true;
}

void solve(){
    ll X;
    cin >> X;

    while (1) {
        if (isprime(X)) {
            cout << X << endl;
            return;
        }
        X++;
    }

    return;
}

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


Measured memory_bytes: 256
using System;

namespace AtC167
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NMX;
            NMX = Console.ReadLine().Split(' ');
            int N = int.Parse(NMX[0]);
            int M = int.Parse(NMX[1]);
            int X = int.Parse(NMX[2]);

            int[][] A = new int[N][];
            for (int i = 0; i < N; i++)
            {
                string[] CA = Console.ReadLine().Split(' ');
                A[i] = new int[M + 1];
                for (int j = 0; j < M + 1; j++) A[i][j] = int.Parse(CA[j]);

            }

            int ans = 100000000;
            int bitflag = 0;
            int[] flag = new int[13] { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048 , 4096};
            
            while (bitflag < 10000)
            {
                int[] Rikai = new int[M];
                int Money = 0;
                bitflag++;
                for(int i = 0; i < N; i++)
                {
                    if((bitflag & flag[i]) >= 1)
                    {
                        Money += A[i][0];
                        for (int j = 0; j < M; j++) Rikai[j] += A[i][j + 1];
                    }
                }
                bool tmp = false;
                for (int i = 0; i < M; i++)if(Rikai[i] < X) tmp = true;
                if (tmp) continue;
                ans = Math.Min(ans, Money);
            }
            if (ans == 100000000) ans = -1;
            Console.WriteLine(ans);
    
        }
    }
}


Measured memory_bytes: 28224
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  if(N == 3) {
    vector<int> ans = {2, 5, 63};
    REP(i, ans.size()) cout << ans[i] << (i!=ans.size()-1 ? " " : "");
    cout << "\n";
    return 0;
  }
  FOR(i, 2, N-1) {
    if(i%3 != 1 && (N-i)%2 == 0 && i <= 15000 && (N-i) <= 5000) {
      int even = i;
      int odd = N-i;
      vector<int> ans;
      REP(i, even) ans.push_back(2*i+2);
      REP(i, odd) ans.push_back(6*i+3);
      REP(i, ans.size()) cout << ans[i] << (i!=ans.size()-1 ? " " : "");
      cout << "\n";
      return 0;
    }
  }

}

Measured memory_bytes: 640
inf = 0x101010
def solve(start,goal):
	cost = [inf]*n
	visited = [False]*n
	cost[start] = 0
	while 1:
		min = inf
		next = -1
		visited[start] = True
		for i in range(n):
			if visited[i]: continue
			if graph[start][i] > -1:
				d = cost[start] + graph[start][i]
				if d < cost[i]:
					cost[i] = d
			if min > cost[i]:
				min = cost[i]
				next = i
		start = next
		if next == -1: break
	return cost[goal]

n = input()
m = input()
graph = [[-1]*n for i in range(n)]
for i in range(m):
	a,b,c,d = map(int,raw_input().split(","))
	graph[a-1][b-1] = c
	graph[b-1][a-1] = d
x1,x2,y1,y2 = map(int,raw_input().split(","))
print y1-y2-solve(x1-1,x2-1)-solve(x2-1,x1-1)

Measured memory_bytes: 4288
#include<stdio.h>
int main(void){
	int n, last, a[100], i, j, tmp, flag = 1, cnt = 0;
	
	scanf("%d\n", &n);
	last = n-1;
	for(i = 0; i < n; i++){
		if(i == last){
			scanf("%d\n", &a[i]);
			break;
		}
		scanf("%d ", &a[i]);
	}
	while(flag){
		flag = 0;
		for(j = last; j > 0; j--){
			if(a[j-1] > a[j]){
				tmp = a[j-1];
				a[j-1] = a[j];
				a[j] = tmp;
				flag = 1;
				cnt++;
			}
		}
	}
	for(i = 0; i < n; i++){
		if(i == last){
			printf("%d\n", a[i]);
			break;
		}
		printf("%d ", a[i]);
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define sz(a) (ll)(a.size())
#define pll pair<ll,ll>
ll a[100005];
int try1(int i, int n, ll dp[])
{
	if(dp[i]!=-1)
		return dp[i];

	if(i==n-1)
	{
		dp[i]=0;
		return dp[i];
	}
	if(i==n-2)
	{
		dp[i]=abs(a[n-1]-a[n-2]);
		return dp[i];
	}
	dp[i] = min(abs(a[i]-a[i+1])+try1(i+1,n,dp),abs(a[i]-a[i+2])+try1(i+2,n,dp)); 
	return dp[i];
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll i,n;
	cin>>n;
	ll dp[100005];
	for(i=0;i<100005;i++)
		dp[i]=-1;
	for(i=0;i<n;i++)
		cin>>a[i];
	cout<<try1(0,n,dp)<<endl;
	return 0;
}

Measured memory_bytes: 5760
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

int n;
double a[3005],f[3005][3005],ans;

int main(void){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%lf",&a[i]);
	f[0][0]=1.0;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=i;j++){
			int k=i-j;
			if(k==0&&j==0)continue;
			if(j==0)
			f[j][k]=f[j][k-1]*(1-a[i]);
			else
			if(k==0)
			f[j][k]=f[j-1][k]*a[i];
			else 
			f[j][k]=f[j-1][k]*a[i]+f[j][k-1]*(1-a[i]);
		}
	}
	for(int i=0;i*2<=n;i++)
	ans+=f[n-i][i];
	printf("%.10lf",ans);
}

Measured memory_bytes: 70016
#include<stdio.h>

int main(){
		int k,s,i,j,ans=0;
		scanf("%d%d",&k,&s);
		for(i=0;i<=k;i++){
				for(j=0;j<=k;j++){
						if(s-(i+j)<=k&&s-(i+j)>=0){
								ans++;
						}
				}
		}
		printf("%d\n",ans);
		return 0;
}


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

int main() {
  int A,B,C;
  int L;
  cin >> A >> B >> C;
  L = A * B;
  if (L<C){
    cout << L << endl;
  }
  else if(C<L){
    cout << C << endl;
  }
  else {
    cout << C << endl;
  }
}

Measured memory_bytes: 256
from typing import List


def forbidden_list(x: int, p: List[int]) -> int:
    for i in range(len(p)):
        if x - i not in p:
            return x - i
        if x + i not in p:
            return x + i
    return x - len(p)


if __name__ == "__main__":
    X, _ = map(int, input().split())
    p = [int(a) for a in input().split()]

    ans = forbidden_list(X, p)
    print(ans)


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

int main()
{
	string s;

	while (cin >> s && s != "-") {
		int m, h;
		for (cin >> m; m && cin >> h; m--)
			s = s.substr(h) + s.substr(0, h);
		cout << s << endl;
	}

	return 0;
}


Measured memory_bytes: 3164
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		if (S.equals("Sunny")) {
			System.out.println("Cloudy");
		} else if (S.equals("Cloudy")) {
			System.out.println("Rainy");
		} else {
			System.out.println("Sunny");
		}
	}

}


Measured memory_bytes: 23636
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    char[] c = s.toCharArray();
    for(char a:c){
      for(int i = 0;i<n;i++){
        a++;
        if(a==91)a=65;
      }
      System.out.print(a);
    }
    System.out.println("");

  }
}


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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> mp(N);

    rep(i, N) {
        mp[i] = make_pair(0, 0);
    }

    rep(i, M) {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if (s == "AC") {
            mp[p].second = 1;
        }
        else if (s == "WA" && mp[p].second == 0) {
            mp[p].first++;
        }
    }

    int ans = 0;
    int pen = 0;
    rep(i, N) {
        ans += mp[i].second;
        if (mp[i].second == 1) {
            pen += mp[i].first;
        }
    }

    cout << ans << " " << pen << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int counter=0,d=0;
    string s;
    cin>>s;
    if(s[0]=='W')d=1;
    else d=0;
    rep(i,s.length()){
        if(d==0&&s[i]=='W'){
            d=1;
            counter++;
        }
        if(d==1&&s[i]=='B'){
            d=0;
            counter++;
        }
    }
    out(counter);
}

Measured memory_bytes: 3856
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)

int main()
{
  string s;
  cin >> s;
  if (s == "ABC")
    cout << "ARC" << endl;
  else
    cout << "ABC" << endl;
}



Measured memory_bytes: 3596
#include<stdio.h>
#include<string.h>
#define NIL (-1)
#define m 1046527
char T[m][14];
int h1(int key) {return key%m;}
int h2(int key) {return key%(m-1);}


int getChar(char ch){
    if (ch=='A') return 1;
    else if (ch=='C') return 2;
    else if (ch=='G') return 3;
    else if (ch=='T') return 4;
    else return 0;
}

long long getKey(char moji[]){
    long long sum=0,p=1,i;
    for(i=0;i<strlen(moji);i++){
        sum+=p*(getChar(moji[i]));
        p*=5;
    }
    return sum;
}


int search(char moji[]){
    long long key,i,h;
    key=getKey(moji);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%m;
        if(strcmp(T[h],moji)==0) return 1;
        else if(strlen(T[h])==0) return 0;
    }
    return 0;
}

int insert(char moji[]){
    long long key,i,h;
    key=getKey(moji);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%m;
        if(strcmp(T[h],moji)==0) return 1;
        else if(strlen(T[h])==0){
            strcpy(T[h],moji);
            return 0;
        }
    }
    return 0;
}


int main(void){
    int i,n;
    char order[9],moji[14];
     for ( i = 0; i < m; i++ ) T[i][0] = '\0';
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s%s",order,moji);
        if(order[0]=='i') insert(moji);
        else if(search(moji)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


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

int main(){

  double xa,ya,xb,yb,xc,yc,xd,yd;

  while(cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd){

    if(yb - ya == 0 && xd - xc == 0) cout << "YES" << endl;
    else if(xb - xa == 0 && yd - yc == 0) cout << "YES" << endl;
    else if((yb - ya)/(xb - xa) == -((xd - xc)/(yd - yc))) cout << "YES" << endl;
    else cout << "NO" << endl;

  }
}

Measured memory_bytes: 1220
#include <iostream>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <set>
//#include
#include <numeric>
#define pb push_back
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;
void solve(){
    long long n; cin >> n;
    long long i = 1;
    long long su = 0;
    while ( i <= n){
        if (i%3 != 0 &&  i%5 != 0){
            su += i;
        }
        i++;
    }
    cout << su << "\n";
}

// Drive program
int main()
{
    solve();

    return 0;
}



Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
n,q=map(int,input().split())
ki=[[] for _ in range(n)]
ans=[0]*n

def dfs(numQ,parent):
    for child in ki[numQ]:
        if child==parent:
            continue
        ans[child]+=ans[numQ]
        dfs(child,numQ)

for i in range(n-1):
    a,b=map(int,input().split())
    ki[a-1].append(b-1)
    ki[b-1].append(a-1)

for i in range(q):
    p,x=map(int,input().split())
    ans[p-1]+=x

dfs(0,-1)
print(*ans)

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

int main(){
    int w, a, b;
    cin >> w >> a >> b;
    if(a < b){
        if(a + w < b){
            cout << b - (a + w)<< endl;
        }else{
            cout << 0 << endl;
        }
    }else{
        if(b + w < a){
            cout << a - (b + w) << endl;
        }else{
            cout << 0 << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define int long long
int n, a, b, h[123456];
bool f(int k) {
	int r = 0;
	int p = a - b;
	for (int i = 0; i < n; i++) {
		r += max((int)0, (h[i] - (k*b) + (p - 1)) / p);
	}
	return (r <= k);
}
int f1(int l, int r) {
	if (l == r)return l;
	if (l + 1 == r) {
		if (f(r))return r;
		else return l;
	}
	int mid = (l + r) / 2;
	return (f(mid) ? f1(l, mid) : f1(mid, r));
}
signed main() {
	cin >> n >> a >> b;
	int m = 0;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		m = max(h[i], m);
	}
	cout << f1(0, (m + b - 1) / b) << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::vector<lint>a(3*n);
    for(lint&x:a)std::cin>>x;
    std::vector<lint>b(n+1),c(n+1);
    for(lint i=0;i<2;i++){
        lint now=0;
        std::priority_queue<lint,std::vector<lint>,std::greater<>>que;
        for(lint j=0;j<n;j++){
            now+=a.at(j);
            que.push(a.at(j));
        }
        b.at(0)=now;
        for(lint j=0;j<n;j++){
            now+=a.at(n+j);
            que.push(a.at(n+j));
            now-=que.top();que.pop();
            b.at(1+j)=now;
        }
        std::reverse(a.begin(),a.end());
        for(lint&x:a)x=-x;
        b.swap(c);
    }
    lint ans=std::numeric_limits<lint>::min();
    for(lint i=0;i<=n;i++){
        lint now=b.at(i)+c.at(n-i);
        if(ans<now)ans=now;
    }
    std::cout<<ans<<'\n';
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

const int N = 40;
const int LOG = 21;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLMOD = 998244353;
const ll LLINF = 1e18;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int tmp = n;
    int len = 0;
    while (tmp) len++, tmp /= 10;
    if (len % 2) {
        if (len == 1) cout << n << "\n";
        else if (len == 3) cout << n - 100 + 1 + 9 << "\n";
        else if (len == 5) cout << n - 10000 + 1 + 909 << "\n";
    } else {
        if (len == 2) cout << "9\n";
        else if (len == 4) cout << "909\n";
        else if (len == 6) cout << "90909\n";
    }
    return 0;
}

Measured memory_bytes: 256
while(n,m=gets.split.map &:to_i)[0]>0
s=?#*n+?0
m.times{(c=gets[0])<?B?(i=s.index ?#):c<?C?(i=n-1
i-=1 while i>=0&&(s[i]!=?#||s[j=i+1]==?A||s[i-1]==?A)
i<0&&i=j-1):c<?D?(j=0
j+=1 while j<n&&(s[j]==?#||s[i=j+1]!=?#&&s[i=j-1]!=?#)
j>=n&&i=n/2):(w=z=1e20
t=[]
u=[]
(0..n-1).map{|k|s[k]!=?#&&w=0;t<<w+=1;s[n-1-k]!=?#&&z=0;u.unshift z+=1}
v=t.zip(u).map &:min
i=v.index{|k|k==v.max})
s[i]=c}
puts s.chop
end

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

using namespace std;


#define loop(i,a,n)     for(int i=a;i<n;i++)
#define rloop(i,n,a)    for(int i=n;i>=a;i--)
#define all(v)          v.begin(),v.end()
#define all(v)          v.begin(),v.end()
#define p(a)            cout<<a<<" ";
#define check           cout<<"OOOOOF"<<endl;

int main()
{
    string s;
    cin>>s;
    cout<<s;
    if(s[s.size()-1]=='s')cout<<"es"<<endl;
    else cout<<"s"<<endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>            //  IT'S NEVER TOO LATE...
    	using namespace std;
        #include<math.h>
    	#define ll long long
    	#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
        #define forn(i, n) fore(i, 0, n)
        #define fori(i, l, r) fore(i, l, (r) + 1)
        #define sz(v) int((v).size())
        #define all(v) (v).begin(), (v).end()
        #define pb push_back
        #define mp make_pair
        #define ff first
        #define ss second

        const double PI = atan(1)*4;

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

    	
    	vector<int> ar[1000001];
        vector<pair<int,int>> path;
        int vis[1000001],dis[1000001];

        /*void dfs(int node)
        {
            vis[node]=1;

            for(int child : ar[node])
            {
                if(vis[child]==0)
                {
                    dis[child]=dis[node]+1;
                    dfs(child);
                }
            }
        }*/

    /*    void bfs(int i)
        {
            queue<int> q;
            q.push(i);
            vis[i]=1;
            dis[i]=0;

            while(!q.empty())
            {
                int curr=q.front();
                q.pop();

                for(int child : ar[curr])
                    if(vis[child]==0)
                    {
                        q.push(child);
                        dis[child]=dis[curr]+1;
                        vis[child]=1;
                    }
            }
        }*/

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

        bool comp(pair<int,int> a, pair<int,int> b)
        {
            return b.ff < a.ff ;
        }

        int modpow(int b,int p,int m)
        {
            if(p==0) return 1%m;
            if(p%2) return (b*modpow(b,p-1,m))%m;
            int u=modpow(b,p/2,m);
            return (u*u)%m;
        }



    	int main()  
    	{
    		int t=1;
    		//cin>>t;
    		
    		while(t--)
    		{
                int k,l,r,ok=0;
                cin>>k>>l>>r;

                fori(i,l,r)
                {
                    if(i%k == 0)
                        ok=1;
                }

                if(ok)
                    cout<<"OK";
                else
                    cout<<"NG";
            }
            return 0;
    	}

        //              NOW IT'S TIME TO WAKE UP...

Measured memory_bytes: 27080
H,W,D=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(H)]
Q=int(input())
B=[list(map(int,input().split())) for _ in range(Q)]
L,R=zip(*B)
C=[[]for i in range(H*W)]
for i in range(H):
  for j in range(W):
    a=A[i][j]
    C[a-1]=((j+1,i+1))
X=[0]*(H*W+1)
for i in range(D):
  x=H*W-D-i
  count=0
  while x>0:
    count+=abs(C[x-1][0]-C[x+D-1][0])+abs(C[x-1][1]-C[x+D-1][1])
    X[x]+=count
    x-=D
for i in range(Q):
  print(X[L[i]]-X[R[i]])

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

#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define per(i, b, a) for(int i = (b); i >= (a); --i)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define boost ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define M (ll)(1e9+7)
#define inf (ll)(2e9+9)
#define infl (ll)(2e18+9)
#define debug1(a) cout<<#a<<" = " <<a<<endl; 
#define debug2(a,b) cout<<#a<<" = " <<a<<" , "<<#b<<" = "<<b<<endl; 
#define debug3(a,b,c) cout<<#a<<" = " <<a<<" , "<<#b<<" = "<<b<<" , "<<#c<<" = "<<c<<endl; 
#define debug4(a,b,c,d) cout<<#a<<" = " <<a<<" , "<<#b<<" = "<<b<<" , "<<#c<<" = "<<c<<" , "<<#d<<" = " <<d<<endl; 
  
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<char> vc; 
typedef vector<ll> vll; 
typedef vector< pair<int,int> > vpii;

/* -------------------------------------------------------------------------*/
/* -------------------------------------------------------------------------*/

void solve(){
  int h,w; cin>>h>>w; 
  vector<vector<int>> dp(h,vector<int> (w)); 
  vector<vector<char>> g(h,vector<char> (w)); 
  rep(i,0,h-1){
    rep(j,0,w-1){
      cin>>g[i][j]; 
    }
  }
  rep(i,0,h-1){
    rep(j,0,w-1){
      if(i==0 && j==0){
        dp[i][j]=1; 
      }
      else if(i==0 && g[i][j]=='.') dp[i][j]=dp[i][j-1]; 
      else if(j==0 && g[i][j]=='.') dp[i][j]=dp[i-1][j]; 
      else if(i>0 && j>0){
        if(g[i][j]=='.'){
          dp[i][j]=dp[i][j-1]+dp[i-1][j];  
          dp[i][j]%=M; 
        }
      }
    }
  }
  cout<<dp[h-1][w-1]; 
}

int main() {
  clock_t beg=clock(); 
  boost;
  int t=1; 
  // cin>>t; 
  while(t--){
    solve(); 
  }
  clock_t end=clock(); 
  fprintf(stderr, "%lf\n", (double)(end-beg)/CLOCKS_PER_SEC);
}


Measured memory_bytes: 5248
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char c[101][101];//神奇的二维字符数组
int main()
    {
    int a,b;
    cin>>a>>b;//输入矩阵大小
    for(int i=0;i<a;i++)
        for(int j=0;j<b;j++)//嵌套循环输入
        {
        cin>>c[i][j];//输入每个位置上的情况
        }
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++)//循环输出，判断周围是否有雷
            {
            int sum=0;
            if(c[i][j]=='#') cout<<'#';//如果该位置有雷，直接输出‘*’
            else         //判断，周围有雷自+1；
                {
                if(c[i-1][j+1]=='#') sum++;
                if(c[i][j+1]=='#') sum++;
                if(c[i+1][j+1]=='#') sum++;
                if(c[i-1][j]=='#') sum++;
                if(c[i+1][j]=='#') sum++;
                if(c[i-1][j-1]=='#') sum++;
                if(c[i][j-1]=='#') sum++;
                if(c[i+1][j-1]=='#') sum++;
                cout<<sum;//判断完毕后直接输出sum
                }
            }
            cout<<endl;//换行
    }   
    return 0;     
    }


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

int main() {
	unsigned long n, k;
	cin >> n >> k;
	unsigned long ans;
	unsigned long t = n / k;
	ans = t * t * t;
	if (k % 2 == 0) {
		t = n / (k / 2) - t;
		ans += t * t * t;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	static Scanner s = new Scanner(System.in);			//文字の入力

	static int N = s.nextInt();
	static int A = s.nextInt();

	static int count =0;
	static int m =0;								//現在地の表示
	static int hanbetu = 0;


	static int ans = 0;
	public static void main(String[] args){

		solve();

	}


	static void solve() {
		N *= N;
		System.out.println(N - A);
		
	}
		
	}

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

using namespace std;
using ll = long long int;

int main() {
    int H, W;
    cin >> H >> W;
    string field[H];
    for (int h = 0; h < H; h++) {
        cin >> field[h];
    }
    int N = H * W;
    int dest[N][N];
    for (int hf = 0; hf < H; hf++) {
        for (int wf = 0; wf < W; wf++) {
            for (int ht = 0; ht < H; ht++) {
                for (int wt = 0; wt < W; wt++) {
                    int d = abs(hf - ht) + abs(wf - wt);
                    int nt = ht * W + wt;
                    int nf = hf * W + wf;

                    if (field[ht][wt] == '#' or field[hf][wf] == '#') {
                        dest[nf][nt] = -1;
                        dest[nt][nf] = -1;
                    } else if (d == 1) {
                        dest[nf][nt] = 1;
                        dest[nt][nf] = 1;
                    } else if (d == 0) {
                        dest[nf][nt] = 0;
                    } else {
                        dest[nf][nt] = -1;
                        dest[nt][nf] = -1;
                    }
                }
            }
        }
    }

    for (int k = 0; k < 3; k++) {
    for (int nt = 0; nt < N; nt++) {
        for (int nf = 0; nf < N; nf++) {
            for (int n = 0; n < N; n++) {
                if (dest[nf][n] >= 0 and dest[n][nt] >= 0) {
                    if (dest[nf][nt] == -1) {
                        dest[nf][nt] = dest[nf][n] + dest[n][nt];
                    } else {
                        dest[nf][nt] = min(dest[nf][nt],
                                           dest[nf][n] + dest[n][nt]);
                    }
                }
            }
        }
    }}

    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            ans = max(dest[i][j], ans);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 896
#include <stdio.h>

int main(){
  
  int mm,kk,n;
  int m[105][105];
  
  int k[105];
  int i,j,rin,ans1,ans2,p,q;
  
  //  scanf("%d",&n);
  p=0;  q=0;
  while(1){  
    p++;
    ans1=0;
    for(i=0;i<105;i++){
      for(j=0;j<105;j++){
	m[i][j]=0;
      }
    }
    
    for(i=0;i<105;i++)
      k[i]=0;

    ans1=0;//初期化
    scanf("%d",&n);
    if(n==0){
      
      return 0;
    }//終了
    
    
  
    for(i=1;i<n+1;i++){
      scanf("%d",&mm);
  
      for(j=1;j<mm+1;j++){
	scanf("%d",&rin);

	m[i][rin]=1;
      }
    }
  
    scanf("%d",&rin);
    kk=rin;
    for(i=1;i<kk+1;i++){
      scanf("%d",&rin);
      k[rin]=1;}
    
    for(i=1;i<n+1;i++){
      for(j=1;m[i][j]>=k[j]&&j<n+1;j++);
  
      if(j==n+1)
	{  /*printf("--------\n");
	  for(j=1;j<n+1;j++) printf("%d ",m[i][j]);
	  printf("\n");
	  for(j=1;j<n+1;j++) printf("%d ",k[j]);
	  printf("\n--------\n");*/
	  ans1++;
	  ans2=i;
	}
    }

    /* for(i=1;i<n+1;i++){
        printf("\n");
      for(j=1;j<n+1;j++)
		printf("  %d",m[i][j]);
		}*/
    if(ans1==1) printf("%d\n",ans2);
      else printf("-1\n");
    
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int n;
    cin >> n;
    int muscle = 1;
    for(int i = 0; i < n; i++)
    {
    muscle *= (i + 1);
    muscle %= 1000000007;
    }
    
   cout << muscle << endl;
}


Measured memory_bytes: 256
import os

def main():
	n,m = map(int, input().split())
	h_list = list(map(int, input().split()))
	ans = [1]*n
	for i in range(m):
		a,b = map(int, input().split())
		if h_list[a-1] < h_list[b-1]:
			ans[a-1] = 0	
		elif h_list[a-1] == h_list[b-1]:
			ans[a-1] = 0
			ans[b-1] = 0
		else:
			ans[b-1] = 0
	print(sum(ans))			

if __name__ == "__main__":
	main()


Measured memory_bytes: 20128