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


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        System.out.println(dfs(n, 0));
    }
    static int dfs(long n, long s) {
        if (s > n) {
            return 0;
        } else {
            int count = 0;
            String ss = String.valueOf(s);
            if (ss.contains("3") && ss.contains("5") && ss.contains("7")) {
                count++;
            }
            count += dfs(n, s * 10 + 3) + dfs(n, s * 10 + 5) + dfs(n, s * 10 + 7);
            return count;
        }
    }
}

Measured memory_bytes: 24276
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long K;
  cin >> K;
  if (K % 2 == 0 || K % 5 == 0) {
    cout << -1 << endl;
  } else {
    int ans;
    long long sum = 0;
    for (ans = 1; ans <= K; ans++) {
      sum = (sum * 10 + 7) % K;
      if (sum == 0) break;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    string s;
    cin >> s;
    int n = s.size();

    int b = 1;
    for (int i = 0; i < n; i++) {
        int j = n - 2 - i;
        if (i >= j) break;
        if (s[i] != s[j]) {
            b = 0;
            break;
        }
    }
    if (s[0] == '0' || s.back() != '0') b = 0;

    if (!b) {
        cout << -1 << endl;
        exit(0);
    }

    int p = 0;
    for (int i = 1; i < n; i++) {
        cout << p + 1 << ' ' << i + 1 << '\n';
        if (s[i - 1] != '0') p = i;
    }

    return 0;
}

Measured memory_bytes: 1616
#include <iostream>
#include <stdio.h>
#include <vector>

#define rep(i,n) for(int i = 0; i < n; i++)

typedef long long ll;

using namespace std;

const int INF = 1e9;
const int MOD = 1e9+7;
const double PI=3.14159265358979323846;

int main(){
  int N;
  cin >> N;
  vector<int> vi(N);
  rep(i,N) cin >> vi[i];

  bool ok = true;
  rep(i,N){
    if(vi[i]%2==0){
       if(vi[i]%3==0 || vi[i]%5==0) continue;
       else{
	 ok = false;
	 break;
       }
    }
  }
  if(ok) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}


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

/**
|||||||||||||       |||||     |||||    ||||||||||
||||||||||||||      |||||     |||||  |||||
|||||     |||||     |||||     |||||  |||||
||||||||||||||||    |||||||||||||||    ||||||||||
|||||||||||||||||   |||||||||||||||           |||||
|||||        |||||  |||||     |||||           |||||
|||||         ||||| |||||     |||||    ||||||||||
AHMED;HASSAN;SAEED;
*/

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    bool no=0;
    for(int i=0;i<s.length();i++){
        if(i%2 && s[i]=='R'){
            cout<<"No"<<endl;
            no=1;
            break;
        }
        else if(!(i%2) && s[i]=='L'){
            cout<<"No"<<endl;
            no=1;
            break;
        }
    }
    if(!no)
        cout << "Yes" << endl;
    return 0;
}


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

using namespace std;

const double pi=3.14159265358979323846;

struct punct
{
    long long x,y;
};

punct v[400010],v1[400010];
long long arb[1000010];

int cmp1(punct a,punct b)
{
    return a.y>b.y;
}

int cmp2(punct a,punct b)
{
    return a.y<b.y;
}

int cmp3(punct a,punct b)
{
    return a.x<b.x;
}

void arbint_update(int nod,int st,int dr,int poz,long long val)
{
    if(st==dr) arb[nod]=val;
    else
    {
        int mid=(st+dr)/2;
        if(poz<=mid) arbint_update(nod*2,st,mid,poz,val);
        else arbint_update(nod*2+1,mid+1,dr,poz,val);
        arb[nod]=max(arb[nod*2],arb[nod*2+1]);
    }
}

long long arbint_query(int nod,int st,int dr,int left,int right)
{
    if(left<=st && dr<=right) return arb[nod];
    int mid=(st+dr)/2;
    long long s=0;
    if(left<=mid) s=max(s,arbint_query(nod*2,st,mid,left,right));
    if(mid<right) s=max(s,arbint_query(nod*2+1,mid+1,dr,left,right));
    return s;
}

