akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        x: usize,
    };
    let mut count = 0;
    for s in 0..=a {
        for t in 0..=b {
            for u in 0..=c {
                if 500 * s + 100 * t + 50 * u == x {
                    count += 1;
                }
            }
        }
    }
    println!("{}", count);
}


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

long long DP[100007][2];
int neg,n;
long long arr[100005],sum,mini;

long long f(int x, int y){
	if(x>=n){
		if(y==1)return -arr[x];
		else return arr[x];
	}
	
	if(DP[x][y]!=-1000000000000000LL) return DP[x][y];
	
	if(y==1){
		return DP[x][y] = max(arr[x]*(-1LL)+f(x+1,0),arr[x]+f(x+1,1));
	} else{
		return DP[x][y] = max(arr[x]+f(x+1,0),arr[x]*(-1LL)+f(x+1,1));
	}
}



int main(){
	scanf("%d",&n);
	mini = 1000000000;
	for(int i =1;i<=n;i++){
		scanf("%lld",&arr[i]);
//		sum+=abs(arr[i]);
//		mini = min(abs(arr[i]),mini);
//		if(arr[i]<0) neg++;
	}
	for(int i =0;i<=100005;i++){
		DP[i][0] = DP[i][1] = -1000000000000000LL;
	}
	long long ans = f(1,0);

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

	return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

#define sz(x) int(x.size())

int main() {
  string s, t;
  cin >> s >> t;
  vector<vector<int> > is(26);

  int n = sz(s);
  int m = sz(t);
  for (int i = 0; i < n; i++) {
    is[s[i] - 'a'].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    is[s[i] - 'a'].push_back(i + n);
  }

  ll ans = 0;
  int p = 0;
  for (int i = 0; i < m; i++) {
    int c = t[i] - 'a';
    if (sz(is[c]) == 0) {
      puts("-1");
      return 0;
    }
    p = *lower_bound(is[c].begin(), is[c].end(), p)+1;
    if (p >= n) {
      p -= n;
      ans += n;
    }
  }
  ans += p;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1724
from copy import deepcopy

N, M = map(int, input().split())

INF = 10000000
D = [[INF for _ in range(N)] for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    D[a-1][b-1] = c
    D[b-1][a-1] = c

F = deepcopy(D)
for k in range(N):
    for i in range(N):
        for j in range(N):
            F[i][j] = min(F[i][j], F[i][k]+F[k][j])
a = 0
for i in range(N):
    for j in range(N):
        if D[i][j] == F[i][j]:
            a += 1
a //= 2
print(M-a)


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

int main() {
  string S; cin >> S;
  int N = S.size();
  string T = S;
  reverse(T.begin(), T.end());
  for (int i = 0; i < N; i++) {
    if (S.at(i) != T.at(i)) {
      cout << "No" << endl;
      return 0;
    }
  }

  int L = (N-1) / 2;
  int R = (N+3) / 2;
  string X = S.substr(0, L);
  string Y = S.substr(R-1);
  string XX = X;
  reverse(XX.begin(), XX.end());
  for (int i = 0; i < X.size(); i++) {
    if (X.at(i) != XX.at(i)) {
      cout << "No" << endl;
      return 0;
    }
  }

  string YY = Y;
  reverse(YY.begin(), YY.end());
  for (int i = 0; i < Y.size(); i++) {
    if (Y.at(i) != YY.at(i)) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        
        Scanner scan = new Scanner(System.in);

        String[] str = (scan.nextLine()).split(" ");
        String res = str[0].substring(0, 1) + str[1].substring(0, 1) + str[2].substring(0, 1);

        System.out.println(res);
        scan.close();

        
    }


}

Measured memory_bytes: 22996
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    String N = sc.next();
    char Taps[]=new char[N.length()];
    boolean M=false;
    
    for(int i=0;i<N.length();i++){
    	Taps[i]=N.charAt(i);
    }
   for(int i=0;i<N.length();i++){
     	if(i%2==0){
        	if(Taps[i]=='L'){
            	M=true;
             	 break;
            }
        }else{
        	if(Taps[i]=='R'){
            	M=true;
             	 break;
        	}
        }
    }
    if(M==true){
    	System.out.println("No");
    }else{
    	System.out.println("Yes");
    }
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

ll n;
map<string, ll> msi;
map<string, vector<string> > msvs;
ll m;
string t;

ll solve(string s){
	if (msvs.find(s) == msvs.end()){
		return msi[s];
	}
	else{
		ll res = 0;
		for (vector<string>::iterator it = msvs[s].begin(); it != msvs[s].end(); it++){
			res += solve(*it);
		}
		return min(msi[s], res);
	}
}

int main(){
	while (cin >> n&&n){
		msi.clear();
		msvs.clear();
		REP(i, n){
			string s;
			ll p;
			cin >> s >> p;
			msi[s] = p;
		}
		cin >> m;
		REP(i, m){
			string o;
			ll k;
			cin >> o >> k;
			REP(j, k){
				string q;
				cin >> q;
				msvs[o].push_back(q);
			}
		}
		cin >> t;
		cout << solve(t) << endl;
	}
}

Measured memory_bytes: 3148
#include<stdio.h>

int main(void){
    int a,b;
    scanf("%d %d", &a,&b);
    int ans = -1;
    int i;
    for(i=0;i<=1100;i++){
        if((int)((double)i*0.08) == a && (int)((double)i*0.1) == b){
            ans = i;
            break;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
solve :: [Int] -> [String] -> Int
solve cs [] = head cs
solve (a:b:cs) ("+":ys) = solve ((a+b):cs) ys
solve (a:b:cs) ("-":ys) = solve ((b-a):cs) ys
solve (a:b:cs) ("*":ys) = solve ((a*b):cs) ys
solve cs (y:ys)	= solve	((read y):cs) ys

main = getContents >>= print . solve [] . words


Measured memory_bytes: 4036
#!/usr/bin/env python3
# n,m = map(int,sys.stdin.readline().split())
# a = list(map(int,sys.stdin.readline().split()))
# a = [sys.stdin.readline() for _ in range(n)]
# s = sys.stdin.readline().rstrip()
# n = int(sys.stdin.readline())
import sys,bisect,math,collections
sys.setrecursionlimit(15000)

N,M = map(int,sys.stdin.readline().split())
h = list(map(int,sys.stdin.readline().split()))
good = [1]*N

for _ in range(M):
    a,b = list(map(int,sys.stdin.readline().split()))
    if h[a-1] > h[b-1]:
        good[b-1] = 0
    elif h[a-1] < h[b-1]:
        good[a-1] = 0
    else:# h[a-1] == h[b-1]:
        good[a-1] = 0
        good[b-1] = 0
#print(good)
print(sum(good))


Measured memory_bytes: 21452
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int h, w;
V< V<int> > a, b;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    a.resize(h, V<int>(w)), b.resize(h, V<int>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> b[i][j];
        }
    }

    const int maxk = 160 * 80 + 1;
    V< V< V<int> > > dp(h, V< V<int> >(w, V<int>(maxk, 0)));
    dp[0][0][abs(a[0][0] - b[0][0])] = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            for (int k = 0; k < maxk; k++) {
                if (i > 0) {
                    if (dp[i - 1][j][k] == 1) {
                        dp[i][j][k + abs(a[i][j] - b[i][j])] = 1;
                        dp[i][j][abs(k - abs(b[i][j] - a[i][j]))] = 1;
                    }
                }
                if (j > 0) {
                    if (dp[i][j - 1][k] == 1) {
                        dp[i][j][k + abs(a[i][j] - b[i][j])] = 1;
                        dp[i][j][abs(k - abs(b[i][j] - a[i][j]))] = 1;
                    }
                }
            }
        }
    }

    for (int k = 0; k < maxk; k++) {
        if (dp[h - 1][w - 1][k] == 1) {
            cout << k << '\n';
            break;
        }
    }
    return 0;
}


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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	long long int a, sum = 100, year = 0; cin >> a;
	while (sum < a)
	{
		sum = sum + (sum / 100);
		year++;
	}
	cout << year << endl;
	return 0;
}

Measured memory_bytes: 3604
N=input()
n=int(N[-1])
if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
    print("hon")
elif n == 0 or n == 1 or n == 6 or n == 8:
    print("pon")
else:
    print("bon")

Measured memory_bytes: 61604
#include "bits/stdc++.h"
using namespace std;

// #include "debug.h"
// #define debug(...) 42

using ll = long long;

void solve() {
   int n, k, s;
   cin >> n >> k >> s;

   vector <int> v(n, s);
   int def = 1e9;
   if(s > 1e5)
      def = 1;
   for(int i = k; i < n; i++) {
      v[i] = def;
   }

   for(int i = 0; i < n; i++) {
      cout << v[i] << " ";
   }
   cout << endl;
} 

int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   int testcase = 1;
   // cin >> testcase;

   for(int i = 0; i < testcase; i++) {
      solve();
   } 
   return 0;
}


