akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF (1e+18)
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
typedef struct{
	int front;
	int rear;
	int size;
	int *data;
} Queue;
void init_queue(Queue* q,int s){
	q->data=calloc(s,sizeof(int));
	q->front=q->rear=0;
	q->size=s;
	return;
}
void end(Queue* q){
	free(q->data);
	return;
}
void push(Queue* q,int a){
	q->data[q->rear]=a;
	q->rear=(q->rear+1)%q->size;
	return;
}
int pop(Queue* q){
	int res=q->data[q->front];
	q->front=(q->front+1)%q->size;
	return res;
}
int isempty(Queue *q){
	return q->front==q->rear;
}
typedef struct LIST{
	int to,cost;
	struct LIST *next;
}Edge;
Edge** init(int v){
	Edge **edge=(Edge**)calloc(v,sizeof(Edge*));
	return edge;
}
void add_edge(Edge **edge,int s,int t,int c){
	Edge *tmp=(Edge*)malloc(sizeof(Edge));
	tmp->to=t,tmp->cost=c;
	tmp->next=edge[s];
	edge[s]=tmp;
	return;
}
void delete_edge(Edge **edge,int v){
	int i;
	Edge *e,*tmp;
	FOR(i,0,v){
		e=edge[i];
		while(e!=NULL){
			tmp=e->next;
			free(e);
			e=tmp;
		}
	}
	return;
}
ll d[100000];
Queue que;
Edge **edge;
int main(void)
{
	int n,a,b,c,q,k,i;
	scanf("%d",&n);
	edge=init(n);
	init_queue(&que,n);
	FOR(i,0,n-1){
		scanf("%d%d%d",&a,&b,&c);
		a--,b--;
		add_edge(edge,a,b,c);
		add_edge(edge,b,a,c);
	}
	FOR(i,0,n) d[i]=INF;
	scanf("%d%d",&q,&k);
	d[--k]=0LL;
	push(&que,k);
	while(!isempty(&que)){
		int p=pop(&que);
		for(Edge *e=edge[p];e!=NULL;e=e->next){
			if(d[e->to]==INF){
				d[e->to]=d[p]+e->cost;
				push(&que,e->to);
			}
		}
	}
	FOR(i,0,q){
		scanf("%d%d",&a,&b);
		printf("%lld\n",d[--a]+d[--b]);
	}
	return 0;
}


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

const int maxn = 2e5 + 5;
int a[maxn], pw[16];
long long dp1[16][maxn], dp2[16][maxn];

int main() {
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    pw[0] = 1;
    for (int i = 1; i <= 15; ++i) pw[i] = pw[i - 1] * 4;
    a[n + 1] = 1000000000;
    a[0] = 1000000000;
    for (int i = 0; i < 16; ++i) { 
        for (int j = 0; j < maxn; ++j) { 
            dp1[i][j] = 1e18; 
            dp2[i][j] = 1e18;
        }
    }
    for (int i = 0; i <= 15; ++i) {
        dp1[i][n + 1] = 0;
        dp2[i][0] = 0;
    }
    for (int i = n; i >= 1; --i) {
        for (int j = 0; j <= 15; ++j) {
            long long v = 1e18;
            long long x = a[i] * 1ll * pw[j];
            for (int k = 0; k <= 15; ++k) {
                long long y = a[i + 1] * 1ll * pw[k];
                if (x <= y)
                    v = min(v, dp1[k][i + 1]);
            }
            int z = 0;
            long long p = 1;
            while (a[i + 1] * p < x) {
                z++;
                p *= 4;
            }
            if (z > 15) 
                v = min(v, i + 1 == n + 1 ? 0ll : dp1[15][i + 1] + (n - i) * 2ll * (z - 15));
            dp1[j][i] = v + 2 * j;
        } 
    } 
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= 15; ++j) {
            long long v = 1e18;
            long long x = a[i] * 1ll * pw[j];
            for (int k = 0; k <= 15; ++k) {
                long long y = a[i - 1] * 1ll * pw[k];
                if (x <= y)
                    v = min(v, dp2[k][i - 1]);
            }
            int z = 0;
            long long p = 1;
            while (a[i - 1] * p < x) {
                z++;
                p *= 4;
            }
            if (z > 15) 
                v = min(v, i - 1 == 0 ? 0ll : dp2[15][i - 1] + (i - 1) * 2ll * (z - 15));
            dp2[j][i] = v + 2 * j;
        } 
    } 
    long long ans = 1e18;
    for (int i = 1; i <= n + 1; ++i) 
        ans = min(ans, dp2[0][i - 1] + i - 1 + dp1[0][i]);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 51072
a,b,d = map(int,input().split())

ans=[]

for i in range(d):
    tmp=a+i
    if tmp<b+1:
        ans.append(a+i)

for i in range(d-1,-1,-1):
    if b-i>a-1:
        ans.append(b-i)

a2=list(set(ans))
a2.sort()

for i in range(len(a2)):
    print(a2[i])

Measured memory_bytes: 3064
#include<iostream>