int main()
{
    //freopen("file.in","r",stdin);
    //freopen("file.out","w",stdout);
    long long x1,y1,x2,y2,n,x,y;
    scanf("%lld%lld%lld%lld",&x1,&y1,&x2,&y2);
    if(x1>x2) {swap(x1,x2);swap(y1,y2);}
    scanf("%lld",&n);
    double sol=1.0*1LL*abs(x2-x1)*100+1.0*1LL*abs(y2-y1)*100;
    int l=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld%lld",&x,&y);
        if(x>=x1 && x<=x2 && y>=min(y1,y2) && y<=max(y1,y2)) v[++l]={x,y};
    }
    if(y1==y2)
    {
        if(l>0) sol=sol-20+5.0*pi*2;
        printf("%.20f",sol);
        return 0;
    }
    if(x1==x2)
    {
        if(l>0) sol=sol-20+5.0*pi*2;
        printf("%.20f",sol);
        return 0;
    }
    if(y1>y2) sort(v+1,v+l+1,cmp1);
    else sort(v+1,v+l+1,cmp2);
    for(int i=1;i<=l;i++) v1[i]=v[i];
    sort(v1+1,v1+l+1,cmp3);
    for(int i=1;i<=l;i++)
        v1[i].y=i;
    long long c=0;
    for(int i=1;i<=l;i++)
    {
        int st=1,dr=l;
        while(st<=dr)
        {
            int mid=(st+dr)/2;
            if(v1[mid].x<v[i].x) st=mid+1;
            else dr=mid-1;
        }
        long long val=arbint_query(1,1,n,1,v1[st].y)+1;
        c=max(c,val);
        arbint_update(1,1,n,v1[st].y,val);
    }
    if(c==min(abs(x2-x1),abs(y2-y1))+1) sol=sol+5.0*pi;
    sol=sol-1.0*1LL*20*c+1.0*1LL*5.0*pi*c;
    printf("%.20f",sol);
    return 0;
}


Measured memory_bytes: 18560
#include <iostream>
#define llint long long

using namespace std;

llint A, B;

int main(void)
{
	cin >> A >> B;
	
	if(A == B){
		cout << 1 << endl;
		return 0;
	}
	
	llint h;
	for(llint i = 60; i >= 0; i--){
		if( (A&(1LL<<i)) && (B&(1LL<<i)) ){
			A -= (1LL<<i);
			B -= (1LL<<i);
		}
		else if( (A&(1LL<<i)) || (B&(1LL<<i)) ){
			h = i;
			break;
		}
	}
	B -= (1LL<<h);
	
	llint h2 = -1;
	for(llint i = 60; i >= 0; i--){
		if(B&(1LL<<i)){
			h2 = i;
			break;
		}
	}
	llint ub = (1LL<<(h2+1))-1;
	
	llint ans = (1LL<<(h+1))-1 - A + 1;
	llint gap = max(0LL, (A - ub - 1));
	ans -= gap;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)

using namespace std;


