akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  vector<ll> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }

  // クイックソートがO(N logN)
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());

  ll ans = 0;
  queue<ll> q;
  // 一人目が到着
  // 一人目の心地よさを享受可能な座席は1つのみのため、キューに1座席追加
  q.push(v.at(0));
  for (int i = 1; i < n; i++) {
    // 1人到着したため、座席を1つ消費する
    ans += q.front();
    q.pop();

    // 二人目以降が到着すると、両隣に座席ができる
    // 心地よさは二座席分享受できるため、キューに2座席分追加
    ll num = v.at(i);
    q.push(num);
    q.push(num);
  }

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


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

using namespace std;

int main()
{
	int x,y;
	cin>>x>>y;
	if(x%y!=0)
	cout<<x<< endl;
	else if(x*2%y!=0)
	cout<< x*2<< endl;
	else cout<< -1<< endl;

	return 0;
}


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

int main(){
    ll n,y;
    cin>>n>>y;
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=n;j++){
            ll k=n-(i+j);
            if(k>=0){
                if((i*10000+j*5000+k*1000)==y){
                    cout<<i<<' '<<j<<' '<<k<<endl;
                    return 0;
                }
            }
        }
    }
    
    cout<<-1<<' '<<-1<<' '<<-1<<endl;
    return 0;
}

Measured memory_bytes: 256
// 2019年08月28日 (水曜日) 14:39:33
#include <bits/stdc++.h>
using namespace std;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

int main() {
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    // // cout << fixed << setprecision(5);

    int n;
    cin >> n;
    int a[200000], s[200000];

    rep(i, n) {
        cin >> a[i];
        s[i] = a[i];
    }

    sort(s, s + n, greater<int>());
    rep(i, n) { cout << (s[0] == a[i] ? s[1] : s[0]) << endl; }

    return 0;
}


Measured memory_bytes: 3200
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=tf-8
#

"""
"""

from collections import defaultdict
import bisect
from itertools import product
from collections import deque

import sys
input = sys.stdin.readline

def solve(h,w,ch,cw,dh,dw,s):
    d = [[10**7]*w for _ in range(h)]
    d[ch][cw] = 0
    dis0 = [(1,0),(0,1),(-1,0),(0,-1)]
    dis1 = [(i,j) for i,j in product(range(-2,3),range(-2,3)) if 1 < abs(i)+abs(j)]
    Q = deque([(ch,cw)])
    ans = -1
    while Q:
        pos1 = Q.pop()
        i, j = pos1
        if i == dh and j==dw:
            ans = d[dh][dw]
            break
        for pos2 in [(i+a,j+b) for a,b in dis0 if 0 <= i+a < h and 0 <= j+b <w and s[i+a][j+b]=="."]:
            k, l = pos2
            alt = d[i][j] 
            if d[k][l] > alt:
                d[k][l] = alt
                Q.append((k,l))
        for pos2 in [(i+a,j+b) for a,b in dis1 if 0 <= i+a < h and 0 <= j+b <w and s[i+a][j+b]=="."]:
            k, l = pos2
            alt = d[i][j]+1
            if d[k][l] > alt:
                d[k][l] = alt
                Q.appendleft((k,l))
    print(ans)



def main():
    h, w = list(map(int,input().split()))
    ch, cw = list(map(int,input().split()))
    dh, dw = list(map(int,input().split()))
    ch -= 1
    cw -= 1
    dh -= 1
    dw -= 1
    s = []
    for _ in range(h):
        s.append(list(input().rstrip()))
    solve(h,w,ch,cw,dh,dw,s)


if __name__ == "__main__":
    main()

Measured memory_bytes: 135616
#include <iostream>

using namespace std;

