akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int putBlocks(int N, int K)
{
	if (N == 1) return 1;
	else {
		int most_under = 1;//最下段のブロックの数
		int count = N;//注目塔の高さ
		while ((((double)count - 1) / (double)most_under) > K) {//注目塔の最下段の強度を判定
            most_under++;
			count--;//塔の高さを減らす（最下段へ）
		}
		return 1 + putBlocks(count - 1,K);//注目塔の最下段を１つ上にずらして返却
	}
}

int main()
{
	int N, K;
	cin >> N >> K;
	cout << putBlocks(N, K) << endl;
	return 0;
}    


Measured memory_bytes: 3092
#include <iostream>
#include <string>
using namespace std;
   
int main() {
  int cnt=0;
  string word, w;
   
  cin >> word;
  for (int i = 0; i < word.size(); i++) {
    if ('A' <= word[i] && word[i] <= 'Z') {word[i] = word[i] + 32;}
  }
   
  while (1) {
    cin >> w;
    if (w == "END_OF_TEXT") break;
    for (int i = 0; i < w.size(); i++) {
      if ('A' <= w[i] && w[i] <= 'Z') { w[i] = w[i] + 32; }
    }
    //if (w[w.size()-1] == '.') {w = w.substr(0, w.size() -2);}
   
    if (w == word) cnt++;
  }
   
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3216
import java.util.*;

class Main {
  public static void main(String[] args) {
	Scanner scanner = new Scanner(System.in);
    
    long S = scanner.nextLong(); //next(文字列), nextDouble, nextLine(1行)とか   
    int k = 0;
    long X = S; //Sの桁数を求めるパート
    while (X > 0){
      k++;
      X /= 10;
    }                  
    long[] A = new long[k]; //Sの各桁を配列に入れる
    for (int i = 0; i < A.length; i++){
      A[i] = S % 10;
      S /= 10;
    }    
    
    long ans = 0;
    for (long bit = 0; bit < (1<<(A.length-1));bit++){
      long temp = 0;
      long ten = 1;
      for (int j = 0; j < A.length; j++){
        temp += A[j]*ten;
        if ((bit & (1 << j)) == 0){
          ten *= 10;
          if (j == A.length-1){
            ans += temp;
          }
        }else{
          ans += temp;
          temp = 0;
          ten = 1;

        }
      }
    }
    System.out.println(ans);     
  }
}


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

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

    long long ans;
    if (K % 2 == 0) {
        ans = A - B;
    } else {
        ans = B - A;
    }

    if (abs(ans) >= (long long)1e18) {
        cout << "Unfair" << endl;
    } else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

const double pi=acos(-1);

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  double a,b,x;
  cin>>a>>b>>x;
  
  if(2*x==a*a*b) cout<<fixed << setprecision(15) <<atan(b/a)*180/pi<<endl;
  else if(2*x>a*a*b) cout<<fixed << setprecision(15) <<atan(2*(a*a*b-x)/a/a/a)*180/pi<<endl;
  else cout<<fixed << setprecision(15) <<atan(a*b*b/2/x)*180/pi<<endl;
  
  return 0;
}

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

using namespace std;

/*
	UNITY_NODE minの単位元
	UNITY_LAZY addの単位元
	nodeの初期値に注意(constructor)
*/
template <class NODE, class LAZY, NODE UNITY_NODE, LAZY UNITY_LAZY>
struct LazySegTree {
// edit start
	void add(LAZY &a, LAZY b) {
		a += b;
	}
	void reflect(NODE& a, LAZY b, int l, int r) {
		a += b;
	}
	NODE merge(NODE a, NODE b) {
		return min(a, b);
	}
// end
	int n;
	vector<NODE> node;
	vector<LAZY> lazy;

	LazySegTree(int sz) : n(calc_n_size(1, sz)), node(2*n-1, 0), lazy(2*n-1, UNITY_LAZY) {}
	LazySegTree(const vector<NODE>& v) : n(calc_n_size(1, v.size())), node(2*n-1, UNITY_NODE), lazy(2*n-1, UNITY_LAZY) {
		for (int i = 0; i < v.size(); i++) node[n-1+i] = v[i];
		for (int i = n - 2; i >= 0; i--) renode(i);
	}