int main() {
  int a,b;
  cin >> a >> b;
  if(a==1 and b ==1) cout << "Draw" << endl;
  else if(b==1) cout << "Bob" << endl;
  else if (a==1) cout << "Alice" << endl;
  else if(a<b) cout << "Bob" << endl;
  else if (b<a) cout << "Alice" << endl;
  else cout << "Draw" << endl;

  return 0;
}


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

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    bool can = false;
    for(int i = 1; i <= B; i++){
        int res = (A * i) % B;
        if(res == C) can = true;
    }
    cout << (can == true ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s.size()<3)cout<<"WA"<<endl;
	else{
		if(s[0]=='A'){
			int cnt=0;
			for(int i=2;i+1<s.size();i++){
				if(s[i]=='C'){cnt++;continue;}
				if(s[i]<'a'||s[i]>'z'){
					cout<<"WA"<<endl;
					return 0;
				}
			}
			if(s[1]<'a'||s[1]>'z'||s[s.size()-1]<'a'||s[s.size()-1]>'z'||cnt!=1)cout<<"WA"<<endl;
			else cout<<"AC"<<endl;
		}
		else cout<<"WA"<<endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main(){
    int n;
    while(cin >> n && n!=0){
        int s[n];
        F(i,0,n) cin >>s[i];
        double m=0;
        F(i,0,n) m+=s[i];
        m=m/n;
        double a=0;
        F(i,0,n) a+=(s[i]-m)*(s[i]-m)/n;
        a=sqrt(a);
        printf("%.10f\n",a);
    }
    return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define fort(i,n) for (int i = 1; i <= n; i++)
#define ll long long
#define sz size()
#define er erase
#define fr first
#define sc second
using namespace std;

ll n,a[100005],b[100005],ans;

int32_t main()
{
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    fort(i,n)
        cin >> a[i];
    if (n==2)
    {
        cout << abs(a[1]-a[2]);
        return 0;
    }
    sort(a+1,a+n+1);
    reverse (a+1,a+n+1);
    ll k=n/2+1, t=n, u=2, x=a[1]-a[n];
    b[k]=a[1];
    fort(i,n-1)
    {
        if (i%4==1) k-=i, b[k]=a[t], --t;
        else if (i%4==2) k+=i, b[k]=a[t], --t;
        else if (i%4==3) k-=i, b[k]=a[u], ++u;
        else k+=i, b[k]=a[u], ++u;
    }
    b[n+1]=b[1];
    fort(i,n)
        ans+=abs(b[i]-b[i+1]), x=min(x,abs(b[i]-b[i+1]));
    cout << ans-x;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

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


void solve(long long N, std::vector<long long> A){
  vector<ll> B = A;
  set<ll> e;
  ll ans = 0;
  sort(B.begin(), B.end());
  for(int i=0; i<N; i++) {
    if(i%2==0) e.insert(A[i]);
  }
  for(int i=0; i<N; i++) {
    if(i%2==0 and e.find(B[i])==e.end()) ans++;
  }
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, std::move(A));
  return 0;
}



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

typedef long long ll;
#define fore(i,ii,iii) for(ll i=ii;i<iii;i++)
#define mset(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define sz(a) (int)a.size()

const ll N=1e4+15,MOD=1e9+7;
string k;
ll d,n,dp[N][128][2],a[N];

ll solve(int p,int m,bool b) {
	if(p==n)return !m;
	if(dp[p][m][b]!=-1)return dp[p][m][b];\
	ll res=0;
	fore(i,0,a[p])res=(res+solve(p+1,(m+i)%d,1))%MOD;
	if(b) {
		fore(i,a[p],10)res=(res+solve(p+1,(m+i)%d,1))%MOD;
	} else {
		res=(res+solve(p+1,(m+a[p])%d,0))%MOD;
	}
	//cout<<p<<" "<<m<<" "<<b<<" : "<<res<<endl;
	return dp[p][m][b]=res;
}


int main() {
  ios::sync_with_stdio(false);
	mset(dp,-1);
	cin>>k>>d;n=k.length();
	fore(i,0,n)a[i]=k[i]-'0';
	cout<<(solve(0,0,0)+MOD-1)%MOD<<endl;
}

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

using namespace std;

#define int long long
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define Endl '\n'
#define cont continue
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define pb push_back
#define mp make_pair
#define mem(x) memset(x, 0, sizeof(x))

const ll inf=1e18;
const int mod=1e9+7;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
const int mxn = 2e5+10;

//ll fact[mxn];
//ll in_fact[mxn];
//fact[0] = 1;
//for(ll i = 1; i < mxn; i++) {
	//fact[i] = (i*fact[i-1])%mod;
//}
//in_fact[mxn-1] = bigmod(fact[mxn-1],mod-2);
//for(ll i = mxn-2; i >= 0; i--) {
	//in_fact[i] = (in_fact[i+1] * (i+1))%mod;
//}
//ll c(ll n,ll r) {
	//ll ans = (fact[n] * (in_fact[r] * in_fact[n-r]%mod))%mod;
	//return ans;
//}
int c = 0;
vector<int>adj[mxn];
int vis[mxn] = {0};
int dfs(int n) {
	vis[n] = 1;
	c++;
	for(int x:adj[n]) {
		if(!vis[x]) dfs(x);
	}
	return c;
}

signed main(){
    fast;
	//freopen ("input.txt", "r", stdin);
	//freopen ("output.txt", "w", stdout);
    int tt = 1;
    //cin>>tt;
    for(int tc = 1; tc <= tt; tc++) {
        int n,m,ans = 0;
        cin>>n>>m;
        for(int i = 0; i < m; i++) {
			int u,v;
			cin>>u>>v;
			adj[u].pb(v);
			adj[v].pb(u);
		}
		for(int i = 1; i <= n; i++) {
			if(!vis[i]) {
				c = 0;
				ans = max(ans,dfs(i));
			}
		}
		cout<<ans<<endl; 
			
        
        
    }



return 0;
}


Measured memory_bytes: 22400
#include<bits/stdc++.h>
#define pb push_back
#define ef(i,u) for(int i=b[u];i;i=nxt[i])
#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 gcd(a,b) __gcd(a,b)
#define MEM(a,x) memset(a,x,sizeof(a))
#define VI vector<int>
#define PII pair<int,int>
#define ull unsigned long long
#define ll long long
#define fi first
#define se second
#define INF 0x3f3f3f3f
using namespace std;
const int N=2e5+5;
template<class T>inline void read(T &res)
{
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
int n,m,x;
struct node{
    int price;
    int a[15];
}f[15];
int ans=INF,ck[15];
void dfs(int tot,int now){
    int ok=0;
    rep(i,1,m){
        if(ck[i]<x)ok=1;
    }
    if(!ok)ans=min(ans,tot);
    if(now>n)return;
    dfs(tot,now+1);
    rep(i,1,m)ck[i]+=f[now].a[i];
    dfs(tot+f[now].price,now+1);
    rep(i,1,m)ck[i]-=f[now].a[i];
}
int main(){
    cin>>n>>m>>x;
    rep(i,1,n){
        read(f[i].price);
        rep(j,1,m){
            read(f[i].a[j]);
        }
    }
    dfs(0,1);
    if(ans==INF)cout<<-1<<'\n';
    else cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
#define read(num) scanf("%d", &num)
#define readll(num) scanf("%lld", &num)
#define read2(num1, num2) scanf("%d%d", &num1, &num2)
#define read3(num1, num2, num3) scanf("%d%d%d", &num1, &num2, &num3)
#define reads(str) scanf("%s", str)
#define readc(ch) scanf("%c", &ch)
#define f first
#define se second
#define M 1000000007
#define pb push_back
#define mp make_pair
#define pii pair<long long, long long>
#define vi vector<int>
#define ll long long


int main(){
 
 string s,t;
 cin>>s>>t;
 for(int i=0;i<s.size();i++){
	 if(s[i]!=t[i]){
		 cout<<"No";
		 return 0;
	 }
 }
 cout<<"Yes";
} 


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

#define pb push_back
#define mp make_pair
#define ft first
#define sc second
#define ull unsigned long long int
#define lli long long int
#define li long int

#define si(n) scanf("%d",&n)
#define sl(n) scanf("%ld",&n)
#define sll(n) scanf("%lld",&n)

#define pi(n) printf("%d",n)
#define pl(n) printf("%ld",n)
#define pll(n) printf("%lld",n)

using namespace std;

const int MAX=1e5+5;

int Get(int a, int b) {

    int cnt1 = 0, cnt2 = 0;
    while(a) {
        cnt1 += (a%10);
        a = (int)(a/10);
    }

    while(b) {
        cnt2 += (b%10);
        b = (int)(b/10);
    }

    return cnt1 + cnt2;
}

int main() {
    // freopen("a.in","r",stdin);
    // freopen("a.out","w",stdout);

    int N;
    cin>>N;
    int mn = 100000;
    for(int i=1; i<=(N>>1)+1; i++) {
        mn = min(mn, Get(i,N-i));
    }

    cout << mn << "\n";


    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(true){
			int n = scan.nextInt();
			if(n == 0){
				break;
			}
			int[][] a = new int[n][2];
			int[] b = new int[2];
			b[0] = 0;
			b[1] = 0;
			for(int j = 0;j < n;j++){
				for(int k = 0;k < 2;k++){
					a[j][k] = scan.nextInt();
				}
			}
			for(int j = 0;j < n;j++){
				if(a[j][0] == a[j][1]){
					b[0] += a[j][0];
					b[1] += a[j][1];
				}else if(a[j][0] > a[j][1]){
					b[0] += a[j][0] + a[j][1];
				}else{
					b[1] += a[j][0] + a[j][1];
				}
			}
			System.out.println(b[0] + " " + b[1]);
		}	
	}
}

Measured memory_bytes: 13000
#include<iostream>
using namespace std;
int main(void){
    long int max=-1000000,min=10000000,sum=0,n,tmp;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>tmp;
        if(max<tmp)max=tmp;
        if(min>tmp)min=tmp;
        sum+=tmp;
    }
    cout<<min<<" "<<max<<" "<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3100
package main

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

func main() {
	io, flush := NewIO()
	defer flush()
	k, n := io.ScanInt(), io.ScanInt()
	a := io.ScanInts(n)
	var max int
	for i := 1; i < n; i++ {
		var length int
		if i == n-1 {
			length = k - a[i] + a[0]
		} else {
			length = a[i+1] - a[i]
		}
		if length > max  {
			max = length
		}
	}
	var sum int
	for i := 0; i < n; i++ {
		if i == n-1 {
			sum += k - a[i] + a[0]
			continue
		}
		sum += a[i+1] - a[i]
	}
	fmt.Println(sum-max)
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


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

using namespace std;
int main()
{
  int n,k;
  cin >> n >> k;
  vector<int> prices(n);
  for(int i=0; i<n; i++){
    cin >> prices[i];
  }
  
  sort(prices.begin(), prices.end());
  int sum = 0;
  for(int i=0; i<k; i++){
    sum += prices[i];
  }
  
  cout << sum << endl;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    int Gu = a * b % 2;
    if (Gu == 0) {
    cout << "Even" << endl;
    }
    else {
    cout << "Odd" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main () {
    int n;
    int a1[] = {2, 4, 5, 7, 9};
    int a2[] = {0, 1, 6, 8};

    scanf("%d", &n);
    n %= 10;

    for (int i=0; i < 5; i++) {
        if (n == a1[i]) {
            printf("hon\n");
            return 0;
        }
    }
    for (int i=0; i < 4; i++) {
        if (n == a2[i]) {
            printf("pon\n");
            return 0;
        }
        
    }
    printf ("bon\n");
    return 0;
}


Measured memory_bytes: 1664
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        _n: usize,
        k: usize,
        s: chars
    }
    let mut s = s;
    let c = s[k-1];
    s[k-1] = c.to_lowercase().next().unwrap();
    for c in s {
        print!("{}", c);
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y = sc.nextLong();
		long a = x;
		int length = 0;
		while(true) {
			if(a <= y) {
				a = a * 2;
				length++;
			}else {
				System.out.println(length);
				return;
			}
		}
	}
}

Measured memory_bytes: 23124
n = int(input())
li = list(map(int, input().split()))

ans_list = []
a = 0
b = 0
for c, l in enumerate(li):
  if l <= a:
    b += 1
    if c == n - 1:
      ans_list.append(b)
  else:
    if c != 0:
      ans_list.append(b)
    b = 0
  a = l

if len(ans_list) != 0:
  ans = max(ans_list)
else:
  ans = 0
print(ans)

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

int main(){
  int h1, h2, k1, k2, a, b, c, d, H, K;

  cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
  H = h1*a + (h1/10)*c + h2*b + (h2/20)*d;
  K = k1*a + (k1/10)*c + k2*b + (k2/20)*d;

  if ( H > K ) cout << "hiroshi" << endl;
  else if ( H < K ) cout << "kenjiro" << endl;
  else cout << "even" << endl;

  return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);

typedef complex<double> Comp;

bool is_pow_of2(int n) {
	int a = 1;
	while (n >= a) {
		if (n == a) {
			return true;
		}
		a <<= 1;
	}
	return false;
}


void fft(vector<Comp>& v) {
	int n = v.size();
	assert(is_pow_of2(n));

	for (int j = 1, i = 0; j < n - 1; j++) {
		for (int k = n >> 1; k >(i ^= k); k >>= 1);
		if (j < i) swap(v[i], v[j]);
	}

	for (int m = 2; m <= n; m <<= 1) {
		double deg = (-1) * 2 * PI / m;
		Comp r(cos(deg), sin(deg));
		for (int i = 0; i < n; i += m) {
			Comp w(1, 0);
			for (int j = i, k = i + m / 2; k < i + m; j++, k++) {
				Comp t1 = v[j], t2 = w*v[k];
				v[j] = t1 + t2, v[k] = t1 - t2;
				w *= r;
			}
		}
	}
}

void ifft(vector<Comp>& v) {
	int n = v.size();
	assert(is_pow_of2(n));
	for (int j = 1, i = 0; j < n - 1; j++) {
		for (int k = n >> 1; k >(i ^= k); k >>= 1);
		if (j < i) swap(v[i], v[j]);
	}
	for (int m = 2; m <= n; m <<= 1) {
		double deg = 2 * PI / m;
		Comp r(cos(deg), sin(deg));
		for (int i = 0; i < n; i += m) {
			Comp w(1, 0);
			for (int j = i, k = i + m / 2; k < i + m; j++, k++) {
				Comp t1 = v[j], t2 = w*v[k];
				v[j] = t1 + t2, v[k] = t1 - t2;
				w *= r;
			}
		}
	}
	for (int i = 0; i < n; ++i) v[i] *= 1.0 / n;
}

vector<Comp> convolution(vector<Comp> P, vector<Comp> Q) {
	fft(P); fft(Q);
	for (size_t i = 0; i < P.size(); i++) P[i] *= Q[i];
	ifft(P);
	return P;
}
int main()
{
	int N;
	long long zero = 0, kosu = 0;
	vector<long long> res((1 << 22) + 1);
	vector<Comp> mat1(1 << 22), mat2(1 << 22);
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> mat1[i * 2048 + j];
			mat2[(1023 - i) * 2048 + 1023 - j] = mat1[i * 2048 + j];
			if(mat1[i * 2048 + j].real() != 0) zero += mat1[i * 2048 + j].real() * (mat1[i * 2048 + j].real() - 1) / 2;
		}
	}
	long double sum = 0.0;
	auto conv = convolution(mat1, mat2);
	for (int i = 0; i < 2048; i++) {
		for (int j = 0; j < 2048; j++) {
			int h = abs(1023 - i), w = abs(1023 - j), val = (w == 0 && h == 0) ? zero * 2 : round(conv[i * 2048 + j].real());
			res[w * w + h * h] += val;
			sum += sqrtl(w * w + h * h) * val;
			kosu += val;
		}
	}
	cout << fixed << setprecision(10) << (kosu ? (sum / kosu) : 0) << endl;
	int cnt = 0;
	for (int i = 0; i <= (1 << 22); i++) {
		if (res[i]) {
			cout << i << ' ' << res[i] / 2 << endl;
			cnt++;
			if (cnt >= 10000) {
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 297856
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

vector<int> cross_product(vector<int>a,vector<int>b) {
    return {a[1]*b[2]-a[2]*b[1],a[2]*b[0]-a[0]*b[2],a[0]*b[1]-a[1]*b[0]};
}
double dot_product(vector<int>a,vector<int>b) {
    return a[0]*b[0]+a[1]*b[1]+a[2]*b[2];
}
double len(vector<int>a) {
    return sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);
}
double dist_line_point(vector<int>a,vector<int>b,vector<int>c) {
    vector<int> ab={b[0]-a[0],b[1]-a[1],b[2]-a[2]};
    vector<int> ac={c[0]-a[0],c[1]-a[1],c[2]-a[2]};
    vector<int> ba={a[0]-b[0],a[1]-b[1],a[2]-b[2]};
    vector<int> bc={c[0]-b[0],c[1]-b[1],c[2]-b[2]};
    if(dot_product(ab,ac)<0) return INF;
    if(dot_product(ba,bc)<0) return INF;
    return len(cross_product(ab,ac))/len(ab);
}
struct obstacle {
    vector<int> p;
    int r;
    int l;
    obstacle():p(3){}
};
const double EPS=1e-8;
signed main() {
    int N,Q;
    cin>>N>>Q;
    vector<obstacle> obs(N);
    REP(i,N) {
        cin>>obs[i].p[0]>>obs[i].p[1]>>obs[i].p[2]>>obs[i].r>>obs[i].l;
    }
    while(Q--) {
        vector<int> a(3),b(3);
        cin>>a[0]>>a[1]>>a[2]>>b[0]>>b[1]>>b[2];
        int ans=0;
        REP(i,N) {
            double d=dist_line_point(a,b,obs[i].p);
            if(d<obs[i].r || abs(obs[i].r-d)<EPS) {
                ans+=obs[i].l;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3224
<?php
  $s = str_split(trim(fgets(STDIN)));
  $t = str_split(trim(fgets(STDIN)));

  $n = count($s);
  $flag = true;
  for ($i=0; $i<$n; $i++) {
    if ($s[$i] != $t[$n-$i-1]) {
      $flag = false;
    }
  }
  
  if ($flag) {
    echo "YES\n";
  } else {
    echo "NO\n";
  }
?>

Measured memory_bytes: 4604
#include <iostream>
    #include <vector>
     
    using namespace std;
     
    int main() {
    int n,t,e;
    cin >> n >> t >> e;
    vector<int> c(n);
    for (int i=0; i<n; i++) {
    cin >> c[i];
    }
    for (int i=0; i<n; i++) {
    int a = t / c[i];
    if (a*c[i] >= t-e || (a+1)*c[i] <= t+e) {
    cout << i+1 << endl;
    return 0;
    }
    }
    cout << "-1" << endl;
    return 0;
    }

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

struct space {          
    int count;       
    int score;              
};

int main()
{
  	int n;
	cin >> n;
  	vector<int> data(n);
  	for(int i=0; i<n; ++i) {
      	cin >> data[i];
    }
  
  	sort(data.begin(),data.end(),greater<int>());
  	long total = 0;
  	space sp;
  	sp.count = 1;
  	sp.score = data[0];
                    
    queue<space> que;
  
  	space nowSpace = sp;
    
  	for(int i=1; i<n; ++i){
      	if (nowSpace.count <= 0) {
          	nowSpace = que.front();
          	que.pop();
        }
      	--nowSpace.count;
      	total += nowSpace.score;
      	space newSpace;
      	newSpace.count = 2;
      	newSpace.score = data[i];
      	que.push(newSpace);
    }
  
  	cout << total;
           
    return 0;
}

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

#define print cout <<
#define printl(s) cout << s << endl;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;

const ll modseed = pow(10,9) + 7;

template <typename T>
vector<T> getValues(int num){
    vector<T> values(num);
    for(int i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

ll calculateMod(ll n, ll expo, ll modSeed){
  ll ret = 1;
  rep(i, expo){
    ret *= n;
    ret = ret%modSeed;
  }
  return ret;
}

int main(){
    ll N;
    cin >> N;
    ll ans = calculateMod(10,N, modseed);
    ans -= calculateMod(9, N, modseed)*2;
    ans += calculateMod(8,N,modseed);
    ans %= modseed;
    ans=(ans+modseed)%modseed;
    printl(ans);
}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  vector<int> a(3);
  for(int i=0;i<3;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  if((a[2]-a[1])%2==0&&(a[2]-a[0])%2==0){
    cout << (2*a[2]-a[1]-a[0])/2 << endl;
  }
  else if((a[2]-a[1])%2==1&&(a[2]-a[0])%2==1){
    cout << (2*a[2]-a[1]-a[0])/2 << endl;
  }
  else
    cout << (2*a[2]-a[0]-a[1]+1)/2+1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int N; cin>>N;
  vector<ll> A(N), D(N,0);
  ll sum = 0;
  REP(i,N) {
    cin>>A[i];
    sum	+= A[i];
  }
  D[0] = sum;
  for(int i = 1; i < N; i+=2) {
    D[0] -= 2LL * A[i];
  }
  for(int i = 1; i < N;	i++) {
    D[i] = A[i-1]*2LL -	D[i-1];
  }
  pp(D, D.size());
  return 0;
}


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

using namespace std;

#define endl "\n"
#define lln long long int
#define IOS ios::sync_with_stdio(0);cin.tie(0);

int main(){
	IOS;

	int n;
	cin >> n;
	int c = 0,fl=0;
	for(int i=0;i<n;i++){
		int x,y;
		cin >> x >> y;
		if(x == y) c++;
		else{
			c = 0;
		}
		if(c == 3) fl = 1;
	}
	if(fl) cout <<  "Yes\n";
	else cout << "No\n";
	return 0;    
}

Measured memory_bytes: 3652
number = input()
list1 = list(map(int, input().split()))
han = 0
count = 0
for i in range(0, len(list1)):
    if list1[i]%2 == 0:
        count += 1
        if list1[i]%3 == 0 or list1[i]%5 == 0:
            han += 1
if han == count:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int > pp;
typedef long long ll;
 
int const N=1e5+2,oo=1e9;
ll const OO=2e18;
double const eps=1e-8,PI=acos(-1);
int mod=oo+7;

int aa[4]={0,1,2,3};
int can[4][4];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    a--,b--;
    can[a][b]=1;
    can[b][a]=1;    
    cin>>a>>b;
    a--,b--;
    can[a][b]=1;
    can[b][a]=1;        
    cin>>a>>b;
    a--,b--;
    can[a][b]=1;
    can[b][a]=1;
    do{
        if(can[aa[0]][aa[1]]&&can[aa[1]][aa[2]]&&can[aa[2]][aa[3]]){
            cout<<  "YES";
            return 0;
        }
    }while(next_permutation(aa,aa+4));
    cout<<"NO";
    return 0;
}



Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    int n = sc.nextInt();
    String a = sc.nextStr();
    String b = sc.nextStr();
    String c = sc.nextStr();
 
    int ans = 0;
    for(int i = 0; i < n; i++){
      char ach = a.charAt(i);
      char bch = b.charAt(i);
      char cch = c.charAt(i);
    
      if(ach == bch && bch == cch){
        continue;
      }else if(ach == bch || bch == cch || cch == ach){
        ans++;
      }else{
        ans += 2;
      }

    }

    System.out.println(ans);
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

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

int main(){
    long long k, a, b, i, res;
    cin >> k >> a >> b;
    if(k > a-1){
        k -= a-1;
        res = a;
    }else{
        k = 0;
        res = k;
    }
    if(k > 0){
        if(b - a > 2){
            res += (b-a)*(k/2);
            res += k%2;
        }else{
            res += k;
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
//go:generate echo "https://atcoder.jp/contests/dp/tasks/dp_a"
package main

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

type scanner struct{ *bufio.Scanner }

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *scanner) IntSlice(l int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := range sl {
		sl[i] = s.Int()
	}
	return sl
}

func iabs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func solve(n int, heights []int) int {
	t := make([]int, n+1, n+1)
	for i := range t {
		t[i] = math.MaxInt64
	}

	t[0] = 0
	for i := 1; i < n; i++ {
		if v := t[i-1] + iabs(heights[i]-heights[i-1]); v < t[i] {
			t[i] = v
		}
		if 1 < i {
			if v := t[i-2] + iabs(heights[i]-heights[i-2]); v < t[i] {
				t[i] = v
			}
		}
	}

	return t[n-1]
}

func main() {
	sc := newScanner(os.Stdin)
	n := sc.Int()
	heights := sc.IntSlice(n)
	ans := solve(n, heights)
	fmt.Println(ans)
}


Measured memory_bytes: 3816
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

ll buy(ll* money, ll rate){
    ll kabu = (*money) / rate;
    (*money) -= rate * kabu;
    return kabu;
}
ll sold(ll *kabu, ll rate){
    ll money = (*kabu) * rate;
    (*kabu) = 0;
    return money;
}

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    ll kabu = 0;
    ll money = 1000;
    ll max_money = 1000;

    for(int i = 0; i < N-1;){
        if(a[i] < a[i+1]){
            kabu += buy(&money, a[i]);
            while(a[i] < a[i+1] && i < N-1) i++;
            money += sold(&kabu, a[i]);
            max_money = max(max_money, money);
        }
        if(a[i] == a[i+1]) i++;
        if(a[i] > a[i+1]){
            money += sold(&kabu, a[i]);
            max_money = max(max_money, money);
            while(a[i] > a[i+1] && i < N-1) i++;
            kabu += buy(&money, a[i]);
        }
    }
    cout << max_money << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>



#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;

int n,a,b;
int main(){
  cin >> n >> a >> b;
  int ans=0;
  for (int i = 1; i <= n; i++) {
    int c=0;
    int t=i;
    for (int j = 0; j < 5; j++){
      c += t % 10;
      t /= 10;
    }
    if (a<=c&&c<=b) ans += i;
  }
  cout << ans << endl;
  return 0;
}


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

public class Main {

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

	    long L=gl();
	    long R=gl();
	    
        if (R-L > 2019) {
	        System.out.println(0);
	        return;
        }
        
        long min=2018;
        for (long i=L; i<=R; i++) {
        	for (long j=i+1; j<=R; j++) {
        		long a=(i*j)%2019;
        		if (a<min) {
        			min=a;
        		}
        	}
        }
        
        System.out.println(min);

	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
}

Measured memory_bytes: 35656
from math import sqrt
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
    
A, B = map(int, input().split())

g = gcd(A, B)
n = int(sqrt(g))+1
ans = 1
for p in range(2,n+1):
    if g%p==0:
        ans += 1
        while g%p==0:
            g = g//p
if g!=1:
    ans += 1

print(ans)

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i,s.length()) {
    if (s[i] != t[i]) ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

//山の整数がk、残っている石の数がaのときのgrundy数
int grundy(int a, int k){
    int x = a%k, y = a/k;
    if(x == 0) return y;
    return grundy(a-(y+1)*((x+y)/(y+1)), k);
}

int main(){
    int N;
    cin >> N;
    int A, K, ans = 0;
    rep(i, N){
        cin >> A >> K;
        ans ^= grundy(A, K);
    }
    if(ans) cout << "Takahashi" << endl;
    else cout << "Aoki" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int dd,mm,yy;
    scanf("%d/%d/%d",&yy,&mm,&dd);
    if(dd<=30 && mm<=04 && yy<=2019)
    {
        printf("Heisei\n");
    }
    else
    {
        printf("TBD\n");
    }
    return 0;
}

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

long long f(int n){
  return (pow(n,2)-n)/2;
}
int main(){
  int N,i,n=1;
  long long ans=0;
  vector<string>A;
  string s;
  
  cin >> N;
  for(i=0;i<N;i++){
    cin >> s;
    sort(s.begin(),s.end());
    A.push_back(s);
  }
  
  sort(A.begin(),A.end());
  A.push_back("");
  
/*  for(i=0;i<N;i++){
    cout << A[i];
  }*/
  
  for(i=0;i<N;i++){
    if (A[i]==A[i+1])n+=1;
    else{
      ans+=f(n);
      n=1;
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5748
import Control.Monad
import Data.List(sort)

read_ :: String -> Int
read_ = read


main = do
 str <- getLine
 let n = read_ str
 when (n>0) $ do
  arr <- sequence $ replicate n getLine
  let a = tail . init . sort . map read $ arr
  print $ sum a `div` length a
  main

Measured memory_bytes: 4128
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#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)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	string aiueo = "aiueo";
	char c;
	cin >> c;
	if (aiueo.find(c) != string::npos)
		cout << "vowel" << endl;
	else
		cout << "consonant" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <cstring>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;

struct StVal {
	ll v = 0; StVal() {}
	StVal(const ll _v) : v(_v) {}
	StVal(const StVal &v1, const StVal &v2) { v = max(v1, v2); }
	operator ll() const { return v; }	
};

struct SegTree {
	int n;
	vector<int> leaves;
	vector<StVal> st;	

	SegTree(const int n) : n(n) {
		leaves.resize(n);
		init(1, 0, n - 1);
	}

	//lo, hi indices of the actual array; si is the index of the segment tree array
	void init(const int si, const int lo, const int hi) {
		if (lo == hi) {
			if (si >= (int)st.size()) { st.resize(si + 1); }
			st[si] = StVal();			//Set the actual array here
			leaves[lo] = si;
			return;
		}
		int lC = si << 1, rC = (si << 1) | 1, mid = (lo + hi) >> 1;
		init(lC, lo, mid); init(rC, mid + 1, hi);
		st[si] = StVal(st[lC], st[rC]);
	}

	//l and r inclusive, 0-indexed
	StVal query(const int l, const int r) { return (l <= r && l < n && r >= 0) ? query(l, r, 1, 0, n - 1) : StVal(); }
	StVal query(const int l, const int r, const int si, const int lo, const int hi) {
		if (l <= lo && hi <= r) return st[si];

		const int mid = (lo + hi) >> 1;
		if (r <= mid) return query(l, r, si << 1, lo, mid);
		if (mid < l) return query(l, r, si << 1 | 1, mid + 1, hi);
		return StVal(query(l, r, si << 1, lo, mid), query(l, r, si << 1 | 1, mid + 1, hi));
	}

	//Change a leaf and update its ancestors' values
	void update(const int i, ll c) {
		int si = leaves[i];
		st[si] = StVal(c);
		for (si >>= 1; si; si >>= 1)
			st[si] = StVal(st[si << 1], st[si << 1 | 1]);
	}
};

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

	int n; cin >> n;
	vector<ll> h(n), a(n);
	for (auto &x : h) { cin >> x; }
	for (auto &x : a) { cin >> x; }

	SegTree st(n + 1);

	//dp[i] = max sum of weights for a sequence that ends at height i
	vector<ll> dp(n + 1, 0);
	for (int i = 0; i < n; i++) {
		ll maxW = st.query(0, h[i]);
		dp[h[i]] = maxW + a[i];
		st.update(h[i], dp[h[i]]);
	}

	cout << *max_element(dp.begin(), dp.end()) << '\n';
}

Measured memory_bytes: 12752
#include <bits/stdc++.h>
using namespace std; 
const int dx[]={1,0,-1,0,1,-1,-1,1}; 
const int dy[]={0,1,0,-1,1,1,-1,-1}; 
const int INF = 1e9; 
const long long LINF = 1e18; 
const double EPS = 1e-8; 
#define pb push_back
#define mk make_pair 
#define fr first 
#define sc second 
#define ll long long 
#define reps(i,j,k) for(int i = (j); i < (k); ++i) 
#define rep(i,j) reps(i,0,j) 
#define all(a) (a).begin(),(a).end() 
#define MOD 1000000007 
typedef pair<int,int> Pii;
typedef pair<Pii,int> P;
typedef vector<ll> vi;
int main(){
	int n;
	cin >> n;
	vi v(n);
	rep(i,n) cin >> v[i];
	int cnt = 1;
	ll sign = 0;
	reps(i,1,n){
		if(sign * (v[i] - v[i-1]) < 0) {
			cnt ++;
			sign = 0;
		}
		else if(v[i] - v[i-1] != 0) sign = v[i] - v[i-1];
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 1024