akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000100
#define LLINF 100000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N;
int c[100100][3];
int dp[100100][3];
int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		for(int j=0;j<3;j++){
			cin >> c[i][j];
		}
	}
	for(int i=0;i<3;i++)dp[0][i]=c[0][i];
	for(int i=1;i<N;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(j==k)continue;
				chmax(dp[i][j],dp[i-1][k]+c[i][j]);
			}
		}
	}
	int ans = 0;
	for(int i=0;i<3;i++)chmax(ans,dp[N-1][i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){fastio
    ll d,t,s;cin>>d>>t>>s;
    if(d>t*s){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }

    return 0;
}





Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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

  ll r = s.size()-1, ans = 0;
  for(ll i=s.size()-1; i>=0; i--){
    if(s[i] == 'B'){
      ans += r-i;
      r--;
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std; 

int main() { 

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	int n;
	cin >> n;

	vector<int> v(n);
	for(int i = 0; i < n; i++) {
		cin >> v[i];
	}

	sort(v.begin(), v.end());

	cout << v[n/2] - v[n/2-1];

	return 0; 
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<long long >A(N);
	for (int n = 0;n<N;++n) {
		cin >> A[n];
	}
	int half = (N + 1) / 2 -1;
	sort(A.begin(), A.end(),std::greater<int>());
	long long ans = -A[0]; 
	//cout << ans << endl;
	for (int n = 0;n<N/2;++n) {
		ans += 2 * A[n];
	}
	//cout << ans << endl;
	if ((N  % 2) == 1){ 
		ans += A[N / 2];
	}
	cout <<ans<<endl;
	return 0;
}

Measured memory_bytes: 4780
a = list(map(int,input().split()))
a_1 = list(map(int,input().split()))
a_2 = list(map(int,input().split()))

def kaijo(a) :
    k = 1
    for i in range(1,a+1) :
        k = k * i
    return k

def zyunretsu(N) :
    len_N = len(N) - 1
    c = 1
    for i in range(0,len(N)) :
        if len_N == 0 :
            break
        a = N[0]
        N_C = sorted(N)
        b = N_C.index(a)
        c = c + kaijo(len_N) * b
        N.remove(a)
        len_N = len_N - 1
    return c

print(abs(zyunretsu(a_1)-zyunretsu(a_2)))

Measured memory_bytes: 3064
using System;
using System.Text.RegularExpressions;

namespace AOJ2369
{
    class Program
    {
        static void Main()
        {
            var regex = new Regex(@"mc?ec?w");

            var text = Console.ReadLine() ?? "c";

            string old = null;
            while (old != text)
            {
                old = text;
                text = regex.Replace(text, "c");
            }

            Console.WriteLine(text == "c" ? "Cat" : "Rabbit");
        }
    }
}

Measured memory_bytes: 11472
N, M = map(int, input().split())
X = list(map(int, input().split()))

X.sort()
X_subtraction = []
for i in range(len(X)-1):
    X_subtraction.append(X[i+1] - X[i])

X_subtraction.sort(reverse=True)
del X_subtraction[0:N-1]

print(sum(X_subtraction))

Measured memory_bytes: 13968
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)	

int max(int a, int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main(void) {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	bool vic = false;
	while (1) {
		c -= b;
		if (c <= 0) {
			vic = true;
			break;
		}
		a -= d;
		if (a <= 0) {

			break;
		}
	}
	if (vic) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}


Measured memory_bytes: 3040
#include<stdio.h>
//#include<bits/stdc++.h>
//using namespace std;
//#define ll long long
//#define f_(i,a,b) for (int i=a;i>=b;i--)
//#define f(i,a,b) for (int i=a;i<=b;i++)
//const ll mod=1000000007;

int main() {
//	freopen("","r",stdin);
//	freopen("","w",stdout);
	int n,k;
	scanf("%d %d", &n, &k);
	if (k==1) printf("0");
	else printf("%d", n-(k-1)-1);
	return 0;
}

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


int main() {
  int N,K; cin>>N>>K;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin>>A[i];
  }
  
  for(int i=0; i<N-K; i++){
    if(A[i]<A[i+K]) cout<<"Yes\n";
    else cout<<"No\n";
  }
}


Measured memory_bytes: 4032
N = int(input())
MAX = 170000

ans = []
for i in range(1,N,2):
    for j in range(0,N,2):
        if (i//2)%3 == 0:
            ans.append((i,j))
        elif (i//2)%3 == 1:
            if (j//2)%2 == 0: ans.append((i,j))
        else:
            if (j//2)%2 == 1: ans.append((i,j))

for i in [0,N-1]:
    for j in range(N):
        if (i+j)%2:
            ans.append((i,j))
            ans.append((j,i))
ans = set(ans)
print(len(ans))
for x,y in ans:
    print('{0} {1}'.format(x,y))

#v = [['.' if (i+j)%2 else '#' for j in range(N)] for i in range(N)]
#for x,y in ans:
#    if (i+j)%2: raise
#    v[x][y] = 'a'
#for row in v:
#    print(''.join(row))

Measured memory_bytes: 25264
//Binary Search Tree II
#include <iostream>

using namespace std;

class Node {
public:
    int key;
    Node *parent = nullptr, *left = nullptr, *right = nullptr;

    Node(int key): key(key) {};
};

class Tree {
public:
    Node *root = nullptr;

    void insert(int k) {
        Node *x = root, *y = nullptr;
        while(x != nullptr) {
            y = x;
            if(k <= x->key) x = x->left;
            else x = x->right;
        }

        Node *z = new Node(k);
        z->parent = y;
        if(y == nullptr) root = z;
        else if(k <= y->key) y->left = z;
        else y->right = z;
    };

    Node* find(int k) {
        Node *x = root;
        while(x != nullptr && x->key != k) {
            if(k < x->key) x = x->left;
            else x = x->right;
        }
        return x;
    };
};

void inOrder(Node *u) {
    if(u == nullptr) return;
    inOrder(u->left);
    cout << " " << u->key;
    inOrder(u->right);
}

void preOrder(Node *u) {
    if(u == nullptr) return;
    cout << " " << u->key;
    preOrder(u->left);
    preOrder(u->right);
}

int main() {
    Tree T;

    int n;
    cin >> n;
    for(int i=0; i<n; i++) {
        string opr;
        int key;
        cin >> opr;
        if(opr == "insert") {
            cin >> key;
            T.insert(key);
        }
        if(opr == "find") {
            cin >> key;
            if(T.find(key) != nullptr) cout << "yes" << endl;
            else cout << "no" << endl;
        }
        if(opr == "print") {
            inOrder(T.root);
            cout << endl;
            preOrder(T.root);
            cout << endl;
        }
    }
}


Measured memory_bytes: 21868
def bubblesort(c, n):
    for i in range(n):
        for j in range(n-1, i, -1):
            if int(c[j][1]) < int(c[j-1][1]):
                c[j], c[j-1] = c[j-1], c[j]
def selectionsort(c, n):
    for i in range(n):
        minj = i
        for j in range(i, n):
            if int(c[j][1]) < int(c[minj][1]):
                minj = j
        c[i], c[minj] = c[minj], c[i]
n = int(input())
a = list(input().split())
b = [i for i in a]
bubblesort(a, n)
selectionsort(b, n)
print(' '.join(a))
print('Stable')
print(' '.join(b))
print('Stable' if a == b else 'Not stable')


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

// 次元圧縮のテクニックを用いる
int main() {
    int n, m;
    cin >> n >> m;
    vector<int> P(m), Y(m);

    for(int i=0; i<m; ++i) {
        cin >> P[i] >> Y[i];
        --P[i];
    }

    vector<vector<int>> vals(n);
    for(int i=0; i<m; ++i) vals[P[i]].push_back(Y[i]);


    for(int v=0; v<n; ++v) {
        sort(vals[v].begin(), vals[v].end());
        vals[v].erase(unique(vals[v].begin(), vals[v].end()), vals[v].end());
    }

    for(int i=0; i<m; ++i) {
        int v = P[i];
        printf("%06d", v+1);
        int idx = lower_bound(vals[v].begin(), vals[v].end(), Y[i]) - vals[v].begin();
        printf("%06d\n", idx+1);
    }  
}

Measured memory_bytes: 7808
/** 
 *  Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int x, y, a, b, c, k, i;
    cin>>x>>y>>a>>b>>c;
    vector<pair<long long,int>> apples(a+b+c);
    for(i=0;i<a;++i)
    {
        cin>>k;
        apples[i] = {k,1};
    }
    for(i=0;i<b;++i)
    {
        cin>>k;
        apples[i+a] = {k,2};
    }
    for(i=0;i<c;++i)
    {
        cin>>k;
        apples[i+a+b] = {k,3};
    }
    sort(apples.begin(),apples.end());
    reverse(apples.begin(),apples.end());
    long long cnt = 0, cntr = 0, cntg = 0, sum = 0;
    for(i=0;i<a+b+c && cnt<x+y ;++i)
    {
        if(apples[i].second == 1 && cntr < x)
        {
            ++cnt;
            sum += apples[i].first;
            ++cntr;
            //cout<<apples[i].first<<" ";
        }
        else if(apples[i].second == 2 && cntg < y)
        {
            ++cnt;
            sum += apples[i].first;
            ++cntg;
            //cout<<apples[i].first<<" ";
        }
        else if(apples[i].second == 3)
        {
            ++cnt;
            sum += apples[i].first;
            //cout<<apples[i].first<<" ";
        }
        //cout<<apples[i].first<<" "<<apples[i].second<<" "<<cnt<<" "<<cntr<<" "<<cntg<<"\n";
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>

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

  if(a==b)
    printf("%d\n",2*a);
  else
    {
      if(a<b)
    a= b;
  printf("%d\n",2*a-1);
    }
  return 0;
}


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

class UnionFind{
public:
    int n;
    vector<int> par;
    vector<int> rank;
    vector<int> member;

    UnionFind(int x){
        n = x;
        par.assign(n + 1, 0);
        rank.assign(n + 1, 0);
        member.assign(n + 1, 1);
        for (int i = 0; i < n + 1; i++) par[i] = i;
    }
    int find(int x);
    bool check(int x, int y);
    void unite(int x, int y);
    int size(int x);
};

int UnionFind::find(int x){
    if (par[x] == x) return x;
    par[x] = find(par[x]);
    return par[x];
}

bool UnionFind::check(int x, int y){
    return find(x) == find(y);
}

void UnionFind::unite(int x, int y){
    int id_x, id_y;
    id_x = find(x); id_y = find(y);
    if (id_x == id_y) return;
    else if (rank[id_x] < rank[id_y]){
        par[id_x] = id_y;
        member[id_y] += member[id_x];
    }
    else if (rank[id_x] > rank[id_y]){
        par[id_y] = id_x;
        member[id_x] += member[id_y];
    }
    else{
        par[id_y] = id_x;
        rank[id_x] += 1;
        member[id_x] += member[id_y];
    }
}

int UnionFind::size(int x){
    return member[find(x)];
}

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

    vector<vector<int>> E(m, vector<int>(2));
    for (int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        E[i][0] = a;
        E[i][1] = b;
    }

    UnionFind U(n);
    vector<long long> ans(m + 1, 0);
    ans[m] = n * (n - 1) / 2;
    for (int i = m - 1; i >= 0; --i){
        int a, b;
        a = E[i][0];
        b = E[i][1];
        if (U.check(a, b)){
            ans[i] = ans[i + 1];
        }
        else{
            ans[i] = ans[i + 1] - U.size(a) * U.size(b);
            U.unite(a, b);
        }
    }
    for (int i = 1; i < m + 1; i++) cout << ans[i] << endl;
}


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

string S;

int solve(){
	int N;
	int ans = 1000;	
	for(int i=0;i<S.length();i++){
		N = atoi(S.substr(i,3).c_str());
		if(abs(753-N)<ans){
			ans = abs(753-N);
		}
	}
	cout << ans << endl;
	return 0;
}


int main(){
	cin >> S;
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define N 200005
using namespace std;
typedef long long LL;
inline int read()
{
	char c=getchar(); int num=0,f=1;
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c<='9'&&c>='0') { num=num*10+c-'0'; c=getchar(); }
	return num*f;
}
int n,a[N];
LL ans;
int main()
{
	n=read();
	for (int i=1;i<=n;i++) a[i]=read();
	if (a[1]!=0) { printf("-1"); return 0; }
	for (int i=2;i<=n;i++) if (a[i]-a[i-1]>1) { printf("-1"); return 0; }
	for (int i=n;i>=1;i--) if (a[i]!=a[i+1]-1) ans+=a[i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
const int INF = 1e9+7;

int main(int argc, char **argv)
{
	int h, m, s;
	scanf("%d", &s);
	m = s / 60;
	s = s % 60;
	h = m / 60;
	m = m % 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

Measured memory_bytes: 592
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;
const int M = 1e9 + 7;
ll mul(ll a, ll b){
    return ((a % M) * (b % M)) % M;
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, m;
    cin >> n >> m;
    int ans = 1;
    if(abs(n - m) > 1){
        cout << 0;
        return 0;
    }
    for(int i = 1; i <= n; i++){
        ans = mul(ans, i);
    }
    for(int i = 1; i <= m; i++){
        ans = mul(ans, i);
    }
    if(abs(n - m) == 0){
        ans = mul(ans, 2);
    }
    cout << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

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

using ll = long long int;
using P = pair<ll,ll>;
constexpr int INF = 1<<30;

int main() {
    int n;
    cin >> n;
    if(n == 1){
        cout << "Hello World" << endl;
    }
    else{
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func main() {
    sc.Split(bufio.ScanWords)
    appleNum := nextInt()
    pieceNum := nextInt() 
    pieceNumMadeFromApples := appleNum * 3
    totalPiece := pieceNumMadeFromApples + pieceNum
    fmt.Println(totalPiece / 2)
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N, D, X;
  cin >> N >> D >> X;
  vector <int> A(N);
  rep(i,N) cin >> A[i];

  int cnt = 0;
  rep(i,N){
    int day = 1;
    while (day <= D){
      cnt ++;
      day += A[i];
    }
  }
  cout << X + cnt << endl;
}


Measured memory_bytes: 3588
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = 0;
        int i = 0;
        while (true) {
            x = scanner.nextInt();
            if (x == 0) break;
            i++;
            System.out.println("Case " + i + ": " + x);
        }
    }
}



Measured memory_bytes: 40940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
 
int main() {
string s;
cin >> s;
stack<char> t;
rep(i,s.size()){
  if(s.at(i) == '0'){
   t.push('0');
  }
  else if(s.at(i) == '1'){
    t.push('1');
  }
  else if(s.at(i) == 'B'){
    if(!t.empty()) t.pop();
  }
}
  int n = t.size();
  vector<char> b;
 rep(i,n){
   b.push_back(t.top());
   t.pop();
 }
  reverse(b.begin(),b.end());
  rep(i,n) cout << b.at(i);
}

Measured memory_bytes: 3652
import sys
sys.setrecursionlimit(10000000)
# input = sys.stdin.readline
from bisect import *
from collections import *
# from heapq import *
# import functools
# import itertools
# import math
INF = 500000
mod = 10**9+7

N, M = map(int, input().split())
flg = [0] * N
cnt = [0] * N
ans = 0
for i in range(M):
    p, S = input().split()
    p = int(p)-1
    if S == 'WA':
        if flg[p] == 0:
            cnt[p] += 1
    else:
        if flg[p] == 0:
            flg[p] = 1
            ans += cnt[p]
print(sum(flg), ans)


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

int main(){
    int n; cin >> n;
    string d;
    int max = 0;
    map<string, int>pole;
    
    for (int i = 0; i < n; i++)
    {
        cin >> d;
        pole[d] ++;
        if(max < pole[d])max = pole[d];
    }

    for(auto p: pole){
        if(p.second == max){
            cout << p.first << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 25216
W,H,x,y = map(int, input().split())

quad = [[0,0],[W,0],[W,H],[0,H]] 
S = (quad[1][0]-quad[0][1]) * (quad[2][1]-quad[0][1])
ans = 0

if W/2 == x and H/2 == y:
    ans = 1

print(S/2 , ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
#define ll long long
#define trace(x) cerr << #x << " = " << x << endl
using namespace std;

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main()
{
   /*
    #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("ouput.txt","w",stdout);
    #endif 
   */

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    while(t--){
        ll n, sum = 0;
	cin>>n;
	vector<ll> a(n);
	for(auto &it : a){
		cin>>it;
		sum += it;
	}
	ll ans = 0;
	for(int i = 0; i < n-1; i++){
		sum -= a[i];
		ans = (ans%mod + (((sum%mod)*(a[i]%mod))%mod)%mod)%mod;
	}
	cout<<(ll)(ans)<<endl;
    }
    return 0;
} 


Measured memory_bytes: 4776
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <vector>
//const int maxn = 1e5+5;
#define ll long long
#define MAX INT_MAX
#define FOR(i,a,b) for( int i = a;i <= b;++i)

using namespace std;
string s;
int k,flag;


int main()
{
    cin>>s;
    for(int i=0;i<s.length();++i)
    {
        k=i;
        flag=0;
        if((s[k]=='d'&&s[k+1]=='r'&&s[k+2]=='e'&&s[k+3]=='a'&&s[k+4]=='m'&&s[k+5]!='e')||(s[k]=='d'&&s[k+1]=='r'&&s[k+2]=='e'&&s[k+3]=='a'&&s[k+4]=='m'&&s[k+5]=='e'&&s[k+6]=='r'&&s[k+7]=='a'&&s[k+8]=='s'&&s[k+9]=='e')||(s[k]=='d'&&s[k+1]=='r'&&s[k+2]=='e'&&s[k+3]=='a'&&s[k+4]=='m'&&s[k+5]=='e'&&s[k+6]=='r'&&s[k+7]=='a'&&s[k+8]=='s'&&s[k+9]=='e'&&s[k+10]=='e'))
        {
            flag=1;
            i=k+4;
        }
        else if(s[k]=='d'&&s[k+1]=='r'&&s[k+2]=='e'&&s[k+3]=='a'&&s[k+4]=='m'&&s[k+5]=='e'&&s[k+6]=='r')
        {
            flag=1;
            i=k+6;
        }
        else if(s[k]=='e'&&s[k+1]=='r'&&s[k+2]=='a'&&s[k+3]=='s'&&s[k+4]=='e'&&s[k+5]!='r')
        {
            flag=1;
            i=k+4;
        }
        else if(s[k]=='e'&&s[k+1]=='r'&&s[k+2]=='a'&&s[k+3]=='s'&&s[k+4]=='e'&&s[k+5]=='r')
        {
            flag=1;
            i=k+5;
        }
        else
        {
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
    return 0;
}


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

const int MAX = 500001;
int a[MAX], bit[MAX];

struct Query 
{ 
	int l, r, idx; 
}; 
Query queries[MAX];
bool cmp(Query x, Query y) 
{ 
	return x.r < y.r; 
} 

void update(int idx, int val, int n) 
{ 
	for (; idx <= n; idx += idx&-idx) 
		bit[idx] += val; 
} 

 
int query(int idx, int n) 
{ 
	int sum = 0; 
	for (; idx>0; idx-=idx&-idx) 
		sum += bit[idx]; 
	return sum; 
} 

void answeringQueries(int n, int q) 
{ 

	int last_visit[MAX]; 
	memset(last_visit, -1, sizeof(last_visit)); 
 
	int ans[q]; 
	int query_counter = 0; 
	for (int i=0; i<n; i++) 
	{ 
		if (last_visit[a[i]] !=-1) 
			update (last_visit[a[i]] + 1, -1, n); 

		last_visit[a[i]] = i; 
		update(i + 1, 1, n); 

		while (query_counter < q && queries[query_counter].r == i) 
		{ 
			ans[queries[query_counter].idx] = 
					query(queries[query_counter].r + 1, n)- 
					query(queries[query_counter].l, n); 
			query_counter++; 
		} 
	} 

	for (int i=0; i<q; i++) 
		cout << ans[i] << endl; 
} 

int main() 
{ 
    int n, q;
    cin >> n >> q;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < q; i++) {
        cin >> queries[i].l >> queries[i].r;
        queries[i].l--;
        queries[i].r--;
        queries[i].idx = i;
    }
    sort(queries, queries + q, cmp);
    answeringQueries(n, q);
	return 0; 
} 


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

#define ll long long
using namespace std;

bool valid(vector<ll>& arr, ll m, ll k) {
	ll cnt = 0;
	for (int i=0; i<arr.size(); i++) {
		if (arr[i] <= m) continue;
		if (arr[i] % m == 0) cnt += (arr[i] / m - 1);
		else cnt += arr[i] / m;		
	}
	return cnt <= k;	
}

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> arr(n);
	for (int i=0; i<n; i++) cin >> arr[i];
	ll l = 1LL, r = (ll)INT_MAX;
	while (l < r) {
		ll m = (l+r)/2LL;
		if (valid(arr, m, k)) {
			r = m;
		}
		else {
			l = m+1;
		}
	}
	cout << l;
}


Measured memory_bytes: 4772
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int f = 0;
    int s = 0;
    int index = 0;
    int cur;
    for(int i = 0 ; i < n ; i++){
      cur = Integer.parseInt(sc.next());
      if(cur >= f){
        s = f;
        f = cur;
        index = i;
      }else if(cur > s){
        s = cur;
      }
    }
    for(int i = 0; i < n; i++){
      if(i != index){
        System.out.println(f);
      }else{
        System.out.println(s);
      }
    }
  }
}




Measured memory_bytes: 67564
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,k,l,a,b,c,d;
    stack<ll>st;
    cin>>n;
    c=0;
    i=0;
    k=n;
    while(k>1)
    {
        k=floor((k/2));
        i++;
        c+=pow(2,i);
    }
    if(k==1)
    {
        c++;
        k=0;
    }
    cout<<c<<endl;
    return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


const int MOD=1000000007;
int INF=100100100100100;
int a[200010];
int b[200010];
signed main(){
  int n;cin>>n;
  rep(i,n){
    cin>>a[i];
    b[i]=a[i];
  }
  sort(b,b+n);
  rep(i,n){
    if(a[i]!=b[n-1])cout<<b[n-1]<<endl;
    else{
      if(b[n-2]==b[n-1])cout<<b[n-1]<<endl;
      else cout<<b[n-2]<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 6712
/* Those who cannot remember the past are condemned to repeat it.*/
/* author:Ajeet */

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
const int sz=1e7+5;
#define mod 1000000007
#define ull unsigned long long int

int main()
{
    fast_cin();
    int n;
    cin>>n;
    int k;
    cin>>k;
    int arr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    cout<<ceil(double(n-1)/double(k-1))<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ifor(i,n) for(i=0;i<n;i++)
#define ll long long
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
      int i,n,t,p=INT_MAX,j=0,x=0,a=0,b,l=0,r=0,c=0,y=0,z=0;
     string s,m;
     int ara[3][3];
     for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            cin>>ara[i][j];
        }
     }
     cin>>n;
     while(n--)
     {
         cin>>p;
         for(i=0;i<3;i++){
            for(j=0;j<3;j++){
              if(ara[i][j]==p){
                ara[i][j]=0;
            }
        }
     }

     }
     for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            if(i==j){
                l=max(l,ara[i][j]);
            }
            if(i+j==2){
                r=max(r,ara[i][j]);
            }
            if(i==0){
                a=max(a,ara[i][j]);
            }
            if(i==1){
                b=max(b,ara[i][j]);
            }
            if(i==2){
                c=max(c,ara[i][j]);
            }
            if(j==0){
                x=max(x,ara[i][j]);
            }
            if(j==1){
                y=max(y,ara[i][j]);
            }
            if(j==2){
                z=max(z,ara[i][j]);
            }
        }
     }
     if(l==0||r==0 || a==0 || b==0 || c==0 || x==0 || y==0 || z==0){
        cout<<"Yes"<<endl;
     }
     else{
        cout<<"No"<<endl;
     }


     return EXIT_SUCCESS;
}



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

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {

             var abc = Console.ReadLine().Split().Select(int.Parse).ToArray();   
             int a= abc[0];
             int b= abc[1];
             int c= abc[2];
                 if (a < b && b < c) { Console.WriteLine("{0} {1} {2}", a, b, c); }
            else if (a < c && c < b) { Console.WriteLine("{0} {1} {2}", a, c, b); }
            else if (b < a && a < c) { Console.WriteLine("{0} {1} {2}", b, a, c); }
            else if (b < c && c < a) { Console.WriteLine("{0} {1} {2}", b, c, a); }
            else if (c < a && a < b) { Console.WriteLine("{0} {1} {2}", c, a, b); }
            else if (c < b && b < a) { Console.WriteLine("{0} {1} {2}", c, b, a); }
            else if (c < b && b == a) { Console.WriteLine("{0} {1} {2}", c, b, a); }
            else if (c > b && b == a) { Console.WriteLine("{0} {1} {2}", a, b, c); }
            else if (c < b && c == a) { Console.WriteLine("{0} {1} {2}", c, a, b); }
            else if (c > b && c == a) { Console.WriteLine("{0} {1} {2}", b, c, a); }
            else if (c < a && b == c) { Console.WriteLine("{0} {1} {2}", c, b, a); }
            else                      { Console.WriteLine("{0} {1} {2}", a, b, c); }
           
        }
    }
}