using namespace std;


long long n, m;
long long ans = 0;
int main() {
  cin >> n;
  cin >> m;

  ans = min(n, m/2);
  n -= ans;
  m -= ans*2;
  m -= min(n, m/2)*2;
  ans += m/4;

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


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

typedef long long int64;
#define REP(i,n) for(int64 i=0;i<(int64)(n);i++)
#define REPD(i,n) for(int64 i=(int64)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int64 i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int64)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define GSORT(x) sort(ALL(x), greater<int64>());
#define SUM(x) accumulate(ALL(A), 0);
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; }

using namespace std;

void Main() {
	int x, y;
	for (int64 i = 0; ; i++) {
		cin>>x>>y;
		if (x == 0 && y == 0) {
			return;
		}
		if (x > y) {
			swap(x, y);
		}
		cout << x << " " << y << "\n";

	}
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}



Measured memory_bytes: 3164
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_N (16L)
#define INF (1000000000000000000L)

using namespace std;

int main() {
  // read inputs
  long N, ass[MAX_N][MAX_N];
  scanf("%ld", &N);
  for (long i = 0; i < N; i++) {
    for (long j = 0; j < N; j++) {
      scanf("%ld", &ass[i][j]);
    }
  }

  // solve dp
  // scores[S] : the score earned when placing the elements in set S in one
  //             group
  // dps[S] : best possible score when choosing from elements in the set S
  long scores[1 << MAX_N], dps[1 << MAX_N];
  // calculate scores O(N^2 2^N)
  for (long S = 0; S < (1 << N); S++) {
    long score = 0;
    for (long i = 0; i < N; i++) {
      if (S & (1 << i)) {
        for (long j = i + 1; j < N; j++) {
          if (S & (1 << j)) {
            score += ass[i][j];
          }
        }
      }
    }
    scores[S] = score;
  }
  // calculate dps O(3^N)
  dps[0] = 0;
  for (long S = 0; S < (1 << N); S++) {
    long dp = scores[S];
    for (long Sd = S; Sd > 0; Sd = (S & (Sd - 1))) {
      const long Sdd = S & ~Sd;
      dp = max(dp, scores[Sd] + dps[Sdd]);
    }
    dps[S] = dp;
  }
  printf("%ld\n", dps[(1 << N) - 1]);
}

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

#define pb push_back
#define fi first
#define se second
typedef long long ll;

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))

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

	ll a, b, k;
	cin >> a >> b >> k;
	cout << a - MIN(a, k) << ' ' << b - MIN(b, MAX(0, k - a)) << '\n';
}


Measured memory_bytes: 256
bingo = []
bingo_ans = []
d = {}
for _ in range(3):
  bingo.append(list(map(int, input().split())))
  bingo_ans.append([False]*3)
  
n = int(input())
  
for _ in range(n):
  i = int(input())
  for j in range(3):
    if i in bingo[j]:
      index = bingo[j].index(i)
      bingo_ans[j][index] = True

ans = "No"

for i in range(3):
  if bingo_ans[i][0] and bingo_ans[i][1] and bingo_ans[i][2]:
    ans = "Yes"
  if bingo_ans[0][i] and bingo_ans[1][i] and bingo_ans[2][i]:
    ans = "Yes"

if bingo_ans[0][0] and bingo_ans[1][1] and bingo_ans[2][2]:
  ans = "Yes"
  
if bingo_ans[2][0] and bingo_ans[1][1] and bingo_ans[0][2]:
  ans = "Yes"
  
print(ans)

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

using namespace std;

typedef long long ll;

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

    int m = 1000;
    for (int i = 0; i <= S.length() - T.length(); i++) {
        int tmp = 0;

        for (int j = 0; j < T.length(); j++) {
            if (S[i+j] != T[j]) {
                tmp++;
            }
        }
        m = min(m, tmp);
    }

    cout << m << endl;
}

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

using namespace std;

#define MOD 1000000007
#define A 0
#define C 1
#define G 2
#define T 3
#define AGC A*4*4+G*4+C
int N;

long long dp[101][4 * 4 * 4];

bool ok(int last4) {

		//AGCはだめ
		int a[4];
		int t = last4;
		for (int i = 3; i >= 0; i--) {
			a[i] = t% 4;
			t /= 4;
		}
		for (int j = 0; j < 4; j++) {
			int b[4];
			for (int i = 0; i < 4; i++) {
				b[i] = a[i];
			}
			if (j > 0) {
				b[j - 1] = a[j];
				b[j] = a[j - 1];
			}

			if (b[0]*4*4+b[1]*4+b[2] == AGC) {
				return false;
			}
			if (b[1]*4*4+b[2]*4+b[3] == AGC) { 
				return false; 
			}
		}
	return true;
}

long long func(int n,int last3) {
	if (dp[n][last3] != -1) {
		return dp[n][last3];
	}
	else if(n==N){
		return 1;
	}
	else {
		long long ret = 0;
		for (int i = 0; i < 4; i++) {
			if (ok(last3 * 4 + i)) {
				ret = (ret + func(n + 1, (last3 % (4 * 4)) * 4 + i))%MOD;
			}
			dp[n][last3] = ret;
		}
		return ret;
	}
}