int main()
{
  int W,H,x,y;
  cin >> W >> H >> x >> y ;
  cout << ((double)W*H)/2.0 << " ";
  if( 2*x==W && 2*y==H )
    cout << 1 << endl;
  else
    cout << 0 << endl;    
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
//cerr
using namespace std;
signed main() {
	int a, b, c; cin >> a >> b >> c;
	if (a == b && b != c)cout << "Yes\n";
	else if (c == b && a != c)cout << "Yes\n";
	else if (a == c && b != c)cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

struct Point { int x, y; };

template<typename T> struct CumulativeSum2D
{
   vector<vector<T>> s;
   CumulativeSum2D(const vector<vector<T>>& v) {
      int M = v.size(), N = v[0].size();
      s.resize(M+1, vector<int>(N+1));
      for (int i = 0; i < M; i++) {
         for (int j = 0; j < N; j++) {
            s[i+1][j+1] = s[i+1][j] + v[i][j];
         }
      }
      for (int i = 0; i < M; i++) {
         for (int j = 0; j < N; j++) {
            s[i+1][j+1] += s[i][j+1];
         }
      }
   }
   int sum(int i, int j) {
      return s[i+1][j+1];
   }
   int sum(int i, int j, int k, int l) {
      return s[k+1][l+1] - s[i][l+1] - s[k+1][j] + s[i][j];
   }
};

signed main()
{
   int N, M, Q; cin >> N >> M >> Q;
   V<string> str(N);
   for (int i = 0; i < N; i++) {
      cin >> str[i];
   }
   V<Point> p1(Q), p2(Q);
   for (int i = 0; i < Q; i++) {
      cin >> p1[i].x >> p1[i].y >> p2[i].x >> p2[i].y;
      p1[i].x--; p1[i].y--; p2[i].x--; p2[i].y--; 
   }

   V<V<int>> S(N, V<int>(M));
   for (int i = 0; i < N; i++) {
      for (int j = 0; j < M; j++) {
         S[i][j] = str[i][j] - '0';
      }
   }
   CumulativeSum2D<int> s1(S);

   V<V<int>> w(N, V<int>(M)), h(N, V<int>(M));
   for (int i = 0; i < N; i++) {
      for (int j = 0; j+1 < M; j++) {
         if (S[i][j] && S[i][j+1]) {
            w[i][j] = 1;
         }
      }
   }
   for (int i = 0; i+1 < N; i++) {
      for (int j = 0; j < M; j++) {
         if (S[i][j] && S[i+1][j]) {
            h[i][j] = 1;
         }
      }
   }
   CumulativeSum2D<int> s2(w), s3(h);

   for (int i = 0; i < Q; i++) {
      cout << s1.sum(p1[i].x, p1[i].y, p2[i].x, p2[i].y)
            - s2.sum(p1[i].x, p1[i].y, p2[i].x, p2[i].y-1)
            - s3.sum(p1[i].x, p1[i].y, p2[i].x-1, p2[i].y) << endl;
   }

   return 0;
}


Measured memory_bytes: 200576
a = input()
b = input()
la = len(a)
lb = len(b)
if la < lb:
    print("LESS")
elif la > lb:
    print("GREATER")
else:
    cas = list(a)
    cbs = list(b)
    for i in range(la):
        if int(cas[i]) > int(cbs[i]):
            print("GREATER")
            exit()
        elif int(cas[i]) < int(cbs[i]):
            print("LESS")
            exit()
    print("EQUAL")




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

int main(){
  string a , b ;
  cin >> a >> b ; 
  string p = a+b ; 
  
  int x = stoi(p) ; 
  
  for(int i = 1 ; i <= sqrt(x) ; i++){
    if(i*i == x){
      cout << "Yes" << endl ; 
      return 0 ; 
    }
  }
  
  cout << "No" << endl ; 
  
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;

int main(){
  int N;
  cin>>N;
  vector<int> L(N);
  for (int i=0;i<N;i++) cin>>L[i];
  sort(L.begin(),L.end(),greater<int>());
  int sum;
  for (int i=1;i<N;i++) sum+=L[i];
  if (L[0]<sum) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s[51];

	//char s[100000];

	int ara[n_size],ara2[n_size];

	//vector<vector<int>>v(50,vector<int>(50,0));

	//vi v[50];

	//mem(v);

	cin>>n>>m;

	f(i,0,n-1){
        //f(j,0,m-1){
            cin>>s[i];
        //}
	}

    f(i,0,n-1){
        count=0;
        f(j,0,m-1){
            if(s[i][j]=='#') continue;
            if(j>0 && s[i][j-1]=='#') count++;
            if( j<m-1 && s[i][j+1]=='#') count++;
            if(i<n-1 && s[i+1][j]=='#') count++;
            if(i>0 && s[i-1][j]=='#') count++;
            if((i>0 && j>0) && s[i-1][j-1]=='#') count++;
            if((i>0 && j<m-1) && s[i-1][j+1]=='#') count++;
            if((i<n-1 && j>0) && s[i+1][j-1]=='#') count++;
            if((i<n-1 && j<m-1) && s[i+1][j+1]=='#') count++;

            //v[i][j]=count;

            s[i][j]='0'+count;

            //cout<<v[i][j];
            count=0;
        }
        //cout<<endl;
    }

    //cout<<endl;

//	f(i,0,n-1){
//        f(j,0,m-1){
//            if(s[i][j]=='.') cout<<v[i][j];
//            else if(s[i][j]='#') cout<<s[i][j];
//        }
//        cout<<endl;
//	}

	f(i,0,n-1){
        cout<<s[i]<<endl;
	}

}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int a[3];
  REP(i,3)cin>>a[i];
  sort(a,a+3);
  cout<<a[0]*a[1]/2<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace abc163
{
    class Program
    {
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var aStrList = Console.ReadLine().Split(' ');
            var numTable = new Dictionary<int, int>();
            foreach (var aStr in aStrList)
            {
                var a = int.Parse(aStr);
                if (numTable.ContainsKey(a))
                {
                    ++numTable[a];
                }
                else
                {
                    numTable.Add(a, 1);
                }
            }
            for (var i = 1; i <= n; ++i)
            {
                Console.WriteLine(numTable.ContainsKey(i) ? numTable[i] : 0);
            }
        }
    }
}


Measured memory_bytes: 43600
#include <stdio.h>

int main(void){
        long long int X,Y,r,z,tmp;

        scanf("%lld %lld ",&X,&Y);

        z = X * Y;

        if (X < Y){
                tmp = X;
                X = Y;
                Y = tmp;
        }

        r = X % Y;
        while (r != 0){
                X = Y;
                Y = r;
                r = X % Y;
        }

        printf("%lld\n", z / Y);

        return 0;
}


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

using namespace std;

namespace {

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        os << "[" << vs[0];
        for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
        return os << "]";
    }

    vector<int> R;
    void input() {
        R.clear();
        while (true) {
            int x; cin >> x;
            if (x == 0) break;
            R.push_back(x);
        }
    }

    vector< vector<int> > G;
    int N;
    vector<int> Z;

    void dfs(int v, int& c, int d, vector<int>& x, int& nv) {
        if (c == R.size()) return;
        //cout << v << " " << c << " " << d << " " << x << endl;
        int p = x[d];
        x[d] = v;
        while (c < R.size() && Z[v] > 0) {
            int r = R[c];
            if (r > 0) {
                G[v].push_back(nv);
                G[nv].push_back(v);
                Z[v]--; Z[nv]--;
                c++;
                int n = nv; nv++;
                dfs(n, c, d + 1, x, nv);
            } else {
                int n = x[d + r];
                //cout << "connect " << v << " " << n << endl;
                G[v].push_back(n);
                G[n].push_back(v);
                Z[v]--; Z[n]--;
                c++;
            }
        }
        x[d] = p;
    }

    void solve() {
        Z.clear();
        for (int i = 0; i < R.size(); i++) {
            int r = R[i];
            if (r > 0) {
                Z.push_back(r);
            }
        }
        N = int(Z.size());
        G.clear(); G.resize(N);
        vector<int> x(N, -1);
        int c = 1;
        int nv = 1;
        dfs(0, c, 0, x, nv);
        for (int i = 0; i < N; i++) {
            sort(G[i].begin(), G[i].end());
            int M = G[i].size();
            cout << i + 1;
            for (int j = 0; j < M; j++) {
                cout << " " << G[i][j] + 1;
            }
            cout << endl;
        }
    }
}

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; i++) {
        input(); solve();
    }
    return 0;
}