Measured memory_bytes: 3764
//最短経路問題をダイクストラ法で解く。
//隣接行列表現を用いる。
//計算量O(v^2) (vは頂点の数)

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

#define MAX 105
#define INFTY 10000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

//Mは隣接行列
int n, M[MAX][MAX], color[MAX];

void dijkstra(){
    int minv;
    int d[MAX], color[MAX];

    for(int i=0; i<n; i++){
        d[i] = INFTY;
        color[i] = WHITE;
    }

    d[0] = 0;
    color[0] = WHITE;

    while(1){
        minv = INFTY;
        int u = -1;
        for(int i=0; i<n; i++){
            if(minv > d[i]  &&  color[i] != BLACK){
                u = i;
                minv = d[i];
            }
        }
        if(u == -1) break;
        color[u] = BLACK;
        for(int v=0; v<n; v++){
            if(color[v] != BLACK  &&  M[u][v] != INFTY){
                if(d[v] > d[u] + M[u][v]){
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }

    for(int i=0; i<n; i++){
        if(d[i] == INFTY) cout << i << " -1" << endl;
        else cout << i << " " << d[i] << endl;
    }
}

int main(){
    cin >> n;
    //隣接リスト表現→隣接行列表現への変換
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            M[i][j] = INFTY;
        }
    }
    for(int i=0; i<n; i++){
        int u, k;
        cin >> u >> k;
        for(int j=0; j<k; j++){
            int v, c;
            cin >> v >> c;
            M[u][v] = c;
        }
    }

    dijkstra();

    return 0;
}


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

typedef long long ll;

#define PB push_back
#define MP make_pair

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    ll n, a, b, c, d, e; cin >> n >> a >> b >> c >> d >> e;
    ll m = min({a, b, c, d, e});
    ll ans;
    if (m >= n) ans = 5;
    else {
        ans = n / m + 5;
        if (m == 1) --ans;
    }
    cout << ans << "\n";
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* print new lines
*/

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    REP(i, 0, n) cin >> a[i];
    REP(i, 0, n) cin >> b[i];
    REP(i, 0, n) cin >> c[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    long long ans = 0;
    REP(j, 0, n) {
        long long ca = 0, cc = 0;
        ca = lower_bound(a.begin(), a.end(), b[j]) - a.begin();
        cc = c.end() - upper_bound(c.begin(), c.end(), b[j]);
        ans += ca * cc;
    }
    cout << ans << endl;
}


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

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

  int time = min(B, D) - max(A, C);
  
  cout << (time > 0 ? time : 0) << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n;
  cin>>n;
  int cnt[n] = {};
  REP(i,n){
    int a;
    cin>>a;
    a--;
    cnt[a]++;
  }
  vector<int> a;
  REP(i,n){
    if(cnt[i] == 0)continue;
    a.push_back(cnt[i]);
  }
  sort(ALL(a));
  
  int m = a.size();
  int s[m];
  REP(i,m){
    if(i==0){
      s[i] = a[i];
    }else{
      s[i] = s[i-1] + a[i];
    }
  }
  REPP(k,n){
    //[l,r)上での二分探索
    int l = 0;
    int r = n/k + 1;
    while(r-l>1){
      int t = (l+r)/2;
      int num = lower_bound(ALL(a), t) - a.begin();//t未満の値を持つaの要素の個数
      int temp;
      if(num == 0){
        temp = t*m;
      }else{
        temp = s[num-1] + t*(m-num);
      }
      if(temp >= t*k){
        l = t;
      }else{
        r = t;
      }
    }
    cout<<l<<endl;
  }
  return 0; 
}


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