int main() {
	cin >> N;
	for (int i = 0; i < 101; i++) {
		for (int j = 0; j < 4 * 4 * 4; j++) {
			dp[i][j] = -1;
		}
	}

	cout << func(0, 4*4*4-1) <<endl;
	cin >> N;
	return 0;
}

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

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

const long long MOD = 1000000007;

int gcd(int a, int b) { return b?gcd(b,a%b):a;}
int lcm(int a, int b) { return a/gcd(a,b)*b;}

int main(){
  int n;
  cin>>n;
  
  int d=0,ans=0;;
  for(int a=1;a<n+1;a++){
    for(int b=1;b<n+1;b++){
      d=gcd(a,b);
      for(int c=1;c<n+1;c++){
        ans+=gcd(c,d);
      }
    }
  }
  
  cout<<ans<<endl;
}


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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int a, b; cin >> a >> b;
  if(a >= 13) cout << b << endl;
  else if(a >= 6) cout << b / 2 << endl;
  else cout << 0 << endl;
}


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

int main() {
  long int N,M,answer;
  cin >> N >> M;
  vector<long int> A(N);
  vector<long int> B(N);
  for (long int i=0; i<N ; i++){
    cin >> A.at(i) >> B.at(i);
  }
  vector<pair<long int, long int> > pairs(N);
  for (long int i = 0; i < N; i++) {
    pairs[i] = make_pair(A.at(i), B.at(i));
  }
  sort(pairs.begin(), pairs.end());
  for (long int i=0; i<N ; i++){
    A.at(i)=pairs[i].first;
    B.at(i)=pairs[i].second;
  }
  long int sum=0;
  long int money=0;
  long int sagaku;
  for (long int i=0; i<N ; i++){
    if (sum + B.at(i) < M){
      money = money + A.at(i) * B.at(i);
      sum = sum + B.at(i);
      continue;
    }
    else if (sum + B.at(i) ==M){
      money = money + A.at(i)*B.at(i);
      break;
    }
    else {
      sagaku = M - sum;
      money = money + A.at(i) * sagaku;
      break;
    }
  }
  cout<< money << endl;
  }

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

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

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int maxn = 200010;

int a[maxn];

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

	rep(i, N) {
		a[i+1] = a[i] + (s[i] == '.');
	}

	int ans = N;

	for (int i = 0; i <= N; ++i) {
		int l = i - a[i];
		int r = a[N] - a[i];
		ans = min(ans, l + r);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1412
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int H = in.nextInt();
            int A = in.nextInt();
            out.println((int) Math.ceil(H / (double) A));
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
from itertools import permutations
import math
menu=5
times=[int(input()) for i in range(menu)]
orders=list(permutations(times))
minimum=sum(math.ceil(time/10)*10 for time in times)
for order in orders:
    total=order[0]
    for i in range(1,menu):
        total+=math.ceil(order[i]/10)*10
    minimum=min(minimum,total)
print(minimum)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;int main(){int N,o=0,n,c,p,t,a=0,b=0;cin>>N;int A[N],B[N],s=N-1,X[N];A[0]=1;B[0]=1;char x;
for(int i=0;i<N;i++){cin>>x;X[i]=x-48;o=o+X[i];}
for(int i=1;i<N;i++)A[i]=A[i-1]*2%(o+1);if(o>1)for(int i=1;i<N;i++)B[i]=B[i-1]*2%(o-1);else for(int i=0;i<N;i++)B[i]=0;for(int i=0;i<N;i++){b=b+B[s-i]*X[i];a=a+A[s-i]*X[i];if(b>2*(o-1))b=b-o+1;if(a>2*(o+1))a=a-o-1;}
for(int i=0;i<N;i++){c=0;if(X[i]){p=o-1;n=b-B[s-i];}else{p=o+1;n=a+A[s-i];}
if(p==0)n=0;else if(n==0)c=1;while(n!=0){n=n%p;t=n;p=0;while(t>0){if(t%2==1)p++;t=t/2;}c++;}
cout<<c<<endl;}}


Measured memory_bytes: 5884
import java.util.*;
public class Main{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=new int[n];
    int x=0;
    for(int i=0;i<n;i++)
    {
       a[i]=sc.nextInt();
        x=x^a[i];
    }
    
    for(int i=0;i<n;i++)
    {
       int y=a[i]^x;
      System.out.print(y+" ");
    }
  }
}

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

using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back

