akhauriyash/Code-Regression huggingface dataset:
from random import *
D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(D)]
X=[0]*26
XX=[0]*26
P=[]
for i in range(D):
  for j in range(26):
    X[j]+=C[j]
    XX[j]+=X[j]
  P.append([])
  for j in range(26):
    P[i].append(j)
  P[i].sort(reverse=True,key=lambda x:X[x]+S[i][x])
  XX[P[i][0]]-=X[P[i][0]]
  X[P[i][0]]=0
SC,SC2=0,0
for i in range(D):
  SC+=S[i][P[i][0]]
YY=[]
Y=[]
for i in range(D):
  for k in range(25):
    SC2=SC
    YY=XX[:]
    Y=X[:]
    SC2-=S[i][P[i][0]]
    SC2+=S[i][P[i][k+1]]
    for j in range(26):
      Y[j]=0
    YY[P[i][0]],YY[P[i][k+1]]=0,0
    for j in range(D):
      if j==i:
        Z=P[j][k+1]
      else:
        Z=P[j][0]
      Y[P[i][0]]+=C[P[i][0]]
      Y[P[i][k+1]]+=C[P[i][k+1]]
      Y[Z]=0
      YY[P[i][0]]+=Y[P[i][0]]
      YY[P[i][k+1]]+=Y[P[i][k+1]]
    if SC2-sum(YY)>SC-sum(XX):
      P[i].insert(0,P[i][k+1])
      del P[i][k+2]
      XX=YY[:]
      SC=SC2
for i in range(D):
  print(P[i][0]+1)

Measured memory_bytes: 103864
using System;
namespace kozaiyApp
{
    public class A
    {
        static void Main()
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            T = T.Remove(T.Length - 1);

            if (S == T)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 25908
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    int N,M;
    cin >> N >> M;
    vint X(M);
    cin >> X;
    sort(X.begin(),X.end());
    if(N >= M){
        cout << 0 << endl;
        return 0;
    }
    vint L;
    REP(i,M-1){
        L.pb(abs(X[i]-X[i+1]));
    }
    sort(L.begin(),L.end(),greater<int>());
    int ans = abs(X[M-1]-X[0]);
    REP(i,N-1){
        ans -= L[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4228
import java.util.Scanner;
import java.util.Arrays;

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

		String[] strs = new String[n];
		for(int i = 0; i < n; i++){
			strs[i] = scan.next();
		}

		Arrays.sort(strs);

		for(int i = 0; i < n; i++){
			System.out.print(strs[i]);
		}
		System.out.println();
	}
}

Measured memory_bytes: 21844
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args){
	
	int N;
	//数の上限
	InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
	InputReader input = new InputReader(inputStream);
	N = input.nextInt();
	int[] num = new int[N];
	for(int i = 0;i < N;i++){
	    num[i] = input.nextInt();
	}
	int minv = num[0];
	int maxv = num[1] - num[0];
	for(int j = 1;j < N;j++){
	    maxv = maxv > (num[j] - minv)?maxv:num[j] - minv;
	    minv = minv < num[j]?minv:num[j];
	}
	System.out.printf("%d\n",maxv);
    }
}
class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;
    
    public InputReader(InputStream stream) {
	reader = new BufferedReader(new InputStreamReader(stream), 32768);
	tokenizer = null;
    }
    
    public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
    }
    
    public int nextInt() {
	return Integer.parseInt(next());
    }
}


Measured memory_bytes: 54676
import numpy as np
Nnum=int(input())
An=np.array([int(i) for i in input().split()])
Ane=An[An%2==0]
Ane3=Ane%3
Ane5=Ane%5
Ane3or5=Ane3*Ane5

if(np.sum(Ane3or5)==0):
    print("APPROVED")
else:
    print("DENIED")    

Measured memory_bytes: 12428
#include<stdio.h>