	int calc_n_size(int n_, int sz) {return n_ < sz ? calc_n_size(n_ * 2, sz) : n_;}
	void eval(int l, int r, int k) {
		reflect(node[k], lazy[k], l, r);
		if (r - l > 1) {
			add(lazy[k*2+1], lazy[k]);
			add(lazy[k*2+2], lazy[k]);
		}
		lazy[k] = UNITY_LAZY;
	}
	void renode(int k) {
		node[k] = merge(node[k*2+1], node[k*2+2]);
	}
	void set(int a, int b, LAZY x, int k, int l, int r) {
		if (b <= l || r <= a) {
			eval(l, r, k);
		} else if (a <= l && r <= b) {
			add(lazy[k], x);
			eval(l, r, k);
		} else {
			eval(l, r, k);
			set(a, b, x, k*2+1, l, (l+r) / 2);
			set(a, b, x, k*2+2, (l+r) / 2, r);
			renode(k);
		}
	}
	NODE get(int a, int b, int k, int l, int r) {
		eval(l, r, k);
		if (b <= l || r <= a) {
			return UNITY_NODE;
		} else if (a <= l && r <= b) {
			return node[k];
		} else {
			NODE t1 = get(a, b, 2*k+1, l, (l+r) / 2);
			NODE t2 = get(a, b, 2*k+2, (l+r) / 2, r);
			renode(k);
			return merge(t1, t2);
		}
	}
	NODE get(int a, int b) {return get(a, b, 0, 0, n);}
	void set(int a, int b, LAZY x) {set(a, b, x, 0, 0, n);}
};

int main() {
	int n, Q;
	cin >> n >> Q;
	LazySegTree<int, int, INT_MAX, 0> L(vector<int>(n, 0));
	while (Q--) {
		int q;
		cin >> q;
		if (q == 0) {
			int s, t, x;
			cin >> s >> t >> x;
			L.set(s, t+1, x);
		} else {
			int s, t;
			cin >> s >> t;
			cout << L.get(s, t+1) << endl;
		}
	}
}


Measured memory_bytes: 5200
import java.util.Scanner;
import java.util.HashSet;
import java.util.List;
import java.util.ArrayList;
public class Main {

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    HashSet<String> S = new HashSet<String>();
    List<String> results = new ArrayList<String>();
    for (int i = 0; i < n; i++) {
      String cmd = s.next();
      String str = s.next();

      switch(cmd) {
        case "insert":
          S.add(str);
          break;
        case "find":
          if (S.contains(str))
            results.add("yes");
          else
            results.add("no");
          break;
        default:
          break;
      }
    }
    s.close();
    for (String result : results) {
      System.out.println(result);
    }
  }
}



Measured memory_bytes: 265684
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
	static void Main(string[] args) {
		new Calc().calc();
	}
	public class Calc {
		public Calc() { }
		public void calc() {
			int N = ReadLine<int>();
			int[] AB = ReadLine<int>(' ');
			double C = ReadLine<double>();
			var D = ReadLines<double>(N).OrderByDescending(_=>_);
			double sum = 0;
			for (int i = 0; i < N; i++) {
				var tmp = (C + D.Select((v, idx) => new { V = v, I = idx }).Where(_ => _.I < i).Sum(_ => _.V)) / (AB[0] + AB[1] * i);
				if (sum < tmp) sum = tmp;
			}
			Console.WriteLine((int)sum);
			return;
		}
	}

	public static T ReadLine<T>() {
		return (T)Convert.ChangeType(Console.ReadLine(), typeof(T));
	}

	public static T[] ReadLine<T>(params char[] separators) {
		return Console.ReadLine()
			.Split(separators)
			.Select(_ => (T)Convert.ChangeType(_, typeof(T)))
			.ToArray();
	}

	public static List<T> ReadLines<T>(int readCount) {
		List<T> rt = new List<T>();
		for (int i = 0; i < readCount; i++) {
			rt.Add(ReadLine<T>());
		}
		return rt;
	}
}
public static class Utils {
	public static string Docking<T>(this IEnumerable<T> s, int sequenceRange, Func<T, string> filter = null) {
		string str = "";
		int c = 0;
		foreach (var item in s) {
			str += filter == null ? item.ToString() : filter(item);
			c++;
			if (c == sequenceRange) break;
		}
		return str;
	}

	public static string Docking<T>(this IEnumerable<T> s, Func<T, string> filter = null) {
		return s.Docking(s.Count(), filter);
	}

	public static string RangeDocking<T>(this IEnumerable<T> s, int start, int end, Func<T, string> filter = null) {
		string str = "";
		end = end < s.Count() ? end : s.Count();
		var items = s.ToArray();
		for (int i = start; i < end; i++) {
			str += filter == null ? items[i].ToString() : filter(items[i]);
		}
		return str;
	}
	public static int IntParse(this string n) {
		return int.Parse(n);
	}
	public static void WriteLine<T>(this IEnumerable<T> list) {
		foreach (var item in list) {
			item.WriteLine();
		}
	}
	public static void WriteLine(this object obj) {
		Console.WriteLine(obj);
	}
	public static void AddTo<T>(this T obj,List<T> list) {
		list.Add(obj);
	}
}

Measured memory_bytes: 10764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

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

#define S second
#define F first
#define int long long  

//////////

int ans[101][100000+1]={};
signed main()
{
    fastio;
    // #ifndef ONLINE_JUDGE
    //     freopen("inputf.in","r",stdin);
    //     freopen("outputf.in","w",stdout);
    // #endif
    int n,W;
    cin>>n>>W;
    for(int i=0;i<=n;++i)
        for(int j=1;j<=100000;++j)
            ans[i][j]=inf;
    for(int i=1;i<=n;++i)
    {
        int w,v;
        cin>>w>>v;
        for(int j=0;j<=100000;++j)
        {
            ans[i][j]=ans[i-1][j];
            if(j-v>=0)
            ans[i][j]=min(ans[i][j],ans[i-1][j-v]+w);
        }
    }
    int an=0;
    for(int i=0;i<=100000;++i){
        if(ans[n][i]<=W)
            an=i;
    }
    cout<<an;
}

