akhauriyash/Code-Regression huggingface dataset:
/*H - Grid 1*/

#include <bits/stdc++.h>

using namespace std;

using Long = long long;
const Long mod = Long(1e9) + 7;

Long memo[1001][1001];

Long roads(const vector < vector <char> >& mat, int x, int y, const int& h, const int& w);

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int h, w;
	cin >> h >> w;

	vector < vector <char> > mat(h, vector <char> (w));

	memset(memo, -1, sizeof memo);

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

	cout << roads(mat, 0, 0, h, w);



	return 0;
}


Long roads(const vector < vector <char> >& mat, int x, int y, const int& h, const int& w){

	if(x == h - 1 and y == w - 1){
		return 1;
	}

	if(memo[x][y] == -1){

		Long aux = 0ll;

		if(x + 1 < h and mat[x + 1][y] == '.'){
			aux += roads(mat, x + 1, y, h, w);
			aux %= mod;
		}

		if(y + 1 < w and mat[x][y + 1] == '.'){
			aux += roads(mat, x, y + 1, h, w);
			aux %= mod;
		}

		memo[x][y] = aux;
		
	}


	return memo[x][y];

}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define powerof2 ()
#define mp make_pair
#define pi acos(-1)
using ll = long long;
const ll M = 1000000007;
const ll M1= 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
ll power(ll x,ll y){
	if(y==0)
		return 1;
	ll res=power(x,y/2);
	res=(res*res);
	if(y&1)
		res=(res*x);
	return res;
}
 
ll powermod(ll x,ll y,ll mod){
	if(y==0)
		return 1;
	ll res=powermod(x,y/2,mod);
	res=(res*res)%mod;
	if(y&1)
		res=(res*x)%mod;
	return res;
}
/*ll binarysearch(ll va)
{
	ll n=1;
	ll l=va+1,u=n;
	ll st=num.order_of_key(va);
	while(l+1<u)
	{
		m=(l+u)/2;
		ll in=num.order_of_key(m);
		if(in-st==m-va)
		{
			l=m;
		}
		else
		{
            u=m;
		}
	}
	if(num1.find(l)==num1.end())
		return l;
	return u;
}*/
void solve(){
	int n,k,q;
	cin>>n>>k>>q;
	int a[q+1];
	int s[n+1],p[n+1]={0};
	for(int i=1;i<=n;i++) s[i]=k;
 	for(int i=1;i<=q;i++){cin>>a[i];p[a[i]]++;}
	for(int i=1;i<=n;i++){
		s[i] -=q;
	s[i] += p[i];
		//cout<<s[i]<<" ";
		if(s[i]>0) cout<<"Yes"<<"\n";
		else cout<<"No\n";
	}
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
 
    for(int i=1;i<=t;i++)
    {//cout<<"Case #"<<i<<": ";
    solve();}
    return 0;
}

Measured memory_bytes: 4772
N = int(input())
xy = []
for i in range(N):
    A = int(input())
    xy.append([])
    for j in range(A):
        xy[i].append(tuple(map(int, input().split())))

ans = 0

for i in range(2 ** N):
    h = [0] * N

    for j in range(N):
        if (i >> j) & 1:
            h[j] = 1
    
    flag = False
    for i in range(N):
        if h[i] == 1:
            for x, y in xy[i]:
                if h[x-1] != y:
                    flag = True
                    break
            if flag:
                break
    
    if not flag:
        ans = max(ans, sum(h))

print(ans)

Measured memory_bytes: 3064
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

int n;
int ar[N];

int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> ar[i];
    }
    int best = 1e9;
    for(int i = 1; i <= n; i++){
        int a = 0 , b = 0;
        for(int j = 1; j <= i; j++){
            a += ar[j];
        }
        for(int j = i+1; j <= n; j++){
            b += ar[j];
        }
        best = min(best , abs(a - b));
    }
    cout << best << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

std::random_device rnd;
const ull mul[2] = {10000 + (rnd()%10000), 10000 + (rnd()%10000)};
const ull mod[2] = {1000000007, 1000000009};

class RollingHash {
public:
    RollingHash() {}
    template<class T>
    RollingHash(const T& s) {
        init(s);
    }
    template<class T>
    void init(const T& s) {
        n = s.size();
        for (int i = 0; i < 2; i++) {
            pow[i].resize(n+1);
            h[i].resize(n+1);
            pow[i][0] = 1; h[i][0] = 0;
        }
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < n; j++) {
                pow[i][j+1] = (mul[i]*pow[i][j]) % mod[i];
                h[i][j+1] = (s[j] + h[i][j]*mul[i]) % mod[i];
            }
        }
    }
    inline pair<ull, ull> hash(int i) const {return make_pair(h[0][i], h[1][i]);}
    // [l, r)
    inline pair<ull, ull> hash(int l, int r) const {
        ull p0 = (h[0][r] - (h[0][l]*pow[0][r-l]%mod[0]) + mod[0]) % mod[0];
        ull p1 = (h[1][r] - (h[1][l]*pow[1][r-l]%mod[1]) + mod[1]) % mod[1];
        return make_pair(p0, p1);
    }