Measured memory_bytes: 9496
#include <iostream>
#include<vector>
#define lli long long int
#include<algorithm>
using namespace std;

int main() {
	// your code goes here
	lli n,t;
	// maxi=0;
	cin>>n;
	t=n;
	vector<lli>v1(3);
	vector<lli>v2(3);
	for(lli  i=0;i<3;i++)cin>>v1[i];
	while(t--){
	vector<lli>v2(3);
	for(lli  i=0;i<3;i++)cin>>v2[i];
	
	for(lli  i=0;i<3;i++){
		v2[i]+=max(v1[(i+1)%3],v1[(i+2)%3]);
	}
	// for(auto x: v1){
	// 	cout<<x<<" ";
		
	// }
	// cout<<endl;
	v1=v2;
		
	}
	
	lli maxi=*max_element(v1.begin(),v1.end());
	cout<<maxi;
	return 0;
	
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int n;

  while(scanf("%d",&n)!=EOF)
    cout<<n*(n+1)/2+1<<endl;
}

Measured memory_bytes: 1212
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 even = 0;
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
            if(A[i] % 2 == 0)
                even++;
        }
        sc.close();
        System.out.println((int)Math.pow(3, N) - (int)Math.pow(2, even));
    }
}

Measured memory_bytes: 22736
<?php

