akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
    int N;
    int a[1000];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> a[i];
//    sort(a, a + N);
    int count = 0;

    for (int i = 1; i < N; ++i){
        if(a[i] == a[i - 1]){
            count++;
            i++;
        }
    }

    cout << count << endl;

}

Measured memory_bytes: 256
def change(x) :
    i = 0
    ans = []
    while True :
        if i >= len(x) : break
        cnt = 1
        j = 1
        while True :
            if i+j >= len(x) or x[i+j] != x[i] :
                ans = ans + list(str(cnt))
                ans.append(x[i])
                i += cnt
                break
            else :
                cnt += 1
                j += 1
    return ans
    

while True :
    n = int(input())
    if n == 0 :
        break
    
    lst = list(input())

    for i in range(n) :
        lst = change(lst)
    print(*lst, sep='')


Measured memory_bytes: 7912
n = int(input())
s = input()
arr = "a b c d e f g h i j k l m n o p q r s t u v w x y z".upper().split()
arr = arr[:] + arr[:] + ["A"]

sol = []
for t in s:
    for i in range(26):
        if t == arr[i]:
            sol.append(arr[i+n])
            break
        
print("".join(sol))

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

int main() {
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<long> A(X), B(Y), C(Z);
  for (auto &a : A) cin >> a;
  for (auto &b : B) cin >> b;
  for (auto &c : C) cin >> c;

  sort(A.rbegin(), A.rend());
  sort(B.rbegin(), B.rend());
  sort(C.rbegin(), C.rend());

  vector<long> ABC;
  for (int i = 0; i < X; i++) {
    for (int j = 0; j < Y; j++) {
      for (int k = 0; k < Z; k++) {
        if ((i + 1) * (j + 1) * (k + 1) <= K) ABC.push_back(A.at(i) + B.at(j) + C.at(k));
        else break;
      }
    }
  }

  sort(ABC.rbegin(), ABC.rend());

  for (int i = 0; i < K; i++) cout << ABC.at(i) << "\n";
}

Measured memory_bytes: 1404
def check(a, b, c):
    return True if c < a + b else False

import bisect
def resolve():
    n = int(input())
    targets = list(map(int, input().split()))
    targets.sort()
    ans = 0

    for i in range(len(targets)):
        for j in range(i + 1, len(targets)):
            rest = targets[j+1:len(targets)]
            ans += bisect.bisect_left(rest,targets[i]+targets[j])

    print(ans)
resolve()


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