int main()
{
    int N,X,d[1000],l[1000],i;
    scanf("%d %d",&N,&X);
    for(i=0;i<N;i++)
    {
        scanf("%d",&l[i]);
    }
    d[0]=0;i=0;
    while(d[i]<=X)
    {
        d[i+1]=d[i]+l[i];
        i++;
    }
    if(i>=N+1) printf("%d",N+1);
    else printf("%d",i);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;
LL mul(LL a,LL b){
  return ((a % mod) * (b % mod)) % mod;
}

LL power(LL x,LL y){//繰り返し二乗法
  if(y==0)return 1;
  else if(y==1)return x%mod;
  else if(y%2==0){
    LL tmp=power(x, y/2) % mod;
    return tmp*tmp%mod;
  }else {
    LL tmp=power(x, y/2) % mod;
    return ((tmp*tmp)%mod)*x%mod;
  }
}

int main(){
	int n,a[111111]={};
	cin>>n;
	int f=n%2,fl=0;
	FOR(i,0,n){
		int b;
		cin>>b;
		a[b]++;
		if(b%2==f){
			fl=1;
		}
		if(a[b]>2){
			fl=1;
		}
	}
	if(f==1&&a[0]!=1)fl=1;
	if(fl==1)cout<<0<<endl;
	else {
		cout<<power(2,n/2)<<endl;
	}
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}

const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

const int N=0;



void solve(){
	int a,b;
	cin>>a>>b;
	cout<<a*b;
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SIEVE
		sieve();
	#endif
	#ifdef NCR
		init();
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
const int mod = 1000000007;
inline int qp(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = 1ll * res * a % mod;
		a = 1ll * a * a % mod;
		b >>= 1;
	}
	return res;
}
int n, h[N];
pair<int, int> solve(int l, int r, int lim) {
	int mn = 0x3f3f3f3f, cntmn = 0;
	for (int i = l; i <= r; i++) {
		if (h[i] < mn) {
			mn = h[i];
			cntmn = 1;
		} else if (h[i] == mn) cntmn++;
	}
	pair<int, int> ret;
	if (cntmn == r - l + 1) {
		ret.first = (qp(2, r - l + 1) - 2 + mod) % mod;
		ret.second = qp(2, mn - lim - 1);
		return ret;
	}
	int t0 = 1, t1 = 1;
	for (int i = l, lst = l - 1; i <= r + 1; i++) {
		if (i > r || h[i] == mn) {
			if (lst < i - 1) {
				pair<int, int> cur = solve(lst + 1, i - 1, mn);
				t0 = 1ll * t0 * (cur.first + 4ll * cur.second % mod) % mod;
				t1 = 1ll * t1 * (2ll * cur.second % mod) % mod;
			}
			lst = i;
		}
	}
	t0 = (t0 - 2 * t1 % mod + mod) % mod;
	ret.first = 1ll * t0 * qp(2, cntmn) % mod;
	ret.first = (ret.first + 2ll * t1 * (qp(2, cntmn) - 1) % mod) % mod;
	ret.second = 1ll * t1 * qp(2, mn - lim - 1) % mod;
	return ret;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &h[i]);
	pair<int, int> ret = solve(1, n, 0);
	int ans = (ret.first + 2ll * ret.second) % mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))

int main()
{
	int n, k;
	string s;
	cin >> n >> k >> s;
	vector<int> nums;
	int now = 1;
	int cnt = 0;
	rep(i, 0, s.size() - 1)
	{
		if (s[i] == (char)(now + '0')) ++cnt;
		else
		{
			nums.push_back(cnt);
			now = 1 - now;
			cnt = 1;
		}
	}
	nums.push_back(cnt);
	if (nums.size() % 2 == 0)nums.push_back(0);
	int add = 2 * k;
	int ans = 0;
	for (int i = 0; i < nums.size(); i += 2)
	{
		int temp = 0;
		int left = i;
		int right = min(left + add, (int)nums.size() - 1);
		rep(j, left, right)
		{
			temp += nums[j];
		}
		ans = max(ans, temp);
	}
	cout << ans << endl;
}



Measured memory_bytes: 1020
#include <iostream>

using namespace std;

void input(int n, int m, long *mat)
{

  for(int i = 0; i < n; ++i)
  { 
     for(int j = 0; j < m; ++j)
     {
         cin >> mat[j + i * m];
     }
  }
  return ;    

}

int main()
{ 
 
  int n, m, l;
  cin >> n >> m >> l;
  
  long *A = new long[n*m], *B = new long[m*l], *C = new long[n*l];
  
  input(n, m, A);
  input(m, l, B);
  
  for(int i = 0; i < n; ++i)
  {
    for(int k = 0; k < l; ++k)
    { C[k + l * i] = 0; }
  }
  
  for(int i = 0; i < n; ++i)
  {
      for(int j = 0; j < l; ++j)
      {
          for(int k = 0; k < m; ++k)
          { C[j + i * l] += A[k + i * m] * B[j + k * l]; }
      }
  }
  
  for(int i = 0; i < n; ++i)
  {
    for(int k = 0; k < l; ++k)
    { 
        cout << C[k + l * i];
        if(k != l - 1) 
          cout << " ";
    }
    cout << endl;
  }
  
  delete [] A;
  delete [] B;
  delete [] C;
  
  return 0;   
}


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

typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = INT_MAX;

int h[MAXN];
int vis[MAXN];
vi adj[MAXN];

void dfs(int i) {
	vis[i] = 1;
	for(auto x:adj[i]) {
		if(!vis[x]) dfs(x);
	}
}

void solve() {
	int n,m;
	cin >> n >> m;

	memset(vis, 0, sizeof(vis));
	F0R(i, n) cin >> h[i];
	F0R(i, m) {
		int u,v;
		cin >> u >> v;
		u--;
		v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	ll cnt = 0;
	
	F0R(i, n) {
		//ll cur = h[i];
		bool ok = 1;
		for(auto x:adj[i]) {
			if(h[i] > h[x]) continue;
			else ok = 0;
		}
		if(ok) cnt++;
	}

	cout << cnt << "\n";
	
}

int32_t main() {_
	//tc(t)
		solve();
}



Measured memory_bytes: 34168
/*
Author: Babin Dutta
*/
 
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
//#define endl "\n"
#define inf 1e18
#define mm 998244353
 
ll power(ll x, ll y, ll p)
{
    ll res = 1;  
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; 
        x = (x*x) % p;  
    }
    return res;
}
ll modInverse(ll A,ll M)
{
    return power(A,M-2,M);
}

