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

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int stringAmount = Integer.parseInt(sc.next());
    int stringLength = Integer.parseInt(sc.next());
    String[] stringArray = new String[stringAmount];
    
    for(int i=0; i<stringAmount; i++){
      stringArray[i] = sc.next();
    }
    
    stringArray = merge(stringArray);
    
    StringBuilder builder = new StringBuilder();
    for(int i=0; i<stringAmount; i++){
      builder.append(stringArray[i]);
    }
    
    System.out.println(builder.toString());
  }
  
  private static String[] merge(String[] sArray){
    if(sArray.length == 1){
      return sArray;
    }else{
      String[] array1 = new String[sArray.length/2];
      String[] array2 = new String[sArray.length-sArray.length/2];
      for(int i=0; i<array1.length; i++){
        array1[i] = sArray[i];
      }
      for(int i=0; i<array2.length; i++){
        array2[i] = sArray[array1.length+i];
      }
      array1 = merge(array1);
      array2 = merge(array2);
      int i1 = 0;
      int i2 = 0;
      while(true){
        if(judge(array1[i1], array2[i2])){
          sArray[i1+i2] = array1[i1];
          i1++;
          if(i1 == array1.length){
            for(int j=0; j<sArray.length-i1-i2; j++){
              sArray[i1+i2+j] = array2[i2+j];
            }
            break;
          }
        }else{
          sArray[i1+i2] = array2[i2];
          i2++;
          if(i2 == array2.length){
            for(int j=0; j<sArray.length-i1-i2; j++){
              sArray[i1+i2+j] = array1[i1+j];
            }
            break;
          }
        }
      }
      return sArray;
    }
  }
  
  private static boolean judge(String s1, String s2){
    byte[] byte1 = s1.getBytes();
    byte[] byte2 = s2.getBytes();
    for(int i=0; i<byte1.length; i++){
      if((int)byte1[i] < (int)byte2[i]){
        return true;
      }else if((int)byte1[i] > (int)byte2[i]){
        return false;
      }
    }
    return true;
  }
}

Measured memory_bytes: 22524
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n, x;
    cin >> n >> x;
    ll l, res = 0, pos = 0;
    REP(i, n){
        cin >> l;
        if(pos <= x) res++;
        pos += l;
    }
    if(pos <= x) res++;
    cout << res << endl;
    return 0;
}

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

bool isPrime(int n) {
    if (n == 1) return false;
    if (n == 2) return true;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return true;
}
int main(void) {
    int n;cin>>n;
    int result = 0;
    for (int i = 1; i <= n; i++) {
        int j;cin>>j;
        if (isPrime(j)) result++;
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3004
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int a,b,c; cin>>a>>b>>c;
    cout<<min(b/a,c)<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        int first = 0;
        int second = 0;
        int third = 0;
        Scanner in = new Scanner(System.in);
        for (int i = 0; i < 10; i++) {
            int h = in.nextInt();
            if (h > first) {
                third = second;
                second = first;
                first = h;
            } else if (h > second) {
                third = second;
                second = h;
            } else if (h > third) {
                third = h;
            }
        }
        System.out.println(first);
        System.out.println(second);
        System.out.println(third);
    }
}

Measured memory_bytes: 17360
#include <stdio.h>
int main(void)
{
int a,b,i;
char op;


while(1){

scanf("%d", &a);
scanf("%s", &op);
scanf("%d", &b);

if(op == '+') {
 printf("%d\n", a+b);
}
 else if(op == '-') {
 printf("%d\n", a-b);
}
else if(op == '*') {
 printf("%d\n", a*b);
}
else if(op == '/') {
 printf("%d\n", a/b);
}
else break;
}

return 0;
}

Measured memory_bytes: 600
import sys

a, b, k = map(int, sys.stdin.readline().split())

def main():
    if a >= k:
        return a - k, b
    elif a + b >= k:
        return 0, a + b - k
    else:
        return 0, 0

if __name__ == '__main__':
    ans = main()
    print(*ans, sep=' ')

Measured memory_bytes: 3060
from time import time

start = time()
D = int(input())
C = [int(i) for i in input().split()]
scores = [[int(i) for i in input().split()] for j in range(D)]
t = []
for i in scores:
    t.append(i.index(max(i))+1)
DC = [0]*26

def calcScore(t):
    score = []
    S = 0
    last = [0]*26
    for d in range(1,D+1):
        S += scores[d-1][t[d-1]-1]
        last[t[d-1]-1] = d
        for i in range(26):
            S -= C[i] * (d - last[i])
            DC[i] += (d - last[i])
        score.append(S)
    return score[-1]

ts = calcScore(t)
i = 0
j = 1
while time() - start < 1.95:
    d,q = i, j
    temp = [t[i] if d-1 != i else q for i in range(D)]
    j += 1
    if calcScore(temp) > ts:
        t = temp
        i += 1
        j = 0

