akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    int k;
    cin>>k;
    if(k%7==0) k/=7;
    int start=1%k,num=1;
    vector<bool> rem(k+10,true);
    rem[start]=false;
    bool flag=true;
    while(flag){
        flag=false;
        if(start==0){
            cout<<num<<"\n";
            return;
        }
        start=(10*start+1)%k;
        num++;
        if(rem[start]){
            flag=true;
            rem[start]=false;
        }
    }
    cout<<"-1\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <deque>
using namespace std;

int main(){
        int h,w,i,j,ch,cw,dh,dw,nh,nw,nv;
        cin >> h >> w;
        vector<vector<char>> s(h,vector<char>(w));
        vector<vector<int>> c(h,vector<int>(w,1e7));
        cin >> ch >> cw;
        --ch; --cw;
        cin >> dh >> dw;
        --dh; --dw;
        for(i=0;i<h;++i){
                for(j=0;j<w;++j){
                        cin >> s.at(i).at(j);
                }
        }
        c.at(ch).at(cw) = 0;
        deque<pair<int,int>> q;
        q.push_front({ch,cw});
        while(q.size()){
                nh = q.front().first;
                nw = q.front().second;
                nv = c.at(nh).at(nw);
                q.pop_front();
                for(i=-2;i<=2;++i){
                        for(j=-2;j<=2;++j){
                                if(nh+i<0||nh+i>=h) continue;
                                if(nw+j<0||nw+j>=w) continue;
                                if(s.at(nh+i).at(nw+j)=='#') continue;
                                if(i==0&&j==0) continue;
                                if(c.at(nh+i).at(nw+j)>nv){
                                        if(abs(i)+abs(j)==1){
                                                c.at(nh+i).at(nw+j) = nv;
                                                q.push_front({nh+i,nw+j});
                                        }else if(c.at(nh+i).at(nw+j)==1e7){
                                                c.at(nh+i).at(nw+j) = nv+1;
                                                q.push_back({nh+i,nw+j});
                                        }
                                }
                        }
                }
        }
        if(c.at(dh).at(dw)==1e7) cout << -1 << endl;
        else cout << c.at(dh).at(dw) << endl;
        return 0;
}

Measured memory_bytes: 8624
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort() # index: 0,...,N-1

ans = 0
for i in range(N-2): # i: 0,...,N-3
    for j in range(i+1, N-1): # j: i+1,...,N-2
        # k の満たすべき条件:
        # 1. L[k] > L[j] - L[i]
        #     L[k] > L[j] なので自動的に満たす
        # 2. L[k] < L[i] + L[j]
        x = bisect.bisect_left(L, L[i]+L[j])
        # (<L[i]+L[j]), (<L[i]+L[j]), ..., (<L[i]+L[j]) | (L[i]+L[j]<=), (L[i]+L[j]<=), ...
        # | (x) より左側はOK
        # j+1 より右側はOK
        # L[j]<L[i]+L[j] と L[i]+L[j]<=L[x] より L[j]<L[x] つまり j<x
        ans += x - (j + 1)

print(ans)


Measured memory_bytes: 3188
def q2():
    N = int(input())
    T = []
    for n in range(N):
        s, p = (i for i in input().split())
        T.append({'n': n+1, 's': s, 'p': int(p)})
    T = sorted(T, key=lambda x: x['p'], reverse=True)
    T = sorted(T, key=lambda x: x['s'])

    for t in T:
        print(t['n'])


if __name__ == '__main__':
    q2()

Measured memory_bytes: 38512
import java.util.Scanner;
class Main{
    public static void main(String[] args){
		int n;
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		call(n);
    }
	public static void call(int n){
		int i=1;
		while(i<=n){
			int x=i;
			if(x%3==0){
				System.out.print(" "+i);
				i++;
				continue;
			}
			while(true){
				if(x%10==3){
					System.out.print(" "+i);
					break;
				}else {
					x/=10;
					if(x==0)break;
				}
			}
			i++;
		}
		System.out.println();
	}
}



Measured memory_bytes: 28748
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define tests(i) cout<<"i: "<<i<<endl;
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
void file(){
    #ifdef LOCAL
    freopen("demo.in","r",stdin);
    freopen("demo.out","w",stdout);
    #endif
}
bool sortdes(const pair<int,int> &a, const pair<int,int> &b){return a.ss<b.ss;}
bool sortasc(const pair<int,int> &a, const pair<int,int> &b){return a.ss>b.ss;} 
int gcd(int x,int y){return __gcd(x,y);}
// lld fact(lld n);
// lld nCr(lld n,lld r){return fact(n) / (fact(r) * fact(n - r));}
// lld fact(lld n){ lld res = 1; for(lld i = 2; i <= n; i++){res = res * i;}return res;} 
// const int maxi = 1e6+10;
// vector<int> v[maxi];
// long long a[maxi];
// void dfs(int x,int y){
//     a[x]+=a[y];
//     for(int i:v[x]){
//         if(i!=y){
//             dfs(i,x);
//         }
//     }
// }