void solve(){
	string s; cin>>s;
	int sum = 0;
	for(int i=0;i<s.length();i++) sum += (s[i]-'0');
	if(sum%9 == 0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}
 
int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 3724
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=1e6;
ll d[mm];
int main()
{
	ll n,m,i,j,k,kk,a,b,t;
	string s1,s2,s3;
	cin>>s1>>s2;
	s3="";
	for(i=0;i<s2.size()-1;i++)
	s3+=s2[i];
	if(s1==s3)
	printf("Yes\n");
	else
	printf("No\n"); 

}

Measured memory_bytes: 3632
#include <stdio.h>

int board[105][105];

#define K 100

int main() {

	int A,B;

	scanf("%d %d",&A,&B);

	int i,j;

	for(i=0;i<K;i++){
		for(j=0;j<K;j++){
			if(i>=K/2){board[i][j]=1;}
		}
	}

	A--;
	B--;

	for(i=K-1;i>=0;i-=2){
		for(j=0;j<K;j+=2){
			if(A==0){break;}
			board[i][j]=0;
			A--;
			if(A==0){break;}
		}
		if(A==0){break;}
	}

	for(i=0;i<K;i+=2){
		for(j=0;j<K;j+=2){
			if(B==0){break;}
			board[i][j]=1;
			B--;
			if(B==0){break;}
		}
		if(B==0){break;}
	}

	printf("%d %d\n",K,K);

	for(i=0;i<K;i++){
		for(j=0;j<K;j++){
			if(board[i][j]==0){printf(".");}
			else{printf("#");}
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[][] kasi = new int[n][5];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < 4; j++) {
					kasi[i][j] = scanner.nextInt();
				}
				kasi[i][4] = kasi[i][1] * 4 + kasi[i][2] * 9 + kasi[i][3] * 4;
			}
			int[] PQR = new int[5];
			for (int i = 1; i <= 4; i++) {
				PQR[i] = scanner.nextInt();
			}
			boolean flag = true;
			loop: for (int i = 0; i < n; i++) {
				for (int j = 1; j <= 4; j++) {
					if (kasi[i][j] > PQR[j]) {
						continue loop;
					}

				}
				System.out.println(kasi[i][0]);
				flag = false;
			}
			if (flag)
				System.out.println("NA");
		}
	}
}

Measured memory_bytes: 64860
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main{

	public static void main(String[] args) throws Exception
	{
		String[] strRing = {"24532453","64136413","56215621","51265126","63146314","54235423"};

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );
		String[] strDice = br.readLine().split(" ");
		int q = Integer.parseInt(br.readLine() );

		HashMap<String,String> map = new HashMap<String,String>();

		for(int i=1; i<=6; i++) map.put(strDice[i-1],Integer.toString(i) );

		for(int i=0; i<q; i++)
		{
			String[] str = br.readLine().split(" ", 2);

			String strBST = Integer.toString(7 - Integer.parseInt(map.get(str[0]) )  ) + map.get(str[1]) + map.get(str[0]);

			for(int j=0; j<6; j++)
			{
				if(-1 < strRing[j].indexOf(strBST) )
				{
					System.out.println(strDice[j]);
					break;
				}
			}
		}

	}
}

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