private:
    int n;
    vector<ull> pow[2], h[2];
};

const int MAXN = 500100;
vector<int> divs[MAXN];

// [l, r)
bool isGood(const RollingHash& rh, int l, int r) {
    int n = r-l;
    for (int d : divs[n]) {
        if (rh.hash(l, r-d) == rh.hash(l+d, r)) return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    {
        vector<int> cnt(26);
        for (char c : s)
            cnt[c-'a']++;
        for (int i = 0; i < 26; i++) {
            if (cnt[i] == n) {
                cout << n << endl;
                cout << 1 << endl;
                return 0;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 2*i; j <= n; j += i) {
            divs[j].push_back(i);
        }
    }
    RollingHash rh(s);
    if (isGood(rh, 0, n)) {
        cout << 1 << endl;
        cout << 1 << endl;
        return 0;
    }
    int ans = 0;
    for (int i = 1; i < n; i++) {
        if (isGood(rh, 0, i) && isGood(rh, i, n)) ans++;
    }
    cout << 2 << endl;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 71964
import java.util.*;
class Main
{
    static long mod = 1000000007;
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextLong();
        }
        long[] b = new long[n+1];
        b[0] = 0;
        for(int i = 1; i <= n; i++){
            b[i] = (b[i-1] + pow(i, mod - 2)) % mod;
        }
        long ans = 0;
        for(int i = 0; i < n; i++){
            ans += a[i] * (b[i+1] + b[n - i] - 1);
            ans %= mod;
        }
        for(int i = 1; i <= n; i++){
            ans *= i;
            ans %= mod;
        }
        System.out.println(ans);
    }
    static long pow(long a, long p){
        if(p == 0) return 1;
        else if(p % 2 == 0){
            long d = pow(a, p/2);
            return d * d % mod;
        }
        else return pow(a, p-1) * a % mod;
    }
}

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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

ll a, b, n, r = -1;

int main()
{
	cin >> a >> b >> n;
	if (n >= b - 1)
		cout << (a * (b - 1)) / b;
	else
		cout << (a * n) / b;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
signed main(){
    string s; cin>>s;
    reverse(s.begin(),s.end());
    vector<string> t={"dream","dreamer","erase","eraser"};
    for(int i=0; i<4; i++) reverse(t.at(i).begin(),t.at(i).end());
    for(int i=0; i<s.size(); i++){
        for(int j=0; j<4; j++){
            if(s.substr(i,t.at(j).size())==t.at(j)){
                i+=t.at(j).size()-1;
                break;
            }
            if(j==3){
                cout<<"NO"<<endl; return 0;
            }
        }
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
	
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
	
using namespace std;
	
using ll = long long;
using ld = long double;
using ull = unsigned long long;
	
signed main(){
	io();
	string s, t; cin >> s >> t;
	int n = int(s.size()), m = int(t.size());
	int df[n + 1][m + 1]; memset(df, 0, sizeof(df));
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= m; ++j){
			df[i][j] = s[i - 1] == t[j - 1] ? df[i - 1][j - 1] + 1 : max(df[i - 1][j] , df[i][j - 1]);
		}
	}
	string ans = "";
	while(n > 0 && m > 0){
		if(s[n - 1] == t[m - 1]){
			ans += t[m - 1];
			--n, --m;
		}else if(df[n - 1][m] > df[n][m - 1]){
			--n;
		}else{
			--m;
		}
	}
	reverse(all(ans));
	return cout << ans << '\n', 0;
}

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

int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }

    sort(a.begin(),a.end());
    vector<bool> f(a.back()+1,true);

    int ans=0;
    for(int i=0;i<a.size();i++){
        if(f[a[i]]){
            for(int j=2;a[i]*j<f.size();j++){
                f[a[i]*j] = false;
            }
        }
    }

    rep(i,n-1){
        if(a[i]==a[i+1]){
            f[a[i]]=false;
        }
    }

    rep(i,n){
        if(f[a[i]]){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int N = s.size();
  for (int i = 0; i < (int)N; ++i) { cout << s[N - 1 - i]; }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3136
import java.io.*;
import java.util.*;
class Main{
  static Node root = null;
  static StringBuilder bl = new StringBuilder();
  public static void main(String args[])throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    String [] s = new String[2];
    for(int i = 0; i<n; i++){

      s = br.readLine().split("\\s+");

      if(s[0].charAt(0) == 'i'){
        Insert( Integer.parseInt(s[1]));
      }
      else if(s[0].charAt(0) == 'p'){
        inorder(root);
        bl.append("\n");
        preorder(root);
        bl.append("\n");
      }else{
        if( find(root, Integer.parseInt(s[1]))){
          bl.append("yes\n");
        }else{
          bl.append("no\n");
        }
      }
    }
    System.out.print(bl);
  }
  
  static void Insert (int k){
    Node y = null;
    Node x = root;
    Node z = new Node();
    z.key = k;
    z.left = null;
    z.right = null;

    while(x != null){
      y = x;
      if(z.key < x.key){
        x = x.left;
      }else{
        x = x.right;
      }
    }
    z.parent = y;

    if( y == null){
      root = z;
    }else if( z.key < y.key){
      y.left = z;
    }else{
      y.right = z;
    }
  }

  static boolean find(Node u, int k){
    while( u != null){
      if(k == u.key){
        return true;
      }
      if(k<u.key){
        u = u.left;
      }else{
        u = u.right;
      }
    }
    return false;
  }

  static void preorder(Node u){
    if( u == null) return;
    bl.append(" ").append(u.key);
    preorder(u.left);
    preorder(u.right);
  }

  static void inorder(Node u){
    if(u == null) return;
    inorder(u.left);
    bl.append(" ").append(u.key);
    inorder(u.right);
  }

}

class Node{
  int key;
  Node parent;
  Node right;
  Node left;
  Node(){};
}


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

long long n, q;

const long long N = 200010;
vector<long long> G[N];
vector<long long> Count(N, 0);
vector<bool> seen(N);

void dfs(long long now, long long cnt){
    seen[now] = true;
    for(long long i = 0; i < G[now].size(); i++){
        long long to = G[now][i];
        if(seen[to]) continue;
        dfs(to, cnt + Count[now]);
    }
    Count[now] += cnt;
    return;
}

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

    cin >> n >> q;
    for(long long i = 0; i < n - 1; i++){
        long long a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    while(q--){
        long long p, x;
        cin >> p >> x;
        p--;
        Count[p] += x;
    }

    dfs(0, 0);

    for(long long i = 0; i < n; i++){
        cout << Count[i] << ' ';
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 24320
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	ll N=in<ll>();

	if(N%2LL){
		out(0);
		return 0;
	}

	ll S=0;
	while(N){
		S += N/10LL;
		N /= 5LL;
	}

	out(S);
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int X = sc.nextInt();
		
		for(int i=0;i<(K*2)-1;i++) {
			int y=(X+1)-K+i;
			if(y<-1000000 || y>1000000) {
				break;
			}
			System.out.print(y+" ");
		}
		
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll a, b, k;
int main() {
    cin>>a>>b>>k;

    while(k>0){
        if(a%2!=0) a--;
        b+=a/2;
        a/=2;
        k--;
        if(k<=0) break;

        if(b%2!=0) b--;
        a+=b/2;
        b/=2;
        k--;
    }

    cout<<a<<" "<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
items = []
for i in range(n):
    a, b = input().split()
    a = str(a)
    b = int(b)
    z = {"id": i+1, "name": a, "score": b}
    items.append(z)
sorted_items = sorted(items, key = lambda x: (x["name"], -x["score"]))
for a in sorted_items:
    print(a["id"])


Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int c =  1;
		for(int i = 0; i < N  - 1; i++){
			c *= (K - 1);
		}
		c = K * c;
		System.out.println(c);
	}
}

Measured memory_bytes: 23508
N, K = map(int, input().split())
H = list(map(int, input().split()))

if N <= K:
    print(0)
    exit()
if K == 0:
    print(sum(H))
    exit()


# 大きいやつからK体を0にして，残りは和
H = sorted(H)
total = sum(H)
kill = sum(H[-K:])
print(total - kill)


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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  ll L, R;
  ll ans = 1 << 30;
  ll i, j;
  cin >> L >> R;

  for (i = L; i <= L + 2019 && i <= R; ++i) {
    for (j = i + 1; j <= j + 2018 && j <= R; ++j) {
      if (((i * j) % 2019) < ans) {
        // cout << i << "," << j << "," << (i * j) % 2019 << endl;
        ans = (i * j) % 2019;
      }
      if (ans == 0) {
        cout << ans << endl;
        return 0;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
N = int(input())
W = list(map(int, input().split()))
minval = 999
sumall = sum(W)
for idx,val in enumerate(W):
    presum = sum(W[:idx])
    aftsum = sumall - presum
    if abs(aftsum - presum) <= minval:
        minval = abs(aftsum - presum)

print(minval)





Measured memory_bytes: 3060
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Control.Monad         (forM_)
import qualified Data.Array.ST         as MA
import           Data.Array.Unboxed    (UArray, (!))
import qualified Data.Array.Unboxed    as A
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  [n, k] <- readInts <$> BS.getLine
  xycs <- map readInt2Char . BS.lines <$> BS.getContents
  print $ solve n k xycs

solve :: Int -> Int -> [(Int, Int, Char)] -> Int
solve n k xycs = maximum [max c (n - c) | x <- [1 .. k], y <- [1 .. k], let c = count x y] where
  xys = map (convert k) xycs
  xys' = A.accumArray (+) 0 ((0, 0), (2 * k - 1, 2 * k - 1))
    [((x, y), 1) | (x, y) <- xys] :: UArray (Int, Int) Int
  bss = cumSum2 xys'
  count x y = count' 0 0 x y
    + count' (x + k) 0 (2 * k) y
    + count' x y (x + k) (y + k)
    + count' 0 (y + k) x (2 * k)
    + count' (x + k) (y + k) (2 * k) (2 * k)
  count' x y x' y' = bss ! (x', y') - bss ! (x, y') - bss ! (x', y) + bss ! (x, y)

cumSum2 :: UArray (Int, Int) Int -> UArray (Int, Int) Int
cumSum2 xss = MA.runSTUArray $ do
  let ((w0, h0), (w1, h1)) = A.bounds xss
  yss <- MA.newArray ((w0, h0), (w1 + 1, h1 + 1)) 0
  forM_ [w0 + 1 .. w1 + 1] $ \i -> do
    forM_ [h0 + 1 .. h1 + 1] $ \j -> do
      let x = xss ! (i - 1, j - 1)
      a <- MA.readArray yss (i - 1, j)
      b <- MA.readArray yss (i, j - 1)
      c <- MA.readArray yss (i - 1, j - 1)
      MA.writeArray yss (i, j) $ x + a + b - c
  return yss

convert :: Int -> (Int, Int, Char) -> (Int, Int)
convert k (x, y, 'B') = (x `mod` (2 * k), y `mod` (2 * k))
convert k (x, y, 'W') = convert k (x, y + k, 'B')
convert _ _           = undefined

readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

readInts :: BS.ByteString -> [Int]
readInts = map readInt . BS.words

readInt2Char :: BS.ByteString -> (Int, Int, Char)
readInt2Char = (\[a, b, c] -> (readInt a, readInt b, BS.index c 0)) . BS.words


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

int main()
{
    int n, k; cin>>n>>k;
    map<int, int> a;
    for(int i=0; i<n; ++i) {
        int t; cin>>t;
        ++a[t];
    }
    /*
    priority_queue<int> q;
    for(auto& e: a) q.push(-e.second);

    long res=0;
    for(; q.size()>k; q.pop()) res-=q.top();
    cout<<res<<endl;
    */
    vector<int> v;
    for(auto& e: a) v.push_back(e.second);

    long res=0;
    for(sort(rbegin(v), rend(v)); v.size()>k; v.pop_back()) res+=v.back();
    cout<<res<<endl;

}


Measured memory_bytes: 10748
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef set<int>        si;
typedef set<ii>         sii;

#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define clr(x,v) memset(x,v,sizeof x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define re return

template<typename T> T sgn (T x)      {re x<0? -1:(x>0? 1:0); }
template<typename T> T gcd (T a, T b) {re a ? gcd (b % a, a) : b; }
template<typename T> T abs (T x)      {re x < 0 ? -x : x; }
template<typename T> T sqr (T x)      {re x*x;}

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define popcount __builtin_popcount
#define mp make_pair
#define pb push_back
#define ins insert
#define sc second
#define fr first
#define endl "\n"
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)

int n, v[N][3] , dp[N][3],mai;

void solve(){
    cin >> n;
    forn(i,0,n)cin >> v[i][0] >> v[i][1] >> v[i][2];
    for(int i=n-1;i>=0;i--){
        forn(j,0,3){
            mai=0;
            forn(k,0,3) if(k^j)mai = max(mai,dp[i+1][k]);
            dp[i][j] = v[i][j] + mai;
        }
    }
    cout << max({dp[0][0],dp[0][1],dp[0][2]  }) << endl;
}
int main(){_
    solve();
    /*
    int t; cin >> t;
    while(t--){
        solve();
    }
    */
}


Measured memory_bytes: 3456
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cassert>

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const int MAXN=101;

int h,w;
char mp[MAXN][MAXN];

int find_r()
{
	for(int i=1;i<=h;i++)
	{
		bool f=1;
		for(int j=1;j<=w;j++) f&=(mp[i][j]=='.');
		if(f) return i;
	}
	return 0;
}

int find_l()
{
	for(int j=1;j<=w;j++)
	{
		bool f=1;
		for(int i=1;i<=h;i++) f&=(mp[i][j]=='.');
		if(f) return j;
	}
	return 0;
}

int main()
{
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++) scanf("%s",mp[i]+1);
	int t;
	while((t=find_r()))
	{
		for(int i=t;i<h;i++)
			for(int j=1;j<=w;j++)
				mp[i][j]=mp[i+1][j];
		h--;
	}
	while((t=find_l()))
	{
		for(int j=t;j<w;j++)
			for(int i=1;i<=h;i++)
				mp[i][j]=mp[i][j+1];
		w--;
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
			printf("%c",mp[i][j]);
		puts("");
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

const ll N=2e5+5;
ll n,m,top,a[N],fst[N],lst[N],nxt[N],vis[N],s[N],ans[N],k;

int main() {
  cin >> n >> k;
  for(ll i=1;i<=n;i++) {
    cin >> a[i];
    if(!fst[a[i]]) fst[a[i]]=i;
  }
  nxt[n+1]=1;
  for(ll i=n;i;i--) {
    if(!lst[a[i]]) nxt[i]=fst[a[i]]+1; 
    else nxt[i]=nxt[lst[a[i]]+1];
    lst[a[i]]=i;
  }
  for(ll i=1;!vis[i];i=nxt[i]) {
    vis[i]=1;
    s[++m]=i;
  }
  memset(vis,0,sizeof(vis));
  for(ll i=s[(k-1)%m+1];i<=n;i++) {
    if(!vis[a[i]])ans[++top]=a[i],vis[a[i]]=1;
    else {
      do{
        vis[ans[top--]]=0;
      } while(ans[top+1]!=a[i]);
    }
  }
  for(ll i=1;i<=top;i++) {
    if(i!=1) cout << " ";
    cout << ans[i];
  }
  cout << endl;
}

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

using namespace std;

const int MAXN = 100010;

int n;

bool dp[MAXN];

string s;
string special[] = { "dream" , "dreamer" , "erase" , "eraser" };

bool isEqual(int L, int ind)
{
	for(int i = 0 ; i < special[ind].size() ; i++)
	{
		if( L + i >= n ) return false;
		if( s[L + i] != special[ind][i] ) return false;
	}

	return true;
}

int main()
{
	cin >> s;

	n = s.size();

	dp[n] = true;

	for(int i = n - 1 ; i >= 0 ; i--)
	{
		for(int j = 0 ; j < 4 ; j++)
		{
			bool aux = isEqual( i , j );

			aux = aux && dp[ i + special[j].size() ];

			dp[i] = dp[i] || aux;
		}
	}

	if( dp[0] ) printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int numValue = sc.nextInt();
        
        List<Integer> list = new ArrayList<Integer>();
        
        for(int i = 0; i < numValue; i++){
            list.add(sc.nextInt());
        }
        
        List<Integer> sortList = new ArrayList<Integer>(list);
        
        for(int i = sortList.size()-1; i > 0; i--){
            System.out.print(list.get(i) + " ");
        }
        // List<Integer> reverseList = new ArrayList<Integer>(list);
        // Collections.reverse(reverseList);
        System.out.println(list.get(0));
    }
}


Measured memory_bytes: 26412
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int a, b, h;
	cin >> a >> b >> h;
	print((a + b)*h / 2);
}

Measured memory_bytes: 3576
import numpy as np

k,n = map(int,input().split())
a_ls = list(map(int,input().split()))

next_ls = [0] * n
for i in range(n-1):
    next_ls[i] = a_ls[i+1] - a_ls[i]
next_ls[n-1] = k - a_ls[-1] + a_ls[0]
argmax = np.argmax(next_ls)
next_ls.pop(argmax)
print(sum(next_ls))

Measured memory_bytes: 34136
x = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))

i = 0

p = [t-j*0.006 for j in h]
q = [abs(a-j) for j in p]
ans_bef = q.index(min(q))
print(ans_bef + 1)


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

import sys
from math import factorial

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD

N = INT()
A = [0] + LIST()
B = [A[i+1] - A[i] for i in range(N)]

add = factorial(N-1) % MOD
# スライムが区間iを通る合計回数をそれぞれ求める
cnt = [0] * N
for i in range(1, N):
    cnt[i] = cnt[i-1] + add
    cnt[i] %= MOD
    add *= fermat(i ,i+1, MOD)
    add %= MOD

ans = 0
for i in range(1, N):
    # 区間長を掛ければ合計距離
    ans += B[i] * cnt[i]
    ans %= MOD
print(ans)


Measured memory_bytes: 15640
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repn(i,a,b) for (int i = a; i >=b ;i--)
#define MOD 1000000007


int main(){
ios::sync_with_stdio(0);
cin.tie(0);
    ll n,m;cin>>n>>m;
    int ht[n+1];
    rep(i,1,n+1)cin>>ht[i];
    vector<int> adj[n+1];
    int tmp1,tmp2;
    rep(i,0,m){
        cin>>tmp1>>tmp2;
        adj[tmp1].push_back(tmp2);
        adj[tmp2].push_back(tmp1);
    }
    ll cnt=n;
    rep(i,1,n+1){
        for(auto x: adj[i]){
            //cout<<i<<" "<<ht[i]<<" "<<x<<" "<<ht[x]<<"\n";
            if(ht[i]<=ht[x]){
                cnt--;
                break;
            }
        }
    } 
    cout<<cnt<<" ";
    //for(auto x : adj[4])cout<<x<< " ";
return 0;
}

Measured memory_bytes: 9168
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long MOD=1e9+7;
int main() {
	int n;
	cin >> n;
	vector <int> a(n);
	for (int i=0; i<n; i++) cin >> a[i];
	sort(a.begin(),a.end());
	long long ans=1;
	int t=0;
	if (n==1) t=0;
	else t=1;
	int knull=0;
	for (int i=0; i<n; i++){
		if (a[i]==0) knull++;
		if (i>0 && a[i-1]!=a[i]) t=1;
		if (i>0 && a[i-1]==a[i]) t++;
		if (t==2) ans=(ans*2)%MOD;
		if (t>2) knull=5;
	}
	if (knull>1 || t==1) cout << 0;
	else cout << ans;
 	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
	int A,B,C,D;
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	scanf("%d",&D);
	int ans;
	if(A>=B)	ans = B;
	else		ans = A;
	if(C>=D)	ans+=D;
	else		ans+=C;
	printf("%d",ans);
	return 0;}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MAX 51
#define MOD 1000000007
using namespace std;
typedef long long ll;

struct MAT {
    ll m[MAX][MAX];
    MAT () {
        memset(m, 0, sizeof m);
    }
};

void printer(MAT y, int sz) {
    for(int i = 0; i < sz; ++i, printf("\n"))
        for(int j = 0; j < sz; ++j)
            printf("%lld ", y.m[i][j]);
    printf("\n");
}

MAT mul(MAT a, MAT b, int p, int q, int r) {
    MAT c = MAT();
    memset(c.m, 0, sizeof c.m);
    for(int i = 0; i < p; ++i)
        for(int j = 0; j < r; ++j)
            for(int k = 0; k < q; ++k) {
                c.m[i][j] = (c.m[i][j] + (a.m[i][k] * b.m[k][j])%MOD);
                if(c.m[i][j] > MOD)
                    c.m[i][j] -= MOD;
            }
    return c;
}

MAT pow(MAT x, ll p, int sz) {
    if(p == 1)
        return x;
    MAT ret;
    for(int i = 0; i < sz; ++i) ret.m[i][i] = 1;
    while(p > 0) {
        if(p&1) ret = mul(ret, x, sz, sz, sz);
        p = p >> 1, x = mul(x, x, sz, sz, sz);
        //printf("Pow %lld\n", p);
        //printer(ret, sz);
        //printer(x, sz);
    }
    return ret;
}



int main() {
    ll n, k;
    cin >> n >> k;

    MAT x;
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            cin >> x.m[i][j];

    x = pow(x, k, n);

    ll ans = 0;
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j) {
            ans += x.m[i][j];
            if(ans > MOD)
                ans -= MOD;
        }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int, ii> iii;
 
ll pwr(ll base, ll p, ll mod=MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}


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


int r, c, cnt[30];
char arr[1002][1002];
int sz[10002], par[10002];

int root(int v){
	if(par[v] == v)	return v;
	return par[v] = root(par[v]);
}

void unite(int a, int b){
	a = root(a), b = root(b);
	if(a == b)	return;
	if(sz[a] < sz[b])	swap(a, b);
	sz[a] += sz[b];
	par[b] = a;
}


int get_index(int i, int j){
	return i*c+j;
}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin>>r>>c;
    for(int i=0;i<r*c;i++){
    	sz[i] = 1;	par[i] = i;
    }

    for(int i=0;i<r;i++){
    	cin>>arr[i];
    	for(int j=0;j<c;j++){
    		unite(get_index(i, j), get_index(r-1-i, j));
    		unite(get_index(i, j), get_index(i, c-1-j));
    		cnt[arr[i][j]-'a']++;
    	}
    }

    priority_queue<int> pq1, pq2;
    for(int i=0;i<26;i++)
    	pq1.push(cnt[i]);
    for(int i=0;i<r*c;i++)
    	if(i == root(i))
    		pq2.push(sz[i]);

    while(!pq2.empty()){

    	if(pq1.empty() || pq1.top() == 0){
    		cout<<"No";
    		return 0;
    	}

    	int a = pq2.top();
    	pq2.pop();
    	int b = pq1.top();
    	pq1.pop();

    	if(b < a){
    		cout<<"No";
    		return 0;
    	}
    	pq1.push(b - a);
    }

    cout<<"Yes";
    return 0;
}







 




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



int main(){
  ll x;
  cin >> x;
  ll ans = (x / 11) * 2;
  ll rest = x % 11;
  if (rest > 0 && rest <= 6) ans++;
  else if (rest > 6) ans += 2;
  cout << ans << endl;
}

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

int main() {
    string str;
    cin>>str;
    ll sum1=0;
    ll sum2=0;
    rep(i,str.size()){
        if(i%2==0){
            if(str[i]!='1'){
                sum1++;
            }else {
                sum2++;
            }
        }else{
            if(str[i]!='0'){
                sum1++;
            }else {
                sum2++;
            }
        }
    }
    cout<<min(sum1,sum2)<<endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>

int main(void){
    int n, a;
    std::cin >> n;
    double ans;
    double tmp = 0;
    for(int i = 0; i < n; i++){
        std::cin >> a;
        tmp += 1.0 / a;
    }
    ans = 1/ tmp;
    std::cout << std::fixed << std::setprecision(15) << ans << std::endl;
    return 0;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define f(i,a,b) for(ll int i=a;i<b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define maxv(a,b) *max_element(a, b)
#define minv(a,b) *min_element(a, b)
#define cv(a,b,x) count(a, b,x) 
#define vi vector<int>
#define mii map<int,int>
#define si set<int>
#define pb push_back
#define pob pop_back
#define mp make_pair
#define fi first
#define se second
#define fv(i,v) for(auto i=v.begin();i!=v.end();++i)
#define fdv(i,v) for(auto i=v.rbegin();i!=v.rend();++i)
#define print(a,n) f(i,0,n) cout<<a[i]<<" "; cout<<endl;
#define printv(v) for(auto iv: v) cout<<iv<<" "; cout<<endl;
#define all(v) v.begin(),v.end()
#define input(v,n) f(i,0,n) {int x; cin>>x; v.pb(x);}
#define r(a,n) ll a[n+1]; f(i,1,n) cin>>a[i];
#define N 200005
using namespace std;

bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
   
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 

void solve() 
{
ll int n;
cin>>n;
cout<<n+pow(n,2)+pow(n,3);
}


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

   ll int t;
   //cin>>t;
   t=1;
   while(t--)
   { 
     solve();}
}




Measured memory_bytes: 4304
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int A,B; cin >> A >> B;
    int cnt=0;
    for(int i=A;i<=B;i++){
        int x=i/10000;int y=i%10;
        int s=(i-x*10000)/1000;
        int p=(i-x*10000-s*1000)/100;
        int t=(i-x*10000-s*1000-p*100)/10;
        //cerr << i << "\t" << x << " " << s << " " << t << " " << y << endl;
        if(x==y && s==t){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            var cin = new MyInputStream();
            var n = cin.ReadInt();
            var ret = new int[26];

            for (int i = 0; i < n; ++i)
            {
                var cnt = new int[26];

                var s = cin.Read();
                for (int j = 0; j < s.Length; ++j)
                    cnt[s[j] - 'a']++;

                for (int j = 0; j < 26; ++j)
                    ret[j] = (i == 0) ? cnt[j] : Min(ret[j], cnt[j]);
            }

            for (int i = 0; i < 26; ++i)
                for (int j = 0; j < ret[i]; ++j)
                    Write((char)(i + 'a'));
            WriteLine();
        }
    }

    public class MyInputStream
    {
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(char separator = ' ')
        {
            this.separator = separator;
            inputStream = new Queue<string>();
        }

        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = Console.ReadLine().Trim().Split(separator);
            for (int i = 0; i < tmp.Length; i++)
            {
                inputStream.Enqueue(tmp[i]);
            }
            return inputStream.Dequeue();
        }
        public string ReadLine() => Console.ReadLine();
        public int ReadInt() => int.Parse(Read());
        public long ReadLong() => long.Parse(Read());
        public double ReadDouble() => double.Parse(Read());
    }
}


Measured memory_bytes: 13268
# ABC140D - Face Produces Unhappiness
def main():
    # change a part properly -> +2
    N, K = tuple(map(int, input().split()))
    S = input().rstrip()
    ans = min(N - 1, sum(i == j for i, j in zip(S, S[1:])) + K * 2)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

signed main() {
  ll H, N;
  cin >> H >> N;
  ll sum = 0;
  rep(i, N) {
    ll a;
    cin >> a;
    sum += a;
  }

  if (H <= sum) {
    COUT("Yes");
  } else {
    COUT("No");
  }
  return 0;
}

Measured memory_bytes: 256
import numpy

n, m = map(int, input().split())

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

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

mod = [ [ 0 for _ in range(m) ] for _ in range(3) ]

for i in range(n):
    for j in range(n):
        if ( i + j )% 3 == 0:
            mod[2][c[i][j] - 1] += 1
        elif ( i + j )% 3 == 1:
            mod[0][c[i][j] - 1] += 1
        else:
            mod[1][c[i][j] - 1] += 1

tri = []
num = []
for i in range(3):
    temp = [ 0 for _ in range(m) ]
    for j in range(m):
        for k in range(m):
            temp[j] += mod[i][k] * d[k][j]
    tri.append(list(numpy.argsort(temp)[:3]))
    num.append(list(numpy.sort(temp)[:3]))

if tri[0][0] != tri[1][0] and tri[1][0] != tri[2][0] and tri[2][0] != tri[0][0]:
    print(num[0][0] + num[1][0] + num[2][0])
    exit()

result = []
for i in range(3):
    for j in range(3):
        if tri[0][i] == tri[1][j]:
            continue
        for k in range(3):
            if tri[1][j] == tri[2][k] or tri[2][k] == tri[0][i]:
                continue
            else:
                result.append(num[0][i] + num[1][j] + num[2][k])

print(min(result))

Measured memory_bytes: 23928
import java.util.*;

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

        ArrayList<Integer> students = new ArrayList<Integer>();
        ArrayList<Integer> inputs = new ArrayList<Integer>();

        for (int i = 1; i <= 30; i++) {
            students.add(i);
        }

        while(true) {
            int number = scan.nextInt();
            inputs.add(number);

            for (int i = 0; i < students.size(); i++) {
                if (students.get(i) == number) {
                    students.set(i, 0);
                }
            }

            if (inputs.size() == 28) {
                break;
            }
        }
        for (int i = 0; i < students.size(); i++) {
            if (students.get(i) != 0) {
                System.out.println(students.get(i));
            }
        }
    }
}