int main()
{
    int i;
    int j;

    int a,b,c;
    int a1,b1,c1;
    cin>>a>>b>>c;
    a1=max(a,max(b,c));
    c1=min(a,min(b,c));
    b1=a+b+c-a1-c1;
    if((a1==b1)&&(b1==c1))
    {
        cout<<0<<endl;
        return 0;
    }
    if(a1==b1)
    {
        int x=a1-c1;
        int ans=(x+1)/2+(x%2);
        cout<<ans<<endl;
        return 0;

    }

    if(b1==c1)
    {

        int x=a1-b1;
        cout<<x<<endl;

        return 0;

    }

    int ans=a1-b1;
    int x=b1-c1;
    ans=ans+((x+1)/2)+(x%2);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#!usr/bim/python
#! -*- coding: utf-8 -*-

n = raw_input()

length = len(n)

status = 0

for i in range(length/2):
    if n[i] == n[length-1-i]:
        pass
    else:
        status = 1
        break

if status == 0:
    print 'Yes'
else:
    print 'No'
    


Measured memory_bytes: 2568
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int a; cin >> a;
    string s; cin >> s;

    if (3200 <= a) cout << s << endl;
    else cout << "red" << endl;
}

Measured memory_bytes: 256
// c
# include<stdio.h>
# include<stdlib.h>
# include<string.h>
int top,S[1000];

void push(int x){
    top++;
    S[top]=x;
}
int pop(){
    top--;
    return S[top+1];
}

int main(){
    int a,b,x;
    char s[100];
    top = 0 ;
    // 読み込みの指定がない場合はEOF判定をする
    while(scanf("%s",s)!= EOF){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        }else if(s[0]=='-'){
            a = pop();
            b = pop();
            push(b-a);
        }else if(s[0]=='*'){
            a = pop();
            b = pop();
            push(a*b);
        }else{
            x = atoi(s);
            push(x);
        }
    }
    printf("%d\n",pop());
    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;

int main(void){
	int n;
	cin >> n;
	int a[n+1],b[n+1],c[n];
	rep(i,n)cin >> a[i+1];
	rep(i,n)cin >> b[i+1];
	rep(i,n-1)cin >> c[i+1];

	ll ans = b[a[1]];

	rep(i,n-1){
		int cur = i+2;
		if(a[cur] == a[cur-1]+1)ans += c[a[cur]-1];
		ans += b[a[cur]];
	}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)