int main() {
    cout.precision(10);
    double ans,l;
    cin>>l;
    ans=pow(l/3,3);
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
#define N 1000005
int n,a[N];
int maxx,minn;
int one,two;//unique 重名？！ 
int main(){
	maxx=0;minn=N;
	one=0;two=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		maxx=max(maxx,a[i]);
		minn=min(minn,a[i]);
	}
	if(maxx==minn){//correct 
		if(minn==n-1||minn<=n/2){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}else if(maxx-minn>1||maxx>=n){
		printf("No\n");
	}else{
		for(int i=1;i<=n;i++){
			if(a[i]==minn) one++;
			else two++;
		}
		if(one>=maxx){//correct
			printf("No\n");
		}else if(one+two/2<maxx){
			printf("No\n");
		}else{
			printf("Yes\n");
		}
	}
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
main()
{
      ll n,i,j,k,ans=0;
      cin>>n;
      ll ara[n+1];
      for(i=1;i<=n;i++)cin>>ara[i];
      for(i=1;i<=n;i++)
      {
          for(j=i+1;j<=n;j++)
          {
              for(k=j+1;k<=n;k++)
              {
                  if(ara[i]+ara[j]>ara[k] && ara[k]+ara[j]>ara[i] && ara[i]+ara[k]>ara[j] && ara[i]!=ara[j] && ara[k]!=ara[j] && ara[i]!=ara[k])
                  {
                      ans++;
                      //cout<<i<<" "<<j<<" "<<k<<endl;
                  }
              }
          }
      }
      cout<<ans<<endl;
}



Measured memory_bytes: 3620
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[])
{
	int n, m;
	cin >> n >> m;
	vector<LL> v[8];
	for (int i = 0; i < n; ++i) {
		LL x, y, z;
		cin >> x >> y >> z;
		for (int j = 0; j < 8; ++j) {
			LL w = ((j & 1) ? x : -x) + ((j & 2) ? y : -y) + ((j & 4) ? z : -z);
			v[j].push_back(w);
		}
	}
	LL ans = 0;
	for (int j = 0; j < 8; ++j) {
		sort(v[j].rbegin(), v[j].rend());
		ans = max(ans, accumulate(v[j].begin(), v[j].begin() + m, 0LL));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
#include<cstdio>
#define ll long long int
#define mod 1000000007
#define pi 3.141592653589793
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define vfind(a, e) find(a.begin(), a.end(), e)
#define forr(i, n) for (ll i = 0; i < n; i++)
#define rfor(i, n) for (ll i = n - 1; i >= 0; i--)
#define fors(i, b, e, steps) for(ll i = b; i < e; i += steps)
#define rfors(i, e, b, steps) for(ll i = e; i > b; i -= steps)
#define mp make_pair
using namespace std;


bool isVowel(char c){
    return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
}

bool isLower(char c){
    return 97 <= c && c <= 122;
}

bool prime[1001];
void sieve() {
    fill(prime, prime + 1000, 1);
    prime[0] = prime[1] = 0;

    fors(i, 2, 1000, 1) {
        if (prime[i]) {
            fors(j, i * 2, 1000, i) prime[j] = 0;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << setprecision(10);

    ll n;
    cin >> n;
    ll a[n];
    forr(i, n){
        cin >> a[i];
    }

    ll dp[n];
    dp[0] = 0;
    dp[1] = abs(a[0] - a[1]);

    fors(i, 2, n, 1) {
        dp[i] = min(dp[i - 2] + abs(a[i - 2] - a[i]), dp[i - 1] + abs(a[i - 1] - a[i]));
    }
    cout << dp[n - 1];

}


Measured memory_bytes: 1792
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const inputs = input.split(' ').map(value => parseInt(value));
const A = inputs[0];
const P = inputs[1];
 
const pieces = A * 3 + P;
const pies = Math.floor(pieces / 2);
 
console.log(pies);

Measured memory_bytes: 7372
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
	int N, K, sum = 0;
	vector <int> a(100000,0), mod(100000,0), csum(100000,0);
	cin >> N >> K;
	int ans = 0;
	for (int i = 0; i<N; i++) {
		cin >> a[i];
		sum += a[i];
	}
	int temp, plus, minus;
	for (int i = 1; i*i <= sum; i++){
		if(sum % i == 0){
			for(int b = 0; b<2; b++)
			{
				if(b==0) temp = sum / i;//おっきいの
				else temp = i;
				plus = 0, minus = 0;
				
				for (int j = 0; j<N; j++){
					mod[j] = a[j] % temp;
				}
				sort(mod.begin(), mod.begin() + N);
				for(int j = 0; j<N; j++){
					if(j > 0) csum[j] = csum[j-1] + mod[j];
					else csum[j] = mod[j];
				}
				for(int j = 0; j<N; j++){
					plus = csum[j];
					minus = temp*(N-1-j) - (csum[N-1] - csum[j]);
					if (plus == minus && plus <= K && minus <= K){
						ans = max(ans,temp);
						if (b==0) break;
					}
				}
				
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}

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

using namespace std;

const int INF = 1e9 + 5;

void a()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
}

int main()
{
    a();

    int n, w;
    cin >> n >> w;
    vector<long long> dp(w + 1);

    for(int i = 0; i < n; i++){
        int weight, value;
        cin >> weight >> value;
        for(int j = w - weight; j >= 0; j--){
            dp[j+weight] = max(dp[j+weight], dp[j] + value);
        }
    }

    long long ans = 0;
    for(long long i : dp){
        ans = max(ans, i);
    }

    cout << ans;
}


Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
#define rep(i ,a, n) for (long long int i=a;i<=n;i++)
#define pb  push_back
#define mp make_pair
#define fp first
#define sp second
#define be(v) v.begin(),v.end()
typedef long long ll;
typedef vector<ll> vi ;
typedef vector<pair<ll , ll > >  vpi ;
const int ma1=3e5+5;
string no="NO",yes="YES";
const unsigned int MOD = 1000000007;
int max_char=26;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    while(t--)
    {

    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        if((i+1)%2==1)
        {
            if(a[i]%2==1)
                sum++;
        }
    }
    cout<<sum;
    }
    return 0;
}













Measured memory_bytes: 3656
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		
		while(sc.hasNext()) {
			boolean[] list = new boolean[10];
			int c1 = (int)sc.nextLong();
			int c2 = (int)sc.nextLong();
			int c3 = (int)sc.nextLong();
			list[c1-1] = true;
			list[c2-1] = true;
			list[c3-1] = true;
			
			int sum = 0;
			int g = 0;
			for(int i = 0; i < 10; i++) {
				if(!list[i]) {
					if(c1 + c2 + i+1  <= 20) {
						g++;
					}
					sum++;
				}
			}
			if((double)g/sum >= 0.5) {
				out.println("YES");
			}
			else {
				out.println("NO");
			}
		}
		out.flush();
	}
}
	
//------------------------------//
//-----------//
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}

Measured memory_bytes: 16872
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    S=input()
    N=len(S)
    K=I()
    
    dpl=[[0]*(K+1)for _ in range(N+1)]
    dpt=[[0]*(K+1)for _ in range(N+1)]
    
    #dp[i][j]はi桁目まで見て0以外がj個．tは上限
    dpt[0][0]=1
    
    for i in range(N):
        #とりあえずルーズな方
        for j in range(K+1):
            dpl[i+1][j]=dpl[i][j]# 0が増えた場合
            
        for j in range(1,K+1):
            dpl[i+1][j]+=dpl[i][j-1]*9 # 0以外が増えた場合
            
        s=int(S[i])
        #タイトな方
        if s==0:
            for j in range(K+1):
                dpt[i+1][j]=dpt[i][j]#0をつけるしかない
        else:
            for j in range(1,K+1):
                dpt[i+1][j]=dpt[i][j-1]#0以外をつける
            
            #ルーズに落ちる
            for j in range(K+1):
                dpl[i+1][j]+=dpt[i][j]#0をつける
            #ルーズに落ちる
            for j in range(K):
                dpl[i+1][j+1]+=dpt[i][j]*(s-1)#0以外をつける
                
    ans=dpt[-1][-1]+dpl[-1][-1]
    
    print(ans)
    
    # for i in range(N+1):
    #     print(dpt[i])
        
    # print()
    # for i in range(N+1):
    #     print(dpl[i])
                
            
            
        
        

main()


Measured memory_bytes: 62548
N = int(input().strip())
abc = []
for i in range(N):
    abc.append(list(map(int, input().strip().split(" "))))

dp = [[0]*3 for i in range(N)]
dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]