Measured memory_bytes: 79232
n=int(input())
a=list(map(int,input().split()))
if a.count(0)>0:
  a=list(map(abs,a))
  print(sum(a))
else:
  a.append(0)
  for i in range(n):
    if a[i]<0:
      a[i+1]*=-1
    if i!=n-1:
      a[i]=abs(a[i])
  if a[-2]>0:
    print(sum(a))
  else:
    a.pop(-1)
    a[-1]=abs(a[-1])
    print(sum(a)-2*min(a))

Measured memory_bytes: 14464
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        string ans = ":(";
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        if(inpt.All(a=>a<=8)) {
            ans = "Yay!";
        }
        Console.WriteLine(ans);
    }


    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"





8 8



";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}

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

int main(){
	string s;
	cin >> s;
	vector<int> c(s.size(),0);
	for(int i=0;i<s.size();i++){
		if(s[i]=='a')c[0]++;
		if(s[i]=='b')c[1]++;
		if(s[i]=='c')c[2]++;
	}
	if(c[0]==1 && c[1]==1 && c[2]==1)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define sz(v) ll(v.size())


void solve(ll N, ll W, vector<ll> w, vector<ll> v){
    ll dp[N+1][100001];
    ll mx = 0;
    rep(i, N) {
        mx += v[i];
    }
    fill(dp[0], dp[N+1], ll(1e9));
    rep(i, N) {
        rep(j, mx + 1) {
            if (j > v[i]) {
                dp[i+1][j] = min(dp[i][j-v[i]] + w[i], dp[i][j]);
            } else {
                dp[i+1][j] = min(w[i], dp[i][j]);
            }
        }
    }
    ll m = 0;
    rep(i, mx + 1) {
        if (dp[N][i] <= W) {
            m = i;
        }
    }
    cout << m << endl;
}

int main() {
    ll N;
    scanf("%lld",&N);
    ll W;
    scanf("%lld",&W);
    vector<ll> w(N);
    vector<ll> v(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&w[i]);
        scanf("%lld",&v[i]);
    }
    solve(N, W, move(w), move(v));
    return 0;
}


Measured memory_bytes: 79104
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second

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

string s;
int main() {
  cin >> s;
  int cnt = 0;
  int ans = s.size();
  rep(i,0,s.size()) {
    if(s[i] == 'T') {
      if(cnt > 0) {
        cnt--;
        ans -= 2;
      }
    } else {
      cnt++;
    }
  }
  P(ans);
  return 0;
}

