akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] times = new int[5];
        for (int i = 0; i < 5; i += 1) {
            times[i] = sc.nextInt();
        }

        Integer[] indices = new Integer[5];
        for (int i = 0; i < 5; i += 1) {
            indices[i] = i;
        }
        List<List<Integer>> permutations = permute(indices);

        int minTime = Integer.MAX_VALUE;
        for (List<Integer> perm : permutations) {
            int time = 0;
            for (int index : perm) {
                if (time % 10 != 0) {
                    time += 10 - (time % 10);
                }
                time += times[index];
            }
            if (minTime > time) {
                minTime = time;
            }
        }

        System.out.println(minTime);
    }

    private static <T> List<List<T>> permute(T[] items) {
        List<List<T>> perms = new LinkedList<>();
        permuteHelper(perms, items, 0);
        return perms;
    }

    private static <T> void permuteHelper(List<List<T>> perms, T[] items, int n) {
        if (n == items.length - 1) {
            List<T> perm = new LinkedList<>();
            for (T item : items) {
                perm.add(item);
            }
            perms.add(perm);
        } else {
            for (int m = n; m < items.length; m += 1) {
                swap(items, n, m);
                permuteHelper(perms, items, n + 1);
                swap(items, n, m);
            }
        }
    }

    private static <T> void swap(T[] items, int index1, int index2) {
        T tmp = items[index1];
        items[index1] = items[index2];
        items[index2] = tmp;
    }

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i=0;i<N;i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n;
vector<PLL> v;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n;
    ll in,in2;
    rep(i,n){
        cin>>in>>in2;
        v.pb(mp(in2,in));
    }
    sort(all(v));
    ll tmp = 0;
    bool flg = true;
    rep(i,v.size()){
        tmp += v[i].second;
        if(tmp>v[i].first){
            flg = false;
            break;
        }
    }
    Yes(flg);
    return 0;
}

Measured memory_bytes: 6512
n, m = map(int, input().split())
a = [0] * 100100
dp = [1, 1]
x = 0
for i in range(m):
    a[i] = int(input())
if a[0] == 1:
    dp[1] = 0
    x = 1

for i in range(len(a)-1):
    if a[i+1] - a[i] == 1:
        print(0)
        exit(0)


for i in range(2, n+1):
    if i != a[x]:
        dp.append((dp[-1] + dp[-2]) % 1000000007)
    else:
        dp.append(0)
        if x < len(a)-1:
            x += 1
# print(dp)
print(dp[-1])


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

int N;
string word;
bool type[100005];

int main() {
	cin >> N;
	cin >> word;
	bool one[4] = { true, true, false, false };
	bool two[4] = { true, false, true, false };
	for (int i = 0; i < 4; ++i) {
		type[0] = one[i];
		type[1] = two[i];
		for (int j = 2; j < N; ++j) {
			type[j] = type[j - 1] ^ (word[j - 1] == 'o') ^ type[j - 2];
		}

		if (type[N - 1] ^ (word[N - 1] != 'o')) {
			if (type[N - 2] != type[0])
				continue;
		} else {
			if (type[N - 2] == type[0])
				continue;
		}
		if (type[0] ^ (word[0] != 'o')) {
			if (type[N - 1] != type[1])
				continue;
		} else {
			if (type[N - 1] == type[1])
				continue;
		}

		for (int j = 0; j < N; ++j) {
			if (type[j])
				cout << 'S';
			else
				cout << 'W';
		}
		return 0;
	}
	cout << -1 << endl;
}

Measured memory_bytes: 640
N, W = map(int, input().split())
w = [0]*N
v = [0]*N
for i in range(N):
    w[i], v[i] = map(int, input().split())

V = sum(v)
dp = [[10**100]* (V + 1) for _ in range(N+1)]

dp[0][0] = 0
for i in range(N):
    for j in range(V+1):
        dp[i+1][j] = dp[i][j]
        if j-v[i] >= 0:
            dp[i+1][j] = min(dp[i+1][j], dp[i][j-v[i]] + w[i])
        

ans = 0
for j in range(V + 1):
    if dp[N][j] <= W:
        ans = j

print(ans)

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



int main(void){
  int N,M;
  cin>>N>>M;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int sum=0;
  for(int i=0;i<N;i++){
    sum+=A[i];
  }
  int count=0;
  for(int i=0;i<N;i++){
    if(A[i]*4*M>=sum) count++;
  }
  if(count>=M) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}