int main(){
    int N, A[110], B[110], k, sum, a;
    cin >> N;
    k = 1000000000;
    B[0] = 0;
    for(int i = 1; i < N + 1; i++) cin >> A[i];
    for(int i = 1; i < N + 1; i++) cin >> B[i];
    for(int i = 1; i < N + 1; i++){
        sum = 0;
        for(int j = 1; j < i; j++){
            sum += B[j];
        }
        for(int j = i + 1; j < N + 1; j++){
            sum += A[j];
        }
        if(sum < k) k = sum;
    }
    for(int i = 1; i < N + 1; i++){
        a += A[i] + B[i];
    }
    cout << a - k << endl;
    
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007

using namespace std;

typedef long long ll;

ll pow_mod(ll x,int k) {
  ll ans=1;
  while (k) {
  	if (k&1) ans=ans*x%MOD;
  	x=x*x%MOD;
  	k>>=1;
  }
  return ans;
}

inline void add(int &x,ll y) {
  x=(x+y)%MOD;
}

ll facd[55],facv[55];

void pre(int n) {
  facd[0]=1;
  for(int i=1;i<=n;i++) facd[i]=facd[i-1]*i%MOD;
  facv[n]=pow_mod(facd[n],MOD-2);
  for(int i=n-1;i>=0;i--) facv[i]=facv[i+1]*(i+1)%MOD;
}

int f[55][55][55];

int dp(int n) {
  f[1][1][0]=1;
  for(int i=1;i<n;i++)
  for(int j=0;j<=i;j++)
  for(int k=0;j+k<=i;k++)
    if (f[i][j][k]) {
    	for(int t1=0;i+t1<=n;t1++)
    	for(int t2=0;i+t1+t2<=n;t2++)
    	  if (t1||t2) {
    	  	if (t1>t2) {
    	  		if (t1-t2>j) continue;
    	  		add(f[i+t1+t2][t1][t2],f[i][j][k]*facv[j-(t1-t2)]%MOD*facv[k+(t1-t2)]);
			  }
			else {
				if (t2-t1>k) continue;
				add(f[i+t1+t2][t1][t2],f[i][j][k]*facv[j+(t2-t1)]%MOD*facv[k-(t2-t1)]);
			}
		  }
	}
  int ans=0;
  for(int i=0;i<=n;i++)
    for(int j=0;i+j<=n;j++)
      if (f[n][i][j]) add(ans,f[n][i][j]*facv[i]%MOD*facv[j]);
  return ans*facd[n]%MOD;
}

int main() {
  int n;
  scanf("%d",&n);
  pre(n);
  printf("%d\n",dp(n));
  return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

struct Info
{
	int x;
	int y;
	int z;

	Info()
	{

	}
	Info(int a)
	{
		x = a;
		if (x % 10 != 0)
		{
			y = 10 - x % 10;
			z = x + y;
		}
		else
		{
			y = -1;
			z = x;
		}
	}
};

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

	vector<Info> a(5);
	for (int i = 0; i < 5; i++)
	{
		int t;
		cin >> t;

		a.at(i) = Info(t);
	}

	sort(a.begin(), a.end(), [](const Info& a, const Info& b)
		{
			return a.y < b.y;
		});

	ll res = 0;
	for (int i = 0; i < 4; i++)
	{
		res += a.at(i).z;
	}
	res += a.at(4).x;

	cout << res << endl;
}

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

int main(){

  string today;
  cin >> today;
  if (today == "Sunny") cout << "Cloudy" << endl;
  if (today == "Cloudy") cout << "Rainy" << endl;
  if (today == "Rainy") cout << "Sunny" << endl;

  return 0;
}


Measured memory_bytes: 256
/// You just can't beat the person who never gives up
/// ICPC next year

///#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
///#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std ;
const int N = 3e5+5 ,mod = 1e9+7 ;

int h ,w ,a ,b ,ans ,dp[N] ,fac[N] ,inv[N] ;
int pwr(int b,int p){
    int res = 1;
    while(p){
        if(p%2) res = 1ll*res*b%mod ;
        b = 1ll*b*b%mod;
        p/=2;
    }
    return res;
}
int ways(int x0,int y0,int x1,int y1){
    int rit = x1 - x0 ;
    int down = y1 - y0 ;
    return 1ll * fac[rit+down] * inv[rit] %mod * inv[down] %mod ;
}
int main(){
    fac[0] = inv[0] = 1 ;
    for(int i=1;i<N;++i){
        fac[i]=(1ll*fac[i-1]*i)%mod;
        inv[i]=pwr(fac[i],mod-2);
    }
    cin >> h >> w >> a >> b ;
    for(int i=h-a;i>=1;--i){
        dp[i] = (0ll + ways(i,b+1,h,w) /*+ dp[i+1]*/)%mod ;
        ans = (ans + 1ll * ways(1,1,i,b) * dp[i] %mod)%mod ;
    }
    cout << ans ;
    return 0;
}


Measured memory_bytes: 6208
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

void solve()
{
	int n, m;
	cin >> n >> m;
	vector<p32> arr(n);
	map<int, int> hashMap;
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i].fi;
		arr[i].se = i + 1;
		hashMap[i + 1] = arr[i].fi;
	}
	vector<v32> adj(n + 1, v32());
	int u, v;
	for (int i = 0; i < m; i++)
	{
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	db(arr);
	int ans = 0;
	for (auto itr : arr)
	{
		int u = itr.se;
		bool flag = true;
		for (int v : adj[u])
		{
			if (hashMap[v] >= hashMap[u])
			{
				flag = false;
				break;
			}
		}
		if (flag)
			ans++;
	}
	cout << ans << ln;
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve();
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


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

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            //

            var N = GetInt();
            var A = GetLongArray();
            var num = A.Count(a => a < 0) % 2;
            A = A.OrderBy(a => Math.Abs(a)).Select(a=>Math.Abs(a)).ToArray() ;
            if (num == 1) { A[0] = -A[0]; }
            var ans = A.Sum();
            

            Console.WriteLine(ans);

            //
            Console.Out.Flush();
            Console.ReadKey();
        }

        static void Solve()
        {

        }

        static long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }

        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c, out V d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<V>(ar[3]);
        }
    }
}

Measured memory_bytes: 29788
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<long, long> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