Measured memory_bytes: 768
{-# OPTIONS_GHC -O #-}

import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.List
import Control.Monad.Trans.State.Strict
import Data.Char (isSpace)
import Data.Maybe (fromJust,fromMaybe,isNothing,isJust)
import qualified Data.ByteString.Lazy.Char8 as B

import Data.Array
import Data.Array.ST
import Data.Array.Unsafe

type Parser a = StateT B.ByteString Maybe a

parseInt :: Parser Int
parseInt = StateT (B.readInt . B.dropWhile isSpace)

parseInt2 :: Parser (Int,Int)
parseInt2 = liftM2 (,) parseInt parseInt

parseInt3 :: Parser (Int,Int,Int)
parseInt3 = liftM3 (,,) parseInt parseInt parseInt

parse :: Parser ((Int,Int), [(Int,Int,Int)])
parse = do
    (n,m)<-parseInt2
    rs<-replicateM m parseInt3
    return ((n,m),rs)

main=do
    ((n,m),rs)<-fromJust.evalStateT parse <$> B.getContents
    let da = wf n $ ml n rs
    print $ length $ filter (\(a,b,c)-> fmap (< c) (da!(a,b)) == Just True) rs

ml::Int->[(Int,Int,Int)]->[((Int,Int),Maybe Int)]
ml n rs =unfoldr phi (1,1,rs2)
    where
    rs2 = sort $ concatMap (\(u,v,l)->[(u,v,l),(v,u,l)]) rs
    phi (i,j,a)
        | i==n+1 = Nothing
        | (not.null) a && i==u && j==v = Just (((i,j),Just l), (ni,nj,x))
        | i==j = Just(((i,j),Just 0), (ni,nj,a))
        | i/=j = Just(((i,j),Nothing), (ni,nj,a))
        where
        nj = if j/=n then j+1 else 1
        ni = if j/=n then i else i+1
        ((u,v,l):x) = a

wf ::Int-> [((Int,Int),Maybe Int)] -> Array (Int,Int) (Maybe Int)
wf n g = foldl' psi (array ((1,1),(n,n)) g) $ replicateM 3 [1..n]
    where
    psi :: Array (Int,Int) (Maybe Int) -> [Int] -> Array (Int,Int) (Maybe Int)
    psi d [k,i,j] = runST $ do
        d' <- unsafeThaw d :: ST s (STArray s (Int,Int) (Maybe Int))
        dc <- readArray d' (i,j)
        dn <- liftA2 (+) <$> readArray d' (i,k) <*> readArray d' (k,j)
        when (isNothing dc || liftA2 (>) dc dn == Just True) $ writeArray d' (i,j) dn
        unsafeFreeze d'

Measured memory_bytes: 4476
N, Y = map(int, input().split())

def main():
    for num_10000 in range(N+1):
        for num_5000 in range(N+1-num_10000):
            num_1000 = N - num_10000 - num_5000
            if num_10000*10000 + num_5000*5000 + num_1000*1000 == Y:
                print(num_10000, num_5000, num_1000)
                return
    print('-1 -1 -1')

if __name__ == "__main__":
    main()

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

int main() {
  int64_t N, M, K, a, b;
  cin >> N >> M >> K;
  vector<int64_t> A(N+1);
  vector<int64_t> B(M+1);
  for (int64_t i=1; i<=N; i++) {
    cin >> a;
    A.at(i) = a + A.at(i-1);
  }
  for (int64_t i=1; i<=M; i++) {
    cin >> b;
    B.at(i) = b + B.at(i-1);
  }
  
  int64_t C=0, j=M;
  for (int i=0; i<=N; i++) {
    if (A.at(i) > K) {break;}
    while (B.at(j) > K - A.at(i)) {
      //cout << i << " " << j << " " << C << endl;
      j--;
    }
    C = max(C, i+j);
  }
  cout << C << endl;
}

Measured memory_bytes: 6412
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

int main(){
  int x,y; cin >> x >> y;
  if(y > x) swap(x, y);
  int tmp;
  while(y != 0){
    tmp = x % y;
    x = y;
    y = tmp;
    // cout << x << " " << y << "\n";
  }
  cout << x << "\n";
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
float temp(int t, int h);

int main(){
    int n;
    cin >> n;
    int h[n], dp[n];
    
    for(int i=0; i<=n; i++){
	cin >> h[i];	
    }
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);

    for(int i = 2; i<n; i++){
	dp[i] = min(dp[i-2]+abs(h[i] - h[i-2]), dp[i-1]+abs(h[i] - h[i-1]));
    }
    
    cout << dp[n-1] << "\n";
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#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 unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

struct E {
	int v, c;
	E(int v, int c) : v(v), c(c) {};
};

int N;
vector<E> G[100010];
int d[100010];
bool vis[100010];

signed main()
{
	cin >> N;

	rep(i, N - 1) {
		int u, v, w; cin >> u >> v >> w;
		--u, --v;
		G[u].PB(E(v, w));
		G[v].PB(E(u, w));
	}

	queue<int> q;
	q.push(0);

	memset(d, -1, sizeof d);
	d[0] = 0;
	vis[0] = true;

	while (q.size()) {
		int v = q.front(); q.pop();

		//printf("v=%lld\n",v+1);

		for (E &e : G[v]) {
			if (vis[e.v]) continue;
			vis[e.v] = true;
			d[e.v] = d[v] + e.c;
			q.push(e.v);
		}
	}

	rep(i, N) {
		printf("%lld\n", d[i] % 2);
	}
}



Measured memory_bytes: 8704
S = gets.chomp

@ans = 0
def solve(s, t)
  (@ans += eval(t); return) if s.empty?
  wk = s[0]
  solve(s[1..-1], t + '+' + wk)
  solve(s[1..-1], t + wk)
end

solve(S[1..-1], S[0])

puts @ans


Measured memory_bytes: 1916
import bisect
N=int(input())
L=sorted(list(map(int,input().split())))
ans=0
for i in range(N-2):
    for j in range(i+1,N-1):
        ab=L[i]+L[j]
        r=bisect.bisect_left(L,ab)
        l=j+1
        ans+=r-l
print(ans)

Measured memory_bytes: 3316
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    if N == 1:
        return print(1 if A[0] % 2 == 0 else 2)
    ans = 0
    d = (-1, 0, 1)
    from itertools import product
    for i in product(range(3), repeat=N):
        cur = 1
        for j in range(N):
            cur *= (A[j] + d[i[j]])
        if cur % 2 == 0:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41068
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] H = new int[N];
        for (int i = 0; i < N; i++){
            H[i] = sc.nextInt();
        }
        if(N==1){
            System.out.println("Yes");
            return;
        } else {
            for(int i = N-2; i >= 0; i--){
                if(H[i] <= H[i+1])
                    continue;
                if(H[i] == H[i+1] + 1)
                    H[i] = H[i] - 1;
                if(H[i] > H[i+1]){
                    System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");
        sc.close();        
    }
}


Measured memory_bytes: 50000
//Author: AnandRaj uux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define forn(i,f,n) for(int i=f;i<f+n;i++)
#define rforn(i,l,n) for(int i=l;i>l-n;i--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int i=f;i<f+n;i++) cin>>V[i]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 1e9+7,MAX = 1e5+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            {
				is_prime[j] = false;
    		}
    	}
	}
}
//////////////////Sieve////////////////////