int main() {
    int N;
    string s,t;
    cin >> N >> s >> t;

    int len = 0;
    for(int i=1; i<=N; ++i) {
        if(s.substr(N - i, i) == t.substr(0, i)) len = i;
    }
    cout << N + N - len << endl;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int H, W;
string s[55];
signed main() {
    cin >> H >> W;
    rep(i, H) { cin >> s[i]; }
    rep(i, H) {
        rep(j, W) {
            if (s[i][j] == '#') {
                bool flag = false;
                rep(k, 4) {
                    int ny = i + DY[k], nx = j + DX[k];
                    if (ny < 0 || ny >= H || nx < 0 || nx >= W) { continue; }
                    flag |= s[ny][nx] == '#';
                }
                if (!flag) { fin("No"); }
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(int argc, char* argv[])
{
	string str;
	char S[99];
	scanf("%s", S);
	str = S;

	int flag = 0;
	int N = (int)str.length();
	int N_half = (N+1)/2;
//	printf("%d\n", N);

	if(N_half%2 == 0){
		int front = 0;
		int back = N_half-1-1;
		for (int i=0; i<N_half/2; i++){
//			printf("%c\n", S[front]);
//			printf("%c\n", S[back]);
			if(str[front] == str[back] &&
					str[front+N_half] == str[back+N_half] &&
					str[front] == str[front+N_half]){
				flag = 0;
			}else{
				flag = 1;
				break;
			}
			front += 1;
			back -= 1;
		}
	}

	if(N_half%2 == 1){
		int front = 0;
		int back = N_half-1-1;
		for (int i=0; i<(N_half-1)/2; i++){
//			printf("%c\n", S[front]);
//			printf("%c\n", S[back]);
			if(str[front] == str[back] &&
					str[front+N_half] == str[back+N_half] &&
					str[front] == str[front+N_half]){
				flag = 0;
			}else{
				flag = 1;
				break;
			}
			front += 1;
			back -= 1;
		}
	}

	if(flag == 0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
}





Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)

H, N = map(int, input().split())

MAGIC = []
for _ in range(N):
    a, b = map(int, input().split())
    MAGIC.append((a, b))

INF = 10 ** 10
dp = [INF] * 20000
dp[0] = 0

for i in range(N):
    for h in range(H):
        a, b = MAGIC[i]

        if dp[h+a] > (dp[h] + b):
            dp[h+a] = dp[h] + b

print(min(dp[H:]))


Measured memory_bytes: 41452
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int len, num;
	scanf("%d%d", &len, &num);
	vector<int>ve, vo;
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		if (z % 2 == 0)ve.push_back(z);
		else vo.push_back(z);
	}
	if (vo.size() >= 3)
	{
		printf("Impossible\n");
		return 0;
	}
	vector<int>ans;
	if (vo.size() >= 1)ans.push_back(vo[0]);
	for (int i = 0; i < ve.size(); i++)ans.push_back(ve[i]);
	if (vo.size() >= 2)ans.push_back(vo[1]);
	for (int i = 0; i < ans.size(); i++)printf("%d ", ans[i]); printf("\n");
	if (ans.size() == 1)
	{
		if (ans[0] == 1)printf("1\n1\n");
		else printf("2\n%d 1\n", ans[0] - 1);
	}
	else
	{
		ans[0]--;
		ans[ans.size() - 1]++;
		if (ans[0] == 0)
		{
			reverse(ans.begin(), ans.end());
			ans.pop_back();
			reverse(ans.begin(), ans.end());
		}
		printf("%d\n", ans.size());
		for (int i = 0; i < ans.size(); i++)printf("%d ", ans[i]); printf("\n");
	}
}

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

int main(){
int n,b[100000],f[100000],r[100000],v[100000];
int A[5][4][11];

for(int i=1;i<5;i++){
for(int j=1;j<4;j++){
for(int k=1;k<11;k++){
A[i][j][k]=0;
}
}
}

cin>>n;
for(int i=1;i<=n;i++){
cin>>b[i]>>f[i]>>r[i]>>v[i];
A[b[i]][f[i]][r[i]] += v[i];
}

for(int i=1;i<=4;i++){
for(int j=1;j<=3;j++){
for(int k=1;k<=10;k++){
cout<<" "<<A[i][j][k];
}
cout<<endl;
}
if(i!=4){
cout<<"####################"<<endl;
}
}

return 0;
}

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

int main() {
  char c;
  char last;
  last = getchar();
  int ans = 0;
  while ((c = getchar()) != EOF) {
    if (c == last) {
      last = c == '0' ? '1' : '0';
      ans++;
    }
    else
      last = c;
  }
  printf("%d\n", ans);
  return 0;}


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

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

  if (D == 25) {
    cout << "Christmas" << endl;
  } else if (D == 24) {
    cout << "Christmas Eve" << endl;
  } else if (D == 23) {
    cout << "Christmas Eve Eve" << endl;
  } else {
    cout << "Christmas Eve Eve Eve" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      String str[] = new String[3];
      for (int i=0;i<3;i++){
        str[i]=scan.next();
        str[i]=str[i].substring(0,1);
      }
      System.out.println(str[0]+str[1]+str[2]);
    }
}

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

int main() {
  int n,r;
  cin >> n >> r;
  if(n >= 10){
    cout << r << endl;
    return 0;
  }else{
    cout << r + (100 * (10 - n))  << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl


int main(){
	string s,t;
	cin >> s >> t;
	int cnt=0;
	for(int i(0);i<3;++i){
		if(s[i]==t[i]) cnt++;
	}
	cout << cnt;
}

Measured memory_bytes: 256
N = int(input())
S = input()
NUMS = list(map(int, S))
ans = 0
for i in range(10):
    for j in range(10):
        iok = False
        jok = False
        k = set()
        for num in NUMS:
            if jok:
                k.add(num)
            elif iok:
                if num == j:
                    jok = True
            else:
                if num == i:
                    iok = True
        ans += len(k)
print(ans)

Measured memory_bytes: 9552
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#include <map>
#include <cstdlib>

using namespace std;

bool func(string s){
  int i;
  for(i = 0; i < s.length() / 2; i++){
    if(s[i] != s[s.length() - 1 - i]) break;
  }
  if(i == s.length() / 2) return true;
  else return false;
}

void solve(){
  string s, sf, ss; cin >> s;
  sf = s.substr(0, s.length() / 2);
  ss = s.substr(s.length() / 2 + 1, s.length());
  if(func(s) == true && func(sf) == true && func(ss) == true) cout << "Yes\n";
  else cout << "No\n";
  return;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  string a;
  cin >> a;
  
  if (a.at(0) != a.at(1) || a.at(0) != a.at(2) || a.at(1) != a.at(2)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;
 
vector<vector<int> > s;
vector<int> c;

int score(vector<int> held,int k){
    vector<int> ld(26,0);
    int ans=0;

    rep(i,held.size()){
        int t=held[i];
        ld[t]=i+1;
        ans+=s[i][t];
        rep(j,26){
            ans-=c[j]*(i+1-ld[j]);
        }
    }

    rep(i,26){
        ans-=c[i]*(held.size()+k*(1+k)+1-ld[i]);
    }

    return ans;
}

int main(){
    int d; cin >> d;
    vector<int> cc(26);
    c=cc;
    rep(i,26) cin >> c[i];
    vector<vector<int> > ss(d);
    s=ss;
    rep(i,d)rep(j,26){
        int a; cin >> a;
        s[i].push_back(a);
    }
 
    //vector<int> ld(26,0);
    vector<vector<int> > ds(26);
    vector<int> ans;
    rep(p,26){
        vector<int> days(0);
        int tmps=-INF;
    rep(i,d){
        int now=-INF;
        int whatday;
        rep(j,26){
            vector<int> tmp=days;
            tmp.push_back(j);
            int sc=score(tmp,p);
            if(sc>now){
                whatday=j;
                now=sc;
            }
        }
        days.push_back(whatday);
    }
    int nows=score(days,0);
    if(tmps<nows){
        ans=days;
        tmps=nows;
    }
    }
    rep(i,d) cout << ans[i]+1 << endl;
return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
int main()
{
    vector<vector<int>> A(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A.at(i).at(j);
      // cout << A.at(i).at(j) << endl;
    }
  }
  int N;
  cin >> N;
  vector<int> b(N);
  for (int i = 0; i < N; i++) {
    cin >> b.at(i);
  }
  
  vector<vector<int>> B(3, vector<int>(3));
  for (int k = 0; k < N; k++) {
  	for (int i = 0; i < 3; i++) {
    	for (int j = 0; j < 3; j++) {
      		if (A[i][j] == b[k]) B[i][j] = 1;
    	}
  	}
  }
  int r;
  	for (int i = 0; i < 3; i++) {
      r = 0;
    	for (int j = 0; j < 3; j++) {
      		r += B[i][j];
    	}
      if (r == 3){
        cout << "Yes" << endl;
        return 0;
      }
  	}
  	for (int i = 0; i < 3; i++) {
      r = 0;
    	for (int j = 0; j < 3; j++) {
      		r += B[j][i];
    	}
      if (r == 3){
        cout << "Yes" << endl;
        return 0;
      }
  	}
  if ((B[0][0] + B[1][1] + B[2][2]) == 3){
    cout << "Yes" << endl;
    return 0;
  }
  if ((B[0][2] + B[1][1] + B[2][0]) == 3){
  cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

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

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

    if (N == 1) {
        cout << "Hello World" << endl;
    } else {
        int A, B; cin >> A >> B;

        cout << A + B << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long mCnt = 0;
        long aCnt = 0;
        long rCnt = 0;
        long cCnt = 0;
        long hCnt = 0;
        for (int i = 0; i < n; i++) {
            char top = sc.next().charAt(0);
            switch (top) {
                case 'M':
                    mCnt++;
                    break;
                case 'A':
                    aCnt++;
                    break;
                case 'R':
                    rCnt++;
                    break;
                case 'C':
                    cCnt++;
                    break;
                case 'H':
                    hCnt++;
                    break;
                default:
                    // not add
            }
        }

        //mar;
        long mar = mCnt * aCnt * rCnt;
        //mac;
        long mac = mCnt * aCnt * cCnt;
        //mah;
        long mah = mCnt * aCnt * hCnt;
        //mrc;
        long mrc = mCnt * rCnt * cCnt;
        //mrh;
        long mrh = mCnt * rCnt * hCnt;
        //mch;
        long mch = mCnt * cCnt * hCnt;
        //arc;
        long arc = aCnt * rCnt * cCnt;
        //arh;
        long arh = aCnt * rCnt * hCnt;
        //ach;
        long ach = aCnt * cCnt * hCnt;
        //rch;
        long rch = rCnt * cCnt * hCnt;

        System.out.println(mar + mac + mah + mrc + mrh + mch + arc + arh + ach + rch);
    }
}

Measured memory_bytes: 46916
# DP
# . -> # に変わる回数が反転が必要な回数
# その最小経路をDPで解く
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
dp = [[0]*W for _ in range(H)]

def cnt(i0, j0, i1, j1):
  if S[i0][j0] == "." and S[i1][j1] == "#":
    return 1
  else:
    return 0

for i in range(H):
  for j in range(W):
    if i == 0 and j == 0:
      dp[0][0] = 0 if S[0][0] == "." else 1
    elif i == 0:
      dp[i][j] = dp[i][j-1] + cnt(i, j-1, i, j)
    elif j == 0:
      dp[i][j] = dp[i-1][j] + cnt(i-1, j, i, j)
    else:
      dp[i][j] = min(dp[i][j-1] + cnt(i, j-1, i, j), dp[i-1][j] + cnt(i-1, j, i, j))

print(dp[H-1][W-1])


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;
using P = pair<int, int>;

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
  t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v) {
  for (auto &e : t) fill(e, v);
}
// auto v = make_vec<int>(h, w);
// fill(v, 0);

signed main(){

  int R, C, K; cin >> R >> C >> K;
  auto t = make_vec<int>(R, C);
  for(int i = 0; i < K; i++){
    int r, c, v; cin >> r >> c >> v;
    r--, c--;
    t[r][c] = v;
  }

  auto dp = make_vec<int>(R+1, C+1, 5);
  fill(dp, 0);
  dp[0][0][1] = t[0][0];

  for(int i = 0; i < R; i++){
    for(int j = 0; j < C; j++){
      for(int k = 0; k <= 3; k++){
        if(i+1 < R){
          dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k]);
          dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][k] + t[i+1][j]);
        }
        if(j+1 < C){
          dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k]);
          dp[i][j+1][k+1] = max(dp[i][j+1][k+1], dp[i][j][k] + t[i][j+1]);
        }
      }
    }
  }

  int ans = 0;
  for(int i = 0; i < 4; i++){
    ans = max(ans, dp[R-1][C-1][i]);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 707300
#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<int>> edge;
vector<int> seen;
void bfs(int start, int color) {
    seen[start] = color;
    queue<int> q;
    q.push(start);
    while (!q.empty()) {
        int now = q.front();
        q.pop();
        // cout << now << endl;
        seen[now] = color;
        for (auto nxt: edge[now]) {
            if (seen[nxt] != -1) continue;
            q.push(nxt);
        }
    }
    return;
}
int main() {
    cin >> n >> m;
    edge.assign(n, vector<int>());
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    seen.assign(n, -1);
    int largest = 0;
    int color = 0;
    for (int i = 0; i < n; i++) {
        if (seen[i] != -1) continue;
        bfs(i, color);
        color++;
    }
    vector<int> num_colors(n, 0);
    for (int i = 0; i < n; i++) {
        num_colors[seen[i]]++;
    }
    for (int c: num_colors) largest = max(largest, c);
    cout << largest << endl;
    return 0;
}

Measured memory_bytes: 16088
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	n, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a := nextInt(sc)
	b := nextInt(sc)
	c := nextInt(sc)

	cnt := 0
	for i := a; i <= b; i++ {
		if c%i == 0 {
			cnt++
		}
	}
	fmt.Println(cnt)
}



Measured memory_bytes: 1088
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
LL S;
LL X[100011];
LL P[100011];
int par[100011];

void MAIN() {
    scanf("%d%lld", &N, &S);
    REP (i, N) scanf("%lld%lld", X+i, P+i);
    memset(par, -1, sizeof par);

    int left = 0, right = N-1;
    vector<LL> pos;
    while (left < right) {
	if (X[left] < S && S < X[right]) {
	    if (P[left] < P[right]) {
		par[left] = right;
		P[right] += P[left];
		pos.push_back(X[left]);
		left++;
	    } else {
		par[right] = left;
		P[left] += P[right];
		pos.push_back(X[right]);
		right--;
	    }
	} else if (S < X[left]) {
	    left++;
	} else {
	    right--;
	}
    }
    pos.push_back(X[left]);

    reverse(pos.begin(), pos.end());
    LL ans = 0;
    EACH (e, pos) {
	ans += abs(*e - S);
	S = *e;
    }

    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 3320
#include <cstdio>
#include <unordered_map>

typedef long long LL;
const int Mod = 1000000007, Inv2 = (Mod + 1) / 2;
const int MN = 1 << 18 | 7;

int H, N, P[MN];
int Inv[MN], f[MN], g[MN];

int tag[MN], Ans;

int main() {
	scanf("%d", &H), --H, N = 1 << H;
	f[0] = f[1] = g[0] = g[1] = 1;
	Inv[1] = 1;
	for (int i = 2; i < 2 * N; ++i) {
		Inv[i] = (LL)(Mod - Mod / i) * Inv[Mod % i] % Mod;
		f[i] = (LL)f[i / 2] * i % Mod;
		g[i] = (LL)g[i / 2] * Inv[i] % Mod;
	}
	for (int i = N - 1; i >= 1; --i) g[i] = (LL)g[i] * g[i / 2] % Mod;
	for (int i = N; i < 2 * N; ++i) scanf("%d", &P[i]), P[i] += N - 1;
	for (int a = 0; a < H; ++a) {
		for (int o = 0; o < 1 << a; ++o) {
			int i = o | 1 << a, Sum = 0;
			for (int q = 0; q < 1 << (H - a - 1); ++q) {
				int j = i << (H - a) | q;
				int val = (LL)f[j] * f[P[j]] % Mod;
				for (int b = 0; b < H; ++b) {
					int k = P[j] >> b;
					tag[k] = (tag[k] + val) % Mod;
				}
			}
			for (int q = 0; q < 1 << (H - a - 1); ++q) {
				int j = i << (H - a) | q | 1 << (H - a - 1);
				int t_Sum = 0;
				for (int b = 0; b < H; ++b) {
					int k = P[j] >> b ^ 1;
					t_Sum = (t_Sum + (LL)tag[k] * g[k / 2]) % Mod;
				}
				Sum = (Sum + (LL)t_Sum * f[j] % Mod * f[P[j]]) % Mod;
			}
			Ans = (Ans + (LL)Sum * g[i]) % Mod;
			for (int q = 0; q < 1 << (H - a - 1); ++q) {
				int j = i << (H - a) | q;
				for (int b = 0; b < H; ++b) tag[P[j] >> b] = 0;
			}
		}
	}
	printf("%d\n", Ans);
	return 0;
}

Measured memory_bytes: 6276
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000007
using namespace std;
ll par[114514];
ll rankk[114514];
void init(int n){
	for(int i=0;i<n;i++){
		par[i] = i;
		rankk[i]=0;
	}
}
ll find(ll x){
	if(par[x] == x){
		return x;
	}else{
		return par[x] = find(par[x]);
	}
}
void unite(ll x, ll y){
	x = find(x);
	y = find(y);
	if(x==y)return;
	if(rankk[x]<rankk[y]){
		par[x]=y;
	}else{
		par[y]=x;
		if(rankk[x]==rankk[y])rankk[x]++;
	}
}
vector<ll> tre[100009];
int main(){
	int n,m;
	vector<ll> a;
	cin>>n>>m;
	if(n-1==m){
		cout<<0<<endl;
		return 0;
	}
	if( n < 2*(n-m-1) ){
		cout<<"Impossible"<<endl;
		return 0;
	}
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		a.pb(x);
	}
	init(n);
	vector<ll> amari;
	for(int i=0;i<m;i++){
		ll x,y;
		cin>>x>>y;
		unite(x,y);
	}
	for(int i=0;i<n;i++){
		ll rt = find((ll)i);
		tre[rt].pb(a[i]);
	}
	ll cnt = 0,ans = 0;
	for(int i=0;i<n;i++){
		if(!tre[i].empty()){
			sort(tre[i].begin(),tre[i].end());
			cnt++;
			ans += tre[i][0];
			//cout<<tre[i][0]<<endl;
			for(int j=1;j<tre[i].size();j++){
				amari.pb(tre[i][j]);
			}
		}
	}
	sort(amari.begin(),amari.end());
	for(int i=cnt;i<2*(n-m-1);i++){
		ans += amari[i-cnt];
		//cout<<amari[i-cnt]<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8180
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int ans = 0;
	for (int i = a; i <= b; i++) {
		string s;
		stringstream ss;
		ss << i;
		ss >> s;
		string rs = s;
		reverse(rs.begin(), rs.end());
		if (s == rs) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<stdio.h>
int main(){
	int u[100][100]={0},a[5]={0},i,o,j=0;
	for(i=0;i<5;i++)
	cin>>a[i];
	if(a[0]<a[4]||a[1]<a[4]){
		cout<<"No"<<endl;
		return 0;
	}
	for(i=0;i<a[0];i++){
		for(o=0;o<a[1];o++){
			u[i][o]=1;
		}
	}
	for(i=a[2]-a[4];i<a[2]+a[4];i++){
		for(o=a[3]-a[4];o<a[3]+a[4];o++){
			u[i][o]+=1;
			if(u[i][o]==1)
			j=1;
		}
	}
	if(j==1)
	cout<<"No"<<endl;
	else
	cout<<"Yes"<<endl;
	return 0;
}

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

int main() {
	ll n,x;
	cin >> n >> x;
	vector<ll> a(n),b(n);
	rep(i,n) cin >> a[i];
	b[0] = min(x,a[0]);
	rep(i,n-1) b[i+1] = min(a[i+1],x-b[i]);
	ll ans = 0;
	rep(i,n) ans += a[i] - b[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

ll a[100001] = {};
ll b[100001] = {};
ll A[100001] = {};
ll B[100001] = {};
map<ll, ll> AS;
map<ll, ll> BS;
int main() {
	ll n; cin >> n;
	repe(i, 1, n / 2) {
		ll x, y; cin >> x >> y;
		AS[x]++;
		BS[y]++;
		a[x]++, A[x]++, b[y]++, B[y]++;
	}

	sort(A + 1, A + 100001);
	reverse(A + 1, A + 100001);
	sort(B + 1, B + 100001);
	reverse(B + 1, B + 100001);
	sort(a + 1, a + 100001);
	reverse(a + 1, a + 100001);
	sort(b + 1, b + 100001);
	reverse(b + 1, b + 100001);

	ll topA = 0;
	ll topAI = 0;
	for (map<ll, ll>::iterator itA = AS.begin(); itA != AS.end(); itA++) {
		if (topAI < itA->second) {
			topA = itA->first;
			topAI = itA->second;
		}
	}
	ll topB = 0;
	ll topBI = 0;
	for (map<ll, ll>::iterator itB = BS.begin(); itB != BS.end(); itB++) {
		if (topBI < itB->second) {
			topB = itB->first;
			topBI = itB->second;
		}
	}

	if (topA != topB) {
		cout << n - A[1] - B[1] << endl;
	}
	else {
		ll ans1 = n - A[1] - B[2];
		ll ans2 = n - A[2] - B[1];
		cout << min(ans1, ans2) << endl;
	}
	return 0;
}

Measured memory_bytes: 9600
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

string list[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

int main() {
  string S;
  cin >> S;

  int index;
  rep(i,7) {
    if(list[i] == S) {
      index = i;
      break;
    }
  }
  cout << 7-index << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    ll res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}
ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}

ll f[200001];
 
ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a; 
 while(b > 0)
    {
        if(b%2 == 1)
    {
        x=(x*y);
        if(x>MOD) x%=MOD;
    }
    y = (y*y);
    if(y>MOD) y%=MOD; 
    b /= 2;
    }
 return x;
}
 
/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}
 
ll C(ll n, ll r, ll MOD)
{
 
 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
 


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char c;
    cin>>c;
    if(c>='a')
        cout<<"a\n";
    else
        cout<<"A\n";


    return 0;   
}


 
 


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

template <i64 p>
class fp {
    public:
    i64 x;
    fp() : x(0) {}
    fp(i64 x_) : x((x_ % p + p) % p) {}
    fp operator+() const { return fp(x); }
    fp operator-() const { return fp(-x); }
    fp& operator+=(const fp& y) {
        x += y.x;
        if (x >= p) x -= p;
        return *this;
    }
    fp& operator-=(const fp& y) { return *this += -y; }
    fp& operator*=(const fp& y) {
        x = x * y.x % p;
        return *this;
    }
    fp& operator/=(const fp& y) { return *this *= fp(inverse(y.x)); }
    fp operator+(const fp& y) const { return fp(x) += y; }
    fp operator-(const fp& y) const { return fp(x) -= y; }
    fp operator*(const fp& y) const { return fp(x) *= y; }
    fp operator/(const fp& y) const { return fp(x) /= y; }
    bool operator==(const fp& y) const { return x == y.x; }
    bool operator!=(const fp& y) const { return !(*this == y); }
    i64 extgcd(i64 a, i64 b, i64& x, i64& y) {
        i64 d = a;
        if (b != 0) {
            d = extgcd(b, a % b, y, x);
            y -= (a / b) * x;
        } else {
            x = 1;
            y = 0;
        }
        return d;
    }
    i64 inverse(i64 a) {
        i64 x, y;
        extgcd(a, p, x, y);
        return (x % p + p) % p;
    }
};

template <i64 p>
i64 abs(const fp<p>& x) { return x.x; }

template <i64 p>
ostream& operator<<(ostream& os, const fp<p>& x) {
    os << x.x;
    return os;
}

template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "[";
    for (const auto& v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename A, typename T, size_t size>
void fill(A (&ary)[size], const T& val) {
    fill((T*)ary, (T*)(ary + size), val);
}

constexpr int inf = 1.01e9;
constexpr i64 inf64 = 4.01e18;
constexpr double eps = 1e-9;

void solve() {
    //constexpr i64 mod = 1'000'000'007;
    i64 N;
    cin >> N;

    i64 ans=0;
    rep(i,1,N+1){
        if(to_string(i).length()%2==1) ++ans;
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

int main() {

  int N, M;
  cin >> N >> M;

  vector<pair<int,int>> sc(N);
  for (int i = 0; i < M; i++) {
    cin >> sc[i].first >> sc[i].second;
  }

  // keyを桁,valueをその桁の値で管理するmap。
  // 見ていない桁は値を-1(初期値)とする。
  map<int,int> v;
  for (int i = 1; i <= N; i++) {
    v[i] = -1;
  }

  // 答えになる整数があるか(ture)、ないか(false)
  bool flg = true;
  
  // mapに桁と値を入れる。
  // 一度値を入れた桁については、同じ値じゃないとダメ。
  for (int i = 0; i < M; i++) {
    int i_ = sc[i].first;
    if (v[i_] == -1) {
      v[i_] = sc[i].second;
    } else if (v[i_] != sc[i].second){
      flg = false;
      break;
    }
  }

  // mapの1桁目の値が0の場合は、
  // Nが1以外の場合はダメ。
  if (v[1] == 0) {
    if (N != 1) {
      flg = false;
    }
  } else if (v[1] == -1) {
    // 1桁目の値が-1の場合は、
    // Nが1の場合は0、それ以外は1にする。
    if (N == 1) {
      v[1] = 0;
    } else {
      v[1] = 1;
    }
  }

  int answer = -1;
  
  if (flg) {
    // 答えを作る。
    answer = 0;
    for (int i = 1; i <= N; i++) {
      if (v[i] != -1) {
        answer += v[i] * pow(10, N - i);
      }
    }
  }

  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>

using namespace std;
#define LL long long 
char d[105][105];

int main(){
    LL n, k;
    LL c;
    LL H, W;
    LL ans = 1e18;
    cin >> n >> k;
    vector<LL> a(n),b(n);
    vector<pair<LL, LL> > E; 
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        E.push_back(make_pair(a[i], b[i]));
    }
    sort(E.begin(), E.end());
    
    for(int i = 0; i < n; i++){
        H = E[i].first;
        W = E[i].second;    
        // cout << H << W << endl;

        k -= W;
        if(k <= 0){
            cout << H << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3956
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}"<<endl;
  return o;
}

//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m; 
  if (u < 0) u += m;
  return u;
}
ll const mod = 1e9+7;

// combination
const int MAX = 510000;
const ll MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int N,a,c=0;
  cin >> N;
  vector<int> A(1,201);
  rep(i,N) {
    cin >> a;
    if (c>0 && A[c]==a) continue;
    else {
      A.push_back(a);
      c++;
    }
  }
  A.push_back(99);
  N=c+2;
  
  ll m=1000,s=0;
  rep2(i,1,c+1) {
    if ((A[i-1]<A[i]&&A[i]<A[i+1]) || (A[i-1]>A[i]&&A[i]>A[i+1])) {
      continue;
    }
    else if (A[i-1]<A[i]&&A[i]>A[i+1]) {
      m += s*A[i];
      s=0;
    }
    else {
      s += m/A[i];
      m -= m/A[i]*A[i];
    }
  }
  cout << m << endl;
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;
typedef tuple<long long, long long, long long> tllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
bool compTuple(const tllint& arg1, const tllint& arg2) { return get<2>(arg1) > get<2>(arg2); }
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; }

vector<pair<llint, llint>> prime_factorize(llint n) {
    vector<pair<llint, llint> > res;
    llint num;

    for(llint p=2;p*p<=n;p++) {
        if (n%p!=0) continue;
        num = 0;
        while (n%p==0) { ++num; n /= p; }
        res.push_back(make_pair(p,num));
    }
    if (n!=1) res.push_back(make_pair(n,1));
    return res;
}

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

    vector<llint> a(n);
    for(int in=0;in<n;++in) {
        cin >> a[in];
    }

    unordered_map<llint,llint> mp;
    for(int in=0;in<n;++in) {
        auto mat = prime_factorize(a[in]);
        for(auto cmat:mat) {
            if(mp.count(cmat.first)==0) mp.insert(make_pair(cmat.first, 1));
            else mp[cmat.first]++;
        }
    }

    int sw = 0;
    for(auto cmp:mp) {
        if(cmp.second==n) {
            sw = 2;
            break;
        }
        if(cmp.second>=2) sw = 1;
    }
    if(sw==0) cout << "pairwise coprime" << endl;
    else if(sw==1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
    return 0;
}


Measured memory_bytes: 14424
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#define LL long long
using namespace std;
int n,a[200010];
int f[200010],g1[200010],g2[200010];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	memset(f,0,sizeof(f));
	for(int j=0;j<20;j++)
	{
		g2[1]=0;
		g1[1]=((1<<j)&a[1])?1:0;
		for(int i=2;i<=n;i++)
		{
			if(!((1<<j)&a[i])) g1[i]=g1[i-1],g2[i]=g2[i-1];
			else g1[i]=i,g2[i]=g1[i-1];
		}
		for(int i=1;i<=n;i++) f[i]=max(f[i],g2[i]);
	}
	LL ans=0;
	for(int i=1;i<=n;i++) ans+=i-f[i];
	printf("%lld",ans);
}

Measured memory_bytes: 3328
package main

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

const size = 1000000
var reader = bufio.NewReaderSize(os.Stdin,size)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n,_ = strconv.Atoi(NextLine())
  return n
}
func NextIntArray() []int {
  var s []string = strings.Split(NextLine()," ")
  var n int = len(s)
  var a []int = make([]int,n)
  for i:=0;i<n;i++ {
    a[i],_ = strconv.Atoi(s[i])
  }
  return a
}

func main() {
  var n int = NextInt()
  var u []int = NextIntArray()
  var l []int = NextIntArray()
  var m,t,su,sl int
  m,su,sl = 0,0,0
  for i:=0;i<n;i++ { sl += l[i] }
  for i:=0;i<n;i++ {
    su += u[i]
    t = su + sl
    if m < t { m = t }
    sl -= l[i]
  }
  fmt.Println(m)
}

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

double A, B, H, M;

signed main(){
    cin >> A >> B >> H >> M;
    double hc = 30*(H+M/60.0);
    double mc = 6*M;
    double c = abs(hc-mc)>180?360-abs(hc-mc):abs(hc-mc);
    //cout << c << endl;
    c = 2.0*3.14159265359*c;
    c = c/360.0;
    //double ans = sqrt(A*A+B*B-2*A*B*cos(c*2.0*3.14159265359/360.0));
    double ans = pow(A*A+B*B-2*A*B*cos(c), 0.50);
    cout << fixed << setprecision(11) << ans << endl;
    return 0;
}

Measured memory_bytes: 4344
#include<stdio.h>

typedef struct{
  char suit;
  char value;
}Card;

int main(void){
  Card C[101];
  Card Select[101];
  int n,i,j;
  int flag = 0;
  int tmp;
  char ch;
  int mini;

  scanf("%d\n", &n);
  for ( i = 0; i < n; i++ )
    scanf("%c%c%c", &C[i].suit, &C[i].value,&ch);

  for(i=0;i<n;i++)
    Select[i] = C[i];

  //bubble sort
  for(i=0;i<n;i++){
    for(j=n-1;j>=i+1;j--){
      if(C[j].value < C[j-1].value){
	tmp = C[j-1].value;
	ch = C[j-1].suit;
	C[j-1] = C[j];
	C[j].value = tmp;
	C[j].suit = ch;
      }
    }
  }
  
  //selection sort
  for(i=0;i<n;i++){
    mini = i;
    for(j=i+1;j<n;j++){
      if(Select[j].value < Select[mini].value){
        mini = j;
      }   
    }
    tmp = Select[i].value;
    ch = Select[i].suit;
    Select[i] = Select[mini];
    Select[mini].value = tmp;
    Select[mini].suit = ch;
  }

  for(i=0;i<n-1;i++)
    printf("%c%c ",C[i].suit,C[i].value);
  printf("%c%c\n",C[i].suit,C[i].value);
  printf("Stable\n");

  for(i=0;i<n-1;i++)
    printf("%c%c ",Select[i].suit,Select[i].value);
  printf("%c%c\n",Select[i].suit,Select[i].value);

  for(i=0;i< n;i++){
    if(Select[i].suit != C[i].suit)
      flag++;
  }

  if(flag == 0)
    printf("Stable\n");
  else
    printf("Not stable\n");

  return 0;
}

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

using graph = vector<vector<ll>>;

vector<ll> ans;

//UnionFind実装
struct UnionFind{
    vector<ll>d;
    UnionFind(ll n=0):d(n,-1){}
    ll root(ll x){
        if(d[x] < 0) return x; // 根は-サイズでここだけが負の値
        return d[x] = root(d[x]) ;// 親を根に移す、経路縮約
    }
    bool unite(ll x,ll y){
        x = root(x),y = root(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x,y); // 小さい方を大きい方につける
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(ll x,ll y){return root(x) == root(y);}
    ll size(ll x) {return -d[root(x)];}
};

int deg[200005];
vector<int> to[200005];
int main(){
  /*UnionFind uf(100);
  if (uf.same(0,1)){cout << "sw" << endl;}
  else{cout << "ss" << endl;}*/
  ll n,m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i,m){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        if(!uf.same(a,b)){
            deg[a]++;
            deg[b]++;
            uf.unite(a,b);
        }
    }
    ll ans = -1;
    rep(i,n){
        ans = max(ans,(ll)uf.size(i));
    }
    cout << ans << endl;
    

    
}

Measured memory_bytes: 10320
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>
int max(int a, int b){return a>b?a:b;}
int min(int a, int b){return a<b?a:b;}
int gcd(int a, int b){return min(a,b)==0 ?max(a,b):gcd(min(a,b),max(a,b)%min(a,b));}
long long llmax(long long a, long long b){return a>b?a:b;}
long long llmin(long long a, long long b){return a<b?a:b;}
long long llgcd(long long a, long long b){return min(a,b)==0 ?max(a,b):gcd(min(a,b),max(a,b)%min(a,b));}
int assort(const void *a, const void *b){return *(int*)a-*(int*)b;}
int dessort(const void *a, const void *b){return *(int*)b-*(int*)a;}
int llassort(const void *a, const void *b){return *(long long*)a-*(long long*)b;}
int lldessort(const void *a, const void *b){return *(long long*)b-*(long long*)a;}
int charassort(const void *a, const void *b){return strcmp((char*)a ,(char*)b);}
int chardessort(const void *a, const void *b){return strcmp((char*)b ,(char*)a);}
char lowcmp[26]="abcdefghijklmnopqrstuvwxyz";
char upcmp[26]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int ntoi(char c){return c-'0';}
int ltoi(char c){return c-'a';}
int utoi(char c){return c-'A';}
long long mod=1000000007;

int main(void){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    printf("%d\n",a+b+c+max(a,max(b,c))*9);
    return 0 ;
}

Measured memory_bytes: 128
// 無能なのでわからなかった…editorialわかりやすい…
#include <bits/stdc++.h>
using namespace std;

int mul (int x) {
  return (x + 9) / 10 * 10;
}

int rem (int x) {
  return mul(x) - x;
}

int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  int ans = mul(a) + mul(b) + mul(c) + mul(d) + mul(e);
  ans -= max({rem(a), rem(b), rem(c), rem(d), rem(e)}); // 3つ以上のmax,minとるときは{}
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  char s[100];
  rep(i, n)
  {
    cin >> s[i];
  }
  rep(j, n)
  {
    if (s[j] == 'Y')
    {
      cout << "Four" << endl;
      exit(0);
    }
  }

  cout << "Three" << endl;
}


Measured memory_bytes: 3624
from collections import defaultdict, deque
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

n = inp()
ans = 0
for i in range(1, n+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)

Measured memory_bytes: 10056
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>

using namespace std;

#define D(x) x
#define REP(i,a,b) for (int i = (a); i < (b); ++i)
#define REPR(i,a,b) for (int i = (b) - 1; i >= (a); --i)
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<vector<int> > VII;

void solve() {
    string s;
    cin >> s;
    int papers = 0;
    for (char c : s)
        papers += c == 'p';
    cout << (int)(s.length()/2) - papers << endl;

}

int main() {
    ios_base::sync_with_stdio(false);
    cout << setprecision(12) << fixed;

    solve();

	return 0;
}


Measured memory_bytes: 512