$input = STDIN;

while (true) {
    list($m, $f, $r) = explode(" ", trim(fgets($input)));

    if ($m == -1 && $f == -1 && $r == -1) break;

    if ($m == -1 || $f == -1) {
        echo "F" . "\n";
        continue;
    }

    $total = 0;
    if ($m !== -1) $total += $m;
    if ($f !== -1) $total += $f;

    if ($total >= 80) {
        echo "A" . "\n";
    } elseif ($total >= 65) {
        echo "B" . "\n";
    } elseif ($total >= 50) {
        echo "C" . "\n";
    } elseif ($total >= 30) {
        if ($r >= 50) echo "C" . "\n";
        else echo "D" . "\n";
    } elseif ($total <= 30) {
        echo "F" . "\n";
    }
}


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

int main() {
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    int cnt[101010];
    for (int i = 1; i < n; i++) {
        if (s[i - 1] == 'A' && s[i] == 'C') {
            cnt[i + 1]++;
        }
    }
    for (int i = 1; i < 101010; i++) {
        cnt[i] += cnt[i - 1];
    }
    while (q--) {
        int l, r;
        cin >> l >> r;
        int ans = cnt[r] - cnt[l - 1];
        if (l >= 2 && s[l - 2] == 'A' && s[l - 1] == 'C') ans--;
        cout << ans << '\n';
    }
}

