akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std ;
 
const long long mod = 1e9 + 7 ;
 
vector <pair<int,int> > g[312345];
int ad[312345], da[312345];
int n;
int col[312345];

void dfs(int u, int p = 0,int ed=0) {
	
	int cur = 1;
	for(int i= 0; i < g[u].size(); i++) {
		int to = g[u][i].first;
		if(to==p) {
			if(ed==cur)cur++;
		}else{
			if(ed==cur)cur++;
			dfs(to, u,cur);
			col[g[u][i].second]=cur;
			cur++;
		}
	}
}
int main ( ) {

	cin >> n;
	for(int i =1 ; i < n; i++) {
		cin >> ad[i] >> da[i];
		g[ad[i]].push_back(make_pair(da[i],i));
		g[da[i]].push_back(make_pair(ad[i],i));
	}	
	int root=1;
	for(int i =1; i <= n; i++)
		if(g[i].size()==1)root=i;
	dfs(root);
	int color = 0;
	for(int i = 1; i < n; i++) color=max(color,col[i]);
	cout<<color<<endl;
	for(int i = 1; i < n; i++)cout<<col[i]<<endl;
	return 0;
}

Measured memory_bytes: 16128
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

char ToLower(char ch){
    return tolower(ch);
} 

int main(){
    
    string taro, hanako;
    int n;
    int taro_count=0, hanako_count=0;

    cin >> n;

    for(int i=0; i<n; i++){
        cin >> taro >> hanako;
        transform(taro.begin(), taro.end(), taro.begin(), ToLower);
        transform(hanako.begin(), hanako.end(), hanako.begin(), ToLower);
        if(taro > hanako){
            taro_count += 3;
        }else if(taro == hanako){
            taro_count++;
            hanako_count++;
        }else{
            hanako_count += 3;
        }
    }

    cout << taro_count << " " << hanako_count << endl;

    return 0;
}




Measured memory_bytes: 3152
length = gets.to_i
arr = []
length.times do
  num = gets.to_i
  arr.push num
end

def cal(length, input)
  max_prof = input[1] - input[0]
  min = input[0]
  for i in 0..(length-2) do
    diff = input[i+1] - min
    max_prof = diff if diff > max_prof

    min = input[i+1] if input[i+1] < min
  end

  p max_prof
end

cal(length, arr)





Measured memory_bytes: 8892
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
#define N 1000000000000000000
typedef long long ll;

ll s=1;
ll a[100005];

int find(ll x,ll y){
    ll X=x;
    ll Y=y;
    unsigned long long s;
   // cout<<x<<y<<endl;
    int i=0,j=0;
    while(X!=0){
        X/=10;
        i++;
    }
    while(Y!=0){
        Y/=10;
        j++;
    }
    if(i+j-1==19){
        s=x*y;
        if(s==N)
            return 1;
    }
    
//     cout<<i<<endl;
    if(i+j-1>=19)
        return 0;
    else{
        x*=y;
        //cout<<x<<endl;
        if(x<=1000000000000000000)
            return 1;
        else
            return 0;
    }
    
    
}

int main(){
    int n,i;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>a[i];
    }
    for(i=1;i<=n;i++){
        if(a[i]==0){
            cout<<"0"<<endl;
            return 0;
        }
    }
    for(i=1;i<=n;i++){
        if(find(s,a[i])==1){
            s*=a[i];
        }
        else{
            cout<<"-1"<<endl;
            return 0;
        }
        //cout<<s;
    }
    
    cout<<s<<endl;
    
    return 0;
}



Measured memory_bytes: 4404
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

class Edge
{
public:
    int to, c;
    Edge(int to, int c){
        this->to = to;
        this->c = c;
    }
};

const int MAX = INT_MAX / 2;