Measured memory_bytes: 1244
using System;
using System.Collections.Generic;

namespace LeetCodeProblem
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> numbers = GetList();

            if(numbers[0] <= numbers[1])
            {
                Console.WriteLine("unsafe");
            }
            else
            {
                Console.WriteLine("safe");
            }
        }

        private static List<int> GetList()
        {
            string[] array = Console.ReadLine().Split(" ");

            List<int> numbers = new List<int>();

            foreach(var ele in array)
            {
                numbers.Add(int.Parse(ele));
            }

            return numbers;
        }
    }
}


Measured memory_bytes: 27840
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>

using namespace std;

int main(void) {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	for (int i = 0; i < s.size() - 1; i++) {
		if (s[i] == s[i + 1]) {
			cout << "no";
			return 0;
		}
	}
	cout << "yes";
	return 0;
}

Measured memory_bytes: 384
// review
#include <iostream>
#include <algorithm>

using namespace std;
const int MAXN = 110;

struct point {
  int x, y;
};

int n;
point red[MAXN], blue[MAXN];
bool used[MAXN];

bool xcompare(point lhs, point rhs) {
  return lhs.x < rhs.x;
}

bool ycompare(point lhs, point rhs) {
  return lhs.y > rhs.y;
}

void solve() {
  sort(red, red + n, ycompare);
  sort(blue, blue + n, xcompare);

  int cnt = 0;
  for (int i=0;i<n;i++) {
    for (int j=0;j<n;j++) {
      if (blue[i].x > red[j].x && blue[i].y > red[j].y && !used[j]) {
        used[j] = true;
        cnt++;
        break;
      }
    }
  }

  cout << cnt << endl;
}

int main() {
  cin >> n;
  for (int i=0;i<n;i++) {
    cin >> red[i].x >> red[i].y;
  }
  for (int i=0;i<n;i++) {
    cin >> blue[i].x >> blue[i].y;
  }
  solve();
}


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

int main(){
 
  int N;
  int num;
  
  cin >> N;
  
  if(N < 10){
    num = 0;
    for(int i = 0;i < N;++i){
      ++num;
    }
    cout << num << endl;
  }
  
  else if(N >= 10 && N < 100){
    cout << 9 << endl;
  }
  
  else if(N >= 100 && N < 1000){
    num = 10;
    for(int i = 100;i < N;++i){
      ++num;
    }
    cout << num << endl;
  }
  
  else if(N >= 1000 && N < 10000){
    cout << 909 << endl;
  }
  
  else if(N >= 10000 && N < 100000){
    num = 910;
    for(int i = 10000;i < N;++i){
      ++num;
    }
    cout << num << endl;
  }
  
  else if(N == 100000){
    cout << 90909 << endl;
  }
}