for i in range(1,N):
    for j in range(3):
        sc = 0
        for k in range(3):
            if j == k:
                t = dp[i-1][k]
            else:
                t = dp[i-1][k] + abc[i][j]
            if sc < t:
                sc = t
        dp[i][j] = sc
print(max(dp[N-1]))


Measured memory_bytes: 74072
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

vector<int> v[101010],art;
vector <pint> bridge;
int low[101010],ord[101010];

void dfs(int& count,int from,int x){
    ord[x]=count++;
    low[x]=ord[x];
    bool isart=false;
    int cnt=0;
    for(auto to:v[x]){
        if(to==from)continue;
        if(ord[to]==-1){
            cnt++;
            dfs(count,x,to);
            if(ord[x]<low[to])bridge.push_back({min(x,to),max(to,x)});
            if(from!=-1&&ord[x]<=low[to])isart=true;
            low[x]=min(low[x],low[to]);
        }
        else low[x]=min(low[x],ord[to]);
    }
    if(from==-1&&cnt>1)isart=true;
    if(isart)art.push_back(x);
}

int main(){
    int n,m;
    cin>>n>>m;
    rep(i,m){
        int s,t;
        cin>>s>>t;
        v[s].push_back(t);
        v[t].push_back(s);
    }
    rep(i,n)ord[i]=low[i]=-1;
    int count=0;
    dfs(count,-1,0);
    sort(art.begin(),art.end());
    for(auto e:art)cout<<e<<endl;
    return 0;
}


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