Measured memory_bytes: 26140
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
using namespace std;
typedef long long ll;
int main() {
    int n,k,d;
    cin >> n >> k;
    set<int> A;
    int tmp;
    for (int i = 0; i < k; i++) {
        cin >> d;
        for (int j = 0; j < d; j++) {
            cin >> tmp;
            A.insert(tmp);
        }
    }
    // for(auto itr = A.begin(); itr != A.end();) {
    //     cout << *itr << endl;
    //     ++itr;
    // }
    int cnt = 0;
    for (int i = 1; i < n+1; i++) {
        auto t = A.count(i);
        if (t == 0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
main()
{
  long long N;
  long long sum=0;
  cin>>N;
  for(int i=1;i<=N;i++)
  {
  	if(i%3!=0 && i%5!=0)
  	sum=sum+i;
  }
  cout<<sum;
}
  


Measured memory_bytes: 3604
#include<iostream>
#include<utility>

int main(){
  unsigned int a,b,tmp,GCD;
  while ( std::cin >> a >> b){
   unsigned long int LCM = a;
   GCD = b;
    if( GCD > a )std::swap( a , GCD );
    while(a % GCD != 0){
      tmp = a % GCD;
      a = GCD;
      GCD = tmp;
    }
    LCM = ( LCM / GCD ) * b;
    std::cout << GCD << " " << LCM << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
int A,B,C,D,E,F; 
ll ans,cnt=0;
double cen=0;
int main(void)
{
	cin>>A>>B>>C>>D>>E>>F;
	int t=A*E;
	int s=B*E;
	ans=100*A;
	for(int i=0;100*A*i<F;i++)
		{
			for(int j=0;100*B*j<F-100*A*i;j++)
			{
				if(i==0&&j==0) continue;
				for(int k=0;C*k<=F-100*A*i-100*B*j;k++)
					{
						for(int l=0;l*D<=F-100*A*i-100*B*j-C*k;l++)
						{
							if(k==0&&l==0) continue;
							ll a=100*A*i+100*B*j+C*k+D*l;
							ll b=C*k+D*l;
							if(t*i+s*j<b) break;
							double m=(double)b/a;
							if(m>=cen)
							{
								ans=a;
								cnt=b;
								cen=m;
							}
						}
					}
			}
		}
		cout<<ans<<" "<<cnt<<endl;
	return 0;
}

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

#define rep(i, a, n) for (int i = a; i < n; i++)
#define asc(v) sort(v.begin(), v.end())
#define desc(v) sort(v.begin(), v.end(), greater<int>())

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> arr(N, 0);
  rep(i, 0, N) cin >> arr[i];
  desc(arr);
  int ans = 1;
  rep(i, 1, N) if (arr[i] < arr[i - 1]) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[]argc){
        Scanner sc = new Scanner(System.in);
        while(true){
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
            char c = op.charAt(0);
            if(c=='+'||c=='-'||c=='*'||c=='/'||c=='?'){
                if(c=='+'){
                    System.out.println(a+b);
                }else if(c=='-'){
                    System.out.println(a-b);
                }else if(c=='*'){
                    System.out.println(a*b);
                }else if(c=='/'){
                    if(b==0){
                        break;
                    }else{
                        System.out.println(a/b);
                    }
                }else if(c=='?'){
                    break;
                }
            }else{
                break;
            }
        }
    }
}



Measured memory_bytes: 26224
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    string s;
    cin >> s;

    int ans = 0;
    int st = 0;
    int n = s.length();
    rep(i, n) {
        if (s[i] == 'T') {
            if (st <= 0) ans += 2;
            else st--;
        }
        else {
            st++;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int a, b, k;
int flag = 0;

int main()
{
	scanf("%d%d%d", &a, &b, &k);
	if(((b - a + 1) % 2 == 0 && (b - a + 1) / 2 <= k) || ((b - a + 1) % 2 == 1 && (b - a + 1) / 2 + 1 <= k)) 
	{
		for(int i = a; i <= b; i++) printf("%d\n", i);
	}
	else
	{
		for(int i = a; i <= a + k - 1; i++) printf("%d\n", i);
		for(int i = b - k + 1; i <= b; i++) printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 256