akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
 
public class Main{
	int N;
	int[][] A;
	
	class Pair{
		int u, v, d;
		public Pair(int u, int v, int d){
			this.u = u;
			this.v = v;
			this.d = d;
		}
	}
	public void solve(){
		N = nextInt();
		A = new int[N][N];
		long[][] ans = new long[N][N];
		Pair[] pair = new Pair[N * (N + 1) / 2];
		int idx = 0;
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				A[i][j] = nextInt();
				if(i < j){
					pair[idx++] = new Pair(i, j, A[i][j]);
				}
				if(i == j) ans[i][j] = 0;
				else ans[i][j] = Integer.MAX_VALUE;
			}
		}
		Arrays.sort(pair, 0, idx, (a, b) -> Integer.compare(a.d, b.d));
		long sum = 0;
		for(int i = 0; i < idx; i++){
			Pair p = pair[i];
			if(ans[p.u][p.v] == p.d){
				continue;
			} else if(ans[p.u][p.v] < p.d){
				sum = -1;
				break;
			}
			sum += p.d;
			ans[p.u][p.v] = p.d;
			ans[p.v][p.u] = p.d;
			for(int j = 0; j < N; j++){
				for(int k = 0; k < N; k++){
					ans[j][k] = Math.min(ans[j][k], ans[j][p.u] + p.d + ans[p.v][k]);
					ans[k][j] = Math.min(ans[k][j], ans[k][p.v] + p.d + ans[p.u][j]);
				}
			}
		}
		boolean flg = true;
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				flg &= ans[i][j] == A[i][j];
			}
		}
		if(flg){
			out.println(sum);
		}else{
			out.println(-1);
		}
	}
	
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