using namespace std;

int main(void) {

	
	int k, s;
	cin>>k>>s;
	int ans = 0;
	for(int i = 0; i <= k; ++i) {
		for(int j = 0; j <= k; ++j) {
			int curr = i+j;
			int req = s - curr;
			if(req >= 0 && req <= k)	ans++;
		}
	}

	cout<<ans;

	return 0;
}












Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <stdlib.h>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <stdio.h>
using namespace std;
const double PI = 3.14159265358979323846;

#define ARRAY_SIZE 100000

int main() {
    int K;
    cin >> K;

    if (K <= 12) {
        cout << K << endl;

        return 0;
    }

    K -= 12;

    int lunlun[ARRAY_SIZE];

    for (int i = 0; i < ARRAY_SIZE; i++) {
        lunlun[i] = -1;
    }
    lunlun[0] = 2;
    lunlun[1] = 1;

    for (int i = 0; i < K; i++) {
        lunlun[0]++;
        for (int j = 0; j < ARRAY_SIZE; j++) {
            int diff = lunlun[j] - lunlun[j + 1];
            if ((lunlun[j + 1] == -1 || diff * diff <= 1) && lunlun[j] < 10) {
                break;
            }

            lunlun[j + 1]++;
            if (lunlun[j + 1] == 0) {
                lunlun[j + 1] = 1;
            }

            for (int k = j; k >= 0; k--) {
                if (lunlun[k + 1] != 0) {
                    lunlun[k] = lunlun[k + 1] - 1;
                }
                else {
                    lunlun[k] = 0;
                }
            }
        }
    }

    for (int j = ARRAY_SIZE - 1; j >= 0; j--) {
        if (lunlun[j] != -1) {
            cout << lunlun[j];
        }
    }
    cout << endl;
	return 0;
}