int main(){
    int N,D;
    cin>>N>>D;
    cout<<(int)(N/(2*D+1))+(N%(2*D+1)!=0)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>

#define ll long long

using namespace std;

int N;

int main()
{
    cin >> N;

    ll L[N+1];
    L[0] = 2;
    L[1] = 1;

    for (int i = 2; i <= N; i++) {
        L[i] = L[i - 1] + L[i - 2];
    }
    
    cout << L[N] << endl;

    return 0;
}

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

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

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

    vector<bool> dp(k+1,0);
    for (int i = 0; i <= k; ++i) {
        for(int move : v) {
            if(move > i) 
                continue;
            if(dp[i-move] == 0)
                dp[i] = 1;
        }
    }

    // for (int i = 0; i < dp.size(); ++i)
    // {
    //     cout << dp[i] << " ";
    // }





    if(dp[k]) {
        cout << "First";
    } else {
        cout << "Second";
    }

    return 0;
}

Measured memory_bytes: 256
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int l,r,u,d;
int w,h,n;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

    cin >> w >> h >> n;
    l = 0, r = w;
    d = 0, u = h;
    for(int i=1;i<=n;i++){
        int x,y,a;
        cin >> x >> y >> a;
        if(a==1){
            l = max(l, x);
        }
        if(a==2){
            r = min(r, x);
        }
        if(a==3){
            d = max(d, y);
        }
        if(a==4){
            u = min(u, y);
        }
    }
    int ans = max(0LL, (r-l) )*max(0LL,(u-d));
    cout << ans << endl;
            
    

return 0;
}
///....


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>

using namespace std;

int main() {
    int x, n;
    cin >> x >> n;
    vector<int> v;
    if (n == 0) {
        cout << x << '\n';
        return 0;
    }
    while(n--){
        int t = 0;
        cin >> t;
        v.push_back(t);
    }

    vector<int>::iterator it = find(v.begin(), v.end(), x);
    if(it == v.end()) {
        cout << x << '\n';
        return 0;
    }
    int p = 1;
    while((it = find(v.begin(), v.end(), x-p)) != v.end()) {
        if((it = find(v.begin(), v.end(), x+p)) == v.end()) {
            cout << x+p << '\n';
            return 0;
        }
        p++;
    }
    cout << x-p << '\n';
    return 0;
}

Measured memory_bytes: 3600
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = Number(input[0][0]);
  const S = Number(input[0][1]);
  const A = input[1].map(Number);
  const MOD = 998244353;

  const dp = [...Array(N + 1)].map(() => Array(S + 1).fill(0));
  dp[0][0] = 1;

  for (let i = 0; i < N; i++) {
    for (let j = 0; j <= S; j++) {
      dp[i + 1][j] += (dp[i][j] * 2) % MOD;

      if (j - A[i] >= 0) {
        dp[i + 1][j] += dp[i][j - A[i]];
        dp[i + 1][j] %= MOD;
      }
    }
  }

  return dp[N][S];
};

console.log(main(read()));


Measured memory_bytes: 123364
n = gets.to_i
d = Array.new(n+1, 0)
(1..100).each do |x|
  (1..100).each do |y|
    (1..100).each do |z|
      a = x**2 + y**2 + z**2 + x*y + y*z + z*x
      d[a] += 1 if a <= n
    end
  end
end
(1..n).each do |i|
  puts d[i]
end


Measured memory_bytes: 14324
n = int(input())
S = {}
cnt = 0
for _ in range(n):
    s = input()
    s = sorted(s)
    u = ""
    for i in range(len(s)):
      u += s[i]
    if u in S.keys():
        S[u] += 1
    else:
        S[u] = 1
for x in S.values():
    x = x-1
    cnt += x*(x+1)//2
print(cnt)

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

int main(){
    while(1){
        int t, n, s, f;
        cin >> t;
        
        if(t == 0)  break;
        cin >> n;
        
        int actual = 0;
        while(n-- > 0){
            cin >> s >> f;
            actual += f-s;
        }
        
        if(actual >= t) cout << "OK" << endl;
        else            cout << t-actual << endl;
    }
    return 0;
}



Measured memory_bytes: 3064
import sys
n=int(input())
s=[]
ans=0
for i in range(n):
    a=int(input())
    if a%10==0:
        b=1
    else:
        b=0
    s.append([b,a])
ans+=sum(i[1] for i in s)
sS=sorted(s,key=lambda x:(x[0],x[1]))
if ans%10!=0:
    print(ans)
    sys.exit()
for i in range(n):
    if sS[i][0]==0:
        ans-=sS[i][1]
        print(ans)
        sys.exit()
print(0)


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

signed main(){
    int m,d,mm,dd;
    cin>>m>>d>>mm>>dd;
    if(m!=mm)cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}

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