int main(){
  ll n,m,sum=0;
  cin >> n >> m;
  vector<ll> a(n);
  FOR(i,0,n)cin>>a[i];
  FOR(i,0,n)sum+=a[i];
  SORT(a);
  REV(a);
  FOR(i,0,m){
    if(a[i]*4*m<sum){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,k,ans,del,num;
inline ll read(){
	ll cnt=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-f;c=getchar();}
	while(isdigit(c)){cnt=(cnt<<1)+(cnt<<3)+(c^48);c=getchar();}
	return cnt*f;
}
int main(){
//	freopen("replace.in","r",stdin);
//	freopen("replace.out","w",stdout);
	n=read(),k=read();
	ll ans1=n%k;
	ll ans2=abs(ans1-k);
	cout<<min(ans1,ans2)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#include <map>
#include <string>
#define maxn 100005
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,m;
int dfn[maxn],low[maxn],ind;
vector <int> adj[maxn];
vector <P> ans;
void tarjan(int u,int f){
  dfn[u] = low[u] = ++ind;
  for(int i=0;i<adj[u].size();i++){
    int v = adj[u][i];
      if(dfn[v] == 0){
        tarjan(v,u);
        low[u] = min(low[u],low[v]);
      }else if(v != f){
        low[u] = min(low[u],dfn[v]);
      }
  }
  if(dfn[u] == low[u]){
  	if(u >= f) swap(u,f);
  	if(u != -1) ans.push_back(mp(u,f));
  }
}
int main(){
  scanf("%d%d",&n,&m);
  for(int i=1;i<=m;i++){
  	int u,v;
  	scanf("%d%d",&u,&v);
  	adj[u].push_back(v);
  	adj[v].push_back(u);
  }
  for(int i=0;i<n;i++){
  	if(dfn[i] == 0) tarjan(i,-1);
  }
  sort(ans.begin(),ans.end());
  for(int i=0;i<ans.size();i++){
  	printf("%d %d\n",ans[i].first,ans[i].second);
  }
  return 0;
}



Measured memory_bytes: 7064
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
signed main()
{
	fastio;
	int n,k;
	cin>>n>>k;
	int a[n+1]={0};
	int dp[n+1];
	memset(dp,MAX,sizeof(dp));
	dp[1]=0;
	forci(1,n+1)	cin>>a[i];
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			if(i-j<=0)
				break;
			dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
		}
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

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

		String str1 = s.next();
		String str2 = s.next();

		int min1 = Integer.MAX_VALUE;
		int max2 = Integer.MIN_VALUE;

		for (int i = 0; i < str1.length(); i++) {
			int strInt1 = (int) str1.charAt(i);
			min1 = Math.min(min1, strInt1);
		}

		for (int i = 0; i < str2.length(); i++) {
			int strInt2 = (int) str2.charAt(i);
			max2 = Math.max(max2, strInt2);
		}

		if ((min1 == max2)) {
			if (str1.replace((char) min1 + "", "").length() == 0 &&
			 	str2.replace((char) max2 + "", "").length() == 0 && 
			 	replace(str1, (char) min1) < replace(str2, (char) max2)) {

				System.out.println("Yes");
				return;
			} else {
				System.out.println("No");
				return;
			}
		}

		String ans = (min1 < max2) ? "Yes" : "No";
		System.out.println(ans);
	}

	static int replace(String str, char target) {
		return str.length() - str.replace(target + "", "").length();
	}
}

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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> works;
  for (int i = 0; i < N; ++i) {
    int A, B;
    cin >> A >> B;
    works.emplace_back(A, B);
  }
  sort(works.begin(), works.end(), [](auto&& lhs, auto&& rhs) {
      return lhs.second > rhs.second;
      });
  set<int> days;
  for (int i = 1; i <= M; ++i) {
    days.emplace(i);
  }
  uint64_t result = 0;
  for (auto it = works.cbegin(); it != works.cend(); ++it) {
    auto day = days.lower_bound(it->first);
    if (day != days.end()) {
      days.erase(day);
      result += it->second;
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 5748
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int K; cin>>K;
  int ans=0;
  REP(i,1,K){
    REP(j,1,K){
      REP(k,1,K) ans+=__gcd(i,__gcd(j,k));
    }
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n";
long long M = 1e9+7;
long long power(long long a, long long p)
{
    if(p==0) return 1;
    long long ans= power(a,p/2);
    ans =(ans * ans) % M;
    if(p%2) ans = (ans*a) % M;
    return ans;
}

bool isPrime(long long n)
{
    if (n <= 1)
        return false;
    for (long long i = 2; i < n; i++)
        if (n % i == 0)
            return false;
    return true;
}
long long SieveOfEratosthenes(long long n, long long a)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (long long p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (long long i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (long long p=2; p<=n; p++)
       if (prime[p])
       {
           if(a%p==0)
           {
               return (a-p);
           }
       }
}
long long nCr(int n, int r)
{
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;
    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }
    return ans;
}
//int vis[51][51];
//int x[]={1,0,0,-1};
//int y[]={0,1,-1,0};
/* void dfs_visit(long long n,long long a, long long b)
{
    vis[a][b]=1;
    for(int i=0; i<4; i++)
    {

        int p=a+x[i];
        int q=b+y[i];
        if(p>=0 && p<n && q>=0 && q<n && vis[p][q]==0)
        {
           // cout<<p<<" "<<q<<endl;
            vis[p][q]=1;
            dfs_visit(n,p,q);
        }
    }
}
*/
long long fun(long long a)
{
    long long co=1,res=0;
    while(a>0)
    {
        if(a%2==0)
        {
            res=co;
        }
        a/=2;
        co++;
    }
    return res;
}

int main()
{
    IOS;
    long long a,b,c,d,e,h,l,n,t,f,m,f1=0,flag=0,flag1=0,co=0,co1=0,co2=0,arr1[100001]={0},sum=0,sum1=0,ma=0,ma1=0,mi=1000000000000000001;
    long long g,co3=0,co4=0,co5=0,co6=0,co7=0,co8=0,mul=1,sum2=0,sum3=0,mu=1,mu1=1;
    long long a1,b1,a2,b2,a3,b3,a4,b4,a5,b5,b6;
    double pi=2 * acos (0.0);
    string str,str1,str2,str3,str4,str5,str6;
    char ch,ch1;
    //vector<long long>v; //vector<long long> v(n+1);
    //vector<long long>v1;
   // vector<string>vs;
   // vector<string>vs1;
    //map<long long,long long>mp;
    //set<long long>s;
    //stack<long long> stk;
    //vector< pair<long long,long long> >v3;
    //map<long long,long long>::iterator it;
    //map<string,string>::iterator it;
   // vector<pair<char, pair<int,int> > > v3;
    //vector< pair<char,int > > v1;
    //int x[]={1,1,1,0,0,-1,-1,-1};
    //int y[]={0,1,-1,1,-1,1,-1,0};
    //int x[]={1,0,0,-1};
    //int y[]={0,1,-1,0};
    cin>>str;
    cin>>str1;
    for(int i=0; i<str1.size()-1; i++)
        str2+=str1[i];
    if(str2==str)
    {
        cout<<"Yes"<<endl;
    }

    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3652
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
	static int mod=1000000007;
	static Scanner scan=new Scanner(System.in);
	static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
	static long lcm (long a, long b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
			}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	static long modpow(long a,long n) {
		if(n==0) return 1;
		else if(n==1)return a;
		long tmp=modpow(a,n/2);
		tmp%=mod;
		tmp*=tmp;
		tmp%=mod;
		if(n%2==0)return tmp;
		else return (tmp*a)%mod;
	}
	public static void main(String[] args) {
		List<Boolean>visited=new ArrayList<Boolean>();
		List<ArrayList<Integer>>node=new ArrayList<ArrayList<Integer>>();
		int a=scan.nextInt();
		int b=scan.nextInt();
		for(int i=0;i<a;i++) {
			visited.add(false);
			node.add(new ArrayList<Integer>());
		}
		for(int i=0;i<b;i++) {
			int c=scan.nextInt();
			int d=scan.nextInt();
			ArrayList<Integer> list=node.get(c-1);
			list.add(d);
			node.set(c-1, list);
		}
		ArrayList<Integer> list=node.get(0);
		for(int i=0;i<list.size();i++) {
			int x=list.get(i);
			for(int j=0;j<node.get(x-1).size();j++) {
				if(node.get(x-1).get(j)==a) {
					System.out.println("POSSIBLE");
					return;
				}
			}
		}
		System.out.println("IMPOSSIBLE");
	}
}

Measured memory_bytes: 120140
import math

PI = math.pi
A, B, H, M = map(int, input().split())

arg_a = (float(H) + float(M)/60) / 12.0 * 360
arg_b = float(M) / 60.0 * 360

#print("arg_a", arg_a)
#print("arg_b", arg_b)

C = math.sqrt(A*A + B*B - 2*A*B* math.cos(math.fabs(arg_a-arg_b)/360*2*PI))
print(C)

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

#define mod 1000000007
#define MAX_N 200010
long long inv[MAX_N];
long long factorial[MAX_N];
long long inv_factorial[MAX_N];

void GetInv(){
    for (int i = 1; i < MAX_N; i++) {
        if (i == 1) inv[i] = 1;
        else {
            inv[i] = (mod - (mod / i) * inv[mod % i]) % mod;
            if (inv[i] < 0) inv[i] += mod;
        }
    }
}
void GetFactorial(){
    factorial[0] = 1; inv_factorial[0] = 1;
    for (int i = 1; i < MAX_N; i++) {
        factorial[i] = factorial[i-1] * i;
        factorial[i] %= mod;
        inv_factorial[i] = inv_factorial[i-1] * inv[i];
        inv_factorial[i] %= mod;
    }
}

long long combination(int n, int r) {
    long long ret = factorial[n] * inv_factorial[r];
    ret %= mod;
    ret *= inv_factorial[n-r];
    return ret % mod;
}

long long modpow(int n, int r) {
    long long ret = 1; long long tmp = (long long) n;
    while (r != 0) {
        if (r % 2) ret *= tmp;
        tmp *= tmp; tmp %= mod; ret %= mod;
        r /= 2;
    }
    return ret;
}

int main(){
    GetInv(); GetFactorial();
    int n, a, b, c; cin >> n >> a >> b >> c;
    long long ans = 0;
    if (a == 0) swap(a, b);
    if (b == 0) {
        long long p = 100 * inv[a] % mod;
        cout << p * n % mod << endl;
    } else {
        long long p = a * inv[a+b] % mod;
        long long q = b * inv[a+b] % mod;
        long long u = 100 * inv[a+b] % mod;
        long long v = 100 * inv[a+b] % mod;
        vector<long long> fact_a(n+1, 1), fact_b(n+1, 1);
        for (int i = 0; i < n; i++) {
            fact_a[i+1] = fact_a[i] * p % mod;
            fact_b[i+1] = fact_b[i] * q % mod;
        }
        for (int i = 0; i < n; i++) {
            long long tmp = (u * n +  v * i) % mod * fact_a[n] % mod * fact_b[i] % mod;
            tmp = tmp * combination(n-1+i, i) % mod;
            ans = (ans + tmp) % mod;
        }
        for (int i = 0; i < n; i++) {
            long long tmp = (v * n + u * i) % mod * fact_b[n] % mod * fact_a[i] % mod;
            tmp = tmp * combination(n-1+i, i) % mod;
            ans = (ans + tmp) % mod;
        }
        cout << ans % mod << endl;
    }
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int int_vector_find(std::vector<int> vec, int num) {
	auto itr = std::find(vec.begin(), vec.end(), num);
	int index = std::distance(vec.begin(), itr);

	if (index != vec.size()) {
		return 1;
	}
	else {
		return 0;
	}
}

int main() {
	int n;
	int k;
	int ans = 1;
	std::cin >> n >> k;

	std::vector<int> vec;
	for (int i = 0; i < n; ++i) {
		int temp;
		std::cin >> temp;
		vec.push_back(temp);
	}

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

	int h = vec.size()-k;


	while (h > 0) {
		h -= k-1;
		ans++;
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 892
import java.io.*;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        InputReader.OutputWriter out = new InputReader.OutputWriter(outputStream);

        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();

        int max = Math.max(Math.max(a,b),c);
        int min = Math.min(Math.min(a,b),c);
        int med = a + b + c - max - min;
        int res = max*10+med + min;
        out.println(res);
        out.flush();

    }
}
class Envelope {
    private int width;
    private int height;

    public int getHeight() {
        return height;
    }

    public int getWidth() {
        return width;
    }

    public Envelope(int width,int height) {
        this.width = width;
        this.height = height;
    }

    @Override
    public String toString() {
        return width + " " + height;
    }
}

class InputReader extends BufferedReader {
    StringTokenizer tokenizer;

    public InputReader(InputStream inputStream) {
        super(new InputStreamReader(inputStream), 32768);
    }

    public InputReader(String filename) {
        super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return tokenizer.nextToken();
    }

    public Integer nextInt() {
        return Integer.valueOf(next());
    }
    public Long nextLong() {return  Long.valueOf(next());}

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream outputStream) {
            super(outputStream);
        }

        public OutputWriter(Writer writer) {
            super(writer);
        }

        public OutputWriter(String filename) throws FileNotFoundException {
            super(filename);
        }

        public void close() {
            super.close();
        }
    }
}

Measured memory_bytes: 21332
#include <iostream>
#include<bits/stdc++.h>
#define  ll long long
 using namespace std;
ll aa[30],bb[30];
ll dd[100003][30];
ll cc[30];
int main()
{
  string s,s1;
  cin>>s>>s1;
  ll a=s.size();
  ll b=s1.size();
  for(ll i=0;i<a;i++)
  {
      aa[s[i]-'a']++;
  }
  for(ll j=0;j<b;j++)
    bb[s1[j]-'a']++;
  for(ll i=0;i<26;i++)
  if(bb[i]&&!aa[i]){
    cout<<-1<<endl;
    return 0;
  }
  for(ll i=a-1;i>=0;i--)
  {
      cc[s[i]-'a']=i;
      for(ll j=0;j<26;j++)
      dd[i][j]=dd[i+1][j];
      dd[i][s[i+1]-'a']=i+1;
  } ll z=cc[s1[0]-'a'];
  ll sum=z+1;//cout<<a<<endl;
  for(ll i=0;i<b-1;i++)
  {
    if(!dd[z][s1[i+1]-'a'])sum+=(a-z-1)+cc[s1[i+1]-'a']+1,z=cc[s1[i+1]-'a'];
    else sum+=(dd[z][s1[i+1]-'a']-z),z=dd[z][s1[i+1]-'a'];
 //  cout<<sum<<endl;
  }cout<<sum<<endl;
}

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

#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
typedef pair<ll,ll> pll;

const double PI = 2*acos(0.0);
double a, b, h, m;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b >> h >> m;
    double teta = (h-m/5)*30 + m/2;
    if (teta > 180)
        teta = 360 - teta;
    teta = teta/180 * PI;
    double c = a*a + b*b - 2*a*b*cos(teta);
    cout << fixed << showpoint;
    cout << setprecision(20);
    cout << sqrt(c) << '\n';
    return 0;
}

Measured memory_bytes: 4176
import System.IO (isEOF)

main = input >>= return . solve >>= output
    
input :: IO [(Int,Int,Int)]
input = do
    quit <- isEOF
    if quit then return [] else do
        line <- getLine
        let
            [a,b,c] = map read $ split ',' line
        fmap ((a,b,c):) input
    where
    split ch s = case break (== ch) s of
        (w,"") -> [w]
        (w,_:s') -> w : split ch s'

output :: (Int,Int) -> IO ()
output (a,b) = do
    print a
    print b

solve :: [(Int,Int,Int)] -> (Int,Int)
solve ps = (length $ filter isRectangle ps, length $ filter isLozenge ps)
    where
    isRectangle (a,b,d) = a^2 + b^2 == d^2
    isLozenge (a,b,_) = a == b

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

int main() {
    ll x;
    cin >> x;
    const ll n = 1000;
    vector<ll> convert(2 * n + 1);
    for (ll num = -n; num <= n; num++) {
        convert[n + num] = num * num * num * num * num;
    }
    // for (int i = 0; i <= 2 * n; i++) {
    //     cout << i << " " << convert[i] << endl;
    // }
    for (ll i = -n; i <= n; i++) {
        for (ll j = -n; j <= n; j++) {
            if (convert[n + i] - convert[n + j] == x) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3656
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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

int n;
int T[1010], A[1010];

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

  cin >> n;
  REP(i, n) cin >> T[i] >> A[i];

  ll t=1, a=1;
  REP(i, n){
    ll v = max(a/A[i] + (a%A[i]? 1 : 0), t/T[i] + (t%T[i]? 1 : 0));    
    t = v * T[i];
    a = v * A[i];    
  }  
  cout << t+a << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int H,W;
int A[10][10];
int main(){
	cin>>H;
	cin>>W;
	REP(i,H){
	    string s;
	    cin>>s;
	    REP(j,W){
	        if(s[j]=='.'){
	           A[i][j]=0;
	        }else{
	           A[i][j]=1;
	        }
	    }
	}
	int x=0;
	int y=0;
	A[0][0]=0;
	while(1){
	   if(x+1<H){
	      if(A[x+1][y]==1){
	         A[x+1][y]=0;
	         x++;
	         continue;
	      }
	   }
	   if(y+1<W){
	      if(A[x][y+1]==1){
	         A[x][y+1]=0;
	         y++;
	         continue;
	      }
	   }
	   break;
	}
	bool check=false;
	if(x==H-1&&(y==W-1)){
	   bool c=true;
	   REP(i,H){
	       REP(j,W){
	           if(A[i][j]==1)c=false;
	       }
	   }
	   check=c;
	}
	if(check){
	   cout<<"Possible"<<endl;
	}else{
           cout<<"Impossible"<<endl;
        }
	return(0);
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(a)-1;i>=n;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define sn st.nd 
ll dx[4]={0,-1,0,1};
ll dy[4]={1,0,-1,0};
/****************************/
string s;
ll n,m,k;
vi v[110];
vi uni(vi v)
{
	vi ans=v;
	sort(ans.begin(),ans.end());
	ans.erase(unique(ans.begin(),ans.end()),ans.end());
	return ans;
}
int quickpower(int m,int n)
{
    if(n==1) return m;
    int temp=quickpower(m,n/2);
    return (n%2==0 ? 1 : m)*temp*temp;
}
int main()
{
	ios::sync_with_stdio(0);
	cin>>n>>k;
	rep(i,k)
	{
		int a;
		cin>>a;
		rep(j,a)
		{
			int b;
			cin>>b;
			v[b].pb(a);
		}
	}
	int ans=0;
	rep3(i,1,n+1)
	{
		if(v[i].size()==0)
		{
			ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3720
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<iostream>
#include<queue>
typedef long long  i64;
using namespace std;
int n;
int m;
int a[2000];
int b[2000];
i64 c[2000];
struct Edge {
	int src, dst;
	i64 cost;
public:
	Edge(int src, int dst, i64 cost) {
		this->src = src;
		this->dst = dst;
		this->cost = cost;
	}
};
struct State {
	int cur;
	i64 cost;
public:State(int cur, i64 cost) {
	this->cur = cur;
	this->cost = cost;
}
};
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i) {
		scanf("%d%d%lld", a + i, b + i, c + i);
		--a[i];
		--b[i];
		c[i] *= -1;
	}

	bool valid[1000];
	valid[n - 1] = true;
	for (int t = 0; t < n; ++t) {
		for (int i = 0; i < m; ++i) {
			valid[a[i]] |= valid[b[i]];
		}
	}

	i64 d[1000];
	for (int i = 0; i < n; ++i) {
		d[i] = 1LL << 60;
	}
	d[0] = 0;

	for (int t = 0; t <= n; ++t) {
		bool update = false;
		for (int i = 0; i < m; ++i) {
			if (valid[a[i]] && valid[b[i]]) {
				if (d[b[i]] > d[a[i]] + c[i]) {
					update = true;
					d[b[i]] = d[a[i]] + c[i];
				}
			}
		}
		if (t == n&&update) {
			cout << "inf" << endl;
			return 0;
		}
	}
	cout << -d[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int N,K;
  cin >> N >> K;
  
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  
  for(int i=K;i<N;i++){
    if(A[i-K] < A[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 4048
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		for(int i = 0; i < n; i++) {
			double x1 = stdIn.nextDouble();
			double y1 = stdIn.nextDouble();
			double x2 = stdIn.nextDouble();
			double y2 = stdIn.nextDouble();
			double x3 = stdIn.nextDouble();
			double y3 = stdIn.nextDouble();
			double x4 = stdIn.nextDouble();
			double y4 = stdIn.nextDouble();
			double cross = Math.abs((x2 - x1)*(y4 - y3) - (x4 - x3)*(y2 - y1));
			
			
			if(cross < 1e-10) {
				System.out.println("YES");
			}
			else {
				System.out.println("NO");
			}
			
		}
	}
}

Measured memory_bytes: 23272
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; }
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; }
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; }
ll pow(ll a, ll b, ll mod=INF){
    ll res=1;
    while(b>0){
        if(b&1) res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res;
}
ll getDigit(ll num){
    ll digit=0; 
    while(num!=0){num/=10;digit++;}
    return digit;
}
//-----------------------------------------
int main(void){
    ll N;cin>>N;
    bool P[1000001];
    REP(i,1000001)P[i]=true;P[0]=P[1]=false;
    FOR(i,2,1000001){
        if(P[i]==true){
            for(ll k=2;i*k<1000001;k++){
                P[i*k]=false;
            }
        }
    }

    //REP(i,1000)cout<<P[i]<<" ";

    ll cnt=0;
    REP(i,1000001){
        if(!P[i])continue;
        for(ll k=i;N>=k&&N%k==0;k*=i){
            //cout<<k<<"\n";
            N/=k;
            cnt++;
        }
    }
    if(N>=1000000)cnt++;
    cout<<cnt<<"\n";
}


Measured memory_bytes: 4608
fun color(rate: Int): Int {
    val c = rate / 400
    return Math.min(c, 8)
}

fun main(args: Array<String>) {
    readLine()
    val players = IntArray(9)
    readLine()!!.split(' ').forEach { rate ->
        val color = color(rate.toInt())
        players[color]++
    }
    var vmin = (0..7).filter { 0 < players[it] }.count()
    if (vmin == 0) {
        vmin = 1
        players[8]--
    }
    val vmax = vmin + players[8]
    println("$vmin $vmax")
}


Measured memory_bytes: 36424
import Control.Monad
import qualified Data.Set as S

data Status = Status {
  end :: Char,
  history :: S.Set String
} deriving Show

status :: String -> Status
status s = Status (last s) (S.singleton s)

game :: String -> Status -> Maybe Status
game "" _ = Nothing
game w (Status c h)
  | head w == c = if S.member w h
                  then Nothing
                  else Just $ Status (last w) (S.insert w h)
  | otherwise = Nothing

doGames :: [String] -> Maybe Status
doGames (s:ss) = foldr (\a b-> b >>= game a) (Just (status s)) $ reverse ss

main = do
  n <- read <$> getLine :: IO Int
  ws <- replicateM n getLine
  case doGames ws of
    Nothing -> putStrLn "No"
    otherwise -> putStrLn "Yes"


Measured memory_bytes: 636
import java.io.InputStream

private val input = FastScanner()

fun main(args: Array<String>) = input.run {
    val n = nextInt()
    val a = nextInts(n)
    var count0 = 0
    var count4 = 0
    a.forEach {
        if (it % 2 == 1) {
            count0++
        } else if (it % 4 == 0) {
            count4++
        }
    }
    if (count0 <= count4 || count0 - 1 == count4 && count0 + count4 == n) {
        println("Yes")
    } else {
        println("No")
    }
}

class FastScanner(private val input: InputStream = System.`in`) {
    private val sb = StringBuilder()
    private val buffer = ByteArray(4096)
    private var pos = 0
    private var size = 0

    fun nextLong(): Long {
        var c = skipWhitespace()

        val sign = if (c == '-'.toInt()) {
            c = read()
            -1
        } else 1

        var ans = 0L

        while (c > ' '.toInt()) {
            ans = ans * 10 + c - '0'.toInt()
            c = read()
        }

        return sign * ans
    }

    fun nextInt() = nextLong().toInt()

    fun nextInts(n: Int) = IntArray(n) { nextInt() }

    private fun skipWhitespace(): Int {
        while (true) {
            val c = read()
            if (c > ' '.toInt() || c < 0) return c
        }
    }

    private fun read(): Int {
        while (pos >= size) {
            if (size < 0) return -1
            size = input.read(buffer, 0, buffer.size)
            pos = 0
        }
        return buffer[pos++].toInt()
    }
}

Measured memory_bytes: 31392
(defconstant inf 1000000)
(defvar *n* (read))
(defvar *hi* (make-array *n*))
 
;dp[i]→i番目にたどり着くための最小コスト
(defvar *dp* (make-array *n* :initial-element inf))
 
(dotimes (i *n*)
         (setf (aref *hi* i) (read)))
 
(defun cost (now delta)
   (abs (- (aref *hi* now) (aref *hi* (- now delta)))))
 
;dpテーブル初期化
(setf (aref *dp* 0) 0)
(setf (aref *dp* 1) (cost 1 1))
 
(loop :for i :from 2 :upto (1- *n*) :do (if (< (aref *dp* i) inf) (aref *dp* i)
                                             (setf (aref *dp* i)
                                                   (min
                                                    (+ (aref *dp* (- i 1)) (cost i 1))
                                                    (+ (aref *dp* (- i 2)) (cost i 2)))
                                                   )))
 
 
                                         
 
(print (aref *dp* (1- *n*)))

Measured memory_bytes: 59752
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;


struct Edge{ //??°????????????
public:
    int src, dst;
    int weight;
    Edge(int a,int b):src(a),dst(b),weight(1){} //?????????????????????
    void setWeight(double x){
        weight = x;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<int> Array;
typedef vector<Array> Matrix;


//int main(){
//    
//    
//    
//    return 0;
//}


int main(){ //??°???????????£??\??????????????£??\?????????????????????????????°??????
    
    int n,k,v,w;
    
    cin >> n; //??°????????????????????\???
    
    Matrix M(n,Array(n,0)); //??£??\??????????????????
    
    for (int i=0; i<n; i++) { //??????????¬???°?????????????????\??? ???????????\??????????????£??\??????????????£??\?????????????´?
        cin >> w >> k;
        for (int j=0; j<k; j++) {
            cin >> v;
            M[w-1][v-1] = 1; //?????????
        }
    }
    
    for (int i=0; i<n; i++) { //????????¢?????§??????
        for (int j=0; j<n; j++) {
            cout << M[i][j];
            if (j!=n-1) {
                cout << " ";
            }
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1256
N = gets.to_i
h = []
h = gets.split.map(&:to_i)

ans = 0
cnt = 0
(N-1).times do |i|
  if h[i] >= h[i+1]
    cnt += 1
    ans = [ans,cnt].max
  else
    cnt = 0
  end
end
puts ans

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

int main() {

	int s;
	cin >> s;

	int a[100000];
	a[0] = s;

	for (int m = 1; m < 100000; m++) {
		if (a[m - 1] % 2 == 0) {
			a[m] = a[m - 1] / 2;
		}
		else {
			a[m] = 3 * a[m - 1] + 1;
		}
		for (int n = 0; n < m; n++) {
			if (a[m] == a[n]) {
				cout << m + 1 << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
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();
		}
		sc.close();
		int len = 1;
		int sum = 0;
		for(int i = 0;i < N-1;i++) {
			if(A[i]==A[i+1]) {
				len++;
			}else {
				sum += len/2;
				len=1;
			}
		}
		if(len > 1) {
			sum += len/2;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 22868
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
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; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
const int mod = 1000000007;
struct mint {
int64_t x;
mint(int64_t 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 { return mint(*this) += a;}
mint operator-(const mint a) const { return mint(*this) -= a;}
mint operator*(const mint a) const { return mint(*this) *= a;}
mint pow(int64_t t) const {if (!t) return 1;mint a = pow(t>>1);a *= a;if (t&1) a *= *this;return a;}
mint inv() const { return pow(mod-2);}
mint& operator/=(const mint a) { return *this *= a.inv();}
mint operator/(const mint a) {return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//numbers of odd is even num -> 0
ll odd(ll a){
    return (a+1)/2%2;
}

ll solve(ll num){
    // if num is even 
    if(num%2==1){
        return odd(num);
    }else{
        return odd(num+1)^(num+1);
    }
}

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

    ll a,b;
    cin>>a>>b;

     ll cnt = solve(a-1)^solve(b);

    cout<<cnt<<endl;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if (c-(a-b) >= 0) {
		System.out.println(c-(a-b));}
		else {
			System.out.println(0);
		}
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <numeric>
#include <regex>
#include <locale>
#include <fstream>
#include <stdlib.h>
#include <cctype>

//#include <map>

using namespace std;

int main()
{
	while(1)
	{
		int n;
		double m;
		vector<int> vs;
		double sigma;
		
		cin >> n;
		cin.ignore();
		if (n == 0)break;

		string temp;
		getline(cin, temp);
		string tmp;
		istringstream iss(temp);
		while (!iss.eof())
		{
			int t;
			iss >> t;
			vs.push_back(t);
			iss.ignore();
		}

		m = accumulate(vs.begin(), vs.end(), 0.0) / n;
		double ts = 0.0;
		for (int i = 0; i < n; i++)
		{
			ts += (pow(vs.at(i) - m, 2.0)) / n;
		}
		sigma = sqrt(ts);
		cout << fixed << setprecision(8) << sigma << endl;
	}
	return 0;
}

Measured memory_bytes: 3292
N,P=list(map(int, input().split()))
A=list(map(int, input().split()))

# たぶん普通にDP
# dp[i]:i番目(1-index)までの袋から偶奇が正しくなるように選ぶ場合の数

dp=[0]*(N+2)
dp[0]=(P+1)%2

for i in range(1,N+1):
    if A[i-1]%2==0:
        dp[i]=2*dp[i-1]
    else:
        dp[i]=(2**(i-1)-dp[i-1])+dp[i-1]
print(dp[N])

Measured memory_bytes: 62024
n=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))
a=sorted(a)
c=sorted(c)
ans=0
import bisect
for i in b:
  t=bisect.bisect_left(a, i)
  q=bisect.bisect_right(c, i)
  ans+=t*(n-q)
print(ans)


Measured memory_bytes: 29152
//Keep pluggin',this is your only outlet.
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cctype>
#define MM(x,y) memset(x,y,sizeof(x))
#define MCPY(a,b) memcpy(a,b,sizeof(b))
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define fi first
#define mp make_pair
#define se second
using namespace std;
//#define int long long

inline int quickpow(int m,int n,int p){int b=1;while(n){if(n&1)b=b*m%p;n=n>>1;m=m*m%p;}return b;}
inline int quickmul(int x,int y,int mod){return (x*y-(int)((long double)x/mod*y)*mod+mod)%mod;}
inline int getinv(int x,int p){return quickpow(x,p-2,p);}
inline int read(void){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){f=ch=='-'?-1:1;ch=getchar();}
    while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x * f;
}

char s[500010];
int a[500010],len;
///------------------hezd------------------
signed main(signed argc, char *argv[]){
    scanf("%s",s+1);
    len = strlen(s+1);
    rep(i,1,len) a[i] = (s[len-i+1] - '0') * 9;
    rep(i,1,len) {
        a[i+1] += a[i] / 10;
        a[i] %= 10;
    }
    while(a[len+1] > 0) ++len;
    int sum = 0;
    rep(i,1,len) sum += a[i];
    for (int i = 1; i <= 10 * len; ++i) {
        a[1] += 9; sum += 9;
        int p = 1;
        while(a[p] >= 10) {
            sum -= a[p+1]; a[p+1] += a[p] / 10; sum += a[p+1];
            sum -= a[p]; a[p] %= 10; sum += a[p];
            ++p; len = max(len,p);
        }
        if (i * 9 >= sum) {
            printf("%d\n",i);
            return 0;
        }
    }
    return 0;
}

/* Examples: */
/*

*/

/*

*/


Measured memory_bytes: 2816