void solve(const vector<vector<Edge> >& edges, int start, vector<int>& ans)
{
    int n = edges.size();
    ans.resize(n, MAX);
    ans[start] = 0;
    multimap<int, int> mm;
    mm.insert(make_pair(0, start));

    while(!mm.empty()){
        int t = mm.begin()->first;
        int pos = mm.begin()->second;
        mm.erase(mm.begin());
        if(ans[pos] < t)
            continue;

        for(const Edge& e : edges[pos]){
            if(t <= e.c && e.c < ans[e.to]){
                ans[e.to] = e.c;
                mm.insert(make_pair(e.c, e.to));
            }
        }
    }
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<Edge> > edges(n);
    vector<vector<Edge> > revEdges(n);
    for(int i=0; i<m; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        -- a;
        -- b;
        edges[a].push_back(Edge(b, c));
        revEdges[b].push_back(Edge(a, c));
    }

    vector<int> t;
    solve(edges, 0, t);
    if(t[n-1] == MAX){
        cout << -1 << endl;
        return 0;
    }

    int ans = 0;
    for(const Edge& e : revEdges[n-1]){
        if(t[e.to] <= e.c)
            ans = max(ans, e.c);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 15640
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int num = Integer.parseInt(sc.nextLine());
    	
      	boolean[] array = new boolean[100+1];
  		
      	for(int i = 1;i <= 100 ;i++){
        	array[i] = false;
        }
      	
      	for(int i = 1;i <= num;i++){
        	int index = Integer.parseInt(sc.nextLine());
          	
          	array[index] = true;
        }
		
      	int ans = 0;
      	for(int i = 1;i <= 100 ;i++){
        	if(array[i] == true){
            	ans++;
            }
        }
        
      System.out.println(ans);
    	
      
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#define INF (1LL<<60)
#define ll long long
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N; cin >> N;
	ll minv = INF, maxv = -INF;
	vector<ll> x(N);
	ll ans = INF;
	for (int i = 0; i < N; i++) {
		cin >> x[i]; minv = min(minv, x[i]); maxv = max(maxv, x[i]);
	}
	if (minv == maxv) { cout << 0 << endl; return 0; }
	for (int y = minv; y <= maxv; y++) {
		ll sum = 0;
		for (int i = 0; i < N;i++) {
			sum += (x[i] - y)*(x[i] - y);
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
}

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

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

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

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    char[] c = s.toCharArray();
    String Before = "";
    String After = "";
    
    for(int i=0; i<n/2; i++){
      Before += c[i];
    }
    
    for(int j=n/2; j<n; j++){
      After += c[j];
    }
    
    if(Before.equals(After)){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - (int)1e8;
const ll INFLL = numeric_limits<ll>::max() - (ll)1e17;

int main() {
    int N;
    cin >> N;
    map<int, int> count;
    for (int i = 2; i <= N; i++) {
        int temp;
        cin >> temp;
        count[temp]++;
    }
    for (int i = 1; i <= N; i++) cout << count[i] << endl;
}

Measured memory_bytes: 12984
#include<iostream>
#include<iomanip>

#define PI (double)3.14159265359

int main()
{
    double r, menseki, shuui;

    std::cin >> r;

    menseki = r * r * PI;
    shuui = 2 * r * PI;

    std::cout << std::setprecision(20) << menseki << " " << std::setprecision(20) << shuui << std::endl;

    return 0;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
  string a, b, c;
  cin >> a >> b;
  c=a+b;
  int n = atoi(c.c_str()), i=1, d=0;
  while(i*i < n){
    i++;
    if(i*i == n)d=1;
  }
  if(d)cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

string S;

signed main(){
    cin >> S;
    rep(i, S.size()-1){
        if(S[i] == S[i+1]){
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
    }
    rep(i, S.size()-2){
        if(S[i] == S[i+2]){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int D,T,S;
    cin >> D >> T >> S;
    
    D<=S*T ? cyes : cno;
    
    
    

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int  main(){
  string s;
  cin >> s;
  string k;
  string y;
  string z;
  rep(i,s.length()){
    k[i]=s[s.length()-1-i];
    if(s[i]!=k[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  int yon = (s.length()-1)/2;
  for(int i=0;i<yon;i++){
    y[i]=s[yon-1-i];
    if(s[i]!=y[i]){
      cout << "No"<<endl;
      return 0;
    }
  }
  int kun =(s.length()+3)/2;
  for(int i=kun-1;i<s.length();i++){
     z[i]=s[s.length()-1-i];
     if(s[i]!=z[i]){
       cout << "No" << endl;
       return 0;
     }
  }
  cout << "Yes" << endl;
  return 0;
}

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

int main(){
    /*B
    int n;
    cin>>n;
    int p=n%10;
    if(p==2||p==4||p==5||p==7||p==9) cout<<"hon"<<endl;
    else if (p==0||p==1||p==6||p==8) cout<<"pon"<<endl;
    else cout<<"bon"<<endl;
    */
   int k;
   string s;
   cin>>k>>s;
   int l=s.length();
   if (l<=k) cout<<s<<endl;
   else cout<<s.substr(0,k)+"..."<<endl;
}


Measured memory_bytes: 3600
#include "bits/stdc++.h"

using namespace std;
 
const long long inf = 1e18;
#define ll long long
#define fr(i,a,n) for (int i=a;i<n;i++)
#define rfr(i,n,a) for (int i=n;i>=a;i--)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define endl "\n"
typedef vector<int> VI;
typedef vector<ll> VL;

ll n,m,k;
VI adj[100001];
int height[100001];
int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	fr(i,1,n+1) {
		cin >> height[i];
	}
	fr(i,0,m) {
		int x,y;
		cin >> x >> y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	int cnt = 0;
	fr(i,1,n+1) {
		bool o = 0;
		for (auto x:adj[i]) {
			if (height[x] >= height[i])
				o = 1;
		}
		if (o)
			continue;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 9184
#include <iostream>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <queue>
#include <math.h>

const long long INF=1001001001;

using namespace std;

int main(void){
    long long N;
    long long A,B;
    long long l, r;
    long long z_const = 0;

    cin >> N >> A >> B;
    long long H[N+5];

    for(long long i=0;i<N+5;i++){
        H[i] = 0;
    }

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

    l = 0;
    r = INF;
    long long ans = 0;
    long long m;
    while(l+1<r){
        m = (l + r) / 2;
        ans = 0;
        for(long long i=0;i<N;i++){
            long long tmp = max(H[i] - B * m, z_const);
            ans = ans + (tmp + A - B - 1) / (A-B);
        }
        if(ans <= m){
            r = m;
        }
        else{
            l = m;
        }
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <iostream>
#include <string>
#include <string.h>
#include <cmath>
#include <algorithm>
#define lli long long int 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
double dp[3001][3001];
int h,n;
double result(double *arr,int a,int sum)
{
    if (a==n)
    {
        if (sum>=h)
        return 1;
        else
        return 0; 
    }
    if (dp[a][sum]!=-1)
    return dp[a][sum];
    if (dp[a][sum]==-1)
    {
        double tum,lum;
        tum=(1-arr[a])*result(arr,a+1,sum);
        lum=(arr[a])*result(arr,a+1,sum+1);
        dp[a][sum]=tum+lum;
        return dp[a][sum];
    }
}
int main() 
{
    fio;
    cin>>n;
    h=(n/2)+1;
    double arr[n];
    for (int i=0;i<=3000;i++)
    {
        for (int j=0;j<=3000;j++)
        dp[i][j]=-1;
    }
    for (int i=0;i<n;i++)
    cin>>arr[i];
    double t=result(arr,0,0);
    cout<<setprecision(10)<<t;
	return 0;
}

Measured memory_bytes: 70784
#include<cstdio>
#include<cstring>
#include<iostream>

using namespace std;

int n,m;long long f[2],g[2];

int main()
{
	
	scanf("%d%d",&n,&m);
	f[0]=1;
	for (int i=1;i<=n;i++){
		int x;scanf("%d",&x);x%=2;
		for (int j=0;j<2;j++) g[j]=f[j];
		for (int j=0;j<2;j++) g[j^x]+=f[j];
		for (int j=0;j<2;j++) f[j]=g[j];
	}
	printf("%lld\n",f[m]);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <tuple>
#include <cstdio>

#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define vec vector
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

char s[4];

int main() {
   cin >> s;
   if(s[2] != '\0') {
      putchar(s[2]);
      putchar(s[1]);
      putchar(s[0]);
      putchar('\n');
   } else {
      cout << s << endl;
   }
   return 0;
}


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

using namespace std;

int main()
{
  int n, k;

  scanf("%d %d", &n, &k);

  vector<int> l(n);

  for (int i = 0; i < n; i++)
  {
    scanf("%d", &l[i]);
  }

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

  int length = 0;

  for (int i = 0; i < k; i++)
  {
    length += l[i];
  }

  printf("%d", length);
}

Measured memory_bytes: 256
let a=Int(readLine()!)!
var arr1=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}
var arr2=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}
var arr3 = arr1

var i = 0
var b = 0
var c = 0

for i in 0..<a {

  if( arr1[i] > arr2[i] ) {
    arr1[i] = arr1[i] - arr2[i]
  } else {
    var tmp = arr1[i]
    arr1[i] = 0
    arr2[i] = arr2[i] - tmp
    c = arr2[i]
    
    if( arr1[i+1] > c ) {
      arr1[i+1] = arr1[i+1] - c
    } else {
      arr1[i+1] = 0
      c = 0
    }
  }
}

for i in 0..<a + 1 {
  b += ( arr3[i] - arr1[i] )
}
print(b)


Measured memory_bytes: 8688
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include <math.h>
using namespace std;

int main()
{
    int N;
    cin >> N;
    if((N * 25 / 27 * 27 / 25) == N) cout << N * 25 / 27 << endl;
    else if(((N * 25 / 27 + 1) * 27 / 25) == N) cout << N * 25 / 27 + 1 << endl;
    else cout << ":(" << endl;
    return 0;
}
 

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int N;
    std::cin >> N;

    long long checker = 1;
    long long pre = 0;
    bool isOverFlowed = false;
    for(int i=0; i<N; i++)
    {
        long long tmp;
        std::cin >> tmp;
        if(tmp == 0)
        {
            std::cout << 0 << std::endl;
            return 0;
        }
        checker *= tmp;
        if(pre > checker)
        {
            isOverFlowed = true;
        }
        pre = checker;
    }

    if(checker > 1000000000000000000)
    {
        std::cout << -1 << std::endl;
        return 0;
    }
    else if(isOverFlowed == true)
    {
        std::cout << -1 << std::endl;
        return 0;
    }

    std::cout << checker << std::endl;

    return 0;
}

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

int main() {
  ll h, w, n;
  cin >> h >> w >> n;

  map<pair<ll, ll>, ll> cnt;
  for (ll i = 0; i < n; ++i) {
    ll a, b;
    cin >> a >> b;
    for (auto ai = -1; ai <= 1; ++ai)
      for (auto bi = -1; bi <= 1; ++bi) {
        cnt[make_pair(a + ai, b + bi)]++;
      }
  }

  vector<ll> res(10);
  res[0] = (h - 2) * (w - 2);
  for (const auto& c : cnt) {
    auto pos = c.first;
    if (1 < pos.first && pos.first < h && 1 < pos.second && pos.second < w) {
      res[c.second]++;
      res[0]--;
    }
  }

  for (auto r : res) {
    cout << r << endl;
  }

  return 0;
}


Measured memory_bytes: 56448
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int n;
vector<bitset<26>> seg(2000100);
string s;

void init(int n_)
{
    n = 1;

    while (n < n_)
    {
        n *= 2;
    }
}

void update(int i, char x)
{
    seg[i + n - 1].reset(s[i] - 'a');
    s[i] = x;
    seg[i + n - 1].set(s[i] - 'a');

    i += n - 1;

    while (i > 0)
    {
        i = (i - 1) / 2;
        seg[i] = seg[2 * i + 1] | seg[2 * i + 2];
    }
}

bitset<26> query(int a, int b, int k, int l, int r)
{
    if (r <= a || b <= l)
    {
        bitset<26> bit(0ll);
        return bit;
    }

    if (a <= l && r <= b)
    {
        return seg[k];
    }
    else
    {
        bitset<26> bit1 = query(a, b, 2 * k + 1, l, (l + r) / 2);
        bitset<26> bit2 = query(a, b, 2 * k + 2, (l + r) / 2, r);

        return bit1 | bit2;
    }
}

int main(void)
{
    int q;
    int i, j;
    int n_;
    vector<int> ans;

    cin >> n_ >> s >> q;

    init(n_);

    rep(i, 0, n_)
    {
        update(i, s[i]);
    }

    init(n_);

    rep(i, 0, q)
    {
        int x;

        cin >> x;

        if (x == 1)
        {
            int iq;
            char c;

            cin >> iq >> c;
            iq--;

            update(iq, c);
        }
        else
        {
            int l, r;
            int an = 0;

            cin >> l >> r;
            l--;

            bitset<26> bit = query(l, r, 0, 0, n);

            an = bit.count();

            ans.push_back(an);
        }
    }

    for (auto &z : ans)
    {
        cout << z << endl;
    }
}

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


int main(){

	ll n;
	cin >> n;
	FORR(i,0,n){
		cout << "ACL";
	}
	cout << endl;
}


Measured memory_bytes: 3632
s = input()

d = s.count("dream")
dr = s.count("dreamer")
e = s.count("erase")
er = s.count("eraser")
de = s.count("dreamerase")

l = (d + e) * 5 + (dr - de) * 2 + er

print("YES" if len(s) == l else "NO")

Measured memory_bytes: 3188
n=int(input())
stairlist=list(map(int,input().split()))
stairlist.reverse()
for i in range(n-1):
  if stairlist[i+1]-stairlist[i]==1:
    stairlist[i+1]=stairlist[i+1]-1
  elif stairlist[i+1]-stairlist[i]>1:
    print("No")
    break
else:
  print("Yes")

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

int main()
{
    int N, A, j, k;
    j = 300;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> A;
        if (A % 2 == 0)
        {
            for (k = 0; A % 2 == 0; k++)
            {
                A /= 2;
            }
            if (k < j)
            {
                j = k;
            }
        }
        else
        {
            j = 0;
            break;
        }
    }
    cout << j << endl;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <iostream>
#include <list>

const int kMaxDigits = 11;

void do_operation(std::list<int>& data, char operator_char)
{
    int operand1, operand2, result;

    operand1 = data.back();
    data.pop_back();
    operand2 = data.back();
    data.pop_back();

    if(operator_char == '+') {
        result = operand2 + operand1;
    } else if(operator_char == '-') {
        result = operand2 - operand1;
    } else if(operator_char == '*') {
        result = operand2 * operand1;
    } else if(operator_char == '/') {
        result = operand2 / operand1;
    } else {
        fputs("Error: Invalid operator\n", stderr);
        exit(EXIT_FAILURE);
    }
    data.push_back(result);
}

int main()
{
    char char_buffer;
    char array_buffer[kMaxDigits + 1]; // +1 for null byte
    int index = 0;
    bool value_flag = false;
    std::list<int> data;

    while((char_buffer = fgetc(stdin)) != EOF) {
        if('0' <= char_buffer && char_buffer <= '9') {
            value_flag = true;
            array_buffer[index] = char_buffer;
            index++;
        } else if(char_buffer == ' ' || char_buffer == '\n') { // clear buffer
            if(value_flag) {
                value_flag = false;
                array_buffer[index] = '\0';
                data.push_back(atoi(array_buffer));
            } else {
                do_operation(data, array_buffer[0]); // index should be 1 at this time
            }
            index = 0;
        } else if(char_buffer == '+' || char_buffer == '-' || char_buffer == '*' || char_buffer == '/') {
            array_buffer[index] = char_buffer;
            index++;
        } else {
            fputs("Error: Invalid character\n", stderr);
            exit(EXIT_FAILURE);
        }
    }

    printf("%d\n", data.front());
    return 0;
}

Measured memory_bytes: 3228
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int NA = Reader.Int();
        var dic = new DefaultValueDic<int>();
        foreach (int a in Reader.IntArray(NA)) dic[a]++;
        int NB = Reader.Int();
        foreach (int b in Reader.IntArray(NB))
            if (--dic[b] < 0) { Console.WriteLine("NO"); return; }
        Console.WriteLine("YES");
    }
}

public class DefaultValueDic<K> : Dictionary<K, int>
{
    public new int this[K key]
    {
        get { return ContainsKey(key) ? base[key] : 0; }
        set { base[key] = value; }
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { Dispose(); A = new string[0]; }
    public static void Set(TextReader r) { Init(); reader = r; }
    public static void Set(string file) { Init(); reader = new StreamReader(file); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    public static void Dispose() { reader.Dispose(); }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

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

g = [[-1 for j in range(n)] for i in range(n)]

for i in range(n):
	a = int(input())
	for _ in range(a):
		x, y = map(int, input().split())
		g[i][x-1] = y

ans = 0
for s in range(2**n):
	ok = True
	for i in range(n):
		if (s>>i&1) == 1:
			for j in range(n):
				if g[i][j] == -1: continue
				if (s>>j&1) != g[i][j]: ok = False
	if ok:
		ans = max(ans, bin(s).count("1"))

print(ans)


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

long long int countP(vector<long long int>& num_level, vector<long long int>& pnum, int level, long long int x){
    long long int ans = 0;
    if(num_level[level] == x){
        ans = pnum[level];
    }else{
        if(x-num_level[level-1]-2 > 0){
            ans = pnum[level-1];
            ans += 1;
            ans += countP(num_level, pnum, level-1, x-num_level[level-1]-2);
        }else if(x-num_level[level-1]-2 == 0){
            ans = pnum[level-1];
            ans += 1;
        }else if(x-num_level[level-1]-1 == 0){
            ans = pnum[level-1];
        }else if(x-1 > 0){
            ans = countP(num_level, pnum, level-1, x-1);
        }else{
            if(level == 0) ans = 1;
            else ans = 0;
        }
    }
    return ans;
}

int main(){
    long long int n, x;
    cin >> n >> x;
    vector<long long int> num_level(n+1);
    vector<long long int> pnum(n+1);
    num_level[0] = 1;
    pnum[0] = 1;
    for(int i = 1; i <= n; i++){
        num_level[i] = 3+2*num_level[i-1];
        pnum[i] = 1+2*pnum[i-1];
    }

    cout << countP(num_level, pnum, n, x);
    return 0;
}

Measured memory_bytes: 256
n, m = map(int,input().split())

kss = [list(map(int, input().split())) for _ in range(m)]

p = list(map(int, input().split()))
    
cnt = 0
    
for i in range(2**n):
    bin_i = "{:010b}".format(i)[::-1]
    
    for j in range(m):
        ks = kss[j]
        k = ks[0]
        s = ks[1:]
        
        sum_s = 0
        
        for x in range(k):
            sum_s += int(bin_i[s[x]-1])
            
        if sum_s % 2 != p[j]:
            break
    else:
        cnt += 1
        
print(cnt)

    


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

int main(){
	int n,m,l,r ;
	cin >> n >> m ;
	l = 0 ; r = 10000000 ;
	for(int i=0;i<m;i++){
		int subl,subr ;
		cin >> subl >> subr ;
		l = max(l,subl) ;
		r = min(r,subr) ;
	}
	cout << max(0,r-l+1) << endl ;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
#define N 100002
#define MOD 1000000007
vector <int> v[N];
bool viz[N];

void dfs(int n, int i, long long &dpa, long long &dpn) {
    viz[i] = true;
    long long da = 1, dn = 1;
    for (int j : v[i]) {
        if (!viz[j]) {
            dfs(n, j, dpa, dpn);
            da = da * (dpa + dpn) % MOD;
            dn = dn * dpa % MOD;
        }
    }
    dpa = da;
    dpn = dn;
}

int main() {
    int n;
    cin >> n;
    for (int i = 1; i < n; i ++) {
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    int root = 0;
    for (int i = 1; i <= n && root == 0; i ++) {
        if (v[i].size() == 1) {
            root = i;
        }
    }
    long long dpa = 0, dpn = 0;
    dfs(n, root, dpa, dpn);
    cout << (dpa + dpn) % MOD;
    return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  for (int i = a; i <= b; ++i) {
    string s = to_string(i);
    string t = s;
    reverse(rng(t));
    if (s == t) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
  ll n, m;
  string s, t;
  cin >> n >> m >> s >> t;
  ll d = gcd(n, m);
  bool is_good = true;
  for (ll i = 0; i < d; i++) is_good &= s[n / d * i] == t[m / d * i];
  cout << (is_good ? n * m / d : -1) << endl;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int main(){
    long double n,m,d;
    cin >> n >> m >> d;
    long double ans = (n-d) * 2 * (m-1) / (n*n);
    if(d==0) ans/=2;
    cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 3756
#include <vector>
#include <algorithm>
#include <cstdio>
int x[100001],d[100001],c[100001];

int lis(int n){
	int i,j,I;
/*
	for(i=-1;I=0,++i<n;d[i]=I+1)
		for(j=i-1;~j;j--)
			if(x[j]<x[i]&&I<d[j])I=d[j];
*/
	// http://stackoverflow.com/questions/6129682/longest-increasing-subsequenceonlogn
	int sz = 1;
	c[1] = x[0];
	d[0] = 1;
	for(i=0;++i<n;){
		if(x[i] < c[1]){
			c[1] = x[i];
			d[i] = 1;
		}else if(x[i] > c[sz]){
			c[sz+1] = x[i];
			d[i] = sz+1;
			sz++;
		}else{
			int k = std::lower_bound(c,c+sz,x[i])-c;
			c[k] = x[i];
			d[i] = k;
		}
	}
	for(i=j=0;i<n;i++)
		if(d[i]>d[j])j=i;
	return d[j];
}

int n;
int main(){
	for(;;){
		n=0;
		std::vector<std::pair<int,int>>v;
		int a,b;
		for(int k=0;k<2;k++){
			int n0;
			if(scanf("%d",&n0),!n0)return 0;
			for(n+=n0;n0--;){
				scanf("%d%d",&a,&b);
				v.emplace_back(a,-b);
			}
		}
		std::sort(v.begin(),v.end());
		for(int i=0;i<n;i++)x[i]=-v[i].second;
		printf("%d\n",lis(n));
	}
}

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

using namespace std;

const int MAX_N = 1000000;

int N;

int len;
int prime[MAX_N];				//save all prime number less than MAX_N
bool isPrime[MAX_N];

void sieve(){
	//init
	fill(isPrime, isPrime + MAX_N, true);
	isPrime[0] = isPrime[1] = false;
	
	for(int i = 2; i < MAX_N; i ++){
		if(isPrime[i]){
			prime[len ++] = i;
			for(int j = 2 * i; j < MAX_N; j += i)
				isPrime[j] = false;
		}
	}
}

void solve(){
	for(int i = len - 1; i >= 0; i --){
		if(N >= prime[i]){
			printf("%d\n", i+1);
			return;
		}
	}
	printf("0\n");
}

int main(int argc, char const *argv[]){

	sieve();
	while(scanf("%d", &N) != EOF){
		solve();
	}

	return 0;
}

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

int main()
{
    unsigned int N;
    cin >> N;
    int64_t sum0 = 2;
    int64_t sum1 = 1;
    int64_t sum2 = sum0 + sum1;      // L2 = L1 + L0

    if (N==1)
    {
        cout << 1 << endl;
    }

    else
    {
        for (int i = 0; i < N-1; i++)
        {
            sum2 = sum1 + sum0;      // L2 = L0 + L1
            sum0 = sum1;            // L0 <- L1
            sum1 = sum2;             // L1 <- L2
            //cout << sum0 << sum1 << sum2 << endl;
        }
        
        cout << sum2 << endl;
    }
}

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

int main(){
	int H,W;
	while(1){
		cin >> H >> W;
		if(H == 0 && W == 0)break;
		for(int i = 0;i < H;i++){
			for(int j = 0;j < W;j++){
				if(j == 0 || j == W-1 || i == 0 || i == H-1)cout << "#";
				else{cout << ".";}
			}
			cout << endl;
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3004
N, K= map(int, input().split())

if N%2==0:
    max_num=N//2
    if max_num>=K:
        print("YES")
    else:
        print("NO") 
else:
    max_num=N//2+1
    if max_num>=K:
        print("YES")
    else:
        print("NO")

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

int f(int a){
  int q = 0;
  while(a%2 == 0){
    a = a/2;
    q++;
  }
  return q;
}

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i =0;i <N;i++){
    cin >> a[i];
    a[i] = f(a[i]);
  }
  int ans = 100000;
  for(int i =0;i <N;i++){
    ans = min(ans,a[i]);
  }
  cout << ans << endl;
}

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

#define ll long long int
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define loop(i,x,n) for(int i=x;i<n;i++)
#define arr 1000005
#define F first
#define S second
#define pii pair<int,int>

const int modu=1e9+7;
ll mod(ll n){
    return (n%modu);
}

bool cmp(ll a,ll b){
    return a>b;
}

int main() {
    FIO
    map<ll,ll> m;
    ll n;
    cin>>n;
    loop(i,1,n){
        ll x;
        cin>>x;
        m[x]++;
    }
    loop(i,1,n+1){
        cout<<m[i]<<"\n";
    }
	return 0;
}


Measured memory_bytes: 15664
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}
void YES(bool ok){
    cout << (ok ? "Yes" : "No") << endl;
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<Pll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i].first;
        a[i].second = i;
    }
    vector<Pll> b(n);
    for(int i = 0; i < n; i++){
        cin >> b[i].first;
        b[i].second = i;
    }

    sort(all(a));
    sort(all(b));
    debug(a, b);
    bool ok = true;
    rep(i,0,n){
        ok &= b[i].first >= a[i].first;
    }
    if(!ok){
        YES(false);
        return 0;
    }
    ok = false;
    rep(i,0,n-1){
        if(b[i].first >= a[i+1].first) ok = true;
    }

    vector<ll> p(n);
    rep(i,0,n){
        p[a[i].second] = b[i].second;
    }

    ll x = 0;
    ll cnt = 0;
    x = p[0];cnt++;
    while(x){
        x = p[x];
        cnt++;
    }

    if(cnt != n) ok = true;
    debug(cnt);
    YES(ok);
}

Measured memory_bytes: 4224
#include <stdio.h>
#include <math.h>
int main(void){
  int N;
  int A[101];
  int i,j;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  int max;
  max=abs(A[0]);
  int min;
  min=abs(A[0]);
  for(i=0;i<N;i++){
    if(abs(A[i])>max){
      max=abs(A[i]);
    }
    else if(abs(A[i])<min){
      min=abs(A[i]);
    }
   }
   int s=max-min;
   printf("%d",s);
   return 0;
            }

Measured memory_bytes: 1732
#include <iostream>
using namespace std;
int main(){
    int h,w;
    while(1){
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        for(int j = 0;j < w; j++){
        if((i+j)%2==0){ 
        cout << '#';
        }else cout << '.';
        }
        cout << "\n";
}
      if(h==0 && w==0) break;
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 3008
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    string s;cin>>s;
    rep(i,s.size()){
        if(s[i]=='?'){
            s[i]='D';
        }
    }
    cout<<s<<endl;
    return 0;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> length(N);
    int total_length = 0;

    for(int i=0; i<N; i++) cin >> length[i];
    sort(length.begin(), length.end());
    reverse(length.begin(), length.end());
    for(int i=0; i<K; i++) total_length += length[i];
    cout << total_length << endl;
}

Measured memory_bytes: 3544
n = gets.to_i
v_array = gets.chomp.split(" ").map(&:to_i)

v_sliced = v_array.each_slice(2)
v_odd = v_sliced.map(&:first)
v_even = v_sliced.map(&:last)

v_odd_g = v_odd.group_by { |e| e }.sort_by { |e| - e[1].length }
v_even_g = v_even.group_by { |e| e }.sort_by { |e| - e[1].length }

if v_odd_g[0][0] != v_even_g[0][0]
    puts n - v_odd_g[0][1].length - v_even_g[0][1].length
else
    r1 = v_odd_g[0][1].length + (v_even_g[1] ? v_even_g[1][1].length : 0)
    r2 = (v_odd_g[1] ? v_odd_g[1][1].length : 0) + v_even_g[0][1].length
    puts n - [r1, r2].max
end


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

int main() {
  int X,Y;
  cin >> X >> Y;
  
  int b=Y-2*X;
  int a=4*X-Y;
  
  if(a>=0 && b>=0){
    if((b%2==0) &&  (a%2==0)){
      cout << "Yes" <<endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    cout << "No" << endl;
  }

}

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

typedef long long ll;
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
#define rep(i, n) for(int i = 0; i < n; i++)
#define fogg(i,a,b) for(int i = (a); i <= (b); i++)
#define ford(i,a,b) for(int i = (a); i >= (b); i--)
#define test int t; cin >> t; while(t--)
#define debug(x) cout << '>' << #x << ':' << x << "\n";
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair



int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i,n){
        cin >> a[i];
    }
    sort(a,a+n);
    double ans=a[0];
    for(int i=1;i<n;i++){
        ans+=double(a[i]);
        ans/=2;
    }
    cout << ans;
return 0;
}

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

#define MAX 200010
#define MOD 1000000009

using namespace std;
typedef long long int lli;
typedef pair<int,int> pii;

int primes[] = {31 , 41};

int n;

char v[MAX];

lli pot[MAX][3];
lli Phash[MAX][3];

map< pii , int > marc;

int val(char a) { return a - 'a'; }

void makeHash(int t)
{
	for(int i = 1 ; i <= n ; i++)
	{
		Phash[ i ][ t ] = primes[ t ] * Phash[ i - 1 ][ t ] + val( v[i - 1] );
		Phash[ i ][ t ] %= MOD;	
	}
}

void makePow(int t)
{
	pot[ 0 ][ t ] = 1;

	for(int i = 1 ; i <= n ; i++)
	{
		pot[ i ][ t ] = primes[ t ] * pot[ i - 1 ][ t ];
		pot[ i ][ t ] %= MOD;
	}
}

lli substringHash(int i, int j, int p) 
{ 
	lli s1 = Phash[j][p];
	lli s2 = (pot[j - i + 1][p] * Phash[i - 1][p])%MOD;

	return ((s1 - s2)%MOD + MOD)%MOD; 
}

bool test(int k)
{
	marc.clear();

	for(int i = 1 ; i + k - 1 <= n ; i++)
	{
		int s1 = substringHash(i , i + k - 1 , 0);
		int s2 = substringHash(i , i + k - 1 , 1);

		if( marc[ { s1 , s2 } ] == 0 ) marc[ { s1 , s2 } ] = i + k - 1;
		else if( marc[ { s1 , s2 } ] < i ) return true;
	}

	return false;
}

int bs()
{
	int l = 0;
	int r = n;

	while(l < r)
	{
		int m = (l + r)/2;
		if(l == r - 1) m = r;

		if( test( m ) ) l = m;
		else r = m - 1;
	}

	return l;
}

int main()
{
	scanf("%d %s",&n,v);

	for(int i = 0 ; i < 3 ; i++)
	{
		makePow( i );
		makeHash( i );
	}

	printf("%d\n",bs());
}

Measured memory_bytes: 2688
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
using namespace std;

int main() {
	string s;
	cin >> s;
	int i = 0;
	while (1) {
		int tmp = s.find('a'+i);
		if (tmp == -1) {
			char ans = 'a' + i;
			if (ans == '{') {
				cout << "None" << endl;
				break;
			}
			cout << ans << endl;
			break;
		}
		else {
			i++;
		}
	}
}

Measured memory_bytes: 512
#include<stdio.h>
#include<algorithm>
#define rpt(n) for(register int ttxyc=0;ttxyc<n;++ttxyc)
using namespace std;
main()
{
	int a[3];
	scanf("%d%d%d",a,a+1,a+2);
	sort(a,a+3);
	if(a[0]==5&&a[1]==5&&a[2]==7)printf("YES\n");
	else printf("NO\n");
}/**/

Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    string str;
    getline(cin,str);
    int nowsize=0;
    int flg=0;
    for(int i=0;i<=str.size();i++){
        if(i==str.size()){
            if(3<=nowsize&&nowsize<=6){
                if(flg)cout<<" ";
                for(int j=nowsize;0<j;j--){
                    if(str[i-j]!=','&&str[i-j]!='.')cout<<str[i-j];
                }
            flg=1;
            }
            nowsize=0;
        }
        else if(str[i]==' '||str[i]=='.'||str[i]==','){
            if(3<=nowsize&&nowsize<=6){
                if(flg)cout<<" ";
                for(int j=nowsize;0<j;j--){
                    if(str[i-j]!=','&&str[i-j]!='.')cout<<str[i-j];
                }
            flg=1;
            }
            nowsize=0;
        }
        else nowsize++;
    }
    puts("");
    return 0;
}

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

using namespace std;

int m, n, tr, cnta, cntb;
int a[100005], b[100005];

int lo(int start, int step) {
	return (start + step + n - 1) % n + 1;
}

int main() {
	cin >> n >> m;
	cnta = 1;
	cntb = n;
	for (int i = 0; i < m; i++) {
		if (i % 2 == 0) {
			a[i] = cnta;
			b[i] = lo(cnta, m - i);
			cnta++;
		}
		else {
			a[i] = cntb;
			b[i] = lo(cntb, i - m);
			cntb--;
		}
	}
	for (int i = 0; i < m; i++) {
		cout << a[i] << ' ' << b[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 4300