void test_case(){
    int a,b,c;
    cin>>a>>b>>c;
    int sum=c-(a-b);
    if(sum<0){
        cout<<"0";
    }
    else{
        cout<<sum;
    }
    
}

int main(){
    fastio;
    file();
    int T=1;
    // int T;
    // cin>>T;
    for(int nr=1;nr<=T;++nr) {
        // cout<<"Case #"<<nr<<": ";
		test_case();
    }
}

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

int main(){  
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if ((a+b)>(c+d))
  {
    cout << "Left" << endl;
  } else if ((a+b)==(c+d))
  {
    cout << "Balanced" << endl;
  } else
  {
    cout << "Right" << endl;
  }
  return 0;
}

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

using namespace std;


const int MAX_N = 1000000;
int par[MAX_N];

//syokika
void init(int n){
  for(int i = 0; i < n; i++) par[i] = i;
}

//kinonewomotomeru
int root(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = root(par[x]);
  }
}

//hanntei
bool same(int x, int y){
  return root(x) == root(y);
}

void unite(int x, int y){
  x = root(x);
  y = root(y);
  if(x == y) return;

  par[x] = y;
}

int main(void){

  int n, m;
  cin >> n >> m;

  vector<int> adj[n];

  //syokika
  init(n);

  //heigou
  for(int i = 0; i < m; i++){
    int s, t; cin >> s >> t;
    unite(s, t);
  }

  int q; cin >> q;

  for(int i = 0; i < q; i++){
    int s, t; cin >> s >> t;
    if(same(s, t)) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  


  return 0;

}

Measured memory_bytes: 6344
#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 mem(x,y) memset(x,y,sizeof(x))  
#define lli long long int
#define ll long long 
#define ld long double
#define pb push_back
#define mp make_pair
#define F first
#define S second 
#define LB lower_bound
#define UB upper_bound
#define BS binary_search
#define pii pair<lli,lli>
const long long int mod=1000000007;
//const long long int mod=998244353;
const long double PI=3.141592653589793;
const long long int inf=1e18;
const long long int inf2=LLONG_MAX;
#define setBitCount(x) __builtin_popcountll(x)
#define all(a) (a).begin(), (a).end()
#define all_r(a) (a).rbegin(), (a).rend()
lli gcd(lli a,lli b)
{
    if(b==0)
    return a;
    else
    return gcd(b,a%b);
}
// calculating (x^y)%p
lli power(lli x,lli y,lli p)
{
    lli res = 1;      
    x = x % p;  
    while (y > 0)
    {
        if (y & 1) //y is odd  
        res = (res*x) % p;
        y = y>>1; 
        x = ( (x%p)*(x%p) )% p;  
    }
    return res%p;
}
// calculating modular inverse using fermat little theorem
lli modInverse(lli n,lli p) 
{
    return power(n, p-2, p)%p;
}

// policy based data structures !!
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
// s.order_of_key (k) : Number of items strictly smaller than k
// *(s.find_by_order(k)) : K-th element in a set (counting from zero)
lli dp[103][100004];
lli pre[104][100004];
lli n,k;
lli a[105]; 
void solve()
{
   cin>>n>>k;
   
   for(lli i=1;i<=n;i++)
   {
      cin>>a[i];
   }
   for(lli i=0;i<=a[1];i++)
   dp[1][i]=1;
   
   pre[1][0]=dp[1][0];
   for(lli i=1;i<=k;i++)
   {
      pre[1][i]=(pre[1][i-1]+dp[1][i])%mod;
   }
   for(lli i=2;i<=n;i++)
   {
      dp[i][0]=dp[i-1][0]%mod;
      pre[i][0]=dp[i][0];
      for(lli j=1;j<=k;j++)
      {
         if(j<=a[i])
         {
            dp[i][j]=pre[i-1][j]%mod;
         }
         else
         {
            lli l=j-a[i];
            lli r=j;
            dp[i][j]=(pre[i-1][r]-pre[i-1][l-1]+mod)%mod;
         }
         pre[i][j]=(pre[i][j-1]+dp[i][j])%mod;
      }
   }
   
   cout<<dp[n][k]%mod;
}
int main()
{
   
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    lli T;
    //cin>>T;
    T=1;
    while(T--)
    {
        solve();
    }




    return 0;
}

Measured memory_bytes: 157568
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = sum(B)
pre = -3
for a in A:
    if pre+1 == a:
        ans += C[pre-1]
    pre = a
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#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(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;

struct edge{int from, to; ll cost;};
const ll inf = 1e18;
int n,m;
vector<edge> g;
ll dist[1005];

int main(){
    cin >> n >> m;
    rep(i, m){
        int f,t; ll c; cin >> f >> t >> c; f--; t--;
        g.push_back(edge{f, t, -c});
    }

    rep(i,n) dist[i] = inf;
    dist[0] = 0;

    rep(i, n){
        rep(j, m){
            edge e = g[j];
            if (dist[e.from] != inf && dist[e.to] > dist[e.from] + e.cost) {
                dist[e.to] = dist[e.from] + e.cost;
            }
        }
    }

    vector<bool> negative(n, false);
    rep(i,n){
        rep(j,m){
            edge e = g[j];
            if (dist[e.from] != inf && dist[e.to] > dist[e.from] + e.cost) {
                dist[e.to] = dist[e.from] + e.cost;
                negative[e.to] = true;
            }
            if(negative[e.from]) negative[e.to] = true;
        }
    }

    if(negative[n-1]) cout << "inf" << endl;
    else cout << -dist[n-1] << endl;
}

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

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

  int ans = b[0]+b[n-2];
  for ( int i = 0; i < n-2; i++ ) {
    ans += min(b[i], b[i+1]);
  }

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


Measured memory_bytes: 3616
import sys

str = sys.stdin.readlines()

n = int(str[0])
alist_str = str[1].split()

target = 1
breaks = 0
for a in alist_str:
    if int(a) == target:
        target += 1
    else:
        breaks += 1

if breaks == n:
    print(-1)
else:
    print(breaks)

Measured memory_bytes: 17168
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    if (S.contains("A") && S.contains("B")) {
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35704
X, Y, V = *0..2
EPS = 1e-9
until (n = gets.to_i).zero?
  cafe = n.times.map{gets.split.map(&:to_f)}
  x, y = cafe.first
  d = 50.0
  r = 0.98
  until d < EPS
    farthermost = cafe.max_by{|c| Math.hypot(c[X] - x, c[Y] - y) / c[V]}
    angle = Math::atan2(farthermost[Y] - y, farthermost[X] - x)
    x += Math::cos(angle) * d
    y += Math::sin(angle) * d
    d *= r
  end
  puts "%.8f"%cafe.map{|c| Math.hypot(c[X] - x, c[Y] - y) / c[V]}.max
end

Measured memory_bytes: 6296
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <math.h>
using namespace std;
using ll=long long;
int ln (ll n){
    int l=1;
    while(n>=10){
        ++l;
        n/=10;
    }
    return l;
}

int main() {
    ll n;
    cin>>n;
    ll a,b;
    int c,d,e=ln(n),f=ln(n);
    for(a=1;a<=sqrt(n);++a){
        if(n%a==0){
            b=n/a;
            c=ln(a);
            d=ln(b);
            if(c>=d) e=c;
            else e=d;
        }
        if(e<f) f=e;
    }
    cout<<f<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define loop(i, l, r) for(int i = l; i < r; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vec_i;

const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int INF = 1e9;
const int MOD = 1e9+7;

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

	vector< vec_i> g(n);
	vec_i indeg(n, 0);
	rep(i, m){
		int a,b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		indeg[b]++;
	}

	stack<int> stk;
	rep(i, n){
		if(indeg[i] == 0) stk.push(i);
	}

	vec_i dist(n, 0);
	while(!stk.empty()){
		int u = stk.top(); stk.pop();
		rep(i, g[u].size()){
			int v = g[u][i];
			dist[v] = max(dist[v], dist[u]+1);
			indeg[v]--;
			if(indeg[v]==0) stk.push(v);
		}
	}

	int ans = 0;
	rep(i, n) ans = max(ans, dist[i]);
	cout << ans << endl;
}

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 510, M = 1010;

int n, m;
int g[N][N], cnt;
vector<PII> from, to;

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i ++ )
		for (int j = 1; j <= m; j ++ )
			cin >> g[i][j];
	
	for (int i = 1; i < n; i ++ )
		for (int j = 1; j <= m; j ++ )
			if (g[i][j] & 1)
			{
				g[i][j] -- ;
				g[i + 1][j] ++ ;
				from.push_back({i, j});
				to.push_back({i + 1, j});
				cnt ++ ;
			}
	
	for (int i = 1; i < m; i ++ )
		if (g[n][i] & 1)
		{
			g[n][i] -- ;
			g[n][i + 1] ++ ;
			from.push_back({n, i});
			to.push_back({n, i + 1});
			cnt ++ ;
		}
		
	// for (int i = 1; i <= n; i ++ )
	// {
		// for (int j = 1; j <= m; j ++ )
			// cout << g[i][j] << ' ';
		// puts("");
	// }
	
	cout << cnt << endl;
	for (int i = 0; i < cnt; i ++ )
		cout << from[i].F << ' ' << from[i].S << ' ' << to[i].F << ' ' << to[i].S << endl;
	return 0;
}

Measured memory_bytes: 5228
//JSD
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#define ll long long
#define Mod 1000000007
using namespace std;
ll modular_exponentiation(ll a,ll b){
	if(b==0){
		return 1;
	}
	if(b==1){
		return a%Mod;
	}
	ll x=modular_exponentiation(a,b/2);
	x=(x*x)%Mod;
	if(b%2==1){
		x=(x*a)%Mod;
	}
	return x;
}
ll modular_divison(ll a,ll b){
    return (modular_exponentiation(b,Mod-2)*a)%Mod;
}

bool isPrime(ll n){
	if(n<=1) return 0;
	if(n==2 or n==3 ) return 1;
	if(n%2==0 or n%3==0) return 0;
	for(ll i=5;i*i<=n;i+=6){
		if(n%i==0 or n%(i+2)==0)
			return 0;
	}
	return 1;
}
struct primeFactorInfo{
	map<ll,ll> M;
	set<ll> S;
};
primeFactorInfo pfs(ll n){
	primeFactorInfo p;
	for(ll i=2;i<=sqrt(n);i++){
		if(n%i==0){
			p.S.insert(i);
			while(((n%i)==0)){
				p.M[i]++;
				n/=i;
			}
		}
	}
	if(n>1){
		p.M[n]++;
		p.S.insert(n);
	}
	return p;
}
void sieve(ll n,vector<ll>& v){
	bool isComposite[n+1]={0};
	isComposite[0]=isComposite[1]=1;
	for(ll i=2;i*i<=n;i++){
		if(!isComposite[i]){
			v.push_back(i);
			for(int j=2;j*i<=n;j++){
				isComposite[i*j]=1;
			}
		}
	}
}
primeFactorInfo pfsUsingSieve(ll n){
	primeFactorInfo p;
	vector<ll > v;
	sieve(n,v);
	for(auto i: v){
		if(n%i==0){
			p.S.insert(i);
			while(((n%i)==0)){
				p.M[i]++;
				n/=i;
			}
		}
	}
	if(n>1){
		p.M[n]++;
		p.S.insert(n);
	}
	return p;
}
int main(){
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n,greater<ll>());
	for(int j=0;j<min(n,k);j++){
		a[j]=0;
	}
	ll ans=0;
	for(ll i=0;i<n;i++){
		ans+=a[i];
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 1792
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

use std::cmp::max;
use std::thread;

fn main() {
    let handler = thread::Builder::new().stack_size(512 << 20).spawn(|| {
        process()
    }).unwrap();

    handler.join().unwrap();
}

fn process() {
    input! {
        n: usize,
        a: [i64; 3],
        b: [i64; 3],
    }

    let m = solve(n, &a, &b, &mut vec![None; n+1]) as usize;
    let ans = solve(m, &b, &a, &mut vec![None; m+1]) as usize;

    println!("{}", ans);
}

fn solve(n: usize, w: &[i64], v: &[i64], tbl: &mut Vec<Option<i64>>) -> i64 {
    if let Some(ret) = tbl[n] {
        return ret;
    }

    let mut ret = n as i64;
    for i in 0..w.len() {
        if (n as i64) < w[i] {
            continue;
        }
        ret = max(ret, solve(n-w[i] as usize, w, v, tbl) + v[i]);
    }
    tbl[n] = Some(ret);
    ret
}


Measured memory_bytes: 700668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
string S;
int main(){
	string key="keyence";
	cin>>S;
	bool f=false;
	if (S.size()==7){
		if (S==key){
			f=true;
		}
	}else{
		int n=S.size();
		REP(i,n){
			int inx=0;
			bool flg=true;
			REP(j,n){
				if (j==i){
					j+=n-7;
					j--;
				}else{
					if (S[j]!=key[inx]){
						flg=false;
					}
					inx++;
				}
			}
			if (flg && inx==7){
				f=true;
			}
		}
	}
	cout<<(f ? "YES" : "NO")<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func main() {
	N := getInt()
	H := getIntArray(N)

	num := make([]int, N)
	num[N-1] = 0
	for i := N-2; i >= 0; i-- {
		if H[i] < H[i+1] {
			num[i] = 0
		} else {
			num[i] = num[i+1] + 1
		}
	}

	fmt.Println(max(num...))
}

type Graph struct {
	n     int
	edges [][]int
}

func NewGraph(n int) *Graph {
	g := &Graph{
		n:     n,
		edges: make([][]int, n),
	}
	return g
}

func (g *Graph) AddEdge(u, v int) {
	g.edges[v] = append(g.edges[v], u)
	g.edges[u] = append(g.edges[u], v)
}

func dfs(c int, edges [][]int, visited map[int]struct{}) {
	visited[c] = struct{}{}

	for _, v := range edges[c] {
		_, flag := visited[v]
		if flag {
			continue
		}
		dfs(v, edges, visited)
	}
}

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getIntArray(n int) []int {
	array := make([]int, n)
	for i := 0; i < n; i++ {
		array[i] = getInt()
	}
	return array
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func powMod(n, p int) int {
	if p == 0 {
		return 1
	} else if p%2 == 0 {
		t := powMod(n, p/2)
		return calcMod(t * t)
	} else {
		return calcMod(n * powMod(n, p-1))
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray)-1])
}

func calcMod(x int) int {
	return x % mod
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func isPrime(n int) bool {
	if n < 2 {
		return false
	} else if n == 2 {
		return true
	} else if n % 2 == 0 {
		return false
	}

	sqrtN := int(math.Sqrt(float64(n)))
	for i := 3; i <= sqrtN; i += 2 {
		if n % i == 0 {
			return false
		}
	}

	return true
}


Measured memory_bytes: 3840
import math

A, B, H, M = map(int, input().split())
rad_a = 30 * H + 0.5 * M
rad_b = 6 * M
rad = abs(rad_a - rad_b)
cos = math.cos(math.radians(rad))

# 余弦定理を利用する
print(math.sqrt(A**2 + B**2 - 2*A*B*cos))

Measured memory_bytes: 9504
#include<stdio.h>

int main()
{
  int i,mini,a[100],n,temp,j,num=0;
  scanf("%d",&n);
  for (i = 0; i < n; i++) {
    scanf("%d",&a[i]);
  }
  for (i = 0; i < n; i++) {
    mini = i;
    for (j = i; j < n; j++) {
      if(a[mini] > a[j])
        mini = j;
    }
    if(mini != i){
      num++;
      temp = a[i];
      a[i] = a[mini];
      a[mini] = temp;
    }  
   }
  for (i = 0; i < n-1; i++)
  printf("%d ",a[i]);
  printf("%d\n",a[n-1]);
  printf("%d\n",num);
  return 0;
}
    
    

Measured memory_bytes: 1812
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

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

#include <utility>
using Histgram = pair<int, int>;

ll maxHist(vector<int> &hist) {
    vector<Histgram> st;
    ll ans = 0;
    hist.push_back(-1);
    REP(i, 0, hist.size()) {
        if (st.empty()) {
            st.emplace_back(hist[i], i);
        } else if (st.back().first == hist[i]) {
            // pass
        } else if (st.back().first < hist[i]) {
            st.emplace_back(hist[i], i);
        } else {
            ll lst = 0;
            while (st.size() && st.back().first > hist[i]) {
                lst = st.back().second;
                ans = max(ans, (i - lst) * st.back().first);
                st.pop_back();
            }
            st.emplace_back(hist[i], lst);
        }
    }
    return ans;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int W, H;
    while (cin >> H >> W, W + H) {
        auto mp = make_v(H, W, '*');
        REP(i, 0, H) {
            REP(j, 0, W) {
                cin >> mp[i][j];
            }
        }
        vector<int> hist(W, 0);
        ll ans = 0;
        REP(i, 0, H) {
            REP(j, 0, W) {
                if (mp[i][j] == '.') {
                    hist[j]++;
                } else {
                    hist[j] = 0;
                }
            }
            ll res = maxHist(hist);
            ans = max(ans, res);
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3180
n = int(input())

def f_pf(n):
    pf = {}
    for i in range(2, n + 1):
        for j in range(2, i + 1):
            while i % j == 0:
                pf[j] = pf.get(j, 0) + 1
                i //= j
    return pf

def cnt(x):
    cnt = 0
    for v in f_pf(n).values():
        if v >= x - 1:
            cnt += 1
    return cnt
        
ans = cnt(75) + cnt(25) * (cnt(3) - 1) + cnt(15) * (cnt(5) - 1) + cnt(5) * (cnt(5) - 1) * (cnt(3) - 2) // 2

print(ans)

Measured memory_bytes: 3064
import numpy as np
n = int(input())
a = np.zeros((2, n))
a[0, :] = np.array(list(map(int, input().split())))
a[1, :] = np.array(list(map(int, input().split())))

candy = []
for i in range(n):
    candy.append(np.sum(a[0, 0: i + 1]) + np.sum(a[1, i:]))
print(int(max(candy)))


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

int main() {
  int n;
  cin >> n;
  int ans = n;
  vector<int> h(n);
  for(int i = 0; i < n; i++) {
    cin >> h.at(i);
  }
  for(int i = 1; i < n; i++) {
    for(int j = 0; j < n-(n-i-1); j++) {
      if(h.at(i) < h.at(j)) {
         ans--;
        goto p;
      }
    }
    p:;
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const ll INF = 1e18;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int N, M, R;
    cin >> N >> M >> R;
    int r[R];
    rep(i, 0, R) {
        cin >> r[i];
        r[i]--;
    }

    ll dist[N][N];
    rep(i, 0, N) {
        rep(j, 0, N) {
            dist[i][j] = INF;
        }
        dist[i][i] = 0;
    }

    rep(i, 0, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }

    rep(k, 0, N) {
        rep(i, 0, N) {
            rep(j, 0, N) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    sort(r, r + R);
    ll ans = INF;
    do {
        ll d = 0;
        rep(i, 0, R - 1) {
            d += dist[r[i]][r[i + 1]];
        }
        ans = min(ans, d);
    } while (next_permutation(r, r + R));

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


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

using namespace std;

int main() {
  int n;
  int ans = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int ll, rr;
    scanf("%d %d", &ll, &rr);
    ans += (rr - ll + 1);
  }
  printf("%d\n", ans);
  return 0;
}

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

#define int long long
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()

signed main(){
    int x,y,z; cin >> x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<' '<<y<<' '<<z<<endl;
}

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

#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;


//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int power(int a,int n)
{
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return a*power(a*a,n/2);
    return power(a*a,n/2);
}
const int md = 998244353;
const int inf = (int) 1e18;

/*int inverse(int x){

    return power(x,mod-2)%mod;//little fermat....
}*/

signed main()
{
    showoff;
    string s;
    cin >> s;
    FOR(i,0,sz(s)-1){
        if(s[i] == s[i+1]){
            cout << "Bad\n";
            return 0;
        }
    }
    cout << "Good";
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...   

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

///nの約数を追加する(nを含む)
vector<pair<long,long> > divisor_pick(ll n){
    vector<pair<long,long> > a;
    for(ll i=2LL;i*i<=n;i++){
        ll count = 0;
        while(n % i == 0){
            n /= i;
            count++;
        }
        if(count)a.push_back({i,count});
    }
    if(n != 1)a.push_back({n,1});
    sort(all(a));
    return a;
}

signed main()
{   
    gearup;
    ll n; cin >> n;
    auto tmp = divisor_pick(n);
    
    vl res;
    //if(n != 1)res.push_back(n);
    for(auto tm:tmp){
        ll cnt = tm.second;
        ll num = tm.first;
        ll now = num;
        res.push_back(now);
        rep1(i,cnt){
            now *= num;
            res.push_back(now);
        }
    }
    sort(all(res));
    //debug(res);
    ll ans = 0;
    int m = res.size();
    //out(m);
    for(int i=0;i<m;i++){
        if(n % res[i] == 0){
            ans++;
            n /= res[i];
        }
    }
    out(ans);
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);
const std::string yes = "Yes";
const std::string no  = "No";

int main(){
    std::string s;
    std::cin >> s;
    int k;
    std::cin >> k;
    for(int i=0; i<s.size(); i++){
        if(i>k-1){break;}
        else if(s[i]!='1'){std::cout << s[i] << "\n"; return 0;}
    }
    std::cout << 1 << "\n";
    return 0;
}


Measured memory_bytes: 3548
mod=10**9+7
n=int(input())
A=list(map(int,input().split()))

B=sorted(A)
for i in range(1,n+1):
    if B[i]==B[i-1]:
        x=B[i]

r=A[::-1].index(x)
l=A.index(x)



s=n+1
INV=[None]*(s+1)#1/aのリストを予め作っておく.
for i in range(1,s+1):
    INV[i]=pow(i,mod-2,mod)

Combi=[None]*(s+1)#Combi[i]=nCi を表す
Combi[0]=1
for i in range(1,s+1):
    Combi[i]=Combi[i-1]*(s-i+1)*INV[i] %mod


m=r+l
INV2=[None]*(m+1)#1/aのリストを予め作っておく.
for i in range(1,m+1):
    INV2[i]=pow(i,mod-2,mod)

Combi2=[None]*(m+1)#Combi[i]=nCi を表す
Combi2[0]=1
for i in range(1,m+1):
    Combi2[i]=Combi2[i-1]*(m-i+1)*INV2[i] %mod











print(n)
for i in range(2,n+2):
    ANS=Combi[i]
    if m>=i-1:
        ANS-=Combi2[i-1]
    print(ANS%mod)
    


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

int main(){

	int money = 100000;
	int n;
	cin >> n;

	while (n--)
	{
		money *= 1.05;
		if (money % 1000 != 0)
		{
			money += 1000 - (money % 1000);
		}
	}
	cout << money << endl;

	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0);  
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define int long long
void test_case(){
	int x; cin>>x;
	if(x >= 30){
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
}
		
 
signed main(){
	IOS;
	int i = 1;
	int t=1; //cin>>t;
	while(t--){
		//cout<<"Case #"<<i<<": ";
		test_case();
		i++;
	}
}


Measured memory_bytes: 3620
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    vv<int> A = vvec(3, 3, 0);
    rep(i, 3) rep(j, 3) cin >> A[i][j];
    int N;
    cin >> N;
    rep(k, N) {
        int b;
        cin >> b;
        rep(i, 3) rep(j, 3) {
            if (A[i][j] == b) A[i][j] = 0;
        }
    }
    bool ans = false;
    rep(i, 3) {
        bool ok = true;
        rep(j, 3) if (A[i][j] != 0) ok = false;
        if (ok) ans = true;
    }
    rep(j, 3) {
        bool ok = true;
        rep(i, 3) if (A[i][j] != 0) ok = false;
        if (ok) ans = true;
    }
    {
        bool ok = true;
        rep(k, 3) if (A[k][k] != 0) ok = false;
        if (ok) ans = true;
    }
    {
        bool ok = true;
        rep(k, 3) if (A[k][2 - k] != 0) ok = false;
        if (ok) ans = true;
    }
    write(ans ? "Yes" : "No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define INF 100000000000000000000;
#define sf(a) scanf("%d",&a)
using namespace std;
int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
typedef pair<int,int> pii;
vector<pii> vii;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n=0,x,a[2010],copi[2010],an,ans=INF;
    cin >> n >> x;
    rep(i,0,n){
        cin >> a[i];
    }
    rep(j,0,n){
        copi[j]=a[j];
    }
    rep(i,0,n){
        rep(j,0,n){
            if(copi[(j+i)%n]>a[j])copi[(j+i)%n]=a[j];
        }
        an=0;
        rep(j,0,n){
            an+=copi[j];
        }
        if(ans>(an+i*x))ans=an+i*x;
    }
    cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<unordered_set>
#include<bitset>

using namespace std;

int main(){
  for(int W,H;cin>>W>>H,W|H;){
    int P[12][12]={};
    bitset<100> is;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin>>P[i][j];
	is[i*10+j]=P[i][j];
      }
    }
    bitset<100>b[100];
    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++){
	b[i*10+j].set();
	int k;
	for(k=0;k+i<=10&&k+j<=10;k++){
	  for(int l=0;l<k;l++){
	    for(int m=0;m<k;m++){
	      if(!P[i+l][j+m]){
		goto end;
	      }
	    }
	  }
	}
      end:
	for(int n=0;n<k-1;n++){
	  for(int o=0;o<k-1;o++){
	    b[i*10+j][(i+n)*10+j+o]=false;
	  }
	}
      }
    }
    unordered_set<bitset<100> > s[123][123];
    s[0][0].insert(is);
    for(int i=0;;i++){
      for(int j=0;j<=100;j++){
	for(auto e:s[i][j]){
	  if(e.none()){
	    cout<<i<<endl;
	    goto next;
	  }
	  if(j<100){
	    s[i+1][j+1].insert(e&b[j]);
	    if(e[j]==false){
	      s[i][j+1].insert(e);
	    }
	  }
	}
      }
    }
  next:
    ;
  }
}

Measured memory_bytes: 5176
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	//FastScannerクラス、普通の Scannerクラスだとメモリと時間を大幅に喰らうので高速化する内部クラス。
	
	public static void main(String[]args) {
		FastScanner sc = new FastScanner(System.in);
		
		int N = Integer.valueOf(sc.next());
		int M = Integer.valueOf(sc.next());
		int []a = new int[M];
		int []b = new int[M];
		int []co = new int[N];
		for(int i = 0;i<M;i++) {
			a[i] = Integer.valueOf(sc.next());
			b[i] = Integer.valueOf(sc.next());
			if(a[i]==1) co[b[i]-1]++;
			if(b[i]==N) co[a[i]-1]++;
		}
		
		for(int i = 1;i<N-1;i++) {
			if(co[i]==2) {
				System.out.println("POSSIBLE");
				System.exit(0);
			}
		}
		
		System.out.println("IMPOSSIBLE");
		
		
	}
	
	static class FastScanner {
		 
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
 
		public FastScanner(InputStream source) {
			in = source;
		}
 
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
 
		private int readByte() {
			if (hasNextByte()) return buffer[ptr++];
			else return -1;
		}
 
		private static boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}
 
		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
		}
 
		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}
 
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
 
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
		

}


Measured memory_bytes: 55624
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    init();

    string s, t; cin >> s >> t;
    int l = -1, r = -1;
    rep(i, 0, s.size()) {
        string a = s.substr(i, t.size());
        if (a.size() != t.size())continue;
        bool ok = true;
        rep(j, 0, t.size()) {
            if (a[j] != '?') {
                if (a[j] != t[j])ok = false;
            }
        }
        if (ok) {
            l = i;
            r = i + t.size() - 1;
        }
    }
    if (l == -1 && r == -1)cout << "UNRESTORABLE" << "\n";
    else {
        rep(i, l, r + 1) {
            s[i] = t[i - l];
        }
        rep(i, 0, s.size()) {
            if (s[i] == '?')cout << 'a';
            else cout << s[i];
        }
        cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    int a;cin>>a;
    string s; cin >> s;
    if (a>=3200) cout << s << endl;
    else cout << "red" << endl;
    
}

Measured memory_bytes: 256
n=int(input())
s="1"+input()
a=[]
for i in range(n):
  if s[i]!=s[i+1]:a+=[1]
  else:a[-1]+=1
x=3*a[0]
for i in range(1,len(a)):
  if a[i-1]==a[i]==1:x*=2
  elif a[i-1]==a[i]==2:x*=3
  elif a[i]==1:x*=1
  else:x*=2
  x%=10**9+7
print(x)

Measured memory_bytes: 3064
import java.util.Scanner;

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

		int n = sc.nextInt();
		int[]a = new int[n];

		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt();
		}
		for(int i = n-1; i >=0; i--){
			System.out.print(a[i]);
			if(i != 0)System.out.print(" ");
			else System.out.println();
		}
	}
}


Measured memory_bytes: 26328
// Longest Path in a Directed Acyclic Graph (DAG)
#include <bits/stdc++.h>
#define ll long long
#define MXN 100001
using namespace std;
// dp[i] = longest path of the graph starting from node i
int dp[MXN];
bool vis[MXN];
vector<int> adj[MXN];

void dfs(int u) {
	vis[u] = true;
	for(int v : adj[u]) {
		if (!vis[v]) {
			dfs(v);
		}
		dp[u] = max(dp[u], 1+dp[v]);
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, m, u, v;
	cin >> n >> m;
	memset(dp, 0, sizeof(dp));
	memset(vis, 0, sizeof(vis));
	for(int i = 0; i < m; i++) {
		cin >> u >> v;
		adj[u].push_back(v);
	}
	for(int i = 1; i <= n; i++) {
		if(!vis[i])
			dfs(i);
	}

	int ans = 0;
	for(int i = 1; i <= n; i++)
		ans = max(ans, dp[i]);

	cout << ans << "\n";
}

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

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

  if (x < 600){
    cout << 8 << endl;
  } else if (x < 800){
    cout << 7 << endl;
  } else if (x < 1000){
    cout << 6 << endl;
  } else if (x < 1200){
    cout << 5 << endl;
  } else if (x < 1400){
    cout << 4 << endl;
  } else if (x < 1600){
    cout << 3 << endl;
  } else if (x < 1800){
    cout << 2 << endl;
  } else if (x < 2000){
    cout << 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3632
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
ll N=1000000000000000000;
void solve()
{
fastio
ll n;
cin>>n;
ll a[n];
ll ans=1;
bool flag1=0,flag=1;
for(auto &x:a)
{
cin>>x;
if(!x)
flag1=1;
}
for(ll i=0;i<n-1;i++)
{
	ans*=a[i];
	if((N/ans)<a[i+1])
	{
		flag=0;
		break; ;
	}
}
if(flag1)
	cout<<0;
else
{
	if(flag)
		cout<<ans*a[n-1];
	else
		cout<<-1;
}
}
int main()
{
//code
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


Measured memory_bytes: 4432
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fr ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include<string>
#include<algorithm>
#include<vector>
const long long int maxn = 1e3+2;
const long long int mod = 1e3+2;

int main()
{
	fr
	ll n, k;	cin>>n>>k;
	ll a[n+2], dp[n+2];
	for(ll i=1;i<=n;i++)
		cin>>a[i], dp[i] = INT_MAX;
	if(k>=n)
	{
		cout<<abs(a[1]-a[n])<<endl;	return 0;
	}
	dp[n] = 0;
	dp[n-1] = abs(a[n-1]-a[n]);
	
	for(ll i=(n-2);i>=(n-k);i--)
	{
		dp[i] = abs(a[i]-a[n]);
		for(ll j=i;j<=n;j++)
		{
			dp[i] = min(dp[i], abs(a[i]-a[j])+dp[j] );
		}
	}
	
//	for(ll i=1;i<=n;i++)	cout<<dp[i]<<" ";	cout<<endl;
	
	for(ll i=(n-k-1);i>=1;i--)
	{
		for(ll j=i+1;j<=(i+k);j++)
		{
			dp[i] = min(dp[i], abs(a[i]-a[j])+dp[j] );	
		}		
	}
	
//	for(ll i=1;i<=n;i++)	cout<<dp[i]<<" ";	cout<<endl;
	cout<<dp[1]<<endl;
	return 0;
	
}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func sum(n []int) int {
	a := 0
	for _, v := range n {
		a += v
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	a := getInt()
	sc.Scan()
	s := sc.Text()
	if a >= 3200 {
		fmt.Println(s)
	} else {
		fmt.Println("red")
	}

}


Measured memory_bytes: 640
N=io.read("n")
x={}
u={}
local total=0
for i=1,N do
  x[i]=io.read("n")
  u[i]=string.match(io.read(),"%a+")
  if u[i]=="BTC" then
    x[i]=380000*x[i]
  end
  total=total+x[i]
end
print(total)


Measured memory_bytes: 1008