int main()
{
	int n;
	cin>>n;
	while(n)
	{
		if(n%10==7) {cout<<"Yes"<<endl;return 0;}
		n/=10;
	}
	cout<<"No"<<endl;
}		

Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;

int main(){
  int n,m;
  int x[100000]={};
  int d[100000]={};
  int ans=0;

  cin >> n >> m;
  LOOP(i,m){
    cin >> x[i];
  }

  if(n>=m){
    cout << 0 << endl;
    return 0;
  }

  sort(x,x+m);
  LOOP(i,m-1){
    d[i] = x[i] - x[i+1];
  }
  sort(d,d+m-1);

  // LOOP(i,m){
  //   cout << x[i] << ":" << d[i] << endl;
  // }

  for(int i=n-1;i<m;i++){
    ans+=d[i];
  }
  ans *= -1;
  cout << ans;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int cnt[100010];

signed main()
{
    int N,K; cin>>N>>K;
    REP(i,N){
        int a,b; cin>>a>>b;
        cnt[a]+=b;
    }

    int sum=0;
    for(int i=1;i<=100000;i++){
        sum+=cnt[i];
        if(sum>=K){
            cout<<i<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1152
#define __mode_debug__
/*   ξ
     ll
   ＿ll＿
 ／  ∞  ＼
│*  Ａ  *│
│*  Ｃ  *│
│*  祈  *│
│*  願  *│
│*      *│
 ￣￣￣￣￣    */
//C++14 (GCC 5.4.1)
#include <bits/stdc++.h>
using namespace std;
#ifdef __mode_debug__
    #define DBG
#else
    #define DBG if(false)
#endif

#define LLINF (1LL<<60)
using ll = long long;
#define mod  1000000007

#define whole(a) (a).begin(),(a).end()
#define rwhole(a) (a).rbegin(),(a).rend()

#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(ll i=(a);i>=(b);i--)
#define each(itr,ds) for(auto itr=(ds).begin();itr!=(ds).end();itr++)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

//DUMP
//  ostream vector<T> , vector<vector<T>> , set<T> ,queue<T> , priority_queue<T> , pair<T,U> , map<T,U>
template<class T> ostream& operator<<(ostream&os,vector<T>&vec){os<<"{ ";rep(i,vec.size()) os<<((i==0)?"":", ")<<i<<":"<<vec[i];os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,vector<vector<T>>&vec){os<<"{"<<endl;rep(i,vec.size())os<<"\t   "<<i<<":"<<vec[i]<<((i==vec.size()-1)? "":",")<<endl;os<<"\t }";return os;}
template<class T> ostream& operator<<(ostream&os,set<T>&p){os<<"{ ";each(itr,p)  os<<((itr==p.begin())?"":", ")<<*itr;os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,queue<T>&p){queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.front();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T> ostream& operator<<(ostream&os,priority_queue<T>&p){priority_queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.top();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T,class U> ostream& operator<<(ostream&os,pair<T,U>&p){os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T,class U> ostream& operator<<(ostream&os,map<T,U>&p){os<<"{ ";each(itr,p)os<<((itr==p.begin())?"":", ")<<itr->first<<":"<<itr->second;os<<" }";return os;}
void dump_f(string &nm,char t){cerr<<endl;}
template<class T,class... Ts> void dump_f(string &nm,char t,T &&x,Ts&&... ts){int l=nm.find_first_of(',');string name(nm,0,l),nx(nm,l+1,-1);if(t=='\n') cerr<<"  "<<name<<"\t: "<<x<<t;else cerr << name<<": "<<x<<","<<t;dump_f(nx,t,forward<Ts>(ts)...);}
template<class... Ts> void dump_m(int &&ln,string &&nm,char t,Ts&&... ts){cerr<<"[ln: "<<ln<<"]"<<t;dump_f(nm,t,forward<Ts>(ts)...);}
#define dump(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\n',__VA_ARGS__)
#define dl(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\t',__VA_ARGS__)

#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(whole(V),c))

int main() {
    ios::sync_with_stdio(false);//stdout<=>cout
    cin.tie(nullptr);//cin<=>cout


    ll X;
    cin >>X;
    ll t=0,c=100;
    while(c<X){
        c+=c/100;
        t++;
    }

    cout << t <<endl;


    return (0);
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 200000000000
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()

bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    char C;
    cin >>C;
    
    cout << (char)(C+1) << endl;


    return 0;
    

}

Measured memory_bytes: 3524
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x, y;
  cin >> x >> y;
  cout << x + (y / 2) << endl;
  return 0;
}



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

const int MOD = 1e9 + 7;

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long ans = 0, maxn = 0;
	for(int i = 0; i < n; i++) {
		maxn = max(maxn, (long long) a[i]);
		ans += maxn - (long long) a[i];
	}
	cout << ans << '\n';
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int t = 1;
	// cin >> t;
	for(int tt = 1; tt <= t; tt++) {
		// cout << "Case #" << tt << ": ";
		solve();
	}
	return 0;
}



Measured memory_bytes: 3960
#include <iostream>

using namespace std;

int main() {
	int x, a, b, c;
	int ans = 0;
	cin >> a >> b >> c >> x;
	for (int i = 0; i <= a; ++i)
		for (int j = 0; j <= b; ++j)
			for (int k = 0; k <= c; ++k)
				if (i * 500 + j * 100 + k * 50 == x)
					++ans;
	cout << ans << endl;
}		

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

main()
{
  stack<int> S1;
  stack<pair<int, int> > S2;
  char ch;
  int sum = 0;
  for (int i = 0; cin >> ch; i++)
  {
    if (ch == '\\')
      S1.push(i);
    else if (ch == '/' && S1.size() > 0)
    {
      int l = S1.top();
      S1.pop();
      sum += i - l;
      int a = i - l;
      while (S2.size() > 0 && S2.top().first > l)
      {
        a += S2.top().second;
        S2.pop();
      }
      S2.push(make_pair(l, a));
    }
  }

  vector<int> ans;
  //  int t = 0;
  while (S2.size() > 0)
  {
    ans.push_back(S2.top().second);
    S2.pop();
  }
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();
  for (int i = 0; i < ans.size(); i++)
  {
    cout << " ";
    //    t += ans[i];
    cout << ans[i];
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 3232
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long long n;

	std::cin >> n;

	std::vector<long long> v(n);

	for (long long i = 0; i < n; i++)
	{
		std::cin >> v[i];
	}

	v[0] = v[0] - 1;
	for (long long i = 1; i < n; i++)
	{
		if (v[i] > v[i - 1]) {
			v[i]--;
		}
		if (v[i] < v[i - 1]) {
			std::cout << "No" << std::endl;
			return 0;
		}
	}

	std::cout << "Yes" << std::endl;

	return 0;
}


Measured memory_bytes: 1024
n,m = map(int, input().split())
number_list = []
for _ in range(n):
	KA = input().split()
	number_list.extend(KA[1:])
count = 0
for i in range(m + 1):
	if number_list.count(str(i)) == n:
		count += 1

print(count)

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

//公約数
void div(long long a, vector<long long> &n) {
  n.push_back(1);
  for (long long i = 2; i <= sqrt(a); i++)
    if (a % i == 0) n.push_back(i);
  if (n.at(n.size() - 1) == sqrt(a))
    for (long long i = n.size() - 2; i >= 0; i--)
      n.push_back(a / n.at(i));
  else
    for (long long i = n.size() - 1; i >= 0; i--)
      n.push_back(a / n.at(i));
  return;
}

void comdiv(long long a, long long b, vector<long long> &n) {
  if (a > b) swap(a, b);
  vector<long long> m(0);
  div(a, m);
  for (long long i = 0; i < m.size(); i++)
    if (b % m.at(i) == 0) n.push_back(m.at(i));
  return;
}

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  vector<long long> n(0);
  comdiv(c, d, n);
  unsigned long long m = c * d / n.at(n.size() - 1);
  long long cnt = b - a + 1, cmin, cmax, dmin, dmax, cdmin, cdmax;
  cmin = (a - 1) / c;
  cmax = b / c;
  dmin = (a - 1) / d;
  dmax = b / d;
  cdmin = (a - 1) / m;
  cdmax = b / m;
  long long cnum, dnum, cdnum;
  cnum = cmax - cmin;
  dnum = dmax - dmin;
  cdnum = cdmax - cdmin;
  cout << cnt - cnum - dnum + cdnum << endl;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
colors = 0
for i in range(8):
    colors += any(i * 400 <= a < (i + 1) * 400 for a in A)
print(max(colors, 1), end=' ')
colors += sum((i + 1) * 400 <= a for a in A)
print(colors)

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

int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    for (int i = 0; i < N; ++i) {
        int x;
        cin >> x;
        X = max(X, x);
    }

    for (int i = 0; i < M; ++i) {
        int y;
        cin >> y;
        Y = min(Y, y);
    }

    if (X < Y) {
        cout << "No ";
    }
    cout << "War" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[6];
    scanf("%s",a);
    int n=strlen(a);
    for(int i=0;i<n;i++)
    {
        if(a[i]=='A'&&a[i+1]=='C')
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
//                   ********** YATIN KWATRA **********

// AC BAKSHI RABBA

#include <bits/stdc++.h>
#define ll                      long long 
#define ld                      long double
#define ull                     unsigned long long 
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                     vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                     unordered_map                
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int> 
#define pll                     pair<long,long>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define pi                      3.1415926535897932384626433832795

using namespace std;

void INPUT() 
{  
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

/*
    
   -> Check For Overflows
   -> Out of Bounds
   -> Initialisations of global arrays and variables
   -> Its not Always Complex, Try to simplify
   -> write it down and try to solve
   -> Have Faith in urself and in ur approach
   -> If it seems totally out of reach, switch to next :)
   -> And Come Back later, if possible ..
*/


const int N = 100005;
ll dp[N][5];
pair<int,pii> v[N];
int n,k;

ll f(int pos, int pre)
{
    if(pos == n) return 0LL;

    if(dp[pos][pre] != -1) return dp[pos][pre];

    ll op1,op2,op3;

    op1 = op2 = op3 = 0;

    if(pre != 1) op1 = f(pos+1,1);
    if(pre != 2) op2 = f(pos+1,2);
    if(pre != 3) op3 = f(pos+1,3);

    ll ans = max(op1,max(op2,op3));

    if(pre == 1) ans += v[pos].ff;
    else if(pre == 2) ans += v[pos].ss.ff;
    else ans += v[pos].ss.ss;

    dp[pos][pre] = ans;
    
    return dp[pos][pre];
}

void solve()
{ 
      cin >> n;

      fo(i,0,n-1) cin >> v[i].ff >> v[i].ss.ff >> v[i].ss.ss;

      memset(dp,-1,sizeof(dp));

      cout << max(f(0,1),max(f(0,2),f(0,3))) << endl;


}
int main() {
    
    FIO
    INPUT();
    
    int t;
    t = 1;
    //cin >> t;
    
    while(t--)
    {
       solve();
    }
    return 0;
}


Measured memory_bytes: 13404
#include <bits/stdc++.h>
using namespace std;
#define int unsigned long long
#define ll unsigned long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vi a(n),s(n+1,0); 
    rep(i,n){
        cin >> a[i];
        s[i+1]=s[i]+a[i];
        //s[i+1]%=MOD;
    }
    int res=0;
    rep(i,n){
        res+=a[i]*((s[n]-s[i+1])%MOD)%MOD;
        res%=MOD;
    }
    cout<<res<<endl;
    
}

Measured memory_bytes: 6316
def a_darker_and_darker(H, W, Grid):
    def is_in_field(row, col):
        return (0 <= row < H) and (0 <= col < W)

    grid, q = [[None] * W for _ in range(H)], []
    # 黒マスがどこにあるかを調べる。ついでにgridを初期化
    for row in range(H):
        for col in range(W):
            if Grid[row][col] == '#':
                grid[row][col] = True
                q.append((row, col))
            else:
                grid[row][col] = False

    # '#'があるマスから上下左右に移動することを繰り返して任意のマスに到達する。
    # 何回繰り返せばすべてのマスに到達できるか？
    directions = ((-1, 0), (0, 1), (1, 0), (0, -1))  # 上右下左の隣接マスを指定
    ans = 0
    while q:
        tmp = []
        for row, col in q:
            for dr, dc in directions:
                nr, nc = row + dr, col + dc
                if is_in_field(nr, nc) and (not grid[nr][nc]):
                    grid[nr][nc] = True
                    tmp.append((nr, nc))
        ans += (1 if tmp else 0)
        q = tmp
    return ans

H, W = [int(i) for i in input().split()]
Grid = [input() for _ in range(H)]
print(a_darker_and_darker(H, W, Grid))

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

const int NIL = -1;

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

void preParse(Node T[], int u){
    if(u == NIL){
        return;
    }
    cout << " " << u;
    preParse(T, T[u].left);
    preParse(T, T[u].right);
}
void inParse(Node T[], int u){
    if(u == NIL){
        return;
    }
    inParse(T, T[u].left);
    cout << " " << u;
    inParse(T, T[u].right);
}
void postParse(Node T[], int u){
    if(u == NIL){
        return;
    }
    postParse(T, T[u].left);
    postParse(T, T[u].right);
    cout << " " << u;
}

int main(){
    int n, i, v, r, l, u;
    cin >> n;
    Node T[n];
    for(i=0; i<n; i++){ T[i].parent = T[i].left = T[i].right = NIL;}
    for(i=0; i<n; i++){
        cin >> v >> l >> r;
        T[v].left = l;
        T[v].right = r;
        if(l != NIL) T[l].parent = v;
        if(r != NIL) T[r].parent = v;
    }
    for(i=0; i<n; i++){
        if(T[i].parent == NIL) u = i;
    }
    cout << "Preorder\n";
    preParse(T, u);
    cout << endl << "Inorder\n";
    inParse(T, u);
    cout << endl << "Postorder\n";
    postParse(T, u);
    cout << endl;
}


Measured memory_bytes: 3096
#include <iostream>
#define INF 1e+9
using namespace std;

int main(){
	int n;
	cin >> n;
	for(int i = 0;i < n;i++){
		int y,m,d;
		cin >> y >> m >> d;
		d += (y - 1) / 3 * 200 + (y - (y - 1) / 3 - 1) * 195;
		if(y % 3 == 0){
			d += (m - 1) * 20;
		}else{
			d += (m - 1) / 2 * 19 + (m - (m - 1) / 2 - 1) * 20;
		}
		cout << 196471 - d << endl;
	}
	return 0;
}

Measured memory_bytes: 3100
#include<stdio.h>
#include <string.h>
int main()
{
    char h[4];
    scanf(" %s",h);
if(h[0]=='S'&&h[1]=='U'&&h[2]=='N'){
    printf("7\n");
}
      else if(h[0]=='M'&&h[1]=='O'&&h[2]=='N'){
    printf("6\n");
}
else if(h[0]=='T'&&h[1]=='U'&&h[2]=='E'){
    printf("5\n");
} else if(h[0]=='W'&&h[1]=='E'&&h[2]=='D'){
    printf("4\n");
} else if(h[0]=='T'&&h[1]=='H'&&h[2]=='U'){
    printf("3\n");
}
else if(h[0]=='F'&&h[1]=='R'&&h[2]=='I'){
    printf("2\n");
}
else if(h[0]=='S'&&h[1]=='A'&&h[2]=='T'){
    printf("1\n");
}


    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,k;
ll m;
ll dp[305][305];
ll dp2[305][305];

int main(void){
	scanf("%d%d%lld",&n,&k,&m);
	dp2[0][0]=1;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			dp2[i+1][j]+=dp2[i][j];
			dp2[i+1][j]%=m;
			dp2[i+1][j+1]+=(ll)dp2[i][j]*(i+1-j)%m;
			dp2[i+1][j+1]%=m;
		}
	}
	dp[0][0]=1;
	for(int i=0;i<=n;i++){
		dp[1][i]=1;
	}
	for(int i=1;i<=k;i++){
		for(int j=0;j<=n;j++){
			for(int k=0;k<=n-j;k++){
				dp[i+1][j+k]+=dp[i][j]*dp2[j+k][k]%m;
				dp[i+1][j+k]%=m;
			}
		}
	}
	printf("%lld\n",dp[k][n]);
	return 0;
}

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

int main() {
	int n;
	long ans;
	string s;
	cin >> n >> s;
	vector<int> r,g,b;
	for(int i = 0; i<s.size();i++){
		if(s[i] == 'R')r.push_back(i);
		else if(s[i] == 'G')g.push_back(i);
		else b.push_back(i);
	}
	ans = r.size() * g.size() * b.size();

	for(int i = 1; i<= s.size() / 2;i++){
		for(int j = i; j<s.size() - i;j++){
			if(s[j - i] !=s[j] && s[j - i] !=s[j + i] && s[j] !=s[j + i])ans--;
		}
	}
	cout << ans << endl;
 }



Measured memory_bytes: 3668
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;



int main(){
  string s;
  cin >> s;
  if (s[2]==s[3] && s[4]==s[5]) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 256
import numpy as np

c = []
for i in range(3):
    c.append(list(map(int, input().split())))

ans = []

c = np.array(c)
ch = np.diff(c)

if np.all(ch[0]==ch[1]) & np.all(ch[1]==ch[2]):
    ans.append(True)
else:
    ans.append(False)

cw = np.diff(c.T)

if np.all(cw[0]==cw[1]) & np.all(cw[1]==cw[2]):
    ans.append(True)
else:
    ans.append(False)

ans = "Yes" if all(ans) else "No"
print(ans)

Measured memory_bytes: 12504
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    if (a + b + c >= 22) {
      System.out.println("bust");
    } else {
      System.out.println("win");
    }
  }
}


Measured memory_bytes: 21716
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        w: [String; n],
    }

    use std::collections::HashSet;

    if w.len() != w.iter().collect::<HashSet<_>>().len() {
        println!("No");
        return;
    }

    for pair in w.windows(2) {
        let a = pair[0].chars().last().unwrap();
        let b = pair[1].chars().next().unwrap();
        if a != b {
            println!("No");
            return;
        }
    }

    println!("Yes");
    return;
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n; cin>>n;
    int p[4], t[4];
    for(int i=0; i<4; i++) cin>>p[i];
    for(int i=0; i<4; i++) cin>>t[i];
    int ans=1e9+7;
    for(int a=0; a<=n; a++){
        for(int b=0; b<=n; b++){
            for(int c=0; c<=n; c++){
                for(int d=0; d<=n; d++){
                    if(t[0]*a+t[1]*b+t[2]*c+t[3]*d>=n){
                        ans=min(ans, p[0]*a+p[1]*b+p[2]*c+p[3]*d);
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;

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

int main() {
    char c;
    cin >> c;
    if(c == 'A') cout << 'T' << endl;
    else if(c == 'T') cout << 'A' << endl;
    else if(c == 'C') cout << 'G' << endl;
    else cout << 'C' << endl;
    
    return 0;
}

Measured memory_bytes: 3604
def read_input():
    n = int(input())
    k = int(input())
    return n, k

def submit():
    n, k = read_input()

    curr = 1
    for i in range(n):
        p1 = curr * 2
        p2 = curr + k

        curr = min(p1, p2)

    print(curr)


if __name__ == '__main__':
    submit()

Measured memory_bytes: 38384