Measured memory_bytes: 3984
#include <stdio.h>
 int main(void)
{
    int r, c;
    int i, j;
    int num;
    int a[101][101]={};
    scanf("%d%d", &r, &c);
    for(i=0; i<r; i++) {
        for(j=0; j<c; j++) {
            scanf("%d", &num);
            a[i][j]+=num;
        }
    }
    
    for(i=0; i<r; i++) {
        for(j=0; j<c; j++)
            a[i][c]+=a[i][j];
    }
    
    for(j=0; j<c+1; j++) {
        for(i=0; i<r; i++)
            a[r][j]+=a[i][j];
    }
     
    for(i=0; i<r+1; i++) {
        for(j=0; j<c+1; j++) {
            printf("%d", a[i][j]);
            if(j<c) putchar(' ');
            if(j==c) putchar('\n');
        }
    }
    return 0;
}


Measured memory_bytes: 2140
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::cmp;

fn main() {
    let n = get!(usize);

    let mut i: usize = 0;
    let mut r = 10;
    while i*i <= n {
        i += 1;
        if n%i == 0 {
            let mut j = n/i;
            let mut t = 0;
            while j > 0 {
                t += 1;
                j /= 10;
            }
            r = cmp::min(r, t);
        }
    }
    println!("{}", r);
}

Measured memory_bytes: 4352
import java.util.*; public class Main { public static void main(String[] args) { int n,c,d; long x,y; Scanner sc = new Scanner(System.in); n = sc.nextInt(); d = sc.nextInt(); c=0; for(int i=0; i<n; i++) { x = sc.nextInt(); y = sc.nextInt(); double dist = Math.sqrt( x*x + y*y ); if(dist <= d) c++; } System.out.println(c); } }

Measured memory_bytes: 59800
#include <stdio.h>
#include <string.h>

int main() {
  char input_a[11];
  char input_b[12];
  scanf("%s%s", input_a, input_b);

  short length = strlen(input_a);

  char output[4] = "Yes";
  for (short i = 0; i < length; i += 1) {
    if (input_a[i] != input_b[i]) {
      strcpy(output, "No");
    }
  }

  printf("%s", output);
  printf("%c", '\n');

  return 0;
}


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

using vi = vector<int>;
using vll = vector<long long>;

constexpr long long mod = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;

    priority_queue<long long> q;

    rep(i, n){
        long long t;
        cin >> t;
        q.push(t);
    }

    while (m > 0) {
        long long t = q.top()/2;
        m--;
        q.pop();

        q.push(t);
    }

    long long sum = 0;
    while(!q.empty()){
        sum += q.top();
        q.pop();
    }
    cout << sum << endl;
}

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

typedef long long ll;
int l,a[200005];
ll f[200005][5];

void upd(ll &x,ll y){if(x>y)x=y;}

int cost(int x,int y){
	if(x==-1)return y;
	if(x==0)return y==0?2:y%2;
	return 1-y%2;
}

int main(){
	scanf("%d",&l);
	for(int i=1;i<=l;i++)scanf("%d",a+i);
	memset(f,0x3f,sizeof f);
	f[0][0]=0;
	for(int i=0;i<l;i++)
		for(int j=0;j<5;j++)
			for(int k=j;k<5;k++)
				upd(f[i+1][k],f[i][j]+cost(k==0||k==4?-1:k==1||k==3?0:1,a[i+1]));
	printf("%lld\n",min({f[l][0],f[l][1],f[l][2],f[l][3],f[l][4]}));
	return 0;
}


Measured memory_bytes: 8832
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

int para;


int input(int n){
    cout << n << endl;
    string s;
    cin >> s;
    if (s == "Male") return 0;
    if (s == "Female") return 1;
    
    exit(0);
}

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

    Int x, y; cin >> x >> y;
    Int X = x;
    Int Y = y;
    

    while (1){
        Int tmp;
        if (X >= 2){
            tmp = X/2;
            X %= 2;
            Y += tmp;
            y += tmp;
        }else if (Y >= 2){
            tmp = Y/2;
            Y %= 2;
            X += tmp;
            x += tmp;
        }else{
            break;
        }
    }
    x -= x%2;
    y -= y%2;

    if (x == y) cout << "Brown" << endl;
    else cout << "Alice" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N;
