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

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

#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define ferrari ios_base::sync_with_stdio(false); cin.tie(NULL)

const ll mod = 1e9 + 7; // 998244353
const ll INF = 1e18;
const int inf = 2e9;
const int N = 200100;

int n, pos[N];
ll a[N], ans;
set<int> inds;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];	
		pos[a[i]] = i;
	}
	inds.insert(0);
	inds.insert(n + 1);
	for (int i = 1; i <= n; i++) {
		int R = *inds.upper_bound(pos[i]);
		auto it = inds.lower_bound(pos[i]);
		it--;
		int L = *it;
		ans += 1LL * (pos[i] - L) * (R - pos[i]) * i;
		inds.insert(pos[i]);
	}
	cout << ans << '\n';
}


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

using namespace std;

const int ATOZ = 26;

vector<int> satisfaction(const vector<int>& c, const vector<vector<int> >& s, const vector<int>& t, map<int, int>& last) {
    vector<int> v(s.size(), 0);
    for (int d = 0; d < s.size(); ++d) {
        v[d] = v[d - 1] + s[d][t[d]];
        last[t[d]] = d;
        for (int i = 0; i < ATOZ; ++i) {
            v[d] -= c[i] * (d - last[i]);
        }
    }
    return v;
}

void Main() {
    int D;
    cin >> D;
    vector<int> c(ATOZ, 0);
    for (int i = 0; i < ATOZ; ++i) {
        cin >> c[i];
    }
    vector<vector<int> > s(D, vector<int>(ATOZ, 0));
    for (int i = 0; i < D; ++i) {
        for (int j = 0; j < ATOZ; ++j) {
            cin >> s[i][j];
        }
    }

    vector<int> t(D, 0);
    for (int i = 0; i < D; ++i) {
        cin >> t[i];
        t[i] -= 1;
    }

    map<int, int> last;
    for (int i = 0; i < ATOZ; ++i) {
        last.insert(make_pair(i, -1));
    }

    vector<int> v = satisfaction(c, s, t, last);
    for (int d = 0; d < D; ++d) {
        cout << v[d] << endl;
    }
}


int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3652
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
const int INF = 0x7fffffff;

int H;
int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}

void maxHeapify(vector<int>* a,int ii){
  int l,r;
  l = ii*2+1;
  r = ii*2+2;
  int largest;

  if(l < H && a->at(l) > a->at(ii)){
    largest = l;
  }
  else{
    largest = ii;
  }

  if(r < H && a->at(r) > a->at(largest)){
    largest = r;
  }

  if(largest != ii){
    int sw;
    sw = a->at(ii);
    a->at(ii) = a->at(largest);
    a->at(largest) = sw;
    maxHeapify(a,largest);
  }
}

void buildMaxHeap(vector<int>* a){
  int ii;
  for(ii=H-1;ii>=0;ii--){
    maxHeapify(a,ii);
  }
}

int main(){
  long ii,jj,kk;
  vector<int> a;
  int n;

  cin >> H;
  a.resize(H);

  for(ii=0;ii<H;ii++){
    cin >> a[ii];
  }

  buildMaxHeap(&a);

  for(ii=0;ii<H;ii++){
    cout << " " << a[ii];
  }
  cout << endl;
  
  return 0;
}



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

using namespace std;

constexpr int nmax = 1e5+5;
int dp[nmax];
char s[nmax];
int n;

bool check(int x, const char* w) {
  for (int i = 0; w[i]; i++) {
    if (x + i == n + 1) return false;
    if (s[x + i] != w[i]) return false;
  }
  return true;
}

int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  dp[n + 1] = 1;
  for (int i = n; i >= 1; --i) {
    dp[i] |= dp[i + 5] && check(i, "dream");
    dp[i] |= dp[i + 5] && check(i, "erase");
    dp[i] |= dp[i + 6] && check(i, "eraser");
    dp[i] |= dp[i + 7] && check(i, "dreamer");
  }

  return 0 * printf("%s\n", dp[1] ? "YES" : "NO");
}


Measured memory_bytes: 768
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
using namespace std;
int main(void){
    int x1,x2,y1,y2; cin >> x1 >> y1 >> x2 >> y2;
    int Xdiff = x1-x2;
    int Ydiff = y1-y2;
    int x3 = Ydiff + x2;
    int y3 = y2 - Xdiff;
    int x4 = x3 + Xdiff;
    int y4 = y3 + Ydiff;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << " " << endl;

}