Measured memory_bytes: 45364
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
const int M=60;
struct Basis{
	long long a[M+10];
	void clear()
	{
		memset(a,0,sizeof(a));
		return ;
	}
	void ins(long long x)
	{
		for(int i=M;i>=0;i--)
			if(x&(1ll<<i))
			{
				if(!a[i]){
					a[i]=x;
					return ;
				}
				x^=a[i];
			}
		return ;
	}
	bool check(long long x)
	{
		for(int i=M;i>=0;i--)
			if(x&(1ll<<i))
			{
				if(!a[i])return false;
				x^=a[i];
			}
		return true;
	}
}S;
long long a[210];
char str[210];
void solve()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	scanf("%s",str+1);
	S.clear();
	for(int i=n;i>=1;i--)
		if(str[i]=='0')S.ins(a[i]);
		else if(!S.check(a[i])){
			printf("1\n");
			return ;
		}
	printf("0\n");
	return ;
}
int main()
{
	int t;scanf("%d",&t);
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 3760
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        HashSet<Integer> set = new HashSet<Integer>();
        int N = scanner.nextInt();
        
        for(int i=1; i<=9; i++){
            for(int j=1; j<=9; j++){
                set.add(i*j);
            }
        }
        
        if(set.contains(N)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23380
MOD = 1_000_000_007

FACT = [1]
(1..1000).each do |k|
  FACT << FACT[-1] * k % MOD
end

def exp(n, k)
  x = 1
  r = n
  while k > 0
    x *= r if k & 1 == 1
    r *= r
    x %= MOD
    r %= MOD
    k >>= 1
  end
  x
end

def inv(n)
  exp(n, MOD - 2)
end

def perm(n, k)
  n >= k ? FACT[n] * inv(FACT[n - k]) % MOD : 0
end

def comb(n, k)
  perm(n, k) * inv(FACT[k]) % MOD
end

n, k = gets.split.map(&:to_i)
answer = 0
(0..k-1).each do |t|
  answer = (answer + (-1) ** t * comb(k, t) % MOD * exp(k - t, n)) % MOD
end
p answer


Measured memory_bytes: 6884
#include <bits/stdc++.h>
        using namespace std;
         
        int main() {
          		unsigned long long N;
          int M;
          cin >> N >> M;
          long long A;
          unsigned long long sum = 0;
          for (int i= 0;i<M;++i){
            cin >> A;
            sum += A;
          }
          int h =   N - sum;    
            
          if(h >= 0){
            cout << N - sum;
          }else{ 
            cout << "-1";
           }
        }

Measured memory_bytes: 3588
using System;

public class Input
{
    public char[] sc;
    public long[] scValues;

    public Input()
    {
        //string[] input = null;

        // 文字列を数値の配列として読込
        sc = Console.ReadLine().ToCharArray();
        scValues = new long[sc.Length];
        for (long i = 0; i < scValues.Length; i++)
        {
            scValues[i] = sc[i] - '0';
        }
    }
}

public class Program
{
    public static void Main(string[] args)
    {
        string output = Proc();

        // 出力
        Console.WriteLine(output);
    }

    static string Proc()
    {
        Input input = new Input();
        string output = string.Empty;

        long result = 0;

        result = Plus(ref input.scValues, 1, input.scValues[0], 0);

        output = result.ToString();
        return output;
    }

    static long Plus(ref long[] scValues, long idx, long buf, long sum)
    {
        if (idx >= scValues.Length)
        {
            return buf + sum;
        }

        long result = 0;

        // +つける
        result += Plus(ref scValues, idx + 1, scValues[idx], sum + buf);

        // +つけない
        result += Plus(ref scValues, idx + 1, buf * 10 + scValues[idx], sum);

        return result;
    }
}



Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n, k, c, i;
	cin >> n >> k >> c;
	string s;
	cin >> s;
	int pre[n];
	memset(pre, 0, sizeof pre);
	int previous[n];
	int prev = -1;
	fo(i, 0, n) {
		if(i > 0)
		pre[i] = pre[i - 1];
		
		if(s[i] == 'x')
		previous[i] = prev;
		else {
			if(prev == -1) {
				previous[i] = prev;
				pre[i]++;
				prev = i;
			}
			else {
				if(i > prev + c) {
					pre[i]++;
					previous[i] = prev;
					prev = i;
				}
				else 
				previous[i] = prev;
			}
		}
	}
	int suf[n + 1];
	memset(suf, 0, sizeof suf);
	for(i = n - 1; i >= 0; i--) {
		suf[i] = suf[i + 1];
		if(s[i] == 'x') continue;
		if(i + c + 1 >= n) suf[i] = 1;
		else
		suf[i] = suf[i + c + 1] + 1; 
	}
	vector <int> ans;
	for(i = 0; i < n; i++) {
		int cnt = 0;
		if(previous[i] != -1)
		cnt += pre[previous[i]];
		
		
		if(previous[i] == -1) 
		cnt += (i + 1 < n ? suf[i + 1] : 0);
		else {
			int x = max(previous[i] + c + 1, i + 1);
			cnt += (x < n ? suf[x] : 0);
		}
		if(cnt < k)
		ans.pb(i + 1);
	}
	if((int)ans.size()) {
		for(int v : ans)
		cout << v << '\n';
	}
}


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

int main(){
    int N;
    cin >> N;
    int ans = 0;
    
    rep(i, N){
        int num = i + 1;
        int tmp = 0;
        while(num % 2 == 0){
            num /= 2;
            tmp++;
        }
        ans = max(ans, tmp);
    }

    int a = 1;
    rep(i, ans){
        a *= 2;
    }
    
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  double n,t,a;
  cin >> n >> t >> a;
  vector<double> h(n);
  rep(i,n){
    cin >> h.at(i);
  }
  double ans=0,mini=10000001;
  rep(i,n){
    double tem=t-0.006*h.at(i);
    if(mini>abs(tem-a)){
      mini=abs(tem-a);
      ans=i+1;
    }
  }
  cout << ans;
}


Measured memory_bytes: 3820
#include<iostream>
using namespace std;
int main(){
    int n ;
    cin>>n;
    for(int i=1;i<=n;i++){
        if(i%3==0){
            cout<<" "<<i;
        }
        else{
            int t=i;
            while(t>0){
                if(t%10==3){
                    cout<<" "<<i;
                    break;
                }
                else{
                    t/=10;
                }
            }
            
        }
        
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3108
import static java.lang.System.*;
import java.util.*;

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

        char c = sc.next().toCharArray()[0];

		if(c=='A') out.println('T');
		if(c=='T') out.println('A');
		if(c=='C') out.println('G');
		if(c=='G') out.println('C');
    }
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a;
    cin >> a;
    sort(a.begin(), a.end());
    if(a[0] == a[1] && a[2] == a[3] && a[2] != a[1]) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
//If you are reading this then you are at wrong place.
#include<bits/stdc++.h>
#define mod 1000000007
#define lli long long int
using namespace std;
bool prime [1000001];
void debug(lli a){cout<<a<<endl;}
lli sieve(lli a){memset(prime,true,sizeof(prime));lli p,i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli find_max(lli __a,lli __b){return __a^((__a^__b) & -(__a<__b));}
lli add(lli __a,lli __b,lli MOD){lli x = (__a+__b)%MOD; return x; }
lli mul(lli a,lli b,lli MOD){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b,lli MOD){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b,lli MOD){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
int v[100001]={0};
vector<int>answer[100001];
int ans=0;
int dfs(int s)
{
	int i;
	v[s]=1;
	if(s==2)
	{
		//cout<<ans;
		return 0;
	}
	for(i=0;i<answer[s].size();i++)
	{
		if(v[answer[s].at(i)]==0)
		{
			ans++;
			dfs(answer[s].at(i));	
		}	
	}	
}
int main()
{
	//ifstream cin("testcase.txt");
	//ofstream cout("output.txt");	
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);	
	cout.precision(20);
	lli t,i,j;
	//cin>>t;
	//memset(dp, -1, sizeof dp);
	t=1;
	lli counter1=0;
	while(t--)
	{
		counter1++;
		int n;
		cin>>n;
		int x;
		for(i=1;i<=n;i++)
		{
			cin>>x;
			answer[i].push_back(x);
		}
		dfs(1);
		if(v[2]==1)
			cout<<ans<<endl;
		else
			cout<<-1<<endl;
		
		//cout<<"Case #"<<counter1<<" ";
		//cout<<endl;	
	}	
}


Measured memory_bytes: 9216
import math

A,B,H,M = list(map(int, input().split()))
if H == 0:
    H_angle = (360/720)*M
    M_angle = 6*M
else:
    H_M = H*60
    H_angle = (360/720)*(H_M + M)
    M_angle = 6*M

dif = H_angle-M_angle
cos = math.cos(math.radians(H_angle-M_angle))
ans = A**2 + B**2 -2*A*B*cos
print(math.sqrt(ans))


Measured memory_bytes: 9364
n = int(input())
dp = [[False for _ in range(n + 5)] for __ in range(100)]
dp[0][0] = True

for i in range(100):
    for m in range(n):
        if dp[i][m] == True:
            for j in range(10):
                if m + 6 ** j > n: break
                dp[i + 1][m + 6 ** j] = True
            for j in range(10):
                if m + 9 ** j > n: break
                dp[i + 1][m + 9 ** j] = True
    if dp[i + 1][n]:
        print(i + 1)
        break



Measured memory_bytes: 171720
#include <iostream>
#include <string>
#include <bitset>

using namespace std;

int main()
{
	int ans = 0;
	int A = 0;
	int B = 0;
	int T = 0;
	int num = 0;

	cin >> A >> B >> T;

	for (int i = 1; i < T + 0.5; i++)
	{
		if (T + 0.5 > A*i)
		{
			num += B;
		}
		else
		{
			break;
		}
	}

	ans = num;

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
import sys
if sys.version[0] == '2':
    range, input = xrange, raw_input
L = input()
N = len(L)
MOD = 10 ** 9 + 7
bits = [1, 2]
acc = [1, 3]
for _ in range(N):
    nex = bits[-1] * 3 % MOD
    bits.append(nex)
    acc.append((acc[-1] + nex) % MOD)
ans = acc[N-1]
cnt = 1
for i, b in enumerate(L):
    if i == 0:
        continue
    now = N-i-1
    if b == '1':
        ans += acc[now] * pow(2, cnt, MOD) % MOD
        cnt += 1
    ans %= MOD
ans += pow(2, cnt, MOD)
ans %= MOD
print(ans)


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

#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define ll long long 

int main(){
    IOS;
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll red=0;
    for(ll i=0;i<n;i++) red+=(s[i]=='R');

    ll rem=0;
    for(ll i=0;i<n;i++){
        if(s[i]=='R' && i>=red) rem++;
    }

    ll ans=0;
    for(ll i=0;i<red;i++){
        if(s[i]=='W' && rem) rem--,s[i]='R',ans++;
    }

    for(ll i=0;i<red;i++){
        if(s[i] != 'R') s[i]='R',ans++;
    }

    if(red) cout<<ans<<"\n";
    else cout<<0<<"\n";

}


Measured memory_bytes: 3732
import heapq

N,M = map(int,input().split())
A = list(map(int,input().split()))
A = list(map(lambda x:x*(-1), A))

heapq.heapify(A)

for _ in range(M):
    A_max = heapq.heappop(A)*(-1)
    heapq.heappush(A, (A_max//2)*(-1))

print(sum(A)*(-1))

Measured memory_bytes: 14180
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
col = []
for i in range(n):
    for j in range(a[i]):
        col.append(i+1)
cnt = 0
for i in range(h):
    p = col[cnt: cnt+w]
    if i%2 == 0:
        print(*p)
    else:
        p = p[::-1]
        print(*p)
    cnt += w

Measured memory_bytes: 3884
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    string s;
    cin>>s;
    int test=0;
    int x=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='I')
            x++;
        else
            x--;
        if(x>test)
            test=x;

    }
    cout<<test<<endl;

    
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
	int a, b, c;

	cin >> a >> b >> c;

	int ab = a + b;
	int ac = a + c;
	int bc = b + c;

	if (ab <= ac) {
		ab >= bc ? cout << bc << endl : cout << ab << endl;
	}
	else {
		ac <= bc ? cout << ac << endl : cout << bc << endl;
	}
	return 0;
}

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

int main()
{
   ios::sync_with_stdio(false);
    int a,b,c,x,y;
    int ans=0,cnta=0,cntb=0;;
    cin>>a>>b>>c>>x>>y;
    float ma,mb;
    ma=(a)/(float)(a+b)*c;
    mb=(b)/(float)(a+b)*c;
    while(cnta<x&&cntb<y)
    {
        if((2*c)<(a+b))
        {
            if(x<y)
            {
                int cc=cnta;
                cnta+=(x-cc);
                cntb+=(x-cc);
                ans+=x*2*c;
            }
           else
           {
                int cc=cntb;
                cnta+=(x-cc);
                cntb+=(x-cc);
                ans+=y*2*c;
           }
        }
        else
        {
             cout<<x*a+y*b;
             return 0;
        }
    }

        if(x>y){
        int cc=min(2*c,a);
        ans+=(cc*(x-y));
    }
    else{
        int cc=min(2*c,b);
        ans+=(cc*(y-x));
    }
    cout<<ans;
    return 0;
}


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

int main(){
	int N, min, max;
	vector<int> A;

	cin >> N;
	A.resize(N);

	for (int i = 0; i < N; ++i){
		cin >> A[i];
	}

	sort(A.begin(), A.end(), greater<int>());

	max = A[0];

	sort(A.begin(), A.end(), less<int>());

	min = A[0];

	cout << max - min << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()

int main(){
	int N;cin>>N;
	vector<int> A(N);
	int count=0,sum=0;
	rep(i,0,N){
		cin>>A[i];
		if(A[i]<=0){
			count++;
			sum-=A[i];
		}else{
			sum+=A[i];
		}
	}sort(range(A));
	if(count==0){
		count=1;
		sum-=2*A[0];
	}else if(count==N){
		count=N-1;
		sum+=2*A[N-1];
	}reverse(A.begin()+1,A.end());
	cout<<sum<<endl;
	rep(i,1,N){
		if(i<=N-count-1){
		    cout<<A[0]<<" "<<A[i]<<endl;
		    A[0]-=A[i];
		}else if(i==N-count){
			cout<<A[i]<<" "<<A[0]<<endl;
			A[0]=A[i]-A[0];
		}else{
			cout<<A[0]<<" "<<A[i]<<endl;
			A[0]-=A[i];
		}
	}
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)
ll N;
ll dp[111][5][5][5];
ll i, j, k, l,m,ans;
bool check(ll& a,ll& b,ll& c,ll &d){
    if(b==0&&c==2&&d==1)
        return false;
    if(b==0&&c==1&&d==2)
        return false;
    if(b==2&&c==0&&d==1)
        return false;
    if(a==0&&b==2&&d==1)
        return false;
    if(a==0&&c==2&&d==1)
        return false;
    return true;
}
int main(){
    scanf("%lld", &N);
    dp[0][3][3][3] = 1;
    fornum(i,0,N){
        fornum(j,0,4){
            fornum(k,0,4){
                fornum(l,0,4){
                    fornum(m,0,4){
                        if(check(j,k,l,m)){
                            dp[i + 1][k][l][m] += dp[i][j][k][l];
                            dp[i + 1][k][l][m] %= MOD;
                        }
                    }
                }
            }
        }
    }
    fornum(i,0,4){
        fornum(j,0,4){
            fornum(k,0,4){
                ans+=dp[N][i][j][k];
                ans %= MOD;
            }
        }
    }
    printf("%lld", ans);

    return 0;
}

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

int main(){
    string s,t,u;
    int a,b;
    cin >> s >> t >> a >> b >> u;
    if(s == u) a--;
    else b--;
    cout << a <<" " <<b << endl;
}

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

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using ull = unsigned long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vvs = vector<vs>;
using vc = vector<char>;
using vvc = vector<vc>;
using ii = pair<int,int>;
using vii = vector<ii>;
using vvii = vector<vii>;
using dd = pair<double, double>;
using vdd = vector<dd>;
using vvdd = vector<vdd>;
using Mii = map<int,int>;
using vMii = vector<Mii>;

#define fi first
#define se second
#define INF INT_MAX
#define mod(a,m) (a%m+m)%m
#define PB push_back
#define MP make_pair

vi memo;
vvi G;

int dp(int x) {
	cerr << "X: " << x <<"\n";
	int& ans = memo[x];
	if(ans != -1) return ans;
	ans = 0;
	for (int i = 0; i < G[x].size(); ++i) {
		ans = max(ans, dp(G[x][i]) + 1);
	}
	return ans;
}

int main(){
//	cout.setf(ios::fixed);
//	cout.precision(4);
	int n, m;
	while (cin >> n >> m) {
		G = vvi(n);
		for (int i = 0; i < m; ++i) {
			int x, y;
			cin >> x >> y;
			G[x-1].push_back(y-1);
		}
		int ans = 0;
		memo = vi(n, -1);
		for (int i = 0; i < n; ++i) ans = max(ans, dp(i));
		cout << ans << '\n';
	}
}




Measured memory_bytes: 7424
#include <bits/stdc++.h>
using i64 = long long;

template <class T = long long int>
class Bit {
    private:
    unsigned len;
    T init;
    std::vector<int> arr;

    public:
    Bit(unsigned length, T initialValue = 0): len(length), init(initialValue), arr(len + 1, init) {}
    void update(unsigned a, T newval) {
        for (unsigned x = a; x <= len; x += x & -x) arr[x] += newval;
    }
    T query(unsigned a) const {
        T ret = init;
        for (unsigned x = a; x > 0; x -= x & -x) ret += arr[x];
        return ret;
    }
};

int main() {
    int n;
    i64 d, a;
    std::cin >> n >> d >> a;

    std::vector<std::pair<i64, i64>> v;
    for (int i = 0; i < n; i++) {
        i64 x, h;
        std::cin >> x >> h;
        v.emplace_back(x, h);
    }

    std::sort(v.begin(), v.end());

    Bit<> bit(n + 10);
    i64 ret = 0;
    for (int i = 0; i < n; i++) {
        int ub = std::upper_bound(v.begin(), v.end(), std::make_pair(v[i].first + 2 * d + 1, 0ll)) - v.begin();
        i64 rem = std::max(0ll, v[i].second - a * bit.query(i + 1));
        i64 t = (rem + a - 1) / a;
        ret += t;
        bit.update(i + 1, t);
        bit.update(ub + 1, -t);
    }

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

    return 0;
}


Measured memory_bytes: 6256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N;

int main(void){
    
    scanf("%d", &N);
    vector<ll> v{2, 1};
    
    if(N == 1) printf("1\n");
    else{
        for(int i = 2; i <= N; ++i) v.push_back(v[i - 1] + v[i - 2]);
        printf("%lld\n", v.back());
    }
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 

const int MOD = 1000000007;

int dp[5001][5001]; // stores length of the matching and non-overlapping substrings ending with i'th and j'th characters.

int main()
{
    string S;
    int N;
    cin >> N >> S;

    memset(dp, 0, sizeof(dp));

    for (int i = 1; i <= N; ++i) {
        for (int j = i+1; j <= N; ++j) {
            if (S[i-1] == S[j-1] && dp[i-1][j-1] < j-i) {
                dp[i][j] = dp[i-1][j-1] + 1;
            } else {
                dp[i][j] = 0;
            }
        }
    }

    int ans = 0;
    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= N; ++j) {
            ans = max(ans, dp[i][j]);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 98048
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int main(){
	//fixed<<setprecision(3)
	string s,t;
	cin>>s>>t;
	int cnt=0;
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i])cnt++;
	}
	cout<<cnt<<endl;
	return 0;
} 

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

typedef long long ll;

int bfs(ll id, ll X, ll Y, ll N, int dir, ll d, ll *min_dist)
{
    //cout << id << "," << dir << endl;
    if(d <= min_dist[id])
    {
        min_dist[id] = d;
    }
    else
    {
        return 0;
    }

    if(id == X)
    {
        bfs(Y, X, Y, N, 1, d+1, min_dist);
    }
    if(id == Y)
    {
        bfs(Y-1, X, Y, N, -1, d+1, min_dist);
    }

    if(1 <= id + dir && id + dir <= N)
    {
        bfs(id + dir, X, Y, N, dir, d+1, min_dist);
    }

    return 0;
}


int main()
{
    ll N, X, Y;
    cin >> N >> X >> Y;

    ll *O = new ll [N];
    for(ll k=0; k<N; k++)
    {
        O[k] = 0;
    }

    ll *min_dist = new ll [N+1];

    for(ll id=1; id<=N; id++)
    {
        for(ll k=0; k<=N; k++)
        {
            min_dist[k] = N;//最大距離
        }
        ll d = 0;
        bfs(id, X, Y, N, 1, d, min_dist);
        if(X < id && id < (X+Y)/2)
        {
            ll d = 0;
            bfs(id, X, Y, N, -1, d, min_dist);
        }
            
        for(ll k=id+1; k<=N; k++)
        {
            //cout << id << "," << k << ":" << min_dist[k] << endl;
            O[min_dist[k]]++;
        }
    }

    //出力
    for(ll k=1; k<N; k++)
    {
        cout << O[k] << endl;
    }


    delete [] O;

    return 0;
}

Measured memory_bytes: 512
process.stdin.resume();
process.stdin.setEncoding('utf8');
var input_string = '';

process.stdin.on('data', function(chunk) {
    input_string += chunk;
});

process.stdin.on('end', function() {
  const lines = input_string.split("\n");
  const n = parseInt(lines[0]);
  const ks = lines[1].split(" ");
  const k = [];
  for(var i=0; i<n; i++){
    k[i] = parseInt(ks[i]);
    }
  var t = 0;
  var changed = true;
  while(changed){
    changed = false;
    for(var i=0;i<n;i++){
      if(k[i]>0){
        //console.log(i+" ");
      for(var j=i+1;j<n&&k[i]<=k[j];j++){
        k[j]--;
        //console.log(j+" ");
      }
      k[i]--;
      t++;
        changed = true;
        //console.log("e");
        break;
      }
    }
  }
  console.log(t);
});

Measured memory_bytes: 7500
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())

d1 = T1*(A1-B1)
d2 = T2*(A2-B2)
if d1>d2:
    d1 *= -1
    d2 *= -1

if (d1>0 and d1+d2>0) or (d1<0 and d1+d2<0):
    print(0)
elif d1+d2==0:
    print("infinity")
else:
    v = (abs(d1)//(d1+d2))
    ans = v*2
    pos = d1+v*(d1+d2)
    if pos<0 and pos+d2>=0:
        ans += 1
    print(ans)

Measured memory_bytes: 9152
import java.util.*;

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

        int N = sc.nextInt();
        int[] V = new int[N];
        int[] C = new int[N];
        int ans = 0;

        for(int i=0; i<N; i++){
            V[i] = sc.nextInt();
        }
        for(int i=0; i<N; i++){
            C[i] = sc.nextInt();
        }
        for(int i=0; i<N; i++){
            if(V[i]>C[i]){
                ans += V[i] - C[i];
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22356
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vint;
typedef vector<uint> vuint;
typedef vector<ull> vull;
typedef vector<ll> vll;

#define init(type,var) type var;cin>>var;
#define vinit(type,var,n) vector<type> var((uint)n);rep(i,0,n)cin>>var[i];
#define linit(type,var,n) list<type> var;rep(i,0,n){type _v;cin>>_v;var.push_back(_v);}
#define range(container) container.begin(),container.end()
#define rep(i,first,end) for(ull i=(first);i<(end);i++)
#define outl(out) cout<<(out)<<endl;

const ull INF = (ull)(-1LL);

typedef ull ntype;

typedef vector<ntype> vntype;
typedef list<ntype> lntype;

int main(void)
{
	init(ntype, A);
	init(ntype, B);
	init(ntype, m);

	vinit(ntype, a, A);
	vinit(ntype, b, B);

	vntype x(m), y(m), c(m);
	rep(i, 0, m)cin >> x[i] >> y[i] >> c[i];

	ntype a_min = a[0], b_min = b[0];
	rep(i, 1, A){
		if (a_min > a[i])a_min = a[i];
	}
	rep(i, 1, B){
		if (b_min > b[i])b_min = b[i];
	}

	ntype ans = a_min + b_min;

	rep(i, 0, m){
		ntype e = a[x[i]-1] + b[y[i]-1] - c[i];
		if (ans > e)ans = e;
	}

	outl(ans);

	return 0;
}

Measured memory_bytes: 4224
#include<iostream>
using namespace std;
int n,ans,ans2,a,b,c;
int main(){
  while(cin>>n&&n){
    cin>>a>>b>>c; ans=a,ans2=b+c;
    for(int i=0;i<n-1;i++){
      cin>>a>>b>>c;
      if(ans2<b+c)ans=a,ans2=b+c;
    }cout<<ans<<' '<<ans2<<endl;
  }
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    vi a(3);
    in(3,a);
    sort(all(a));

    a[0]==a[1]&&a[1]==a[2] ? cyes:cno;
    
    
    

    return 0;
}


Measured memory_bytes: 256
import * as fs from 'fs';

function main(input: string) {


  const lines = input.split("\n");
  const [n, k] = lines[0].split(' ').map((v: string) => +v);

  const h = lines[1].split(' ')
    .map((v: string) => +v)
    .sort((a: number, b: number) => b - a)
    .slice(k);

  console.log(h.reduce((prev: number, current: number) => prev + current, 0));
}

main(fs.readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 37328
from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
for i in range(K, N+2):
    min = 0
    max = 0
    min = (i*(i-1))//2
    max = i*N-min
    ans += max-min+1
print(ans % (10**9+7))


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

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

const int64 mod = 1e9+7;

/*
int32 H, W;
vector<vector<int32>> v;
vector<string> s;

int main(void){
	cin >> H >> W;
	s.resize(H);
	v = vector<vector<int32>>(H-1, vector<int32>(W-1, 0));
	REP(i, H){
		cin >> s[i];
	}
	REP(i, H-1){
		REP(j, W-1){
			int32 cnt = 0;
			REP(k, 2){
				REP(l, 2){
					cnt += s[i+k][j+l] == '.';
				}
			}
			if(cnt%2 == 0) v[i][j] = 1;
		}
	}
	FOR(i, 1, H-1){
		REP(j, W-1){
			if(v[i][j] == 1) v[i][j] += v[i-1][j];
		}
	}
	int64 res = max(H, W);
	REP(i, H-1){
		stack<PLL> st;
		st.push(PLL(-1, -1));
		REP(j, W-1){
			while(st.top().fs >= v[i][j]) st.pop();
			res = max(res, (v[i][j]+1)*(j-st.top().sc+1));
			st.push(PLL(v[i][j], j));
		}
	}
	cout << res << endl;
}
*/

int main(void){
	int32 N;
	vector<int64> v;
	cin >> N;
	v.resize(N);
	REP(i, N) cin >> v[i];
	v.push_back(0);
	int64 res = 0;
	stack<PLL> st;
	st.push(PLL(-1, -1));
	REP(i, N+1){
		int32 l = i;
		while(st.top().fs >= v[i]){
			res = max(res, st.top().fs*(i-st.top().sc));
			l = st.top().sc;
			st.pop();
		}
		st.push(PLL(v[i], l));
	}
	cout << res << endl;
}


Measured memory_bytes: 5232
#include<bits/stdc++.h>
using namespace std;
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	int ans=0,v[21],c,n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>v[i];
	for(int i=0;i<n;i++){
		cin>>c;
		ans+=max(0,v[i]-c);
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,l,r;
  cin >> a >> b>>c>>d;
 l=a+b;
 r=c+d;
  if (l > r) {
    cout << "Left" << endl;
  }
  else if (l<r) {
      cout << "Right" << endl;
    }
  else {
     cout << "Balanced"<<endl;
   }
}


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

int solveMeFirst(int a, int b) {
 // Hint: Type return a+b; below:
  
}

int main() {
  int a1, a2, a3;
  int sum = 0;
  cin>>a1>>a2>>a3;
  sum += a1;
  sum += a2;
  sum += a3;
  if(sum >= 22) cout<<"bust";
  else cout<<"win";
  return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <stdio.h>

static const int MAX_NUM_INPUT = 200000;
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int main()
{
    int n, i;
    int R[MAX_NUM_INPUT];
    int maxv = INT_MIN;
    int minv;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%d", &R[i]);
    }
    
    minv = R[0];
    
    for (i = 1; i < n; i++) {
        maxv = MAX(maxv, R[i] - minv);
        minv = MIN(minv, R[i]);
    }
    
    printf("%d\n", maxv);
    
    return 0;
}



Measured memory_bytes: 2636
N = int(input())
ans = 10**6
for i in range(N//2):
    A, B = i+1, N - i - 1
    A_sum = sum(map(int, list(str(A))))
    B_sum = sum(map(int, list(str(B))))
    ans = min(ans, A_sum+B_sum)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
using namespace std;
using ll = long long;
void self_max(int &a,int b){
  a = max(a,b);
}

int main(){
  int a,b; cin >> a >> b;
  std::vector<int> v;
  v.push_back(a);
  v.push_back(a-1);
  v.push_back(b);
  v.push_back(b-1);
  sort(v.begin(),v.end());
  cout << v[3] + v[2] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>

int getNumsInt32(int32_t *buf, int32_t num)
{
  int32_t i;

  for (i = 0; i < num; i++) {
    if (scanf("%d", &buf[i]) == EOF) {
      return -1;
    }
  }
  return 0;
}

int main()
{
  int32_t val[3];
  float time;
  int32_t ans;

  if (getNumsInt32((int32_t *)val, (int32_t)3) == -1) {
    return -1;
  }

  time = (float)val[2] + (float)0.5;

  ans = ((uint32_t)(time / val[0])) * val[1];

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

  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); //??\???????¨????
		
		while(true){ //????????????????????????
			 int x = sc.nextInt();
			 int y = sc.nextInt();
			 
			 if(x == 0 && y == 0){
				 break;
			 }
			 if(x > y){
				 System.out.println(y + " " + x);
			 }else
			 {
				 System.out.println(x + " " + y);
			 }

	}
	}
}

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

using ll = long long;

int H, N;
vector<int> A;
vector<int> B;

void solve(){
    vector<int> dp(H + 1, INT_MAX);
    dp[0] = 0;

    for(int i = 0; i <= H; ++i){
        for(int j = 0; j < N; ++j){
            int prev = max(i - A[j], 0);
            dp[i] = min(dp[i], dp[prev] + B[j]);
        }
    }
    cout << dp[H];
}

int main(){
    cin >> H >> N;
    A.resize(N);
    B.resize(N);
    for(int i = 0; i < N; ++i){
        cin >> A[i] >> B[i];
    }
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	std::string s; cin >> s;
	int q; scanf("%d", &q);
	
	bool rev = false;
	while(q--) {
		int type; scanf("%d", &type);

		if(type == 1) {
			rev = !rev;
		} else if(type == 2) {
			int x; char c; cin >> x >> c;
			
			if(x == 1) {
				if(rev) s.push_back(c);
				else s.insert(begin(s), c);
			} else if(x == 2) {
				if(!rev) s.push_back(c);
				else s.insert(begin(s), c);
			}
		}
	}
	if(rev) reverse(begin(s), end(s));
	
	printf("%s\n", s.c_str());
	return 0;
}


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  string s;
  cin >> s;
  vecll a(26, 0);
  if(s == "zyxwvutsrqponmlkjihgfedcba"){
	cout << -1 << endl;
	return 0;
  }
  if(s.size() < 26){
	forll(i, 0, s.size())
	  a[s[i] - 'a']++;
	forll(i, 0, 26){
	  if (a[i] == 0){
		s += (i + 'a');
		cout << s << endl;
		return 0;
	  }
	}
  }
  string t = s;
  next_permutation(s.begin(), s.end());
  forll(i, 0, 26){
	cout << s[i];
	if (s[i] != t[i]){
	  cout << endl;
	  return 0;
	}
  }
  cout << endl;
}


Measured memory_bytes: 256
house = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
n = int(input())
for x in range (n):
    b, f, r, v = map(int, input().split())
    house[b - 1][f - 1][r - 1] += v
for b in range(4):
    for f in house[b]:
        print('', *f)
    if b != 3:
        print('#' * 20)


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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var n = cin.ReadInt;
            var d = new List<int>();
            for (var i = 0; i < n; i++) {
                d.Add(cin.ReadInt);
            }

            d = d.Distinct().ToList();
            WriteLine(d.Count());
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	int N;
	cin >> N;

	int kotae = 0;
	int kari = 0;
	int mae = 0;
	rep(i, N) {
		int h;
		cin >> h;
		if (mae >= h) kari++;
		else kari = 0;

		kotae = max(kotae, kari);
		mae = h;
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line: Vec<usize> = read_as_vec();
    let (n, m) = (line[0], line[1]);
    let mut steps: Vec<i64> = vec![0;n+1];

    for _ in 0..m{
        let broken: usize = read_as_vec()[0];
        steps[broken] = -1;
    }

    steps[0] = 1;
    if steps[1] != -1{
        steps[1] = 1;
    }

    for i in 2..n+1{
        if steps[i] == -1{
            continue
        }

        steps[i] = (cmp::max(0, steps[i-1]) + cmp::max(0, steps[i-2]))%1000000007;
    }

    println!("{}",steps[n]);
    
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    int n;
    cin >> n;
    VL av(n);
    REP(i, n) cin >> av[i];
    SORT(av);
    REVERSE(av);
    ll ans = 0;
    int now = 1;
    REP(i, n-1) ans += av[(i+now) / 2];
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


Measured memory_bytes: 4772
#include <iostream>

typedef long long ll;

using namespace std;

int main(){
    ll b[51];
    ll p[51];
    ll d[51];
    ll N, K;
    ll ans = 0;
    cin >> N >> K;
    b[0] = 0;
    p[0] = 1;
    d[0] = 1;
    for(int i = 1; i < 51; i++){
        b[i] = 2 + 2*b[i-1];
        p[i] = 1 + 2*p[i-1];
        d[i] = 3 + 2*d[i-1];
    }
    
    while(N > 0){
        if(K == 1){
            break;
        }else if(K < d[N-1]+2){
            if(N == 1) ans+= 1;
            N--;
            K--;
        }else if(K == d[N-1]+2){
            ans+=(p[N-1] + 1);
            break;
        }else if(K < d[N]){
            ans+=(p[N-1] + 1);
            if(N == 1) ans+= 1;
            K -= (d[N-1]+2);
            N--;
        }else{
            ans+=(2*p[N-1] + 1);
            break;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stdio.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;

int main() {
	string S, T;
	cin >> S >> T;

	if (T.substr(0, S.length()) == S) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  int len = a[n-1]+1;
  vi yakusuu(len);
  rep(i,n){
    for(int j=a[i]; j<=len; j+=a[i]){
      yakusuu[j]++;
    }
  }
  int ans=0;
  rep(i,n){
    if(yakusuu[a[i]] == 1) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 7928
#include <bits/stdc++.h>
#define int long long
using namespace std;

inline int read(){
    int 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;
}

inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

inline void writeln(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
    puts("");
}

signed main(){
    int n=read();

    int ans[100010];

    memset(ans,0,sizeof(ans));

    for(int i=1;i<=110;i++)
        for(int j=1;j<=110;j++)
            for(int k=1;k<=110;k++)
                ans[i*i+j*j+k*k+i*j+i*k+j*k]++;

    for(int i=1;i<=n;i++)
        writeln(ans[i]);

    return 0;
}

Measured memory_bytes: 4344