int D[50];
int cnt[13];
int table[25], tmp[25];
vector<int> ones;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  cnt[0] = 1;
  for (int i = 0; i < N; i++) {
    cin >> D[i];
    cnt[D[i]]++;
  }

  bool zero = false;
  if (cnt[0] > 1 || cnt[12] > 1) zero = true;
  for (int i = 1; i < 12; i++) {
    if (cnt[i] > 2) zero = true;
  }
  if (zero) {
    cout << 0 << endl;
    return 0;
  }

  table[0] = table[24] = 1;
  if (cnt[12]) table[12] = 1;
  for (int i = 1; i < 12; i++) {
    if (cnt[i] == 2) {
      table[i] = table[24-i] = 1;
    } else if (cnt[i] == 1) {
      ones.emplace_back(i);
    }
  }
  int sz = ones.size();
  int ans = 0;
  for (int i = 0; i < 1 << sz; i++) {
    copy(table, table+25, tmp);
    for (int j = 0; j < sz; j++) {
      if (i >> j & 1) tmp[24-ones[j]] = 1;
      else tmp[ones[j]] = 1;
    }
    int mn = 24, last = 0;
    for (int j = 1; j < 25; j++) {
      if (tmp[j] == 0) continue;
      mn = min(mn, j-last);
      last = j;
    }
    ans = max(ans, mn);
  }
  cout << ans << endl;

  return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────────────────

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

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {  
  		Scanner sc = new Scanner(System.in);
      	int appleNum = sc.nextInt();
      	int pieces	 = sc.nextInt();
      
      	pieces = (appleNum * 3) + pieces;
      	int applePie = pieces / 2;
      	System.out.println(applePie);
  
  
    }
}

Measured memory_bytes: 21588
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int h,w; cin >> h >> w;
    vector<string> s(h);
    rep(i,h) {
        cin >> s[i];
    }   
    rep(i,h) {
        cout << s[i] << endl << s[i] << endl;
    }
    return 0;
}

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


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solveA(args);
//		solveB(args);
//		solveC(args);
//		solveD(args);
//		solveE(args);
//		solveF(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solveA(String[] args) throws Exception{
		int N= nextInt();

		if(N>=30) {
			pw.println("Yes");
		}else {
			pw.println("No");
		}
	}
	public static void solveB(String[] args) throws Exception{

	}
	public static void solveC(String[] args) throws Exception{


	}


	public static void solveD(String[] args) throws Exception{

	}


	public static void solveE(String[] args) throws Exception{


	}

	public static void solveF(String[] args) throws Exception{

	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 25384
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        int c=0;
        cin >> a[i];
        while(a[i]%2==0&&a[i]!=0){
            c++;
            a[i]/=2;
        }
        a[i]=c;
    }
    cout << accumulate(a.begin(),a.end(),0);
}

Measured memory_bytes: 256
//39
#include<iostream>
#include<queue>
#include<utility>

using namespace std;

int main(){
  int r,cc,a,aa,b,bb;
  cin>>r>>cc>>a>>b>>aa>>bb;
  static int mat[1000][1000]={};
  static int p[1000][1000]={};
  queue<pair<int,pair<int,int> > > que;
  que.push(make_pair(1,make_pair(a,b)));
  mat[a][b]=1;
  while(p[aa][bb]==0||p[aa][bb]==que.front().first){
    pair<int,pair<int,int> > c=que.front();
    que.pop();
    for(int i=0;i<4;i++){
      static int d[]={0,1,0,-1,0};
      int dy=(c.second.first+d[i]+r)%r;
      int dx=(c.second.second+d[i+1]+cc)%cc;
      if(p[dy][dx]==0||p[dy][dx]==c.first){
	mat[dy][dx]=(mat[dy][dx]+mat[c.second.first][c.second.second])%100000007;
	if(p[dy][dx]==0){
	  p[dy][dx]=c.first;

	  que.push(make_pair(c.first+1,make_pair(dy,dx)));
	}
      }
    }
  }
  cout<<mat[aa][bb]<<endl;
  return 0;
}

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

int main() {
    int k, s;
    cin >> k >> s;

    int count = 0;
    for (int x = 0; x <= k; ++x) {
        for (int y = 0; y <= k; ++y) {
            int z = s - x - y;
            if (z < 0) {
                continue;
            }
            if (z > k) {
                continue;
            }
            count++;
        }
    }
    cout << count << endl;
}

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

typedef struct {
  string name;
  int time;
} elem; 

int main()
{
  int n, q;
  cin >> n >> q;

  queue<elem> que;
  for (int i = 0; i < n; i++) {
    string name; int time;
    cin >> name >> time;
    que.push((elem){ name, time });
  }

  int sum_t = 0;
  while (!que.empty()) {
    elem e = que.front(); que.pop();
    if (e.time <= q) {
      sum_t += e.time;
      cout << e.name << " " << sum_t << endl;
    } else {
      sum_t += q;
      e.time -= q;
      que.push(e);
    }
  }

  return EXIT_SUCCESS;
}




Measured memory_bytes: 6236
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