Measured memory_bytes: 3624
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right){
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for ( k = left; k < right; k++ ){
    if ( L[i].value <= R[j].value ){
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}
 
void mergeSort(struct Card A[], int n, int left, int right ){
  int mid;
  if ( left+1 < right ){
    mid = (left + right)/2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int partition(struct Card A[], int n, int p, int r){
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p - 1;
  for ( j = p; j < r; j++ ){
    if ( A[j].value <= x.value ){
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  }
  t = A[i+1]; A[i+1] = A[r]; A[r] = t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r){
  int q;
  if ( p < r ){
    q = partition(A, n, p, r);
    quickSort(A, n, p, q - 1);
    quickSort(A, n, q + 1, r);
  }
}

main(){
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    scanf("%s %d", S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n-1);

  for ( i = 0; i < n; i++ ){
    if ( A[i].suit != B[i].suit ) stable = 0;
  }

  if ( stable == 1 ) printf("Stable\n");
  else printf("Not stable\n");
  for ( i = 0; i < n; i++ ) {
    printf("%c %d\n", B[i].suit, B[i].value);
  }
}


Measured memory_bytes: 4060
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;

#define all(c) begin(c), end(c)

const int MOD = 1e9 + 7;
string A, B, C;
int a[55], b[55], c[55];

int main() {
    while (cin >> A >> B >> C && A != "0") {
        reverse(all(A));
        reverse(all(B));
        reverse(all(C));
        int n = A.size();
        for (size_t i = 0; i < n; i++) {
            a[i] = isdigit(A[i]) ? A[i] - '0' : -1;
            b[i] = isdigit(B[i]) ? B[i] - '0' : -1;
            c[i] = isdigit(C[i]) ? C[i] - '0' : -1;
        }
        
        int dp[55][2] = {};
        dp[0][0] = 1;
        for (size_t i = 0; i < n; i++) {
            for (size_t j = 0; j < 2; j++) {
                for (size_t ia = 0; ia < 10; ia++) {
                    for (size_t ib = 0; ib < 10; ib++) {
                        for (size_t ic = 0; ic < 10; ic++) {
                            if (a[i] != -1 && ia != a[i]) continue;
                            if (b[i] != -1 && ib != b[i]) continue;
                            if (c[i] != -1 && ic != c[i]) continue;
                            if (i == n - 1 && (ia == 0 || ib == 0 || ic == 0)) continue;
                            int dig = ia + ib + j;
                            if (dig % 10 != ic) continue;
                            (dp[i + 1][dig >= 10] += dp[i][j]) %= MOD;
                        }
                    }
                }

            }
        }
        cout << dp[n][0] << endl;
    }
}

Measured memory_bytes: 3216
#include<iostream>


int main(int argc, char const *argv[])
{
    unsigned long long n,m,d;
    std::cin >> n >> m >> d;

    if(d==0)
    {
        double a = n;
        double b = n*n;
        double all_pairs = m-1;
        // printf("%f %f %f\n", a, b, all_pairs);
        printf("%.10f\n", (a/b)*all_pairs);
    }
    else
    {
        double a = 2*(n-d);
        double b = n*n;
        double all_pairs = m-1;
        // printf("%f %f %f\n", a, b, all_pairs);
        printf("%.10f\n", (a/b)*all_pairs);
    }
    return 0;
}


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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

// const ll mod = 1000000007;
const ll mod = 998244353;

const int MAX_N = 300010;
ll fact[MAX_N],fact_inv[MAX_N],inv[MAX_N];

ll pow(ll a,ll b) {
    ll ret;
    if (b == 0) ret = 1;
    else if (b == 1) ret = a;
    else {
        ll c = pow(a,b/2);
        if (b%2) ret = (c*c)%mod*a%mod;
        else ret = c*c%mod;
    }
    return ret;
}

void create_table(int n) {
    fact[0] = 1;fact[1] = 1;
    for (int i = 2;i <= n;++i) fact[i] = fact[i-1]*i%mod;
    fact_inv[n] = pow(fact[n],mod-2);
    for (int i = n;i > 0;--i) fact_inv[i-1] = fact_inv[i]*i%mod;
    for (int i = 1;i <= n;++i) inv[i] = fact_inv[i]*fact[i-1]%mod;
}

ll combi(ll a, ll b) {
    return fact[a]*fact_inv[b]%mod*fact_inv[a-b]%mod;
}

int main() {
    ll n,a,b,k;
    cin >> n >> a >> b >> k;
    create_table(n);
    ll ans = 0;
    for (int i = 0;i <= n;++i) if (k >= a*i && (k-a*i)%b == 0 && (k-a*i)/b <= n) {
        ans += combi(n,i)*combi(n,(k-a*i)/b)%mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7296
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
BC = []
for i in range(Q):
    BC.append(list(map(int,input().split())))

num = [0]*(10**5+1)
#num = [0]*100000  #後で変える
S = []

#1 iterlation
S.append(sum(A))
#print('S0:', S[0])  #############
for i in range(N):
    num[A[i]]+=1
#print('num0:', num)  ########

for j in range(Q):
    if num[BC[j][0]] != 0:
        B = BC[j][0]
        C = BC[j][1]
        #print('B,C:', B,C)  ##########
        S.append(S[-1] + (C - B)*num[B] )
        #num[B] -=1
        dammy = num[B]
        num[B] = 0
        num[C] += dammy
        #print('num:', num)  ########
        #print('S:',S)   #############

    else:
        B = BC[j][0]
        C = BC[j][1]
        #print('B,C:', B,C)  ##########
        #print('yaaaaaah')  ########
        S.append(S[-1])
        #print('S:',S)   ##########


#print('finalS:', S)   #############

for i in range(1,Q+1):
    print(S[i])


Measured memory_bytes: 98132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Vec  =vector<int>;

bool		is_mm(char a, char b)
{
	if (a > '1')
		return (0);
	if (a == '1' && b > '2')
		return (0);
	if (a == '0' && b == '0')
		return (0);
	return (1);
}

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

	bool f1, f2;
	f1 = is_mm(s[0], s[1]);
	f2 = is_mm(s[2], s[3]);
	if (f1 && f2)
		cout << "AMBIGUOUS" << endl;
	else if (f1 && !f2)
		cout << "MMYY" << endl;
	else if (!f1 && f2)
		cout << "YYMM" << endl;
	else
		cout << "NA" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;

int main(){
    int n; cin >> n;
    ll a[n+1] = {0};
    REP(i,1,n+1)cin >> a[i];
    REP(i,1,n+1){
        printf("node %lld: key = %lld, ", i, a[i]);
        if(i != 1)printf("parent key = %lld, ", a[i/2]);
        if(2*i <= n)printf("left key = %lld, ", a[2*i]);
        if(2*i + 1 <= n)printf("right key = %lld, ", a[2*i + 1]);
        cout << endl;
    }
    return 0;
}


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

int main(){
    int a[13]={0,1,3,1,2,1,2,1,1,2,1,2,1};
    int x,y;
    cin>>x>>y;
    cout<<(a[x]==a[y]?"Yes":"No")<<endl;
    return 0;
}

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

int main() {
  int N, K, x, sum;
  x = 0;
  sum = 0;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    cin >> x;
    if(x >= K - x){
      sum += K - x;
    }
    else{
      sum += x;
    }
  }
  cout << sum*2 << endl;   
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

int gcd(int a, int b) {//最大公約数
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {//最小公倍数
	int g = gcd(a, b);
	return a / g * b;
}

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

	int A, B, C, D;
	cin >> A >> B >> C >> D;
	A--;
	int sum = B-(B / C + B / D);
	//cout << sum << endl;
	sum += (B / lcm(C,D));
	//cout << sum << endl;

	int cnt = A - (A / C + A / D);
	//cout << cnt << endl;
	cnt += (A / lcm(C,D));
	//cout << cnt << endl;

	cout << sum - cnt << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	int a, b;
	cin >> a >> b;
	if (a == b) cout << "Draw";
	else if (((a > b) && (b != 1)) || (a == 1)) cout << "Alice";
	else cout << "Bob";

	return 0;
}



Measured memory_bytes: 256
#n番目をxに変更して更新する
def seg_tree_update(n,x):
    ind=2**m-1+n
    tree[ind]=x
    ind=(ind-1)//2
    while ind>=0:
        tree[ind]=max(tree[2*ind+1],tree[2*ind+2])
        ind=(ind-1)//2

#区間[L,R]における最大値を返す(非負整数)
def seg_tree_find_max(L,R):
    L,R=2**m-1+L,2**m-1+R
    qqq=0
    while L<R:
        if L%2==0:
            qqq=max(qqq,tree[L])
        if R%2==1:
            qqq=max(qqq,tree[R])
        L//=2
        R=R//2-1
        
    if L==R:
        qqq=max(qqq,tree[L])
    return qqq
  
N=int(input())
h=list(map(int,input().split()))
a=list(map(int,input().split()))

m=0
while pow(2,m)<N+1:
    m+=1
tree=[0]*(pow(2,m+1)-1)

for i in range(N):
    M=seg_tree_find_max(0,h[i])
    if tree[2**m-1+h[i]]<a[i]+M:
        seg_tree_update(h[i],a[i]+M)

ans=0
for i in range(N+1):
    ans=max(ans,tree[2**m-1+i])

print(ans)

Measured memory_bytes: 123856
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
  cin>>n>>m;
  if(n==m)
  {
	cout<<"Yes"<<endl;
  }
  else if(m>n)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using i64 = long long;

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

template <class T>
std::vector<T> getDivisors(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    std::sort(ret.begin(), ret.end());
    return ret;
}

int main() {
    i64 a, b;
    std::cin >> a >> b;
    i64 g = gcd(a, b);
    auto ds = getDivisors(g);

    std::vector<i64> r;
    for (auto d : ds) {
        bool flg = true;
        for (int i = 0; flg && i < r.size(); i++) {
            if (gcd(d, r[i]) > 1) flg = false;
        }
        if (flg) r.push_back(d);
    }

    std::cout << r.size() << std::endl;

    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int A = sc.nextInt();
		int h[] = new int[N];
		double k[] = new double[N];
		double l[] = new double[N];
		
		for (int i=0; i<N; i++){
			k[i] = T-(sc.nextInt()*0.006);
			if (A > k[i]){
				l[i] = A - k[i];
			}
			else {
				l[i] = k[i] - A;
			}
		}
		
		int kai = 0;
		double tmp = 0;
		for (int i=0; i<N; i++){
			if (i == 0){
				kai = 0;
				tmp = l[i];
			}
			else {
				if (tmp > l[i]){
					kai = i;
					tmp = l[i];
				}
			}
		}
		
		
		
		
		System.out.println(kai+1);
		
		return;
		
		
	}
	
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

int dfs(int s, vector<vector<int>>& G, vector<bool>& calculated, vector<int>& memo){
    if(memo[s] > 0){
        if(!calculated[s]) return -1;
        else return memo[s];
    }
    memo[s] = 1;
    for(int v: G[s]){
        int ret = dfs(v, G, calculated, memo);
        if(ret == -1) return -1;
        memo[s] = max(memo[s], ret+1);
    }
    calculated[s] = true;
    return memo[s];
}

int main()
{
    int N;
    cin >> N;
    vector<vector<int>> A(N, vector<int>(N-1));
    REP(i, N){
        REP(j, N-1){
            cin >> A[i][j];
            --A[i][j];
        }
    }

    // 各試合を頂点と見立てて id を振る
    vector<vector<int>> id(N, vector<int>(N));
    int count = 0;
    REP(i, N){
        FOR(j, i+1, N){  // i < j とする
            id[i][j] = count;
            ++count;
        }
    }
    REP(i, N){ // i > j も作っておく
        REP(j, i) id[i][j] = id[j][i];
    }

    // 有向グラフを作る
    vector<vector<int>> G(N*(N-1)/2);
    REP(i, N){
        REP(j, N-2){
            G[id[i][A[i][j]]].push_back(id[i][A[i][j+1]]);
        }
    }

    // グラフの最長経路を探索
    int ans = 0;
    vector<int> memo(N*(N-1)/2, 0); // max length of path from v
    vector<bool> calculated(N*(N-1)/2, false); // cycle detection
    REP(i, N*(N-1)/2){
        int ret = dfs(i, G, calculated, memo);
        if(ret == -1){ // 閉路があったらだめ
            ans = -1;
            break;
        }
        ans = max(ans, ret);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 37632
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    int sl=s.length();
    string ans="yes";
    rep(i,sl){
        rep(j,sl){
            if(i!=j){
                if(s[i]==s[j]){
                    ans="no";
                }
            }
        }
    }
    cout<<ans<<endl;
}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    string s, t;
    cin >> s >> t;
    Int res = 0;
    for (Int i = 0; i < (Int)s.size(); i++) {
        if (s[i] != t[i]) res++;
    }
    print(res);
    return 0;
}

Measured memory_bytes: 3860
n = int(input())
a = [int(x) for x in input().split()]

x = a[0]
y = sum(a[1:])
ans = abs(x-y)

for i in range(1, n-1):
    x += a[i]
    y -= a[i]
    ans = min(ans, abs(x-y))
print(ans)

Measured memory_bytes: 24832
A, B, C, X, Y = map(int, input().split())

total_AtoC = C * 2 * X + max((Y - X) * B, 0)
total_BtoC = C * 2 * Y + max((X - Y) * A, 0)
total_AB = A * X + B * Y

ans = min(total_AtoC, total_BtoC, total_AB)

print(ans)

Measured memory_bytes: 9092
import sys
sys.setrecursionlimit(10**9)
n = int(input())
t = [[] for _ in range(n)]
for i in range(n-1):
  a,b,c = map(int,input().split())
  t[a-1].append((b-1,c))
  t[b-1].append((a-1,c))
q,k = map(int,input().split())
k -= 1
l = [0]*n
def dfs(a,b,c):
  for i,j in t[b]:
    if i != a:
      l[i] = c+j
      dfs(b,i,c+j)
dfs(-1,k,0)
for _ in range(q):
  x,y = map(lambda x:int(x)-1,input().split())
  print(l[x]+l[y])

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

int main(){
    int flag=1,ans=0;
    int n;
    cin >> n;
    string pastw,w;
    
    map<string, int> m;
    
    cin >> pastw;
    m[pastw]=1;
    for (int i = 1; i < n; i++){
        cin >> w;

        if(pastw[pastw.size()-1]!= w[0]){
            flag=0;
            break;
        }
        if(m.find(w)!=m.end()){
            flag=0;
            break;
        }else{
            m[w]=1;
        }

        pastw = w;
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    if(flag==1)cout << "Yes" <<endl;
    else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
 


int main(){
     
    int n,m,t[100],p[100],x[100];
    long sum=0;
    
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>t[i];
        sum+=t[i];
    }
    cin>>m;
    for(int i=0;i<m;i++)cin>>p[i]>>x[i];
    for(int i=0;i<m;i++){
        cout<<sum-t[p[i]-1]+x[i]<<endl;
    }
     
    return 0;
}
 

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

typedef long long ll;
using namespace std;

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

    if (n == 3 || n == 5 || n == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

class Plogram
{
    static void Main()
    {
        var line = Console.ReadLine().Split();
        int N = int.Parse(line[0]);
        int Q = int.Parse(line[1]);
        string S = Console.ReadLine();

        int[] left = new int[Q];
        int[] right = new int[Q];
        int[] ans = new int[N];
        int count = 0;

        for(int i = 0; i < Q; i++)
        {
            var num = Console.ReadLine().Split().Select(x=>int.Parse(x)).ToArray();
            left[i] = num[0] - 1;
            right[i] = num[1] - 1;
        }

        for (int i = 1; i < N; i++)
        {
            if (S.Substring(i-1, 2) == "AC")
            {
                count++;
            }
            ans[i] = count;
        }

        for (int i = 0; i < Q; i++)
        {
            Console.WriteLine(ans[right[i]] - ans[left[i]]);
        }
    }
}


Measured memory_bytes: 19256
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

int vis[M+3];
vector<int>adj[M+3],abr_adj[M+2];
map<pi,bool>chk;
vector<pi>edg;
inline pi con(int x,int y){int a,b;a=min(x,y);b=max(x,y);return mp(a,b);}
vector<int>depth[M+4];
int last_lvl=0;
int out[M+3];
int dfs(int u,int lvl)
{
    vis[u]=true;
    depth[lvl].pb(u);
    last_lvl=max(last_lvl,lvl);
    for(auto v:adj[u])
    {
        if(vis[v]==false)
        {
             abr_adj[v].pb(u);
             chk[con(u,v)]=true;
             dfs(v,lvl+1);
        }
    }
}
vector<pi>ses;
 main()

{
    fast
    int n,m;
    cin>>n>>m;
    f(i,1,m)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
        edg.pb(con(u,v));
    }
    if(m%2==1)
    {
        cout<<"-1"<<endl;
        return 0;
    }
    dfs(1,0);
    f(i,0,m-1)
    {
         int u=edg[i].fi;
         int v=edg[i].si;
         if(chk[mp(u,v)]==false)
         {
               out[u]++;
               ses.pb(mp(u,v));
               chk[mp(u,v)]=true;
         }
    }
    rf(i,last_lvl,1)
    {

        for(auto x:depth[i])
        {

            if(out[x]%2==0)
            {
                 int p=abr_adj[x][0];
                 ses.pb(mp(p,x));
                 out[p]++;
            }
            else
            {
                 int p=abr_adj[x][0];
                 ses.pb(mp(x,p));
                 out[x]++;
            }
        }
    }
    for(auto x:ses)
    {
        cout<<x.fi<<" "<<x.si<<endl;
    }
    return 0;

}





































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

int main() {
  vector<int>data(5);
  int k;
  for(int i = 0;i < 5;i++){
    cin >> data.at(i);
  }
  cin >> k;
  for(int i = 0;i < 5;i++){
    for(int j = i;j < 5;j++){
      if(data.at(j)-data.at(i) > k){
        cout << ":(" << endl;
        goto end;
      }
    }
  }
  cout << "Yay!" << endl;
  end:;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int n,m;
long long sum,ans,a,k;
int main(){
	scanf("%lld%lld",&a,&k);
	ans=1;
	while(a--)
		ans=min(ans*2,ans+k);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,c;
    int i,count=0;
    scanf("%d %d %d",&a,&b,&c);

       for(i=a;i<=b;i++){
               if(c%i==0){
               count++;
           } 
       }

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


Measured memory_bytes: 2112
#include<queue>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define F(i,n,v) for(register int i=1;i<=n;i+=v)
#define R(i,n,v) for(register int i=n;i>=1;i-=v)
#define LL long long
#define mod 1000000007
#define inf 0x7ffffff
using namespace std;
inline int read();
inline int read()
{
	char c;
	while((c=getchar())<'0'||c>'9');
	int res=c-48;
	while((c=getchar())>='0'&&c<='9')
	   res=res*10+c-48;
	return res;
}const int MAX=10015;
bool prime(int x)
{
	for(int i=2;i<=sqrt(x);i++)
	if(x%i==0)return false;
	return true;
}int n,m,cnt,a[MAX];
int work()
{
	for(int i=n;i<=m;i++)
	if(m%i==0)return m/i;
}
int main()
{
	scanf("%d%d",&n,&m);
	if(prime(m)==true)printf("1");
	else 
	{
		if(m%n==0)printf("%d",m/n);
		else printf("%d",work());
	}
    return 0;
}

Measured memory_bytes: 256
hash = Hash.new(0)
n = gets.to_i
hash["AC"] = 0
hash["WA"] = 0
hash["TLE"] = 0
hash["RE"] = 0
n.times do
  s = gets.chomp
  hash[s] += 1
end
hash.to_a.each do |k,v|
  puts "#{k} x #{v}"
end

Measured memory_bytes: 14260
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

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

    std::map<std::string, std::vector<int>> mp;
    std::string s;
    int p;
    while (std::cin >> s >> p) { mp[s].push_back(p); }

    for (auto m : mp) {
        std::cout << m.first << std::endl;
        std::sort(m.second.begin(), m.second.end());
        int c = 0;
        for (auto x : m.second) {
            if (c++ == 0)
                std::cout << x;
            else
                std::cout << ' ' << x;
        }
        std::cout << std::endl;
    }
}

Measured memory_bytes: 3032
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <iterator>
#include <list>
#include <unordered_map>
#include <string>
#include <math.h>
#include <stdio.h>
using namespace std;

int main() {
	int n, cur = 0, max = 0;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'I') cur++;
		else if (s[i] == 'D') cur--;
		if (cur > max) max = cur;
	}
	cout << max;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();

		if (A <= 8 && B <= 8) {
			System.out.println("Yay!");
		} else {
			System.out.println(":(");
		}
    }
}

Measured memory_bytes: 21716
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atcoder1
{
    class Program
    {
        static void Main(string[] args)
        {
            string b=Console.ReadLine();
            if (b == "A")
            {
                Console.WriteLine("T");
            }
            else if (b == "T")
            {
                Console.WriteLine("A");
            }
            else if (b == "C")
            {
                Console.WriteLine("G");
            }
            else if (b == "G")
            {
                Console.WriteLine("C");
            }
            Console.Read();
        }
    }
}


Measured memory_bytes: 11092
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int ret = 0;
  for (int i = 0; i < n / 2; ++i) {
    if (s[i] != s[n - 1 - i]) ++ret;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
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(){
	int h,w,d;cin>>h>>w>>d;
	vector<ll> x(100005,0);
	vector<ll> y(100005,0);
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			ll p;cin>>p;
			x[p] = i + 1;y[p] = j + 1;
		}
	}

	int q;cin>>q;
	int i = 0;
	vector<ll> a(100005,0);
	while(i <= a.size()){
		if(i <= d){
			a[i] = 0;
		}
		else{
			a[i] = a[i - d] + abs(x[i] - x[i - d]) + abs(y[i] - y[i - d]);
		}
		i++;
	}
	for(int i = 0; i < q; i++) {
		int l,r;cin>>l>>r;
		cout << a[r] - a[l] << endl;
	}
	return 0;
}

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

using namespace std;

#define ll long long
#define ld long double
#define pll pair <ll , ll>

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair

#define X first
#define Y second

#define LB(x) ((x) & -(x))
#define BIT(a , b) (((a)>>(b)) & 1)

const ll maxn = 1e3 + 10;

ll a[maxn];

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

	ll n , res = 0;
	cin >> n;

	for (ll i = 1; i <= 2 * n; i++)
    {
        cin >> a[i];
    }

    sort(a + 1 , a + 2 * n + 1);

    for (ll i = 1; i <= n; i++)
    {
        res += a[2 * i - 1];
    }

    cout << res;
}


Measured memory_bytes: 3552
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    set<char> c;
    for (int i = 0; i < 4; i++) {
        c.insert(s[i]);
    }
    if (c.size() == 2) {
        string a;
        a.push_back(s[0]);
        for (int i = 1; i < 4; i++) {
            if (a[0] == s[i]) {
                a.push_back(s[i]);
            }
        }

        if (a.size() == 2) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import *
from heapq import*
import sys
input=sys.stdin.readline
d=defaultdict(list)
n=int(input())
 
for s in range(n-1):
    a,b,c=map(int,input().split())
    d[a].append([b,c])
    d[b].append([a,c])
#defaultdict(<class 'list'>, {1: [[2, 1], [3, 1]], 2: [[1, 1], [3, 3]], 3: [[1, 1], [2, 3]]})
 
def DIJKSTRA(point,d):
    cost      = {node:1e18 for node in d.keys()}
    Q         = []  #頂点のリスト
    cost[point]=0  #開始地点のコストをゼロとする（当たり前
    heappush(Q,(point,cost[point]))
    while Q:
        prefnd,tmpC=heappop(Q)
        if cost[prefnd]<tmpC:
            continue
        for node,c in d[prefnd]:
            altC=c+tmpC
            if cost[node]>altC:
                cost[node]=altC
                heappush(Q,(node,altC))
    return cost
 
q,k=map(int,input().split())
y=DIJKSTRA(k,d)
 
for i in range(q):
    a,b=map(int,input().split())
    print(y[a]+y[b])


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

int main () {
  int N, ans;
  cin >> N;
  ans = N;
  string S;
  cin >> S;
  for (int i = 0; i < N - 1; i++) {
    if (S[i] == S[i + 1]) {
      ans--;
    }
  }
  cout << ans;
}

Measured memory_bytes: 512
#include <stdio.h>

#define Max 100000

void  swap(int *x, int *y)
{
    int  buff;
	
	buff = *x;
	*x = *y;  
	*y = buff;
}

void printA(int A[Max], int N, int q) {
	int i;

	for (i = 0; i < N - 1; i++) {
		if (i == q) printf("[%d] ", A[i]);
		else printf("%d ", A[i]);
	}
	if (q == N - 1) printf("[%d] ", A[i]);
	else  printf("%d\n", A[N - 1]);
}

int partition(int A[Max], int p, int r) {
	int x = A[r];
	int i = p-1;
	int j;
	
	for (j = p; j < r; j++)
		if (A[j] <= x) swap(&A[++i], &A[j]);

	swap(&A[i + 1], &A[r]);

	return i + 1;
}

int main( ) {
	int N, i, q;
	int A[Max];

	scanf("%d", &N);

	for (i = 0; i < N; i++) scanf("%d", &A[i]);

	q = partition(A, 0, N - 1);

	printA(A, N, q);

	return 0;
}

Measured memory_bytes: 988
N, a, b = map(int, raw_input().split())
S = raw_input()
count = 0
count_b = 1
max = a + b

for i in range(N):
  if S[i]=='a':
    if count < max:
      print "Yes"
      count += 1
    else:
      print "No"
  elif S[i] == 'b':
    if count < max and count_b <= b:
      print "Yes"
      count += 1
    else:
      print "No"  
    count_b += 1
  else:
    print "No"

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

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    int count = n/x;
    if (n%x != 0) count++;
    cout << t * count << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint a[200100];
int main()
{
	int n;cin>>n;rep(i,n) cin>>a[i];
	sort(a,a+n);reverse(a,a+n);
	lint out=0;
	rep(i,n-1){
		out+=a[(i+1)/2];
	}
	cout<<out<<endl;
}


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

using namespace std;

#define watch(x) cout << (#x) << " is " << (x) << endl
#define watchArray(v) for(auto i : v) cout << i << " "; cout << endl;
#define all(v) (v).begin(), (v).end()

#define endl '\n'
#define MAX 100000
#define MOD 100000007
#define INF numeric_limits<int>::max()
#define INFLL numeric_limits<long long int>::max()

typedef long long int lli;
typedef long double ld;

string s1, s2, ans;
vector<vector<int>> mem;

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

  cin >> s1 >> s2;

  mem.assign(s1.size() + 1, vector<int>(s2.size() + 1, 0));

  for(int i = 1; i < s1.size() + 1; i++) {
    for(int j = 1; j < s2.size() + 1; j++) {
      if(s1[i-1] == s2[j-1]) mem[i][j] = mem[i-1][j-1] + 1;
      else mem[i][j] = max(mem[i-1][j], mem[i][j-1]);
    }
  }

  // for(auto i : mem) {
  //   watchArray(i);
  // }

  int i = s1.size(), j = s2.size();
  while(i != 0 or j != 0) {
    if(mem[i][j] == 0) break;
    if(s1[i-1] == s2[j-1]) {
      ans.push_back(s2[j-1]);
      i--;
      j--;
    } else if(mem[i-1][j] > mem[i][j-1]) i--;
    else j--;
  }

  reverse(all(ans));

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


Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>

using std::cout;
using std::cin;

void oneCase () {
    uint64_t n;
    cin >> n;
    uint64_t ms = n;
    for (uint64_t s = static_cast<uint64_t >(sqrt(n)) + 1; s > 0; --s) {
        if (n % s == 0) {
            ms = s + n / s;
            break;
        }
    }

    cout << ms - 2 << "\n";
}


int main() {
    int k = 1;
//    cin >> k;
    for (int i = 0; i < k; ++i) {
        oneCase();
    }

    return 0;
}

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

int main(){
    int h,a,m;
    cin >> h >> a;
    for(int i = 1; i <= h; i++){
        m = h - a * i;
        if(m <= 0){
            cout << i << endl;
            break;
        }
    
    }
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {r: i32}
    println!("{}", r * r);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define pb push_back
#define A first
#define B second
using namespace std;

typedef long long ll;
typedef pair <int, int> pi;
constexpr double PI = atan(1) * 4;
constexpr int inf = 0x3f3f3f3f;
inline int LSB(int i) {return (i & -i);}

int n, h[100005];
ll c[100005];

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

    cin >> n;
    for(int i = 0; i < n; i++){
    	cin >> h[i];
    	c[i] = 1e18 + 5;
    }
    c[0] = 0;
    for(int i = 0; i < n; i++){
    	if(i >= n - 1) continue;
    	c[i+1] = min(c[i+1], c[i] + abs(h[i+1] - h[i]));
    	if(i >= n - 2) continue;
    	c[i+2] = min(c[i+2], c[i] + abs(h[i+2] - h[i]));
    }
    cout << c[n-1] << endl;
    return 0;
}



Measured memory_bytes: 4800
def resolve():
    (N,M)=map(int,input().split())
    querys=[[int(j) for j in input().split()] for i in range(M)]
    querys.sort()
    now=[querys[0][0],querys[0][1]]
    count=1

    for i in range(1,len(querys)):
        
        if querys[i][0]<now[1]:
            now[1]=min(now[1],querys[i][1])
            now[0]=querys[i][0]

        else:
            now=[querys[i][0],querys[i][1]]
            count+=1

    print(count)



if __name__ == "__main__":
    resolve()

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


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

    int idx[15];
    pair<int,int> data[15];
    for (int i=1; i<=n; i++) {
        scanf("%d %d", &data[i].first, &data[i].second);
        idx[i] = i;
    }

    double res = 0;
    int cnt = 0;
    do {
        for (int i=2; i<=n; i++) {
            res += hypot(
                data[idx[i]].first - data[idx[i-1]].first,
                data[idx[i]].second - data[idx[i-1]].second
            );
        }
        cnt += 1;
    } while (next_permutation(idx+1, idx+1+n));

    printf("%.8lf", res / (double)cnt);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100

void selectionSort(int*,int);

int main(void){

	int A[N],n;
	int i=0;

	scanf("%d",&n);

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

	selectionSort(A,n);

	return 0;
}

void selectionSort(int *A, int n){

	int i,j,swap,minj,count=0;
	int a;

	//????´???????????????????
	for(i = 0; i < n; i++){
		//??????????´????????°??????¨?????????????????????????????????
		minj = i;
		//????°?????????????????????????????????????????????????
		for(j = i+1; j < n; j++){
			if(A[j] < A[minj]){
				minj = j;	
			}
		}
		if(i != minj){
			swap = A[i];
			A[i] = A[minj];
			A[minj] = swap;
			count++;
		}
	}

	for (i = 0; i < n-1; i++){
		printf("%d ",A[i]);
	}
	printf("%d\n",A[n-1]);
	printf("%d\n",count);
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b)
    {
        cout << c << endl;
    }
    else if (a == c)
    {
        cout << b << endl;
    }
    else
    {
        cout << a << endl;
    }
}

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

int main() {
	int n, ans;
	cin >> n;
	if (n >= 64)
		ans = 64;
	else if (n >= 32)
		ans = 32;
	else if (n >= 16)
		ans = 16;
	else if (n >= 8)
		ans = 8;
	else if (n >= 4)
		ans = 4;
	else if (n >= 2)
		ans = 2;
	else
		ans = 1;
	cout << ans << endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> cnt(pow(10,5));
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        cnt.at(a)++;
    }
    int ans=0;
    for(int i=1; i<cnt.size()-1; i++){
        ans = max(ans, cnt.at(i-1)+cnt.at(i)+cnt.at(i+1));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define all(v) v.begin(), v.end()
  #define mod INT_MAX 
  const int MOD=1e9+7;
  const int N=2e5+2;

  int32_t main()
  {
    /*#ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif*/
       IOS
       int x,y;
       cin>>x>>y;
       if(y<2*x or y>4*x or y&1)
       {
       	cout<<"No";
       }
       else
       	cout<<"Yes";
       return 0;
      }


Measured memory_bytes: 3604
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e18
#define flush fflush(stdout);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
//-------------------------------Template--Above------------------------------------------------
 
 
int main()
{
	boost
	ll n;
	cin>>n;
	ll a[n];
	vector<pair<ll,ll> > ans;
	priority_queue<ll,vector<ll>,greater<ll> > pq;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	ll last=-1;
	if(a[0]<0&&a[n-1]>=0)
	{
		for(ll i=0;i<n-1;i++)
		{
			if(i+1<n&&a[i+1]<0)
			{
				ans.pb(mp(a[n-1],a[i]));
				a[n-1]-=a[i];
			}
			else
			{
				last=i-1;
				break;
			}
		}
	}
	else if(a[0]<0&&a[n-1]<0)
	{
		for(ll i=0;i<n-1;i++)
		{
			ans.pb(mp(a[n-1],a[i]));
			a[n-1]-=a[i];
		}
		cout<<a[n-1]<<endl;
		for(ll i=0;i<ans.size();i++)
		{
			cout<<ans[i].fi<<" "<<ans[i].se<<endl;
		}
		return 0;
	}
	for(ll i=last+1;i<n;i++)
	{
		pq.push(a[i]);
	}
	while(!pq.empty())
	{
		ll mini=pq.top();
		pq.pop();
		if(pq.empty())
		{
			cout<<mini<<endl;
			break;
		}
		if(pq.size()!=1)
		{
			ans.pb(mp(mini,pq.top()));
			mini=mini-pq.top();
		}
		else
		{
			ans.pb(mp(pq.top(),mini));
			mini=pq.top()-mini;
			cout<<mini<<endl;
			break;
		}
		pq.pop();
		pq.push(mini);
	}
	for(ll i=0;i<ans.size();i++)
	{
		cout<<ans[i].fi<<" "<<ans[i].se<<endl;
	}
	return 0;
}

Measured memory_bytes: 5868