Measured memory_bytes: 1408
#include <iostream>
int main(){
	int n=0,A=0,B=0;
	while(std::cin >> n, n){
		for(int i=0;i<n;i++){
			int a=0,b=0;
			std::cin>>a>>b;
			int ab=a+b;
			if(a>b){
				A+=ab;
			}else{
				if(a<b){
					B+=ab;
				}else{
					A+=a;
					B+=b;
				}
			}
		}
		std::cout<<A<<" "<<B<<std::endl;
		A=0,B=0;
	}
	return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;


void solve(){
    string s,t;cin >> s >> t;
    int n = s.size();
    vector<int>cnt(26);
    vector<int>cnt2(26);
    for(int i = 0;i<n;i++) cnt[s[i]-'a']++;
    sort(cnt.begin(),cnt.end());
    for(int i = 0;i<n;i++) cnt2[t[i]-'a']++;
    sort(cnt2.begin(),cnt2.end());
    bool ok = 1;
    for(int i = 0;i<26;i++){
        if(cnt[i]!=cnt2[i]) ok = 0;
    }
    if(ok) cout <<"Yes"<<endl;
    else cout <<"No"<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 3776
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    sc.close();
    if(s.equals("Sunny")){
      System.out.println("Cloudy");
    }else if(s.equals("Cloudy")){
      System.out.println("Rainy");
    }else{
      System.out.println("Sunny");
    }
  }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
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; }
const long long INF = 1LL << 60;
using Graph=vector<vector<int>>;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  int n,m;
  lint all=0;
  cin>>n>>m;
  priority_queue<int,vector<int>,less<int>> q;
  rep(i,n){
    int j;
    cin>>j;
    q.push(j);
  }
  rep(i,m){
    int j=q.top();
    q.pop();
    j/=2;
    q.push(j);
  }
  rep(i,n){
    int j=q.top();
    q.pop();
    all+=j;
  }
  cout<<all<<endl;

  

}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long n,k,b,ans=0;
  cin >> n >> k;
  for (b=k+1;b<=n;b++){
    ans+=(n/b)*(b-k);
    if (n%b>=k) ans+=n%b-k+1;
  }
  if (k==0) ans=n*n;
  cout << ans << endl;
  return 0;
}

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