Measured memory_bytes: 256
def resolve():
	N = int(input())
	A, B, C = [], [], []
	for _ in range(N):
		a, b, c = map(int, input().split())
		A.append(a), B.append(b), C.append(c)
	# dp_A[i]： i日目にAを選んで得られる最大の幸福度
	dp_A = [0] * N
	dp_B = [0] * N
	dp_C = [0] * N
	dp_A[0], dp_B[0], dp_C[0] = A[0], B[0], C[0]
	for i in range(1, N):
		dp_A[i] = max(dp_B[i-1], dp_C[i-1]) + A[i]
		dp_B[i] = max(dp_A[i-1], dp_C[i-1]) + B[i]
		dp_C[i] = max(dp_B[i-1], dp_A[i-1]) + C[i]
	print(max(dp_A[N-1], dp_B[N-1], dp_C[N-1]))
    
resolve()

Measured memory_bytes: 27076
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
char nn[55][55] = {0};
int main()
{ 
	int h,w;
	scanf("%d%d",&h,&w);
	int t,t1;
	for(t=1;t<=h;t++)
		scanf("%s",nn[t]+1);
	for(t=1;t<=h;t++)
	{
		for(t1=1;t1<=w;t1++)
		{
			if(nn[t][t1] == '.')
			{
				int s=0;
				if(nn[t-1][t1] == '#')	s++;
				if(nn[t+1][t1] == '#')	s++;
				if(nn[t][t1-1] == '#')	s++;
				if(nn[t][t1+1] == '#')	s++;
				if(nn[t-1][t1-1] == '#')	s++;
				if(nn[t-1][t1+1] == '#')	s++;
				if(nn[t+1][t1-1] == '#')	s++;
				if(nn[t+1][t1+1] == '#')	s++;
				printf("%d",s);
				
			}
			else
				printf("#");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int n;
cin >> n;
int a[n];
int i,ans=1,count=1;
for(i=1;i<n+1;i++) cin >> a[i];
while(1){
ans = a[ans];
if(ans==2) break;
count++;
if(a[ans]==1 or count>2*n){count=-1; break;}
}
cout << count <<endl;
}


Measured memory_bytes: 640
#include<algorithm>
#include<stack>
#include<ctime>
#include<cstring>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<queue>
using namespace std;
inline int read(){
	int num=0,f=1;char x=getchar();
	while(x<'0'||x>'9'){if(x=='-')f=-1;x=getchar();}
	while(x>='0'&&x<='9'){num=num*10+x-'0';x=getchar();}
	return num*f;
}
const int maxn=10005;
int f[maxn];
int main(){
	for(int i=1;i<=100;++i)
		for(int j=1;j<=100;++j)
			for(int k=1;k<=100;++k){
				int t=i*i+j*j+k*k+i*j+j*k+k*i;
				if(t>1e4)continue;
				++f[t];
			}
	int n=read();
	for(int i=1;i<=n;++i)printf("%d\n",f[i]);
	return 0;
}


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

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;

int main() {
    int n;  // 3*10e5;
    cin >> n;

    string s;
    cin >> s;
    vector<int> west(n, 0);
    vector<int> east(n, 0);
    int eastCnt = 0;
    rep(i, 0, n - 1) {
        if (s[i] == 'W') {
            west[i + 1] = west[i] + 1;
            east[i + 1] = east[i];
        } else {
            west[i + 1] = west[i];
            east[i + 1] = east[i] + 1;
            eastCnt++;
        }
    }
    if (s[n - 1] == 'E') {
        eastCnt++;
    }
    // for (int cnt : west) {
    //     cout << cnt << " ";
    // }
    // cout << endl;
    // for (int cnt : east) {
    //     cout << cnt << " ";
    // }
    // cout << endl;

    rep(i, 0, n) {
        if (i < n - 1) {
            if (east[i + 1] > east[i]) {
                eastCnt--;
            }
            east[i] = eastCnt;
        } else {
            east[i] = 0;
        }
    }
    // for (int cnt : east) {
    //     cout << cnt << " ";
    // }
    // cout << endl;

    int ans = n;
    rep(i, 0, n) {
        ans = min(ans, west[i] + east[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3076
#include <stdio.h>
int main(void)
{
char x[2] = {'#', '.'};
int W, H, i, j, n;

while(1) {

scanf("%d %d",&H,&W);

if(H == 0 && W == 0)
   break;


for(j = 0; H > j; j++){

i = j % 2;
n = 0;

while(W > n){
printf("%c", x[i % 2]);
n++;
i++;
}
printf("\n");
}
printf("\n");
}
return 0;
}

Measured memory_bytes: 1000
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstdlib>
using namespace std;

const int N = 4;

int u, v;
vector<int> adj[N];

void DFS(int u, int p = 0, int h = 0)
{
    if (h == 3)
    {
        printf("YES");
        exit(0);
    }
    for (int &v : adj[u])
        if (v != p)
            DFS(v, u, h + 1);
}

int main()
{
    for (int i = 1; i < N; i++)
    {
        scanf("%d%d", &u, &v);
        --u; --v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for (int i = 0; i < N; i++)
        DFS(i);
    printf("NO");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long H,W,h[2],w[2],h1[2],w1[2],ans,s1,s2,s3;
  cin>>H>>W;
  ans=H*W;
  if(H%3==0||W%3==0){cout<<0;return 0;}
  if(H>W){swap(W,H);}
  if(H==2){cout<<(abs(2*(W/3)-(W-W/3))>abs(2*(1+W/3)-(W-1-W/3))?abs(2*(1+W/3)-(W-1-W/3)):abs(2*(W/3)-(W-W/3)));return 0;}
  for(int i=1;i<W;i++){
    if(i*H<H*W/3&&W*H/3<(i+1)*H){w[0]=i,w[1]=i+1;break;}
  }
  h[0]=H/2,h[1]=h[0]+1;
  for(int i=1;i<H;i++){
    if(i*W<H*W/3&&W*H/3<(i+1)*W){h1[0]=i,h1[1]=i+1;break;}
  }
  w1[0]=W/2,w1[1]=w1[0]+1;
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      s1=h1[j]*W;s2=(H-h1[j])*w1[i];s3=H*W-s1-s2;
      if(s1>s2){swap(s1,s2);}
      if(s2>s3){swap(s2,s3);}
      if(s1>s2){swap(s1,s2);}
      if(s3-s1<ans){ans=s3-s1;}
    }
  }
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      s1=w[j]*H;s2=(W-w[j])*h[i];s3=H*W-s1-s2;
      if(s1>s2){swap(s1,s2);}
      if(s2>s3){swap(s2,s3);}
      if(s1>s2){swap(s1,s2);}
      if(s3-s1<ans){ans=s3-s1;}
    }
  }
  if(ans>H){ans=H;}
  else if(ans>W){ans=W;}
  cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<ll> > vvll;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
int main() {ll n,i,a=0,b=0,c=0,d=0;
cin>>n;
while(n--)
{string s;
	cin>>s;
	if(s=="AC")
	{
		a++;
	}
	else
	{
		if(s=="WA")
		{
			b++;
		}
		else
		{
			if(s=="TLE")
			{
				c++;
			}
			else
			{
				d++;
			}
			
		}
	}
}
cout<<"AC x "<<a<<endl<<"WA x "<<b<<endl<<"TLE x "<<c<<endl<<"RE x "<<d<<endl;
	
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD=1000000007;
using Graph = vector<vector<int>>;

int cut(int a, int b) {//切り捨て
    return (a - a % b) / b;
}
int up(int a, int b) {
    return (a + a % b) / b;
}

int k, n;
int a[200005];
int maxer, maxi = 0;
int ans = 0;
int len[200005];
int main() {
    cin >> k >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    len[0] = k - a[n - 1] + a[0];
    maxer = len[0];
    for (int i = 1; i < n; i++) {
        len[i] = a[i] - a[i - 1];
        if (maxer < len[i]) {
            maxer = len[i];
            maxi = i;
        }
    }
    len[maxi] = 0;
    for (int i = 0; i < n; i++) {
        ans += len[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<math.h>

int main() {
	int n;
	char a[101], b[101], ans[201];

	scanf("%d", &n);
	scanf("%s %s", a, b);
	for (int i = 0; i < n; i++) {
		ans[2 * i] = a[i];
		ans[2 * i + 1] = b[i];
	}
	for (int i = 0; i < 2 * n; i++) {
		printf("%c", ans[i]);
	}
}

Measured memory_bytes: 128
import java.util.*;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		String arr[] = new String[K];
		
		for(int i = 0;i<K;i++) {
			arr[i] = sc.next();
		}
		
		loops : for(int i = N;i < 100000;i++) {
			String ans = String.valueOf(i);
			for(String a : arr) {
				if(ans.contains(a)) {
					continue loops;
				}
			}
			System.out.println(i);
			break;
		}
	}
}


Measured memory_bytes: 26452
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	ans := 1
	for i := 0; i < n; i++ {
		ans += min(ans*2-ans, k)
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n, a, b;
    cin >> n >> a >> b;
    Int res = (n / (a + b)) * a;
    n %= (a + b);
    res += min(a, n);
    dump(res);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
long long n, k, a[100005];
int main() {
	int i;
	scanf("%d", &n);
	for (i=1; i<=n; i++) scanf("%d", &a[i]);
	sort(a+1, a+n+1);
	for (i=1; i<n-1; i++) {
		a[i] += a[i-1];
		if (a[i]*2 < a[i+1]) k = i;
	}
	printf("%d", n-k);
	return 0;
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/rope"
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
#define lambdify(x) [&](auto &&...args){ return x(forward<decltype(args)>(args)...); }
template<typename T, typename U> T &ctmax(T &x, const U &y){ return x = max<T>(x, y); }
template<typename T, typename U> T &ctmin(T &x, const U &y){ return x = min<T>(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for(auto i = 0; i < n; ++ i){
		cin >> a[i] >> b[i];
	}
	sort(a.begin(), a.end()), sort(b.begin(), b.end());
	if(n % 2){
		int x = a[n / 2], y = b[n / 2];
		cout << max(x, y) - min(x, y) + 1;
	}
	else{
		int x = a[n / 2 - 1] + a[n / 2], y = b[n / 2 - 1] + b[n / 2];
		cout << max(x, y) - min(x, y) + 1;
	}
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 4820
N = gets.chomp.to_i
aAry = gets.chomp.split.map(&:to_i)
Q = gets.chomp.to_i

# 各Qで毎回 Array#sum するとそれ自体にループが含まれるので最大 100,000 アイテムの 2重ループになってダメ。
# 初期値の合計を取っておいて、毎回のQでは変化した要素の分だけ引いたり足したりしてやる。
nAry = Array.new(10 ** 5 + 1, 0)

aAry.each do |a|
    nAry[a] += 1
end

ans = 0
nAry.size.times { |n| ans += n * nAry[n] }

Q.times do
    b, c = gets.chomp.split.map(&:to_i)
    if nAry[b] != 0 then
        ans -= b * nAry[b]
        ans -= c * nAry[c]
        nAry[c] += nAry[b]
        nAry[b] = 0
        ans += c * nAry[c]
    end
    puts ans
end


Measured memory_bytes: 22648
#include <iostream>
using std::cin, std::cout, std::endl, std::string, std::min;

int main()
{
    int n; cin >> n;
    string c; cin >> c;

    int W2R = 0; // 白 → 赤に変える数
    int R2W = 0;     // 赤 → 白に変える数
    for (int i = 0;i < n; ++i)
        if(c[i]=='R') R2W++; // 初期値は赤い石の数

    auto needed = [](int a, int b){return a+b-(min(a,b));};
    // 必要な手数は W2R と R2W の計 - ペアで変えれる数（min(W2R, R2W))
    auto ans = needed(W2R,R2W);
    for (int i = 0;i < n; ++i){
        if (c[i] == 'R') R2W--; else W2R++;
        ans = min(ans, needed(W2R,R2W));
    }

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


Measured memory_bytes: 3756
import collections

N = int(input())
list = list(map(int,input().strip().split()))
list_c = collections.Counter(list)
odd_list = []
even_list = []

if N == list_c.most_common()[0][1]:
    ans = N//2

else:
    for i in range(N//2):
        odd_list.append(list[2*i-2])
        even_list.append(list[2*i-1])

    odd_list_c = collections.Counter(odd_list)
    even_list_c = collections.Counter(even_list)

    if odd_list_c.most_common()[0][0] == even_list_c.most_common()[0][0]:
        num = odd_list_c.most_common()[0][1] + even_list_c.most_common()[1][1]
        cnt = odd_list_c.most_common()[1][1] + even_list_c.most_common()[0][1]
        cnt = max(num,cnt)
        ans = N - cnt
    else:
        cnt_odd = odd_list_c.most_common()[0][1]
        cnt_even = even_list_c.most_common()[0][1]
        cnt = cnt_odd + cnt_even
        ans = N - cnt

print(ans)


Measured memory_bytes: 26844
from collections import Counter

S = list(input())
c = Counter(S)

ans = True

if (c["N"]> 0 and c["S"] == 0) or (c["N"]== 0 and c["S"] > 0) or (c["W"] > 0 and c["E"] == 0) or (c["W"] == 0 and c["E"] > 0):
    ans = False

if ans:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#define ll long long
using namespace std;

int main()
{
  ll n, sp;
  cin >> n >> sp;
  ll arr[n + 1];
  for (int i = 0; i < n; i++)
  {
    cin >> arr[i];
  }
  sort(arr, arr + n, greater<long>());
  if (sp > n)
  {
    cout << 0;
  }
  else
  {
    ll total = 0;
    for (int i = sp; i < n; i++)
      total += arr[i];
    cout << total;
  }
  return 0;
}

Measured memory_bytes: 1792
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort((x).rbegin(),(x).rend())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
template<class T>bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
// clang-format on

multimap<ll, ll> prime_factor_r(int64_t n) {
  multimap<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    ll c = 0;
    while (n % i == 0) {
      c++;
      n /= i;
    }
    ret.insert(mp(c, i));
  }
  if (n != 1)
    ret.insert(mp(1, n));
  return ret;
}

map<int64_t, int> prime_factor(int64_t n) {
  map<int64_t, int> ret;
  for (int64_t i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

void solve(long long N) {
  ll ans = 0;
  for (auto p : prime_factor(N)) {
    ll dim = p.second;
    for (ll div = 1; div <= dim; div++) {
      ans++;
      dim -= div;
    }
  }
  ANS(ans);
  // ll ans = 0;
  // for (ll i = 2; i * i <= N; i++) {
  //   ll n = N, c = 0;
  //   while (n % i == 0) {
  //     c++;
  //     n /= i;
  //   }
  //   if (c > ans)
  //     ans = c;
  // }
  // ANS(ans);
}

// clang-format off
int main() {
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define endl			"\n"
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <ll,ll>
#define vii				vector <ii>
#define ull				unsigned long long
const double PI = 2 * acos(0.0);
void run() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
}
const int N = 1e6 + 5;

int main() {
	run();
	int n;
	cin >> n;
	vi v(n);
	int fr = 0, sec = 0;
	multiset<int, greater<int>> ms;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		ms.insert(v[i]);

	}
	for (int i = 0; i < n; i++) {
		auto it = ms.lower_bound(v[i]);
		int val = *it;
		ms.erase(it);
		cout << *ms.begin() << endl;
		ms.insert(val);
	}
}


Measured memory_bytes: 11776
#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 vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,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 rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll 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 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;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
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;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,q;
	string s;
	cin>>n>>q>>s;
	vi a(n,0);
	rep(i,n-1){
		if(s[i]=='A' and s[i+1]=='C')a[i+1]=1;
	}
	partial_sum(all(a),a.begin());
	rep(i,q){
		int l,r;
		cin>>l>>r;
		puta(a[r-1]-a[l-1]);
	}
	return 0;
}

Measured memory_bytes: 1488
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N,M; cin>>N>>M;
    string s,t; cin>>s>>t;
    ll tmp=lcm(N,M);
    ll A=tmp/M,B=tmp/N;
    bool ans=true;
    rep(i,gcd(N,M)){
        if(s[A*i]!=t[B*i]) ans=false;
    }
    if(ans) cout<<lcm(N,M)<<endl;
    else cout<<-1<<endl;
}



Measured memory_bytes: 3708
c="w kstnhmyr"
v="aiueo"
d=["T","L","U","R","D"]
f=[]
a=input()
for i in range(0,len(a),2):
    b=int(a[i])
    e=d.index(a[i+1])
    if b==0 and e==2: f+='nn'
    elif b==1: f+=v[e]
    else:f+=c[b]+v[e]
print("".join(f))

Measured memory_bytes: 7700
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	string s; cin >> s;
	int ans = 0; char c = s[0];
	for (auto i : s)
	{
		if (i != c)
		{
			c = i;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, k, x1, y1, x2, y2;
    cin >> n >> m >> k >> x1 >> y1 >> x2 >> y2; x1--; y1--; x2--; y2--;
    vector<string> s(n);
    vector<vector<vector<ll>>> d(n);
    priority_queue<pair<pair<ll, int>, pii>, vector<pair<pair<ll, int>, pii>>, greater<pair<pair<ll, int>, pii>>> q;
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int i = 0; i < n; i++) {
        d[i].resize(m);
        for (int j = 0; j < m; j++) {
            for (int l = 0; l < 4; l++) d[i][j].push_back(1ll * mod * mod);
        }
    }
    for (int i = 0; i < 4; i++) q.push(make_pair(make_pair(0, i), make_pair(x1, y1))), d[x1][y1][i] = 0;
    while (!q.empty()) {
        int w = q.top().first.second, x = q.top().second.first, y = q.top().second.second;
        //cout << x << ' ' << y << ' ' << w << '\n';
        q.pop();
        int u = k - d[x][y][w] % k + 1;
        vector<int> v = {u, u, u, u};
        if (u == k + 1) v = {1, 1, 1, 1};
        v[w] = 1;
        if (x && s[x - 1][y] == '.' && d[x - 1][y][0] > d[x][y][w] + v[0]) {
            d[x - 1][y][0] = d[x][y][w] + v[0];
            q.push(make_pair(make_pair(d[x - 1][y][0], 0), make_pair(x - 1, y)));
        }
        if (y && s[x][y - 1] == '.' && d[x][y - 1][1] > d[x][y][w] + v[1]) {
            d[x][y - 1][1] = d[x][y][w] + v[1];
            q.push(make_pair(make_pair(d[x][y - 1][1], 1), make_pair(x, y - 1)));
        }
        if (x + 1 < n && s[x + 1][y] == '.' && d[x + 1][y][2] > d[x][y][w] + v[2]) {
            d[x + 1][y][2] = d[x][y][w] + v[2];
            q.push(make_pair(make_pair(d[x + 1][y][2], 2), make_pair(x + 1, y)));
        }
        if (y + 1 < m && s[x][y + 1] == '.' && d[x][y + 1][3] > d[x][y][w] + v[3]) {
            d[x][y + 1][3] = d[x][y][w] + v[3];
            q.push(make_pair(make_pair(d[x][y + 1][3], 3), make_pair(x, y + 1)));
        }
    }
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < n; j++) {
            //for (int l = 0; l < m; l++) cout << d[j][l][i] << ' ';
            //cout << '\n';
        }
        //cout << '\n';
    }
    ll z = min({d[x2][y2][0], d[x2][y2][1], d[x2][y2][2], d[x2][y2][3]});
    if (z == 1ll * mod * mod) cout << -1;
    else cout << (z - 1) / k + 1;
}


Measured memory_bytes: 81056
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < (int)(n);++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<int>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()


void fastik() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}
const double eps = 1e-9;
//ifstream &cin
double getDist(vll a,vll b){
    double f = 0;
    forn(i,sz(a)){
        f += pow(a[i] - b[i],2);
    }
    return pow(f,0.5);
}
int main() {
    fastik();
    ll n; cin >> n;
    ll d; cin >> d;
    vvll x(n,vll(d,0));
    forn(i,n){
        forn(j,d){
            cin >> x[i][j];
        }
    }
    ll ans=0;
    double lf;
    ll dist;
    forn(i,n-1){
        fore(j,i+1,n-1){
           lf = getDist(x[i],x[j]);
           dist = ll(lf);
           if(abs(dist-lf) < eps){
               ans++;
           }
        }
    }
    cout << ans;
}

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

long long int N, s, d, i, j, k, b, c;
long long int m[5] = {0x55555555, 0x33333333, 0xF0F0F0F, 0xFF00FF, 0xFFFF};

inline long long int R(long long int a){
    int ret = 16;
    for(k = 16; k >= 1; k >>= 1){
        if(a & (((1 << k) - 1) << ret)){
            ret += (k >> 1);
        }else{
            ret -= k == 1 ? 1 : (k >> 1);
        }
    }
    return ret;
}

int main(){
    scanf("%lld", &N);
    for(; i < N; i++){
        scanf("%lld%lld", &s, &d);
        if(s * d > 0){
            if(s < 0){s = -s; d = -d; swap(s, d);}
            c = R(s ^ d);
            s = (s & (1 << (c + 1)) - 1) - (1 << c);
            d = (d & (1 << (c + 1)) - 1) - (1 << c);
        }
        s = -s;
        s = (s & 1431655765) + ((s >> 1) & 1431655765);
        d = (d & 1431655765) + ((d >> 1) & 1431655765);
        s = (s & 858993459) + ((s >> 2) & 858993459);
        d = (d & 858993459) + ((d >> 2) & 858993459);
        s = (s & 252645135) + ((s >> 4) & 252645135);
        d = (d & 252645135) + ((d >> 4) & 252645135);
        s = (s & 16711935) + ((s >> 8) & 16711935);
        d = (d & 16711935) + ((d >> 8) & 16711935);
        s = (s & 65535) + ((s >> 16) & 65535);
        d = (d & 65535) + ((d >> 16) & 65535);
        cout << s + d << endl;
    }
    return 0;
}

Measured memory_bytes: 3228
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
//#include <bits/stdc++.h>
#include <cassert>
using namespace std;

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

const int maxn = 1e5+1;
int a[3][maxn];
ll s[3][maxn];
int n;
int main()
{
    scanf("%d", &n);
    for (int k = 0; k < 3; ++k)
    {
        for (int i = 1; i <= n; ++i)
            scanf("%d", &a[k][i]);
        sort(a[k]+1, a[k]+n+1);
    }
    for (int i = 1; i <= n; ++i)
        s[0][i] = 1+s[0][i-1];
    for (int k = 1; k < 3; ++k)
        for (int i = 1; i <= n; ++i)
            s[k][i] = s[k][i-1] + s[k-1][(lower_bound(a[k-1]+1, a[k-1]+n+1, a[k][i])-a[k-1]-1)];
    printf("%lld\n", s[2][n]);
    return 0;
}


Measured memory_bytes: 3712
(* unihernandez22
 * https://atcoder.jp/contests/abc173/tasks/abc173_b
 * implementation
 * *)

include Printf;;

Scanf.scanf "%d\n" @@ fun n ->
    let s = Array.init n @@ fun _ -> Scanf.scanf "%s\n" @@ fun x -> x in
    let c = Array.init 4 @@ fun _ -> ref 0 in
    for i = 0 to n-1 do
        if s.(i) = "AC" then c.(0) := !(c.(0)) + 1
        else if s.(i) = "WA" then c.(1) := !(c.(1)) + 1
        else if s.(i) = "TLE" then c.(2) := !(c.(2)) + 1
        else c.(3) := !(c.(3)) + 1
    done;
    printf "AC x %d\n"  !(c.(0));
    printf "WA x %d\n"  !(c.(1));
    printf "TLE x %d\n" !(c.(2));
    printf "RE x %d\n"  !(c.(3));


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

int main() {
	int a[100],num;
	cin >> num;
	for(int i=0;i<num;i++){
	    cin >> a[i];
	}
	for(int i=0;i<num-1;i++){
    	cout << a[num-i-1] << " ";
	}
    cout << a[0]<<endl;
}

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

int main()
{

    long long  n , m;
    cin >> n >> m;
    vector<pair<long long  , long long >>all(n);
    long long  req = 0;

    for(long long  i = 0; i < n; i++)
    {
        long long  a , b;
        cin >> a >> b;
        all[i].first = a;
        all[i].second = b;
    }
    sort(all.begin() , all.end());

    for(long long  i = 0; i < n; i++)
    {
        long long  p = min(all[i].second , m);
        req += (p*all[i].first);
        m -= p;
        if( m == 0)
            break;

    }
    cout << req << "\n";













return 0;}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int h,w,k;
    cin>>h>>w>>k;
    vector<string>g(h);
    rep(i,h)cin>>g[i];
    int n,a=0;
    rep(ch,1<<h)rep(cw,1<<w){
        n=0;
        rep(i,h)rep(j,w){
            if(ch&1<<i&&cw&1<<j&&g[i][j]=='#')n++;
        }
        if(n==k)a++;
    }
    cout<<a;
	return 0;
}


Measured memory_bytes: 3596