vector<int> odd, even, out;

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	f(i, 0, m){
		int t;
		scanf("%d", &t);
		if (t & 1)odd.push_back(t);
		else even.push_back(t);
	}
	if (odd.size() > 2)printf("Impossible\n"), exit(0);
	if (n == 1)printf("1\n1\n1\n"), exit(0);
	if (even.empty() && odd.size() == 1)printf("%d\n2\n1 %d\n", odd[0], odd[0] - 1), exit(0);
	if (!odd.empty())out.push_back(odd[0] + 1);
	else out.push_back(1);
	f(i, 0, even.size())out.push_back(even[i]);
	if (odd.size() == 2)out.push_back(odd[1] - 1);
	else --out.back();
	if (!out.back())out.pop_back();
	printf("%d", odd.empty() ? even[0] : odd[0]);
	f(i, odd.empty(), even.size())printf(" %d", even[i]);
	if (odd.size() == 2)printf(" %d", odd[1]);
	printf("\n%d\n%d", (int)out.size(), out[0]);
	f(i, 1, out.size())printf(" %d", out[i]);
	printf("\n");
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

struct square {
	int h, w, diasq;

	bool operator >(const square& s) const {
		if (diasq != s.diasq) return diasq > s.diasq;
		else return h > s.h;
	}
};

int main() {
	int h, w;
	while(cin >> h >> w, h|w){
		int diasq = h*h + w*w;
		square input = {h, w, diasq};
		priority_queue<square, vector<square>, greater<square>> q;
		for(int i = 1; i < 151; i++){
			for(int j = i+1; j < 151; j++){
				if((square){i, j, i*i+j*j} > input){
					q.push({i, j, i*i+j*j});
				}
			}
		}
		cout << q.top().h << " " << q.top().w << endl;
	}
	return 0;
}

Measured memory_bytes: 1440
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


s = input()
n = len(s)
end = n-1
movement = 0
for i in range(n-1, -1, -1):
    if s[i] == 'B':
        movement += end - i
        end -= 1
print(movement)


Measured memory_bytes: 3500
x=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n=int(input())
print(x[n-1])

Measured memory_bytes: 3060
import java.util.Scanner;

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

		long H = sc.nextLong();
		long hp = H;
		long cnt = 1;
		long monster = 1;
		while (true) {
			if (hp == 1) {
				break;
			}
			else {
				hp /= 2;
				monster *= 2;
				cnt += monster;
			}
		}
		System.out.println(cnt);
	}
}

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

int main(){
 int N,M,C;
 cin >> N >> M >> C;
 int count = 0;
 int B[M],A[M];
 int judge;
 for(int i = 0 ; i < M; ++i) cin >> B[i];
 for(int i = 0; i < N; ++i){
     judge = 0;
     for(int j = 0; j < M;++j){
         cin >> A[j];
         judge += B[j] * A[j];
     }
     judge += C;
     if(judge > 0) count += 1;
 }
 cout << count << endl;
}

Measured memory_bytes: 256
H, W, K = map(int, input().split())
S = []
for _ in range(H):
    S.append(input().split())

T = []
back_n = -1
count = 1
la = []
for i in range(H):
    if "#" in S[i][0]:
        a = []
        c = 0
        if back_n == 0:
            for j in range(W):
                if S[i][0][j] == "#":
                    c += 1
                if S[i][0][j] == "#" and c >= 2:
                    count += 1

                a.append(count)
            if back_n == -1:
                T.append(a)
            else:
                for k in range(i - back_n + 1):
                    T.append(a)
            back_n = -1
            la = a
            count += 1
        else:
            for j in range(W):
                if S[i][0][j] == "#":
                    c += 1
                if S[i][0][j] == "#" and c >= 2:
                    count += 1

                a.append(count)

            if back_n == -1:
                T.append(a)
            else:
                for k in range(i - back_n + 1):
                    T.append(a)
            back_n = -1
            la = a
            count += 1

    elif back_n == -1 and not ("#" in S[i][0]):
        back_n = i

for k in range(H - len(T)):
    T.append(la)

for i in range(H):
    for j in range(W):
        print(T[i][j], end=" ")
    print(end="\n")


Measured memory_bytes: 7624
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {

static long[] list=new long[87];

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

   String nyuA=sc.nextLine();
   
int N=Integer.parseInt(nyuA);
String S=sc.nextLine();
int ans=0;
for(int i=0;i<=N;i++){
int temp=func(S.substring(0,i),S.substring(i));
ans=Math.max(ans,temp);
}

System.out.println(ans);
}

static int func(String s,String t){
int ans=0;
for(char c='a';c<='z';c++){
boolean founds=false,foundt=false;
for(int i=0;i<s.length();i++){
if(s.toCharArray()[i]==c){
founds=true;
}//if
}//f
for(int i=0;i<t.length();i++){
if(t.toCharArray()[i]==c){
foundt=true;
}//if
}//f

if(founds && foundt)ans++;
}//f
return ans;
}

}



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

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    if ((r*100+g*10+b)%4){
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    var C = IntArray(N-1, {0})
    var S = IntArray(N-1, {0})
    var F = IntArray(N-1, {0})
    for (i in 0..N-2) {
        var (c, s, f) = readLine()!!.split(" ").map{it.toInt()}
        C[i] = c
        S[i] = s
        F[i] = f
    }
    var ans: Int
    for (i in 0..N-1) {
        ans = 0
        for (j in i..N-2) {
            if (ans < S[j]) ans = S[j]
            else ans = ((ans-S[j]-1)/F[j]+1)*F[j] + S[j]
            ans += C[j]
        }
        println(ans)
    }
}