int main() {
    vector<string> s(3);
    rep(i,3) {
        cin >> s[i];
    }
    rep(i,3) {
        cout << s[i][i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
// Author : heyuhhh
// Created Time : 2020/08/22 20:01:51
#include<bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;
void run() {
    string s;
    cin >> s;
    int sum = 0;
    int n = s.length();
    for (int i = 0; i < n; i++) {
        sum = (sum + s[i] - '0') % 9;
    }
    if (sum == 0) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}
int main() {
#ifdef Local
    freopen("input.in", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}

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

int main() {
	int a;
	cin >> a;
	string s;
	cin >> s;
	if (a >= 3200) cout << s << endl;
	else cout << "red" << endl;
	return 0;
}


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

int main(void)
{
    string s;
    cin >> s;
    for (char c = 'a'; c <= 'z'; c++)
    {
        bool found = false;
        for (int i = 0; i < s.length(); i++)
        {
            if (s[i] == c) { found = true; }
        }
        if (!found)
        {
            cout << c << endl;
            return 0;
        }
    }

    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll n,cnt=0,sum=0;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
	{
	    cin>>a[i];
	    if(a[i]<=0)
	        cnt++;
	        
	   a[i]=abs(a[i]);
	}
	sort(a,a+n);
	if(cnt%2==0)
	{
	    sum+=a[0];
	}
	else
	{
	    sum-=a[0];
	}
	for(ll i=1;i<n;i++)
	{
	    sum+=a[i];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,B;
  cin >> N >> B;
  if(N-B-B>0)
  {
    cout << N-2*B << endl;
  }
  else
  {
    cout << 0 << endl;
  }
  return 0;
}


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

int main()
{
    unsigned long long a,b;
    unsigned long long x;
    unsigned long long st;
    unsigned long long count=0;
    cin>>a>>b>>x;
    count = b/x;
    count = count - (a/x) + (a%x==0?1:0);
    cout<<count;
    return 0;
}


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

int main(){
    int A[3];
    for(int i=0;i<3;i++)cin>>A[i];
    sort(A,A+3);
    bool a,b,c;
    if(A[2]%2==0)a=true;
    else a=false;
    if(A[1]%2==0)b=true;
    else b=false;
    if(A[0]%2==0)c=true;
    else c=false;

    int ans=(A[2]-A[0])/2+(A[2]-A[1])/2;

    if(a==c&&b==c)cout<<ans<<endl;
    else if(a!=b&&a!=c)cout<<ans+1<<endl;
    else cout<<ans+2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
long long n,k,s;
long long a[100005],ft[100005],inv[100005];
long long sq[40];
int main(){
    scanf("%lld %lld",&n,&k);
    for(long long i=0;i<n;i++)scanf("%lld",&a[i]);
    sort(a,a+n);
    ft[0]=1;
    for(long long i=1;i<=n;i++)ft[i]=(ft[i-1]*i)%MOD;
    long long p=MOD-2LL;
    sq[0]=ft[n];
    for(int i=1;i<35;i++)sq[i]=(sq[i-1]*sq[i-1])%MOD;
    inv[n]=1;
    for(int i=0;i<35;i++){
        if(p%2)inv[n]=(inv[n]*sq[i])%MOD;
        p>>=1;
    }
    for(long long i=n-1;i>=0;i--)inv[i]=(inv[i+1]*(i+1))%MOD;
    for(long long i=k-1;i<n;i++){
        long long cnst=(ft[i]*inv[k-1])%MOD;
        cnst=(cnst*inv[i-k+1])%MOD;
        s+=(a[i]*cnst)%MOD;
        s%=MOD;
    }
    for(long long i=0;i<=n-k;i++){
        long long cnst=(ft[n-i-1]*inv[k-1])%MOD;
        cnst=(cnst*inv[n-k-i])%MOD;
        s+=((MOD-a[i])*cnst)%MOD;
        s%=MOD;
    }
    printf("%lld",s);
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{int n;
 cin>>n;
 int sum=0;
 char s[100001];
for(int i=0;i<n;i++)
{cin>>s[i];
 if(i>0)
  {if(s[i]==s[i-1])
     continue;
   else 
      sum=sum+1;
   }
}
 
cout<<sum+1; 
return 0;
}

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

int main()
{
	int k,x,a;
	cin >> k >> x;
	a = x - k + 1;
	for(int i = 0; i < k * 2 - 1 ; i ++ )
	{
		cout << a << " ";
		a++;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
w,h,x,y,r=map(int,input().split())

sum_x=x+r
sum_y=y+r
f=0
if r>x or r>y:
    f=1
if abs(sum_x)>w:
    f=1
if abs(sum_y)>h:
    f=1
if f==0:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 5592
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  ll t=1;
  while(t--)
  {
    string s;
    cin>>s;
    int count=0;
    ll ans=0;
    REP(i,s.length())
    {
        if(s[i]=='B')
        {
            count++;
        }
        else
        {
            ans+=count;
        }
    }
    cout<<ans;
  }  
  return 0;
}

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

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<int> a;
	for(int i = 0; i < N; ++i) {
		int t;
		cin >> t;
		--t;
		a.push_back(t);
	}
	int res = 0;
	for(int i = 0; i < N; ++i) {
		if(i < a[i] && a[a[i]] == i) {
			++res;
		}
	}
	cout << res << '\n';
	return 0;
}



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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

int main() {
  llong N;
  vector<string> S;
  map<string, int> m;

  cin >> N;
  S.resize(N);
  for (auto &in: S) {
    cin >> in;
    m[in]++;
  }

  cout << "AC x " << m["AC"] << endl;
  cout << "WA x " << m["WA"] << endl;
  cout << "TLE x " << m["TLE"] << endl;
  cout << "RE x " << m["RE"] << endl;

  return 0;
}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int A, B;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> A >> B;
    for(int i = 1; i <= 3; i++) {
        if(A != i and B != i) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  vector<int> b(n);
  range(i, 0, n) {
    cin >> b[i];
    b[i] -= i;
  }
  long long res = 0;
  map<int, int> pos;
  map<int, int> p;
  range(i, 0, n) {
    if(b[i] < -i || b[i] > 0) {
      cout << -1;
      return 0;
    }
    pos[-b[i]] = i;
    if(p.find(-b[i]) == p.end()) p[-b[i]] = i;
  }
  int cur = -1;
  for(auto it : pos) {
    if(p[it.first] < cur) {
      cout << -1;
      return 0;
    }
    cur = max(cur, it.second);
    res += it.second - it.first;
  }
  cout << res;
  return 0;
}


Measured memory_bytes: 19840
<?php

$is_honban = 1;

if ($is_honban) {
  //----------------------------------------------------------------------------------
  // Input for honban
  //----------------------------------------------------------------------------------
  $sc = new Scanner();
  $n = $sc->nextInt();
  $a = array();
  for ($i = 0; $i < $n; $i++) {
    $a[] = $sc->nextInt();
  }



} else {
  //----------------------------------------------------------------------------------
  // Input for test
  //----------------------------------------------------------------------------------
  error_reporting(E_ERROR | E_WARNING | E_PARSE);

  $n = 4;
  $a = array(2,7,4);



}
//----------------------------------------------------------------------------------
// Main
//----------------------------------------------------------------------------------

$ans = 0;

rsort($a);
$alice = 0;
$bob = 0;
for ($i = 0; $i < $n; $i++) {
  if ($i % 2 == 0) {
    $alice += $a[$i];
  } else {
    $bob += $a[$i];
  }
}

$ans = $alice - $bob;

//----------------------------------------------------------------------------------
// Output
//----------------------------------------------------------------------------------
out::println($ans);



//----------------------------------------------------------------------------------
// Ref: https://qiita.com/yoshikyoto/items/6924478283dbdd549e4b
//----------------------------------------------------------------------------------
class Scanner {
  private $arr = array();
  private $count = 0;
  private $pointer = 0;
  public function next() {
    if($this->pointer >= $this->count) {
      $str = trim(fgets(STDIN));
      $this->arr = explode(' ', $str);
      $this->count = count($this->arr);
      $this->pointer = 0;
    }
    $result = $this->arr[$this->pointer];
    $this->pointer++;
    return $result;
  }
  public function hasNext() {
    return $this->pointer < $this->count;
  }
  public function nextInt() {
    return (int)$this->next();
  }
  public function nextDouble() {
    return (double)$this->next();
  }
}

class out {
  public static function println($str = "") {
    echo $str . PHP_EOL;
  }
}

?>


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

int main(){
    int N,X,Y;
    cin>>N>>X>>Y;
    int k = N-1;
    vector<int> x(N);
    vector<int> y(N);
    for(int i=0;i<N;i++){
        int I=i+1;
        if(X>=I){
            x.at(i)=X-I;
        }
        else{
            x.at(i)=I-X;
        }
        if(Y>=I){
            y.at(i)=Y-I;
        }
        else{
            y.at(i)=I-Y;
        }
    }
    map<int,int> mp;
    for(int i=1;i<N;i++){
        for(int j=i+1;j<=N;j++){
            vector<int> Ans(3);
            Ans.at(0)=j-i;
            Ans.at(1)=x.at(i-1)+y.at(j-1)+1;
            Ans.at(2)=y.at(i-1)+x.at(j-1)+1;
            sort(Ans.begin(),Ans.end());
            mp[Ans.at(0)]++;
            //cout<<i<<" "<<j<<" "<<Ans.at(0)<<endl;
        }
    }
    for(int i=1;i<=k;i++){
        cout<<mp[i]<<endl;
    }
}

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

int main(){
  int N,A1[100],A2[100],Answer = 0,down_point = 0,now = 0;
  cin >> N;
  for (int j = 0; j <= N-1 ; j++){
    cin >> A1[j];
  }
  for (int j = 0; j <= N-1 ; j++){
    cin >> A2[j];
  }
  /////////////////////////////////////////
  while(down_point <= N-1){
    for(int i = 0; i <= down_point; i++){
      now += A1[i];
    }
    for(int i = down_point; i <= N-1; i++){
      now += A2[i];
    }
    if (Answer <= now){
      Answer = now;
    }
  now = 0;
  down_point ++;
  }
  cout <<Answer <<endl;
}


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

using namespace std;

long long lcm(long long a,long long b){
    return a*b/__gcd(a,b);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);      cout.tie(0);

    long long n,m;
    cin>>n>>m;
    vector<long long> v(n);
    long long lc=1ll;
    for(int i=0;i<n;i++){
        long long tm;
        cin>>tm;
        tm/=2ll;
        lc=lcm(lc,tm);
        v[i]=2ll*tm;
    }
    int f1=0,f2=0;
    for(int i=0;i<n;i++){
        if((lc)%v[i]==0ll){
            f1=f2=1;
        }
    }
    if(f1&&f2)
        cout<<0;
    else
        cout<<(m/lc)/2ll+((m/lc)%2ll)<<'\n';
    return 0;
}
/***
4 3 2 3
1 4 1 100
1 2 1 10
1 3 20 1
*/


Measured memory_bytes: 3932
from math import gcd

#####segfunc#####
def segfunc(x, y):
    # return min(x, y) #最小値
    # return max(x, y) #最大値
    # return x + y #区間和
    # return x * y #区間積
    return gcd(x, y) # 最大公約数

#################
INF = float("inf")
#####ide_ele 単位元#####
# ide_ele = INF
# ide_ele = -INF
# ide_ele = 0
# ide_ele = 1
ide_ele = 0

#################

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

N = int(input())
A = list(map(int,input().split()))
ans = 1
seg_tree = SegTree(A, segfunc, ide_ele)
for i in range(N):
    ans = max(ans, gcd(seg_tree.query(0, i), seg_tree.query(i+1, N)))
print(ans)

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

using namespace std;

typedef long long ll;

template<typename T>
void _dump(const char* s, T&& head)
{
  cerr << s << "=" << head << endl;
}

template<typename T, typename... Args>
void _dump(const char* s, T&& head, Args&&... tail)
{
  while (*s != ',')
    cerr << *s++;
  cerr << "=" << head << ",";
  _dump(s + 1, tail...);
}

template<typename T>
void _dumpv(const char* s, T&& v)
{
  cerr << *s << "=";
  for (auto it = v.begin(); it != v.end(); it++) {
    cerr << *it << " ";
  }
  cerr << endl;
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__)
#define dumpv(...) _dumpv(#__VA_ARGS__, __VA_ARGS__)

const ll MOD = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("template.1", "r", stdin);

  int N, M, C;
  cin >> N >> M >> C;
  dump(N, M, C);
  vector<int> B(M + 1);
  int i, j;
  for (i = 1; i <= M; i++) {
    cin >> B[i];
  }
  dumpv(B);
  // vector<vector<int>> A(N + 1);
  vector<vector<int>> A = vector<vector<int>>(N + 1, vector<int>(M + 1, 0));
  for (j = 1; j <= N; j++) {
    for (i = 1; i <= M; i++) {
      cin >> A[j][i];
    }
  }
  for (int y = 1; y <= N; y++) {
    dumpv(A[y]);
  }
  int ans = 0;
  for (j = 1; j <= N; j++) {
    int acc = C;
    for (i = 1; i <= M; i++) {
      acc += A[j][i] * B[i];
    }
    if (acc > 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,m,n) for(ll i = (m); i < (n); i++)
#define all(v) v.begin(), v.end()
#define print(x) cout << (x) << endl
//宣言
ll N,M;
vector<int> num,s,c;

void solve(){
    bool ans = true;

    rep(i,M) {
        int idx = s[i]-1,val = c[i];
        if(num[idx] == -1){
            num[idx] = val;
            if(N >=2 && idx == 0 && val == 0) ans = false; 
        }else if(num[idx] != val) ans = false;
    }
    rep(i,N){
        if(num[i] == -1){
            if(N >= 2 && i == 0) num[i] = 1;
            else num[i] = 0;
        }
    }
    
    if(ans) rep(i,N) cout << num[i];
    else cout <<-1;
    cout << endl;
}

int main() {
    //入力忘れるなよ～//vec = vector<ll>(N,0);もね
    cin >> N >> M;
    num = vector<int>(N,-1);
    s = vector<int>(M);
    c = vector<int>(M);

    rep(i,M){
        cin >> s[i] >> c[i];
    }

    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
const ll MOD=1000000007;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const vector<pll> dir={{0,1},{1,0},{-1,0},{0,-1},{1,1},{-1,1},{1,-1},{-1,-1}};
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=b-1;i>=a;i--)
#define range(i) (i).begin(),(i).end()
#define rrange(i) (i).rbegin(),(i).rend()
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll lcm (ll a,ll b) {return a*b/gcd(a,b);}
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
inline constexpr int modf(ll n){
    ll ans=1;
    rep(i,0,n) {ans=ans*(n-i)%MOD;}
    return ans;
}

vector<ll> func,inv;
void init(ll n){
    func.resize(n+1);inv.resize(n+1);
    func[0]=1;
    rep(i,0,n) {func[i+1]=func[i]*(i+1)%MOD;}
    inv[n]=intpow(func[n],MOD-2);
    rrep(i,1,n+1) {inv[i-1]=inv[i]*i%MOD;}
}
ll comb(ll a,ll b) {return func[a]*inv[b]%MOD*inv[a-b]%MOD;}

inline long double median(vector<ll> v){
    ll size=v.size();
    sort(v.begin(),v.end());
    if (size % 2 == 1) return v[(size - 1) / 2];
    else return v[(size / 2) - 1] ;
}
template<class T> inline bool chmax(T& a,T b) {if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b) {if(a>b){a=b;return 1;} return 0;}

int main(){
    ll n;
    cin>>n;
    cout<<n*(n-1)/2;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 10

void BubbleSort(int *a, int n);

int main(void){
  int i, Mt[N];

  for(i = 0; i < N; i++){
    scanf("%d", &Mt[i]);
  }
  BubbleSort(Mt, N);

  for(i = 0; i < 3; i++){
    printf("%d\n", Mt[N-1-i]);
  }
  return 0;
}


void BubbleSort(int *a, int n){
  int i, j, temp;

  for(i = n-1; i > 0; i--){
    for(j = 0; j < i; j++){
      if(a[j] > a[j+1]){
	temp = a[j];
	a[j] = a[j+1];
	a[j+1] = temp;
      }
    }
  }
}

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

using namespace std;

using ll = long long;
using Vector = vector<ll>;
using Matrix = vector<Vector>;

void Multiple(Matrix &l, const Matrix &r, const int MOD) {
    const int n = l.size();
    Matrix res(n, Vector(n));
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            for (int k = 0; k < n; ++k)
                (res[i][j] += l[i][k] * r[k][j]) %= MOD;
    l = move(res);
}

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

    ll n, k;
    cin >> n >> k;

    Matrix a(n, Vector(n)), x(n, Vector(n));
    for (int i = 0; i < n; ++i) {
        x[i][i] = 1;
        for (int j = 0; j < n; ++j)
            cin >> a[i][j];
    }

    constexpr ll MOD = 1e9 + 7;
    for ( ; 0 < k; k >>= 1) {
        if (k & 1) Multiple(x, a, MOD);
        Multiple(a, a, MOD);
    }

    ll res = 0;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            res = (res + x[i][j]) % MOD;

    cout << res << endl;

    return 0;
}


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

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
struct Card {
	char suit;
	int value;
	bool operator<(const Card &c) {
		return value < c.value;
	}
	bool operator>(const Card &c) {
		return value > c.value;
	}
	bool operator == (const Card &c) {
		return suit == c.suit&&value == c.value;
	}
};
void bubbleSort(vector<Card>v) {
	vector<Card>w(v);
	for (int i = 0; i < v.size(); i++) {
		for (int j = v.size() - 1; i < j; j--) {
			if (v[j - 1] > v[j])swap(v[j - 1], v[j]);
		}
	}
	rep(i, 0, v.size())cout << v[i].suit << v[i].value << (i == v.size() - 1 ? '\n' : ' ');

	for(int i=0;i<v.size()-1;i++)for(int j=i+1;j<v.size();j++)
		for(int a=0;a<v.size()-1;a++)for(int b=a+1;b<v.size();b++)
			if (w[i] == v[b] && w[j] == v[a]&&w[i].value==w[j].value) {
				cout << "Not stable" << endl;
				dump(i,j,a,b)	
				return;
			}
	cout << "Stable" << endl;
	return;
}
void selectionSort(vector<Card>v) {
	vector<Card>w(v);
	rep(i, 0, v.size()) {
		int index = i;
		rep(j, i + 1, v.size())if (v[index] > v[j])index = j;
		swap(v[i], v[index]);
	}
	rep(i, 0, v.size())cout << v[i].suit << v[i].value << (i == v.size() - 1 ? '\n' : ' ');

	for (int i = 0; i<v.size() - 1; i++)for (int j = i + 1; j<v.size(); j++)
		for (int a = 0; a<v.size() - 1; a++)for (int b = a + 1; b<v.size(); b++)
			if (w[i] == v[b] && w[j] == v[a]&& w[i].value == w[j].value) {
				cout << "Not stable" << endl;
				return;
			}
	cout << "Stable" << endl;
	return;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<Card>v(N);
	rep(i, 0, N) {
		cin >> v[i].suit >> v[i].value;
	}
	bubbleSort(v);
	selectionSort(v);
	return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;

int main() {
  int N; cin >> N;
  vector<int> p(N); REP(i,N) cin >> p[i];
  REP(i,N) p[i]--;
  bool f = false;
  int ans = 0;
  REP(i,N) {
    if (f) f = false;
    else if (i==p[i]) {
        ans++;
        f = true;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		ll n;
		cin >> n;
		ll x = ceil((double)n/(double)1000);
		//cerr << imie(x);
		ll res = (1000*x)-n;
		cout << res << endl;
		return 0;  
}  


Measured memory_bytes: 3728
#include<iostream>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
double pi= 3.14159265358979323846;
int main(){
	int R;
	cin>>R;
	printf("%.20lf\n",2*pi*R);
	return 0;
} 
//458.67252742410977361942
//458.67252742410977361942

//6.28318530717958623200
//6.28318530717958623200

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

int main() {
  int64_t X;
  cin >> X;
  int64_t a = 100,count = 0;
  for (int i = 0; i < 4000; i++) {
    if (a >= X)
      break;
    a += a / 100;
    count++;
  }
  cout << count << endl;
      
    
  
}

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

int main(){
  string n;
  cin >> n;
  
  int a = 0, ans = 0;
  for (int i=0 ; i<3 ; i++){
    if (a == 2){
      ans = 1;
      break;
    }
    if (n.at(i) == n.at(i+1))
      a++;
    else
      a = 0;
  }
  if (a == 2)
    ans = 1;
  
  if (ans == 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3536
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  string s;cin>>s;
  rep(i,s.size()-1){
    if(s[i]=='B'&&s[i+1]=='C'){
      s=s.replace(i,2,"D");
      i--;
    }
  }
  ll count=0;
  ll part=0;
  rep(i,s.size()){
    if(s[i]=='A')part++;
    else if(s[i]=='D')count+=part;
    else part=0;
  }
  cout<<count<<endl;
}
  
  

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

using namespace std;

int main() {
	int d;
	int seki;
	int yaku;
	int sum = 0;

	while (cin >> d) {
		yaku = 600 / d - 1;

		for (int i = 0; i < yaku; i++) {
			seki = d * d * d * (i + 1) * (i + 1);
			sum += seki;
		}

		cout << sum << endl;
		sum = 0;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<cstdio>

int min(int a,int b){return a<b?a:b;}

int main()
{
    int n,k,ans=1;scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++) ans+=min(ans,k);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define r(i, n) for (int i=0;i<n;i++)
using namespace std;
int main() {
  string s,t="Yes";
  cin >> s;
  for (int i=0; i<s.length(); i+=2) {
    if (s.at(i)=='L') t="No";
  }
  for (int i=1; i<s.length(); i+=2) {
    if (s.at(i)=='R') t="No";
  }
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

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

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  ll b = B - (B / C + B / D) + (B / lcm(C, D));
  ll a = (A - 1) - ((A - 1) / C + (A - 1) / D) + ((A - 1) / lcm(C, D));
  cout << b - a << endl;

  return 0;
}


Measured memory_bytes: 256
from sys import stdin
import itertools as it
import functools as fc


def fin(f):
    return f(input())


def gin(f, n=1):
    for _ in range(n):
        yield list(map(f, stdin.readline().split()))


def lin(f):
    return next(gin(f))


N = fin(int)

S = fin(list)

ans = [""]
for s in S:
    if not ans[-1] == s:
        ans.append(s)

print(len("".join(ans[1:])))



Measured memory_bytes: 6060