akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    cin >> x;
    sort(x.begin(), x.end());
    int ans = x[m - 1] - x[0];
    adjacent_difference(x.begin(), x.end(), x.begin());
    sort(x.begin() + 1, x.end(), greater<int>());
    for(int i = 1; i < min(n, m); i++) {
        ans -= x[i];
    }
    cout << ans << endl;
    return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
/**
 * Simple Graph Definition
 */
struct Edge{
  int to, cost;

  Edge(int t, int c = 0): to(t), cost(c)
  {}
  bool operator>(const Edge& rhs) const{
	return cost > rhs.cost;
  }
  bool operator<(const Edge& rhs) const{
	return cost < rhs.cost;
  }

};
using Graph =  vector< vector<Edge> >;

// ????????°???????????¨???
void add_edge(Graph& graph, int u, int v, int cost = 0){
  graph[u].push_back(Edge(v,cost));
  graph[v].push_back(Edge(u,cost));
}

void SCC(const Graph& g,
		 vector< vector<int> >& scc) {
  const int n = g.size();
  vector<int> num(n), low(n);
  stack<int> S;
  vector<bool> inS(n);
  int time = 0;

  function<void(int)> visit = [&](int v){
	low[v] = num[v] = ++time;
	S.push(v); inS[v] = true;
	for(auto& e: g[v]) {
	  int w = e.to;
	  if (num[w] == 0) {
		visit(w);
		low[v] = min(low[v], low[w]);
	  } else if (inS[w])
		low[v] = min(low[v], num[w]);
	}
	if (low[v] == num[v]) {
	  scc.push_back(vector<int>());
	  while (1) {
		int w = S.top(); S.pop(); inS[w] = false;
		scc.back().push_back(w);
		if (v == w) break;
	  }
	}
  };

  REP(u, n) if (num[u] == 0)
    visit(u);
}

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

  int V, E;
  cin >> V >> E;
  Graph G(V);
  REP(i,E){
	int s, t;
	cin >> s >> t;
	G[s].EB(t);
  }
  vector<vector<int>> scc;
  SCC(G, scc);
  vector<int> gr(V);
  REP(i,SZ(scc))
	for(int u: scc[i])
	  gr[u] = i;

  int Q;
  cin >> Q;
  while(Q--){
	int u, v;
	cin >> u >> v;
	cout << (gr[u] == gr[v]) << endl;
  }

  return 0;
}

Measured memory_bytes: 5116
//???????????????????????°???????????´???www(^??^)9m
#include <stdio.h>
int main(void){int i,s,o,n[4],q[4],toread,L,S,a,b,c,A;while(1){for(i=0;i<=3;i++){scanf("%1d",&n[i]);q[i]=n[i];}A=0;if(n[0]==n[1]&&n[1]==n[2]&&n[2]==n[3]){if(n[0]==0){break;}printf("NA\n");}else if(n[0]==6&&n[1]==1&&n[2]==7&&n[3]==4){printf("0\n");}else{for(s=0;A!=6174;s++){for(o=0;o<=3;o++){for(i=0;i<=3;i++){if(n[i]<n[o]){toread=n[i];n[i]=n[o];n[o]=toread;}}}L=n[0]*1000+n[1]*100+n[2]*10+n[3];for(o=0;o<=3;o++){for(i=0;i<=3;i++){if(n[i]>n[o]){toread=n[i];n[i]=n[o];n[o]=toread;}}}S=n[0]*1000+n[1]*100+n[2]*10+n[3];A=L-S;a=A/1000;n[0]=a;n[1]=(A-(n[0]*1000))/100;n[2]=(A-((n[0]*1000)+(n[1]*100)))/10;n[3]=A-((n[0]*1000)+(n[1]*100)+(n[2]*10));}printf("%d\n",s);}}return 0;}

Measured memory_bytes: 608
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

vector<int> has(1000001 , 0);
vector<int> primes;

void sieve()
{
	has[0] = has[1] = 1;
	for(int i = 2;i*i<=1000000;i++)
	{
		if(!has[i])
			for(int j = i*i;j<=1000000;j+=i) has[j] = 1;
	}
	
	for(int i = 0;i<=1000000;i++)
	{
		if(!has[i]) primes.push_back(i);
	}
}

int solve(int count)
{	
	int start = 1,end = 40;
	while(start <= end)
	{
		int mid = (start + end)/2;
		int val = mid*(mid+1)/2;
		
		if(val > count) end = mid-1;
		else start = mid+1;
	}
	
	return start-1;
	return 0;	
}