ll powmod(ll a,ll n,ll m) {
    if(n == 0)
        return 1;

    if(n % 2 ==0){
        ll r = powmod(a,n/2,m);
        return r*r % m;
    }

    return a*powmod(a,n-1,m)%m;
}

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

ll factmod(ll a,ll m) {
    ll s=1;
    while(a>0){
        s = s*a % m;
        a -= 1;
    }
    return s;
}

int main(){

  ll n,m,k;
  cin >> n>> m >> k;
  ll s=0,l;
  ll a,b,c;
  a=factmod(n*m-2,mod);
  b=modinv(factmod(k-2,mod),mod);
  c=modinv(factmod(n*m-k,mod),mod);
  for(int i=1;i<n;i++){
    l=1;
    l*=(n-i);
    l%=mod;
    l*=pow(m,2);
    l%=mod;
    l*=a;
    l%=mod;
    l*=b;
    l%=mod;
    l*=c;
    l%=mod;
    l*=i;
    l%=mod;
    s+=l;
    s%=mod;
  }

  for(int i=1;i<m;i++){
    l=1;
    l*=(m-i);
    l%=mod;
    l*=pow(n,2);
    l%=mod;
    l*=a;
    l%=mod;
    l*=b;
    l%=mod;
    l*=c;
    l%=mod;
    l*=i;
    l%=mod;
    s+=l;
    s%=mod;
  }

  cout << s << endl;

}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#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;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln = '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////


template<typename C>
struct Trie {
    struct Node {
        int exist,len;
        vector<int> accept;
        map<C, int> ch;
        Node() : exist(0), len(0) {}  
    };

    vector<Node> node;

    Trie() {node.emplace_back();}

    template<typename S>
    void add (const S &A, int id) {
        int cur = 0;
        for (int i = 0; i < (int)A.size(); i++) {
            if (!node[cur].ch.count(A[i])) {
                int nex = node.size();
                node.emplace_back();
                node[nex].len = node[cur].len + 1;
                node[cur].ch.emplace(A[i],nex);
            }
            node[cur].exist++;
            cur = node[cur].ch[A[i]];
        }
        node[cur].exist++;
        node[cur].accept.emplace_back(id);
    }

    template<typename S>
    int find(const S &A) {
        int cur = 0;
        for (int i = 0; i < (int)A.size(); i++) {
            if (!node[cur].ch.count(A[i])) return -1;
            cur = node[cur].ch[A[i]];
        }
        return cur;
    }

    int count() const {return node[0].eixst;}

    int size() const {return(int)node.size();}
};

int underbit(ll x) {
    if (x==0) return 0;
    rep(i,64) {
        if ((x>>i)&1) return i+1;
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,L; cin >> N >> L;
    Trie<char> T;

    ll g = 0;
    rep(_,N) {
        string S; cin >> S;
        int K = S.size();
        int cur = 0, len = 0;
        rep(i,K) {
            if (!T.node[cur].ch.count(S[i])) {
                len = T.node[cur].len;
                break;
            }
            cur = T.node[cur].ch[S[i]];
        }
        ll val = L - len;
        g ^= underbit(val);
        ll l = L - K + 1;
        for (ll i = l; i < val; i++) g ^= underbit(i);
        T.add(S,_);
    }

    cout << (g ? "Alice" : "Bob") << ln;
}


Measured memory_bytes: 16456
#include<bits/stdc++.h>
#define a 200001
using namespace std;
const int INF=1e9;
int main()
{
    int n,r[a];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>r[i];
        int ans=-INF;
        int mn=r[0];
        for(int i=1;i<n;i++){
            ans=max(ans,r[i]-mn);
        mn=min(mn,r[i]);
}
cout<<ans<<"\n";
return 0;
}



Measured memory_bytes: 3884
H, W = map(int, input().split())
arr = []
for i in range(H):
    arr.append(list(str(input())))

n_arr = [[0 for i in range(W)] for j in range(H)]


for i in range(H):
    tmp = 0
    for j in range(W):
        if arr[i][j] == ".":
            tmp += 1
            n_arr[i][j] += tmp
        else:
            tmp = 0

for i in range(H):
    tmp = 0
    for j in range(W-1,-1,-1):
        if arr[i][j] == ".":
            tmp += 1
            n_arr[i][j] += tmp - 1
        else:
            tmp = 0


for i in range(W):
    tmp = 0
    for j in range(H):
        if arr[j][i] == ".":
            tmp += 1
            n_arr[j][i] += tmp - 1
        else:
            tmp = 0

ans = 0
for i in range(W):
    tmp = 0
    for j in range(H-1,-1,-1):
        if arr[j][i] == ".":
            tmp += 1
            n_arr[j][i] += tmp - 1
        else:
            tmp = 0
        ans = max(ans, n_arr[j][i])

print(ans)

Measured memory_bytes: 215176