Measured memory_bytes: 37948
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

int main() {
    int N;
    std::cin >> N;

    int T, A;
    std::cin >> T >> A;

    std::vector<int> v(N);
    for (int i = 0; i < N; ++i) {
        std::cin >> v[i];
    }

    std::vector<double> absDiffs;
    absDiffs.reserve(N);
    std::transform(
        v.cbegin(), v.cend(),
        std::back_inserter(absDiffs),
        [&](int x) { return std::fabs(T - x*0.006 - A); }
    );

    const auto min_element = std::min_element(absDiffs.cbegin(), absDiffs.cend());
    const int ret = min_element - absDiffs.cbegin() + 1;

    std::cout << ret << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const ll INF = 1e9;
inline ll read(){
	ll X = 0,w = 0 ;
	char ch = 0;
	while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
	while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
	return w ? -X : X;
}


ll h[1005];
ll Has[1005];
ll tot;
ll dp[1005][1005];
ll n;
ll mod=1e9+7;
ll Pow(ll x,ll y)
{
	if(y<=0)
	{
		return 1;
	}
	ll res=1;
	while(y)
	{
		if(y&1)
		{
			res=res*x%mod;
		}
		y>>=1;
		x=(x*x)%mod;
	}
	return res;
}
int main()
{
	cin>>n;
	dp[0][0]=1;
	for(ll i=1;i<=n;i++)
	{
		cin>>h[i];
		Has[++tot]=h[i];
	}
	sort(Has+1,Has+tot+1);
	tot=unique(Has+1,Has+tot+1)-Has-1;
	for(ll i=1;i<=n;i++)
	{
		h[i]=lower_bound(Has+1,Has+tot+1,h[i])-Has;
	}
	for(ll i=1;i<=n;i++)
	{
		dp[i][0]=dp[i-1][0]*2%mod;
		for(ll j=h[i]+1;j<=h[i-1];j++)
		{
			dp[i][0]=(dp[i][0]+dp[i-1][j]*2%mod)%mod;
		}
		ll tmpPow=Pow(2,Has[h[i]]-Has[h[i-1]]);
		for(ll j=1;j<=min(h[i-1],h[i]);j++)
		{
			dp[i][j]=dp[i-1][j]*tmpPow%mod;
		}
		for(ll j=h[i-1]+1;j<=h[i];j++)
		{
			dp[i][j]=(dp[i][j]+j==1?(dp[i-1][0]*(Pow(2,Has[j])-2)%mod*Pow(2,Has[h[i]]-Has[j])%mod):(dp[i-1][0]*2*(Pow(2,Has[j]-Has[j-1])-1)%mod*Pow(2,Has[h[i]]-Has[j])%mod))%mod;
		}
	}
	ll res=0;
	for(ll i=0;i<=tot;i++)
	{
		res=(res+dp[n][i])%mod;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 768
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int S = sc.nextInt();
    int answer=0;
    for(int i=0;i<=K;i++){
      if(i>S){
        break;
      }
      for(int j=i;j<=K;j++){
        if(i+j>S){
          break;
        }
        for(int l=j;l<=K;l++){
          if(i+j+l==S){
              if(i<j&&j<l){
                  answer=answer+6;
              }else if((i==j&&j<l)||(i<j&&j==l)){
                  answer=answer+3;
              }else{
                  answer++;
              }
            
            break;
          }
        }
      }
    }
    System.out.println(answer);
  }
  

  
}


Measured memory_bytes: 23892
main(f,x){unsigned u;for(scanf("%d",&x);~scanf("%x",&u);printf("%s%d.%0*d\n",u&(1<<31)?"-":"",u<<1>>8,x,f))for(f=(u&0x7f)*78125,x=8;--x&&!(f%10);f/=10);exit(0);}

Measured memory_bytes: 616
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
MOD = 10**9+7


N = int(input())
seq = [int(input()) for _ in range(N)]
LIS = deque([seq[0]])
for i in range(1,len(seq)):
    if seq[i] <= LIS[0]:
        LIS.appendleft(seq[i])
    else:
        LIS[bisect.bisect_left(LIS, seq[i])-1] = seq[i]

print(len(LIS))

Measured memory_bytes: 79768
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    A = input_int_list()
    A_sum = sum(A)
    cusum = [0] * (n + 1)
    ans = float("inf")
    for i in range(1, n + 1):
        cusum[i] = cusum[i - 1] + A[i - 1]
        ans = min(ans, abs(cusum[i] - (A_sum - cusum[i])))
    print(ans)

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 104376
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int k[] =new int[n];
		int a[][]=new int [n][m];
		for(int i=0;i<n;i++) {
			k[i]=scan.nextInt();
			for(int j=0;j<k[i];j++) {
				a[i][j]=scan.nextInt();
			}
		}
		scan.close();
		int cnt=0;
		int check[]=new int[m];
		for(int i=0;i<m;i++) {
			check[i]=0;
		}
		for(int i=0;i<n;i++) {
			for(int j=0;j<k[i];j++) {
				int num=a[i][j]-1;
				check[num]+=1;
			}
		}
		for(int i=0;i<m;i++) {
			if(check[i] == n)cnt++;
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 23632
#include <bits/stdc++.h>
#include <queue>
#define MOD 1000000007
using namespace std;

vector<long long> getBits(long long num) {
    vector<long long> bits(65, 0);
    long long d = 1;
    for (int i = 0; i < 64; i++) {
        if(num < d) break;
        long long mock = floor((double)num / (d * 2));
        long long namu = num % (d * 2);

        bits[i] = mock * d;
        if(namu + 1> d){
            bits[i] += (namu + 1) - d;
        }
        d *= 2;
    }

    return bits;
}

int main() {
    long long A,B;
    cin>>A>>B;
    vector<long long> a = getBits(A-1);
    vector<long long> b = getBits(B);
    vector<long long> c(64,0);
    long long ans=0, d=1;
    for (int i=0;i<64;i++){
        ans |= ((b[i]-a[i]) % 2) << i;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void) {
  string str;
  cin >> str;
  for (int i = 0; i < 2; i++) {
    if (str[i] == '9') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Mon May  4 20:55:48 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

#N = int(input())
A, B = map(int,input().split())

if B % A == 0:
    print(A+B)
else:
    print(B-A)



Measured memory_bytes: 2940
//بِسْمِ ٱللَّٰهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;

#define endl "\n"

const int MOD = 1000000007;

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

    int a;
    cin >> a;
    int ara[a];
    for(int i = 0 ; i < a; i++) cin >> ara[i];
    int sum = 0;
    sort(ara,ara+a);
    for(int i = 0 ; i < (a-1); i++){ sum += ara[i];};
    if(ara[a-1] >= sum){
        cout << "No" << endl;
    }


    else if(ara[a-1] < sum){
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 3548
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
using namespace std;

int main(){  
  double a,b;
  double n;
  cin >> a >> b;
  n = (a+b)/2+0.9;
  cout << (int)n << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main() {
  string s;
  cin >> s;
  rep(bit,(1<<3)){
    ll sum = s[0]-'0';
    string ans= "";
    ans += s[0];
    rep(i,3){
      if (bit & (1<<i)) {
        sum += s[i+1]-'0';
        ans += "+" + s.substr(i+1,1);
      } else {
        sum -= s[i+1]-'0';
        ans += "-" + s.substr(i+1,1);
      }
    }
    if(sum == 7){
      cout << ans <<  "=7" << endl;
      bit = 8;
    } 
  }
  return 0;
}

Measured memory_bytes: 3612
n,k,*b=`dd`.split.map &:to_i
a=[]
n.times{|i|s=0;(i...n).map{|j|a<<s+=b[j]}}
r=0
40.downto(r=0){|i|o=1<<i;a.count{|e|r+o&e==r+o}<k||r+=o}
p r

Measured memory_bytes: 12416
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn=1e5+5;
typedef long long ll;
ll dp[maxn],s[maxn];
ll val[maxn];
vector<int> adj[maxn],bdj[maxn];
int a[maxn],b[maxn],n,m;
pair<int,int> c[maxn];
int ufs[maxn];
int vis[maxn];
inline int find(int u){
	if (ufs[u]==u) return u;
	else return ufs[u]=find(ufs[u]);
}
inline bool cmp1(pair<int,int> a1,pair<int,int> b1){
	return a1.first<b1.first;
}
inline void dfs(int u,int fa){
	s[u]=b[u];
	for (int i=0;i<bdj[u].size();i++){
		int v=bdj[u][i];
		if (v==fa) continue;
		dfs(v,u);
		s[u]+=s[v];
	}
	if (bdj[u].size()==0){
		dp[u]=max(a[u],b[u]);
		return;
	}
	else dp[u]=1e16;
	for (int i=0;i<bdj[u].size();i++){
		int v=bdj[u][i];
		if (v==fa) continue;
		dp[u]=min(dp[u],max(dp[v],val[u])+s[u]-s[v]);
	}
}
int main(){
	cin>>n>>m;
	for (int i=1;i<=n;i++){
		scanf("%d%d",&a[i],&b[i]);
		c[i].first=max(0,a[i]-b[i]); 
		val[i]=c[i].first;
		c[i].second=i;
		ufs[i]=i;
	}
	for (int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	sort(c+1,c+n+1,cmp1);
	for (int i=1;i<=n;i++){
		int id=c[i].second;
		vis[id]=1;
		for (int j=0;j<adj[id].size();j++){
			int v=adj[id][j];
			if (vis[v]==0) continue;
			v=find(v);
			if (v==id) continue;
			bdj[id].push_back(v);
			ufs[v]=id;
		}
	}
	dfs(c[n].second,c[n].second);
	cout<<dp[c[n].second]<<endl;
}

Measured memory_bytes: 23808