int main()
{
	sieve();
	ll n;cin>>n;
	int ans = 0;
	
	for(int i = 0;i<primes.size() && primes[i] <= n;i++)
	{
		int count = 0;
		while(n%primes[i] == 0)
		{
			n/=primes[i];
			count++;
		}
		ans+=solve(count);
	}
	
	if(n > 1)
	{
		ans++;
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7664
#include <deque>
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    int N;
    cin >> N;
    deque<int> dq;
    for (int i = 0; i < N;i++){
        int t;
        cin >> t;
        int x = lower_bound(dq.begin(), dq.end(), t) - dq.begin();
        if(x == 0)
            dq.push_front(t);
        else
            dq[x - 1] = t;
    }
    cout << (int)dq.size() << endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main()
{
  int a, b, c, i, sum = 0;

  scanf("%d %d", &a, &b);

  c = b - a;

  for(i=0; i<c; i++){
    sum = sum + i;
  }
  printf("%d\n", sum - a); 
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int a,b,c[4],d[4],i,j,hit,brow;
  while(1){
    scanf("%d %d",&a,&b);
    if(a==0&&b==0)break;
    c[0]=a/1000,d[0]=b/1000;
    c[1]=a%1000/100,d[1]=b%1000/100;
    c[2]=a%100/10,d[2]=b%100/10;
    c[3]=a%10,d[3]=b%10;

    hit=0;
    brow=0;
    for(i=0;i<4;i++){
 
    }
    for(i=0;i<4;i++){
      if(c[i]==d[i])hit++;
      else{
	for(j=0;j<4;j++){
	  if(c[i]==d[j])brow++;
	}
      }
    }
    printf("%d %d\n",hit,brow);
  }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int n, k;

int main() {
scanf("%d %d", &n, &k);
if (k == 1) printf("0\n"); else printf("%d\n", n - k);
return 0;
}

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


int main()
{
	ll N;
	cin>>N;
	cout<<(N-1)*N/2<<endl;
	return 0;
}


Measured memory_bytes: 3580
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        
        AtCoder problem = new AtCoder(sc);
        problem.solve(out);
        
        out.flush();
    }
    
}

class AtCoder {

    final int N, A, B;

    AtCoder(FastScanner sc) {
        N = sc.nextInt();
        A = sc.nextInt();
        B = sc.nextInt();
    }
    
    void solve(PrintWriter out) {
        out.println(Math.min(A * N, B));
    }
    
}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {
    
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    
    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }
    
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }
    
    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    
    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22996
var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var counter = function(str,seq){
    return str.split(seq).length - 1;
}
reader.on('line', function(line) {
  lines.push(line);
});
reader.on('close', function() {
    console.log(counter(lines[0], /1/));
});

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


int main() {

    vector<string> s(3);
    for(int i=0; i<3; i++) {
	cin >> s[i];
    }

    int turn = 0;
    while(s[turn].size() > 0) {
	int nxt = s[turn][0] - 'a';
	if(s[turn].size() == 1)
	    s[turn] = "";
	else
	    s[turn] = s[turn].substr(1);
	turn = nxt;
    }
    if(turn == 0)
	cout << "A" << endl;
    if(turn == 1)
	cout << "B" << endl;
    if(turn == 2)
	cout << "C" << endl;
    
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, L;
    cin >> N >> L;
    string A[N];
    rep(i, N) {
        cin >> A[i];
    }

    sort(A, A+N);
    rep(i, N) {
        cout << A[i];
    }
    cout << endl;

    return 0;
}


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


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

    string s;
    cin >> s;

    const int n = s.length();

    stack<char> st;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'T' && !st.empty() && st.top() == 'S') {
            st.pop();
        } else {
            st.push(s[i]);
        }
    }

    cout << st.size() << endl;

    return 0;
}

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

int now;
string s;

int calc(){
    vector<int> v;
    int ret = 0;
    while(s[now]!=']'){
        if(s[now]=='['){
            now++;
            v.push_back(calc());
        }
        else{
            int x=0;
            while(s[now]>='0' && s[now]<='9'){
                x=x*10+s[now]-'0';
                now++;
            }
            ret = x/2 + x%2;
        }
    }
    now++;
    if(ret==0){
        sort(v.begin(),v.end());
        int vs=v.size();
        for(int i=0;i<(vs/2 + vs%2);i++){
            ret+=v[i];
        }
    }
    //cout << ret << endl;
    return ret;
}

int main(void){
    int n,ret;
    cin >> n;
    while(n--){
        cin >> s;
        now=1;
        ret=calc();
        cout << ret << endl;
    }
}