int main(){
  int n,l;
  cin >> n >> l;
  vector<string> s(n);
  rep(i,n) cin >> s.at(i);  
  sort(s.begin(), s.end());
  rep(i,n) cout << s.at(i);
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

const int N = 5e5 + 5;

long long inv[N], fact[N], ifact[N];
void pre()
{
	inv[1] = fact[0] = fact[1] = ifact[0] = ifact[1] = 1;
	for (int i = 2; i < N; i++)
	{
		inv[i] = mul(MOD - MOD / i, inv[MOD % i], MOD);
		fact[i] = mul(i * 1ll, fact[i - 1], MOD);
		ifact[i] = mul(inv[i], ifact[i - 1], MOD);
	}
	return;
}
long long nCr(long long n, long long r)
{
	if (n >= 0 && r >= 0 && n >= r)
		return mul(fact[n], mul(ifact[r], ifact[n - r], MOD), MOD);
	return 0;
}
void solve(int tc)
{
	int n, m;
	cin >> n >> m;
	pre();
	ll ans = mul(nCr(m, n), fact[n], MOD);
	ans = mul(ans, ans, MOD);
	ll ex = 0;
	for (int i = 1; i < n + 1; i++)
	{
		ll tmp = nCr(n, i);
		tmp = mul(tmp, mul(nCr(m, i), fact[i], MOD), MOD);
		ll tmp1 = mul(nCr(m - i, n - i), fact[n - i], MOD);
		tmp1 = mul(tmp1, tmp1, MOD);
		tmp = mul(tmp, tmp1, MOD);
		//db(tmp);
		if (i & 1)
			ex = add(ex, tmp, MOD);
		else
			ex = add(ex, MOD - tmp, MOD);
	}
	db(ans, ex);
	ans = add(ans, MOD - ex, MOD);
	cout << ans << ln;
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve(tc);
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 15300
import sys
from collections import deque

sys.setrecursionlimit(10000000)

readline = sys.stdin.readline

N, M = map(int, readline().split())
uv = [list(map(int, readline().split())) for i in range(M)]
S, T = map(int, readline().split())

S, T = S - 1, T - 1

nodes = [{} for i in range(N)]
for u, v in uv:
    nodes[u - 1][v - 1] = 1

visited = [[False] * N for i in range(3)]

def kenken(u, rem):
    if rem != 3 and visited[rem][u]:
        return deque()
    
    if rem != 3:
        visited[rem][u] = True
    if rem > 0:
        a = deque()
        for v in nodes[u]:
            a.extend(kenken(v, rem - 1))
        return a
    else:
        return deque([u])
    

q = deque()

q.append([S, 0])

_count = -1
while len(q) != 0:
    u, count = q.popleft()

    ret = kenken(u, 3)
    if any(T == r for r in ret):
        _count = count + 1
        break
    q.extend([r, count + 1] for r in ret)


print(_count)

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

int main(){
  string str="abcdefghijklmnopqrstuvwxyz";
  char c;
  cin>>c;
  int i;
  for(i=0;i<25;i++){
    if(str.at(i)==c){
      break;
    }
  }
  cout<<str.at(i+1)<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>ll(b);i--)
using ll = long long;
using namespace std;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
//sort(a, a + N, greater<ll>())   // descend
//sort(a, a+N)                    //  ascend

/* 
void comb(vector<vector <ll> > &v) {
	ll mod=1000000007;
	rep (i,0,v.size()) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	rep (k,1,v.size()) {
		rep (j,1,k) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%mod;
		}
	}
}
/*main内でnCn~nC0 生成 **
vector<vector<ll> > v(n + 1, vector<ll>(n + 1, 0));
comb(v);
*/

int main(){
	ll r;
	cin>>r;
	cout<<3*r*r;
}




Measured memory_bytes: 256
#include<stdio.h>
#define min(a,b) (a)<(b)?(a):(b)
#define max(a,b) (a)>(b)?(a):(b)
int main(void)
{
  int n;
  int b[100],left,mid,right;
  long long ans=0;
  scanf("%d",&n);
  for(int i=0;i<n-1;i++){
    scanf("%d",&b[i]);
  }
  ans+=b[0];
  for(int i=1;i<n-1;i++){
    ans+=min(b[i-1],b[i]);
  }
  ans+=b[n-2];
  printf("%lld",ans);
  return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
    #define ll long long
    #define mod 1000000007
    #define maxn 200005
    #define vi vector<int>
    #define vl vector<ll>
    #define mii map<int,int>
    #define mli map<ll,int>
    #define forit(it,v) for(auto it=v.begin();it!=v.end();++it)
    #define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
    using namespace std;
    void solve()
    {
        ll n,k;
        cin>>n>>k;
        vl a(n);
        for (int i = 0; i < n; ++i)
        {
            cin>>a[i];
        }
        ll beg=1,end=(ll)1e9,ans=end;
        while(beg<=end)
        {
            ll mid=beg+(end-beg)/2;
            ll c=0,c1=0;
            for (int i = 0; i < n; ++i)
            {
                c1=a[i]/mid;
                if (a[i]%mid==0)
                {
                    c1--;
                }
                if (round((a[i]) / (c1 + 1)) > mid)
                {
                    c1++;
                }
                c+=c1;               
            }
            if (c<=k)
            {
                ans=mid;
                end=mid-1;
            }
            else
            {
                beg=mid+1;
            }
        }
        cout<<ans;
        // ll n,k;
        // cin>>n>>k;
        // priority_queue<float> q;
        // for (int i = 0; i < n; ++i)
        // {
        //     float x;
        //     cin>>x;
        //     q.push(x*1.0);
        // }
        // int i=0;
        // while(i<k)
        // {
        //     i++;
        //     float x=q.top();
        //     cout<<x<<" ";
        //     q.pop();
        //     q.push(x/2.0f);
        //     q.push(x-x/2.0f);
        // }
        // ll v=q.top();
        // cout<<v;
    }
    int main()
    {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
        fastIO;
        // sieve();
        int t=1;
        // int t;
        // cin>>t;
        while(t--)
        {
            solve();
        }
        return 0;
    }

Measured memory_bytes: 4784
use proconio::input;
 
fn main() {
    input! {
        (x, y): (u64, u64)
    }

    let a = x * 4;
    if y > a {
        println!("No");
        return ;
    }

    let b = y % 2;
    if b == 1 {
        println!("No");
        return ;
    }
    
    let c = x * 2;
    if c == y {
        println!("Yes");
        return ;
    }
   
    let d = x * 4;
    if d == y {
        println!("Yes");
        return ;
    }
   
    for i in 1..=x {
        let ans = (i * 2) + (x - i) * 4;
        if ans == y {
            println!("Yes");
            return;
        };
    }

    println!("No")
}

Measured memory_bytes: 2148
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

int a[200000];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    sort(a, a + n);
    if (unique(a, a + n) - a < n)
        cout << "NO";
    else
        cout << "YES";
}


Measured memory_bytes: 1024
N=int(input())
*A,=map(int,input().split())
B=[0]*N
a1=A[0]
i=1
while i<N:
    a1+=A[i+1]-A[i]
    i+=2
B[0]=a1
i=1
while i<N:
    B[i]=2*(A[i-1]-B[i-1]//2)
    i+=1
print(*B)

Measured memory_bytes: 20504
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,X,Y;
 
map<LL,LL> ans;//iとjの距離がkになるような(i,j)の個数をans[k]とおく

void solve(){
    //隣接行列を作る
    vector<vector<LL>> adj(N+1);
    for(int i=1;i<=N;i++){
        if(i>=2) adj[i].push_back(i-1);
        if(i<=N-1) adj[i].push_back(i+1);
    }
    adj[X].push_back(Y);
    adj[Y].push_back(X);

    for(int i=1;i<=N;i++){
        //頂点iと各点の最短距離をBFSで求める
        vector<int> used(N+1,-1);//頂点iを訪れたかどうか
        queue<LL> q;
        q.push(i);
        used[i] = 0;
        while(!q.empty()){
            LL now = q.front();q.pop();
            for(auto next : adj[now]){
                if(used[next]==-1){
                    q.push(next);
                    used[next] = used[now] + 1;
                    ans[used[now] + 1]++;
                }
            }
        }
    }
}
 
int main(){
    cin >> N >> X >> Y;
 
    solve();
 
    for(LL i=1;i<=N-1;i++) cout << ans[i]/2 << endl;
    return 0;
}

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

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

Measured memory_bytes: 3820
a = 2, 3, 5

def f(n):
  m = memo.get(n)
  if m is None:
    m = d * n
    for p, c in zip(a, b):
      k, r = divmod(n, p);
      m = min(m, f(k) + r * d + c)
      if r:
       m = min(m, f(k + 1) + (p - r) * d + c)
    memo[n] = m
  return m

t = int(input())
for _ in range(t):
  n, *b, d = map(int, input().split())
  memo = {0: 0, 1: d}
  print(f(n))


Measured memory_bytes: 10876
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var S, T string

func main() {
	sc.Split(bufio.ScanWords)

	S, T = nextStr(), nextStr()
	l := len(S)

	ans := "No"

	for i := 0; i < l; i++ {
		Si := i
		Ti := 0
		for Ti < l {
			if Si >= l {
				Si = 0
			}
			//fmt.Println(string(S[Si]), string(T[Ti]))
			if string(S[Si]) != string(T[Ti]) {
				break
			}
			Si++
			Ti++
		}
		if Ti == l {
			ans = "Yes"
			break
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640