akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int left = a + b;
  int right = c + d;
  if (left > right) {
     cout << "Left" << endl;
  } else if (left < right) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
  
}

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

int m, d;

int main()
{
	int ans = 0;
	cin >> m >> d;
	for (size_t i = 1; i <= d; i++)
	{
		if ((i > 21) && (i / 10 * (i % 10) <= m) && (i % 10 > 1))
		{
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 888
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int n;
    cin>>n;
    long long x[n];
    for(int i=0;i<n;++i)
    {
        cin>>x[i];
    }
    long long max=-LONG_LONG_MAX;
    long long min=LONG_LONG_MAX;
    for(int i=0;i<n;++i)
    {
        if(x[i]>max) max=x[i];
        if(x[i]<min) min=x[i];
    }
    cout<<abs(max-min);
    return 0;
}


Measured memory_bytes: 1016
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

int f(int n) {
  return (n > 0)? (n%10 + f(n/10)) : 0;
}

signed main()
{
  int N;
  cin >> N;
  if (N % f(N) == 0) {
    puts("Yes");
  } else {
    puts("No");
  }

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

class unionfind {
    vector<int> par, rank;
    int forest_num;
public:
    unionfind(int n) : par(n), rank(n, 1) {
        forest_num = n;
        for (int i = 0; i < n; i++)par[i] = i;
    }
    void init(int n) {
        par.clear(); par.resize(n);
        rank.clear(); rank.resize(n, 1);
        forest_num = n;
        for (int i = 0; i < n; i++)par[i] = i;
    }
    int root(int x) {
        if (par[x] == x)return x;
        return par[x] = root(par[x]);
    }
    int size(int x) {
        if (par[x] == x)return rank[x];
        return size(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)return;
        if (rank[rx] < rank[ry]) {
            par[rx] = ry;
            rank[ry] += rank[rx];
        }
        else {
            par[ry] = rx;
            rank[rx] += rank[ry];
        }
        forest_num--;
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int fnum() {
        return forest_num;
    }
};

int main() {
    init();

    int n, k, l;
    cin >> n >> k >> l;
    unionfind car(n), train(n);
    int s, t;
    FOR(i, 0, k) {
        cin >> s >> t;
        car.unite(--s, --t);
    }
    FOR(i, 0, l) {
        cin >> s >> t;
        train.unite(--s, --t);
    }
    map<pair<int, int>,int> map;
    FOR(i, 0, n)map[{car.root(i), train.root(i)}]++;
    FOR(i, 0, n)cout << map[{car.root(i), train.root(i)}] << (i == n - 1 ? "\n" : " ");
}



Measured memory_bytes: 15104
import itertools
n=int(input())
keta=len(str(n))
ans=0
for k in range(1,keta+1):
  for c in itertools.product(range(3),repeat=k):
    nn=""
    flag3,flag5,flag7=0,0,0
    for i in range(k):
      if c[i]==0:
        nn+="3"
        flag3=1
      elif c[i]==1:
        nn+="5"
        flag5=1
      else:
        nn+="7"
        flag7=1
    if flag3*flag5*flag7==1 and int(nn)<=n:
      ans+=1
print(ans)

Measured memory_bytes: 3064
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;
 
import static java.util.Comparator.*;
 
public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==================================================================
    public void solve() {
    	int N = Integer.parseInt(sc.next());
    	int a, cnt = 1, ans = 0;
    	for (int i = 0; i < N; i++) {
			a = Integer.parseInt(sc.next());
			if(a == cnt) {
				cnt++;
				continue;
			}
			ans++;
		}
    	if(cnt == 1)	out.println(-1);
    	else			out.println(ans);
    }
}

Measured memory_bytes: 51144
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

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 FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 4999999999999999999
#define ALL(n) n.begin(),n.end()


ll N, K, s[114514],ans = INF64;
int main(){
	cin >> N >> K;
	REP(i, N) cin >> s[i];
	REP(i, N - K + 1) {
		ll a;
		if (K == 1)a = abs(s[i]);
		else {
			bool x = false, y = false;
			if (s[i] > 0)x = true;
			if (s[i + K - 1] > 0)y = true;
			if (x == y)a = max(abs(s[i]), abs(s[i + K - 1]));
			else {
				a = abs(s[i]) + abs(s[i + K - 1]);
				a += min(abs(s[i]), abs(s[i + K - 1]));
			}
		}
		ans = min(a, ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <vector>
#include <algorithm>

template <class Tp>
Tp& chmin(Tp& dst, const Tp& src) {
  if (src < dst) dst = src;
  return dst;
}

template <class Tp>
Tp& chmax(Tp& dst, const Tp& src) {
  if (dst < src) dst = src;
  return dst;
}

int main() {
  size_t N;
  int Ma, Mb;
  scanf("%zu %d %d", &N, &Ma, &Mb);

  std::vector<int> a(N), b(N), c(N);
  for (size_t i = 0; i < N; ++i)
    scanf("%d %d %d", &a[i], &b[i], &c[i]);

  int INF = 1e9;
  int M = 400;
  std::vector<std::vector<std::vector<int>>> dp(
      N+1, std::vector<std::vector<int>>(
        M+1, std::vector<int>(M+1, INF)));

  dp[0][0][0] = 0;
  for (size_t i = 1; i <= N; ++i) {
    for (int j = 0; j <= M; ++j)
      for (int k = 0; k <= M; ++k) {
        dp[i][j][k] = std::min(dp[i][j][k], dp[i-1][j][k]);
        if (a[i-1] <= j && b[i-1] <= k)
          chmin(dp[i][j][k], dp[i-1][j-a[i-1]][k-b[i-1]]+c[i-1]);
      }
  }

  int res = INF;
  for (int j = 1; j <= M; ++j)
    for (int k = 1; k <= M; ++k)
      if (j*Mb == k*Ma)
        chmin(res, dp[N][j][k]);

  if (res == INF) return puts("-1"), 0;
  printf("%d\n", res);
}


Measured memory_bytes: 29312
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl;
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main()
{
    ll h,ans = 0;
    cin >> h;
    for (ll i = 0; h > 0; ++i) {
        h /= 2;
        ans += pow(2, i);
    }
    pf(ans)
    return 0;
}


Measured memory_bytes: 512
// inputに入力データ全体が入る
function Main(input) {
	input = input.split("\n");
	var a = parseInt(input[0], 10);
	var arr = input[1].split(" ");

       returner = 0;

       for(var i=0; i<arr.length; i++){
          returner += 1/arr[i];
       }

	console.log( 1/returner );
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21192
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for (auto &it : t) cout << it << " ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

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

void solve(){
    int w, h;
    while (cin >> w >> h, w && h){
		int g[h][w];
		bool visited[h][w];
		for (int i = 0; i < h; i++){
		  for (int j = 0; j < w; j++){
			  cin >> g[i][j]; 
			}	
		}
	  memset(visited, false, sizeof visited);
	  int ret = 0;
	  for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			if (g[i][j] == 1 && !visited[i][j]){
			  ret++;
			  queue< pair<int, int> > q;
			  q.push({i, j});
			  while (!q.empty()){
				 auto p = q.front();
				 q.pop();
				 int ny = p.f, nx = p.s;
				 for (int k = 0; k < 8; k++){
					 int X = nx + dx[k];
					 int Y = ny + dy[k];
					 if (X >= 0 && Y >= 0 && X < w && Y < h){
					  if (g[Y][X] == 1 && !visited[Y][X]){
						   visited[Y][X] = true;
						   q.push({Y, X}); 
						 }	 
					  } 
				   }  
				}	
			 }
		  } 
		}
	 cout << ret << endl;	
	}
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}




Measured memory_bytes: 3212
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1LL<<59)
 
#define int ll
 
signed main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    
    if(k<=1){
        cout<<0<<endl;
        return 0;
    }
    
    int ans = INF;
    for(int i=0;i<1<<n;i++){
        vector<int> v(n);
        int num = i;
        int c=0;
        rep(j,n){
            v[j] = num%2;
            num/=2;
            if(v[j]==1)c++;
        }
        if(c<k)continue;
        if(v[0]==0)continue;
        
        int tmp = 0;
        int now = -1;
        rep(j,v.size()){
            if(v[j]==0){
now = max(now,a[j]);
continue;
}
            if(a[j]<=now){
                tmp+=now-a[j]+1;
                now = now+1;
            }else{
                now = a[j];
            }
        }
        ans = min(ans,tmp);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
n = int(input())
ns = list(map(int, input().split()))
dp = [[0] * n for i in range(n)]
cur = [0]
cnt = 0
for i in ns:
    cnt += i
    cur.append(cnt)

for i in range(n-1, -1, -1):
    for j in range(i + 1, n):
        dp[i][j] = min(dp[i][k] + dp[k + 1][j] for k in range(i, j)) + cur[j+1] - cur[i]
print(dp[0][-1])

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

int main() {
  int A, B, N;
  1 <= N <= 20;
  1 <= A <= 100;
  1 <= B <= 2000;
  
  cin >> N >> A >> B ;

  if ( N*A >= B ) {
    cout << B << endl;
  }
  else if ( N*A < B ) {
    cout << N*A << endl;
  }
}


Measured memory_bytes: 256
package main
import (
  "fmt"
)
func main() {
  var s, t string
  fmt.Scan(&s, &t)
  result := "No"
  for startIndex := 0; startIndex < len(s); startIndex++ {
    isSame := true
    for i := 0; i < len(s); i++ {
      if s[(startIndex+i)%len(s)] != t[i] {
        isSame = false
      }
      if !isSame {
        break
      }
    }
    if isSame {
      result = "Yes"
      break
    }
  }
  fmt.Println(result)
}

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

namespace B_016_45
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            //new Logic_A().Start();
            new Logic_B().Start();
            Console.ReadLine();
        }

        public class Logic_B
        {
            public void Start()
            {
                var A = Console.ReadLine();
                var B = Console.ReadLine();
                var C = Console.ReadLine();
                var Aindex = 0;
                var Bindex = 0;
                var Cindex = 0;
                var turnNum = Math.Max(Math.Max(A.Length, B.Length), C.Length);
                var winner = string.Empty;
                var card = 'a';
                for (int i = 0; i <= turnNum * 3; i++)
                {
                    //Console.Write(card.ToString() + " ");

                    if (card == 'a' && Aindex == A.Length)
                    {
                        winner = "A";
                        break;
                    }
                    else if (card == 'b' && Bindex == B.Length)
                    {
                        winner = "B";
                        break;
                    }
                    else if (card == 'c' && Cindex == C.Length)
                    {
                        winner = "C";
                        break;
                    }
                    switch (card)
                    {
                        case 'a': card = A[Aindex]; Aindex++; break;
                        case 'b': card = B[Bindex]; Bindex++; break;
                        case 'c': card = C[Cindex]; Cindex++; break;
                        default: break;
                    }
                }
                Console.WriteLine(winner);
            }
        }

    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<deque>
using namespace std;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	int ans=min(a+b,min(b+c,c+a));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define I_O		ios::sync_with_stdio(false),cin.tie(0)
#define ll		long long
#define ff		first
#define ss		second
#define mod 		1000000007
#define rep(i,n)	for(int i=1;i<=n;i++)
#define repv(i,a,n)	for(int i=a;i<=n;i++)
#define pb 		push_back
#define newl		'\n'
int main()
{
	I_O;
	int n,m;	cin>>n>>m;
	cout<<(n*m);
	
}


Measured memory_bytes: 3636
x = list(map(int,input().split(" ")))
a = x[0]
b = x[1]
m = x[2]
a_list = list(map(int,input().split(" ")))
b_list = list(map(int,input().split(" ")))
x_list =[]
money_list = []
for i in range(m):
    xi_list = []
for i in range(m):
    xi = list(map(int,input().split(" ")))
    x_list.append(xi)
    money = a_list[xi[0]-1]+b_list[xi[1]-1]-xi[2]
    money_list.append(money)
    # print(money_list)
money_list.append(min(a_list)+min(b_list))
# print(money_list)
print(min(money_list))

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

class Main {

	void solve() {
		
		out.println((inint()-1) * (inint()-1));
		
	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}
	
	public String instr() {
		return in.next();
	}

	public char inchar() {
		return in.next().charAt(0);
	}
	
	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define speed                                                                  \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define oprecision                                                             \
  cout.precision(30);                                                          \
  cerr.precision(7);
#define bb bool
#define ii int
#define ll long long
#define ff float
#define dd double
#define cc char
#define ss string
#define forn(sz) for (int i = 1; i <= sz; i++)
#define forni(i, sz) for (int i = 1; i <= sz; i++)
#define fornid(i, m, sz) for (int i = m; i <= sz; i++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vii vector<ii>
#define vii64 vector<ll>
#define vb vector<bb>
using namespace std;
ii a, b, c;
ii main() {
  speed;
  oprecision;
  /*#ifndef ONLINE_JUDGE
    freopen("outd.txt", "rt", stdin);
  #endif*/
  // code
  cin >> a >> b >> c;
  cout << (c + b - a <= 0 ? 0 : c + b - a);
  // endl
#ifndef ONLINE_JUDGE
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#define forn(i, n) for (long long i = 0; i < (long long) (n); ++i)
#define pb emplace_back
#define endl '\n'

template<typename T> void _dbg(const char*_s,T _h) { cerr<<_s<<" = "<<_h<<"\n"; }

template<typename T, typename... Ts> void _dbg(const char*_s,T _h,Ts... _t) {
    for(int _b=0;((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',';)cerr<<*_s++;
    cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);
}

#define int long long

#ifdef LOCAL
    #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
    #define dbg(...)
#endif

const int N = 500 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n, k;
int res[N];

bool read() {
    if (!(cin >> n >> k))
        return false;

    return true;
}

int bp(int a, int b) {
    int res = 1;

    for (; b > 0; b /= 2, a = (a * a) % MOD)
        if (b & 1)
            (res *= a) %= MOD;

    return res;
}

void solve(int id = 0) {
    int ans = 0;

    for (int g = k; g >= 1; --g) {
        int nn = k / g;
        res[g] = bp(nn, n);

        for (int t = 2; t * g <= k; ++t) {
            res[g] -= res[t * g];

            if (res[g] < 0)
                res[g] += MOD;
        }

        ans += (res[g] * g) % MOD;

        if (ans >= MOD)
            ans -= MOD;
    }

    cout << ans << endl;
}

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

    int T;
    T = 1;

    while (read())
        solve(T++);

    return 0;
}



Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, a1, a2, a3, a4, a5, I;
  int j=0;
  cin >> A >> B;
  for (int i = A; i <= B; i++) {
    I = i;
    a1 = I/10000;
    I -= 10000*(a1);
    a2 = I/1000;
    I -= 1000*(a2);
    a3 = I/100;
    I -= 100*(a3);
    a4 = I/10;
    I -= 10*(a4);
    a5 = I;
      
    if (a1==a5 && a2==a4) {
      j++;
    }
  }
  cout << j << endl;
}

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

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

C = []
for i in range(n-1):
    C.append(A[i+1]-A[i])
n -= 1
A=C[:]

mod  =10**9+7

B = [0] * (n+1)


l=n+5
M = [1]  # i!のmod
m = 1
for i in range(1, l):
    m = (m * i) % mod
    M.append(m)

def inv(x, y):  # xのmod yでの逆元を返す関数
    yy = y - 2
    ans = 1
    while yy > 0:
        if yy % 2 == 1:
            ans = (ans * x) % y
        x = (x**2) % y
        yy //= 2
    return ans

for i in range(1, n+1):
    B[i] = (inv(i,mod) * M[n-1]) % mod


p=M[n]
ans = p*A[0]
for i in range(1, n):
    
    p = (p + M[n-1] + B[i+1]*(n-1-i)) % mod
    # print("p",p)
    ans = (ans+p*A[i]) % mod
print(ans%mod)

Measured memory_bytes: 66584
#include <bits/stdc++.h>
using namespace std;
/*
3 1 4 1 5 9 2
1 1 2 3 4 5 9 
*/
int main() {
  int N; cin >> N;
  int bottom = 100000000 , up = 0;
  vector<int> backet(100001,0);
  for(int i = 0; i < N; i++){
    int a; cin >> a;
    backet.at(a)++;
    bottom = min(bottom,a);
    up = max(up,a);
  }
  
  int ans = 0;
  for(int X = bottom; X <= up; X++){
    int local_ans;
    local_ans = backet.at(X);
    if(X-1 > 0) local_ans += backet.at(X-1);
    if(X+1 < backet.size()) local_ans += backet.at(X+1);
    ans = max(ans,local_ans);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
using namespace std;
int N;
long long x;
int ary[110];
int main(){
	scanf("%d%lld",&N,&x);
	for(int i=0;i<N;i++){
		scanf("%d",&ary[i]);
	}
	sort(ary,ary+N);
	long long sum=0;
	int i=0;
	for(i;i<N;i++){
		if(ary[i]+sum<=x){
			sum+=ary[i];
		}else{
			break;
		}
	}
	if(i==N&&sum<x){
		i--;
	}
	printf("%d",i);
	return 0;
	
}

Measured memory_bytes: 128
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;
int maxi = 0;
int arr[51][5];
int n,m,q;
vector<int> vec;

void generate(int pos)
{
	if(pos == n+1)
	{		
		int sum = 0;
		for(int i = 0;i<q;i++)
		{
			int ai = arr[i][0] , bi = arr[i][1] , ci = arr[i][2] , di = arr[i][3];
			if((vec[bi] - vec[ai]) == ci)
			{  
				sum+=di;
			}
		}	
		
		maxi = max(maxi , sum);
		return;	
	}	
	
	for(int i = vec[pos-1];i<=m;i++)
	{
		vec.push_back(i);
		generate(pos+1);
		vec.pop_back();
	}
}

int main()
{	
	cin>>n>>m>>q;
	
	for(int i = 0;i<q;i++)
	{
		cin>>arr[i][0]>>arr[i][1]>>arr[i][2]>>arr[i][3];	
	}	
	
	vec.push_back(1);
	
	generate(1);
	
	cout<<maxi<<endl;
	
	return 0;
}

Measured memory_bytes: 3508
S = list(map(str, input()))
S_tmp = []
sum_all = 0
sum_tmp = []

for i in range(len(S)*2-1):
    if i % 2 == 0:
        S_tmp.append(S[int(i/2)])
    
    else:
        S_tmp.append(" ")

def bubunwa1(i, S_tmp, sum_all):
    if i < len(S)-1:
        S_tmp[2*i + 1] = '+'
        bubunwa1(i+1, S_tmp, sum_all)

        S_tmp[2*i + 1] = ''
        bubunwa1(i+1, S_tmp, sum_all)

    elif i == len(S)-1:
        sum_all = eval(''.join(S_tmp).replace(' ', ''))
        sum_tmp.append(sum_all)

bubunwa1(0, S_tmp, sum_all)
print(sum(sum_tmp))

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

string s="ATCG";
string S;

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

  cin>>S;
  int n=S.size();

  int res=0;
  rep(i,n){
    repl(j,i,n){
      bool ok=false;
      rep(k,4){
        if(S[j]==s[k])ok=true;
      }
      if(ok)maxch(res,j-i+1);
      else break;
    }
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
n=int(input())
h = list(map(int,input().split()))

import numpy as np

h = np.array(h)

cnt =1
for i in range(1,n):
    
    flg=0
    for j in range(i):

        if h[j]>h[i]:
            flg+=1

    if flg==0:
        cnt+=1


print(cnt)        



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

int main(){
  
  int n;
  int count = 1;
  scanf("%d",&n);

  char S[n][11];
  
  for(int i=0; i<n; i++){
    scanf("%s",S[i]);
  }
  qsort(S,n,11,strcmp);

  for(int i=1; i<n; i++){
    if(strcmp(S[i-1],S[i])<0){
      count ++;
    }
  }

  printf("%d",count);

  return 0;
}

Measured memory_bytes: 5744
import java.io.*;
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
  
  public static void main(String[] args){
    
    try {
      
      //local変数
      String jadge = "Yes";
      int    atack = 0;
      
      //標準入力受け取り
      Scanner scan            = new Scanner(System.in);
      ArrayList<Integer> strs = new ArrayList<Integer>();
      
      while (scan.hasNext()){
      	strs.add(scan.nextInt());
      }
      
      for (int i=2; i<strs.size(); i++) {
      	atack += strs.get(i);
      }
      
      if (strs.get(0) > atack) {
      	jadge = "No";
      }

      System.out.println(jadge);
      
    } catch (Exception e) {
      
      System.out.println("error");

    }
  }
}


Measured memory_bytes: 60060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> pint;
#define rep(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

int m[10][10];
int main(){
	int x,y,size;
	for(;~scanf("%d,%d,%d",&x,&y,&size);){
		m[x][y]++;
		x<9&&m[x+1][y]++;
		y<9&&m[x][y+1]++;
		x>0&&m[x-1][y]++;
		y>0&&m[x][y-1]++;
		if(size>=2){
			x<9&&y<9&&m[x+1][y+1]++;
			x<9&&y>0&&m[x+1][y-1]++;
			x>0&&y<9&&m[x-1][y+1]++;
			y>0&&y>0&&m[x-1][y-1]++;
		}
		if(size==3){
			x<8&&m[x+2][y]++;
			y<8&&m[x][y+2]++;
			x>1&&m[x-2][y]++;
			y>1&&m[x][y-2]++;
		}
	}
	int mx=0,k=0;
	rep(i,10){
		rep(j,10){
			mx=max(mx,m[i][j]);
			if(!m[i][j])k++;
		}
	}
	cout<<k<<endl<<mx<<endl;
	return 0;
}

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

int main(){
    int a, b, c,d ;
    cin >> a;
    b = a / 100;
    c = a / 10 - 10 * b;
    d = a - 10 * c - 100 * b;
    cout << b + c + d;
}

Measured memory_bytes: 256
from operator import itemgetter
n, *AB = map(int, open(0).read().split())
A, B = AB[::2], AB[1::2]
AB = sorted([(a, b) for a, b in zip(A, B)], key=sum, reverse=1)
print(sum(map(itemgetter(0), AB[::2])) - sum(map(itemgetter(1), AB[1::2])))

Measured memory_bytes: 25820
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;
    string s;
    cin >> a;
    cin >> s;
    if(a>=3200){
        cout << s << endl;
    }else{
        cout << "red\n";
    }

    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
S = gets.chomp
r = S.count("R")
g = S.count("G")
b = N - r - g
ans = r * b * g
(N - 2).times do |i|
    t = 1
    while i + 2 * t < N do
        if S[i] != S[i + t] && S[i] != S[i + 2 * t] && S[i + 2 * t] != S[i + t]
            ans -= 1
        end
        t += 1
    end
end

puts ans

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

using namespace std;

int main() {
	int H, W, ans = 0;
	char s[50][50];

	cin >> H >> W;

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> s[i][j];
		}
	}

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (s[i][j] == '#' && s[i][j - 1] == '.' && s[i][j + 1] == '.' && s[i - 1][j] == '.' && s[i + 1][j] == '.') {
				ans++;
			}
		}
	}

	if (ans == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

pair<int, char> a,b,c;

void input(){
    int x, y, z;
    cin >> x >> y >> z;
    a.first = x;
    b.first = y;
    c.first = z;
    a.second = 'A';
    b.second = 'B';
    c.second = 'C';
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    vector<pair<int, char>> abc = {a, b, c};
    std::sort(abc.begin(), abc.end(), [](const auto& a, const auto& b){return a.first > b.first;});
    cout << abc[0].second << endl;
    return 0;
}


Measured memory_bytes: 3136
/*Code by Codercjh*/
#include<bits/stdc++.h>
#define fr(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,a,b) for(int i=(a);i>=(b);--i)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
typedef long long ll;
template<typename T>
inline void read(T &x){
	char c=getchar();T fh=0;bool f=false;
	while(!isdigit(c))f|=(c=='-'),c=getchar();
	while(isdigit(c))fh=(fh<<1)+(fh<<3)+(c^48),c=getchar();
	x=f?-fh:fh;
	return;
}
int n,m,a;
int main(){
    read(n),read(m);
    fr(i,1,m)read(a),n-=a;
    cout<<max(n,-1)<<endl;
	return 0;
}


Measured memory_bytes: 3636
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

# Kを二進数表記する
# Kでbit=1の桁でbit orを0にすると，それ以下の桁は何でもよい

N,K = LI()
A0,B0 = LIR(N,2)

A = []
B = []
for i in range(N):
    if A0[i] <= K:
        A.append(A0[i])
        B.append(B0[i])

Ks = format(K,'b')
L = len(Ks)
last_zero = -1
for i in range(L)[::-1]:
    if Ks[i] == '0':
        last_zero = i
        break

if last_zero == -1:
    print(sum(B))
else:
    zeros = []
    must_zero = []
    for i,s in enumerate(Ks):
        if s == '1':
            must_zero.append(zeros+[i])
        else:
            zeros.append(i)
            if i == last_zero:
                must_zero.append(zeros)
                break
    ans = 0
    for zl in must_zero:
        temp = 0
        for a,b in zip(A,B):
            flag = False
            for i in zl:
                if a & 1<<(L-i-1) != 0:
                    flag = True
                    break
            if not flag:
                temp += b
        if temp > ans:
            ans = temp
    print(ans)

Measured memory_bytes: 78696
/* In the name of Allah */

#include<bits/stdc++.h>

using namespace std;

int main(){
	
	long long sum = 0, b;
	int n, k;
	cin >> n >> k;
	int arr[n + 1];
	for(int i = 0; i < n; i++){
		cin >> arr[i];
	}
	sort(arr, arr + n);
	for(int i = 0; i < k; i++){
		sum += arr[i];
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 3600
n = int(input())
k = int(input())
num = 1

def plus(num, k):
    return num + k

def double(num):
    return num * 2

for i in range(n):
    if plus(num, k) < double(num):
        num = plus(num, k)
    else:
        num = double(num)
print(num)


Measured memory_bytes: 3060
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun bsCondOpCl(A: LongArray, L: Int, R: Int, C: Int, K: Int): Int {
    val N = A.size
    fun isCondition(A: LongArray, m: Int): Boolean {
        var cnt = 1
        var i = 0
        var sum = 0
        var nt = A[0] + K
        while (i < N) {
            if (sum >= C || A[i] > nt) {
                cnt++
                sum = 0
                nt = A[i] + K
            }

            if (cnt > m) return false

            if (sum < C && A[i] <= nt) {
                sum++
                i++
            }
        }
        return true
    }
    var l = L; var r = R
    while (l+1 < r) {
        val m = (l + r) / 2
        if (isCondition(A, m)) {
            r = m
        } else {
            l = m
        }
    }
    return r
}


fun solve() {
    val (N, C, K) = rd.readIntArray()
    val T = LongArray(N)
    for (i in 0 until N) {
        T[i] = rd.readLong()
    }
    T.sort()

    val ans = bsCondOpCl(T, 0, N, C, K)
    println(ans)
}


//val rd = debug.Reader("agc", "011", "a", "sample-2")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


Measured memory_bytes: 52508
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n; cin >> n;
    int count = 0;
    int minnum = INF;
    ll ans = 0;
    rep(i,n){
        int num; cin >> num;
        if(num<0) count++;
        minnum = min(minnum,abs(num));
        ans += abs(num);
    }
    if(count%2==0) cout << ans << endl;
    else cout << ans - minnum*2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
const ll mod=1e9+7;
int main(void){
    ll n;cin>>n;
    vector<ll> a(n),b(n);
    rep(i,n){
        cin>>a[i];
        b[n-i-1]=a[i];
    }
    
    rep(i,n-1){
        b[i+1]+=b[i];
        b[i+1]%=mod;
    }
    reverse(b.begin(),b.end());
    ll res=0;
    rep(i,n-1){
        res+=((a[i]*b[i+1])%mod);
        res%=mod;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 6316
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){

    string S;
    cin >> S;

    int i, num = 0, ans = 10000;

    for(i = 0; i < S.size() - 2; i++){
        num = (int)(S[i] - '0') * 100 + (int)(S[i + 1] - '0') * 10 + (int)(S[i + 2] - '0');
        int tmp = (int)abs(num - 753);
        ans = min(ans, tmp);
    }

    cout << ans << endl;
    return 0;

}



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

int main()
{
    while (true)
    {
        int h, w;
        scanf("%d %d", &h, &w);
        if (h == 0 && w == 0)
            break;

        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> nums(n);
  for (int i = 0; i < m; i++)
    cin >> nums.at(i);

  int sum = accumulate(nums.begin(), nums.end(), 0);

  int r;
  if (n - sum >= 0) {
    r = n - sum;
  }
  else {
    r = -1;
  }

  cout << r << endl;
}


Measured memory_bytes: 7144
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(ll i=a;i<b;i++)
#define rFor(i,a,b) for(ll i=a;i>b;i--)
#define wFor(i,a,b) for(ll i=a;i<b;i+=2)
#define wrFor(i,a,b) for(ll i=a;i>b;i-=2)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//(char-'0') 数字に変換
//vector<vector<int>> data(a,vector<int>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  ll a,b,c;
  ci(a>>b>>c);
  ll d=max({a,b,c});
  co(a*b*c/2/d);
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;

#define pf(n) cout << n << endl
#define ps() cout <<" ";
#define sf(n) cin >> n
#define in(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define vp vector<pair<int, int>>
#define graph vector< vector<int> >
#define vs vector<string>
/**  '' "\n" ^ **/


typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
int INF=1e9+7;
int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int n,m;
    sf(n);sf(m);
    vector<string> a(n);
    in(i,n)
    {
        sf(a[i]);
    }
    int dp[n][m];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
            dp[i][j]=0;
    }
    dp[0][0]=1;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(a[i][j]=='#'){
                    dp[i][j]=0;
                    continue;
            }
            if(i-1>=0)dp[i][j]=dp[i-1][j]%INF;
            if(j-1>=0)dp[i][j]=(dp[i][j]+(dp[i][j-1]%INF))%INF;
        }
    }
    /*in(i,n)
    {
        in(j,m)
        {
            cout<<dp[i][j];ps();
        }
        cout<<endl;
    }*/
    cout<<dp[n-1][m-1]<<endl;
}


Measured memory_bytes: 5248
function Main(input) {
  const numbers = input.split(' ').map(n => Number(n));
  const x = numbers[0];
  const a = numbers[1];
  const b = numbers[2];

  if(a >= b) {
    console.log('delicious');
  } else if(b - a <= x) {
    console.log('safe');
  } else {
    console.log('dangerous');
  }
}

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

Measured memory_bytes: 11468
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


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

const ll INF = 1e17;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)




int main() {
    string s;
    cin >> s;
    
    int n = 0;
    REP(i, 3){
        if(s[i] == 'o')n++;
    }
    
    cout << 700 + 100 * n << endl;
}

Measured memory_bytes: 256
#include<iostream>

int main() {
    int i,A[2];
    for (i = 0; i < 3; i++) {
      std::cin >> A[i];
    }

    long long max = A[0],min = A[0];
    for (i = 0; i < 3; i++) {
      if (max < A[i]) {
        max = A[i];
      }
      if (min > A[i]) {
        min = A[i];
      }
    }
    std::cout << max - min;
  return 0;
}


Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i).sort

a = A
b = [a.pop]

M.times do
  b.unshift((!a.empty? && a.last >= b.last ? a.pop : b.pop) / 2)
end

puts (a + b).inject(:+)


Measured memory_bytes: 10608
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

ll find(ll x){
    return x*x*x*x*x;
}

int main(){
    vector<ll> p5;
    forn(i,300){
        p5.push_back(find(i));
    }
    ll x;
    cin>>x;
    fore(i,0,300){
        fore(j,i,300){
            if(p5[j] - p5[i]==x){
                cout<<j<<" "<<i<<endl;
                return 0;
            }else if(p5[j]+p5[i]==x){
                cout<<j<<" "<<-i<<endl;
                return 0;
            }
        }
    }
    return 0;

}

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

int main(){
    int A,B,C;
    int D,ans = 0;
    int sum = 0;
    cin >> A >> B >> C;
    ans = A + B;
    if(ans >= C){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
h, w = map(int, input().split())
ans = []
for _ in range(h):
    data = [i for i in input()]
    cnt = 1
    for i in range(w-1):
        if (data[i] == "c" and data[i+1] == ".") or (type(data[i]) == int and data[i+1] == "."):
            data[i+1] = cnt
            cnt += 1
        else:
            cnt = 1

    data = ["-1" if d == "." else d for d in data]
    data = ["0" if d == "c" else d for d in data]
    data = list(map(str, data))
    print(*data)


Measured memory_bytes: 5632
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>

using namespace std;

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

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) (((n%m) + m)%m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'

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

	string x, y;
	cin >> x >> y;
	
	int cnt = 0;
	rep(i, 0, sz(x))
		 if (x[i] == y[i])
			 cnt++;
	
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int ABC=26;
const int maxn=2e5+2;
const int maxm=1<<ABC;
const int INF=0x3f3f3f3f;
int len,bit=0;
char str[maxn];
int dp[maxm];
int change(char ch){return ch-'a';}
void DP(){
	dp[0]=0;
	for (int i=1;i<(1<<ABC);i++) dp[i]=INF;
	for (int i=1;i<=len;i++){
		bit^=(1<<(str[i]-'a'));
		for (int j=0;j<26;j++) dp[bit]=min(dp[bit],dp[bit^(1<<j)]+1);
	}
}
int main(){
	scanf("%s",str+1);
	len=strlen(str+1);
	DP();
	printf("%d",max(1,dp[bit]));
	return 0;
}

Measured memory_bytes: 262528