Measured memory_bytes: 3244
#include <iostream>
using namespace std;
int main(){
	int r[5]={0},l[5]={0};
	float x,y;
	while(cin>>x>>y){
		if(x<0.2){
			r[3]++;
		}else if(x<0.6){
			r[2]++;
		}else if(x<1.1){
			r[1]++;
		}else{
			r[0]++;
		}
		if(y<0.2){
			l[3]++;
		}else if(y<0.6){
			l[2]++;
		}else if(y<1.1){
			l[1]++;
		}else{
			l[0]++;
		}
	}
	for(int i=0;i<4;i++){
		cout<<r[i]<<" "<<l[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3136
#include <stdio.h>
 
int main(void)
{
	int A;
	int B;
	int C;
	
	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%d", &C);
	
	if ((A+B)>=C){
		printf("Yes\n");
	}
	else if ((A+B)<=C){
		printf("No\n");
	}
	
	return (0);
}

Measured memory_bytes: 128
(defun func ()
  (let ((s (read-char)))
	(if (char= s #\B)
	  (cons s (func))
	  (when (not (char= s #\newline))
		(let ((res (func)))
		  (if (and res (char= (car res) #\B))
			(cdr res)
			(cons s res)))))))

(mapc (lambda (x) (when (not (char= x #\B)) (princ x))) (func))


Measured memory_bytes: 4324
N=int(input())
A=[int(i) for i in input().split()]
B=sorted([A[j]-j-1 for j in range(N)])

def median(seq):
    s = sorted(seq)
    if len(s) % 2 == 0:          # 要素が偶数個なら2つの平均
        return (s[len(s) // 2] + s[(len(s) // 2) - 1]) / 2
    else:
        return s[len(s) // 2]    # 要素が奇数個なら中央の値

b=median(B)

ans=0
for i in range(N):
    ans+=abs(A[i]-(b+i+1))

print(int(ans))


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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

int main(int argc, const char* argv[]) {
	ll n;
	cin >> n;

	ll ret = 0;

	vector<ll> p(n);
	cin >> p[0];
	cin >> p[1];
	repd(i, 2, n) {
		cin >> p[i];
		if( (p[i-2] < p[i-1] && p[i-1] <= p[i] ) || (p[i] < p[i-1] && p[i-1] <= p[i-2]) ) {
			ret++;
		}
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    long double a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    long double ans=0,temp=0;
    for(int i=0;i<k;i++)
    {
        ans+=(a[i]/2)+0.5;
    }
    temp=ans;
    for(int i=k;i<n;i++)
    {
        temp-=(a[i-k]/2)+0.5;
        temp+=(a[i]/2)+0.5;
        ans=max(temp,ans);
    }
    cout<<fixed<<setprecision(12);
    cout<<ans;
	return 0;
}







Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;

signed main() {
    string S;
    cin >> S;
    int ans = 0;
    int stackA = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'A') ++stackA;
        else if (S.substr(i, 2) == "BC") {
            ans += stackA;
            i++;
        } else {
            stackA = 0;
        }
    }
    cout << ans << endl;
}


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

#define MaxN 100005
#define INF 2140000000
using namespace std;

int X,N,fr[MaxN],Max=0;

int main()
{
    cin>>N;
    for(int i=1;i<=N;i++)
    {
        cin>>X;
        fr[X]++;
    }
    for(int i=1;i<100000;i++)
        Max=max(Max,fr[i]+fr[i-1]+fr[i+1]);
    cout<<Max;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5;
vector <int> G[MAX_N + 5];
int point[MAX_N + 5];
bool vis[MAX_N + 5];
bool ran[MAX_N + 5];
int d_max[MAX_N + 5];
int n, m, q;
int xx[MAX_N + 5], dd[MAX_N + 5], cc[MAX_N + 5];
void dfs(int v, int d, int c)
{
    if (d == 0 || d <= d_max[v]) return;
    for (int i = 0; i < G[v].size(); i++) {
        if (!vis[G[v][i]]) {
            if (!ran[G[v][i]]) {
                point[G[v][i]] = c;
                ran[G[v][i]] = 1;
            }
            vis[G[v][i]] = 1;
            dfs(G[v][i], d - 1, c);
            vis[G[v][i]] = 0;
        }
    }
    d_max[v] = d;
}
int main()
{
    scanf("%d%d", &n, &m);
    int u, v;
    memset(point, 0, sizeof(point));
    for (int i = 0; i <= n; i++) G[i].clear();
    for (int i = 0; i < m; i++) {
        scanf("%d%d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    scanf("%d", &q);
    int d, c;
    for (int i = 0; i < q; i++) {
        scanf("%d%d%d", &xx[i], &dd[i], &cc[i]);
    }
    memset(ran, 0, sizeof(ran));
    memset(d_max, -1, sizeof(d_max));
    for (int i = q - 1; i >= 0; i--) {
        if (dd[i] <= d_max[xx[i]]) continue;
        if (!ran[xx[i]]) {
            point[xx[i]] = cc[i];
            ran[xx[i]] = 1;
        }
        memset(vis, 0, sizeof(vis));
        vis[xx[i]] = 1;
        dfs(xx[i], dd[i], cc[i]);
        d_max[xx[i]] = dd[i];
    }
    for (int i = 1; i <= n; i++) {
        printf("%d\n", point[i]);
    }
    return 0;
}


Measured memory_bytes: 8696
import sys,collections
S = list(input())
S_Collection = collections.Counter(S) #Sの各文字の出現回数

#S_Collectionの内容が[2,2]であれば各文字は2回ずつ出現することになる
if list(S_Collection.values()) == [2,2]:
    print("Yes")
    sys.exit()
print("No")

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  int N;
  cin >> N;
  int a[N]={},b[N]={};
  rep(i,N){
    int s;
    cin >> s;
    s--;
    a[i]=s;
  }
  int ans=0;
  rep(i,N){
    int t;
    cin >> t;
    ans+=t;
  }
  rep(i,N-1) cin >> b[i];
  rep(i,N-1){
    if(a[i]+1==a[i+1]){
      ans+=b[a[i]];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()
T = input()
ans = 10**10

len_s = len(S)
len_t = len(T)

for i in range(len_s-len_t+1):
    cnt = 0
    for s, t in zip(S[i:], T):
        if s != t:
            cnt += 1
    ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 67828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int x[n], y[n], h[n];
    int n0;
    rep(i, 0, n) {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i] > 0) n0 = i;
    }

    rep(cx, 0, 101) {
        rep(cy, 0, 101) {
            int H = h[n0] + abs(cx - x[n0]) + abs(cy - y[n0]);
            bool flag = true;
            rep(i, 0, n) {
                int nH = h[i] + abs(cx - x[i]) + abs(cy - y[i]);
                if (h[i] == 0) {
                    if (H > nH) flag = false;
                } else {
                    if (H != nH) flag = false;
                }
            }
            if (flag) cout << cx << " " << cy << " " << H << endl;
        }
    }
    return 0;
}


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

typedef long long int ll;

#define sc1(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld %lld",&a,&b)

int main()
{
    ll x;
    sc1(x);
    
    if(x==0)
    {
        cout<< "1" << endl;
    }
    if(x==1)
    {
        cout<< "0" << endl;
    }
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
 int i,n,m,ans;
 cin>>n>>m;
 if(n>=m){cout <<0;return 0;}
 vector<int> x(m),sa(m,0);
 for(i=0;i<m;i++)cin>>x[i];
 sort(x.begin(),x.end());
 
 for(i=1;i<m;i++)sa[i]=x[i]-x[i-1];
 sort(sa.begin(),sa.end(),greater<int>());
 ans=x[m-1]-x[0];
 for(i=0;i<n-1;i++)ans-=sa[i];
 cout <<ans;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
#define fst first
#define snd second
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


template<typename T>
vector<int> compress(vector<T> &v) {
  vector<T> t = v;
  sort(t.begin(), t.end());
  t.erase(unique(t.begin(), t.end()), t.end());
	vector<int> r(v.size());
  for (int i = 0; i < v.size(); i++) {
    r[i] = lower_bound(t.begin(), t.end(), v[i]) - t.begin();
  }
	return r;
}


int main() {
  ll n, k; cin >> n >> k;
  V t(n), d(n);
  rep(i, n) cin >> t[i] >> d[i]; 

  t = compress(t);
  ll m = *max_element(all(t)) + 1;
  V mx(m);

  VV e(m, V());
  rep(i, n) e[t[i]].push_back(d[i]);

  priority_queue<int> pq;
  rep(i, m) {
    sort(all(e[i]));
    mx[i] = e[i].back();
    e[i].pop_back();
    for (auto &x : e[i]) pq.push(x);
  }
  sort(all(mx), greater<int>());

  ll z = min(m, k);
  ll sum = 0;
  rep(i, z) sum += mx[i];
  rep(i, k-z) { 
    sum += pq.top(); pq.pop();
  }

  ll ans = sum + z*z;
  drep(i, z) {
    sum -= mx[i];
    pq.push(mx[i]);
    sum += pq.top(); pq.pop();
    chmax(ans, sum + ll(i)*i);
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    string S, T;
    cin >> S >> T;
    bool can = false;
    for (int i = 0; i < S.size(); i++){
        if (S == T){
            can = true;
            break;
        }
        S = S.back() + S.substr(0, S.size() - 1);
    }
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.lang.Long.min

fun main() {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }
    var answer1 = getAnswer(a, true)
    var answer2 = getAnswer(a, false)


    print(min(answer1, answer2))
}

fun getAnswer(a: List<Long>, initial: Boolean): Long {
    var answer = 0L
    var total = 0L
    var isPlus = initial
    for (x in a) {
        total += x

        if (isPlus) {
            if (total <= 0) {
                answer += -total + 1
                total = 1
            }
        } else {
            if (total >= 0) {
                answer += total + 1
                total = -1
            }
        }

        isPlus = !isPlus
    }

    return answer
}

Measured memory_bytes: 52552
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,n;
    cin>>N>>n;
    for(int i=0,ai,bi;i<n;i++){
        cin>>ai>>bi;
        if(ai>(N+1)/2)ai=N-ai+1;
        if(bi>(N+1)/2)bi=N-bi+1;
        if(ai%3==1&&bi-ai>=0&&N-bi>=3*(ai/3)||
           bi%3==1&&ai-bi>=0&&N-ai>=3*(ai/3))cout<<"1\n";
        else if(ai%3==2&&bi-ai>=0&&N-bi>=3*(ai/3)-1||
                bi%3==2&&ai-bi>=0&&N-ai>=3*(ai/3)-1)cout<<"2\n";
        else cout<<"3\n";
    }
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  string s;
  cin >> n >> s;
  int64 ans = 0;
  int r = 0, g = 0, b = 0;
  for (char c : s) {
    if (c == 'R') {
      ++r;
      ans += g * b;
    }
    if (c == 'G') {
      ++g;
      ans += r * b;
    }
    if (c == 'B') {
      ++b;
      ans += r * g;
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j + (j - i) < n; ++j) {
      if (s[i] != s[j] && s[i] != s[j + j - i] && s[j] != s[j + j - i]) {
        --ans;
      }
    }
  }
  cout << ans << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 3656
package main

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

type node struct {
	parent   int
	depth    int
	degree   int
	height   int
	left     int
	right    int
	nodeType string
}

func main() {
	sc := bufio.NewScanner(os.Stdin)

	sc.Scan()
	num, _ := strconv.Atoi(sc.Text())
	tree := make([]node, num)

	for sc.Scan() {
		rawInputs := strings.Split(sc.Text(), " ")

		id, _ := strconv.Atoi(rawInputs[0])
		tree[id].left, _ = strconv.Atoi(rawInputs[1])
		tree[id].right, _ = strconv.Atoi(rawInputs[2])
	}

	for i, v := range tree {
		if v.left != -1 || v.right != -1 {
			if v.left == -1 || v.right == -1 {
				tree[i].degree = 1
			} else {
				tree[i].degree = 2
			}
			if v.depth == 0 {
				getParent(tree, i, -1, 0)
			}
		} else if v.parent == 0 {
			tree[i].parent = -1
		}
	}

	for i, v := range tree {
		if v.parent == -1 {
			tree[i].nodeType = "root"
		} else if v.left == -1 && v.right == -1 {
			tree[i].nodeType = "leaf"
		} else {
			tree[i].nodeType = "internal node"
		}
	}

	for i, v := range tree {
		if v.nodeType == "leaf" {
			getHeight(tree, i, 0)
		}
	}

	for i, v := range tree {
		sibling := -1

		if (v.left != -1 || v.right != -1) && v.depth == 0 {
			v.parent = -1
			v.nodeType = "root"
		}

		if v.parent != -1 {
			if tree[v.parent].left != i {
				sibling = tree[v.parent].left
			} else {
				sibling = tree[v.parent].right
			}
		}

		fmt.Printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", i, v.parent, sibling, v.degree, v.depth, v.height, v.nodeType)
	}
}

func getParent(tree []node, id int, parent int, depth int) {
	tree[id].parent = parent
	tree[id].depth = depth
	if tree[id].left != -1 {
		getParent(tree, tree[id].left, id, depth+1)
	}
	if tree[id].right != -1 {
		getParent(tree, tree[id].right, id, depth+1)
	}
}

func getHeight(tree []node, id int, height int) {
	if tree[id].height <= height {
		tree[id].height = height
		if tree[id].parent != -1 {
			getHeight(tree, tree[id].parent, height+1)
		}
	}
}



Measured memory_bytes: 1164
N, K = map(int, input().split())

X = []
for i in range(N):
    h, w, c = input().split()
    h, w = int(h) - 1, int(w) - 1
    if c == "W":
        h += K
    X.append((h % (2 * K), w % (2 * K)))


class Ruisekiwa2D:
    def __init__(self, h, w):
        self.H = h
        self.W = w
        self.G = [[0] * w for _ in range(h)]

    def load(self, points):
        # 問題によってイメージしやすいよう書き換えてください
        for x, y in points:
            self.G[x][y] += 1

    def load_imos(self, points):
        # pointsは[[左上h, 左上w, 右下h, 右下w], ...]であること
        for i1, j1, i2, j2 in points:
            self.G[i1][j1] += 1  # 左上
            if j2 + 1 < self.W:  # 右上
                self.G[i1][j2+1] -= 1
            if i2 + 1 < self.H:
                self.G[i2+1][j1] -= 1  # 左下
            if j2 + 1 < self.W and i2 + 1 < self.H:  # 右下
                self.G[i2+1][j2+1] += 1

    def calc(self):
        for y in range(self.W):
            for x in range(1, self.H):
                self.G[x][y] += self.G[x-1][y]

        for y in range(1, self.W):
            for x in range(self.H):
                self.G[x][y] += self.G[x][y-1]

    def get(self, i1, j1, i2, j2):
        if i1 > i2 or j1 > j2 or i1 < 0 or j1 < 0 or i2 < 0 or j2 < 0:
            return 0
        elif i1 > 0 and j1 > 0:
            return self.G[i2][j2] - self.G[i1-1][j2] - self.G[i2][j1-1] + self.G[i1-1][j1-1]
        elif i1 <= 0 < j1:
            return self.G[i2][j2] - self.G[i2][j1-1]
        elif j1 <= 0 < i1:
            return self.G[i2][j2] - self.G[i1 - 1][j2]
        else:
            return self.G[i2][j2]


R2D = Ruisekiwa2D(2 * K, 2 * K)
R2D.load(X)
R2D.calc()

ans = 0
for h in range(K):
    for w in range(K):
        tmp = 0
        tmp += R2D.get(h, w, h + K - 1, w + K - 1)  # 真ん中
        tmp += R2D.get(0, 0, h - 1, w - 1)  # 左上
        tmp += R2D.get(0, w + K, h - 1, 2 * K - 1)  # 右上
        tmp += R2D.get(h + K, 0, 2 * K - 1, w - 1)  # 左下
        tmp += R2D.get(h + K, w + K, 2 * K - 1, 2 * K - 1)  # 右下
        ans = max(ans, tmp, N - tmp)

print(ans)


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

int main() {
    int N; cin >> N;
    vector<vector<pair<int, int>>> xy(N);
    for (int i = 0; i < N; i++) {
        int A; cin >> A;
        for (int j = 0; j < A; j++) {
            int x, y; cin >> x >> y;
            xy[i].push_back(pair<int, int>(x-1, y));
        }
    }
    int ans = 0;
    for (int i = 0; i < 1<<N; i++) {
        int temp = 0;
        bool valid = true;
        for (int j = 0; j < N; j++) {
            if (i>>j & 1) {
                temp++;
                for (auto x : xy[j]) {
                    if (((i>>x.first) & 1) != x.second) {
                        valid = false;
                        break;
                    }
                }
            }
        }
        if (valid) ans = max(ans, temp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e5+10;
VI E[2][SIZE];
VI ee[SIZE];
int root[2];
int V[2][SIZE];
int dfs0(VI e[],int x,int v[]){
    v[x]=1;
    VI ker;
    REP(i,SZ(e[x])){
        int y=e[x][i];
        ker.PB(dfs0(e,y,v));
        v[x]^=1;
    }
    for(int i=0;i+1<SZ(ker);i+=2){
        ee[ker[i]].PB(ker[i+1]);
        ee[ker[i+1]].PB(ker[i]);
    }
    if(v[x])return x;
    return ker.back();
}
int an[SIZE];
void go(int x,int v){
    an[x]=v;
    REP(i,SZ(ee[x])){
        int y=ee[x][i];
        if(!an[y])
            go(y,v*-1);
    }
}
int main(){
    DRI(N);
    REP(k,2){
        REPP(i,1,N+1){
            DRI(x);
            if(x==-1)root[k]=i;
            else E[k][x].PB(i);
        }
    }
    REP(k,2){
        dfs0(E[k],root[k],V[k]);
    }
    REPP(i,1,N+1){
        if(V[0][i]!=V[1][i])return 0*puts("IMPOSSIBLE");
    }
    puts("POSSIBLE");
    REPP(i,1,N+1){
        if(V[0][i]&&!an[i]){
            go(i,1);
        }
    }
    REPP(i,1,N+1)printf("%d%c",an[i]," \n"[i==N]);
    return 0;
}

Measured memory_bytes: 23808
import math
a,b,h,m = [int(i) for i in input().split()]
s = min(abs(h * 30 + m * 0.5 - m * 6), 360 - abs(h * 30 + m * 0.5 - m * 6))
print(math.sqrt(a * a + b * b - 2 * a * b * math.cos(math.radians(s))))

Measured memory_bytes: 9568
using System;
class p
{
  static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    int N = int.Parse(input[0]);
    int A = int.Parse(input[1]);
    int B = int.Parse(input[2]);
    Console.WriteLine(Math.Min(N*A, B));
  }
}

Measured memory_bytes: 11092
N = int(input())
A = list(map(int,input().split()))

dl = [0]
x = 0
for a in A:
    dl.append(dl[-1] + abs(a-x))
    x = a
dl.append(dl[-1] + abs(a))

A = [0] + A + [0]

for i in range(1,N+1):
    ans = dl[i-1] + abs(A[i-1] - A[i+1]) + dl[-1]-dl[i+1]
    print(ans)

Measured memory_bytes: 13920
#include <stdio.h>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main(void) {
  int w, i, j;
  vector<int> v;
  scanf("%d", &w);
  while(w) {
    int t = w % 3;
    if(t == 2) t = -1;
    v.push_back(t);
    w -= t;
    w /= 3;
  }
  vector<int>::iterator it;
  for(it = v.end() - 1; it >= v.begin(); --it) {
    if(!(*it)) printf("0");
    else if(*it == 1) printf("+");
    else printf("-");
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2716
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <bitset>
#include <queue>
#include <cstring>
#include <set>
#include <map>

#define rep(i, l, r) for(int i=l; i<=r; i++)
#define dow(i, l, r) for(int i=l; i>=r; i--)
#define clr(x, c) memset(x, c, sizeof(x))
#define travel(x) for(edge *p=fir[x]; p; p=p->n)
#define all(x) (x).begin,(x).end
#define pb push_back
#define fi first
#define se second
#define l(x) Left[x]
#define r(x) Right[x]
#define lowbit(x) (x&-x)
#define pi acos(-1)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

inline int read()
{
    int x=0; bool f=0; char ch=getchar();
    while (ch<'0' || '9'<ch) f|=ch=='-', ch=getchar();
    while ('0'<=ch && ch<='9') x=x*10+ch-'0', ch=getchar();
    return f?-x:x;
}

int k[999];

int main()
{
	int n=read(), a=0;
	rep(i, 1, n) k[i]=read(); sort(k+1, k+1+n);
	rep(i, 1, n) a+=k[i];
	if (a%10) printf("%d\n", a); else rep(i, 1, n+1) 
	{if ((a-k[i])%10) 
	{
		printf("%d\n", a-k[i]); break;
	} else if (i>n) puts("0");}
	return 0;
}

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

long long n,m;
bool graph[12][12];
long long ans = 0;

bool dfs(long long *arr){

	if(arr[1] != 1)
		return 0;

	long long src = arr[1];
	for(long long i=2;i<=n;i++){

		if(graph[arr[i]][arr[i-1]] != 1){

			return 0;
		}
	}
	return 1;
}


void func(long long index,long long *arr,bool *visited){

	if(index == n+1){

		if(dfs(arr))
			ans++;
	}
	else{

		for(long long i=1;i<=n;i++){

			if(visited[i] == 0){

				visited[i] = 1;
				arr[index] = i;
				func(index+1,arr,visited);
				visited[i] = 0;
			}
		}
	}
}
int main(){

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

	cin >> n >> m;

	for(long long i=1;i<=n;i++)
		for(long long j=1;j<=n;j++)
			graph[i][j] = 0;

	for(long long i=1;i<=m;i++){

		long long a,b;
		cin >> a >> b;

		graph[a][b] = graph[b][a] = 1;
	}


	long long arr[n+1];
	bool visited[n+1];
	
	for(long long i=1;i<=n;i++)
		visited[i] = 0;

	func(1LL,arr,visited);

	cout << ans << endl;
}

Measured memory_bytes: 256
//**PEACE BE UPON YOU**
// AZMAYEN FAYEK SABIL
// IUT CSE SWE-19

#include <iostream>
#include <bits/stdc++.h>

#include <cmath>
#include <string>
#include <algorithm>
using namespace std;


int main()

{
    long long int n;
    cin>>n;

    long long int i,sum=0;



    for(i=1;i<=n;i++)
    {
        if(i%3!=0 && i%5!=0)
        {
            sum=sum+i;
        }
    }

    cout<<sum;


    return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

struct Edge { int src,dst,weight; };

const int MAX_V = 1010;
const int IINF = INT_MAX;

int V,C[MAX_V];
vector<Edge> G[MAX_V];

int dfs(int cur,int prev){
  if( cur && G[cur].size() == 1 ) return C[cur] ? IINF : 0;
  if( C[cur] ) return IINF;
  int cost = 0;
  rep(i,G[cur].size()){
    int next = G[cur][i].dst;
    if( next == prev ) continue;
    int mini = min(dfs(next,cur),G[cur][i].weight);
    assert( mini != IINF );
    cost  += mini;
  }
  return cost;
}

int main(){
  cin >> V;
  REP(i,1,V) cin >> C[i];
  rep(i,V-1){
    int u,v,p;
    cin >> u >> v >> p;
    G[u].push_back((Edge){u,v,p});
    G[v].push_back((Edge){v,u,p});
  }
  cout << dfs(0,-1) << endl;
  return 0;
}

Measured memory_bytes: 1280
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,g;
    cin>>n>>k;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    sort(rall(v));
    rep(i,k) sum+=v[i];
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

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

    if(s[0] == s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
#define N 1000000
int p[N];
int main() {
	int i, j,n,cnt;
	for (i = 2; i <= sqrt(N); i++) if (!p[i]) for (j = i*i; j < N; j += i)p[j] = 1;
	while (cin >> n) {
		cnt = 0;
		for (i = 2; i <= n; i++) if (!p[i]) cnt++;
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 6960
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    string s;
    cin>>s;
    if(c<d){
        for(int i=a-1;i<d-1;i++){
            if(s[i]=='#'&&s[i+1]=='#'){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
    }
    else{
        for(int i=a-1;i<c-1;i++){
            if(s[i]=='#'&&s[i+1]=='#'){
                cout<<"No"<<endl;
                return 0;
            }
        }
        for(int i=b-1;i<d;i++){
            if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.'){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 640
N, Q = map(int, input().split(" "))
S = input()

ACIndex = [0] * (N+1)
for i in range(N) :
    ACIndex[i+1] = ACIndex[i] + (1 if S[i:i+2] == "AC" else 0)

for i in range(Q) :
    l,r = map(int, input().split(" "))
    print(ACIndex[r-1] - ACIndex[l-1])

Measured memory_bytes: 7748
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i = 1;
        int x;
        while ((x = sc.nextInt()) != 0) {
            System.out.printf("Case %d: %d\n", i++, x);
        }
    }
}

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

int main(){
    int h,w,d;
    cin>>h>>w>>d;
    int a;
    map<int,pair<int,int>> mp;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++){
        cin>>a;
        a--;
        mp[a]=make_pair(i,j);
    }

    int sum[h*w]={};

    for(int i=0;i<d;i++){
        for(int j=0;j+i+d<h*w;j+=d){
            sum[j+i+d]=sum[j+i]+abs(mp[j+i].first - mp[j+i+d].first)+abs(mp[j+i].second - mp[j+i+d].second);
        }
    }

    int q;
    cin>>q;
    int l,r;
    for(int i=0;i<q;i++){
        cin>>l>>r;
        cerr<<sum[r-1]<<" "<<sum[l-1]<<endl;
        cout<<sum[r-1]-sum[l-1]<<endl;
    }
}

Measured memory_bytes: 7040
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>


using namespace std;


int main() {
	long long N;
	int K;
	cin >> N >> K;
	long long ans = 0;
	while (N != 0) {
		N /= K;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int W,H,x,y;
  int ans2=0;
  double ans1;
  scanf("%d %d %d %d",&W,&H,&x,&y);
  if(W == x*2 && H == y*2)ans2=1;
  ans1 = (double)W*(double)H / 2;
  printf("%lf %d\n",ans1,ans2);
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()

int main() {
	int n, k;
	cin >> n >> k;
	vector<double> ev(n);
	rep(i,n){
		cin >> ev[i];
		ev[i] = (1+ev[i])/(double)2;
	}
	int l=0;
	double ans=0.0, tmp=0.0;
	rep(i, n) {
		if(i-l<k){
			tmp += ev[i];
		} else {
			tmp -= ev[l];
			tmp += ev[i];
			l++;
		}
		ans = max(ans, tmp);
	}
	printf("%.12f\n", ans);
}


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

template <typename Monoid, typename OperatorMonoid = Monoid> struct LazySegmentTree {
  using F = function<Monoid(Monoid, Monoid)>;
  using G = function<Monoid(Monoid, OperatorMonoid)>;
  using H = function<OperatorMonoid(OperatorMonoid, OperatorMonoid)>;
  using P = function<OperatorMonoid(OperatorMonoid, int)>;

  size_t sz;
  vector<Monoid> data;
  vector<OperatorMonoid> lazy;
  const F f;
  const G g;
  const H h;
  const P p;
  const Monoid M1;
  const OperatorMonoid OM0;

  LazySegmentTree(size_t n, const F f, const G g, const H h, const P p, const Monoid &M1, const OperatorMonoid &OM0) : sz(1 << (32 - __builtin_clz(n - 1))), f(f), g(g), h(h), p(p), M1(M1), OM0(OM0) {
    data.assign(2 * sz, M1);
    lazy.assign(2 * sz, OM0);
  }

  void set(int k, const Monoid &x) {
    data[k + sz] = x;
  }

  void build() {
    for (int k = sz - 1; k; --k) {
      data[k] = f(data[2 * k], data[2 * k + 1]);
    }
  }

  inline void propagate(int k, int length) {
    if (lazy[k] != OM0) {
      if (k < sz) {
        lazy[2 * k + 0] = h(lazy[2 * k + 0], lazy[k]);
        lazy[2 * k + 1] = h(lazy[2 * k + 1], lazy[k]);
      }

      data[k] = g(data[k], p(lazy[k], length));
      lazy[k] = OM0;
    }
  }

  Monoid update(int a, int b, const OperatorMonoid &x) {
    return update(a, b, x, 1, 0, sz);
  }

  Monoid update(int a, int b, const OperatorMonoid &x, int k, int l, int r) {
    propagate(k, r - l);

    if (r <= a || b <= l) {
      return data[k];
    } else if (a <= l && r <= b) {
      lazy[k] = h(lazy[k], x);
      propagate(k, r - l);
      return data[k];
    } else {
      return data[k] = f(update(a, b, x, 2 * k, l, (l + r) >> 1), update(a, b, x, 2 * k + 1, (l + r) >> 1, r));
    }
  }

  Monoid query(int a, int b) {
    return query(a, b, 1, 0, sz);
  }

  Monoid query(int a, int b, int k, int l, int r) {
    propagate(k, r - l);

    if (r <= a || b <= l) {
      return M1;
    } else if (a <= l && r <= b) {
      return data[k];
    } else {
      return f(query(a, b, 2 * k, l, (r + l) >> 1), query(a, b, 2 * k + 1, (r + l) >> 1, r));
    }
  }
};

// https://onlinejudge.u-aizu.ac.jp/#/courses/library/3/DSL/2/DSL_2_F
int main() {
  int n, q;
  cin >> n >> q;

  auto f = [](int64_t a, int64_t b) { return min(a, b); };
  auto g = [](int64_t a, int64_t b) { return b < 0 ? a : b; };
  auto p = [](int64_t a, int b) { return a; };
  LazySegmentTree<int64_t> seg(n, f, g, g, p, (1ll << 31) - 1, -1);
  while (q--) {
    int type;
    cin >> type;

    if (type) {
      int s, t;
      cin >> s >> t;

      cout << seg.query(s, t + 1) << endl;
    } else {
      int s, t, x;
      cin >> s >> t >> x;

      seg.update(s, t + 1, x);
    }
  }
}



Measured memory_bytes: 7056
#include<bits/stdc++.h>
using namespace std;
//size_t f = string::npos
//make pair, tuple

int main(){
      map<int, int> m;
      m[1] = 1;
      m[3] = 1;
      m[5] = 1;
      m[7] = 1;
      m[8] = 1;
      m[10] = 1;
      m[12] = 1;
      m[4] = 2;
      m[6] = 2;
      m[9] = 2;
      m[11] = 2;
      m[2] = 3;
      int a,b;cin >> a >> b;
      if(m[a] == m[b])cout << "Yes";
      else cout << "No";
}

Measured memory_bytes: 256
--AOJ Simple Calculator

import Control.Applicative

rInt :: String -> Int
rInt str = read str :: Int

simpleCalculator :: Int -> Int -> String -> Int
simpleCalculator x y "+" = x + y
simpleCalculator x y "-" = x - y
simpleCalculator x y "*" = x * y
simpleCalculator x y "/" = x `div` y
  
main :: IO ()
main = do
  lst <- pure words <*> getLine
  let x = rInt $ lst !! 0
      y = rInt $ lst !! 2
      op = lst !! 1  
  if op == "?"
    then return ()
    else do
    print $ simpleCalculator x y op
    main

Measured memory_bytes: 4092