print("\n".join(map(str, t)))

Measured memory_bytes: 9528
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

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

  int N;cin>>N;
  vector<int>a(N);
  rep(i,0,N)cin>>a[i];

  vector<int>big,small;
  vector<pair<int,int>>ans;
  rep(i,0,N){
    if(a[i]>=0){
      big.push_back(i);

    }
    else{
      small.push_back(i);
    }
  }

  auto b=max_element(all(a)),s=min_element(all(a));

  if(abs(*b)>abs(*s)){
    int index=distance(a.begin(),b);
    rep(i,0,N){
      ans.push_back(make_pair(index,i));
    }
    rep(i,1,N){
      ans.push_back(make_pair(i-1,i));
    }
  }

  else{
    int index=distance(a.begin(),s);
    rep(i,0,N){
      ans.push_back(make_pair(index,i));
    }
    rrep(i,1,N){
      ans.push_back(make_pair(i,i-1));
    }
  }

  cout<<ans.size()<<endl;
  rep(i,0,ans.size()){
    cout<<ans[i].first+1<<" "<<ans[i].second+1<<endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int dp[2][111][555];
struct st{
  int f,dist,time,pos;
  st(){}
  st(int f,int dist,int time,int pos):f(f),dist(dist),time(time),pos(pos){}
  bool operator<(const st& a) const{
    return dist>a.dist;
  }
};
signed main(){
  int n,m;
  cin>>n>>m;
  int x[m],y[m],t[m];
  for(int i=0;i<m;i++) cin>>x[i]>>y[i]>>t[i];
  int v,a,b,c;
  cin>>v>>a>>b>>c;
  
  //memset(dp,-1,sizeof(dp));
  int INF=1LL<<60LL;
  for(int i=0;i<c;i++)
    for(int j=0;j<n;j++)
      dp[0][i][j]=dp[1][i][j]=INF;

  int e[n][n];
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      e[i][j]=INF;
  for(int i=0;i<m;i++)
    e[x[i]-1][y[i]-1]=e[y[i]-1][x[i]-1]=t[i];

  vector<int> ve;
  map<int,int> mv;
  ve.push_back(v);
  int w=0;
  while(!mv.count(ve[w])){
    mv[ve[w]]=w;
    ve.push_back((a*ve[w]+b)%c);
    w++;
  }
  
  int r=w-mv[ve[w]];
  

  priority_queue<st> q;
  q.push(st(0,0,0,0));
  dp[0][0][0]=0;
  while(!q.empty()){
    st p=q.top();q.pop();
    int f=p.f,d=p.dist,t=p.time,u=p.pos;
    assert(0<=t&&t<c);
    assert(d>=0);
    //cout<<d<<" "<<t<<" "<<u<<endl;
    if(f&&u==0){
      cout<<d<<endl;
      return 0;
    }
    if(dp[f][t][u]<d) continue;
    assert(dp[f][t][u]==d);
    if(u==n-1&&!f){
      if(d<dp[1][t][u]){
	dp[1][t][u]=d;
	q.push(st(1,d,t,u));
      }
    }
    
    for(int i=0;i<n;i++){
      if(e[u][i]==INF) continue;
      int nt=t+1;
      if(nt>=w) nt-=r;
      int nc=e[u][i]*ve[t];
      if(d+nc<dp[f][nt][i]){
	dp[f][nt][i]=d+nc;
	q.push(st(f,d+nc,nt,i));
      }
    }
    
  }
  assert(0);
  return 0;
}

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

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 5;

int cnt[MAX_N];

signed main()
{
  using II = pair<int, int>;
  vector<II> Edge;
  REP(n,3) {
    int a, b; cin >> a >> b;
    a--; b--;
    Edge.push_back(II(a, b));
    cnt[a]++; cnt[b]++;
  }

  int ans = 0;
  REP(n,4) {
    if(cnt[n]%2 == 1) {
      ans++;
    }
  }

  if(ans!=4) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()

class SuffixArray(object):
    def __init__(self,s):
        self.__s=s
        self.__n=len(s)
        self.__suffix_array()
        self.__lcp_array()
        self.__sparse_table()

    def __suffix_array(self):
        s=self.__s; n=self.__n
        sa=list(range(n))
        rank=[ord(s[i]) for i in range(n)]
        tmp=[0]*n
        k=1
        cmp_key=lambda i:(rank[i],rank[i+k] if i+k<n else -1)
        while(k<=n):
            sa.sort(key=cmp_key)
            tmp[sa[0]]=0
            for i in range(1,n):
                tmp[sa[i]]=tmp[sa[i-1]]+(cmp_key(sa[i-1])<cmp_key(sa[i]))
            rank=tmp[:]
            k<<=1
        self.__sa=sa
        self.__rank=rank

    def __lcp_array(self):
        s=self.__s; n=self.__n
        sa=self.__sa; rank=self.__rank
        lcp=[0]*n
        h=0
        for i in range(n):
            j=sa[rank[i]-1]
            if(h>0): h-=1
            if(rank[i]==0): continue
            while(j+h<n and i+h<n and s[j+h]==s[i+h]): h+=1
            lcp[rank[i]]=h
        self.__lcp=lcp

    def __sparse_table(self):
        n=self.__n
        logn=max(1,(n-1).bit_length())
        table=[[0]*n for _ in range(logn)]
        table[0]=self.__lcp[:]
        from itertools import product
        for i,k in product(range(1,logn),range(n)):
            if(k+(1<<(i-1))>=n): table[i][k]=table[i-1][k]
            else: table[i][k]=min(table[i-1][k],table[i-1][k+(1<<(i-1))])
        self.__table=table

    @property
    def suffix(self):
        return self.__sa

    def lcp(self,a,b):
        if(a==b): return self.__n-a
        l,r=self.__rank[a],self.__rank[b]
        l,r=min(l,r)+1,max(l,r)+1
        i=max(0,(r-l-1).bit_length()-1)
        table=self.__table
        return min(table[i][l],table[i][r-(1<<i)])

def resolve():
    S=input()
    n=len(S)
    k=int(input())

    sa=SuffixArray(S)
    D=set()
    for i in sa.suffix:
        for j in range(i+1,n+1):
            D.add(S[i:j])
            if(len(D)==k):
                print(sorted(D)[-1])
                return
resolve()

Measured memory_bytes: 45552
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int 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;
	}
	//Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));
	
	public static void main(String[] args) {
		int a=scan.nextInt();
		System.out.println(a*a*a);
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    int n, k;
    cin >> n >> k;
    vector<double> p(n);
    for (int i = 0; i < n; ++i) cin >> p[i];
    double ans = 0;
    double e = 0;
    for (int i = 0; i < n; ++i) {
        e += (p[i] + 1) / 2;
        if (i >= k) {
            e -= (p[i - k] + 1) / 2;
        }
        if (i >= k - 1) {
            ans = max(ans, e);
        }
    }
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int bsr(int x) { return 31 - __builtin_clz(x); }
int bsr(ll x) { return 63 - __builtin_clzll(x); }
int bsf(int x) { return __builtin_ctz(x); }
int bsf(ll x) { return __builtin_ctzll(x); }

class compare {
public:
	bool operator()(tuple<ll, ll> a, tuple<ll, ll> b) {
		return (get<1>(a) > get<1>(b));
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a=0,b=0,in;
	rep(i,4){
		cin>>in;
		a+=in;
	}
	rep(i,4){
		cin>>in;
		b+=in;
	}
	cout<<max(a,b)<<endl;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define mp make_pair
using namespace std;

using ll = long long;
using ii = pair<int, int>;
const int INF = (int)10e9;

int main() {
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int N, M;
	cin >> N >> M;
	vector<pair<long, long>> v(N);
	for(int i = 0; i < N; i++) {
		ll a, b;
		cin>>a>>b;
		v[i] = {a,b};
	}
	sort(all(v));
	ll res = 0;
	for(int i = 0; i < N; i++) {
		ll can = v[i].second;
		if(M - can >= 0) M -= can;
		else {
			can = M;
			M = 0;
		}
		res += (v[i].first * can);
	}
	cout<<res<<endl;

    return 0;
}


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

int main() {
	string s,t;
//	s="abc";
//	vector<char> s,t;
	cin>>s>>t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),greater<char>());
//	vector<char>::iterator itr;
//	cout<<t<<endl;
	bool flag=0;
	for(int i=0;i<=s.length();i++){
		if(i==t.length()){
			break;
		}
		if(i==s.length()){
			flag=1;
			break;
		}
		if(s[i]<t[i]){
			flag=1;
			break;
		}
		if(s[i]>t[i]){
			break;
		}
	}
	if(flag){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
//	for(itr=s.begin();itr!=s.end();itr++){
//		cout<<&itr<<endl;
//	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <vector>

typedef long long ll;
using namespace std;

int main()
{
    double N, K;
    double sum = 0, ans;
    double y = 0;
    cin >> N >> K;

    for (double i = 1; i <= N; i++) {
        double x = i;
        ans = 1.0;
        while (x < K) {
            x *= 2.0;
            ans *= 1.0/2.0;
            //cout << ans << endl;
        }
        y += 1.0/N*ans;
    }
    cout << setprecision(12) <<  y << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple {
    int N, A;
    void Solve() {
        //input
        N = io.Int;
        A = io.Int;
        //cal
        var ans = N * N - A;
        //ret
        Console.WriteLine(ans);
    }    
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() {
        Solve();
        io.writeFlush();
    }
}
class SimpleIO {
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length)
            return nextBuffer[BufferCnt++];

        string st = Console.ReadLine();
        while (st == "")
            st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 11092
import java.util.Scanner;


public class Main {

	void io(){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int []histgram=new int[6];
		for(int i=0;i<n;++i){
			double height=s.nextDouble();
			if(height<165.0){
				++histgram[0];
			}
			else if(height<170.0){
				++histgram[1];
			}
			else if(height<175.0){
				++histgram[2];
			}
			else if(height<180.0){
				++histgram[3];
			}
			else if(height<185.0){
				++histgram[4];
			}
			else{
				++histgram[5];
			}
		}
		for(int i=0;i<6;++i){
			System.out.print((i+1)+":");
			for(int k=0;k<histgram[i];++k){
				System.out.print('*');
			}
			System.out.println();
		}
		s.close();
	}
	
	public static void main(String[] args) {
		new Main().io();
	}

}

Measured memory_bytes: 11000
import sys

cc = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
c  = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

while True:
  s = sys.stdin.readline().rstrip('\r\n')
  if s == '':
    break

  for ii in range(len(s)):
    test = s[ii].lower()
    for jj in range(len(cc)):
      if test == cc[jj]:
        c[jj] += 1

for ii in range(len(cc)):
  print(cc[ii] +  ' : ' + str(c[ii]))



Measured memory_bytes: 5576
#pragma warning(disable:4996)
#include "bits/stdc++.h"
using namespace std;

//template
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,a,b) for(int i=(int)(b);i>=(int)(a);i--)
#define rrep(i,n) RREP(i,0,n)
using ll = long long;
using ull = unsigned long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
#define all(a) (a).begin(),(a).end()
template<typename A, typename T>
void assign2d(A&arr, ll H, ll W, T t) {
	arr.resize(H);
	for (ll i = 0; i < H; i++) {
		arr[i].assign(W, t);
	}
}
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }

//pair
using P = pair<ll, ll>;
#define mp make_pair
#define EPS (1e-8)

int main() {
	ll N;
	cin >> N;
	ll ans = -1;
	rrep(i, N) {
		ll rn = sqrt(i);
		if (rn*rn == i) {
			ans = i;
			break;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    int n,ni=0,yon=0,odd=0;cin>>n;
    for(int i=0;i < n;i++)
    {
        int a;cin>>a;
        if(a%4==2)ni++;
        else if(a%4==0)yon++;
        else odd++;
    }

    if(ni>0){
        if(odd>yon)cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }else{
        if(odd>yon+1)cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let N: i32 = read();
    let K: i32 = read();
    let mut H: Vec<i32> = (0..N).map(|_| read()).collect();
    H.sort();
    let (mut l, mut r) = (0, K-1);
    let mut ans = 2e9 as i32;
    while r<N {
        ans = std::cmp::min(ans, H[r as usize]-H[l]);
        r += 1;
        l += 1;
    }
    println!("{}", ans);
}


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

int N;
vector<pair<int, int> > VP[100000];
int DIS[100000] = {};

void DFS(int x, int y, int z) {
	DIS[x] = z;
	for (pair<int, int> p : VP[x]) {
		if (p.first != y) DFS(p.first, x, z + p.second);
	}
}

int main() {
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		u--, v--, w = w % 2;
		VP[u].push_back({ v, w });
		VP[v].push_back({ u, w });
	}
	DFS(0, -1, 0);
	for (int i = 0; i < N; i++) {
		cout << DIS[i] % 2 << endl;
	}
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(2e5)+10;
int n,a[maxn],tot,head[maxn],nxt[maxn*2],to[maxn*2];
void add(int x,int y) {
	tot++; nxt[tot]=head[x];
	head[x]=tot; to[tot]=y;
}
int st[maxn],ans[maxn];
struct node { int x,y,z; } delta[maxn];
void dfs(int u,int p) {
	int l=1,r=tot,mid,res=tot+1;
	while (l<=r) {
		mid=(l+r)/2;
		if (st[mid]>=a[u]) res=mid,r=mid-1;
		else l=mid+1;
	}
	delta[u]=(node){res,st[res],(res>tot)};
	st[res]=a[u]; if (res>tot) tot++;
	ans[u]=tot;
	for (int i=head[u],v;i;i=nxt[i]) {
		v=to[i];
		if (v==p) continue;
		dfs(v,u);
	}
	st[delta[u].x]=delta[u].y;
	if (delta[u].z) tot--;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) read(a[i]);
	int x,y;
	for (int i=1;i<n;i++) {
		read(x); read(y);
		add(x,y); add(y,x);
	}
	tot=0;
	dfs(1,0);
	for (int i=1;i<=n;i++) printf("%d\n",ans[i]);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 25876
#include <iostream>
#include <vector>

int main() {
    long long n, par = 0;
    constexpr auto mod = 1000000007;
    std::cin >> n;
    std::vector<long long> v(n + 1);

    v[0] = 1;
    v[1] = n;
    v[2] = n * n;
    for (auto i = 3ll; i <= n; i++) {
        par = (par + v[i - 3]) % mod;
        v[i] = ((n - 1) * (n - 1) + v[i - 1] + n - i + 1 + par) % mod;
    }
    std::cout << v[n] << std::endl;

    return 0;
}

Measured memory_bytes: 8064
N = int(input())
X = []
Y = []
for _ in range(N):
    x, y = list(map(int, input().split()))
    X.append(x)
    Y.append(y)
    
points = []
for i, (x, y) in enumerate(zip(X, Y)):
    points.append((
        x + y,
        x + y,
        x - y,
        x - y
    ))
print(max(max(dim) - min(dim) for dim in zip(*points)))

Measured memory_bytes: 82060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void push(int x);
int pop();

int top;
int S[1000];

int main(){
int x,y;
top = 0;
char s[100];

 while(scanf("%s", s) != EOF){
if(s[0] == '+' ){
x = pop();
y = pop();
 push(x + y);
}else if(s[0] == '-' ){
y = pop();
x = pop();
 push(x - y);
}else if(s[0] == '*' ){
x = pop();
y = pop();
 push(x * y);
}
else{
push(atoi(s));
}}
 
printf("%d\n", pop());
 
return 0;
} 

void push(int x){
  top++;
  S[top] = x;
}

int pop(){
top--;
return S[top+1];
}



Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <cstdint>
#include <string.h>
#include <queue>

using namespace std;

int main()
{
    int D;
    cin >> D;
    switch (D) {
    case 22: cout << "Christmas Eve Eve Eve" << endl;; break;
    case 23: cout << "Christmas Eve Eve" << endl;; break;
    case 24: cout << "Christmas Eve" << endl;; break;
    case 25: cout << "Christmas" << endl;; break;
    }
    return 0;
}

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

struct p
{
    ll ads;
    ll verb;
};

int main()
{
    p a,b;
    ll t;
    while(cin>>a.ads>>a.verb>>b.ads>>b.verb>>t)
    {
        if(a.ads<b.ads)//a is behind b
        {
            if((a.verb-b.verb)*t>=b.ads-a.ads)
                printf("YES\n");
            else
                printf("NO\n");
        }
        else
        {
            if((a.verb-b.verb)*t>=a.ads-b.ads)
                printf("YES\n");
            else
                printf("NO\n");
        }
    }
return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;
#define int LL

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 2e5 + 5;
struct Edges { int to, next; } e[MAXN * 2];
int head[MAXN], tot;
int Ans[MAXN], si[MAXN], Out[MAXN];
int a[MAXN];

inline void addedge(int from, int to) {
  e[++tot] = (Edges){to, head[from]};
  head[from] = tot;
  e[++tot] = (Edges){from, head[to]};
  head[to] = tot;
}

void Dfs(int now, int fa) {
  si[now] = 1;
  for (RI i = head[now]; i; i = e[i].next)
    if (e[i].to != fa) {
      int nowsplit = Out[a[now]];
      Dfs(e[i].to, now);
      si[now] += si[e[i].to];
      int addsize = Out[a[now]] - nowsplit;
      int S = si[e[i].to] - addsize;
      Out[a[now]] += S;
      Ans[a[now]] -= S * (S + 1) / 2;
    }
  ++Out[a[now]];
}

signed main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int n; read(n);
  for (RI i = 1; i <= n; ++i)
    read(a[i]), Ans[i] = n * (n + 1) / 2;
  for (RI i = 1, x, y; i < n; ++i)
    read(x), read(y), addedge(x, y);
  Dfs(1, 0);
  for (RI i = 1; i <= n; ++i) {
    Ans[i] -= (n - Out[i]) * (n - Out[i] + 1) / 2;
    printf("%lld\n", Ans[i]);
  }

  return 0;
}

// created by Daniel yuan


Measured memory_bytes: 34176
n, m = map(int, input().split())
h = list(map(int, input().split()))
eg = [[] for _ in range(n)]

for _ in range(m):
    a, b = map(int, input().split())
    eg[a - 1].append(b - 1)
    eg[b - 1].append(a - 1)

ans = 0
for i in range(n):
    high = True
    for to in eg[i]:
        if h[i] <= h[to]:
            high = False
    if high:
        ans += 1
print(ans)


Measured memory_bytes: 94448
s = input()
t = input()
start = -1
for i in range(len(s)-len(t)+1):
    flag = 1
    for j in range(len(t)):
        if s[i+j] != t[j] and s[i+j] != "?":
            flag = 0
    if flag:
        start = i

if start == -1:
    print("UNRESTORABLE")
else:
    ans = s[:start] + t + s[start+len(t):]
    for i in ans:
        if i == "?":
            print("a", end="")
        else:
            print(i, end="")
    print()

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

int main() {
  double r;
  cin >> r;

  double pi = 3.14159265358979;

  cout  << fixed << setprecision(15) <<  2 * pi * r<<endl;

  return 0;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	int n;
	cin >> n;
	
	vi a(n);
	for(int& x : a)cin >> x;
	
	vi b(n);
	for(int& x : b)cin >> x;
	
	reverse(all(b));
	
	int l=0, r=n-1;
	for(int i=0 ; i<n ; ++i){
		if(a[i] == b[i]){
			if(a[l] != b[i] && b[l] != b[i]){
				swap(b[i], b[l]);
				++l;
			}
			else if(a[r] != b[i] && b[r] != b[i]){
				swap(b[i], b[r]);
				--r;
			}
			else{
				cout << "No\n";
				return;
			}
		}
	}
	
	for(int i=0 ; i<n ; ++i){
		if(a[i] == b[i]){
			cout << "No\n";
			return;
		}
	}
	
	cout << "Yes\n";
	for(int& x : b)cout << x << " ";
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 4788
import array

n= int(input())

maxN = 1000000
a = list(map(int, input().split()))

def calculate_prime():
    primes = [True] * maxN
    primes[0] = primes[1] = False
    prim = []
    prime_map = dict()
    for i in range(2, maxN):
        if primes[i] == True:
            prime_map[i] = 0
            prim.append(i)
            j = i * i
            while j < maxN:
                primes[j]= False
                j+=i
    return prime_map, array.array('i',prim)

prime_map, prim = calculate_prime()

pppp = []
#print(prim)
for i in list(set(a)):
    if i in prime_map:
        if prime_map[i] < 1:
            pppp.append(i)
            prime_map[i] = 1

    else:
        k = i
        for j in prim:
            if k % j == 0:
                tmp = 0
                while k % j == 0:
                    k = k // j
                    tmp += 1
                if tmp > prime_map[j]:
                    if prime_map[j] == 0:
                        pppp.append(j)
                    prime_map[j] = tmp
            if k in prime_map:
                if prime_map[k] < 1:
                    pppp.append(k)
                    prime_map[k] = 1
                    break
            if k == 1:
                break

lcm = 1
for k in list(set(pppp)):
    lcm = lcm * (k**prime_map[k])

#print(lcm)
result = 0

for i in a:
    result += lcm // i

if result >= 1000000007:
    result = result % 1000000007
print(result)


Measured memory_bytes: 17892
#include<bits/stdc++.h>
using namespace std;
int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;
	int sum = 0;
	if (A < K) {
		sum += A;
		K = K - A;
	}
	else {
		sum = K;
		K = 0;
	}

	if (B < K && K!=0) {
		K = K - B;
	}
	else if (K != 0) {
		K = 0;
	}

	if (C < K && K != 0) {
		sum += -C;
		K = K - C;
	}
	else if (K != 0) {
		sum += -K;
		K = 0;
	}

	cout << sum << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string c;
  cin>>c;
  int i = -1;
  while(c[++i]!='\0'){
    if(c[i]=='7'){
      cout<<"Yes";
      return 0;
    }
  }
  cout<<"No";
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
 
using namespace std;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = 4*atan(1);
typedef long long ll;
typedef pair<int,int> pii;
int n, a, cnt[200001];
void solve() {
	cin >> n;
	for (int i = 1; i < n; i++) {
		cin >> a;
		cnt[a]++;
	}
	for (int i = 1; i <= n; i++) cout << cnt[i] << endl;
}
int main() {
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	// int t;
	// cin >> t;
	// for (int i = 1; i <= t; i++) { 
		// cout << "Case #" << i << ": ";
		solve();
	// }
}

Measured memory_bytes: 4396
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#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--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

long long to_long_long(string s){
	return strtoll(s.c_str(),0,10);
}

int max_plus_i;
long long solve(string s, int plus_i){
	long long sum = 0;
	if(plus_i < max_plus_i){
		sum += solve(s, plus_i + 2);
		s.erase(s.begin() + plus_i);
		s.insert(plus_i,"+");
		sum += solve(s, plus_i + 2);
	}else{
	vector<long long> a;
	int last_i = 0;
	for(int i = 0;i<s.size();i++){
		if(s[i] == '?') s.erase(s.begin() + i);
		if(s[i] == '+'){
			string tmp_s = s.substr(last_i, i - last_i);
			a.push_back(to_long_long(tmp_s));
			last_i = i + 1;
		}
	}
	sum +=  accumulate(a.begin() , a.end() ,0LL);
	}
	return sum;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int s_size = s.size();
	REP(i,s_size - 1) s.insert(i * 2 + 1, "?");
	s = s + '+';
	max_plus_i = s.size() -1;
	cout << solve(s,1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

char s[200001];
char t[200000];
int d[200000];

int main() {
    int n, q, l1, r1, m1, l2, r2, m2, i;
    
    scanf("%d %d", &n, &q);
    scanf("%s", s);
    
    for (i = 0; i < q; i++) {
        char c1[2];
        char c2[2];
        
        scanf("%s %s", c1, c2);
        
        t[i] = c1[0];
        if (c2[0] == 'L') {
            d[i] = -1;
        } else {
            d[i] = 1;
        }
    }
    
    l1 = -1, r1 = n, m1 = (l1 + r1) / 2;
    
    while (r1 - l1 > 1) {
        int x = m1;
        
        for (i = 0; i < q; i++) {
            if (s[x] == t[i]) x += d[i];
            if (x < 0 || x >= n) break;
        }
        
        if (x < 0) {
            l1 = m1;
            m1 = (l1 + r1) / 2;
        } else {
            r1 = m1;
            m1 = (l1 + r1) / 2;
        }
    }
    
    l2 = -1, r2 = n, m2 = (l2 + r2) / 2;
    
    while (r2 - l2 > 1) {
        int x = m2;
        
        for (i = 0; i < q; i++) {
            if (s[x] == t[i]) x += d[i];
            if (x < 0 || x >= n) break;
        }
        
        if (x >= n) {
            r2 = m2;
            m2 = (l2 + r2) / 2;
        } else {
            l2 = m2;
            m2 = (l2 + r2) / 2;
        }
    }
    
    printf("%d\n", n - (l1 + 1) - (n - r2));
    
    return 0;
}


Measured memory_bytes: 1280
n=int(input())
A=[int(input()) for i in range(2**n)]
for i in range(n):
  B=[]
  for j in range(2**(n-1-i)):
    if A[2*j]==A[2*j+1]:
      B.append(A[2*j])
    else:
      B.append(abs(A[2*j]-A[2*j+1]))
  A=B
print(B[0])


Measured memory_bytes: 18596
//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define all(_obj) _obj.begin(),_obj.end()
#define F first
#define S second
#define INF 1e18
#define pll pair<ll, ll> 
#define vll vector<ll>
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=1e5+11,mod=1e9+7;
inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline vll read(int n) {vll v(n);for (int i = 0; i < v.size(); i++)cin>>v[i];return v;}
void sol(void)
{
cin>>n;
cout<<(n==0);
return ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    for(int i=1;i<=test;i++)
    sol();
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<int> p(n);
    REP(i,n)cin >> p[i];
    int b[n+1];
    REP(i,n) b[p[i]] = i;
    int M = 0;
    int c = 1;
    if (n==1) {
        cout << 0 << std::endl;
        return 0;
    }
    for (int i = 1; i < n; ++i) {
        if (b[i] < b[i+1]) c++;
        else c = 1;
        M = max(M, c);
    }
    cout << n-M << std::endl;
    return 0;
}

Measured memory_bytes: 1792
def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    dp = [[0,0] for _ in range(n+1)]
    dp[0][0] = 0
    dp[0][1] = -float("inf")
    for i in range(n):
        dp[i+1][0] = max(dp[i][0]+a[i],dp[i][1]-a[i])
        dp[i+1][1] = max(dp[i][0]-a[i],dp[i][1]+a[i])
    print(dp[n][0])
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 73504
#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)))
int sum(int X){
  int A=0;
  while(1){
    A+=X%10;
    X/=10;
    if(X==0)
      break;
    }
  return A;
  }
signed main(){
  int N,A,B;
  cin>>N>>A>>B;
  int ans=0;
  REP(i,1,N){
    int X=sum(i);
    if(A<=X&&X<=B)
      ans+=i;
    }
  cout<<ans;
  }


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	rep(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	rep(i, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
	cin.tie(0);	ios::sync_with_stdio(false);

  int s; cin >> s;
  vector <int>tmp;
  int ans=1;
  tmp.pb(s);
  while(true){
      ans++;
      if(s%2==0){s/=2;}else{s = s*3+1;}
      auto it = find(ALL(tmp),s);
      if(it == tmp.end()){tmp.pb(s);}else{cout << ans << endl;break;}
  }


  return 0;
}


Measured memory_bytes: 3616
# -*- coding: utf-8 -*-
#mitsui a
import sys
import math
import collections
#sys.setrecursionlimit(100000)

n=int(input())

#tmp = input().split()
#a,b = list(map(lambda a: int(a), tmp))
#tmp = input().split()
#c,d = list(map(lambda a: int(a), tmp))

for i in range(1,50001):
	if (i*1.08>=n)and(i*1.08<n+1):
		print(i)
		sys.exit()
print(":(")
sys.exit()

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

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = ReadInt();
            var b = ReadInt();
            WriteLine((b - a) + b);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
//Zory-2019
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<deque>
using namespace std;
namespace mine
{
	typedef long long ll;
	#define double long double
	const int INF=0x3f3f3f3f;
	const ll LLINF=0x3f3f3f3f3f3f3f3fll;
	ll qread()
	{
		ll ans=0;char c=getchar();int f=1;
		while(c<'0' or c>'9') {if(c=='-') f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num)
	{
		if(num<0) {num=-num;putchar('-');}
		if(num>9) write(num/10);
		putchar('0'+num%10);
	}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);puts("");}
	#define FR first
	#define SE second
	#define MP make_pair
	#define pr pair<int,int>
	#define PB push_back
	#define vc vector
	void chmax(int &x,const int y) {x=x>y?x:y;}
	void chmin(int &x,const int y) {x=x<y?x:y;}
	const int MAX_N=2e5+10;
	const ll MOD=1e9+7;
	void add(int &x,int y){x+=y;if(x>=MOD) x-=MOD;if(x<0) x+=MOD;}
	
	struct BIT
	{
		vc<int> bit[MAX_N];int now[MAX_N];BIT(){memset(now,0,sizeof now);}
		#define lowbit(x) ((x)&-(x))
		void change(int x,int c){while(x<MAX_N) bit[x].PB(max(bit[x][now[x]],c)),now[x]++,x+=lowbit(x);}
		int ask(int x){int ans=-INF;while(x>=1) chmax(ans,bit[x][now[x]]),x-=lowbit(x);return ans;}
		void gaygay(int x){while(x<MAX_N) now[x]--,x+=lowbit(x);}
	}bit[2];
	int a[MAX_N];vc<int> ans;
	int c[2],mi[2],cnt[MAX_N];
	bool check(int i,int now)
	{
		int tmp1=c[now],tmp2=mi[now];
		if(a[i]<mi[now]) c[now]++,mi[now]=a[i];
		for(int j=0;j<=1;j++)
		{
			int wt=c[j]-c[j^1]+cnt[i+1];if(wt<0) continue;
			if(bit[wt&1].ask(mi[j^1])>=wt) return 1;
		}
		c[now]=tmp1;mi[now]=tmp2;
		return 0;
	}
	void main()
	{
		for(int i=1;i<MAX_N;i++) bit[0].bit[i].PB(0);
		for(int i=1;i<MAX_N;i++) bit[1].bit[i].PB(-1);
		
		int n=qread();for(int i=1;i<=n;i++) a[i]=n-qread()+1;
		int lstmi=INF;for(int i=1;i<=n;i++) if(a[i]<lstmi) lstmi=a[i],cnt[i]=1; else cnt[i]=0;
		for(int i=n;i>=1;i--) cnt[i]+=cnt[i+1];
		
		for(int i=n;i>=1;i--)
		{
			int t0=bit[0].ask(a[i]),t1=bit[1].ask(a[i]);if(t1==-1) t1=-INF;
			t0+=1+(cnt[i]-cnt[i+1]);t1+=1+(cnt[i]-cnt[i+1]);
			if((t0&1)==(t1&1)) bit[t1&1].change(a[i],max(t0,t1)),bit[(t1&1)^1].change(a[i],-INF);
			else bit[t0&1].change(a[i],t0),bit[t1&1].change(a[i],t1);
		}
		mi[0]=mi[1]=n+1;
		for(int i=1;i<=n;i++)
		{
			bit[0].gaygay(a[i]);bit[1].gaygay(a[i]);
			
			if(check(i,0)) ans.PB(0);
			else if(check(i,1)) ans.PB(1);
			else {puts("-1");return;}
		}
		for(int t=0;t<n;t++) putchar('0'+ans[t]);
	}
};
signed main()
{
	srand(time(0));
	mine::main();
}


Measured memory_bytes: 50408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define min(a,b) ((a>b)? b:a)
#define max(a,b) ((a>b)? a:b)
int main()
{
  ll a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  if(2*c>=a+b){
    cout<<x*a+b*y;
    return 0;
  }
  ll ans=min(x,y)*2*c;
  if(max(x,y)==x){
    ans+=(max(x,y)-min(x,y))*min(a,2*c);
  }
  else ans+=(max(x,y)-min(x,y))*min(b,2*c);
  cout<<ans;
}

Measured memory_bytes: 256
#include<cstdio>
#define LL long long
using namespace std;
LL n;
void check(LL x){
	int num=0;
	while(x) num+=x%10,x/=10;
	if (n%num==0) printf("Yes\n");else printf("No\n");
}
int main(){
	scanf("%lld",&n);
	check(n);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int c;
  map<int, int> cnt;

  for (int i = 0; i < N; i++) {
    cin >> c;
    cnt[c]++;
  }
  int min = N;
  int res = 0;
  for(auto i = cnt.begin(); i != cnt.end(); i++) {
    if (i->first <= i->second) {
      res += i->second - i->first;
    } else {
      res += i->second;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 4736
def main():
    import sys
    input = sys.stdin.readline
    N, M = [int(x) for x in input().strip().split()]
    l = [0] * N
    for m in range(M):
        a, b = [int(x) for x in input().strip().split()]
        l[a-1] += 1
        l[b-1] += 1
    if [i for i in l if i % 2]:
        print('NO')
    else:
        print('YES')

if __name__ == '__main__':
    main()

Measured memory_bytes: 4276